@manyducks.co/dolla 2.0.0-alpha.22 → 2.0.0-alpha.23

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.
@@ -0,0 +1,1453 @@
1
+ var Oe = Object.defineProperty;
2
+ var Pe = (s, e, t) => e in s ? Oe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var o = (s, e, t) => Pe(s, typeof e != "symbol" ? e + "" : e, t);
4
+ function we(s) {
5
+ return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
6
+ }
7
+ var O = { exports: {} }, Q;
8
+ function qe() {
9
+ return Q || (Q = 1, function(s, e) {
10
+ Object.defineProperty(e, "__esModule", { value: !0 });
11
+ var t = /* @__PURE__ */ function() {
12
+ function a(l, h) {
13
+ var f = [], d = !0, m = !1, S = void 0;
14
+ try {
15
+ for (var E, C = l[Symbol.iterator](); !(d = (E = C.next()).done) && (f.push(E.value), !(h && f.length === h)); d = !0) ;
16
+ } catch (g) {
17
+ m = !0, S = g;
18
+ } finally {
19
+ try {
20
+ !d && C.return && C.return();
21
+ } finally {
22
+ if (m) throw S;
23
+ }
24
+ }
25
+ return f;
26
+ }
27
+ return function(l, h) {
28
+ if (Array.isArray(l)) return l;
29
+ if (Symbol.iterator in Object(l)) return a(l, h);
30
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
31
+ };
32
+ }(), n = function(a) {
33
+ return a.reduce(function(l, h) {
34
+ return 16 > h ? l + "0" + h.toString(16) : l + h.toString(16);
35
+ }, "#");
36
+ }, r = function(a, l, h) {
37
+ var f = 0.5 > h ? h * (1 + l) : h + l - h * l, d = 2 * h - f, m = function(g, k, v) {
38
+ var j = Math.round, w = 0 > v ? v + 1 : 1 < v ? v - 1 : v;
39
+ return w = w < 1 / 6 ? g + 6 * (k - g) * w : w < 1 / 2 ? k : w < 2 / 3 ? g + 6 * (k - g) * (2 / 3 - w) : g, j(255 * w);
40
+ }, S = m(d, f, a + 1 / 3), E = m(d, f, a), C = m(d, f, a - 1 / 3);
41
+ return [S, E, C];
42
+ }, i = function(a, l, h, f) {
43
+ var d = a % 1007 / 1007, m = function(g, k, v) {
44
+ return g * (v - k) + k;
45
+ }, S = m(d, l.min, l.max), E = m(d, h.min, h.max), C = m(d, f.max, f.min);
46
+ return [S, E, C];
47
+ }, u = function(a) {
48
+ return a.split("").reduce(function(l, h, f) {
49
+ return l * h.charCodeAt(0) * f + 1;
50
+ }, 1);
51
+ }, c = function(a) {
52
+ var l = a.str, h = a.hue, f = h === void 0 ? { min: 0, max: 360 } : h, d = a.sat, m = d === void 0 ? { min: 0.35, max: 0.65 } : d, S = a.light, E = S === void 0 ? { min: 0.3, max: 0.7 } : S, C = a.hashFunction, g = C === void 0 ? u : C, k = a.scheme, v = k === void 0 ? "hex" : k, j = i(g(l), f, m, E), w = t(j, 3), Y = w[0], Z = w[1], X = w[2], J = r(Y / 360, Z, X), Te = n(J);
53
+ return v === "hsl" ? [Y, Z, X] : v === "rgb" ? J : Te;
54
+ };
55
+ e.default = c, s.exports = e.default;
56
+ }(O, O.exports)), O.exports;
57
+ }
58
+ var Ue = qe();
59
+ const We = /* @__PURE__ */ we(Ue);
60
+ function N(s) {
61
+ const e = typeof s;
62
+ switch (e) {
63
+ case "undefined":
64
+ return e;
65
+ case "number":
66
+ return isNaN(s) ? "NaN" : e;
67
+ case "function":
68
+ return /^\s*class\s+/.test(s.toString()) ? "class" : e;
69
+ case "object":
70
+ return s === null ? "null" : s instanceof Promise ? "promise" : s instanceof Map ? "map" : s instanceof Set ? "set" : Array.isArray(s) ? "array" : e;
71
+ default:
72
+ return e;
73
+ }
74
+ }
75
+ function lt(s, e) {
76
+ if (!s)
77
+ throw new TypeError(
78
+ F(s, e || "Failed assertion. Value is not truthy. Got type: %t, value: %v")
79
+ );
80
+ }
81
+ function V(s) {
82
+ return Array.isArray(s);
83
+ }
84
+ function ye(...s) {
85
+ const e = s[0], t = (n) => V(n) && n.every((r) => e(r));
86
+ return s.length < 2 ? t : t(s[1]);
87
+ }
88
+ function ht(...s) {
89
+ const e = s[0], t = x(s[2]) ? s[2] : "Expected an array of valid items. Got type: %t, value: %v", n = (r) => {
90
+ if (V(r) && r.every((i) => e(i)))
91
+ return !0;
92
+ throw new TypeError(F(r, t));
93
+ };
94
+ return s.length < 2 ? n : n(s[1]);
95
+ }
96
+ function x(s) {
97
+ return typeof s == "string";
98
+ }
99
+ function ft(s, e) {
100
+ if (x(s))
101
+ return !0;
102
+ throw new TypeError(F(s, e ?? "Expected a string. Got type: %t, value: %v"));
103
+ }
104
+ function P(s) {
105
+ return typeof s == "function" && !Fe(s);
106
+ }
107
+ function _e(s) {
108
+ return typeof s == "number" && !isNaN(s);
109
+ }
110
+ function Fe(s) {
111
+ return typeof s == "function" && /^\s*class\s+/.test(s.toString());
112
+ }
113
+ function dt(...s) {
114
+ const e = s[0], t = x(s[2]) ? s[2] : `Expected instance of ${e.name}. Got type: %t, value: %v`, n = (r) => {
115
+ if (r instanceof e)
116
+ return !0;
117
+ throw new TypeError(F(r, t));
118
+ };
119
+ return s.length < 2 ? n : n(s[1]);
120
+ }
121
+ function Ce(s) {
122
+ return s != null && typeof s == "object" && !V(s);
123
+ }
124
+ function F(s, e) {
125
+ var r;
126
+ const t = N(s), n = ((r = s == null ? void 0 : s.toString) == null ? void 0 : r.call(s)) || String(s);
127
+ return e.replaceAll("%t", t).replaceAll("%v", n);
128
+ }
129
+ var I, ee;
130
+ function Le() {
131
+ return ee || (ee = 1, I = function s(e, t) {
132
+ if (e === t) return !0;
133
+ if (e && t && typeof e == "object" && typeof t == "object") {
134
+ if (e.constructor !== t.constructor) return !1;
135
+ var n, r, i;
136
+ if (Array.isArray(e)) {
137
+ if (n = e.length, n != t.length) return !1;
138
+ for (r = n; r-- !== 0; )
139
+ if (!s(e[r], t[r])) return !1;
140
+ return !0;
141
+ }
142
+ if (e instanceof Map && t instanceof Map) {
143
+ if (e.size !== t.size) return !1;
144
+ for (r of e.entries())
145
+ if (!t.has(r[0])) return !1;
146
+ for (r of e.entries())
147
+ if (!s(r[1], t.get(r[0]))) return !1;
148
+ return !0;
149
+ }
150
+ if (e instanceof Set && t instanceof Set) {
151
+ if (e.size !== t.size) return !1;
152
+ for (r of e.entries())
153
+ if (!t.has(r[0])) return !1;
154
+ return !0;
155
+ }
156
+ if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
157
+ if (n = e.length, n != t.length) return !1;
158
+ for (r = n; r-- !== 0; )
159
+ if (e[r] !== t[r]) return !1;
160
+ return !0;
161
+ }
162
+ if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
163
+ if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
164
+ if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
165
+ if (i = Object.keys(e), n = i.length, n !== Object.keys(t).length) return !1;
166
+ for (r = n; r-- !== 0; )
167
+ if (!Object.prototype.hasOwnProperty.call(t, i[r])) return !1;
168
+ for (r = n; r-- !== 0; ) {
169
+ var u = i[r];
170
+ if (!s(e[u], t[u])) return !1;
171
+ }
172
+ return !0;
173
+ }
174
+ return e !== e && t !== t;
175
+ }), I;
176
+ }
177
+ var je = Le();
178
+ const Ie = /* @__PURE__ */ we(je), Re = () => {
179
+ };
180
+ let R = 1;
181
+ function ve() {
182
+ return R = R % Number.MAX_SAFE_INTEGER + 1, R.toString(36) + Date.now().toString(36);
183
+ }
184
+ function be(s, e) {
185
+ return s === e;
186
+ }
187
+ function pt(s, e) {
188
+ if (s === e) return !0;
189
+ const t = N(s);
190
+ if (t !== N(e))
191
+ return !1;
192
+ switch (t) {
193
+ case "object":
194
+ let n = 0;
195
+ for (const r in s) {
196
+ if (s[r] !== e[r]) return !1;
197
+ n++;
198
+ }
199
+ return Object.keys(e).length === n;
200
+ case "array":
201
+ if (s.length !== e.length) return !1;
202
+ for (let r = 0; r < s.length; r++)
203
+ if (s[r] !== e[r]) return !1;
204
+ return !0;
205
+ case "map":
206
+ if (s.size !== e.size) return !1;
207
+ for (const r of s.keys())
208
+ if (s[r] !== e[r]) return !1;
209
+ return !0;
210
+ case "set":
211
+ if (P(s.symmetricDifference))
212
+ return s.symmetricDifference(e).size === 0;
213
+ for (const r of s.keys())
214
+ if (s[r] !== e.get(r)) return !1;
215
+ return !0;
216
+ }
217
+ return !1;
218
+ }
219
+ const mt = Ie;
220
+ function Ge(s, e) {
221
+ const t = (n) => {
222
+ const r = {};
223
+ for (const i in n)
224
+ s.includes(i) || (r[i] = n[i]);
225
+ return r;
226
+ };
227
+ return e == null ? t : t(e);
228
+ }
229
+ function De(s) {
230
+ return We({
231
+ str: s,
232
+ sat: { min: 0.35, max: 0.55 },
233
+ light: { min: 0.6, max: 0.6 }
234
+ });
235
+ }
236
+ function gt(s) {
237
+ if (s instanceof RegExp)
238
+ return (n) => s.test(n);
239
+ const e = {
240
+ positive: [],
241
+ negative: []
242
+ }, t = s.split(",").map((n) => n.trim()).filter((n) => n !== "");
243
+ for (let n of t) {
244
+ let r = "positive";
245
+ n.startsWith("-") && (r = "negative", n = n.slice(1)), n === "*" ? e[r].push(function() {
246
+ return !0;
247
+ }) : n.endsWith("*") ? e[r].push(function(i) {
248
+ return i.startsWith(n.slice(0, n.length - 1));
249
+ }) : e[r].push(function(i) {
250
+ return i === n;
251
+ });
252
+ }
253
+ return function(n) {
254
+ const { positive: r, negative: i } = e;
255
+ return !(i.some((u) => u(n)) || r.length > 0 && !r.some((u) => u(n)));
256
+ };
257
+ }
258
+ const T = Symbol.for("DollaState"), D = Symbol.for("DollaSettableState"), Se = Symbol.for("DollaRef"), ke = Symbol.for("DollaMarkup"), b = Symbol.for("DollaMarkupElement"), q = {
259
+ watcherCount: 0,
260
+ increment() {
261
+ this.watcherCount++, this._log();
262
+ },
263
+ decrement() {
264
+ this.watcherCount--, this._log();
265
+ },
266
+ _label: "dolla/state-tracker",
267
+ _timeout: null,
268
+ _log() {
269
+ window.DOLLA_DEV_DEBUG === !0 && !this._timeout && (this._timeout = setTimeout(() => {
270
+ console.log(
271
+ `%c[DOLLA_DEV_DEBUG] %c${this._label}%c%c%c`,
272
+ "color:#e44c4c;font-weight:bold",
273
+ `color:${De(this._label)};font-weight:bold`,
274
+ "color:#777",
275
+ "color:#aaa",
276
+ "color:#777",
277
+ { watcherCount: this.watcherCount }
278
+ ), this._timeout = null;
279
+ }, 200));
280
+ }
281
+ };
282
+ function p(s) {
283
+ return (s == null ? void 0 : s[T]) === !0;
284
+ }
285
+ function B(s) {
286
+ return (s == null ? void 0 : s[D]) === !0;
287
+ }
288
+ function Ee(s) {
289
+ return (s == null ? void 0 : s[Se]) === !0;
290
+ }
291
+ function Be(s) {
292
+ return p(s) ? s.get() : s;
293
+ }
294
+ function L(s) {
295
+ return B(s) ? new U(s) : p(s) ? s : new U({
296
+ get() {
297
+ return s;
298
+ },
299
+ watch(e, t = {}) {
300
+ return t != null && t.lazy || e(s), Re;
301
+ }
302
+ });
303
+ }
304
+ class z {
305
+ constructor(e, t) {
306
+ o(this, "value");
307
+ o(this, "watchers", []);
308
+ o(this, "equals", be);
309
+ this.value = e, t != null && t.equals && (this.equals = t.equals);
310
+ }
311
+ get() {
312
+ return this.value;
313
+ }
314
+ set(e) {
315
+ if (typeof e == "function" && (e = e(this.value)), !this.equals(e, this.value)) {
316
+ this.value = e;
317
+ try {
318
+ for (const t of this.watchers)
319
+ t(e);
320
+ } catch (t) {
321
+ throw console.error("Error in watcher", t), t;
322
+ }
323
+ }
324
+ }
325
+ watch(e, t) {
326
+ return this.watchers.push(e), t != null && t.lazy || e(this.value), q.increment(), () => {
327
+ const n = this.watchers.indexOf(e);
328
+ n > -1 && this.watchers.splice(n, 1), q.decrement();
329
+ };
330
+ }
331
+ }
332
+ var se;
333
+ se = T;
334
+ class U {
335
+ constructor(e) {
336
+ // Instances will pass isState() with this symbol
337
+ o(this, se, !0);
338
+ o(this, "__value");
339
+ if (e == null)
340
+ throw new TypeError("Value is null");
341
+ this.__value = e;
342
+ }
343
+ get() {
344
+ return this.__value.get();
345
+ }
346
+ watch(e, t) {
347
+ return this.__value.watch(e, t);
348
+ }
349
+ }
350
+ function G(s, e) {
351
+ const t = new z(s, e);
352
+ return [new U(t), (r) => t.set(r)];
353
+ }
354
+ var re, ie;
355
+ ie = T, re = D;
356
+ class ze {
357
+ constructor(e) {
358
+ // Instances will pass isState() and isSettableState() with these symbols
359
+ o(this, ie, !0);
360
+ o(this, re, !0);
361
+ o(this, "__value");
362
+ if (e == null)
363
+ throw new TypeError("Value is null");
364
+ this.__value = e;
365
+ }
366
+ get() {
367
+ return this.__value.get();
368
+ }
369
+ set(e) {
370
+ this.__value.set(e);
371
+ }
372
+ watch(e, t) {
373
+ return this.__value.watch(e, t);
374
+ }
375
+ }
376
+ function wt(s, e) {
377
+ return new ze(new z(s, e));
378
+ }
379
+ function yt(s, e) {
380
+ return {
381
+ [T]: !0,
382
+ [D]: !0,
383
+ get: s.get.bind(s),
384
+ watch: s.watch.bind(s),
385
+ set: e
386
+ };
387
+ }
388
+ function _t(s, e) {
389
+ return function(n) {
390
+ const r = s.get();
391
+ let i;
392
+ typeof n == "function" ? i = n(r) : i = n, e(i, r);
393
+ };
394
+ }
395
+ const te = Symbol("EMPTY");
396
+ class Ke {
397
+ constructor(e, t, n) {
398
+ o(this, "equals", be);
399
+ /**
400
+ * Array of states this holder's value is derived from.
401
+ */
402
+ o(this, "sources", []);
403
+ /**
404
+ * The function that does the deriving. Receives source values and returns a derived value.
405
+ */
406
+ o(this, "fn");
407
+ /**
408
+ *
409
+ */
410
+ o(this, "sourceWatcher", K());
411
+ /**
412
+ * Array of functions awaiting notification when this holder's value changes.
413
+ */
414
+ o(this, "watchers", []);
415
+ /**
416
+ * True when this holder is actively watching sources.
417
+ */
418
+ o(this, "isWatchingSources", !1);
419
+ /**
420
+ * Latest values as received from sources.
421
+ */
422
+ o(this, "previousSourceValues");
423
+ /**
424
+ * The current value as returned from `fn` (may be a State)
425
+ */
426
+ o(this, "value", te);
427
+ /**
428
+ * The current unwrapped value.
429
+ */
430
+ o(this, "rawValue");
431
+ /**
432
+ * When value is a State, this function will stop watching its value.
433
+ */
434
+ o(this, "stopWatchingCurrentValue");
435
+ this.sources = e.map(L), this.fn = t, n != null && n.equals && (this.equals = n.equals), this.previousSourceValues = new Array(e.length).fill(te, 0, e.length);
436
+ }
437
+ /*==========================*\
438
+ || "Public" methods ||
439
+ \*==========================*/
440
+ get() {
441
+ return this.getValue();
442
+ }
443
+ watch(e, t) {
444
+ this.isWatchingSources || this.startWatchingSources();
445
+ const n = this.watchers;
446
+ return n.push(e), t != null && t.lazy || e(this.rawValue), q.increment(), () => {
447
+ n.splice(n.indexOf(e), 1), this.isWatchingSources && n.length === 0 && this.stopWatchingSources(), q.decrement();
448
+ };
449
+ }
450
+ /*==========================*\
451
+ || Internal ||
452
+ \*==========================*/
453
+ notify(e) {
454
+ for (const t of this.watchers)
455
+ t(e);
456
+ }
457
+ update() {
458
+ const e = this.sources, t = this.previousSourceValues;
459
+ let n = !1, r;
460
+ for (let i = 0; i < e.length; i++)
461
+ r = e[i].get(), !n && !this.equals(r, t[i]) && (n = !0), t[i] = r;
462
+ n && this.setValue(this.fn(...t));
463
+ }
464
+ getValue() {
465
+ return this.isWatchingSources || this.update(), this.rawValue;
466
+ }
467
+ setValue(e) {
468
+ this.stopWatchingCurrentValue && (this.stopWatchingCurrentValue(), this.stopWatchingCurrentValue = void 0), this.value = e, this.rawValue = Be(e), this.isWatchingSources && p(e) ? this.stopWatchingCurrentValue = e.watch((t) => {
469
+ this.rawValue = t, this.notify(t);
470
+ }) : this.notify(this.rawValue);
471
+ }
472
+ startWatchingSources() {
473
+ const e = this.previousSourceValues;
474
+ for (let n = 0; n < this.sources.length; n++)
475
+ this.sourceWatcher.watch([this.sources[n]], (r) => {
476
+ if (e[n] = r, this.isWatchingSources) {
477
+ const i = this.fn(...e);
478
+ this.equals(i, this.value) || this.setValue(i);
479
+ }
480
+ });
481
+ this.isWatchingSources = !0;
482
+ const t = this.fn(...e);
483
+ this.equals(t, this.value) || this.setValue(t);
484
+ }
485
+ stopWatchingSources() {
486
+ this.sourceWatcher.stopAll(), this.stopWatchingCurrentValue && (this.stopWatchingCurrentValue(), this.stopWatchingCurrentValue = void 0), this.isWatchingSources = !1;
487
+ }
488
+ }
489
+ function He(s, e, t) {
490
+ const n = new Ke(s, e, t);
491
+ return new U(n);
492
+ }
493
+ var oe, ue;
494
+ ue = Se, oe = T;
495
+ class Ye {
496
+ constructor(e) {
497
+ // Instances will pass isRef() and isState() with these symbols
498
+ o(this, ue, !0);
499
+ o(this, oe, !0);
500
+ o(this, "__value");
501
+ this.__value = e;
502
+ }
503
+ get() {
504
+ return this.__value.get();
505
+ }
506
+ watch(e, t) {
507
+ return this.__value.watch(e, t);
508
+ }
509
+ get node() {
510
+ return this.__value.get();
511
+ }
512
+ set node(e) {
513
+ this.__value.set(e);
514
+ }
515
+ }
516
+ function Ct() {
517
+ return new Ye(new z(void 0));
518
+ }
519
+ function K() {
520
+ const s = [];
521
+ return {
522
+ watch(e, t) {
523
+ if (e.length === 0)
524
+ throw new TypeError("Expected at least one state to watch.");
525
+ e = e.map(L);
526
+ let n;
527
+ return e.length > 1 ? n = He(e, t).watch(() => null) : n = e[0].watch(t), s.push(n), () => {
528
+ let r = s.indexOf(n);
529
+ r > -1 && s.splice(r, 1), n();
530
+ };
531
+ },
532
+ stopAll() {
533
+ for (; s.length > 0; )
534
+ s.pop()();
535
+ }
536
+ };
537
+ }
538
+ function Ze(s) {
539
+ for (var e, t, n = arguments, r = 1, i = "", u = "", c = [0], a = function(f) {
540
+ r === 1 && (f || (i = i.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? c.push(f ? n[f] : i) : r === 3 && (f || i) ? (c[1] = f ? n[f] : i, r = 2) : r === 2 && i === "..." && f ? c[2] = Object.assign(c[2] || {}, n[f]) : r === 2 && i && !f ? (c[2] = c[2] || {})[i] = !0 : r >= 5 && (r === 5 ? ((c[2] = c[2] || {})[t] = f ? i ? i + n[f] : n[f] : i, r = 6) : (f || i) && (c[2][t] += f ? i + n[f] : i)), i = "";
541
+ }, l = 0; l < s.length; l++) {
542
+ l && (r === 1 && a(), a(l));
543
+ for (var h = 0; h < s[l].length; h++) e = s[l][h], r === 1 ? e === "<" ? (a(), c = [c, "", null], r = 3) : i += e : r === 4 ? i === "--" && e === ">" ? (r = 1, i = "") : i = e + i[0] : u ? e === u ? u = "" : i += e : e === '"' || e === "'" ? u = e : e === ">" ? (a(), r = 1) : r && (e === "=" ? (r = 5, t = i, i = "") : e === "/" && (r < 5 || s[l][h + 1] === ">") ? (a(), r === 3 && (c = c[0]), r = c, (c = c[0]).push(this.apply(null, r.slice(1))), r = 0) : e === " " || e === " " || e === `
544
+ ` || e === "\r" ? (a(), r = 2) : i += e), r === 3 && i === "!--" && (r = 4, c = c[0]);
545
+ }
546
+ return a(), c.length > 2 ? c.slice(1) : c[1];
547
+ }
548
+ var ae;
549
+ ae = b;
550
+ class Xe {
551
+ constructor(e) {
552
+ o(this, ae, !0);
553
+ o(this, "node");
554
+ o(this, "endNode");
555
+ o(this, "$predicate");
556
+ o(this, "stopCallback");
557
+ o(this, "thenContent");
558
+ o(this, "elseContent");
559
+ o(this, "connectedContent", []);
560
+ o(this, "elementContext");
561
+ o(this, "initialUpdateHappened", !1);
562
+ o(this, "previousValue");
563
+ this.$predicate = e.$predicate, this.thenContent = e.thenContent ? A(e.thenContent) : void 0, this.elseContent = e.elseContent ? A(e.elseContent) : void 0, this.elementContext = e.elementContext, this.elementContext.root.getEnv() === "development" ? (this.node = document.createComment("Conditional"), this.endNode = document.createComment("/Conditional")) : (this.node = document.createTextNode(""), this.endNode = document.createTextNode(""));
564
+ }
565
+ get isMounted() {
566
+ return this.node.parentNode != null;
567
+ }
568
+ mount(e, t) {
569
+ this.isMounted || (e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), this.elementContext.root.getEnv() === "development" && e.insertBefore(this.endNode, this.node.nextSibling), this.stopCallback = this.$predicate.watch((n) => {
570
+ (!this.initialUpdateHappened || n && !this.previousValue || !n && this.previousValue) && (this.update(n), this.initialUpdateHappened = !0, this.previousValue = n);
571
+ }));
572
+ }
573
+ unmount(e = !1) {
574
+ var t, n;
575
+ this.stopCallback && (this.stopCallback(), this.stopCallback = void 0);
576
+ for (const r of this.connectedContent)
577
+ r.unmount(e);
578
+ this.connectedContent = [], this.isMounted && ((t = this.node.parentNode) == null || t.removeChild(this.node), (n = this.endNode.parentNode) == null || n.removeChild(this.endNode));
579
+ }
580
+ update(e) {
581
+ var t;
582
+ for (const n of this.connectedContent)
583
+ n.unmount(!1);
584
+ if (this.connectedContent = [], this.node.parentNode != null) {
585
+ e && this.thenContent ? this.connectedContent = _(this.elementContext, this.thenContent) : !e && this.elseContent && (this.connectedContent = _(this.elementContext, this.elseContent));
586
+ for (let n = 0; n < this.connectedContent.length; n++) {
587
+ const r = this.connectedContent[n], i = ((t = this.connectedContent[n - 1]) == null ? void 0 : t.node) ?? this.node;
588
+ r.mount(this.node.parentNode, i);
589
+ }
590
+ this.elementContext.root.getEnv() === "development" && (this.node.textContent = `Conditional (${e ? "truthy" : "falsy"})`);
591
+ }
592
+ }
593
+ }
594
+ const Je = (s) => /^on[A-Z]/.test(s);
595
+ var ce;
596
+ ce = b;
597
+ class Qe {
598
+ constructor({ tag: e, props: t, children: n, elementContext: r }) {
599
+ o(this, ce, !0);
600
+ o(this, "node");
601
+ o(this, "props");
602
+ o(this, "children");
603
+ o(this, "stopCallbacks", []);
604
+ o(this, "elementContext");
605
+ o(this, "uniqueId", ve());
606
+ // Track the ref so we can nullify it on unmount.
607
+ o(this, "ref");
608
+ // Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
609
+ o(this, "canClickAway", !1);
610
+ if (r = { ...r }, e.toLowerCase() === "svg" && (r.isSVG = !0), r.isSVG ? this.node = document.createElementNS("http://www.w3.org/2000/svg", e) : this.node = document.createElement(e), r.root.getEnv() === "development" && (this.node.dataset.uniqueId = this.uniqueId), t.ref)
611
+ if (Ee(t.ref))
612
+ this.ref = t.ref;
613
+ else
614
+ throw new Error("Expected ref to be a Ref object. Got: " + t.ref);
615
+ this.props = {
616
+ ...Ge(["ref", "class", "className"], t),
617
+ class: t.className ?? t.class
618
+ }, this.children = n ? _(r, n) : [], this.elementContext = r;
619
+ }
620
+ get isMounted() {
621
+ return this.node.parentNode != null;
622
+ }
623
+ mount(e, t) {
624
+ if (e == null)
625
+ throw new Error(`HTML element requires a parent element as the first argument to connect. Got: ${e}`);
626
+ if (!this.isMounted) {
627
+ for (const n of this.children)
628
+ n.mount(this.node);
629
+ this.applyProps(this.node, this.props), this.props.style && this.applyStyles(this.node, this.props.style, this.stopCallbacks), this.props.class && this.applyClasses(this.node, this.props.class, this.stopCallbacks);
630
+ }
631
+ e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), this.ref && (this.ref.node = this.node), setTimeout(() => {
632
+ this.canClickAway = !0;
633
+ }, 0);
634
+ }
635
+ unmount(e = !1) {
636
+ var t;
637
+ if (this.isMounted) {
638
+ for (const n of this.children)
639
+ n.unmount(!0);
640
+ this.ref && (this.ref.node = void 0), e || (t = this.node.parentNode) == null || t.removeChild(this.node), this.canClickAway = !1;
641
+ for (const n of this.stopCallbacks)
642
+ n();
643
+ this.stopCallbacks = [];
644
+ }
645
+ }
646
+ getUpdateKey(e, t) {
647
+ return `${this.uniqueId}:${e}:${t}`;
648
+ }
649
+ attachProp(e, t, n) {
650
+ p(e) ? this.stopCallbacks.push(
651
+ e.watch((r) => {
652
+ this.elementContext.root.batch.write(() => {
653
+ t(r);
654
+ }, n);
655
+ })
656
+ ) : this.elementContext.root.batch.write(() => {
657
+ t(e);
658
+ }, n);
659
+ }
660
+ applyProps(e, t) {
661
+ for (const n in t) {
662
+ const r = t[n];
663
+ if (n === "attributes") {
664
+ const i = r;
665
+ for (const u in i)
666
+ this.attachProp(
667
+ i[u],
668
+ (c) => {
669
+ c == null ? e.removeAttribute(u) : e.setAttribute(u, String(c));
670
+ },
671
+ this.getUpdateKey("attr", u)
672
+ );
673
+ } else if (n === "eventListeners") {
674
+ const i = r;
675
+ for (const u in i) {
676
+ const c = p(r) ? (a) => r.get()(a) : r;
677
+ e.addEventListener(u, c), this.stopCallbacks.push(() => {
678
+ e.removeEventListener(u, c);
679
+ });
680
+ }
681
+ } else if (n === "onClickOutside" || n === "onclickoutside") {
682
+ const i = (c) => {
683
+ this.canClickAway && !e.contains(c.target) && (p(r) ? r.get()(c) : r(c));
684
+ }, u = { capture: !0 };
685
+ window.addEventListener("click", i, u), this.stopCallbacks.push(() => {
686
+ window.removeEventListener("click", i, u);
687
+ });
688
+ } else if (n === "$$value") {
689
+ if (!B(r))
690
+ throw new TypeError(`$$value attribute must be a settable state. Got: ${r}`);
691
+ this.attachProp(
692
+ r,
693
+ (u) => {
694
+ u == null ? e.value = "" : e.value = String(u);
695
+ },
696
+ this.getUpdateKey("attr", "value")
697
+ );
698
+ const i = (u) => {
699
+ const c = et(r.get(), u.currentTarget.value);
700
+ r.set(c);
701
+ };
702
+ e.addEventListener("input", i), this.stopCallbacks.push(() => {
703
+ e.removeEventListener("input", i);
704
+ });
705
+ } else if (Je(n)) {
706
+ const i = n.slice(2).toLowerCase(), u = p(r) ? (c) => r.get()(c) : r;
707
+ e.addEventListener(i, u), this.stopCallbacks.push(() => {
708
+ e.removeEventListener(i, u);
709
+ });
710
+ } else if (n.includes("-"))
711
+ this.attachProp(
712
+ r,
713
+ (i) => {
714
+ i == null ? e.removeAttribute(n) : e.setAttribute(n, String(i));
715
+ },
716
+ this.getUpdateKey("attr", n)
717
+ );
718
+ else if (!tt.includes(n))
719
+ if (this.elementContext.isSVG)
720
+ this.attachProp(
721
+ r,
722
+ (i) => {
723
+ i != null ? e.setAttribute(n, String(t[n])) : e.removeAttribute(n);
724
+ },
725
+ this.getUpdateKey("attr", n)
726
+ );
727
+ else
728
+ switch (n) {
729
+ case "contentEditable":
730
+ case "value":
731
+ this.attachProp(
732
+ r,
733
+ (i) => {
734
+ e[n] = String(i);
735
+ },
736
+ this.getUpdateKey("prop", n)
737
+ );
738
+ break;
739
+ case "for":
740
+ this.attachProp(
741
+ r,
742
+ (i) => {
743
+ e.htmlFor = i;
744
+ },
745
+ this.getUpdateKey("prop", "htmlFor")
746
+ );
747
+ break;
748
+ case "checked":
749
+ this.attachProp(
750
+ r,
751
+ (i) => {
752
+ e.checked = i, i ? e.setAttribute("checked", "") : e.removeAttribute("checked");
753
+ },
754
+ this.getUpdateKey("prop", "checked")
755
+ );
756
+ break;
757
+ // Attribute-aliased props
758
+ case "exportParts":
759
+ case "part":
760
+ case "translate":
761
+ case "type":
762
+ case "title": {
763
+ const i = n.toLowerCase();
764
+ this.attachProp(
765
+ r,
766
+ (u) => {
767
+ u == null ? e.removeAttribute(i) : e.setAttribute(i, String(u));
768
+ },
769
+ this.getUpdateKey("attr", i)
770
+ );
771
+ break;
772
+ }
773
+ case "autocomplete":
774
+ case "autocapitalize":
775
+ this.attachProp(
776
+ r,
777
+ (i) => {
778
+ typeof i == "string" ? e.autocomplete = i : i ? e.autocomplete = "on" : e.autocomplete = "off";
779
+ },
780
+ this.getUpdateKey("prop", n)
781
+ );
782
+ break;
783
+ default: {
784
+ this.attachProp(
785
+ r,
786
+ (i) => {
787
+ e[n] = i;
788
+ },
789
+ this.getUpdateKey("prop", n)
790
+ );
791
+ break;
792
+ }
793
+ }
794
+ }
795
+ }
796
+ applyStyles(e, t, n) {
797
+ const r = [];
798
+ if (p(t)) {
799
+ let i;
800
+ const u = t.watch((c) => {
801
+ this.elementContext.root.batch.write(
802
+ () => {
803
+ P(i) && i(), e.style.cssText = "", i = this.applyStyles(e, c, n);
804
+ },
805
+ this.getUpdateKey("styles", "*")
806
+ );
807
+ });
808
+ n.push(u), r.push(u);
809
+ } else {
810
+ const i = Me(t);
811
+ for (const u in i) {
812
+ const { value: c, priority: a } = i[u];
813
+ if (p(c)) {
814
+ const l = c.watch((h) => {
815
+ this.elementContext.root.batch.write(() => {
816
+ h ? e.style.setProperty(u, String(h), a) : e.style.removeProperty(u);
817
+ });
818
+ });
819
+ n.push(l), r.push(l);
820
+ } else c != null && e.style.setProperty(u, String(c));
821
+ }
822
+ }
823
+ return function() {
824
+ for (const u of r)
825
+ u(), n.splice(n.indexOf(u), 1);
826
+ };
827
+ }
828
+ applyClasses(e, t, n) {
829
+ const r = [];
830
+ if (p(t)) {
831
+ let i;
832
+ const u = t.watch((c) => {
833
+ this.elementContext.root.batch.write(
834
+ () => {
835
+ P(i) && i(), e.removeAttribute("class"), i = this.applyClasses(e, c, n);
836
+ },
837
+ this.getUpdateKey("attr", "class")
838
+ );
839
+ });
840
+ n.push(u), r.push(u);
841
+ } else {
842
+ const i = xe(t);
843
+ for (const u in i) {
844
+ const c = i[u];
845
+ if (p(c)) {
846
+ const a = c.watch((l) => {
847
+ this.elementContext.root.batch.write(() => {
848
+ l ? e.classList.add(u) : e.classList.remove(u);
849
+ });
850
+ });
851
+ n.push(a), r.push(a);
852
+ } else c && e.classList.add(u);
853
+ }
854
+ }
855
+ return function() {
856
+ for (const u of r)
857
+ u(), n.splice(n.indexOf(u), 1);
858
+ };
859
+ }
860
+ }
861
+ function xe(s) {
862
+ let e = {};
863
+ if (x(s)) {
864
+ const t = s.split(" ");
865
+ for (const n of t)
866
+ e[n] = !0;
867
+ } else Ce(s) ? Object.assign(e, s) : Array.isArray(s) && Array.from(s).filter(Boolean).forEach((t) => {
868
+ Object.assign(e, xe(t));
869
+ });
870
+ return delete e.undefined, e;
871
+ }
872
+ function Me(s) {
873
+ let e = {};
874
+ if (x(s)) {
875
+ const t = s.split(";").filter((n) => n.trim() !== "");
876
+ for (const n of t) {
877
+ const [r, i] = n.split(":"), u = {
878
+ value: i
879
+ };
880
+ i.includes("!important") ? (u.priority = "important", u.value = i.replace("!important", "").trim()) : u.value = i.trim(), e[ne(r.trim())] = u;
881
+ }
882
+ }
883
+ if (Ce(s))
884
+ for (const t in s)
885
+ t.startsWith("--") ? e[t] = { value: s[t] } : e[ne(t)] = { value: s[t] };
886
+ else Array.isArray(s) && Array.from(s).filter((t) => t != null).forEach((t) => {
887
+ Object.assign(e, Me(t));
888
+ });
889
+ return e;
890
+ }
891
+ function ne(s) {
892
+ return s.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (e, t) => (t ? "-" : "") + e.toLowerCase());
893
+ }
894
+ function et(s, e) {
895
+ const t = typeof s;
896
+ return t === "string" ? String(e) : t === "number" ? Number(e) : t === "boolean" ? !!e : e;
897
+ }
898
+ const tt = ["ref", "children", "class", "style", "data"];
899
+ var le;
900
+ le = b;
901
+ class nt {
902
+ constructor({ states: e, renderFn: t, elementContext: n }) {
903
+ o(this, le, !0);
904
+ o(this, "node");
905
+ o(this, "endNode");
906
+ o(this, "connectedViews", []);
907
+ o(this, "renderFn");
908
+ o(this, "elementContext");
909
+ o(this, "observerControls");
910
+ o(this, "watcher", K());
911
+ this.elementContext = n, this.renderFn = t, this.node = document.createComment("Observer"), this.endNode = document.createComment("/Observer");
912
+ let r;
913
+ this.observerControls = {
914
+ start: () => {
915
+ r == null && (r = this.watcher.watch(e, (...i) => {
916
+ let u = this.renderFn(...i);
917
+ if (!Ve(u))
918
+ throw console.error(u, i), new TypeError(
919
+ `Observer received invalid value to render. Got type: ${N(u)}, value: ${u}`
920
+ );
921
+ Array.isArray(u) ? this.update(...u) : this.update(u);
922
+ }));
923
+ },
924
+ stop: () => {
925
+ r != null && (r(), r = void 0);
926
+ }
927
+ };
928
+ }
929
+ get isMounted() {
930
+ return this.node.parentNode != null;
931
+ }
932
+ mount(e, t) {
933
+ this.isMounted || (e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), this.observerControls.start());
934
+ }
935
+ unmount(e = !1) {
936
+ var t;
937
+ this.observerControls.stop(), this.watcher.stopAll(), this.isMounted && (this.cleanup(e), (t = this.node.parentNode) == null || t.removeChild(this.node));
938
+ }
939
+ cleanup(e) {
940
+ var t;
941
+ for (; this.connectedViews.length > 0; )
942
+ (t = this.connectedViews.pop()) == null || t.unmount(e);
943
+ }
944
+ update(...e) {
945
+ var n, r;
946
+ if (this.cleanup(!1), e == null || !this.isMounted)
947
+ return;
948
+ const t = e.map((i) => Ne(i) ? i : $(i) ? M(_(this.elementContext, i)) : M(_(this.elementContext, A(i))));
949
+ for (const i of t) {
950
+ const u = ((n = this.connectedViews.at(-1)) == null ? void 0 : n.node) || this.node;
951
+ i.mount(this.node.parentNode, u), this.connectedViews.push(i);
952
+ }
953
+ if (this.elementContext.root.getEnv() === "development") {
954
+ const i = (r = this.connectedViews.at(-1)) == null ? void 0 : r.node;
955
+ this.endNode.previousSibling !== i && this.node.parentNode.insertBefore(this.endNode, (i == null ? void 0 : i.nextSibling) ?? null);
956
+ }
957
+ }
958
+ }
959
+ var he;
960
+ he = b;
961
+ class $e {
962
+ constructor(e) {
963
+ o(this, he, !0);
964
+ o(this, "node", document.createTextNode(""));
965
+ o(this, "isMounted", !1);
966
+ o(this, "elements");
967
+ o(this, "children", []);
968
+ o(this, "stopCallback");
969
+ this.elements = e;
970
+ }
971
+ mount(e, t) {
972
+ this.isMounted || (this.isMounted = !0, e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), p(this.elements) ? this.stopCallback = this.elements.watch((n) => {
973
+ this.update(n);
974
+ }) : this.update(this.children));
975
+ }
976
+ unmount(e = !1) {
977
+ if (this.stopCallback && (this.stopCallback(), this.stopCallback = void 0), this.isMounted) {
978
+ for (const t of this.children)
979
+ t.unmount(e);
980
+ this.children = [], this.isMounted = !1;
981
+ }
982
+ }
983
+ update(e) {
984
+ for (const t of this.children)
985
+ t.unmount(!1);
986
+ for (let t = 0; t < e.length; t++) {
987
+ const n = e[t], r = t > 0 ? e[t] : void 0;
988
+ n.mount(this.node.parentElement, r == null ? void 0 : r.node);
989
+ }
990
+ this.children = e;
991
+ }
992
+ }
993
+ var fe;
994
+ fe = b;
995
+ class st {
996
+ constructor(e) {
997
+ o(this, fe, !0);
998
+ o(this, "config");
999
+ o(this, "element");
1000
+ this.config = e;
1001
+ }
1002
+ get isMounted() {
1003
+ return this.element ? this.element.isMounted : !1;
1004
+ }
1005
+ mount(e, t) {
1006
+ const { content: n, parent: r } = this.config;
1007
+ Ne(n) ? this.element = n : $(n) ? this.element = M(_(this.config.elementContext, n)) : this.element = M(_(this.config.elementContext, A(n))), this.element.mount(r);
1008
+ }
1009
+ unmount(e = !1) {
1010
+ var t;
1011
+ (t = this.element) != null && t.isMounted && this.element.unmount(e);
1012
+ }
1013
+ }
1014
+ class rt {
1015
+ constructor(e) {
1016
+ o(this, "__view");
1017
+ this.__view = e;
1018
+ const t = Object.getOwnPropertyDescriptors(this.__view._logger);
1019
+ for (const n in t)
1020
+ n !== "getName" && Object.defineProperty(this, n, t[n]);
1021
+ }
1022
+ get uid() {
1023
+ return this.__view.uniqueId;
1024
+ }
1025
+ setName(e) {
1026
+ return this.__view._logger.setName(e), this;
1027
+ }
1028
+ set(e, t) {
1029
+ return this.__view._elementContext.data[e] = t, t;
1030
+ }
1031
+ get(e) {
1032
+ let t = this.__view._elementContext;
1033
+ for (; ; ) {
1034
+ if (e in t.data)
1035
+ return t.data[e];
1036
+ if (t.parent)
1037
+ t = t.parent;
1038
+ else
1039
+ break;
1040
+ }
1041
+ return null;
1042
+ }
1043
+ getAll() {
1044
+ const e = [];
1045
+ let t = this.__view._elementContext;
1046
+ for (; e.push(t.data), t.parent; )
1047
+ t = t.parent;
1048
+ const n = {};
1049
+ for (const r of e.reverse())
1050
+ Object.assign(n, r);
1051
+ return n;
1052
+ }
1053
+ beforeMount(e) {
1054
+ this.__view._beforeMountCallbacks.push(e);
1055
+ }
1056
+ onMount(e) {
1057
+ this.__view._onMountCallbacks.push(e);
1058
+ }
1059
+ beforeUnmount(e) {
1060
+ this.__view._beforeUnmountCallbacks.push(e);
1061
+ }
1062
+ onUnmount(e) {
1063
+ this.__view._onUnmountCallbacks.push(e);
1064
+ }
1065
+ watch(e, t) {
1066
+ const n = this.__view;
1067
+ if (n.isMounted)
1068
+ return n._watcher.watch(e, t);
1069
+ {
1070
+ let r, i = !1;
1071
+ return n._onMountCallbacks.push(() => {
1072
+ i || (r = n._watcher.watch(e, t));
1073
+ }), () => {
1074
+ r != null && (i = !0, r());
1075
+ };
1076
+ }
1077
+ }
1078
+ outlet() {
1079
+ return y("$outlet", { $children: this.__view._$children });
1080
+ }
1081
+ }
1082
+ var de;
1083
+ de = b;
1084
+ const H = class H {
1085
+ constructor(e, t, n, r = []) {
1086
+ o(this, de, !0);
1087
+ o(this, "uniqueId", ve());
1088
+ o(this, "_elementContext");
1089
+ o(this, "_logger");
1090
+ o(this, "_view");
1091
+ o(this, "_props");
1092
+ o(this, "_element");
1093
+ o(this, "_$children");
1094
+ o(this, "_setChildren");
1095
+ o(this, "_watcher", K());
1096
+ o(this, "_beforeMountCallbacks", []);
1097
+ o(this, "_onMountCallbacks", []);
1098
+ o(this, "_beforeUnmountCallbacks", []);
1099
+ o(this, "_onUnmountCallbacks", []);
1100
+ o(this, "isMounted", !1);
1101
+ this._elementContext = { ...e, data: {}, parent: e }, this._logger = e.root.createLogger(t.name, { uid: this.uniqueId }), this._view = t, this._props = n, [this._$children, this._setChildren] = G(_(e, r));
1102
+ }
1103
+ /*===============================*\
1104
+ || "Public" API ||
1105
+ \*===============================*/
1106
+ get node() {
1107
+ var e;
1108
+ return (e = this._element) == null ? void 0 : e.node;
1109
+ }
1110
+ mount(e, t) {
1111
+ const n = this.isMounted;
1112
+ if (!n)
1113
+ for (this.initialize(); this._beforeMountCallbacks.length > 0; )
1114
+ this._beforeMountCallbacks.shift()();
1115
+ this._element && this._element.mount(e, t), n || (this.isMounted = !0, requestAnimationFrame(() => {
1116
+ for (; this._onMountCallbacks.length > 0; )
1117
+ this._onMountCallbacks.shift()();
1118
+ }));
1119
+ }
1120
+ unmount(e = !1) {
1121
+ for (; this._beforeUnmountCallbacks.length > 0; )
1122
+ this._beforeUnmountCallbacks.shift()();
1123
+ for (this._element && this._element.unmount(e), this.isMounted = !1; this._onUnmountCallbacks.length > 0; )
1124
+ this._onUnmountCallbacks.shift()();
1125
+ this._watcher.stopAll();
1126
+ }
1127
+ setChildView(e) {
1128
+ const t = new H(this._elementContext, e, {});
1129
+ return this._setChildren([t]), t;
1130
+ }
1131
+ /*===============================*\
1132
+ || Internal ||
1133
+ \*===============================*/
1134
+ initialize() {
1135
+ const e = new rt(this);
1136
+ let t;
1137
+ try {
1138
+ t = this._view(this._props, e);
1139
+ } catch (n) {
1140
+ throw n instanceof Error && this._logger.crash(n), n;
1141
+ }
1142
+ if (t !== null) if (t instanceof Node)
1143
+ this._element = M(_(this._elementContext, y("$node", { value: t })));
1144
+ else if ($(t) || ye($, t))
1145
+ this._element = M(_(this._elementContext, t));
1146
+ else if (p(t))
1147
+ this._element = M(
1148
+ _(this._elementContext, y("$observer", { states: [t], renderFn: (n) => n }))
1149
+ );
1150
+ else {
1151
+ const n = new TypeError(
1152
+ `Expected '${this._view.name}' function to return a DOM node, Markup element, Readable or null. Got: ${N(t)}`
1153
+ );
1154
+ this._logger.crash(n);
1155
+ }
1156
+ }
1157
+ };
1158
+ let W = H;
1159
+ var pe;
1160
+ pe = b;
1161
+ class it {
1162
+ constructor({ elementContext: e, $items: t, renderFn: n, keyFn: r }) {
1163
+ o(this, pe, !0);
1164
+ o(this, "node");
1165
+ o(this, "endNode");
1166
+ o(this, "$items");
1167
+ o(this, "stopCallback");
1168
+ o(this, "connectedItems", []);
1169
+ o(this, "elementContext");
1170
+ o(this, "renderFn");
1171
+ o(this, "keyFn");
1172
+ this.elementContext = e, this.$items = t, this.renderFn = n, this.keyFn = r, this.elementContext.root.getEnv() === "development" ? (this.node = document.createComment("Repeat"), this.endNode = document.createComment("/Repeat")) : (this.node = document.createTextNode(""), this.endNode = document.createTextNode(""));
1173
+ }
1174
+ get isMounted() {
1175
+ return this.node.parentNode != null;
1176
+ }
1177
+ mount(e, t) {
1178
+ this.isMounted || (e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null), this.stopCallback = this.$items.watch((n) => {
1179
+ this._update(Array.from(n));
1180
+ }));
1181
+ }
1182
+ unmount(e = !1) {
1183
+ var t, n;
1184
+ this.stopCallback && (this.stopCallback(), this.stopCallback = void 0), !e && this.isMounted && ((t = this.node.parentNode) == null || t.removeChild(this.node), (n = this.endNode.parentNode) == null || n.removeChild(this.endNode)), this._cleanup(e);
1185
+ }
1186
+ _cleanup(e) {
1187
+ for (const t of this.connectedItems)
1188
+ t.element.unmount(e);
1189
+ this.connectedItems = [];
1190
+ }
1191
+ _update(e) {
1192
+ var i, u, c;
1193
+ if (e.length === 0 || !this.isMounted)
1194
+ return this._cleanup(!1);
1195
+ const t = [];
1196
+ let n = 0;
1197
+ for (const a of e)
1198
+ t.push({
1199
+ key: this.keyFn(a, n),
1200
+ value: a,
1201
+ index: n++
1202
+ });
1203
+ const r = [];
1204
+ for (const a of this.connectedItems)
1205
+ t.find((h) => h.key === a.key) || a.element.unmount(!1);
1206
+ for (const a of t) {
1207
+ const l = this.connectedItems.find((h) => h.key === a.key);
1208
+ if (l)
1209
+ l.setValue(a.value), l.setIndex(a.index), r[a.index] = l;
1210
+ else {
1211
+ const [h, f] = G(a.value), [d, m] = G(a.index);
1212
+ r[a.index] = {
1213
+ key: a.key,
1214
+ $value: h,
1215
+ setValue: f,
1216
+ $index: d,
1217
+ setIndex: m,
1218
+ element: new W(this.elementContext, ot, {
1219
+ $value: h,
1220
+ $index: d,
1221
+ renderFn: this.renderFn
1222
+ })
1223
+ };
1224
+ }
1225
+ }
1226
+ for (let a = 0; a < r.length; a++) {
1227
+ const l = r[a], h = ((i = r[a - 1]) == null ? void 0 : i.element.node) ?? this.node;
1228
+ l.element.mount(this.node.parentNode, h);
1229
+ }
1230
+ if (this.connectedItems = r, this.elementContext.root.getEnv() === "development") {
1231
+ this.node.textContent = `Repeat (${r.length} item${r.length === 1 ? "" : "s"})`;
1232
+ const a = ((u = r.at(-1)) == null ? void 0 : u.element.node) ?? this.node;
1233
+ (c = this.node.parentNode) == null || c.insertBefore(this.endNode, a.nextSibling);
1234
+ }
1235
+ }
1236
+ }
1237
+ function ot({ $value: s, $index: e, renderFn: t }, n) {
1238
+ return t(s, e, n);
1239
+ }
1240
+ var me;
1241
+ me = b;
1242
+ class ut {
1243
+ constructor({ value: e }) {
1244
+ o(this, me, !0);
1245
+ o(this, "node", document.createTextNode(""));
1246
+ o(this, "value", "");
1247
+ o(this, "stopCallback");
1248
+ this.value = e;
1249
+ }
1250
+ get isMounted() {
1251
+ return this.node.parentNode != null;
1252
+ }
1253
+ async mount(e, t = null) {
1254
+ this.isMounted || (p(this.value) ? this.stopCallback = this.value.watch((n) => {
1255
+ this.update(n);
1256
+ }) : this.update(this.value)), e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null);
1257
+ }
1258
+ async unmount(e = !1) {
1259
+ this.isMounted && (this.stopCallback && (this.stopCallback(), this.stopCallback = void 0), e || this.node.parentNode.removeChild(this.node));
1260
+ }
1261
+ update(e) {
1262
+ e != null ? this.node.textContent = e.toString() : this.node.textContent = "";
1263
+ }
1264
+ }
1265
+ function $(s) {
1266
+ return (s == null ? void 0 : s[ke]) === !0;
1267
+ }
1268
+ function Ne(s) {
1269
+ return (s == null ? void 0 : s[b]) === !0;
1270
+ }
1271
+ function A(s) {
1272
+ return V(s) || (s = [s]), s.flat(1 / 0).filter((e) => e != null && e !== !1).map((e) => {
1273
+ if (e instanceof Node)
1274
+ return y("$node", { value: e });
1275
+ if (e instanceof Ae)
1276
+ return y("$node", { value: e.node });
1277
+ if ($(e))
1278
+ return e;
1279
+ if (x(e) || _e(e))
1280
+ return y("$text", { value: e });
1281
+ if (p(e))
1282
+ return y("$observer", {
1283
+ states: [e],
1284
+ renderFn: (t) => t
1285
+ });
1286
+ throw console.error(e), new TypeError(`Unexpected child type. Got: ${e}`);
1287
+ });
1288
+ }
1289
+ function y(s, e, ...t) {
1290
+ return e != null && at(e), {
1291
+ [ke]: !0,
1292
+ type: s,
1293
+ props: e,
1294
+ children: A(t)
1295
+ };
1296
+ }
1297
+ function at(s) {
1298
+ if (s.ref && !Ee(s.ref))
1299
+ throw console.warn(s.ref), new TypeError(`Prop 'ref' must be a Ref object. Got: ${s.ref}`);
1300
+ for (const e in s)
1301
+ if (e.startsWith("$$") && s[e] !== void 0) {
1302
+ if (!B(s[e]))
1303
+ throw new TypeError(`Prop '${e}' is named as a SettableState but value is not. Got: ${s[e]}`);
1304
+ } else if (e.startsWith("$") && s[e] !== void 0 && !p(s[e]))
1305
+ throw new TypeError(`Prop '${e}' is named as a State but value is not. Got: ${s[e]}`);
1306
+ }
1307
+ const vt = Ze.bind(y);
1308
+ function bt(s, e, t) {
1309
+ const n = L(s);
1310
+ return y("$cond", {
1311
+ $predicate: n,
1312
+ thenContent: e,
1313
+ elseContent: t
1314
+ });
1315
+ }
1316
+ function St(s, e, t) {
1317
+ const n = L(s);
1318
+ return y("$repeat", { $items: n, keyFn: e, renderFn: t });
1319
+ }
1320
+ function kt(s, e) {
1321
+ return y("$portal", { parent: s, content: e });
1322
+ }
1323
+ var ge;
1324
+ ge = b;
1325
+ class Ae {
1326
+ constructor(e) {
1327
+ o(this, ge, !0);
1328
+ o(this, "node");
1329
+ this.node = e;
1330
+ }
1331
+ get isMounted() {
1332
+ return this.node.parentNode != null;
1333
+ }
1334
+ async mount(e, t) {
1335
+ e.insertBefore(this.node, (t == null ? void 0 : t.nextSibling) ?? null);
1336
+ }
1337
+ async unmount() {
1338
+ this.node.parentNode && this.node.parentNode.removeChild(this.node);
1339
+ }
1340
+ }
1341
+ function _(s, e) {
1342
+ return (V(e) ? e : [e]).map((n) => {
1343
+ if (P(n.type))
1344
+ return new W(s, n.type, n.props, n.children);
1345
+ if (x(n.type))
1346
+ switch (n.type) {
1347
+ case "$node": {
1348
+ const r = n.props;
1349
+ return new Ae(r.value);
1350
+ }
1351
+ case "$text": {
1352
+ const r = n.props;
1353
+ return new ut({
1354
+ value: r.value
1355
+ });
1356
+ }
1357
+ case "$cond": {
1358
+ const r = n.props;
1359
+ return new Xe({
1360
+ $predicate: r.$predicate,
1361
+ thenContent: r.thenContent,
1362
+ elseContent: r.elseContent,
1363
+ elementContext: s
1364
+ });
1365
+ }
1366
+ case "$repeat": {
1367
+ const r = n.props;
1368
+ return new it({
1369
+ $items: r.$items,
1370
+ keyFn: r.keyFn,
1371
+ renderFn: r.renderFn,
1372
+ elementContext: s
1373
+ });
1374
+ }
1375
+ case "$observer": {
1376
+ const r = n.props;
1377
+ return new nt({
1378
+ states: r.states,
1379
+ renderFn: r.renderFn,
1380
+ elementContext: s
1381
+ });
1382
+ }
1383
+ case "$outlet": {
1384
+ const r = n.props;
1385
+ return new $e(r.$children);
1386
+ }
1387
+ case "$portal": {
1388
+ const r = n.props;
1389
+ return new st({
1390
+ content: r.content,
1391
+ parent: r.parent,
1392
+ elementContext: s
1393
+ });
1394
+ }
1395
+ default:
1396
+ if (n.type.startsWith("$"))
1397
+ throw new Error(`Unknown markup type: ${n.type}`);
1398
+ return new Qe({
1399
+ tag: n.type,
1400
+ props: n.props ?? {},
1401
+ children: n.children,
1402
+ elementContext: s
1403
+ });
1404
+ }
1405
+ else
1406
+ throw new TypeError(`Expected a string or view function. Got: ${n.type}`);
1407
+ });
1408
+ }
1409
+ function M(s) {
1410
+ return s.length === 1 ? s[0] : new $e(s);
1411
+ }
1412
+ function Ve(s) {
1413
+ return s == null || s === !1 || x(s) || _e(s) || $(s) || p(s) || ye(Ve, s);
1414
+ }
1415
+ function Et(s, e) {
1416
+ return e.outlet();
1417
+ }
1418
+ export {
1419
+ _ as A,
1420
+ _t as B,
1421
+ be as C,
1422
+ kt as D,
1423
+ St as E,
1424
+ Et as P,
1425
+ W as V,
1426
+ G as a,
1427
+ x as b,
1428
+ bt as c,
1429
+ He as d,
1430
+ mt as e,
1431
+ P as f,
1432
+ ft as g,
1433
+ vt as h,
1434
+ Ce as i,
1435
+ ht as j,
1436
+ lt as k,
1437
+ K as l,
1438
+ gt as m,
1439
+ wt as n,
1440
+ yt as o,
1441
+ L as p,
1442
+ Ct as q,
1443
+ Ee as r,
1444
+ pt as s,
1445
+ N as t,
1446
+ dt as u,
1447
+ Be as v,
1448
+ y as w,
1449
+ Re as x,
1450
+ De as y,
1451
+ M as z
1452
+ };
1453
+ //# sourceMappingURL=passthrough-C9975ULD.js.map