UNPKG

43.6 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function noop() { }
6const identity = x => x;
7function assign(tar, src) {
8 // @ts-ignore
9 for (const k in src)
10 tar[k] = src[k];
11 return tar;
12}
13function is_promise(value) {
14 return value && typeof value === 'object' && typeof value.then === 'function';
15}
16function add_location(element, file, line, column, char) {
17 element.__svelte_meta = {
18 loc: { file, line, column, char }
19 };
20}
21function run(fn) {
22 return fn();
23}
24function blank_object() {
25 return Object.create(null);
26}
27function run_all(fns) {
28 fns.forEach(run);
29}
30function is_function(thing) {
31 return typeof thing === 'function';
32}
33function safe_not_equal(a, b) {
34 return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
35}
36function not_equal(a, b) {
37 return a != a ? b == b : a !== b;
38}
39function validate_store(store, name) {
40 if (!store || typeof store.subscribe !== 'function') {
41 throw new Error(`'${name}' is not a store with a 'subscribe' method`);
42 }
43}
44function subscribe(component, store, callback) {
45 const unsub = store.subscribe(callback);
46 component.$$.on_destroy.push(unsub.unsubscribe
47 ? () => unsub.unsubscribe()
48 : unsub);
49}
50function create_slot(definition, ctx, fn) {
51 if (definition) {
52 const slot_ctx = get_slot_context(definition, ctx, fn);
53 return definition[0](slot_ctx);
54 }
55}
56function get_slot_context(definition, ctx, fn) {
57 return definition[1]
58 ? assign({}, assign(ctx.$$scope.ctx, definition[1](fn ? fn(ctx) : {})))
59 : ctx.$$scope.ctx;
60}
61function get_slot_changes(definition, ctx, changed, fn) {
62 return definition[1]
63 ? assign({}, assign(ctx.$$scope.changed || {}, definition[1](fn ? fn(changed) : {})))
64 : ctx.$$scope.changed || {};
65}
66function exclude_internal_props(props) {
67 const result = {};
68 for (const k in props)
69 if (k[0] !== '$')
70 result[k] = props[k];
71 return result;
72}
73function once(fn) {
74 let ran = false;
75 return function (...args) {
76 if (ran)
77 return;
78 ran = true;
79 fn.call(this, ...args);
80 };
81}
82const is_client = typeof window !== 'undefined';
83exports.now = is_client
84 ? () => window.performance.now()
85 : () => Date.now();
86exports.raf = is_client ? requestAnimationFrame : noop;
87// used internally for testing
88function set_now(fn) {
89 exports.now = fn;
90}
91function set_raf(fn) {
92 exports.raf = fn;
93}
94
95const tasks = new Set();
96let running = false;
97function run_tasks() {
98 tasks.forEach(task => {
99 if (!task[0](exports.now())) {
100 tasks.delete(task);
101 task[1]();
102 }
103 });
104 running = tasks.size > 0;
105 if (running)
106 exports.raf(run_tasks);
107}
108function clear_loops() {
109 // for testing...
110 tasks.forEach(task => tasks.delete(task));
111 running = false;
112}
113function loop(fn) {
114 let task;
115 if (!running) {
116 running = true;
117 exports.raf(run_tasks);
118 }
119 return {
120 promise: new Promise(fulfil => {
121 tasks.add(task = [fn, fulfil]);
122 }),
123 abort() {
124 tasks.delete(task);
125 }
126 };
127}
128
129function append(target, node) {
130 target.appendChild(node);
131}
132function insert(target, node, anchor) {
133 target.insertBefore(node, anchor || null);
134}
135function detach(node) {
136 node.parentNode.removeChild(node);
137}
138function detach_between(before, after) {
139 while (before.nextSibling && before.nextSibling !== after) {
140 before.parentNode.removeChild(before.nextSibling);
141 }
142}
143function detach_before(after) {
144 while (after.previousSibling) {
145 after.parentNode.removeChild(after.previousSibling);
146 }
147}
148function detach_after(before) {
149 while (before.nextSibling) {
150 before.parentNode.removeChild(before.nextSibling);
151 }
152}
153function destroy_each(iterations, detaching) {
154 for (let i = 0; i < iterations.length; i += 1) {
155 if (iterations[i])
156 iterations[i].d(detaching);
157 }
158}
159function element(name) {
160 return document.createElement(name);
161}
162function object_without_properties(obj, exclude) {
163 // eslint-disable-next-line @typescript-eslint/no-object-literal-type-assertion
164 const target = {};
165 for (const k in obj) {
166 if (Object.prototype.hasOwnProperty.call(obj, k)
167 // @ts-ignore
168 && exclude.indexOf(k) === -1) {
169 // @ts-ignore
170 target[k] = obj[k];
171 }
172 }
173 return target;
174}
175function svg_element(name) {
176 return document.createElementNS('http://www.w3.org/2000/svg', name);
177}
178function text(data) {
179 return document.createTextNode(data);
180}
181function space() {
182 return text(' ');
183}
184function empty() {
185 return text('');
186}
187function listen(node, event, handler, options) {
188 node.addEventListener(event, handler, options);
189 return () => node.removeEventListener(event, handler, options);
190}
191function prevent_default(fn) {
192 return function (event) {
193 event.preventDefault();
194 // @ts-ignore
195 return fn.call(this, event);
196 };
197}
198function stop_propagation(fn) {
199 return function (event) {
200 event.stopPropagation();
201 // @ts-ignore
202 return fn.call(this, event);
203 };
204}
205function attr(node, attribute, value) {
206 if (value == null)
207 node.removeAttribute(attribute);
208 else
209 node.setAttribute(attribute, value);
210}
211function set_attributes(node, attributes) {
212 for (const key in attributes) {
213 if (key === 'style') {
214 node.style.cssText = attributes[key];
215 }
216 else if (key in node) {
217 node[key] = attributes[key];
218 }
219 else {
220 attr(node, key, attributes[key]);
221 }
222 }
223}
224function set_custom_element_data(node, prop, value) {
225 if (prop in node) {
226 node[prop] = value;
227 }
228 else {
229 attr(node, prop, value);
230 }
231}
232function xlink_attr(node, attribute, value) {
233 node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);
234}
235function get_binding_group_value(group) {
236 const value = [];
237 for (let i = 0; i < group.length; i += 1) {
238 if (group[i].checked)
239 value.push(group[i].__value);
240 }
241 return value;
242}
243function to_number(value) {
244 return value === '' ? undefined : +value;
245}
246function time_ranges_to_array(ranges) {
247 const array = [];
248 for (let i = 0; i < ranges.length; i += 1) {
249 array.push({ start: ranges.start(i), end: ranges.end(i) });
250 }
251 return array;
252}
253function children(element) {
254 return Array.from(element.childNodes);
255}
256function claim_element(nodes, name, attributes, svg) {
257 for (let i = 0; i < nodes.length; i += 1) {
258 const node = nodes[i];
259 if (node.nodeName === name) {
260 for (let j = 0; j < node.attributes.length; j += 1) {
261 const attribute = node.attributes[j];
262 if (!attributes[attribute.name])
263 node.removeAttribute(attribute.name);
264 }
265 return nodes.splice(i, 1)[0]; // TODO strip unwanted attributes
266 }
267 }
268 return svg ? svg_element(name) : element(name);
269}
270function claim_text(nodes, data) {
271 for (let i = 0; i < nodes.length; i += 1) {
272 const node = nodes[i];
273 if (node.nodeType === 3) {
274 node.data = data;
275 return nodes.splice(i, 1)[0];
276 }
277 }
278 return text(data);
279}
280function set_data(text, data) {
281 data = '' + data;
282 if (text.data !== data)
283 text.data = data;
284}
285function set_input_type(input, type) {
286 try {
287 input.type = type;
288 }
289 catch (e) {
290 // do nothing
291 }
292}
293function set_style(node, key, value) {
294 node.style.setProperty(key, value);
295}
296function select_option(select, value) {
297 for (let i = 0; i < select.options.length; i += 1) {
298 const option = select.options[i];
299 if (option.__value === value) {
300 option.selected = true;
301 return;
302 }
303 }
304}
305function select_options(select, value) {
306 for (let i = 0; i < select.options.length; i += 1) {
307 const option = select.options[i];
308 option.selected = ~value.indexOf(option.__value);
309 }
310}
311function select_value(select) {
312 const selected_option = select.querySelector(':checked') || select.options[0];
313 return selected_option && selected_option.__value;
314}
315function select_multiple_value(select) {
316 return [].map.call(select.querySelectorAll(':checked'), option => option.__value);
317}
318function add_resize_listener(element, fn) {
319 if (getComputedStyle(element).position === 'static') {
320 element.style.position = 'relative';
321 }
322 const object = document.createElement('object');
323 object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
324 object.type = 'text/html';
325 let win;
326 object.onload = () => {
327 win = object.contentDocument.defaultView;
328 win.addEventListener('resize', fn);
329 };
330 if (/Trident/.test(navigator.userAgent)) {
331 element.appendChild(object);
332 object.data = 'about:blank';
333 }
334 else {
335 object.data = 'about:blank';
336 element.appendChild(object);
337 }
338 return {
339 cancel: () => {
340 win && win.removeEventListener && win.removeEventListener('resize', fn);
341 element.removeChild(object);
342 }
343 };
344}
345function toggle_class(element, name, toggle) {
346 element.classList[toggle ? 'add' : 'remove'](name);
347}
348function custom_event(type, detail) {
349 const e = document.createEvent('CustomEvent');
350 e.initCustomEvent(type, false, false, detail);
351 return e;
352}
353
354let stylesheet;
355let active = 0;
356let current_rules = {};
357// https://github.com/darkskyapp/string-hash/blob/master/index.js
358function hash(str) {
359 let hash = 5381;
360 let i = str.length;
361 while (i--)
362 hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
363 return hash >>> 0;
364}
365function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
366 const step = 16.666 / duration;
367 let keyframes = '{\n';
368 for (let p = 0; p <= 1; p += step) {
369 const t = a + (b - a) * ease(p);
370 keyframes += p * 100 + `%{${fn(t, 1 - t)}}\n`;
371 }
372 const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
373 const name = `__svelte_${hash(rule)}_${uid}`;
374 if (!current_rules[name]) {
375 if (!stylesheet) {
376 const style = element('style');
377 document.head.appendChild(style);
378 stylesheet = style.sheet;
379 }
380 current_rules[name] = true;
381 stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
382 }
383 const animation = node.style.animation || '';
384 node.style.animation = `${animation ? `${animation}, ` : ``}${name} ${duration}ms linear ${delay}ms 1 both`;
385 active += 1;
386 return name;
387}
388function delete_rule(node, name) {
389 node.style.animation = (node.style.animation || '')
390 .split(', ')
391 .filter(name
392 ? anim => anim.indexOf(name) < 0 // remove specific animation
393 : anim => anim.indexOf('__svelte') === -1 // remove all Svelte animations
394 )
395 .join(', ');
396 if (name && !--active)
397 clear_rules();
398}
399function clear_rules() {
400 exports.raf(() => {
401 if (active)
402 return;
403 let i = stylesheet.cssRules.length;
404 while (i--)
405 stylesheet.deleteRule(i);
406 current_rules = {};
407 });
408}
409
410function create_animation(node, from, fn, params) {
411 if (!from)
412 return noop;
413 const to = node.getBoundingClientRect();
414 if (from.left === to.left && from.right === to.right && from.top === to.top && from.bottom === to.bottom)
415 return noop;
416 const { delay = 0, duration = 300, easing = identity,
417 // @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation?
418 start: start_time = exports.now() + delay,
419 // @ts-ignore todo:
420 end = start_time + duration, tick = noop, css } = fn(node, { from, to }, params);
421 let running = true;
422 let started = false;
423 let name;
424 function start() {
425 if (css) {
426 name = create_rule(node, 0, 1, duration, delay, easing, css);
427 }
428 if (!delay) {
429 started = true;
430 }
431 }
432 function stop() {
433 if (css)
434 delete_rule(node, name);
435 running = false;
436 }
437 loop(now => {
438 if (!started && now >= start_time) {
439 started = true;
440 }
441 if (started && now >= end) {
442 tick(1, 0);
443 stop();
444 }
445 if (!running) {
446 return false;
447 }
448 if (started) {
449 const p = now - start_time;
450 const t = 0 + 1 * easing(p / duration);
451 tick(t, 1 - t);
452 }
453 return true;
454 });
455 start();
456 tick(0, 1);
457 return stop;
458}
459function fix_position(node) {
460 const style = getComputedStyle(node);
461 if (style.position !== 'absolute' && style.position !== 'fixed') {
462 const { width, height } = style;
463 const a = node.getBoundingClientRect();
464 node.style.position = 'absolute';
465 node.style.width = width;
466 node.style.height = height;
467 add_transform(node, a);
468 }
469}
470function add_transform(node, a) {
471 const b = node.getBoundingClientRect();
472 if (a.left !== b.left || a.top !== b.top) {
473 const style = getComputedStyle(node);
474 const transform = style.transform === 'none' ? '' : style.transform;
475 node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`;
476 }
477}
478
479function set_current_component(component) {
480 exports.current_component = component;
481}
482function get_current_component() {
483 if (!exports.current_component)
484 throw new Error(`Function called outside component initialization`);
485 return exports.current_component;
486}
487function beforeUpdate(fn) {
488 get_current_component().$$.before_render.push(fn);
489}
490function onMount(fn) {
491 get_current_component().$$.on_mount.push(fn);
492}
493function afterUpdate(fn) {
494 get_current_component().$$.after_render.push(fn);
495}
496function onDestroy(fn) {
497 get_current_component().$$.on_destroy.push(fn);
498}
499function createEventDispatcher() {
500 const component = exports.current_component;
501 return (type, detail) => {
502 const callbacks = component.$$.callbacks[type];
503 if (callbacks) {
504 // TODO are there situations where events could be dispatched
505 // in a server (non-DOM) environment?
506 const event = custom_event(type, detail);
507 callbacks.slice().forEach(fn => {
508 fn.call(component, event);
509 });
510 }
511 };
512}
513function setContext(key, context) {
514 get_current_component().$$.context.set(key, context);
515}
516function getContext(key) {
517 return get_current_component().$$.context.get(key);
518}
519// TODO figure out if we still want to support
520// shorthand events, or if we want to implement
521// a real bubbling mechanism
522function bubble(component, event) {
523 const callbacks = component.$$.callbacks[event.type];
524 if (callbacks) {
525 callbacks.slice().forEach(fn => fn(event));
526 }
527}
528
529const dirty_components = [];
530const intros = { enabled: false };
531const resolved_promise = Promise.resolve();
532let update_scheduled = false;
533const binding_callbacks = [];
534const render_callbacks = [];
535const flush_callbacks = [];
536function schedule_update() {
537 if (!update_scheduled) {
538 update_scheduled = true;
539 resolved_promise.then(flush);
540 }
541}
542function tick() {
543 schedule_update();
544 return resolved_promise;
545}
546function add_binding_callback(fn) {
547 binding_callbacks.push(fn);
548}
549function add_render_callback(fn) {
550 render_callbacks.push(fn);
551}
552function add_flush_callback(fn) {
553 flush_callbacks.push(fn);
554}
555function flush() {
556 const seen_callbacks = new Set();
557 do {
558 // first, call beforeUpdate functions
559 // and update components
560 while (dirty_components.length) {
561 const component = dirty_components.shift();
562 set_current_component(component);
563 update(component.$$);
564 }
565 while (binding_callbacks.length)
566 binding_callbacks.shift()();
567 // then, once components are updated, call
568 // afterUpdate functions. This may cause
569 // subsequent updates...
570 while (render_callbacks.length) {
571 const callback = render_callbacks.pop();
572 if (!seen_callbacks.has(callback)) {
573 callback();
574 // ...so guard against infinite loops
575 seen_callbacks.add(callback);
576 }
577 }
578 } while (dirty_components.length);
579 while (flush_callbacks.length) {
580 flush_callbacks.pop()();
581 }
582 update_scheduled = false;
583}
584function update($$) {
585 if ($$.fragment) {
586 $$.update($$.dirty);
587 run_all($$.before_render);
588 $$.fragment.p($$.dirty, $$.ctx);
589 $$.dirty = null;
590 $$.after_render.forEach(add_render_callback);
591 }
592}
593
594let promise;
595function wait() {
596 if (!promise) {
597 promise = Promise.resolve();
598 promise.then(() => {
599 promise = null;
600 });
601 }
602 return promise;
603}
604function dispatch(node, direction, kind) {
605 node.dispatchEvent(custom_event(`${direction ? 'intro' : 'outro'}${kind}`));
606}
607let outros;
608function group_outros() {
609 outros = {
610 remaining: 0,
611 callbacks: []
612 };
613}
614function check_outros() {
615 if (!outros.remaining) {
616 run_all(outros.callbacks);
617 }
618}
619function on_outro(callback) {
620 outros.callbacks.push(callback);
621}
622function create_in_transition(node, fn, params) {
623 let config = fn(node, params);
624 let running = false;
625 let animation_name;
626 let task;
627 let uid = 0;
628 function cleanup() {
629 if (animation_name)
630 delete_rule(node, animation_name);
631 }
632 function go() {
633 const { delay = 0, duration = 300, easing = identity, tick: tick$$1 = noop, css } = config;
634 if (css)
635 animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++);
636 tick$$1(0, 1);
637 const start_time = exports.now() + delay;
638 const end_time = start_time + duration;
639 if (task)
640 task.abort();
641 running = true;
642 add_render_callback(() => dispatch(node, true, 'start'));
643 task = loop(now => {
644 if (running) {
645 if (now >= end_time) {
646 tick$$1(1, 0);
647 dispatch(node, true, 'end');
648 cleanup();
649 return running = false;
650 }
651 if (now >= start_time) {
652 const t = easing((now - start_time) / duration);
653 tick$$1(t, 1 - t);
654 }
655 }
656 return running;
657 });
658 }
659 let started = false;
660 return {
661 start() {
662 if (started)
663 return;
664 delete_rule(node);
665 if (is_function(config)) {
666 config = config();
667 wait().then(go);
668 }
669 else {
670 go();
671 }
672 },
673 invalidate() {
674 started = false;
675 },
676 end() {
677 if (running) {
678 cleanup();
679 running = false;
680 }
681 }
682 };
683}
684function create_out_transition(node, fn, params) {
685 let config = fn(node, params);
686 let running = true;
687 let animation_name;
688 const group = outros;
689 group.remaining += 1;
690 function go() {
691 const { delay = 0, duration = 300, easing = identity, tick: tick$$1 = noop, css } = config;
692 if (css)
693 animation_name = create_rule(node, 1, 0, duration, delay, easing, css);
694 const start_time = exports.now() + delay;
695 const end_time = start_time + duration;
696 add_render_callback(() => dispatch(node, false, 'start'));
697 loop(now => {
698 if (running) {
699 if (now >= end_time) {
700 tick$$1(0, 1);
701 dispatch(node, false, 'end');
702 if (!--group.remaining) {
703 // this will result in `end()` being called,
704 // so we don't need to clean up here
705 run_all(group.callbacks);
706 }
707 return false;
708 }
709 if (now >= start_time) {
710 const t = easing((now - start_time) / duration);
711 tick$$1(1 - t, t);
712 }
713 }
714 return running;
715 });
716 }
717 if (is_function(config)) {
718 wait().then(() => {
719 // @ts-ignore
720 config = config();
721 go();
722 });
723 }
724 else {
725 go();
726 }
727 return {
728 end(reset) {
729 if (reset && config.tick) {
730 config.tick(1, 0);
731 }
732 if (running) {
733 if (animation_name)
734 delete_rule(node, animation_name);
735 running = false;
736 }
737 }
738 };
739}
740function create_bidirectional_transition(node, fn, params, intro) {
741 let config = fn(node, params);
742 let t = intro ? 0 : 1;
743 let running_program = null;
744 let pending_program = null;
745 let animation_name = null;
746 function clear_animation() {
747 if (animation_name)
748 delete_rule(node, animation_name);
749 }
750 function init(program, duration) {
751 const d = program.b - t;
752 duration *= Math.abs(d);
753 return {
754 a: t,
755 b: program.b,
756 d,
757 duration,
758 start: program.start,
759 end: program.start + duration,
760 group: program.group
761 };
762 }
763 function go(b) {
764 const { delay = 0, duration = 300, easing = identity, tick: tick$$1 = noop, css } = config;
765 const program = {
766 start: exports.now() + delay,
767 b
768 };
769 if (!b) {
770 // @ts-ignore todo: improve typings
771 program.group = outros;
772 outros.remaining += 1;
773 }
774 if (running_program) {
775 pending_program = program;
776 }
777 else {
778 // if this is an intro, and there's a delay, we need to do
779 // an initial tick and/or apply CSS animation immediately
780 if (css) {
781 clear_animation();
782 animation_name = create_rule(node, t, b, duration, delay, easing, css);
783 }
784 if (b)
785 tick$$1(0, 1);
786 running_program = init(program, duration);
787 add_render_callback(() => dispatch(node, b, 'start'));
788 loop(now => {
789 if (pending_program && now > pending_program.start) {
790 running_program = init(pending_program, duration);
791 pending_program = null;
792 dispatch(node, running_program.b, 'start');
793 if (css) {
794 clear_animation();
795 animation_name = create_rule(node, t, running_program.b, running_program.duration, 0, easing, config.css);
796 }
797 }
798 if (running_program) {
799 if (now >= running_program.end) {
800 tick$$1(t = running_program.b, 1 - t);
801 dispatch(node, running_program.b, 'end');
802 if (!pending_program) {
803 // we're done
804 if (running_program.b) {
805 // intro — we can tidy up immediately
806 clear_animation();
807 }
808 else {
809 // outro — needs to be coordinated
810 if (!--running_program.group.remaining)
811 run_all(running_program.group.callbacks);
812 }
813 }
814 running_program = null;
815 }
816 else if (now >= running_program.start) {
817 const p = now - running_program.start;
818 t = running_program.a + running_program.d * easing(p / running_program.duration);
819 tick$$1(t, 1 - t);
820 }
821 }
822 return !!(running_program || pending_program);
823 });
824 }
825 }
826 return {
827 run(b) {
828 if (is_function(config)) {
829 wait().then(() => {
830 // @ts-ignore
831 config = config();
832 go(b);
833 });
834 }
835 else {
836 go(b);
837 }
838 },
839 end() {
840 clear_animation();
841 running_program = pending_program = null;
842 }
843 };
844}
845
846function handle_promise(promise, info) {
847 const token = info.token = {};
848 function update(type, index, key, value) {
849 if (info.token !== token)
850 return;
851 info.resolved = key && { [key]: value };
852 const child_ctx = assign(assign({}, info.ctx), info.resolved);
853 const block = type && (info.current = type)(child_ctx);
854 if (info.block) {
855 if (info.blocks) {
856 info.blocks.forEach((block, i) => {
857 if (i !== index && block) {
858 group_outros();
859 on_outro(() => {
860 block.d(1);
861 info.blocks[i] = null;
862 });
863 block.o(1);
864 check_outros();
865 }
866 });
867 }
868 else {
869 info.block.d(1);
870 }
871 block.c();
872 if (block.i)
873 block.i(1);
874 block.m(info.mount(), info.anchor);
875 flush();
876 }
877 info.block = block;
878 if (info.blocks)
879 info.blocks[index] = block;
880 }
881 if (is_promise(promise)) {
882 promise.then(value => {
883 update(info.then, 1, info.value, value);
884 }, error => {
885 update(info.catch, 2, info.error, error);
886 });
887 // if we previously had a then/catch block, destroy it
888 if (info.current !== info.pending) {
889 update(info.pending, 0);
890 return true;
891 }
892 }
893 else {
894 if (info.current !== info.then) {
895 update(info.then, 1, info.value, promise);
896 return true;
897 }
898 info.resolved = { [info.value]: promise };
899 }
900}
901
902function destroy_block(block, lookup) {
903 block.d(1);
904 lookup.delete(block.key);
905}
906function outro_and_destroy_block(block, lookup) {
907 on_outro(() => {
908 destroy_block(block, lookup);
909 });
910 block.o(1);
911}
912function fix_and_destroy_block(block, lookup) {
913 block.f();
914 destroy_block(block, lookup);
915}
916function fix_and_outro_and_destroy_block(block, lookup) {
917 block.f();
918 outro_and_destroy_block(block, lookup);
919}
920function update_keyed_each(old_blocks, changed, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) {
921 let o = old_blocks.length;
922 let n = list.length;
923 let i = o;
924 const old_indexes = {};
925 while (i--)
926 old_indexes[old_blocks[i].key] = i;
927 const new_blocks = [];
928 const new_lookup = new Map();
929 const deltas = new Map();
930 i = n;
931 while (i--) {
932 const child_ctx = get_context(ctx, list, i);
933 const key = get_key(child_ctx);
934 let block = lookup.get(key);
935 if (!block) {
936 block = create_each_block(key, child_ctx);
937 block.c();
938 }
939 else if (dynamic) {
940 block.p(changed, child_ctx);
941 }
942 new_lookup.set(key, new_blocks[i] = block);
943 if (key in old_indexes)
944 deltas.set(key, Math.abs(i - old_indexes[key]));
945 }
946 const will_move = new Set();
947 const did_move = new Set();
948 function insert(block) {
949 if (block.i)
950 block.i(1);
951 block.m(node, next);
952 lookup.set(block.key, block);
953 next = block.first;
954 n--;
955 }
956 while (o && n) {
957 const new_block = new_blocks[n - 1];
958 const old_block = old_blocks[o - 1];
959 const new_key = new_block.key;
960 const old_key = old_block.key;
961 if (new_block === old_block) {
962 // do nothing
963 next = new_block.first;
964 o--;
965 n--;
966 }
967 else if (!new_lookup.has(old_key)) {
968 // remove old block
969 destroy(old_block, lookup);
970 o--;
971 }
972 else if (!lookup.has(new_key) || will_move.has(new_key)) {
973 insert(new_block);
974 }
975 else if (did_move.has(old_key)) {
976 o--;
977 }
978 else if (deltas.get(new_key) > deltas.get(old_key)) {
979 did_move.add(new_key);
980 insert(new_block);
981 }
982 else {
983 will_move.add(old_key);
984 o--;
985 }
986 }
987 while (o--) {
988 const old_block = old_blocks[o];
989 if (!new_lookup.has(old_block.key))
990 destroy(old_block, lookup);
991 }
992 while (n)
993 insert(new_blocks[n - 1]);
994 return new_blocks;
995}
996function measure(blocks) {
997 const rects = {};
998 let i = blocks.length;
999 while (i--)
1000 rects[blocks[i].key] = blocks[i].node.getBoundingClientRect();
1001 return rects;
1002}
1003
1004function get_spread_update(levels, updates) {
1005 const update = {};
1006 const to_null_out = {};
1007 const accounted_for = { $$scope: 1 };
1008 let i = levels.length;
1009 while (i--) {
1010 const o = levels[i];
1011 const n = updates[i];
1012 if (n) {
1013 for (const key in o) {
1014 if (!(key in n))
1015 to_null_out[key] = 1;
1016 }
1017 for (const key in n) {
1018 if (!accounted_for[key]) {
1019 update[key] = n[key];
1020 accounted_for[key] = 1;
1021 }
1022 }
1023 levels[i] = n;
1024 }
1025 else {
1026 for (const key in o) {
1027 accounted_for[key] = 1;
1028 }
1029 }
1030 }
1031 for (const key in to_null_out) {
1032 if (!(key in update))
1033 update[key] = undefined;
1034 }
1035 return update;
1036}
1037
1038const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1039// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
1040// https://infra.spec.whatwg.org/#noncharacter
1041function spread(args) {
1042 const attributes = Object.assign({}, ...args);
1043 let str = '';
1044 Object.keys(attributes).forEach(name => {
1045 if (invalid_attribute_name_character.test(name))
1046 return;
1047 const value = attributes[name];
1048 if (value === undefined)
1049 return;
1050 if (value === true)
1051 str += " " + name;
1052 const escaped = String(value)
1053 .replace(/"/g, '&#34;')
1054 .replace(/'/g, '&#39;');
1055 str += " " + name + "=" + JSON.stringify(escaped);
1056 });
1057 return str;
1058}
1059const escaped = {
1060 '"': '&quot;',
1061 "'": '&#39;',
1062 '&': '&amp;',
1063 '<': '&lt;',
1064 '>': '&gt;'
1065};
1066function escape(html) {
1067 return String(html).replace(/["'&<>]/g, match => escaped[match]);
1068}
1069function each(items, fn) {
1070 let str = '';
1071 for (let i = 0; i < items.length; i += 1) {
1072 str += fn(items[i], i);
1073 }
1074 return str;
1075}
1076const missing_component = {
1077 $$render: () => ''
1078};
1079function validate_component(component, name) {
1080 if (!component || !component.$$render) {
1081 if (name === 'svelte:component')
1082 name += ' this={...}';
1083 throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);
1084 }
1085 return component;
1086}
1087function debug(file, line, column, values) {
1088 console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); // eslint-disable-line no-console
1089 console.log(values); // eslint-disable-line no-console
1090 return '';
1091}
1092let on_destroy;
1093function create_ssr_component(fn) {
1094 function $$render(result, props, bindings, slots) {
1095 const parent_component = exports.current_component;
1096 const $$ = {
1097 on_destroy,
1098 context: new Map(parent_component ? parent_component.$$.context : []),
1099 // these will be immediately discarded
1100 on_mount: [],
1101 before_render: [],
1102 after_render: [],
1103 callbacks: blank_object()
1104 };
1105 set_current_component({ $$ });
1106 const html = fn(result, props, bindings, slots);
1107 set_current_component(parent_component);
1108 return html;
1109 }
1110 return {
1111 render: (props = {}, options = {}) => {
1112 on_destroy = [];
1113 const result = { head: '', css: new Set() };
1114 const html = $$render(result, props, {}, options);
1115 run_all(on_destroy);
1116 return {
1117 html,
1118 css: {
1119 code: Array.from(result.css).map(css => css.code).join('\n'),
1120 map: null // TODO
1121 },
1122 head: result.head
1123 };
1124 },
1125 $$render
1126 };
1127}
1128function get_store_value(store) {
1129 let value;
1130 store.subscribe(_ => value = _)();
1131 return value;
1132}
1133
1134function bind(component, name, callback) {
1135 if (component.$$.props.indexOf(name) === -1)
1136 return;
1137 component.$$.bound[name] = callback;
1138 callback(component.$$.ctx[name]);
1139}
1140function mount_component(component, target, anchor) {
1141 const { fragment, on_mount, on_destroy, after_render } = component.$$;
1142 fragment.m(target, anchor);
1143 // onMount happens after the initial afterUpdate. Because
1144 // afterUpdate callbacks happen in reverse order (inner first)
1145 // we schedule onMount callbacks before afterUpdate callbacks
1146 add_render_callback(() => {
1147 const new_on_destroy = on_mount.map(run).filter(is_function);
1148 if (on_destroy) {
1149 on_destroy.push(...new_on_destroy);
1150 }
1151 else {
1152 // Edge case - component was destroyed immediately,
1153 // most likely as a result of a binding initialising
1154 run_all(new_on_destroy);
1155 }
1156 component.$$.on_mount = [];
1157 });
1158 after_render.forEach(add_render_callback);
1159}
1160function destroy(component, detaching) {
1161 if (component.$$) {
1162 run_all(component.$$.on_destroy);
1163 component.$$.fragment.d(detaching);
1164 // TODO null out other refs, including component.$$ (but need to
1165 // preserve final state?)
1166 component.$$.on_destroy = component.$$.fragment = null;
1167 component.$$.ctx = {};
1168 }
1169}
1170function make_dirty(component, key) {
1171 if (!component.$$.dirty) {
1172 dirty_components.push(component);
1173 schedule_update();
1174 component.$$.dirty = blank_object();
1175 }
1176 component.$$.dirty[key] = true;
1177}
1178function init(component, options, instance, create_fragment, not_equal$$1, prop_names) {
1179 const parent_component = exports.current_component;
1180 set_current_component(component);
1181 const props = options.props || {};
1182 const $$ = component.$$ = {
1183 fragment: null,
1184 ctx: null,
1185 // state
1186 props: prop_names,
1187 update: noop,
1188 not_equal: not_equal$$1,
1189 bound: blank_object(),
1190 // lifecycle
1191 on_mount: [],
1192 on_destroy: [],
1193 before_render: [],
1194 after_render: [],
1195 context: new Map(parent_component ? parent_component.$$.context : []),
1196 // everything else
1197 callbacks: blank_object(),
1198 dirty: null
1199 };
1200 let ready = false;
1201 $$.ctx = instance
1202 ? instance(component, props, (key, value) => {
1203 if ($$.ctx && not_equal$$1($$.ctx[key], $$.ctx[key] = value)) {
1204 if ($$.bound[key])
1205 $$.bound[key](value);
1206 if (ready)
1207 make_dirty(component, key);
1208 }
1209 })
1210 : props;
1211 $$.update();
1212 ready = true;
1213 run_all($$.before_render);
1214 $$.fragment = create_fragment($$.ctx);
1215 if (options.target) {
1216 if (options.hydrate) {
1217 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1218 $$.fragment.l(children(options.target));
1219 }
1220 else {
1221 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1222 $$.fragment.c();
1223 }
1224 if (options.intro && component.$$.fragment.i)
1225 component.$$.fragment.i();
1226 mount_component(component, options.target, options.anchor);
1227 flush();
1228 }
1229 set_current_component(parent_component);
1230}
1231if (typeof HTMLElement !== 'undefined') {
1232 exports.SvelteElement = class extends HTMLElement {
1233 constructor() {
1234 super();
1235 this.attachShadow({ mode: 'open' });
1236 }
1237 connectedCallback() {
1238 // @ts-ignore todo: improve typings
1239 for (const key in this.$$.slotted) {
1240 // @ts-ignore todo: improve typings
1241 this.appendChild(this.$$.slotted[key]);
1242 }
1243 }
1244 attributeChangedCallback(attr$$1, _oldValue, newValue) {
1245 this[attr$$1] = newValue;
1246 }
1247 $destroy() {
1248 destroy(this, true);
1249 this.$destroy = noop;
1250 }
1251 $on(type, callback) {
1252 // TODO should this delegate to addEventListener?
1253 const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
1254 callbacks.push(callback);
1255 return () => {
1256 const index = callbacks.indexOf(callback);
1257 if (index !== -1)
1258 callbacks.splice(index, 1);
1259 };
1260 }
1261 $set() {
1262 // overridden by instance, if it has props
1263 }
1264 };
1265}
1266class SvelteComponent {
1267 $destroy() {
1268 destroy(this, true);
1269 this.$destroy = noop;
1270 }
1271 $on(type, callback) {
1272 const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
1273 callbacks.push(callback);
1274 return () => {
1275 const index = callbacks.indexOf(callback);
1276 if (index !== -1)
1277 callbacks.splice(index, 1);
1278 };
1279 }
1280 $set() {
1281 // overridden by instance, if it has props
1282 }
1283}
1284class SvelteComponentDev extends SvelteComponent {
1285 constructor(options) {
1286 if (!options || (!options.target && !options.$$inline)) {
1287 throw new Error(`'target' is a required option`);
1288 }
1289 super();
1290 }
1291 $destroy() {
1292 super.$destroy();
1293 this.$destroy = () => {
1294 console.warn(`Component was already destroyed`); // eslint-disable-line no-console
1295 };
1296 }
1297}
1298
1299exports.create_animation = create_animation;
1300exports.fix_position = fix_position;
1301exports.add_transform = add_transform;
1302exports.handle_promise = handle_promise;
1303exports.append = append;
1304exports.insert = insert;
1305exports.detach = detach;
1306exports.detach_between = detach_between;
1307exports.detach_before = detach_before;
1308exports.detach_after = detach_after;
1309exports.destroy_each = destroy_each;
1310exports.element = element;
1311exports.object_without_properties = object_without_properties;
1312exports.svg_element = svg_element;
1313exports.text = text;
1314exports.space = space;
1315exports.empty = empty;
1316exports.listen = listen;
1317exports.prevent_default = prevent_default;
1318exports.stop_propagation = stop_propagation;
1319exports.attr = attr;
1320exports.set_attributes = set_attributes;
1321exports.set_custom_element_data = set_custom_element_data;
1322exports.xlink_attr = xlink_attr;
1323exports.get_binding_group_value = get_binding_group_value;
1324exports.to_number = to_number;
1325exports.time_ranges_to_array = time_ranges_to_array;
1326exports.children = children;
1327exports.claim_element = claim_element;
1328exports.claim_text = claim_text;
1329exports.set_data = set_data;
1330exports.set_input_type = set_input_type;
1331exports.set_style = set_style;
1332exports.select_option = select_option;
1333exports.select_options = select_options;
1334exports.select_value = select_value;
1335exports.select_multiple_value = select_multiple_value;
1336exports.add_resize_listener = add_resize_listener;
1337exports.toggle_class = toggle_class;
1338exports.custom_event = custom_event;
1339exports.destroy_block = destroy_block;
1340exports.outro_and_destroy_block = outro_and_destroy_block;
1341exports.fix_and_destroy_block = fix_and_destroy_block;
1342exports.fix_and_outro_and_destroy_block = fix_and_outro_and_destroy_block;
1343exports.update_keyed_each = update_keyed_each;
1344exports.measure = measure;
1345exports.set_current_component = set_current_component;
1346exports.beforeUpdate = beforeUpdate;
1347exports.onMount = onMount;
1348exports.afterUpdate = afterUpdate;
1349exports.onDestroy = onDestroy;
1350exports.createEventDispatcher = createEventDispatcher;
1351exports.setContext = setContext;
1352exports.getContext = getContext;
1353exports.bubble = bubble;
1354exports.clear_loops = clear_loops;
1355exports.loop = loop;
1356exports.dirty_components = dirty_components;
1357exports.intros = intros;
1358exports.schedule_update = schedule_update;
1359exports.tick = tick;
1360exports.add_binding_callback = add_binding_callback;
1361exports.add_render_callback = add_render_callback;
1362exports.add_flush_callback = add_flush_callback;
1363exports.flush = flush;
1364exports.get_spread_update = get_spread_update;
1365exports.invalid_attribute_name_character = invalid_attribute_name_character;
1366exports.spread = spread;
1367exports.escaped = escaped;
1368exports.escape = escape;
1369exports.each = each;
1370exports.missing_component = missing_component;
1371exports.validate_component = validate_component;
1372exports.debug = debug;
1373exports.create_ssr_component = create_ssr_component;
1374exports.get_store_value = get_store_value;
1375exports.group_outros = group_outros;
1376exports.check_outros = check_outros;
1377exports.on_outro = on_outro;
1378exports.create_in_transition = create_in_transition;
1379exports.create_out_transition = create_out_transition;
1380exports.create_bidirectional_transition = create_bidirectional_transition;
1381exports.noop = noop;
1382exports.identity = identity;
1383exports.assign = assign;
1384exports.is_promise = is_promise;
1385exports.add_location = add_location;
1386exports.run = run;
1387exports.blank_object = blank_object;
1388exports.run_all = run_all;
1389exports.is_function = is_function;
1390exports.safe_not_equal = safe_not_equal;
1391exports.not_equal = not_equal;
1392exports.validate_store = validate_store;
1393exports.subscribe = subscribe;
1394exports.create_slot = create_slot;
1395exports.get_slot_context = get_slot_context;
1396exports.get_slot_changes = get_slot_changes;
1397exports.exclude_internal_props = exclude_internal_props;
1398exports.once = once;
1399exports.set_now = set_now;
1400exports.set_raf = set_raf;
1401exports.bind = bind;
1402exports.mount_component = mount_component;
1403exports.init = init;
1404exports.SvelteComponent = SvelteComponent;
1405exports.SvelteComponentDev = SvelteComponentDev;