@triiiceratops/plugin-image-export 1.0.0-rc.0

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.
package/dist/index.js ADDED
@@ -0,0 +1,3578 @@
1
+ import { svgIcon as fi, dispatchPluginCommandError as ci, definePluginStyles as di, definePlugin as vi } from "@triiiceratops/plugin-sdk";
2
+ import { resolveAllCanvasImages as Zt, clampCompositeSize as Zr, composeImages as Xr, getResolvedImageExportUrl as wr, fetchImageBlob as br, getVisibleCanvasEntries as _i, buildRelativeSizeOptions as Jr, resolveExportSizeOptions as hi, getCompositeImagePlacement as pi, getCanvasId as Qr, getCanvasDisplayLayouts as gi, MULTI_CANVAS_GAP as mi, getCanvasLabel as Lr, downloadBlob as wi } from "triiiceratops/image-export";
3
+ const fr = !1;
4
+ var yr = Array.isArray, bi = Array.prototype.indexOf, Xt = Array.from, yi = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, Ei = Object.getOwnPropertyDescriptors, xi = Object.prototype, Si = Array.prototype, en = Object.getPrototypeOf, Pr = Object.isExtensible;
5
+ const tn = () => {
6
+ };
7
+ function Ci(e) {
8
+ for (var t = 0; t < e.length; t++)
9
+ e[t]();
10
+ }
11
+ function rn() {
12
+ var e, t, r = new Promise((n, i) => {
13
+ e = n, t = i;
14
+ });
15
+ return { promise: r, resolve: e, reject: t };
16
+ }
17
+ const Q = 2, Er = 4, xr = 8, nn = 1 << 24, Ne = 16, Re = 32, tt = 64, Jt = 128, be = 512, te = 1024, ce = 2048, ze = 4096, pe = 8192, Pe = 16384, Sr = 32768, Xe = 65536, Or = 1 << 17, an = 1 << 18, ht = 1 << 19, Ai = 1 << 20, Le = 1 << 25, Je = 32768, cr = 1 << 21, Cr = 1 << 22, He = 1 << 23, Ye = Symbol("$state"), Ii = Symbol("legacy props"), ki = Symbol(""), ut = new class extends Error {
18
+ name = "StaleReactionError";
19
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
20
+ }();
21
+ function Ti(e) {
22
+ throw new Error("https://svelte.dev/e/lifecycle_outside_component");
23
+ }
24
+ function Mi() {
25
+ throw new Error("https://svelte.dev/e/async_derived_orphan");
26
+ }
27
+ function Di(e) {
28
+ throw new Error("https://svelte.dev/e/effect_in_teardown");
29
+ }
30
+ function Li() {
31
+ throw new Error("https://svelte.dev/e/effect_in_unowned_derived");
32
+ }
33
+ function Pi(e) {
34
+ throw new Error("https://svelte.dev/e/effect_orphan");
35
+ }
36
+ function Oi() {
37
+ throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
38
+ }
39
+ function Ni(e) {
40
+ throw new Error("https://svelte.dev/e/props_invalid_value");
41
+ }
42
+ function Ri() {
43
+ throw new Error("https://svelte.dev/e/state_descriptors_fixed");
44
+ }
45
+ function zi() {
46
+ throw new Error("https://svelte.dev/e/state_prototype_fixed");
47
+ }
48
+ function $i() {
49
+ throw new Error("https://svelte.dev/e/state_unsafe_mutation");
50
+ }
51
+ function Fi() {
52
+ throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
53
+ }
54
+ const Bi = 1, Wi = 2, on = 4, Hi = 8, Vi = 16, qi = 1, Ui = 4, ji = 8, Yi = 16, Ki = 1, Gi = 2, X = Symbol(), Zi = "http://www.w3.org/1999/xhtml", Xi = "@attach";
55
+ function Ji() {
56
+ console.warn("https://svelte.dev/e/select_multiple_invalid_value");
57
+ }
58
+ function Qi() {
59
+ console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
60
+ }
61
+ function ln(e) {
62
+ return e === this.v;
63
+ }
64
+ function ea(e, t) {
65
+ return e != e ? t == t : e !== t || e !== null && typeof e == "object" || typeof e == "function";
66
+ }
67
+ function sn(e) {
68
+ return !ea(e, this.v);
69
+ }
70
+ let ta = !1, ae = null;
71
+ function dt(e) {
72
+ ae = e;
73
+ }
74
+ function ra(e) {
75
+ return (
76
+ /** @type {T} */
77
+ na().get(e)
78
+ );
79
+ }
80
+ function Ar(e, t = !1, r) {
81
+ ae = {
82
+ p: ae,
83
+ i: !1,
84
+ c: null,
85
+ e: null,
86
+ s: e,
87
+ x: null,
88
+ l: null
89
+ };
90
+ }
91
+ function Ir(e) {
92
+ var t = (
93
+ /** @type {ComponentContext} */
94
+ ae
95
+ ), r = t.e;
96
+ if (r !== null) {
97
+ t.e = null;
98
+ for (var n of r)
99
+ Sn(n);
100
+ }
101
+ return t.i = !0, ae = t.p, /** @type {T} */
102
+ {};
103
+ }
104
+ function un() {
105
+ return !0;
106
+ }
107
+ function na(e) {
108
+ return ae === null && Ti(), ae.c ??= new Map(ia(ae) || void 0);
109
+ }
110
+ function ia(e) {
111
+ let t = e.p;
112
+ for (; t !== null; ) {
113
+ const r = t.c;
114
+ if (r !== null)
115
+ return r;
116
+ t = t.p;
117
+ }
118
+ return null;
119
+ }
120
+ let ft = [];
121
+ function aa() {
122
+ var e = ft;
123
+ ft = [], Ci(e);
124
+ }
125
+ function rt(e) {
126
+ if (ft.length === 0) {
127
+ var t = ft;
128
+ queueMicrotask(() => {
129
+ t === ft && aa();
130
+ });
131
+ }
132
+ ft.push(e);
133
+ }
134
+ function fn(e) {
135
+ var t = M;
136
+ if (t === null)
137
+ return k.f |= He, e;
138
+ if ((t.f & Sr) === 0) {
139
+ if ((t.f & Jt) === 0)
140
+ throw e;
141
+ t.b.error(e);
142
+ } else
143
+ vt(e, t);
144
+ }
145
+ function vt(e, t) {
146
+ for (; t !== null; ) {
147
+ if ((t.f & Jt) !== 0)
148
+ try {
149
+ t.b.error(e);
150
+ return;
151
+ } catch (r) {
152
+ e = r;
153
+ }
154
+ t = t.parent;
155
+ }
156
+ throw e;
157
+ }
158
+ const Ft = /* @__PURE__ */ new Set();
159
+ let P = null, Ht = null, me = null, Ee = [], kr = null, dr = !1;
160
+ class xe {
161
+ committed = !1;
162
+ /**
163
+ * The current values of any sources that are updated in this batch
164
+ * They keys of this map are identical to `this.#previous`
165
+ * @type {Map<Source, any>}
166
+ */
167
+ current = /* @__PURE__ */ new Map();
168
+ /**
169
+ * The values of any sources that are updated in this batch _before_ those updates took place.
170
+ * They keys of this map are identical to `this.#current`
171
+ * @type {Map<Source, any>}
172
+ */
173
+ previous = /* @__PURE__ */ new Map();
174
+ /**
175
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
176
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
177
+ * @type {Set<() => void>}
178
+ */
179
+ #e = /* @__PURE__ */ new Set();
180
+ /**
181
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
182
+ * @type {Set<(batch: Batch) => void>}
183
+ */
184
+ #t = /* @__PURE__ */ new Set();
185
+ /**
186
+ * The number of async effects that are currently in flight
187
+ */
188
+ #n = 0;
189
+ /**
190
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
191
+ */
192
+ #r = 0;
193
+ /**
194
+ * A deferred that resolves when the batch is committed, used with `settled()`
195
+ * TODO replace with Promise.withResolvers once supported widely enough
196
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
197
+ */
198
+ #s = null;
199
+ /**
200
+ * Deferred effects (which run after async work has completed) that are DIRTY
201
+ * @type {Effect[]}
202
+ */
203
+ #a = [];
204
+ /**
205
+ * Deferred effects that are MAYBE_DIRTY
206
+ * @type {Effect[]}
207
+ */
208
+ #i = [];
209
+ /**
210
+ * A set of branches that still exist, but will be destroyed when this batch
211
+ * is committed — we skip over these during `process`
212
+ * @type {Set<Effect>}
213
+ */
214
+ skipped_effects = /* @__PURE__ */ new Set();
215
+ is_fork = !1;
216
+ is_deferred() {
217
+ return this.is_fork || this.#r > 0;
218
+ }
219
+ /**
220
+ *
221
+ * @param {Effect[]} root_effects
222
+ */
223
+ process(t) {
224
+ Ee = [], Ht = null, this.apply();
225
+ var r = {
226
+ parent: null,
227
+ effect: null,
228
+ effects: [],
229
+ render_effects: [],
230
+ block_effects: []
231
+ };
232
+ for (const n of t)
233
+ this.#o(n, r);
234
+ this.is_fork || this.#f(), this.is_deferred() ? (this.#l(r.effects), this.#l(r.render_effects), this.#l(r.block_effects)) : (Ht = this, P = null, Nr(r.render_effects), Nr(r.effects), Ht = null, this.#s?.resolve()), me = null;
235
+ }
236
+ /**
237
+ * Traverse the effect tree, executing effects or stashing
238
+ * them for later execution as appropriate
239
+ * @param {Effect} root
240
+ * @param {EffectTarget} target
241
+ */
242
+ #o(t, r) {
243
+ t.f ^= te;
244
+ for (var n = t.first; n !== null; ) {
245
+ var i = n.f, a = (i & (Re | tt)) !== 0, l = a && (i & te) !== 0, f = l || (i & pe) !== 0 || this.skipped_effects.has(n);
246
+ if ((n.f & Jt) !== 0 && n.b?.is_pending() && (r = {
247
+ parent: r,
248
+ effect: n,
249
+ effects: [],
250
+ render_effects: [],
251
+ block_effects: []
252
+ }), !f && n.fn !== null) {
253
+ a ? n.f ^= te : (i & Er) !== 0 ? r.effects.push(n) : Ot(n) && ((n.f & Ne) !== 0 && r.block_effects.push(n), Dt(n));
254
+ var s = n.first;
255
+ if (s !== null) {
256
+ n = s;
257
+ continue;
258
+ }
259
+ }
260
+ var u = n.parent;
261
+ for (n = n.next; n === null && u !== null; )
262
+ u === r.effect && (this.#l(r.effects), this.#l(r.render_effects), this.#l(r.block_effects), r = /** @type {EffectTarget} */
263
+ r.parent), n = u.next, u = u.parent;
264
+ }
265
+ }
266
+ /**
267
+ * @param {Effect[]} effects
268
+ */
269
+ #l(t) {
270
+ for (const r of t)
271
+ ((r.f & ce) !== 0 ? this.#a : this.#i).push(r), this.#u(r.deps), re(r, te);
272
+ }
273
+ /**
274
+ * @param {Value[] | null} deps
275
+ */
276
+ #u(t) {
277
+ if (t !== null)
278
+ for (const r of t)
279
+ (r.f & Q) === 0 || (r.f & Je) === 0 || (r.f ^= Je, this.#u(
280
+ /** @type {Derived} */
281
+ r.deps
282
+ ));
283
+ }
284
+ /**
285
+ * Associate a change to a given source with the current
286
+ * batch, noting its previous and current values
287
+ * @param {Source} source
288
+ * @param {any} value
289
+ */
290
+ capture(t, r) {
291
+ this.previous.has(t) || this.previous.set(t, r), (t.f & He) === 0 && (this.current.set(t, t.v), me?.set(t, t.v));
292
+ }
293
+ activate() {
294
+ P = this, this.apply();
295
+ }
296
+ deactivate() {
297
+ P === this && (P = null, me = null);
298
+ }
299
+ flush() {
300
+ if (this.activate(), Ee.length > 0) {
301
+ if (oa(), P !== null && P !== this)
302
+ return;
303
+ } else this.#n === 0 && this.process([]);
304
+ this.deactivate();
305
+ }
306
+ discard() {
307
+ for (const t of this.#t) t(this);
308
+ this.#t.clear();
309
+ }
310
+ #f() {
311
+ if (this.#r === 0) {
312
+ for (const t of this.#e) t();
313
+ this.#e.clear();
314
+ }
315
+ this.#n === 0 && this.#c();
316
+ }
317
+ #c() {
318
+ if (Ft.size > 1) {
319
+ this.previous.clear();
320
+ var t = me, r = !0, n = {
321
+ parent: null,
322
+ effect: null,
323
+ effects: [],
324
+ render_effects: [],
325
+ block_effects: []
326
+ };
327
+ for (const a of Ft) {
328
+ if (a === this) {
329
+ r = !1;
330
+ continue;
331
+ }
332
+ const l = [];
333
+ for (const [s, u] of this.current) {
334
+ if (a.current.has(s))
335
+ if (r && u !== a.current.get(s))
336
+ a.current.set(s, u);
337
+ else
338
+ continue;
339
+ l.push(s);
340
+ }
341
+ if (l.length === 0)
342
+ continue;
343
+ const f = [...a.current.keys()].filter((s) => !this.current.has(s));
344
+ if (f.length > 0) {
345
+ var i = Ee;
346
+ Ee = [];
347
+ const s = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map();
348
+ for (const c of l)
349
+ cn(c, f, s, u);
350
+ if (Ee.length > 0) {
351
+ P = a, a.apply();
352
+ for (const c of Ee)
353
+ a.#o(c, n);
354
+ a.deactivate();
355
+ }
356
+ Ee = i;
357
+ }
358
+ }
359
+ P = null, me = t;
360
+ }
361
+ this.committed = !0, Ft.delete(this);
362
+ }
363
+ /**
364
+ *
365
+ * @param {boolean} blocking
366
+ */
367
+ increment(t) {
368
+ this.#n += 1, t && (this.#r += 1);
369
+ }
370
+ /**
371
+ *
372
+ * @param {boolean} blocking
373
+ */
374
+ decrement(t) {
375
+ this.#n -= 1, t && (this.#r -= 1), this.revive();
376
+ }
377
+ revive() {
378
+ for (const t of this.#a)
379
+ re(t, ce), Qe(t);
380
+ for (const t of this.#i)
381
+ re(t, ze), Qe(t);
382
+ this.#a = [], this.#i = [], this.flush();
383
+ }
384
+ /** @param {() => void} fn */
385
+ oncommit(t) {
386
+ this.#e.add(t);
387
+ }
388
+ /** @param {(batch: Batch) => void} fn */
389
+ ondiscard(t) {
390
+ this.#t.add(t);
391
+ }
392
+ settled() {
393
+ return (this.#s ??= rn()).promise;
394
+ }
395
+ static ensure() {
396
+ if (P === null) {
397
+ const t = P = new xe();
398
+ Ft.add(P), xe.enqueue(() => {
399
+ P === t && t.flush();
400
+ });
401
+ }
402
+ return P;
403
+ }
404
+ /** @param {() => void} task */
405
+ static enqueue(t) {
406
+ rt(t);
407
+ }
408
+ apply() {
409
+ }
410
+ }
411
+ function oa() {
412
+ var e = Ge;
413
+ dr = !0;
414
+ var t = null;
415
+ try {
416
+ var r = 0;
417
+ for (Yt(!0); Ee.length > 0; ) {
418
+ var n = xe.ensure();
419
+ if (r++ > 1e3) {
420
+ var i, a;
421
+ la();
422
+ }
423
+ n.process(Ee), Ve.clear();
424
+ }
425
+ } finally {
426
+ dr = !1, Yt(e), kr = null;
427
+ }
428
+ }
429
+ function la() {
430
+ try {
431
+ Oi();
432
+ } catch (e) {
433
+ vt(e, kr);
434
+ }
435
+ }
436
+ let De = null;
437
+ function Nr(e) {
438
+ var t = e.length;
439
+ if (t !== 0) {
440
+ for (var r = 0; r < t; ) {
441
+ var n = e[r++];
442
+ if ((n.f & (Pe | pe)) === 0 && Ot(n) && (De = /* @__PURE__ */ new Set(), Dt(n), n.deps === null && n.first === null && n.nodes === null && (n.teardown === null && n.ac === null ? Tn(n) : n.fn = null), De?.size > 0)) {
443
+ Ve.clear();
444
+ for (const i of De) {
445
+ if ((i.f & (Pe | pe)) !== 0) continue;
446
+ const a = [i];
447
+ let l = i.parent;
448
+ for (; l !== null; )
449
+ De.has(l) && (De.delete(l), a.push(l)), l = l.parent;
450
+ for (let f = a.length - 1; f >= 0; f--) {
451
+ const s = a[f];
452
+ (s.f & (Pe | pe)) === 0 && Dt(s);
453
+ }
454
+ }
455
+ De.clear();
456
+ }
457
+ }
458
+ De = null;
459
+ }
460
+ }
461
+ function cn(e, t, r, n) {
462
+ if (!r.has(e) && (r.add(e), e.reactions !== null))
463
+ for (const i of e.reactions) {
464
+ const a = i.f;
465
+ (a & Q) !== 0 ? cn(
466
+ /** @type {Derived} */
467
+ i,
468
+ t,
469
+ r,
470
+ n
471
+ ) : (a & (Cr | Ne)) !== 0 && (a & ce) === 0 && dn(i, t, n) && (re(i, ce), Qe(
472
+ /** @type {Effect} */
473
+ i
474
+ ));
475
+ }
476
+ }
477
+ function dn(e, t, r) {
478
+ const n = r.get(e);
479
+ if (n !== void 0) return n;
480
+ if (e.deps !== null)
481
+ for (const i of e.deps) {
482
+ if (t.includes(i))
483
+ return !0;
484
+ if ((i.f & Q) !== 0 && dn(
485
+ /** @type {Derived} */
486
+ i,
487
+ t,
488
+ r
489
+ ))
490
+ return r.set(
491
+ /** @type {Derived} */
492
+ i,
493
+ !0
494
+ ), !0;
495
+ }
496
+ return r.set(e, !1), !1;
497
+ }
498
+ function Qe(e) {
499
+ for (var t = kr = e; t.parent !== null; ) {
500
+ t = t.parent;
501
+ var r = t.f;
502
+ if (dr && t === M && (r & Ne) !== 0 && (r & an) === 0)
503
+ return;
504
+ if ((r & (tt | Re)) !== 0) {
505
+ if ((r & te) === 0) return;
506
+ t.f ^= te;
507
+ }
508
+ }
509
+ Ee.push(t);
510
+ }
511
+ function sa(e) {
512
+ let t = 0, r = et(0), n;
513
+ return () => {
514
+ Tt() && (o(r), Cn(() => (t === 0 && (n = rr(() => e(() => It(r)))), t += 1, () => {
515
+ rt(() => {
516
+ t -= 1, t === 0 && (n?.(), n = void 0, It(r));
517
+ });
518
+ })));
519
+ };
520
+ }
521
+ var ua = Xe | ht | Jt;
522
+ function fa(e, t, r) {
523
+ new ca(e, t, r);
524
+ }
525
+ class ca {
526
+ /** @type {Boundary | null} */
527
+ parent;
528
+ #e = !1;
529
+ /** @type {TemplateNode} */
530
+ #t;
531
+ /** @type {TemplateNode | null} */
532
+ #n = null;
533
+ /** @type {BoundaryProps} */
534
+ #r;
535
+ /** @type {((anchor: Node) => void)} */
536
+ #s;
537
+ /** @type {Effect} */
538
+ #a;
539
+ /** @type {Effect | null} */
540
+ #i = null;
541
+ /** @type {Effect | null} */
542
+ #o = null;
543
+ /** @type {Effect | null} */
544
+ #l = null;
545
+ /** @type {DocumentFragment | null} */
546
+ #u = null;
547
+ /** @type {TemplateNode | null} */
548
+ #f = null;
549
+ #c = 0;
550
+ #d = 0;
551
+ #_ = !1;
552
+ /**
553
+ * A source containing the number of pending async deriveds/expressions.
554
+ * Only created if `$effect.pending()` is used inside the boundary,
555
+ * otherwise updating the source results in needless `Batch.ensure()`
556
+ * calls followed by no-op flushes
557
+ * @type {Source<number> | null}
558
+ */
559
+ #v = null;
560
+ #w = sa(() => (this.#v = et(this.#c), () => {
561
+ this.#v = null;
562
+ }));
563
+ /**
564
+ * @param {TemplateNode} node
565
+ * @param {BoundaryProps} props
566
+ * @param {((anchor: Node) => void)} children
567
+ */
568
+ constructor(t, r, n) {
569
+ this.#t = t, this.#r = r, this.#s = n, this.parent = /** @type {Effect} */
570
+ M.b, this.#e = !!this.#r.pending, this.#a = tr(() => {
571
+ M.b = this;
572
+ {
573
+ var i = this.#g();
574
+ try {
575
+ this.#i = ue(() => n(i));
576
+ } catch (a) {
577
+ this.error(a);
578
+ }
579
+ this.#d > 0 ? this.#p() : this.#e = !1;
580
+ }
581
+ return () => {
582
+ this.#f?.remove();
583
+ };
584
+ }, ua);
585
+ }
586
+ #b() {
587
+ try {
588
+ this.#i = ue(() => this.#s(this.#t));
589
+ } catch (t) {
590
+ this.error(t);
591
+ }
592
+ this.#e = !1;
593
+ }
594
+ #y() {
595
+ const t = this.#r.pending;
596
+ t && (this.#o = ue(() => t(this.#t)), xe.enqueue(() => {
597
+ var r = this.#g();
598
+ this.#i = this.#h(() => (xe.ensure(), ue(() => this.#s(r)))), this.#d > 0 ? this.#p() : (Ke(
599
+ /** @type {Effect} */
600
+ this.#o,
601
+ () => {
602
+ this.#o = null;
603
+ }
604
+ ), this.#e = !1);
605
+ }));
606
+ }
607
+ #g() {
608
+ var t = this.#t;
609
+ return this.#e && (this.#f = qe(), this.#t.before(this.#f), t = this.#f), t;
610
+ }
611
+ /**
612
+ * Returns `true` if the effect exists inside a boundary whose pending snippet is shown
613
+ * @returns {boolean}
614
+ */
615
+ is_pending() {
616
+ return this.#e || !!this.parent && this.parent.is_pending();
617
+ }
618
+ has_pending_snippet() {
619
+ return !!this.#r.pending;
620
+ }
621
+ /**
622
+ * @param {() => Effect | null} fn
623
+ */
624
+ #h(t) {
625
+ var r = M, n = k, i = ae;
626
+ Ce(this.#a), fe(this.#a), dt(this.#a.ctx);
627
+ try {
628
+ return t();
629
+ } catch (a) {
630
+ return fn(a), null;
631
+ } finally {
632
+ Ce(r), fe(n), dt(i);
633
+ }
634
+ }
635
+ #p() {
636
+ const t = (
637
+ /** @type {(anchor: Node) => void} */
638
+ this.#r.pending
639
+ );
640
+ this.#i !== null && (this.#u = document.createDocumentFragment(), this.#u.append(
641
+ /** @type {TemplateNode} */
642
+ this.#f
643
+ ), Ln(this.#i, this.#u)), this.#o === null && (this.#o = ue(() => t(this.#t)));
644
+ }
645
+ /**
646
+ * Updates the pending count associated with the currently visible pending snippet,
647
+ * if any, such that we can replace the snippet with content once work is done
648
+ * @param {1 | -1} d
649
+ */
650
+ #m(t) {
651
+ if (!this.has_pending_snippet()) {
652
+ this.parent && this.parent.#m(t);
653
+ return;
654
+ }
655
+ this.#d += t, this.#d === 0 && (this.#e = !1, this.#o && Ke(this.#o, () => {
656
+ this.#o = null;
657
+ }), this.#u && (this.#t.before(this.#u), this.#u = null));
658
+ }
659
+ /**
660
+ * Update the source that powers `$effect.pending()` inside this boundary,
661
+ * and controls when the current `pending` snippet (if any) is removed.
662
+ * Do not call from inside the class
663
+ * @param {1 | -1} d
664
+ */
665
+ update_pending_count(t) {
666
+ this.#m(t), this.#c += t, this.#v && _t(this.#v, this.#c);
667
+ }
668
+ get_effect_pending() {
669
+ return this.#w(), o(
670
+ /** @type {Source<number>} */
671
+ this.#v
672
+ );
673
+ }
674
+ /** @param {unknown} error */
675
+ error(t) {
676
+ var r = this.#r.onerror;
677
+ let n = this.#r.failed;
678
+ if (this.#_ || !r && !n)
679
+ throw t;
680
+ this.#i && (J(this.#i), this.#i = null), this.#o && (J(this.#o), this.#o = null), this.#l && (J(this.#l), this.#l = null);
681
+ var i = !1, a = !1;
682
+ const l = () => {
683
+ if (i) {
684
+ Qi();
685
+ return;
686
+ }
687
+ i = !0, a && Fi(), xe.ensure(), this.#c = 0, this.#l !== null && Ke(this.#l, () => {
688
+ this.#l = null;
689
+ }), this.#e = this.has_pending_snippet(), this.#i = this.#h(() => (this.#_ = !1, ue(() => this.#s(this.#t)))), this.#d > 0 ? this.#p() : this.#e = !1;
690
+ };
691
+ var f = k;
692
+ try {
693
+ fe(null), a = !0, r?.(t, l), a = !1;
694
+ } catch (s) {
695
+ vt(s, this.#a && this.#a.parent);
696
+ } finally {
697
+ fe(f);
698
+ }
699
+ n && rt(() => {
700
+ this.#l = this.#h(() => {
701
+ xe.ensure(), this.#_ = !0;
702
+ try {
703
+ return ue(() => {
704
+ n(
705
+ this.#t,
706
+ () => t,
707
+ () => l
708
+ );
709
+ });
710
+ } catch (s) {
711
+ return vt(
712
+ s,
713
+ /** @type {Effect} */
714
+ this.#a.parent
715
+ ), null;
716
+ } finally {
717
+ this.#_ = !1;
718
+ }
719
+ });
720
+ });
721
+ }
722
+ }
723
+ function vn(e, t, r, n) {
724
+ const i = Qt;
725
+ if (r.length === 0 && e.length === 0) {
726
+ n(t.map(i));
727
+ return;
728
+ }
729
+ var a = P, l = (
730
+ /** @type {Effect} */
731
+ M
732
+ ), f = da();
733
+ function s() {
734
+ Promise.all(r.map((u) => /* @__PURE__ */ va(u))).then((u) => {
735
+ f();
736
+ try {
737
+ n([...t.map(i), ...u]);
738
+ } catch (c) {
739
+ (l.f & Pe) === 0 && vt(c, l);
740
+ }
741
+ a?.deactivate(), Ut();
742
+ }).catch((u) => {
743
+ vt(u, l);
744
+ });
745
+ }
746
+ e.length > 0 ? Promise.all(e).then(() => {
747
+ f();
748
+ try {
749
+ return s();
750
+ } finally {
751
+ a?.deactivate(), Ut();
752
+ }
753
+ }) : s();
754
+ }
755
+ function da() {
756
+ var e = M, t = k, r = ae, n = P;
757
+ return function(a = !0) {
758
+ Ce(e), fe(t), dt(r), a && n?.activate();
759
+ };
760
+ }
761
+ function Ut() {
762
+ Ce(null), fe(null), dt(null);
763
+ }
764
+ // @__NO_SIDE_EFFECTS__
765
+ function Qt(e) {
766
+ var t = Q | ce, r = k !== null && (k.f & Q) !== 0 ? (
767
+ /** @type {Derived} */
768
+ k
769
+ ) : null;
770
+ return M !== null && (M.f |= ht), {
771
+ ctx: ae,
772
+ deps: null,
773
+ effects: null,
774
+ equals: ln,
775
+ f: t,
776
+ fn: e,
777
+ reactions: null,
778
+ rv: 0,
779
+ v: (
780
+ /** @type {V} */
781
+ X
782
+ ),
783
+ wv: 0,
784
+ parent: r ?? M,
785
+ ac: null
786
+ };
787
+ }
788
+ // @__NO_SIDE_EFFECTS__
789
+ function va(e, t) {
790
+ let r = (
791
+ /** @type {Effect | null} */
792
+ M
793
+ );
794
+ r === null && Mi();
795
+ var n = (
796
+ /** @type {Boundary} */
797
+ r.b
798
+ ), i = (
799
+ /** @type {Promise<V>} */
800
+ /** @type {unknown} */
801
+ void 0
802
+ ), a = et(
803
+ /** @type {V} */
804
+ X
805
+ ), l = !k, f = /* @__PURE__ */ new Map();
806
+ return Aa(() => {
807
+ var s = rn();
808
+ i = s.promise;
809
+ try {
810
+ Promise.resolve(e()).then(s.resolve, s.reject).then(() => {
811
+ u === P && u.committed && u.deactivate(), Ut();
812
+ });
813
+ } catch (v) {
814
+ s.reject(v), Ut();
815
+ }
816
+ var u = (
817
+ /** @type {Batch} */
818
+ P
819
+ );
820
+ if (l) {
821
+ var c = !n.is_pending();
822
+ n.update_pending_count(1), u.increment(c), f.get(u)?.reject(ut), f.delete(u), f.set(u, s);
823
+ }
824
+ const d = (v, _ = void 0) => {
825
+ if (u.activate(), _)
826
+ _ !== ut && (a.f |= He, _t(a, _));
827
+ else {
828
+ (a.f & He) !== 0 && (a.f ^= He), _t(a, v);
829
+ for (const [p, w] of f) {
830
+ if (f.delete(p), p === u) break;
831
+ w.reject(ut);
832
+ }
833
+ }
834
+ l && (n.update_pending_count(-1), u.decrement(c));
835
+ };
836
+ s.promise.then(d, (v) => d(null, v || "unknown"));
837
+ }), xn(() => {
838
+ for (const s of f.values())
839
+ s.reject(ut);
840
+ }), new Promise((s) => {
841
+ function u(c) {
842
+ function d() {
843
+ c === i ? s(a) : u(i);
844
+ }
845
+ c.then(d, d);
846
+ }
847
+ u(i);
848
+ });
849
+ }
850
+ // @__NO_SIDE_EFFECTS__
851
+ function L(e) {
852
+ const t = /* @__PURE__ */ Qt(e);
853
+ return Pn(t), t;
854
+ }
855
+ // @__NO_SIDE_EFFECTS__
856
+ function _n(e) {
857
+ const t = /* @__PURE__ */ Qt(e);
858
+ return t.equals = sn, t;
859
+ }
860
+ function hn(e) {
861
+ var t = e.effects;
862
+ if (t !== null) {
863
+ e.effects = null;
864
+ for (var r = 0; r < t.length; r += 1)
865
+ J(
866
+ /** @type {Effect} */
867
+ t[r]
868
+ );
869
+ }
870
+ }
871
+ function _a(e) {
872
+ for (var t = e.parent; t !== null; ) {
873
+ if ((t.f & Q) === 0)
874
+ return (t.f & Pe) === 0 ? (
875
+ /** @type {Effect} */
876
+ t
877
+ ) : null;
878
+ t = t.parent;
879
+ }
880
+ return null;
881
+ }
882
+ function Tr(e) {
883
+ var t, r = M;
884
+ Ce(_a(e));
885
+ try {
886
+ e.f &= ~Je, hn(e), t = zn(e);
887
+ } finally {
888
+ Ce(r);
889
+ }
890
+ return t;
891
+ }
892
+ function pn(e) {
893
+ var t = Tr(e);
894
+ if (e.equals(t) || (P?.is_fork || (e.v = t), e.wv = Nn()), !nt)
895
+ if (me !== null)
896
+ (Tt() || P?.is_fork) && me.set(e, t);
897
+ else {
898
+ var r = (e.f & be) === 0 ? ze : te;
899
+ re(e, r);
900
+ }
901
+ }
902
+ let vr = /* @__PURE__ */ new Set();
903
+ const Ve = /* @__PURE__ */ new Map();
904
+ let gn = !1;
905
+ function et(e, t) {
906
+ var r = {
907
+ f: 0,
908
+ // TODO ideally we could skip this altogether, but it causes type errors
909
+ v: e,
910
+ reactions: null,
911
+ equals: ln,
912
+ rv: 0,
913
+ wv: 0
914
+ };
915
+ return r;
916
+ }
917
+ // @__NO_SIDE_EFFECTS__
918
+ function O(e, t) {
919
+ const r = et(e);
920
+ return Pn(r), r;
921
+ }
922
+ // @__NO_SIDE_EFFECTS__
923
+ function ha(e, t = !1, r = !0) {
924
+ const n = et(e);
925
+ return t || (n.equals = sn), n;
926
+ }
927
+ function x(e, t, r = !1) {
928
+ k !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
929
+ // to ensure we error if state is set inside an inspect effect
930
+ (!Se || (k.f & Or) !== 0) && un() && (k.f & (Q | Ne | Cr | Or)) !== 0 && !Oe?.includes(e) && $i();
931
+ let n = r ? We(t) : t;
932
+ return _t(e, n);
933
+ }
934
+ function _t(e, t) {
935
+ if (!e.equals(t)) {
936
+ var r = e.v;
937
+ nt ? Ve.set(e, t) : Ve.set(e, r), e.v = t;
938
+ var n = xe.ensure();
939
+ n.capture(e, r), (e.f & Q) !== 0 && ((e.f & ce) !== 0 && Tr(
940
+ /** @type {Derived} */
941
+ e
942
+ ), re(e, (e.f & be) !== 0 ? te : ze)), e.wv = Nn(), mn(e, ce), M !== null && (M.f & te) !== 0 && (M.f & (Re | tt)) === 0 && (ge === null ? Ta([e]) : ge.push(e)), !n.is_fork && vr.size > 0 && !gn && pa();
943
+ }
944
+ return t;
945
+ }
946
+ function pa() {
947
+ gn = !1;
948
+ var e = Ge;
949
+ Yt(!0);
950
+ const t = Array.from(vr);
951
+ try {
952
+ for (const r of t)
953
+ (r.f & te) !== 0 && re(r, ze), Ot(r) && Dt(r);
954
+ } finally {
955
+ Yt(e);
956
+ }
957
+ vr.clear();
958
+ }
959
+ function Rr(e, t = 1) {
960
+ var r = o(e), n = t === 1 ? r++ : r--;
961
+ return x(e, r), n;
962
+ }
963
+ function It(e) {
964
+ x(e, e.v + 1);
965
+ }
966
+ function mn(e, t) {
967
+ var r = e.reactions;
968
+ if (r !== null)
969
+ for (var n = r.length, i = 0; i < n; i++) {
970
+ var a = r[i], l = a.f, f = (l & ce) === 0;
971
+ if (f && re(a, t), (l & Q) !== 0) {
972
+ var s = (
973
+ /** @type {Derived} */
974
+ a
975
+ );
976
+ me?.delete(s), (l & Je) === 0 && (l & be && (a.f |= Je), mn(s, ze));
977
+ } else f && ((l & Ne) !== 0 && De !== null && De.add(
978
+ /** @type {Effect} */
979
+ a
980
+ ), Qe(
981
+ /** @type {Effect} */
982
+ a
983
+ ));
984
+ }
985
+ }
986
+ function We(e) {
987
+ if (typeof e != "object" || e === null || Ye in e)
988
+ return e;
989
+ const t = en(e);
990
+ if (t !== xi && t !== Si)
991
+ return e;
992
+ var r = /* @__PURE__ */ new Map(), n = yr(e), i = /* @__PURE__ */ O(0), a = Ze, l = (f) => {
993
+ if (Ze === a)
994
+ return f();
995
+ var s = k, u = Ze;
996
+ fe(null), Wr(a);
997
+ var c = f();
998
+ return fe(s), Wr(u), c;
999
+ };
1000
+ return n && r.set("length", /* @__PURE__ */ O(
1001
+ /** @type {any[]} */
1002
+ e.length
1003
+ )), new Proxy(
1004
+ /** @type {any} */
1005
+ e,
1006
+ {
1007
+ defineProperty(f, s, u) {
1008
+ (!("value" in u) || u.configurable === !1 || u.enumerable === !1 || u.writable === !1) && Ri();
1009
+ var c = r.get(s);
1010
+ return c === void 0 ? c = l(() => {
1011
+ var d = /* @__PURE__ */ O(u.value);
1012
+ return r.set(s, d), d;
1013
+ }) : x(c, u.value, !0), !0;
1014
+ },
1015
+ deleteProperty(f, s) {
1016
+ var u = r.get(s);
1017
+ if (u === void 0) {
1018
+ if (s in f) {
1019
+ const c = l(() => /* @__PURE__ */ O(X));
1020
+ r.set(s, c), It(i);
1021
+ }
1022
+ } else
1023
+ x(u, X), It(i);
1024
+ return !0;
1025
+ },
1026
+ get(f, s, u) {
1027
+ if (s === Ye)
1028
+ return e;
1029
+ var c = r.get(s), d = s in f;
1030
+ if (c === void 0 && (!d || ct(f, s)?.writable) && (c = l(() => {
1031
+ var _ = We(d ? f[s] : X), p = /* @__PURE__ */ O(_);
1032
+ return p;
1033
+ }), r.set(s, c)), c !== void 0) {
1034
+ var v = o(c);
1035
+ return v === X ? void 0 : v;
1036
+ }
1037
+ return Reflect.get(f, s, u);
1038
+ },
1039
+ getOwnPropertyDescriptor(f, s) {
1040
+ var u = Reflect.getOwnPropertyDescriptor(f, s);
1041
+ if (u && "value" in u) {
1042
+ var c = r.get(s);
1043
+ c && (u.value = o(c));
1044
+ } else if (u === void 0) {
1045
+ var d = r.get(s), v = d?.v;
1046
+ if (d !== void 0 && v !== X)
1047
+ return {
1048
+ enumerable: !0,
1049
+ configurable: !0,
1050
+ value: v,
1051
+ writable: !0
1052
+ };
1053
+ }
1054
+ return u;
1055
+ },
1056
+ has(f, s) {
1057
+ if (s === Ye)
1058
+ return !0;
1059
+ var u = r.get(s), c = u !== void 0 && u.v !== X || Reflect.has(f, s);
1060
+ if (u !== void 0 || M !== null && (!c || ct(f, s)?.writable)) {
1061
+ u === void 0 && (u = l(() => {
1062
+ var v = c ? We(f[s]) : X, _ = /* @__PURE__ */ O(v);
1063
+ return _;
1064
+ }), r.set(s, u));
1065
+ var d = o(u);
1066
+ if (d === X)
1067
+ return !1;
1068
+ }
1069
+ return c;
1070
+ },
1071
+ set(f, s, u, c) {
1072
+ var d = r.get(s), v = s in f;
1073
+ if (n && s === "length")
1074
+ for (var _ = u; _ < /** @type {Source<number>} */
1075
+ d.v; _ += 1) {
1076
+ var p = r.get(_ + "");
1077
+ p !== void 0 ? x(p, X) : _ in f && (p = l(() => /* @__PURE__ */ O(X)), r.set(_ + "", p));
1078
+ }
1079
+ if (d === void 0)
1080
+ (!v || ct(f, s)?.writable) && (d = l(() => /* @__PURE__ */ O(void 0)), x(d, We(u)), r.set(s, d));
1081
+ else {
1082
+ v = d.v !== X;
1083
+ var w = l(() => We(u));
1084
+ x(d, w);
1085
+ }
1086
+ var h = Reflect.getOwnPropertyDescriptor(f, s);
1087
+ if (h?.set && h.set.call(c, u), !v) {
1088
+ if (n && typeof s == "string") {
1089
+ var g = (
1090
+ /** @type {Source<number>} */
1091
+ r.get("length")
1092
+ ), A = Number(s);
1093
+ Number.isInteger(A) && A >= g.v && x(g, A + 1);
1094
+ }
1095
+ It(i);
1096
+ }
1097
+ return !0;
1098
+ },
1099
+ ownKeys(f) {
1100
+ o(i);
1101
+ var s = Reflect.ownKeys(f).filter((d) => {
1102
+ var v = r.get(d);
1103
+ return v === void 0 || v.v !== X;
1104
+ });
1105
+ for (var [u, c] of r)
1106
+ c.v !== X && !(u in f) && s.push(u);
1107
+ return s;
1108
+ },
1109
+ setPrototypeOf() {
1110
+ zi();
1111
+ }
1112
+ }
1113
+ );
1114
+ }
1115
+ function zr(e) {
1116
+ try {
1117
+ if (e !== null && typeof e == "object" && Ye in e)
1118
+ return e[Ye];
1119
+ } catch {
1120
+ }
1121
+ return e;
1122
+ }
1123
+ function ga(e, t) {
1124
+ return Object.is(zr(e), zr(t));
1125
+ }
1126
+ var $r, wn, bn, yn;
1127
+ function ma() {
1128
+ if ($r === void 0) {
1129
+ $r = window, wn = /Firefox/.test(navigator.userAgent);
1130
+ var e = Element.prototype, t = Node.prototype, r = Text.prototype;
1131
+ bn = ct(t, "firstChild").get, yn = ct(t, "nextSibling").get, Pr(e) && (e.__click = void 0, e.__className = void 0, e.__attributes = null, e.__style = void 0, e.__e = void 0), Pr(r) && (r.__t = void 0);
1132
+ }
1133
+ }
1134
+ function qe(e = "") {
1135
+ return document.createTextNode(e);
1136
+ }
1137
+ // @__NO_SIDE_EFFECTS__
1138
+ function jt(e) {
1139
+ return (
1140
+ /** @type {TemplateNode | null} */
1141
+ bn.call(e)
1142
+ );
1143
+ }
1144
+ // @__NO_SIDE_EFFECTS__
1145
+ function Lt(e) {
1146
+ return (
1147
+ /** @type {TemplateNode | null} */
1148
+ yn.call(e)
1149
+ );
1150
+ }
1151
+ function S(e, t) {
1152
+ return /* @__PURE__ */ jt(e);
1153
+ }
1154
+ function yt(e, t = !1) {
1155
+ {
1156
+ var r = /* @__PURE__ */ jt(e);
1157
+ return r instanceof Comment && r.data === "" ? /* @__PURE__ */ Lt(r) : r;
1158
+ }
1159
+ }
1160
+ function Y(e, t = 1, r = !1) {
1161
+ let n = e;
1162
+ for (; t--; )
1163
+ n = /** @type {TemplateNode} */
1164
+ /* @__PURE__ */ Lt(n);
1165
+ return n;
1166
+ }
1167
+ function wa(e) {
1168
+ e.textContent = "";
1169
+ }
1170
+ function En() {
1171
+ return !1;
1172
+ }
1173
+ function ba(e, t) {
1174
+ if (t) {
1175
+ const r = document.body;
1176
+ e.autofocus = !0, rt(() => {
1177
+ document.activeElement === r && e.focus();
1178
+ });
1179
+ }
1180
+ }
1181
+ let Fr = !1;
1182
+ function ya() {
1183
+ Fr || (Fr = !0, document.addEventListener(
1184
+ "reset",
1185
+ (e) => {
1186
+ Promise.resolve().then(() => {
1187
+ if (!e.defaultPrevented)
1188
+ for (
1189
+ const t of
1190
+ /**@type {HTMLFormElement} */
1191
+ e.target.elements
1192
+ )
1193
+ t.__on_r?.();
1194
+ });
1195
+ },
1196
+ // In the capture phase to guarantee we get noticed of it (no possibility of stopPropagation)
1197
+ { capture: !0 }
1198
+ ));
1199
+ }
1200
+ function er(e) {
1201
+ var t = k, r = M;
1202
+ fe(null), Ce(null);
1203
+ try {
1204
+ return e();
1205
+ } finally {
1206
+ fe(t), Ce(r);
1207
+ }
1208
+ }
1209
+ function Ea(e, t, r, n = r) {
1210
+ e.addEventListener(t, () => er(r));
1211
+ const i = e.__on_r;
1212
+ i ? e.__on_r = () => {
1213
+ i(), n(!0);
1214
+ } : e.__on_r = () => n(!0), ya();
1215
+ }
1216
+ function xa(e) {
1217
+ M === null && (k === null && Pi(), Li()), nt && Di();
1218
+ }
1219
+ function Sa(e, t) {
1220
+ var r = t.last;
1221
+ r === null ? t.last = t.first = e : (r.next = e, e.prev = r, t.last = e);
1222
+ }
1223
+ function Ae(e, t, r) {
1224
+ var n = M;
1225
+ n !== null && (n.f & pe) !== 0 && (e |= pe);
1226
+ var i = {
1227
+ ctx: ae,
1228
+ deps: null,
1229
+ nodes: null,
1230
+ f: e | ce | be,
1231
+ first: null,
1232
+ fn: t,
1233
+ last: null,
1234
+ next: null,
1235
+ parent: n,
1236
+ b: n && n.b,
1237
+ prev: null,
1238
+ teardown: null,
1239
+ wv: 0,
1240
+ ac: null
1241
+ };
1242
+ if (r)
1243
+ try {
1244
+ Dt(i), i.f |= Sr;
1245
+ } catch (f) {
1246
+ throw J(i), f;
1247
+ }
1248
+ else t !== null && Qe(i);
1249
+ var a = i;
1250
+ if (r && a.deps === null && a.teardown === null && a.nodes === null && a.first === a.last && // either `null`, or a singular child
1251
+ (a.f & ht) === 0 && (a = a.first, (e & Ne) !== 0 && (e & Xe) !== 0 && a !== null && (a.f |= Xe)), a !== null && (a.parent = n, n !== null && Sa(a, n), k !== null && (k.f & Q) !== 0 && (e & tt) === 0)) {
1252
+ var l = (
1253
+ /** @type {Derived} */
1254
+ k
1255
+ );
1256
+ (l.effects ??= []).push(a);
1257
+ }
1258
+ return i;
1259
+ }
1260
+ function Tt() {
1261
+ return k !== null && !Se;
1262
+ }
1263
+ function xn(e) {
1264
+ const t = Ae(xr, null, !1);
1265
+ return re(t, te), t.teardown = e, t;
1266
+ }
1267
+ function xt(e) {
1268
+ xa();
1269
+ var t = (
1270
+ /** @type {Effect} */
1271
+ M.f
1272
+ ), r = !k && (t & Re) !== 0 && (t & Sr) === 0;
1273
+ if (r) {
1274
+ var n = (
1275
+ /** @type {ComponentContext} */
1276
+ ae
1277
+ );
1278
+ (n.e ??= []).push(e);
1279
+ } else
1280
+ return Sn(e);
1281
+ }
1282
+ function Sn(e) {
1283
+ return Ae(Er | Ai, e, !1);
1284
+ }
1285
+ function Ca(e) {
1286
+ xe.ensure();
1287
+ const t = Ae(tt | ht, e, !0);
1288
+ return (r = {}) => new Promise((n) => {
1289
+ r.outro ? Ke(t, () => {
1290
+ J(t), n(void 0);
1291
+ }) : (J(t), n(void 0));
1292
+ });
1293
+ }
1294
+ function Pt(e) {
1295
+ return Ae(Er, e, !1);
1296
+ }
1297
+ function Aa(e) {
1298
+ return Ae(Cr | ht, e, !0);
1299
+ }
1300
+ function Cn(e, t = 0) {
1301
+ return Ae(xr | t, e, !0);
1302
+ }
1303
+ function Z(e, t = [], r = [], n = []) {
1304
+ vn(n, t, r, (i) => {
1305
+ Ae(xr, () => e(...i.map(o)), !0);
1306
+ });
1307
+ }
1308
+ function tr(e, t = 0) {
1309
+ var r = Ae(Ne | t, e, !0);
1310
+ return r;
1311
+ }
1312
+ function An(e, t = 0) {
1313
+ var r = Ae(nn | t, e, !0);
1314
+ return r;
1315
+ }
1316
+ function ue(e) {
1317
+ return Ae(Re | ht, e, !0);
1318
+ }
1319
+ function In(e) {
1320
+ var t = e.teardown;
1321
+ if (t !== null) {
1322
+ const r = nt, n = k;
1323
+ Br(!0), fe(null);
1324
+ try {
1325
+ t.call(null);
1326
+ } finally {
1327
+ Br(r), fe(n);
1328
+ }
1329
+ }
1330
+ }
1331
+ function kn(e, t = !1) {
1332
+ var r = e.first;
1333
+ for (e.first = e.last = null; r !== null; ) {
1334
+ const i = r.ac;
1335
+ i !== null && er(() => {
1336
+ i.abort(ut);
1337
+ });
1338
+ var n = r.next;
1339
+ (r.f & tt) !== 0 ? r.parent = null : J(r, t), r = n;
1340
+ }
1341
+ }
1342
+ function Ia(e) {
1343
+ for (var t = e.first; t !== null; ) {
1344
+ var r = t.next;
1345
+ (t.f & Re) === 0 && J(t), t = r;
1346
+ }
1347
+ }
1348
+ function J(e, t = !0) {
1349
+ var r = !1;
1350
+ (t || (e.f & an) !== 0) && e.nodes !== null && e.nodes.end !== null && (ka(
1351
+ e.nodes.start,
1352
+ /** @type {TemplateNode} */
1353
+ e.nodes.end
1354
+ ), r = !0), kn(e, t && !r), Kt(e, 0), re(e, Pe);
1355
+ var n = e.nodes && e.nodes.t;
1356
+ if (n !== null)
1357
+ for (const a of n)
1358
+ a.stop();
1359
+ In(e);
1360
+ var i = e.parent;
1361
+ i !== null && i.first !== null && Tn(e), e.next = e.prev = e.teardown = e.ctx = e.deps = e.fn = e.nodes = e.ac = null;
1362
+ }
1363
+ function ka(e, t) {
1364
+ for (; e !== null; ) {
1365
+ var r = e === t ? null : /* @__PURE__ */ Lt(e);
1366
+ e.remove(), e = r;
1367
+ }
1368
+ }
1369
+ function Tn(e) {
1370
+ var t = e.parent, r = e.prev, n = e.next;
1371
+ r !== null && (r.next = n), n !== null && (n.prev = r), t !== null && (t.first === e && (t.first = n), t.last === e && (t.last = r));
1372
+ }
1373
+ function Ke(e, t, r = !0) {
1374
+ var n = [];
1375
+ Mn(e, n, !0);
1376
+ var i = () => {
1377
+ r && J(e), t && t();
1378
+ }, a = n.length;
1379
+ if (a > 0) {
1380
+ var l = () => --a || i();
1381
+ for (var f of n)
1382
+ f.out(l);
1383
+ } else
1384
+ i();
1385
+ }
1386
+ function Mn(e, t, r) {
1387
+ if ((e.f & pe) === 0) {
1388
+ e.f ^= pe;
1389
+ var n = e.nodes && e.nodes.t;
1390
+ if (n !== null)
1391
+ for (const f of n)
1392
+ (f.is_global || r) && t.push(f);
1393
+ for (var i = e.first; i !== null; ) {
1394
+ var a = i.next, l = (i.f & Xe) !== 0 || // If this is a branch effect without a block effect parent,
1395
+ // it means the parent block effect was pruned. In that case,
1396
+ // transparency information was transferred to the branch effect.
1397
+ (i.f & Re) !== 0 && (e.f & Ne) !== 0;
1398
+ Mn(i, t, l ? r : !1), i = a;
1399
+ }
1400
+ }
1401
+ }
1402
+ function Mr(e) {
1403
+ Dn(e, !0);
1404
+ }
1405
+ function Dn(e, t) {
1406
+ if ((e.f & pe) !== 0) {
1407
+ e.f ^= pe, (e.f & te) === 0 && (re(e, ce), Qe(e));
1408
+ for (var r = e.first; r !== null; ) {
1409
+ var n = r.next, i = (r.f & Xe) !== 0 || (r.f & Re) !== 0;
1410
+ Dn(r, i ? t : !1), r = n;
1411
+ }
1412
+ var a = e.nodes && e.nodes.t;
1413
+ if (a !== null)
1414
+ for (const l of a)
1415
+ (l.is_global || t) && l.in();
1416
+ }
1417
+ }
1418
+ function Ln(e, t) {
1419
+ if (e.nodes)
1420
+ for (var r = e.nodes.start, n = e.nodes.end; r !== null; ) {
1421
+ var i = r === n ? null : /* @__PURE__ */ Lt(r);
1422
+ t.append(r), r = i;
1423
+ }
1424
+ }
1425
+ let Ge = !1;
1426
+ function Yt(e) {
1427
+ Ge = e;
1428
+ }
1429
+ let nt = !1;
1430
+ function Br(e) {
1431
+ nt = e;
1432
+ }
1433
+ let k = null, Se = !1;
1434
+ function fe(e) {
1435
+ k = e;
1436
+ }
1437
+ let M = null;
1438
+ function Ce(e) {
1439
+ M = e;
1440
+ }
1441
+ let Oe = null;
1442
+ function Pn(e) {
1443
+ k !== null && (Oe === null ? Oe = [e] : Oe.push(e));
1444
+ }
1445
+ let ie = null, he = 0, ge = null;
1446
+ function Ta(e) {
1447
+ ge = e;
1448
+ }
1449
+ let On = 1, Mt = 0, Ze = Mt;
1450
+ function Wr(e) {
1451
+ Ze = e;
1452
+ }
1453
+ function Nn() {
1454
+ return ++On;
1455
+ }
1456
+ function Ot(e) {
1457
+ var t = e.f;
1458
+ if ((t & ce) !== 0)
1459
+ return !0;
1460
+ if (t & Q && (e.f &= ~Je), (t & ze) !== 0) {
1461
+ var r = e.deps;
1462
+ if (r !== null)
1463
+ for (var n = r.length, i = 0; i < n; i++) {
1464
+ var a = r[i];
1465
+ if (Ot(
1466
+ /** @type {Derived} */
1467
+ a
1468
+ ) && pn(
1469
+ /** @type {Derived} */
1470
+ a
1471
+ ), a.wv > e.wv)
1472
+ return !0;
1473
+ }
1474
+ (t & be) !== 0 && // During time traveling we don't want to reset the status so that
1475
+ // traversal of the graph in the other batches still happens
1476
+ me === null && re(e, te);
1477
+ }
1478
+ return !1;
1479
+ }
1480
+ function Rn(e, t, r = !0) {
1481
+ var n = e.reactions;
1482
+ if (n !== null && !Oe?.includes(e))
1483
+ for (var i = 0; i < n.length; i++) {
1484
+ var a = n[i];
1485
+ (a.f & Q) !== 0 ? Rn(
1486
+ /** @type {Derived} */
1487
+ a,
1488
+ t,
1489
+ !1
1490
+ ) : t === a && (r ? re(a, ce) : (a.f & te) !== 0 && re(a, ze), Qe(
1491
+ /** @type {Effect} */
1492
+ a
1493
+ ));
1494
+ }
1495
+ }
1496
+ function zn(e) {
1497
+ var t = ie, r = he, n = ge, i = k, a = Oe, l = ae, f = Se, s = Ze, u = e.f;
1498
+ ie = /** @type {null | Value[]} */
1499
+ null, he = 0, ge = null, k = (u & (Re | tt)) === 0 ? e : null, Oe = null, dt(e.ctx), Se = !1, Ze = ++Mt, e.ac !== null && (er(() => {
1500
+ e.ac.abort(ut);
1501
+ }), e.ac = null);
1502
+ try {
1503
+ e.f |= cr;
1504
+ var c = (
1505
+ /** @type {Function} */
1506
+ e.fn
1507
+ ), d = c(), v = e.deps;
1508
+ if (ie !== null) {
1509
+ var _;
1510
+ if (Kt(e, he), v !== null && he > 0)
1511
+ for (v.length = he + ie.length, _ = 0; _ < ie.length; _++)
1512
+ v[he + _] = ie[_];
1513
+ else
1514
+ e.deps = v = ie;
1515
+ if (Tt() && (e.f & be) !== 0)
1516
+ for (_ = he; _ < v.length; _++)
1517
+ (v[_].reactions ??= []).push(e);
1518
+ } else v !== null && he < v.length && (Kt(e, he), v.length = he);
1519
+ if (un() && ge !== null && !Se && v !== null && (e.f & (Q | ze | ce)) === 0)
1520
+ for (_ = 0; _ < /** @type {Source[]} */
1521
+ ge.length; _++)
1522
+ Rn(
1523
+ ge[_],
1524
+ /** @type {Effect} */
1525
+ e
1526
+ );
1527
+ return i !== null && i !== e && (Mt++, ge !== null && (n === null ? n = ge : n.push(.../** @type {Source[]} */
1528
+ ge))), (e.f & He) !== 0 && (e.f ^= He), d;
1529
+ } catch (p) {
1530
+ return fn(p);
1531
+ } finally {
1532
+ e.f ^= cr, ie = t, he = r, ge = n, k = i, Oe = a, dt(l), Se = f, Ze = s;
1533
+ }
1534
+ }
1535
+ function Ma(e, t) {
1536
+ let r = t.reactions;
1537
+ if (r !== null) {
1538
+ var n = bi.call(r, e);
1539
+ if (n !== -1) {
1540
+ var i = r.length - 1;
1541
+ i === 0 ? r = t.reactions = null : (r[n] = r[i], r.pop());
1542
+ }
1543
+ }
1544
+ r === null && (t.f & Q) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
1545
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
1546
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
1547
+ (ie === null || !ie.includes(t)) && (re(t, ze), (t.f & be) !== 0 && (t.f ^= be, t.f &= ~Je), hn(
1548
+ /** @type {Derived} **/
1549
+ t
1550
+ ), Kt(
1551
+ /** @type {Derived} **/
1552
+ t,
1553
+ 0
1554
+ ));
1555
+ }
1556
+ function Kt(e, t) {
1557
+ var r = e.deps;
1558
+ if (r !== null)
1559
+ for (var n = t; n < r.length; n++)
1560
+ Ma(e, r[n]);
1561
+ }
1562
+ function Dt(e) {
1563
+ var t = e.f;
1564
+ if ((t & Pe) === 0) {
1565
+ re(e, te);
1566
+ var r = M, n = Ge;
1567
+ M = e, Ge = !0;
1568
+ try {
1569
+ (t & (Ne | nn)) !== 0 ? Ia(e) : kn(e), In(e);
1570
+ var i = zn(e);
1571
+ e.teardown = typeof i == "function" ? i : null, e.wv = On;
1572
+ var a;
1573
+ fr && ta && (e.f & ce) !== 0 && e.deps;
1574
+ } finally {
1575
+ Ge = n, M = r;
1576
+ }
1577
+ }
1578
+ }
1579
+ function o(e) {
1580
+ var t = e.f, r = (t & Q) !== 0;
1581
+ if (k !== null && !Se) {
1582
+ var n = M !== null && (M.f & Pe) !== 0;
1583
+ if (!n && !Oe?.includes(e)) {
1584
+ var i = k.deps;
1585
+ if ((k.f & cr) !== 0)
1586
+ e.rv < Mt && (e.rv = Mt, ie === null && i !== null && i[he] === e ? he++ : ie === null ? ie = [e] : ie.includes(e) || ie.push(e));
1587
+ else {
1588
+ (k.deps ??= []).push(e);
1589
+ var a = e.reactions;
1590
+ a === null ? e.reactions = [k] : a.includes(k) || a.push(k);
1591
+ }
1592
+ }
1593
+ }
1594
+ if (nt) {
1595
+ if (Ve.has(e))
1596
+ return Ve.get(e);
1597
+ if (r) {
1598
+ var l = (
1599
+ /** @type {Derived} */
1600
+ e
1601
+ ), f = l.v;
1602
+ return ((l.f & te) === 0 && l.reactions !== null || Fn(l)) && (f = Tr(l)), Ve.set(l, f), f;
1603
+ }
1604
+ } else r && (!me?.has(e) || P?.is_fork && !Tt()) && (l = /** @type {Derived} */
1605
+ e, Ot(l) && pn(l), Ge && Tt() && (l.f & be) === 0 && $n(l));
1606
+ if (me?.has(e))
1607
+ return me.get(e);
1608
+ if ((e.f & He) !== 0)
1609
+ throw e.v;
1610
+ return e.v;
1611
+ }
1612
+ function $n(e) {
1613
+ if (e.deps !== null) {
1614
+ e.f ^= be;
1615
+ for (const t of e.deps)
1616
+ (t.reactions ??= []).push(e), (t.f & Q) !== 0 && (t.f & be) === 0 && $n(
1617
+ /** @type {Derived} */
1618
+ t
1619
+ );
1620
+ }
1621
+ }
1622
+ function Fn(e) {
1623
+ if (e.v === X) return !0;
1624
+ if (e.deps === null) return !1;
1625
+ for (const t of e.deps)
1626
+ if (Ve.has(t) || (t.f & Q) !== 0 && Fn(
1627
+ /** @type {Derived} */
1628
+ t
1629
+ ))
1630
+ return !0;
1631
+ return !1;
1632
+ }
1633
+ function rr(e) {
1634
+ var t = Se;
1635
+ try {
1636
+ return Se = !0, e();
1637
+ } finally {
1638
+ Se = t;
1639
+ }
1640
+ }
1641
+ const Da = -7169;
1642
+ function re(e, t) {
1643
+ e.f = e.f & Da | t;
1644
+ }
1645
+ function La(e) {
1646
+ return e.endsWith("capture") && e !== "gotpointercapture" && e !== "lostpointercapture";
1647
+ }
1648
+ const Pa = [
1649
+ "beforeinput",
1650
+ "click",
1651
+ "change",
1652
+ "dblclick",
1653
+ "contextmenu",
1654
+ "focusin",
1655
+ "focusout",
1656
+ "input",
1657
+ "keydown",
1658
+ "keyup",
1659
+ "mousedown",
1660
+ "mousemove",
1661
+ "mouseout",
1662
+ "mouseover",
1663
+ "mouseup",
1664
+ "pointerdown",
1665
+ "pointermove",
1666
+ "pointerout",
1667
+ "pointerover",
1668
+ "pointerup",
1669
+ "touchend",
1670
+ "touchmove",
1671
+ "touchstart"
1672
+ ];
1673
+ function Oa(e) {
1674
+ return Pa.includes(e);
1675
+ }
1676
+ const Na = {
1677
+ // no `class: 'className'` because we handle that separately
1678
+ formnovalidate: "formNoValidate",
1679
+ ismap: "isMap",
1680
+ nomodule: "noModule",
1681
+ playsinline: "playsInline",
1682
+ readonly: "readOnly",
1683
+ defaultvalue: "defaultValue",
1684
+ defaultchecked: "defaultChecked",
1685
+ srcobject: "srcObject",
1686
+ novalidate: "noValidate",
1687
+ allowfullscreen: "allowFullscreen",
1688
+ disablepictureinpicture: "disablePictureInPicture",
1689
+ disableremoteplayback: "disableRemotePlayback"
1690
+ };
1691
+ function Ra(e) {
1692
+ return e = e.toLowerCase(), Na[e] ?? e;
1693
+ }
1694
+ const za = ["touchstart", "touchmove"];
1695
+ function $a(e) {
1696
+ return za.includes(e);
1697
+ }
1698
+ const Bn = /* @__PURE__ */ new Set(), _r = /* @__PURE__ */ new Set();
1699
+ function Fa(e, t, r, n = {}) {
1700
+ function i(a) {
1701
+ if (n.capture || St.call(t, a), !a.cancelBubble)
1702
+ return er(() => r?.call(this, a));
1703
+ }
1704
+ return e.startsWith("pointer") || e.startsWith("touch") || e === "wheel" ? rt(() => {
1705
+ t.addEventListener(e, i, n);
1706
+ }) : t.addEventListener(e, i, n), i;
1707
+ }
1708
+ function Wn(e) {
1709
+ for (var t = 0; t < e.length; t++)
1710
+ Bn.add(e[t]);
1711
+ for (var r of _r)
1712
+ r(e);
1713
+ }
1714
+ let Hr = null;
1715
+ function St(e) {
1716
+ var t = this, r = (
1717
+ /** @type {Node} */
1718
+ t.ownerDocument
1719
+ ), n = e.type, i = e.composedPath?.() || [], a = (
1720
+ /** @type {null | Element} */
1721
+ i[0] || e.target
1722
+ );
1723
+ Hr = e;
1724
+ var l = 0, f = Hr === e && e.__root;
1725
+ if (f) {
1726
+ var s = i.indexOf(f);
1727
+ if (s !== -1 && (t === document || t === /** @type {any} */
1728
+ window)) {
1729
+ e.__root = t;
1730
+ return;
1731
+ }
1732
+ var u = i.indexOf(t);
1733
+ if (u === -1)
1734
+ return;
1735
+ s <= u && (l = s);
1736
+ }
1737
+ if (a = /** @type {Element} */
1738
+ i[l] || e.target, a !== t) {
1739
+ yi(e, "currentTarget", {
1740
+ configurable: !0,
1741
+ get() {
1742
+ return a || r;
1743
+ }
1744
+ });
1745
+ var c = k, d = M;
1746
+ fe(null), Ce(null);
1747
+ try {
1748
+ for (var v, _ = []; a !== null; ) {
1749
+ var p = a.assignedSlot || a.parentNode || /** @type {any} */
1750
+ a.host || null;
1751
+ try {
1752
+ var w = a["__" + n];
1753
+ w != null && (!/** @type {any} */
1754
+ a.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
1755
+ // -> the target could not have been disabled because it emits the event in the first place
1756
+ e.target === a) && w.call(a, e);
1757
+ } catch (h) {
1758
+ v ? _.push(h) : v = h;
1759
+ }
1760
+ if (e.cancelBubble || p === t || p === null)
1761
+ break;
1762
+ a = p;
1763
+ }
1764
+ if (v) {
1765
+ for (let h of _)
1766
+ queueMicrotask(() => {
1767
+ throw h;
1768
+ });
1769
+ throw v;
1770
+ }
1771
+ } finally {
1772
+ e.__root = t, delete e.currentTarget, fe(c), Ce(d);
1773
+ }
1774
+ }
1775
+ }
1776
+ function Ba(e) {
1777
+ var t = document.createElement("template");
1778
+ return t.innerHTML = e.replaceAll("<!>", "<!---->"), t.content;
1779
+ }
1780
+ function hr(e, t) {
1781
+ var r = (
1782
+ /** @type {Effect} */
1783
+ M
1784
+ );
1785
+ r.nodes === null && (r.nodes = { start: e, end: t, a: null, t: null });
1786
+ }
1787
+ // @__NO_SIDE_EFFECTS__
1788
+ function U(e, t) {
1789
+ var r = (t & Ki) !== 0, n = (t & Gi) !== 0, i, a = !e.startsWith("<!>");
1790
+ return () => {
1791
+ i === void 0 && (i = Ba(a ? e : "<!>" + e), r || (i = /** @type {TemplateNode} */
1792
+ /* @__PURE__ */ jt(i)));
1793
+ var l = (
1794
+ /** @type {TemplateNode} */
1795
+ n || wn ? document.importNode(i, !0) : i.cloneNode(!0)
1796
+ );
1797
+ if (r) {
1798
+ var f = (
1799
+ /** @type {TemplateNode} */
1800
+ /* @__PURE__ */ jt(l)
1801
+ ), s = (
1802
+ /** @type {TemplateNode} */
1803
+ l.lastChild
1804
+ );
1805
+ hr(f, s);
1806
+ } else
1807
+ hr(l, l);
1808
+ return l;
1809
+ };
1810
+ }
1811
+ function Vr() {
1812
+ var e = document.createDocumentFragment(), t = document.createComment(""), r = qe();
1813
+ return e.append(t, r), hr(t, r), e;
1814
+ }
1815
+ function W(e, t) {
1816
+ e !== null && e.before(
1817
+ /** @type {Node} */
1818
+ t
1819
+ );
1820
+ }
1821
+ function K(e, t) {
1822
+ var r = t == null ? "" : typeof t == "object" ? t + "" : t;
1823
+ r !== (e.__t ??= e.nodeValue) && (e.__t = r, e.nodeValue = r + "");
1824
+ }
1825
+ function Wa(e, t) {
1826
+ return Ha(e, t);
1827
+ }
1828
+ const lt = /* @__PURE__ */ new Map();
1829
+ function Ha(e, { target: t, anchor: r, props: n = {}, events: i, context: a, intro: l = !0 }) {
1830
+ ma();
1831
+ var f = /* @__PURE__ */ new Set(), s = (d) => {
1832
+ for (var v = 0; v < d.length; v++) {
1833
+ var _ = d[v];
1834
+ if (!f.has(_)) {
1835
+ f.add(_);
1836
+ var p = $a(_);
1837
+ t.addEventListener(_, St, { passive: p });
1838
+ var w = lt.get(_);
1839
+ w === void 0 ? (document.addEventListener(_, St, { passive: p }), lt.set(_, 1)) : lt.set(_, w + 1);
1840
+ }
1841
+ }
1842
+ };
1843
+ s(Xt(Bn)), _r.add(s);
1844
+ var u = void 0, c = Ca(() => {
1845
+ var d = r ?? t.appendChild(qe());
1846
+ return fa(
1847
+ /** @type {TemplateNode} */
1848
+ d,
1849
+ {
1850
+ pending: () => {
1851
+ }
1852
+ },
1853
+ (v) => {
1854
+ if (a) {
1855
+ Ar({});
1856
+ var _ = (
1857
+ /** @type {ComponentContext} */
1858
+ ae
1859
+ );
1860
+ _.c = a;
1861
+ }
1862
+ i && (n.$$events = i), u = e(v, n) || {}, a && Ir();
1863
+ }
1864
+ ), () => {
1865
+ for (var v of f) {
1866
+ t.removeEventListener(v, St);
1867
+ var _ = (
1868
+ /** @type {number} */
1869
+ lt.get(v)
1870
+ );
1871
+ --_ === 0 ? (document.removeEventListener(v, St), lt.delete(v)) : lt.set(v, _);
1872
+ }
1873
+ _r.delete(s), d !== r && d.parentNode?.removeChild(d);
1874
+ };
1875
+ });
1876
+ return pr.set(u, c), u;
1877
+ }
1878
+ let pr = /* @__PURE__ */ new WeakMap();
1879
+ function Va(e, t) {
1880
+ const r = pr.get(e);
1881
+ return r ? (pr.delete(e), r(t)) : Promise.resolve();
1882
+ }
1883
+ class Hn {
1884
+ /** @type {TemplateNode} */
1885
+ anchor;
1886
+ /** @type {Map<Batch, Key>} */
1887
+ #e = /* @__PURE__ */ new Map();
1888
+ /**
1889
+ * Map of keys to effects that are currently rendered in the DOM.
1890
+ * These effects are visible and actively part of the document tree.
1891
+ * Example:
1892
+ * ```
1893
+ * {#if condition}
1894
+ * foo
1895
+ * {:else}
1896
+ * bar
1897
+ * {/if}
1898
+ * ```
1899
+ * Can result in the entries `true->Effect` and `false->Effect`
1900
+ * @type {Map<Key, Effect>}
1901
+ */
1902
+ #t = /* @__PURE__ */ new Map();
1903
+ /**
1904
+ * Similar to #onscreen with respect to the keys, but contains branches that are not yet
1905
+ * in the DOM, because their insertion is deferred.
1906
+ * @type {Map<Key, Branch>}
1907
+ */
1908
+ #n = /* @__PURE__ */ new Map();
1909
+ /**
1910
+ * Keys of effects that are currently outroing
1911
+ * @type {Set<Key>}
1912
+ */
1913
+ #r = /* @__PURE__ */ new Set();
1914
+ /**
1915
+ * Whether to pause (i.e. outro) on change, or destroy immediately.
1916
+ * This is necessary for `<svelte:element>`
1917
+ */
1918
+ #s = !0;
1919
+ /**
1920
+ * @param {TemplateNode} anchor
1921
+ * @param {boolean} transition
1922
+ */
1923
+ constructor(t, r = !0) {
1924
+ this.anchor = t, this.#s = r;
1925
+ }
1926
+ #a = () => {
1927
+ var t = (
1928
+ /** @type {Batch} */
1929
+ P
1930
+ );
1931
+ if (this.#e.has(t)) {
1932
+ var r = (
1933
+ /** @type {Key} */
1934
+ this.#e.get(t)
1935
+ ), n = this.#t.get(r);
1936
+ if (n)
1937
+ Mr(n), this.#r.delete(r);
1938
+ else {
1939
+ var i = this.#n.get(r);
1940
+ i && (this.#t.set(r, i.effect), this.#n.delete(r), i.fragment.lastChild.remove(), this.anchor.before(i.fragment), n = i.effect);
1941
+ }
1942
+ for (const [a, l] of this.#e) {
1943
+ if (this.#e.delete(a), a === t)
1944
+ break;
1945
+ const f = this.#n.get(l);
1946
+ f && (J(f.effect), this.#n.delete(l));
1947
+ }
1948
+ for (const [a, l] of this.#t) {
1949
+ if (a === r || this.#r.has(a)) continue;
1950
+ const f = () => {
1951
+ if (Array.from(this.#e.values()).includes(a)) {
1952
+ var u = document.createDocumentFragment();
1953
+ Ln(l, u), u.append(qe()), this.#n.set(a, { effect: l, fragment: u });
1954
+ } else
1955
+ J(l);
1956
+ this.#r.delete(a), this.#t.delete(a);
1957
+ };
1958
+ this.#s || !n ? (this.#r.add(a), Ke(l, f, !1)) : f();
1959
+ }
1960
+ }
1961
+ };
1962
+ /**
1963
+ * @param {Batch} batch
1964
+ */
1965
+ #i = (t) => {
1966
+ this.#e.delete(t);
1967
+ const r = Array.from(this.#e.values());
1968
+ for (const [n, i] of this.#n)
1969
+ r.includes(n) || (J(i.effect), this.#n.delete(n));
1970
+ };
1971
+ /**
1972
+ *
1973
+ * @param {any} key
1974
+ * @param {null | ((target: TemplateNode) => void)} fn
1975
+ */
1976
+ ensure(t, r) {
1977
+ var n = (
1978
+ /** @type {Batch} */
1979
+ P
1980
+ ), i = En();
1981
+ if (r && !this.#t.has(t) && !this.#n.has(t))
1982
+ if (i) {
1983
+ var a = document.createDocumentFragment(), l = qe();
1984
+ a.append(l), this.#n.set(t, {
1985
+ effect: ue(() => r(l)),
1986
+ fragment: a
1987
+ });
1988
+ } else
1989
+ this.#t.set(
1990
+ t,
1991
+ ue(() => r(this.anchor))
1992
+ );
1993
+ if (this.#e.set(n, t), i) {
1994
+ for (const [f, s] of this.#t)
1995
+ f === t ? n.skipped_effects.delete(s) : n.skipped_effects.add(s);
1996
+ for (const [f, s] of this.#n)
1997
+ f === t ? n.skipped_effects.delete(s.effect) : n.skipped_effects.add(s.effect);
1998
+ n.oncommit(this.#a), n.ondiscard(this.#i);
1999
+ } else
2000
+ this.#a();
2001
+ }
2002
+ }
2003
+ function Me(e, t, r = !1) {
2004
+ var n = new Hn(e), i = r ? Xe : 0;
2005
+ function a(l, f) {
2006
+ n.ensure(l, f);
2007
+ }
2008
+ tr(() => {
2009
+ var l = !1;
2010
+ t((f, s = !0) => {
2011
+ l = !0, a(s, f);
2012
+ }), l || a(!1, null);
2013
+ }, i);
2014
+ }
2015
+ function lr(e, t) {
2016
+ return t;
2017
+ }
2018
+ function qa(e, t, r) {
2019
+ for (var n = [], i = t.length, a, l = t.length, f = 0; f < i; f++) {
2020
+ let d = t[f];
2021
+ Ke(
2022
+ d,
2023
+ () => {
2024
+ if (a) {
2025
+ if (a.pending.delete(d), a.done.add(d), a.pending.size === 0) {
2026
+ var v = (
2027
+ /** @type {Set<EachOutroGroup>} */
2028
+ e.outrogroups
2029
+ );
2030
+ gr(Xt(a.done)), v.delete(a), v.size === 0 && (e.outrogroups = null);
2031
+ }
2032
+ } else
2033
+ l -= 1;
2034
+ },
2035
+ !1
2036
+ );
2037
+ }
2038
+ if (l === 0) {
2039
+ var s = n.length === 0 && r !== null;
2040
+ if (s) {
2041
+ var u = (
2042
+ /** @type {Element} */
2043
+ r
2044
+ ), c = (
2045
+ /** @type {Element} */
2046
+ u.parentNode
2047
+ );
2048
+ wa(c), c.append(u), e.items.clear();
2049
+ }
2050
+ gr(t, !s);
2051
+ } else
2052
+ a = {
2053
+ pending: new Set(t),
2054
+ done: /* @__PURE__ */ new Set()
2055
+ }, (e.outrogroups ??= /* @__PURE__ */ new Set()).add(a);
2056
+ }
2057
+ function gr(e, t = !0) {
2058
+ for (var r = 0; r < e.length; r++)
2059
+ J(e[r], t);
2060
+ }
2061
+ var qr;
2062
+ function Vt(e, t, r, n, i, a = null) {
2063
+ var l = e, f = /* @__PURE__ */ new Map(), s = (t & on) !== 0;
2064
+ if (s) {
2065
+ var u = (
2066
+ /** @type {Element} */
2067
+ e
2068
+ );
2069
+ l = u.appendChild(qe());
2070
+ }
2071
+ var c = null, d = /* @__PURE__ */ _n(() => {
2072
+ var g = r();
2073
+ return yr(g) ? g : g == null ? [] : Xt(g);
2074
+ }), v, _ = !0;
2075
+ function p() {
2076
+ h.fallback = c, Ua(h, v, l, t, n), c !== null && (v.length === 0 ? (c.f & Le) === 0 ? Mr(c) : (c.f ^= Le, Ct(c, null, l)) : Ke(c, () => {
2077
+ c = null;
2078
+ }));
2079
+ }
2080
+ var w = tr(() => {
2081
+ v = /** @type {V[]} */
2082
+ o(d);
2083
+ for (var g = v.length, A = /* @__PURE__ */ new Set(), y = (
2084
+ /** @type {Batch} */
2085
+ P
2086
+ ), E = En(), C = 0; C < g; C += 1) {
2087
+ var R = v[C], I = n(R, C), z = _ ? null : f.get(I);
2088
+ z ? (z.v && _t(z.v, R), z.i && _t(z.i, C), E && y.skipped_effects.delete(z.e)) : (z = ja(
2089
+ f,
2090
+ _ ? l : qr ??= qe(),
2091
+ R,
2092
+ I,
2093
+ C,
2094
+ i,
2095
+ t,
2096
+ r
2097
+ ), _ || (z.e.f |= Le), f.set(I, z)), A.add(I);
2098
+ }
2099
+ if (g === 0 && a && !c && (_ ? c = ue(() => a(l)) : (c = ue(() => a(qr ??= qe())), c.f |= Le)), !_)
2100
+ if (E) {
2101
+ for (const [de, j] of f)
2102
+ A.has(de) || y.skipped_effects.add(j.e);
2103
+ y.oncommit(p), y.ondiscard(() => {
2104
+ });
2105
+ } else
2106
+ p();
2107
+ o(d);
2108
+ }), h = { effect: w, items: f, outrogroups: null, fallback: c };
2109
+ _ = !1;
2110
+ }
2111
+ function Ua(e, t, r, n, i) {
2112
+ var a = (n & Hi) !== 0, l = t.length, f = e.items, s = e.effect.first, u, c = null, d, v = [], _ = [], p, w, h, g;
2113
+ if (a)
2114
+ for (g = 0; g < l; g += 1)
2115
+ p = t[g], w = i(p, g), h = /** @type {EachItem} */
2116
+ f.get(w).e, (h.f & Le) === 0 && (h.nodes?.a?.measure(), (d ??= /* @__PURE__ */ new Set()).add(h));
2117
+ for (g = 0; g < l; g += 1) {
2118
+ if (p = t[g], w = i(p, g), h = /** @type {EachItem} */
2119
+ f.get(w).e, e.outrogroups !== null)
2120
+ for (const j of e.outrogroups)
2121
+ j.pending.delete(h), j.done.delete(h);
2122
+ if ((h.f & Le) !== 0)
2123
+ if (h.f ^= Le, h === s)
2124
+ Ct(h, null, r);
2125
+ else {
2126
+ var A = c ? c.next : s;
2127
+ h === e.effect.last && (e.effect.last = h.prev), h.prev && (h.prev.next = h.next), h.next && (h.next.prev = h.prev), Be(e, c, h), Be(e, h, A), Ct(h, A, r), c = h, v = [], _ = [], s = c.next;
2128
+ continue;
2129
+ }
2130
+ if ((h.f & pe) !== 0 && (Mr(h), a && (h.nodes?.a?.unfix(), (d ??= /* @__PURE__ */ new Set()).delete(h))), h !== s) {
2131
+ if (u !== void 0 && u.has(h)) {
2132
+ if (v.length < _.length) {
2133
+ var y = _[0], E;
2134
+ c = y.prev;
2135
+ var C = v[0], R = v[v.length - 1];
2136
+ for (E = 0; E < v.length; E += 1)
2137
+ Ct(v[E], y, r);
2138
+ for (E = 0; E < _.length; E += 1)
2139
+ u.delete(_[E]);
2140
+ Be(e, C.prev, R.next), Be(e, c, C), Be(e, R, y), s = y, c = R, g -= 1, v = [], _ = [];
2141
+ } else
2142
+ u.delete(h), Ct(h, s, r), Be(e, h.prev, h.next), Be(e, h, c === null ? e.effect.first : c.next), Be(e, c, h), c = h;
2143
+ continue;
2144
+ }
2145
+ for (v = [], _ = []; s !== null && s !== h; )
2146
+ (u ??= /* @__PURE__ */ new Set()).add(s), _.push(s), s = s.next;
2147
+ if (s === null)
2148
+ continue;
2149
+ }
2150
+ (h.f & Le) === 0 && v.push(h), c = h, s = h.next;
2151
+ }
2152
+ if (e.outrogroups !== null) {
2153
+ for (const j of e.outrogroups)
2154
+ j.pending.size === 0 && (gr(Xt(j.done)), e.outrogroups?.delete(j));
2155
+ e.outrogroups.size === 0 && (e.outrogroups = null);
2156
+ }
2157
+ if (s !== null || u !== void 0) {
2158
+ var I = [];
2159
+ if (u !== void 0)
2160
+ for (h of u)
2161
+ (h.f & pe) === 0 && I.push(h);
2162
+ for (; s !== null; )
2163
+ (s.f & pe) === 0 && s !== e.fallback && I.push(s), s = s.next;
2164
+ var z = I.length;
2165
+ if (z > 0) {
2166
+ var de = (n & on) !== 0 && l === 0 ? r : null;
2167
+ if (a) {
2168
+ for (g = 0; g < z; g += 1)
2169
+ I[g].nodes?.a?.measure();
2170
+ for (g = 0; g < z; g += 1)
2171
+ I[g].nodes?.a?.fix();
2172
+ }
2173
+ qa(e, I, de);
2174
+ }
2175
+ }
2176
+ a && rt(() => {
2177
+ if (d !== void 0)
2178
+ for (h of d)
2179
+ h.nodes?.a?.apply();
2180
+ });
2181
+ }
2182
+ function ja(e, t, r, n, i, a, l, f) {
2183
+ var s = (l & Bi) !== 0 ? (l & Vi) === 0 ? /* @__PURE__ */ ha(r, !1, !1) : et(r) : null, u = (l & Wi) !== 0 ? et(i) : null;
2184
+ return {
2185
+ v: s,
2186
+ i: u,
2187
+ e: ue(() => (a(t, s ?? r, u ?? i, f), () => {
2188
+ e.delete(n);
2189
+ }))
2190
+ };
2191
+ }
2192
+ function Ct(e, t, r) {
2193
+ if (e.nodes)
2194
+ for (var n = e.nodes.start, i = e.nodes.end, a = t && (t.f & Le) === 0 ? (
2195
+ /** @type {EffectNodes} */
2196
+ t.nodes.start
2197
+ ) : r; n !== null; ) {
2198
+ var l = (
2199
+ /** @type {TemplateNode} */
2200
+ /* @__PURE__ */ Lt(n)
2201
+ );
2202
+ if (a.before(n), n === i)
2203
+ return;
2204
+ n = l;
2205
+ }
2206
+ }
2207
+ function Be(e, t, r) {
2208
+ t === null ? e.effect.first = r : t.next = r, r === null ? e.effect.last = t : r.prev = t;
2209
+ }
2210
+ function Vn(e, t, ...r) {
2211
+ var n = new Hn(e);
2212
+ tr(() => {
2213
+ const i = t() ?? null;
2214
+ n.ensure(i, i && ((a) => i(a, ...r)));
2215
+ }, Xe);
2216
+ }
2217
+ function Ya(e, t, r) {
2218
+ Pt(() => {
2219
+ var n = rr(() => t(e, r?.()) || {});
2220
+ if (n?.destroy)
2221
+ return () => (
2222
+ /** @type {Function} */
2223
+ n.destroy()
2224
+ );
2225
+ });
2226
+ }
2227
+ function Ka(e, t) {
2228
+ var r = void 0, n;
2229
+ An(() => {
2230
+ r !== (r = t()) && (n && (J(n), n = null), r && (n = ue(() => {
2231
+ Pt(() => (
2232
+ /** @type {(node: Element) => void} */
2233
+ r(e)
2234
+ ));
2235
+ })));
2236
+ });
2237
+ }
2238
+ function qn(e) {
2239
+ var t, r, n = "";
2240
+ if (typeof e == "string" || typeof e == "number") n += e;
2241
+ else if (typeof e == "object") if (Array.isArray(e)) {
2242
+ var i = e.length;
2243
+ for (t = 0; t < i; t++) e[t] && (r = qn(e[t])) && (n && (n += " "), n += r);
2244
+ } else for (r in e) e[r] && (n && (n += " "), n += r);
2245
+ return n;
2246
+ }
2247
+ function Ga() {
2248
+ for (var e, t, r = 0, n = "", i = arguments.length; r < i; r++) (e = arguments[r]) && (t = qn(e)) && (n && (n += " "), n += t);
2249
+ return n;
2250
+ }
2251
+ function Za(e) {
2252
+ return typeof e == "object" ? Ga(e) : e ?? "";
2253
+ }
2254
+ const Ur = [...`
2255
+ \r\f \v\uFEFF`];
2256
+ function Xa(e, t, r) {
2257
+ var n = e == null ? "" : "" + e;
2258
+ if (t && (n = n ? n + " " + t : t), r) {
2259
+ for (var i in r)
2260
+ if (r[i])
2261
+ n = n ? n + " " + i : i;
2262
+ else if (n.length)
2263
+ for (var a = i.length, l = 0; (l = n.indexOf(i, l)) >= 0; ) {
2264
+ var f = l + a;
2265
+ (l === 0 || Ur.includes(n[l - 1])) && (f === n.length || Ur.includes(n[f])) ? n = (l === 0 ? "" : n.substring(0, l)) + n.substring(f + 1) : l = f;
2266
+ }
2267
+ }
2268
+ return n === "" ? null : n;
2269
+ }
2270
+ function jr(e, t = !1) {
2271
+ var r = t ? " !important;" : ";", n = "";
2272
+ for (var i in e) {
2273
+ var a = e[i];
2274
+ a != null && a !== "" && (n += " " + i + ": " + a + r);
2275
+ }
2276
+ return n;
2277
+ }
2278
+ function sr(e) {
2279
+ return e[0] !== "-" || e[1] !== "-" ? e.toLowerCase() : e;
2280
+ }
2281
+ function Ja(e, t) {
2282
+ if (t) {
2283
+ var r = "", n, i;
2284
+ if (Array.isArray(t) ? (n = t[0], i = t[1]) : n = t, e) {
2285
+ e = String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
2286
+ var a = !1, l = 0, f = !1, s = [];
2287
+ n && s.push(...Object.keys(n).map(sr)), i && s.push(...Object.keys(i).map(sr));
2288
+ var u = 0, c = -1;
2289
+ const w = e.length;
2290
+ for (var d = 0; d < w; d++) {
2291
+ var v = e[d];
2292
+ if (f ? v === "/" && e[d - 1] === "*" && (f = !1) : a ? a === v && (a = !1) : v === "/" && e[d + 1] === "*" ? f = !0 : v === '"' || v === "'" ? a = v : v === "(" ? l++ : v === ")" && l--, !f && a === !1 && l === 0) {
2293
+ if (v === ":" && c === -1)
2294
+ c = d;
2295
+ else if (v === ";" || d === w - 1) {
2296
+ if (c !== -1) {
2297
+ var _ = sr(e.substring(u, c).trim());
2298
+ if (!s.includes(_)) {
2299
+ v !== ";" && d++;
2300
+ var p = e.substring(u, d).trim();
2301
+ r += " " + p + ";";
2302
+ }
2303
+ }
2304
+ u = d + 1, c = -1;
2305
+ }
2306
+ }
2307
+ }
2308
+ }
2309
+ return n && (r += jr(n)), i && (r += jr(i, !0)), r = r.trim(), r === "" ? null : r;
2310
+ }
2311
+ return e == null ? null : String(e);
2312
+ }
2313
+ function At(e, t, r, n, i, a) {
2314
+ var l = e.__className;
2315
+ if (l !== r || l === void 0) {
2316
+ var f = Xa(r, n, a);
2317
+ f == null ? e.removeAttribute("class") : t ? e.className = f : e.setAttribute("class", f), e.__className = r;
2318
+ } else if (a && i !== a)
2319
+ for (var s in a) {
2320
+ var u = !!a[s];
2321
+ (i == null || u !== !!i[s]) && e.classList.toggle(s, u);
2322
+ }
2323
+ return a;
2324
+ }
2325
+ function ur(e, t = {}, r, n) {
2326
+ for (var i in r) {
2327
+ var a = r[i];
2328
+ t[i] !== a && (r[i] == null ? e.style.removeProperty(i) : e.style.setProperty(i, a, n));
2329
+ }
2330
+ }
2331
+ function mr(e, t, r, n) {
2332
+ var i = e.__style;
2333
+ if (i !== t) {
2334
+ var a = Ja(t, n);
2335
+ a == null ? e.removeAttribute("style") : e.style.cssText = a, e.__style = t;
2336
+ } else n && (Array.isArray(n) ? (ur(e, r?.[0], n[0]), ur(e, r?.[1], n[1], "important")) : ur(e, r, n));
2337
+ return n;
2338
+ }
2339
+ function Gt(e, t, r = !1) {
2340
+ if (e.multiple) {
2341
+ if (t == null)
2342
+ return;
2343
+ if (!yr(t))
2344
+ return Ji();
2345
+ for (var n of e.options)
2346
+ n.selected = t.includes(kt(n));
2347
+ return;
2348
+ }
2349
+ for (n of e.options) {
2350
+ var i = kt(n);
2351
+ if (ga(i, t)) {
2352
+ n.selected = !0;
2353
+ return;
2354
+ }
2355
+ }
2356
+ (!r || t !== void 0) && (e.selectedIndex = -1);
2357
+ }
2358
+ function Un(e) {
2359
+ var t = new MutationObserver(() => {
2360
+ Gt(e, e.__value);
2361
+ });
2362
+ t.observe(e, {
2363
+ // Listen to option element changes
2364
+ childList: !0,
2365
+ subtree: !0,
2366
+ // because of <optgroup>
2367
+ // Listen to option element value attribute changes
2368
+ // (doesn't get notified of select value changes,
2369
+ // because that property is not reflected as an attribute)
2370
+ attributes: !0,
2371
+ attributeFilter: ["value"]
2372
+ }), xn(() => {
2373
+ t.disconnect();
2374
+ });
2375
+ }
2376
+ function Qa(e, t, r = t) {
2377
+ var n = /* @__PURE__ */ new WeakSet(), i = !0;
2378
+ Ea(e, "change", (a) => {
2379
+ var l = a ? "[selected]" : ":checked", f;
2380
+ if (e.multiple)
2381
+ f = [].map.call(e.querySelectorAll(l), kt);
2382
+ else {
2383
+ var s = e.querySelector(l) ?? // will fall back to first non-disabled option if no option is selected
2384
+ e.querySelector("option:not([disabled])");
2385
+ f = s && kt(s);
2386
+ }
2387
+ r(f), P !== null && n.add(P);
2388
+ }), Pt(() => {
2389
+ var a = t();
2390
+ if (e === document.activeElement) {
2391
+ var l = (
2392
+ /** @type {Batch} */
2393
+ Ht ?? P
2394
+ );
2395
+ if (n.has(l))
2396
+ return;
2397
+ }
2398
+ if (Gt(e, a, i), i && a === void 0) {
2399
+ var f = e.querySelector(":checked");
2400
+ f !== null && (a = kt(f), r(a));
2401
+ }
2402
+ e.__value = a, i = !1;
2403
+ }), Un(e);
2404
+ }
2405
+ function kt(e) {
2406
+ return "__value" in e ? e.__value : e.value;
2407
+ }
2408
+ const st = Symbol("class"), Et = Symbol("style"), jn = Symbol("is custom element"), Yn = Symbol("is html");
2409
+ function eo(e, t) {
2410
+ t ? e.hasAttribute("selected") || e.setAttribute("selected", "") : e.removeAttribute("selected");
2411
+ }
2412
+ function ye(e, t, r, n) {
2413
+ var i = Gn(e);
2414
+ i[t] !== (i[t] = r) && (t === "loading" && (e[ki] = r), r == null ? e.removeAttribute(t) : typeof r != "string" && Zn(e).includes(t) ? e[t] = r : e.setAttribute(t, r));
2415
+ }
2416
+ function to(e, t, r, n, i = !1, a = !1) {
2417
+ var l = Gn(e), f = l[jn], s = !l[Yn], u = t || {}, c = e.tagName === "OPTION";
2418
+ for (var d in t)
2419
+ d in r || (r[d] = null);
2420
+ r.class ? r.class = Za(r.class) : (n || r[st]) && (r.class = null), r[Et] && (r.style ??= null);
2421
+ var v = Zn(e);
2422
+ for (const y in r) {
2423
+ let E = r[y];
2424
+ if (c && y === "value" && E == null) {
2425
+ e.value = e.__value = "", u[y] = E;
2426
+ continue;
2427
+ }
2428
+ if (y === "class") {
2429
+ var _ = e.namespaceURI === "http://www.w3.org/1999/xhtml";
2430
+ At(e, _, E, n, t?.[st], r[st]), u[y] = E, u[st] = r[st];
2431
+ continue;
2432
+ }
2433
+ if (y === "style") {
2434
+ mr(e, E, t?.[Et], r[Et]), u[y] = E, u[Et] = r[Et];
2435
+ continue;
2436
+ }
2437
+ var p = u[y];
2438
+ if (!(E === p && !(E === void 0 && e.hasAttribute(y)))) {
2439
+ u[y] = E;
2440
+ var w = y[0] + y[1];
2441
+ if (w !== "$$")
2442
+ if (w === "on") {
2443
+ const C = {}, R = "$$" + y;
2444
+ let I = y.slice(2);
2445
+ var h = Oa(I);
2446
+ if (La(I) && (I = I.slice(0, -7), C.capture = !0), !h && p) {
2447
+ if (E != null) continue;
2448
+ e.removeEventListener(I, u[R], C), u[R] = null;
2449
+ }
2450
+ if (E != null)
2451
+ if (h)
2452
+ e[`__${I}`] = E, Wn([I]);
2453
+ else {
2454
+ let z = function(de) {
2455
+ u[y].call(this, de);
2456
+ };
2457
+ u[R] = Fa(I, e, z, C);
2458
+ }
2459
+ else h && (e[`__${I}`] = void 0);
2460
+ } else if (y === "style")
2461
+ ye(e, y, E);
2462
+ else if (y === "autofocus")
2463
+ ba(
2464
+ /** @type {HTMLElement} */
2465
+ e,
2466
+ !!E
2467
+ );
2468
+ else if (!f && (y === "__value" || y === "value" && E != null))
2469
+ e.value = e.__value = E;
2470
+ else if (y === "selected" && c)
2471
+ eo(
2472
+ /** @type {HTMLOptionElement} */
2473
+ e,
2474
+ E
2475
+ );
2476
+ else {
2477
+ var g = y;
2478
+ s || (g = Ra(g));
2479
+ var A = g === "defaultValue" || g === "defaultChecked";
2480
+ if (E == null && !f && !A)
2481
+ if (l[y] = null, g === "value" || g === "checked") {
2482
+ let C = (
2483
+ /** @type {HTMLInputElement} */
2484
+ e
2485
+ );
2486
+ const R = t === void 0;
2487
+ if (g === "value") {
2488
+ let I = C.defaultValue;
2489
+ C.removeAttribute(g), C.defaultValue = I, C.value = C.__value = R ? I : null;
2490
+ } else {
2491
+ let I = C.defaultChecked;
2492
+ C.removeAttribute(g), C.defaultChecked = I, C.checked = R ? I : !1;
2493
+ }
2494
+ } else
2495
+ e.removeAttribute(y);
2496
+ else A || v.includes(g) && (f || typeof E != "string") ? (e[g] = E, g in l && (l[g] = X)) : typeof E != "function" && ye(e, g, E);
2497
+ }
2498
+ }
2499
+ }
2500
+ return u;
2501
+ }
2502
+ function Kn(e, t, r = [], n = [], i = [], a, l = !1, f = !1) {
2503
+ vn(i, r, n, (s) => {
2504
+ var u = void 0, c = {}, d = e.nodeName === "SELECT", v = !1;
2505
+ if (An(() => {
2506
+ var p = t(...s.map(o)), w = to(
2507
+ e,
2508
+ u,
2509
+ p,
2510
+ a,
2511
+ l,
2512
+ f
2513
+ );
2514
+ v && d && "value" in p && Gt(
2515
+ /** @type {HTMLSelectElement} */
2516
+ e,
2517
+ p.value
2518
+ );
2519
+ for (let g of Object.getOwnPropertySymbols(c))
2520
+ p[g] || J(c[g]);
2521
+ for (let g of Object.getOwnPropertySymbols(p)) {
2522
+ var h = p[g];
2523
+ g.description === Xi && (!u || h !== u[g]) && (c[g] && J(c[g]), c[g] = ue(() => Ka(e, () => h))), w[g] = h;
2524
+ }
2525
+ u = w;
2526
+ }), d) {
2527
+ var _ = (
2528
+ /** @type {HTMLSelectElement} */
2529
+ e
2530
+ );
2531
+ Pt(() => {
2532
+ Gt(
2533
+ _,
2534
+ /** @type {Record<string | symbol, any>} */
2535
+ u.value,
2536
+ !0
2537
+ ), Un(_);
2538
+ });
2539
+ }
2540
+ v = !0;
2541
+ });
2542
+ }
2543
+ function Gn(e) {
2544
+ return (
2545
+ /** @type {Record<string | symbol, unknown>} **/
2546
+ // @ts-expect-error
2547
+ e.__attributes ??= {
2548
+ [jn]: e.nodeName.includes("-"),
2549
+ [Yn]: e.namespaceURI === Zi
2550
+ }
2551
+ );
2552
+ }
2553
+ var Yr = /* @__PURE__ */ new Map();
2554
+ function Zn(e) {
2555
+ var t = e.getAttribute("is") || e.nodeName, r = Yr.get(t);
2556
+ if (r) return r;
2557
+ Yr.set(t, r = []);
2558
+ for (var n, i = e, a = Element.prototype; a !== i; ) {
2559
+ n = Ei(i);
2560
+ for (var l in n)
2561
+ n[l].set && r.push(l);
2562
+ i = en(i);
2563
+ }
2564
+ return r;
2565
+ }
2566
+ function Kr(e, t) {
2567
+ return e === t || e?.[Ye] === t;
2568
+ }
2569
+ function qt(e = {}, t, r, n) {
2570
+ return Pt(() => {
2571
+ var i, a;
2572
+ return Cn(() => {
2573
+ i = a, a = [], rr(() => {
2574
+ e !== r(...a) && (t(e, ...a), i && Kr(r(...i), e) && t(null, ...i));
2575
+ });
2576
+ }), () => {
2577
+ rt(() => {
2578
+ a && Kr(r(...a), e) && t(null, ...a);
2579
+ });
2580
+ };
2581
+ }), e;
2582
+ }
2583
+ let Bt = !1;
2584
+ function ro(e) {
2585
+ var t = Bt;
2586
+ try {
2587
+ return Bt = !1, [e(), Bt];
2588
+ } finally {
2589
+ Bt = t;
2590
+ }
2591
+ }
2592
+ const no = {
2593
+ get(e, t) {
2594
+ if (!e.exclude.includes(t))
2595
+ return e.props[t];
2596
+ },
2597
+ set(e, t) {
2598
+ return !1;
2599
+ },
2600
+ getOwnPropertyDescriptor(e, t) {
2601
+ if (!e.exclude.includes(t) && t in e.props)
2602
+ return {
2603
+ enumerable: !0,
2604
+ configurable: !0,
2605
+ value: e.props[t]
2606
+ };
2607
+ },
2608
+ has(e, t) {
2609
+ return e.exclude.includes(t) ? !1 : t in e.props;
2610
+ },
2611
+ ownKeys(e) {
2612
+ return Reflect.ownKeys(e.props).filter((t) => !e.exclude.includes(t));
2613
+ }
2614
+ };
2615
+ // @__NO_SIDE_EFFECTS__
2616
+ function Xn(e, t, r) {
2617
+ return new Proxy(
2618
+ { props: e, exclude: t },
2619
+ no
2620
+ );
2621
+ }
2622
+ function se(e, t, r, n) {
2623
+ var i = (r & ji) !== 0, a = (r & Yi) !== 0, l = (
2624
+ /** @type {V} */
2625
+ n
2626
+ ), f = !0, s = () => (f && (f = !1, l = a ? rr(
2627
+ /** @type {() => V} */
2628
+ n
2629
+ ) : (
2630
+ /** @type {V} */
2631
+ n
2632
+ )), l), u;
2633
+ if (i) {
2634
+ var c = Ye in e || Ii in e;
2635
+ u = ct(e, t)?.set ?? (c && t in e ? (A) => e[t] = A : void 0);
2636
+ }
2637
+ var d, v = !1;
2638
+ i ? [d, v] = ro(() => (
2639
+ /** @type {V} */
2640
+ e[t]
2641
+ )) : d = /** @type {V} */
2642
+ e[t], d === void 0 && n !== void 0 && (d = s(), u && (Ni(), u(d)));
2643
+ var _;
2644
+ if (_ = () => {
2645
+ var A = (
2646
+ /** @type {V} */
2647
+ e[t]
2648
+ );
2649
+ return A === void 0 ? s() : (f = !0, A);
2650
+ }, (r & Ui) === 0)
2651
+ return _;
2652
+ if (u) {
2653
+ var p = e.$$legacy;
2654
+ return (
2655
+ /** @type {() => V} */
2656
+ (function(A, y) {
2657
+ return arguments.length > 0 ? ((!y || p || v) && u(y ? _() : A), A) : _();
2658
+ })
2659
+ );
2660
+ }
2661
+ var w = !1, h = ((r & qi) !== 0 ? Qt : _n)(() => (w = !1, _()));
2662
+ i && o(h);
2663
+ var g = (
2664
+ /** @type {Effect} */
2665
+ M
2666
+ );
2667
+ return (
2668
+ /** @type {() => V} */
2669
+ (function(A, y) {
2670
+ if (arguments.length > 0) {
2671
+ const E = y ? o(h) : i ? We(A) : A;
2672
+ return x(h, E), w = !0, l !== void 0 && (l = E), A;
2673
+ }
2674
+ return nt && w || (g.f & Pe) !== 0 ? h.v : o(h);
2675
+ })
2676
+ );
2677
+ }
2678
+ const io = ".btn.svelte-kz0hjp{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-kz0hjp:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-kz0hjp:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-kz0hjp:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-kz0hjp{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-kz0hjp:disabled,.btn[disabled].svelte-kz0hjp{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-kz0hjp:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-kz0hjp:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-kz0hjp{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-kz0hjp{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-kz0hjp{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-kz0hjp:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-kz0hjp:active:not(.active),.ghost.active.svelte-kz0hjp{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-kz0hjp:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1h1ta11{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1h1ta11{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1h1ta11{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1h1ta11{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1h1ta11{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1h1ta11:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1h1ta11:focus-visible,.select.open.svelte-1h1ta11{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1h1ta11:is(:where(.svelte-1h1ta11):disabled,[disabled]:where(.svelte-1h1ta11)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1h1ta11{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1h1ta11:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1h1ta11:focus-visible,.ghost.open.svelte-1h1ta11{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1h1ta11{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1h1ta11:not(:popover-open){display:none}.option.svelte-1h1ta11{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1h1ta11{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1h1ta11{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1h1ta11{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1h1ta11{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n", ao = {
2679
+ en: {
2680
+ image_download_title: "Download Image",
2681
+ image_download_close: "Close Download Image",
2682
+ image_download_description: "Download the current canvas as an image.",
2683
+ image_download_mode: "What to download",
2684
+ image_download_mode_composite: "Composite canvas",
2685
+ image_download_mode_composite_hint: "Every image on the current canvas, composited together.",
2686
+ image_download_mode_single: "Single image",
2687
+ image_download_mode_single_hint: "One image from the current canvas.",
2688
+ image_download_mode_world: "Current view",
2689
+ image_download_mode_world_hint: "Everything currently laid out together in the viewer.",
2690
+ image_download_canvas: "Canvas",
2691
+ image_download_image: "Image",
2692
+ image_download_resolution: "Resolution",
2693
+ image_download_resolution_placeholder: "Select a resolution",
2694
+ image_download_downloading: "Downloading...",
2695
+ image_download_download: "Download",
2696
+ image_download_disabled_no_canvas: "Load a manifest to download an image.",
2697
+ image_download_disabled_no_resolution: "Select a resolution to download.",
2698
+ image_download_result_downloaded: "Downloaded {filename}.",
2699
+ image_download_error_failed: "Unable to download image. Check the browser console for details."
2700
+ },
2701
+ de: {
2702
+ image_download_title: "Bild herunterladen",
2703
+ image_download_close: "Bild-Download schließen",
2704
+ image_download_description: "Die aktuelle Leinwand als Bild herunterladen.",
2705
+ image_download_mode: "Was heruntergeladen werden soll",
2706
+ image_download_mode_composite: "Zusammengesetzte Leinwand",
2707
+ image_download_mode_composite_hint: "Alle Bilder der aktuellen Leinwand, zusammengesetzt.",
2708
+ image_download_mode_single: "Einzelbild",
2709
+ image_download_mode_single_hint: "Ein Bild von der aktuellen Leinwand.",
2710
+ image_download_mode_world: "Aktuelle Ansicht",
2711
+ image_download_mode_world_hint: "Alles, was aktuell zusammen im Viewer angezeigt wird.",
2712
+ image_download_canvas: "Leinwand",
2713
+ image_download_image: "Bild",
2714
+ image_download_resolution: "Auflösung",
2715
+ image_download_resolution_placeholder: "Auflösung auswählen",
2716
+ image_download_downloading: "Wird heruntergeladen...",
2717
+ image_download_download: "Herunterladen",
2718
+ image_download_disabled_no_canvas: "Laden Sie ein Manifest, um ein Bild herunterzuladen.",
2719
+ image_download_disabled_no_resolution: "Wählen Sie eine Auflösung zum Herunterladen aus.",
2720
+ image_download_result_downloaded: "{filename} heruntergeladen.",
2721
+ image_download_error_failed: "Bild kann nicht heruntergeladen werden. Details in der Browserkonsole."
2722
+ }
2723
+ }, Jn = Symbol("triiiceratops:plugin-image-download"), oo = "0 0 256 256", lo = '<path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/>', Qn = fi(
2724
+ `<svg viewBox="${oo}">${lo}</svg>`
2725
+ ), so = "5";
2726
+ typeof window < "u" && ((window.__svelte ??= {}).v ??= /* @__PURE__ */ new Set()).add(so);
2727
+ var uo = /* @__PURE__ */ U("<button><!></button>");
2728
+ function fo(e, t) {
2729
+ let r = se(t, "variant", 3, "default"), n = se(t, "size", 3, "md"), i = se(t, "circle", 3, !1), a = se(t, "square", 3, !1), l = se(t, "ghost", 3, !1), f = se(t, "outline", 3, !1), s = se(t, "active", 3, !1), u = se(t, "class", 3, ""), c = se(t, "style", 3, ""), d = /* @__PURE__ */ Xn(t, [
2730
+ "$$slots",
2731
+ "$$events",
2732
+ "$$legacy",
2733
+ "variant",
2734
+ "size",
2735
+ "circle",
2736
+ "square",
2737
+ "ghost",
2738
+ "outline",
2739
+ "active",
2740
+ "class",
2741
+ "style",
2742
+ "children"
2743
+ ]);
2744
+ const v = {
2745
+ default: "",
2746
+ primary: "--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",
2747
+ neutral: "--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",
2748
+ success: "--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",
2749
+ warning: "--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",
2750
+ error: "--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"
2751
+ }, _ = {
2752
+ xs: "--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",
2753
+ sm: "--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",
2754
+ md: "--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",
2755
+ lg: "--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"
2756
+ };
2757
+ let p = /* @__PURE__ */ L(() => `${_[n()]}${v[r()]}${c()}`);
2758
+ var w = uo();
2759
+ Kn(
2760
+ w,
2761
+ () => ({
2762
+ class: `btn ${u() ?? ""}`,
2763
+ style: o(p),
2764
+ ...d,
2765
+ [st]: {
2766
+ circle: i(),
2767
+ square: a(),
2768
+ ghost: l(),
2769
+ outline: f(),
2770
+ active: s()
2771
+ }
2772
+ }),
2773
+ void 0,
2774
+ void 0,
2775
+ void 0,
2776
+ "svelte-kz0hjp"
2777
+ );
2778
+ var h = S(w);
2779
+ Vn(h, () => t.children ?? tn), W(e, w);
2780
+ }
2781
+ let co = 0;
2782
+ var vo = /* @__PURE__ */ U('<div role="option"> </div>'), _o = /* @__PURE__ */ U('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1h1ta11" popover="manual" tabindex="-1"></div></div>');
2783
+ function Wt(e, t) {
2784
+ Ar(t, !0);
2785
+ let r = se(t, "value", 15), n = se(t, "size", 3, "md"), i = se(t, "ghost", 3, !1), a = se(t, "class", 3, ""), l = se(t, "style", 3, ""), f = /* @__PURE__ */ Xn(t, [
2786
+ "$$slots",
2787
+ "$$events",
2788
+ "$$legacy",
2789
+ "value",
2790
+ "size",
2791
+ "ghost",
2792
+ "class",
2793
+ "style",
2794
+ "children"
2795
+ ]);
2796
+ const s = {
2797
+ xs: "calc(var(--tri-size-field,0.25rem)*6)",
2798
+ sm: "calc(var(--tri-size-field,0.25rem)*8)",
2799
+ md: "calc(var(--tri-size-field,0.25rem)*10)",
2800
+ lg: "calc(var(--tri-size-field,0.25rem)*12)"
2801
+ };
2802
+ let u = /* @__PURE__ */ L(() => `--size:${s[n()]};${l()}`);
2803
+ const c = `tri-listbox-${co++}`;
2804
+ let d = /* @__PURE__ */ O(null), v = /* @__PURE__ */ O(null), _ = /* @__PURE__ */ O(null), p = /* @__PURE__ */ O(We([])), w = /* @__PURE__ */ O(!1), h = /* @__PURE__ */ O(-1), g = /* @__PURE__ */ L(() => !!t.disabled), A = /* @__PURE__ */ L(() => r() == null ? "" : String(r())), y = /* @__PURE__ */ L(() => o(p).find((m) => m.value === o(A)) ?? o(p)[0]);
2805
+ function E() {
2806
+ o(d) && x(
2807
+ p,
2808
+ Array.from(o(d).querySelectorAll("option")).map((m) => ({
2809
+ value: m.value,
2810
+ label: (m.textContent ?? "").trim(),
2811
+ disabled: m.disabled
2812
+ })),
2813
+ !0
2814
+ );
2815
+ }
2816
+ xt(() => {
2817
+ if (!o(d)) return;
2818
+ E();
2819
+ const m = new MutationObserver(() => E());
2820
+ return m.observe(o(d), {
2821
+ childList: !0,
2822
+ subtree: !0,
2823
+ characterData: !0,
2824
+ attributes: !0
2825
+ }), () => m.disconnect();
2826
+ });
2827
+ function C(m) {
2828
+ const D = o(p)[m];
2829
+ !o(d) || !D || D.disabled || (o(d).value = D.value, o(d).dispatchEvent(new Event("input", { bubbles: !0 })), o(d).dispatchEvent(new Event("change", { bubbles: !0 })), j());
2830
+ }
2831
+ function R() {
2832
+ if (!o(v) || !o(_)) return;
2833
+ const m = o(v).getBoundingClientRect();
2834
+ o(_).style.minWidth = `${m.width}px`, o(_).style.left = `${m.left}px`;
2835
+ const D = o(_).offsetHeight, B = window.innerHeight - m.bottom;
2836
+ B < D && m.top > B ? o(_).style.top = `${Math.max(4, m.top - D - 4)}px` : o(_).style.top = `${m.bottom + 4}px`;
2837
+ }
2838
+ function I() {
2839
+ o(_)?.children[o(h)]?.scrollIntoView({ block: "nearest" });
2840
+ }
2841
+ function z(m) {
2842
+ const D = m.composedPath();
2843
+ o(v) && D.includes(o(v)) || o(_) && D.includes(o(_)) || j();
2844
+ }
2845
+ function de() {
2846
+ o(g) || o(w) || !o(_) || (x(w, !0), o(_).showPopover(), R(), x(h, o(p).findIndex((m) => m.value === o(A)), !0), o(h) < 0 && x(h, o(p).findIndex((m) => !m.disabled), !0), I(), window.addEventListener("scroll", R, !0), window.addEventListener("resize", R), document.addEventListener("pointerdown", z, !0));
2847
+ }
2848
+ function j() {
2849
+ o(w) && (x(w, !1), o(_)?.hidePopover(), window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R), document.removeEventListener("pointerdown", z, !0), o(v)?.focus());
2850
+ }
2851
+ function pt() {
2852
+ o(w) ? j() : de();
2853
+ }
2854
+ function Nt(m) {
2855
+ if (!o(p).length) return;
2856
+ let D = o(h);
2857
+ for (let B = 0; B < o(p).length; B++)
2858
+ if (D = (D + m + o(p).length) % o(p).length, !o(p)[D]?.disabled) {
2859
+ x(h, D, !0), I();
2860
+ return;
2861
+ }
2862
+ }
2863
+ function Ue(m) {
2864
+ const D = m === "start" ? o(p).map((B, le) => le) : o(p).map((B, le) => o(p).length - 1 - le);
2865
+ for (const B of D)
2866
+ if (!o(p)[B]?.disabled) {
2867
+ x(h, B, !0), I();
2868
+ return;
2869
+ }
2870
+ }
2871
+ let $e = "", Rt;
2872
+ function je(m) {
2873
+ $e += m.toLowerCase(), clearTimeout(Rt), Rt = setTimeout(() => $e = "", 600);
2874
+ const D = o(p).findIndex((B) => !B.disabled && B.label.toLowerCase().startsWith($e));
2875
+ D >= 0 && (x(h, D, !0), I());
2876
+ }
2877
+ function zt(m) {
2878
+ if (!o(g)) {
2879
+ if (!o(w)) {
2880
+ ["ArrowDown", "ArrowUp", "Enter", " "].includes(m.key) && (m.preventDefault(), de());
2881
+ return;
2882
+ }
2883
+ switch (m.key) {
2884
+ case "ArrowDown":
2885
+ m.preventDefault(), Nt(1);
2886
+ break;
2887
+ case "ArrowUp":
2888
+ m.preventDefault(), Nt(-1);
2889
+ break;
2890
+ case "Home":
2891
+ m.preventDefault(), Ue("start");
2892
+ break;
2893
+ case "End":
2894
+ m.preventDefault(), Ue("end");
2895
+ break;
2896
+ case "Enter":
2897
+ case " ":
2898
+ m.preventDefault(), o(h) >= 0 && C(o(h));
2899
+ break;
2900
+ case "Escape":
2901
+ m.preventDefault(), j();
2902
+ break;
2903
+ case "Tab":
2904
+ j();
2905
+ break;
2906
+ default:
2907
+ m.key.length === 1 && !m.metaKey && !m.ctrlKey && je(m.key);
2908
+ }
2909
+ }
2910
+ }
2911
+ var Fe = _o(), Ie = S(Fe);
2912
+ Kn(
2913
+ Ie,
2914
+ () => ({
2915
+ class: "native-select",
2916
+ tabindex: "-1",
2917
+ "aria-hidden": "true",
2918
+ ...f
2919
+ }),
2920
+ void 0,
2921
+ void 0,
2922
+ void 0,
2923
+ "svelte-1h1ta11"
2924
+ );
2925
+ var $t = S(Ie);
2926
+ Vn($t, () => t.children ?? tn), qt(Ie, (m) => x(d, m), () => o(d));
2927
+ var oe = Y(Ie, 2);
2928
+ let it;
2929
+ oe.__click = pt, oe.__keydown = zt;
2930
+ var gt = S(oe);
2931
+ let mt;
2932
+ var nr = S(gt);
2933
+ qt(oe, (m) => x(v, m), () => o(v));
2934
+ var at = Y(oe, 2);
2935
+ Vt(at, 23, () => o(p), (m, D) => m.value + "\0" + D, (m, D, B) => {
2936
+ var le = vo();
2937
+ let wt;
2938
+ le.__click = () => C(o(B)), le.__pointermove = () => x(h, o(B), !0);
2939
+ var ir = S(le);
2940
+ Z(() => {
2941
+ ye(le, "id", `${c}-opt-${o(B) ?? ""}`), wt = At(le, 1, "option svelte-1h1ta11", null, wt, {
2942
+ active: o(B) === o(h),
2943
+ selected: o(D).value === o(A)
2944
+ }), ye(le, "aria-selected", o(D).value === o(A)), ye(le, "aria-disabled", o(D).disabled), K(ir, o(D).label);
2945
+ }), W(m, le);
2946
+ }), qt(at, (m) => x(_, m), () => o(_)), Z(() => {
2947
+ At(Fe, 1, `select-wrapper ${a() ?? ""}`, "svelte-1h1ta11"), mr(Fe, l()), it = At(oe, 1, "select svelte-1h1ta11", null, it, { ghost: i(), open: o(w) }), mr(oe, o(u)), oe.disabled = o(g), ye(oe, "aria-expanded", o(w)), ye(oe, "aria-controls", c), ye(oe, "aria-activedescendant", o(w) && o(h) >= 0 ? `${c}-opt-${o(h)}` : void 0), ye(oe, "aria-label", f["aria-label"]), mt = At(gt, 1, "select-label svelte-1h1ta11", null, mt, { placeholder: o(y)?.disabled }), K(nr, o(y)?.label ?? ""), ye(at, "id", c);
2948
+ }), Qa(Ie, r), W(e, Fe), Ir();
2949
+ }
2950
+ Wn(["click", "keydown", "pointermove"]);
2951
+ function ho(e, t, r) {
2952
+ ci(
2953
+ e,
2954
+ "@triiiceratops/plugin-image-export",
2955
+ "1.0.0-rc.0",
2956
+ t,
2957
+ r
2958
+ );
2959
+ }
2960
+ function po(e) {
2961
+ return e.replace(/[^a-z0-9-_]+/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
2962
+ }
2963
+ function go(e, t, r) {
2964
+ const n = r === "image/jpeg" ? "jpg" : "png", i = po(e) || "image", a = t === "single" ? "" : `-${t}`;
2965
+ return `${i}${a}.${n}`;
2966
+ }
2967
+ function Gr(e, t) {
2968
+ return Zt(e, { getSelectedChoice: t });
2969
+ }
2970
+ function mo(e) {
2971
+ return hi(e);
2972
+ }
2973
+ function wo(e, t) {
2974
+ const n = Zt(e, {
2975
+ getSelectedChoice: t
2976
+ })[0];
2977
+ return !n?.canvasWidth || !n?.canvasHeight ? [] : Jr(n.canvasWidth, n.canvasHeight);
2978
+ }
2979
+ async function bo(e, t) {
2980
+ const r = t.url ?? wr(e, {
2981
+ width: t.width,
2982
+ height: t.height
2983
+ });
2984
+ if (!r)
2985
+ throw new Error("No exportable image found for this canvas.");
2986
+ return br(r);
2987
+ }
2988
+ async function yo(e, t, r = {}) {
2989
+ const n = Zt(e, {
2990
+ getSelectedChoice: r.getSelectedChoice
2991
+ }), i = n[0];
2992
+ if (!i)
2993
+ throw new Error("No exportable image found for this canvas.");
2994
+ const { canvasWidth: a, canvasHeight: l } = i;
2995
+ if (!a || !l)
2996
+ throw new Error("Unable to determine canvas dimensions for export.");
2997
+ const { width: f, height: s } = Zr(
2998
+ t.width,
2999
+ t.height
3000
+ ), u = f / a, c = await Promise.all(
3001
+ n.map(
3002
+ async (d) => Eo(d, a, l, u)
3003
+ )
3004
+ );
3005
+ return Xr(
3006
+ c,
3007
+ f,
3008
+ s,
3009
+ r.format ?? "image/png"
3010
+ );
3011
+ }
3012
+ async function Eo(e, t, r, n) {
3013
+ const i = pi(
3014
+ e,
3015
+ t,
3016
+ r,
3017
+ n
3018
+ ), a = wr(e, { width: i.width });
3019
+ if (!a)
3020
+ throw new Error("No exportable image found for this canvas.");
3021
+ return {
3022
+ blob: await br(a),
3023
+ ...i
3024
+ };
3025
+ }
3026
+ function ei(e) {
3027
+ return _i({
3028
+ canvases: e.canvases,
3029
+ currentCanvasId: e.canvasId,
3030
+ currentCanvasIndex: e.currentCanvasIndex,
3031
+ viewingMode: e.viewingMode,
3032
+ pagedOffset: e.pagedOffset
3033
+ }).map((t) => t.canvas);
3034
+ }
3035
+ function ti(e, t) {
3036
+ const r = ei(e);
3037
+ if (!r.length) return null;
3038
+ const n = r.flatMap((d, v) => {
3039
+ const _ = Qr(d) ?? `canvas-${v}`;
3040
+ return Zt(d, { getSelectedChoice: t }).map(
3041
+ (p) => ({
3042
+ canvasId: _,
3043
+ x: p.x,
3044
+ y: p.y,
3045
+ width: p.width,
3046
+ tileSource: {
3047
+ width: p.resourceWidth || p.canvasWidth,
3048
+ height: p.resourceHeight || p.canvasHeight,
3049
+ resolved: p
3050
+ }
3051
+ })
3052
+ );
3053
+ });
3054
+ if (!n.length) return null;
3055
+ const { layouts: i, sources: a } = gi(n, {
3056
+ mode: e.viewingMode,
3057
+ direction: e.viewingDirection,
3058
+ preserveCanvasScale: e.preserveCanvasScale,
3059
+ gap: mi
3060
+ });
3061
+ if (!i.length) return null;
3062
+ const l = Math.min(...i.map((d) => d.x)), f = Math.min(...i.map((d) => d.y)), s = Math.max(...i.map((d) => d.x + d.width)), u = Math.max(...i.map((d) => d.y + d.height));
3063
+ return { entries: a.map((d) => ({
3064
+ resolved: d.tileSource.resolved,
3065
+ x: d.x - l,
3066
+ y: d.y - f,
3067
+ width: d.width
3068
+ })), worldWidth: s - l, worldHeight: u - f };
3069
+ }
3070
+ function xo(e, t) {
3071
+ const r = ti(e, t);
3072
+ if (!r) return [];
3073
+ const n = r.entries[0], i = n?.resolved.resourceWidth && n.width > 0 ? n.resolved.resourceWidth / n.width : 1600, a = Math.round(r.worldWidth * i), l = Math.round(r.worldHeight * i);
3074
+ return !a || !l ? [] : Jr(a, l);
3075
+ }
3076
+ async function So(e, t, r = {}) {
3077
+ const n = ti(e, r.getSelectedChoice);
3078
+ if (!n)
3079
+ throw new Error("Nothing is currently displayed in the viewer.");
3080
+ const { width: i, height: a } = Zr(
3081
+ t.width,
3082
+ t.height
3083
+ ), l = i / n.worldWidth, f = await Promise.all(
3084
+ n.entries.map(async ({ resolved: s, x: u, y: c, width: d }) => {
3085
+ const v = Math.max(1, Math.round(d * l)), _ = s.resourceWidth && s.resourceHeight ? s.resourceHeight / s.resourceWidth : 1, p = Math.max(1, Math.round(v * _)), w = wr(s, {
3086
+ width: v
3087
+ });
3088
+ if (!w)
3089
+ throw new Error(
3090
+ "No exportable image found for the current view."
3091
+ );
3092
+ return {
3093
+ blob: await br(w),
3094
+ x: Math.round(u * l),
3095
+ y: Math.round(c * l),
3096
+ width: v,
3097
+ height: p
3098
+ };
3099
+ })
3100
+ );
3101
+ return Xr(
3102
+ f,
3103
+ i,
3104
+ a,
3105
+ r.format ?? "image/png"
3106
+ );
3107
+ }
3108
+ var Co = /* @__PURE__ */ U("<option> </option>"), Ao = /* @__PURE__ */ U("<option> </option>"), Io = /* @__PURE__ */ U("<!> <option> </option> <!>", 1), ko = /* @__PURE__ */ U('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'), To = /* @__PURE__ */ U("<option> </option>"), Mo = /* @__PURE__ */ U('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'), Do = /* @__PURE__ */ U("<option> </option>"), Lo = /* @__PURE__ */ U('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'), Po = /* @__PURE__ */ U("<option> </option>"), Oo = /* @__PURE__ */ U("<option disabled> </option> <!>", 1), No = /* @__PURE__ */ U('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'), Ro = /* @__PURE__ */ U('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'), zo = /* @__PURE__ */ U('<div class="tri-id-alert"><span> </span></div>'), $o = /* @__PURE__ */ U('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'), Fo = /* @__PURE__ */ U('<span aria-hidden="true"></span> ', 1), Bo = /* @__PURE__ */ U('<div class="tri-id" data-tri-id="" data-panel-id="image-download"><div class="tri-id-body"><p class="tri-id-desc"> </p> <div class="tri-id-fields"><!> <!> <!> <div class="tri-id-field"><label class="tri-id-label" for="tri-id-resolution"><span> </span></label> <!></div></div> <!></div> <div class="tri-id-footer"><!></div></div>');
3109
+ function Wo(e, t) {
3110
+ Ar(t, !0);
3111
+ const { context: r } = ra(Jn), { viewerState: n, selectors: i, locale: a, ui: l } = r;
3112
+ let f = /* @__PURE__ */ O(0), s = /* @__PURE__ */ O(0);
3113
+ i.select((b) => [
3114
+ b.canvasId,
3115
+ b.currentCanvasIndex,
3116
+ b.canvases,
3117
+ b.viewingMode,
3118
+ b.viewingDirection,
3119
+ b.pagedOffset,
3120
+ b.preserveCanvasScale
3121
+ ]).subscribe(() => {
3122
+ Rr(f);
3123
+ }), a.subscribe(() => {
3124
+ Rr(s);
3125
+ });
3126
+ const u = (b, T) => (o(s), a.t(b, T));
3127
+ let c = /* @__PURE__ */ O("single"), d = /* @__PURE__ */ O(0), v = /* @__PURE__ */ O(0), _ = /* @__PURE__ */ O(We([])), p = /* @__PURE__ */ O(null), w = /* @__PURE__ */ O(!1), h = /* @__PURE__ */ O(!1), g = /* @__PURE__ */ O(""), A = /* @__PURE__ */ O(""), y = /* @__PURE__ */ O(null);
3128
+ const E = (b) => n.getSelectedChoice(b), C = /* @__PURE__ */ L(() => (o(f), n.currentCanvasIndex >= 0 ? n.canvases[n.currentCanvasIndex] ?? null : null)), R = /* @__PURE__ */ L(() => (o(f), o(C) ? Gr(o(C), E) : [])), I = /* @__PURE__ */ L(() => o(R).length > 1), z = /* @__PURE__ */ L(() => o(I)), de = /* @__PURE__ */ L(() => (o(f), ei(n))), j = /* @__PURE__ */ L(() => o(de).length > 1), pt = /* @__PURE__ */ L(() => o(j)), Nt = /* @__PURE__ */ L(() => o(z) || o(pt)), Ue = /* @__PURE__ */ L(() => (o(f), o(c) === "single" && o(j) ? o(de)[o(d)] ?? o(C) : o(C))), $e = /* @__PURE__ */ L(() => (o(f), o(Ue) ? Gr(o(Ue), E) : [])), Rt = /* @__PURE__ */ L(() => o($e).length > 1), je = /* @__PURE__ */ L(() => o(p) !== null ? o(_)[o(p)] ?? null : null), zt = /* @__PURE__ */ L(() => !o(h) && !o(w) && !!o(C) && !!o(je)), Fe = /* @__PURE__ */ L(() => (o(s), o(C) ? !o(w) && !o(_).length ? u("image_download_disabled_no_resolution") : null : u("image_download_disabled_no_canvas")));
3129
+ xt(() => {
3130
+ (o(c) === "composite" && !o(z) || o(c) === "world" && !o(pt)) && x(c, "single");
3131
+ }), xt(() => {
3132
+ o(f);
3133
+ const b = n.canvasId, T = o(de).findIndex((H) => Qr(H) === b);
3134
+ x(d, T >= 0 ? T : 0, !0);
3135
+ }), xt(() => {
3136
+ o(Ue), x(v, 0);
3137
+ }), xt(() => {
3138
+ const b = o(C), T = o(c), H = o(v);
3139
+ let $ = !1;
3140
+ if (x(_, [], !0), x(p, null), !!b) {
3141
+ if (T === "single") {
3142
+ const V = o($e)[H];
3143
+ if (!V) return;
3144
+ x(w, !0), mo(V).then((ee) => {
3145
+ $ || (x(_, ee, !0), x(p, ee.length ? 0 : null, !0));
3146
+ }).finally(() => {
3147
+ $ || x(w, !1);
3148
+ });
3149
+ } else if (T === "composite") {
3150
+ const V = wo(b, E);
3151
+ x(_, V, !0), x(p, V.length ? 0 : null, !0);
3152
+ } else {
3153
+ const V = xo(n, E);
3154
+ x(_, V, !0), x(p, V.length ? 0 : null, !0);
3155
+ }
3156
+ return () => {
3157
+ $ = !0;
3158
+ };
3159
+ }
3160
+ });
3161
+ function Ie(b) {
3162
+ const T = Number(b);
3163
+ return Number.isInteger(T) ? T : 0;
3164
+ }
3165
+ async function $t() {
3166
+ if (!(!o(C) || !o(je) || !o(zt))) {
3167
+ x(h, !0), x(g, ""), x(A, "");
3168
+ try {
3169
+ let b, T = o(C);
3170
+ if (o(c) === "single") {
3171
+ T = o(Ue);
3172
+ const $ = o($e)[o(v)];
3173
+ if (!$) return;
3174
+ b = await bo($, o(je));
3175
+ } else o(c) === "composite" ? b = await yo(o(C), o(je), { getSelectedChoice: E }) : b = await So(n, o(je), { getSelectedChoice: E });
3176
+ const H = go(Lr(T, n.currentCanvasIndex), o(c), "image/png");
3177
+ wi(b, H), x(A, u("image_download_result_downloaded", { filename: H }), !0);
3178
+ } catch (b) {
3179
+ x(g, u("image_download_error_failed"), !0), o(y) && ho(o(y), b, () => void $t());
3180
+ } finally {
3181
+ x(h, !1);
3182
+ }
3183
+ }
3184
+ }
3185
+ function oe(b) {
3186
+ return { destroy: l.renderIcon(Qn, b) };
3187
+ }
3188
+ var it = Bo(), gt = S(it), mt = S(gt), nr = S(mt), at = Y(mt, 2), m = S(at);
3189
+ {
3190
+ var D = (b) => {
3191
+ var T = ko(), H = S(T), $ = S(H), V = S($), ee = Y(H, 2);
3192
+ {
3193
+ let F = /* @__PURE__ */ L(() => u("image_download_mode"));
3194
+ Wt(ee, {
3195
+ id: "tri-id-mode",
3196
+ class: "tri-id-field-select",
3197
+ "data-tri-id-mode": !0,
3198
+ get "aria-label"() {
3199
+ return o(F);
3200
+ },
3201
+ get disabled() {
3202
+ return o(h);
3203
+ },
3204
+ get value() {
3205
+ return o(c);
3206
+ },
3207
+ onchange: (ne) => {
3208
+ x(c, ne.currentTarget.value, !0);
3209
+ },
3210
+ children: (ne, ot) => {
3211
+ var N = Io(), G = yt(N);
3212
+ {
3213
+ var ve = (_e) => {
3214
+ var Te = Co(), ar = S(Te);
3215
+ Te.value = Te.__value = "composite", Z((or) => K(ar, or), [() => u("image_download_mode_composite")]), W(_e, Te);
3216
+ };
3217
+ Me(G, (_e) => {
3218
+ o(z) && _e(ve);
3219
+ });
3220
+ }
3221
+ var q = Y(G, 2), ke = S(q);
3222
+ q.value = q.__value = "single";
3223
+ var we = Y(q, 2);
3224
+ {
3225
+ var bt = (_e) => {
3226
+ var Te = Ao(), ar = S(Te);
3227
+ Te.value = Te.__value = "world", Z((or) => K(ar, or), [() => u("image_download_mode_world")]), W(_e, Te);
3228
+ };
3229
+ Me(we, (_e) => {
3230
+ o(pt) && _e(bt);
3231
+ });
3232
+ }
3233
+ Z((_e) => K(ke, _e), [() => u("image_download_mode_single")]), W(ne, N);
3234
+ },
3235
+ $$slots: { default: !0 }
3236
+ });
3237
+ }
3238
+ Z((F) => K(V, F), [() => u("image_download_mode")]), W(b, T);
3239
+ };
3240
+ Me(m, (b) => {
3241
+ o(Nt) && b(D);
3242
+ });
3243
+ }
3244
+ var B = Y(m, 2);
3245
+ {
3246
+ var le = (b) => {
3247
+ var T = Mo(), H = S(T), $ = S(H), V = S($), ee = Y(H, 2);
3248
+ {
3249
+ let F = /* @__PURE__ */ L(() => u("image_download_canvas"));
3250
+ Wt(ee, {
3251
+ id: "tri-id-canvas",
3252
+ class: "tri-id-field-select",
3253
+ get "aria-label"() {
3254
+ return o(F);
3255
+ },
3256
+ get disabled() {
3257
+ return o(h);
3258
+ },
3259
+ get value() {
3260
+ return o(d);
3261
+ },
3262
+ onchange: (ne) => {
3263
+ x(d, Ie(ne.currentTarget.value), !0);
3264
+ },
3265
+ children: (ne, ot) => {
3266
+ var N = Vr(), G = yt(N);
3267
+ Vt(G, 17, () => o(de), lr, (ve, q, ke) => {
3268
+ var we = To(), bt = S(we);
3269
+ we.value = we.__value = ke, Z((_e) => K(bt, _e), [() => Lr(o(q), ke)]), W(ve, we);
3270
+ }), W(ne, N);
3271
+ },
3272
+ $$slots: { default: !0 }
3273
+ });
3274
+ }
3275
+ Z((F) => K(V, F), [() => u("image_download_canvas")]), W(b, T);
3276
+ };
3277
+ Me(B, (b) => {
3278
+ o(c) === "single" && o(j) && b(le);
3279
+ });
3280
+ }
3281
+ var wt = Y(B, 2);
3282
+ {
3283
+ var ir = (b) => {
3284
+ var T = Lo(), H = S(T), $ = S(H), V = S($), ee = Y(H, 2);
3285
+ {
3286
+ let F = /* @__PURE__ */ L(() => u("image_download_image"));
3287
+ Wt(ee, {
3288
+ id: "tri-id-image",
3289
+ class: "tri-id-field-select",
3290
+ get "aria-label"() {
3291
+ return o(F);
3292
+ },
3293
+ get disabled() {
3294
+ return o(h);
3295
+ },
3296
+ get value() {
3297
+ return o(v);
3298
+ },
3299
+ onchange: (ne) => {
3300
+ x(v, Ie(ne.currentTarget.value), !0);
3301
+ },
3302
+ children: (ne, ot) => {
3303
+ var N = Vr(), G = yt(N);
3304
+ Vt(G, 17, () => o($e), lr, (ve, q, ke) => {
3305
+ var we = Do(), bt = S(we);
3306
+ we.value = we.__value = ke, Z((_e) => K(bt, _e), [
3307
+ () => o(q).label ?? `${u("image_download_image")} ${ke + 1}`
3308
+ ]), W(ve, we);
3309
+ }), W(ne, N);
3310
+ },
3311
+ $$slots: { default: !0 }
3312
+ });
3313
+ }
3314
+ Z((F) => K(V, F), [() => u("image_download_image")]), W(b, T);
3315
+ };
3316
+ Me(wt, (b) => {
3317
+ o(c) === "single" && o(Rt) && b(ir);
3318
+ });
3319
+ }
3320
+ var ri = Y(wt, 2), Dr = S(ri), ni = S(Dr), ii = S(ni), ai = Y(Dr, 2);
3321
+ {
3322
+ let b = /* @__PURE__ */ L(() => u("image_download_resolution")), T = /* @__PURE__ */ L(() => o(h) || o(w) || !o(_).length), H = /* @__PURE__ */ L(() => o(p) ?? "");
3323
+ Wt(ai, {
3324
+ id: "tri-id-resolution",
3325
+ class: "tri-id-field-select",
3326
+ "data-tri-id-resolution": !0,
3327
+ get "aria-label"() {
3328
+ return o(b);
3329
+ },
3330
+ get disabled() {
3331
+ return o(T);
3332
+ },
3333
+ get value() {
3334
+ return o(H);
3335
+ },
3336
+ onchange: ($) => {
3337
+ x(p, Ie($.currentTarget.value), !0);
3338
+ },
3339
+ children: ($, V) => {
3340
+ var ee = Oo(), F = yt(ee), ne = S(F);
3341
+ F.value = F.__value = "";
3342
+ var ot = Y(F, 2);
3343
+ Vt(ot, 17, () => o(_), lr, (N, G, ve) => {
3344
+ var q = Po(), ke = S(q);
3345
+ q.value = q.__value = ve, Z(() => K(ke, o(G).label)), W(N, q);
3346
+ }), Z((N) => K(ne, N), [() => u("image_download_resolution_placeholder")]), W($, ee);
3347
+ },
3348
+ $$slots: { default: !0 }
3349
+ });
3350
+ }
3351
+ var oi = Y(at, 2);
3352
+ {
3353
+ var li = (b) => {
3354
+ var T = $o(), H = S(T), $ = S(H);
3355
+ {
3356
+ var V = (N) => {
3357
+ var G = No(), ve = S(G), q = S(ve);
3358
+ Z(() => K(q, o(A))), W(N, G);
3359
+ };
3360
+ Me($, (N) => {
3361
+ o(A) && N(V);
3362
+ });
3363
+ }
3364
+ var ee = Y($, 2);
3365
+ {
3366
+ var F = (N) => {
3367
+ var G = Ro(), ve = S(G), q = S(ve);
3368
+ Z(() => K(q, o(g))), W(N, G);
3369
+ };
3370
+ Me(ee, (N) => {
3371
+ o(g) && N(F);
3372
+ });
3373
+ }
3374
+ var ne = Y(ee, 2);
3375
+ {
3376
+ var ot = (N) => {
3377
+ var G = zo(), ve = S(G), q = S(ve);
3378
+ Z(() => K(q, o(Fe))), W(N, G);
3379
+ };
3380
+ Me(ne, (N) => {
3381
+ o(Fe) && N(ot);
3382
+ });
3383
+ }
3384
+ W(b, T);
3385
+ };
3386
+ Me(oi, (b) => {
3387
+ (o(A) || o(g) || o(Fe)) && b(li);
3388
+ });
3389
+ }
3390
+ var si = Y(gt, 2), ui = S(si);
3391
+ {
3392
+ let b = /* @__PURE__ */ L(() => !o(zt));
3393
+ fo(ui, {
3394
+ variant: "primary",
3395
+ class: "tri-id-download",
3396
+ "data-tri-id-download": !0,
3397
+ style: "width:100%",
3398
+ get disabled() {
3399
+ return o(b);
3400
+ },
3401
+ onclick: $t,
3402
+ children: (T, H) => {
3403
+ var $ = Fo(), V = yt($);
3404
+ Ya(V, (F) => oe?.(F));
3405
+ var ee = Y(V);
3406
+ Z((F) => K(ee, ` ${F ?? ""}`), [
3407
+ () => o(h) ? u("image_download_downloading") : u("image_download_download")
3408
+ ]), W(T, $);
3409
+ },
3410
+ $$slots: { default: !0 }
3411
+ });
3412
+ }
3413
+ qt(it, (b) => x(y, b), () => o(y)), Z(
3414
+ (b, T) => {
3415
+ K(nr, b), K(ii, T);
3416
+ },
3417
+ [
3418
+ () => u("image_download_description"),
3419
+ () => u("image_download_resolution")
3420
+ ]
3421
+ ), W(e, it), Ir();
3422
+ }
3423
+ const { STYLES: Ho, STYLE_ID: Vo } = di(
3424
+ `
3425
+ .tri-id {
3426
+ display: flex;
3427
+ flex-direction: column;
3428
+ min-height: 0;
3429
+ width: 100%;
3430
+ color: var(--panel-fg, var(--tri-panel-content, currentColor));
3431
+ }
3432
+
3433
+ .tri-id-body {
3434
+ width: 100%;
3435
+ padding: 1rem;
3436
+ display: flex;
3437
+ flex-direction: column;
3438
+ gap: 1rem;
3439
+ }
3440
+
3441
+ .tri-id-desc {
3442
+ font-size: 0.875rem;
3443
+ line-height: 1.25rem;
3444
+ margin: 0;
3445
+ color: color-mix(in oklab, var(--panel-fg, currentColor) 70%, transparent);
3446
+ }
3447
+
3448
+ .tri-id-fields {
3449
+ display: grid;
3450
+ grid-template-columns: repeat(1, minmax(0, 1fr));
3451
+ gap: 0.75rem;
3452
+ }
3453
+
3454
+ .tri-id-field {
3455
+ width: 100%;
3456
+ }
3457
+
3458
+ .tri-id-label {
3459
+ display: inline-flex;
3460
+ align-items: center;
3461
+ gap: 0.375rem;
3462
+ margin-bottom: 0.25rem;
3463
+ white-space: nowrap;
3464
+ font-size: 0.75rem;
3465
+ color: color-mix(in oklab, currentColor 60%, transparent);
3466
+ }
3467
+
3468
+ /* The themed Select renders its wrapper with this class; stretch it to fill. */
3469
+ .tri-id-field-select {
3470
+ width: 100%;
3471
+ }
3472
+
3473
+ .tri-id-card {
3474
+ display: flex;
3475
+ flex-direction: column;
3476
+ position: relative;
3477
+ border-radius: var(--tri-radius-panels, 0.75rem);
3478
+ border: 1px solid var(--tri-surface-border, rgb(0 0 0 / 0.15));
3479
+ background-color: var(--tri-input-bg, #fff);
3480
+ }
3481
+
3482
+ .tri-id-card-body {
3483
+ display: flex;
3484
+ flex-direction: column;
3485
+ flex: auto;
3486
+ gap: 0.5rem;
3487
+ padding: 1rem;
3488
+ font-size: 0.875rem;
3489
+ }
3490
+
3491
+ /*
3492
+ * Soft alert: tinted background/border derived from --alert-color, no shadow.
3493
+ * The color variant sets --alert-color (drives bg/border) and overrides the
3494
+ * text color to the variant's *-content token.
3495
+ */
3496
+ .tri-id-alert {
3497
+ --alert-color: var(--panel-fg, currentColor);
3498
+ display: grid;
3499
+ grid-auto-flow: column;
3500
+ grid-template-columns: auto;
3501
+ justify-content: start;
3502
+ place-items: center start;
3503
+ gap: 1rem;
3504
+ text-align: start;
3505
+ padding-block: 0.5rem;
3506
+ padding-inline: 1rem;
3507
+ font-size: 0.875rem;
3508
+ line-height: 1.25rem;
3509
+ border: 1px solid
3510
+ color-mix(in oklab, var(--alert-color) 10%, var(--tri-input-bg, #fff));
3511
+ border-radius: var(--tri-radius-panels, 0.75rem);
3512
+ color: var(--panel-fg, currentColor);
3513
+ background: color-mix(
3514
+ in oklab,
3515
+ var(--alert-color) 8%,
3516
+ var(--tri-input-bg, #fff)
3517
+ );
3518
+ box-shadow: none;
3519
+ }
3520
+ .tri-id-alert.is-success {
3521
+ --alert-color: var(--tri-color-success, #16a34a);
3522
+ color: var(--tri-color-success-content, currentColor);
3523
+ }
3524
+ .tri-id-alert.is-error {
3525
+ --alert-color: var(--tri-color-error, #dc2626);
3526
+ color: var(--tri-color-error-content, currentColor);
3527
+ }
3528
+
3529
+ .tri-id-footer {
3530
+ width: 100%;
3531
+ padding: 1rem;
3532
+ border-top: 1px solid var(--tri-surface-border, rgb(0 0 0 / 0.15));
3533
+ }
3534
+
3535
+ /* The themed Button renders with this class; size its download glyph. */
3536
+ .tri-id-download svg {
3537
+ width: 1.125rem;
3538
+ height: 1.125rem;
3539
+ fill: currentColor;
3540
+ }
3541
+ `,
3542
+ "panel"
3543
+ ), qo = {
3544
+ mount(e, t) {
3545
+ const r = t.styles.install(Ho, Vo), n = t.styles.install(io, "bundled"), i = Wa(Wo, {
3546
+ target: e,
3547
+ context: /* @__PURE__ */ new Map([
3548
+ [Jn, { context: t }]
3549
+ ])
3550
+ });
3551
+ return () => {
3552
+ Va(i), n(), r();
3553
+ };
3554
+ }
3555
+ }, Ko = vi({
3556
+ name: "@triiiceratops/plugin-image-export",
3557
+ uiId: "image-download",
3558
+ version: "1.0.0-rc.0",
3559
+ coreRange: ">=1.0.0-rc.0",
3560
+ pluginApiRange: "^1.0.0",
3561
+ requiredCapabilities: ["osd@5"],
3562
+ icon: Qn,
3563
+ target: "panel",
3564
+ catalog: ao,
3565
+ view: qo
3566
+ });
3567
+ export {
3568
+ Ko as ImageDownloadPlugin,
3569
+ go as buildImageDownloadFilename,
3570
+ yo as exportCompositeCanvas,
3571
+ So as exportCurrentWorld,
3572
+ bo as exportSingleImage,
3573
+ Gr as getCanvasImageChoices,
3574
+ ei as getVisibleCanvasesForDownload,
3575
+ wo as resolveCompositeCanvasSizeOptions,
3576
+ mo as resolveSingleImageSizeOptions,
3577
+ xo as resolveWorldSizeOptions
3578
+ };