@manyducks.co/dolla 2.0.0-alpha.55 → 2.0.0-alpha.57

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 (49) hide show
  1. package/README.md +5 -2
  2. package/dist/core/context.d.ts +38 -25
  3. package/dist/core/env.d.ts +2 -8
  4. package/dist/core/index.d.ts +3 -5
  5. package/dist/core/logger.d.ts +2 -2
  6. package/dist/core/markup.d.ts +43 -42
  7. package/dist/core/mount.d.ts +1 -1
  8. package/dist/core/nodes/dom.d.ts +6 -6
  9. package/dist/core/nodes/dynamic.d.ts +13 -15
  10. package/dist/core/nodes/html.d.ts +9 -21
  11. package/dist/core/nodes/portal.d.ts +8 -12
  12. package/dist/core/nodes/repeat.d.ts +13 -18
  13. package/dist/core/nodes/view.d.ts +10 -23
  14. package/dist/core/ref.d.ts +2 -6
  15. package/dist/core/symbols.d.ts +1 -1
  16. package/dist/core/views/default-crash-view.d.ts +1 -1
  17. package/dist/core/views/fragment.d.ts +1 -2
  18. package/dist/fragment-BahD_BJA.js +7 -0
  19. package/dist/fragment-BahD_BJA.js.map +1 -0
  20. package/dist/http.js +1 -1
  21. package/dist/i18n.js +2 -2
  22. package/dist/index.js +41 -41
  23. package/dist/index.js.map +1 -1
  24. package/dist/jsx-dev-runtime.d.ts +1 -1
  25. package/dist/jsx-dev-runtime.js +2 -2
  26. package/dist/jsx-runtime.d.ts +2 -2
  27. package/dist/jsx-runtime.js +2 -2
  28. package/dist/{logger-CXdzxt1e.js → logger-sSxIw5od.js} +100 -100
  29. package/dist/logger-sSxIw5od.js.map +1 -0
  30. package/dist/markup-CAJd0zdA.js +937 -0
  31. package/dist/markup-CAJd0zdA.js.map +1 -0
  32. package/dist/router/index.d.ts +1 -1
  33. package/dist/router/router.d.ts +6 -6
  34. package/dist/{router-B-rtBG7i.js → router-ClSFnmRK.js} +184 -183
  35. package/dist/router-ClSFnmRK.js.map +1 -0
  36. package/dist/router.js +1 -1
  37. package/dist/router.js.map +1 -1
  38. package/dist/{typeChecking-lgllKIVq.js → typeChecking-BJ-ymQ2F.js} +5 -10
  39. package/dist/{typeChecking-lgllKIVq.js.map → typeChecking-BJ-ymQ2F.js.map} +1 -1
  40. package/dist/types.d.ts +40 -22
  41. package/package.json +1 -1
  42. package/dist/core/nodes/fragment.d.ts +0 -19
  43. package/dist/core/nodes/outlet.d.ts +0 -19
  44. package/dist/fragment-VXM-P2tT.js +0 -7
  45. package/dist/fragment-VXM-P2tT.js.map +0 -1
  46. package/dist/logger-CXdzxt1e.js.map +0 -1
  47. package/dist/markup-yTuFdC0t.js +0 -923
  48. package/dist/markup-yTuFdC0t.js.map +0 -1
  49. package/dist/router-B-rtBG7i.js.map +0 -1
