UNPKG

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