@manyducks.co/dolla 2.0.0-alpha.9 → 2.0.0

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