UNPKG

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