@pie-players/pie-section-player 0.3.19 → 0.3.21

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