@manyducks.co/dolla 2.0.0-alpha.16 → 2.0.0-alpha.17

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