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

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