@pie-players/pie-section-player 0.3.3 → 0.3.5

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.
Files changed (66) hide show
  1. package/README.md +123 -5
  2. package/dist/components/section-player-item-card-element.d.ts +2 -0
  3. package/dist/components/section-player-item-card-element.d.ts.map +1 -0
  4. package/dist/components/section-player-items-pane-element.d.ts +2 -0
  5. package/dist/components/section-player-items-pane-element.d.ts.map +1 -0
  6. package/dist/components/section-player-kernel-host-element.d.ts +2 -0
  7. package/dist/components/section-player-kernel-host-element.d.ts.map +1 -0
  8. package/dist/components/section-player-passage-card-element.d.ts +2 -0
  9. package/dist/components/section-player-passage-card-element.d.ts.map +1 -0
  10. package/dist/components/section-player-passages-pane-element.d.ts +2 -0
  11. package/dist/components/section-player-passages-pane-element.d.ts.map +1 -0
  12. package/dist/components/section-player-shell-element.d.ts +2 -0
  13. package/dist/components/section-player-shell-element.d.ts.map +1 -0
  14. package/dist/components/shared/outer-scrollbars.d.ts +6 -0
  15. package/dist/components/shared/outer-scrollbars.d.ts.map +1 -0
  16. package/dist/components/shared/player-action.d.ts +1 -0
  17. package/dist/components/shared/player-action.d.ts.map +1 -1
  18. package/dist/components/shared/player-preload.d.ts +5 -0
  19. package/dist/components/shared/player-preload.d.ts.map +1 -1
  20. package/dist/components/shared/section-player-card-context.d.ts +15 -0
  21. package/dist/components/shared/section-player-card-context.d.ts.map +1 -0
  22. package/dist/components/shared/section-player-props.d.ts +2 -0
  23. package/dist/components/shared/section-player-props.d.ts.map +1 -0
  24. package/dist/components/shared/section-player-readiness.d.ts +14 -0
  25. package/dist/components/shared/section-player-readiness.d.ts.map +1 -0
  26. package/dist/components/shared/section-player-runtime.d.ts +4 -4
  27. package/dist/components/shared/section-player-runtime.d.ts.map +1 -1
  28. package/dist/components/shared/section-player-view-state.d.ts +9 -0
  29. package/dist/components/shared/section-player-view-state.d.ts.map +1 -1
  30. package/dist/contracts/layout-contract.d.ts +18 -0
  31. package/dist/contracts/layout-contract.d.ts.map +1 -0
  32. package/dist/contracts/layout-parity-metadata.d.ts +4 -0
  33. package/dist/contracts/layout-parity-metadata.d.ts.map +1 -0
  34. package/dist/contracts/public-events.d.ts +25 -0
  35. package/dist/contracts/public-events.d.ts.map +1 -0
  36. package/dist/contracts/runtime-host-contract.d.ts +29 -0
  37. package/dist/contracts/runtime-host-contract.d.ts.map +1 -0
  38. package/dist/controllers/SectionController.d.ts +10 -14
  39. package/dist/controllers/SectionController.d.ts.map +1 -1
  40. package/dist/controllers/toolkit-section-contracts.d.ts +1 -1
  41. package/dist/controllers/toolkit-section-contracts.d.ts.map +1 -1
  42. package/dist/controllers/types.d.ts +27 -13
  43. package/dist/controllers/types.d.ts.map +1 -1
  44. package/dist/index-CGEKDUBQ-C-8EFMUk.js +216 -0
  45. package/dist/index-DF-Dk87f-lxErM8bo.js +178 -0
  46. package/dist/pie-section-player.d.ts +7 -0
  47. package/dist/pie-section-player.d.ts.map +1 -1
  48. package/dist/pie-section-player.js +8249 -7564
  49. package/dist/{player-preload-9v0AQsMd.js → player-preload-Boa1VXUc.js} +2707 -2649
  50. package/dist/policies/guards.d.ts +3 -0
  51. package/dist/policies/guards.d.ts.map +1 -0
  52. package/dist/policies/index.d.ts +3 -0
  53. package/dist/policies/index.d.ts.map +1 -0
  54. package/dist/policies/types.d.ts +23 -0
  55. package/dist/policies/types.d.ts.map +1 -0
  56. package/dist/tool-annotation-toolbar-DJvpXk1K.js +4917 -0
  57. package/dist/utils/player-preload.js +1 -1
  58. package/package.json +54 -13
  59. package/dist/tool-annotation-toolbar-m4Mv2j0H.js +0 -4305
  60. package/src/components/ItemShellElement.svelte +0 -302
  61. package/src/components/PassageShellElement.svelte +0 -217
  62. package/src/components/PieSectionPlayerBaseElement.svelte +0 -245
  63. package/src/components/PieSectionPlayerSplitPaneElement.svelte +0 -675
  64. package/src/components/PieSectionPlayerVerticalElement.svelte +0 -439
  65. package/src/components/shared/SectionItemCard.svelte +0 -92
  66. package/src/components/shared/SectionPassageCard.svelte +0 -88
