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

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