@triiiceratops/plugin-pdf-export 1.0.0-rc.1

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