@arenarium/maps 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.es.js DELETED
@@ -1,3288 +0,0 @@
1
- var br = Array.isArray, kn = Array.prototype.indexOf, Mn = Array.from, Mt = Object.defineProperty, Ue = Object.getOwnPropertyDescriptor, xn = Object.prototype, Pn = Array.prototype, Sn = Object.getPrototypeOf, sr = Object.isExtensible;
2
- function An(t) {
3
- for (var e = 0; e < t.length; e++)
4
- t[e]();
5
- }
6
- function Dn() {
7
- var t, e, r = new Promise((n, i) => {
8
- t = n, e = i;
9
- });
10
- return { promise: r, resolve: t, reject: e };
11
- }
12
- const R = 2, It = 4, Er = 8, Le = 16, fe = 32, ge = 64, Ft = 128, q = 256, st = 512, L = 1024, re = 2048, ce = 4096, Ae = 8192, Ie = 16384, Ot = 32768, kr = 65536, or = 1 << 17, Cn = 1 << 18, Fe = 1 << 19, Tn = 1 << 20, xt = 1 << 21, Rt = 1 << 22, ve = 1 << 23, rt = Symbol("$state"), Nt = new class extends Error {
13
- name = "StaleReactionError";
14
- message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
15
- }();
16
- function Ln() {
17
- throw new Error("https://svelte.dev/e/async_derived_orphan");
18
- }
19
- function In(t) {
20
- throw new Error("https://svelte.dev/e/effect_in_teardown");
21
- }
22
- function Fn() {
23
- throw new Error("https://svelte.dev/e/effect_in_unowned_derived");
24
- }
25
- function On(t) {
26
- throw new Error("https://svelte.dev/e/effect_orphan");
27
- }
28
- function Rn() {
29
- throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
30
- }
31
- function Nn() {
32
- throw new Error("https://svelte.dev/e/state_descriptors_fixed");
33
- }
34
- function jn() {
35
- throw new Error("https://svelte.dev/e/state_prototype_fixed");
36
- }
37
- function zn() {
38
- throw new Error("https://svelte.dev/e/state_unsafe_mutation");
39
- }
40
- function Bn() {
41
- throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
42
- }
43
- const Un = 2, x = Symbol();
44
- function Zn() {
45
- console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
46
- }
47
- function Mr(t) {
48
- return t === this.v;
49
- }
50
- let Y = null;
51
- function De(t) {
52
- Y = t;
53
- }
54
- function jt(t, e = !1, r) {
55
- Y = {
56
- p: Y,
57
- c: null,
58
- e: null,
59
- s: t,
60
- x: null,
61
- l: null
62
- };
63
- }
64
- function zt(t) {
65
- var e = (
66
- /** @type {ComponentContext} */
67
- Y
68
- ), r = e.e;
69
- if (r !== null) {
70
- e.e = null;
71
- for (var n of r)
72
- Nr(n);
73
- }
74
- return t !== void 0 && (e.x = t), Y = e.p, t ?? /** @type {T} */
75
- {};
76
- }
77
- function xr() {
78
- return !0;
79
- }
80
- let Me = [];
81
- function qn() {
82
- var t = Me;
83
- Me = [], An(t);
84
- }
85
- function ut(t) {
86
- if (Me.length === 0) {
87
- var e = Me;
88
- queueMicrotask(() => {
89
- e === Me && qn();
90
- });
91
- }
92
- Me.push(t);
93
- }
94
- const Hn = /* @__PURE__ */ new WeakMap();
95
- function Pr(t) {
96
- var e = m;
97
- if (e === null)
98
- return v.f |= ve, t;
99
- if ((e.f & Ot) === 0) {
100
- if ((e.f & Ft) === 0)
101
- throw !e.parent && t instanceof Error && Sr(t), t;
102
- e.b.error(t);
103
- } else
104
- Ce(t, e);
105
- }
106
- function Ce(t, e) {
107
- for (; e !== null; ) {
108
- if ((e.f & Ft) !== 0)
109
- try {
110
- e.b.error(t);
111
- return;
112
- } catch (r) {
113
- t = r;
114
- }
115
- e = e.parent;
116
- }
117
- throw t instanceof Error && Sr(t), t;
118
- }
119
- function Sr(t) {
120
- const e = Hn.get(t);
121
- e && (Mt(t, "message", {
122
- value: e.message
123
- }), Mt(t, "stack", {
124
- value: e.stack
125
- }));
126
- }
127
- const wt = /* @__PURE__ */ new Set();
128
- let A = null, Pt = /* @__PURE__ */ new Set(), Xe = [], Bt = null, St = !1;
129
- class ie {
130
- /**
131
- * The current values of any sources that are updated in this batch
132
- * They keys of this map are identical to `this.#previous`
133
- * @type {Map<Source, any>}
134
- */
135
- current = /* @__PURE__ */ new Map();
136
- /**
137
- * The values of any sources that are updated in this batch _before_ those updates took place.
138
- * They keys of this map are identical to `this.#current`
139
- * @type {Map<Source, any>}
140
- */
141
- #e = /* @__PURE__ */ new Map();
142
- /**
143
- * When the batch is committed (and the DOM is updated), we need to remove old branches
144
- * and append new ones by calling the functions added inside (if/each/key/etc) blocks
145
- * @type {Set<() => void>}
146
- */
147
- #t = /* @__PURE__ */ new Set();
148
- /**
149
- * The number of async effects that are currently in flight
150
- */
151
- #a = 0;
152
- /**
153
- * A deferred that resolves when the batch is committed, used with `settled()`
154
- * TODO replace with Promise.withResolvers once supported widely enough
155
- * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
156
- */
157
- #n = null;
158
- /**
159
- * True if an async effect inside this batch resolved and
160
- * its parent branch was already deleted
161
- */
162
- #c = !1;
163
- /**
164
- * Async effects (created inside `async_derived`) encountered during processing.
165
- * These run after the rest of the batch has updated, since they should
166
- * always have the latest values
167
- * @type {Effect[]}
168
- */
169
- #o = [];
170
- /**
171
- * The same as `#async_effects`, but for effects inside a newly-created
172
- * `<svelte:boundary>` — these do not prevent the batch from committing
173
- * @type {Effect[]}
174
- */
175
- #i = [];
176
- /**
177
- * Template effects and `$effect.pre` effects, which run when
178
- * a batch is committed
179
- * @type {Effect[]}
180
- */
181
- #r = [];
182
- /**
183
- * The same as `#render_effects`, but for `$effect` (which runs after)
184
- * @type {Effect[]}
185
- */
186
- #s = [];
187
- /**
188
- * Block effects, which may need to re-run on subsequent flushes
189
- * in order to update internal sources (e.g. each block items)
190
- * @type {Effect[]}
191
- */
192
- #l = [];
193
- /**
194
- * Deferred effects (which run after async work has completed) that are DIRTY
195
- * @type {Effect[]}
196
- */
197
- #h = [];
198
- /**
199
- * Deferred effects that are MAYBE_DIRTY
200
- * @type {Effect[]}
201
- */
202
- #f = [];
203
- /**
204
- * A set of branches that still exist, but will be destroyed when this batch
205
- * is committed — we skip over these during `process`
206
- * @type {Set<Effect>}
207
- */
208
- skipped_effects = /* @__PURE__ */ new Set();
209
- /**
210
- *
211
- * @param {Effect[]} root_effects
212
- */
213
- process(e) {
214
- Xe = [];
215
- for (const i of e)
216
- this.#p(i);
217
- if (this.#o.length === 0 && this.#a === 0) {
218
- this.#d();
219
- var r = this.#r, n = this.#s;
220
- this.#r = [], this.#s = [], this.#l = [], A = null, ar(r), ar(n), A === null ? A = this : wt.delete(this), this.#n?.resolve();
221
- } else
222
- this.#u(this.#r), this.#u(this.#s), this.#u(this.#l);
223
- for (const i of this.#o)
224
- Se(i);
225
- for (const i of this.#i)
226
- Se(i);
227
- this.#o = [], this.#i = [];
228
- }
229
- /**
230
- * Traverse the effect tree, executing effects or stashing
231
- * them for later execution as appropriate
232
- * @param {Effect} root
233
- */
234
- #p(e) {
235
- e.f ^= L;
236
- for (var r = e.first; r !== null; ) {
237
- var n = r.f, i = (n & (fe | ge)) !== 0, s = i && (n & L) !== 0, o = s || (n & Ae) !== 0 || this.skipped_effects.has(r);
238
- if (!o && r.fn !== null) {
239
- if (i)
240
- r.f ^= L;
241
- else if ((n & It) !== 0)
242
- this.#s.push(r);
243
- else if ((n & L) === 0)
244
- if ((n & Rt) !== 0) {
245
- var l = r.b?.is_pending() ? this.#i : this.#o;
246
- l.push(r);
247
- } else ct(r) && ((r.f & Le) !== 0 && this.#l.push(r), Se(r));
248
- var a = r.first;
249
- if (a !== null) {
250
- r = a;
251
- continue;
252
- }
253
- }
254
- var u = r.parent;
255
- for (r = r.next; r === null && u !== null; )
256
- r = u.next, u = u.parent;
257
- }
258
- }
259
- /**
260
- * @param {Effect[]} effects
261
- */
262
- #u(e) {
263
- for (const r of e)
264
- ((r.f & re) !== 0 ? this.#h : this.#f).push(r), H(r, L);
265
- e.length = 0;
266
- }
267
- /**
268
- * Associate a change to a given source with the current
269
- * batch, noting its previous and current values
270
- * @param {Source} source
271
- * @param {any} value
272
- */
273
- capture(e, r) {
274
- this.#e.has(e) || this.#e.set(e, r), this.current.set(e, e.v);
275
- }
276
- activate() {
277
- A = this;
278
- }
279
- deactivate() {
280
- A = null;
281
- for (const e of Pt)
282
- if (Pt.delete(e), e(), A !== null)
283
- break;
284
- }
285
- neuter() {
286
- this.#c = !0;
287
- }
288
- flush() {
289
- Xe.length > 0 ? Yn() : this.#d(), A === this && (this.#a === 0 && wt.delete(this), this.deactivate());
290
- }
291
- /**
292
- * Append and remove branches to/from the DOM
293
- */
294
- #d() {
295
- if (!this.#c)
296
- for (const e of this.#t)
297
- e();
298
- this.#t.clear();
299
- }
300
- increment() {
301
- this.#a += 1;
302
- }
303
- decrement() {
304
- if (this.#a -= 1, this.#a === 0) {
305
- for (const e of this.#h)
306
- H(e, re), We(e);
307
- for (const e of this.#f)
308
- H(e, ce), We(e);
309
- this.#r = [], this.#s = [], this.flush();
310
- } else
311
- this.deactivate();
312
- }
313
- /** @param {() => void} fn */
314
- add_callback(e) {
315
- this.#t.add(e);
316
- }
317
- settled() {
318
- return (this.#n ??= Dn()).promise;
319
- }
320
- static ensure() {
321
- if (A === null) {
322
- const e = A = new ie();
323
- wt.add(A), ie.enqueue(() => {
324
- A === e && e.flush();
325
- });
326
- }
327
- return A;
328
- }
329
- /** @param {() => void} task */
330
- static enqueue(e) {
331
- ut(e);
332
- }
333
- }
334
- function Yn() {
335
- var t = Pe;
336
- St = !0;
337
- try {
338
- var e = 0;
339
- for (fr(!0); Xe.length > 0; ) {
340
- var r = ie.ensure();
341
- if (e++ > 1e3) {
342
- var n, i;
343
- Vn();
344
- }
345
- r.process(Xe), ue.clear();
346
- }
347
- } finally {
348
- St = !1, fr(t), Bt = null;
349
- }
350
- }
351
- function Vn() {
352
- try {
353
- Rn();
354
- } catch (t) {
355
- Ce(t, Bt);
356
- }
357
- }
358
- let de = null;
359
- function ar(t) {
360
- var e = t.length;
361
- if (e !== 0) {
362
- for (var r = 0; r < e; ) {
363
- var n = t[r++];
364
- if ((n.f & (Ie | Ae)) === 0 && ct(n) && (de = [], Se(n), n.deps === null && n.first === null && n.nodes_start === null && (n.teardown === null && n.ac === null ? Ur(n) : n.fn = null), de?.length > 0)) {
365
- ue.clear();
366
- for (const i of de)
367
- Se(i);
368
- de = [];
369
- }
370
- }
371
- de = null;
372
- }
373
- }
374
- function We(t) {
375
- for (var e = Bt = t; e.parent !== null; ) {
376
- e = e.parent;
377
- var r = e.f;
378
- if (St && e === m && (r & Le) !== 0)
379
- return;
380
- if ((r & (ge | fe)) !== 0) {
381
- if ((r & L) === 0) return;
382
- e.f ^= L;
383
- }
384
- }
385
- Xe.push(e);
386
- }
387
- function Xn(t) {
388
- let e = 0, r = ft(0), n;
389
- return () => {
390
- li() && (g(r), qt(() => (e === 0 && (n = Wr(() => t(() => Ze(r)))), e += 1, () => {
391
- ut(() => {
392
- e -= 1, e === 0 && (n?.(), n = void 0, Ze(r));
393
- });
394
- })));
395
- };
396
- }
397
- var Wn = kr | Fe | Ft;
398
- function Gn(t, e, r) {
399
- new Kn(t, e, r);
400
- }
401
- class Kn {
402
- /** @type {Boundary | null} */
403
- parent;
404
- #e = !1;
405
- /** @type {TemplateNode} */
406
- #t;
407
- /** @type {TemplateNode | null} */
408
- #a = null;
409
- /** @type {BoundaryProps} */
410
- #n;
411
- /** @type {((anchor: Node) => void)} */
412
- #c;
413
- /** @type {Effect} */
414
- #o;
415
- /** @type {Effect | null} */
416
- #i = null;
417
- /** @type {Effect | null} */
418
- #r = null;
419
- /** @type {Effect | null} */
420
- #s = null;
421
- /** @type {DocumentFragment | null} */
422
- #l = null;
423
- #h = 0;
424
- #f = 0;
425
- #p = !1;
426
- /**
427
- * A source containing the number of pending async deriveds/expressions.
428
- * Only created if `$effect.pending()` is used inside the boundary,
429
- * otherwise updating the source results in needless `Batch.ensure()`
430
- * calls followed by no-op flushes
431
- * @type {Source<number> | null}
432
- */
433
- #u = null;
434
- #d = () => {
435
- this.#u && ot(this.#u, this.#h);
436
- };
437
- #g = Xn(() => (this.#u = ft(this.#h), () => {
438
- this.#u = null;
439
- }));
440
- /**
441
- * @param {TemplateNode} node
442
- * @param {BoundaryProps} props
443
- * @param {((anchor: Node) => void)} children
444
- */
445
- constructor(e, r, n) {
446
- this.#t = e, this.#n = r, this.#c = n, this.parent = /** @type {Effect} */
447
- m.b, this.#e = !!this.#n.pending, this.#o = hi(() => {
448
- m.b = this;
449
- {
450
- try {
451
- this.#i = pe(() => n(this.#t));
452
- } catch (i) {
453
- this.error(i);
454
- }
455
- this.#f > 0 ? this.#m() : this.#e = !1;
456
- }
457
- }, Wn);
458
- }
459
- #_() {
460
- try {
461
- this.#i = pe(() => this.#c(this.#t));
462
- } catch (e) {
463
- this.error(e);
464
- }
465
- this.#e = !1;
466
- }
467
- #w() {
468
- const e = this.#n.pending;
469
- e && (this.#r = pe(() => e(this.#t)), ie.enqueue(() => {
470
- this.#i = this.#v(() => (ie.ensure(), pe(() => this.#c(this.#t)))), this.#f > 0 ? this.#m() : (nt(
471
- /** @type {Effect} */
472
- this.#r,
473
- () => {
474
- this.#r = null;
475
- }
476
- ), this.#e = !1);
477
- }));
478
- }
479
- /**
480
- * Returns `true` if the effect exists inside a boundary whose pending snippet is shown
481
- * @returns {boolean}
482
- */
483
- is_pending() {
484
- return this.#e || !!this.parent && this.parent.is_pending();
485
- }
486
- has_pending_snippet() {
487
- return !!this.#n.pending;
488
- }
489
- /**
490
- * @param {() => Effect | null} fn
491
- */
492
- #v(e) {
493
- var r = m, n = v, i = Y;
494
- ne(this.#o), I(this.#o), De(this.#o.ctx);
495
- try {
496
- return e();
497
- } catch (s) {
498
- return Pr(s), null;
499
- } finally {
500
- ne(r), I(n), De(i);
501
- }
502
- }
503
- #m() {
504
- const e = (
505
- /** @type {(anchor: Node) => void} */
506
- this.#n.pending
507
- );
508
- this.#i !== null && (this.#l = document.createDocumentFragment(), Jn(this.#i, this.#l)), this.#r === null && (this.#r = pe(() => e(this.#t)));
509
- }
510
- /**
511
- * Updates the pending count associated with the currently visible pending snippet,
512
- * if any, such that we can replace the snippet with content once work is done
513
- * @param {1 | -1} d
514
- */
515
- #y(e) {
516
- if (!this.has_pending_snippet()) {
517
- this.parent && this.parent.#y(e);
518
- return;
519
- }
520
- this.#f += e, this.#f === 0 && (this.#e = !1, this.#r && nt(this.#r, () => {
521
- this.#r = null;
522
- }), this.#l && (this.#t.before(this.#l), this.#l = null));
523
- }
524
- /**
525
- * Update the source that powers `$effect.pending()` inside this boundary,
526
- * and controls when the current `pending` snippet (if any) is removed.
527
- * Do not call from inside the class
528
- * @param {1 | -1} d
529
- */
530
- update_pending_count(e) {
531
- this.#y(e), this.#h += e, Pt.add(this.#d);
532
- }
533
- get_effect_pending() {
534
- return this.#g(), g(
535
- /** @type {Source<number>} */
536
- this.#u
537
- );
538
- }
539
- /** @param {unknown} error */
540
- error(e) {
541
- var r = this.#n.onerror;
542
- let n = this.#n.failed;
543
- if (this.#p || !r && !n)
544
- throw e;
545
- this.#i && (ee(this.#i), this.#i = null), this.#r && (ee(this.#r), this.#r = null), this.#s && (ee(this.#s), this.#s = null);
546
- var i = !1, s = !1;
547
- const o = () => {
548
- if (i) {
549
- Zn();
550
- return;
551
- }
552
- i = !0, s && Bn(), ie.ensure(), this.#h = 0, this.#s !== null && nt(this.#s, () => {
553
- this.#s = null;
554
- }), this.#e = this.has_pending_snippet(), this.#i = this.#v(() => (this.#p = !1, pe(() => this.#c(this.#t)))), this.#f > 0 ? this.#m() : this.#e = !1;
555
- };
556
- var l = v;
557
- try {
558
- I(null), s = !0, r?.(e, o), s = !1;
559
- } catch (a) {
560
- Ce(a, this.#o && this.#o.parent);
561
- } finally {
562
- I(l);
563
- }
564
- n && ut(() => {
565
- this.#s = this.#v(() => {
566
- this.#p = !0;
567
- try {
568
- return pe(() => {
569
- n(
570
- this.#t,
571
- () => e,
572
- () => o
573
- );
574
- });
575
- } catch (a) {
576
- return Ce(
577
- a,
578
- /** @type {Effect} */
579
- this.#o.parent
580
- ), null;
581
- } finally {
582
- this.#p = !1;
583
- }
584
- });
585
- });
586
- }
587
- }
588
- function Jn(t, e) {
589
- for (var r = t.nodes_start, n = t.nodes_end; r !== null; ) {
590
- var i = r === n ? null : (
591
- /** @type {TemplateNode} */
592
- /* @__PURE__ */ Zt(r)
593
- );
594
- e.append(r), r = i;
595
- }
596
- }
597
- function Qn(t, e, r) {
598
- const n = ei;
599
- if (e.length === 0) {
600
- r(t.map(n));
601
- return;
602
- }
603
- var i = A, s = (
604
- /** @type {Effect} */
605
- m
606
- ), o = $n();
607
- Promise.all(e.map((l) => /* @__PURE__ */ ti(l))).then((l) => {
608
- i?.activate(), o();
609
- try {
610
- r([...t.map(n), ...l]);
611
- } catch (a) {
612
- (s.f & Ie) === 0 && Ce(a, s);
613
- }
614
- i?.deactivate(), Ar();
615
- }).catch((l) => {
616
- Ce(l, s);
617
- });
618
- }
619
- function $n() {
620
- var t = m, e = v, r = Y, n = A;
621
- return function() {
622
- ne(t), I(e), De(r), n?.activate();
623
- };
624
- }
625
- function Ar() {
626
- ne(null), I(null), De(null);
627
- }
628
- // @__NO_SIDE_EFFECTS__
629
- function ei(t) {
630
- var e = R | re, r = v !== null && (v.f & R) !== 0 ? (
631
- /** @type {Derived} */
632
- v
633
- ) : null;
634
- return m === null || r !== null && (r.f & q) !== 0 ? e |= q : m.f |= Fe, {
635
- ctx: Y,
636
- deps: null,
637
- effects: null,
638
- equals: Mr,
639
- f: e,
640
- fn: t,
641
- reactions: null,
642
- rv: 0,
643
- v: (
644
- /** @type {V} */
645
- x
646
- ),
647
- wv: 0,
648
- parent: r ?? m,
649
- ac: null
650
- };
651
- }
652
- // @__NO_SIDE_EFFECTS__
653
- function ti(t, e) {
654
- let r = (
655
- /** @type {Effect | null} */
656
- m
657
- );
658
- r === null && Ln();
659
- var n = (
660
- /** @type {Boundary} */
661
- r.b
662
- ), i = (
663
- /** @type {Promise<V>} */
664
- /** @type {unknown} */
665
- void 0
666
- ), s = ft(
667
- /** @type {V} */
668
- x
669
- ), o = null, l = !v;
670
- return ci(() => {
671
- try {
672
- var a = t();
673
- o && Promise.resolve(a).catch(() => {
674
- });
675
- } catch (c) {
676
- a = Promise.reject(c);
677
- }
678
- var u = () => a;
679
- i = o?.then(u, u) ?? Promise.resolve(a), o = i;
680
- var f = (
681
- /** @type {Batch} */
682
- A
683
- ), p = n.is_pending();
684
- l && (n.update_pending_count(1), p || f.increment());
685
- const h = (c, d = void 0) => {
686
- o = null, p || f.activate(), d ? d !== Nt && (s.f |= ve, ot(s, d)) : ((s.f & ve) !== 0 && (s.f ^= ve), ot(s, c)), l && (n.update_pending_count(-1), p || f.decrement()), Ar();
687
- };
688
- if (i.then(h, (c) => h(null, c || "unknown")), f)
689
- return () => {
690
- queueMicrotask(() => f.neuter());
691
- };
692
- }), new Promise((a) => {
693
- function u(f) {
694
- function p() {
695
- f === i ? a(s) : u(i);
696
- }
697
- f.then(p, p);
698
- }
699
- u(i);
700
- });
701
- }
702
- function Dr(t) {
703
- var e = t.effects;
704
- if (e !== null) {
705
- t.effects = null;
706
- for (var r = 0; r < e.length; r += 1)
707
- ee(
708
- /** @type {Effect} */
709
- e[r]
710
- );
711
- }
712
- }
713
- function ri(t) {
714
- for (var e = t.parent; e !== null; ) {
715
- if ((e.f & R) === 0)
716
- return (
717
- /** @type {Effect} */
718
- e
719
- );
720
- e = e.parent;
721
- }
722
- return null;
723
- }
724
- function Ut(t) {
725
- var e, r = m;
726
- ne(ri(t));
727
- try {
728
- Dr(t), e = Vr(t);
729
- } finally {
730
- ne(r);
731
- }
732
- return e;
733
- }
734
- function Cr(t) {
735
- var e = Ut(t);
736
- if (t.equals(e) || (t.v = e, t.wv = Hr()), !Oe) {
737
- var r = (le || (t.f & q) !== 0) && t.deps !== null ? ce : L;
738
- H(t, r);
739
- }
740
- }
741
- const ue = /* @__PURE__ */ new Map();
742
- function ft(t, e) {
743
- var r = {
744
- f: 0,
745
- // TODO ideally we could skip this altogether, but it causes type errors
746
- v: t,
747
- reactions: null,
748
- equals: Mr,
749
- rv: 0,
750
- wv: 0
751
- };
752
- return r;
753
- }
754
- // @__NO_SIDE_EFFECTS__
755
- function D(t, e) {
756
- const r = ft(t);
757
- return mi(r), r;
758
- }
759
- function P(t, e, r = !1) {
760
- v !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
761
- // to ensure we error if state is set inside an inspect effect
762
- (!G || (v.f & or) !== 0) && xr() && (v.f & (R | Le | Rt | or)) !== 0 && !se?.includes(t) && zn();
763
- let n = r ? je(e) : e;
764
- return ot(t, n);
765
- }
766
- function ot(t, e) {
767
- if (!t.equals(e)) {
768
- var r = t.v;
769
- Oe ? ue.set(t, e) : ue.set(t, r), t.v = e;
770
- var n = ie.ensure();
771
- n.capture(t, r), (t.f & R) !== 0 && ((t.f & re) !== 0 && Ut(
772
- /** @type {Derived} */
773
- t
774
- ), H(t, (t.f & q) === 0 ? L : ce)), t.wv = Hr(), Tr(t, re), m !== null && (m.f & L) !== 0 && (m.f & (fe | ge)) === 0 && (j === null ? yi([t]) : j.push(t));
775
- }
776
- return e;
777
- }
778
- function Ze(t) {
779
- P(t, t.v + 1);
780
- }
781
- function Tr(t, e) {
782
- var r = t.reactions;
783
- if (r !== null)
784
- for (var n = r.length, i = 0; i < n; i++) {
785
- var s = r[i], o = s.f, l = (o & re) === 0;
786
- l && H(s, e), (o & R) !== 0 ? Tr(
787
- /** @type {Derived} */
788
- s,
789
- ce
790
- ) : l && ((o & Le) !== 0 && de !== null && de.push(
791
- /** @type {Effect} */
792
- s
793
- ), We(
794
- /** @type {Effect} */
795
- s
796
- ));
797
- }
798
- }
799
- function je(t) {
800
- if (typeof t != "object" || t === null || rt in t)
801
- return t;
802
- const e = Sn(t);
803
- if (e !== xn && e !== Pn)
804
- return t;
805
- var r = /* @__PURE__ */ new Map(), n = br(t), i = /* @__PURE__ */ D(0), s = me, o = (l) => {
806
- if (me === s)
807
- return l();
808
- var a = v, u = me;
809
- I(null), hr(s);
810
- var f = l();
811
- return I(a), hr(u), f;
812
- };
813
- return n && r.set("length", /* @__PURE__ */ D(
814
- /** @type {any[]} */
815
- t.length
816
- )), new Proxy(
817
- /** @type {any} */
818
- t,
819
- {
820
- defineProperty(l, a, u) {
821
- (!("value" in u) || u.configurable === !1 || u.enumerable === !1 || u.writable === !1) && Nn();
822
- var f = r.get(a);
823
- return f === void 0 ? f = o(() => {
824
- var p = /* @__PURE__ */ D(u.value);
825
- return r.set(a, p), p;
826
- }) : P(f, u.value, !0), !0;
827
- },
828
- deleteProperty(l, a) {
829
- var u = r.get(a);
830
- if (u === void 0) {
831
- if (a in l) {
832
- const f = o(() => /* @__PURE__ */ D(x));
833
- r.set(a, f), Ze(i);
834
- }
835
- } else
836
- P(u, x), Ze(i);
837
- return !0;
838
- },
839
- get(l, a, u) {
840
- if (a === rt)
841
- return t;
842
- var f = r.get(a), p = a in l;
843
- if (f === void 0 && (!p || Ue(l, a)?.writable) && (f = o(() => {
844
- var c = je(p ? l[a] : x), d = /* @__PURE__ */ D(c);
845
- return d;
846
- }), r.set(a, f)), f !== void 0) {
847
- var h = g(f);
848
- return h === x ? void 0 : h;
849
- }
850
- return Reflect.get(l, a, u);
851
- },
852
- getOwnPropertyDescriptor(l, a) {
853
- var u = Reflect.getOwnPropertyDescriptor(l, a);
854
- if (u && "value" in u) {
855
- var f = r.get(a);
856
- f && (u.value = g(f));
857
- } else if (u === void 0) {
858
- var p = r.get(a), h = p?.v;
859
- if (p !== void 0 && h !== x)
860
- return {
861
- enumerable: !0,
862
- configurable: !0,
863
- value: h,
864
- writable: !0
865
- };
866
- }
867
- return u;
868
- },
869
- has(l, a) {
870
- if (a === rt)
871
- return !0;
872
- var u = r.get(a), f = u !== void 0 && u.v !== x || Reflect.has(l, a);
873
- if (u !== void 0 || m !== null && (!f || Ue(l, a)?.writable)) {
874
- u === void 0 && (u = o(() => {
875
- var h = f ? je(l[a]) : x, c = /* @__PURE__ */ D(h);
876
- return c;
877
- }), r.set(a, u));
878
- var p = g(u);
879
- if (p === x)
880
- return !1;
881
- }
882
- return f;
883
- },
884
- set(l, a, u, f) {
885
- var p = r.get(a), h = a in l;
886
- if (n && a === "length")
887
- for (var c = u; c < /** @type {Source<number>} */
888
- p.v; c += 1) {
889
- var d = r.get(c + "");
890
- d !== void 0 ? P(d, x) : c in l && (d = o(() => /* @__PURE__ */ D(x)), r.set(c + "", d));
891
- }
892
- if (p === void 0)
893
- (!h || Ue(l, a)?.writable) && (p = o(() => /* @__PURE__ */ D(void 0)), P(p, je(u)), r.set(a, p));
894
- else {
895
- h = p.v !== x;
896
- var w = o(() => je(u));
897
- P(p, w);
898
- }
899
- var F = Reflect.getOwnPropertyDescriptor(l, a);
900
- if (F?.set && F.set.call(f, u), !h) {
901
- if (n && typeof a == "string") {
902
- var K = (
903
- /** @type {Source<number>} */
904
- r.get("length")
905
- ), k = Number(a);
906
- Number.isInteger(k) && k >= K.v && P(K, k + 1);
907
- }
908
- Ze(i);
909
- }
910
- return !0;
911
- },
912
- ownKeys(l) {
913
- g(i);
914
- var a = Reflect.ownKeys(l).filter((p) => {
915
- var h = r.get(p);
916
- return h === void 0 || h.v !== x;
917
- });
918
- for (var [u, f] of r)
919
- f.v !== x && !(u in l) && a.push(u);
920
- return a;
921
- },
922
- setPrototypeOf() {
923
- jn();
924
- }
925
- }
926
- );
927
- }
928
- var lr, Lr, Ir, Fr;
929
- function ni() {
930
- if (lr === void 0) {
931
- lr = window, Lr = /Firefox/.test(navigator.userAgent);
932
- var t = Element.prototype, e = Node.prototype, r = Text.prototype;
933
- Ir = Ue(e, "firstChild").get, Fr = Ue(e, "nextSibling").get, sr(t) && (t.__click = void 0, t.__className = void 0, t.__attributes = null, t.__style = void 0, t.__e = void 0), sr(r) && (r.__t = void 0);
934
- }
935
- }
936
- function ii(t = "") {
937
- return document.createTextNode(t);
938
- }
939
- // @__NO_SIDE_EFFECTS__
940
- function Or(t) {
941
- return Ir.call(t);
942
- }
943
- // @__NO_SIDE_EFFECTS__
944
- function Zt(t) {
945
- return Fr.call(t);
946
- }
947
- function ur(t, e) {
948
- return /* @__PURE__ */ Or(t);
949
- }
950
- function si(t, e = 1, r = !1) {
951
- let n = t;
952
- for (; e--; )
953
- n = /** @type {TemplateNode} */
954
- /* @__PURE__ */ Zt(n);
955
- return n;
956
- }
957
- function Rr(t) {
958
- var e = v, r = m;
959
- I(null), ne(null);
960
- try {
961
- return t();
962
- } finally {
963
- I(e), ne(r);
964
- }
965
- }
966
- function oi(t) {
967
- m === null && v === null && On(), v !== null && (v.f & q) !== 0 && m === null && Fn(), Oe && In();
968
- }
969
- function ai(t, e) {
970
- var r = e.last;
971
- r === null ? e.last = e.first = t : (r.next = t, t.prev = r, e.last = t);
972
- }
973
- function he(t, e, r, n = !0) {
974
- var i = m;
975
- i !== null && (i.f & Ae) !== 0 && (t |= Ae);
976
- var s = {
977
- ctx: Y,
978
- deps: null,
979
- nodes_start: null,
980
- nodes_end: null,
981
- f: t | re,
982
- first: null,
983
- fn: e,
984
- last: null,
985
- next: null,
986
- parent: i,
987
- b: i && i.b,
988
- prev: null,
989
- teardown: null,
990
- transitions: null,
991
- wv: 0,
992
- ac: null
993
- };
994
- if (r)
995
- try {
996
- Se(s), s.f |= Ot;
997
- } catch (a) {
998
- throw ee(s), a;
999
- }
1000
- else e !== null && We(s);
1001
- if (n) {
1002
- var o = s;
1003
- if (r && o.deps === null && o.teardown === null && o.nodes_start === null && o.first === o.last && // either `null`, or a singular child
1004
- (o.f & Fe) === 0 && (o = o.first), o !== null && (o.parent = i, i !== null && ai(o, i), v !== null && (v.f & R) !== 0 && (t & ge) === 0)) {
1005
- var l = (
1006
- /** @type {Derived} */
1007
- v
1008
- );
1009
- (l.effects ??= []).push(o);
1010
- }
1011
- }
1012
- return s;
1013
- }
1014
- function li() {
1015
- return v !== null && !G;
1016
- }
1017
- function J(t) {
1018
- oi();
1019
- var e = (
1020
- /** @type {Effect} */
1021
- m.f
1022
- ), r = !v && (e & fe) !== 0 && (e & Ot) === 0;
1023
- if (r) {
1024
- var n = (
1025
- /** @type {ComponentContext} */
1026
- Y
1027
- );
1028
- (n.e ??= []).push(t);
1029
- } else
1030
- return Nr(t);
1031
- }
1032
- function Nr(t) {
1033
- return he(It | Tn, t, !1);
1034
- }
1035
- function ui(t) {
1036
- ie.ensure();
1037
- const e = he(ge | Fe, t, !0);
1038
- return (r = {}) => new Promise((n) => {
1039
- r.outro ? nt(e, () => {
1040
- ee(e), n(void 0);
1041
- }) : (ee(e), n(void 0));
1042
- });
1043
- }
1044
- function fi(t) {
1045
- return he(It, t, !1);
1046
- }
1047
- function ci(t) {
1048
- return he(Rt | Fe, t, !0);
1049
- }
1050
- function qt(t, e = 0) {
1051
- return he(Er | e, t, !0);
1052
- }
1053
- function jr(t, e = [], r = []) {
1054
- Qn(e, r, (n) => {
1055
- he(Er, () => t(...n.map(g)), !0);
1056
- });
1057
- }
1058
- function hi(t, e = 0) {
1059
- var r = he(Le | e, t, !0);
1060
- return r;
1061
- }
1062
- function pe(t, e = !0) {
1063
- return he(fe | Fe, t, !0, e);
1064
- }
1065
- function zr(t) {
1066
- var e = t.teardown;
1067
- if (e !== null) {
1068
- const r = Oe, n = v;
1069
- cr(!0), I(null);
1070
- try {
1071
- e.call(null);
1072
- } finally {
1073
- cr(r), I(n);
1074
- }
1075
- }
1076
- }
1077
- function Br(t, e = !1) {
1078
- var r = t.first;
1079
- for (t.first = t.last = null; r !== null; ) {
1080
- const i = r.ac;
1081
- i !== null && Rr(() => {
1082
- i.abort(Nt);
1083
- });
1084
- var n = r.next;
1085
- (r.f & ge) !== 0 ? r.parent = null : ee(r, e), r = n;
1086
- }
1087
- }
1088
- function pi(t) {
1089
- for (var e = t.first; e !== null; ) {
1090
- var r = e.next;
1091
- (e.f & fe) === 0 && ee(e), e = r;
1092
- }
1093
- }
1094
- function ee(t, e = !0) {
1095
- var r = !1;
1096
- (e || (t.f & Cn) !== 0) && t.nodes_start !== null && t.nodes_end !== null && (di(
1097
- t.nodes_start,
1098
- /** @type {TemplateNode} */
1099
- t.nodes_end
1100
- ), r = !0), Br(t, e && !r), at(t, 0), H(t, Ie);
1101
- var n = t.transitions;
1102
- if (n !== null)
1103
- for (const s of n)
1104
- s.stop();
1105
- zr(t);
1106
- var i = t.parent;
1107
- i !== null && i.first !== null && Ur(t), t.next = t.prev = t.teardown = t.ctx = t.deps = t.fn = t.nodes_start = t.nodes_end = t.ac = null;
1108
- }
1109
- function di(t, e) {
1110
- for (; t !== null; ) {
1111
- var r = t === e ? null : (
1112
- /** @type {TemplateNode} */
1113
- /* @__PURE__ */ Zt(t)
1114
- );
1115
- t.remove(), t = r;
1116
- }
1117
- }
1118
- function Ur(t) {
1119
- var e = t.parent, r = t.prev, n = t.next;
1120
- r !== null && (r.next = n), n !== null && (n.prev = r), e !== null && (e.first === t && (e.first = n), e.last === t && (e.last = r));
1121
- }
1122
- function nt(t, e) {
1123
- var r = [];
1124
- Zr(t, r, !0), vi(r, () => {
1125
- ee(t), e && e();
1126
- });
1127
- }
1128
- function vi(t, e) {
1129
- var r = t.length;
1130
- if (r > 0) {
1131
- var n = () => --r || e();
1132
- for (var i of t)
1133
- i.out(n);
1134
- } else
1135
- e();
1136
- }
1137
- function Zr(t, e, r) {
1138
- if ((t.f & Ae) === 0) {
1139
- if (t.f ^= Ae, t.transitions !== null)
1140
- for (const o of t.transitions)
1141
- (o.is_global || r) && e.push(o);
1142
- for (var n = t.first; n !== null; ) {
1143
- var i = n.next, s = (n.f & kr) !== 0 || (n.f & fe) !== 0;
1144
- Zr(n, e, s ? r : !1), n = i;
1145
- }
1146
- }
1147
- }
1148
- let Pe = !1;
1149
- function fr(t) {
1150
- Pe = t;
1151
- }
1152
- let Oe = !1;
1153
- function cr(t) {
1154
- Oe = t;
1155
- }
1156
- let v = null, G = !1;
1157
- function I(t) {
1158
- v = t;
1159
- }
1160
- let m = null;
1161
- function ne(t) {
1162
- m = t;
1163
- }
1164
- let se = null;
1165
- function mi(t) {
1166
- v !== null && (se === null ? se = [t] : se.push(t));
1167
- }
1168
- let C = null, O = 0, j = null;
1169
- function yi(t) {
1170
- j = t;
1171
- }
1172
- let qr = 1, Ge = 0, me = Ge;
1173
- function hr(t) {
1174
- me = t;
1175
- }
1176
- let le = !1;
1177
- function Hr() {
1178
- return ++qr;
1179
- }
1180
- function ct(t) {
1181
- var e = t.f;
1182
- if ((e & re) !== 0)
1183
- return !0;
1184
- if ((e & ce) !== 0) {
1185
- var r = t.deps, n = (e & q) !== 0;
1186
- if (r !== null) {
1187
- var i, s, o = (e & st) !== 0, l = n && m !== null && !le, a = r.length;
1188
- if ((o || l) && (m === null || (m.f & Ie) === 0)) {
1189
- var u = (
1190
- /** @type {Derived} */
1191
- t
1192
- ), f = u.parent;
1193
- for (i = 0; i < a; i++)
1194
- s = r[i], (o || !s?.reactions?.includes(u)) && (s.reactions ??= []).push(u);
1195
- o && (u.f ^= st), l && f !== null && (f.f & q) === 0 && (u.f ^= q);
1196
- }
1197
- for (i = 0; i < a; i++)
1198
- if (s = r[i], ct(
1199
- /** @type {Derived} */
1200
- s
1201
- ) && Cr(
1202
- /** @type {Derived} */
1203
- s
1204
- ), s.wv > t.wv)
1205
- return !0;
1206
- }
1207
- (!n || m !== null && !le) && H(t, L);
1208
- }
1209
- return !1;
1210
- }
1211
- function Yr(t, e, r = !0) {
1212
- var n = t.reactions;
1213
- if (n !== null && !se?.includes(t))
1214
- for (var i = 0; i < n.length; i++) {
1215
- var s = n[i];
1216
- (s.f & R) !== 0 ? Yr(
1217
- /** @type {Derived} */
1218
- s,
1219
- e,
1220
- !1
1221
- ) : e === s && (r ? H(s, re) : (s.f & L) !== 0 && H(s, ce), We(
1222
- /** @type {Effect} */
1223
- s
1224
- ));
1225
- }
1226
- }
1227
- function Vr(t) {
1228
- var e = C, r = O, n = j, i = v, s = le, o = se, l = Y, a = G, u = me, f = t.f;
1229
- C = /** @type {null | Value[]} */
1230
- null, O = 0, j = null, le = (f & q) !== 0 && (G || !Pe || v === null), v = (f & (fe | ge)) === 0 ? t : null, se = null, De(t.ctx), G = !1, me = ++Ge, t.ac !== null && (Rr(() => {
1231
- t.ac.abort(Nt);
1232
- }), t.ac = null);
1233
- try {
1234
- t.f |= xt;
1235
- var p = (
1236
- /** @type {Function} */
1237
- t.fn
1238
- ), h = p(), c = t.deps;
1239
- if (C !== null) {
1240
- var d;
1241
- if (at(t, O), c !== null && O > 0)
1242
- for (c.length = O + C.length, d = 0; d < C.length; d++)
1243
- c[O + d] = C[d];
1244
- else
1245
- t.deps = c = C;
1246
- if (!le || // Deriveds that already have reactions can cleanup, so we still add them as reactions
1247
- (f & R) !== 0 && /** @type {import('#client').Derived} */
1248
- t.reactions !== null)
1249
- for (d = O; d < c.length; d++)
1250
- (c[d].reactions ??= []).push(t);
1251
- } else c !== null && O < c.length && (at(t, O), c.length = O);
1252
- if (xr() && j !== null && !G && c !== null && (t.f & (R | ce | re)) === 0)
1253
- for (d = 0; d < /** @type {Source[]} */
1254
- j.length; d++)
1255
- Yr(
1256
- j[d],
1257
- /** @type {Effect} */
1258
- t
1259
- );
1260
- return i !== null && i !== t && (Ge++, j !== null && (n === null ? n = j : n.push(.../** @type {Source[]} */
1261
- j))), (t.f & ve) !== 0 && (t.f ^= ve), h;
1262
- } catch (w) {
1263
- return Pr(w);
1264
- } finally {
1265
- t.f ^= xt, C = e, O = r, j = n, v = i, le = s, se = o, De(l), G = a, me = u;
1266
- }
1267
- }
1268
- function gi(t, e) {
1269
- let r = e.reactions;
1270
- if (r !== null) {
1271
- var n = kn.call(r, t);
1272
- if (n !== -1) {
1273
- var i = r.length - 1;
1274
- i === 0 ? r = e.reactions = null : (r[n] = r[i], r.pop());
1275
- }
1276
- }
1277
- r === null && (e.f & R) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
1278
- // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
1279
- // allows us to skip the expensive work of disconnecting and immediately reconnecting it
1280
- (C === null || !C.includes(e)) && (H(e, ce), (e.f & (q | st)) === 0 && (e.f ^= st), Dr(
1281
- /** @type {Derived} **/
1282
- e
1283
- ), at(
1284
- /** @type {Derived} **/
1285
- e,
1286
- 0
1287
- ));
1288
- }
1289
- function at(t, e) {
1290
- var r = t.deps;
1291
- if (r !== null)
1292
- for (var n = e; n < r.length; n++)
1293
- gi(t, r[n]);
1294
- }
1295
- function Se(t) {
1296
- var e = t.f;
1297
- if ((e & Ie) === 0) {
1298
- H(t, L);
1299
- var r = m, n = Pe;
1300
- m = t, Pe = !0;
1301
- try {
1302
- (e & Le) !== 0 ? pi(t) : Br(t), zr(t);
1303
- var i = Vr(t);
1304
- t.teardown = typeof i == "function" ? i : null, t.wv = qr;
1305
- var s;
1306
- } finally {
1307
- Pe = n, m = r;
1308
- }
1309
- }
1310
- }
1311
- function g(t) {
1312
- var e = t.f, r = (e & R) !== 0;
1313
- if (v !== null && !G) {
1314
- var n = m !== null && (m.f & Ie) !== 0;
1315
- if (!n && !se?.includes(t)) {
1316
- var i = v.deps;
1317
- if ((v.f & xt) !== 0)
1318
- t.rv < Ge && (t.rv = Ge, C === null && i !== null && i[O] === t ? O++ : C === null ? C = [t] : (!le || !C.includes(t)) && C.push(t));
1319
- else {
1320
- (v.deps ??= []).push(t);
1321
- var s = t.reactions;
1322
- s === null ? t.reactions = [v] : s.includes(v) || s.push(v);
1323
- }
1324
- }
1325
- } else if (r && /** @type {Derived} */
1326
- t.deps === null && /** @type {Derived} */
1327
- t.effects === null) {
1328
- var o = (
1329
- /** @type {Derived} */
1330
- t
1331
- ), l = o.parent;
1332
- l !== null && (l.f & q) === 0 && (o.f ^= q);
1333
- }
1334
- if (Oe) {
1335
- if (ue.has(t))
1336
- return ue.get(t);
1337
- if (r) {
1338
- o = /** @type {Derived} */
1339
- t;
1340
- var a = o.v;
1341
- return ((o.f & L) === 0 && o.reactions !== null || Xr(o)) && (a = Ut(o)), ue.set(o, a), a;
1342
- }
1343
- } else r && (o = /** @type {Derived} */
1344
- t, ct(o) && Cr(o));
1345
- if ((t.f & ve) !== 0)
1346
- throw t.v;
1347
- return t.v;
1348
- }
1349
- function Xr(t) {
1350
- if (t.v === x) return !0;
1351
- if (t.deps === null) return !1;
1352
- for (const e of t.deps)
1353
- if (ue.has(e) || (e.f & R) !== 0 && Xr(
1354
- /** @type {Derived} */
1355
- e
1356
- ))
1357
- return !0;
1358
- return !1;
1359
- }
1360
- function Wr(t) {
1361
- var e = G;
1362
- try {
1363
- return G = !0, t();
1364
- } finally {
1365
- G = e;
1366
- }
1367
- }
1368
- const _i = -7169;
1369
- function H(t, e) {
1370
- t.f = t.f & _i | e;
1371
- }
1372
- const wi = ["touchstart", "touchmove"];
1373
- function bi(t) {
1374
- return wi.includes(t);
1375
- }
1376
- const Ei = /* @__PURE__ */ new Set(), pr = /* @__PURE__ */ new Set();
1377
- let dr = null;
1378
- function et(t) {
1379
- var e = this, r = (
1380
- /** @type {Node} */
1381
- e.ownerDocument
1382
- ), n = t.type, i = t.composedPath?.() || [], s = (
1383
- /** @type {null | Element} */
1384
- i[0] || t.target
1385
- );
1386
- dr = t;
1387
- var o = 0, l = dr === t && t.__root;
1388
- if (l) {
1389
- var a = i.indexOf(l);
1390
- if (a !== -1 && (e === document || e === /** @type {any} */
1391
- window)) {
1392
- t.__root = e;
1393
- return;
1394
- }
1395
- var u = i.indexOf(e);
1396
- if (u === -1)
1397
- return;
1398
- a <= u && (o = a);
1399
- }
1400
- if (s = /** @type {Element} */
1401
- i[o] || t.target, s !== e) {
1402
- Mt(t, "currentTarget", {
1403
- configurable: !0,
1404
- get() {
1405
- return s || r;
1406
- }
1407
- });
1408
- var f = v, p = m;
1409
- I(null), ne(null);
1410
- try {
1411
- for (var h, c = []; s !== null; ) {
1412
- var d = s.assignedSlot || s.parentNode || /** @type {any} */
1413
- s.host || null;
1414
- try {
1415
- var w = s["__" + n];
1416
- if (w != null && (!/** @type {any} */
1417
- s.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
1418
- // -> the target could not have been disabled because it emits the event in the first place
1419
- t.target === s))
1420
- if (br(w)) {
1421
- var [F, ...K] = w;
1422
- F.apply(s, [t, ...K]);
1423
- } else
1424
- w.call(s, t);
1425
- } catch (k) {
1426
- h ? c.push(k) : h = k;
1427
- }
1428
- if (t.cancelBubble || d === e || d === null)
1429
- break;
1430
- s = d;
1431
- }
1432
- if (h) {
1433
- for (let k of c)
1434
- queueMicrotask(() => {
1435
- throw k;
1436
- });
1437
- throw h;
1438
- }
1439
- } finally {
1440
- t.__root = e, delete t.currentTarget, I(f), ne(p);
1441
- }
1442
- }
1443
- }
1444
- function ki(t) {
1445
- var e = document.createElement("template");
1446
- return e.innerHTML = t.replaceAll("<!>", "<!---->"), e.content;
1447
- }
1448
- function Mi(t, e) {
1449
- var r = (
1450
- /** @type {Effect} */
1451
- m
1452
- );
1453
- r.nodes_start === null && (r.nodes_start = t, r.nodes_end = e);
1454
- }
1455
- // @__NO_SIDE_EFFECTS__
1456
- function Gr(t, e) {
1457
- var r = (e & Un) !== 0, n, i = !t.startsWith("<!>");
1458
- return () => {
1459
- n === void 0 && (n = ki(i ? t : "<!>" + t), n = /** @type {Node} */
1460
- /* @__PURE__ */ Or(n));
1461
- var s = (
1462
- /** @type {TemplateNode} */
1463
- r || Lr ? document.importNode(n, !0) : n.cloneNode(!0)
1464
- );
1465
- return Mi(s, s), s;
1466
- };
1467
- }
1468
- function Kr(t, e) {
1469
- t !== null && t.before(
1470
- /** @type {Node} */
1471
- e
1472
- );
1473
- }
1474
- function Ht(t, e) {
1475
- return xi(t, e);
1476
- }
1477
- const ke = /* @__PURE__ */ new Map();
1478
- function xi(t, { target: e, anchor: r, props: n = {}, events: i, context: s, intro: o = !0 }) {
1479
- ni();
1480
- var l = /* @__PURE__ */ new Set(), a = (p) => {
1481
- for (var h = 0; h < p.length; h++) {
1482
- var c = p[h];
1483
- if (!l.has(c)) {
1484
- l.add(c);
1485
- var d = bi(c);
1486
- e.addEventListener(c, et, { passive: d });
1487
- var w = ke.get(c);
1488
- w === void 0 ? (document.addEventListener(c, et, { passive: d }), ke.set(c, 1)) : ke.set(c, w + 1);
1489
- }
1490
- }
1491
- };
1492
- a(Mn(Ei)), pr.add(a);
1493
- var u = void 0, f = ui(() => {
1494
- var p = r ?? e.appendChild(ii());
1495
- return Gn(
1496
- /** @type {TemplateNode} */
1497
- p,
1498
- {
1499
- pending: () => {
1500
- }
1501
- },
1502
- (h) => {
1503
- if (s) {
1504
- jt({});
1505
- var c = (
1506
- /** @type {ComponentContext} */
1507
- Y
1508
- );
1509
- c.c = s;
1510
- }
1511
- i && (n.$$events = i), u = t(h, n) || {}, s && zt();
1512
- }
1513
- ), () => {
1514
- for (var h of l) {
1515
- e.removeEventListener(h, et);
1516
- var c = (
1517
- /** @type {number} */
1518
- ke.get(h)
1519
- );
1520
- --c === 0 ? (document.removeEventListener(h, et), ke.delete(h)) : ke.set(h, c);
1521
- }
1522
- pr.delete(a), p !== r && p.parentNode?.removeChild(p);
1523
- };
1524
- });
1525
- return Pi.set(u, f), u;
1526
- }
1527
- let Pi = /* @__PURE__ */ new WeakMap();
1528
- function Jr(t) {
1529
- var e, r, n = "";
1530
- if (typeof t == "string" || typeof t == "number") n += t;
1531
- else if (typeof t == "object") if (Array.isArray(t)) {
1532
- var i = t.length;
1533
- for (e = 0; e < i; e++) t[e] && (r = Jr(t[e])) && (n && (n += " "), n += r);
1534
- } else for (r in t) t[r] && (n && (n += " "), n += r);
1535
- return n;
1536
- }
1537
- function Si() {
1538
- for (var t, e, r = 0, n = "", i = arguments.length; r < i; r++) (t = arguments[r]) && (e = Jr(t)) && (n && (n += " "), n += e);
1539
- return n;
1540
- }
1541
- function Qr(t) {
1542
- return typeof t == "object" ? Si(t) : t ?? "";
1543
- }
1544
- function Ai(t, e, r) {
1545
- var n = t == null ? "" : "" + t;
1546
- return e && (n = n ? n + " " + e : e), n === "" ? null : n;
1547
- }
1548
- function vr(t, e = !1) {
1549
- var r = e ? " !important;" : ";", n = "";
1550
- for (var i in t) {
1551
- var s = t[i];
1552
- s != null && s !== "" && (n += " " + i + ": " + s + r);
1553
- }
1554
- return n;
1555
- }
1556
- function Di(t, e) {
1557
- if (e) {
1558
- var r = "", n, i;
1559
- return Array.isArray(e) ? (n = e[0], i = e[1]) : n = e, n && (r += vr(n)), i && (r += vr(i, !0)), r = r.trim(), r === "" ? null : r;
1560
- }
1561
- return String(t);
1562
- }
1563
- function $r(t, e, r, n, i, s) {
1564
- var o = t.__className;
1565
- if (o !== r || o === void 0) {
1566
- var l = Ai(r, n);
1567
- l == null ? t.removeAttribute("class") : t.className = l, t.__className = r;
1568
- }
1569
- return s;
1570
- }
1571
- function bt(t, e = {}, r, n) {
1572
- for (var i in r) {
1573
- var s = r[i];
1574
- e[i] !== s && (r[i] == null ? t.style.removeProperty(i) : t.style.setProperty(i, s, n));
1575
- }
1576
- }
1577
- function ze(t, e, r, n) {
1578
- var i = t.__style;
1579
- if (i !== e) {
1580
- var s = Di(e, n);
1581
- s == null ? t.removeAttribute("style") : t.style.cssText = s, t.__style = e;
1582
- } else n && (Array.isArray(n) ? (bt(t, r?.[0], n[0]), bt(t, r?.[1], n[1], "important")) : bt(t, r, n));
1583
- return n;
1584
- }
1585
- const Ci = () => performance.now(), Q = {
1586
- // don't access requestAnimationFrame eagerly outside method
1587
- // this allows basic testing of user code without JSDOM
1588
- // bunder will eval and remove ternary when the user's app is built
1589
- tick: (
1590
- /** @param {any} _ */
1591
- (t) => requestAnimationFrame(t)
1592
- ),
1593
- now: () => Ci(),
1594
- tasks: /* @__PURE__ */ new Set()
1595
- };
1596
- function en() {
1597
- const t = Q.now();
1598
- Q.tasks.forEach((e) => {
1599
- e.c(t) || (Q.tasks.delete(e), e.f());
1600
- }), Q.tasks.size !== 0 && Q.tick(en);
1601
- }
1602
- function Ti(t) {
1603
- let e;
1604
- return Q.tasks.size === 0 && Q.tick(en), {
1605
- promise: new Promise((r) => {
1606
- Q.tasks.add(e = { c: t, f: r });
1607
- }),
1608
- abort() {
1609
- Q.tasks.delete(e);
1610
- }
1611
- };
1612
- }
1613
- function mr(t, e) {
1614
- return t === e || t?.[rt] === e;
1615
- }
1616
- function Be(t = {}, e, r, n) {
1617
- return fi(() => {
1618
- var i, s;
1619
- return qt(() => {
1620
- i = s, s = [], Wr(() => {
1621
- t !== r(...s) && (e(t, ...s), i && mr(r(...i), t) && e(null, ...i));
1622
- });
1623
- }), () => {
1624
- ut(() => {
1625
- s && mr(r(...s), t) && e(null, ...s);
1626
- });
1627
- };
1628
- }), t;
1629
- }
1630
- const Li = "5";
1631
- typeof window < "u" && ((window.__svelte ??= {}).v ??= /* @__PURE__ */ new Set()).add(Li);
1632
- function Ii(t) {
1633
- return t;
1634
- }
1635
- function At(t) {
1636
- return -0.5 * (Math.cos(Math.PI * t) - 1);
1637
- }
1638
- function Fi(t) {
1639
- const e = Math.cos(t * Math.PI * 0.5);
1640
- return Math.abs(e) < 1e-14 ? 1 : 1 - e;
1641
- }
1642
- function Oi(t) {
1643
- return Math.sin(t * Math.PI / 2);
1644
- }
1645
- const Ri = 128, Ni = 0, ji = 1, zi = 2;
1646
- class Bi {
1647
- animationsStarted = !1;
1648
- animationsCount = 0;
1649
- animationsLimit = Ri;
1650
- layers = new Array();
1651
- start() {
1652
- window.requestAnimationFrame(this.tick.bind(this));
1653
- }
1654
- tick() {
1655
- try {
1656
- this.animationsCount = 0;
1657
- for (let e = 0; e < this.layers.length; e++) {
1658
- const r = this.layers[e];
1659
- if (r == null) continue;
1660
- const n = r.animations;
1661
- if (n != null)
1662
- for (let i = 0; i < n.length; i++) {
1663
- const s = n[i];
1664
- if (s != null) {
1665
- for (const o of s.values())
1666
- if (!o.executed && (o.executed = !0, o.function(), this.animationsCount++, this.animationsCount == this.animationsLimit))
1667
- return;
1668
- }
1669
- }
1670
- }
1671
- } catch {
1672
- } finally {
1673
- window.requestAnimationFrame(this.tick.bind(this));
1674
- }
1675
- }
1676
- equeue(e, r, n, i) {
1677
- let s = this.layers[e];
1678
- s == null && (s = this.layers[e] = { animations: new Array() });
1679
- let o = s.animations[r];
1680
- o == null && (o = s.animations[r] = /* @__PURE__ */ new Map());
1681
- let l = { id: n, priority: r, executed: !1, function: i };
1682
- o.set(n, l), this.animationsStarted == !1 && (this.animationsStarted = !0, this.start());
1683
- }
1684
- clear(e, r) {
1685
- for (let n = 0; n < this.layers.length; n++) {
1686
- let i = this.layers[n];
1687
- if (i == null) continue;
1688
- let s = i.animations[e];
1689
- if (s == null) return;
1690
- let o = s.get(r);
1691
- if (o == null || o.executed == !1) return;
1692
- s.delete(r);
1693
- }
1694
- }
1695
- speed() {
1696
- return Math.pow(2, 2 * this.animationsCount / this.animationsLimit);
1697
- }
1698
- stacked() {
1699
- return this.animationsCount == this.animationsLimit;
1700
- }
1701
- setLimit(e) {
1702
- this.animationsLimit = e;
1703
- }
1704
- }
1705
- const ae = new Bi();
1706
- function yr(t) {
1707
- return Object.prototype.toString.call(t) === "[object Date]";
1708
- }
1709
- function Dt(t, e) {
1710
- if (t === e || t !== t) return () => t;
1711
- const r = typeof t;
1712
- if (r !== typeof e || Array.isArray(t) !== Array.isArray(e))
1713
- throw new Error("Cannot interpolate values of different type");
1714
- if (Array.isArray(t)) {
1715
- const n = (
1716
- /** @type {Array<any>} */
1717
- e.map((i, s) => Dt(
1718
- /** @type {Array<any>} */
1719
- t[s],
1720
- i
1721
- ))
1722
- );
1723
- return (i) => n.map((s) => s(i));
1724
- }
1725
- if (r === "object") {
1726
- if (!t || !e)
1727
- throw new Error("Object cannot be null");
1728
- if (yr(t) && yr(e)) {
1729
- const s = t.getTime(), l = e.getTime() - s;
1730
- return (a) => new Date(s + a * l);
1731
- }
1732
- const n = Object.keys(e), i = {};
1733
- return n.forEach((s) => {
1734
- i[s] = Dt(t[s], e[s]);
1735
- }), (s) => {
1736
- const o = {};
1737
- return n.forEach((l) => {
1738
- o[l] = i[l](s);
1739
- }), o;
1740
- };
1741
- }
1742
- if (r === "number") {
1743
- const n = (
1744
- /** @type {number} */
1745
- e - /** @type {number} */
1746
- t
1747
- );
1748
- return (i) => t + i * n;
1749
- }
1750
- return () => e;
1751
- }
1752
- class Yt {
1753
- #e;
1754
- #t;
1755
- /** @type {TweenedOptions<T>} */
1756
- #a;
1757
- /** @type {import('../internal/client/types').Task | null} */
1758
- #n = null;
1759
- /**
1760
- * @param {T} value
1761
- * @param {TweenedOptions<T>} options
1762
- */
1763
- constructor(e, r = {}) {
1764
- this.#e = /* @__PURE__ */ D(e), this.#t = /* @__PURE__ */ D(e), this.#a = r;
1765
- }
1766
- /**
1767
- * Create a tween whose value is bound to the return value of `fn`. This must be called
1768
- * inside an effect root (for example, during component initialisation).
1769
- *
1770
- * ```svelte
1771
- * <script>
1772
- * import { Tween } from 'svelte/motion';
1773
- *
1774
- * let { number } = $props();
1775
- *
1776
- * const tween = Tween.of(() => number);
1777
- * <\/script>
1778
- * ```
1779
- * @template U
1780
- * @param {() => U} fn
1781
- * @param {TweenedOptions<U>} [options]
1782
- */
1783
- static of(e, r) {
1784
- const n = new Yt(e(), r);
1785
- return qt(() => {
1786
- n.set(e());
1787
- }), n;
1788
- }
1789
- /**
1790
- * Sets `tween.target` to `value` and returns a `Promise` that resolves if and when `tween.current` catches up to it.
1791
- *
1792
- * If `options` are provided, they will override the tween's defaults.
1793
- * @param {T} value
1794
- * @param {TweenedOptions<T>} [options]
1795
- * @returns
1796
- */
1797
- set(e, r) {
1798
- P(this.#t, e);
1799
- let {
1800
- delay: n = 0,
1801
- duration: i = 400,
1802
- easing: s = Ii,
1803
- interpolate: o = Dt
1804
- } = { ...this.#a, ...r };
1805
- if (i === 0)
1806
- return this.#n?.abort(), P(this.#e, e), Promise.resolve();
1807
- const l = Q.now() + n;
1808
- let a, u = !1, f = this.#n;
1809
- return this.#n = Ti((p) => {
1810
- if (p < l)
1811
- return !0;
1812
- if (!u) {
1813
- u = !0;
1814
- const c = this.#e.v;
1815
- a = o(c, e), typeof i == "function" && (i = i(c, e)), f?.abort();
1816
- }
1817
- const h = p - l;
1818
- return h > /** @type {number} */
1819
- i ? (P(this.#e, e), !1) : (P(this.#e, a(s(h / /** @type {number} */
1820
- i))), !0);
1821
- }), this.#n.promise;
1822
- }
1823
- get current() {
1824
- return g(this.#e);
1825
- }
1826
- get target() {
1827
- return g(this.#t);
1828
- }
1829
- set target(e) {
1830
- this.set(e);
1831
- }
1832
- }
1833
- class it {
1834
- value;
1835
- motion;
1836
- constructor(e, r) {
1837
- this.value = e, this.motion = new Yt(e, r);
1838
- }
1839
- set(e, r) {
1840
- this.value = e, this.motion.set(e, r);
1841
- }
1842
- update(e) {
1843
- this.motion.set(this.value, e);
1844
- }
1845
- snap() {
1846
- this.motion.set(this.value, { duration: 0 });
1847
- }
1848
- }
1849
- var Ui = /* @__PURE__ */ Gr("<div></div>");
1850
- function Zi(t, e) {
1851
- jt(e, !0);
1852
- let r = e.style.width, n = e.style.height, i = e.style.radius, s = e.colors?.background ?? "darkgreen", o = e.colors?.border ?? "white", l = e.colors?.shadow ?? "0px 2px 2px rgba(0, 0, 0, 0.5)", a;
1853
- function u() {
1854
- return a;
1855
- }
1856
- let f = /* @__PURE__ */ D(!1);
1857
- function p(b) {
1858
- P(f, b, !0);
1859
- }
1860
- function h() {
1861
- return g(f);
1862
- }
1863
- let c = /* @__PURE__ */ D(!0), d = 0, w = 150;
1864
- function F(b) {
1865
- b != g(c) && (P(c, b, !0), d = performance.now());
1866
- }
1867
- function K() {
1868
- return performance.now() - d < w ? V.motion.current == 0 : V.value == 0;
1869
- }
1870
- let k = 0, V = new it(0, { easing: At });
1871
- J(() => {
1872
- g(f) == !1 && (V.snap(), ae.clear(e.priority, e.id));
1873
- }), J(() => {
1874
- V.set(g(c) ? 0 : k, { duration: 75 });
1875
- }), J(() => {
1876
- Je(V.motion.current);
1877
- });
1878
- function Je(b) {
1879
- a && ae.equeue(e.layer, e.priority, e.id, () => {
1880
- a.style.scale = b.toString(), a.style.filter = `brightness(${0.25 + 0.75 * b})`;
1881
- });
1882
- }
1883
- function pt(b) {
1884
- b != k && (k = b, V.set(b, { duration: 75 }));
1885
- }
1886
- function dt() {
1887
- return V.value;
1888
- }
1889
- var vt = {
1890
- getBody: u,
1891
- setDisplayed: p,
1892
- getDisplayed: h,
1893
- setCollapsed: F,
1894
- getCollapsed: K,
1895
- setScale: pt,
1896
- getScale: dt
1897
- }, M = Ui();
1898
- let Qe;
1899
- return Be(
1900
- M,
1901
- (b) => (
1902
- //#endregion
1903
- a = b
1904
- ),
1905
- () => a
1906
- ), jr(
1907
- (b) => {
1908
- $r(M, 1, Qr(["pin", g(f) && "displayed"]), "svelte-zz3jrb"), Qe = ze(M, "", Qe, b);
1909
- },
1910
- [
1911
- () => ({
1912
- width: `${r}px`,
1913
- height: `${n}px`,
1914
- "border-radius": `${i}px`,
1915
- "border-color": o,
1916
- "background-color": s,
1917
- "box-shadow": l
1918
- })
1919
- ]
1920
- ), Kr(t, M), zt(vt);
1921
- }
1922
- var qe;
1923
- ((t) => {
1924
- function e(r, n, i) {
1925
- const s = r / 2, o = n / 2, l = Math.sqrt(s * s + o * o), a = Math.atan(o / s) * (180 / Math.PI), u = i * (Math.PI / 180);
1926
- return i < 180 ? i < 90 ? i < a ? {
1927
- x: 0,
1928
- y: l * Math.sin(u) - o
1929
- } : {
1930
- x: l * Math.cos(u) - s,
1931
- y: 0
1932
- } : i < 180 - a ? {
1933
- x: l * Math.cos(u) - s,
1934
- y: 0
1935
- } : {
1936
- x: -r,
1937
- y: l * Math.sin(u) - o
1938
- } : i < 270 ? i < 180 + a ? {
1939
- x: -r,
1940
- y: l * Math.sin(u) - o
1941
- } : {
1942
- x: l * Math.cos(u) - s,
1943
- y: -n
1944
- } : i < 360 - a ? {
1945
- x: l * Math.cos(u) - s,
1946
- y: -n
1947
- } : {
1948
- x: 0,
1949
- y: l * Math.sin(u) - o
1950
- };
1951
- }
1952
- t.getOffsets = e;
1953
- })(qe || (qe = {}));
1954
- var qi = /* @__PURE__ */ Gr('<div><div class="pointer svelte-11extwn"></div> <div class="bubble svelte-11extwn"><div class="body svelte-11extwn"></div></div></div>');
1955
- function tn(t, e) {
1956
- jt(e, !0);
1957
- let r = e.style.width, n = e.style.height, i = e.style.margin, s = e.style.radius, o = e.colors?.background ?? "white", l = e.colors?.shadow ?? "0px 2px 2px rgba(0, 0, 0, 0.5)", a, u, f, p;
1958
- const h = r + 2 * i, c = n + 2 * i, d = () => p;
1959
- J(() => {
1960
- f.style.width = `${i * 4}px`, f.style.height = `${i * 4}px`;
1961
- });
1962
- let w = /* @__PURE__ */ D(!0);
1963
- function F(y) {
1964
- P(w, y, !0);
1965
- }
1966
- function K() {
1967
- return g(w);
1968
- }
1969
- let k = /* @__PURE__ */ D(!0), V = 0, Je = 300;
1970
- function pt(y) {
1971
- y != g(k) && (P(k, y, !0), V = performance.now());
1972
- }
1973
- function dt() {
1974
- return performance.now() - V < Je ? M.motion.current == 0 : M.value == 0;
1975
- }
1976
- function vt() {
1977
- return performance.now() - V < Je ? M.motion.current == 1 : M.value == 1;
1978
- }
1979
- let M = new it(0);
1980
- J(() => {
1981
- g(w) == !1 && (M.snap(), ae.clear(e.priority, e.id + "_scale"));
1982
- }), J(() => {
1983
- g(k) == !0 && M.value != 0 && (ae.stacked() ? M.set(0, { duration: 0 }) : M.set(0, { duration: 150, easing: Fi })), g(k) == !1 && M.value != 1 && M.set(1, { duration: 150, easing: Oi });
1984
- }), J(() => {
1985
- Qe(M.motion.current);
1986
- });
1987
- function Qe(y) {
1988
- !a || !u || !f || ae.equeue(g(k) ? 0 : e.layer, e.priority, e.id + "_scale", () => {
1989
- a.style.opacity = `${y}`, u.style.scale = `${y}`, f.style.scale = `${y}`;
1990
- });
1991
- }
1992
- let b = NaN, mt = /* @__PURE__ */ D(!1), oe = new it(-h / 2, { easing: At }), $e = new it(-c / 2, { easing: At });
1993
- J(() => {
1994
- g(w) == !1 && (oe.snap(), oe.snap(), ae.clear(e.priority, e.id + "_angle"));
1995
- }), J(() => {
1996
- g(k) == !0 && g(mt) && (oe.update({ duration: 75 }), oe.update({ duration: 75 }));
1997
- }), J(() => {
1998
- Jt(oe.motion.current, $e.motion.current);
1999
- });
2000
- function Jt(y, _e) {
2001
- if (!a || !u || !f) return;
2002
- const X = y + h / 2, we = _e + c / 2, be = c < h ? X * c / h : X, Ee = c > h ? we * h / c : we, gn = Math.atan2(Ee, be) / Math.PI * 180 - 45, nr = 0, _n = 30, _t = Math.sqrt(be * be + Ee * Ee), Ne = Math.min(h, c) / 2, wn = Ne * Math.SQRT2, bn = (_t - Ne) / (wn - Ne), ir = nr + bn * (_n - nr), En = _t < Ne ? _t / Ne : 1;
2003
- ae.equeue(e.layer, e.priority, e.id + "_angle", () => {
2004
- u.style.transform = `translate(${Math.round(y)}px, ${Math.round(_e)}px)`, f.style.transform = `scale(${En}) rotate(${gn}deg) skew(${ir}deg, ${ir}deg)`;
2005
- });
2006
- }
2007
- function vn(y, _e) {
2008
- if (g(mt) == !1 || _e == !0) {
2009
- let X = qe.getOffsets(h, c, y);
2010
- oe.set(Math.round(X.x), { duration: 0 }), $e.set(Math.round(X.y), { duration: 0 }), Jt(oe.value, $e.value), b = y, P(mt, !0);
2011
- } else if (y != b) {
2012
- let X = Math.abs(y - b), we = X < 180 ? X : 360 - X, be = Math.log(we) * 75, Ee = qe.getOffsets(h, c, y);
2013
- oe.set(Math.round(Ee.x), { duration: be }), $e.set(Math.round(Ee.y), { duration: be }), b = y;
2014
- }
2015
- }
2016
- function mn() {
2017
- return qe.getOffsets(h, c, b);
2018
- }
2019
- var yn = {
2020
- getBody: d,
2021
- setDisplayed: F,
2022
- getDisplayed: K,
2023
- setCollapsed: pt,
2024
- getCollapsed: dt,
2025
- getExpanded: vt,
2026
- setAngle: vn,
2027
- getOffsets: mn
2028
- }, Re = qi();
2029
- let Qt;
2030
- var yt = ur(Re);
2031
- let $t;
2032
- Be(
2033
- yt,
2034
- (y) => (
2035
- //#endregion
2036
- f = y
2037
- ),
2038
- () => f
2039
- );
2040
- var gt = si(yt, 2);
2041
- let er;
2042
- var tr = ur(gt);
2043
- let rr;
2044
- return Be(tr, (y) => p = y, () => p), Be(gt, (y) => u = y, () => u), Be(Re, (y) => a = y, () => a), jr(
2045
- (y, _e, X, we) => {
2046
- $r(Re, 1, Qr(["anchor", g(w) && "displayed"]), "svelte-11extwn"), Qt = ze(Re, "", Qt, y), $t = ze(yt, "", $t, _e), er = ze(gt, "", er, X), rr = ze(tr, "", rr, we);
2047
- },
2048
- [
2049
- () => ({ filter: `drop-shadow(${l})` }),
2050
- () => ({ "background-color": o }),
2051
- () => ({ margin: `${i}px;` }),
2052
- () => ({
2053
- width: `${r}px`,
2054
- height: `${n}px`,
2055
- "border-radius": `${s}px;`,
2056
- "background-color": o
2057
- })
2058
- ]
2059
- ), Kr(t, Re), zt(yn);
2060
- }
2061
- var He;
2062
- ((t) => {
2063
- async function e(n, i) {
2064
- const s = await fetch(n, i);
2065
- if (!s.ok) throw new Error(s.statusText);
2066
- return s.json();
2067
- }
2068
- t.get = e;
2069
- async function r(n, i, s) {
2070
- const o = await fetch(n, {
2071
- method: "POST",
2072
- body: JSON.stringify(i),
2073
- headers: {
2074
- "Content-Type": "application/json",
2075
- ...s?.headers
2076
- },
2077
- ...s
2078
- });
2079
- if (!o.ok) throw new Error(o.statusText);
2080
- return o.json();
2081
- }
2082
- t.post = r;
2083
- })(He || (He = {}));
2084
- var xe;
2085
- ((t) => {
2086
- function e(l, a, u) {
2087
- return {
2088
- x: n(a) * u,
2089
- y: i(l) * u
2090
- };
2091
- }
2092
- t.project = e;
2093
- function r(l, a, u) {
2094
- return {
2095
- lat: o(a / u),
2096
- lng: s(l / u)
2097
- };
2098
- }
2099
- t.unproject = r;
2100
- function n(l) {
2101
- return (180 + l) / 360;
2102
- }
2103
- function i(l) {
2104
- return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + l * Math.PI / 360))) / 360;
2105
- }
2106
- function s(l) {
2107
- return l * 360 - 180;
2108
- }
2109
- function o(l) {
2110
- return 360 / Math.PI * Math.atan(Math.exp((180 - l * 360) * Math.PI / 180)) - 90;
2111
- }
2112
- })(xe || (xe = {}));
2113
- class rn {
2114
- swLat;
2115
- swLng;
2116
- neLat;
2117
- neLng;
2118
- /**
2119
- * @param mapBounds - The bounds of the map.
2120
- * @param mapZoom - The zoom level of the map.
2121
- * @param mapSize - The size of the map in pixels at zoom level 0.
2122
- * @param offsetX - The x offset of the map in pixels at zoom level n.
2123
- * @param offsetY - The y offset of the map in pixels at zoom level n.
2124
- */
2125
- constructor(e, r, n, i, s) {
2126
- const o = n * Math.pow(2, r), l = xe.project(e.sw.lat, e.sw.lng, o), a = xe.project(e.ne.lat, e.ne.lng, o), u = l.x - i, f = l.y + s, p = a.x + i, h = a.y - s, c = xe.unproject(u, f, o), d = xe.unproject(p, h, o);
2127
- this.swLat = c.lat, this.swLng = c.lng, this.neLat = d.lat, this.neLng = d.lng;
2128
- }
2129
- contains(e, r) {
2130
- return this.swLat <= e && e <= this.neLat ? this.swLng < this.neLng ? this.swLng <= r && r <= this.neLng : r <= this.neLng || this.swLng <= r : !1;
2131
- }
2132
- }
2133
- var Et;
2134
- // @__NO_SIDE_EFFECTS__
2135
- function nn(t) {
2136
- return {
2137
- lang: t?.lang ?? Et?.lang,
2138
- message: t?.message,
2139
- abortEarly: t?.abortEarly ?? Et?.abortEarly,
2140
- abortPipeEarly: t?.abortPipeEarly ?? Et?.abortPipeEarly
2141
- };
2142
- }
2143
- var Hi;
2144
- // @__NO_SIDE_EFFECTS__
2145
- function Yi(t) {
2146
- return Hi?.get(t);
2147
- }
2148
- var Vi;
2149
- // @__NO_SIDE_EFFECTS__
2150
- function Xi(t) {
2151
- return Vi?.get(t);
2152
- }
2153
- var Wi;
2154
- // @__NO_SIDE_EFFECTS__
2155
- function Gi(t, e) {
2156
- return Wi?.get(t)?.get(e);
2157
- }
2158
- // @__NO_SIDE_EFFECTS__
2159
- function Ke(t) {
2160
- const e = typeof t;
2161
- return e === "string" ? `"${t}"` : e === "number" || e === "bigint" || e === "boolean" ? `${t}` : e === "object" || e === "function" ? (t && Object.getPrototypeOf(t)?.constructor?.name) ?? "null" : e;
2162
- }
2163
- function S(t, e, r, n, i) {
2164
- const s = i && "input" in i ? i.input : r.value, o = i?.expected ?? t.expects ?? null, l = i?.received ?? /* @__PURE__ */ Ke(s), a = {
2165
- kind: t.kind,
2166
- type: t.type,
2167
- input: s,
2168
- expected: o,
2169
- received: l,
2170
- message: `Invalid ${e}: ${o ? `Expected ${o} but r` : "R"}eceived ${l}`,
2171
- requirement: t.requirement,
2172
- path: i?.path,
2173
- issues: i?.issues,
2174
- lang: n.lang,
2175
- abortEarly: n.abortEarly,
2176
- abortPipeEarly: n.abortPipeEarly
2177
- }, u = t.kind === "schema", f = i?.message ?? t.message ?? /* @__PURE__ */ Gi(t.reference, a.lang) ?? (u ? /* @__PURE__ */ Xi(a.lang) : null) ?? n.message ?? /* @__PURE__ */ Yi(a.lang);
2178
- f !== void 0 && (a.message = typeof f == "function" ? (
2179
- // @ts-expect-error
2180
- f(a)
2181
- ) : f), u && (r.typed = !1), r.issues ? r.issues.push(a) : r.issues = [a];
2182
- }
2183
- // @__NO_SIDE_EFFECTS__
2184
- function N(t) {
2185
- return {
2186
- version: 1,
2187
- vendor: "valibot",
2188
- validate(e) {
2189
- return t["~run"]({ value: e }, /* @__PURE__ */ nn());
2190
- }
2191
- };
2192
- }
2193
- var ht = class extends Error {
2194
- /**
2195
- * Creates a Valibot error with useful information.
2196
- *
2197
- * @param issues The error issues.
2198
- */
2199
- constructor(t) {
2200
- super(t[0].message), this.name = "ValiError", this.issues = t;
2201
- }
2202
- };
2203
- // @__NO_SIDE_EFFECTS__
2204
- function z(t) {
2205
- return {
2206
- kind: "transformation",
2207
- type: "args",
2208
- reference: z,
2209
- async: !1,
2210
- schema: t,
2211
- "~run"(e, r) {
2212
- const n = e.value;
2213
- return e.value = (...i) => {
2214
- const s = this.schema["~run"]({ value: i }, r);
2215
- if (s.issues)
2216
- throw new ht(s.issues);
2217
- return n(...s.value);
2218
- }, e;
2219
- }
2220
- };
2221
- }
2222
- // @__NO_SIDE_EFFECTS__
2223
- function sn() {
2224
- return {
2225
- kind: "transformation",
2226
- type: "await",
2227
- reference: sn,
2228
- async: !0,
2229
- async "~run"(t) {
2230
- return t.value = await t.value, t;
2231
- }
2232
- };
2233
- }
2234
- // @__NO_SIDE_EFFECTS__
2235
- function on(t, e) {
2236
- return {
2237
- kind: "validation",
2238
- type: "check",
2239
- reference: on,
2240
- async: !1,
2241
- expects: null,
2242
- requirement: t,
2243
- message: e,
2244
- "~run"(r, n) {
2245
- return r.typed && !this.requirement(r.value) && S(this, "input", r, n), r;
2246
- }
2247
- };
2248
- }
2249
- // @__NO_SIDE_EFFECTS__
2250
- function an(t, e) {
2251
- return {
2252
- kind: "validation",
2253
- type: "length",
2254
- reference: an,
2255
- async: !1,
2256
- expects: `${t}`,
2257
- requirement: t,
2258
- message: e,
2259
- "~run"(r, n) {
2260
- return r.typed && r.value.length !== this.requirement && S(this, "length", r, n, {
2261
- received: `${r.value.length}`
2262
- }), r;
2263
- }
2264
- };
2265
- }
2266
- // @__NO_SIDE_EFFECTS__
2267
- function Te(t, e) {
2268
- return {
2269
- kind: "validation",
2270
- type: "max_value",
2271
- reference: Te,
2272
- async: !1,
2273
- expects: `<=${t instanceof Date ? t.toJSON() : /* @__PURE__ */ Ke(t)}`,
2274
- requirement: t,
2275
- message: e,
2276
- "~run"(r, n) {
2277
- return r.typed && !(r.value <= this.requirement) && S(this, "value", r, n, {
2278
- received: r.value instanceof Date ? r.value.toJSON() : /* @__PURE__ */ Ke(r.value)
2279
- }), r;
2280
- }
2281
- };
2282
- }
2283
- // @__NO_SIDE_EFFECTS__
2284
- function Vt(t, e) {
2285
- return {
2286
- kind: "validation",
2287
- type: "min_length",
2288
- reference: Vt,
2289
- async: !1,
2290
- expects: `>=${t}`,
2291
- requirement: t,
2292
- message: e,
2293
- "~run"(r, n) {
2294
- return r.typed && r.value.length < this.requirement && S(this, "length", r, n, {
2295
- received: `${r.value.length}`
2296
- }), r;
2297
- }
2298
- };
2299
- }
2300
- // @__NO_SIDE_EFFECTS__
2301
- function $(t, e) {
2302
- return {
2303
- kind: "validation",
2304
- type: "min_value",
2305
- reference: $,
2306
- async: !1,
2307
- expects: `>=${t instanceof Date ? t.toJSON() : /* @__PURE__ */ Ke(t)}`,
2308
- requirement: t,
2309
- message: e,
2310
- "~run"(r, n) {
2311
- return r.typed && !(r.value >= this.requirement) && S(this, "value", r, n, {
2312
- received: r.value instanceof Date ? r.value.toJSON() : /* @__PURE__ */ Ke(r.value)
2313
- }), r;
2314
- }
2315
- };
2316
- }
2317
- // @__NO_SIDE_EFFECTS__
2318
- function W(t) {
2319
- return {
2320
- kind: "transformation",
2321
- type: "returns",
2322
- reference: W,
2323
- async: !1,
2324
- schema: t,
2325
- "~run"(e, r) {
2326
- const n = e.value;
2327
- return e.value = (...i) => {
2328
- const s = this.schema["~run"](
2329
- { value: n(...i) },
2330
- r
2331
- );
2332
- if (s.issues)
2333
- throw new ht(s.issues);
2334
- return s.value;
2335
- }, e;
2336
- }
2337
- };
2338
- }
2339
- // @__NO_SIDE_EFFECTS__
2340
- function ln(t) {
2341
- return {
2342
- kind: "transformation",
2343
- type: "returns",
2344
- reference: ln,
2345
- async: !1,
2346
- schema: t,
2347
- "~run"(e, r) {
2348
- const n = e.value;
2349
- return e.value = async (...i) => {
2350
- const s = await this.schema["~run"](
2351
- { value: await n(...i) },
2352
- r
2353
- );
2354
- if (s.issues)
2355
- throw new ht(s.issues);
2356
- return s.value;
2357
- }, e;
2358
- }
2359
- };
2360
- }
2361
- // @__NO_SIDE_EFFECTS__
2362
- function Ki(t, e, r) {
2363
- return typeof t.fallback == "function" ? (
2364
- // @ts-expect-error
2365
- t.fallback(e, r)
2366
- ) : (
2367
- // @ts-expect-error
2368
- t.fallback
2369
- );
2370
- }
2371
- // @__NO_SIDE_EFFECTS__
2372
- function un(t, e, r) {
2373
- return typeof t.default == "function" ? (
2374
- // @ts-expect-error
2375
- t.default(e, r)
2376
- ) : (
2377
- // @ts-expect-error
2378
- t.default
2379
- );
2380
- }
2381
- // @__NO_SIDE_EFFECTS__
2382
- function fn(t, e) {
2383
- return {
2384
- kind: "schema",
2385
- type: "array",
2386
- reference: fn,
2387
- expects: "Array",
2388
- async: !1,
2389
- item: t,
2390
- message: e,
2391
- get "~standard"() {
2392
- return /* @__PURE__ */ N(this);
2393
- },
2394
- "~run"(r, n) {
2395
- const i = r.value;
2396
- if (Array.isArray(i)) {
2397
- r.typed = !0, r.value = [];
2398
- for (let s = 0; s < i.length; s++) {
2399
- const o = i[s], l = this.item["~run"]({ value: o }, n);
2400
- if (l.issues) {
2401
- const a = {
2402
- type: "array",
2403
- origin: "value",
2404
- input: i,
2405
- key: s,
2406
- value: o
2407
- };
2408
- for (const u of l.issues)
2409
- u.path ? u.path.unshift(a) : u.path = [a], r.issues?.push(u);
2410
- if (r.issues || (r.issues = l.issues), n.abortEarly) {
2411
- r.typed = !1;
2412
- break;
2413
- }
2414
- }
2415
- l.typed || (r.typed = !1), r.value.push(l.value);
2416
- }
2417
- } else
2418
- S(this, "type", r, n);
2419
- return r;
2420
- }
2421
- };
2422
- }
2423
- // @__NO_SIDE_EFFECTS__
2424
- function cn(t) {
2425
- return {
2426
- kind: "schema",
2427
- type: "boolean",
2428
- reference: cn,
2429
- expects: "boolean",
2430
- async: !1,
2431
- message: t,
2432
- get "~standard"() {
2433
- return /* @__PURE__ */ N(this);
2434
- },
2435
- "~run"(e, r) {
2436
- return typeof e.value == "boolean" ? e.typed = !0 : S(this, "type", e, r), e;
2437
- }
2438
- };
2439
- }
2440
- // @__NO_SIDE_EFFECTS__
2441
- function hn(t, e) {
2442
- return {
2443
- kind: "schema",
2444
- type: "custom",
2445
- reference: hn,
2446
- expects: "unknown",
2447
- async: !1,
2448
- check: t,
2449
- message: e,
2450
- get "~standard"() {
2451
- return /* @__PURE__ */ N(this);
2452
- },
2453
- "~run"(r, n) {
2454
- return this.check(r.value) ? r.typed = !0 : S(this, "type", r, n), r;
2455
- }
2456
- };
2457
- }
2458
- // @__NO_SIDE_EFFECTS__
2459
- function B(t) {
2460
- return {
2461
- kind: "schema",
2462
- type: "function",
2463
- reference: B,
2464
- expects: "Function",
2465
- async: !1,
2466
- message: t,
2467
- get "~standard"() {
2468
- return /* @__PURE__ */ N(this);
2469
- },
2470
- "~run"(e, r) {
2471
- return typeof e.value == "function" ? e.typed = !0 : S(this, "type", e, r), e;
2472
- }
2473
- };
2474
- }
2475
- // @__NO_SIDE_EFFECTS__
2476
- function E(t) {
2477
- return {
2478
- kind: "schema",
2479
- type: "number",
2480
- reference: E,
2481
- expects: "number",
2482
- async: !1,
2483
- message: t,
2484
- get "~standard"() {
2485
- return /* @__PURE__ */ N(this);
2486
- },
2487
- "~run"(e, r) {
2488
- return typeof e.value == "number" && !isNaN(e.value) ? e.typed = !0 : S(this, "type", e, r), e;
2489
- }
2490
- };
2491
- }
2492
- // @__NO_SIDE_EFFECTS__
2493
- function T(t, e) {
2494
- return {
2495
- kind: "schema",
2496
- type: "object",
2497
- reference: T,
2498
- expects: "Object",
2499
- async: !1,
2500
- entries: t,
2501
- message: e,
2502
- get "~standard"() {
2503
- return /* @__PURE__ */ N(this);
2504
- },
2505
- "~run"(r, n) {
2506
- const i = r.value;
2507
- if (i && typeof i == "object") {
2508
- r.typed = !0, r.value = {};
2509
- for (const s in this.entries) {
2510
- const o = this.entries[s];
2511
- if (s in i || (o.type === "exact_optional" || o.type === "optional" || o.type === "nullish") && // @ts-expect-error
2512
- o.default !== void 0) {
2513
- const l = s in i ? (
2514
- // @ts-expect-error
2515
- i[s]
2516
- ) : /* @__PURE__ */ un(o), a = o["~run"]({ value: l }, n);
2517
- if (a.issues) {
2518
- const u = {
2519
- type: "object",
2520
- origin: "value",
2521
- input: i,
2522
- key: s,
2523
- value: l
2524
- };
2525
- for (const f of a.issues)
2526
- f.path ? f.path.unshift(u) : f.path = [u], r.issues?.push(f);
2527
- if (r.issues || (r.issues = a.issues), n.abortEarly) {
2528
- r.typed = !1;
2529
- break;
2530
- }
2531
- }
2532
- a.typed || (r.typed = !1), r.value[s] = a.value;
2533
- } else if (o.fallback !== void 0)
2534
- r.value[s] = /* @__PURE__ */ Ki(o);
2535
- else if (o.type !== "exact_optional" && o.type !== "optional" && o.type !== "nullish" && (S(this, "key", r, n, {
2536
- input: void 0,
2537
- expected: `"${s}"`,
2538
- path: [
2539
- {
2540
- type: "object",
2541
- origin: "key",
2542
- input: i,
2543
- key: s,
2544
- // @ts-expect-error
2545
- value: i[s]
2546
- }
2547
- ]
2548
- }), n.abortEarly))
2549
- break;
2550
- }
2551
- } else
2552
- S(this, "type", r, n);
2553
- return r;
2554
- }
2555
- };
2556
- }
2557
- // @__NO_SIDE_EFFECTS__
2558
- function U(t, e) {
2559
- return {
2560
- kind: "schema",
2561
- type: "optional",
2562
- reference: U,
2563
- expects: `(${t.expects} | undefined)`,
2564
- async: !1,
2565
- wrapped: t,
2566
- default: e,
2567
- get "~standard"() {
2568
- return /* @__PURE__ */ N(this);
2569
- },
2570
- "~run"(r, n) {
2571
- return r.value === void 0 && (this.default !== void 0 && (r.value = /* @__PURE__ */ un(this, r, n)), r.value === void 0) ? (r.typed = !0, r) : this.wrapped["~run"](r, n);
2572
- }
2573
- };
2574
- }
2575
- // @__NO_SIDE_EFFECTS__
2576
- function pn(t) {
2577
- return {
2578
- kind: "schema",
2579
- type: "promise",
2580
- reference: pn,
2581
- expects: "Promise",
2582
- async: !1,
2583
- message: t,
2584
- get "~standard"() {
2585
- return /* @__PURE__ */ N(this);
2586
- },
2587
- "~run"(e, r) {
2588
- return e.value instanceof Promise ? e.typed = !0 : S(this, "type", e, r), e;
2589
- }
2590
- };
2591
- }
2592
- // @__NO_SIDE_EFFECTS__
2593
- function te(t) {
2594
- return {
2595
- kind: "schema",
2596
- type: "string",
2597
- reference: te,
2598
- expects: "string",
2599
- async: !1,
2600
- message: t,
2601
- get "~standard"() {
2602
- return /* @__PURE__ */ N(this);
2603
- },
2604
- "~run"(e, r) {
2605
- return typeof e.value == "string" ? e.typed = !0 : S(this, "type", e, r), e;
2606
- }
2607
- };
2608
- }
2609
- // @__NO_SIDE_EFFECTS__
2610
- function Z(t, e) {
2611
- return {
2612
- kind: "schema",
2613
- type: "tuple",
2614
- reference: Z,
2615
- expects: "Array",
2616
- async: !1,
2617
- items: t,
2618
- message: e,
2619
- get "~standard"() {
2620
- return /* @__PURE__ */ N(this);
2621
- },
2622
- "~run"(r, n) {
2623
- const i = r.value;
2624
- if (Array.isArray(i)) {
2625
- r.typed = !0, r.value = [];
2626
- for (let s = 0; s < this.items.length; s++) {
2627
- const o = i[s], l = this.items[s]["~run"]({ value: o }, n);
2628
- if (l.issues) {
2629
- const a = {
2630
- type: "array",
2631
- origin: "value",
2632
- input: i,
2633
- key: s,
2634
- value: o
2635
- };
2636
- for (const u of l.issues)
2637
- u.path ? u.path.unshift(a) : u.path = [a], r.issues?.push(u);
2638
- if (r.issues || (r.issues = l.issues), n.abortEarly) {
2639
- r.typed = !1;
2640
- break;
2641
- }
2642
- }
2643
- l.typed || (r.typed = !1), r.value.push(l.value);
2644
- }
2645
- } else
2646
- S(this, "type", r, n);
2647
- return r;
2648
- }
2649
- };
2650
- }
2651
- // @__NO_SIDE_EFFECTS__
2652
- function Ye(t) {
2653
- return {
2654
- kind: "schema",
2655
- type: "void",
2656
- reference: Ye,
2657
- expects: "void",
2658
- async: !1,
2659
- message: t,
2660
- get "~standard"() {
2661
- return /* @__PURE__ */ N(this);
2662
- },
2663
- "~run"(e, r) {
2664
- return e.value === void 0 ? e.typed = !0 : S(this, "type", e, r), e;
2665
- }
2666
- };
2667
- }
2668
- function tt(t, e, r) {
2669
- const n = t["~run"]({ value: e }, /* @__PURE__ */ nn(r));
2670
- if (n.issues)
2671
- throw new ht(n.issues);
2672
- return n.value;
2673
- }
2674
- // @__NO_SIDE_EFFECTS__
2675
- function _(...t) {
2676
- return {
2677
- ...t[0],
2678
- pipe: t,
2679
- get "~standard"() {
2680
- return /* @__PURE__ */ N(this);
2681
- },
2682
- "~run"(e, r) {
2683
- for (const n of t)
2684
- if (n.kind !== "metadata") {
2685
- if (e.issues && (n.kind === "schema" || n.kind === "transformation")) {
2686
- e.typed = !1;
2687
- break;
2688
- }
2689
- (!e.issues || !r.abortEarly && !r.abortPipeEarly) && (e = n["~run"](e, r));
2690
- }
2691
- return e;
2692
- }
2693
- };
2694
- }
2695
- // @__NO_SIDE_EFFECTS__
2696
- function Ji(...t) {
2697
- return {
2698
- ...t[0],
2699
- pipe: t,
2700
- async: !0,
2701
- get "~standard"() {
2702
- return /* @__PURE__ */ N(this);
2703
- },
2704
- async "~run"(e, r) {
2705
- for (const n of t)
2706
- if (n.kind !== "metadata") {
2707
- if (e.issues && (n.kind === "schema" || n.kind === "transformation")) {
2708
- e.typed = !1;
2709
- break;
2710
- }
2711
- (!e.issues || !r.abortEarly && !r.abortPipeEarly) && (e = await n["~run"](e, r));
2712
- }
2713
- return e;
2714
- }
2715
- };
2716
- }
2717
- const Ct = /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(-90), /* @__PURE__ */ Te(90)), Tt = /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(-180), /* @__PURE__ */ Te(180)), Qi = /* @__PURE__ */ T({
2718
- sw: /* @__PURE__ */ T({ lat: Ct, lng: Tt }),
2719
- ne: /* @__PURE__ */ T({ lat: Ct, lng: Tt })
2720
- }), Lt = /* @__PURE__ */ hn((t) => t instanceof HTMLElement, "Must be an HTMLElement"), $i = /* @__PURE__ */ T({
2721
- mapSize: /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(1)),
2722
- zoomMin: /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(0)),
2723
- zoomMax: /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(0)),
2724
- zoomScale: /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(1), /* @__PURE__ */ Te(10))
2725
- }), es = /* @__PURE__ */ T({
2726
- inserted: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([])), /* @__PURE__ */ W(/* @__PURE__ */ cn())),
2727
- insert: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([])), /* @__PURE__ */ W(/* @__PURE__ */ Ye())),
2728
- remove: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([])), /* @__PURE__ */ W(/* @__PURE__ */ Ye())),
2729
- update: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([/* @__PURE__ */ E()])), /* @__PURE__ */ W(/* @__PURE__ */ Ye()))
2730
- }), ts = /* @__PURE__ */ T({
2731
- getParameters: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([])), /* @__PURE__ */ W($i)),
2732
- getContainer: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([])), /* @__PURE__ */ W(Lt)),
2733
- getZoom: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([])), /* @__PURE__ */ W(/* @__PURE__ */ E())),
2734
- getBounds: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([])), /* @__PURE__ */ W(Qi)),
2735
- panBy: /* @__PURE__ */ _(/* @__PURE__ */ B(), /* @__PURE__ */ z(/* @__PURE__ */ Z([/* @__PURE__ */ E(), /* @__PURE__ */ E()])), /* @__PURE__ */ W(/* @__PURE__ */ Ye())),
2736
- createMarker: /* @__PURE__ */ _(
2737
- /* @__PURE__ */ B(),
2738
- /* @__PURE__ */ z(/* @__PURE__ */ Z([Lt, Ct, Tt, /* @__PURE__ */ E()])),
2739
- /* @__PURE__ */ W(es)
2740
- )
2741
- }), kt = /* @__PURE__ */ _(
2742
- /* @__PURE__ */ B(),
2743
- /* @__PURE__ */ z(/* @__PURE__ */ Z([/* @__PURE__ */ te()])),
2744
- /* @__PURE__ */ ln(/* @__PURE__ */ Ji(/* @__PURE__ */ pn(), /* @__PURE__ */ sn(), Lt))
2745
- ), rs = /* @__PURE__ */ T({
2746
- background: /* @__PURE__ */ U(/* @__PURE__ */ te()),
2747
- border: /* @__PURE__ */ U(/* @__PURE__ */ te()),
2748
- shadow: /* @__PURE__ */ U(/* @__PURE__ */ te())
2749
- }), ns = /* @__PURE__ */ T({
2750
- width: /* @__PURE__ */ E(),
2751
- height: /* @__PURE__ */ E(),
2752
- radius: /* @__PURE__ */ E()
2753
- }), gr = /* @__PURE__ */ T({
2754
- background: /* @__PURE__ */ U(/* @__PURE__ */ te()),
2755
- shadow: /* @__PURE__ */ U(/* @__PURE__ */ te())
2756
- }), _r = /* @__PURE__ */ _(
2757
- /* @__PURE__ */ T({
2758
- width: /* @__PURE__ */ E(),
2759
- height: /* @__PURE__ */ E(),
2760
- margin: /* @__PURE__ */ E(),
2761
- radius: /* @__PURE__ */ E()
2762
- }),
2763
- /* @__PURE__ */ on(
2764
- (t) => Math.min(t.width, t.height) / t.margin >= 6,
2765
- "Tooltip: minimum of width or height must be greater than or equal to 6 * margin"
2766
- )
2767
- ), is = /* @__PURE__ */ T({
2768
- id: /* @__PURE__ */ _(/* @__PURE__ */ te(), /* @__PURE__ */ Vt(1)),
2769
- rank: /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(0)),
2770
- lat: /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(-90), /* @__PURE__ */ Te(90)),
2771
- lng: /* @__PURE__ */ _(/* @__PURE__ */ E(), /* @__PURE__ */ $(-180), /* @__PURE__ */ Te(180)),
2772
- tooltip: /* @__PURE__ */ T({
2773
- body: kt,
2774
- style: _r,
2775
- colors: /* @__PURE__ */ U(gr)
2776
- }),
2777
- pin: /* @__PURE__ */ U(
2778
- /* @__PURE__ */ T({
2779
- body: kt,
2780
- style: /* @__PURE__ */ U(ns),
2781
- colors: /* @__PURE__ */ U(rs)
2782
- })
2783
- ),
2784
- popup: /* @__PURE__ */ U(
2785
- /* @__PURE__ */ T({
2786
- body: kt,
2787
- style: _r,
2788
- colors: /* @__PURE__ */ U(gr)
2789
- })
2790
- )
2791
- }), ss = /* @__PURE__ */ fn(is);
2792
- var ye;
2793
- ((t) => {
2794
- t.COUNT = 12, t.DEGREES = [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330], t.DEGREES_DEFAULT = 270;
2795
- })(ye || (ye = {}));
2796
- const os = /* @__PURE__ */ _(/* @__PURE__ */ te(), /* @__PURE__ */ an(32)), as = /* @__PURE__ */ _(/* @__PURE__ */ te(), /* @__PURE__ */ Vt(1)), wr = "1.2.0", Xt = "https://maps.api.arenarium.dev", ls = `${Xt}/auth`, us = `${Xt}/states`, fs = `${Xt}/log`;
2797
- class dn {
2798
- apiKey;
2799
- apiToken;
2800
- apiDevEnvironment;
2801
- mapProvider;
2802
- markerDataArray = new Array();
2803
- markerDataMap = /* @__PURE__ */ new Map();
2804
- markerDataUpdating = !1;
2805
- markerPinProcessor;
2806
- markerTooltipProcessor;
2807
- markerPopupProcessor;
2808
- constructor(e, r, n, i) {
2809
- tt(os, e), tt(as, r), tt(ts, n), this.apiKey = e, this.apiToken = r, this.apiDevEnvironment = window?.location.host.startsWith("localhost") || window?.location.host.startsWith("127.0.0.1"), this.mapProvider = n, this.markerPinProcessor = new lt(n), this.markerTooltipProcessor = new hs(n), this.markerPopupProcessor = new ps(n), this.setConfiguration(i);
2810
- }
2811
- static async create(e, r, n) {
2812
- const i = { key: e, version: wr };
2813
- let o = (await He.post(ls, i)).token;
2814
- if (!o) throw new Error("Failed to get api token");
2815
- return new dn(e, o, r, n);
2816
- }
2817
- setConfiguration(e) {
2818
- ae.setLimit(e?.animation?.queue?.limit ?? 8 * navigator.hardwareConcurrency), this.markerPinProcessor.setConfiguration(e);
2819
- }
2820
- async updateMarkers(e) {
2821
- tt(ss, e);
2822
- try {
2823
- await this.updateMarkerData(e), this.processMarkerDataCallback();
2824
- } catch (r) {
2825
- throw console.error(r), this.removeMarkerData(), r instanceof Error && this.log("error", "Failed to update markers", r), r;
2826
- }
2827
- }
2828
- removeMarkers() {
2829
- try {
2830
- this.removeMarkerData();
2831
- } catch (e) {
2832
- throw console.error(e), e instanceof Error && this.log("error", "Failed to remove markers", e), e;
2833
- }
2834
- }
2835
- showPopup(e) {
2836
- try {
2837
- for (const r of this.markerDataArray)
2838
- r.marker.id == e ? this.markerPopupProcessor.show(r) : this.markerPopupProcessor.hide(r);
2839
- } catch (r) {
2840
- console.error(r);
2841
- for (const n of this.markerDataArray)
2842
- this.markerPopupProcessor.hide(n);
2843
- throw r instanceof Error && this.log("error", "Failed to show popup", r), r;
2844
- }
2845
- }
2846
- hidePopup(e) {
2847
- try {
2848
- if (e) {
2849
- const r = this.markerDataMap.get(e);
2850
- if (r == null) return;
2851
- this.markerPopupProcessor.hide(r);
2852
- } else
2853
- for (const r of this.markerDataArray)
2854
- this.markerPopupProcessor.hide(r);
2855
- } catch (r) {
2856
- console.error(r);
2857
- for (const n of this.markerDataArray)
2858
- this.markerPopupProcessor.hide(n);
2859
- throw r instanceof Error && this.log("error", "Failed to hide popup", r), r;
2860
- }
2861
- }
2862
- async updateMarkerData(e) {
2863
- try {
2864
- let r = this.markerDataArray.map((i) => i.marker);
2865
- for (let i = 0; i < e.length; i++) {
2866
- const s = e[i];
2867
- this.markerDataMap.get(s.id) || r.push(s);
2868
- }
2869
- const n = await this.getMarkerStates(r);
2870
- try {
2871
- this.markerDataUpdating = !0;
2872
- for (let i = 0; i < r.length; i++) {
2873
- const s = r[i], o = n[i], l = this.markerDataMap.get(s.id);
2874
- if (l)
2875
- l.update(o);
2876
- else {
2877
- const a = new cs(this.mapProvider, s, o);
2878
- a.create(), this.markerDataMap.set(s.id, a), this.markerDataArray.push(a);
2879
- }
2880
- }
2881
- this.markerDataArray.sort((i, s) => i.zoom - s.zoom), this.markerPinProcessor.updateElements(this.markerDataArray.map((i) => i.pin)), this.markerTooltipProcessor.updateElements(this.markerDataArray.map((i) => i.tooltip)), this.markerPopupProcessor.updateElements(this.markerDataArray.map((i) => i.popup).filter((i) => i != null));
2882
- } finally {
2883
- this.markerDataUpdating = !1;
2884
- }
2885
- } catch (r) {
2886
- throw console.error(r), this.markerDataArray.forEach((n) => n.remove()), this.markerDataArray.length = 0, this.markerDataMap.clear(), r instanceof Error && this.log("error", "Failed to update marker data", r), r;
2887
- } finally {
2888
- this.markerDataUpdating = !1;
2889
- }
2890
- }
2891
- removeMarkerData() {
2892
- try {
2893
- this.markerDataUpdating = !0, this.markerPinProcessor.removeElements(), this.markerTooltipProcessor.removeElements(), this.markerPopupProcessor.removeElements(), this.markerDataArray.length = 0, this.markerDataMap.clear();
2894
- } catch (e) {
2895
- throw console.error(e), e instanceof Error && this.log("error", "Failed to remove marker data", e), e;
2896
- } finally {
2897
- this.markerDataUpdating = !1;
2898
- }
2899
- }
2900
- async getMarkerStates(e) {
2901
- if (e.length == 0) return [];
2902
- if (e.length == 1) return [[0, [[0, ye.DEGREES.indexOf(ye.DEGREES_DEFAULT)]]]];
2903
- const r = e.map((s) => ({
2904
- id: s.id,
2905
- rank: s.rank,
2906
- lat: s.lat,
2907
- lng: s.lng,
2908
- width: s.tooltip.style.width,
2909
- height: s.tooltip.style.height,
2910
- margin: s.tooltip.style.margin
2911
- })), n = {
2912
- key: this.apiKey,
2913
- token: this.apiToken,
2914
- parameters: this.mapProvider.getParameters(),
2915
- input: r
2916
- }, i = await He.post(us, n, {
2917
- headers: { "Cache-Control": this.apiDevEnvironment ? "no-cache" : "" }
2918
- });
2919
- return i.token && (this.apiToken = i.token), i.states;
2920
- }
2921
- processMarkerDataCallback() {
2922
- if (this.mapProvider.getContainer().parentElement != null && this.markerDataArray.length != 0)
2923
- try {
2924
- this.processMarkerData(), window.setTimeout(this.processMarkerDataCallback.bind(this), 25);
2925
- } catch (e) {
2926
- console.error(e), e instanceof Error && this.log("error", "Failed to process marker data", e);
2927
- }
2928
- }
2929
- processMarkerData() {
2930
- if (this.markerDataUpdating) return;
2931
- const e = this.mapProvider.getBounds(), r = this.mapProvider.getZoom();
2932
- this.markerPopupProcessor.process(), this.markerTooltipProcessor.process(e, r), this.markerPinProcessor.process(e, r);
2933
- }
2934
- async log(e, r, n) {
2935
- if (!this.apiDevEnvironment)
2936
- try {
2937
- const i = {
2938
- key: this.apiKey,
2939
- title: r,
2940
- level: e,
2941
- content: {
2942
- version: wr,
2943
- ...n
2944
- }
2945
- };
2946
- await He.post(fs, i);
2947
- } catch (i) {
2948
- console.error(i);
2949
- }
2950
- }
2951
- }
2952
- class cs {
2953
- marker;
2954
- zoom;
2955
- pin;
2956
- tooltip;
2957
- popup;
2958
- constructor(e, r, n) {
2959
- this.marker = r, this.zoom = n[0], this.pin = new Ve(e, r, n), this.tooltip = new Gt(e, r, n), r.popup && (this.popup = new Kt(e, r));
2960
- }
2961
- create() {
2962
- this.pin.create(), this.tooltip.create(), this.popup?.create();
2963
- }
2964
- update(e) {
2965
- this.pin.update(e), this.tooltip.update(e);
2966
- }
2967
- remove() {
2968
- this.pin.remove(), this.tooltip.remove(), this.popup?.remove();
2969
- }
2970
- }
2971
- class Wt {
2972
- provider;
2973
- id;
2974
- lat;
2975
- lng;
2976
- shown;
2977
- element;
2978
- component;
2979
- marker;
2980
- constructor(e, r) {
2981
- this.provider = e, this.id = r.id, this.lat = r.lat, this.lng = r.lng, this.shown = !0;
2982
- }
2983
- create() {
2984
- this.createElement(), this.createMarker(), this.updateZIndex();
2985
- }
2986
- createElement() {
2987
- throw new Error("Create element not implemented");
2988
- }
2989
- createMarker() {
2990
- const e = this.element;
2991
- if (!e) throw new Error("Failed to create provider marker");
2992
- this.marker = this.provider.createMarker(e, this.lat, this.lng, this.getZindex());
2993
- }
2994
- updateZIndex() {
2995
- if (this.marker == null) throw new Error("Failed to update provider marker z-index");
2996
- this.marker.update(this.getZindex());
2997
- }
2998
- updateMap(e) {
2999
- const r = this.marker, n = this.component;
3000
- if (r == null || n == null) throw new Error("Failed to update provider marker map");
3001
- e ? r.inserted() == !1 && r.insert() : r.inserted() == !0 && r.remove();
3002
- }
3003
- getZindex() {
3004
- throw new Error("Get z-index not implemented");
3005
- }
3006
- remove() {
3007
- this.marker?.remove();
3008
- }
3009
- }
3010
- class Ve extends Wt {
3011
- static DEFAULT_SIZE = 16;
3012
- style;
3013
- colors;
3014
- zoom;
3015
- bodyLoading = !1;
3016
- bodyLoaded = !1;
3017
- bodyCallback;
3018
- constructor(e, r, n) {
3019
- super(e, r), this.style = r.pin?.style ?? { width: Ve.DEFAULT_SIZE, height: Ve.DEFAULT_SIZE, radius: Ve.DEFAULT_SIZE }, this.colors = r.pin?.colors, this.zoom = n[0], this.bodyCallback = r.pin?.body;
3020
- }
3021
- createElement() {
3022
- this.element = document.createElement("div"), this.element.classList.add("pin"), this.component = Ht(Zi, {
3023
- target: this.element,
3024
- props: {
3025
- id: this.id + "_pin",
3026
- layer: zi,
3027
- priority: this.zoom * this.provider.getParameters().zoomScale,
3028
- style: this.style,
3029
- colors: this.colors
3030
- }
3031
- });
3032
- }
3033
- update(e) {
3034
- this.zoom = e[0], this.updateZIndex();
3035
- }
3036
- updateMap(e) {
3037
- super.updateMap(e), this.component?.setDisplayed(e);
3038
- }
3039
- updateBody() {
3040
- if (this.bodyCallback == null || this.bodyLoaded || this.bodyLoading) return;
3041
- const e = this.component?.getBody();
3042
- e != null && (this.bodyLoading = !0, this.bodyCallback(this.id).then((r) => {
3043
- r instanceof HTMLElement ? e.appendChild(r) : console.error("Failed to load pin body");
3044
- }).catch((r) => console.error(r)).finally(() => {
3045
- this.bodyLoaded = !0, this.bodyLoading = !1;
3046
- }));
3047
- }
3048
- setCollapsed(e) {
3049
- if (this.component == null) throw new Error("Failed to set pin collapsed");
3050
- this.component.setCollapsed(e);
3051
- }
3052
- setScale(e) {
3053
- if (this.component == null) throw new Error("Failed to set pin scale");
3054
- this.component.setScale(e);
3055
- }
3056
- getScaleFromZoomDistance(e) {
3057
- return this.zoom < e ? 1 : Math.max(0, 1 - (this.zoom - e) * 0.125);
3058
- }
3059
- getZindex() {
3060
- const e = this.provider.getParameters();
3061
- return Math.round((e.zoomMax - this.zoom) * e.zoomScale);
3062
- }
3063
- isCollapsed() {
3064
- return this.component == null ? !1 : this.component.getCollapsed();
3065
- }
3066
- isBodyLoaded() {
3067
- return this.bodyCallback == null || this.bodyLoaded;
3068
- }
3069
- }
3070
- class lt {
3071
- static MAP_PINS_MAX_ZOOM = 2;
3072
- static MAP_PINS_MAX_COUNT = 128;
3073
- provider;
3074
- // Data
3075
- pinElements = new Array();
3076
- // Configuration
3077
- pinMaxWidth = 0;
3078
- pinMaxHeight = 0;
3079
- pinFade = !1;
3080
- pinMaxCount = 0;
3081
- pinMaxZoomDelta = 0;
3082
- constructor(e) {
3083
- this.provider = e;
3084
- }
3085
- setConfiguration(e) {
3086
- this.pinFade = e?.pin?.fade ?? !0, this.pinMaxCount = e?.pin?.maxCount ?? Math.max(lt.MAP_PINS_MAX_COUNT, 8 * navigator.hardwareConcurrency), this.pinMaxZoomDelta = e?.pin?.maxZoom ?? lt.MAP_PINS_MAX_ZOOM;
3087
- }
3088
- updateElements(e) {
3089
- this.pinElements = e, this.pinMaxWidth = e.reduce((r, n) => Math.max(r, n.style.width), 0), this.pinMaxHeight = e.reduce((r, n) => Math.max(r, n.style.height), 0);
3090
- }
3091
- removeElements() {
3092
- this.pinElements.forEach((e) => e.remove()), this.pinElements.length = 0;
3093
- }
3094
- process(e, r) {
3095
- const n = this.provider.getParameters().mapSize, i = new rn(e, r, n, this.pinMaxWidth * 2, this.pinMaxHeight * 2);
3096
- let s = 0;
3097
- for (const o of this.pinElements)
3098
- i.contains(o.lat, o.lng) ? o.shown && r < o.zoom && o.zoom < r + this.pinMaxZoomDelta ? (s < this.pinMaxCount && (o.setCollapsed(!1), o.setScale(this.pinFade ? o.getScaleFromZoomDistance(r) : 1), o.updateMap(!0), o.isBodyLoaded() == !1 && o.updateBody()), s++) : (o.setCollapsed(!0), o.isCollapsed() && o.updateMap(!1)) : o.updateMap(!1);
3099
- }
3100
- }
3101
- class Gt extends Wt {
3102
- static Z_INDEX_OFFSET = 1e6;
3103
- style;
3104
- colors;
3105
- zoom;
3106
- angle;
3107
- states;
3108
- bodyLoading = !1;
3109
- bodyLoaded = !1;
3110
- bodyCallback;
3111
- constructor(e, r, n) {
3112
- super(e, r), this.style = r.tooltip.style, this.colors = r.tooltip.colors, this.zoom = n[0], this.angle = ye.DEGREES_DEFAULT, this.states = n[1].map((i) => [i[0], ye.DEGREES[i[1]]]), this.bodyCallback = r.tooltip.body;
3113
- }
3114
- createElement() {
3115
- this.element = document.createElement("div"), this.element.classList.add("tooltip"), this.component = Ht(tn, {
3116
- target: this.element,
3117
- props: {
3118
- id: this.id + "_tooltip",
3119
- layer: ji,
3120
- priority: this.zoom * this.provider.getParameters().zoomScale,
3121
- style: this.style,
3122
- colors: this.colors
3123
- }
3124
- });
3125
- }
3126
- update(e) {
3127
- this.zoom = e[0], this.states = e[1].map((r) => [r[0], ye.DEGREES[r[1]]]), this.updateZIndex();
3128
- }
3129
- updateMap(e) {
3130
- super.updateMap(e), this.component?.setDisplayed(e);
3131
- }
3132
- updateState(e) {
3133
- if (this.component == null) throw new Error("Failed to update tooltip state");
3134
- this.angle = this.getAngle(e), this.component.setAngle(this.angle);
3135
- }
3136
- updateBody() {
3137
- if (this.bodyLoaded || this.bodyLoading) return;
3138
- const e = this.component?.getBody();
3139
- e != null && (this.bodyLoading = !0, this.bodyCallback(this.id).then((r) => {
3140
- r instanceof HTMLElement ? e.appendChild(r) : console.error("Failed to load tooltip body");
3141
- }).catch((r) => console.error(r)).finally(() => {
3142
- this.bodyLoaded = !0, this.bodyLoading = !1;
3143
- }));
3144
- }
3145
- getAngle(e) {
3146
- const r = this.states.findLast((n) => n[0] <= e);
3147
- if (!r) throw new Error("Angle not found");
3148
- return r[1];
3149
- }
3150
- getZindex() {
3151
- const e = this.provider.getParameters();
3152
- return Math.round((e.zoomMax - this.zoom) * e.zoomScale) + Gt.Z_INDEX_OFFSET;
3153
- }
3154
- setCollapsed(e) {
3155
- if (this.component == null) throw new Error("Failed to set tooltip collapsed");
3156
- this.component.setCollapsed(e);
3157
- }
3158
- isExpanded() {
3159
- return this.component == null ? !1 : this.component.getExpanded();
3160
- }
3161
- isCollapsed() {
3162
- return this.component == null ? !1 : this.component.getCollapsed();
3163
- }
3164
- isBodyLoaded() {
3165
- return this.bodyLoaded;
3166
- }
3167
- }
3168
- class hs {
3169
- provider;
3170
- // Data
3171
- tooltipElements = new Array();
3172
- // Configuration
3173
- tooltipMaxWidth = 0;
3174
- tooltipMaxHeight = 0;
3175
- constructor(e) {
3176
- this.provider = e;
3177
- }
3178
- updateElements(e) {
3179
- this.tooltipElements = e, this.tooltipMaxWidth = this.tooltipElements.reduce((r, n) => Math.max(r, n.style.width), 0), this.tooltipMaxHeight = this.tooltipElements.reduce((r, n) => Math.max(r, n.style.height), 0);
3180
- }
3181
- removeElements() {
3182
- this.tooltipElements.forEach((e) => e.remove()), this.tooltipElements.length = 0;
3183
- }
3184
- process(e, r) {
3185
- const n = this.provider.getParameters().mapSize, i = new rn(e, r, n, this.tooltipMaxWidth * 2, this.tooltipMaxHeight * 2);
3186
- for (const s of this.tooltipElements)
3187
- i.contains(s.lat, s.lng) ? s.shown && s.zoom <= r ? (s.updateState(r), s.setCollapsed(!1), s.updateMap(!0), s.isCollapsed() == !1 && s.isBodyLoaded() == !1 && s.updateBody()) : (s.setCollapsed(!0), s.isCollapsed() && s.updateMap(!1)) : s.updateMap(!1);
3188
- }
3189
- }
3190
- class Kt extends Wt {
3191
- static Z_INDEX_OFFSET = 2e6;
3192
- style;
3193
- colors;
3194
- bodyLoading = !1;
3195
- bodyLoaded = !1;
3196
- bodyCallback;
3197
- constructor(e, r) {
3198
- if (r.popup == null) throw new Error("Failed to create popup");
3199
- super(e, r), this.shown = !1, this.style = r.popup.style, this.colors = r.popup.colors, this.bodyCallback = r.popup.body;
3200
- }
3201
- createElement() {
3202
- this.element = document.createElement("div"), this.element.classList.add("popup"), this.component = Ht(tn, {
3203
- target: this.element,
3204
- props: {
3205
- id: this.id + "_popup",
3206
- layer: Ni,
3207
- priority: 0,
3208
- style: this.style,
3209
- colors: this.colors
3210
- }
3211
- });
3212
- }
3213
- updateMap(e) {
3214
- super.updateMap(e), this.component?.setDisplayed(e);
3215
- }
3216
- updateBody() {
3217
- if (this.bodyLoaded || this.bodyLoading) return;
3218
- const e = this.component?.getBody();
3219
- e != null && (this.bodyLoading = !0, this.bodyCallback(this.id).then((r) => {
3220
- r instanceof HTMLElement ? e.appendChild(r) : console.error("Failed to load popup body");
3221
- }).catch((r) => console.error(r)).finally(() => {
3222
- this.bodyLoaded = !0, this.bodyLoading = !1;
3223
- }));
3224
- }
3225
- getZindex() {
3226
- return Kt.Z_INDEX_OFFSET;
3227
- }
3228
- setCollapsed(e) {
3229
- if (this.component == null) throw new Error("Failed to set popup collapsed");
3230
- this.component.setCollapsed(e);
3231
- }
3232
- setAngle(e) {
3233
- if (this.component == null) throw new Error("Failed to set popup angle");
3234
- this.component.setAngle(e, !0);
3235
- }
3236
- isExpanded() {
3237
- return this.component == null ? !1 : this.component.getExpanded();
3238
- }
3239
- isCollapsed() {
3240
- return this.component == null ? !1 : this.component.getCollapsed();
3241
- }
3242
- isBodyLoaded() {
3243
- return this.bodyLoaded;
3244
- }
3245
- }
3246
- class ps {
3247
- provider;
3248
- // Data
3249
- popupElements = new Array();
3250
- popupPositioned = /* @__PURE__ */ new Map();
3251
- constructor(e) {
3252
- this.provider = e;
3253
- }
3254
- show(e) {
3255
- e.popup && (e.pin.shown = !1, e.tooltip.shown = !1, this.popupPositioned.set(e.marker.id, !1), e.popup.setAngle(e.tooltip.angle), e.popup.shown = !0);
3256
- }
3257
- hide(e) {
3258
- e.popup && (e.pin.shown = !0, e.tooltip.shown = !0, e.popup.shown = !1);
3259
- }
3260
- updateElements(e) {
3261
- this.popupElements = e, this.popupPositioned = new Map(e.map((r) => [r.id, !1]));
3262
- }
3263
- removeElements() {
3264
- this.popupElements.forEach((e) => e.remove()), this.popupElements.length = 0, this.popupPositioned.clear();
3265
- }
3266
- process() {
3267
- for (const e of this.popupElements)
3268
- if (e.shown) {
3269
- if (e.setCollapsed(!1), e.updateMap(!0), e.isExpanded() && e.isBodyLoaded() == !1 && e.updateBody(), e.isCollapsed() == !1 && this.popupPositioned.get(e.id) == !1) {
3270
- const r = e.component?.getBody();
3271
- if (r == null) continue;
3272
- const n = e.component?.getOffsets();
3273
- if (n == null) continue;
3274
- const i = r.getBoundingClientRect();
3275
- if (i.x == 0 && i.y == 0 && i.width == 0 && i.height == 0) continue;
3276
- const s = i.x + i.width / 2, o = i.y + i.height / 2, l = s + n.x, a = o + n.y, u = l + e.style.width, f = a + e.style.height, p = this.provider.getContainer().getBoundingClientRect(), h = l - p.left, c = p.right - u, d = a - p.top, w = p.bottom - f, F = Math.min(e.style.width, e.style.height) / 4, K = h < 0 ? h - F : c < 0 ? -c + F : 0, k = d < 0 ? d - F : w < 0 ? -w + F : 0;
3277
- this.provider.panBy(K, k), this.popupPositioned.set(e.id, !0);
3278
- }
3279
- } else
3280
- e.setCollapsed(!0), e.isCollapsed() && e.updateMap(!1);
3281
- }
3282
- }
3283
- const ds = () => '<img src="https://arenarium.dev/favicon.svg" alt="Arenarium Maps" style="height: 1.25em; vertical-align: middle;" />', ys = () => `<a href="https://arenarium.dev" target="_blank" style="color: inherit;">${ds()}<span>&nbsp;@arenarium/maps</span></a>`;
3284
- export {
3285
- dn as MapManager,
3286
- ys as getAttributionHtml,
3287
- ds as getImageHtml
3288
- };