@manyducks.co/dolla 2.0.0-alpha.45 → 2.0.0-alpha.47

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,12 +1,8 @@
1
- var $e = Object.defineProperty;
2
- var oe = (t) => {
3
- throw TypeError(t);
4
- };
5
- var Ie = (t, e, s) => e in t ? $e(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
6
- var c = (t, e, s) => Ie(t, typeof e != "symbol" ? e + "" : e, s), W = (t, e, s) => e.has(t) || oe("Cannot " + s);
7
- var w = (t, e, s) => (W(t, e, "read from private field"), s ? s.call(t) : e.get(t)), T = (t, e, s) => e.has(t) ? oe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), $ = (t, e, s, n) => (W(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), ue = (t, e, s) => (W(t, e, "access private method"), s);
8
- var M = /* @__PURE__ */ ((t) => (t[t.Computed = 1] = "Computed", t[t.Effect = 2] = "Effect", t[t.Tracking = 4] = "Tracking", t[t.Notified = 8] = "Notified", t[t.Recursed = 16] = "Recursed", t[t.Dirty = 32] = "Dirty", t[t.PendingComputed = 64] = "PendingComputed", t[t.PendingEffect = 128] = "PendingEffect", t[t.Propagated = 224] = "Propagated", t))(M || {});
9
- function ve({
1
+ var Ne = Object.defineProperty;
2
+ var xe = (t, e, s) => e in t ? Ne(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var f = (t, e, s) => xe(t, typeof e != "symbol" ? e + "" : e, s);
4
+ var E = /* @__PURE__ */ ((t) => (t[t.Computed = 1] = "Computed", t[t.Effect = 2] = "Effect", t[t.Tracking = 4] = "Tracking", t[t.Notified = 8] = "Notified", t[t.Recursed = 16] = "Recursed", t[t.Dirty = 32] = "Dirty", t[t.PendingComputed = 64] = "PendingComputed", t[t.PendingEffect = 128] = "PendingEffect", t[t.Propagated = 224] = "Propagated", t))(E || {});
5
+ function oe({
10
6
  updateComputed: t,
11
7
  notifyEffect: e
12
8
  }) {
@@ -19,18 +15,18 @@ function ve({
19
15
  * @param sub - The subscriber that depends on this dependency.
20
16
  * @returns The newly created link object if the two are not already linked; otherwise `undefined`.
21
17
  */
22
- link(r, u) {
18
+ link(o, u) {
23
19
  const l = u.depsTail;
24
- if (l !== void 0 && l.dep === r)
20
+ if (l !== void 0 && l.dep === o)
25
21
  return;
26
22
  const d = l !== void 0 ? l.nextDep : u.deps;
27
- if (d !== void 0 && d.dep === r) {
23
+ if (d !== void 0 && d.dep === o) {
28
24
  u.depsTail = d;
29
25
  return;
30
26
  }
31
- const a = r.subsTail;
27
+ const a = o.subsTail;
32
28
  if (!(a !== void 0 && a.sub === u && p(a, u)))
33
- return i(r, u, d, l);
29
+ return i(o, u, d, l);
34
30
  },
35
31
  /**
36
32
  * Traverses and marks subscribers starting from the provided link.
@@ -41,27 +37,27 @@ function ve({
41
37
  *
42
38
  * @param link - The starting link from which propagation begins.
43
39
  */
44
- propagate(r) {
45
- let u = 32, l = r, d = 0;
40
+ propagate(o) {
41
+ let u = 32, l = o, d = 0;
46
42
  e: do {
47
- const a = r.sub, h = a.flags;
48
- if (!(h & 244) && (a.flags = h | u | 8, !0) || h & 16 && !(h & 4) && (a.flags = h & -17 | u | 8, !0) || !(h & 224) && p(r, a) && (a.flags = h | 16 | u | 8, a.subs !== void 0)) {
49
- const N = a.subs;
50
- if (N !== void 0) {
51
- N.nextSub !== void 0 ? (N.prevSub = l, r = l = N, u = 64, ++d) : (r = N, u = h & 2 ? 128 : 64);
43
+ const a = o.sub, h = a.flags;
44
+ if (!(h & 244) && (a.flags = h | u | 8, !0) || h & 16 && !(h & 4) && (a.flags = h & -17 | u | 8, !0) || !(h & 224) && p(o, a) && (a.flags = h | 16 | u | 8, a.subs !== void 0)) {
45
+ const w = a.subs;
46
+ if (w !== void 0) {
47
+ w.nextSub !== void 0 ? (w.prevSub = l, o = l = w, u = 64, ++d) : (o = w, u = h & 2 ? 128 : 64);
52
48
  continue;
53
49
  }
54
50
  h & 2 && (n !== void 0 ? n.depsTail.nextDep = a.deps : s = a, n = a);
55
- } else h & (4 | u) ? !(h & u) && h & 224 && p(r, a) && (a.flags = h | u) : (a.flags = h | u | 8, (h & 10) === 2 && (n !== void 0 ? n.depsTail.nextDep = a.deps : s = a, n = a));
56
- if ((r = l.nextSub) !== void 0) {
57
- l = r, u = d ? 64 : 32;
51
+ } else h & (4 | u) ? !(h & u) && h & 224 && p(o, a) && (a.flags = h | u) : (a.flags = h | u | 8, (h & 10) === 2 && (n !== void 0 ? n.depsTail.nextDep = a.deps : s = a, n = a));
52
+ if ((o = l.nextSub) !== void 0) {
53
+ l = o, u = d ? 64 : 32;
58
54
  continue;
59
55
  }
60
56
  for (; d; ) {
61
57
  --d;
62
- const re = l.dep.subs;
63
- if (l = re.prevSub, re.prevSub = void 0, (r = l.nextSub) !== void 0) {
64
- l = r, u = d ? 64 : 32;
58
+ const W = l.dep.subs;
59
+ if (l = W.prevSub, W.prevSub = void 0, (o = l.nextSub) !== void 0) {
60
+ l = o, u = d ? 64 : 32;
65
61
  continue e;
66
62
  }
67
63
  }
@@ -76,8 +72,8 @@ function ve({
76
72
  *
77
73
  * @param sub - The subscriber to start tracking.
78
74
  */
79
- startTracking(r) {
80
- r.depsTail = void 0, r.flags = r.flags & -249 | 4;
75
+ startTracking(o) {
76
+ o.depsTail = void 0, o.flags = o.flags & -249 | 4;
81
77
  },
82
78
  /**
83
79
  * Concludes tracking of dependencies for the specified subscriber.
@@ -87,13 +83,13 @@ function ve({
87
83
  *
88
84
  * @param sub - The subscriber whose tracking is ending.
89
85
  */
90
- endTracking(r) {
91
- const u = r.depsTail;
86
+ endTracking(o) {
87
+ const u = o.depsTail;
92
88
  if (u !== void 0) {
93
89
  const l = u.nextDep;
94
- l !== void 0 && (m(l), u.nextDep = void 0);
95
- } else r.deps !== void 0 && (m(r.deps), r.deps = void 0);
96
- r.flags &= -5;
90
+ l !== void 0 && (g(l), u.nextDep = void 0);
91
+ } else o.deps !== void 0 && (g(o.deps), o.deps = void 0);
92
+ o.flags &= -5;
97
93
  },
98
94
  /**
99
95
  * Updates the dirty flag for the given subscriber based on its dependencies.
@@ -105,8 +101,8 @@ function ve({
105
101
  * @param flags - The current flag set for this subscriber.
106
102
  * @returns `true` if the subscriber is marked as Dirty; otherwise `false`.
107
103
  */
108
- updateDirtyFlag(r, u) {
109
- return o(r.deps) ? (r.flags = u | 32, !0) : (r.flags = u & -65, !1);
104
+ updateDirtyFlag(o, u) {
105
+ return r(o.deps) ? (o.flags = u | 32, !0) : (o.flags = u & -65, !1);
110
106
  },
111
107
  /**
112
108
  * Updates the computed subscriber if necessary before its value is accessed.
@@ -118,10 +114,10 @@ function ve({
118
114
  * @param computed - The computed subscriber to update.
119
115
  * @param flags - The current flag set for this subscriber.
120
116
  */
121
- processComputedUpdate(r, u) {
122
- if ((u & 32 || (o(r.deps) || (r.flags = u & -65, !1))) && t(r)) {
123
- const l = r.subs;
124
- l !== void 0 && f(l);
117
+ processComputedUpdate(o, u) {
118
+ if ((u & 32 || (r(o.deps) || (o.flags = u & -65, !1))) && t(o)) {
119
+ const l = o.subs;
120
+ l !== void 0 && c(l);
125
121
  }
126
122
  },
127
123
  /**
@@ -135,10 +131,10 @@ function ve({
135
131
  * @param sub - The subscriber which may have pending effects.
136
132
  * @param flags - The current flags on the subscriber to check.
137
133
  */
138
- processPendingInnerEffects(r, u) {
134
+ processPendingInnerEffects(o, u) {
139
135
  if (u & 128) {
140
- r.flags = u & -129;
141
- let l = r.deps;
136
+ o.flags = u & -129;
137
+ let l = o.deps;
142
138
  do {
143
139
  const d = l.dep;
144
140
  "flags" in d && d.flags & 2 && d.flags & 224 && e(d), l = l.nextDep;
@@ -154,69 +150,69 @@ function ve({
154
150
  */
155
151
  processEffectNotifications() {
156
152
  for (; s !== void 0; ) {
157
- const r = s, u = r.depsTail, l = u.nextDep;
158
- l !== void 0 ? (u.nextDep = void 0, s = l.sub) : (s = void 0, n = void 0), e(r) || (r.flags &= -9);
153
+ const o = s, u = o.depsTail, l = u.nextDep;
154
+ l !== void 0 ? (u.nextDep = void 0, s = l.sub) : (s = void 0, n = void 0), e(o) || (o.flags &= -9);
159
155
  }
160
156
  }
161
157
  };
162
- function i(r, u, l, d) {
158
+ function i(o, u, l, d) {
163
159
  const a = {
164
- dep: r,
160
+ dep: o,
165
161
  sub: u,
166
162
  nextDep: l,
167
163
  prevSub: void 0,
168
164
  nextSub: void 0
169
165
  };
170
- if (d === void 0 ? u.deps = a : d.nextDep = a, r.subs === void 0)
171
- r.subs = a;
166
+ if (d === void 0 ? u.deps = a : d.nextDep = a, o.subs === void 0)
167
+ o.subs = a;
172
168
  else {
173
- const h = r.subsTail;
169
+ const h = o.subsTail;
174
170
  a.prevSub = h, h.nextSub = a;
175
171
  }
176
- return u.depsTail = a, r.subsTail = a, a;
172
+ return u.depsTail = a, o.subsTail = a, a;
177
173
  }
178
- function o(r) {
174
+ function r(o) {
179
175
  let u = 0, l;
180
176
  e: do {
181
177
  l = !1;
182
- const d = r.dep;
178
+ const d = o.dep;
183
179
  if ("flags" in d) {
184
180
  const a = d.flags;
185
181
  if ((a & 33) === 33) {
186
182
  if (t(d)) {
187
183
  const h = d.subs;
188
- h.nextSub !== void 0 && f(h), l = !0;
184
+ h.nextSub !== void 0 && c(h), l = !0;
189
185
  }
190
186
  } else if ((a & 65) === 65) {
191
187
  const h = d.subs;
192
- h.nextSub !== void 0 && (h.prevSub = r), r = d.deps, ++u;
188
+ h.nextSub !== void 0 && (h.prevSub = o), o = d.deps, ++u;
193
189
  continue;
194
190
  }
195
191
  }
196
- if (!l && r.nextDep !== void 0) {
197
- r = r.nextDep;
192
+ if (!l && o.nextDep !== void 0) {
193
+ o = o.nextDep;
198
194
  continue;
199
195
  }
200
196
  if (u) {
201
- let a = r.sub;
197
+ let a = o.sub;
202
198
  do {
203
199
  --u;
204
200
  const h = a.subs;
205
201
  if (l) {
206
202
  if (t(a)) {
207
- (r = h.prevSub) !== void 0 ? (h.prevSub = void 0, f(a.subs), a = r.sub) : a = h.sub;
203
+ (o = h.prevSub) !== void 0 ? (h.prevSub = void 0, c(a.subs), a = o.sub) : a = h.sub;
208
204
  continue;
209
205
  }
210
206
  } else
211
207
  a.flags &= -65;
212
- if ((r = h.prevSub) !== void 0) {
213
- if (h.prevSub = void 0, r.nextDep !== void 0) {
214
- r = r.nextDep;
208
+ if ((o = h.prevSub) !== void 0) {
209
+ if (h.prevSub = void 0, o.nextDep !== void 0) {
210
+ o = o.nextDep;
215
211
  continue e;
216
212
  }
217
- a = r.sub;
213
+ a = o.sub;
218
214
  } else {
219
- if ((r = h.nextDep) !== void 0)
215
+ if ((o = h.nextDep) !== void 0)
220
216
  continue e;
221
217
  a = h.sub;
222
218
  }
@@ -226,18 +222,18 @@ function ve({
226
222
  return l;
227
223
  } while (!0);
228
224
  }
229
- function f(r) {
225
+ function c(o) {
230
226
  do {
231
- const u = r.sub, l = u.flags;
232
- (l & 96) === 64 && (u.flags = l | 32 | 8, (l & 10) === 2 && (n !== void 0 ? n.depsTail.nextDep = u.deps : s = u, n = u)), r = r.nextSub;
233
- } while (r !== void 0);
227
+ const u = o.sub, l = u.flags;
228
+ (l & 96) === 64 && (u.flags = l | 32 | 8, (l & 10) === 2 && (n !== void 0 ? n.depsTail.nextDep = u.deps : s = u, n = u)), o = o.nextSub;
229
+ } while (o !== void 0);
234
230
  }
235
- function p(r, u) {
231
+ function p(o, u) {
236
232
  const l = u.depsTail;
237
233
  if (l !== void 0) {
238
234
  let d = u.deps;
239
235
  do {
240
- if (d === r)
236
+ if (d === o)
241
237
  return !0;
242
238
  if (d === l)
243
239
  break;
@@ -246,61 +242,61 @@ function ve({
246
242
  }
247
243
  return !1;
248
244
  }
249
- function m(r) {
245
+ function g(o) {
250
246
  do {
251
- const u = r.dep, l = r.nextDep, d = r.nextSub, a = r.prevSub;
247
+ const u = o.dep, l = o.nextDep, d = o.nextSub, a = o.prevSub;
252
248
  if (d !== void 0 ? d.prevSub = a : u.subsTail = a, a !== void 0 ? a.nextSub = d : u.subs = d, u.subs === void 0 && "deps" in u) {
253
249
  const h = u.flags;
254
250
  h & 32 || (u.flags = h | 32);
255
- const N = u.deps;
256
- if (N !== void 0) {
257
- r = N, u.depsTail.nextDep = l, u.deps = void 0, u.depsTail = void 0;
251
+ const w = u.deps;
252
+ if (w !== void 0) {
253
+ o = w, u.depsTail.nextDep = l, u.deps = void 0, u.depsTail = void 0;
258
254
  continue;
259
255
  }
260
256
  }
261
- r = l;
262
- } while (r !== void 0);
257
+ o = l;
258
+ } while (o !== void 0);
263
259
  }
264
260
  }
265
261
  var {
266
- link: lt,
267
- propagate: at,
268
- updateDirtyFlag: Ve,
269
- startTracking: we,
270
- endTracking: be,
271
- processEffectNotifications: dt,
272
- processComputedUpdate: ht,
273
- processPendingInnerEffects: Ne
274
- } = ve({
262
+ link: Je,
263
+ propagate: Qe,
264
+ updateDirtyFlag: Ee,
265
+ startTracking: re,
266
+ endTracking: ue,
267
+ processEffectNotifications: Ye,
268
+ processComputedUpdate: et,
269
+ processPendingInnerEffects: ce
270
+ } = oe({
275
271
  updateComputed(t) {
276
- we(t);
272
+ re(t);
277
273
  try {
278
274
  const e = t.currentValue, s = t.getter(e);
279
275
  return e !== s ? (t.currentValue = s, !0) : !1;
280
276
  } finally {
281
- be(t);
277
+ ue(t);
282
278
  }
283
279
  },
284
280
  notifyEffect(t) {
285
- return "isScope" in t ? qe(t) : _e(t);
281
+ return "isScope" in t ? Te(t) : Me(t);
286
282
  }
287
283
  });
288
- function je(t) {
289
- we(t);
284
+ function Se(t) {
285
+ re(t);
290
286
  try {
291
287
  t.fn();
292
288
  } finally {
293
- be(t);
289
+ ue(t);
294
290
  }
295
291
  }
296
- function _e(t) {
292
+ function Me(t) {
297
293
  const e = t.flags;
298
- return e & 32 || e & 64 && Ve(t, e) ? je(t) : Ne(t, t.flags), !0;
294
+ return e & 32 || e & 64 && Ee(t, e) ? Se(t) : ce(t, t.flags), !0;
299
295
  }
300
- function qe(t) {
301
- return t.flags & 128 ? (Ne(t, t.flags), !0) : !1;
296
+ function Te(t) {
297
+ return t.flags & 128 ? (ce(t, t.flags), !0) : !1;
302
298
  }
303
- function D(t) {
299
+ function T(t) {
304
300
  const e = typeof t;
305
301
  switch (e) {
306
302
  case "undefined":
@@ -315,287 +311,187 @@ function D(t) {
315
311
  return e;
316
312
  }
317
313
  }
318
- function _(t) {
314
+ function k(t) {
319
315
  return Array.isArray(t);
320
316
  }
321
- function J(t, e) {
322
- return _(e) && e.every((s) => t(s));
317
+ function V(t, e) {
318
+ return k(e) && e.every((s) => t(s));
323
319
  }
324
- function pt(t, e, s) {
325
- if (J(t, e))
320
+ function tt(t, e, s) {
321
+ if (V(t, e))
326
322
  return !0;
327
- throw new TypeError(F(e, s));
323
+ throw new TypeError(I(e, s));
328
324
  }
329
- function O(t) {
325
+ function L(t) {
330
326
  return typeof t == "string";
331
327
  }
332
- function mt(t, e) {
333
- if (O(t))
328
+ function st(t, e) {
329
+ if (L(t))
334
330
  return !0;
335
- throw new TypeError(F(t, e ?? "Expected a string. Got type: %t, value: %v"));
331
+ throw new TypeError(I(t, e ?? "Expected a string. Got type: %t, value: %v"));
336
332
  }
337
- function S(t) {
338
- return D(t) === "function";
333
+ function m(t) {
334
+ return T(t) === "function";
339
335
  }
340
- function Ue(t) {
336
+ function ke(t) {
341
337
  return typeof t == "number" && !isNaN(t);
342
338
  }
343
- function gt(...t) {
344
- const e = t[0], s = O(t[2]) ? t[2] : `Expected instance of ${e.name}. Got type: %t, value: %v`, n = (i) => {
339
+ function nt(...t) {
340
+ const e = t[0], s = L(t[2]) ? t[2] : `Expected instance of ${e.name}. Got type: %t, value: %v`, n = (i) => {
345
341
  if (i instanceof e)
346
342
  return !0;
347
- throw new TypeError(F(i, s));
343
+ throw new TypeError(I(i, s));
348
344
  };
349
345
  return t.length < 2 ? n : n(t[1]);
350
346
  }
351
- function Q(t) {
352
- return t != null && typeof t == "object" && !_(t);
347
+ function R(t) {
348
+ return t != null && typeof t == "object" && !k(t);
353
349
  }
354
- function yt(t, e) {
355
- if (Q(t))
350
+ function it(t, e) {
351
+ if (R(t))
356
352
  return !0;
357
- throw new TypeError(F(t, e));
353
+ throw new TypeError(I(t, e));
358
354
  }
359
- function F(t, e) {
355
+ function I(t, e) {
360
356
  var i;
361
- const s = D(t), n = ((i = t == null ? void 0 : t.toString) == null ? void 0 : i.call(t)) || String(t);
357
+ const s = T(t), n = ((i = t == null ? void 0 : t.toString) == null ? void 0 : i.call(t)) || String(t);
362
358
  return e.replaceAll("%t", s).replaceAll("%v", n);
363
359
  }
364
- let k, P = [];
365
360
  const {
366
- link: Y,
367
- propagate: Re,
368
- updateDirtyFlag: ze,
369
- startTracking: ee,
370
- endTracking: te,
371
- processEffectNotifications: Be,
372
- processComputedUpdate: Fe,
373
- processPendingInnerEffects: Ge
374
- } = ve({
361
+ link: B,
362
+ propagate: Le,
363
+ updateDirtyFlag: Ce,
364
+ startTracking: G,
365
+ endTracking: z,
366
+ processEffectNotifications: Ae,
367
+ processComputedUpdate: De,
368
+ processPendingInnerEffects: Oe
369
+ } = oe({
375
370
  updateComputed(t) {
376
- const e = g;
377
- g = t, P.length = 0, ee(t);
371
+ const e = v;
372
+ v = t, G(t);
378
373
  try {
379
- const s = t.currentValue, n = t.getter(s);
380
- return t.equals(s, n) ? !1 : (t.currentValue = n, !0);
374
+ const s = t.current, n = t.getter(s);
375
+ return t.equals(s, n) ? !1 : (t.current = n, !0);
381
376
  } finally {
382
- g = e, k !== void 0 && (k(P), k = void 0), te(t);
377
+ v = e, z(t);
383
378
  }
384
379
  },
385
380
  notifyEffect(t) {
386
381
  const e = t.flags;
387
- return e & M.Dirty || e & M.PendingComputed && ze(t, e) ? xe(t) : Ge(t, t.flags), !0;
382
+ return e & E.Dirty || e & E.PendingComputed && Ce(t, e) ? fe(t) : Oe(t, t.flags), !0;
388
383
  }
389
384
  });
390
- let g;
391
- const L = [];
392
- let Z = !1;
393
- function We() {
394
- Z || (Z = !0, queueMicrotask(() => {
395
- Z = !1;
396
- for (let t = 0; t < L.length; t++) {
397
- const e = L[t], s = g;
398
- g = e, P.length = 0, ee(e);
385
+ let v;
386
+ const S = [];
387
+ let q = !1;
388
+ function Pe() {
389
+ q || (q = !0, queueMicrotask(() => {
390
+ q = !1;
391
+ for (let t = 0; t < S.length; t++) {
392
+ const e = S[t], s = v;
393
+ v = e, G(e);
399
394
  try {
400
- e.fn();
395
+ e.cleanup && (ae(), e.cleanup(), de()), e.cleanup = e.fn() ?? void 0;
401
396
  } finally {
402
- g = s, te(e), k !== void 0 && (k(P), k = void 0);
397
+ v = s, z(e);
403
398
  }
404
399
  }
405
- L.length = 0;
400
+ S.length = 0;
406
401
  }));
407
402
  }
408
- function xe(t) {
409
- L.push(t), We();
403
+ function fe(t) {
404
+ S.push(t), Pe();
410
405
  }
411
- function Ze() {
412
- ee(this), te(this), queueMicrotask(() => {
413
- L.splice(L.indexOf(this), 1);
406
+ function $e() {
407
+ G(this), z(this), queueMicrotask(() => {
408
+ S.splice(S.indexOf(this), 1), this.cleanup && this.cleanup();
414
409
  });
415
410
  }
416
- const Ee = [];
417
- function He() {
418
- Ee.push(g), g = void 0;
411
+ const le = [];
412
+ function ae() {
413
+ le.push(v), v = void 0;
419
414
  }
420
- function Ke() {
421
- g = Ee.pop();
415
+ function de() {
416
+ v = le.pop();
422
417
  }
423
- var b, V;
424
- class Me {
425
- constructor(e, s) {
426
- T(this, b);
427
- T(this, V);
428
- c(this, "name");
429
- $(this, b, {
430
- currentValue: e,
431
- subs: void 0,
432
- subsTail: void 0
433
- }), $(this, V, (s == null ? void 0 : s.equals) ?? Object.is), s != null && s.name && (this.name = s.name);
434
- }
435
- /**
436
- * Returns the latest value. The signal is tracked as a dependency if called within `effect` or `compose`.
437
- */
438
- get() {
439
- return g !== void 0 && (Y(w(this, b), g), P.push(this)), w(this, b).currentValue;
440
- }
441
- /**
442
- * Returns the latest value. The signal is NOT tracked if called within `effect` or `compose`.
443
- */
444
- peek() {
445
- return w(this, b).currentValue;
446
- }
447
- /**
448
- * Replaces the current value with `next`.
449
- *
450
- * @example
451
- * const count = atom(0);
452
- * count.set(2);
453
- * count.set(count.get() + 1);
454
- */
455
- set(e) {
456
- if (!w(this, V).call(this, w(this, b).currentValue, e)) {
457
- w(this, b).currentValue = e;
458
- const s = w(this, b).subs;
459
- s !== void 0 && (Re(s), Be());
460
- }
461
- }
462
- /**
463
- * Passes the current value to `fn` and sets the return value as the next value.
464
- *
465
- * @example
466
- * const count = atom(0);
467
- * count.update((current) => current + 1);
468
- * count.update((current) => current * 5);
469
- *
470
- * // Also works very well with Immer `produce` for complex objects.
471
- * const items = atom([{ name: "Alice", age: 26 }, { name: "Bob", age: 33 }]);
472
- *
473
- * // Without Immer:
474
- * items.update((current) => {
475
- * // Return a new array with Bob's age increased by 1.
476
- * const newItems = [...current];
477
- * newItems[1] = {
478
- * ...newItems[1],
479
- * age: newItems[1].age + 1
480
- * };
481
- * return newItems;
482
- * });
483
- *
484
- * // With Immer:
485
- * import { produce } from "immer";
486
- *
487
- * items.update(produce((draft) => {
488
- * // Mutate draft to increase Bob's age by 1.
489
- * // Results in a new object with this patch applied.
490
- * draft[1].age++;
491
- * }));
492
- */
493
- update(e) {
494
- this.set(e(this.peek()));
495
- }
496
- /**
497
- * @deprecated use `get()`
498
- */
499
- get value() {
500
- return this.peek();
501
- }
502
- /**
503
- * @deprecated use `set()`
504
- */
505
- set value(e) {
506
- this.set(e);
507
- }
418
+ const Z = Symbol("SIGNAL"), he = Symbol("SOURCE");
419
+ function _(t) {
420
+ let e;
421
+ return ae(), e = b(t), de(), e;
508
422
  }
509
- b = new WeakMap(), V = new WeakMap();
510
- var A, j, B, ke;
511
- class Se {
512
- constructor(e, s) {
513
- T(this, B);
514
- T(this, A);
515
- T(this, j);
516
- c(this, "name");
517
- $(this, j, e), $(this, A, {
518
- currentValue: void 0,
519
- equals: (s == null ? void 0 : s.equals) ?? Object.is,
520
- subs: void 0,
521
- subsTail: void 0,
522
- deps: void 0,
523
- depsTail: void 0,
524
- flags: M.Computed | M.Dirty,
525
- getter: ue(this, B, ke).bind(this)
526
- }), s != null && s.name && (this.name = s.name);
527
- }
528
- get() {
529
- return g !== void 0 && (Y(w(this, A), g), P.push(this)), this.peek();
530
- }
531
- peek() {
532
- const e = w(this, A), s = e.flags;
533
- return s & (M.Dirty | M.PendingComputed) && Fe(e, s), e.currentValue;
534
- }
535
- /**
536
- * @deprecated use `get()`
537
- */
538
- get value() {
539
- return this.peek();
540
- }
423
+ function b(t) {
424
+ return m(t) ? t() : t;
541
425
  }
542
- A = new WeakMap(), j = new WeakMap(), B = new WeakSet(), ke = function(e) {
543
- let s = w(this, j).call(this, e);
544
- return y(s) && (s = s.get()), s;
545
- };
546
426
  function y(t) {
547
- return t instanceof Me || t instanceof Se;
548
- }
549
- function X(t, e) {
550
- return new Me(t, e);
551
- }
552
- function se(t, e) {
553
- return new Se(t, e);
554
- }
555
- function Xe(t, e) {
556
- if (S(e))
557
- t.update(e);
558
- else if (arguments.length > 1)
559
- t.set(e);
560
- else
561
- return (s) => Xe(t, s);
562
- }
563
- function I(t) {
564
- return y(t) ? t.get() : t;
565
- }
566
- function vt(t) {
567
- return y(t) ? t.peek() : t;
568
- }
569
- function G(t) {
570
- He(), t(), Ke();
571
- }
572
- function wt(t) {
573
- k = t;
574
- }
575
- function v(t) {
576
427
  const e = {
577
428
  fn: t,
578
429
  subs: void 0,
579
430
  subsTail: void 0,
580
431
  deps: void 0,
581
432
  depsTail: void 0,
582
- flags: M.Effect
433
+ flags: E.Effect
583
434
  };
584
- return g !== void 0 && Y(e, g), xe(e), Ze.bind(e);
435
+ return v !== void 0 && B(e, v), fe(e), $e.bind(e);
436
+ }
437
+ function D(t, e) {
438
+ return m(t) ? Ie(t, e) : H(t === void 0 ? void 0 : t, e);
585
439
  }
586
- const bt = () => {
440
+ function H(t, e) {
441
+ const s = {
442
+ current: t,
443
+ subs: void 0,
444
+ subsTail: void 0
445
+ }, n = (e == null ? void 0 : e.equals) ?? Object.is, i = function() {
446
+ if (arguments.length > 0) {
447
+ let r = arguments[0];
448
+ if (typeof r == "function" && (r = r(s.current)), !n(s.current, r)) {
449
+ s.current = r;
450
+ const c = s.subs;
451
+ c !== void 0 && (Le(c), Ae());
452
+ }
453
+ } else
454
+ return v !== void 0 && B(s, v), s.current;
455
+ };
456
+ return i._type = he, i;
457
+ }
458
+ function Ie(t, e) {
459
+ if (m(t) && t._type === Z)
460
+ return t._type === he ? () => t() : t;
461
+ const s = {
462
+ current: void 0,
463
+ equals: (e == null ? void 0 : e.equals) ?? Object.is,
464
+ subs: void 0,
465
+ subsTail: void 0,
466
+ deps: void 0,
467
+ depsTail: void 0,
468
+ flags: E.Computed | E.Dirty,
469
+ getter: (i) => {
470
+ const r = t(i);
471
+ return b(r);
472
+ }
473
+ }, n = function() {
474
+ if (arguments.length > 0)
475
+ throw new Error("Signals cannot be set as their values are derived from the sources they depend on.");
476
+ v !== void 0 && B(s, v);
477
+ const i = s.flags;
478
+ return i & (E.Dirty | E.PendingComputed) && De(s, i), s.current;
479
+ };
480
+ return n._type = Z, n;
481
+ }
482
+ const ot = () => {
587
483
  };
588
- let H = 1;
589
- function Te() {
590
- return H = H % Number.MAX_SAFE_INTEGER + 1, H.toString(36) + Date.now().toString(36);
484
+ let U = 1;
485
+ function pe() {
486
+ return U = U % Number.MAX_SAFE_INTEGER + 1, U.toString(36) + Date.now().toString(36);
591
487
  }
592
- function Nt(t, e) {
488
+ function rt(t, e) {
593
489
  return Object.is(t, e);
594
490
  }
595
- function xt(t, e) {
491
+ function ut(t, e) {
596
492
  if (Object.is(t, e)) return !0;
597
- const s = D(t);
598
- if (s !== D(e))
493
+ const s = T(t);
494
+ if (s !== T(e))
599
495
  return !1;
600
496
  switch (s) {
601
497
  case "object":
@@ -616,7 +512,7 @@ function xt(t, e) {
616
512
  if (t[i] !== e[i]) return !1;
617
513
  return !0;
618
514
  case "set":
619
- if (S(t.symmetricDifference))
515
+ if (m(t.symmetricDifference))
620
516
  return t.symmetricDifference(e).size === 0;
621
517
  for (const i of t.keys())
622
518
  if (t[i] !== e.get(i)) return !1;
@@ -624,20 +520,20 @@ function xt(t, e) {
624
520
  }
625
521
  return !1;
626
522
  }
627
- function K(t, e) {
523
+ function C(t, e) {
628
524
  if (t === e) return !0;
629
525
  if (t && e && typeof t == "object" && typeof e == "object") {
630
526
  if (t.constructor !== e.constructor) return !1;
631
527
  var s, n, i;
632
528
  if (Array.isArray(t)) {
633
529
  if (s = t.length, s != e.length) return !1;
634
- for (n = s; n-- !== 0; ) if (!K(t[n], e[n])) return !1;
530
+ for (n = s; n-- !== 0; ) if (!C(t[n], e[n])) return !1;
635
531
  return !0;
636
532
  }
637
533
  if (t instanceof Map && e instanceof Map) {
638
534
  if (t.size !== e.size) return !1;
639
535
  for (n of t.entries()) if (!e.has(n[0])) return !1;
640
- for (n of t.entries()) if (!K(n[1], e.get(n[0]))) return !1;
536
+ for (n of t.entries()) if (!C(n[1], e.get(n[0]))) return !1;
641
537
  return !0;
642
538
  }
643
539
  if (t instanceof Set && e instanceof Set) {
@@ -656,26 +552,26 @@ function K(t, e) {
656
552
  if (i = Object.keys(t), s = i.length, s !== Object.keys(e).length) return !1;
657
553
  for (n = s; n-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(e, i[n])) return !1;
658
554
  for (n = s; n-- !== 0; ) {
659
- var o = i[n];
660
- if (!K(t[o], e[o])) return !1;
555
+ var r = i[n];
556
+ if (!C(t[r], e[r])) return !1;
661
557
  }
662
558
  return !0;
663
559
  }
664
560
  return t !== t && e !== e;
665
561
  }
666
- function Je(t, e) {
562
+ function _e(t, e) {
667
563
  const s = {};
668
564
  for (const n in e)
669
565
  t.includes(n) || (s[n] = e[n]);
670
566
  return s;
671
567
  }
672
- function Et(t) {
568
+ function ct(t) {
673
569
  let e = 0;
674
570
  for (let s = 0; s < t.length; s++)
675
571
  e = (e + t.charCodeAt(s) * 10) % 360;
676
572
  return `oklch(0.68 0.15 ${e}deg)`;
677
573
  }
678
- function Mt(t) {
574
+ function ft(t) {
679
575
  if (t instanceof RegExp)
680
576
  return (n) => t.test(n);
681
577
  const e = {
@@ -686,24 +582,24 @@ function Mt(t) {
686
582
  let i = "positive";
687
583
  n.startsWith("-") && (i = "negative", n = n.slice(1)), n === "*" ? e[i].push(function() {
688
584
  return !0;
689
- }) : n.endsWith("*") ? e[i].push(function(o) {
690
- return o.startsWith(n.slice(0, n.length - 1));
691
- }) : e[i].push(function(o) {
692
- return o === n;
585
+ }) : n.endsWith("*") ? e[i].push(function(r) {
586
+ return r.startsWith(n.slice(0, n.length - 1));
587
+ }) : e[i].push(function(r) {
588
+ return r === n;
693
589
  });
694
590
  }
695
591
  return function(n) {
696
- const { positive: i, negative: o } = e;
697
- return !(o.some((f) => f(n)) || i.length > 0 && !i.some((f) => f(n)));
592
+ const { positive: i, negative: r } = e;
593
+ return !(r.some((c) => c(n)) || i.length > 0 && !i.some((c) => c(n)));
698
594
  };
699
595
  }
700
- const E = Symbol.for("DollaMarkupElement"), St = Symbol.for("DollaRouter");
701
- var le;
702
- le = E;
703
- class ce {
596
+ const x = Symbol.for("DollaMarkupElement"), lt = Symbol.for("DollaRouter");
597
+ var J;
598
+ J = x;
599
+ class K {
704
600
  constructor(e) {
705
- c(this, le, !0);
706
- c(this, "domNode");
601
+ f(this, J, !0);
602
+ f(this, "domNode");
707
603
  this.domNode = e;
708
604
  }
709
605
  get isMounted() {
@@ -716,30 +612,30 @@ class ce {
716
612
  this.domNode.parentNode && !e && this.domNode.parentNode.removeChild(this.domNode);
717
613
  }
718
614
  }
719
- var ae;
720
- ae = E;
721
- class Qe {
615
+ var Q;
616
+ Q = x;
617
+ class je {
722
618
  constructor(e) {
723
- c(this, ae, !0);
724
- c(this, "domNode", document.createTextNode(""));
725
- c(this, "children", []);
726
- c(this, "elementContext");
727
- c(this, "source");
728
- c(this, "unsubscribe");
619
+ f(this, Q, !0);
620
+ f(this, "domNode", document.createTextNode(""));
621
+ f(this, "children", []);
622
+ f(this, "elementContext");
623
+ f(this, "source");
624
+ f(this, "unsubscribe");
729
625
  this.source = e.source, this.elementContext = e.elementContext;
730
626
  }
731
627
  get isMounted() {
732
628
  return this.domNode.parentNode != null;
733
629
  }
734
630
  mount(e, s) {
735
- this.isMounted || (e.insertBefore(this.domNode, (s == null ? void 0 : s.nextSibling) ?? null), this.unsubscribe = v(() => {
736
- const n = this.source.get();
737
- if (!Oe(n))
631
+ this.isMounted || (e.insertBefore(this.domNode, (s == null ? void 0 : s.nextSibling) ?? null), this.unsubscribe = y(() => {
632
+ const n = this.source();
633
+ if (console.log("$dynamic effect", n, this.source), !we(n))
738
634
  throw console.error(n), new TypeError(
739
- `Dynamic received invalid value to render. Got type: ${D(n)}, value: ${n}`
635
+ `Dynamic received invalid value to render. Got type: ${T(n)}, value: ${n}`
740
636
  );
741
- G(() => {
742
- this.update(_(n) ? n : [n]);
637
+ _(() => {
638
+ this.update(k(n) ? n : [n]);
743
639
  });
744
640
  }));
745
641
  }
@@ -753,46 +649,86 @@ class Qe {
753
649
  this.children = [];
754
650
  }
755
651
  update(e) {
756
- var o, f, p;
652
+ var r, c, p;
757
653
  if (this.cleanup(!1), e == null || e.length === 0 || !this.isMounted)
758
654
  return;
759
- const s = e.flatMap((m) => De(m) ? m : C(this.elementContext, ne(m)));
760
- for (const m of s) {
761
- const r = ((o = this.children.at(-1)) == null ? void 0 : o.domNode) || this.domNode;
762
- m.mount(this.domNode.parentNode, r), this.children.push(m);
655
+ const s = e.flatMap((g) => ye(g) ? g : M(this.elementContext, j(g)));
656
+ console.log("$dynamic update", s, e);
657
+ for (const g of s) {
658
+ const o = ((r = this.children.at(-1)) == null ? void 0 : r.domNode) || this.domNode;
659
+ g.mount(this.domNode.parentNode, o), this.children.push(g);
763
660
  }
764
- const n = this.domNode.parentNode, i = ((p = (f = this.children.at(-1)) == null ? void 0 : f.domNode) == null ? void 0 : p.nextSibling) ?? null;
765
- n.insertBefore(this.domNode, i);
661
+ const n = this.domNode.parentNode, i = ((p = (c = this.children.at(-1)) == null ? void 0 : c.domNode) == null ? void 0 : p.nextSibling) ?? null;
662
+ "moveBefore" in n ? n.moveBefore(this.domNode, i) : n.insertBefore(this.domNode, i);
766
663
  }
767
664
  }
768
- const Ye = (t) => /^on[A-Z]/.test(t);
769
- var de;
770
- de = E;
771
- class et {
665
+ var Y;
666
+ Y = x;
667
+ class me {
668
+ constructor(e) {
669
+ f(this, Y, !0);
670
+ f(this, "domNode", document.createTextNode(""));
671
+ f(this, "isMounted", !1);
672
+ f(this, "source");
673
+ f(this, "elements", []);
674
+ f(this, "unsubscribe");
675
+ this.source = e;
676
+ }
677
+ mount(e, s) {
678
+ this.isMounted || (this.isMounted = !0, e.insertBefore(this.domNode, (s == null ? void 0 : s.nextSibling) ?? null), m(this.source) ? this.unsubscribe = y(() => {
679
+ const n = b(this.source);
680
+ _(() => {
681
+ this.update(n);
682
+ });
683
+ }) : this.update(this.elements));
684
+ }
685
+ unmount(e = !1) {
686
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.isMounted && (this.cleanup(e), this.isMounted = !1);
687
+ }
688
+ cleanup(e) {
689
+ for (const s of this.elements)
690
+ s.unmount(e);
691
+ this.elements = [];
692
+ }
693
+ update(e) {
694
+ var s, n;
695
+ if (this.cleanup(!1), e.length > 0) {
696
+ for (let i = 0; i < e.length; i++) {
697
+ const r = e[i], c = i > 0 ? this.elements[i - 1] : void 0;
698
+ r.mount(this.domNode.parentElement, c == null ? void 0 : c.domNode), this.elements.push(r);
699
+ }
700
+ (n = this.domNode.parentNode) == null || n.insertBefore(this.domNode, ((s = this.elements.at(-1)) == null ? void 0 : s.domNode) ?? null);
701
+ }
702
+ }
703
+ }
704
+ const qe = (t) => /^on[A-Z]/.test(t);
705
+ var ee;
706
+ ee = x;
707
+ class Ue {
772
708
  constructor({ tag: e, props: s, children: n, elementContext: i }) {
773
- c(this, de, !0);
774
- c(this, "domNode");
775
- c(this, "props");
776
- c(this, "childMarkup", []);
777
- c(this, "children", []);
778
- c(this, "unsubscribers", []);
779
- c(this, "elementContext");
709
+ f(this, ee, !0);
710
+ f(this, "domNode");
711
+ f(this, "props");
712
+ f(this, "childMarkup", []);
713
+ f(this, "children", []);
714
+ f(this, "unsubscribers", []);
715
+ f(this, "elementContext");
780
716
  // Track the ref so we can nullify it on unmount.
781
- c(this, "ref");
717
+ f(this, "ref");
782
718
  // Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
783
- c(this, "canClickAway", !1);
719
+ f(this, "canClickAway", !1);
784
720
  if (e.toLowerCase() === "svg" && (i = {
785
721
  ...i,
786
722
  isSVG: !0
787
723
  }), i.isSVG ? this.domNode = document.createElementNS("http://www.w3.org/2000/svg", e) : this.domNode = document.createElement(e), i.root.getEnv() === "development" && i.viewName && (this.domNode.dataset.view = i.viewName), s.ref)
788
- if (S(s.ref))
724
+ if (m(s.ref))
789
725
  this.ref = s.ref, this.ref(this.domNode);
790
726
  else
791
727
  throw new Error("Expected ref to be a function. Got: " + s.ref);
792
728
  this.props = {
793
- ...Je(["ref", "class", "className"], s),
729
+ ..._e(["ref", "class", "className"], s),
794
730
  class: s.className ?? s.class
795
- }, n && (this.childMarkup = ne(n)), this.elementContext = i;
731
+ }, n && (this.childMarkup = j(n)), console.log(this.domNode, { children: n, childMarkup: this.childMarkup }), this.elementContext = i;
796
732
  }
797
733
  get isMounted() {
798
734
  return this.domNode.parentNode != null;
@@ -801,10 +737,10 @@ class et {
801
737
  if (e == null)
802
738
  throw new Error(`HTML element requires a parent element as the first argument to connect. Got: ${e}`);
803
739
  if (!this.isMounted) {
804
- this.childMarkup.length > 0 && (this.children = C(this.elementContext, this.childMarkup));
740
+ this.childMarkup.length > 0 && (this.children = M(this.elementContext, this.childMarkup));
805
741
  for (let n = 0; n < this.children.length; n++) {
806
- const i = this.children[n], o = n > 0 ? this.children[n - 1].domNode : void 0;
807
- i.mount(this.domNode, o);
742
+ const i = this.children[n], r = n > 0 ? this.children[n - 1].domNode : void 0;
743
+ i.mount(this.domNode, r);
808
744
  }
809
745
  this.applyProps(this.domNode, this.props), this.props.style && this.applyStyles(this.domNode, this.props.style, this.unsubscribers), this.props.class && this.applyClasses(this.domNode, this.props.class, this.unsubscribers);
810
746
  }
@@ -825,9 +761,9 @@ class et {
825
761
  }
826
762
  }
827
763
  attachProp(e, s) {
828
- y(e) ? this.unsubscribers.push(
829
- v(() => {
830
- s(e.get());
764
+ m(e) ? this.unsubscribers.push(
765
+ y(() => {
766
+ s(e());
831
767
  })
832
768
  ) : s(e);
833
769
  }
@@ -835,74 +771,81 @@ class et {
835
771
  for (const n in s) {
836
772
  const i = s[n];
837
773
  if (n === "on:clickoutside" || n === "onClickOutside" || n === "onclickoutside") {
838
- const o = (p) => {
839
- this.canClickAway && !e.contains(p.target) && (y(i) ? i.peek()(p) : i(p));
840
- }, f = { capture: !0 };
841
- window.addEventListener("click", o, f), this.unsubscribers.push(() => {
842
- window.removeEventListener("click", o, f);
774
+ const r = (p) => {
775
+ this.canClickAway && !e.contains(p.target) && i(p);
776
+ }, c = { capture: !0 };
777
+ window.addEventListener("click", r, c), this.unsubscribers.push(() => {
778
+ window.removeEventListener("click", r, c);
843
779
  });
844
- } else if (Ye(n)) {
845
- const o = n.slice(2).toLowerCase(), f = y(i) ? (p) => i.peek()(p) : i;
846
- e.addEventListener(o, f), this.unsubscribers.push(() => {
847
- e.removeEventListener(o, f);
780
+ } else if (m(i) && qe(n)) {
781
+ const r = n.slice(2).toLowerCase(), c = i;
782
+ e.addEventListener(r, c), this.unsubscribers.push(() => {
783
+ e.removeEventListener(r, c);
784
+ });
785
+ } else if (m(i) && Re.includes(n)) {
786
+ const r = n.substring(2);
787
+ e.addEventListener(r, i), this.unsubscribers.push(() => {
788
+ e.removeEventListener(r, i);
848
789
  });
849
790
  } else if (n.includes("-"))
850
- this.attachProp(i, (o) => {
851
- o == null ? e.removeAttribute(n) : e.setAttribute(n, String(o));
791
+ this.attachProp(i, (r) => {
792
+ r == null ? e.removeAttribute(n) : e.setAttribute(n, String(r));
852
793
  });
853
- else if (!tt.includes(n))
794
+ else if (!Ve.includes(n))
854
795
  if (this.elementContext.isSVG)
855
- this.attachProp(i, (o) => {
856
- o != null ? e.setAttribute(n, String(s[n])) : e.removeAttribute(n);
796
+ this.attachProp(i, (r) => {
797
+ r != null ? e.setAttribute(n, String(s[n])) : e.removeAttribute(n);
857
798
  });
858
799
  else
859
800
  switch (n) {
860
801
  case "contentEditable":
861
802
  case "value":
862
- this.attachProp(i, (o) => {
863
- e[n] = String(o);
803
+ this.attachProp(i, (r) => {
804
+ e[n] = String(r);
864
805
  });
865
806
  break;
866
807
  case "for":
867
- this.attachProp(i, (o) => {
868
- e.htmlFor = o;
808
+ this.attachProp(i, (r) => {
809
+ e.htmlFor = r;
869
810
  });
870
811
  break;
871
812
  case "title":
872
- this.attachProp(i, (o) => {
873
- o == null ? e.removeAttribute(n) : e.setAttribute(n, String(o));
813
+ this.attachProp(i, (r) => {
814
+ r == null ? e.removeAttribute(n) : e.setAttribute(n, String(r));
874
815
  });
875
816
  case "checked":
876
- this.attachProp(i, (o) => {
877
- e.checked = o, o ? e.setAttribute("checked", "") : e.removeAttribute("checked");
817
+ this.attachProp(i, (r) => {
818
+ e.checked = r, r ? e.setAttribute("checked", "") : e.removeAttribute("checked");
878
819
  });
879
820
  break;
880
821
  case "autocomplete":
881
822
  case "autocapitalize":
882
- this.attachProp(i, (o) => {
883
- typeof o == "string" ? e[n] = o : o ? e[n] = "on" : e[n] = "off";
823
+ this.attachProp(i, (r) => {
824
+ typeof r == "string" ? e[n] = r : r ? e[n] = "on" : e[n] = "off";
884
825
  });
885
826
  break;
886
827
  default: {
887
828
  if (n.startsWith("prop:")) {
888
- const o = n.substring(5);
889
- this.attachProp(i, (f) => {
890
- e[o] = f;
829
+ const r = n.substring(5);
830
+ this.attachProp(i, (c) => {
831
+ e[r] = c;
891
832
  });
892
833
  } else if (n.startsWith("on:")) {
893
- const o = n.substring(3);
894
- let f;
895
- this.attachProp(i, (p) => {
896
- !p && f ? e.removeEventListener(o, f) : p != null && (f && f !== p && e.removeEventListener(o, f), e.addEventListener(o, p)), f = p;
834
+ const r = n.substring(3);
835
+ let c;
836
+ m(i) ? (e.addEventListener(r, i), this.unsubscribers.push(() => {
837
+ e.removeEventListener(r, i);
838
+ })) : this.attachProp(i, (p) => {
839
+ !p && c ? e.removeEventListener(r, c) : p != null && (c && c !== p && e.removeEventListener(r, c), e.addEventListener(r, p)), c = p;
897
840
  });
898
841
  } else if (n.startsWith("attr:")) {
899
- const o = n.substring(5).toLowerCase();
900
- this.attachProp(i, (f) => {
901
- f != null ? e.setAttribute(o, String(f)) : e.removeAttribute(o);
842
+ const r = n.substring(5).toLowerCase();
843
+ this.attachProp(i, (c) => {
844
+ c != null ? e.setAttribute(r, String(c)) : e.removeAttribute(r);
902
845
  });
903
846
  } else
904
- this.attachProp(i, (o) => {
905
- e[n] = o;
847
+ this.attachProp(i, (r) => {
848
+ e[n] = r;
906
849
  });
907
850
  break;
908
851
  }
@@ -911,92 +854,143 @@ class et {
911
854
  }
912
855
  applyStyles(e, s, n) {
913
856
  const i = [];
914
- if (y(s)) {
915
- let o;
916
- const f = v(() => {
917
- S(o) && o(), e.style.cssText = "", o = this.applyStyles(e, I(s), n);
857
+ if (m(s)) {
858
+ let r;
859
+ const c = y(() => {
860
+ m(r) && r(), e.style.cssText = "", r = this.applyStyles(e, b(s), n);
918
861
  });
919
- n.push(f), i.push(f);
862
+ n.push(c), i.push(c);
920
863
  } else {
921
- const o = Ce(s);
922
- for (const f in o) {
923
- const { value: p, priority: m } = o[f];
924
- if (y(p)) {
925
- const r = v(() => {
926
- p.get() ? e.style.setProperty(f, String(p.get()), m) : e.style.removeProperty(f);
864
+ const r = ve(s);
865
+ for (const c in r) {
866
+ const { value: p, priority: g } = r[c];
867
+ if (m(p)) {
868
+ const o = y(() => {
869
+ b(p) ? e.style.setProperty(c, String(b(p)), g) : e.style.removeProperty(c);
927
870
  });
928
- n.push(r), i.push(r);
929
- } else p != null && e.style.setProperty(f, String(p));
871
+ n.push(o), i.push(o);
872
+ } else p != null && e.style.setProperty(c, String(p));
930
873
  }
931
874
  }
932
875
  return function() {
933
- for (const f of i)
934
- f(), n.splice(n.indexOf(f), 1);
876
+ for (const c of i)
877
+ c(), n.splice(n.indexOf(c), 1);
935
878
  };
936
879
  }
937
880
  applyClasses(e, s, n) {
938
881
  const i = [];
939
- if (y(s)) {
940
- let o;
941
- const f = v(() => {
942
- S(o) && o(), e.removeAttribute("class"), o = this.applyClasses(e, I(s), n);
882
+ if (m(s)) {
883
+ let r;
884
+ const c = y(() => {
885
+ m(r) && r(), e.removeAttribute("class"), r = this.applyClasses(e, b(s), n);
943
886
  });
944
- n.push(f), i.push(f);
887
+ n.push(c), i.push(c);
945
888
  } else {
946
- const o = Le(s);
947
- for (const f in o) {
948
- const p = o[f];
949
- if (y(p)) {
950
- const m = v(() => {
951
- I(p) ? e.classList.add(f) : e.classList.remove(f);
889
+ const r = ge(s);
890
+ for (const c in r) {
891
+ const p = r[c];
892
+ if (m(p)) {
893
+ const g = y(() => {
894
+ b(p) ? e.classList.add(c) : e.classList.remove(c);
952
895
  });
953
- n.push(m), i.push(m);
954
- } else p && e.classList.add(f);
896
+ n.push(g), i.push(g);
897
+ } else p && e.classList.add(c);
955
898
  }
956
899
  }
957
900
  return function() {
958
- for (const f of i)
959
- f(), n.splice(n.indexOf(f), 1);
901
+ for (const c of i)
902
+ c(), n.splice(n.indexOf(c), 1);
960
903
  };
961
904
  }
962
905
  }
963
- function Le(t) {
906
+ function ge(t) {
964
907
  let e = {};
965
- if (O(t)) {
908
+ if (L(t)) {
966
909
  const s = t.split(" ");
967
910
  for (const n of s)
968
911
  e[n] = !0;
969
- } else Q(t) ? Object.assign(e, t) : Array.isArray(t) && Array.from(t).filter(Boolean).forEach((s) => {
970
- Object.assign(e, Le(s));
912
+ } else R(t) ? Object.assign(e, t) : Array.isArray(t) && Array.from(t).filter(Boolean).forEach((s) => {
913
+ Object.assign(e, ge(s));
971
914
  });
972
915
  return delete e.undefined, e;
973
916
  }
974
- function Ce(t) {
917
+ function ve(t) {
975
918
  let e = {};
976
- if (O(t)) {
919
+ if (L(t)) {
977
920
  const s = t.split(";").filter((n) => n.trim() !== "");
978
921
  for (const n of s) {
979
- const [i, o] = n.split(":"), f = {
980
- value: o
922
+ const [i, r] = n.split(":"), c = {
923
+ value: r
981
924
  };
982
- o.includes("!important") ? (f.priority = "important", f.value = o.replace("!important", "").trim()) : f.value = o.trim(), e[fe(i.trim())] = f;
925
+ r.includes("!important") ? (c.priority = "important", c.value = r.replace("!important", "").trim()) : c.value = r.trim(), e[X(i.trim())] = c;
983
926
  }
984
927
  }
985
- if (Q(t))
928
+ if (R(t))
986
929
  for (const s in t)
987
- s.startsWith("--") ? e[s] = { value: t[s] } : e[fe(s)] = { value: t[s] };
930
+ s.startsWith("--") ? e[s] = { value: t[s] } : e[X(s)] = { value: t[s] };
988
931
  else Array.isArray(t) && Array.from(t).filter((s) => s != null).forEach((s) => {
989
- Object.assign(e, Ce(s));
932
+ Object.assign(e, ve(s));
990
933
  });
991
934
  return e;
992
935
  }
993
- function fe(t) {
936
+ function X(t) {
994
937
  return t.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (e, s) => (s ? "-" : "") + e.toLowerCase());
995
938
  }
996
- const tt = ["ref", "children", "class", "style", "data"];
997
- let st = class {
939
+ const Ve = ["ref", "children", "class", "style", "data"], Re = ["onsubmit", "onclick", "ontransitionend"];
940
+ var te;
941
+ te = x;
942
+ class Be {
998
943
  constructor(e) {
999
- c(this, "store");
944
+ f(this, te, !0);
945
+ f(this, "domNode", document.createTextNode(""));
946
+ f(this, "isMounted", !1);
947
+ f(this, "view");
948
+ f(this, "mountedView");
949
+ f(this, "unsubscribe");
950
+ this.view = e;
951
+ }
952
+ mount(e, s) {
953
+ this.isMounted || (this.isMounted = !0, e.insertBefore(this.domNode, (s == null ? void 0 : s.nextSibling) ?? null), this.unsubscribe = y(() => {
954
+ const n = this.view();
955
+ _(() => {
956
+ this.update(n);
957
+ });
958
+ }));
959
+ }
960
+ unmount(e = !1) {
961
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.isMounted && (this.cleanup(e), this.isMounted = !1);
962
+ }
963
+ cleanup(e) {
964
+ this.mountedView && this.mountedView.unmount(e), this.mountedView = void 0;
965
+ }
966
+ update(e) {
967
+ this.cleanup(!1), e && (e.mount(this.domNode.parentElement, this.domNode), this.mountedView = e);
968
+ }
969
+ }
970
+ var se;
971
+ se = x;
972
+ class Ge {
973
+ constructor(e) {
974
+ f(this, se, !0);
975
+ f(this, "config");
976
+ f(this, "element");
977
+ this.config = e;
978
+ }
979
+ get isMounted() {
980
+ return this.element ? this.element.isMounted : !1;
981
+ }
982
+ mount(e, s) {
983
+ const { content: n, parent: i } = this.config;
984
+ ye(n) ? this.element = n : this.element = A(M(this.config.elementContext, j(n))), this.element.mount(i);
985
+ }
986
+ unmount(e = !1) {
987
+ var s;
988
+ (s = this.element) != null && s.isMounted && this.element.unmount(!1);
989
+ }
990
+ }
991
+ let ze = class {
992
+ constructor(e) {
993
+ f(this, "store");
1000
994
  this.store = e;
1001
995
  const s = Object.getOwnPropertyDescriptors(this.store.logger);
1002
996
  for (const n in s)
@@ -1012,15 +1006,15 @@ let st = class {
1012
1006
  this.store.name = e, this.store.logger.setName(e);
1013
1007
  }
1014
1008
  get(e) {
1015
- if (S(e)) {
1009
+ if (m(e)) {
1016
1010
  let s = this.store.elementContext, n;
1017
1011
  for (; n = s.stores.get(e), n == null && s.parent != null; )
1018
1012
  s = s.parent;
1019
1013
  if (n == null)
1020
- throw new U(`Store '${e.name}' is not provided on this context.`);
1014
+ throw new O(`Store '${e.name}' is not provided on this context.`);
1021
1015
  return n.value;
1022
1016
  } else
1023
- throw new U("Invalid store.");
1017
+ throw new O("Invalid store.");
1024
1018
  }
1025
1019
  onMount(e) {
1026
1020
  this.store.lifecycleListeners.mount.push(e);
@@ -1031,32 +1025,32 @@ let st = class {
1031
1025
  effect(e) {
1032
1026
  const s = this.store;
1033
1027
  if (s.isMounted) {
1034
- const n = v(e);
1028
+ const n = y(e);
1035
1029
  return s.lifecycleListeners.unmount.push(n), n;
1036
1030
  } else {
1037
1031
  let n, i = !1;
1038
1032
  return s.lifecycleListeners.mount.push(() => {
1039
- i || (n = v(e), s.lifecycleListeners.unmount.push(n));
1033
+ i || (n = y(e), s.lifecycleListeners.unmount.push(n));
1040
1034
  }), () => {
1041
1035
  n != null && (i = !0, n());
1042
1036
  };
1043
1037
  }
1044
1038
  }
1045
1039
  };
1046
- class nt {
1040
+ class Fe {
1047
1041
  constructor(e, s) {
1048
- c(this, "fn");
1049
- c(this, "_options");
1042
+ f(this, "fn");
1043
+ f(this, "_options");
1050
1044
  /**
1051
1045
  * Value is guaranteed to be set after `attach` is called.
1052
1046
  */
1053
- c(this, "value");
1054
- c(this, "isMounted", !1);
1055
- c(this, "elementContext");
1056
- c(this, "lifecycleListeners", { mount: [], unmount: [] });
1057
- c(this, "logger");
1058
- c(this, "id", Te());
1059
- c(this, "name");
1047
+ f(this, "value");
1048
+ f(this, "isMounted", !1);
1049
+ f(this, "elementContext");
1050
+ f(this, "lifecycleListeners", { mount: [], unmount: [] });
1051
+ f(this, "logger");
1052
+ f(this, "id", pe());
1053
+ f(this, "name");
1060
1054
  this.fn = e, this.name = e.name, this._options = s;
1061
1055
  }
1062
1056
  /**
@@ -1067,7 +1061,7 @@ class nt {
1067
1061
  if (e.stores.has(this.fn))
1068
1062
  return !1;
1069
1063
  this.elementContext = e, this.logger = e.root.createLogger(this.name);
1070
- const s = new st(this);
1064
+ const s = new ze(this);
1071
1065
  try {
1072
1066
  this.value = this.fn.call(s, this._options, s);
1073
1067
  } catch (n) {
@@ -1088,11 +1082,11 @@ class nt {
1088
1082
  this.lifecycleListeners.unmount.length = 0;
1089
1083
  }
1090
1084
  }
1091
- class U extends Error {
1085
+ class O extends Error {
1092
1086
  }
1093
- class it {
1087
+ class We {
1094
1088
  constructor(e) {
1095
- c(this, "view");
1089
+ f(this, "view");
1096
1090
  this.view = e;
1097
1091
  const s = Object.getOwnPropertyDescriptors(this.view.logger);
1098
1092
  for (const n in s)
@@ -1111,7 +1105,7 @@ class it {
1111
1105
  this.view.elementContext.viewName = e, this.view.logger.setName(e);
1112
1106
  }
1113
1107
  provide(e, s) {
1114
- const n = new nt(e, s);
1108
+ const n = new Fe(e, s);
1115
1109
  if (n.attach(this.view.elementContext))
1116
1110
  return this.view.lifecycleListeners.mount.push(() => {
1117
1111
  n.handleMount();
@@ -1119,20 +1113,20 @@ class it {
1119
1113
  n.handleUnmount();
1120
1114
  }), n.value;
1121
1115
  {
1122
- let o = e.name ? `'${e.name}'` : "this store";
1123
- return this.view.logger.warn(`An instance of ${o} was already attached to this context.`), this.get(e);
1116
+ let r = e.name ? `'${e.name}'` : "this store";
1117
+ return this.view.logger.warn(`An instance of ${r} was already attached to this context.`), this.get(e);
1124
1118
  }
1125
1119
  }
1126
1120
  get(e) {
1127
- if (S(e)) {
1121
+ if (m(e)) {
1128
1122
  let s = this.view.elementContext, n;
1129
1123
  for (; n = s.stores.get(e), n == null && s.parent != null; )
1130
1124
  s = s.parent;
1131
1125
  if (n == null)
1132
- throw new U(`Store '${e.name}' is not provided on this context.`);
1126
+ throw new O(`Store '${e.name}' is not provided on this context.`);
1133
1127
  return n.value;
1134
1128
  } else
1135
- throw new U("Invalid store.");
1129
+ throw new O("Invalid store.");
1136
1130
  }
1137
1131
  beforeMount(e) {
1138
1132
  this.view.lifecycleListeners.beforeMount.push(e);
@@ -1148,40 +1142,40 @@ class it {
1148
1142
  }
1149
1143
  effect(e) {
1150
1144
  if (this.view.isMounted) {
1151
- const s = v(e);
1145
+ const s = y(e);
1152
1146
  return this.view.lifecycleListeners.unmount.push(s), s;
1153
1147
  } else {
1154
1148
  let s, n = !1;
1155
1149
  return this.view.lifecycleListeners.mount.push(() => {
1156
- n || (s = v(e), this.view.lifecycleListeners.unmount.push(s));
1150
+ n || (s = y(e), this.view.lifecycleListeners.unmount.push(s));
1157
1151
  }), () => {
1158
1152
  s != null && (n = !0, s());
1159
1153
  };
1160
1154
  }
1161
1155
  }
1162
1156
  outlet() {
1163
- return x("$outlet", { view: this.view.elementContext.route });
1157
+ return N("$outlet", { view: this.view.elementContext.route });
1164
1158
  }
1165
1159
  }
1166
- var he;
1167
- he = E;
1168
- const ie = class ie {
1160
+ var ne;
1161
+ ne = x;
1162
+ const F = class F {
1169
1163
  constructor(e, s, n, i) {
1170
- c(this, he, !0);
1171
- c(this, "uniqueId", Te());
1172
- c(this, "elementContext");
1173
- c(this, "logger");
1174
- c(this, "props");
1175
- c(this, "fn");
1176
- c(this, "element");
1177
- c(this, "lifecycleListeners", { beforeMount: [], mount: [], beforeUnmount: [], unmount: [] });
1178
- c(this, "isMounted", !1);
1164
+ f(this, ne, !0);
1165
+ f(this, "uniqueId", pe());
1166
+ f(this, "elementContext");
1167
+ f(this, "logger");
1168
+ f(this, "props");
1169
+ f(this, "fn");
1170
+ f(this, "element");
1171
+ f(this, "lifecycleListeners", { beforeMount: [], mount: [], beforeUnmount: [], unmount: [] });
1172
+ f(this, "isMounted", !1);
1179
1173
  this.elementContext = {
1180
1174
  ...e,
1181
1175
  parent: e,
1182
1176
  viewName: s.name,
1183
1177
  stores: /* @__PURE__ */ new Map(),
1184
- route: X()
1178
+ route: D()
1185
1179
  }, this.logger = e.root.createLogger(s.name || "🌇 anonymous view", { uid: this.uniqueId }), this.props = {
1186
1180
  ...n,
1187
1181
  children: i
@@ -1215,14 +1209,14 @@ const ie = class ie {
1215
1209
  this.lifecycleListeners.beforeMount.length = 0, this.lifecycleListeners.mount.length = 0, this.lifecycleListeners.beforeUnmount.length = 0, this.lifecycleListeners.unmount.length = 0;
1216
1210
  }
1217
1211
  setRouteView(e) {
1218
- const s = new ie(this.elementContext, e, {});
1219
- return this.elementContext.route.set(s), s;
1212
+ const s = new F(this.elementContext, e, {});
1213
+ return this.elementContext.route(s), s;
1220
1214
  }
1221
1215
  /*===============================*\
1222
1216
  || Internal ||
1223
1217
  \*===============================*/
1224
1218
  _initialize() {
1225
- const e = new it(this);
1219
+ const e = new We(this);
1226
1220
  let s;
1227
1221
  try {
1228
1222
  s = this.fn.call(e, this.props, e);
@@ -1230,43 +1224,43 @@ const ie = class ie {
1230
1224
  throw n instanceof Error && this.logger.crash(n), n;
1231
1225
  }
1232
1226
  if (s !== null) if (s instanceof Node)
1233
- this.element = q(C(this.elementContext, x("$node", { value: s })));
1234
- else if (y(s))
1235
- this.element = q(
1236
- C(this.elementContext, x("$dynamic", { source: s }))
1227
+ this.element = A(M(this.elementContext, N("$node", { value: s })));
1228
+ else if (m(s))
1229
+ this.element = A(
1230
+ M(this.elementContext, N("$dynamic", { source: s }))
1237
1231
  );
1238
- else if (z(s) || J(z, s))
1239
- this.element = q(C(this.elementContext, s));
1232
+ else if ($(s) || V($, s))
1233
+ this.element = A(M(this.elementContext, s));
1240
1234
  else {
1241
1235
  const n = new TypeError(
1242
- `Expected '${this.fn.name}' function to return a DOM node, Markup element, Readable or null. Got: ${D(s)}`
1236
+ `Expected '${this.fn.name}' function to return a DOM node, Markup element, Signal or null. Got: ${T(s)}`
1243
1237
  );
1244
1238
  this.logger.crash(n);
1245
1239
  }
1246
1240
  }
1247
1241
  };
1248
- let R = ie;
1249
- var pe;
1250
- pe = E;
1251
- class rt {
1242
+ let P = F;
1243
+ var ie;
1244
+ ie = x;
1245
+ class Ze {
1252
1246
  constructor({ elementContext: e, items: s, renderFn: n, keyFn: i }) {
1253
- c(this, pe, !0);
1254
- c(this, "domNode", document.createTextNode(""));
1255
- c(this, "items");
1256
- c(this, "unsubscribe", null);
1257
- c(this, "connectedItems", []);
1258
- c(this, "elementContext");
1259
- c(this, "renderFn");
1260
- c(this, "keyFn");
1247
+ f(this, ie, !0);
1248
+ f(this, "domNode", document.createTextNode(""));
1249
+ f(this, "items");
1250
+ f(this, "unsubscribe", null);
1251
+ f(this, "connectedItems", []);
1252
+ f(this, "elementContext");
1253
+ f(this, "renderFn");
1254
+ f(this, "keyFn");
1261
1255
  this.elementContext = e, this.items = s, this.renderFn = n, this.keyFn = i;
1262
1256
  }
1263
1257
  get isMounted() {
1264
1258
  return this.domNode.parentNode != null;
1265
1259
  }
1266
1260
  mount(e, s) {
1267
- this.isMounted || (e.insertBefore(this.domNode, (s == null ? void 0 : s.nextSibling) ?? null), this.unsubscribe = v(() => {
1268
- let n = this.items.get();
1269
- n == null && (n = [], console.log("list received empty value", n, this)), G(() => {
1261
+ this.isMounted || (e.insertBefore(this.domNode, (s == null ? void 0 : s.nextSibling) ?? null), this.unsubscribe = y(() => {
1262
+ let n = this.items();
1263
+ n == null && (n = [], console.log("repeat received empty value", n, this)), _(() => {
1270
1264
  this._update(Array.from(n));
1271
1265
  });
1272
1266
  }));
@@ -1281,191 +1275,126 @@ class rt {
1281
1275
  this.connectedItems = [];
1282
1276
  }
1283
1277
  _update(e) {
1284
- var f, p, m;
1278
+ var c, p, g;
1285
1279
  if (e.length === 0 || !this.isMounted)
1286
1280
  return this._cleanup(!1);
1287
1281
  const s = [];
1288
1282
  let n = 0;
1289
- for (const r of e)
1283
+ for (const o of e)
1290
1284
  s.push({
1291
- key: this.keyFn(r, n),
1292
- value: r,
1285
+ key: this.keyFn(o, n),
1286
+ value: o,
1293
1287
  index: n++
1294
1288
  });
1295
1289
  const i = [];
1296
- for (const r of this.connectedItems)
1297
- s.find((l) => l.key === r.key) || r.element.unmount(!1);
1298
- for (const r of s) {
1299
- const u = this.connectedItems.find((l) => l.key === r.key);
1290
+ for (const o of this.connectedItems)
1291
+ s.find((l) => l.key === o.key) || o.element.unmount(!1);
1292
+ for (const o of s) {
1293
+ const u = this.connectedItems.find((l) => l.key === o.key);
1300
1294
  if (u)
1301
- u.item.set(r.value), u.index.set(r.index), i[r.index] = u;
1295
+ u.item(o.value), u.index(o.index), i[o.index] = u;
1302
1296
  else {
1303
- const l = X(r.value), d = X(r.index);
1304
- i[r.index] = {
1305
- key: r.key,
1297
+ const l = D(o.value, { equals: C }), d = D(o.index);
1298
+ i[o.index] = {
1299
+ key: o.key,
1306
1300
  item: l,
1307
1301
  index: d,
1308
- element: new R(this.elementContext, ot, {
1309
- item: se(() => l.get()),
1310
- index: d,
1302
+ element: new P(this.elementContext, He, {
1303
+ item: () => l(),
1304
+ index: () => d(),
1311
1305
  renderFn: this.renderFn
1312
1306
  })
1313
1307
  };
1314
1308
  }
1315
1309
  }
1316
- for (let r = 0; r < i.length; r++) {
1317
- const u = i[r], l = ((f = i[r - 1]) == null ? void 0 : f.element.domNode) ?? this.domNode;
1310
+ for (let o = 0; o < i.length; o++) {
1311
+ const u = i[o], l = ((c = i[o - 1]) == null ? void 0 : c.element.domNode) ?? this.domNode;
1318
1312
  u.element.mount(this.domNode.parentNode, l);
1319
1313
  }
1320
1314
  this.connectedItems = i;
1321
- const o = ((p = i.at(-1)) == null ? void 0 : p.element.domNode) ?? this.domNode;
1322
- (m = this.domNode.parentNode) == null || m.insertBefore(this.domNode, o.nextSibling);
1323
- }
1324
- }
1325
- function ot(t, e) {
1326
- return e.name = "@ListItem", t.renderFn.call(e, t.item, t.index, e);
1327
- }
1328
- var me;
1329
- me = E;
1330
- class Ae {
1331
- constructor(e) {
1332
- c(this, me, !0);
1333
- c(this, "domNode", document.createTextNode(""));
1334
- c(this, "isMounted", !1);
1335
- c(this, "source");
1336
- c(this, "elements", []);
1337
- c(this, "unsubscribe");
1338
- this.source = e;
1339
- }
1340
- mount(e, s) {
1341
- this.isMounted || (this.isMounted = !0, e.insertBefore(this.domNode, (s == null ? void 0 : s.nextSibling) ?? null), y(this.source) ? this.unsubscribe = v(() => {
1342
- const n = I(this.source);
1343
- G(() => {
1344
- this.update(n);
1345
- });
1346
- }) : this.update(this.elements));
1347
- }
1348
- unmount(e = !1) {
1349
- this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.isMounted && (this.cleanup(e), this.isMounted = !1);
1350
- }
1351
- cleanup(e) {
1352
- for (const s of this.elements)
1353
- s.unmount(e);
1354
- this.elements = [];
1355
- }
1356
- update(e) {
1357
- var s, n;
1358
- if (this.cleanup(!1), e.length > 0) {
1359
- for (let i = 0; i < e.length; i++) {
1360
- const o = e[i], f = i > 0 ? this.elements[i - 1] : void 0;
1361
- o.mount(this.domNode.parentElement, f == null ? void 0 : f.domNode), this.elements.push(o);
1362
- }
1363
- (n = this.domNode.parentNode) == null || n.insertBefore(this.domNode, ((s = this.elements.at(-1)) == null ? void 0 : s.domNode) ?? null);
1364
- }
1315
+ const r = ((p = i.at(-1)) == null ? void 0 : p.element.domNode) ?? this.domNode;
1316
+ (g = this.domNode.parentNode) == null || g.insertBefore(this.domNode, r.nextSibling);
1365
1317
  }
1366
1318
  }
1367
- var ge;
1368
- ge = E;
1369
- class ut {
1370
- constructor(e) {
1371
- c(this, ge, !0);
1372
- c(this, "config");
1373
- c(this, "element");
1374
- this.config = e;
1375
- }
1376
- get isMounted() {
1377
- return this.element ? this.element.isMounted : !1;
1378
- }
1379
- mount(e, s) {
1380
- const { content: n, parent: i } = this.config;
1381
- De(n) ? this.element = n : this.element = q(C(this.config.elementContext, ne(n))), this.element.mount(i);
1382
- }
1383
- unmount(e = !1) {
1384
- var s;
1385
- (s = this.element) != null && s.isMounted && this.element.unmount(!1);
1386
- }
1319
+ function He(t, e) {
1320
+ return e.name = "@RepeatItem", t.renderFn.call(e, t.item, t.index, e);
1387
1321
  }
1388
- var ye;
1389
- ye = E;
1390
- class ct {
1391
- constructor(e) {
1392
- c(this, ye, !0);
1393
- c(this, "domNode", document.createTextNode(""));
1394
- c(this, "isMounted", !1);
1395
- c(this, "view");
1396
- c(this, "mountedView");
1397
- c(this, "unsubscribe");
1398
- this.view = e;
1399
- }
1400
- mount(e, s) {
1401
- this.isMounted || (this.isMounted = !0, e.insertBefore(this.domNode, (s == null ? void 0 : s.nextSibling) ?? null), this.unsubscribe = v(() => {
1402
- const n = this.view.get();
1403
- G(() => {
1404
- this.update(n);
1405
- });
1406
- }));
1407
- }
1408
- unmount(e = !1) {
1409
- this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.isMounted && (this.cleanup(e), this.isMounted = !1);
1410
- }
1411
- cleanup(e) {
1412
- this.mountedView && this.mountedView.unmount(e), this.mountedView = void 0;
1413
- }
1414
- update(e) {
1415
- this.cleanup(!1), e && (e.mount(this.domNode.parentElement, this.domNode), this.mountedView = e);
1416
- }
1322
+ function $(t) {
1323
+ return t instanceof be;
1417
1324
  }
1418
- function z(t) {
1419
- return t instanceof Pe;
1325
+ function ye(t) {
1326
+ return (t == null ? void 0 : t[x]) === !0;
1420
1327
  }
1421
- function De(t) {
1422
- return (t == null ? void 0 : t[E]) === !0;
1423
- }
1424
- function ne(t) {
1425
- return _(t) || (t = [t]), t.flat(1 / 0).filter((e) => e != null && e !== !1).map((e) => z(e) ? e : e instanceof Node ? x("$node", { value: e }) : y(e) ? x("$dynamic", { source: e }) : x("$text", { value: e }));
1328
+ function j(t) {
1329
+ k(t) || (t = [t]);
1330
+ const e = [];
1331
+ for (const s of t)
1332
+ if (!(s == null || s === !1)) {
1333
+ if (s instanceof Node) {
1334
+ e.push(N("$node", { value: s }));
1335
+ continue;
1336
+ }
1337
+ if ($(s)) {
1338
+ e.push(s);
1339
+ continue;
1340
+ }
1341
+ if (m(s)) {
1342
+ e.push(N("$dynamic", { source: s }));
1343
+ continue;
1344
+ }
1345
+ if (k(s)) {
1346
+ e.push(...j(s));
1347
+ continue;
1348
+ }
1349
+ e.push(N("$text", { value: s }));
1350
+ }
1351
+ return e;
1426
1352
  }
1427
- function x(t, e, ...s) {
1428
- return new Pe(t, e, ...s);
1353
+ function N(t, e, ...s) {
1354
+ return new be(t, e, ...s);
1429
1355
  }
1430
- class Pe {
1356
+ class be {
1431
1357
  constructor(e, s, ...n) {
1432
- c(this, "type");
1433
- c(this, "props");
1434
- c(this, "children");
1358
+ f(this, "type");
1359
+ f(this, "props");
1360
+ f(this, "children");
1435
1361
  this.type = e, this.props = s, this.children = n;
1436
1362
  }
1437
1363
  }
1438
- function Tt(t, e, s) {
1439
- return x("$dynamic", {
1440
- source: se(() => {
1441
- const n = I(t);
1364
+ function Ke(t, e, s) {
1365
+ return N("$dynamic", {
1366
+ source: D(() => {
1367
+ const n = b(t);
1442
1368
  return n && e ? e : !n && s ? s : null;
1443
1369
  })
1444
1370
  });
1445
1371
  }
1446
- function Lt(t, e, s) {
1447
- return x("$list", { items: se(() => t), keyFn: e, renderFn: s });
1372
+ function dt(t, e, s) {
1373
+ return Ke(t, s, e);
1448
1374
  }
1449
- function Ct(t, e) {
1450
- return x("$portal", { parent: t, content: e });
1375
+ function ht(t, e, s) {
1376
+ return N("$repeat", { items: () => b(t), keyFn: e, renderFn: s });
1451
1377
  }
1452
- function C(t, e) {
1453
- return (_(e) ? e : [e]).map((n) => {
1454
- if (S(n.type))
1455
- return new R(t, n.type, n.props, n.children);
1456
- if (O(n.type))
1378
+ function pt(t, e) {
1379
+ return N("$portal", { parent: t, content: e });
1380
+ }
1381
+ function M(t, e) {
1382
+ return (k(e) ? e : [e]).map((n) => {
1383
+ if (m(n.type))
1384
+ return new P(t, n.type, n.props, n.children);
1385
+ if (L(n.type))
1457
1386
  switch (n.type) {
1458
1387
  case "$node": {
1459
1388
  const i = n.props;
1460
- return new ce(i.value);
1389
+ return new K(i.value);
1461
1390
  }
1462
1391
  case "$text": {
1463
1392
  const i = n.props;
1464
- return new ce(document.createTextNode(String(i.value)));
1393
+ return new K(document.createTextNode(String(i.value)));
1465
1394
  }
1466
- case "$list": {
1395
+ case "$repeat": {
1467
1396
  const i = n.props;
1468
- return new rt({
1397
+ return new Ze({
1469
1398
  items: i.items,
1470
1399
  keyFn: i.keyFn,
1471
1400
  renderFn: i.renderFn,
@@ -1474,31 +1403,29 @@ function C(t, e) {
1474
1403
  }
1475
1404
  case "$dynamic": {
1476
1405
  const i = n.props;
1477
- return new Qe({
1406
+ return new je({
1478
1407
  source: i.source,
1479
1408
  elementContext: t
1480
1409
  });
1481
1410
  }
1482
1411
  case "$fragment": {
1483
1412
  const i = n.props;
1484
- return new Ae(i.children);
1413
+ return new me(i.children);
1485
1414
  }
1486
1415
  case "$outlet": {
1487
1416
  const i = n.props;
1488
- return new ct(i.view);
1417
+ return new Be(i.view);
1489
1418
  }
1490
1419
  case "$portal": {
1491
1420
  const i = n.props;
1492
- return new ut({
1421
+ return new Ge({
1493
1422
  content: i.content,
1494
1423
  parent: i.parent,
1495
1424
  elementContext: t
1496
1425
  });
1497
1426
  }
1498
1427
  default:
1499
- if (n.type.startsWith("$"))
1500
- throw new Error(`Unknown markup type: ${n.type}`);
1501
- return new et({
1428
+ return new Ue({
1502
1429
  tag: n.type,
1503
1430
  props: n.props ?? {},
1504
1431
  children: n.children,
@@ -1509,44 +1436,42 @@ function C(t, e) {
1509
1436
  throw new TypeError(`Expected a string or view function. Got: ${n.type}`);
1510
1437
  });
1511
1438
  }
1512
- function q(t) {
1513
- return t.length === 1 ? t[0] : new Ae(t);
1439
+ function A(t) {
1440
+ return t.length === 1 ? t[0] : new me(t);
1514
1441
  }
1515
- function Oe(t) {
1516
- return t == null || t === !1 || O(t) || Ue(t) || z(t) || y(t) || J(Oe, t);
1442
+ function we(t) {
1443
+ return t == null || t === !1 || m(t) || L(t) || ke(t) || $(t) || V(we, t);
1517
1444
  }
1518
1445
  export {
1519
- Nt as A,
1520
- Lt as B,
1521
- Ct as C,
1522
- St as I,
1523
- nt as S,
1524
- R as V,
1525
- pt as a,
1526
- mt as b,
1527
- X as c,
1528
- se as d,
1529
- yt as e,
1530
- O as f,
1531
- Q as g,
1532
- K as h,
1533
- S as i,
1534
- I as j,
1535
- Tt as k,
1536
- Mt as l,
1537
- x as m,
1538
- U as n,
1539
- gt as o,
1540
- q as p,
1541
- C as q,
1542
- bt as r,
1543
- xt as s,
1544
- D as t,
1545
- Et as u,
1546
- v,
1547
- wt as w,
1548
- vt as x,
1549
- Xe as y,
1550
- G as z
1446
+ D as $,
1447
+ lt as I,
1448
+ Fe as S,
1449
+ P as V,
1450
+ tt as a,
1451
+ st as b,
1452
+ it as c,
1453
+ k as d,
1454
+ R as e,
1455
+ L as f,
1456
+ C as g,
1457
+ b as h,
1458
+ m as i,
1459
+ ft as j,
1460
+ O as k,
1461
+ nt as l,
1462
+ N as m,
1463
+ A as n,
1464
+ M as o,
1465
+ _ as p,
1466
+ ot as q,
1467
+ ct as r,
1468
+ ut as s,
1469
+ T as t,
1470
+ y as u,
1471
+ rt as v,
1472
+ Ke as w,
1473
+ pt as x,
1474
+ ht as y,
1475
+ dt as z
1551
1476
  };
1552
- //# sourceMappingURL=markup-DZcvFR50.js.map
1477
+ //# sourceMappingURL=markup-B-2w-v-S.js.map