@manyducks.co/dolla 2.0.0-alpha.33 → 2.0.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +12 -14
  2. package/dist/core/{batch.d.ts → _batch.d.ts} +4 -0
  3. package/dist/core/context.d.ts +20 -17
  4. package/dist/core/dolla.d.ts +7 -48
  5. package/dist/core/markup.d.ts +9 -31
  6. package/dist/core/nodes/{observer.d.ts → dynamic.d.ts} +8 -10
  7. package/dist/core/nodes/html.d.ts +5 -7
  8. package/dist/core/nodes/{repeat.d.ts → list.d.ts} +12 -14
  9. package/dist/core/nodes/outlet.d.ts +4 -4
  10. package/dist/core/nodes/view.d.ts +22 -18
  11. package/dist/core/ref.d.ts +16 -0
  12. package/dist/core/signals.d.ts +128 -0
  13. package/dist/core/store.d.ts +9 -7
  14. package/dist/core/symbols.d.ts +0 -2
  15. package/dist/{views → core/views}/default-crash-view.d.ts +1 -1
  16. package/dist/{views → core/views}/passthrough.d.ts +2 -2
  17. package/dist/{modules/http.d.ts → http/index.d.ts} +1 -2
  18. package/dist/index.d.ts +8 -11
  19. package/dist/index.js +709 -846
  20. package/dist/index.js.map +1 -1
  21. package/dist/jsx-dev-runtime.d.ts +1 -1
  22. package/dist/jsx-dev-runtime.js +2 -2
  23. package/dist/jsx-dev-runtime.js.map +1 -1
  24. package/dist/jsx-runtime.d.ts +1 -1
  25. package/dist/jsx-runtime.js +2 -2
  26. package/dist/jsx-runtime.js.map +1 -1
  27. package/dist/markup-BWJWLvDF.js +1634 -0
  28. package/dist/markup-BWJWLvDF.js.map +1 -0
  29. package/dist/{modules/router.d.ts → router/index.d.ts} +5 -5
  30. package/dist/router/router.utils.test.d.ts +1 -0
  31. package/dist/{modules/i18n.d.ts → translate/index.d.ts} +20 -16
  32. package/dist/types.d.ts +9 -9
  33. package/docs/signals.md +149 -0
  34. package/docs/views.md +1 -1
  35. package/notes/atomic.md +146 -0
  36. package/package.json +11 -7
  37. package/vite.config.js +3 -0
  38. package/dist/core/state.d.ts +0 -126
  39. package/dist/core/stats.d.ts +0 -31
  40. package/dist/markup-Dbw-610R.js +0 -1525
  41. package/dist/markup-Dbw-610R.js.map +0 -1
  42. package/notes/viewstate.md +0 -15
  43. package/tests/state.test.js +0 -135
  44. /package/dist/{modules/router.utils.test.d.ts → core/signals.test.d.ts} +0 -0
  45. /package/dist/{modules → router}/router.utils.d.ts +0 -0
