function noop() { } function assign(tar, src) { // @ts-ignore for (const k in src) tar[k] = src[k]; return tar; } function add_location(element, file, line, column, char) { element.__svelte_meta = { loc: { file, line, column, char } }; } function run(fn) { return fn(); } function blank_object() { return Object.create(null); } function run_all(fns) { fns.forEach(run); } function is_function(thing) { return typeof thing === 'function'; } function safe_not_equal(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } let src_url_equal_anchor; function src_url_equal(element_src, url) { if (!src_url_equal_anchor) { src_url_equal_anchor = document.createElement('a'); } src_url_equal_anchor.href = url; return element_src === src_url_equal_anchor.href; } function is_empty(obj) { return Object.keys(obj).length === 0; } function create_slot(definition, ctx, $$scope, fn) { if (definition) { const slot_ctx = get_slot_context(definition, ctx, $$scope, fn); return definition[0](slot_ctx); } } function get_slot_context(definition, ctx, $$scope, fn) { return definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx; } function get_slot_changes(definition, $$scope, dirty, fn) { if (definition[2] && fn) { const lets = definition[2](fn(dirty)); if ($$scope.dirty === undefined) { return lets; } if (typeof lets === 'object') { const merged = []; const len = Math.max($$scope.dirty.length, lets.length); for (let i = 0; i < len; i += 1) { merged[i] = $$scope.dirty[i] | lets[i]; } return merged; } return $$scope.dirty | lets; } return $$scope.dirty; } function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) { if (slot_changes) { const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn); slot.p(slot_context, slot_changes); } } function get_all_dirty_from_scope($$scope) { if ($$scope.ctx.length > 32) { const dirty = []; const length = $$scope.ctx.length / 32; for (let i = 0; i < length; i++) { dirty[i] = -1; } return dirty; } return -1; } // Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM // at the end of hydration without touching the remaining nodes. let is_hydrating = false; function start_hydrating() { is_hydrating = true; } function end_hydrating() { is_hydrating = false; } function upper_bound(low, high, key, value) { // Return first index of value larger than input value in the range [low, high) while (low < high) { const mid = low + ((high - low) >> 1); if (key(mid) <= value) { low = mid + 1; } else { high = mid; } } return low; } function init_hydrate(target) { if (target.hydrate_init) return; target.hydrate_init = true; // We know that all children have claim_order values since the unclaimed have been detached if target is not let children = target.childNodes; // If target is , there may be children without claim_order if (target.nodeName === 'HEAD') { const myChildren = []; for (let i = 0; i < children.length; i++) { const node = children[i]; if (node.claim_order !== undefined) { myChildren.push(node); } } children = myChildren; } /* * Reorder claimed children optimally. * We can reorder claimed children optimally by finding the longest subsequence of * nodes that are already claimed in order and only moving the rest. The longest * subsequence subsequence of nodes that are claimed in order can be found by * computing the longest increasing subsequence of .claim_order values. * * This algorithm is optimal in generating the least amount of reorder operations * possible. * * Proof: * We know that, given a set of reordering operations, the nodes that do not move * always form an increasing subsequence, since they do not move among each other * meaning that they must be already ordered among each other. Thus, the maximal * set of nodes that do not move form a longest increasing subsequence. */ // Compute longest increasing subsequence // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j const m = new Int32Array(children.length + 1); // Predecessor indices + 1 const p = new Int32Array(children.length); m[0] = -1; let longest = 0; for (let i = 0; i < children.length; i++) { const current = children[i].claim_order; // Find the largest subsequence length such that it ends in a value less than our current value // upper_bound returns first greater value, so we subtract one // with fast path for when we are on the current longest subsequence const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1; p[i] = m[seqLen] + 1; const newLen = seqLen + 1; // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence. m[newLen] = i; longest = Math.max(newLen, longest); } // The longest increasing subsequence of nodes (initially reversed) const lis = []; // The rest of the nodes, nodes that will be moved const toMove = []; let last = children.length - 1; for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) { lis.push(children[cur - 1]); for (; last >= cur; last--) { toMove.push(children[last]); } last--; } for (; last >= 0; last--) { toMove.push(children[last]); } lis.reverse(); // We sort the nodes being moved to guarantee that their insertion order matches the claim order toMove.sort((a, b) => a.claim_order - b.claim_order); // Finally, we move the nodes for (let i = 0, j = 0; i < toMove.length; i++) { while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) { j++; } const anchor = j < lis.length ? lis[j] : null; target.insertBefore(toMove[i], anchor); } } function append_hydration(target, node) { if (is_hydrating) { init_hydrate(target); if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentElement !== target))) { target.actual_end_child = target.firstChild; } // Skip nodes of undefined ordering while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) { target.actual_end_child = target.actual_end_child.nextSibling; } if (node !== target.actual_end_child) { // We only insert if the ordering of this node should be modified or the parent node is not target if (node.claim_order !== undefined || node.parentNode !== target) { target.insertBefore(node, target.actual_end_child); } } else { target.actual_end_child = node.nextSibling; } } else if (node.parentNode !== target || node.nextSibling !== null) { target.appendChild(node); } } function insert_hydration(target, node, anchor) { if (is_hydrating && !anchor) { append_hydration(target, node); } else if (node.parentNode !== target || node.nextSibling != anchor) { target.insertBefore(node, anchor || null); } } function detach(node) { node.parentNode.removeChild(node); } function element(name) { return document.createElement(name); } function svg_element(name) { return document.createElementNS('http://www.w3.org/2000/svg', name); } function text(data) { return document.createTextNode(data); } function space() { return text(' '); } function empty() { return text(''); } function listen(node, event, handler, options) { node.addEventListener(event, handler, options); return () => node.removeEventListener(event, handler, options); } function attr(node, attribute, value) { if (value == null) node.removeAttribute(attribute); else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value); } function children(element) { return Array.from(element.childNodes); } function init_claim_info(nodes) { if (nodes.claim_info === undefined) { nodes.claim_info = { last_index: 0, total_claimed: 0 }; } } function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) { // Try to find nodes in an order such that we lengthen the longest increasing subsequence init_claim_info(nodes); const resultNode = (() => { // We first try to find an element after the previous one for (let i = nodes.claim_info.last_index; i < nodes.length; i++) { const node = nodes[i]; if (predicate(node)) { const replacement = processNode(node); if (replacement === undefined) { nodes.splice(i, 1); } else { nodes[i] = replacement; } if (!dontUpdateLastIndex) { nodes.claim_info.last_index = i; } return node; } } // Otherwise, we try to find one before // We iterate in reverse so that we don't go too far back for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) { const node = nodes[i]; if (predicate(node)) { const replacement = processNode(node); if (replacement === undefined) { nodes.splice(i, 1); } else { nodes[i] = replacement; } if (!dontUpdateLastIndex) { nodes.claim_info.last_index = i; } else if (replacement === undefined) { // Since we spliced before the last_index, we decrease it nodes.claim_info.last_index--; } return node; } } // If we can't find any matching node, we create a new one return createNode(); })(); resultNode.claim_order = nodes.claim_info.total_claimed; nodes.claim_info.total_claimed += 1; return resultNode; } function claim_element(nodes, name, attributes, svg) { return claim_node(nodes, (node) => node.nodeName === name, (node) => { const remove = []; for (let j = 0; j < node.attributes.length; j++) { const attribute = node.attributes[j]; if (!attributes[attribute.name]) { remove.push(attribute.name); } } remove.forEach(v => node.removeAttribute(v)); return undefined; }, () => svg ? svg_element(name) : element(name)); } function claim_text(nodes, data) { return claim_node(nodes, (node) => node.nodeType === 3, (node) => { const dataStr = '' + data; if (node.data.startsWith(dataStr)) { if (node.data.length !== dataStr.length) { return node.splitText(dataStr.length); } } else { node.data = dataStr; } }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements ); } function claim_space(nodes) { return claim_text(nodes, ' '); } function custom_event(type, detail, bubbles = false) { const e = document.createEvent('CustomEvent'); e.initCustomEvent(type, bubbles, false, detail); return e; } function query_selector_all(selector, parent = document.body) { return Array.from(parent.querySelectorAll(selector)); } let current_component; function set_current_component(component) { current_component = component; } function get_current_component() { if (!current_component) throw new Error('Function called outside component initialization'); return current_component; } function onMount(fn) { get_current_component().$$.on_mount.push(fn); } function afterUpdate(fn) { get_current_component().$$.after_update.push(fn); } function createEventDispatcher() { const component = get_current_component(); return (type, detail) => { const callbacks = component.$$.callbacks[type]; if (callbacks) { // TODO are there situations where events could be dispatched // in a server (non-DOM) environment? const event = custom_event(type, detail); callbacks.slice().forEach(fn => { fn.call(component, event); }); } }; } function setContext(key, context) { get_current_component().$$.context.set(key, context); } const dirty_components = []; const binding_callbacks = []; const render_callbacks = []; const flush_callbacks = []; const resolved_promise = Promise.resolve(); let update_scheduled = false; function schedule_update() { if (!update_scheduled) { update_scheduled = true; resolved_promise.then(flush); } } function add_render_callback(fn) { render_callbacks.push(fn); } let flushing = false; const seen_callbacks = new Set(); function flush() { if (flushing) return; flushing = true; do { // first, call beforeUpdate functions // and update components for (let i = 0; i < dirty_components.length; i += 1) { const component = dirty_components[i]; set_current_component(component); update(component.$$); } set_current_component(null); dirty_components.length = 0; while (binding_callbacks.length) binding_callbacks.pop()(); // then, once components are updated, call // afterUpdate functions. This may cause // subsequent updates... for (let i = 0; i < render_callbacks.length; i += 1) { const callback = render_callbacks[i]; if (!seen_callbacks.has(callback)) { // ...so guard against infinite loops seen_callbacks.add(callback); callback(); } } render_callbacks.length = 0; } while (dirty_components.length); while (flush_callbacks.length) { flush_callbacks.pop()(); } update_scheduled = false; flushing = false; seen_callbacks.clear(); } function update($$) { if ($$.fragment !== null) { $$.update(); run_all($$.before_update); const dirty = $$.dirty; $$.dirty = [-1]; $$.fragment && $$.fragment.p($$.ctx, dirty); $$.after_update.forEach(add_render_callback); } } const outroing = new Set(); let outros; function group_outros() { outros = { r: 0, c: [], p: outros // parent group }; } function check_outros() { if (!outros.r) { run_all(outros.c); } outros = outros.p; } function transition_in(block, local) { if (block && block.i) { outroing.delete(block); block.i(local); } } function transition_out(block, local, detach, callback) { if (block && block.o) { if (outroing.has(block)) return; outroing.add(block); outros.c.push(() => { outroing.delete(block); if (callback) { if (detach) block.d(1); callback(); } }); block.o(local); } } const globals = (typeof window !== 'undefined' ? window : typeof globalThis !== 'undefined' ? globalThis : global); function get_spread_update(levels, updates) { const update = {}; const to_null_out = {}; const accounted_for = { $$scope: 1 }; let i = levels.length; while (i--) { const o = levels[i]; const n = updates[i]; if (n) { for (const key in o) { if (!(key in n)) to_null_out[key] = 1; } for (const key in n) { if (!accounted_for[key]) { update[key] = n[key]; accounted_for[key] = 1; } } levels[i] = n; } else { for (const key in o) { accounted_for[key] = 1; } } } for (const key in to_null_out) { if (!(key in update)) update[key] = undefined; } return update; } function get_spread_object(spread_props) { return typeof spread_props === 'object' && spread_props !== null ? spread_props : {}; } function create_component(block) { block && block.c(); } function claim_component(block, parent_nodes) { block && block.l(parent_nodes); } function mount_component(component, target, anchor, customElement) { const { fragment, on_mount, on_destroy, after_update } = component.$$; fragment && fragment.m(target, anchor); if (!customElement) { // onMount happens before the initial afterUpdate add_render_callback(() => { const new_on_destroy = on_mount.map(run).filter(is_function); if (on_destroy) { on_destroy.push(...new_on_destroy); } else { // Edge case - component was destroyed immediately, // most likely as a result of a binding initialising run_all(new_on_destroy); } component.$$.on_mount = []; }); } after_update.forEach(add_render_callback); } function destroy_component(component, detaching) { const $$ = component.$$; if ($$.fragment !== null) { run_all($$.on_destroy); $$.fragment && $$.fragment.d(detaching); // TODO null out other refs, including component.$$ (but need to // preserve final state?) $$.on_destroy = $$.fragment = null; $$.ctx = []; } } function make_dirty(component, i) { if (component.$$.dirty[0] === -1) { dirty_components.push(component); schedule_update(); component.$$.dirty.fill(0); } component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } function init$1(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) { const parent_component = current_component; set_current_component(component); const $$ = component.$$ = { fragment: null, ctx: null, // state props, update: noop, not_equal, bound: blank_object(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], context: new Map(parent_component ? parent_component.$$.context : options.context || []), // everything else callbacks: blank_object(), dirty, skip_bound: false, root: options.target || parent_component.$$.root }; append_styles && append_styles($$.root); let ready = false; $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => { const value = rest.length ? rest[0] : ret; if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value); if (ready) make_dirty(component, i); } return ret; }) : []; $$.update(); ready = true; run_all($$.before_update); // `false` as a special case of no DOM component $$.fragment = create_fragment ? create_fragment($$.ctx) : false; if (options.target) { if (options.hydrate) { start_hydrating(); const nodes = children(options.target); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.l(nodes); nodes.forEach(detach); } else { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.c(); } if (options.intro) transition_in(component.$$.fragment); mount_component(component, options.target, options.anchor, options.customElement); end_hydrating(); flush(); } set_current_component(parent_component); } /** * Base class for Svelte components. Used when dev=false. */ class SvelteComponent { $destroy() { destroy_component(this, 1); this.$destroy = noop; } $on(type, callback) { const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); callbacks.push(callback); return () => { const index = callbacks.indexOf(callback); if (index !== -1) callbacks.splice(index, 1); }; } $set($$props) { if (this.$$set && !is_empty($$props)) { this.$$.skip_bound = true; this.$$set($$props); this.$$.skip_bound = false; } } } function dispatch_dev(type, detail) { document.dispatchEvent(custom_event(type, Object.assign({ version: '3.42.1' }, detail), true)); } function append_hydration_dev(target, node) { dispatch_dev('SvelteDOMInsert', { target, node }); append_hydration(target, node); } function insert_hydration_dev(target, node, anchor) { dispatch_dev('SvelteDOMInsert', { target, node, anchor }); insert_hydration(target, node, anchor); } function detach_dev(node) { dispatch_dev('SvelteDOMRemove', { node }); detach(node); } function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) { const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : []; if (has_prevent_default) modifiers.push('preventDefault'); if (has_stop_propagation) modifiers.push('stopPropagation'); dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers }); const dispose = listen(node, event, handler, options); return () => { dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers }); dispose(); }; } function attr_dev(node, attribute, value) { attr(node, attribute, value); if (value == null) dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute }); else dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value }); } function set_data_dev(text, data) { data = '' + data; if (text.wholeText === data) return; dispatch_dev('SvelteDOMSetData', { node: text, data }); text.data = data; } function validate_slots(name, slot, keys) { for (const slot_key of Object.keys(slot)) { if (!~keys.indexOf(slot_key)) { console.warn(`<${name}> received an unexpected slot "${slot_key}".`); } } } /** * Base class for Svelte components with some minor dev-enhancements. Used when dev=true. */ class SvelteComponentDev extends SvelteComponent { constructor(options) { if (!options || (!options.target && !options.$$inline)) { throw new Error("'target' is a required option"); } super(); } $destroy() { super.$destroy(); this.$destroy = () => { console.warn('Component was already destroyed'); // eslint-disable-line no-console }; } $capture_state() { } $inject_state() { } } const subscriber_queue = []; /** * Create a `Writable` store that allows both updating and reading by subscription. * @param {*=}value initial value * @param {StartStopNotifier=}start start and stop notifications for subscriptions */ function writable(value, start = noop) { let stop; const subscribers = new Set(); function set(new_value) { if (safe_not_equal(value, new_value)) { value = new_value; if (stop) { // store is ready const run_queue = !subscriber_queue.length; for (const subscriber of subscribers) { subscriber[1](); subscriber_queue.push(subscriber, value); } if (run_queue) { for (let i = 0; i < subscriber_queue.length; i += 2) { subscriber_queue[i][0](subscriber_queue[i + 1]); } subscriber_queue.length = 0; } } } } function update(fn) { set(fn(value)); } function subscribe(run, invalidate = noop) { const subscriber = [run, invalidate]; subscribers.add(subscriber); if (subscribers.size === 1) { stop = start(set) || noop; } run(value); return () => { subscribers.delete(subscriber); if (subscribers.size === 0) { stop(); stop = null; } }; } return { set, update, subscribe }; } const CONTEXT_KEY = {}; /* src/components/Button.svelte generated by Svelte v3.42.1 */ const file$4 = "src/components/Button.svelte"; function create_fragment$5(ctx) { let button; let t; let button_class_value; let mounted; let dispose; const block = { c: function create() { button = element("button"); t = text(/*label*/ ctx[1]); this.h(); }, l: function claim(nodes) { button = claim_element(nodes, "BUTTON", { type: true, class: true, style: true }); var button_nodes = children(button); t = claim_text(button_nodes, /*label*/ ctx[1]); button_nodes.forEach(detach_dev); this.h(); }, h: function hydrate() { attr_dev(button, "type", "button"); attr_dev(button, "class", button_class_value = [ 'storybook-button', `storybook-button--${/*size*/ ctx[0]}`, /*mode*/ ctx[2] ].join(' ')); attr_dev(button, "style", /*style*/ ctx[3]); add_location(button, file$4, 35, 0, 717); }, m: function mount(target, anchor) { insert_hydration_dev(target, button, anchor); append_hydration_dev(button, t); if (!mounted) { dispose = listen_dev(button, "click", /*onClick*/ ctx[4], false, false, false); mounted = true; } }, p: function update(ctx, [dirty]) { if (dirty & /*label*/ 2) set_data_dev(t, /*label*/ ctx[1]); if (dirty & /*size*/ 1 && button_class_value !== (button_class_value = [ 'storybook-button', `storybook-button--${/*size*/ ctx[0]}`, /*mode*/ ctx[2] ].join(' '))) { attr_dev(button, "class", button_class_value); } }, i: noop, o: noop, d: function destroy(detaching) { if (detaching) detach_dev(button); mounted = false; dispose(); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$5.name, type: "component", source: "", ctx }); return block; } function instance$5($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots('Button', slots, []); let { primary = false } = $$props; let { backgroundColor } = $$props; let { size = 'medium' } = $$props; let { label = '' } = $$props; let mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; let style = backgroundColor ? `background-color: ${backgroundColor}` : ''; const dispatch = createEventDispatcher(); /** * Optional click handler */ function onClick(event) { dispatch('click', event); } const writable_props = ['primary', 'backgroundColor', 'size', 'label']; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`