@pie-players/pie-tool-answer-eliminator 0.2.0

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