@@ -0,0 +1,1634 @@
1
+ var Ue = Object.defineProperty;
2
+ var me = (n) => {
3
+ throw TypeError(n);
4
+ };
5
+ var Ge = (n, e, t) => e in n ? Ue(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
+ var l = (n, e, t) => Ge(n, typeof e != "symbol" ? e + "" : e, t), _e = (n, e, t) => e.has(n) || me("Cannot " + t);
7
+ var T = (n, e, t) => (_e(n, e, "read from private field"), t ? t.call(n) : e.get(n)), L = (n, e, t) => e.has(n) ? me("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), I = (n, e, t, s) => (_e(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
8
+ var D = /* @__PURE__ */ ((n) => (n[n.Computed = 1] = "Computed", n[n.Effect = 2] = "Effect", n[n.Tracking = 4] = "Tracking", n[n.Notified = 8] = "Notified", n[n.Recursed = 16] = "Recursed", n[n.Dirty = 32] = "Dirty", n[n.PendingComputed = 64] = "PendingComputed", n[n.PendingEffect = 128] = "PendingEffect", n[n.Propagated = 224] = "Propagated", n))(D || {});
9
+ function ze({
10
+ updateComputed: n,
11
+ notifyEffect: e
12
+ }) {
13
+ let t, s;
14
+ return {
15
+ /**
16
+ * Links a given dependency and subscriber if they are not already linked.
17
+ *
18
+ * @param dep - The dependency to be linked.
19
+ * @param sub - The subscriber that depends on this dependency.
20
+ * @returns The newly created link object if the two are not already linked; otherwise `undefined`.
21
+ */
22
+ link(r, u) {
23
+ const f = u.depsTail;
24
+ if (f !== void 0 && f.dep === r)
25
+ return;
26
+ const h = f !== void 0 ? f.nextDep : u.deps;
27
+ if (h !== void 0 && h.dep === r) {
28
+ u.depsTail = h;
29
+ return;
30
+ }
31
+ const d = r.subsTail;
32
+ if (!(d !== void 0 && d.sub === u && a(d, u)))
33
+ return i(r, u, h, f);
34
+ },
35
+ /**
36
+ * Traverses and marks subscribers starting from the provided link.
37
+ *
38
+ * It sets flags (e.g., Dirty, PendingComputed, PendingEffect) on each subscriber
39
+ * to indicate which ones require re-computation or effect processing.
40
+ * This function should be called after a signal's value changes.
41
+ *
42
+ * @param link - The starting link from which propagation begins.
43
+ */
44
+ propagate(r) {
45
+ let u = 32, f = r, h = 0;
46
+ e: do {
47
+ const d = r.sub, m = d.flags;
48
+ if (!(m & 244) && (d.flags = m | u | 8, !0) || m & 16 && !(m & 4) && (d.flags = m & -17 | u | 8, !0) || !(m & 224) && a(r, d) && (d.flags = m | 16 | u | 8, d.subs !== void 0)) {
49
+ const _ = d.subs;
50
+ if (_ !== void 0) {
51
+ _.nextSub !== void 0 ? (_.prevSub = f, r = f = _, u = 64, ++h) : (r = _, u = m & 2 ? 128 : 64);
52
+ continue;
53
+ }
54
+ m & 2 && (s !== void 0 ? s.depsTail.nextDep = d.deps : t = d, s = d);
55
+ } else m & (4 | u) ? !(m & u) && m & 224 && a(r, d) && (d.flags = m | u) : (d.flags = m | u | 8, (m & 10) === 2 && (s !== void 0 ? s.depsTail.nextDep = d.deps : t = d, s = d));
56
+ if ((r = f.nextSub) !== void 0) {
57
+ f = r, u = h ? 64 : 32;
58
+ continue;
59
+ }
60
+ for (; h; ) {
61
+ --h;
62
+ const g = f.dep.subs;
63
+ if (f = g.prevSub, g.prevSub = void 0, (r = f.nextSub) !== void 0) {
64
+ f = r, u = h ? 64 : 32;
65
+ continue e;
66
+ }
67
+ }
68
+ break;
69
+ } while (!0);
70
+ },
71
+ /**
72
+ * Prepares the given subscriber to track new dependencies.
73
+ *
74
+ * It resets the subscriber's internal pointers (e.g., depsTail) and
75
+ * sets its flags to indicate it is now tracking dependency links.
76
+ *
77
+ * @param sub - The subscriber to start tracking.
78
+ */
79
+ startTracking(r) {
80
+ r.depsTail = void 0, r.flags = r.flags & -249 | 4;
81
+ },
82
+ /**
83
+ * Concludes tracking of dependencies for the specified subscriber.
84
+ *
85
+ * It clears or unlinks any tracked dependency information, then
86
+ * updates the subscriber's flags to indicate tracking is complete.
87
+ *
88
+ * @param sub - The subscriber whose tracking is ending.
89
+ */
90
+ endTracking(r) {
91
+ const u = r.depsTail;
92
+ if (u !== void 0) {
93
+ const f = u.nextDep;
94
+ f !== void 0 && (p(f), u.nextDep = void 0);
95
+ } else r.deps !== void 0 && (p(r.deps), r.deps = void 0);
96
+ r.flags &= -5;
97
+ },
98
+ /**
99
+ * Updates the dirty flag for the given subscriber based on its dependencies.
100
+ *
101
+ * If the subscriber has any pending computeds, this function sets the Dirty flag
102
+ * and returns `true`. Otherwise, it clears the PendingComputed flag and returns `false`.
103
+ *
104
+ * @param sub - The subscriber to update.
105
+ * @param flags - The current flag set for this subscriber.
106
+ * @returns `true` if the subscriber is marked as Dirty; otherwise `false`.
107
+ */
108
+ updateDirtyFlag(r, u) {
109
+ return o(r.deps) ? (r.flags = u | 32, !0) : (r.flags = u & -65, !1);
110
+ },
111
+ /**
112
+ * Updates the computed subscriber if necessary before its value is accessed.
113
+ *
114
+ * If the subscriber is marked Dirty or PendingComputed, this function runs
115
+ * the provided updateComputed logic and triggers a shallowPropagate for any
116
+ * downstream subscribers if an actual update occurs.
117
+ *
118
+ * @param computed - The computed subscriber to update.
119
+ * @param flags - The current flag set for this subscriber.
120
+ */
121
+ processComputedUpdate(r, u) {
122
+ if ((u & 32 || (o(r.deps) || (r.flags = u & -65, !1))) && n(r)) {
123
+ const f = r.subs;
124
+ f !== void 0 && c(f);
125
+ }
126
+ },
127
+ /**
128
+ * Ensures all pending internal effects for the given subscriber are processed.
129
+ *
130
+ * This should be called after an effect decides not to re-run itself but may still
131
+ * have dependencies flagged with PendingEffect. If the subscriber is flagged with
132
+ * PendingEffect, this function clears that flag and invokes `notifyEffect` on any
133
+ * related dependencies marked as Effect and Propagated, processing pending effects.
134
+ *
135
+ * @param sub - The subscriber which may have pending effects.
136
+ * @param flags - The current flags on the subscriber to check.
137
+ */
138
+ processPendingInnerEffects(r, u) {
139
+ if (u & 128) {
140
+ r.flags = u & -129;
141
+ let f = r.deps;
142
+ do {
143
+ const h = f.dep;
144
+ "flags" in h && h.flags & 2 && h.flags & 224 && e(h), f = f.nextDep;
145
+ } while (f !== void 0);
146
+ }
147
+ },
148
+ /**
149
+ * Processes queued effect notifications after a batch operation finishes.
150
+ *
151
+ * Iterates through all queued effects, calling notifyEffect on each.
152
+ * If an effect remains partially handled, its flags are updated, and future
153
+ * notifications may be triggered until fully handled.
154
+ */
155
+ processEffectNotifications() {
156
+ for (; t !== void 0; ) {
157
+ const r = t, u = r.depsTail, f = u.nextDep;
158
+ f !== void 0 ? (u.nextDep = void 0, t = f.sub) : (t = void 0, s = void 0), e(r) || (r.flags &= -9);
159
+ }
160
+ }
161
+ };
162
+ function i(r, u, f, h) {
163
+ const d = {
164
+ dep: r,
165
+ sub: u,
166
+ nextDep: f,
167
+ prevSub: void 0,
168
+ nextSub: void 0
169
+ };
170
+ if (h === void 0 ? u.deps = d : h.nextDep = d, r.subs === void 0)
171
+ r.subs = d;
172
+ else {
173
+ const m = r.subsTail;
174
+ d.prevSub = m, m.nextSub = d;
175
+ }
176
+ return u.depsTail = d, r.subsTail = d, d;
177
+ }
178
+ function o(r) {
179
+ let u = 0, f;
180
+ e: do {
181
+ f = !1;
182
+ const h = r.dep;
183
+ if ("flags" in h) {
184
+ const d = h.flags;
185
+ if ((d & 33) === 33) {
186
+ if (n(h)) {
187
+ const m = h.subs;
188
+ m.nextSub !== void 0 && c(m), f = !0;
189
+ }
190
+ } else if ((d & 65) === 65) {
191
+ const m = h.subs;
192
+ m.nextSub !== void 0 && (m.prevSub = r), r = h.deps, ++u;
193
+ continue;
194
+ }
195
+ }
196
+ if (!f && r.nextDep !== void 0) {
197
+ r = r.nextDep;
198
+ continue;
199
+ }
200
+ if (u) {
201
+ let d = r.sub;
202
+ do {
203
+ --u;
204
+ const m = d.subs;
205
+ if (f) {
206
+ if (n(d)) {
207
+ (r = m.prevSub) !== void 0 ? (m.prevSub = void 0, c(d.subs), d = r.sub) : d = m.sub;
208
+ continue;
209
+ }
210
+ } else
211
+ d.flags &= -65;
212
+ if ((r = m.prevSub) !== void 0) {
213
+ if (m.prevSub = void 0, r.nextDep !== void 0) {
214
+ r = r.nextDep;
215
+ continue e;
216
+ }
217
+ d = r.sub;
218
+ } else {
219
+ if ((r = m.nextDep) !== void 0)
220
+ continue e;
221
+ d = m.sub;
222
+ }
223
+ f = !1;
224
+ } while (u);
225
+ }
226
+ return f;
227
+ } while (!0);
228
+ }
229
+ function c(r) {
230
+ do {
231
+ const u = r.sub, f = u.flags;
232
+ (f & 96) === 64 && (u.flags = f | 32 | 8, (f & 10) === 2 && (s !== void 0 ? s.depsTail.nextDep = u.deps : t = u, s = u)), r = r.nextSub;
233
+ } while (r !== void 0);
234
+ }
235
+ function a(r, u) {
236
+ const f = u.depsTail;
237
+ if (f !== void 0) {
238
+ let h = u.deps;
239
+ do {
240
+ if (h === r)
241
+ return !0;
242
+ if (h === f)
243
+ break;
244
+ h = h.nextDep;
245
+ } while (h !== void 0);
246
+ }
247
+ return !1;
248
+ }
249
+ function p(r) {
250
+ do {
251
+ const u = r.dep, f = r.nextDep, h = r.nextSub, d = r.prevSub;
252
+ if (h !== void 0 ? h.prevSub = d : u.subsTail = d, d !== void 0 ? d.nextSub = h : u.subs = h, u.subs === void 0 && "deps" in u) {
253
+ const m = u.flags;
254
+ m & 32 || (u.flags = m | 32);
255
+ const _ = u.deps;
256
+ if (_ !== void 0) {
257
+ r = _, u.depsTail.nextDep = f, u.deps = void 0, u.depsTail = void 0;
258
+ continue;
259
+ }
260
+ }
261
+ r = f;
262
+ } while (r !== void 0);
263
+ }
264
+ }
265
+ function q(n) {
266
+ const e = typeof n;
267
+ switch (e) {
268
+ case "undefined":
269
+ return e;
270
+ case "number":
271
+ return isNaN(n) ? "NaN" : e;
272
+ case "function":
273
+ return /^\s*class\s+/.test(n.toString()) ? "class" : e;
274
+ case "object":
275
+ return n === null ? "null" : n instanceof Promise ? "promise" : n instanceof Map ? "map" : n instanceof Set ? "set" : Array.isArray(n) ? "array" : e;
276
+ default:
277
+ return e;
278
+ }
279
+ }
280
+ function $(n) {
281
+ return Array.isArray(n);
282
+ }
283
+ function De(...n) {
284
+ const e = n[0], t = (s) => $(s) && s.every((i) => e(i));
285
+ return n.length < 2 ? t : t(n[1]);
286
+ }
287
+ function Tt(...n) {
288
+ const e = n[0], t = P(n[2]) ? n[2] : "Expected an array of valid items. Got type: %t, value: %v", s = (i) => {
289
+ if ($(i) && i.every((o) => e(o)))
290
+ return !0;
291
+ throw new TypeError(K(i, t));
292
+ };
293
+ return n.length < 2 ? s : s(n[1]);
294
+ }
295
+ function P(n) {
296
+ return typeof n == "string";
297
+ }
298
+ function Nt(n, e) {
299
+ if (P(n))
300
+ return !0;
301
+ throw new TypeError(K(n, e ?? "Expected a string. Got type: %t, value: %v"));
302
+ }
303
+ function A(n) {
304
+ return typeof n == "function" && !Be(n);
305
+ }
306
+ function Fe(n) {
307
+ return typeof n == "number" && !isNaN(n);
308
+ }
309
+ function Be(n) {
310
+ return typeof n == "function" && /^\s*class\s+/.test(n.toString());
311
+ }
312
+ function At(...n) {
313
+ const e = n[0], t = P(n[2]) ? n[2] : `Expected instance of ${e.name}. Got type: %t, value: %v`, s = (i) => {
314
+ if (i instanceof e)
315
+ return !0;
316
+ throw new TypeError(K(i, t));
317
+ };
318
+ return n.length < 2 ? s : s(n[1]);
319
+ }
320
+ function te(n) {
321
+ return n != null && typeof n == "object" && !$(n);
322
+ }
323
+ function Dt(n, e) {
324
+ if (te(n))
325
+ return !0;
326
+ throw new TypeError(K(n, e));
327
+ }
328
+ function K(n, e) {
329
+ var i;
330
+ const t = q(n), s = ((i = n == null ? void 0 : n.toString) == null ? void 0 : i.call(n)) || String(n);
331
+ return e.replaceAll("%t", t).replaceAll("%v", s);
332
+ }
333
+ const ne = Symbol.for("DollaReactive"), se = Symbol("dependency"), {
334
+ link: ke,
335
+ propagate: He,
336
+ updateDirtyFlag: We,
337
+ startTracking: ie,
338
+ endTracking: re,
339
+ processEffectNotifications: Ke,
340
+ processComputedUpdate: Ze,
341
+ processPendingInnerEffects: Xe
342
+ } = ze({
343
+ updateComputed(n) {
344
+ const e = M;
345
+ M = n, ie(n);
346
+ try {
347
+ const t = n.currentValue, s = n.getter(t);
348
+ return n.equals(t, s) ? !1 : (n.currentValue = s, !0);
349
+ } finally {
350
+ M = e, re(n);
351
+ }
352
+ },
353
+ notifyEffect(n) {
354
+ const e = n.flags;
355
+ return e & D.Dirty || e & D.PendingComputed && We(n, e) ? Oe(n) : Xe(n, n.flags), !0;
356
+ }
357
+ });
358
+ let M;
359
+ const j = [];
360
+ let X = !1;
361
+ function Ye() {
362
+ X || (X = !0, queueMicrotask(() => {
363
+ X = !1;
364
+ for (let n = 0; n < j.length; n++) {
365
+ const e = j[n], t = M;
366
+ M = e, ie(e);
367
+ try {
368
+ e.fn();
369
+ } finally {
370
+ M = t, re(e);
371
+ }
372
+ }
373
+ j.length = 0;
374
+ }));
375
+ }
376
+ function Oe(n) {
377
+ j.push(n), Ye();
378
+ }
379
+ function Je() {
380
+ ie(this), re(this), queueMicrotask(() => {
381
+ j.splice(j.indexOf(this), 1);
382
+ });
383
+ }
384
+ var N, R;
385
+ class Qe {
386
+ constructor(e, t) {
387
+ L(this, N);
388
+ L(this, R);
389
+ /**
390
+ * A label for debugging purposes.
391
+ */
392
+ l(this, "name");
393
+ I(this, N, e), I(this, R, (t == null ? void 0 : t.equals) ?? Object.is), t != null && t.name && (this.name = t.name), Object.defineProperties(this, {
394
+ [ne]: {
395
+ value: !0,
396
+ configurable: !1,
397
+ enumerable: !1,
398
+ writable: !1
399
+ },
400
+ [se]: {
401
+ value: e,
402
+ configurable: !1,
403
+ enumerable: !1,
404
+ writable: !1
405
+ }
406
+ });
407
+ }
408
+ get value() {
409
+ return T(this, N).currentValue;
410
+ }
411
+ set value(e) {
412
+ if (!T(this, R).call(this, T(this, N).currentValue, e)) {
413
+ T(this, N).currentValue = e;
414
+ const t = T(this, N).subs;
415
+ t !== void 0 && (He(t), Ke());
416
+ }
417
+ }
418
+ }
419
+ N = new WeakMap(), R = new WeakMap();
420
+ var V;
421
+ class et {
422
+ constructor(e) {
423
+ L(this, V);
424
+ I(this, V, e), Object.defineProperties(this, {
425
+ [ne]: {
426
+ value: !0,
427
+ configurable: !1,
428
+ enumerable: !1,
429
+ writable: !1
430
+ },
431
+ [se]: {
432
+ value: e,
433
+ configurable: !1,
434
+ enumerable: !1,
435
+ writable: !1
436
+ }
437
+ });
438
+ }
439
+ get value() {
440
+ const e = T(this, V), t = e.flags;
441
+ return t & (D.Dirty | D.PendingComputed) && Ze(e, t), e.currentValue;
442
+ }
443
+ }
444
+ V = new WeakMap();
445
+ function w(n) {
446
+ return n != null && n[ne] === !0;
447
+ }
448
+ function Q(n, e) {
449
+ return new Qe({ currentValue: n, subs: void 0, subsTail: void 0 }, e);
450
+ }
451
+ function oe(n, e) {
452
+ return new et({
453
+ currentValue: void 0,
454
+ equals: (e == null ? void 0 : e.equals) ?? Object.is,
455
+ subs: void 0,
456
+ subsTail: void 0,
457
+ deps: void 0,
458
+ depsTail: void 0,
459
+ flags: D.Computed | D.Dirty,
460
+ getter: (t) => {
461
+ let s = n(t);
462
+ return s = S(s), s;
463
+ }
464
+ });
465
+ }
466
+ function tt(n, e) {
467
+ if (A(e))
468
+ n.value = e(n.value);
469
+ else if (arguments.length > 1)
470
+ n.value = e;
471
+ else
472
+ return (t) => tt(n, t);
473
+ }
474
+ function S(n) {
475
+ if (w(n)) {
476
+ if (M !== void 0) {
477
+ const e = n[se];
478
+ ke(e, M);
479
+ }
480
+ return n.value;
481
+ } else
482
+ return n;
483
+ }
484
+ function kt(n) {
485
+ return w(n) ? n.value : n;
486
+ }
487
+ function b(n) {
488
+ const e = {
489
+ fn: n,
490
+ subs: void 0,
491
+ subsTail: void 0,
492
+ deps: void 0,
493
+ depsTail: void 0,
494
+ flags: D.Effect
495
+ };
496
+ return M !== void 0 && ke(e, M), Oe(e), Je.bind(e);
497
+ }
498
+ function Pe(n) {
499
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
500
+ }
501
+ var z = { exports: {} }, ge;
502
+ function nt() {
503
+ return ge || (ge = 1, function(n, e) {
504
+ Object.defineProperty(e, "__esModule", { value: !0 });
505
+ var t = /* @__PURE__ */ function() {
506
+ function p(r, u) {
507
+ var f = [], h = !0, d = !1, m = void 0;
508
+ try {
509
+ for (var _, g = r[Symbol.iterator](); !(h = (_ = g.next()).done) && (f.push(_.value), !(u && f.length === u)); h = !0) ;
510
+ } catch (y) {
511
+ d = !0, m = y;
512
+ } finally {
513
+ try {
514
+ !h && g.return && g.return();
515
+ } finally {
516
+ if (d) throw m;
517
+ }
518
+ }
519
+ return f;
520
+ }
521
+ return function(r, u) {
522
+ if (Array.isArray(r)) return r;
523
+ if (Symbol.iterator in Object(r)) return p(r, u);
524
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
525
+ };
526
+ }(), s = function(p) {
527
+ return p.reduce(function(r, u) {
528
+ return 16 > u ? r + "0" + u.toString(16) : r + u.toString(16);
529
+ }, "#");
530
+ }, i = function(p, r, u) {
531
+ var f = 0.5 > u ? u * (1 + r) : u + r - u * r, h = 2 * u - f, d = function(y, C, x) {
532
+ var Z = Math.round, v = 0 > x ? x + 1 : 1 < x ? x - 1 : x;
533
+ return v = v < 1 / 6 ? y + 6 * (C - y) * v : v < 1 / 2 ? C : v < 2 / 3 ? y + 6 * (C - y) * (2 / 3 - v) : y, Z(255 * v);
534
+ }, m = d(h, f, p + 1 / 3), _ = d(h, f, p), g = d(h, f, p - 1 / 3);
535
+ return [m, _, g];
536
+ }, o = function(p, r, u, f) {
537
+ var h = p % 1007 / 1007, d = function(y, C, x) {
538
+ return y * (x - C) + C;
539
+ }, m = d(h, r.min, r.max), _ = d(h, u.min, u.max), g = d(h, f.max, f.min);
540
+ return [m, _, g];
541
+ }, c = function(p) {
542
+ return p.split("").reduce(function(r, u, f) {
543
+ return r * u.charCodeAt(0) * f + 1;
544
+ }, 1);
545
+ }, a = function(p) {
546
+ var r = p.str, u = p.hue, f = u === void 0 ? { min: 0, max: 360 } : u, h = p.sat, d = h === void 0 ? { min: 0.35, max: 0.65 } : h, m = p.light, _ = m === void 0 ? { min: 0.3, max: 0.7 } : m, g = p.hashFunction, y = g === void 0 ? c : g, C = p.scheme, x = C === void 0 ? "hex" : C, Z = o(y(r), f, d, _), v = t(Z, 3), ae = v[0], de = v[1], he = v[2], pe = i(ae / 360, de, he), Ve = s(pe);
547
+ return x === "hsl" ? [ae, de, he] : x === "rgb" ? pe : Ve;
548
+ };
549
+ e.default = a, n.exports = e.default;
550
+ }(z, z.exports)), z.exports;
551
+ }
552
+ var st = nt();
553
+ const it = /* @__PURE__ */ Pe(st);
554
+ var Y, we;
555
+ function rt() {
556
+ return we || (we = 1, Y = function n(e, t) {
557
+ if (e === t) return !0;
558
+ if (e && t && typeof e == "object" && typeof t == "object") {
559
+ if (e.constructor !== t.constructor) return !1;
560
+ var s, i, o;
561
+ if (Array.isArray(e)) {
562
+ if (s = e.length, s != t.length) return !1;
563
+ for (i = s; i-- !== 0; )
564
+ if (!n(e[i], t[i])) return !1;
565
+ return !0;
566
+ }
567
+ if (e instanceof Map && t instanceof Map) {
568
+ if (e.size !== t.size) return !1;
569
+ for (i of e.entries())
570
+ if (!t.has(i[0])) return !1;
571
+ for (i of e.entries())
572
+ if (!n(i[1], t.get(i[0]))) return !1;
573
+ return !0;
574
+ }
575
+ if (e instanceof Set && t instanceof Set) {
576
+ if (e.size !== t.size) return !1;
577
+ for (i of e.entries())
578
+ if (!t.has(i[0])) return !1;
579
+ return !0;
580
+ }
581
+ if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
582
+ if (s = e.length, s != t.length) return !1;
583
+ for (i = s; i-- !== 0; )
584
+ if (e[i] !== t[i]) return !1;
585
+ return !0;
586
+ }
587
+ if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
588
+ if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
589
+ if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
590
+ if (o = Object.keys(e), s = o.length, s !== Object.keys(t).length) return !1;
591
+ for (i = s; i-- !== 0; )
592
+ if (!Object.prototype.hasOwnProperty.call(t, o[i])) return !1;
593
+ for (i = s; i-- !== 0; ) {
594
+ var c = o[i];
595
+ if (!n(e[c], t[c])) return !1;
596
+ }
597
+ return !0;
598
+ }
599
+ return e !== e && t !== t;
600
+ }), Y;
601
+ }
602
+ var ot = rt();
603
+ const ut = /* @__PURE__ */ Pe(ot), Ot = () => {
604
+ };
605
+ let J = 1;
606
+ function ue() {
607
+ return J = J % Number.MAX_SAFE_INTEGER + 1, J.toString(36) + Date.now().toString(36);
608
+ }
609
+ function Pt(n, e) {
610
+ return Object.is(n, e);
611
+ }
612
+ function Lt(n, e) {
613
+ if (Object.is(n, e)) return !0;
614
+ const t = q(n);
615
+ if (t !== q(e))
616
+ return !1;
617
+ switch (t) {
618
+ case "object":
619
+ let s = 0;
620
+ for (const i in n) {
621
+ if (n[i] !== e[i]) return !1;
622
+ s++;
623
+ }
624
+ return Object.keys(e).length === s;
625
+ case "array":
626
+ if (n.length !== e.length) return !1;
627
+ for (let i = 0; i < n.length; i++)
628
+ if (n[i] !== e[i]) return !1;
629
+ return !0;
630
+ case "map":
631
+ if (n.size !== e.size) return !1;
632
+ for (const i of n.keys())
633
+ if (n[i] !== e[i]) return !1;
634
+ return !0;
635
+ case "set":
636
+ if (A(n.symmetricDifference))
637
+ return n.symmetricDifference(e).size === 0;
638
+ for (const i of n.keys())
639
+ if (n[i] !== e.get(i)) return !1;
640
+ return !0;
641
+ }
642
+ return !1;
643
+ }
644
+ const It = ut;
645
+ function ft(n, e) {
646
+ const t = (s) => {
647
+ const i = {};
648
+ for (const o in s)
649
+ n.includes(o) || (i[o] = s[o]);
650
+ return i;
651
+ };
652
+ return e == null ? t : t(e);
653
+ }
654
+ function jt(n) {
655
+ return it({
656
+ str: n,
657
+ sat: { min: 0.35, max: 0.55 },
658
+ light: { min: 0.6, max: 0.6 }
659
+ });
660
+ }
661
+ function $t(n) {
662
+ if (n instanceof RegExp)
663
+ return (s) => n.test(s);
664
+ const e = {
665
+ positive: [],
666
+ negative: []
667
+ }, t = n.split(",").map((s) => s.trim()).filter((s) => s !== "");
668
+ for (let s of t) {
669
+ let i = "positive";
670
+ s.startsWith("-") && (i = "negative", s = s.slice(1)), s === "*" ? e[i].push(function() {
671
+ return !0;
672
+ }) : s.endsWith("*") ? e[i].push(function(o) {
673
+ return o.startsWith(s.slice(0, s.length - 1));
674
+ }) : e[i].push(function(o) {
675
+ return o === s;
676
+ });
677
+ }
678
+ return function(s) {
679
+ const { positive: i, negative: o } = e;
680
+ return !(o.some((c) => c(s)) || i.length > 0 && !i.some((c) => c(s)));
681
+ };
682
+ }
683
+ const qt = Symbol.for("DollaRef"), Le = Symbol.for("DollaMarkup"), k = Symbol.for("DollaMarkupElement"), Rt = Symbol.for("DollaRouter");
684
+ function Vt(n, e) {
685
+ return e.outlet();
686
+ }
687
+ function ct(n) {
688
+ for (var e, t, s = arguments, i = 1, o = "", c = "", a = [0], p = function(f) {
689
+ i === 1 && (f || (o = o.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? a.push(f ? s[f] : o) : i === 3 && (f || o) ? (a[1] = f ? s[f] : o, i = 2) : i === 2 && o === "..." && f ? a[2] = Object.assign(a[2] || {}, s[f]) : i === 2 && o && !f ? (a[2] = a[2] || {})[o] = !0 : i >= 5 && (i === 5 ? ((a[2] = a[2] || {})[t] = f ? o ? o + s[f] : s[f] : o, i = 6) : (f || o) && (a[2][t] += f ? o + s[f] : o)), o = "";
690
+ }, r = 0; r < n.length; r++) {
691
+ r && (i === 1 && p(), p(r));
692
+ for (var u = 0; u < n[r].length; u++) e = n[r][u], i === 1 ? e === "<" ? (p(), a = [a, "", null], i = 3) : o += e : i === 4 ? o === "--" && e === ">" ? (i = 1, o = "") : o = e + o[0] : c ? e === c ? c = "" : o += e : e === '"' || e === "'" ? c = e : e === ">" ? (p(), i = 1) : i && (e === "=" ? (i = 5, t = o, o = "") : e === "/" && (i < 5 || n[r][u + 1] === ">") ? (p(), i === 3 && (a = a[0]), i = a, (a = a[0]).push(this.apply(null, i.slice(1))), i = 0) : e === " " || e === " " || e === `
693
+ ` || e === "\r" ? (p(), i = 2) : o += e), i === 3 && o === "!--" && (i = 4, a = a[0]);
694
+ }
695
+ return p(), a.length > 2 ? a.slice(1) : a[1];
696
+ }
697
+ var xe;
698
+ xe = k;
699
+ class be {
700
+ constructor(e) {
701
+ l(this, xe, !0);
702
+ l(this, "node");
703
+ this.node = e;
704
+ }
705
+ get isMounted() {
706
+ return this.node.parentNode != null;
707
+ }
708
+ mount(e, t) {
709
+ e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null);
710
+ }
711
+ unmount(e = !1) {
712
+ this.node.parentNode && !e && this.node.parentNode.removeChild(this.node);
713
+ }
714
+ }
715
+ var Se;
716
+ Se = k;
717
+ class lt {
718
+ constructor(e) {
719
+ l(this, Se, !0);
720
+ l(this, "node", document.createTextNode(""));
721
+ l(this, "children", []);
722
+ l(this, "elementContext");
723
+ l(this, "source");
724
+ l(this, "unsubscribe");
725
+ this.source = e.source, this.elementContext = e.elementContext;
726
+ }
727
+ get isMounted() {
728
+ return this.node.parentNode != null;
729
+ }
730
+ mount(e, t) {
731
+ this.isMounted || (e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), this.unsubscribe = b(() => {
732
+ const s = S(this.source);
733
+ if (!Re(s))
734
+ throw console.error(s), new TypeError(
735
+ `Dynamic received invalid value to render. Got type: ${q(s)}, value: ${s}`
736
+ );
737
+ this.update($(s) ? s : [s]);
738
+ }));
739
+ }
740
+ unmount(e = !1) {
741
+ var t, s;
742
+ (t = this.unsubscribe) == null || t.call(this), this.isMounted && (this.cleanup(e), (s = this.node.parentNode) == null || s.removeChild(this.node));
743
+ }
744
+ cleanup(e) {
745
+ for (const t of this.children)
746
+ t.unmount(e);
747
+ this.children = [];
748
+ }
749
+ update(e) {
750
+ var o, c, a;
751
+ if (this.cleanup(!1), e == null || e.length === 0 || !this.isMounted)
752
+ return;
753
+ const t = e.flatMap((p) => qe(p) ? p : O(this.elementContext, ce(p)));
754
+ for (const p of t) {
755
+ const r = ((o = this.children.at(-1)) == null ? void 0 : o.node) || this.node;
756
+ p.mount(this.node.parentNode, r), this.children.push(p);
757
+ }
758
+ const s = this.node.parentNode, i = ((a = (c = this.children.at(-1)) == null ? void 0 : c.node) == null ? void 0 : a.nextSibling) ?? null;
759
+ s.insertBefore(this.node, i);
760
+ }
761
+ }
762
+ const at = (n) => /^on[A-Z]/.test(n);
763
+ var Me;
764
+ Me = k;
765
+ class dt {
766
+ constructor({ tag: e, props: t, children: s, elementContext: i }) {
767
+ l(this, Me, !0);
768
+ l(this, "node");
769
+ l(this, "props");
770
+ l(this, "childMarkup", []);
771
+ l(this, "children", []);
772
+ l(this, "unsubscribers", []);
773
+ l(this, "elementContext");
774
+ l(this, "uniqueId", ue());
775
+ // Track the ref so we can nullify it on unmount.
776
+ l(this, "ref");
777
+ // Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
778
+ l(this, "canClickAway", !1);
779
+ if (i = { ...i }, e.toLowerCase() === "svg" && (i.isSVG = !0), i.isSVG ? this.node = document.createElementNS("http://www.w3.org/2000/svg", e) : this.node = document.createElement(e), t.ref)
780
+ if (A(t.ref))
781
+ this.ref = t.ref, this.ref(this.node);
782
+ else
783
+ throw new Error("Expected ref to be a function. Got: " + t.ref);
784
+ this.props = {
785
+ ...ft(["ref", "class", "className"], t),
786
+ class: t.className ?? t.class
787
+ }, s && (this.childMarkup = s), this.elementContext = i, this.children = O(this.elementContext, this.childMarkup);
788
+ }
789
+ get isMounted() {
790
+ return this.node.parentNode != null;
791
+ }
792
+ mount(e, t) {
793
+ if (e == null)
794
+ throw new Error(`HTML element requires a parent element as the first argument to connect. Got: ${e}`);
795
+ if (!this.isMounted) {
796
+ for (let s = 0; s < this.children.length; s++) {
797
+ const i = this.children[s], o = s > 0 ? this.children[s - 1].node : void 0;
798
+ i.mount(this.node, o);
799
+ }
800
+ this.applyProps(this.node, this.props), this.props.style && this.applyStyles(this.node, this.props.style, this.unsubscribers), this.props.class && this.applyClasses(this.node, this.props.class, this.unsubscribers);
801
+ }
802
+ e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), setTimeout(() => {
803
+ this.canClickAway = !0;
804
+ }, 0);
805
+ }
806
+ unmount(e = !1) {
807
+ var t;
808
+ if (this.isMounted) {
809
+ for (const s of this.children)
810
+ s.unmount(!0);
811
+ e || (t = this.node.parentNode) == null || t.removeChild(this.node), this.ref && this.ref(void 0), this.canClickAway = !1;
812
+ for (const s of this.unsubscribers)
813
+ s();
814
+ this.unsubscribers.length = 0;
815
+ }
816
+ }
817
+ getUpdateKey(e, t) {
818
+ return `${this.uniqueId}:${e}:${t}`;
819
+ }
820
+ attachProp(e, t) {
821
+ w(e) ? this.unsubscribers.push(b(() => t(S(e)))) : t(e);
822
+ }
823
+ applyProps(e, t) {
824
+ for (const s in t) {
825
+ const i = t[s];
826
+ if (s === "attributes") {
827
+ const o = i;
828
+ for (const c in o)
829
+ this.attachProp(o[c], (a) => {
830
+ a == null ? e.removeAttribute(c) : e.setAttribute(c, String(a));
831
+ });
832
+ } else if (s === "onClickOutside" || s === "onclickoutside") {
833
+ const o = (a) => {
834
+ this.canClickAway && !e.contains(a.target) && (w(i) ? i.value(a) : i(a));
835
+ }, c = { capture: !0 };
836
+ window.addEventListener("click", o, c), this.unsubscribers.push(() => {
837
+ window.removeEventListener("click", o, c);
838
+ });
839
+ } else if (at(s)) {
840
+ const o = s.slice(2).toLowerCase(), c = w(i) ? (a) => i.value(a) : i;
841
+ e.addEventListener(o, c), this.unsubscribers.push(() => {
842
+ e.removeEventListener(o, c);
843
+ });
844
+ } else if (s.includes("-"))
845
+ this.attachProp(i, (o) => {
846
+ o == null ? e.removeAttribute(s) : e.setAttribute(s, String(o));
847
+ });
848
+ else if (!ht.includes(s))
849
+ if (this.elementContext.isSVG)
850
+ this.attachProp(i, (o) => {
851
+ o != null ? e.setAttribute(s, String(t[s])) : e.removeAttribute(s);
852
+ });
853
+ else
854
+ switch (s) {
855
+ case "contentEditable":
856
+ case "value":
857
+ this.attachProp(i, (o) => {
858
+ e[s] = String(o);
859
+ });
860
+ break;
861
+ case "for":
862
+ this.attachProp(i, (o) => {
863
+ e.htmlFor = o;
864
+ });
865
+ break;
866
+ case "checked":
867
+ this.attachProp(i, (o) => {
868
+ e.checked = o, o ? e.setAttribute("checked", "") : e.removeAttribute("checked");
869
+ });
870
+ break;
871
+ // Attribute-aliased props
872
+ case "exportParts":
873
+ case "part":
874
+ case "translate":
875
+ case "type":
876
+ case "title": {
877
+ const o = s.toLowerCase();
878
+ this.attachProp(i, (c) => {
879
+ c == null ? e.removeAttribute(o) : e.setAttribute(o, String(c));
880
+ });
881
+ break;
882
+ }
883
+ case "autocomplete":
884
+ case "autocapitalize":
885
+ this.attachProp(i, (o) => {
886
+ typeof o == "string" ? e.autocomplete = o : o ? e.autocomplete = "on" : e.autocomplete = "off";
887
+ });
888
+ break;
889
+ default: {
890
+ this.attachProp(i, (o) => {
891
+ e[s] = o;
892
+ });
893
+ break;
894
+ }
895
+ }
896
+ }
897
+ }
898
+ applyStyles(e, t, s) {
899
+ const i = [];
900
+ if (w(t)) {
901
+ let o;
902
+ const c = b(() => {
903
+ A(o) && o(), e.style.cssText = "", o = this.applyStyles(e, S(t), s);
904
+ });
905
+ s.push(c), i.push(c);
906
+ } else {
907
+ const o = je(t);
908
+ for (const c in o) {
909
+ const { value: a, priority: p } = o[c];
910
+ if (w(a)) {
911
+ const r = b(() => {
912
+ S(a) ? e.style.setProperty(c, String(a.value), p) : e.style.removeProperty(c);
913
+ });
914
+ s.push(r), i.push(r);
915
+ } else a != null && e.style.setProperty(c, String(a));
916
+ }
917
+ }
918
+ return function() {
919
+ for (const c of i)
920
+ c(), s.splice(s.indexOf(c), 1);
921
+ };
922
+ }
923
+ applyClasses(e, t, s) {
924
+ const i = [];
925
+ if (w(t)) {
926
+ let o;
927
+ const c = b(() => {
928
+ A(o) && o(), e.removeAttribute("class"), o = this.applyClasses(e, S(t), s);
929
+ });
930
+ s.push(c), i.push(c);
931
+ } else {
932
+ const o = Ie(t);
933
+ for (const c in o) {
934
+ const a = o[c];
935
+ if (w(a)) {
936
+ const p = b(() => {
937
+ S(a) ? e.classList.add(c) : e.classList.remove(c);
938
+ });
939
+ s.push(p), i.push(p);
940
+ } else a && e.classList.add(c);
941
+ }
942
+ }
943
+ return function() {
944
+ for (const c of i)
945
+ c(), s.splice(s.indexOf(c), 1);
946
+ };
947
+ }
948
+ }
949
+ function Ie(n) {
950
+ let e = {};
951
+ if (P(n)) {
952
+ const t = n.split(" ");
953
+ for (const s of t)
954
+ e[s] = !0;
955
+ } else te(n) ? Object.assign(e, n) : Array.isArray(n) && Array.from(n).filter(Boolean).forEach((t) => {
956
+ Object.assign(e, Ie(t));
957
+ });
958
+ return delete e.undefined, e;
959
+ }
960
+ function je(n) {
961
+ let e = {};
962
+ if (P(n)) {
963
+ const t = n.split(";").filter((s) => s.trim() !== "");
964
+ for (const s of t) {
965
+ const [i, o] = s.split(":"), c = {
966
+ value: o
967
+ };
968
+ o.includes("!important") ? (c.priority = "important", c.value = o.replace("!important", "").trim()) : c.value = o.trim(), e[ye(i.trim())] = c;
969
+ }
970
+ }
971
+ if (te(n))
972
+ for (const t in n)
973
+ t.startsWith("--") ? e[t] = { value: n[t] } : e[ye(t)] = { value: n[t] };
974
+ else Array.isArray(n) && Array.from(n).filter((t) => t != null).forEach((t) => {
975
+ Object.assign(e, je(t));
976
+ });
977
+ return e;
978
+ }
979
+ function ye(n) {
980
+ return n.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (e, t) => (t ? "-" : "") + e.toLowerCase());
981
+ }
982
+ const ht = ["ref", "children", "class", "style", "data"];
983
+ var pt = Object.defineProperty, mt = (n, e, t) => e in n ? pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, ve = (n, e, t) => mt(n, typeof e != "symbol" ? e + "" : e, t);
984
+ class ee {
985
+ constructor() {
986
+ ve(this, "_l", /* @__PURE__ */ new Map()), ve(this, "_a", (e) => {
987
+ if (typeof e != "string" && !(e instanceof Symbol))
988
+ throw new TypeError("Emitter: eventName should be a string or symbol");
989
+ });
990
+ }
991
+ emit(e, ...t) {
992
+ let s = this.listeners(e);
993
+ for (const i of s)
994
+ try {
995
+ i(...t);
996
+ } catch (o) {
997
+ let c = this._l.get("error");
998
+ if (c != null && c.length)
999
+ for (const a of c)
1000
+ a(o, e, i, ...t);
1001
+ else throw o;
1002
+ }
1003
+ return e != "*" && this.emit("*", e, ...t) || s.length > 0;
1004
+ }
1005
+ on(e, t) {
1006
+ return this.listeners(e).push(t), this;
1007
+ }
1008
+ off(e, t) {
1009
+ const s = this.listeners(e);
1010
+ return s.splice(s.indexOf(t), 1), this;
1011
+ }
1012
+ once(e, t) {
1013
+ return this.on(e, (...s) => {
1014
+ t(...s), this.off(e, t);
1015
+ });
1016
+ }
1017
+ clear() {
1018
+ this._l.clear();
1019
+ }
1020
+ listeners(e) {
1021
+ return this._l.get(e) ?? (this._a(e), this._l.set(e, []).get(e));
1022
+ }
1023
+ events() {
1024
+ return [...this._l.entries()].filter(([, e]) => e.length).map(([e]) => e);
1025
+ }
1026
+ }
1027
+ var U, G;
1028
+ class fe {
1029
+ constructor(e) {
1030
+ L(this, U);
1031
+ L(this, G, !1);
1032
+ I(this, U, e);
1033
+ }
1034
+ get type() {
1035
+ return T(this, U);
1036
+ }
1037
+ get isStopped() {
1038
+ return T(this, G);
1039
+ }
1040
+ stop() {
1041
+ I(this, G, !0);
1042
+ }
1043
+ get [Symbol.toStringTag]() {
1044
+ return "ContextEvent";
1045
+ }
1046
+ }
1047
+ U = new WeakMap(), G = new WeakMap();
1048
+ let _t = class {
1049
+ constructor(e) {
1050
+ l(this, "__store");
1051
+ this.__store = e;
1052
+ const t = Object.getOwnPropertyDescriptors(this.__store._logger);
1053
+ for (const s in t)
1054
+ s !== "setName" && Object.defineProperty(this, s, t[s]);
1055
+ }
1056
+ get isMounted() {
1057
+ return this.__store.isMounted;
1058
+ }
1059
+ get name() {
1060
+ return this.__store._name;
1061
+ }
1062
+ set name(e) {
1063
+ this.__store._name = e, this.__store._logger.setName(e);
1064
+ }
1065
+ on(e, t) {
1066
+ if (e === "*") {
1067
+ const s = (i, o, ...c) => {
1068
+ t(o, ...c);
1069
+ };
1070
+ this.__store._elementContext.emitter.on(e, s), this.__store._wildcardListeners.set(t, s);
1071
+ } else
1072
+ this.__store._elementContext.emitter.on(e, t);
1073
+ }
1074
+ off(e, t) {
1075
+ if (e === "*") {
1076
+ const s = this.__store._wildcardListeners.get(t);
1077
+ s && (this.__store._elementContext.emitter.off(e, s), this.__store._wildcardListeners.delete(t));
1078
+ } else
1079
+ this.__store._elementContext.emitter.off(e, t);
1080
+ }
1081
+ once(e, t) {
1082
+ if (e === "*") {
1083
+ const s = (i, o, ...c) => {
1084
+ this.__store._wildcardListeners.delete(t), t(o, ...c);
1085
+ };
1086
+ this.__store._elementContext.emitter.once(e, s), this.__store._wildcardListeners.set(t, s);
1087
+ } else
1088
+ this.__store._elementContext.emitter.once(e, t);
1089
+ }
1090
+ emit(e, ...t) {
1091
+ return this.__store._elementContext.emitter.emit(e, new fe(e), ...t);
1092
+ }
1093
+ get(e) {
1094
+ if (A(e)) {
1095
+ let t = this.__store._elementContext, s;
1096
+ for (; s = t.stores.get(e), s == null && t.parent != null; )
1097
+ t = t.parent;
1098
+ if (s == null)
1099
+ throw new B(`Store '${e.name}' is not provided on this context.`);
1100
+ return s.value;
1101
+ } else
1102
+ throw new B("Invalid store.");
1103
+ }
1104
+ onMount(e) {
1105
+ this.__store._emitter.on("mounted", e);
1106
+ }
1107
+ onUnmount(e) {
1108
+ this.__store._emitter.on("unmounted", e);
1109
+ }
1110
+ effect(e) {
1111
+ const t = this.__store;
1112
+ if (t.isMounted) {
1113
+ const s = b(e);
1114
+ return t._unsubscribes.push(s), s;
1115
+ } else {
1116
+ let s, i = !1;
1117
+ return t._emitter.on("mounted", () => {
1118
+ i || (s = b(e), t._unsubscribes.push(s));
1119
+ }), () => {
1120
+ s != null && (i = !0, s());
1121
+ };
1122
+ }
1123
+ }
1124
+ };
1125
+ class gt {
1126
+ constructor(e, t) {
1127
+ l(this, "fn");
1128
+ l(this, "_options");
1129
+ /**
1130
+ * Value is guaranteed to be set after `attach` is called.
1131
+ */
1132
+ l(this, "value");
1133
+ l(this, "isMounted", !1);
1134
+ l(this, "_elementContext");
1135
+ l(this, "_emitter", new ee());
1136
+ l(this, "_wildcardListeners", /* @__PURE__ */ new Map());
1137
+ l(this, "_logger");
1138
+ l(this, "_unsubscribes", []);
1139
+ l(this, "_name");
1140
+ l(this, "_id", ue());
1141
+ this.fn = e, this._name = e.name, this._options = t;
1142
+ }
1143
+ get name() {
1144
+ return this._name || this._id;
1145
+ }
1146
+ /**
1147
+ * Attaches this Store to the elementContext.
1148
+ * Returns false if there was already an instance attached, and true otherwise.
1149
+ */
1150
+ attach(e) {
1151
+ if (e.stores.has(this.fn))
1152
+ return !1;
1153
+ this._elementContext = e, this._logger = e.root.createLogger(this._name), this._emitter.on("error", (s, i, ...o) => {
1154
+ this._logger.error({ error: s, eventName: i, args: o }), this._logger.crash(s);
1155
+ });
1156
+ const t = new _t(this);
1157
+ try {
1158
+ this.value = this.fn.call(t, this._options, t);
1159
+ } catch (s) {
1160
+ throw this._logger.crash(s), s;
1161
+ }
1162
+ return e.stores.set(this.fn, this), !0;
1163
+ }
1164
+ handleMount() {
1165
+ this.isMounted = !0, this._emitter.emit("mounted");
1166
+ }
1167
+ handleUnmount() {
1168
+ this.isMounted = !1, this._emitter.emit("unmounted"), this._emitter.clear();
1169
+ for (const e of this._unsubscribes)
1170
+ e();
1171
+ this._unsubscribes.length = 0;
1172
+ }
1173
+ }
1174
+ class B extends Error {
1175
+ }
1176
+ class wt {
1177
+ constructor(e) {
1178
+ l(this, "__view");
1179
+ l(this, "list", Mt);
1180
+ l(this, "if", St);
1181
+ l(this, "portal", Et);
1182
+ this.__view = e;
1183
+ const t = Object.getOwnPropertyDescriptors(this.__view._logger);
1184
+ for (const s in t)
1185
+ s !== "setName" && Object.defineProperty(this, s, t[s]);
1186
+ }
1187
+ get uid() {
1188
+ return this.__view.uniqueId;
1189
+ }
1190
+ get isMounted() {
1191
+ return this.__view.isMounted;
1192
+ }
1193
+ get name() {
1194
+ return this.__view._elementContext.viewName || this.__view.uniqueId;
1195
+ }
1196
+ set name(e) {
1197
+ this.__view._elementContext.viewName = e, this.__view._logger.setName(e);
1198
+ }
1199
+ on(e, t) {
1200
+ if (e === "*") {
1201
+ const s = (i, o, ...c) => {
1202
+ t(o, ...c);
1203
+ };
1204
+ this.__view._elementContext.emitter.on(e, s), this.__view._wildcardListeners.set(t, s);
1205
+ } else
1206
+ this.__view._elementContext.emitter.on(e, t);
1207
+ }
1208
+ off(e, t) {
1209
+ if (e === "*") {
1210
+ const s = this.__view._wildcardListeners.get(t);
1211
+ s && (this.__view._elementContext.emitter.off(e, s), this.__view._wildcardListeners.delete(t));
1212
+ } else
1213
+ this.__view._elementContext.emitter.off(e, t);
1214
+ }
1215
+ once(e, t) {
1216
+ if (e === "*") {
1217
+ const s = (i, o, ...c) => {
1218
+ this.__view._wildcardListeners.delete(t), t(o, ...c);
1219
+ };
1220
+ this.__view._elementContext.emitter.once(e, s), this.__view._wildcardListeners.set(t, s);
1221
+ } else
1222
+ this.__view._elementContext.emitter.once(e, t);
1223
+ }
1224
+ emit(e, ...t) {
1225
+ return this.__view._elementContext.emitter.emit(e, new fe(e), ...t);
1226
+ }
1227
+ provide(e, t) {
1228
+ const s = new gt(e, t);
1229
+ if (s.attach(this.__view._elementContext))
1230
+ return this.__view._emitter.on("mounted", () => {
1231
+ s.handleMount();
1232
+ }), this.__view._emitter.on("unmounted", () => {
1233
+ s.handleUnmount();
1234
+ }), s.value;
1235
+ {
1236
+ let o = e.name ? `'${e.name}'` : "this store";
1237
+ return this.__view._logger.warn(`An instance of ${o} was already attached to this context.`), this.get(e);
1238
+ }
1239
+ }
1240
+ get(e) {
1241
+ if (A(e)) {
1242
+ let t = this.__view._elementContext, s;
1243
+ for (; s = t.stores.get(e), s == null && t.parent != null; )
1244
+ t = t.parent;
1245
+ if (s == null)
1246
+ throw new B(`Store '${e.name}' is not provided on this context.`);
1247
+ return s.value;
1248
+ } else
1249
+ throw new B("Invalid store.");
1250
+ }
1251
+ beforeMount(e) {
1252
+ this.__view._emitter.on("beforeMount", e);
1253
+ }
1254
+ onMount(e) {
1255
+ this.__view._emitter.on("mounted", e);
1256
+ }
1257
+ beforeUnmount(e) {
1258
+ this.__view._emitter.on("beforeUnmount", e);
1259
+ }
1260
+ onUnmount(e) {
1261
+ this.__view._emitter.on("unmounted", e);
1262
+ }
1263
+ effect(e) {
1264
+ const t = this.__view;
1265
+ if (t.isMounted) {
1266
+ const s = b(e);
1267
+ return this.__view._unsubscribes.push(s), s;
1268
+ } else {
1269
+ let s, i = !1;
1270
+ return t._emitter.on("mounted", () => {
1271
+ i || (s = b(e), this.__view._unsubscribes.push(s));
1272
+ }), () => {
1273
+ s != null && (i = !0, s());
1274
+ };
1275
+ }
1276
+ }
1277
+ outlet() {
1278
+ return E("$outlet", { children: this.__view._children });
1279
+ }
1280
+ }
1281
+ var Ee;
1282
+ Ee = k;
1283
+ const le = class le {
1284
+ constructor(e, t, s, i = []) {
1285
+ l(this, Ee, !0);
1286
+ l(this, "uniqueId", ue());
1287
+ l(this, "_elementContext");
1288
+ l(this, "_logger");
1289
+ l(this, "_view");
1290
+ l(this, "_props");
1291
+ l(this, "_element");
1292
+ l(this, "_childMarkup");
1293
+ l(this, "_children", Q([]));
1294
+ l(this, "_unsubscribes", []);
1295
+ l(this, "_emitter", new ee());
1296
+ l(this, "_wildcardListeners", /* @__PURE__ */ new Map());
1297
+ l(this, "isMounted", !1);
1298
+ this._elementContext = {
1299
+ ...e,
1300
+ data: {},
1301
+ parent: e,
1302
+ viewName: t.name,
1303
+ emitter: new ee(),
1304
+ stores: /* @__PURE__ */ new Map()
1305
+ }, this._logger = e.root.createLogger(t.name || "🌇 anonymous view", { uid: this.uniqueId }), this._view = t, this._props = s, this._childMarkup = i, this._emitter.on("error", (o, c, ...a) => {
1306
+ console.error([o, c, ...a]), this._logger.error(o.message, { error: o, type: c, args: a }), this._logger.crash(o);
1307
+ }), this._elementContext.emitter.on("*", (o, c, ...a) => {
1308
+ var p;
1309
+ c instanceof fe && (c.isStopped || (p = this._elementContext.parent) == null || p.emitter.emit(o, c, ...a));
1310
+ });
1311
+ }
1312
+ /*===============================*\
1313
+ || "Public" API ||
1314
+ \*===============================*/
1315
+ get node() {
1316
+ var e;
1317
+ return (e = this._element) == null ? void 0 : e.node;
1318
+ }
1319
+ mount(e, t) {
1320
+ const s = this.isMounted;
1321
+ s || (this._initialize(), this._emitter.emit("beforeMount")), this._element && this._element.mount(e, t), s || (this.isMounted = !0, requestAnimationFrame(() => {
1322
+ this._emitter.emit("mounted");
1323
+ }));
1324
+ }
1325
+ unmount(e = !1) {
1326
+ this._emitter.emit("beforeUnmount"), this._element && this._element.unmount(e), this.isMounted = !1, this._emitter.emit("unmounted"), this._emitter.clear();
1327
+ for (const t of this._unsubscribes)
1328
+ t();
1329
+ this._unsubscribes.length = 0;
1330
+ }
1331
+ setChildView(e) {
1332
+ this._childMarkup = [];
1333
+ const t = new le(this._elementContext, e, {});
1334
+ return this._children.value = [t], t;
1335
+ }
1336
+ /*===============================*\
1337
+ || Internal ||
1338
+ \*===============================*/
1339
+ _initialize() {
1340
+ const e = new wt(this);
1341
+ let t;
1342
+ try {
1343
+ t = this._view.call(e, this._props, e), this._childMarkup.length && (this._children.value = O(this._elementContext, this._childMarkup));
1344
+ } catch (s) {
1345
+ throw s instanceof Error && this._logger.crash(s), s;
1346
+ }
1347
+ if (t !== null) if (t instanceof Node)
1348
+ this._element = F(O(this._elementContext, E("$node", { value: t })));
1349
+ else if (w(t))
1350
+ this._element = F(
1351
+ O(this._elementContext, E("$dynamic", { source: t }))
1352
+ );
1353
+ else if (W(t) || De(W, t))
1354
+ this._element = F(O(this._elementContext, t));
1355
+ else {
1356
+ const s = new TypeError(
1357
+ `Expected '${this._view.name}' function to return a DOM node, Markup element, Readable or null. Got: ${q(t)}`
1358
+ );
1359
+ this._logger.crash(s);
1360
+ }
1361
+ }
1362
+ };
1363
+ let H = le;
1364
+ var Ce;
1365
+ Ce = k;
1366
+ class bt {
1367
+ constructor({ elementContext: e, items: t, renderFn: s, keyFn: i }) {
1368
+ l(this, Ce, !0);
1369
+ l(this, "node", document.createTextNode(""));
1370
+ l(this, "items");
1371
+ l(this, "unsubscribe", null);
1372
+ l(this, "connectedItems", []);
1373
+ l(this, "elementContext");
1374
+ l(this, "renderFn");
1375
+ l(this, "keyFn");
1376
+ this.elementContext = e, this.items = t, this.renderFn = s, this.keyFn = i;
1377
+ }
1378
+ get isMounted() {
1379
+ return this.node.parentNode != null;
1380
+ }
1381
+ mount(e, t) {
1382
+ this.isMounted || (e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), this.unsubscribe = b(() => {
1383
+ let s = S(this.items);
1384
+ s == null && (s = [], console.log("list received empty value", s, this)), this._update(Array.from(s));
1385
+ }));
1386
+ }
1387
+ unmount(e = !1) {
1388
+ var t;
1389
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = null), !e && this.isMounted && ((t = this.node.parentNode) == null || t.removeChild(this.node)), this._cleanup(e);
1390
+ }
1391
+ _cleanup(e) {
1392
+ for (const t of this.connectedItems)
1393
+ t.element.unmount(e);
1394
+ this.connectedItems = [];
1395
+ }
1396
+ _update(e) {
1397
+ var c, a, p;
1398
+ if (e.length === 0 || !this.isMounted)
1399
+ return this._cleanup(!1);
1400
+ const t = [];
1401
+ let s = 0;
1402
+ for (const r of e)
1403
+ t.push({
1404
+ key: this.keyFn(r, s),
1405
+ value: r,
1406
+ index: s++
1407
+ });
1408
+ const i = [];
1409
+ for (const r of this.connectedItems)
1410
+ t.find((f) => f.key === r.key) || r.element.unmount(!1);
1411
+ for (const r of t) {
1412
+ const u = this.connectedItems.find((f) => f.key === r.key);
1413
+ if (u)
1414
+ u.item.value = r.value, u.index.value = r.index, i[r.index] = u;
1415
+ else {
1416
+ const f = Q(r.value), h = Q(r.index);
1417
+ i[r.index] = {
1418
+ key: r.key,
1419
+ item: f,
1420
+ index: h,
1421
+ element: new H(this.elementContext, yt, {
1422
+ item: oe(() => f.value),
1423
+ index: h,
1424
+ renderFn: this.renderFn
1425
+ })
1426
+ };
1427
+ }
1428
+ }
1429
+ for (let r = 0; r < i.length; r++) {
1430
+ const u = i[r], f = ((c = i[r - 1]) == null ? void 0 : c.element.node) ?? this.node;
1431
+ u.element.mount(this.node.parentNode, f);
1432
+ }
1433
+ this.connectedItems = i;
1434
+ const o = ((a = i.at(-1)) == null ? void 0 : a.element.node) ?? this.node;
1435
+ (p = this.node.parentNode) == null || p.insertBefore(this.node, o.nextSibling);
1436
+ }
1437
+ }
1438
+ function yt(n, e) {
1439
+ return e.name = "@ListItem", n.renderFn.call(e, n.item, n.index, e);
1440
+ }
1441
+ var Te;
1442
+ Te = k;
1443
+ class $e {
1444
+ constructor(e) {
1445
+ l(this, Te, !0);
1446
+ l(this, "node", document.createTextNode(""));
1447
+ l(this, "isMounted", !1);
1448
+ l(this, "source");
1449
+ l(this, "elements", []);
1450
+ l(this, "unsubscribe");
1451
+ this.source = e;
1452
+ }
1453
+ mount(e, t) {
1454
+ this.isMounted || (this.isMounted = !0, e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), w(this.source) ? this.unsubscribe = b(() => {
1455
+ this.update(S(this.source));
1456
+ }) : this.update(this.elements));
1457
+ }
1458
+ unmount(e = !1) {
1459
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.isMounted && (this.cleanup(e), this.isMounted = !1);
1460
+ }
1461
+ cleanup(e) {
1462
+ for (const t of this.elements)
1463
+ t.unmount(e);
1464
+ this.elements = [];
1465
+ }
1466
+ update(e) {
1467
+ var t, s;
1468
+ if (this.cleanup(!1), e.length > 0) {
1469
+ for (let i = 0; i < e.length; i++) {
1470
+ const o = e[i], c = i > 0 ? this.elements[i - 1] : void 0;
1471
+ o.mount(this.node.parentElement, c == null ? void 0 : c.node), this.elements.push(o);
1472
+ }
1473
+ (s = this.node.parentNode) == null || s.insertBefore(this.node, ((t = this.elements.at(-1)) == null ? void 0 : t.node) ?? null);
1474
+ }
1475
+ }
1476
+ }
1477
+ var Ne;
1478
+ Ne = k;
1479
+ class vt {
1480
+ constructor(e) {
1481
+ l(this, Ne, !0);
1482
+ l(this, "config");
1483
+ l(this, "element");
1484
+ this.config = e;
1485
+ }
1486
+ get isMounted() {
1487
+ return this.element ? this.element.isMounted : !1;
1488
+ }
1489
+ mount(e, t) {
1490
+ const { content: s, parent: i } = this.config;
1491
+ qe(s) ? this.element = s : this.element = F(O(this.config.elementContext, ce(s))), this.element.mount(i);
1492
+ }
1493
+ unmount(e = !1) {
1494
+ var t;
1495
+ (t = this.element) != null && t.isMounted && this.element.unmount(e);
1496
+ }
1497
+ }
1498
+ function W(n) {
1499
+ return (n == null ? void 0 : n[Le]) === !0;
1500
+ }
1501
+ function qe(n) {
1502
+ return (n == null ? void 0 : n[k]) === !0;
1503
+ }
1504
+ function ce(n) {
1505
+ return $(n) || (n = [n]), n.flat(1 / 0).filter((e) => e != null && e !== !1).map((e) => W(e) ? e : e instanceof Node ? E("$node", { value: e }) : w(e) ? E("$dynamic", { source: e }) : E("$text", { value: e }));
1506
+ }
1507
+ function E(n, e, ...t) {
1508
+ return new xt(n, e, ...t);
1509
+ }
1510
+ var Ae;
1511
+ Ae = Le;
1512
+ class xt {
1513
+ constructor(e, t, ...s) {
1514
+ l(this, Ae, !0);
1515
+ l(this, "type");
1516
+ l(this, "props");
1517
+ l(this, "children");
1518
+ this.type = e, this.props = t, this.children = ce(s);
1519
+ }
1520
+ }
1521
+ const Gt = ct.bind(E);
1522
+ function St(n, e, t) {
1523
+ return E("$dynamic", {
1524
+ source: oe(() => {
1525
+ const s = S(n);
1526
+ return s && e ? e : !s && t ? t : null;
1527
+ })
1528
+ });
1529
+ }
1530
+ function Mt(n, e, t) {
1531
+ return E("$list", { items: oe(() => n), keyFn: e, renderFn: t });
1532
+ }
1533
+ function Et(n, e) {
1534
+ return E("$portal", { parent: n, content: e });
1535
+ }
1536
+ function O(n, e) {
1537
+ return ($(e) ? e : [e]).map((s) => {
1538
+ if (A(s.type))
1539
+ return new H(n, s.type, s.props, s.children);
1540
+ if (P(s.type))
1541
+ switch (s.type) {
1542
+ case "$node": {
1543
+ const i = s.props;
1544
+ return new be(i.value);
1545
+ }
1546
+ case "$text": {
1547
+ const i = s.props;
1548
+ return new be(document.createTextNode(String(i.value)));
1549
+ }
1550
+ case "$list": {
1551
+ const i = s.props;
1552
+ return new bt({
1553
+ items: i.items,
1554
+ keyFn: i.keyFn,
1555
+ renderFn: i.renderFn,
1556
+ elementContext: n
1557
+ });
1558
+ }
1559
+ case "$dynamic": {
1560
+ const i = s.props;
1561
+ return new lt({
1562
+ source: i.source,
1563
+ elementContext: n
1564
+ });
1565
+ }
1566
+ case "$outlet": {
1567
+ const i = s.props;
1568
+ return new $e(i.children);
1569
+ }
1570
+ case "$portal": {
1571
+ const i = s.props;
1572
+ return new vt({
1573
+ content: i.content,
1574
+ parent: i.parent,
1575
+ elementContext: n
1576
+ });
1577
+ }
1578
+ default:
1579
+ if (s.type.startsWith("$"))
1580
+ throw new Error(`Unknown markup type: ${s.type}`);
1581
+ return new dt({
1582
+ tag: s.type,
1583
+ props: s.props ?? {},
1584
+ children: s.children,
1585
+ elementContext: n
1586
+ });
1587
+ }
1588
+ else
1589
+ throw new TypeError(`Expected a string or view function. Got: ${s.type}`);
1590
+ });
1591
+ }
1592
+ function F(n) {
1593
+ return n.length === 1 ? n[0] : new $e(n);
1594
+ }
1595
+ function Re(n) {
1596
+ return n == null || n === !1 || P(n) || Fe(n) || W(n) || w(n) || De(Re, n);
1597
+ }
1598
+ export {
1599
+ kt as A,
1600
+ Pt as B,
1601
+ Et as C,
1602
+ Mt as D,
1603
+ qt as I,
1604
+ Vt as P,
1605
+ gt as S,
1606
+ H as V,
1607
+ Nt as a,
1608
+ Tt as b,
1609
+ Rt as c,
1610
+ Q as d,
1611
+ oe as e,
1612
+ Dt as f,
1613
+ S as g,
1614
+ P as h,
1615
+ A as i,
1616
+ te as j,
1617
+ It as k,
1618
+ Gt as l,
1619
+ St as m,
1620
+ $t as n,
1621
+ B as o,
1622
+ ee as p,
1623
+ At as q,
1624
+ E as r,
1625
+ Lt as s,
1626
+ q as t,
1627
+ Ot as u,
1628
+ jt as v,
1629
+ F as w,
1630
+ O as x,
1631
+ b as y,
1632
+ tt as z
1633
+ };
1634
+ //# sourceMappingURL=markup-BWJWLvDF.js.map