@@ -0,0 +1,937 @@
1
+ var Y = Object.defineProperty;
2
+ var P = (o) => {
3
+ throw TypeError(o);
4
+ };
5
+ var tt = (o, t, e) => t in o ? Y(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
6
+ var c = (o, t, e) => tt(o, typeof t != "symbol" ? t + "" : t, e), C = (o, t, e) => t.has(o) || P("Cannot " + e);
7
+ var d = (o, t, e) => (C(o, t, "read from private field"), e ? e.call(o) : t.get(o)), L = (o, t, e) => t.has(o) ? P("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e), v = (o, t, e, s) => (C(o, t, "write to private field"), s ? s.call(o, e) : t.set(o, e), e);
8
+ import { c as u, t as et, g as H, b as T, i as z } from "./typeChecking-BJ-ymQ2F.js";
9
+ import { p as k, f as st, g as y, j as F, e as p, b as it, k as nt, $ as O, d as ot } from "./logger-sSxIw5od.js";
10
+ var m = /* @__PURE__ */ ((o) => (o[o.WILL_MOUNT = 0] = "WILL_MOUNT", o[o.DID_MOUNT = 1] = "DID_MOUNT", o[o.WILL_UNMOUNT = 2] = "WILL_UNMOUNT", o[o.DID_UNMOUNT = 3] = "DID_UNMOUNT", o))(m || {}), h;
11
+ class rt {
12
+ constructor() {
13
+ c(this, "state", 0);
14
+ c(this, "dependents", 0);
15
+ L(this, h, {});
16
+ }
17
+ on(t, e) {
18
+ d(this, h)[t] ? d(this, h)[t].indexOf(e) === -1 && d(this, h)[t].push(e) : d(this, h)[t] = [e];
19
+ }
20
+ off(t, e) {
21
+ d(this, h)[t] && (d(this, h)[t].splice(d(this, h)[t].indexOf(e), 1), d(this, h)[t].length === 0 && delete d(this, h)[t]);
22
+ }
23
+ notify(t) {
24
+ if (d(this, h)[t])
25
+ for (const e of d(this, h)[t])
26
+ e();
27
+ }
28
+ emit(t, e = !1) {
29
+ switch (t) {
30
+ case 0: {
31
+ e && this.dependents++, this.state < 1 && (this.state = e ? 2 : 1, this.notify(t));
32
+ break;
33
+ }
34
+ case 1: {
35
+ this.state >= 1 && this.state < 3 && (this.state += 2, this.notify(t));
36
+ break;
37
+ }
38
+ case 2: {
39
+ e ? (this.dependents--, this.dependents || this.emit(
40
+ 2
41
+ /* WILL_UNMOUNT */
42
+ )) : this.state >= 3 && this.state < 5 && (this.notify(t), this.state += 2);
43
+ break;
44
+ }
45
+ case 3: {
46
+ e ? !this.dependents && this.state === 6 && this.emit(
47
+ 3
48
+ /* DID_UNMOUNT */
49
+ ) : this.state >= 5 && this.state < 7 && (this.state = 7 % 7, this.notify(t));
50
+ break;
51
+ }
52
+ }
53
+ }
54
+ dispose() {
55
+ this.emit(
56
+ 2
57
+ /* WILL_UNMOUNT */
58
+ ), this.emit(
59
+ 3
60
+ /* DID_UNMOUNT */
61
+ ), v(this, h, {});
62
+ }
63
+ }
64
+ h = new WeakMap();
65
+ var _;
66
+ const S = class S {
67
+ constructor(t, e) {
68
+ L(this, _);
69
+ c(this, "_name");
70
+ c(this, "_lifecycle", new rt());
71
+ c(this, "_parent");
72
+ c(this, "_stores");
73
+ c(this, "_state");
74
+ v(this, _, t), this._name = k(t);
75
+ const s = st(() => y(d(this, _)), e == null ? void 0 : e.logger), i = Object.getOwnPropertyDescriptors(s);
76
+ for (const n in i)
77
+ Object.defineProperty(this, n, i[n]);
78
+ }
79
+ get isMounted() {
80
+ const { state: t } = this._lifecycle;
81
+ return t >= 3 && t < 7;
82
+ }
83
+ /**
84
+ * Returns a new Context with this one as its parent.
85
+ */
86
+ static linked(t, e, s) {
87
+ const i = new S(e, s);
88
+ return i._parent = t, s != null && s.bindLifecycleToParent ? (t._lifecycle.on(0, () => {
89
+ i._lifecycle.emit(
90
+ 0
91
+ /* WILL_MOUNT */
92
+ );
93
+ }), t._lifecycle.on(1, () => {
94
+ i._lifecycle.emit(
95
+ 1
96
+ /* DID_MOUNT */
97
+ );
98
+ }), t._lifecycle.on(2, () => {
99
+ i._lifecycle.emit(
100
+ 2
101
+ /* WILL_UNMOUNT */
102
+ );
103
+ }), t._lifecycle.on(3, () => {
104
+ i._lifecycle.emit(
105
+ 3
106
+ /* DID_UNMOUNT */
107
+ );
108
+ })) : (i._lifecycle.on(0, () => {
109
+ t._lifecycle.emit(0, !0);
110
+ }), i._lifecycle.on(1, () => {
111
+ t._lifecycle.emit(1, !0);
112
+ }), i._lifecycle.on(2, () => {
113
+ t._lifecycle.emit(2, !0);
114
+ }), i._lifecycle.on(3, () => {
115
+ t._lifecycle.emit(3, !0);
116
+ })), i;
117
+ }
118
+ static emit(t, e) {
119
+ e._lifecycle.emit(t);
120
+ }
121
+ /**
122
+ * Returns the current name of this context.
123
+ */
124
+ getName() {
125
+ return k(d(this, _));
126
+ }
127
+ /**
128
+ * Sets a new name for this context.
129
+ */
130
+ setName(t) {
131
+ v(this, _, t), this._name = k(t);
132
+ }
133
+ addStore(t, e) {
134
+ var i;
135
+ if ((i = this._stores) != null && i.get(t)) {
136
+ let n = t.name ? `'${t.name}'` : "this store";
137
+ return this.warn(`An instance of ${n} was already added on this context.`), this;
138
+ }
139
+ const s = S.linked(this, t.name, {
140
+ bindLifecycleToParent: !0,
141
+ logger: { tag: F(), tagName: "uid" }
142
+ });
143
+ try {
144
+ this._stores || (this._stores = /* @__PURE__ */ new Map());
145
+ const n = t.call(s, e, s);
146
+ this._stores.set(t, n);
147
+ } catch (n) {
148
+ throw this.crash(n);
149
+ }
150
+ return this;
151
+ }
152
+ getStore(t) {
153
+ var i;
154
+ if (!u(t))
155
+ throw new D("Invalid store.");
156
+ let e = this, s;
157
+ for (; s = (i = e._stores) == null ? void 0 : i.get(t), s == null && e._parent != null; )
158
+ e = e._parent;
159
+ if (s == null)
160
+ throw this.crash(new D(`Store '${t.name}' is not provided by this context.`));
161
+ return s;
162
+ }
163
+ /**
164
+ * Schedule a callback function to run just before this context is mounted.
165
+ */
166
+ beforeMount(t) {
167
+ return this._lifecycle.on(0, t), () => this._lifecycle.off(0, t);
168
+ }
169
+ /**
170
+ * Schedule a callback function to run after this context is mounted.
171
+ */
172
+ onMount(t) {
173
+ return this._lifecycle.on(1, t), () => this._lifecycle.off(1, t);
174
+ }
175
+ /**
176
+ * Schedule a callback function to run just before this context is unmounted.
177
+ */
178
+ beforeUnmount(t) {
179
+ return this._lifecycle.on(2, t), () => this._lifecycle.off(2, t);
180
+ }
181
+ /**
182
+ * Schedule a callback function to run after this context is unmounted.
183
+ */
184
+ onUnmount(t) {
185
+ return this._lifecycle.on(3, t), () => this._lifecycle.off(3, t);
186
+ }
187
+ effect(t) {
188
+ const e = () => {
189
+ try {
190
+ return t();
191
+ } catch (s) {
192
+ this.error(s), s instanceof Error ? this.crash(s) : typeof s == "string" ? this.crash(new Error(s)) : this.crash(new Error("Unknown error thrown in effect callback"));
193
+ }
194
+ };
195
+ if (this._lifecycle.state >= 1) {
196
+ const s = p(e);
197
+ return this._lifecycle.on(3, s), s;
198
+ } else {
199
+ let s, i = !1;
200
+ return this._lifecycle.on(0, () => {
201
+ i || (s = p(e), this._lifecycle.on(3, s));
202
+ }), () => {
203
+ s != null && (i = !0, s());
204
+ };
205
+ }
206
+ }
207
+ getState(t, e) {
208
+ var s;
209
+ if (arguments.length > 0) {
210
+ let i = this, n;
211
+ for (; n = (s = i._state) == null ? void 0 : s.get(t), n === void 0 && i._parent != null; )
212
+ i = i._parent;
213
+ if (n === void 0) {
214
+ if (arguments.length > 1)
215
+ return e;
216
+ throw new Error(`Expected a value for '${String(t)}' but got undefined.`);
217
+ }
218
+ return n;
219
+ } else {
220
+ let i = this;
221
+ const n = [];
222
+ for (; i._state && n.push(...i._state.entries()), i._parent != null; )
223
+ i = i._parent;
224
+ return new Map(n.reverse());
225
+ }
226
+ }
227
+ setState() {
228
+ if (this._state || (this._state = /* @__PURE__ */ new Map()), arguments.length === 2)
229
+ this._state.set(arguments[0], arguments[1]);
230
+ else if (et(arguments[0]) === "array")
231
+ for (const [t, e] of arguments[0])
232
+ e === void 0 ? this._state.delete(t) : this._state.set(t, e);
233
+ else
234
+ throw new Error("Invalid arguments.");
235
+ return this;
236
+ }
237
+ };
238
+ _ = new WeakMap();
239
+ let f = S;
240
+ function _t(o, t) {
241
+ return new f(o, t);
242
+ }
243
+ class D extends Error {
244
+ }
245
+ const x = Symbol.for("dollaMarkupNode");
246
+ var W;
247
+ W = x;
248
+ class N {
249
+ constructor(t) {
250
+ c(this, W, !0);
251
+ c(this, "root");
252
+ this.root = t;
253
+ }
254
+ get isMounted() {
255
+ return this.root.parentNode != null;
256
+ }
257
+ mount(t, e) {
258
+ t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null);
259
+ }
260
+ unmount(t = !1) {
261
+ this.root.parentNode && !t && this.root.parentNode.removeChild(this.root);
262
+ }
263
+ }
264
+ var B;
265
+ B = x;
266
+ class M {
267
+ constructor(t, e) {
268
+ c(this, B, !0);
269
+ c(this, "root", document.createTextNode(""));
270
+ c(this, "children", []);
271
+ c(this, "context");
272
+ c(this, "$slot");
273
+ c(this, "unsubscribe");
274
+ this.context = t, this.$slot = e;
275
+ }
276
+ get isMounted() {
277
+ return this.root.parentNode != null;
278
+ }
279
+ mount(t, e) {
280
+ this.isMounted || (t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.unsubscribe = p(() => {
281
+ try {
282
+ const s = this.$slot();
283
+ k(() => {
284
+ this.update(H(s) ? s : [s]);
285
+ });
286
+ } catch (s) {
287
+ this.context.error(s), this.context.crash(s);
288
+ }
289
+ }));
290
+ }
291
+ unmount(t = !1) {
292
+ var e, s;
293
+ (e = this.unsubscribe) == null || e.call(this), this.isMounted && (this.cleanup(t), (s = this.root.parentNode) == null || s.removeChild(this.root));
294
+ }
295
+ cleanup(t) {
296
+ for (const e of this.children)
297
+ e.unmount(t);
298
+ this.children = [];
299
+ }
300
+ update(t) {
301
+ var s;
302
+ if (this.cleanup(!1), t.length === 0 || !this.isMounted) return;
303
+ const e = A(this.context, t);
304
+ for (const i of e) {
305
+ const n = ((s = this.children.at(-1)) == null ? void 0 : s.root) || this.root;
306
+ i.mount(this.root.parentNode, n), this.children.push(i);
307
+ }
308
+ this.moveMarker();
309
+ }
310
+ /**
311
+ * Move marker node to end of children.
312
+ */
313
+ moveMarker() {
314
+ var s, i;
315
+ const t = this.root.parentNode, e = ((i = (s = this.children.at(-1)) == null ? void 0 : s.root) == null ? void 0 : i.nextSibling) ?? null;
316
+ "moveBefore" in t ? t.moveBefore(this.root, e) : t.insertBefore(this.root, e);
317
+ }
318
+ }
319
+ const R = Symbol("View");
320
+ var j;
321
+ j = x;
322
+ class Z {
323
+ constructor(t, e, s, i) {
324
+ c(this, j, !0);
325
+ c(this, "uniqueId", F());
326
+ c(this, "context");
327
+ c(this, "props");
328
+ c(this, "fn");
329
+ c(this, "node");
330
+ this.context = f.linked(t, e.name ?? "anonymous view", {
331
+ logger: {
332
+ tag: this.uniqueId,
333
+ tagName: "uid"
334
+ }
335
+ }), this.context.setState(R, this), this.props = { ...s, children: i }, this.fn = e;
336
+ }
337
+ /*===============================*\
338
+ || "Public" API ||
339
+ \*===============================*/
340
+ get root() {
341
+ var t;
342
+ return (t = this.node) == null ? void 0 : t.root;
343
+ }
344
+ get isMounted() {
345
+ return this.context.isMounted;
346
+ }
347
+ mount(t, e) {
348
+ const s = this.isMounted;
349
+ s || (this._initialize(), f.emit(m.WILL_MOUNT, this.context)), this.node && this.node.mount(t, e), s || f.emit(m.DID_MOUNT, this.context);
350
+ }
351
+ unmount(t = !1) {
352
+ f.emit(m.WILL_UNMOUNT, this.context), this.node && this.node.unmount(t), f.emit(m.DID_UNMOUNT, this.context);
353
+ }
354
+ /*===============================*\
355
+ || Internal ||
356
+ \*===============================*/
357
+ _initialize() {
358
+ const { context: t, props: e, fn: s } = this;
359
+ let i;
360
+ try {
361
+ i = s.call(t, e, t);
362
+ } catch (n) {
363
+ throw n instanceof Error && t.crash(n), n;
364
+ }
365
+ i == null || (i instanceof Node ? this.node = new N(i) : u(i) ? this.node = new M(t, i) : this.node = X(i, t));
366
+ }
367
+ }
368
+ const ct = (o) => /^on[A-Z]/.test(o), I = Symbol("HTML.isSVG");
369
+ var q;
370
+ q = x;
371
+ class at {
372
+ constructor(t, e, s, i) {
373
+ c(this, q, !0);
374
+ c(this, "root");
375
+ c(this, "context");
376
+ c(this, "props");
377
+ c(this, "children");
378
+ c(this, "childNodes", []);
379
+ c(this, "unsubscribers", []);
380
+ // Track the ref so we can nullify it on unmount.
381
+ c(this, "ref");
382
+ // Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
383
+ c(this, "canClickAway", !1);
384
+ if (this.context = f.linked(t, e), e.toLowerCase() === "svg" && this.context.setState(I, !0), this.context.getState(I, !1) ? this.root = document.createElementNS("http://www.w3.org/2000/svg", e) : this.root = document.createElement(e), it() === "development") {
385
+ const n = this.context.getState(R, null);
386
+ n && (this.root.dataset.view = n.context.getName());
387
+ }
388
+ if (s.ref)
389
+ if (u(s.ref))
390
+ this.ref = s.ref, this.ref(this.root);
391
+ else
392
+ throw new Error("Expected ref to be a function. Got: " + s.ref);
393
+ if (s.mixin) {
394
+ const n = H(s.mixin) ? s.mixin : [s.mixin];
395
+ for (const r of n)
396
+ r(
397
+ this.root,
398
+ f.linked(this.context, () => lt(this), {
399
+ bindLifecycleToParent: !0,
400
+ logger: { tagName: r.name === "mixin" ? void 0 : "mixin", tag: r.name }
401
+ })
402
+ );
403
+ }
404
+ this.props = {
405
+ ...nt(["ref", "mixin", "class", "className"], s),
406
+ class: s.className ?? s.class
407
+ }, this.children = i;
408
+ }
409
+ get isMounted() {
410
+ return this.root.parentNode != null;
411
+ }
412
+ mount(t, e) {
413
+ if (t == null)
414
+ throw new Error(`HTML element requires a parent element as the first argument to connect. Got: ${t}`);
415
+ const s = this.isMounted;
416
+ if (!s) {
417
+ f.emit(m.WILL_MOUNT, this.context), this.children && this.children.length > 0 && (this.childNodes = A(this.context, this.children));
418
+ for (let i = 0; i < this.childNodes.length; i++) {
419
+ const n = this.childNodes[i], r = i > 0 ? this.childNodes[i - 1].root : void 0;
420
+ n.mount(this.root, r);
421
+ }
422
+ this.applyProps(this.root, this.props), this.props.style && this.applyStyles(this.root, this.props.style, this.unsubscribers), this.props.class && this.applyClasses(this.root, this.props.class, this.unsubscribers);
423
+ }
424
+ t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), queueMicrotask(() => {
425
+ this.canClickAway = !0, s || f.emit(m.DID_MOUNT, this.context);
426
+ });
427
+ }
428
+ unmount(t = !1) {
429
+ var e;
430
+ if (this.isMounted) {
431
+ f.emit(m.WILL_UNMOUNT, this.context), t || (e = this.root.parentNode) == null || e.removeChild(this.root);
432
+ for (const s of this.childNodes)
433
+ s.unmount(!0);
434
+ this.canClickAway = !1;
435
+ for (const s of this.unsubscribers)
436
+ s();
437
+ this.unsubscribers.length = 0, this.ref && this.ref(void 0), f.emit(m.DID_UNMOUNT, this.context);
438
+ }
439
+ }
440
+ attachProp(t, e) {
441
+ u(t) ? this.unsubscribers.push(
442
+ p(() => {
443
+ try {
444
+ e(t());
445
+ } catch (s) {
446
+ this.context.error(s), this.context.crash(s);
447
+ }
448
+ })
449
+ ) : e(t);
450
+ }
451
+ applyProps(t, e) {
452
+ for (const s in e) {
453
+ const i = e[s];
454
+ if (s === "on:clickoutside" || s === "onClickOutside" || s === "onclickoutside") {
455
+ const n = (l) => {
456
+ this.canClickAway && !t.contains(l.target) && i(l);
457
+ }, r = { capture: !0 };
458
+ window.addEventListener("click", n, r), this.unsubscribers.push(() => {
459
+ window.removeEventListener("click", n, r);
460
+ });
461
+ } else if (u(i) && ct(s)) {
462
+ const n = s.slice(2).toLowerCase(), r = i;
463
+ t.addEventListener(n, r), this.unsubscribers.push(() => {
464
+ t.removeEventListener(n, r);
465
+ });
466
+ } else if (s.startsWith("on") && u(i) && ut.includes(s.substring(2)))
467
+ t[s] = i, this.unsubscribers.push(() => {
468
+ t[s] = void 0;
469
+ });
470
+ else if (s.includes("-"))
471
+ this.attachProp(i, (n) => {
472
+ n == null ? t.removeAttribute(s) : t.setAttribute(s, String(n));
473
+ });
474
+ else if (!ht.includes(s))
475
+ if (this.context.getState(I, !1))
476
+ this.attachProp(i, (n) => {
477
+ n != null ? t.setAttribute(s, String(e[s])) : t.removeAttribute(s);
478
+ });
479
+ else
480
+ switch (s) {
481
+ case "contentEditable":
482
+ case "value":
483
+ this.attachProp(i, (n) => {
484
+ t[s] = String(n);
485
+ });
486
+ break;
487
+ case "for":
488
+ this.attachProp(i, (n) => {
489
+ t.htmlFor = n;
490
+ });
491
+ break;
492
+ case "innerHTML":
493
+ this.attachProp(i, (n) => {
494
+ t.innerHTML = n;
495
+ });
496
+ break;
497
+ case "title":
498
+ this.attachProp(i, (n) => {
499
+ n == null ? t.removeAttribute(s) : t.setAttribute(s, String(n));
500
+ });
501
+ case "checked":
502
+ this.attachProp(i, (n) => {
503
+ t.checked = n, n ? t.setAttribute("checked", "") : t.removeAttribute("checked");
504
+ });
505
+ break;
506
+ case "autocomplete":
507
+ case "autocapitalize":
508
+ this.attachProp(i, (n) => {
509
+ typeof n == "string" ? t[s] = n : n ? t[s] = "on" : t[s] = "off";
510
+ });
511
+ break;
512
+ default: {
513
+ if (s.startsWith("prop:")) {
514
+ const n = s.substring(5);
515
+ this.attachProp(i, (r) => {
516
+ t[n] = r;
517
+ });
518
+ } else if (s.startsWith("on:")) {
519
+ const n = s.substring(3);
520
+ let r;
521
+ u(i) ? (t.addEventListener(n, i), this.unsubscribers.push(() => {
522
+ t.removeEventListener(n, i);
523
+ })) : this.attachProp(i, (l) => {
524
+ !l && r ? t.removeEventListener(n, r) : l != null && (r && r !== l && t.removeEventListener(n, r), t.addEventListener(n, l)), r = l;
525
+ });
526
+ } else if (s.startsWith("attr:")) {
527
+ const n = s.substring(5).toLowerCase();
528
+ this.attachProp(i, (r) => {
529
+ r != null ? t.setAttribute(n, String(r)) : t.removeAttribute(n);
530
+ });
531
+ } else
532
+ this.attachProp(i, (n) => {
533
+ t[s] = n;
534
+ });
535
+ break;
536
+ }
537
+ }
538
+ }
539
+ }
540
+ applyStyles(t, e, s) {
541
+ const i = [];
542
+ if (u(e)) {
543
+ let n;
544
+ const r = p(() => {
545
+ u(n) && n(), t.style.cssText = "", n = this.applyStyles(t, y(e), s);
546
+ });
547
+ s.push(r), i.push(r);
548
+ } else {
549
+ const n = J(e);
550
+ for (const r in n) {
551
+ const { value: l, priority: b } = n[r];
552
+ if (u(l)) {
553
+ const a = p(() => {
554
+ y(l) ? t.style.setProperty(r, String(y(l)), b) : t.style.removeProperty(r);
555
+ });
556
+ s.push(a), i.push(a);
557
+ } else l != null && t.style.setProperty(r, String(l));
558
+ }
559
+ }
560
+ return function() {
561
+ for (const r of i)
562
+ r(), s.splice(s.indexOf(r), 1);
563
+ };
564
+ }
565
+ applyClasses(t, e, s) {
566
+ const i = [];
567
+ if (u(e)) {
568
+ let n;
569
+ const r = p(() => {
570
+ u(n) && n(), t.removeAttribute("class"), n = this.applyClasses(t, y(e), s);
571
+ });
572
+ s.push(r), i.push(r);
573
+ } else {
574
+ const n = K(e);
575
+ for (const r in n) {
576
+ const l = n[r];
577
+ if (u(l)) {
578
+ const b = p(() => {
579
+ y(l) ? t.classList.add(r) : t.classList.remove(r);
580
+ });
581
+ s.push(b), i.push(b);
582
+ } else l && t.classList.add(r);
583
+ }
584
+ }
585
+ return function() {
586
+ for (const r of i)
587
+ r(), s.splice(s.indexOf(r), 1);
588
+ };
589
+ }
590
+ }
591
+ function K(o) {
592
+ let t = {};
593
+ if (T(o)) {
594
+ const e = o.split(" ");
595
+ for (const s of e)
596
+ t[s] = !0;
597
+ } else z(o) ? Object.assign(t, o) : Array.isArray(o) && Array.from(o).filter(Boolean).forEach((e) => {
598
+ Object.assign(t, K(e));
599
+ });
600
+ return delete t.undefined, t;
601
+ }
602
+ function J(o) {
603
+ let t = {};
604
+ if (T(o)) {
605
+ const e = o.split(";").filter((s) => s.trim() !== "");
606
+ for (const s of e) {
607
+ const [i, n] = s.split(":"), r = {
608
+ value: n
609
+ };
610
+ n.includes("!important") ? (r.priority = "important", r.value = n.replace("!important", "").trim()) : r.value = n.trim(), t[$(i.trim())] = r;
611
+ }
612
+ }
613
+ if (z(o))
614
+ for (const e in o)
615
+ e.startsWith("--") ? t[e] = { value: o[e] } : t[$(e)] = { value: o[e] };
616
+ else Array.isArray(o) && Array.from(o).filter((e) => e != null).forEach((e) => {
617
+ Object.assign(t, J(e));
618
+ });
619
+ return t;
620
+ }
621
+ function lt(o) {
622
+ let t = o.root.tagName.toLowerCase();
623
+ if (o.root.id && (t += `#${o.root.id}`), o.root.classList.length > 0)
624
+ for (const e of o.root.classList.values())
625
+ t += `.${e}`;
626
+ return t;
627
+ }
628
+ function $(o) {
629
+ return o.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, e) => (e ? "-" : "") + t.toLowerCase());
630
+ }
631
+ const ht = ["ref", "children", "class", "style", "data", "mixin"], ut = [
632
+ // Element
633
+ "animationcancel",
634
+ "animationend",
635
+ "animationiteration",
636
+ "animationstart",
637
+ "auxclick",
638
+ "beforeinput",
639
+ "beforematch",
640
+ "beforexrselect",
641
+ "blur",
642
+ "click",
643
+ "compositionend",
644
+ "compositionstart",
645
+ "compositionupdate",
646
+ "contentvisibilityautostatechange",
647
+ "contextmenu",
648
+ "copy",
649
+ "cut",
650
+ "dblclick",
651
+ "focus",
652
+ "focusin",
653
+ "focusout",
654
+ "fullscreenchange",
655
+ "fullscreenerror",
656
+ "gotpointercapture",
657
+ "input",
658
+ "keydown",
659
+ "keyup",
660
+ "lostpointercapture",
661
+ "mousedown",
662
+ "mouseenter",
663
+ "mouseleave",
664
+ "mousemove",
665
+ "mouseout",
666
+ "mouseover",
667
+ "mouseup",
668
+ "paste",
669
+ "pointercancel",
670
+ "pointerdown",
671
+ "pointerenter",
672
+ "pointerleave",
673
+ "pointermove",
674
+ "pointerout",
675
+ "pointerover",
676
+ "pointerrawupdate",
677
+ "pointerup",
678
+ "scroll",
679
+ "scrollend",
680
+ "scrollsnapchange",
681
+ "scrollsnapchanging",
682
+ "securitypolicyviolation",
683
+ "touchcancel",
684
+ "touchend",
685
+ "touchmove",
686
+ "touchstart",
687
+ "transitioncancel",
688
+ "transitionend",
689
+ "transitionrun",
690
+ "transitionstart",
691
+ "webkitmouseforcechanged",
692
+ "webkitmouseforcedown",
693
+ "webkitmouseforceup",
694
+ "webkimouseforcewillbegin",
695
+ "wheel",
696
+ // HTMLElement
697
+ "beforetoggle",
698
+ "change",
699
+ "command",
700
+ "drag",
701
+ "dragend",
702
+ "dragenter",
703
+ "dragleave",
704
+ "dragover",
705
+ "dragstart",
706
+ "drop",
707
+ "error",
708
+ "load",
709
+ "toggle",
710
+ // HTMLInputElement
711
+ "cancel",
712
+ "invalid",
713
+ "search",
714
+ "select",
715
+ "selectionchange",
716
+ // HTMLFormElement
717
+ "formdata",
718
+ "reset",
719
+ "submit"
720
+ ];
721
+ var V;
722
+ V = x;
723
+ class ft {
724
+ constructor(t, e, s) {
725
+ c(this, V, !0);
726
+ c(this, "context");
727
+ c(this, "content");
728
+ c(this, "parent");
729
+ c(this, "element");
730
+ this.context = t, this.content = e, this.parent = s;
731
+ }
732
+ get isMounted() {
733
+ return this.element ? this.element.isMounted : !1;
734
+ }
735
+ mount(t, e) {
736
+ this.element = X(this.content, this.context), this.element.mount(this.parent);
737
+ }
738
+ unmount(t = !1) {
739
+ var e;
740
+ (e = this.element) != null && e.isMounted && this.element.unmount(!1);
741
+ }
742
+ }
743
+ var G;
744
+ G = x;
745
+ class dt {
746
+ constructor(t, e, s, i) {
747
+ c(this, G, !0);
748
+ c(this, "root", document.createTextNode(""));
749
+ c(this, "context");
750
+ c(this, "items");
751
+ c(this, "key");
752
+ c(this, "render");
753
+ c(this, "unsubscribe", null);
754
+ c(this, "connectedItems", []);
755
+ this.context = t, this.items = e, this.key = s, this.render = i;
756
+ }
757
+ get isMounted() {
758
+ return this.root.parentNode != null;
759
+ }
760
+ mount(t, e) {
761
+ this.isMounted || (t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.unsubscribe = p(() => {
762
+ let s = this.items();
763
+ s == null && (s = [], this.context.warn("repeat() received empty value for items", s)), k(() => {
764
+ this._update(Array.from(s));
765
+ });
766
+ }));
767
+ }
768
+ unmount(t = !1) {
769
+ var e;
770
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = null), !t && this.isMounted && ((e = this.root.parentNode) == null || e.removeChild(this.root)), this._cleanup(t);
771
+ }
772
+ _cleanup(t) {
773
+ for (const e of this.connectedItems)
774
+ e.node.unmount(t);
775
+ this.connectedItems = [];
776
+ }
777
+ _update(t) {
778
+ var r, l, b;
779
+ if (t.length === 0 || !this.isMounted)
780
+ return this._cleanup(!1);
781
+ const e = [];
782
+ let s = 0;
783
+ for (const a of t)
784
+ e.push({
785
+ key: this.key(a, s),
786
+ value: a,
787
+ index: s++
788
+ });
789
+ const i = [];
790
+ for (const a of this.connectedItems)
791
+ e.find((g) => g.key === a.key) || a.node.unmount(!1);
792
+ for (const a of e) {
793
+ const w = this.connectedItems.find((g) => g.key === a.key);
794
+ if (w)
795
+ w.item(a.value), w.index(a.index), i[a.index] = w;
796
+ else {
797
+ const g = O(a.value, { equals: ot }), E = O(a.index);
798
+ i[a.index] = {
799
+ key: a.key,
800
+ item: g,
801
+ index: E,
802
+ node: new Z(this.context, pt, {
803
+ item: () => g(),
804
+ index: () => E(),
805
+ renderFn: this.render
806
+ })
807
+ };
808
+ }
809
+ }
810
+ for (let a = 0; a < i.length; a++) {
811
+ const w = i[a], g = ((r = i[a - 1]) == null ? void 0 : r.node.root) ?? this.root;
812
+ w.node.mount(this.root.parentNode, g);
813
+ }
814
+ this.connectedItems = i;
815
+ const n = ((l = i.at(-1)) == null ? void 0 : l.node.root) ?? this.root;
816
+ (b = this.root.parentNode) == null || b.insertBefore(this.root, n.nextSibling);
817
+ }
818
+ }
819
+ function pt(o, t) {
820
+ return t.setName("@RepeatItem"), o.renderFn.call(t, o.item, o.index, t);
821
+ }
822
+ class Q {
823
+ constructor(t, e, ...s) {
824
+ /**
825
+ * In the case of a view, type will be the View function itself. It can also hold an identifier for special nodes like "$cond", "$repeat", etc.
826
+ * DOM nodes can be created by name, such as HTML elements like "div", "ul" or "span", SVG elements like ""
827
+ */
828
+ c(this, "type");
829
+ /**
830
+ * Data that will be passed to a new MarkupNode instance when it is constructed.
831
+ */
832
+ c(this, "props");
833
+ /**
834
+ *
835
+ */
836
+ c(this, "children");
837
+ this.type = t, this.props = e, this.children = s;
838
+ }
839
+ }
840
+ function mt(o) {
841
+ return (o == null ? void 0 : o[x]) === !0;
842
+ }
843
+ function U(o, t, ...e) {
844
+ return new Q(o, t, ...e);
845
+ }
846
+ function gt(o, t, e) {
847
+ return U("$dynamic", {
848
+ source: O(() => {
849
+ const s = y(o);
850
+ return s && t ? t : !s && e ? e : null;
851
+ })
852
+ });
853
+ }
854
+ function xt(o, t, e) {
855
+ return gt(o, e, t);
856
+ }
857
+ function Nt(o, t, e) {
858
+ return U("$repeat", { items: () => y(o), key: t, render: e });
859
+ }
860
+ function kt(o, t) {
861
+ return U("$portal", { parent: o, content: t });
862
+ }
863
+ function X(o, t = new f("$")) {
864
+ const e = A(t, [o]);
865
+ return e.length === 1 ? e[0] : new M(t, () => e);
866
+ }
867
+ function A(o, ...t) {
868
+ const e = t.flat(1 / 0), s = [];
869
+ for (const i of e)
870
+ if (!(i == null || i === !1)) {
871
+ if (i instanceof Node) {
872
+ s.push(new N(i));
873
+ continue;
874
+ }
875
+ if (i instanceof Q)
876
+ if (u(i.type)) {
877
+ s.push(new Z(o, i.type, i.props, i.children));
878
+ continue;
879
+ } else if (T(i.type))
880
+ switch (i.type) {
881
+ case "$dom": {
882
+ const n = i.props;
883
+ s.push(new N(n.value));
884
+ continue;
885
+ }
886
+ case "$text": {
887
+ const n = i.props;
888
+ s.push(new N(document.createTextNode(String(n.value))));
889
+ continue;
890
+ }
891
+ case "$repeat": {
892
+ const n = i.props;
893
+ s.push(new dt(o, n.items, n.key, n.render));
894
+ continue;
895
+ }
896
+ case "$dynamic": {
897
+ const n = i.props;
898
+ s.push(new M(o, n.source));
899
+ continue;
900
+ }
901
+ case "$portal": {
902
+ const n = i.props;
903
+ s.push(new ft(o, n.content, n.parent));
904
+ continue;
905
+ }
906
+ default:
907
+ s.push(new at(o, i.type, i.props ?? {}, i.children));
908
+ continue;
909
+ }
910
+ else
911
+ throw new TypeError(`Expected a string or view function. Got: ${i.type}`);
912
+ if (mt(i)) {
913
+ s.push(i);
914
+ continue;
915
+ }
916
+ if (u(i)) {
917
+ s.push(new M(o, i));
918
+ continue;
919
+ }
920
+ s.push(new N(document.createTextNode(String(i))));
921
+ }
922
+ return s;
923
+ }
924
+ export {
925
+ f as C,
926
+ M as D,
927
+ m as L,
928
+ Z as V,
929
+ Nt as a,
930
+ _t as c,
931
+ U as m,
932
+ kt as p,
933
+ X as r,
934
+ xt as u,
935
+ gt as w
936
+ };
937
+ //# sourceMappingURL=markup-CAJd0zdA.js.map