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

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