@pie-element/element-player 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2841 @@
1
+ import { m as Ht } from "./math-mathjax-Dwo4iuV6.js";
2
+ const Hn = "5";
3
+ typeof window < "u" && ((window.__svelte ??= {}).v ??= /* @__PURE__ */ new Set()).add(Hn);
4
+ const Yn = 1, zn = 4, Kn = 8, Gn = 16, Wn = 2, $t = "[", yt = "[!", Yt = "]", Re = {}, O = /* @__PURE__ */ Symbol(), Jn = "http://www.w3.org/1999/xhtml", dt = !1;
5
+ var zt = Array.isArray, Zn = Array.prototype.indexOf, Oe = Array.prototype.includes, Xn = Array.from, Qe = Object.keys, et = Object.defineProperty, we = Object.getOwnPropertyDescriptor, Qn = Object.prototype, er = Array.prototype, tr = Object.getPrototypeOf, Pt = Object.isExtensible;
6
+ const nr = () => {
7
+ };
8
+ function rr(e) {
9
+ for (var t = 0; t < e.length; t++)
10
+ e[t]();
11
+ }
12
+ function Kt() {
13
+ var e, t, n = new Promise((r, i) => {
14
+ e = r, t = i;
15
+ });
16
+ return { promise: n, resolve: e, reject: t };
17
+ }
18
+ const k = 2, Be = 4, ot = 8, Gt = 1 << 24, le = 16, X = 32, ve = 64, Wt = 128, U = 512, R = 1024, C = 2048, K = 4096, W = 8192, ie = 16384, De = 32768, ke = 65536, Dt = 1 << 17, Jt = 1 << 18, Te = 1 << 19, ir = 1 << 20, Ee = 65536, ht = 1 << 21, bt = 1 << 22, ce = 1 << 23, Ie = /* @__PURE__ */ Symbol("$state"), Zt = /* @__PURE__ */ Symbol("legacy props"), pe = new class extends Error {
19
+ name = "StaleReactionError";
20
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
21
+ }(), Et = 3, He = 8;
22
+ function Xt(e) {
23
+ throw new Error("https://svelte.dev/e/lifecycle_outside_component");
24
+ }
25
+ function sr() {
26
+ throw new Error("https://svelte.dev/e/async_derived_orphan");
27
+ }
28
+ function lr(e) {
29
+ throw new Error("https://svelte.dev/e/effect_in_teardown");
30
+ }
31
+ function or() {
32
+ throw new Error("https://svelte.dev/e/effect_in_unowned_derived");
33
+ }
34
+ function fr(e) {
35
+ throw new Error("https://svelte.dev/e/effect_orphan");
36
+ }
37
+ function ar() {
38
+ throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
39
+ }
40
+ function ur() {
41
+ throw new Error("https://svelte.dev/e/hydration_failed");
42
+ }
43
+ function cr(e) {
44
+ throw new Error("https://svelte.dev/e/props_invalid_value");
45
+ }
46
+ function dr() {
47
+ throw new Error("https://svelte.dev/e/state_descriptors_fixed");
48
+ }
49
+ function hr() {
50
+ throw new Error("https://svelte.dev/e/state_prototype_fixed");
51
+ }
52
+ function vr() {
53
+ throw new Error("https://svelte.dev/e/state_unsafe_mutation");
54
+ }
55
+ function _r() {
56
+ throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
57
+ }
58
+ function ft(e) {
59
+ console.warn("https://svelte.dev/e/hydration_mismatch");
60
+ }
61
+ function pr() {
62
+ console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
63
+ }
64
+ let A = !1;
65
+ function Ne(e) {
66
+ A = e;
67
+ }
68
+ let T;
69
+ function J(e) {
70
+ if (e === null)
71
+ throw ft(), Re;
72
+ return T = e;
73
+ }
74
+ function xt() {
75
+ return J(/* @__PURE__ */ _e(T));
76
+ }
77
+ function fe(e) {
78
+ if (A) {
79
+ if (/* @__PURE__ */ _e(T) !== null)
80
+ throw ft(), Re;
81
+ T = e;
82
+ }
83
+ }
84
+ function mr(e = 1) {
85
+ if (A) {
86
+ for (var t = e, n = T; t--; )
87
+ n = /** @type {TemplateNode} */
88
+ /* @__PURE__ */ _e(n);
89
+ T = n;
90
+ }
91
+ }
92
+ function Qt(e = !0) {
93
+ for (var t = 0, n = T; ; ) {
94
+ if (n.nodeType === He) {
95
+ var r = (
96
+ /** @type {Comment} */
97
+ n.data
98
+ );
99
+ if (r === Yt) {
100
+ if (t === 0) return n;
101
+ t -= 1;
102
+ } else (r === $t || r === yt || // "[1", "[2", etc. for if blocks
103
+ r[0] === "[" && !isNaN(Number(r.slice(1)))) && (t += 1);
104
+ }
105
+ var i = (
106
+ /** @type {TemplateNode} */
107
+ /* @__PURE__ */ _e(n)
108
+ );
109
+ e && n.remove(), n = i;
110
+ }
111
+ }
112
+ function gr(e) {
113
+ if (!e || e.nodeType !== He)
114
+ throw ft(), Re;
115
+ return (
116
+ /** @type {Comment} */
117
+ e.data
118
+ );
119
+ }
120
+ function en(e) {
121
+ return e === this.v;
122
+ }
123
+ function wr(e, t) {
124
+ return e != e ? t == t : e !== t || e !== null && typeof e == "object" || typeof e == "function";
125
+ }
126
+ function tn(e) {
127
+ return !wr(e, this.v);
128
+ }
129
+ let $r = !1, F = null;
130
+ function Ce(e) {
131
+ F = e;
132
+ }
133
+ function Tt(e, t = !1, n) {
134
+ F = {
135
+ p: F,
136
+ i: !1,
137
+ c: null,
138
+ e: null,
139
+ s: e,
140
+ x: null,
141
+ l: null
142
+ };
143
+ }
144
+ function St(e) {
145
+ var t = (
146
+ /** @type {ComponentContext} */
147
+ F
148
+ ), n = t.e;
149
+ if (n !== null) {
150
+ t.e = null;
151
+ for (var r of n)
152
+ yn(r);
153
+ }
154
+ return e !== void 0 && (t.x = e), t.i = !0, F = t.p, e ?? /** @type {T} */
155
+ {};
156
+ }
157
+ function nn() {
158
+ return !0;
159
+ }
160
+ let me = [];
161
+ function rn() {
162
+ var e = me;
163
+ me = [], rr(e);
164
+ }
165
+ function $e(e) {
166
+ if (me.length === 0 && !je) {
167
+ var t = me;
168
+ queueMicrotask(() => {
169
+ t === me && rn();
170
+ });
171
+ }
172
+ me.push(e);
173
+ }
174
+ function yr() {
175
+ for (; me.length > 0; )
176
+ rn();
177
+ }
178
+ function sn(e) {
179
+ var t = y;
180
+ if (t === null)
181
+ return w.f |= ce, e;
182
+ if ((t.f & De) === 0 && (t.f & Be) === 0)
183
+ throw e;
184
+ Me(e, t);
185
+ }
186
+ function Me(e, t) {
187
+ for (; t !== null; ) {
188
+ if ((t.f & Wt) !== 0) {
189
+ if ((t.f & De) === 0)
190
+ throw e;
191
+ try {
192
+ t.b.error(e);
193
+ return;
194
+ } catch (n) {
195
+ e = n;
196
+ }
197
+ }
198
+ t = t.parent;
199
+ }
200
+ throw e;
201
+ }
202
+ const br = -7169;
203
+ function S(e, t) {
204
+ e.f = e.f & br | t;
205
+ }
206
+ function Nt(e) {
207
+ (e.f & U) !== 0 || e.deps === null ? S(e, R) : S(e, K);
208
+ }
209
+ function ln(e) {
210
+ if (e !== null)
211
+ for (const t of e)
212
+ (t.f & k) === 0 || (t.f & Ee) === 0 || (t.f ^= Ee, ln(
213
+ /** @type {Derived} */
214
+ t.deps
215
+ ));
216
+ }
217
+ function on(e, t, n) {
218
+ (e.f & C) !== 0 ? t.add(e) : (e.f & K) !== 0 && n.add(e), ln(e.deps), S(e, R);
219
+ }
220
+ const Ke = /* @__PURE__ */ new Set();
221
+ let x = null, H = null, P = [], at = null, vt = !1, je = !1;
222
+ class se {
223
+ committed = !1;
224
+ /**
225
+ * The current values of any sources that are updated in this batch
226
+ * They keys of this map are identical to `this.#previous`
227
+ * @type {Map<Source, any>}
228
+ */
229
+ current = /* @__PURE__ */ new Map();
230
+ /**
231
+ * The values of any sources that are updated in this batch _before_ those updates took place.
232
+ * They keys of this map are identical to `this.#current`
233
+ * @type {Map<Source, any>}
234
+ */
235
+ previous = /* @__PURE__ */ new Map();
236
+ /**
237
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
238
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
239
+ * @type {Set<() => void>}
240
+ */
241
+ #e = /* @__PURE__ */ new Set();
242
+ /**
243
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
244
+ * @type {Set<(batch: Batch) => void>}
245
+ */
246
+ #t = /* @__PURE__ */ new Set();
247
+ /**
248
+ * The number of async effects that are currently in flight
249
+ */
250
+ #n = 0;
251
+ /**
252
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
253
+ */
254
+ #l = 0;
255
+ /**
256
+ * A deferred that resolves when the batch is committed, used with `settled()`
257
+ * TODO replace with Promise.withResolvers once supported widely enough
258
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
259
+ */
260
+ #o = null;
261
+ /**
262
+ * Deferred effects (which run after async work has completed) that are DIRTY
263
+ * @type {Set<Effect>}
264
+ */
265
+ #i = /* @__PURE__ */ new Set();
266
+ /**
267
+ * Deferred effects that are MAYBE_DIRTY
268
+ * @type {Set<Effect>}
269
+ */
270
+ #r = /* @__PURE__ */ new Set();
271
+ /**
272
+ * A map of branches that still exist, but will be destroyed when this batch
273
+ * is committed — we skip over these during `process`.
274
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
275
+ * so they can be rescheduled if the branch survives.
276
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
277
+ */
278
+ #s = /* @__PURE__ */ new Map();
279
+ is_fork = !1;
280
+ #f = !1;
281
+ is_deferred() {
282
+ return this.is_fork || this.#l > 0;
283
+ }
284
+ /**
285
+ * Add an effect to the #skipped_branches map and reset its children
286
+ * @param {Effect} effect
287
+ */
288
+ skip_effect(t) {
289
+ this.#s.has(t) || this.#s.set(t, { d: [], m: [] });
290
+ }
291
+ /**
292
+ * Remove an effect from the #skipped_branches map and reschedule
293
+ * any tracked dirty/maybe_dirty child effects
294
+ * @param {Effect} effect
295
+ */
296
+ unskip_effect(t) {
297
+ var n = this.#s.get(t);
298
+ if (n) {
299
+ this.#s.delete(t);
300
+ for (var r of n.d)
301
+ S(r, C), Y(r);
302
+ for (r of n.m)
303
+ S(r, K), Y(r);
304
+ }
305
+ }
306
+ /**
307
+ *
308
+ * @param {Effect[]} root_effects
309
+ */
310
+ process(t) {
311
+ P = [], this.apply();
312
+ var n = [], r = [];
313
+ for (const i of t)
314
+ this.#a(i, n, r);
315
+ if (this.is_deferred()) {
316
+ this.#c(r), this.#c(n);
317
+ for (const [i, s] of this.#s)
318
+ cn(i, s);
319
+ } else {
320
+ for (const i of this.#e) i();
321
+ this.#e.clear(), this.#n === 0 && this.#u(), x = null, Lt(r), Lt(n), this.#o?.resolve();
322
+ }
323
+ H = null;
324
+ }
325
+ /**
326
+ * Traverse the effect tree, executing effects or stashing
327
+ * them for later execution as appropriate
328
+ * @param {Effect} root
329
+ * @param {Effect[]} effects
330
+ * @param {Effect[]} render_effects
331
+ */
332
+ #a(t, n, r) {
333
+ t.f ^= R;
334
+ for (var i = t.first, s = null; i !== null; ) {
335
+ var l = i.f, o = (l & (X | ve)) !== 0, f = o && (l & R) !== 0, a = f || (l & W) !== 0 || this.#s.has(i);
336
+ if (!a && i.fn !== null) {
337
+ o ? i.f ^= R : s !== null && (l & (Be | ot | Gt)) !== 0 ? s.b.defer_effect(i) : (l & Be) !== 0 ? n.push(i) : ze(i) && ((l & le) !== 0 && this.#r.add(i), Pe(i));
338
+ var d = i.first;
339
+ if (d !== null) {
340
+ i = d;
341
+ continue;
342
+ }
343
+ }
344
+ var c = i.parent;
345
+ for (i = i.next; i === null && c !== null; )
346
+ c === s && (s = null), i = c.next, c = c.parent;
347
+ }
348
+ }
349
+ /**
350
+ * @param {Effect[]} effects
351
+ */
352
+ #c(t) {
353
+ for (var n = 0; n < t.length; n += 1)
354
+ on(t[n], this.#i, this.#r);
355
+ }
356
+ /**
357
+ * Associate a change to a given source with the current
358
+ * batch, noting its previous and current values
359
+ * @param {Source} source
360
+ * @param {any} value
361
+ */
362
+ capture(t, n) {
363
+ n !== O && !this.previous.has(t) && this.previous.set(t, n), (t.f & ce) === 0 && (this.current.set(t, t.v), H?.set(t, t.v));
364
+ }
365
+ activate() {
366
+ x = this, this.apply();
367
+ }
368
+ deactivate() {
369
+ x === this && (x = null, H = null);
370
+ }
371
+ flush() {
372
+ if (this.activate(), P.length > 0) {
373
+ if (fn(), x !== null && x !== this)
374
+ return;
375
+ } else this.#n === 0 && this.process([]);
376
+ this.deactivate();
377
+ }
378
+ discard() {
379
+ for (const t of this.#t) t(this);
380
+ this.#t.clear();
381
+ }
382
+ #u() {
383
+ if (Ke.size > 1) {
384
+ this.previous.clear();
385
+ var t = H, n = !0;
386
+ for (const i of Ke) {
387
+ if (i === this) {
388
+ n = !1;
389
+ continue;
390
+ }
391
+ const s = [];
392
+ for (const [o, f] of this.current) {
393
+ if (i.current.has(o))
394
+ if (n && f !== i.current.get(o))
395
+ i.current.set(o, f);
396
+ else
397
+ continue;
398
+ s.push(o);
399
+ }
400
+ if (s.length === 0)
401
+ continue;
402
+ const l = [...i.current.keys()].filter((o) => !this.current.has(o));
403
+ if (l.length > 0) {
404
+ var r = P;
405
+ P = [];
406
+ const o = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map();
407
+ for (const a of s)
408
+ an(a, l, o, f);
409
+ if (P.length > 0) {
410
+ x = i, i.apply();
411
+ for (const a of P)
412
+ i.#a(a, [], []);
413
+ i.deactivate();
414
+ }
415
+ P = r;
416
+ }
417
+ }
418
+ x = null, H = t;
419
+ }
420
+ this.committed = !0, Ke.delete(this);
421
+ }
422
+ /**
423
+ *
424
+ * @param {boolean} blocking
425
+ */
426
+ increment(t) {
427
+ this.#n += 1, t && (this.#l += 1);
428
+ }
429
+ /**
430
+ *
431
+ * @param {boolean} blocking
432
+ */
433
+ decrement(t) {
434
+ this.#n -= 1, t && (this.#l -= 1), !this.#f && (this.#f = !0, $e(() => {
435
+ this.#f = !1, this.is_deferred() ? P.length > 0 && this.flush() : this.revive();
436
+ }));
437
+ }
438
+ revive() {
439
+ for (const t of this.#i)
440
+ this.#r.delete(t), S(t, C), Y(t);
441
+ for (const t of this.#r)
442
+ S(t, K), Y(t);
443
+ this.flush();
444
+ }
445
+ /** @param {() => void} fn */
446
+ oncommit(t) {
447
+ this.#e.add(t);
448
+ }
449
+ /** @param {(batch: Batch) => void} fn */
450
+ ondiscard(t) {
451
+ this.#t.add(t);
452
+ }
453
+ settled() {
454
+ return (this.#o ??= Kt()).promise;
455
+ }
456
+ static ensure() {
457
+ if (x === null) {
458
+ const t = x = new se();
459
+ Ke.add(x), je || $e(() => {
460
+ x === t && t.flush();
461
+ });
462
+ }
463
+ return x;
464
+ }
465
+ apply() {
466
+ }
467
+ }
468
+ function re(e) {
469
+ var t = je;
470
+ je = !0;
471
+ try {
472
+ for (var n; ; ) {
473
+ if (yr(), P.length === 0 && (x?.flush(), P.length === 0))
474
+ return at = null, /** @type {T} */
475
+ n;
476
+ fn();
477
+ }
478
+ } finally {
479
+ je = t;
480
+ }
481
+ }
482
+ function fn() {
483
+ vt = !0;
484
+ var e = null;
485
+ try {
486
+ for (var t = 0; P.length > 0; ) {
487
+ var n = se.ensure();
488
+ if (t++ > 1e3) {
489
+ var r, i;
490
+ Er();
491
+ }
492
+ n.process(P), de.clear();
493
+ }
494
+ } finally {
495
+ P = [], vt = !1, at = null;
496
+ }
497
+ }
498
+ function Er() {
499
+ try {
500
+ ar();
501
+ } catch (e) {
502
+ Me(e, at);
503
+ }
504
+ }
505
+ let te = null;
506
+ function Lt(e) {
507
+ var t = e.length;
508
+ if (t !== 0) {
509
+ for (var n = 0; n < t; ) {
510
+ var r = e[n++];
511
+ if ((r.f & (ie | W)) === 0 && ze(r) && (te = /* @__PURE__ */ new Set(), Pe(r), r.deps === null && r.first === null && r.nodes === null && r.teardown === null && r.ac === null && Tn(r), te?.size > 0)) {
512
+ de.clear();
513
+ for (const i of te) {
514
+ if ((i.f & (ie | W)) !== 0) continue;
515
+ const s = [i];
516
+ let l = i.parent;
517
+ for (; l !== null; )
518
+ te.has(l) && (te.delete(l), s.push(l)), l = l.parent;
519
+ for (let o = s.length - 1; o >= 0; o--) {
520
+ const f = s[o];
521
+ (f.f & (ie | W)) === 0 && Pe(f);
522
+ }
523
+ }
524
+ te.clear();
525
+ }
526
+ }
527
+ te = null;
528
+ }
529
+ }
530
+ function an(e, t, n, r) {
531
+ if (!n.has(e) && (n.add(e), e.reactions !== null))
532
+ for (const i of e.reactions) {
533
+ const s = i.f;
534
+ (s & k) !== 0 ? an(
535
+ /** @type {Derived} */
536
+ i,
537
+ t,
538
+ n,
539
+ r
540
+ ) : (s & (bt | le)) !== 0 && (s & C) === 0 && un(i, t, r) && (S(i, C), Y(
541
+ /** @type {Effect} */
542
+ i
543
+ ));
544
+ }
545
+ }
546
+ function un(e, t, n) {
547
+ const r = n.get(e);
548
+ if (r !== void 0) return r;
549
+ if (e.deps !== null)
550
+ for (const i of e.deps) {
551
+ if (Oe.call(t, i))
552
+ return !0;
553
+ if ((i.f & k) !== 0 && un(
554
+ /** @type {Derived} */
555
+ i,
556
+ t,
557
+ n
558
+ ))
559
+ return n.set(
560
+ /** @type {Derived} */
561
+ i,
562
+ !0
563
+ ), !0;
564
+ }
565
+ return n.set(e, !1), !1;
566
+ }
567
+ function Y(e) {
568
+ for (var t = at = e; t.parent !== null; ) {
569
+ t = t.parent;
570
+ var n = t.f;
571
+ if (vt && t === y && (n & le) !== 0 && (n & Jt) === 0)
572
+ return;
573
+ if ((n & (ve | X)) !== 0) {
574
+ if ((n & R) === 0) return;
575
+ t.f ^= R;
576
+ }
577
+ }
578
+ P.push(t);
579
+ }
580
+ function cn(e, t) {
581
+ if (!((e.f & X) !== 0 && (e.f & R) !== 0)) {
582
+ (e.f & C) !== 0 ? t.d.push(e) : (e.f & K) !== 0 && t.m.push(e), S(e, R);
583
+ for (var n = e.first; n !== null; )
584
+ cn(n, t), n = n.next;
585
+ }
586
+ }
587
+ function xr(e) {
588
+ let t = 0, n = Ye(0), r;
589
+ return () => {
590
+ kt() && (p(n), Ct(() => (t === 0 && (r = ut(() => e(() => qe(n)))), t += 1, () => {
591
+ $e(() => {
592
+ t -= 1, t === 0 && (r?.(), r = void 0, qe(n));
593
+ });
594
+ })));
595
+ };
596
+ }
597
+ var Tr = ke | Te | Wt;
598
+ function Sr(e, t, n) {
599
+ new Nr(e, t, n);
600
+ }
601
+ class Nr {
602
+ /** @type {Boundary | null} */
603
+ parent;
604
+ is_pending = !1;
605
+ /** @type {TemplateNode} */
606
+ #e;
607
+ /** @type {TemplateNode | null} */
608
+ #t = A ? T : null;
609
+ /** @type {BoundaryProps} */
610
+ #n;
611
+ /** @type {((anchor: Node) => void)} */
612
+ #l;
613
+ /** @type {Effect} */
614
+ #o;
615
+ /** @type {Effect | null} */
616
+ #i = null;
617
+ /** @type {Effect | null} */
618
+ #r = null;
619
+ /** @type {Effect | null} */
620
+ #s = null;
621
+ /** @type {DocumentFragment | null} */
622
+ #f = null;
623
+ /** @type {TemplateNode | null} */
624
+ #a = null;
625
+ #c = 0;
626
+ #u = 0;
627
+ #v = !1;
628
+ #h = !1;
629
+ /** @type {Set<Effect>} */
630
+ #_ = /* @__PURE__ */ new Set();
631
+ /** @type {Set<Effect>} */
632
+ #p = /* @__PURE__ */ new Set();
633
+ /**
634
+ * A source containing the number of pending async deriveds/expressions.
635
+ * Only created if `$effect.pending()` is used inside the boundary,
636
+ * otherwise updating the source results in needless `Batch.ensure()`
637
+ * calls followed by no-op flushes
638
+ * @type {Source<number> | null}
639
+ */
640
+ #d = null;
641
+ #y = xr(() => (this.#d = Ye(this.#c), () => {
642
+ this.#d = null;
643
+ }));
644
+ /**
645
+ * @param {TemplateNode} node
646
+ * @param {BoundaryProps} props
647
+ * @param {((anchor: Node) => void)} children
648
+ */
649
+ constructor(t, n, r) {
650
+ this.#e = t, this.#n = n, this.#l = r, this.parent = /** @type {Effect} */
651
+ y.b, this.is_pending = !!this.#n.pending, this.#o = En(() => {
652
+ if (y.b = this, A) {
653
+ const s = this.#t;
654
+ xt(), /** @type {Comment} */
655
+ s.nodeType === He && /** @type {Comment} */
656
+ s.data === yt ? this.#E() : (this.#b(), this.#u === 0 && (this.is_pending = !1));
657
+ } else {
658
+ var i = this.#w();
659
+ try {
660
+ this.#i = ne(() => r(i));
661
+ } catch (s) {
662
+ this.error(s);
663
+ }
664
+ this.#u > 0 ? this.#g() : this.is_pending = !1;
665
+ }
666
+ return () => {
667
+ this.#a?.remove();
668
+ };
669
+ }, Tr), A && (this.#e = T);
670
+ }
671
+ #b() {
672
+ try {
673
+ this.#i = ne(() => this.#l(this.#e));
674
+ } catch (t) {
675
+ this.error(t);
676
+ }
677
+ }
678
+ #E() {
679
+ const t = this.#n.pending;
680
+ t && (this.#r = ne(() => t(this.#e)), $e(() => {
681
+ var n = this.#w();
682
+ this.#i = this.#m(() => (se.ensure(), ne(() => this.#l(n)))), this.#u > 0 ? this.#g() : (Ue(
683
+ /** @type {Effect} */
684
+ this.#r,
685
+ () => {
686
+ this.#r = null;
687
+ }
688
+ ), this.is_pending = !1);
689
+ }));
690
+ }
691
+ #w() {
692
+ var t = this.#e;
693
+ return this.is_pending && (this.#a = xe(), this.#e.before(this.#a), t = this.#a), t;
694
+ }
695
+ /**
696
+ * Defer an effect inside a pending boundary until the boundary resolves
697
+ * @param {Effect} effect
698
+ */
699
+ defer_effect(t) {
700
+ on(t, this.#_, this.#p);
701
+ }
702
+ /**
703
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
704
+ * @returns {boolean}
705
+ */
706
+ is_rendered() {
707
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
708
+ }
709
+ has_pending_snippet() {
710
+ return !!this.#n.pending;
711
+ }
712
+ /**
713
+ * @param {() => Effect | null} fn
714
+ */
715
+ #m(t) {
716
+ var n = y, r = w, i = F;
717
+ Z(this.#o), V(this.#o), Ce(this.#o.ctx);
718
+ try {
719
+ return t();
720
+ } catch (s) {
721
+ return sn(s), null;
722
+ } finally {
723
+ Z(n), V(r), Ce(i);
724
+ }
725
+ }
726
+ #g() {
727
+ const t = (
728
+ /** @type {(anchor: Node) => void} */
729
+ this.#n.pending
730
+ );
731
+ this.#i !== null && (this.#f = document.createDocumentFragment(), this.#f.append(
732
+ /** @type {TemplateNode} */
733
+ this.#a
734
+ ), An(this.#i, this.#f)), this.#r === null && (this.#r = ne(() => t(this.#e)));
735
+ }
736
+ /**
737
+ * Updates the pending count associated with the currently visible pending snippet,
738
+ * if any, such that we can replace the snippet with content once work is done
739
+ * @param {1 | -1} d
740
+ */
741
+ #$(t) {
742
+ if (!this.has_pending_snippet()) {
743
+ this.parent && this.parent.#$(t);
744
+ return;
745
+ }
746
+ if (this.#u += t, this.#u === 0) {
747
+ this.is_pending = !1;
748
+ for (const n of this.#_)
749
+ S(n, C), Y(n);
750
+ for (const n of this.#p)
751
+ S(n, K), Y(n);
752
+ this.#_.clear(), this.#p.clear(), this.#r && Ue(this.#r, () => {
753
+ this.#r = null;
754
+ }), this.#f && (this.#e.before(this.#f), this.#f = null);
755
+ }
756
+ }
757
+ /**
758
+ * Update the source that powers `$effect.pending()` inside this boundary,
759
+ * and controls when the current `pending` snippet (if any) is removed.
760
+ * Do not call from inside the class
761
+ * @param {1 | -1} d
762
+ */
763
+ update_pending_count(t) {
764
+ this.#$(t), this.#c += t, !(!this.#d || this.#v) && (this.#v = !0, $e(() => {
765
+ this.#v = !1, this.#d && tt(this.#d, this.#c);
766
+ }));
767
+ }
768
+ get_effect_pending() {
769
+ return this.#y(), p(
770
+ /** @type {Source<number>} */
771
+ this.#d
772
+ );
773
+ }
774
+ /** @param {unknown} error */
775
+ error(t) {
776
+ var n = this.#n.onerror;
777
+ let r = this.#n.failed;
778
+ if (this.#h || !n && !r)
779
+ throw t;
780
+ this.#i && (L(this.#i), this.#i = null), this.#r && (L(this.#r), this.#r = null), this.#s && (L(this.#s), this.#s = null), A && (J(
781
+ /** @type {TemplateNode} */
782
+ this.#t
783
+ ), mr(), J(Qt()));
784
+ var i = !1, s = !1;
785
+ const l = () => {
786
+ if (i) {
787
+ pr();
788
+ return;
789
+ }
790
+ i = !0, s && _r(), se.ensure(), this.#c = 0, this.#s !== null && Ue(this.#s, () => {
791
+ this.#s = null;
792
+ }), this.is_pending = this.has_pending_snippet(), this.#i = this.#m(() => (this.#h = !1, ne(() => this.#l(this.#e)))), this.#u > 0 ? this.#g() : this.is_pending = !1;
793
+ };
794
+ $e(() => {
795
+ try {
796
+ s = !0, n?.(t, l), s = !1;
797
+ } catch (o) {
798
+ Me(o, this.#o && this.#o.parent);
799
+ }
800
+ r && (this.#s = this.#m(() => {
801
+ se.ensure(), this.#h = !0;
802
+ try {
803
+ return ne(() => {
804
+ r(
805
+ this.#e,
806
+ () => t,
807
+ () => l
808
+ );
809
+ });
810
+ } catch (o) {
811
+ return Me(
812
+ o,
813
+ /** @type {Effect} */
814
+ this.#o.parent
815
+ ), null;
816
+ } finally {
817
+ this.#h = !1;
818
+ }
819
+ }));
820
+ });
821
+ }
822
+ }
823
+ function Ar(e, t, n, r) {
824
+ const i = At;
825
+ var s = e.filter((u) => !u.settled);
826
+ if (n.length === 0 && s.length === 0) {
827
+ r(t.map(i));
828
+ return;
829
+ }
830
+ var l = x, o = (
831
+ /** @type {Effect} */
832
+ y
833
+ ), f = Rr(), a = s.length === 1 ? s[0].promise : s.length > 1 ? Promise.all(s.map((u) => u.promise)) : null;
834
+ function d(u) {
835
+ f();
836
+ try {
837
+ r(u);
838
+ } catch (v) {
839
+ (o.f & ie) === 0 && Me(v, o);
840
+ }
841
+ l?.deactivate(), _t();
842
+ }
843
+ if (n.length === 0) {
844
+ a.then(() => d(t.map(i)));
845
+ return;
846
+ }
847
+ function c() {
848
+ f(), Promise.all(n.map((u) => /* @__PURE__ */ Or(u))).then((u) => d([...t.map(i), ...u])).catch((u) => Me(u, o));
849
+ }
850
+ a ? a.then(c) : c();
851
+ }
852
+ function Rr() {
853
+ var e = y, t = w, n = F, r = x;
854
+ return function(s = !0) {
855
+ Z(e), V(t), Ce(n), s && r?.activate();
856
+ };
857
+ }
858
+ function _t() {
859
+ Z(null), V(null), Ce(null);
860
+ }
861
+ // @__NO_SIDE_EFFECTS__
862
+ function At(e) {
863
+ var t = k | C, n = w !== null && (w.f & k) !== 0 ? (
864
+ /** @type {Derived} */
865
+ w
866
+ ) : null;
867
+ return y !== null && (y.f |= Te), {
868
+ ctx: F,
869
+ deps: null,
870
+ effects: null,
871
+ equals: en,
872
+ f: t,
873
+ fn: e,
874
+ reactions: null,
875
+ rv: 0,
876
+ v: (
877
+ /** @type {V} */
878
+ O
879
+ ),
880
+ wv: 0,
881
+ parent: n ?? y,
882
+ ac: null
883
+ };
884
+ }
885
+ // @__NO_SIDE_EFFECTS__
886
+ function Or(e, t, n) {
887
+ let r = (
888
+ /** @type {Effect | null} */
889
+ y
890
+ );
891
+ r === null && sr();
892
+ var i = (
893
+ /** @type {Boundary} */
894
+ r.b
895
+ ), s = (
896
+ /** @type {Promise<V>} */
897
+ /** @type {unknown} */
898
+ void 0
899
+ ), l = Ye(
900
+ /** @type {V} */
901
+ O
902
+ ), o = !w, f = /* @__PURE__ */ new Map();
903
+ return Hr(() => {
904
+ var a = Kt();
905
+ s = a.promise;
906
+ try {
907
+ Promise.resolve(e()).then(a.resolve, a.reject).then(() => {
908
+ d === x && d.committed && d.deactivate(), _t();
909
+ });
910
+ } catch (v) {
911
+ a.reject(v), _t();
912
+ }
913
+ var d = (
914
+ /** @type {Batch} */
915
+ x
916
+ );
917
+ if (o) {
918
+ var c = i.is_rendered();
919
+ i.update_pending_count(1), d.increment(c), f.get(d)?.reject(pe), f.delete(d), f.set(d, a);
920
+ }
921
+ const u = (v, m = void 0) => {
922
+ if (d.activate(), m)
923
+ m !== pe && (l.f |= ce, tt(l, m));
924
+ else {
925
+ (l.f & ce) !== 0 && (l.f ^= ce), tt(l, v);
926
+ for (const [g, b] of f) {
927
+ if (f.delete(g), g === d) break;
928
+ b.reject(pe);
929
+ }
930
+ }
931
+ o && (i.update_pending_count(-1), d.decrement(c));
932
+ };
933
+ a.promise.then(u, (v) => u(null, v || "unknown"));
934
+ }), Ur(() => {
935
+ for (const a of f.values())
936
+ a.reject(pe);
937
+ }), new Promise((a) => {
938
+ function d(c) {
939
+ function u() {
940
+ c === s ? a(l) : d(s);
941
+ }
942
+ c.then(u, u);
943
+ }
944
+ d(s);
945
+ });
946
+ }
947
+ // @__NO_SIDE_EFFECTS__
948
+ function kr(e) {
949
+ const t = /* @__PURE__ */ At(e);
950
+ return t.equals = tn, t;
951
+ }
952
+ function Cr(e) {
953
+ var t = e.effects;
954
+ if (t !== null) {
955
+ e.effects = null;
956
+ for (var n = 0; n < t.length; n += 1)
957
+ L(
958
+ /** @type {Effect} */
959
+ t[n]
960
+ );
961
+ }
962
+ }
963
+ function Mr(e) {
964
+ for (var t = e.parent; t !== null; ) {
965
+ if ((t.f & k) === 0)
966
+ return (t.f & ie) === 0 ? (
967
+ /** @type {Effect} */
968
+ t
969
+ ) : null;
970
+ t = t.parent;
971
+ }
972
+ return null;
973
+ }
974
+ function Rt(e) {
975
+ var t, n = y;
976
+ Z(Mr(e));
977
+ try {
978
+ e.f &= ~Ee, Cr(e), t = Cn(e);
979
+ } finally {
980
+ Z(n);
981
+ }
982
+ return t;
983
+ }
984
+ function dn(e) {
985
+ var t = Rt(e);
986
+ if (!e.equals(t) && (e.wv = On(), (!x?.is_fork || e.deps === null) && (e.v = t, e.deps === null))) {
987
+ S(e, R);
988
+ return;
989
+ }
990
+ he || (H !== null ? (kt() || x?.is_fork) && H.set(e, t) : Nt(e));
991
+ }
992
+ function Pr(e) {
993
+ if (e.effects !== null)
994
+ for (const t of e.effects)
995
+ (t.teardown || t.ac) && (t.teardown?.(), t.ac?.abort(pe), t.teardown = nr, t.ac = null, Ve(t, 0), Mt(t));
996
+ }
997
+ function hn(e) {
998
+ if (e.effects !== null)
999
+ for (const t of e.effects)
1000
+ t.teardown && Pe(t);
1001
+ }
1002
+ let pt = /* @__PURE__ */ new Set();
1003
+ const de = /* @__PURE__ */ new Map();
1004
+ let vn = !1;
1005
+ function Ye(e, t) {
1006
+ var n = {
1007
+ f: 0,
1008
+ // TODO ideally we could skip this altogether, but it causes type errors
1009
+ v: e,
1010
+ reactions: null,
1011
+ equals: en,
1012
+ rv: 0,
1013
+ wv: 0
1014
+ };
1015
+ return n;
1016
+ }
1017
+ // @__NO_SIDE_EFFECTS__
1018
+ function M(e, t) {
1019
+ const n = Ye(e);
1020
+ return Gr(n), n;
1021
+ }
1022
+ // @__NO_SIDE_EFFECTS__
1023
+ function Dr(e, t = !1, n = !0) {
1024
+ const r = Ye(e);
1025
+ return t || (r.equals = tn), r;
1026
+ }
1027
+ function $(e, t, n = !1) {
1028
+ w !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1029
+ // to ensure we error if state is set inside an inspect effect
1030
+ (!z || (w.f & Dt) !== 0) && nn() && (w.f & (k | le | bt | Dt)) !== 0 && (B === null || !Oe.call(B, e)) && vr();
1031
+ let r = n ? Ae(t) : t;
1032
+ return tt(e, r);
1033
+ }
1034
+ function tt(e, t) {
1035
+ if (!e.equals(t)) {
1036
+ var n = e.v;
1037
+ he ? de.set(e, t) : de.set(e, n), e.v = t;
1038
+ var r = se.ensure();
1039
+ if (r.capture(e, n), (e.f & k) !== 0) {
1040
+ const i = (
1041
+ /** @type {Derived} */
1042
+ e
1043
+ );
1044
+ (e.f & C) !== 0 && Rt(i), Nt(i);
1045
+ }
1046
+ e.wv = On(), _n(e, C), y !== null && (y.f & R) !== 0 && (y.f & (X | ve)) === 0 && (q === null ? Wr([e]) : q.push(e)), !r.is_fork && pt.size > 0 && !vn && Lr();
1047
+ }
1048
+ return t;
1049
+ }
1050
+ function Lr() {
1051
+ vn = !1;
1052
+ for (const e of pt)
1053
+ (e.f & R) !== 0 && S(e, K), ze(e) && Pe(e);
1054
+ pt.clear();
1055
+ }
1056
+ function qe(e) {
1057
+ $(e, e.v + 1);
1058
+ }
1059
+ function _n(e, t) {
1060
+ var n = e.reactions;
1061
+ if (n !== null)
1062
+ for (var r = n.length, i = 0; i < r; i++) {
1063
+ var s = n[i], l = s.f, o = (l & C) === 0;
1064
+ if (o && S(s, t), (l & k) !== 0) {
1065
+ var f = (
1066
+ /** @type {Derived} */
1067
+ s
1068
+ );
1069
+ H?.delete(f), (l & Ee) === 0 && (l & U && (s.f |= Ee), _n(f, K));
1070
+ } else o && ((l & le) !== 0 && te !== null && te.add(
1071
+ /** @type {Effect} */
1072
+ s
1073
+ ), Y(
1074
+ /** @type {Effect} */
1075
+ s
1076
+ ));
1077
+ }
1078
+ }
1079
+ function Ae(e) {
1080
+ if (typeof e != "object" || e === null || Ie in e)
1081
+ return e;
1082
+ const t = tr(e);
1083
+ if (t !== Qn && t !== er)
1084
+ return e;
1085
+ var n = /* @__PURE__ */ new Map(), r = zt(e), i = /* @__PURE__ */ M(0), s = ye, l = (o) => {
1086
+ if (ye === s)
1087
+ return o();
1088
+ var f = w, a = ye;
1089
+ V(null), jt(s);
1090
+ var d = o();
1091
+ return V(f), jt(a), d;
1092
+ };
1093
+ return r && n.set("length", /* @__PURE__ */ M(
1094
+ /** @type {any[]} */
1095
+ e.length
1096
+ )), new Proxy(
1097
+ /** @type {any} */
1098
+ e,
1099
+ {
1100
+ defineProperty(o, f, a) {
1101
+ (!("value" in a) || a.configurable === !1 || a.enumerable === !1 || a.writable === !1) && dr();
1102
+ var d = n.get(f);
1103
+ return d === void 0 ? l(() => {
1104
+ var c = /* @__PURE__ */ M(a.value);
1105
+ return n.set(f, c), c;
1106
+ }) : $(d, a.value, !0), !0;
1107
+ },
1108
+ deleteProperty(o, f) {
1109
+ var a = n.get(f);
1110
+ if (a === void 0) {
1111
+ if (f in o) {
1112
+ const d = l(() => /* @__PURE__ */ M(O));
1113
+ n.set(f, d), qe(i);
1114
+ }
1115
+ } else
1116
+ $(a, O), qe(i);
1117
+ return !0;
1118
+ },
1119
+ get(o, f, a) {
1120
+ if (f === Ie)
1121
+ return e;
1122
+ var d = n.get(f), c = f in o;
1123
+ if (d === void 0 && (!c || we(o, f)?.writable) && (d = l(() => {
1124
+ var v = Ae(c ? o[f] : O), m = /* @__PURE__ */ M(v);
1125
+ return m;
1126
+ }), n.set(f, d)), d !== void 0) {
1127
+ var u = p(d);
1128
+ return u === O ? void 0 : u;
1129
+ }
1130
+ return Reflect.get(o, f, a);
1131
+ },
1132
+ getOwnPropertyDescriptor(o, f) {
1133
+ var a = Reflect.getOwnPropertyDescriptor(o, f);
1134
+ if (a && "value" in a) {
1135
+ var d = n.get(f);
1136
+ d && (a.value = p(d));
1137
+ } else if (a === void 0) {
1138
+ var c = n.get(f), u = c?.v;
1139
+ if (c !== void 0 && u !== O)
1140
+ return {
1141
+ enumerable: !0,
1142
+ configurable: !0,
1143
+ value: u,
1144
+ writable: !0
1145
+ };
1146
+ }
1147
+ return a;
1148
+ },
1149
+ has(o, f) {
1150
+ if (f === Ie)
1151
+ return !0;
1152
+ var a = n.get(f), d = a !== void 0 && a.v !== O || Reflect.has(o, f);
1153
+ if (a !== void 0 || y !== null && (!d || we(o, f)?.writable)) {
1154
+ a === void 0 && (a = l(() => {
1155
+ var u = d ? Ae(o[f]) : O, v = /* @__PURE__ */ M(u);
1156
+ return v;
1157
+ }), n.set(f, a));
1158
+ var c = p(a);
1159
+ if (c === O)
1160
+ return !1;
1161
+ }
1162
+ return d;
1163
+ },
1164
+ set(o, f, a, d) {
1165
+ var c = n.get(f), u = f in o;
1166
+ if (r && f === "length")
1167
+ for (var v = a; v < /** @type {Source<number>} */
1168
+ c.v; v += 1) {
1169
+ var m = n.get(v + "");
1170
+ m !== void 0 ? $(m, O) : v in o && (m = l(() => /* @__PURE__ */ M(O)), n.set(v + "", m));
1171
+ }
1172
+ if (c === void 0)
1173
+ (!u || we(o, f)?.writable) && (c = l(() => /* @__PURE__ */ M(void 0)), $(c, Ae(a)), n.set(f, c));
1174
+ else {
1175
+ u = c.v !== O;
1176
+ var g = l(() => Ae(a));
1177
+ $(c, g);
1178
+ }
1179
+ var b = Reflect.getOwnPropertyDescriptor(o, f);
1180
+ if (b?.set && b.set.call(d, a), !u) {
1181
+ if (r && typeof f == "string") {
1182
+ var I = (
1183
+ /** @type {Source<number>} */
1184
+ n.get("length")
1185
+ ), N = Number(f);
1186
+ Number.isInteger(N) && N >= I.v && $(I, N + 1);
1187
+ }
1188
+ qe(i);
1189
+ }
1190
+ return !0;
1191
+ },
1192
+ ownKeys(o) {
1193
+ p(i);
1194
+ var f = Reflect.ownKeys(o).filter((c) => {
1195
+ var u = n.get(c);
1196
+ return u === void 0 || u.v !== O;
1197
+ });
1198
+ for (var [a, d] of n)
1199
+ d.v !== O && !(a in o) && f.push(a);
1200
+ return f;
1201
+ },
1202
+ setPrototypeOf() {
1203
+ hr();
1204
+ }
1205
+ }
1206
+ );
1207
+ }
1208
+ var Ft, pn, mn, gn;
1209
+ function mt() {
1210
+ if (Ft === void 0) {
1211
+ Ft = window, pn = /Firefox/.test(navigator.userAgent);
1212
+ var e = Element.prototype, t = Node.prototype, n = Text.prototype;
1213
+ mn = we(t, "firstChild").get, gn = we(t, "nextSibling").get, Pt(e) && (e.__click = void 0, e.__className = void 0, e.__attributes = null, e.__style = void 0, e.__e = void 0), Pt(n) && (n.__t = void 0);
1214
+ }
1215
+ }
1216
+ function xe(e = "") {
1217
+ return document.createTextNode(e);
1218
+ }
1219
+ // @__NO_SIDE_EFFECTS__
1220
+ function nt(e) {
1221
+ return (
1222
+ /** @type {TemplateNode | null} */
1223
+ mn.call(e)
1224
+ );
1225
+ }
1226
+ // @__NO_SIDE_EFFECTS__
1227
+ function _e(e) {
1228
+ return (
1229
+ /** @type {TemplateNode | null} */
1230
+ gn.call(e)
1231
+ );
1232
+ }
1233
+ function ae(e, t) {
1234
+ if (!A)
1235
+ return /* @__PURE__ */ nt(e);
1236
+ var n = /* @__PURE__ */ nt(T);
1237
+ if (n === null)
1238
+ n = T.appendChild(xe());
1239
+ else if (t && n.nodeType !== Et) {
1240
+ var r = xe();
1241
+ return n?.before(r), J(r), r;
1242
+ }
1243
+ return t && wn(
1244
+ /** @type {Text} */
1245
+ n
1246
+ ), J(n), n;
1247
+ }
1248
+ function rt(e, t = 1, n = !1) {
1249
+ let r = A ? T : e;
1250
+ for (var i; t--; )
1251
+ i = r, r = /** @type {TemplateNode} */
1252
+ /* @__PURE__ */ _e(r);
1253
+ if (!A)
1254
+ return r;
1255
+ if (n) {
1256
+ if (r?.nodeType !== Et) {
1257
+ var s = xe();
1258
+ return r === null ? i?.after(s) : r.before(s), J(s), s;
1259
+ }
1260
+ wn(
1261
+ /** @type {Text} */
1262
+ r
1263
+ );
1264
+ }
1265
+ return J(r), r;
1266
+ }
1267
+ function Fr(e) {
1268
+ e.textContent = "";
1269
+ }
1270
+ function Ir() {
1271
+ return !1;
1272
+ }
1273
+ function Ot(e, t, n) {
1274
+ return (
1275
+ /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */
1276
+ document.createElementNS(Jn, e, void 0)
1277
+ );
1278
+ }
1279
+ function wn(e) {
1280
+ if (
1281
+ /** @type {string} */
1282
+ e.nodeValue.length < 65536
1283
+ )
1284
+ return;
1285
+ let t = e.nextSibling;
1286
+ for (; t !== null && t.nodeType === Et; )
1287
+ t.remove(), e.nodeValue += /** @type {string} */
1288
+ t.nodeValue, t = e.nextSibling;
1289
+ }
1290
+ function $n(e) {
1291
+ var t = w, n = y;
1292
+ V(null), Z(null);
1293
+ try {
1294
+ return e();
1295
+ } finally {
1296
+ V(t), Z(n);
1297
+ }
1298
+ }
1299
+ function jr(e) {
1300
+ y === null && (w === null && fr(), or()), he && lr();
1301
+ }
1302
+ function qr(e, t) {
1303
+ var n = t.last;
1304
+ n === null ? t.last = t.first = e : (n.next = e, e.prev = n, t.last = e);
1305
+ }
1306
+ function Q(e, t, n) {
1307
+ var r = y;
1308
+ r !== null && (r.f & W) !== 0 && (e |= W);
1309
+ var i = {
1310
+ ctx: F,
1311
+ deps: null,
1312
+ nodes: null,
1313
+ f: e | C | U,
1314
+ first: null,
1315
+ fn: t,
1316
+ last: null,
1317
+ next: null,
1318
+ parent: r,
1319
+ b: r && r.b,
1320
+ prev: null,
1321
+ teardown: null,
1322
+ wv: 0,
1323
+ ac: null
1324
+ };
1325
+ if (n)
1326
+ try {
1327
+ Pe(i);
1328
+ } catch (o) {
1329
+ throw L(i), o;
1330
+ }
1331
+ else t !== null && Y(i);
1332
+ var s = i;
1333
+ if (n && s.deps === null && s.teardown === null && s.nodes === null && s.first === s.last && // either `null`, or a singular child
1334
+ (s.f & Te) === 0 && (s = s.first, (e & le) !== 0 && (e & ke) !== 0 && s !== null && (s.f |= ke)), s !== null && (s.parent = r, r !== null && qr(s, r), w !== null && (w.f & k) !== 0 && (e & ve) === 0)) {
1335
+ var l = (
1336
+ /** @type {Derived} */
1337
+ w
1338
+ );
1339
+ (l.effects ??= []).push(s);
1340
+ }
1341
+ return i;
1342
+ }
1343
+ function kt() {
1344
+ return w !== null && !z;
1345
+ }
1346
+ function Ur(e) {
1347
+ const t = Q(ot, null, !1);
1348
+ return S(t, R), t.teardown = e, t;
1349
+ }
1350
+ function G(e) {
1351
+ jr();
1352
+ var t = (
1353
+ /** @type {Effect} */
1354
+ y.f
1355
+ ), n = !w && (t & X) !== 0 && (t & De) === 0;
1356
+ if (n) {
1357
+ var r = (
1358
+ /** @type {ComponentContext} */
1359
+ F
1360
+ );
1361
+ (r.e ??= []).push(e);
1362
+ } else
1363
+ return yn(e);
1364
+ }
1365
+ function yn(e) {
1366
+ return Q(Be | ir, e, !1);
1367
+ }
1368
+ function Br(e) {
1369
+ se.ensure();
1370
+ const t = Q(ve | Te, e, !0);
1371
+ return () => {
1372
+ L(t);
1373
+ };
1374
+ }
1375
+ function Vr(e) {
1376
+ se.ensure();
1377
+ const t = Q(ve | Te, e, !0);
1378
+ return (n = {}) => new Promise((r) => {
1379
+ n.outro ? Ue(t, () => {
1380
+ L(t), r(void 0);
1381
+ }) : (L(t), r(void 0));
1382
+ });
1383
+ }
1384
+ function bn(e) {
1385
+ return Q(Be, e, !1);
1386
+ }
1387
+ function Hr(e) {
1388
+ return Q(bt | Te, e, !0);
1389
+ }
1390
+ function Ct(e, t = 0) {
1391
+ return Q(ot | t, e, !0);
1392
+ }
1393
+ function it(e, t = [], n = [], r = []) {
1394
+ Ar(r, t, n, (i) => {
1395
+ Q(ot, () => e(...i.map(p)), !0);
1396
+ });
1397
+ }
1398
+ function En(e, t = 0) {
1399
+ var n = Q(le | t, e, !0);
1400
+ return n;
1401
+ }
1402
+ function ne(e) {
1403
+ return Q(X | Te, e, !0);
1404
+ }
1405
+ function xn(e) {
1406
+ var t = e.teardown;
1407
+ if (t !== null) {
1408
+ const n = he, r = w;
1409
+ It(!0), V(null);
1410
+ try {
1411
+ t.call(null);
1412
+ } finally {
1413
+ It(n), V(r);
1414
+ }
1415
+ }
1416
+ }
1417
+ function Mt(e, t = !1) {
1418
+ var n = e.first;
1419
+ for (e.first = e.last = null; n !== null; ) {
1420
+ const i = n.ac;
1421
+ i !== null && $n(() => {
1422
+ i.abort(pe);
1423
+ });
1424
+ var r = n.next;
1425
+ (n.f & ve) !== 0 ? n.parent = null : L(n, t), n = r;
1426
+ }
1427
+ }
1428
+ function Yr(e) {
1429
+ for (var t = e.first; t !== null; ) {
1430
+ var n = t.next;
1431
+ (t.f & X) === 0 && L(t), t = n;
1432
+ }
1433
+ }
1434
+ function L(e, t = !0) {
1435
+ var n = !1;
1436
+ (t || (e.f & Jt) !== 0) && e.nodes !== null && e.nodes.end !== null && (zr(
1437
+ e.nodes.start,
1438
+ /** @type {TemplateNode} */
1439
+ e.nodes.end
1440
+ ), n = !0), Mt(e, t && !n), Ve(e, 0), S(e, ie);
1441
+ var r = e.nodes && e.nodes.t;
1442
+ if (r !== null)
1443
+ for (const s of r)
1444
+ s.stop();
1445
+ xn(e);
1446
+ var i = e.parent;
1447
+ i !== null && i.first !== null && Tn(e), e.next = e.prev = e.teardown = e.ctx = e.deps = e.fn = e.nodes = e.ac = null;
1448
+ }
1449
+ function zr(e, t) {
1450
+ for (; e !== null; ) {
1451
+ var n = e === t ? null : /* @__PURE__ */ _e(e);
1452
+ e.remove(), e = n;
1453
+ }
1454
+ }
1455
+ function Tn(e) {
1456
+ var t = e.parent, n = e.prev, r = e.next;
1457
+ n !== null && (n.next = r), r !== null && (r.prev = n), t !== null && (t.first === e && (t.first = r), t.last === e && (t.last = n));
1458
+ }
1459
+ function Ue(e, t, n = !0) {
1460
+ var r = [];
1461
+ Sn(e, r, !0);
1462
+ var i = () => {
1463
+ n && L(e), t && t();
1464
+ }, s = r.length;
1465
+ if (s > 0) {
1466
+ var l = () => --s || i();
1467
+ for (var o of r)
1468
+ o.out(l);
1469
+ } else
1470
+ i();
1471
+ }
1472
+ function Sn(e, t, n) {
1473
+ if ((e.f & W) === 0) {
1474
+ e.f ^= W;
1475
+ var r = e.nodes && e.nodes.t;
1476
+ if (r !== null)
1477
+ for (const o of r)
1478
+ (o.is_global || n) && t.push(o);
1479
+ for (var i = e.first; i !== null; ) {
1480
+ var s = i.next, l = (i.f & ke) !== 0 || // If this is a branch effect without a block effect parent,
1481
+ // it means the parent block effect was pruned. In that case,
1482
+ // transparency information was transferred to the branch effect.
1483
+ (i.f & X) !== 0 && (e.f & le) !== 0;
1484
+ Sn(i, t, l ? n : !1), i = s;
1485
+ }
1486
+ }
1487
+ }
1488
+ function Kr(e) {
1489
+ Nn(e, !0);
1490
+ }
1491
+ function Nn(e, t) {
1492
+ if ((e.f & W) !== 0) {
1493
+ e.f ^= W, (e.f & R) === 0 && (S(e, C), Y(e));
1494
+ for (var n = e.first; n !== null; ) {
1495
+ var r = n.next, i = (n.f & ke) !== 0 || (n.f & X) !== 0;
1496
+ Nn(n, i ? t : !1), n = r;
1497
+ }
1498
+ var s = e.nodes && e.nodes.t;
1499
+ if (s !== null)
1500
+ for (const l of s)
1501
+ (l.is_global || t) && l.in();
1502
+ }
1503
+ }
1504
+ function An(e, t) {
1505
+ if (e.nodes)
1506
+ for (var n = e.nodes.start, r = e.nodes.end; n !== null; ) {
1507
+ var i = n === r ? null : /* @__PURE__ */ _e(n);
1508
+ t.append(n), n = i;
1509
+ }
1510
+ }
1511
+ let Ze = !1, he = !1;
1512
+ function It(e) {
1513
+ he = e;
1514
+ }
1515
+ let w = null, z = !1;
1516
+ function V(e) {
1517
+ w = e;
1518
+ }
1519
+ let y = null;
1520
+ function Z(e) {
1521
+ y = e;
1522
+ }
1523
+ let B = null;
1524
+ function Gr(e) {
1525
+ w !== null && (B === null ? B = [e] : B.push(e));
1526
+ }
1527
+ let D = null, j = 0, q = null;
1528
+ function Wr(e) {
1529
+ q = e;
1530
+ }
1531
+ let Rn = 1, ge = 0, ye = ge;
1532
+ function jt(e) {
1533
+ ye = e;
1534
+ }
1535
+ function On() {
1536
+ return ++Rn;
1537
+ }
1538
+ function ze(e) {
1539
+ var t = e.f;
1540
+ if ((t & C) !== 0)
1541
+ return !0;
1542
+ if (t & k && (e.f &= ~Ee), (t & K) !== 0) {
1543
+ for (var n = (
1544
+ /** @type {Value[]} */
1545
+ e.deps
1546
+ ), r = n.length, i = 0; i < r; i++) {
1547
+ var s = n[i];
1548
+ if (ze(
1549
+ /** @type {Derived} */
1550
+ s
1551
+ ) && dn(
1552
+ /** @type {Derived} */
1553
+ s
1554
+ ), s.wv > e.wv)
1555
+ return !0;
1556
+ }
1557
+ (t & U) !== 0 && // During time traveling we don't want to reset the status so that
1558
+ // traversal of the graph in the other batches still happens
1559
+ H === null && S(e, R);
1560
+ }
1561
+ return !1;
1562
+ }
1563
+ function kn(e, t, n = !0) {
1564
+ var r = e.reactions;
1565
+ if (r !== null && !(B !== null && Oe.call(B, e)))
1566
+ for (var i = 0; i < r.length; i++) {
1567
+ var s = r[i];
1568
+ (s.f & k) !== 0 ? kn(
1569
+ /** @type {Derived} */
1570
+ s,
1571
+ t,
1572
+ !1
1573
+ ) : t === s && (n ? S(s, C) : (s.f & R) !== 0 && S(s, K), Y(
1574
+ /** @type {Effect} */
1575
+ s
1576
+ ));
1577
+ }
1578
+ }
1579
+ function Cn(e) {
1580
+ var t = D, n = j, r = q, i = w, s = B, l = F, o = z, f = ye, a = e.f;
1581
+ D = /** @type {null | Value[]} */
1582
+ null, j = 0, q = null, w = (a & (X | ve)) === 0 ? e : null, B = null, Ce(e.ctx), z = !1, ye = ++ge, e.ac !== null && ($n(() => {
1583
+ e.ac.abort(pe);
1584
+ }), e.ac = null);
1585
+ try {
1586
+ e.f |= ht;
1587
+ var d = (
1588
+ /** @type {Function} */
1589
+ e.fn
1590
+ ), c = d();
1591
+ e.f |= De;
1592
+ var u = e.deps, v = x?.is_fork;
1593
+ if (D !== null) {
1594
+ var m;
1595
+ if (v || Ve(e, j), u !== null && j > 0)
1596
+ for (u.length = j + D.length, m = 0; m < D.length; m++)
1597
+ u[j + m] = D[m];
1598
+ else
1599
+ e.deps = u = D;
1600
+ if (kt() && (e.f & U) !== 0)
1601
+ for (m = j; m < u.length; m++)
1602
+ (u[m].reactions ??= []).push(e);
1603
+ } else !v && u !== null && j < u.length && (Ve(e, j), u.length = j);
1604
+ if (nn() && q !== null && !z && u !== null && (e.f & (k | K | C)) === 0)
1605
+ for (m = 0; m < /** @type {Source[]} */
1606
+ q.length; m++)
1607
+ kn(
1608
+ q[m],
1609
+ /** @type {Effect} */
1610
+ e
1611
+ );
1612
+ if (i !== null && i !== e) {
1613
+ if (ge++, i.deps !== null)
1614
+ for (let g = 0; g < n; g += 1)
1615
+ i.deps[g].rv = ge;
1616
+ if (t !== null)
1617
+ for (const g of t)
1618
+ g.rv = ge;
1619
+ q !== null && (r === null ? r = q : r.push(.../** @type {Source[]} */
1620
+ q));
1621
+ }
1622
+ return (e.f & ce) !== 0 && (e.f ^= ce), c;
1623
+ } catch (g) {
1624
+ return sn(g);
1625
+ } finally {
1626
+ e.f ^= ht, D = t, j = n, q = r, w = i, B = s, Ce(l), z = o, ye = f;
1627
+ }
1628
+ }
1629
+ function Jr(e, t) {
1630
+ let n = t.reactions;
1631
+ if (n !== null) {
1632
+ var r = Zn.call(n, e);
1633
+ if (r !== -1) {
1634
+ var i = n.length - 1;
1635
+ i === 0 ? n = t.reactions = null : (n[r] = n[i], n.pop());
1636
+ }
1637
+ }
1638
+ if (n === null && (t.f & k) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
1639
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
1640
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
1641
+ (D === null || !Oe.call(D, t))) {
1642
+ var s = (
1643
+ /** @type {Derived} */
1644
+ t
1645
+ );
1646
+ (s.f & U) !== 0 && (s.f ^= U, s.f &= ~Ee), Nt(s), Pr(s), Ve(s, 0);
1647
+ }
1648
+ }
1649
+ function Ve(e, t) {
1650
+ var n = e.deps;
1651
+ if (n !== null)
1652
+ for (var r = t; r < n.length; r++)
1653
+ Jr(e, n[r]);
1654
+ }
1655
+ function Pe(e) {
1656
+ var t = e.f;
1657
+ if ((t & ie) === 0) {
1658
+ S(e, R);
1659
+ var n = y, r = Ze;
1660
+ y = e, Ze = !0;
1661
+ try {
1662
+ (t & (le | Gt)) !== 0 ? Yr(e) : Mt(e), xn(e);
1663
+ var i = Cn(e);
1664
+ e.teardown = typeof i == "function" ? i : null, e.wv = Rn;
1665
+ var s;
1666
+ dt && $r && (e.f & C) !== 0 && e.deps;
1667
+ } finally {
1668
+ Ze = r, y = n;
1669
+ }
1670
+ }
1671
+ }
1672
+ function p(e) {
1673
+ var t = e.f, n = (t & k) !== 0;
1674
+ if (w !== null && !z) {
1675
+ var r = y !== null && (y.f & ie) !== 0;
1676
+ if (!r && (B === null || !Oe.call(B, e))) {
1677
+ var i = w.deps;
1678
+ if ((w.f & ht) !== 0)
1679
+ e.rv < ge && (e.rv = ge, D === null && i !== null && i[j] === e ? j++ : D === null ? D = [e] : D.push(e));
1680
+ else {
1681
+ (w.deps ??= []).push(e);
1682
+ var s = e.reactions;
1683
+ s === null ? e.reactions = [w] : Oe.call(s, w) || s.push(w);
1684
+ }
1685
+ }
1686
+ }
1687
+ if (he && de.has(e))
1688
+ return de.get(e);
1689
+ if (n) {
1690
+ var l = (
1691
+ /** @type {Derived} */
1692
+ e
1693
+ );
1694
+ if (he) {
1695
+ var o = l.v;
1696
+ return ((l.f & R) === 0 && l.reactions !== null || Pn(l)) && (o = Rt(l)), de.set(l, o), o;
1697
+ }
1698
+ var f = (l.f & U) === 0 && !z && w !== null && (Ze || (w.f & U) !== 0), a = (l.f & De) === 0;
1699
+ ze(l) && (f && (l.f |= U), dn(l)), f && !a && (hn(l), Mn(l));
1700
+ }
1701
+ if (H?.has(e))
1702
+ return H.get(e);
1703
+ if ((e.f & ce) !== 0)
1704
+ throw e.v;
1705
+ return e.v;
1706
+ }
1707
+ function Mn(e) {
1708
+ if (e.f |= U, e.deps !== null)
1709
+ for (const t of e.deps)
1710
+ (t.reactions ??= []).push(e), (t.f & k) !== 0 && (t.f & U) === 0 && (hn(
1711
+ /** @type {Derived} */
1712
+ t
1713
+ ), Mn(
1714
+ /** @type {Derived} */
1715
+ t
1716
+ ));
1717
+ }
1718
+ function Pn(e) {
1719
+ if (e.v === O) return !0;
1720
+ if (e.deps === null) return !1;
1721
+ for (const t of e.deps)
1722
+ if (de.has(t) || (t.f & k) !== 0 && Pn(
1723
+ /** @type {Derived} */
1724
+ t
1725
+ ))
1726
+ return !0;
1727
+ return !1;
1728
+ }
1729
+ function ut(e) {
1730
+ var t = z;
1731
+ try {
1732
+ return z = !0, e();
1733
+ } finally {
1734
+ z = t;
1735
+ }
1736
+ }
1737
+ const Zr = /* @__PURE__ */ new Set(), qt = /* @__PURE__ */ new Set();
1738
+ let Ut = null;
1739
+ function Bt(e) {
1740
+ var t = this, n = (
1741
+ /** @type {Node} */
1742
+ t.ownerDocument
1743
+ ), r = e.type, i = e.composedPath?.() || [], s = (
1744
+ /** @type {null | Element} */
1745
+ i[0] || e.target
1746
+ );
1747
+ Ut = e;
1748
+ var l = 0, o = Ut === e && e.__root;
1749
+ if (o) {
1750
+ var f = i.indexOf(o);
1751
+ if (f !== -1 && (t === document || t === /** @type {any} */
1752
+ window)) {
1753
+ e.__root = t;
1754
+ return;
1755
+ }
1756
+ var a = i.indexOf(t);
1757
+ if (a === -1)
1758
+ return;
1759
+ f <= a && (l = f);
1760
+ }
1761
+ if (s = /** @type {Element} */
1762
+ i[l] || e.target, s !== t) {
1763
+ et(e, "currentTarget", {
1764
+ configurable: !0,
1765
+ get() {
1766
+ return s || n;
1767
+ }
1768
+ });
1769
+ var d = w, c = y;
1770
+ V(null), Z(null);
1771
+ try {
1772
+ for (var u, v = []; s !== null; ) {
1773
+ var m = s.assignedSlot || s.parentNode || /** @type {any} */
1774
+ s.host || null;
1775
+ try {
1776
+ var g = s["__" + r];
1777
+ g != null && (!/** @type {any} */
1778
+ s.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
1779
+ // -> the target could not have been disabled because it emits the event in the first place
1780
+ e.target === s) && g.call(s, e);
1781
+ } catch (b) {
1782
+ u ? v.push(b) : u = b;
1783
+ }
1784
+ if (e.cancelBubble || m === t || m === null)
1785
+ break;
1786
+ s = m;
1787
+ }
1788
+ if (u) {
1789
+ for (let b of v)
1790
+ queueMicrotask(() => {
1791
+ throw b;
1792
+ });
1793
+ throw u;
1794
+ }
1795
+ } finally {
1796
+ e.__root = t, delete e.currentTarget, V(d), Z(c);
1797
+ }
1798
+ }
1799
+ }
1800
+ const Xr = /* @__PURE__ */ globalThis?.window?.trustedTypes?.createPolicy(
1801
+ "svelte-trusted-html",
1802
+ {
1803
+ /** @param {string} html */
1804
+ createHTML: (e) => e
1805
+ }
1806
+ );
1807
+ function Qr(e) {
1808
+ return (
1809
+ /** @type {string} */
1810
+ Xr?.createHTML(e) ?? e
1811
+ );
1812
+ }
1813
+ function ei(e, t = !1) {
1814
+ var n = Ot("template");
1815
+ return e = e.replaceAll("<!>", "<!---->"), n.innerHTML = t ? Qr(e) : e, n.content;
1816
+ }
1817
+ function gt(e, t) {
1818
+ var n = (
1819
+ /** @type {Effect} */
1820
+ y
1821
+ );
1822
+ n.nodes === null && (n.nodes = { start: e, end: t, a: null, t: null });
1823
+ }
1824
+ // @__NO_SIDE_EFFECTS__
1825
+ function Le(e, t) {
1826
+ var n = (t & Wn) !== 0, r, i = !e.startsWith("<!>");
1827
+ return () => {
1828
+ if (A)
1829
+ return gt(T, null), T;
1830
+ r === void 0 && (r = ei(i ? e : "<!>" + e, !0), r = /** @type {TemplateNode} */
1831
+ /* @__PURE__ */ nt(r));
1832
+ var s = (
1833
+ /** @type {TemplateNode} */
1834
+ n || pn ? document.importNode(r, !0) : r.cloneNode(!0)
1835
+ );
1836
+ return gt(s, s), s;
1837
+ };
1838
+ }
1839
+ function be(e, t) {
1840
+ if (A) {
1841
+ var n = (
1842
+ /** @type {Effect & { nodes: EffectNodes }} */
1843
+ y
1844
+ );
1845
+ ((n.f & De) === 0 || n.nodes.end === null) && (n.nodes.end = T), xt();
1846
+ return;
1847
+ }
1848
+ e !== null && e.before(
1849
+ /** @type {Node} */
1850
+ t
1851
+ );
1852
+ }
1853
+ const ti = ["touchstart", "touchmove"];
1854
+ function ni(e) {
1855
+ return ti.includes(e);
1856
+ }
1857
+ function st(e, t) {
1858
+ var n = t == null ? "" : typeof t == "object" ? t + "" : t;
1859
+ n !== (e.__t ??= e.nodeValue) && (e.__t = n, e.nodeValue = n + "");
1860
+ }
1861
+ function Dn(e, t) {
1862
+ return Ln(e, t);
1863
+ }
1864
+ function ri(e, t) {
1865
+ mt(), t.intro = t.intro ?? !1;
1866
+ const n = t.target, r = A, i = T;
1867
+ try {
1868
+ for (var s = /* @__PURE__ */ nt(n); s && (s.nodeType !== He || /** @type {Comment} */
1869
+ s.data !== $t); )
1870
+ s = /* @__PURE__ */ _e(s);
1871
+ if (!s)
1872
+ throw Re;
1873
+ Ne(!0), J(
1874
+ /** @type {Comment} */
1875
+ s
1876
+ );
1877
+ const l = Ln(e, { ...t, anchor: s });
1878
+ return Ne(!1), /** @type {Exports} */
1879
+ l;
1880
+ } catch (l) {
1881
+ if (l instanceof Error && l.message.split(`
1882
+ `).some((o) => o.startsWith("https://svelte.dev/e/")))
1883
+ throw l;
1884
+ return l !== Re && console.warn("Failed to hydrate: ", l), t.recover === !1 && ur(), mt(), Fr(n), Ne(!1), Dn(e, t);
1885
+ } finally {
1886
+ Ne(r), J(i);
1887
+ }
1888
+ }
1889
+ const Ge = /* @__PURE__ */ new Map();
1890
+ function Ln(e, { target: t, anchor: n, props: r = {}, events: i, context: s, intro: l = !0 }) {
1891
+ mt();
1892
+ var o = /* @__PURE__ */ new Set(), f = (c) => {
1893
+ for (var u = 0; u < c.length; u++) {
1894
+ var v = c[u];
1895
+ if (!o.has(v)) {
1896
+ o.add(v);
1897
+ var m = ni(v);
1898
+ for (const I of [t, document]) {
1899
+ var g = Ge.get(I);
1900
+ g === void 0 && (g = /* @__PURE__ */ new Map(), Ge.set(I, g));
1901
+ var b = g.get(v);
1902
+ b === void 0 ? (I.addEventListener(v, Bt, { passive: m }), g.set(v, 1)) : g.set(v, b + 1);
1903
+ }
1904
+ }
1905
+ }
1906
+ };
1907
+ f(Xn(Zr)), qt.add(f);
1908
+ var a = void 0, d = Vr(() => {
1909
+ var c = n ?? t.appendChild(xe());
1910
+ return Sr(
1911
+ /** @type {TemplateNode} */
1912
+ c,
1913
+ {
1914
+ pending: () => {
1915
+ }
1916
+ },
1917
+ (u) => {
1918
+ Tt({});
1919
+ var v = (
1920
+ /** @type {ComponentContext} */
1921
+ F
1922
+ );
1923
+ if (s && (v.c = s), i && (r.$$events = i), A && gt(
1924
+ /** @type {TemplateNode} */
1925
+ u,
1926
+ null
1927
+ ), a = e(u, r) || {}, A && (y.nodes.end = T, T === null || T.nodeType !== He || /** @type {Comment} */
1928
+ T.data !== Yt))
1929
+ throw ft(), Re;
1930
+ St();
1931
+ }
1932
+ ), () => {
1933
+ for (var u of o)
1934
+ for (const g of [t, document]) {
1935
+ var v = (
1936
+ /** @type {Map<string, number>} */
1937
+ Ge.get(g)
1938
+ ), m = (
1939
+ /** @type {number} */
1940
+ v.get(u)
1941
+ );
1942
+ --m == 0 ? (g.removeEventListener(u, Bt), v.delete(u), v.size === 0 && Ge.delete(g)) : v.set(u, m);
1943
+ }
1944
+ qt.delete(f), c !== n && c.parentNode?.removeChild(c);
1945
+ };
1946
+ });
1947
+ return wt.set(a, d), a;
1948
+ }
1949
+ let wt = /* @__PURE__ */ new WeakMap();
1950
+ function ii(e, t) {
1951
+ const n = wt.get(e);
1952
+ return n ? (wt.delete(e), n(t)) : Promise.resolve();
1953
+ }
1954
+ class si {
1955
+ /** @type {TemplateNode} */
1956
+ anchor;
1957
+ /** @type {Map<Batch, Key>} */
1958
+ #e = /* @__PURE__ */ new Map();
1959
+ /**
1960
+ * Map of keys to effects that are currently rendered in the DOM.
1961
+ * These effects are visible and actively part of the document tree.
1962
+ * Example:
1963
+ * ```
1964
+ * {#if condition}
1965
+ * foo
1966
+ * {:else}
1967
+ * bar
1968
+ * {/if}
1969
+ * ```
1970
+ * Can result in the entries `true->Effect` and `false->Effect`
1971
+ * @type {Map<Key, Effect>}
1972
+ */
1973
+ #t = /* @__PURE__ */ new Map();
1974
+ /**
1975
+ * Similar to #onscreen with respect to the keys, but contains branches that are not yet
1976
+ * in the DOM, because their insertion is deferred.
1977
+ * @type {Map<Key, Branch>}
1978
+ */
1979
+ #n = /* @__PURE__ */ new Map();
1980
+ /**
1981
+ * Keys of effects that are currently outroing
1982
+ * @type {Set<Key>}
1983
+ */
1984
+ #l = /* @__PURE__ */ new Set();
1985
+ /**
1986
+ * Whether to pause (i.e. outro) on change, or destroy immediately.
1987
+ * This is necessary for `<svelte:element>`
1988
+ */
1989
+ #o = !0;
1990
+ /**
1991
+ * @param {TemplateNode} anchor
1992
+ * @param {boolean} transition
1993
+ */
1994
+ constructor(t, n = !0) {
1995
+ this.anchor = t, this.#o = n;
1996
+ }
1997
+ #i = () => {
1998
+ var t = (
1999
+ /** @type {Batch} */
2000
+ x
2001
+ );
2002
+ if (this.#e.has(t)) {
2003
+ var n = (
2004
+ /** @type {Key} */
2005
+ this.#e.get(t)
2006
+ ), r = this.#t.get(n);
2007
+ if (r)
2008
+ Kr(r), this.#l.delete(n);
2009
+ else {
2010
+ var i = this.#n.get(n);
2011
+ i && (this.#t.set(n, i.effect), this.#n.delete(n), i.fragment.lastChild.remove(), this.anchor.before(i.fragment), r = i.effect);
2012
+ }
2013
+ for (const [s, l] of this.#e) {
2014
+ if (this.#e.delete(s), s === t)
2015
+ break;
2016
+ const o = this.#n.get(l);
2017
+ o && (L(o.effect), this.#n.delete(l));
2018
+ }
2019
+ for (const [s, l] of this.#t) {
2020
+ if (s === n || this.#l.has(s)) continue;
2021
+ const o = () => {
2022
+ if (Array.from(this.#e.values()).includes(s)) {
2023
+ var a = document.createDocumentFragment();
2024
+ An(l, a), a.append(xe()), this.#n.set(s, { effect: l, fragment: a });
2025
+ } else
2026
+ L(l);
2027
+ this.#l.delete(s), this.#t.delete(s);
2028
+ };
2029
+ this.#o || !r ? (this.#l.add(s), Ue(l, o, !1)) : o();
2030
+ }
2031
+ }
2032
+ };
2033
+ /**
2034
+ * @param {Batch} batch
2035
+ */
2036
+ #r = (t) => {
2037
+ this.#e.delete(t);
2038
+ const n = Array.from(this.#e.values());
2039
+ for (const [r, i] of this.#n)
2040
+ n.includes(r) || (L(i.effect), this.#n.delete(r));
2041
+ };
2042
+ /**
2043
+ *
2044
+ * @param {any} key
2045
+ * @param {null | ((target: TemplateNode) => void)} fn
2046
+ */
2047
+ ensure(t, n) {
2048
+ var r = (
2049
+ /** @type {Batch} */
2050
+ x
2051
+ ), i = Ir();
2052
+ if (n && !this.#t.has(t) && !this.#n.has(t))
2053
+ if (i) {
2054
+ var s = document.createDocumentFragment(), l = xe();
2055
+ s.append(l), this.#n.set(t, {
2056
+ effect: ne(() => n(l)),
2057
+ fragment: s
2058
+ });
2059
+ } else
2060
+ this.#t.set(
2061
+ t,
2062
+ ne(() => n(this.anchor))
2063
+ );
2064
+ if (this.#e.set(r, t), i) {
2065
+ for (const [o, f] of this.#t)
2066
+ o === t ? r.unskip_effect(f) : r.skip_effect(f);
2067
+ for (const [o, f] of this.#n)
2068
+ o === t ? r.unskip_effect(f.effect) : r.skip_effect(f.effect);
2069
+ r.oncommit(this.#i), r.ondiscard(this.#r);
2070
+ } else
2071
+ A && (this.anchor = T), this.#i();
2072
+ }
2073
+ }
2074
+ function Fn(e) {
2075
+ F === null && Xt(), G(() => {
2076
+ const t = ut(e);
2077
+ if (typeof t == "function") return (
2078
+ /** @type {() => void} */
2079
+ t
2080
+ );
2081
+ });
2082
+ }
2083
+ function li(e, t, { bubbles: n = !1, cancelable: r = !1 } = {}) {
2084
+ return new CustomEvent(e, { detail: t, bubbles: n, cancelable: r });
2085
+ }
2086
+ function oi() {
2087
+ const e = F;
2088
+ return e === null && Xt(), (t, n, r) => {
2089
+ const i = (
2090
+ /** @type {Record<string, Function | Function[]>} */
2091
+ e.s.$$events?.[
2092
+ /** @type {string} */
2093
+ t
2094
+ ]
2095
+ );
2096
+ if (i) {
2097
+ const s = zt(i) ? i.slice() : [i], l = li(
2098
+ /** @type {string} */
2099
+ t,
2100
+ n,
2101
+ r
2102
+ );
2103
+ for (const o of s)
2104
+ o.call(e.x, l);
2105
+ return !l.defaultPrevented;
2106
+ }
2107
+ return !0;
2108
+ };
2109
+ }
2110
+ function lt(e, t, n = !1) {
2111
+ A && xt();
2112
+ var r = new si(e), i = n ? ke : 0;
2113
+ function s(l, o) {
2114
+ if (A) {
2115
+ const d = gr(e);
2116
+ var f;
2117
+ if (d === $t ? f = 0 : d === yt ? f = !1 : f = parseInt(d.substring(1)), l !== f) {
2118
+ var a = Qt();
2119
+ J(a), r.anchor = a, Ne(!1), r.ensure(l, o), Ne(!0);
2120
+ return;
2121
+ }
2122
+ }
2123
+ r.ensure(l, o);
2124
+ }
2125
+ En(() => {
2126
+ var l = !1;
2127
+ t((o, f = 0) => {
2128
+ l = !0, s(f, o);
2129
+ }), l || s(!1, null);
2130
+ }, i);
2131
+ }
2132
+ function In(e, t) {
2133
+ bn(() => {
2134
+ var n = e.getRootNode(), r = (
2135
+ /** @type {ShadowRoot} */
2136
+ n.host ? (
2137
+ /** @type {ShadowRoot} */
2138
+ n
2139
+ ) : (
2140
+ /** @type {Document} */
2141
+ n.head ?? /** @type {Document} */
2142
+ n.ownerDocument.head
2143
+ )
2144
+ );
2145
+ if (!r.querySelector("#" + t.hash)) {
2146
+ const i = Ot("style");
2147
+ i.id = t.hash, i.textContent = t.code, r.appendChild(i);
2148
+ }
2149
+ });
2150
+ }
2151
+ function Vt(e, t) {
2152
+ return e === t || e?.[Ie] === t;
2153
+ }
2154
+ function jn(e = {}, t, n, r) {
2155
+ return bn(() => {
2156
+ var i, s;
2157
+ return Ct(() => {
2158
+ i = s, s = [], ut(() => {
2159
+ e !== n(...s) && (t(e, ...s), i && Vt(n(...i), e) && t(null, ...i));
2160
+ });
2161
+ }), () => {
2162
+ $e(() => {
2163
+ s && Vt(n(...s), e) && t(null, ...s);
2164
+ });
2165
+ };
2166
+ }), e;
2167
+ }
2168
+ let We = !1;
2169
+ function fi(e) {
2170
+ var t = We;
2171
+ try {
2172
+ return We = !1, [e(), We];
2173
+ } finally {
2174
+ We = t;
2175
+ }
2176
+ }
2177
+ function ue(e, t, n, r) {
2178
+ var i = (n & Kn) !== 0, s = (n & Gn) !== 0, l = (
2179
+ /** @type {V} */
2180
+ r
2181
+ ), o = !0, f = () => (o && (o = !1, l = s ? ut(
2182
+ /** @type {() => V} */
2183
+ r
2184
+ ) : (
2185
+ /** @type {V} */
2186
+ r
2187
+ )), l), a;
2188
+ if (i) {
2189
+ var d = Ie in e || Zt in e;
2190
+ a = we(e, t)?.set ?? (d && t in e ? (N) => e[t] = N : void 0);
2191
+ }
2192
+ var c, u = !1;
2193
+ i ? [c, u] = fi(() => (
2194
+ /** @type {V} */
2195
+ e[t]
2196
+ )) : c = /** @type {V} */
2197
+ e[t], c === void 0 && r !== void 0 && (c = f(), a && (cr(), a(c)));
2198
+ var v;
2199
+ if (v = () => {
2200
+ var N = (
2201
+ /** @type {V} */
2202
+ e[t]
2203
+ );
2204
+ return N === void 0 ? f() : (o = !0, N);
2205
+ }, (n & zn) === 0)
2206
+ return v;
2207
+ if (a) {
2208
+ var m = e.$$legacy;
2209
+ return (
2210
+ /** @type {() => V} */
2211
+ (function(N, oe) {
2212
+ return arguments.length > 0 ? ((!oe || m || u) && a(oe ? v() : N), N) : v();
2213
+ })
2214
+ );
2215
+ }
2216
+ var g = !1, b = ((n & Yn) !== 0 ? At : kr)(() => (g = !1, v()));
2217
+ i && p(b);
2218
+ var I = (
2219
+ /** @type {Effect} */
2220
+ y
2221
+ );
2222
+ return (
2223
+ /** @type {() => V} */
2224
+ (function(N, oe) {
2225
+ if (arguments.length > 0) {
2226
+ const _ = oe ? p(b) : i ? Ae(N) : N;
2227
+ return $(b, _), g = !0, l !== void 0 && (l = _), N;
2228
+ }
2229
+ return he && g || (I.f & ie) !== 0 ? b.v : p(b);
2230
+ })
2231
+ );
2232
+ }
2233
+ function ai(e) {
2234
+ return new ui(e);
2235
+ }
2236
+ class ui {
2237
+ /** @type {any} */
2238
+ #e;
2239
+ /** @type {Record<string, any>} */
2240
+ #t;
2241
+ /**
2242
+ * @param {ComponentConstructorOptions & {
2243
+ * component: any;
2244
+ * }} options
2245
+ */
2246
+ constructor(t) {
2247
+ var n = /* @__PURE__ */ new Map(), r = (s, l) => {
2248
+ var o = /* @__PURE__ */ Dr(l, !1, !1);
2249
+ return n.set(s, o), o;
2250
+ };
2251
+ const i = new Proxy(
2252
+ { ...t.props || {}, $$events: {} },
2253
+ {
2254
+ get(s, l) {
2255
+ return p(n.get(l) ?? r(l, Reflect.get(s, l)));
2256
+ },
2257
+ has(s, l) {
2258
+ return l === Zt ? !0 : (p(n.get(l) ?? r(l, Reflect.get(s, l))), Reflect.has(s, l));
2259
+ },
2260
+ set(s, l, o) {
2261
+ return $(n.get(l) ?? r(l, o), o), Reflect.set(s, l, o);
2262
+ }
2263
+ }
2264
+ );
2265
+ this.#t = (t.hydrate ? ri : Dn)(t.component, {
2266
+ target: t.target,
2267
+ anchor: t.anchor,
2268
+ props: i,
2269
+ context: t.context,
2270
+ intro: t.intro ?? !1,
2271
+ recover: t.recover
2272
+ }), (!t?.props?.$$host || t.sync === !1) && re(), this.#e = i.$$events;
2273
+ for (const s of Object.keys(this.#t))
2274
+ s === "$set" || s === "$destroy" || s === "$on" || et(this, s, {
2275
+ get() {
2276
+ return this.#t[s];
2277
+ },
2278
+ /** @param {any} value */
2279
+ set(l) {
2280
+ this.#t[s] = l;
2281
+ },
2282
+ enumerable: !0
2283
+ });
2284
+ this.#t.$set = /** @param {Record<string, any>} next */
2285
+ (s) => {
2286
+ Object.assign(i, s);
2287
+ }, this.#t.$destroy = () => {
2288
+ ii(this.#t);
2289
+ };
2290
+ }
2291
+ /** @param {Record<string, any>} props */
2292
+ $set(t) {
2293
+ this.#t.$set(t);
2294
+ }
2295
+ /**
2296
+ * @param {string} event
2297
+ * @param {(...args: any[]) => any} callback
2298
+ * @returns {any}
2299
+ */
2300
+ $on(t, n) {
2301
+ this.#e[t] = this.#e[t] || [];
2302
+ const r = (...i) => n.call(this, ...i);
2303
+ return this.#e[t].push(r), () => {
2304
+ this.#e[t] = this.#e[t].filter(
2305
+ /** @param {any} fn */
2306
+ (i) => i !== r
2307
+ );
2308
+ };
2309
+ }
2310
+ $destroy() {
2311
+ this.#t.$destroy();
2312
+ }
2313
+ }
2314
+ let qn;
2315
+ typeof HTMLElement == "function" && (qn = class extends HTMLElement {
2316
+ /** The Svelte component constructor */
2317
+ $$ctor;
2318
+ /** Slots */
2319
+ $$s;
2320
+ /** @type {any} The Svelte component instance */
2321
+ $$c;
2322
+ /** Whether or not the custom element is connected */
2323
+ $$cn = !1;
2324
+ /** @type {Record<string, any>} Component props data */
2325
+ $$d = {};
2326
+ /** `true` if currently in the process of reflecting component props back to attributes */
2327
+ $$r = !1;
2328
+ /** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
2329
+ $$p_d = {};
2330
+ /** @type {Record<string, EventListenerOrEventListenerObject[]>} Event listeners */
2331
+ $$l = {};
2332
+ /** @type {Map<EventListenerOrEventListenerObject, Function>} Event listener unsubscribe functions */
2333
+ $$l_u = /* @__PURE__ */ new Map();
2334
+ /** @type {any} The managed render effect for reflecting attributes */
2335
+ $$me;
2336
+ /** @type {ShadowRoot | null} The ShadowRoot of the custom element */
2337
+ $$shadowRoot = null;
2338
+ /**
2339
+ * @param {*} $$componentCtor
2340
+ * @param {*} $$slots
2341
+ * @param {ShadowRootInit | undefined} shadow_root_init
2342
+ */
2343
+ constructor(e, t, n) {
2344
+ super(), this.$$ctor = e, this.$$s = t, n && (this.$$shadowRoot = this.attachShadow(n));
2345
+ }
2346
+ /**
2347
+ * @param {string} type
2348
+ * @param {EventListenerOrEventListenerObject} listener
2349
+ * @param {boolean | AddEventListenerOptions} [options]
2350
+ */
2351
+ addEventListener(e, t, n) {
2352
+ if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) {
2353
+ const r = this.$$c.$on(e, t);
2354
+ this.$$l_u.set(t, r);
2355
+ }
2356
+ super.addEventListener(e, t, n);
2357
+ }
2358
+ /**
2359
+ * @param {string} type
2360
+ * @param {EventListenerOrEventListenerObject} listener
2361
+ * @param {boolean | AddEventListenerOptions} [options]
2362
+ */
2363
+ removeEventListener(e, t, n) {
2364
+ if (super.removeEventListener(e, t, n), this.$$c) {
2365
+ const r = this.$$l_u.get(t);
2366
+ r && (r(), this.$$l_u.delete(t));
2367
+ }
2368
+ }
2369
+ async connectedCallback() {
2370
+ if (this.$$cn = !0, !this.$$c) {
2371
+ let e = function(r) {
2372
+ return (i) => {
2373
+ const s = Ot("slot");
2374
+ r !== "default" && (s.name = r), be(i, s);
2375
+ };
2376
+ };
2377
+ if (await Promise.resolve(), !this.$$cn || this.$$c)
2378
+ return;
2379
+ const t = {}, n = ci(this);
2380
+ for (const r of this.$$s)
2381
+ r in n && (r === "default" && !this.$$d.children ? (this.$$d.children = e(r), t.default = !0) : t[r] = e(r));
2382
+ for (const r of this.attributes) {
2383
+ const i = this.$$g_p(r.name);
2384
+ i in this.$$d || (this.$$d[i] = Xe(i, r.value, this.$$p_d, "toProp"));
2385
+ }
2386
+ for (const r in this.$$p_d)
2387
+ !(r in this.$$d) && this[r] !== void 0 && (this.$$d[r] = this[r], delete this[r]);
2388
+ this.$$c = ai({
2389
+ component: this.$$ctor,
2390
+ target: this.$$shadowRoot || this,
2391
+ props: {
2392
+ ...this.$$d,
2393
+ $$slots: t,
2394
+ $$host: this
2395
+ }
2396
+ }), this.$$me = Br(() => {
2397
+ Ct(() => {
2398
+ this.$$r = !0;
2399
+ for (const r of Qe(this.$$c)) {
2400
+ if (!this.$$p_d[r]?.reflect) continue;
2401
+ this.$$d[r] = this.$$c[r];
2402
+ const i = Xe(
2403
+ r,
2404
+ this.$$d[r],
2405
+ this.$$p_d,
2406
+ "toAttribute"
2407
+ );
2408
+ i == null ? this.removeAttribute(this.$$p_d[r].attribute || r) : this.setAttribute(this.$$p_d[r].attribute || r, i);
2409
+ }
2410
+ this.$$r = !1;
2411
+ });
2412
+ });
2413
+ for (const r in this.$$l)
2414
+ for (const i of this.$$l[r]) {
2415
+ const s = this.$$c.$on(r, i);
2416
+ this.$$l_u.set(i, s);
2417
+ }
2418
+ this.$$l = {};
2419
+ }
2420
+ }
2421
+ // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
2422
+ // and setting attributes through setAttribute etc, this is helpful
2423
+ /**
2424
+ * @param {string} attr
2425
+ * @param {string} _oldValue
2426
+ * @param {string} newValue
2427
+ */
2428
+ attributeChangedCallback(e, t, n) {
2429
+ this.$$r || (e = this.$$g_p(e), this.$$d[e] = Xe(e, n, this.$$p_d, "toProp"), this.$$c?.$set({ [e]: this.$$d[e] }));
2430
+ }
2431
+ disconnectedCallback() {
2432
+ this.$$cn = !1, Promise.resolve().then(() => {
2433
+ !this.$$cn && this.$$c && (this.$$c.$destroy(), this.$$me(), this.$$c = void 0);
2434
+ });
2435
+ }
2436
+ /**
2437
+ * @param {string} attribute_name
2438
+ */
2439
+ $$g_p(e) {
2440
+ return Qe(this.$$p_d).find(
2441
+ (t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e
2442
+ ) || e;
2443
+ }
2444
+ });
2445
+ function Xe(e, t, n, r) {
2446
+ const i = n[e]?.type;
2447
+ if (t = i === "Boolean" && typeof t != "boolean" ? t != null : t, !r || !n[e])
2448
+ return t;
2449
+ if (r === "toAttribute")
2450
+ switch (i) {
2451
+ case "Object":
2452
+ case "Array":
2453
+ return t == null ? null : JSON.stringify(t);
2454
+ case "Boolean":
2455
+ return t ? "" : null;
2456
+ case "Number":
2457
+ return t ?? null;
2458
+ default:
2459
+ return t;
2460
+ }
2461
+ else
2462
+ switch (i) {
2463
+ case "Object":
2464
+ case "Array":
2465
+ return t && JSON.parse(t);
2466
+ case "Boolean":
2467
+ return t;
2468
+ // conversion already handled above
2469
+ case "Number":
2470
+ return t != null ? +t : t;
2471
+ default:
2472
+ return t;
2473
+ }
2474
+ }
2475
+ function ci(e) {
2476
+ const t = {};
2477
+ return e.childNodes.forEach((n) => {
2478
+ t[
2479
+ /** @type {Element} node */
2480
+ n.slot || "default"
2481
+ ] = !0;
2482
+ }), t;
2483
+ }
2484
+ function Un(e, t, n, r, i, s) {
2485
+ let l = class extends qn {
2486
+ constructor() {
2487
+ super(e, n, i), this.$$p_d = t;
2488
+ }
2489
+ static get observedAttributes() {
2490
+ return Qe(t).map(
2491
+ (o) => (t[o].attribute || o).toLowerCase()
2492
+ );
2493
+ }
2494
+ };
2495
+ return Qe(t).forEach((o) => {
2496
+ et(l.prototype, o, {
2497
+ get() {
2498
+ return this.$$c && o in this.$$c ? this.$$c[o] : this.$$d[o];
2499
+ },
2500
+ set(f) {
2501
+ f = Xe(o, f, t), this.$$d[o] = f;
2502
+ var a = this.$$c;
2503
+ if (a) {
2504
+ var d = we(a, o)?.get;
2505
+ d ? a[o] = f : a.$set({ [o]: f });
2506
+ }
2507
+ }
2508
+ });
2509
+ }), r.forEach((o) => {
2510
+ et(l.prototype, o, {
2511
+ get() {
2512
+ return this.$$c?.[o];
2513
+ }
2514
+ });
2515
+ }), e.element = /** @type {any} */
2516
+ l, l;
2517
+ }
2518
+ let Je = null;
2519
+ async function Bn(e, t, n, r = !1, i = !1) {
2520
+ if (customElements.get(t)) {
2521
+ r && console.log(`[element-loader] Element ${t} already registered`);
2522
+ return;
2523
+ }
2524
+ r && console.log(`[element-loader] Loading element ${e} (cdnUrl: ${n || "local"})`);
2525
+ try {
2526
+ let s;
2527
+ if (!n || n === "") {
2528
+ if (!Je)
2529
+ try {
2530
+ Je = await import("$lib/element-imports");
2531
+ } catch {
2532
+ console.warn("[element-loader] Static imports module not found, trying direct import");
2533
+ }
2534
+ Je?.hasElementModule(e) ? s = await Je.getElementModule(e) : s = await import(
2535
+ /* @vite-ignore */
2536
+ e
2537
+ );
2538
+ } else
2539
+ s = await import(`${n}/${e}`);
2540
+ const l = s.default || s.Element;
2541
+ if (!l)
2542
+ throw new Error(`No default or Element export found for ${e}`);
2543
+ if (typeof l != "function")
2544
+ throw new Error(`Export from ${e} is not a constructor function`);
2545
+ customElements.define(t, l), r && console.log(`[element-loader] ✓ Registered custom element: ${t}`);
2546
+ } catch (s) {
2547
+ const l = s;
2548
+ if (!i)
2549
+ throw console.error(`[element-loader] Failed to load element ${e}:`, l), new Error(`Failed to load element ${e}: ${l.message}`);
2550
+ r && console.log(`[element-loader] Optional element ${e} not available`);
2551
+ }
2552
+ }
2553
+ var di = /* @__PURE__ */ Le('<div class="loading svelte-156cx1g"> </div>'), hi = /* @__PURE__ */ Le('<div class="error svelte-156cx1g"><strong>Error loading element:</strong> <pre class="svelte-156cx1g"> </pre></div>'), vi = /* @__PURE__ */ Le('<div class="esm-element-player svelte-156cx1g"><!> <!></div>');
2554
+ const _i = {
2555
+ hash: "svelte-156cx1g",
2556
+ code: ".esm-element-player.svelte-156cx1g {width:100%;min-height:100px;}.loading.svelte-156cx1g {padding:2rem;text-align:center;color:#666;font-style:italic;}.error.svelte-156cx1g {padding:1rem;background:#fee;border:1px solid #fcc;border-radius:4px;color:#c00;}.error.svelte-156cx1g pre:where(.svelte-156cx1g) {margin:0.5rem 0 0;padding:0.5rem;background:#fff;border-radius:4px;font-size:0.875rem;overflow-x:auto;}"
2557
+ };
2558
+ function pi(e, t) {
2559
+ Tt(t, !0), In(e, _i);
2560
+ let n = ue(t, "elementName", 7, ""), r = ue(t, "cdnUrl", 7, ""), i = ue(t, "model", 15), s = ue(t, "session", 15);
2561
+ const l = oi();
2562
+ let o, f = /* @__PURE__ */ M(null), a = /* @__PURE__ */ M(null), d = /* @__PURE__ */ M(null), c = /* @__PURE__ */ M(!0), u = null, v = null;
2563
+ G(() => {
2564
+ console.log("[esm-player] Element name changed:", n()), n() ? m() : ($(d, "No element name provided"), $(c, !1));
2565
+ }), G(() => {
2566
+ if (p(f) && i() !== void 0)
2567
+ try {
2568
+ p(f).model = i();
2569
+ } catch (h) {
2570
+ console.error("[esm-player] Error setting model:", h);
2571
+ }
2572
+ }), Fn(() => {
2573
+ if (u = Ht(), typeof window < "u" && (window["@pie-lib/math-rendering"] = { renderMath: u }), u && typeof window < "u") {
2574
+ const h = document.createElement("div");
2575
+ u(h).catch(() => {
2576
+ });
2577
+ }
2578
+ return () => {
2579
+ v && v.disconnect();
2580
+ };
2581
+ }), G(() => {
2582
+ if (o && u) {
2583
+ v && v.disconnect();
2584
+ let h = null;
2585
+ v = new MutationObserver(() => {
2586
+ h && clearTimeout(h), h = window.setTimeout(
2587
+ () => {
2588
+ u && o && u(o).catch((E) => {
2589
+ console.error("[esm-player] Math rendering error:", E);
2590
+ });
2591
+ },
2592
+ 100
2593
+ );
2594
+ }), v.observe(o, {
2595
+ childList: !0,
2596
+ subtree: !0,
2597
+ attributes: !1,
2598
+ characterData: !1
2599
+ }), u(o).catch((E) => {
2600
+ console.error("[esm-player] Initial math rendering error:", E);
2601
+ });
2602
+ }
2603
+ }), G(() => {
2604
+ o && u && i() && requestAnimationFrame(() => {
2605
+ requestAnimationFrame(() => {
2606
+ u && o && u(o).catch((h) => {
2607
+ console.error("[esm-player] Math rendering error:", h);
2608
+ });
2609
+ });
2610
+ });
2611
+ });
2612
+ async function m() {
2613
+ if (!n()) {
2614
+ $(d, "No element name provided"), $(c, !1);
2615
+ return;
2616
+ }
2617
+ try {
2618
+ $(c, !0), $(d, null);
2619
+ const h = `@pie-element/${n()}`;
2620
+ console.log(`[esm-player] Loading element: ${h}`);
2621
+ const E = `${n()}-element`, ee = new Promise((ct, Fe) => setTimeout(() => Fe(new Error(`Timeout loading ${h} (>10s). Check /@pie- routes, Vite server, and network.`)), 1e4));
2622
+ await Promise.race([
2623
+ Bn(h, E, r()),
2624
+ ee
2625
+ ]), await customElements.whenDefined(E), p(f) && p(a) === E ? console.log(`[esm-player] Reusing element instance: ${E}`) : (p(f) && p(f).remove(), console.log(`[esm-player] Creating element instance: ${E}`), $(f, document.createElement(E), !0), $(a, E)), i() !== void 0 && (p(f).model = i());
2626
+ const Se = s() ?? p(f).session;
2627
+ Se !== void 0 && (p(f).session = Se), p(f).addEventListener("session-changed", (ct) => {
2628
+ ct.stopPropagation();
2629
+ const Fe = ct, Vn = p(f).session;
2630
+ console.log("[esm-player] Session changed:", Fe.detail), l("session-changed", {
2631
+ session: Vn,
2632
+ complete: Fe.detail?.complete,
2633
+ component: Fe.detail?.component
2634
+ });
2635
+ }), o && p(f).parentElement !== o && (o.innerHTML = "", o.appendChild(p(f))), console.log(`[esm-player] Element ${n()} loaded successfully`), $(c, !1);
2636
+ } catch (h) {
2637
+ console.error(`[esm-player] Failed to load element ${n()}:`, h), $(d, h instanceof Error ? h.message : String(h), !0), $(c, !1);
2638
+ }
2639
+ }
2640
+ var g = {
2641
+ get elementName() {
2642
+ return n();
2643
+ },
2644
+ set elementName(h = "") {
2645
+ n(h), re();
2646
+ },
2647
+ get cdnUrl() {
2648
+ return r();
2649
+ },
2650
+ set cdnUrl(h = "") {
2651
+ r(h), re();
2652
+ },
2653
+ get model() {
2654
+ return i();
2655
+ },
2656
+ set model(h) {
2657
+ i(h), re();
2658
+ },
2659
+ get session() {
2660
+ return s();
2661
+ },
2662
+ set session(h) {
2663
+ s(h), re();
2664
+ }
2665
+ }, b = vi(), I = ae(b);
2666
+ {
2667
+ var N = (h) => {
2668
+ var E = di(), ee = ae(E);
2669
+ fe(E), it(() => st(ee, `Loading ${n() ?? ""}...`)), be(h, E);
2670
+ };
2671
+ lt(I, (h) => {
2672
+ p(c) && h(N);
2673
+ });
2674
+ }
2675
+ var oe = rt(I, 2);
2676
+ {
2677
+ var _ = (h) => {
2678
+ var E = hi(), ee = rt(ae(E), 2), Se = ae(ee, !0);
2679
+ fe(ee), fe(E), it(() => st(Se, p(d))), be(h, E);
2680
+ };
2681
+ lt(oe, (h) => {
2682
+ p(d) && h(_);
2683
+ });
2684
+ }
2685
+ return fe(b), jn(b, (h) => o = h, () => o), be(e, b), St(g);
2686
+ }
2687
+ customElements.define("pie-esm-element-player", Un(
2688
+ pi,
2689
+ {
2690
+ elementName: { attribute: "element-name", reflect: !0, type: "String" },
2691
+ cdnUrl: { attribute: "cdn-url", reflect: !0, type: "String" },
2692
+ model: { type: "Object" },
2693
+ session: { type: "Object" }
2694
+ },
2695
+ [],
2696
+ []
2697
+ ));
2698
+ var mi = /* @__PURE__ */ Le('<div class="loading svelte-xidvdr"> </div>'), gi = /* @__PURE__ */ Le('<div class="error svelte-xidvdr"><strong>Error loading print element:</strong> <pre class="svelte-xidvdr"> </pre></div>'), wi = /* @__PURE__ */ Le('<div class="esm-print-player svelte-xidvdr"><!> <!></div>');
2699
+ const $i = {
2700
+ hash: "svelte-xidvdr",
2701
+ code: ".esm-print-player.svelte-xidvdr {width:100%;min-height:100px;}.loading.svelte-xidvdr {padding:2rem;text-align:center;color:#666;font-style:italic;}.error.svelte-xidvdr {padding:1rem;background:#fee;border:1px solid #fcc;border-radius:4px;color:#c00;}.error.svelte-xidvdr pre:where(.svelte-xidvdr) {margin:0.5rem 0 0;padding:0.5rem;background:#fff;border-radius:4px;font-size:0.875rem;overflow-x:auto;}"
2702
+ };
2703
+ function yi(e, t) {
2704
+ Tt(t, !0), In(e, $i);
2705
+ let n = ue(t, "elementName", 7, ""), r = ue(t, "cdnUrl", 7, ""), i = ue(t, "model", 15), s = ue(t, "role", 7, "student"), l, o = /* @__PURE__ */ M(null), f = /* @__PURE__ */ M(null), a = /* @__PURE__ */ M(null), d = /* @__PURE__ */ M(!0), c = null, u = null;
2706
+ G(() => {
2707
+ console.log("[esm-print-player] Element name changed:", n()), n() ? v() : ($(a, "No element name provided"), $(d, !1));
2708
+ }), G(() => {
2709
+ if (p(o) && i() !== void 0)
2710
+ try {
2711
+ p(o).model = i();
2712
+ } catch (_) {
2713
+ console.error("[esm-print-player] Error setting model:", _);
2714
+ }
2715
+ }), G(() => {
2716
+ if (p(o) && s() !== void 0)
2717
+ try {
2718
+ p(o).options = { role: s() };
2719
+ } catch (_) {
2720
+ console.error("[esm-print-player] Error setting role:", _);
2721
+ }
2722
+ }), Fn(() => {
2723
+ if (c = Ht(), typeof window < "u" && (window["@pie-lib/math-rendering"] = { renderMath: c }), c && typeof window < "u") {
2724
+ const _ = document.createElement("div");
2725
+ c(_).catch(() => {
2726
+ });
2727
+ }
2728
+ return () => {
2729
+ u && u.disconnect();
2730
+ };
2731
+ }), G(() => {
2732
+ if (l && c) {
2733
+ u && u.disconnect();
2734
+ let _ = null;
2735
+ u = new MutationObserver(() => {
2736
+ _ && clearTimeout(_), _ = window.setTimeout(
2737
+ () => {
2738
+ c && l && c(l).catch((h) => {
2739
+ console.error("[esm-print-player] Math rendering error:", h);
2740
+ });
2741
+ },
2742
+ 150
2743
+ );
2744
+ }), u.observe(l, {
2745
+ childList: !0,
2746
+ subtree: !0,
2747
+ attributes: !1,
2748
+ characterData: !1
2749
+ }), c(l).catch((h) => {
2750
+ console.error("[esm-print-player] Initial math rendering error:", h);
2751
+ });
2752
+ }
2753
+ }), G(() => {
2754
+ l && c && (i() || s()) && requestAnimationFrame(() => {
2755
+ requestAnimationFrame(() => {
2756
+ c && l && c(l).catch((_) => {
2757
+ console.error("[esm-print-player] Math rendering error:", _);
2758
+ });
2759
+ });
2760
+ });
2761
+ });
2762
+ async function v() {
2763
+ if (!n()) {
2764
+ $(a, "No element name provided"), $(d, !1);
2765
+ return;
2766
+ }
2767
+ try {
2768
+ $(d, !0), $(a, null);
2769
+ const _ = `@pie-element/${n()}/print`;
2770
+ console.log(`[esm-print-player] Loading print element: ${_}`);
2771
+ const h = `${n()}-print`, E = new Promise((ee, Se) => setTimeout(() => Se(new Error(`Timeout loading ${_} (>10s). Check /@pie- routes, Vite server, and network.`)), 1e4));
2772
+ await Promise.race([
2773
+ Bn(_, h, r()),
2774
+ E
2775
+ ]), await customElements.whenDefined(h), p(o) && p(f) === h ? console.log(`[esm-print-player] Reusing element instance: ${h}`) : (p(o) && p(o).remove(), console.log(`[esm-print-player] Creating element instance: ${h}`), $(o, document.createElement(h), !0), $(f, h)), i() !== void 0 && (p(o).model = i()), s() !== void 0 && (p(o).options = { role: s() }), l && p(o).parentElement !== l && (l.innerHTML = "", l.appendChild(p(o))), console.log(`[esm-print-player] Print element ${n()} loaded successfully`), $(d, !1);
2776
+ } catch (_) {
2777
+ console.error(`[esm-print-player] Failed to load print element ${n()}:`, _), $(a, _ instanceof Error ? _.message : String(_), !0), $(d, !1);
2778
+ }
2779
+ }
2780
+ var m = {
2781
+ get elementName() {
2782
+ return n();
2783
+ },
2784
+ set elementName(_ = "") {
2785
+ n(_), re();
2786
+ },
2787
+ get cdnUrl() {
2788
+ return r();
2789
+ },
2790
+ set cdnUrl(_ = "") {
2791
+ r(_), re();
2792
+ },
2793
+ get model() {
2794
+ return i();
2795
+ },
2796
+ set model(_) {
2797
+ i(_), re();
2798
+ },
2799
+ get role() {
2800
+ return s();
2801
+ },
2802
+ set role(_ = "student") {
2803
+ s(_), re();
2804
+ }
2805
+ }, g = wi(), b = ae(g);
2806
+ {
2807
+ var I = (_) => {
2808
+ var h = mi(), E = ae(h);
2809
+ fe(h), it(() => st(E, `Loading ${n() ?? ""} (print)...`)), be(_, h);
2810
+ };
2811
+ lt(b, (_) => {
2812
+ p(d) && _(I);
2813
+ });
2814
+ }
2815
+ var N = rt(b, 2);
2816
+ {
2817
+ var oe = (_) => {
2818
+ var h = gi(), E = rt(ae(h), 2), ee = ae(E, !0);
2819
+ fe(E), fe(h), it(() => st(ee, p(a))), be(_, h);
2820
+ };
2821
+ lt(N, (_) => {
2822
+ p(a) && _(oe);
2823
+ });
2824
+ }
2825
+ return fe(g), jn(g, (_) => l = _, () => l), be(e, g), St(m);
2826
+ }
2827
+ customElements.define("pie-esm-print-player", Un(
2828
+ yi,
2829
+ {
2830
+ elementName: { attribute: "element-name", reflect: !0, type: "String" },
2831
+ cdnUrl: { attribute: "cdn-url", reflect: !0, type: "String" },
2832
+ model: { type: "Object" },
2833
+ role: { reflect: !0, type: "String" }
2834
+ },
2835
+ [],
2836
+ []
2837
+ ));
2838
+ export {
2839
+ pi as EsmElementPlayer,
2840
+ yi as EsmPrintPlayer
2841
+ };