@@ -1,4305 +0,0 @@
1
- var Ji = Object.defineProperty, On = (e) => {
2
- throw TypeError(e);
3
- }, Zi = (e, t, o) => t in e ? Ji(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, $ = (e, t, o) => Zi(e, typeof t != "symbol" ? t + "" : t, o), Uo = (e, t, o) => t.has(e) || On("Cannot " + o), u = (e, t, o) => (Uo(e, t, "read from private field"), o ? o.call(e) : t.get(e)), x = (e, t, o) => t.has(e) ? On("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, o), T = (e, t, o, n) => (Uo(e, t, "write to private field"), t.set(e, o), o), G = (e, t, o) => (Uo(e, t, "access private method"), o), vn;
4
- typeof window < "u" && ((vn = window.__svelte ?? (window.__svelte = {})).v ?? (vn.v = /* @__PURE__ */ new Set())).add("5");
5
- const Xi = 1, Yi = 2, Qi = 16, tr = 1, er = 2, Ko = "[", vo = "[!", Jo = "]", ye = {}, j = /* @__PURE__ */ Symbol(), Rn = "http://www.w3.org/1999/xhtml", or = !1;
6
- var Nn = Array.isArray, nr = Array.prototype.indexOf, we = Array.prototype.includes, go = Array.from, co = Object.keys, uo = Object.defineProperty, be = Object.getOwnPropertyDescriptor, ir = Object.getOwnPropertyDescriptors, rr = Object.prototype, sr = Array.prototype, jn = Object.getPrototypeOf, gn = Object.isExtensible;
7
- const lr = () => {
8
- };
9
- function ar(e) {
10
- for (var t = 0; t < e.length; t++)
11
- e[t]();
12
- }
13
- function Pn() {
14
- var e, t, o = new Promise((n, i) => {
15
- e = n, t = i;
16
- });
17
- return { promise: o, resolve: e, reject: t };
18
- }
19
- const P = 2, ze = 4, bo = 8, qn = 1 << 24, Mt = 16, dt = 32, Jt = 64, Vo = 128, Y = 512, N = 1024, q = 2048, ht = 4096, J = 8192, Vt = 16384, Se = 32768, Te = 65536, bn = 1 << 17, Zo = 1 << 18, he = 1 << 19, cr = 1 << 20, Gt = 1 << 25, se = 65536, Mo = 1 << 21, Xo = 1 << 22, Ft = 1 << 23, eo = /* @__PURE__ */ Symbol("$state"), ur = /* @__PURE__ */ Symbol("legacy props"), fr = /* @__PURE__ */ Symbol(""), oe = new class extends Error {
20
- constructor() {
21
- super(...arguments), $(this, "name", "StaleReactionError"), $(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed");
22
- }
23
- }(), hr = (
24
- // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
25
- !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml")
26
- ), mo = 3, ke = 8;
27
- function dr() {
28
- throw new Error("https://svelte.dev/e/async_derived_orphan");
29
- }
30
- function pr(e, t, o) {
31
- throw new Error("https://svelte.dev/e/each_key_duplicate");
32
- }
33
- function vr(e) {
34
- throw new Error("https://svelte.dev/e/effect_in_teardown");
35
- }
36
- function gr() {
37
- throw new Error("https://svelte.dev/e/effect_in_unowned_derived");
38
- }
39
- function br(e) {
40
- throw new Error("https://svelte.dev/e/effect_orphan");
41
- }
42
- function mr() {
43
- throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
44
- }
45
- function yr() {
46
- throw new Error("https://svelte.dev/e/hydration_failed");
47
- }
48
- function wr() {
49
- throw new Error("https://svelte.dev/e/state_descriptors_fixed");
50
- }
51
- function Tr() {
52
- throw new Error("https://svelte.dev/e/state_prototype_fixed");
53
- }
54
- function $r() {
55
- throw new Error("https://svelte.dev/e/state_unsafe_mutation");
56
- }
57
- function Ir() {
58
- throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
59
- }
60
- function yo(e) {
61
- console.warn("https://svelte.dev/e/hydration_mismatch");
62
- }
63
- function xr() {
64
- console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
65
- }
66
- let L = !1;
67
- function at(e) {
68
- L = e;
69
- }
70
- let E;
71
- function B(e) {
72
- if (e === null)
73
- throw yo(), ye;
74
- return E = e;
75
- }
76
- function wo() {
77
- return B(/* @__PURE__ */ et(E));
78
- }
79
- function Ze(e) {
80
- if (L) {
81
- if (/* @__PURE__ */ et(E) !== null)
82
- throw yo(), ye;
83
- E = e;
84
- }
85
- }
86
- function _r(e = 1) {
87
- if (L) {
88
- for (var t = e, o = E; t--; )
89
- o = /** @type {TemplateNode} */
90
- /* @__PURE__ */ et(o);
91
- E = o;
92
- }
93
- }
94
- function fo(e = !0) {
95
- for (var t = 0, o = E; ; ) {
96
- if (o.nodeType === ke) {
97
- var n = (
98
- /** @type {Comment} */
99
- o.data
100
- );
101
- if (n === Jo) {
102
- if (t === 0) return o;
103
- t -= 1;
104
- } else (n === Ko || n === vo || // "[1", "[2", etc. for if blocks
105
- n[0] === "[" && !isNaN(Number(n.slice(1)))) && (t += 1);
106
- }
107
- var i = (
108
- /** @type {TemplateNode} */
109
- /* @__PURE__ */ et(o)
110
- );
111
- e && o.remove(), o = i;
112
- }
113
- }
114
- function Wn(e) {
115
- if (!e || e.nodeType !== ke)
116
- throw yo(), ye;
117
- return (
118
- /** @type {Comment} */
119
- e.data
120
- );
121
- }
122
- function Dn(e) {
123
- return e === this.v;
124
- }
125
- function Sr(e, t) {
126
- return e != e ? t == t : e !== t || e !== null && typeof e == "object" || typeof e == "function";
127
- }
128
- function Hn(e) {
129
- return !Sr(e, this.v);
130
- }
131
- let kr = !1, tt = null;
132
- function $e(e) {
133
- tt = e;
134
- }
135
- function Bn(e, t = !1, o) {
136
- tt = {
137
- p: tt,
138
- i: !1,
139
- c: null,
140
- e: null,
141
- s: e,
142
- x: null,
143
- l: null
144
- };
145
- }
146
- function zn(e) {
147
- var t = (
148
- /** @type {ComponentContext} */
149
- tt
150
- ), o = t.e;
151
- if (o !== null) {
152
- t.e = null;
153
- for (var n of o)
154
- vi(n);
155
- }
156
- return e !== void 0 && (t.x = e), t.i = !0, tt = t.p, e ?? /** @type {T} */
157
- {};
158
- }
159
- function Gn() {
160
- return !0;
161
- }
162
- let ne = [];
163
- function Fn() {
164
- var e = ne;
165
- ne = [], ar(e);
166
- }
167
- function le(e) {
168
- if (ne.length === 0 && !We) {
169
- var t = ne;
170
- queueMicrotask(() => {
171
- t === ne && Fn();
172
- });
173
- }
174
- ne.push(e);
175
- }
176
- function Cr() {
177
- for (; ne.length > 0; )
178
- Fn();
179
- }
180
- function Un(e) {
181
- var t = S;
182
- if (t === null)
183
- return _.f |= Ft, e;
184
- if ((t.f & Se) === 0 && (t.f & ze) === 0)
185
- throw e;
186
- Ie(e, t);
187
- }
188
- function Ie(e, t) {
189
- for (; t !== null; ) {
190
- if ((t.f & Vo) !== 0) {
191
- if ((t.f & Se) === 0)
192
- throw e;
193
- try {
194
- t.b.error(e);
195
- return;
196
- } catch (o) {
197
- e = o;
198
- }
199
- }
200
- t = t.parent;
201
- }
202
- throw e;
203
- }
204
- const Ar = -7169;
205
- function M(e, t) {
206
- e.f = e.f & Ar | t;
207
- }
208
- function Yo(e) {
209
- (e.f & Y) !== 0 || e.deps === null ? M(e, N) : M(e, ht);
210
- }
211
- function Kn(e) {
212
- if (e !== null)
213
- for (const t of e)
214
- (t.f & P) === 0 || (t.f & se) === 0 || (t.f ^= se, Kn(
215
- /** @type {Derived} */
216
- t.deps
217
- ));
218
- }
219
- function Jn(e, t, o) {
220
- (e.f & q) !== 0 ? t.add(e) : (e.f & ht) !== 0 && o.add(e), Kn(e.deps), M(e, N);
221
- }
222
- const oo = /* @__PURE__ */ new Set();
223
- let V = null, ft = null, F = [], To = null, Oo = !1, We = !1;
224
- var Oe, Re, Nt, Qt, Ne, ho, me, Ht, je, te, Ro, No, Zn;
225
- const Lr = class Xn {
226
- constructor() {
227
- x(this, te), $(this, "committed", !1), $(this, "current", /* @__PURE__ */ new Map()), $(this, "previous", /* @__PURE__ */ new Map()), x(this, Oe, /* @__PURE__ */ new Set()), x(this, Re, /* @__PURE__ */ new Set()), x(this, Nt, 0), x(this, Qt, 0), x(this, Ne, null), x(this, ho, /* @__PURE__ */ new Set()), x(this, me, /* @__PURE__ */ new Set()), x(this, Ht, /* @__PURE__ */ new Map()), $(this, "is_fork", !1), x(this, je, !1);
228
- }
229
- is_deferred() {
230
- return this.is_fork || u(this, Qt) > 0;
231
- }
232
- /**
233
- * Add an effect to the #skipped_branches map and reset its children
234
- * @param {Effect} effect
235
- */
236
- skip_effect(t) {
237
- u(this, Ht).has(t) || u(this, Ht).set(t, { d: [], m: [] });
238
- }
239
- /**
240
- * Remove an effect from the #skipped_branches map and reschedule
241
- * any tracked dirty/maybe_dirty child effects
242
- * @param {Effect} effect
243
- */
244
- unskip_effect(t) {
245
- var o = u(this, Ht).get(t);
246
- if (o) {
247
- u(this, Ht).delete(t);
248
- for (var n of o.d)
249
- M(n, q), ct(n);
250
- for (n of o.m)
251
- M(n, ht), ct(n);
252
- }
253
- }
254
- /**
255
- *
256
- * @param {Effect[]} root_effects
257
- */
258
- process(t) {
259
- F = [], this.apply();
260
- var o = [], n = [];
261
- for (const i of t)
262
- G(this, te, Ro).call(this, i, o, n);
263
- if (this.is_deferred()) {
264
- G(this, te, No).call(this, n), G(this, te, No).call(this, o);
265
- for (const [i, r] of u(this, Ht))
266
- ei(i, r);
267
- } else {
268
- for (const i of u(this, Oe)) i();
269
- u(this, Oe).clear(), u(this, Nt) === 0 && G(this, te, Zn).call(this), V = null, mn(n), mn(o), u(this, Ne)?.resolve();
270
- }
271
- ft = null;
272
- }
273
- /**
274
- * Associate a change to a given source with the current
275
- * batch, noting its previous and current values
276
- * @param {Source} source
277
- * @param {any} value
278
- */
279
- capture(t, o) {
280
- o !== j && !this.previous.has(t) && this.previous.set(t, o), (t.f & Ft) === 0 && (this.current.set(t, t.v), ft?.set(t, t.v));
281
- }
282
- activate() {
283
- V = this, this.apply();
284
- }
285
- deactivate() {
286
- V === this && (V = null, ft = null);
287
- }
288
- flush() {
289
- if (this.activate(), F.length > 0) {
290
- if (Yn(), V !== null && V !== this)
291
- return;
292
- } else u(this, Nt) === 0 && this.process([]);
293
- this.deactivate();
294
- }
295
- discard() {
296
- for (const t of u(this, Re)) t(this);
297
- u(this, Re).clear();
298
- }
299
- /**
300
- *
301
- * @param {boolean} blocking
302
- */
303
- increment(t) {
304
- T(this, Nt, u(this, Nt) + 1), t && T(this, Qt, u(this, Qt) + 1);
305
- }
306
- /**
307
- *
308
- * @param {boolean} blocking
309
- */
310
- decrement(t) {
311
- T(this, Nt, u(this, Nt) - 1), t && T(this, Qt, u(this, Qt) - 1), !u(this, je) && (T(this, je, !0), le(() => {
312
- T(this, je, !1), this.is_deferred() ? F.length > 0 && this.flush() : this.revive();
313
- }));
314
- }
315
- revive() {
316
- for (const t of u(this, ho))
317
- u(this, me).delete(t), M(t, q), ct(t);
318
- for (const t of u(this, me))
319
- M(t, ht), ct(t);
320
- this.flush();
321
- }
322
- /** @param {() => void} fn */
323
- oncommit(t) {
324
- u(this, Oe).add(t);
325
- }
326
- /** @param {(batch: Batch) => void} fn */
327
- ondiscard(t) {
328
- u(this, Re).add(t);
329
- }
330
- settled() {
331
- return (u(this, Ne) ?? T(this, Ne, Pn())).promise;
332
- }
333
- static ensure() {
334
- if (V === null) {
335
- const t = V = new Xn();
336
- oo.add(V), We || le(() => {
337
- V === t && t.flush();
338
- });
339
- }
340
- return V;
341
- }
342
- apply() {
343
- }
344
- };
345
- Oe = /* @__PURE__ */ new WeakMap(), Re = /* @__PURE__ */ new WeakMap(), Nt = /* @__PURE__ */ new WeakMap(), Qt = /* @__PURE__ */ new WeakMap(), Ne = /* @__PURE__ */ new WeakMap(), ho = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), Ht = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakSet(), /**
346
- * Traverse the effect tree, executing effects or stashing
347
- * them for later execution as appropriate
348
- * @param {Effect} root
349
- * @param {Effect[]} effects
350
- * @param {Effect[]} render_effects
351
- */
352
- Ro = function(e, t, o) {
353
- e.f ^= N;
354
- for (var n = e.first, i = null; n !== null; ) {
355
- var r = n.f, s = (r & (dt | Jt)) !== 0, l = s && (r & N) !== 0, a = l || (r & J) !== 0 || u(this, Ht).has(n);
356
- if (!a && n.fn !== null) {
357
- s ? n.f ^= N : i !== null && (r & (ze | bo | qn)) !== 0 ? i.b.defer_effect(n) : (r & ze) !== 0 ? t.push(n) : Fe(n) && ((r & Mt) !== 0 && u(this, me).add(n), _e(n));
358
- var c = n.first;
359
- if (c !== null) {
360
- n = c;
361
- continue;
362
- }
363
- }
364
- for (; n !== null; ) {
365
- n === i && (i = null);
366
- var f = n.next;
367
- if (f !== null) {
368
- n = f;
369
- break;
370
- }
371
- n = n.parent;
372
- }
373
- }
374
- }, /**
375
- * @param {Effect[]} effects
376
- */
377
- No = function(e) {
378
- for (var t = 0; t < e.length; t += 1)
379
- Jn(e[t], u(this, ho), u(this, me));
380
- }, Zn = function() {
381
- var e;
382
- if (oo.size > 1) {
383
- this.previous.clear();
384
- var t = ft, o = !0;
385
- for (const i of oo) {
386
- if (i === this) {
387
- o = !1;
388
- continue;
389
- }
390
- const r = [];
391
- for (const [l, a] of this.current) {
392
- if (i.current.has(l))
393
- if (o && a !== i.current.get(l))
394
- i.current.set(l, a);
395
- else
396
- continue;
397
- r.push(l);
398
- }
399
- if (r.length === 0)
400
- continue;
401
- const s = [...i.current.keys()].filter((l) => !this.current.has(l));
402
- if (s.length > 0) {
403
- var n = F;
404
- F = [];
405
- const l = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
406
- for (const c of r)
407
- Qn(c, s, l, a);
408
- if (F.length > 0) {
409
- V = i, i.apply();
410
- for (const c of F)
411
- G(e = i, te, Ro).call(e, c, [], []);
412
- i.deactivate();
413
- }
414
- F = n;
415
- }
416
- }
417
- V = null, ft = t;
418
- }
419
- this.committed = !0, oo.delete(this);
420
- };
421
- let ae = Lr;
422
- function no(e) {
423
- var t = We;
424
- We = !0;
425
- try {
426
- for (var o; ; ) {
427
- if (Cr(), F.length === 0 && (V?.flush(), F.length === 0))
428
- return To = null, /** @type {T} */
429
- o;
430
- Yn();
431
- }
432
- } finally {
433
- We = t;
434
- }
435
- }
436
- function Yn() {
437
- Oo = !0;
438
- try {
439
- for (var e = 0; F.length > 0; ) {
440
- var t = ae.ensure();
441
- if (e++ > 1e3) {
442
- var o, n;
443
- Er();
444
- }
445
- t.process(F), Ut.clear();
446
- }
447
- } finally {
448
- F = [], Oo = !1, To = null;
449
- }
450
- }
451
- function Er() {
452
- try {
453
- mr();
454
- } catch (e) {
455
- Ie(e, To);
456
- }
457
- }
458
- let At = null;
459
- function mn(e) {
460
- var t = e.length;
461
- if (t !== 0) {
462
- for (var o = 0; o < t; ) {
463
- var n = e[o++];
464
- if ((n.f & (Vt | J)) === 0 && Fe(n) && (At = /* @__PURE__ */ new Set(), _e(n), n.deps === null && n.first === null && n.nodes === null && n.teardown === null && n.ac === null && mi(n), At?.size > 0)) {
465
- Ut.clear();
466
- for (const i of At) {
467
- if ((i.f & (Vt | J)) !== 0) continue;
468
- const r = [i];
469
- let s = i.parent;
470
- for (; s !== null; )
471
- At.has(s) && (At.delete(s), r.push(s)), s = s.parent;
472
- for (let l = r.length - 1; l >= 0; l--) {
473
- const a = r[l];
474
- (a.f & (Vt | J)) === 0 && _e(a);
475
- }
476
- }
477
- At.clear();
478
- }
479
- }
480
- At = null;
481
- }
482
- }
483
- function Qn(e, t, o, n) {
484
- if (!o.has(e) && (o.add(e), e.reactions !== null))
485
- for (const i of e.reactions) {
486
- const r = i.f;
487
- (r & P) !== 0 ? Qn(
488
- /** @type {Derived} */
489
- i,
490
- t,
491
- o,
492
- n
493
- ) : (r & (Xo | Mt)) !== 0 && (r & q) === 0 && ti(i, t, n) && (M(i, q), ct(
494
- /** @type {Effect} */
495
- i
496
- ));
497
- }
498
- }
499
- function ti(e, t, o) {
500
- const n = o.get(e);
501
- if (n !== void 0) return n;
502
- if (e.deps !== null)
503
- for (const i of e.deps) {
504
- if (we.call(t, i))
505
- return !0;
506
- if ((i.f & P) !== 0 && ti(
507
- /** @type {Derived} */
508
- i,
509
- t,
510
- o
511
- ))
512
- return o.set(
513
- /** @type {Derived} */
514
- i,
515
- !0
516
- ), !0;
517
- }
518
- return o.set(e, !1), !1;
519
- }
520
- function ct(e) {
521
- for (var t = To = e; t.parent !== null; ) {
522
- t = t.parent;
523
- var o = t.f;
524
- if (Oo && t === S && (o & Mt) !== 0 && (o & Zo) === 0)
525
- return;
526
- if ((o & (Jt | dt)) !== 0) {
527
- if ((o & N) === 0) return;
528
- t.f ^= N;
529
- }
530
- }
531
- F.push(t);
532
- }
533
- function ei(e, t) {
534
- if (!((e.f & dt) !== 0 && (e.f & N) !== 0)) {
535
- (e.f & q) !== 0 ? t.d.push(e) : (e.f & ht) !== 0 && t.m.push(e), M(e, N);
536
- for (var o = e.first; o !== null; )
537
- ei(o, t), o = o.next;
538
- }
539
- }
540
- function Vr(e) {
541
- let t = 0, o = ce(0), n;
542
- return () => {
543
- on() && (b(o), nn(() => (t === 0 && (n = Ai(() => e(() => Be(o)))), t += 1, () => {
544
- le(() => {
545
- t -= 1, t === 0 && (n?.(), n = void 0, Be(o));
546
- });
547
- })));
548
- };
549
- }
550
- var Mr = Te | he;
551
- function Or(e, t, o) {
552
- new Rr(e, t, o);
553
- }
554
- var lt, io, zt, pe, Lt, Et, X, kt, jt, ee, Pt, Pe, De, He, qt, jo, st, oi, ni, Po, po, qo;
555
- class Rr {
556
- /**
557
- * @param {TemplateNode} node
558
- * @param {BoundaryProps} props
559
- * @param {((anchor: Node) => void)} children
560
- */
561
- constructor(t, o, n) {
562
- x(this, st), $(this, "parent"), $(this, "is_pending", !1), x(this, lt), x(this, io, L ? E : null), x(this, zt), x(this, pe), x(this, Lt), x(this, Et, null), x(this, X, null), x(this, kt, null), x(this, jt, null), x(this, ee, 0), x(this, Pt, 0), x(this, Pe, !1), x(this, De, /* @__PURE__ */ new Set()), x(this, He, /* @__PURE__ */ new Set()), x(this, qt, null), x(this, jo, Vr(() => (T(this, qt, ce(u(this, ee))), () => {
563
- T(this, qt, null);
564
- }))), T(this, lt, t), T(this, zt, o), T(this, pe, (i) => {
565
- var r = (
566
- /** @type {Effect} */
567
- S
568
- );
569
- r.b = this, r.f |= Vo, n(i);
570
- }), this.parent = /** @type {Effect} */
571
- S.b, T(this, Lt, Io(() => {
572
- if (L) {
573
- const i = (
574
- /** @type {Comment} */
575
- u(this, io)
576
- );
577
- wo(), i.data === vo ? G(this, st, ni).call(this) : G(this, st, oi).call(this);
578
- } else
579
- G(this, st, Po).call(this);
580
- }, Mr)), L && T(this, lt, E);
581
- }
582
- /**
583
- * Defer an effect inside a pending boundary until the boundary resolves
584
- * @param {Effect} effect
585
- */
586
- defer_effect(t) {
587
- Jn(t, u(this, De), u(this, He));
588
- }
589
- /**
590
- * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
591
- * @returns {boolean}
592
- */
593
- is_rendered() {
594
- return !this.is_pending && (!this.parent || this.parent.is_rendered());
595
- }
596
- has_pending_snippet() {
597
- return !!u(this, zt).pending;
598
- }
599
- /**
600
- * Update the source that powers `$effect.pending()` inside this boundary,
601
- * and controls when the current `pending` snippet (if any) is removed.
602
- * Do not call from inside the class
603
- * @param {1 | -1} d
604
- */
605
- update_pending_count(t) {
606
- G(this, st, qo).call(this, t), T(this, ee, u(this, ee) + t), !(!u(this, qt) || u(this, Pe)) && (T(this, Pe, !0), le(() => {
607
- T(this, Pe, !1), u(this, qt) && xe(u(this, qt), u(this, ee));
608
- }));
609
- }
610
- get_effect_pending() {
611
- return u(this, jo).call(this), b(
612
- /** @type {Source<number>} */
613
- u(this, qt)
614
- );
615
- }
616
- /** @param {unknown} error */
617
- error(t) {
618
- var o = u(this, zt).onerror;
619
- let n = u(this, zt).failed;
620
- if (!o && !n)
621
- throw t;
622
- u(this, Et) && (H(u(this, Et)), T(this, Et, null)), u(this, X) && (H(u(this, X)), T(this, X, null)), u(this, kt) && (H(u(this, kt)), T(this, kt, null)), L && (B(
623
- /** @type {TemplateNode} */
624
- u(this, io)
625
- ), _r(), B(fo()));
626
- var i = !1, r = !1;
627
- const s = () => {
628
- if (i) {
629
- xr();
630
- return;
631
- }
632
- i = !0, r && Ir(), u(this, kt) !== null && fe(u(this, kt), () => {
633
- T(this, kt, null);
634
- }), G(this, st, po).call(this, () => {
635
- ae.ensure(), G(this, st, Po).call(this);
636
- });
637
- };
638
- le(() => {
639
- try {
640
- r = !0, o?.(t, s), r = !1;
641
- } catch (l) {
642
- Ie(l, u(this, Lt) && u(this, Lt).parent);
643
- }
644
- n && T(this, kt, G(this, st, po).call(this, () => {
645
- ae.ensure();
646
- try {
647
- return yt(() => {
648
- var l = (
649
- /** @type {Effect} */
650
- S
651
- );
652
- l.b = this, l.f |= Vo, n(
653
- u(this, lt),
654
- () => t,
655
- () => s
656
- );
657
- });
658
- } catch (l) {
659
- return Ie(
660
- l,
661
- /** @type {Effect} */
662
- u(this, Lt).parent
663
- ), null;
664
- }
665
- }));
666
- });
667
- }
668
- }
669
- lt = /* @__PURE__ */ new WeakMap(), io = /* @__PURE__ */ new WeakMap(), zt = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap(), Lt = /* @__PURE__ */ new WeakMap(), Et = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap(), jt = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakMap(), Pt = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap(), qt = /* @__PURE__ */ new WeakMap(), jo = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakSet(), oi = function() {
670
- try {
671
- T(this, Et, yt(() => u(this, pe).call(this, u(this, lt))));
672
- } catch (e) {
673
- this.error(e);
674
- }
675
- }, ni = function() {
676
- const e = u(this, zt).pending;
677
- e && (this.is_pending = !0, T(this, X, yt(() => e(u(this, lt)))), le(() => {
678
- var t = T(this, jt, document.createDocumentFragment()), o = wt();
679
- t.append(o), T(this, Et, G(this, st, po).call(this, () => (ae.ensure(), yt(() => u(this, pe).call(this, o))))), u(this, Pt) === 0 && (u(this, lt).before(t), T(this, jt, null), fe(
680
- /** @type {Effect} */
681
- u(this, X),
682
- () => {
683
- T(this, X, null);
684
- }
685
- ), this.is_pending = !1);
686
- }));
687
- }, Po = function() {
688
- try {
689
- if (this.is_pending = this.has_pending_snippet(), T(this, Pt, 0), T(this, ee, 0), T(this, Et, yt(() => {
690
- u(this, pe).call(this, u(this, lt));
691
- })), u(this, Pt) > 0) {
692
- var e = T(this, jt, document.createDocumentFragment());
693
- Ti(u(this, Et), e);
694
- const t = (
695
- /** @type {(anchor: Node) => void} */
696
- u(this, zt).pending
697
- );
698
- T(this, X, yt(() => t(u(this, lt))));
699
- } else
700
- this.is_pending = !1;
701
- } catch (t) {
702
- this.error(t);
703
- }
704
- }, /**
705
- * @template T
706
- * @param {() => T} fn
707
- */
708
- po = function(e) {
709
- var t = S, o = _, n = tt;
710
- Tt(u(this, Lt)), ot(u(this, Lt)), $e(u(this, Lt).ctx);
711
- try {
712
- return e();
713
- } catch (i) {
714
- return Un(i), null;
715
- } finally {
716
- Tt(t), ot(o), $e(n);
717
- }
718
- }, /**
719
- * Updates the pending count associated with the currently visible pending snippet,
720
- * if any, such that we can replace the snippet with content once work is done
721
- * @param {1 | -1} d
722
- */
723
- qo = function(e) {
724
- var t;
725
- if (!this.has_pending_snippet()) {
726
- this.parent && G(t = this.parent, st, qo).call(t, e);
727
- return;
728
- }
729
- if (T(this, Pt, u(this, Pt) + e), u(this, Pt) === 0) {
730
- this.is_pending = !1;
731
- for (const o of u(this, De))
732
- M(o, q), ct(o);
733
- for (const o of u(this, He))
734
- M(o, ht), ct(o);
735
- u(this, De).clear(), u(this, He).clear(), u(this, X) && fe(u(this, X), () => {
736
- T(this, X, null);
737
- }), u(this, jt) && (u(this, lt).before(u(this, jt)), T(this, jt, null));
738
- }
739
- };
740
- function Nr(e, t, o, n) {
741
- const i = $o;
742
- var r = e.filter((v) => !v.settled);
743
- if (o.length === 0 && r.length === 0) {
744
- n(t.map(i));
745
- return;
746
- }
747
- var s = V, l = (
748
- /** @type {Effect} */
749
- S
750
- ), a = jr(), c = r.length === 1 ? r[0].promise : r.length > 1 ? Promise.all(r.map((v) => v.promise)) : null;
751
- function f(v) {
752
- a();
753
- try {
754
- n(v);
755
- } catch (d) {
756
- (l.f & Vt) === 0 && Ie(d, l);
757
- }
758
- s?.deactivate(), Wo();
759
- }
760
- if (o.length === 0) {
761
- c.then(() => f(t.map(i)));
762
- return;
763
- }
764
- function p() {
765
- a(), Promise.all(o.map((v) => /* @__PURE__ */ Pr(v))).then((v) => f([...t.map(i), ...v])).catch((v) => Ie(v, l));
766
- }
767
- c ? c.then(p) : p();
768
- }
769
- function jr() {
770
- var e = S, t = _, o = tt, n = V;
771
- return function(i = !0) {
772
- Tt(e), ot(t), $e(o), i && n?.activate();
773
- };
774
- }
775
- function Wo() {
776
- Tt(null), ot(null), $e(null);
777
- }
778
- // @__NO_SIDE_EFFECTS__
779
- function $o(e) {
780
- var t = P | q, o = _ !== null && (_.f & P) !== 0 ? (
781
- /** @type {Derived} */
782
- _
783
- ) : null;
784
- return S !== null && (S.f |= he), {
785
- ctx: tt,
786
- deps: null,
787
- effects: null,
788
- equals: Dn,
789
- f: t,
790
- fn: e,
791
- reactions: null,
792
- rv: 0,
793
- v: (
794
- /** @type {V} */
795
- j
796
- ),
797
- wv: 0,
798
- parent: o ?? S,
799
- ac: null
800
- };
801
- }
802
- // @__NO_SIDE_EFFECTS__
803
- function Pr(e, t, o) {
804
- let n = (
805
- /** @type {Effect | null} */
806
- S
807
- );
808
- n === null && dr();
809
- var i = (
810
- /** @type {Boundary} */
811
- n.b
812
- ), r = (
813
- /** @type {Promise<V>} */
814
- /** @type {unknown} */
815
- void 0
816
- ), s = ce(
817
- /** @type {V} */
818
- j
819
- ), l = !_, a = /* @__PURE__ */ new Map();
820
- return Jr(() => {
821
- var c = Pn();
822
- r = c.promise;
823
- try {
824
- Promise.resolve(e()).then(c.resolve, c.reject).then(() => {
825
- f === V && f.committed && f.deactivate(), Wo();
826
- });
827
- } catch (d) {
828
- c.reject(d), Wo();
829
- }
830
- var f = (
831
- /** @type {Batch} */
832
- V
833
- );
834
- if (l) {
835
- var p = i.is_rendered();
836
- i.update_pending_count(1), f.increment(p), a.get(f)?.reject(oe), a.delete(f), a.set(f, c);
837
- }
838
- const v = (d, h = void 0) => {
839
- if (f.activate(), h)
840
- h !== oe && (s.f |= Ft, xe(s, h));
841
- else {
842
- (s.f & Ft) !== 0 && (s.f ^= Ft), xe(s, d);
843
- for (const [m, y] of a) {
844
- if (a.delete(m), m === f) break;
845
- y.reject(oe);
846
- }
847
- }
848
- l && (i.update_pending_count(-1), f.decrement(p));
849
- };
850
- c.promise.then(v, (d) => v(null, d || "unknown"));
851
- }), Fr(() => {
852
- for (const c of a.values())
853
- c.reject(oe);
854
- }), new Promise((c) => {
855
- function f(p) {
856
- function v() {
857
- p === r ? c(s) : f(r);
858
- }
859
- p.then(v, v);
860
- }
861
- f(r);
862
- });
863
- }
864
- // @__NO_SIDE_EFFECTS__
865
- function Ao(e) {
866
- const t = /* @__PURE__ */ $o(e);
867
- return $i(t), t;
868
- }
869
- // @__NO_SIDE_EFFECTS__
870
- function qr(e) {
871
- const t = /* @__PURE__ */ $o(e);
872
- return t.equals = Hn, t;
873
- }
874
- function Wr(e) {
875
- var t = e.effects;
876
- if (t !== null) {
877
- e.effects = null;
878
- for (var o = 0; o < t.length; o += 1)
879
- H(
880
- /** @type {Effect} */
881
- t[o]
882
- );
883
- }
884
- }
885
- function Dr(e) {
886
- for (var t = e.parent; t !== null; ) {
887
- if ((t.f & P) === 0)
888
- return (t.f & Vt) === 0 ? (
889
- /** @type {Effect} */
890
- t
891
- ) : null;
892
- t = t.parent;
893
- }
894
- return null;
895
- }
896
- function Qo(e) {
897
- var t, o = S;
898
- Tt(Dr(e));
899
- try {
900
- e.f &= ~se, Wr(e), t = Si(e);
901
- } finally {
902
- Tt(o);
903
- }
904
- return t;
905
- }
906
- function ii(e) {
907
- var t = Qo(e);
908
- if (!e.equals(t) && (e.wv = xi(), (!V?.is_fork || e.deps === null) && (e.v = t, e.deps === null))) {
909
- M(e, N);
910
- return;
911
- }
912
- Kt || (ft !== null ? (on() || V?.is_fork) && ft.set(e, t) : Yo(e));
913
- }
914
- function Hr(e) {
915
- if (e.effects !== null)
916
- for (const t of e.effects)
917
- (t.teardown || t.ac) && (t.teardown?.(), t.ac?.abort(oe), t.teardown = lr, t.ac = null, Ge(t, 0), rn(t));
918
- }
919
- function ri(e) {
920
- if (e.effects !== null)
921
- for (const t of e.effects)
922
- t.teardown && _e(t);
923
- }
924
- let Do = /* @__PURE__ */ new Set();
925
- const Ut = /* @__PURE__ */ new Map();
926
- let si = !1;
927
- function ce(e, t) {
928
- var o = {
929
- f: 0,
930
- // TODO ideally we could skip this altogether, but it causes type errors
931
- v: e,
932
- reactions: null,
933
- equals: Dn,
934
- rv: 0,
935
- wv: 0
936
- };
937
- return o;
938
- }
939
- // @__NO_SIDE_EFFECTS__
940
- function R(e, t) {
941
- const o = ce(e);
942
- return $i(o), o;
943
- }
944
- // @__NO_SIDE_EFFECTS__
945
- function li(e, t = !1, o = !0) {
946
- const n = ce(e);
947
- return t || (n.equals = Hn), n;
948
- }
949
- function C(e, t, o = !1) {
950
- _ !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
951
- // to ensure we error if state is set inside an inspect effect
952
- (!ut || (_.f & bn) !== 0) && Gn() && (_.f & (P | Mt | Xo | bn)) !== 0 && (Q === null || !we.call(Q, e)) && $r();
953
- let n = o ? ve(t) : t;
954
- return xe(e, n);
955
- }
956
- function xe(e, t) {
957
- if (!e.equals(t)) {
958
- var o = e.v;
959
- Kt ? Ut.set(e, t) : Ut.set(e, o), e.v = t;
960
- var n = ae.ensure();
961
- if (n.capture(e, o), (e.f & P) !== 0) {
962
- const i = (
963
- /** @type {Derived} */
964
- e
965
- );
966
- (e.f & q) !== 0 && Qo(i), Yo(i);
967
- }
968
- e.wv = xi(), ai(e, q), S !== null && (S.f & N) !== 0 && (S.f & (dt | Jt)) === 0 && (Z === null ? Yr([e]) : Z.push(e)), !n.is_fork && Do.size > 0 && !si && Br();
969
- }
970
- return t;
971
- }
972
- function Br() {
973
- si = !1;
974
- for (const e of Do)
975
- (e.f & N) !== 0 && M(e, ht), Fe(e) && _e(e);
976
- Do.clear();
977
- }
978
- function Be(e) {
979
- C(e, e.v + 1);
980
- }
981
- function ai(e, t) {
982
- var o = e.reactions;
983
- if (o !== null)
984
- for (var n = o.length, i = 0; i < n; i++) {
985
- var r = o[i], s = r.f, l = (s & q) === 0;
986
- if (l && M(r, t), (s & P) !== 0) {
987
- var a = (
988
- /** @type {Derived} */
989
- r
990
- );
991
- ft?.delete(a), (s & se) === 0 && (s & Y && (r.f |= se), ai(a, ht));
992
- } else l && ((s & Mt) !== 0 && At !== null && At.add(
993
- /** @type {Effect} */
994
- r
995
- ), ct(
996
- /** @type {Effect} */
997
- r
998
- ));
999
- }
1000
- }
1001
- function ve(e) {
1002
- if (typeof e != "object" || e === null || eo in e)
1003
- return e;
1004
- const t = jn(e);
1005
- if (t !== rr && t !== sr)
1006
- return e;
1007
- var o = /* @__PURE__ */ new Map(), n = Nn(e), i = /* @__PURE__ */ R(0), r = re, s = (l) => {
1008
- if (re === r)
1009
- return l();
1010
- var a = _, c = re;
1011
- ot(null), $n(r);
1012
- var f = l();
1013
- return ot(a), $n(c), f;
1014
- };
1015
- return n && o.set("length", /* @__PURE__ */ R(
1016
- /** @type {any[]} */
1017
- e.length
1018
- )), new Proxy(
1019
- /** @type {any} */
1020
- e,
1021
- {
1022
- defineProperty(l, a, c) {
1023
- (!("value" in c) || c.configurable === !1 || c.enumerable === !1 || c.writable === !1) && wr();
1024
- var f = o.get(a);
1025
- return f === void 0 ? s(() => {
1026
- var p = /* @__PURE__ */ R(c.value);
1027
- return o.set(a, p), p;
1028
- }) : C(f, c.value, !0), !0;
1029
- },
1030
- deleteProperty(l, a) {
1031
- var c = o.get(a);
1032
- if (c === void 0) {
1033
- if (a in l) {
1034
- const f = s(() => /* @__PURE__ */ R(j));
1035
- o.set(a, f), Be(i);
1036
- }
1037
- } else
1038
- C(c, j), Be(i);
1039
- return !0;
1040
- },
1041
- get(l, a, c) {
1042
- if (a === eo)
1043
- return e;
1044
- var f = o.get(a), p = a in l;
1045
- if (f === void 0 && (!p || be(l, a)?.writable) && (f = s(() => {
1046
- var d = ve(p ? l[a] : j), h = /* @__PURE__ */ R(d);
1047
- return h;
1048
- }), o.set(a, f)), f !== void 0) {
1049
- var v = b(f);
1050
- return v === j ? void 0 : v;
1051
- }
1052
- return Reflect.get(l, a, c);
1053
- },
1054
- getOwnPropertyDescriptor(l, a) {
1055
- var c = Reflect.getOwnPropertyDescriptor(l, a);
1056
- if (c && "value" in c) {
1057
- var f = o.get(a);
1058
- f && (c.value = b(f));
1059
- } else if (c === void 0) {
1060
- var p = o.get(a), v = p?.v;
1061
- if (p !== void 0 && v !== j)
1062
- return {
1063
- enumerable: !0,
1064
- configurable: !0,
1065
- value: v,
1066
- writable: !0
1067
- };
1068
- }
1069
- return c;
1070
- },
1071
- has(l, a) {
1072
- if (a === eo)
1073
- return !0;
1074
- var c = o.get(a), f = c !== void 0 && c.v !== j || Reflect.has(l, a);
1075
- if (c !== void 0 || S !== null && (!f || be(l, a)?.writable)) {
1076
- c === void 0 && (c = s(() => {
1077
- var v = f ? ve(l[a]) : j, d = /* @__PURE__ */ R(v);
1078
- return d;
1079
- }), o.set(a, c));
1080
- var p = b(c);
1081
- if (p === j)
1082
- return !1;
1083
- }
1084
- return f;
1085
- },
1086
- set(l, a, c, f) {
1087
- var p = o.get(a), v = a in l;
1088
- if (n && a === "length")
1089
- for (var d = c; d < /** @type {Source<number>} */
1090
- p.v; d += 1) {
1091
- var h = o.get(d + "");
1092
- h !== void 0 ? C(h, j) : d in l && (h = s(() => /* @__PURE__ */ R(j)), o.set(d + "", h));
1093
- }
1094
- if (p === void 0)
1095
- (!v || be(l, a)?.writable) && (p = s(() => /* @__PURE__ */ R(void 0)), C(p, ve(c)), o.set(a, p));
1096
- else {
1097
- v = p.v !== j;
1098
- var m = s(() => ve(c));
1099
- C(p, m);
1100
- }
1101
- var y = Reflect.getOwnPropertyDescriptor(l, a);
1102
- if (y?.set && y.set.call(f, c), !v) {
1103
- if (n && typeof a == "string") {
1104
- var k = (
1105
- /** @type {Source<number>} */
1106
- o.get("length")
1107
- ), I = Number(a);
1108
- Number.isInteger(I) && I >= k.v && C(k, I + 1);
1109
- }
1110
- Be(i);
1111
- }
1112
- return !0;
1113
- },
1114
- ownKeys(l) {
1115
- b(i);
1116
- var a = Reflect.ownKeys(l).filter((p) => {
1117
- var v = o.get(p);
1118
- return v === void 0 || v.v !== j;
1119
- });
1120
- for (var [c, f] of o)
1121
- f.v !== j && !(c in l) && a.push(c);
1122
- return a;
1123
- },
1124
- setPrototypeOf() {
1125
- Tr();
1126
- }
1127
- }
1128
- );
1129
- }
1130
- var yn, ci, ui, fi;
1131
- function Ho() {
1132
- if (yn === void 0) {
1133
- yn = window, ci = /Firefox/.test(navigator.userAgent);
1134
- var e = Element.prototype, t = Node.prototype, o = Text.prototype;
1135
- ui = be(t, "firstChild").get, fi = be(t, "nextSibling").get, gn(e) && (e.__click = void 0, e.__className = void 0, e.__attributes = null, e.__style = void 0, e.__e = void 0), gn(o) && (o.__t = void 0);
1136
- }
1137
- }
1138
- function wt(e = "") {
1139
- return document.createTextNode(e);
1140
- }
1141
- // @__NO_SIDE_EFFECTS__
1142
- function ue(e) {
1143
- return (
1144
- /** @type {TemplateNode | null} */
1145
- ui.call(e)
1146
- );
1147
- }
1148
- // @__NO_SIDE_EFFECTS__
1149
- function et(e) {
1150
- return (
1151
- /** @type {TemplateNode | null} */
1152
- fi.call(e)
1153
- );
1154
- }
1155
- function Xe(e, t) {
1156
- if (!L)
1157
- return /* @__PURE__ */ ue(e);
1158
- var o = /* @__PURE__ */ ue(E);
1159
- if (o === null)
1160
- o = E.appendChild(wt());
1161
- else if (t && o.nodeType !== mo) {
1162
- var n = wt();
1163
- return o?.before(n), B(n), n;
1164
- }
1165
- return t && en(
1166
- /** @type {Text} */
1167
- o
1168
- ), B(o), o;
1169
- }
1170
- function Lo(e, t = !1) {
1171
- if (!L) {
1172
- var o = /* @__PURE__ */ ue(e);
1173
- return o instanceof Comment && o.data === "" ? /* @__PURE__ */ et(o) : o;
1174
- }
1175
- if (t) {
1176
- if (E?.nodeType !== mo) {
1177
- var n = wt();
1178
- return E?.before(n), B(n), n;
1179
- }
1180
- en(
1181
- /** @type {Text} */
1182
- E
1183
- );
1184
- }
1185
- return E;
1186
- }
1187
- function Ot(e, t = 1, o = !1) {
1188
- let n = L ? E : e;
1189
- for (var i; t--; )
1190
- i = n, n = /** @type {TemplateNode} */
1191
- /* @__PURE__ */ et(n);
1192
- if (!L)
1193
- return n;
1194
- if (o) {
1195
- if (n?.nodeType !== mo) {
1196
- var r = wt();
1197
- return n === null ? i?.after(r) : n.before(r), B(r), r;
1198
- }
1199
- en(
1200
- /** @type {Text} */
1201
- n
1202
- );
1203
- }
1204
- return B(n), n;
1205
- }
1206
- function hi(e) {
1207
- e.textContent = "";
1208
- }
1209
- function di() {
1210
- return !1;
1211
- }
1212
- function tn(e, t, o) {
1213
- return (
1214
- /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */
1215
- document.createElementNS(Rn, e, void 0)
1216
- );
1217
- }
1218
- function en(e) {
1219
- if (
1220
- /** @type {string} */
1221
- e.nodeValue.length < 65536
1222
- )
1223
- return;
1224
- let t = e.nextSibling;
1225
- for (; t !== null && t.nodeType === mo; )
1226
- t.remove(), e.nodeValue += /** @type {string} */
1227
- t.nodeValue, t = e.nextSibling;
1228
- }
1229
- function pi(e) {
1230
- var t = _, o = S;
1231
- ot(null), Tt(null);
1232
- try {
1233
- return e();
1234
- } finally {
1235
- ot(t), Tt(o);
1236
- }
1237
- }
1238
- function zr(e) {
1239
- S === null && (_ === null && br(), gr()), Kt && vr();
1240
- }
1241
- function Gr(e, t) {
1242
- var o = t.last;
1243
- o === null ? t.last = t.first = e : (o.next = e, e.prev = o, t.last = e);
1244
- }
1245
- function $t(e, t, o) {
1246
- var n = S;
1247
- n !== null && (n.f & J) !== 0 && (e |= J);
1248
- var i = {
1249
- ctx: tt,
1250
- deps: null,
1251
- nodes: null,
1252
- f: e | q | Y,
1253
- first: null,
1254
- fn: t,
1255
- last: null,
1256
- next: null,
1257
- parent: n,
1258
- b: n && n.b,
1259
- prev: null,
1260
- teardown: null,
1261
- wv: 0,
1262
- ac: null
1263
- };
1264
- if (o)
1265
- try {
1266
- _e(i);
1267
- } catch (l) {
1268
- throw H(i), l;
1269
- }
1270
- else t !== null && ct(i);
1271
- var r = i;
1272
- if (o && r.deps === null && r.teardown === null && r.nodes === null && r.first === r.last && // either `null`, or a singular child
1273
- (r.f & he) === 0 && (r = r.first, (e & Mt) !== 0 && (e & Te) !== 0 && r !== null && (r.f |= Te)), r !== null && (r.parent = n, n !== null && Gr(r, n), _ !== null && (_.f & P) !== 0 && (e & Jt) === 0)) {
1274
- var s = (
1275
- /** @type {Derived} */
1276
- _
1277
- );
1278
- (s.effects ?? (s.effects = [])).push(r);
1279
- }
1280
- return i;
1281
- }
1282
- function on() {
1283
- return _ !== null && !ut;
1284
- }
1285
- function Fr(e) {
1286
- const t = $t(bo, null, !1);
1287
- return M(t, N), t.teardown = e, t;
1288
- }
1289
- function wn(e) {
1290
- zr();
1291
- var t = (
1292
- /** @type {Effect} */
1293
- S.f
1294
- ), o = !_ && (t & dt) !== 0 && (t & Se) === 0;
1295
- if (o) {
1296
- var n = (
1297
- /** @type {ComponentContext} */
1298
- tt
1299
- );
1300
- (n.e ?? (n.e = [])).push(e);
1301
- } else
1302
- return vi(e);
1303
- }
1304
- function vi(e) {
1305
- return $t(ze | cr, e, !1);
1306
- }
1307
- function Ur(e) {
1308
- ae.ensure();
1309
- const t = $t(Jt | he, e, !0);
1310
- return () => {
1311
- H(t);
1312
- };
1313
- }
1314
- function Kr(e) {
1315
- ae.ensure();
1316
- const t = $t(Jt | he, e, !0);
1317
- return (o = {}) => new Promise((n) => {
1318
- o.outro ? fe(t, () => {
1319
- H(t), n(void 0);
1320
- }) : (H(t), n(void 0));
1321
- });
1322
- }
1323
- function gi(e) {
1324
- return $t(ze, e, !1);
1325
- }
1326
- function Jr(e) {
1327
- return $t(Xo | he, e, !0);
1328
- }
1329
- function nn(e, t = 0) {
1330
- return $t(bo | t, e, !0);
1331
- }
1332
- function Ye(e, t = [], o = [], n = []) {
1333
- Nr(n, t, o, (i) => {
1334
- $t(bo, () => e(...i.map(b)), !0);
1335
- });
1336
- }
1337
- function Io(e, t = 0) {
1338
- var o = $t(Mt | t, e, !0);
1339
- return o;
1340
- }
1341
- function yt(e) {
1342
- return $t(dt | he, e, !0);
1343
- }
1344
- function bi(e) {
1345
- var t = e.teardown;
1346
- if (t !== null) {
1347
- const o = Kt, n = _;
1348
- Tn(!0), ot(null);
1349
- try {
1350
- t.call(null);
1351
- } finally {
1352
- Tn(o), ot(n);
1353
- }
1354
- }
1355
- }
1356
- function rn(e, t = !1) {
1357
- var o = e.first;
1358
- for (e.first = e.last = null; o !== null; ) {
1359
- const i = o.ac;
1360
- i !== null && pi(() => {
1361
- i.abort(oe);
1362
- });
1363
- var n = o.next;
1364
- (o.f & Jt) !== 0 ? o.parent = null : H(o, t), o = n;
1365
- }
1366
- }
1367
- function Zr(e) {
1368
- for (var t = e.first; t !== null; ) {
1369
- var o = t.next;
1370
- (t.f & dt) === 0 && H(t), t = o;
1371
- }
1372
- }
1373
- function H(e, t = !0) {
1374
- var o = !1;
1375
- (t || (e.f & Zo) !== 0) && e.nodes !== null && e.nodes.end !== null && (Xr(
1376
- e.nodes.start,
1377
- /** @type {TemplateNode} */
1378
- e.nodes.end
1379
- ), o = !0), rn(e, t && !o), Ge(e, 0), M(e, Vt);
1380
- var n = e.nodes && e.nodes.t;
1381
- if (n !== null)
1382
- for (const r of n)
1383
- r.stop();
1384
- bi(e);
1385
- var i = e.parent;
1386
- i !== null && i.first !== null && mi(e), e.next = e.prev = e.teardown = e.ctx = e.deps = e.fn = e.nodes = e.ac = null;
1387
- }
1388
- function Xr(e, t) {
1389
- for (; e !== null; ) {
1390
- var o = e === t ? null : /* @__PURE__ */ et(e);
1391
- e.remove(), e = o;
1392
- }
1393
- }
1394
- function mi(e) {
1395
- var t = e.parent, o = e.prev, n = e.next;
1396
- o !== null && (o.next = n), n !== null && (n.prev = o), t !== null && (t.first === e && (t.first = n), t.last === e && (t.last = o));
1397
- }
1398
- function fe(e, t, o = !0) {
1399
- var n = [];
1400
- yi(e, n, !0);
1401
- var i = () => {
1402
- o && H(e), t && t();
1403
- }, r = n.length;
1404
- if (r > 0) {
1405
- var s = () => --r || i();
1406
- for (var l of n)
1407
- l.out(s);
1408
- } else
1409
- i();
1410
- }
1411
- function yi(e, t, o) {
1412
- if ((e.f & J) === 0) {
1413
- e.f ^= J;
1414
- var n = e.nodes && e.nodes.t;
1415
- if (n !== null)
1416
- for (const l of n)
1417
- (l.is_global || o) && t.push(l);
1418
- for (var i = e.first; i !== null; ) {
1419
- var r = i.next, s = (i.f & Te) !== 0 || // If this is a branch effect without a block effect parent,
1420
- // it means the parent block effect was pruned. In that case,
1421
- // transparency information was transferred to the branch effect.
1422
- (i.f & dt) !== 0 && (e.f & Mt) !== 0;
1423
- yi(i, t, s ? o : !1), i = r;
1424
- }
1425
- }
1426
- }
1427
- function sn(e) {
1428
- wi(e, !0);
1429
- }
1430
- function wi(e, t) {
1431
- if ((e.f & J) !== 0) {
1432
- e.f ^= J, (e.f & N) === 0 && (M(e, q), ct(e));
1433
- for (var o = e.first; o !== null; ) {
1434
- var n = o.next, i = (o.f & Te) !== 0 || (o.f & dt) !== 0;
1435
- wi(o, i ? t : !1), o = n;
1436
- }
1437
- var r = e.nodes && e.nodes.t;
1438
- if (r !== null)
1439
- for (const s of r)
1440
- (s.is_global || t) && s.in();
1441
- }
1442
- }
1443
- function Ti(e, t) {
1444
- if (e.nodes)
1445
- for (var o = e.nodes.start, n = e.nodes.end; o !== null; ) {
1446
- var i = o === n ? null : /* @__PURE__ */ et(o);
1447
- t.append(o), o = i;
1448
- }
1449
- }
1450
- let ro = !1, Kt = !1;
1451
- function Tn(e) {
1452
- Kt = e;
1453
- }
1454
- let _ = null, ut = !1;
1455
- function ot(e) {
1456
- _ = e;
1457
- }
1458
- let S = null;
1459
- function Tt(e) {
1460
- S = e;
1461
- }
1462
- let Q = null;
1463
- function $i(e) {
1464
- _ !== null && (Q === null ? Q = [e] : Q.push(e));
1465
- }
1466
- let z = null, K = 0, Z = null;
1467
- function Yr(e) {
1468
- Z = e;
1469
- }
1470
- let Ii = 1, ie = 0, re = ie;
1471
- function $n(e) {
1472
- re = e;
1473
- }
1474
- function xi() {
1475
- return ++Ii;
1476
- }
1477
- function Fe(e) {
1478
- var t = e.f;
1479
- if ((t & q) !== 0)
1480
- return !0;
1481
- if (t & P && (e.f &= ~se), (t & ht) !== 0) {
1482
- for (var o = (
1483
- /** @type {Value[]} */
1484
- e.deps
1485
- ), n = o.length, i = 0; i < n; i++) {
1486
- var r = o[i];
1487
- if (Fe(
1488
- /** @type {Derived} */
1489
- r
1490
- ) && ii(
1491
- /** @type {Derived} */
1492
- r
1493
- ), r.wv > e.wv)
1494
- return !0;
1495
- }
1496
- (t & Y) !== 0 && // During time traveling we don't want to reset the status so that
1497
- // traversal of the graph in the other batches still happens
1498
- ft === null && M(e, N);
1499
- }
1500
- return !1;
1501
- }
1502
- function _i(e, t, o = !0) {
1503
- var n = e.reactions;
1504
- if (n !== null && !(Q !== null && we.call(Q, e)))
1505
- for (var i = 0; i < n.length; i++) {
1506
- var r = n[i];
1507
- (r.f & P) !== 0 ? _i(
1508
- /** @type {Derived} */
1509
- r,
1510
- t,
1511
- !1
1512
- ) : t === r && (o ? M(r, q) : (r.f & N) !== 0 && M(r, ht), ct(
1513
- /** @type {Effect} */
1514
- r
1515
- ));
1516
- }
1517
- }
1518
- function Si(e) {
1519
- var t, o = z, n = K, i = Z, r = _, s = Q, l = tt, a = ut, c = re, f = e.f;
1520
- z = /** @type {null | Value[]} */
1521
- null, K = 0, Z = null, _ = (f & (dt | Jt)) === 0 ? e : null, Q = null, $e(e.ctx), ut = !1, re = ++ie, e.ac !== null && (pi(() => {
1522
- e.ac.abort(oe);
1523
- }), e.ac = null);
1524
- try {
1525
- e.f |= Mo;
1526
- var p = (
1527
- /** @type {Function} */
1528
- e.fn
1529
- ), v = p();
1530
- e.f |= Se;
1531
- var d = e.deps, h = V?.is_fork;
1532
- if (z !== null) {
1533
- var m;
1534
- if (h || Ge(e, K), d !== null && K > 0)
1535
- for (d.length = K + z.length, m = 0; m < z.length; m++)
1536
- d[K + m] = z[m];
1537
- else
1538
- e.deps = d = z;
1539
- if (on() && (e.f & Y) !== 0)
1540
- for (m = K; m < d.length; m++)
1541
- ((t = d[m]).reactions ?? (t.reactions = [])).push(e);
1542
- } else !h && d !== null && K < d.length && (Ge(e, K), d.length = K);
1543
- if (Gn() && Z !== null && !ut && d !== null && (e.f & (P | ht | q)) === 0)
1544
- for (m = 0; m < /** @type {Source[]} */
1545
- Z.length; m++)
1546
- _i(
1547
- Z[m],
1548
- /** @type {Effect} */
1549
- e
1550
- );
1551
- if (r !== null && r !== e) {
1552
- if (ie++, r.deps !== null)
1553
- for (let y = 0; y < n; y += 1)
1554
- r.deps[y].rv = ie;
1555
- if (o !== null)
1556
- for (const y of o)
1557
- y.rv = ie;
1558
- Z !== null && (i === null ? i = Z : i.push(.../** @type {Source[]} */
1559
- Z));
1560
- }
1561
- return (e.f & Ft) !== 0 && (e.f ^= Ft), v;
1562
- } catch (y) {
1563
- return Un(y);
1564
- } finally {
1565
- e.f ^= Mo, z = o, K = n, Z = i, _ = r, Q = s, $e(l), ut = a, re = c;
1566
- }
1567
- }
1568
- function Qr(e, t) {
1569
- let o = t.reactions;
1570
- if (o !== null) {
1571
- var n = nr.call(o, e);
1572
- if (n !== -1) {
1573
- var i = o.length - 1;
1574
- i === 0 ? o = t.reactions = null : (o[n] = o[i], o.pop());
1575
- }
1576
- }
1577
- if (o === null && (t.f & P) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
1578
- // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
1579
- // allows us to skip the expensive work of disconnecting and immediately reconnecting it
1580
- (z === null || !we.call(z, t))) {
1581
- var r = (
1582
- /** @type {Derived} */
1583
- t
1584
- );
1585
- (r.f & Y) !== 0 && (r.f ^= Y, r.f &= ~se), Yo(r), Hr(r), Ge(r, 0);
1586
- }
1587
- }
1588
- function Ge(e, t) {
1589
- var o = e.deps;
1590
- if (o !== null)
1591
- for (var n = t; n < o.length; n++)
1592
- Qr(e, o[n]);
1593
- }
1594
- function _e(e) {
1595
- var t = e.f;
1596
- if ((t & Vt) === 0) {
1597
- M(e, N);
1598
- var o = S, n = ro;
1599
- S = e, ro = !0;
1600
- try {
1601
- (t & (Mt | qn)) !== 0 ? Zr(e) : rn(e), bi(e);
1602
- var i = Si(e);
1603
- e.teardown = typeof i == "function" ? i : null, e.wv = Ii;
1604
- var r;
1605
- or && kr && (e.f & q) !== 0 && e.deps;
1606
- } finally {
1607
- ro = n, S = o;
1608
- }
1609
- }
1610
- }
1611
- function b(e) {
1612
- var t = e.f, o = (t & P) !== 0;
1613
- if (_ !== null && !ut) {
1614
- var n = S !== null && (S.f & Vt) !== 0;
1615
- if (!n && (Q === null || !we.call(Q, e))) {
1616
- var i = _.deps;
1617
- if ((_.f & Mo) !== 0)
1618
- e.rv < ie && (e.rv = ie, z === null && i !== null && i[K] === e ? K++ : z === null ? z = [e] : z.push(e));
1619
- else {
1620
- (_.deps ?? (_.deps = [])).push(e);
1621
- var r = e.reactions;
1622
- r === null ? e.reactions = [_] : we.call(r, _) || r.push(_);
1623
- }
1624
- }
1625
- }
1626
- if (Kt && Ut.has(e))
1627
- return Ut.get(e);
1628
- if (o) {
1629
- var s = (
1630
- /** @type {Derived} */
1631
- e
1632
- );
1633
- if (Kt) {
1634
- var l = s.v;
1635
- return ((s.f & N) === 0 && s.reactions !== null || Ci(s)) && (l = Qo(s)), Ut.set(s, l), l;
1636
- }
1637
- var a = (s.f & Y) === 0 && !ut && _ !== null && (ro || (_.f & Y) !== 0), c = (s.f & Se) === 0;
1638
- Fe(s) && (a && (s.f |= Y), ii(s)), a && !c && (ri(s), ki(s));
1639
- }
1640
- if (ft?.has(e))
1641
- return ft.get(e);
1642
- if ((e.f & Ft) !== 0)
1643
- throw e.v;
1644
- return e.v;
1645
- }
1646
- function ki(e) {
1647
- if (e.f |= Y, e.deps !== null)
1648
- for (const t of e.deps)
1649
- (t.reactions ?? (t.reactions = [])).push(e), (t.f & P) !== 0 && (t.f & Y) === 0 && (ri(
1650
- /** @type {Derived} */
1651
- t
1652
- ), ki(
1653
- /** @type {Derived} */
1654
- t
1655
- ));
1656
- }
1657
- function Ci(e) {
1658
- if (e.v === j) return !0;
1659
- if (e.deps === null) return !1;
1660
- for (const t of e.deps)
1661
- if (Ut.has(t) || (t.f & P) !== 0 && Ci(
1662
- /** @type {Derived} */
1663
- t
1664
- ))
1665
- return !0;
1666
- return !1;
1667
- }
1668
- function Ai(e) {
1669
- var t = ut;
1670
- try {
1671
- return ut = !0, e();
1672
- } finally {
1673
- ut = t;
1674
- }
1675
- }
1676
- const ge = /* @__PURE__ */ Symbol("events"), Li = /* @__PURE__ */ new Set(), Bo = /* @__PURE__ */ new Set();
1677
- function Ee(e, t, o) {
1678
- (t[ge] ?? (t[ge] = {}))[e] = o;
1679
- }
1680
- function ts(e) {
1681
- for (var t = 0; t < e.length; t++)
1682
- Li.add(e[t]);
1683
- for (var o of Bo)
1684
- o(e);
1685
- }
1686
- let In = null;
1687
- function xn(e) {
1688
- var t = this, o = (
1689
- /** @type {Node} */
1690
- t.ownerDocument
1691
- ), n = e.type, i = e.composedPath?.() || [], r = (
1692
- /** @type {null | Element} */
1693
- i[0] || e.target
1694
- );
1695
- In = e;
1696
- var s = 0, l = In === e && e[ge];
1697
- if (l) {
1698
- var a = i.indexOf(l);
1699
- if (a !== -1 && (t === document || t === /** @type {any} */
1700
- window)) {
1701
- e[ge] = t;
1702
- return;
1703
- }
1704
- var c = i.indexOf(t);
1705
- if (c === -1)
1706
- return;
1707
- a <= c && (s = a);
1708
- }
1709
- if (r = /** @type {Element} */
1710
- i[s] || e.target, r !== t) {
1711
- uo(e, "currentTarget", {
1712
- configurable: !0,
1713
- get() {
1714
- return r || o;
1715
- }
1716
- });
1717
- var f = _, p = S;
1718
- ot(null), Tt(null);
1719
- try {
1720
- for (var v, d = []; r !== null; ) {
1721
- var h = r.assignedSlot || r.parentNode || /** @type {any} */
1722
- r.host || null;
1723
- try {
1724
- var m = r[ge]?.[n];
1725
- m != null && (!/** @type {any} */
1726
- r.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
1727
- // -> the target could not have been disabled because it emits the event in the first place
1728
- e.target === r) && m.call(r, e);
1729
- } catch (y) {
1730
- v ? d.push(y) : v = y;
1731
- }
1732
- if (e.cancelBubble || h === t || h === null)
1733
- break;
1734
- r = h;
1735
- }
1736
- if (v) {
1737
- for (let y of d)
1738
- queueMicrotask(() => {
1739
- throw y;
1740
- });
1741
- throw v;
1742
- }
1743
- } finally {
1744
- e[ge] = t, delete e.currentTarget, ot(f), Tt(p);
1745
- }
1746
- }
1747
- }
1748
- const es = (
1749
- // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
1750
- globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
1751
- /** @param {string} html */
1752
- createHTML: (e) => e
1753
- })
1754
- );
1755
- function os(e) {
1756
- return (
1757
- /** @type {string} */
1758
- es?.createHTML(e) ?? e
1759
- );
1760
- }
1761
- function ns(e, t = !1) {
1762
- var o = tn("template");
1763
- return e = e.replaceAll("<!>", "<!---->"), o.innerHTML = t ? os(e) : e, o.content;
1764
- }
1765
- function so(e, t) {
1766
- var o = (
1767
- /** @type {Effect} */
1768
- S
1769
- );
1770
- o.nodes === null && (o.nodes = { start: e, end: t, a: null, t: null });
1771
- }
1772
- // @__NO_SIDE_EFFECTS__
1773
- function Zt(e, t) {
1774
- var o = (t & tr) !== 0, n = (t & er) !== 0, i, r = !e.startsWith("<!>");
1775
- return () => {
1776
- if (L)
1777
- return so(E, null), E;
1778
- i === void 0 && (i = ns(r ? e : "<!>" + e, !0), o || (i = /** @type {TemplateNode} */
1779
- /* @__PURE__ */ ue(i)));
1780
- var s = (
1781
- /** @type {TemplateNode} */
1782
- n || ci ? document.importNode(i, !0) : i.cloneNode(!0)
1783
- );
1784
- if (o) {
1785
- var l = (
1786
- /** @type {TemplateNode} */
1787
- /* @__PURE__ */ ue(s)
1788
- ), a = (
1789
- /** @type {TemplateNode} */
1790
- s.lastChild
1791
- );
1792
- so(l, a);
1793
- } else
1794
- so(s, s);
1795
- return s;
1796
- };
1797
- }
1798
- function Ct(e, t) {
1799
- if (L) {
1800
- var o = (
1801
- /** @type {Effect & { nodes: EffectNodes }} */
1802
- S
1803
- );
1804
- ((o.f & Se) === 0 || o.nodes.end === null) && (o.nodes.end = E), wo();
1805
- return;
1806
- }
1807
- e !== null && e.before(
1808
- /** @type {Node} */
1809
- t
1810
- );
1811
- }
1812
- const is = ["touchstart", "touchmove"];
1813
- function rs(e) {
1814
- return is.includes(e);
1815
- }
1816
- function _n(e, t) {
1817
- var o = t == null ? "" : typeof t == "object" ? t + "" : t;
1818
- o !== (e.__t ?? (e.__t = e.nodeValue)) && (e.__t = o, e.nodeValue = o + "");
1819
- }
1820
- function Ei(e, t) {
1821
- return Vi(e, t);
1822
- }
1823
- function ss(e, t) {
1824
- Ho(), t.intro = t.intro ?? !1;
1825
- const o = t.target, n = L, i = E;
1826
- try {
1827
- for (var r = /* @__PURE__ */ ue(o); r && (r.nodeType !== ke || /** @type {Comment} */
1828
- r.data !== Ko); )
1829
- r = /* @__PURE__ */ et(r);
1830
- if (!r)
1831
- throw ye;
1832
- at(!0), B(
1833
- /** @type {Comment} */
1834
- r
1835
- );
1836
- const s = Vi(e, { ...t, anchor: r });
1837
- return at(!1), /** @type {Exports} */
1838
- s;
1839
- } catch (s) {
1840
- if (s instanceof Error && s.message.split(`
1841
- `).some((l) => l.startsWith("https://svelte.dev/e/")))
1842
- throw s;
1843
- return s !== ye && console.warn("Failed to hydrate: ", s), t.recover === !1 && yr(), Ho(), hi(o), at(!1), Ei(e, t);
1844
- } finally {
1845
- at(n), B(i);
1846
- }
1847
- }
1848
- const Qe = /* @__PURE__ */ new Map();
1849
- function Vi(e, { target: t, anchor: o, props: n = {}, events: i, context: r, intro: s = !0 }) {
1850
- Ho();
1851
- var l = void 0, a = Kr(() => {
1852
- var c = o ?? t.appendChild(wt());
1853
- Or(
1854
- /** @type {TemplateNode} */
1855
- c,
1856
- {
1857
- pending: () => {
1858
- }
1859
- },
1860
- (v) => {
1861
- Bn({});
1862
- var d = (
1863
- /** @type {ComponentContext} */
1864
- tt
1865
- );
1866
- if (r && (d.c = r), i && (n.$$events = i), L && so(
1867
- /** @type {TemplateNode} */
1868
- v,
1869
- null
1870
- ), l = e(v, n) || {}, L && (S.nodes.end = E, E === null || E.nodeType !== ke || /** @type {Comment} */
1871
- E.data !== Jo))
1872
- throw yo(), ye;
1873
- zn();
1874
- }
1875
- );
1876
- var f = /* @__PURE__ */ new Set(), p = (v) => {
1877
- for (var d = 0; d < v.length; d++) {
1878
- var h = v[d];
1879
- if (!f.has(h)) {
1880
- f.add(h);
1881
- var m = rs(h);
1882
- for (const I of [t, document]) {
1883
- var y = Qe.get(I);
1884
- y === void 0 && (y = /* @__PURE__ */ new Map(), Qe.set(I, y));
1885
- var k = y.get(h);
1886
- k === void 0 ? (I.addEventListener(h, xn, { passive: m }), y.set(h, 1)) : y.set(h, k + 1);
1887
- }
1888
- }
1889
- }
1890
- };
1891
- return p(go(Li)), Bo.add(p), () => {
1892
- for (var v of f)
1893
- for (const m of [t, document]) {
1894
- var d = (
1895
- /** @type {Map<string, number>} */
1896
- Qe.get(m)
1897
- ), h = (
1898
- /** @type {number} */
1899
- d.get(v)
1900
- );
1901
- --h == 0 ? (m.removeEventListener(v, xn), d.delete(v), d.size === 0 && Qe.delete(m)) : d.set(v, h);
1902
- }
1903
- Bo.delete(p), c !== o && c.parentNode?.removeChild(c);
1904
- };
1905
- });
1906
- return zo.set(l, a), l;
1907
- }
1908
- let zo = /* @__PURE__ */ new WeakMap();
1909
- function ls(e, t) {
1910
- const o = zo.get(e);
1911
- return o ? (zo.delete(e), o(t)) : Promise.resolve();
1912
- }
1913
- var bt, Wt, mt, de, lo, Go, Mi;
1914
- class as {
1915
- /**
1916
- * @param {TemplateNode} anchor
1917
- * @param {boolean} transition
1918
- */
1919
- constructor(t, o = !0) {
1920
- $(this, "anchor"), x(this, bt, /* @__PURE__ */ new Map()), x(this, Wt, /* @__PURE__ */ new Map()), x(this, mt, /* @__PURE__ */ new Map()), x(this, de, /* @__PURE__ */ new Set()), x(this, lo, !0), x(this, Go, () => {
1921
- var n = (
1922
- /** @type {Batch} */
1923
- V
1924
- );
1925
- if (u(this, bt).has(n)) {
1926
- var i = (
1927
- /** @type {Key} */
1928
- u(this, bt).get(n)
1929
- ), r = u(this, Wt).get(i);
1930
- if (r)
1931
- sn(r), u(this, de).delete(i);
1932
- else {
1933
- var s = u(this, mt).get(i);
1934
- s && (u(this, Wt).set(i, s.effect), u(this, mt).delete(i), s.fragment.lastChild.remove(), this.anchor.before(s.fragment), r = s.effect);
1935
- }
1936
- for (const [l, a] of u(this, bt)) {
1937
- if (u(this, bt).delete(l), l === n)
1938
- break;
1939
- const c = u(this, mt).get(a);
1940
- c && (H(c.effect), u(this, mt).delete(a));
1941
- }
1942
- for (const [l, a] of u(this, Wt)) {
1943
- if (l === i || u(this, de).has(l)) continue;
1944
- const c = () => {
1945
- if (Array.from(u(this, bt).values()).includes(l)) {
1946
- var f = document.createDocumentFragment();
1947
- Ti(a, f), f.append(wt()), u(this, mt).set(l, { effect: a, fragment: f });
1948
- } else
1949
- H(a);
1950
- u(this, de).delete(l), u(this, Wt).delete(l);
1951
- };
1952
- u(this, lo) || !r ? (u(this, de).add(l), fe(a, c, !1)) : c();
1953
- }
1954
- }
1955
- }), x(this, Mi, (n) => {
1956
- u(this, bt).delete(n);
1957
- const i = Array.from(u(this, bt).values());
1958
- for (const [r, s] of u(this, mt))
1959
- i.includes(r) || (H(s.effect), u(this, mt).delete(r));
1960
- }), this.anchor = t, T(this, lo, o);
1961
- }
1962
- /**
1963
- *
1964
- * @param {any} key
1965
- * @param {null | ((target: TemplateNode) => void)} fn
1966
- */
1967
- ensure(t, o) {
1968
- var n = (
1969
- /** @type {Batch} */
1970
- V
1971
- ), i = di();
1972
- o && !u(this, Wt).has(t) && !u(this, mt).has(t) && u(this, Wt).set(
1973
- t,
1974
- yt(() => o(this.anchor))
1975
- ), u(this, bt).set(n, t), i || (L && (this.anchor = E), u(this, Go).call(this));
1976
- }
1977
- }
1978
- bt = /* @__PURE__ */ new WeakMap(), Wt = /* @__PURE__ */ new WeakMap(), mt = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), lo = /* @__PURE__ */ new WeakMap(), Go = /* @__PURE__ */ new WeakMap(), Mi = /* @__PURE__ */ new WeakMap();
1979
- function Ve(e, t, o = !1) {
1980
- L && wo();
1981
- var n = new as(e), i = o ? Te : 0;
1982
- function r(s, l) {
1983
- if (L) {
1984
- const f = Wn(e);
1985
- var a;
1986
- if (f === Ko ? a = 0 : f === vo ? a = !1 : a = parseInt(f.substring(1)), s !== a) {
1987
- var c = fo();
1988
- B(c), n.anchor = c, at(!1), n.ensure(s, l), at(!0);
1989
- return;
1990
- }
1991
- }
1992
- n.ensure(s, l);
1993
- }
1994
- Io(() => {
1995
- var s = !1;
1996
- t((l, a = 0) => {
1997
- s = !0, r(a, l);
1998
- }), s || r(!1, null);
1999
- }, i);
2000
- }
2001
- function cs(e, t) {
2002
- return t;
2003
- }
2004
- function us(e, t, o) {
2005
- for (var n = [], i = t.length, r, s = t.length, l = 0; l < i; l++) {
2006
- let p = t[l];
2007
- fe(
2008
- p,
2009
- () => {
2010
- if (r) {
2011
- if (r.pending.delete(p), r.done.add(p), r.pending.size === 0) {
2012
- var v = (
2013
- /** @type {Set<EachOutroGroup>} */
2014
- e.outrogroups
2015
- );
2016
- Fo(go(r.done)), v.delete(r), v.size === 0 && (e.outrogroups = null);
2017
- }
2018
- } else
2019
- s -= 1;
2020
- },
2021
- !1
2022
- );
2023
- }
2024
- if (s === 0) {
2025
- var a = n.length === 0 && o !== null;
2026
- if (a) {
2027
- var c = (
2028
- /** @type {Element} */
2029
- o
2030
- ), f = (
2031
- /** @type {Element} */
2032
- c.parentNode
2033
- );
2034
- hi(f), f.append(c), e.items.clear();
2035
- }
2036
- Fo(t, !a);
2037
- } else
2038
- r = {
2039
- pending: new Set(t),
2040
- done: /* @__PURE__ */ new Set()
2041
- }, (e.outrogroups ?? (e.outrogroups = /* @__PURE__ */ new Set())).add(r);
2042
- }
2043
- function Fo(e, t = !0) {
2044
- for (var o = 0; o < e.length; o++)
2045
- H(e[o], t);
2046
- }
2047
- var to;
2048
- function fs(e, t, o, n, i, r = null) {
2049
- var s = e, l = /* @__PURE__ */ new Map();
2050
- L && wo();
2051
- var a = null, c = /* @__PURE__ */ qr(() => {
2052
- var m = o();
2053
- return Nn(m) ? m : m == null ? [] : go(m);
2054
- }), f, p = !0;
2055
- function v() {
2056
- h.fallback = a, hs(h, f, s, t, n), a !== null && (f.length === 0 ? (a.f & Gt) === 0 ? sn(a) : (a.f ^= Gt, qe(a, null, s)) : fe(a, () => {
2057
- a = null;
2058
- }));
2059
- }
2060
- var d = Io(() => {
2061
- f = /** @type {V[]} */
2062
- b(c);
2063
- var m = f.length;
2064
- let y = !1;
2065
- if (L) {
2066
- var k = Wn(s) === vo;
2067
- k !== (m === 0) && (s = fo(), B(s), at(!1), y = !0);
2068
- }
2069
- for (var I = /* @__PURE__ */ new Set(), vt = (
2070
- /** @type {Batch} */
2071
- V
2072
- ), xt = di(), W = 0; W < m; W += 1) {
2073
- L && E.nodeType === ke && /** @type {Comment} */
2074
- E.data === Jo && (s = /** @type {Comment} */
2075
- E, y = !0, at(!1));
2076
- var _t = f[W], gt = n(_t, W), O = p ? null : l.get(gt);
2077
- O ? (O.v && xe(O.v, _t), O.i && xe(O.i, W), xt && vt.unskip_effect(O.e)) : (O = ds(
2078
- l,
2079
- p ? s : to ?? (to = wt()),
2080
- _t,
2081
- gt,
2082
- W,
2083
- i,
2084
- t,
2085
- o
2086
- ), p || (O.e.f |= Gt), l.set(gt, O)), I.add(gt);
2087
- }
2088
- if (m === 0 && r && !a && (p ? a = yt(() => r(s)) : (a = yt(() => r(to ?? (to = wt()))), a.f |= Gt)), m > I.size && pr(), L && m > 0 && B(fo()), !p)
2089
- if (xt) {
2090
- for (const [So, ko] of l)
2091
- I.has(So) || vt.skip_effect(ko.e);
2092
- vt.oncommit(v), vt.ondiscard(() => {
2093
- });
2094
- } else
2095
- v();
2096
- y && at(!0), b(c);
2097
- }), h = { effect: d, items: l, outrogroups: null, fallback: a };
2098
- p = !1, L && (s = E);
2099
- }
2100
- function Me(e) {
2101
- for (; e !== null && (e.f & dt) === 0; )
2102
- e = e.next;
2103
- return e;
2104
- }
2105
- function hs(e, t, o, n, i) {
2106
- var r = t.length, s = e.items, l = Me(e.effect.first), a, c = null, f = [], p = [], v, d, h, m;
2107
- for (m = 0; m < r; m += 1) {
2108
- if (v = t[m], d = i(v, m), h = /** @type {EachItem} */
2109
- s.get(d).e, e.outrogroups !== null)
2110
- for (const O of e.outrogroups)
2111
- O.pending.delete(h), O.done.delete(h);
2112
- if ((h.f & Gt) !== 0)
2113
- if (h.f ^= Gt, h === l)
2114
- qe(h, null, o);
2115
- else {
2116
- var y = c ? c.next : l;
2117
- h === e.effect.last && (e.effect.last = h.prev), h.prev && (h.prev.next = h.next), h.next && (h.next.prev = h.prev), Rt(e, c, h), Rt(e, h, y), qe(h, y, o), c = h, f = [], p = [], l = Me(c.next);
2118
- continue;
2119
- }
2120
- if ((h.f & J) !== 0 && sn(h), h !== l) {
2121
- if (a !== void 0 && a.has(h)) {
2122
- if (f.length < p.length) {
2123
- var k = p[0], I;
2124
- c = k.prev;
2125
- var vt = f[0], xt = f[f.length - 1];
2126
- for (I = 0; I < f.length; I += 1)
2127
- qe(f[I], k, o);
2128
- for (I = 0; I < p.length; I += 1)
2129
- a.delete(p[I]);
2130
- Rt(e, vt.prev, xt.next), Rt(e, c, vt), Rt(e, xt, k), l = k, c = xt, m -= 1, f = [], p = [];
2131
- } else
2132
- a.delete(h), qe(h, l, o), Rt(e, h.prev, h.next), Rt(e, h, c === null ? e.effect.first : c.next), Rt(e, c, h), c = h;
2133
- continue;
2134
- }
2135
- for (f = [], p = []; l !== null && l !== h; )
2136
- (a ?? (a = /* @__PURE__ */ new Set())).add(l), p.push(l), l = Me(l.next);
2137
- if (l === null)
2138
- continue;
2139
- }
2140
- (h.f & Gt) === 0 && f.push(h), c = h, l = Me(h.next);
2141
- }
2142
- if (e.outrogroups !== null) {
2143
- for (const O of e.outrogroups)
2144
- O.pending.size === 0 && (Fo(go(O.done)), e.outrogroups?.delete(O));
2145
- e.outrogroups.size === 0 && (e.outrogroups = null);
2146
- }
2147
- if (l !== null || a !== void 0) {
2148
- var W = [];
2149
- if (a !== void 0)
2150
- for (h of a)
2151
- (h.f & J) === 0 && W.push(h);
2152
- for (; l !== null; )
2153
- (l.f & J) === 0 && l !== e.fallback && W.push(l), l = Me(l.next);
2154
- var _t = W.length;
2155
- if (_t > 0) {
2156
- var gt = null;
2157
- us(e, W, gt);
2158
- }
2159
- }
2160
- }
2161
- function ds(e, t, o, n, i, r, s, l) {
2162
- var a = (s & Xi) !== 0 ? (s & Qi) === 0 ? /* @__PURE__ */ li(o, !1, !1) : ce(o) : null, c = (s & Yi) !== 0 ? ce(i) : null;
2163
- return {
2164
- v: a,
2165
- i: c,
2166
- e: yt(() => (r(t, a ?? o, c ?? i, l), () => {
2167
- e.delete(n);
2168
- }))
2169
- };
2170
- }
2171
- function qe(e, t, o) {
2172
- if (e.nodes)
2173
- for (var n = e.nodes.start, i = e.nodes.end, r = t && (t.f & Gt) === 0 ? (
2174
- /** @type {EffectNodes} */
2175
- t.nodes.start
2176
- ) : o; n !== null; ) {
2177
- var s = (
2178
- /** @type {TemplateNode} */
2179
- /* @__PURE__ */ et(n)
2180
- );
2181
- if (r.before(n), n === i)
2182
- return;
2183
- n = s;
2184
- }
2185
- }
2186
- function Rt(e, t, o) {
2187
- t === null ? e.effect.first = o : t.next = o, o === null ? e.effect.last = t : o.prev = t;
2188
- }
2189
- function ps(e, t) {
2190
- let o = null, n = L;
2191
- var i;
2192
- if (L) {
2193
- o = E;
2194
- for (var r = /* @__PURE__ */ ue(document.head); r !== null && (r.nodeType !== ke || /** @type {Comment} */
2195
- r.data !== e); )
2196
- r = /* @__PURE__ */ et(r);
2197
- if (r === null)
2198
- at(!1);
2199
- else {
2200
- var s = (
2201
- /** @type {TemplateNode} */
2202
- /* @__PURE__ */ et(r)
2203
- );
2204
- r.remove(), B(s);
2205
- }
2206
- }
2207
- L || (i = document.head.appendChild(wt()));
2208
- try {
2209
- Io(() => t(i), Zo);
2210
- } finally {
2211
- n && (at(!0), B(
2212
- /** @type {TemplateNode} */
2213
- o
2214
- ));
2215
- }
2216
- }
2217
- function vs(e, t) {
2218
- gi(() => {
2219
- var o = e.getRootNode(), n = (
2220
- /** @type {ShadowRoot} */
2221
- o.host ? (
2222
- /** @type {ShadowRoot} */
2223
- o
2224
- ) : (
2225
- /** @type {Document} */
2226
- o.head ?? /** @type {Document} */
2227
- o.ownerDocument.head
2228
- )
2229
- );
2230
- if (!n.querySelector("#" + t.hash)) {
2231
- const i = tn("style");
2232
- i.id = t.hash, i.textContent = t.code, n.appendChild(i);
2233
- }
2234
- });
2235
- }
2236
- function gs(e, t) {
2237
- return e == null ? null : String(e);
2238
- }
2239
- function Sn(e, t, o, n) {
2240
- var i = e.__style;
2241
- if (L || i !== t) {
2242
- var r = gs(t);
2243
- (!L || r !== e.getAttribute("style")) && (r == null ? e.removeAttribute("style") : e.style.cssText = r), e.__style = t;
2244
- }
2245
- return n;
2246
- }
2247
- const bs = /* @__PURE__ */ Symbol("is custom element"), ms = /* @__PURE__ */ Symbol("is html"), ys = hr ? "link" : "LINK";
2248
- function kn(e, t, o, n) {
2249
- var i = ws(e);
2250
- L && (i[t] = e.getAttribute(t), t === "src" || t === "srcset" || t === "href" && e.nodeName === ys) || i[t] !== (i[t] = o) && (t === "loading" && (e[fr] = o), o == null ? e.removeAttribute(t) : typeof o != "string" && Ts(e).includes(t) ? e[t] = o : e.setAttribute(t, o));
2251
- }
2252
- function ws(e) {
2253
- return (
2254
- /** @type {Record<string | symbol, unknown>} **/
2255
- // @ts-expect-error
2256
- e.__attributes ?? (e.__attributes = {
2257
- [bs]: e.nodeName.includes("-"),
2258
- [ms]: e.namespaceURI === Rn
2259
- })
2260
- );
2261
- }
2262
- var Cn = /* @__PURE__ */ new Map();
2263
- function Ts(e) {
2264
- var t = e.getAttribute("is") || e.nodeName, o = Cn.get(t);
2265
- if (o) return o;
2266
- Cn.set(t, o = []);
2267
- for (var n, i = e, r = Element.prototype; r !== i; ) {
2268
- n = ir(i);
2269
- for (var s in n)
2270
- n[s].set && o.push(s);
2271
- i = jn(i);
2272
- }
2273
- return o;
2274
- }
2275
- function An(e, t) {
2276
- return e === t || e?.[eo] === t;
2277
- }
2278
- function Ln(e = {}, t, o, n) {
2279
- return gi(() => {
2280
- var i, r;
2281
- return nn(() => {
2282
- i = r, r = [], Ai(() => {
2283
- e !== o(...r) && (t(e, ...r), i && An(o(...i), e) && t(null, ...i));
2284
- });
2285
- }), () => {
2286
- le(() => {
2287
- r && An(o(...r), e) && t(null, ...r);
2288
- });
2289
- };
2290
- }), e;
2291
- }
2292
- function Eo(e, t, o, n) {
2293
- var i = (
2294
- /** @type {V} */
2295
- n
2296
- ), r = !0, s = () => (r && (r = !1, i = /** @type {V} */
2297
- n), i), l;
2298
- l = /** @type {V} */
2299
- e[t], l === void 0 && n !== void 0 && (l = s());
2300
- var a;
2301
- a = () => {
2302
- var v = (
2303
- /** @type {V} */
2304
- e[t]
2305
- );
2306
- return v === void 0 ? s() : (r = !0, v);
2307
- };
2308
- var c = !1, f = /* @__PURE__ */ $o(() => (c = !1, a())), p = (
2309
- /** @type {Effect} */
2310
- S
2311
- );
2312
- return (
2313
- /** @type {() => V} */
2314
- (function(v, d) {
2315
- if (arguments.length > 0) {
2316
- const h = d ? b(f) : v;
2317
- return C(f, h), c = !0, i !== void 0 && (i = h), v;
2318
- }
2319
- return Kt && c || (p.f & Vt) !== 0 ? f.v : b(f);
2320
- })
2321
- );
2322
- }
2323
- function $s(e) {
2324
- return new Is(e);
2325
- }
2326
- var Dt, rt;
2327
- class Is {
2328
- /**
2329
- * @param {ComponentConstructorOptions & {
2330
- * component: any;
2331
- * }} options
2332
- */
2333
- constructor(t) {
2334
- x(this, Dt), x(this, rt);
2335
- var o = /* @__PURE__ */ new Map(), n = (r, s) => {
2336
- var l = /* @__PURE__ */ li(s, !1, !1);
2337
- return o.set(r, l), l;
2338
- };
2339
- const i = new Proxy(
2340
- { ...t.props || {}, $$events: {} },
2341
- {
2342
- get(r, s) {
2343
- return b(o.get(s) ?? n(s, Reflect.get(r, s)));
2344
- },
2345
- has(r, s) {
2346
- return s === ur ? !0 : (b(o.get(s) ?? n(s, Reflect.get(r, s))), Reflect.has(r, s));
2347
- },
2348
- set(r, s, l) {
2349
- return C(o.get(s) ?? n(s, l), l), Reflect.set(r, s, l);
2350
- }
2351
- }
2352
- );
2353
- T(this, rt, (t.hydrate ? ss : Ei)(t.component, {
2354
- target: t.target,
2355
- anchor: t.anchor,
2356
- props: i,
2357
- context: t.context,
2358
- intro: t.intro ?? !1,
2359
- recover: t.recover
2360
- })), (!t?.props?.$$host || t.sync === !1) && no(), T(this, Dt, i.$$events);
2361
- for (const r of Object.keys(u(this, rt)))
2362
- r === "$set" || r === "$destroy" || r === "$on" || uo(this, r, {
2363
- get() {
2364
- return u(this, rt)[r];
2365
- },
2366
- /** @param {any} value */
2367
- set(s) {
2368
- u(this, rt)[r] = s;
2369
- },
2370
- enumerable: !0
2371
- });
2372
- u(this, rt).$set = /** @param {Record<string, any>} next */
2373
- (r) => {
2374
- Object.assign(i, r);
2375
- }, u(this, rt).$destroy = () => {
2376
- ls(u(this, rt));
2377
- };
2378
- }
2379
- /** @param {Record<string, any>} props */
2380
- $set(t) {
2381
- u(this, rt).$set(t);
2382
- }
2383
- /**
2384
- * @param {string} event
2385
- * @param {(...args: any[]) => any} callback
2386
- * @returns {any}
2387
- */
2388
- $on(t, o) {
2389
- u(this, Dt)[t] = u(this, Dt)[t] || [];
2390
- const n = (...i) => o.call(this, ...i);
2391
- return u(this, Dt)[t].push(n), () => {
2392
- u(this, Dt)[t] = u(this, Dt)[t].filter(
2393
- /** @param {any} fn */
2394
- (i) => i !== n
2395
- );
2396
- };
2397
- }
2398
- $destroy() {
2399
- u(this, rt).$destroy();
2400
- }
2401
- }
2402
- Dt = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap();
2403
- let Oi;
2404
- typeof HTMLElement == "function" && (Oi = class extends HTMLElement {
2405
- /**
2406
- * @param {*} $$componentCtor
2407
- * @param {*} $$slots
2408
- * @param {ShadowRootInit | undefined} shadow_root_init
2409
- */
2410
- constructor(e, t, o) {
2411
- super(), $(this, "$$ctor"), $(this, "$$s"), $(this, "$$c"), $(this, "$$cn", !1), $(this, "$$d", {}), $(this, "$$r", !1), $(this, "$$p_d", {}), $(this, "$$l", {}), $(this, "$$l_u", /* @__PURE__ */ new Map()), $(this, "$$me"), $(this, "$$shadowRoot", null), this.$$ctor = e, this.$$s = t, o && (this.$$shadowRoot = this.attachShadow(o));
2412
- }
2413
- /**
2414
- * @param {string} type
2415
- * @param {EventListenerOrEventListenerObject} listener
2416
- * @param {boolean | AddEventListenerOptions} [options]
2417
- */
2418
- addEventListener(e, t, o) {
2419
- if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) {
2420
- const n = this.$$c.$on(e, t);
2421
- this.$$l_u.set(t, n);
2422
- }
2423
- super.addEventListener(e, t, o);
2424
- }
2425
- /**
2426
- * @param {string} type
2427
- * @param {EventListenerOrEventListenerObject} listener
2428
- * @param {boolean | AddEventListenerOptions} [options]
2429
- */
2430
- removeEventListener(e, t, o) {
2431
- if (super.removeEventListener(e, t, o), this.$$c) {
2432
- const n = this.$$l_u.get(t);
2433
- n && (n(), this.$$l_u.delete(t));
2434
- }
2435
- }
2436
- async connectedCallback() {
2437
- if (this.$$cn = !0, !this.$$c) {
2438
- let e = function(n) {
2439
- return (i) => {
2440
- const r = tn("slot");
2441
- n !== "default" && (r.name = n), Ct(i, r);
2442
- };
2443
- };
2444
- if (await Promise.resolve(), !this.$$cn || this.$$c)
2445
- return;
2446
- const t = {}, o = xs(this);
2447
- for (const n of this.$$s)
2448
- n in o && (n === "default" && !this.$$d.children ? (this.$$d.children = e(n), t.default = !0) : t[n] = e(n));
2449
- for (const n of this.attributes) {
2450
- const i = this.$$g_p(n.name);
2451
- i in this.$$d || (this.$$d[i] = ao(i, n.value, this.$$p_d, "toProp"));
2452
- }
2453
- for (const n in this.$$p_d)
2454
- !(n in this.$$d) && this[n] !== void 0 && (this.$$d[n] = this[n], delete this[n]);
2455
- this.$$c = $s({
2456
- component: this.$$ctor,
2457
- target: this.$$shadowRoot || this,
2458
- props: {
2459
- ...this.$$d,
2460
- $$slots: t,
2461
- $$host: this
2462
- }
2463
- }), this.$$me = Ur(() => {
2464
- nn(() => {
2465
- this.$$r = !0;
2466
- for (const n of co(this.$$c)) {
2467
- if (!this.$$p_d[n]?.reflect) continue;
2468
- this.$$d[n] = this.$$c[n];
2469
- const i = ao(
2470
- n,
2471
- this.$$d[n],
2472
- this.$$p_d,
2473
- "toAttribute"
2474
- );
2475
- i == null ? this.removeAttribute(this.$$p_d[n].attribute || n) : this.setAttribute(this.$$p_d[n].attribute || n, i);
2476
- }
2477
- this.$$r = !1;
2478
- });
2479
- });
2480
- for (const n in this.$$l)
2481
- for (const i of this.$$l[n]) {
2482
- const r = this.$$c.$on(n, i);
2483
- this.$$l_u.set(i, r);
2484
- }
2485
- this.$$l = {};
2486
- }
2487
- }
2488
- // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
2489
- // and setting attributes through setAttribute etc, this is helpful
2490
- /**
2491
- * @param {string} attr
2492
- * @param {string} _oldValue
2493
- * @param {string} newValue
2494
- */
2495
- attributeChangedCallback(e, t, o) {
2496
- this.$$r || (e = this.$$g_p(e), this.$$d[e] = ao(e, o, this.$$p_d, "toProp"), this.$$c?.$set({ [e]: this.$$d[e] }));
2497
- }
2498
- disconnectedCallback() {
2499
- this.$$cn = !1, Promise.resolve().then(() => {
2500
- !this.$$cn && this.$$c && (this.$$c.$destroy(), this.$$me(), this.$$c = void 0);
2501
- });
2502
- }
2503
- /**
2504
- * @param {string} attribute_name
2505
- */
2506
- $$g_p(e) {
2507
- return co(this.$$p_d).find(
2508
- (t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e
2509
- ) || e;
2510
- }
2511
- });
2512
- function ao(e, t, o, n) {
2513
- const i = o[e]?.type;
2514
- if (t = i === "Boolean" && typeof t != "boolean" ? t != null : t, !n || !o[e])
2515
- return t;
2516
- if (n === "toAttribute")
2517
- switch (i) {
2518
- case "Object":
2519
- case "Array":
2520
- return t == null ? null : JSON.stringify(t);
2521
- case "Boolean":
2522
- return t ? "" : null;
2523
- case "Number":
2524
- return t ?? null;
2525
- default:
2526
- return t;
2527
- }
2528
- else
2529
- switch (i) {
2530
- case "Object":
2531
- case "Array":
2532
- return t && JSON.parse(t);
2533
- case "Boolean":
2534
- return t;
2535
- // conversion already handled above
2536
- case "Number":
2537
- return t != null ? +t : t;
2538
- default:
2539
- return t;
2540
- }
2541
- }
2542
- function xs(e) {
2543
- const t = {};
2544
- return e.childNodes.forEach((o) => {
2545
- t[
2546
- /** @type {Element} node */
2547
- o.slot || "default"
2548
- ] = !0;
2549
- }), t;
2550
- }
2551
- function _s(e, t, o, n, i, r) {
2552
- let s = class extends Oi {
2553
- constructor() {
2554
- super(e, o, i), this.$$p_d = t;
2555
- }
2556
- static get observedAttributes() {
2557
- return co(t).map(
2558
- (l) => (t[l].attribute || l).toLowerCase()
2559
- );
2560
- }
2561
- };
2562
- return co(t).forEach((l) => {
2563
- uo(s.prototype, l, {
2564
- get() {
2565
- return this.$$c && l in this.$$c ? this.$$c[l] : this.$$d[l];
2566
- },
2567
- set(a) {
2568
- a = ao(l, a, t), this.$$d[l] = a;
2569
- var c = this.$$c;
2570
- if (c) {
2571
- var f = be(c, l)?.get;
2572
- f ? c[l] = a : c.$set({ [l]: a });
2573
- }
2574
- }
2575
- });
2576
- }), n.forEach((l) => {
2577
- uo(s.prototype, l, {
2578
- get() {
2579
- return this.$$c?.[l];
2580
- }
2581
- });
2582
- }), e.element = /** @type {any} */
2583
- s, s;
2584
- }
2585
- class Ss extends Event {
2586
- constructor(t, o, n, i) {
2587
- super("context-request", { bubbles: !0, composed: !0 }), $(this, "context"), $(this, "contextTarget"), $(this, "callback"), $(this, "subscribe"), this.context = t, this.contextTarget = o, this.callback = n, this.subscribe = i ?? !1;
2588
- }
2589
- }
2590
- class ks {
2591
- constructor(t, o) {
2592
- $(this, "host"), $(this, "context"), $(this, "subscribe"), $(this, "onValue"), $(this, "isConnected", !1), $(this, "unsubscribe"), $(this, "currentValue"), $(this, "handleValue", (n, i) => {
2593
- i !== this.unsubscribe && (this.unsubscribe?.(), this.unsubscribe = i), !this.subscribe && this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.currentValue = n, this.onValue?.(n);
2594
- }), this.host = t, this.context = o.context, this.subscribe = o.subscribe ?? !0, this.onValue = o.onValue;
2595
- }
2596
- connect() {
2597
- this.isConnected || (this.isConnected = !0, this.requestValue());
2598
- }
2599
- disconnect() {
2600
- this.isConnected && (this.isConnected = !1, this.unsubscribe?.(), this.unsubscribe = void 0);
2601
- }
2602
- get value() {
2603
- return this.currentValue;
2604
- }
2605
- requestValue() {
2606
- this.host.dispatchEvent(new Ss(this.context, this.host, this.handleValue, this.subscribe));
2607
- }
2608
- }
2609
- const Ri = (e) => e, Cs = Ri(/* @__PURE__ */ Symbol.for("pie.assessmentToolkit.shellContext")), As = Ri(/* @__PURE__ */ Symbol.for("pie.assessmentToolkit.regionScopeContext"));
2610
- function Ni(e, t, o) {
2611
- let n = !1;
2612
- const i = new ks(e, {
2613
- context: t,
2614
- subscribe: !0,
2615
- onValue: (c) => {
2616
- n = !0, o(c);
2617
- }
2618
- });
2619
- i.connect();
2620
- const r = (c) => {
2621
- c.context === t && i.requestValue();
2622
- };
2623
- e.addEventListener("context-provider", r);
2624
- let s = 0;
2625
- const l = 200, a = globalThis.setInterval(() => {
2626
- if (n || s >= l) {
2627
- globalThis.clearInterval(a);
2628
- return;
2629
- }
2630
- s += 1, i.requestValue();
2631
- }, 50);
2632
- return () => {
2633
- globalThis.clearInterval(a), e.removeEventListener("context-provider", r), i.disconnect();
2634
- };
2635
- }
2636
- function Ls(e, t) {
2637
- return Ni(e, Cs, t);
2638
- }
2639
- function Es(e, t) {
2640
- return Ni(e, As, t);
2641
- }
2642
- var En;
2643
- (function(e) {
2644
- e.TTS_WORD = "tts-word", e.TTS_SENTENCE = "tts-sentence", e.ANNOTATION = "annotation";
2645
- })(En || (En = {}));
2646
- var Bt;
2647
- (function(e) {
2648
- e.YELLOW = "yellow", e.GREEN = "green", e.BLUE = "blue", e.PINK = "pink", e.ORANGE = "orange", e.UNDERLINE = "underline";
2649
- })(Bt || (Bt = {}));
2650
- const Vs = {
2651
- tts: "textToSpeech",
2652
- colorScheme: "theme"
2653
- };
2654
- function Ms(e) {
2655
- const t = e.trim();
2656
- return t ? Vs[t] || t : "";
2657
- }
2658
- class Os {
2659
- constructor() {
2660
- $(this, "tools", /* @__PURE__ */ new Map()), $(this, "pnpIndex", /* @__PURE__ */ new Map()), $(this, "componentOverrides", {}), $(this, "moduleLoaders", /* @__PURE__ */ new Map()), $(this, "loadedToolModules", /* @__PURE__ */ new Set()), $(this, "moduleLoadPromises", /* @__PURE__ */ new Map());
2661
- }
2662
- /**
2663
- * Normalize a single tool alias to canonical toolId.
2664
- */
2665
- normalizeToolId(t) {
2666
- return Ms(t);
2667
- }
2668
- /**
2669
- * Normalize a list of tool aliases to canonical toolIds.
2670
- */
2671
- normalizeToolIds(t) {
2672
- return t.map((o) => this.normalizeToolId(o));
2673
- }
2674
- /**
2675
- * Register a tool
2676
- *
2677
- * @param registration - Tool registration
2678
- * @throws Error if toolId is already registered
2679
- */
2680
- register(t) {
2681
- if (this.tools.has(t.toolId))
2682
- throw new Error(`Tool '${t.toolId}' is already registered`);
2683
- if (this.tools.set(t.toolId, t), t.pnpSupportIds)
2684
- for (const o of t.pnpSupportIds)
2685
- this.pnpIndex.has(o) || this.pnpIndex.set(o, /* @__PURE__ */ new Set()), this.pnpIndex.get(o).add(t.toolId);
2686
- }
2687
- /**
2688
- * Override an existing tool registration
2689
- *
2690
- * @param registration - New tool registration (must have existing toolId)
2691
- */
2692
- override(t) {
2693
- if (!this.tools.has(t.toolId))
2694
- throw new Error(`Cannot override non-existent tool '${t.toolId}'`);
2695
- const o = this.tools.get(t.toolId);
2696
- if (o.pnpSupportIds)
2697
- for (const n of o.pnpSupportIds)
2698
- this.pnpIndex.get(n)?.delete(t.toolId);
2699
- if (this.tools.set(t.toolId, t), t.pnpSupportIds)
2700
- for (const n of t.pnpSupportIds)
2701
- this.pnpIndex.has(n) || this.pnpIndex.set(n, /* @__PURE__ */ new Set()), this.pnpIndex.get(n).add(t.toolId);
2702
- }
2703
- /**
2704
- * Unregister a tool
2705
- *
2706
- * @param toolId - Tool ID to remove
2707
- */
2708
- unregister(t) {
2709
- const o = this.tools.get(t);
2710
- if (o) {
2711
- if (o.pnpSupportIds)
2712
- for (const n of o.pnpSupportIds)
2713
- this.pnpIndex.get(n)?.delete(t);
2714
- this.tools.delete(t);
2715
- }
2716
- }
2717
- /**
2718
- * Get a tool registration by ID
2719
- *
2720
- * @param toolId - Tool ID
2721
- * @returns Tool registration or undefined
2722
- */
2723
- get(t) {
2724
- return this.tools.get(t);
2725
- }
2726
- /**
2727
- * Check if a tool is registered
2728
- *
2729
- * @param toolId - Tool ID
2730
- * @returns true if registered
2731
- */
2732
- has(t) {
2733
- return this.tools.has(t);
2734
- }
2735
- /**
2736
- * Get all registered tool IDs
2737
- *
2738
- * @returns Array of tool IDs
2739
- */
2740
- getAllToolIds() {
2741
- return Array.from(this.tools.keys());
2742
- }
2743
- /**
2744
- * Get all tool registrations
2745
- *
2746
- * @returns Array of tool registrations
2747
- */
2748
- getAllTools() {
2749
- return Array.from(this.tools.values());
2750
- }
2751
- /**
2752
- * Find tool IDs that support a given PNP support ID
2753
- *
2754
- * @param pnpSupportId - PNP support ID (e.g., 'calculator')
2755
- * @returns Set of tool IDs that support this PNP ID
2756
- */
2757
- getToolsByPNPSupport(t) {
2758
- return this.pnpIndex.get(t) || /* @__PURE__ */ new Set();
2759
- }
2760
- /**
2761
- * Get tools that support a specific level
2762
- *
2763
- * @param level - Tool level (assessment, section, item, passage, element)
2764
- * @returns Array of tool registrations that support this level
2765
- */
2766
- getToolsByLevel(t) {
2767
- return this.getAllTools().filter((o) => o.supportedLevels.includes(t));
2768
- }
2769
- /**
2770
- * Resolve tool activation with backward-compatible defaults.
2771
- */
2772
- getToolActivation(t) {
2773
- return this.get(t)?.activation || "toolbar-toggle";
2774
- }
2775
- /**
2776
- * Resolve singleton scope for a tool when present.
2777
- */
2778
- getToolSingletonScope(t) {
2779
- return this.get(t)?.singletonScope || null;
2780
- }
2781
- /**
2782
- * Filter tool IDs by activation type.
2783
- */
2784
- filterToolIdsByActivation(t, o) {
2785
- return t.filter((n) => this.getToolActivation(n) === o);
2786
- }
2787
- /**
2788
- * Filter tools by visibility in a given context
2789
- *
2790
- * Pass 2 of the two-pass model: Given a list of allowed tool IDs (from Pass 1),
2791
- * ask each tool if it's relevant in this context.
2792
- *
2793
- * @param allowedToolIds - Tool IDs that passed Pass 1 (orchestrator approval)
2794
- * @param context - Context to evaluate
2795
- * @returns Array of visible tool registrations
2796
- */
2797
- filterVisibleInContext(t, o) {
2798
- const n = [];
2799
- for (const i of t) {
2800
- const r = this.get(i);
2801
- if (!r) {
2802
- console.warn(`Tool '${i}' is allowed but not registered`);
2803
- continue;
2804
- }
2805
- if (r.supportedLevels.includes(o.level))
2806
- try {
2807
- r.isVisibleInContext(o) && n.push(r);
2808
- } catch (s) {
2809
- console.error(`Error evaluating visibility for tool '${i}':`, s);
2810
- }
2811
- }
2812
- return n;
2813
- }
2814
- /**
2815
- * Get tool metadata for building UIs
2816
- * Useful for building PNP configuration interfaces
2817
- *
2818
- * @returns Array of tool metadata (id, name, description, pnpSupportIds)
2819
- */
2820
- getToolMetadata() {
2821
- return this.getAllTools().map((t) => ({
2822
- toolId: t.toolId,
2823
- name: t.name,
2824
- description: t.description,
2825
- pnpSupportIds: t.pnpSupportIds || [],
2826
- supportedLevels: t.supportedLevels,
2827
- activation: t.activation || "toolbar-toggle",
2828
- singletonScope: t.singletonScope || null
2829
- }));
2830
- }
2831
- /**
2832
- * Generate PNP support IDs from enabled tools
2833
- * Useful for creating PNP profiles
2834
- *
2835
- * @param enabledToolIds - Tool IDs to enable
2836
- * @returns Array of unique PNP support IDs
2837
- */
2838
- generatePNPSupportsFromTools(t) {
2839
- const o = /* @__PURE__ */ new Set();
2840
- for (const n of t) {
2841
- const i = this.get(n);
2842
- if (i?.pnpSupportIds)
2843
- for (const r of i.pnpSupportIds)
2844
- o.add(r);
2845
- }
2846
- return Array.from(o);
2847
- }
2848
- /**
2849
- * Clear all registrations (useful for testing)
2850
- */
2851
- clear() {
2852
- this.tools.clear(), this.pnpIndex.clear();
2853
- }
2854
- /**
2855
- * Configure global component overrides used by tool instance creation.
2856
- */
2857
- setComponentOverrides(t) {
2858
- this.componentOverrides = t;
2859
- }
2860
- /**
2861
- * Register lazy module loaders by toolId.
2862
- * Toolbars call ensureToolModuleLoaded(toolId) before instance creation.
2863
- */
2864
- setToolModuleLoaders(t) {
2865
- for (const [o, n] of Object.entries(t))
2866
- n && this.moduleLoaders.set(o, n);
2867
- }
2868
- /**
2869
- * Ensure tool module side-effects are loaded exactly once.
2870
- * Safe to call repeatedly; concurrent callers share the same promise.
2871
- */
2872
- async ensureToolModuleLoaded(t) {
2873
- if (this.loadedToolModules.has(t))
2874
- return;
2875
- const o = this.moduleLoadPromises.get(t);
2876
- if (o) {
2877
- await o;
2878
- return;
2879
- }
2880
- const n = this.moduleLoaders.get(t);
2881
- if (!n)
2882
- return;
2883
- const i = (async () => {
2884
- await n(), this.loadedToolModules.add(t);
2885
- })();
2886
- this.moduleLoadPromises.set(t, i);
2887
- try {
2888
- await i;
2889
- } finally {
2890
- this.moduleLoadPromises.delete(t);
2891
- }
2892
- }
2893
- /**
2894
- * Ensure a set of tool modules are loaded.
2895
- */
2896
- async ensureToolModulesLoaded(t) {
2897
- await Promise.all(t.map((o) => this.ensureToolModuleLoaded(o)));
2898
- }
2899
- /**
2900
- * Whether a tool module has already been loaded.
2901
- */
2902
- isToolModuleLoaded(t) {
2903
- return this.loadedToolModules.has(t);
2904
- }
2905
- /**
2906
- * Render a tool for toolbar use with component overrides attached.
2907
- */
2908
- renderForToolbar(t, o, n) {
2909
- const i = this.get(t);
2910
- if (!i)
2911
- throw new Error(`Tool '${t}' is not registered`);
2912
- const r = {
2913
- ...n,
2914
- componentOverrides: {
2915
- ...this.componentOverrides || {},
2916
- ...n.componentOverrides || {}
2917
- }
2918
- };
2919
- return i.renderToolbar(o, r);
2920
- }
2921
- }
2922
- function ji(e) {
2923
- return e.level === "item";
2924
- }
2925
- function Rs(e) {
2926
- return e.level === "passage";
2927
- }
2928
- function Ns(e) {
2929
- return e.level === "rubric";
2930
- }
2931
- function Pi(e) {
2932
- return e.level === "element";
2933
- }
2934
- function ln(e) {
2935
- if (Pi(e)) {
2936
- const t = e.item.config;
2937
- if (!t)
2938
- return "";
2939
- const o = [], n = (l) => l.replace(/<[^>]*>/g, " ").trim(), i = t.elements?.[e.elementId];
2940
- i && typeof i == "string" && o.push(n(i));
2941
- const r = t.models, s = (Array.isArray(r) ? r : r && typeof r == "object" ? Object.values(r) : []).find((l) => l && typeof l == "object" && l.id === e.elementId);
2942
- if (s) {
2943
- for (const l of Object.values(s))
2944
- if (typeof l == "string" && o.push(n(l)), Array.isArray(l)) {
2945
- for (const a of l)
2946
- if (a && typeof a == "object")
2947
- for (const c of Object.values(a))
2948
- typeof c == "string" && o.push(n(c));
2949
- }
2950
- }
2951
- return o.filter(Boolean).join(" ").trim();
2952
- }
2953
- if (ji(e)) {
2954
- const t = e.item;
2955
- if (!t?.config)
2956
- return "";
2957
- const o = t.config, n = [], i = (a) => a.replace(/<[^>]*>/g, " ").trim();
2958
- typeof o.markup == "string" && n.push(i(o.markup));
2959
- const r = o.elements;
2960
- if (r && typeof r == "object")
2961
- for (const a of Object.values(r))
2962
- typeof a == "string" && n.push(i(a));
2963
- const s = o.models, l = Array.isArray(s) ? s : s && typeof s == "object" ? Object.values(s) : [];
2964
- for (const a of l)
2965
- if (!(!a || typeof a != "object")) {
2966
- for (const c of Object.values(a))
2967
- if (typeof c == "string" && n.push(i(c)), Array.isArray(c)) {
2968
- for (const f of c)
2969
- if (f && typeof f == "object")
2970
- for (const p of Object.values(f))
2971
- typeof p == "string" && n.push(i(p));
2972
- }
2973
- }
2974
- return n.filter(Boolean).join(" ").trim();
2975
- }
2976
- if (Rs(e)) {
2977
- const t = e.passage;
2978
- if (!t?.config)
2979
- return "";
2980
- const o = t.config, n = [], i = (a) => a.replace(/<[^>]*>/g, " ").trim();
2981
- typeof o.markup == "string" && n.push(i(o.markup)), typeof o.content == "string" && n.push(i(o.content)), typeof o.prompt == "string" && n.push(i(o.prompt));
2982
- const r = o.elements;
2983
- if (r && typeof r == "object")
2984
- for (const a of Object.values(r))
2985
- typeof a == "string" && n.push(i(a));
2986
- const s = o.models, l = Array.isArray(s) ? s : s && typeof s == "object" ? Object.values(s) : [];
2987
- for (const a of l)
2988
- if (!(!a || typeof a != "object")) {
2989
- for (const c of Object.values(a))
2990
- if (typeof c == "string" && n.push(i(c)), Array.isArray(c)) {
2991
- for (const f of c)
2992
- if (f && typeof f == "object")
2993
- for (const p of Object.values(f))
2994
- typeof p == "string" && n.push(i(p));
2995
- }
2996
- }
2997
- return n.filter(Boolean).join(" ").trim();
2998
- }
2999
- if (Ns(e)) {
3000
- const t = e.rubricBlock;
3001
- return t.passage?.config ? (t.passage.config.markup || "").replace(/<[^>]*>/g, " ").trim() : (t.content || "").replace(/<[^>]*>/g, " ").trim();
3002
- }
3003
- return "";
3004
- }
3005
- function xo(e) {
3006
- const t = ln(e);
3007
- return [
3008
- /<math[>\s]/i,
3009
- // MathML
3010
- /\\\[([^\]]+)\\\]/,
3011
- // LaTeX display math
3012
- /\$\$[^$]+\$\$/,
3013
- // LaTeX display math ($$...$$)
3014
- /\\\(/,
3015
- // LaTeX inline math
3016
- /[+\-*/=<>≤≥∑∫√π]/,
3017
- // Math symbols
3018
- /\d+\s*[+\-*/=]\s*\d+/
3019
- // Simple arithmetic
3020
- ].some((o) => o.test(t));
3021
- }
3022
- function js(e) {
3023
- const t = [
3024
- "pie-multiple-choice",
3025
- "pie-inline-choice",
3026
- "pie-select-text",
3027
- "multiple-choice",
3028
- "inline-choice",
3029
- "select-text"
3030
- ];
3031
- if (Pi(e)) {
3032
- const o = e.item.config;
3033
- if (!o?.models)
3034
- return !1;
3035
- const n = (Array.isArray(o.models) ? o.models : Object.values(o.models)).find((r) => r && typeof r == "object" && r.id === e.elementId);
3036
- if (!n)
3037
- return !1;
3038
- const i = n.element || "";
3039
- return t.includes(i);
3040
- }
3041
- if (ji(e)) {
3042
- const o = e.item.config?.models;
3043
- return (Array.isArray(o) ? o : o && typeof o == "object" ? Object.values(o) : []).some((n) => {
3044
- if (!n || typeof n != "object")
3045
- return !1;
3046
- const i = n.element || "";
3047
- return t.includes(i) ? !0 : Array.isArray(n.choices) && n.choices.length > 0;
3048
- });
3049
- }
3050
- return !1;
3051
- }
3052
- function _o(e) {
3053
- return ln(e).trim().length >= 10;
3054
- }
3055
- function Ps(e) {
3056
- const t = ln(e);
3057
- return [
3058
- /chemistry|chemical|element|atom|molecule|compound/i,
3059
- /periodic\s+table/i,
3060
- /H₂O|CO₂|NaCl|O₂|N₂/i,
3061
- // Chemical formulas
3062
- /\b[A-Z][a-z]?\d*\b/,
3063
- // Element symbols (H, He, Li, etc.)
3064
- /biology|organism|cell|DNA|RNA|protein/i,
3065
- /physics|force|energy|velocity|acceleration/i
3066
- ].some((o) => o.test(t));
3067
- }
3068
- const qs = [
3069
- "assessment",
3070
- "section",
3071
- "item",
3072
- "passage",
3073
- "rubric"
3074
- ], Ws = new Set(qs);
3075
- function Ds(e) {
3076
- return Ws.has(e);
3077
- }
3078
- function pt(e, t, o) {
3079
- const n = e.trim(), i = o.trim();
3080
- if (!n || !i)
3081
- throw new Error("Tool instance ids require non-empty tool and scope ids");
3082
- if (!Ds(t))
3083
- throw new Error(`Unknown tool scope level '${t}'. Register custom levels with registerToolScopeLevel().`);
3084
- return `${n}:${t}:${i}`;
3085
- }
3086
- const Hs = /* @__PURE__ */ new Set([
3087
- "annotation-xml",
3088
- "color-profile",
3089
- "font-face",
3090
- "font-face-src",
3091
- "font-face-uri",
3092
- "font-face-format",
3093
- "font-face-name",
3094
- "missing-glyph"
3095
- ]), Bs = /^[a-z][a-z0-9._-]*-[a-z0-9._-]*$/, zs = (e, t = "custom element tag") => {
3096
- if (!e || typeof e != "string")
3097
- throw new Error(`Invalid ${t}: expected a non-empty string`);
3098
- const o = e.trim();
3099
- if (!o)
3100
- throw new Error(`Invalid ${t}: tag is empty`);
3101
- if (o !== o.toLowerCase())
3102
- throw new Error(`Invalid ${t} "${o}": custom element names must be lowercase`);
3103
- if (!o.includes("-"))
3104
- throw new Error(`Invalid ${t} "${o}": custom element names must include a hyphen`);
3105
- if (Hs.has(o))
3106
- throw new Error(`Invalid ${t} "${o}": this name is reserved by the HTML spec`);
3107
- if (!Bs.test(o))
3108
- throw new Error(`Invalid ${t} "${o}": allowed characters are lowercase letters, numbers, ".", "_" and "-"`);
3109
- return o;
3110
- }, qi = {
3111
- calculator: "pie-tool-calculator",
3112
- textToSpeech: "pie-tool-text-to-speech",
3113
- ruler: "pie-tool-ruler",
3114
- protractor: "pie-tool-protractor",
3115
- answerEliminator: "pie-tool-answer-eliminator",
3116
- highlighter: "pie-tool-annotation-toolbar",
3117
- lineReader: "pie-tool-line-reader",
3118
- theme: "pie-tool-theme",
3119
- colorScheme: "pie-tool-theme",
3120
- annotationToolbar: "pie-tool-annotation-toolbar",
3121
- graph: "pie-tool-graph",
3122
- periodicTable: "pie-tool-periodic-table"
3123
- }, Gs = (e, t) => {
3124
- const o = t?.toolTagMap?.[e] ?? qi[e] ?? e;
3125
- return zs(o, `tool component tag for "${e}"`);
3126
- }, Fs = (e) => document.createElement(e), It = (e, t, o, n) => {
3127
- const i = Gs(e, n), r = n?.toolComponentFactories?.[e] ?? n?.toolComponentFactory;
3128
- return r ? r({ toolId: e, tagName: i, context: t, toolbarContext: o }) : Fs(i);
3129
- }, Us = {
3130
- toolId: "calculator",
3131
- name: "Calculator",
3132
- description: "Multi-type calculator (basic, scientific, graphing)",
3133
- icon: "calculator",
3134
- // Calculator is item-level in this player architecture.
3135
- supportedLevels: ["item"],
3136
- // PNP support IDs that enable this tool
3137
- // Maps to QTI 3.0 standard features: calculator, graphingCalculator
3138
- pnpSupportIds: [
3139
- "calculator",
3140
- // QTI 3.0 standard (cognitive.calculator)
3141
- "graphingCalculator",
3142
- // QTI 3.0 standard (assessment.graphingCalculator)
3143
- "basicCalculator",
3144
- // Common variant
3145
- "scientificCalculator"
3146
- // Common variant
3147
- ],
3148
- /**
3149
- * Pass 2: Determine if calculator is relevant in this context
3150
- *
3151
- * Calculator is relevant when context contains mathematical content
3152
- * (MathML, LaTeX, arithmetic markers).
3153
- */
3154
- isVisibleInContext(e) {
3155
- return xo(e);
3156
- },
3157
- renderToolbar(e, t) {
3158
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = t.componentOverrides, i = It(this.toolId, e, t, n);
3159
- i.setAttribute("tool-id", o);
3160
- const r = {
3161
- toolId: this.toolId,
3162
- label: this.name,
3163
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3164
- disabled: !1,
3165
- ariaLabel: "Open scientific calculator",
3166
- tooltip: "Calculator",
3167
- onClick: () => t.toggleTool(this.toolId),
3168
- active: t.isToolVisible(o)
3169
- };
3170
- return {
3171
- toolId: this.toolId,
3172
- elements: [{ element: i, mount: "after-buttons" }],
3173
- button: r,
3174
- sync: () => {
3175
- const s = t.isToolVisible(o);
3176
- r.active = s, r.ariaLabel = s ? "Close scientific calculator" : "Open scientific calculator", r.tooltip = s ? "Close calculator" : "Calculator", i.visible = s;
3177
- },
3178
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3179
- s(t.isToolVisible(o));
3180
- }) : () => {
3181
- }
3182
- };
3183
- }
3184
- }, Ks = {
3185
- toolId: "textToSpeech",
3186
- name: "Text to Speech",
3187
- description: "Read content aloud",
3188
- icon: "volume-up",
3189
- // TTS can appear at all levels except assessment and element.
3190
- supportedLevels: ["section", "item", "passage", "rubric"],
3191
- // PNP support IDs that enable this tool
3192
- // Maps to QTI 3.0 standard features: textToSpeech, readAloud
3193
- pnpSupportIds: [
3194
- "textToSpeech",
3195
- // QTI 3.0 standard (auditory.textToSpeech)
3196
- "readAloud",
3197
- // QTI 3.0 standard (auditory.readAloud)
3198
- "tts",
3199
- // Common abbreviation
3200
- "speechOutput"
3201
- // Common variant
3202
- ],
3203
- /**
3204
- * Pass 2: Determine if TTS is relevant in this context
3205
- *
3206
- * TTS is relevant when:
3207
- * - Context contains readable text (at least 10 characters)
3208
- */
3209
- isVisibleInContext(e) {
3210
- return _o(e);
3211
- },
3212
- renderToolbar(e, t) {
3213
- let o = null;
3214
- const n = t.ttsService, i = pt(this.toolId, t.scope.level, t.scope.scopeId), r = () => t.isToolVisible(i), s = {
3215
- toolId: this.toolId,
3216
- label: "Read aloud",
3217
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3218
- ariaLabel: "Read aloud",
3219
- tooltip: "Read aloud",
3220
- onClick: () => {
3221
- v();
3222
- },
3223
- disabled: !1,
3224
- active: !1
3225
- }, l = () => {
3226
- const d = r() ? "Stop reading" : "Read aloud";
3227
- s.label = d, s.ariaLabel = d, s.tooltip = d, s.active = r(), s.disabled = !t.ttsService;
3228
- }, a = (d) => {
3229
- (d === "idle" || d === "error") && r() && (t.toggleTool(this.toolId), l());
3230
- }, c = async () => {
3231
- t.ensureTTSReady && (o || (o = (async () => {
3232
- await t.ensureTTSReady?.(), t.toolkitCoordinator?.highlightCoordinator && n?.setHighlightCoordinator?.(t.toolkitCoordinator.highlightCoordinator);
3233
- })()), await o);
3234
- }, f = () => {
3235
- n?.stop?.(), r() && t.toggleTool(this.toolId), l();
3236
- }, p = () => {
3237
- const d = t.getScopeElement?.();
3238
- if (d)
3239
- return d;
3240
- const h = (k) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(k) : k.replace(/"/g, '\\"'), m = [
3241
- t.catalogId,
3242
- t.scope.itemId,
3243
- t.scope.canonicalItemId
3244
- ].filter((k) => typeof k == "string" && k.length > 0), y = [];
3245
- for (const k of m) {
3246
- const I = h(k);
3247
- t.scope.level === "passage" && y.push(`pie-passage-shell[item-id="${I}"] [data-region="content"]`), y.push(`pie-item-shell[item-id="${I}"] [data-region="content"]`);
3248
- }
3249
- y.push("[data-region='content']");
3250
- for (const k of y) {
3251
- const I = document.querySelector(k);
3252
- if (I instanceof HTMLElement)
3253
- return I;
3254
- }
3255
- return null;
3256
- }, v = async () => {
3257
- if (!n?.speak || !t.ttsService)
3258
- return;
3259
- if (r()) {
3260
- f();
3261
- return;
3262
- }
3263
- const d = p();
3264
- if (!d)
3265
- return;
3266
- const h = d.textContent || "";
3267
- if (h.trim())
3268
- try {
3269
- r() || t.toggleTool(this.toolId), l(), await c(), n.setRootElement?.(d), n.speak(h, {
3270
- // For passage-level TTS, use rendered DOM text as the source of truth.
3271
- // Catalog/SSML content can diverge from rendered text and break
3272
- // word-boundary-to-DOM mapping for progressive yellow highlighting.
3273
- catalogId: t.scope.level === "passage" ? void 0 : t.catalogId || t.itemId,
3274
- language: t.language,
3275
- contentElement: d
3276
- }).catch((m) => {
3277
- console.error("[ttsToolRegistration] Failed to start reading:", m), l();
3278
- }), l();
3279
- } catch (m) {
3280
- l(), console.error("[ttsToolRegistration] Failed to start reading:", m);
3281
- }
3282
- };
3283
- return {
3284
- toolId: this.toolId,
3285
- button: s,
3286
- sync: () => {
3287
- l(), t.ensureTTSReady && c().catch((d) => {
3288
- console.error("[ttsToolRegistration] Failed to initialize TTS service:", d);
3289
- });
3290
- },
3291
- subscribeActive: (d) => {
3292
- const h = [];
3293
- if (t.subscribeVisibility) {
3294
- const m = t.subscribeVisibility(() => {
3295
- const y = r();
3296
- l(), d(y);
3297
- });
3298
- h.push(m);
3299
- }
3300
- if (t.ttsService) {
3301
- const m = `tts-toolbar:${i}`, y = (k) => {
3302
- a(String(k || ""));
3303
- const I = r();
3304
- l(), d(I);
3305
- };
3306
- t.ttsService.onStateChange(m, y), h.push(() => {
3307
- t.ttsService?.offStateChange(m, y);
3308
- });
3309
- }
3310
- return h.length === 0 ? () => {
3311
- } : () => {
3312
- for (const m of h)
3313
- m();
3314
- };
3315
- }
3316
- };
3317
- }
3318
- }, Js = {
3319
- toolId: "ruler",
3320
- name: "Ruler",
3321
- description: "On-screen ruler for measurements",
3322
- icon: "ruler",
3323
- // Ruler typically appears at item/element level
3324
- supportedLevels: ["item", "element"],
3325
- // PNP support IDs
3326
- // Maps to QTI 3.0 standard feature: ruler
3327
- pnpSupportIds: [
3328
- "ruler",
3329
- // QTI 3.0 standard (assessment.ruler)
3330
- "measurement"
3331
- // Common variant
3332
- ],
3333
- /**
3334
- * Pass 2: Ruler is relevant when math content is present
3335
- */
3336
- isVisibleInContext(e) {
3337
- return xo(e);
3338
- },
3339
- renderToolbar(e, t) {
3340
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = {
3341
- toolId: this.toolId,
3342
- label: this.name,
3343
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3344
- disabled: !1,
3345
- ariaLabel: "Open ruler tool",
3346
- tooltip: "Ruler",
3347
- onClick: () => t.toggleTool(this.toolId),
3348
- active: t.isToolVisible(o)
3349
- }, i = t.componentOverrides ?? {}, r = It(this.toolId, e, t, i);
3350
- return r.setAttribute("tool-id", o), {
3351
- toolId: this.toolId,
3352
- button: n,
3353
- elements: [{ element: r, mount: "after-buttons" }],
3354
- sync: () => {
3355
- const s = t.isToolVisible(o);
3356
- n.active = s, r.visible = s, t.toolkitCoordinator && (r.toolkitCoordinator = t.toolkitCoordinator);
3357
- },
3358
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3359
- s(t.isToolVisible(o));
3360
- }) : () => {
3361
- }
3362
- };
3363
- }
3364
- }, Zs = {
3365
- toolId: "protractor",
3366
- name: "Protractor",
3367
- description: "On-screen protractor for angle measurements",
3368
- icon: "protractor",
3369
- // Protractor typically appears at item/element level
3370
- supportedLevels: ["item", "element"],
3371
- // PNP support IDs
3372
- // Maps to QTI 3.0 standard feature: protractor
3373
- pnpSupportIds: [
3374
- "protractor",
3375
- // QTI 3.0 standard (assessment.protractor)
3376
- "angleMeasurement"
3377
- // Common variant
3378
- ],
3379
- /**
3380
- * Pass 2: Protractor is relevant when math content is present
3381
- */
3382
- isVisibleInContext(e) {
3383
- return xo(e);
3384
- },
3385
- renderToolbar(e, t) {
3386
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = {
3387
- toolId: this.toolId,
3388
- label: this.name,
3389
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3390
- disabled: !1,
3391
- ariaLabel: "Open protractor tool",
3392
- tooltip: "Protractor",
3393
- onClick: () => t.toggleTool(this.toolId),
3394
- active: t.isToolVisible(o)
3395
- }, i = t.componentOverrides ?? {}, r = It(this.toolId, e, t, i);
3396
- return r.setAttribute("tool-id", o), {
3397
- toolId: this.toolId,
3398
- button: n,
3399
- elements: [{ element: r, mount: "after-buttons" }],
3400
- sync: () => {
3401
- const s = t.isToolVisible(o);
3402
- n.active = s, r.visible = s, t.toolkitCoordinator && (r.toolkitCoordinator = t.toolkitCoordinator);
3403
- },
3404
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3405
- s(t.isToolVisible(o));
3406
- }) : () => {
3407
- }
3408
- };
3409
- }
3410
- }, Xs = {
3411
- toolId: "answerEliminator",
3412
- name: "Answer Eliminator",
3413
- description: "Strike through answer choices",
3414
- icon: "strikethrough",
3415
- // Answer eliminator appears at item level only
3416
- supportedLevels: ["item"],
3417
- // PNP support IDs
3418
- // Maps to QTI 3.0 standard feature: answerMasking
3419
- pnpSupportIds: [
3420
- "answerMasking",
3421
- // QTI 3.0 standard (assessment.answerMasking)
3422
- "answerEliminator",
3423
- // QTI 3.0 standard (assessment.answerEliminator)
3424
- "strikethrough",
3425
- // Common variant
3426
- "choiceMasking"
3427
- // Common variant
3428
- ],
3429
- /**
3430
- * Pass 2: Answer eliminator is relevant only for choice-based questions
3431
- */
3432
- isVisibleInContext(e) {
3433
- return js(e);
3434
- },
3435
- renderToolbar(e, t) {
3436
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = t.componentOverrides ?? {}, i = It(this.toolId, e, t, n);
3437
- i.setAttribute("tool-id", o), i.setAttribute("strategy", "strikethrough"), i.setAttribute("button-alignment", "inline");
3438
- const r = {
3439
- toolId: this.toolId,
3440
- label: this.name,
3441
- icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="currentColor" aria-hidden="true"><path d="M19,3H16.3H7.7H5A2,2 0 0,0 3,5V7.7V16.4V19A2,2 0 0,0 5,21H7.7H16.4H19A2,2 0 0,0 21,19V16.3V7.7V5A2,2 0 0,0 19,3M15.6,17L12,13.4L8.4,17L7,15.6L10.6,12L7,8.4L8.4,7L12,10.6L15.6,7L17,8.4L13.4,12L17,15.6L15.6,17Z"/></svg>',
3442
- disabled: !1,
3443
- ariaLabel: "Answer eliminator - Strike through choices",
3444
- tooltip: "Strike Through",
3445
- onClick: () => t.toggleTool(this.toolId),
3446
- active: t.isToolVisible(o)
3447
- };
3448
- return {
3449
- toolId: this.toolId,
3450
- button: r,
3451
- elements: [{ element: i, mount: "after-buttons" }],
3452
- sync: () => {
3453
- const s = t.isToolVisible(o);
3454
- r.active = s, i.visible = s, t.toolCoordinator && (i.coordinator = t.toolCoordinator), i.scopeElement = t.getScopeElement?.() || null, t.elementToolStateStore && (i.elementToolStateStore = t.elementToolStateStore);
3455
- const l = t.getGlobalElementId?.();
3456
- l && (i.globalElementId = l);
3457
- },
3458
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3459
- s(t.isToolVisible(o));
3460
- }) : () => {
3461
- }
3462
- };
3463
- }
3464
- }, Ys = {
3465
- toolId: "highlighter",
3466
- name: "Highlighter",
3467
- description: "Highlight text",
3468
- icon: "highlighter",
3469
- activation: "toolbar-toggle",
3470
- // Highlighter appears at passage, rubric, item, and element levels
3471
- supportedLevels: ["passage", "rubric", "item", "element"],
3472
- // PNP support IDs
3473
- pnpSupportIds: ["highlighter", "textHighlight", "annotation"],
3474
- /**
3475
- * Pass 2: Highlighter is relevant when readable text is available
3476
- */
3477
- isVisibleInContext(e) {
3478
- return _o(e);
3479
- },
3480
- renderToolbar(e, t) {
3481
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = {
3482
- toolId: this.toolId,
3483
- label: this.name,
3484
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3485
- disabled: !1,
3486
- ariaLabel: "Highlighter - Highlight text",
3487
- tooltip: "Highlight",
3488
- onClick: () => t.toggleTool(this.toolId),
3489
- active: t.isToolVisible(o)
3490
- }, i = t.componentOverrides ?? {}, r = It(this.toolId, e, t, i);
3491
- return r.setAttribute("tool-id", o), {
3492
- toolId: this.toolId,
3493
- button: n,
3494
- elements: [{ element: r, mount: "after-buttons" }],
3495
- sync: () => {
3496
- const s = t.isToolVisible(o);
3497
- n.active = s, r.enabled = s, r.visible = s, t.ttsService && (r.ttsService = t.ttsService);
3498
- },
3499
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3500
- s(t.isToolVisible(o));
3501
- }) : () => {
3502
- }
3503
- };
3504
- }
3505
- }, Qs = {
3506
- toolId: "lineReader",
3507
- name: "Line Reader",
3508
- description: "Reading guide overlay",
3509
- icon: "bars-3",
3510
- // Line reader appears where there's text to read
3511
- supportedLevels: ["passage", "rubric", "item"],
3512
- // PNP support IDs
3513
- // Maps to QTI 3.0 standard features: readingMask, readingGuide, readingRuler
3514
- pnpSupportIds: [
3515
- "readingMask",
3516
- // QTI 3.0 standard (reading.readingMask)
3517
- "readingGuide",
3518
- // QTI 3.0 standard (reading.readingGuide)
3519
- "readingRuler",
3520
- // QTI 3.0 standard (reading.readingRuler)
3521
- "lineReader",
3522
- // Common variant
3523
- "trackingGuide"
3524
- // Common variant
3525
- ],
3526
- /**
3527
- * Pass 2: Line reader is relevant when readable text is present
3528
- */
3529
- isVisibleInContext(e) {
3530
- return _o(e);
3531
- },
3532
- renderToolbar(e, t) {
3533
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = {
3534
- toolId: this.toolId,
3535
- label: this.name,
3536
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3537
- disabled: !1,
3538
- ariaLabel: "Line reader - Reading guide",
3539
- tooltip: "Line Reader",
3540
- onClick: () => t.toggleTool(this.toolId),
3541
- active: t.isToolVisible(o)
3542
- }, i = t.componentOverrides ?? {}, r = It(this.toolId, e, t, i);
3543
- return r.setAttribute("tool-id", o), {
3544
- toolId: this.toolId,
3545
- button: n,
3546
- elements: [{ element: r, mount: "after-buttons" }],
3547
- sync: () => {
3548
- const s = t.isToolVisible(o);
3549
- n.active = s, r.visible = s, t.toolkitCoordinator && (r.toolkitCoordinator = t.toolkitCoordinator);
3550
- },
3551
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3552
- s(t.isToolVisible(o));
3553
- }) : () => {
3554
- }
3555
- };
3556
- }
3557
- }, tl = {
3558
- toolId: "theme",
3559
- name: "Theme",
3560
- description: "Accessible themes and contrast",
3561
- icon: "swatch",
3562
- // Color scheme is assessment-wide
3563
- supportedLevels: ["assessment", "section"],
3564
- // PNP support IDs
3565
- // Maps to QTI 3.0 standard features: highContrastDisplay, colorContrast, invertColors
3566
- pnpSupportIds: [
3567
- "highContrastDisplay",
3568
- // QTI 3.0 standard (visual.highContrastDisplay)
3569
- "colorContrast",
3570
- // QTI 3.0 standard (visual.colorContrast)
3571
- "invertColors",
3572
- // QTI 3.0 standard (visual.invertColors)
3573
- "colorScheme",
3574
- // Legacy alias
3575
- "theme",
3576
- // Canonical id
3577
- "highContrast",
3578
- // Common variant
3579
- "customColors"
3580
- // Common variant
3581
- ],
3582
- /**
3583
- * Pass 2: Color scheme is always relevant when allowed
3584
- */
3585
- isVisibleInContext(e) {
3586
- return !0;
3587
- },
3588
- renderToolbar(e, t) {
3589
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = {
3590
- toolId: this.toolId,
3591
- label: this.name,
3592
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3593
- disabled: !1,
3594
- ariaLabel: "Theme - Change colors and contrast",
3595
- tooltip: "Theme",
3596
- onClick: () => t.toggleTool(this.toolId),
3597
- active: t.isToolVisible(o)
3598
- }, i = t.componentOverrides ?? {}, r = It(this.toolId, e, t, i);
3599
- return r.setAttribute("tool-id", o), {
3600
- toolId: this.toolId,
3601
- button: n,
3602
- elements: [{ element: r, mount: "after-buttons" }],
3603
- sync: () => {
3604
- const s = t.isToolVisible(o);
3605
- n.active = s, r.visible = s, t.toolkitCoordinator && (r.toolkitCoordinator = t.toolkitCoordinator);
3606
- },
3607
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3608
- s(t.isToolVisible(o));
3609
- }) : () => {
3610
- }
3611
- };
3612
- }
3613
- }, el = tl, ol = {
3614
- toolId: "annotationToolbar",
3615
- name: "Highlighter",
3616
- description: "Highlight and annotate text",
3617
- icon: "highlighter",
3618
- activation: "selection-gateway",
3619
- singletonScope: "section",
3620
- // Annotation appears where there's text content
3621
- supportedLevels: ["passage", "rubric", "item", "element"],
3622
- // PNP support IDs
3623
- // Maps to QTI 3.0 standard features: highlighting, annotations
3624
- pnpSupportIds: [
3625
- "highlighting",
3626
- // QTI 3.0 standard (cognitive.highlighting / reading.wordHighlighting)
3627
- "annotations",
3628
- // QTI 3.0 standard (cognitive.annotations)
3629
- "highlighter",
3630
- // Common variant
3631
- "textHighlight",
3632
- // Common variant
3633
- "annotation"
3634
- // Common variant
3635
- ],
3636
- /**
3637
- * Pass 2: Annotation is relevant when readable text is present
3638
- */
3639
- isVisibleInContext(e) {
3640
- return _o(e);
3641
- },
3642
- renderToolbar(e, t) {
3643
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = {
3644
- toolId: this.toolId,
3645
- label: this.name,
3646
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3647
- disabled: !1,
3648
- ariaLabel: "Annotation toolbar - Highlight text",
3649
- tooltip: "Highlight",
3650
- onClick: () => t.toggleTool(this.toolId),
3651
- active: t.isToolVisible(o)
3652
- }, i = t.componentOverrides ?? {}, r = It(this.toolId, e, t, i);
3653
- return r.setAttribute("tool-id", o), {
3654
- toolId: this.toolId,
3655
- button: n,
3656
- elements: [{ element: r, mount: "after-buttons" }],
3657
- sync: () => {
3658
- const s = t.isToolVisible(o);
3659
- n.active = s, r.visible = s, t.toolkitCoordinator && (r.toolkitCoordinator = t.toolkitCoordinator);
3660
- },
3661
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3662
- s(t.isToolVisible(o));
3663
- }) : () => {
3664
- }
3665
- };
3666
- }
3667
- }, nl = {
3668
- toolId: "graph",
3669
- name: "Graph",
3670
- description: "Graphing calculator and coordinate plane",
3671
- icon: "chart-bar",
3672
- // Graph appears at item and element level where graphing might be needed
3673
- supportedLevels: ["item", "element"],
3674
- // PNP support IDs
3675
- // Maps to QTI 3.0 standard features: graph, graphingCalculator
3676
- pnpSupportIds: [
3677
- "graph",
3678
- // QTI 3.0 standard (assessment.graph)
3679
- "graphingCalculator",
3680
- // QTI 3.0 standard (assessment.graphingCalculator)
3681
- "coordinatePlane",
3682
- // Common variant
3683
- "graphingTool"
3684
- // Common variant
3685
- ],
3686
- /**
3687
- * Pass 2: Graph is relevant when math content is present
3688
- */
3689
- isVisibleInContext(e) {
3690
- return xo(e);
3691
- },
3692
- renderToolbar(e, t) {
3693
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = {
3694
- toolId: this.toolId,
3695
- label: this.name,
3696
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3697
- disabled: !1,
3698
- ariaLabel: "Graph - Graphing calculator",
3699
- tooltip: "Graph",
3700
- onClick: () => t.toggleTool(this.toolId),
3701
- active: t.isToolVisible(o)
3702
- }, i = t.componentOverrides ?? {}, r = It(this.toolId, e, t, i);
3703
- return r.setAttribute("tool-id", o), {
3704
- toolId: this.toolId,
3705
- button: n,
3706
- elements: [{ element: r, mount: "after-buttons" }],
3707
- sync: () => {
3708
- const s = t.isToolVisible(o);
3709
- n.active = s, r.visible = s, t.toolkitCoordinator && (r.toolkitCoordinator = t.toolkitCoordinator);
3710
- },
3711
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3712
- s(t.isToolVisible(o));
3713
- }) : () => {
3714
- }
3715
- };
3716
- }
3717
- }, il = {
3718
- toolId: "periodicTable",
3719
- name: "Periodic Table",
3720
- description: "Chemistry periodic table reference",
3721
- icon: "beaker",
3722
- // Periodic table appears at item and element level
3723
- supportedLevels: ["item", "element"],
3724
- // PNP support IDs
3725
- // Maps to QTI 3.0 standard feature: periodicTable
3726
- pnpSupportIds: [
3727
- "periodicTable",
3728
- // QTI 3.0 standard (assessment.periodicTable)
3729
- "chemistryReference",
3730
- // Common variant
3731
- "elementReference"
3732
- // Common variant
3733
- ],
3734
- /**
3735
- * Pass 2: Periodic table is relevant when science content is present
3736
- */
3737
- isVisibleInContext(e) {
3738
- return Ps(e);
3739
- },
3740
- renderToolbar(e, t) {
3741
- const o = pt(this.toolId, t.scope.level, t.scope.scopeId), n = {
3742
- toolId: this.toolId,
3743
- label: this.name,
3744
- icon: typeof this.icon == "function" ? this.icon(e) : this.icon,
3745
- disabled: !1,
3746
- ariaLabel: "Periodic table - Chemistry reference",
3747
- tooltip: "Periodic Table",
3748
- onClick: () => t.toggleTool(this.toolId),
3749
- active: t.isToolVisible(o)
3750
- }, i = t.componentOverrides ?? {}, r = It(this.toolId, e, t, i);
3751
- return r.setAttribute("tool-id", o), {
3752
- toolId: this.toolId,
3753
- button: n,
3754
- elements: [{ element: r, mount: "after-buttons" }],
3755
- sync: () => {
3756
- const s = t.isToolVisible(o);
3757
- n.active = s, r.visible = s, t.toolkitCoordinator && (r.toolkitCoordinator = t.toolkitCoordinator);
3758
- },
3759
- subscribeActive: (s) => t.subscribeVisibility ? t.subscribeVisibility(() => {
3760
- s(t.isToolVisible(o));
3761
- }) : () => {
3762
- }
3763
- };
3764
- }
3765
- }, rl = [
3766
- Us,
3767
- Ks,
3768
- Js,
3769
- Zs,
3770
- Xs,
3771
- Ys,
3772
- Qs,
3773
- el,
3774
- ol,
3775
- nl,
3776
- il
3777
- ];
3778
- function sl(e = {}) {
3779
- const t = new Os(), o = {
3780
- toolTagMap: {
3781
- ...qi,
3782
- ...e.toolTagMap || {}
3783
- },
3784
- toolComponentFactory: e.toolComponentFactory,
3785
- toolComponentFactories: e.toolComponentFactories
3786
- }, n = (i) => e.overrides?.[i.toolId] || i;
3787
- return e.includePackagedTools && ll(t, {
3788
- toolIds: e.toolIds,
3789
- applyOverrides: n
3790
- }), e.toolModuleLoaders && Object.keys(e.toolModuleLoaders).length > 0 && t.setToolModuleLoaders(e.toolModuleLoaders), t.setComponentOverrides(o), t;
3791
- }
3792
- function ll(e, t = {}) {
3793
- const o = t.toolIds && t.toolIds.length > 0 ? new Set(t.toolIds) : null, n = t.applyOverrides || ((i) => i);
3794
- for (const i of rl)
3795
- o && !o.has(i.toolId) || e.register(n(i));
3796
- }
3797
- function al() {
3798
- const e = sl(), t = /* @__PURE__ */ new Set();
3799
- for (const o of e.getAllTools())
3800
- for (const n of o.pnpSupportIds || [])
3801
- t.add(n);
3802
- return [...t].sort();
3803
- }
3804
- al();
3805
- const cl = {
3806
- /**
3807
- * Visual accessibility features
3808
- * For students with low vision, color blindness, or visual processing needs
3809
- */
3810
- visual: {
3811
- // Magnification and zoom
3812
- magnification: "magnification",
3813
- screenMagnifier: "screenMagnifier",
3814
- zoomable: "zoomable",
3815
- // Color and contrast
3816
- highContrastDisplay: "highContrastDisplay",
3817
- highContrastAudio: "highContrastAudio",
3818
- colorContrast: "colorContrast",
3819
- invertColors: "invertColors",
3820
- // Display customization
3821
- displayTransformability: "displayTransformability",
3822
- largePrint: "largePrint",
3823
- fontEnlargement: "fontEnlargement",
3824
- resizeText: "resizeText",
3825
- // Visual alternatives
3826
- alternativeText: "alternativeText",
3827
- longDescription: "longDescription",
3828
- describedMath: "describedMath",
3829
- tactileGraphic: "tactileGraphic",
3830
- tactileObject: "tactileObject"
3831
- },
3832
- /**
3833
- * Auditory accessibility features
3834
- * For students who are deaf, hard of hearing, or benefit from audio
3835
- */
3836
- auditory: {
3837
- // Audio output
3838
- audioDescription: "audioDescription",
3839
- textToSpeech: "textToSpeech",
3840
- readAloud: "readAloud",
3841
- humanVoice: "humanVoice",
3842
- syntheticVoice: "syntheticVoice",
3843
- // Speech control
3844
- speechRate: "speechRate",
3845
- speechVolume: "speechVolume",
3846
- voicePitch: "voicePitch",
3847
- // Visual alternatives for audio
3848
- captions: "captions",
3849
- closedCaptions: "closedCaptions",
3850
- openCaptions: "openCaptions",
3851
- transcript: "transcript",
3852
- signLanguage: "signLanguage",
3853
- subtitles: "subtitles",
3854
- // Audio adjustments
3855
- audioControl: "audioControl",
3856
- noBackgroundAudio: "noBackgroundAudio"
3857
- },
3858
- /**
3859
- * Motor/physical accessibility features
3860
- * For students with limited mobility or motor control
3861
- */
3862
- motor: {
3863
- // Input alternatives
3864
- keyboardControl: "keyboardControl",
3865
- mouseControl: "mouseControl",
3866
- touchControl: "touchControl",
3867
- voiceControl: "voiceControl",
3868
- switchControl: "switchControl",
3869
- eyeGazeControl: "eyeGazeControl",
3870
- // Keyboard features
3871
- singleSwitchAccess: "singleSwitchAccess",
3872
- stickyKeys: "stickyKeys",
3873
- keyboardShortcuts: "keyboardShortcuts",
3874
- // Timing
3875
- timingControl: "timingControl",
3876
- unlimitedTime: "unlimitedTime",
3877
- extendedTime: "extendedTime",
3878
- pauseControl: "pauseControl"
3879
- },
3880
- /**
3881
- * Cognitive/learning accessibility features
3882
- * For students with learning disabilities, ADHD, autism, etc.
3883
- */
3884
- cognitive: {
3885
- // Content simplification
3886
- simplifiedLanguage: "simplifiedLanguage",
3887
- reducedComplexity: "reducedComplexity",
3888
- structuralNavigation: "structuralNavigation",
3889
- tableOfContents: "tableOfContents",
3890
- // Focus and attention
3891
- reducedDistraction: "reducedDistraction",
3892
- noFlashing: "noFlashing",
3893
- pauseAnimation: "pauseAnimation",
3894
- // Organization and support
3895
- annotations: "annotations",
3896
- bookmarking: "bookmarking",
3897
- highlighting: "highlighting",
3898
- guidedNavigation: "guidedNavigation",
3899
- // Tools
3900
- calculator: "calculator",
3901
- thesaurus: "thesaurus",
3902
- spellingAssistance: "spellingAssistance",
3903
- grammarAssistance: "grammarAssistance"
3904
- },
3905
- /**
3906
- * Reading support features
3907
- * For students with dyslexia or reading challenges
3908
- */
3909
- reading: {
3910
- // Text presentation
3911
- lineSpacing: "lineSpacing",
3912
- wordSpacing: "wordSpacing",
3913
- letterSpacing: "letterSpacing",
3914
- fontFamily: "fontFamily",
3915
- readingMask: "readingMask",
3916
- readingGuide: "readingGuide",
3917
- readingRuler: "readingRuler",
3918
- // Highlighting and emphasis
3919
- wordHighlighting: "wordHighlighting",
3920
- lineHighlighting: "lineHighlighting",
3921
- focusIndicator: "focusIndicator",
3922
- // Content support
3923
- printableResource: "printableResource",
3924
- braille: "braille",
3925
- nemeth: "nemeth",
3926
- refreshableBraille: "refreshableBraille"
3927
- },
3928
- /**
3929
- * Navigation features
3930
- * For efficient content navigation
3931
- */
3932
- navigation: {
3933
- // Structure
3934
- index: "index",
3935
- pageNavigation: "pageNavigation",
3936
- skipContent: "skipContent",
3937
- breadcrumbs: "breadcrumbs",
3938
- // Search
3939
- searchable: "searchable",
3940
- fullTextSearch: "fullTextSearch"
3941
- },
3942
- /**
3943
- * Linguistic features
3944
- * For language support
3945
- */
3946
- linguistic: {
3947
- // Languages
3948
- multilingualText: "multilingualText",
3949
- translatedText: "translatedText",
3950
- glossary: "glossary",
3951
- // Sign language
3952
- signLanguageInterpretation: "signLanguageInterpretation",
3953
- visualLanguage: "visualLanguage"
3954
- },
3955
- /**
3956
- * Assessment-specific features
3957
- * Features specific to test-taking environments
3958
- */
3959
- assessment: {
3960
- // Tools
3961
- protractor: "protractor",
3962
- ruler: "ruler",
3963
- graph: "graph",
3964
- graphingCalculator: "graphingCalculator",
3965
- periodicTable: "periodicTable",
3966
- formulaSheet: "formulaSheet",
3967
- // Answer support
3968
- answerMasking: "answerMasking",
3969
- answerEliminator: "answerEliminator",
3970
- strikethrough: "strikethrough",
3971
- // Item features
3972
- itemGlossary: "itemGlossary",
3973
- tutorialAvailable: "tutorialAvailable"
3974
- }
3975
- };
3976
- Object.values(cl).flatMap((e) => Object.values(e));
3977
- var Vn;
3978
- (function(e) {
3979
- e[e.BASE = 0] = "BASE", e[e.TOOL = 1e3] = "TOOL", e[e.MODAL = 2e3] = "MODAL", e[e.CONTROL = 3e3] = "CONTROL", e[e.HIGHLIGHT = 4e3] = "HIGHLIGHT";
3980
- })(Vn || (Vn = {}));
3981
- var Mn;
3982
- (function(e) {
3983
- e.IDLE = "idle", e.LOADING = "loading", e.PLAYING = "playing", e.PAUSED = "paused", e.ERROR = "error";
3984
- })(Mn || (Mn = {}));
3985
- var ul = /* @__PURE__ */ Zt('<link rel="stylesheet" href="./highlights.css"/>'), fl = /* @__PURE__ */ Zt('<button class="pie-tool-annotation-toolbar__highlight-swatch svelte-g8qu62"><span class="pie-sr-only svelte-g8qu62"> </span></button>'), hl = /* @__PURE__ */ Zt('<div class="divider divider-horizontal mx-0 w-px svelte-g8qu62"></div> <button class="pie-tool-annotation-toolbar__button pie-tool-annotation-toolbar__button--icon svelte-g8qu62" aria-label="Read selected text aloud" title="Read Aloud"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" class="svelte-g8qu62"><path d="M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z"></path></svg></button>', 1), dl = /* @__PURE__ */ Zt('<button class="pie-tool-annotation-toolbar__button pie-tool-annotation-toolbar__button--warning svelte-g8qu62" aria-label="Remove this annotation" title="Remove"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" class="svelte-g8qu62"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path></svg></button>'), pl = /* @__PURE__ */ Zt('<button class="pie-tool-annotation-toolbar__button pie-tool-annotation-toolbar__button--danger svelte-g8qu62" aria-label="Clear all annotations from document" title="Clear All">Clear All</button>'), vl = /* @__PURE__ */ Zt('<div class="divider divider-horizontal mx-0 w-px svelte-g8qu62"></div> <!> <!>', 1), gl = /* @__PURE__ */ Zt('<div class="pie-tool-annotation-toolbar notranslate svelte-g8qu62" role="toolbar" aria-label="Text annotation toolbar" translate="no"><!> <button class="pie-tool-annotation-toolbar__button pie-tool-annotation-toolbar__button--icon svelte-g8qu62" aria-label="Underline selected text" title="Underline"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" class="svelte-g8qu62"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z"></path></svg></button> <!> <!></div>'), bl = /* @__PURE__ */ Zt('<div style="display: none;" aria-hidden="true"></div> <!> <div role="status" aria-live="polite" aria-atomic="true" class="pie-sr-only svelte-g8qu62"> </div>', 1);
3986
- const ml = {
3987
- hash: "svelte-g8qu62",
3988
- code: `.pie-tool-annotation-toolbar.svelte-g8qu62 {position:fixed;z-index:4200;display:flex;gap:0.25rem;padding:0.5rem;border-radius:0.5rem;background:var(--pie-background, #fff);color:var(--pie-text, #111827);border:1px solid var(--pie-border, #d1d5db);box-shadow:0 10px 25px -8px rgb(0 0 0 / 0.3);user-select:none;}.pie-tool-annotation-toolbar__highlight-swatch.svelte-g8qu62 {width:2.5rem;height:2rem;border:2px solid color-mix(in srgb, var(--pie-border-dark, #111827) 20%, transparent);border-radius:0.375rem;cursor:pointer;transition:all 0.15s ease;display:flex;align-items:center;justify-content:center;padding:0;}.pie-tool-annotation-toolbar__highlight-swatch.svelte-g8qu62:hover {transform:scale(1.1);border-color:color-mix(in srgb, var(--pie-border-dark, #111827) 45%, transparent);box-shadow:0 2px 8px rgb(0 0 0 / 0.15);}.pie-tool-annotation-toolbar__highlight-swatch.svelte-g8qu62:focus-visible {outline:2px solid var(--pie-button-focus-outline, var(--pie-primary, #3f51b5));outline-offset:2px;}.pie-tool-annotation-toolbar.svelte-g8qu62 .divider-horizontal:where(.svelte-g8qu62) {height:auto;width:1px;background-color:color-mix(in srgb, var(--pie-border, #d1d5db) 70%, transparent);}
3989
-
3990
- /* Screen reader only content */.pie-sr-only.svelte-g8qu62 {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;}
3991
-
3992
- /* Button styling */.pie-tool-annotation-toolbar__button.svelte-g8qu62 {display:inline-flex;align-items:center;justify-content:center;gap:0.35rem;padding:0.4rem 0.55rem;border:1px solid var(--pie-button-border, #d1d5db);border-radius:0.4rem;background:var(--pie-button-bg, #fff);color:var(--pie-button-color, var(--pie-text, #111827));cursor:pointer;}.pie-tool-annotation-toolbar__button--icon.svelte-g8qu62 {min-width:2rem;min-height:2rem;padding:0.45rem;}.pie-tool-annotation-toolbar__button.svelte-g8qu62:hover {background:var(--pie-button-hover-bg, #f9fafb);color:var(--pie-button-hover-color, var(--pie-text, #111827));border-color:var(--pie-button-hover-border, #9ca3af);}.pie-tool-annotation-toolbar__button.svelte-g8qu62:focus-visible {outline:2px solid var(--pie-button-focus-outline, var(--pie-primary, #3f51b5));outline-offset:2px;}.pie-tool-annotation-toolbar__button.svelte-g8qu62:disabled {opacity:0.6;cursor:not-allowed;}.pie-tool-annotation-toolbar__button--warning.svelte-g8qu62 {color:var(--pie-missing-icon, #92400e);}.pie-tool-annotation-toolbar__button--danger.svelte-g8qu62 {color:var(--pie-incorrect-icon, #b91c1c);}.pie-tool-annotation-toolbar__button.svelte-g8qu62 svg:where(.svelte-g8qu62) {width:18px;height:18px;}`
3993
- };
3994
- function yl(e, t) {
3995
- Bn(t, !0), vs(e, ml);
3996
- let o = Eo(t, "enabled", 7, !0), n = Eo(t, "highlightCoordinator", 7, null), i = Eo(t, "ttsService", 7, null);
3997
- const r = typeof window < "u", s = "pie-annotations", l = [
3998
- {
3999
- name: Bt.YELLOW,
4000
- hex: "#fde995",
4001
- label: "Yellow highlight"
4002
- },
4003
- {
4004
- name: Bt.PINK,
4005
- hex: "#ff9fae",
4006
- label: "Pink highlight"
4007
- },
4008
- {
4009
- name: Bt.BLUE,
4010
- hex: "#a7e0f6",
4011
- label: "Blue highlight"
4012
- },
4013
- {
4014
- name: Bt.GREEN,
4015
- hex: "#a6e1c5",
4016
- label: "Green highlight"
4017
- }
4018
- ], a = [
4019
- "button",
4020
- "input",
4021
- "select",
4022
- "textarea",
4023
- '[contenteditable="true"]',
4024
- ".pie-tool-annotation-toolbar",
4025
- ".pie-tool-toolbar",
4026
- '[role="button"]',
4027
- '[role="textbox"]'
4028
- ];
4029
- let c = /* @__PURE__ */ R(null), f = /* @__PURE__ */ R(null), p = /* @__PURE__ */ R(null), v = /* @__PURE__ */ R(null), d = /* @__PURE__ */ R(ve({
4030
- isVisible: !1,
4031
- selectedText: "",
4032
- selectedRange: null,
4033
- toolbarPosition: { x: 0, y: 0 }
4034
- })), h = /* @__PURE__ */ R(!1), m = /* @__PURE__ */ R(
4035
- !1
4036
- // Flag to prevent immediate hiding after showing
4037
- ), y = /* @__PURE__ */ R(
4038
- ""
4039
- // For screen readers when toolbar is repositioned
4040
- ), k = /* @__PURE__ */ R(0), I = /* @__PURE__ */ R(null), vt = /* @__PURE__ */ Ao(() => b(k) > 0), xt = /* @__PURE__ */ Ao(() => b(I) !== null), W = /* @__PURE__ */ Ao(() => b(v)?.scopeElement || b(p)?.scopeElement || null);
4041
- function _t() {
4042
- const g = b(c)?.ownerDocument;
4043
- return b(W) || g?.documentElement || document.documentElement;
4044
- }
4045
- function gt() {
4046
- const g = b(p)?.canonicalItemId || b(p)?.itemId || "global";
4047
- return `${s}:${g}`;
4048
- }
4049
- function O(g) {
4050
- if (!n()) return null;
4051
- const w = n().getAnnotations();
4052
- for (const A of w) {
4053
- const D = g.compareBoundaryPoints(Range.START_TO_START, A.range), Xt = g.compareBoundaryPoints(Range.END_TO_END, A.range), Ce = g.compareBoundaryPoints(Range.START_TO_END, A.range), Ae = g.compareBoundaryPoints(Range.END_TO_START, A.range);
4054
- if (D >= 0 && Xt <= 0 || // selection inside annotation
4055
- D <= 0 && Xt >= 0 || // annotation inside selection
4056
- Ce > 0 && Ae < 0)
4057
- return A.id;
4058
- }
4059
- return null;
4060
- }
4061
- function So(g) {
4062
- if (g.nodeType !== Node.ELEMENT_NODE && g.nodeType !== Node.TEXT_NODE)
4063
- return !1;
4064
- const w = g.nodeType === Node.TEXT_NODE ? g.parentElement : g;
4065
- return w ? !a.some((A) => {
4066
- try {
4067
- return w.closest(A) !== null;
4068
- } catch {
4069
- return !1;
4070
- }
4071
- }) : !1;
4072
- }
4073
- function ko(g) {
4074
- if (!b(W)) return !0;
4075
- const w = g.commonAncestorContainer, A = w.nodeType === Node.TEXT_NODE ? w.parentElement : w;
4076
- return !!A && b(W).contains(A);
4077
- }
4078
- function an() {
4079
- if (!(!r || !n()))
4080
- try {
4081
- const g = _t(), w = n().exportAnnotations(g);
4082
- sessionStorage.setItem(gt(), JSON.stringify(w));
4083
- } catch (g) {
4084
- console.error("[AnnotationToolbar] Failed to save annotations:", g);
4085
- }
4086
- }
4087
- function Wi() {
4088
- if (!(!r || !n()))
4089
- try {
4090
- const g = sessionStorage.getItem(gt());
4091
- if (!g) return;
4092
- const w = JSON.parse(g), A = _t(), D = n().importAnnotations(w, A);
4093
- console.log(`[AnnotationToolbar] Restored ${D} annotations`), C(k, n().getAnnotations().length, !0);
4094
- } catch (g) {
4095
- console.error("[AnnotationToolbar] Failed to load annotations:", g);
4096
- }
4097
- }
4098
- function Ue() {
4099
- if (!o() || !r) return;
4100
- const g = window.getSelection();
4101
- if (!g || g.rangeCount === 0) return St();
4102
- const w = g.getRangeAt(0), A = g.toString().trim();
4103
- if (!A || !ko(w) || !So(w.commonAncestorContainer))
4104
- return St();
4105
- const D = w.getBoundingClientRect(), Xt = D.left + D.width / 2, Ce = D.top - 8;
4106
- C(I, O(w), !0), b(d).isVisible = !0, b(d).selectedText = A, b(d).selectedRange = w.cloneRange(), b(d).toolbarPosition = { x: Xt, y: Ce };
4107
- const Ae = A.length > 30 ? A.substring(0, 30) + "..." : A;
4108
- C(y, `Annotation toolbar opened for "${Ae}"`), setTimeout(
4109
- () => {
4110
- C(y, "");
4111
- },
4112
- 2e3
4113
- ), C(m, !0), setTimeout(
4114
- () => {
4115
- C(m, !1);
4116
- },
4117
- 100
4118
- );
4119
- }
4120
- function St() {
4121
- b(h) && i() && (i().stop(), C(h, !1)), b(d).isVisible = !1, b(d).selectedText = "", b(d).selectedRange = null;
4122
- }
4123
- function cn(g) {
4124
- if (!b(d).selectedRange || !n()) return;
4125
- const w = b(d).selectedText;
4126
- n().addAnnotation(b(d).selectedRange, g), C(k, n().getAnnotations().length, !0), an();
4127
- const A = g === Bt.UNDERLINE ? "underlined" : `highlighted in ${g}`, D = w.length > 30 ? w.substring(0, 30) + "..." : w;
4128
- C(y, `"${D}" ${A}`), setTimeout(
4129
- () => {
4130
- C(y, "");
4131
- },
4132
- 3e3
4133
- ), St();
4134
- }
4135
- function Di() {
4136
- if (!b(I) || !n()) {
4137
- console.warn("[AnnotationToolbar] No overlapping annotation to remove");
4138
- return;
4139
- }
4140
- console.log("[AnnotationToolbar] Removing annotation:", b(I));
4141
- const g = n().getAnnotation(b(I));
4142
- if (!g) {
4143
- console.warn("[AnnotationToolbar] Annotation not found:", b(I));
4144
- return;
4145
- }
4146
- const w = g.range.toString();
4147
- n().removeAnnotation(b(I));
4148
- const A = n().getAnnotations().length;
4149
- C(k, A, !0), console.log("[AnnotationToolbar] Annotations remaining:", A), an();
4150
- const D = w.length > 30 ? w.substring(0, 30) + "..." : w;
4151
- C(y, `Removed annotation from "${D}"`), setTimeout(
4152
- () => {
4153
- C(y, "");
4154
- },
4155
- 3e3
4156
- ), St();
4157
- }
4158
- function Hi() {
4159
- const g = b(k);
4160
- n()?.clearAnnotations(), C(k, 0), sessionStorage.removeItem(gt()), C(y, `${g} annotation${g === 1 ? "" : "s"} cleared`), setTimeout(
4161
- () => {
4162
- C(y, "");
4163
- },
4164
- 3e3
4165
- ), St();
4166
- }
4167
- async function Bi() {
4168
- if (!(!b(d).selectedRange || !i())) {
4169
- C(h, !0);
4170
- try {
4171
- console.log("[AnnotationToolbar] Speaking range:", b(d).selectedRange.toString().substring(0, 50)), await i().speakRange(b(d).selectedRange, { contentRoot: _t() }), console.log("[AnnotationToolbar] TTS completed successfully");
4172
- } catch (g) {
4173
- console.error("[AnnotationToolbar] TTS error:", g), alert(`TTS failed: ${g instanceof Error ? g.message : String(g)}`);
4174
- } finally {
4175
- C(h, !1);
4176
- }
4177
- }
4178
- }
4179
- function un(g) {
4180
- g.key === "Escape" && b(d).isVisible && (g.preventDefault(), St());
4181
- }
4182
- function Ke(g) {
4183
- !b(d).isVisible || b(m) || b(f) && !b(f).contains(g.target) && St();
4184
- }
4185
- wn(() => {
4186
- if (!r) return;
4187
- const g = setTimeout(
4188
- () => {
4189
- Wi();
4190
- },
4191
- 2e3
4192
- ), w = b(W) || document;
4193
- return w.addEventListener("mouseup", Ue), w.addEventListener("click", Ke), w.addEventListener("touchend", Ue), w.addEventListener("touchstart", Ke), document.addEventListener("keydown", un), window.addEventListener("scroll", St, !0), () => {
4194
- clearTimeout(g), w.removeEventListener("mouseup", Ue), w.removeEventListener("click", Ke), w.removeEventListener("touchend", Ue), w.removeEventListener("touchstart", Ke), document.removeEventListener("keydown", un), window.removeEventListener("scroll", St, !0);
4195
- };
4196
- }), wn(() => {
4197
- if (!b(c)) return;
4198
- const g = Ls(b(c), (A) => {
4199
- C(p, A, !0);
4200
- }), w = Es(b(c), (A) => {
4201
- C(v, A, !0);
4202
- });
4203
- return () => {
4204
- w(), g();
4205
- };
4206
- });
4207
- var zi = {
4208
- get enabled() {
4209
- return o();
4210
- },
4211
- set enabled(g = !0) {
4212
- o(g), no();
4213
- },
4214
- get highlightCoordinator() {
4215
- return n();
4216
- },
4217
- set highlightCoordinator(g = null) {
4218
- n(g), no();
4219
- },
4220
- get ttsService() {
4221
- return i();
4222
- },
4223
- set ttsService(g = null) {
4224
- i(g), no();
4225
- }
4226
- }, fn = bl();
4227
- ps("g8qu62", (g) => {
4228
- var w = ul();
4229
- Ct(g, w);
4230
- });
4231
- var hn = Lo(fn);
4232
- Ln(hn, (g) => C(c, g), () => b(c));
4233
- var dn = Ot(hn, 2);
4234
- {
4235
- var Gi = (g) => {
4236
- var w = gl(), A = Xe(w);
4237
- fs(A, 17, () => l, cs, (nt, it) => {
4238
- var U = fl(), Je = Xe(U), Co = Xe(Je, !0);
4239
- Ze(Je), Ze(U), Ye(() => {
4240
- Sn(U, `background-color: ${b(it).hex ?? ""};`), kn(U, "aria-label", b(it).label), kn(U, "title", b(it).label), _n(Co, b(it).label);
4241
- }), Ee("click", U, () => cn(b(it).name)), Ct(nt, U);
4242
- });
4243
- var D = Ot(A, 2), Xt = Ot(D, 2);
4244
- {
4245
- var Ce = (nt) => {
4246
- var it = hl(), U = Ot(Lo(it), 2);
4247
- Ye(() => U.disabled = b(h)), Ee("click", U, Bi), Ct(nt, it);
4248
- };
4249
- Ve(Xt, (nt) => {
4250
- i() && nt(Ce);
4251
- });
4252
- }
4253
- var Ae = Ot(Xt, 2);
4254
- {
4255
- var Ui = (nt) => {
4256
- var it = vl(), U = Ot(Lo(it), 2);
4257
- {
4258
- var Je = (Yt) => {
4259
- var Le = dl();
4260
- Ee("click", Le, Di), Ct(Yt, Le);
4261
- };
4262
- Ve(U, (Yt) => {
4263
- b(xt) && Yt(Je);
4264
- });
4265
- }
4266
- var Co = Ot(U, 2);
4267
- {
4268
- var Ki = (Yt) => {
4269
- var Le = pl();
4270
- Ee("click", Le, Hi), Ct(Yt, Le);
4271
- };
4272
- Ve(Co, (Yt) => {
4273
- b(vt) && Yt(Ki);
4274
- });
4275
- }
4276
- Ct(nt, it);
4277
- };
4278
- Ve(Ae, (nt) => {
4279
- (b(xt) || b(vt)) && nt(Ui);
4280
- });
4281
- }
4282
- Ze(w), Ln(w, (nt) => C(f, nt), () => b(f)), Ye(() => Sn(w, `left:${b(d).toolbarPosition.x}px; top:${b(d).toolbarPosition.y}px; transform: translate(-50%, -100%);`)), Ee("click", D, () => cn(Bt.UNDERLINE)), Ct(g, w);
4283
- };
4284
- Ve(dn, (g) => {
4285
- b(d).isVisible && g(Gi);
4286
- });
4287
- }
4288
- var pn = Ot(dn, 2), Fi = Xe(pn, !0);
4289
- return Ze(pn), Ye(() => _n(Fi, b(y))), Ct(e, fn), zn(zi);
4290
- }
4291
- ts(["click"]);
4292
- customElements.define("pie-tool-annotation-toolbar", _s(
4293
- yl,
4294
- {
4295
- enabled: { attribute: "enabled", type: "Boolean" },
4296
- highlightCoordinator: { type: "Object" },
4297
- ttsService: { type: "Object" }
4298
- },
4299
- [],
4300
- [],
4301
- { mode: "open" }
4302
- ));
4303
- export {
4304
- yl as default
4305
- };