@jasonshimmy/custom-elements-runtime 0.1.3 → 0.1.5

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.
@@ -7,7 +7,7 @@ function nt(e, t) {
7
7
  return J(t(r, n), `each-${o}`);
8
8
  });
9
9
  }
10
- function be() {
10
+ function ve() {
11
11
  const e = [];
12
12
  return {
13
13
  when(t, r) {
@@ -17,11 +17,11 @@ function be() {
17
17
  return e.push([!0, t]), this;
18
18
  },
19
19
  done() {
20
- return ve(...e);
20
+ return xe(...e);
21
21
  }
22
22
  };
23
23
  }
24
- function ve(...e) {
24
+ function xe(...e) {
25
25
  for (let t = 0; t < e.length; t++) {
26
26
  const [r, n] = e[t];
27
27
  if (r) return [J(n, `whenChain-branch-${t}`)];
@@ -36,7 +36,7 @@ function J(e, t) {
36
36
  children: r
37
37
  };
38
38
  }
39
- class P extends EventTarget {
39
+ class O extends EventTarget {
40
40
  handlers = {};
41
41
  static instance;
42
42
  eventCounters = /* @__PURE__ */ new Map();
@@ -44,7 +44,7 @@ class P extends EventTarget {
44
44
  * Returns the singleton instance of GlobalEventBus
45
45
  */
46
46
  static getInstance() {
47
- return P.instance || (P.instance = new P()), P.instance;
47
+ return O.instance || (O.instance = new O()), O.instance;
48
48
  }
49
49
  // Enhanced emit method with better typing and event storm protection
50
50
  /**
@@ -160,22 +160,24 @@ class P extends EventTarget {
160
160
  this.eventCounters.clear();
161
161
  }
162
162
  }
163
- const H = P.getInstance(), ot = (e, t) => H.emit(e, t), it = (e, t) => H.on(e, t), st = (e, t) => H.off(e, t), at = (e, t) => H.once(e, t), lt = (e, t, r) => H.listen(e, t, r);
163
+ const H = O.getInstance(), ot = (e, t) => H.emit(e, t), it = (e, t) => H.on(e, t), st = (e, t) => H.off(e, t), at = (e, t) => H.once(e, t), lt = (e, t, r) => H.listen(e, t, r);
164
164
  function ie(e) {
165
- let t = new Proxy(e, {
166
- set: (i, a, l) => (i[a] = l, s(), !0)
167
- });
165
+ let t = { ...e };
168
166
  const r = [];
169
- function n(i) {
170
- r.push(i), i(t);
167
+ function n(a) {
168
+ r.push(a), a(t);
171
169
  }
172
170
  function o() {
173
171
  return t;
174
172
  }
175
- function s() {
176
- r.forEach((i) => i(t));
173
+ function s(a) {
174
+ const c = typeof a == "function" ? a(t) : a;
175
+ t = { ...t, ...c }, i();
176
+ }
177
+ function i() {
178
+ r.forEach((a) => a(t));
177
179
  }
178
- return { subscribe: n, getState: o };
180
+ return { subscribe: n, getState: o, setState: s };
179
181
  }
180
182
  function ne(e) {
181
183
  return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
@@ -192,7 +194,7 @@ function ee(e) {
192
194
  })[t]
193
195
  ) : e;
194
196
  }
195
- function xe(e, t, r) {
197
+ function we(e, t, r) {
196
198
  if (r)
197
199
  for (const [n, o] of Object.entries(r)) {
198
200
  let s, i = {};
@@ -212,14 +214,14 @@ function xe(e, t, r) {
212
214
  function te(e, t) {
213
215
  return t.split(".").reduce((r, n) => r?.[n], e);
214
216
  }
215
- function we(e, t, r, n) {
217
+ function ke(e, t, r, n) {
216
218
  const o = (i, a) => {
217
219
  if (i === a) return !0;
218
220
  if (typeof i != typeof a || typeof i != "object" || i === null || a === null) return !1;
219
221
  if (Array.isArray(i) && Array.isArray(a))
220
- return i.length !== a.length ? !1 : i.every((p, d) => o(p, a[d]));
221
- const l = Object.keys(i), f = Object.keys(a);
222
- return l.length !== f.length ? !1 : l.every((p) => o(i[p], a[p]));
222
+ return i.length !== a.length ? !1 : i.every((g, d) => o(g, a[d]));
223
+ const c = Object.keys(i), f = Object.keys(a);
224
+ return c.length !== f.length ? !1 : c.every((g) => o(i[g], a[g]));
223
225
  }, s = t.get(r);
224
226
  if (s && !o(n, s.oldValue))
225
227
  try {
@@ -230,13 +232,13 @@ function we(e, t, r, n) {
230
232
  for (const [i, a] of t.entries())
231
233
  if (a.options.deep && r.startsWith(i + "."))
232
234
  try {
233
- const l = te(e, i);
234
- o(l, a.oldValue) || (a.callback(l, a.oldValue, e), a.oldValue = l);
235
- } catch (l) {
236
- console.error(`Error in deep watcher for "${i}":`, l);
235
+ const c = te(e, i);
236
+ o(c, a.oldValue) || (a.callback(c, a.oldValue, e), a.oldValue = c);
237
+ } catch (c) {
238
+ console.error(`Error in deep watcher for "${i}":`, c);
237
239
  }
238
240
  }
239
- function ke(e, t, r) {
241
+ function $e(e, t, r) {
240
242
  if (!t.props) return;
241
243
  function n(o, s) {
242
244
  return s === Boolean ? o === "true" : s === Number ? Number(o) : o;
@@ -250,13 +252,13 @@ function ke(e, t, r) {
250
252
  }
251
253
  });
252
254
  }
253
- function $e(e, t, r, n) {
255
+ function Ce(e, t, r, n) {
254
256
  e.onConnected && !r && (e.onConnected(t), n(!0));
255
257
  }
256
- function Ce(e, t, r, n, o, s, i, a) {
257
- e.onDisconnected && e.onDisconnected(t), r.forEach((l) => l()), n(), o(), s(!1), i(null), a(!1);
258
+ function Se(e, t, r, n, o, s, i, a) {
259
+ e.onDisconnected && e.onDisconnected(t), r.forEach((c) => c()), n(), o(), s(!1), i(null), a(!1);
258
260
  }
259
- function Se(e, t, r, n, o) {
261
+ function _e(e, t, r, n, o) {
260
262
  e.onAttributeChanged && e.onAttributeChanged(t, r, n, o);
261
263
  }
262
264
  function z(e, t) {
@@ -276,32 +278,32 @@ function se(e, t, r) {
276
278
  const s = n.reduce((i, a) => (a in i || (i[a] = {}), i[a]), e);
277
279
  s[o] = r;
278
280
  }
279
- function _e(e, t, r, n, o, s, i) {
281
+ function Ae(e, t, r, n, o, s, i) {
280
282
  if (!s) return;
281
- const a = t.includes("lazy"), l = t.includes("trim"), f = t.includes("number"), p = () => {
282
- const y = s._state || s;
283
- return R(y, e);
284
- }, d = p();
283
+ const a = t.includes("lazy"), c = t.includes("trim"), f = t.includes("number"), g = () => {
284
+ const h = s._state || s;
285
+ return R(h, e);
286
+ }, d = g();
285
287
  let u = "text";
286
- const m = n?.type;
287
- if (i instanceof HTMLInputElement ? u = m || i.type || "text" : i instanceof HTMLSelectElement ? u = "select" : i instanceof HTMLTextAreaElement && (u = "textarea"), u === "checkbox")
288
+ const v = n?.type;
289
+ if (i instanceof HTMLInputElement ? u = v || i.type || "text" : i instanceof HTMLSelectElement ? u = "select" : i instanceof HTMLTextAreaElement && (u = "textarea"), u === "checkbox")
288
290
  if (Array.isArray(d)) {
289
- const y = i?.getAttribute("value") || n?.value || "", c = d.includes(y);
290
- i && i.checked !== c && (r.checked = c);
291
+ const h = i?.getAttribute("value") || n?.value || "", l = d.includes(h);
292
+ i && i.checked !== l && (r.checked = l);
291
293
  } else {
292
- const y = i?.getAttribute("true-value") || !0, c = d === y;
293
- i && i.checked !== c && (r.checked = c);
294
+ const h = i?.getAttribute("true-value") || !0, l = d === h;
295
+ i && i.checked !== l && (r.checked = l);
294
296
  }
295
297
  else if (u === "radio") {
296
- const y = n?.value || "", c = d === y;
297
- i && i.checked !== c && (r.checked = c);
298
+ const h = n?.value || "", l = d === h;
299
+ i && i.checked !== l && (r.checked = l);
298
300
  } else if (u === "select")
299
301
  if (i && i.hasAttribute("multiple")) {
300
- const y = i, c = Array.isArray(d) ? d : [];
302
+ const h = i, l = Array.isArray(d) ? d : [];
301
303
  setTimeout(() => {
302
- Array.from(y.options).forEach((b) => {
303
- const g = c.includes(b.value);
304
- b.selected !== g && (b.selected = g);
304
+ Array.from(h.options).forEach((p) => {
305
+ const m = l.includes(p.value);
306
+ p.selected !== m && (p.selected = m);
305
307
  });
306
308
  }, 0);
307
309
  } else
@@ -309,72 +311,72 @@ function _e(e, t, r, n, o, s, i) {
309
311
  i instanceof HTMLSelectElement && i.value !== String(d) && (i.value = String(d));
310
312
  }, 0);
311
313
  else {
312
- const y = String(d ?? "");
313
- (!i || i.value !== y) && (r.value = d);
314
- }
315
- const h = a || u === "checkbox" || u === "radio" || u === "select" ? "change" : "input", C = (y) => {
316
- if (y.isComposing || o._isComposing || y.isTrusted === !1) return;
317
- const c = y.target;
318
- if (c._modelUpdating) return;
319
- const b = p();
320
- let g = c.value;
314
+ const h = String(d ?? "");
315
+ (!i || i.value !== h) && (r.value = d);
316
+ }
317
+ const y = a || u === "checkbox" || u === "radio" || u === "select" ? "change" : "input", b = (h) => {
318
+ if (h.isComposing || o._isComposing || h.isTrusted === !1) return;
319
+ const l = h.target;
320
+ if (l._modelUpdating) return;
321
+ const p = g();
322
+ let m = l.value;
321
323
  if (u === "checkbox")
322
- if (Array.isArray(b)) {
323
- const S = c.getAttribute("value") || "", _ = [...b];
324
- if (c.checked)
324
+ if (Array.isArray(p)) {
325
+ const S = l.getAttribute("value") || "", _ = [...p];
326
+ if (l.checked)
325
327
  _.includes(S) || _.push(S);
326
328
  else {
327
- const x = _.indexOf(S);
328
- x > -1 && _.splice(x, 1);
329
+ const w = _.indexOf(S);
330
+ w > -1 && _.splice(w, 1);
329
331
  }
330
- g = _;
332
+ m = _;
331
333
  } else {
332
- const S = c.getAttribute("true-value") || !0, _ = c.getAttribute("false-value") || !1;
333
- g = c.checked ? S : _;
334
+ const S = l.getAttribute("true-value") || !0, _ = l.getAttribute("false-value") || !1;
335
+ m = l.checked ? S : _;
334
336
  }
335
337
  else if (u === "radio")
336
- g = c.getAttribute("value") || c.value;
337
- else if (u === "select" && c.multiple) {
338
- const S = c;
339
- g = Array.from(S.selectedOptions).map(
338
+ m = l.getAttribute("value") || l.value;
339
+ else if (u === "select" && l.multiple) {
340
+ const S = l;
341
+ m = Array.from(S.selectedOptions).map(
340
342
  (_) => _.value
341
343
  );
342
- } else if (l && (g = g.trim()), f) {
343
- const S = Number(g);
344
- isNaN(S) || (g = S);
344
+ } else if (c && (m = m.trim()), f) {
345
+ const S = Number(m);
346
+ isNaN(S) || (m = S);
345
347
  }
346
- const v = s._state || s, w = R(v, e);
347
- if (Array.isArray(g) && Array.isArray(w) ? JSON.stringify([...g].sort()) !== JSON.stringify([...w].sort()) : g !== w) {
348
- const S = y.target;
349
- S._modelUpdating = !0, se(v, e, g), setTimeout(() => {
348
+ const x = s._state || s, k = R(x, e);
349
+ if (Array.isArray(m) && Array.isArray(k) ? JSON.stringify([...m].sort()) !== JSON.stringify([...k].sort()) : m !== k) {
350
+ const S = h.target;
351
+ S._modelUpdating = !0, se(x, e, m), setTimeout(() => {
350
352
  S._modelUpdating = !1;
351
353
  }, 0), s._requestRender && s._requestRender();
352
354
  }
353
355
  };
354
- if (o[h] = C, u === "text" || u === "textarea") {
355
- const y = () => {
356
+ if (o[y] = b, u === "text" || u === "textarea") {
357
+ const h = () => {
356
358
  o._isComposing = !0;
357
- }, c = (b) => {
359
+ }, l = (p) => {
358
360
  o._isComposing = !1;
359
- const g = b.target;
361
+ const m = p.target;
360
362
  setTimeout(() => {
361
- if (g) {
362
- let v = g.value;
363
- if (l && (v = v.trim()), f) {
364
- const _ = Number(v);
365
- isNaN(_) || (v = _);
363
+ if (m) {
364
+ let x = m.value;
365
+ if (c && (x = x.trim()), f) {
366
+ const _ = Number(x);
367
+ isNaN(_) || (x = _);
366
368
  }
367
- const w = s._state || s, k = R(w, e);
368
- (Array.isArray(v) && Array.isArray(k) ? JSON.stringify([...v].sort()) !== JSON.stringify([...k].sort()) : v !== k) && (g && (g._modelUpdating = !0, setTimeout(() => {
369
- g._modelUpdating = !1;
370
- }, 0)), se(w, e, v), s._requestRender && s._requestRender());
369
+ const k = s._state || s, $ = R(k, e);
370
+ (Array.isArray(x) && Array.isArray($) ? JSON.stringify([...x].sort()) !== JSON.stringify([...$].sort()) : x !== $) && (m && (m._modelUpdating = !0, setTimeout(() => {
371
+ m._modelUpdating = !1;
372
+ }, 0)), se(k, e, x), s._requestRender && s._requestRender());
371
373
  }
372
374
  }, 0);
373
375
  };
374
- o.compositionstart = y, o.compositionend = c;
376
+ o.compositionstart = h, o.compositionend = l;
375
377
  }
376
378
  }
377
- function Ae(e, t, r, n) {
379
+ function Ee(e, t, r, n) {
378
380
  if (n)
379
381
  try {
380
382
  const o = JSON.parse(e);
@@ -386,18 +388,18 @@ function Ae(e, t, r, n) {
386
388
  r[e] = o;
387
389
  }
388
390
  }
389
- function Ee(e, t, r) {
391
+ function Te(e, t, r) {
390
392
  if (!r) return;
391
393
  const n = R(r, e), o = t.style || "", s = n ? "" : "none";
392
394
  if (o) {
393
395
  const i = o.split(";").filter(Boolean), a = i.findIndex(
394
- (l) => l.trim().startsWith("display:")
396
+ (c) => c.trim().startsWith("display:")
395
397
  );
396
398
  a >= 0 ? i[a] = `display: ${s}` : i.push(`display: ${s}`), t.style = i.join("; ");
397
399
  } else
398
400
  t.style = `display: ${s}`;
399
401
  }
400
- function Te(e, t, r) {
402
+ function je(e, t, r) {
401
403
  if (!r) return;
402
404
  const n = R(r, e);
403
405
  let o = [];
@@ -405,7 +407,7 @@ function Te(e, t, r) {
405
407
  const s = t.class || "", i = s ? `${s} ${o.join(" ")}`.trim() : o.join(" ");
406
408
  i && (t.class = i);
407
409
  }
408
- function je(e, t, r) {
410
+ function Le(e, t, r) {
409
411
  let n;
410
412
  if (typeof e == "string") {
411
413
  if (!r) return;
@@ -417,12 +419,12 @@ function je(e, t, r) {
417
419
  o = n;
418
420
  else if (n && typeof n == "object") {
419
421
  const i = [];
420
- for (const [a, l] of Object.entries(n))
421
- if (l != null && l !== "") {
422
+ for (const [a, c] of Object.entries(n))
423
+ if (c != null && c !== "") {
422
424
  const f = a.replace(
423
425
  /[A-Z]/g,
424
426
  (u) => `-${u.toLowerCase()}`
425
- ), p = [
427
+ ), g = [
426
428
  "width",
427
429
  "height",
428
430
  "top",
@@ -448,23 +450,23 @@ function je(e, t, r) {
448
450
  "min-height",
449
451
  "max-height"
450
452
  ];
451
- let d = String(l);
452
- typeof l == "number" && p.includes(f) && (d = `${l}px`), i.push(`${f}: ${d}`);
453
+ let d = String(c);
454
+ typeof c == "number" && g.includes(f) && (d = `${c}px`), i.push(`${f}: ${d}`);
453
455
  }
454
456
  o = i.join("; ") + (i.length > 0 ? ";" : "");
455
457
  }
456
458
  const s = t.style || "";
457
459
  t.style = s + (s && !s.endsWith(";") ? "; " : "") + o;
458
460
  }
459
- function pe(e, t, r, n) {
461
+ function he(e, t, r, n) {
460
462
  const o = {}, s = { ...n || {} }, i = {};
461
- for (const [a, l] of Object.entries(e)) {
462
- const { value: f, modifiers: p } = l;
463
+ for (const [a, c] of Object.entries(e)) {
464
+ const { value: f, modifiers: g } = c;
463
465
  switch (a) {
464
466
  case "model":
465
- _e(
467
+ Ae(
466
468
  typeof f == "string" ? f : String(f),
467
- p,
469
+ g,
468
470
  o,
469
471
  s,
470
472
  i,
@@ -473,16 +475,16 @@ function pe(e, t, r, n) {
473
475
  );
474
476
  break;
475
477
  case "bind":
476
- Ae(f, o, s, t);
478
+ Ee(f, o, s, t);
477
479
  break;
478
480
  case "show":
479
- Ee(f, s, t);
481
+ Te(f, s, t);
480
482
  break;
481
483
  case "class":
482
- Te(f, s, t);
484
+ je(f, s, t);
483
485
  break;
484
486
  case "style":
485
- je(f, s, t);
487
+ Le(f, s, t);
486
488
  break;
487
489
  }
488
490
  }
@@ -498,20 +500,20 @@ function re(e, t) {
498
500
  const d = i.tag || "node", u = i.props?.attrs?.id ?? i.props?.attrs?.name ?? i.props?.attrs?.["data-key"] ?? "";
499
501
  a = u ? `${t}:${d}:${u}` : `${t}:${d}`;
500
502
  }
501
- let l = a, f = 1;
502
- for (; s.has(l); )
503
- l = `${a}#${f++}`;
504
- s.add(l);
505
- let p = i.children;
506
- return Array.isArray(p) && (p = re(p, l)), { ...i, key: l, children: p };
503
+ let c = a, f = 1;
504
+ for (; s.has(c); )
505
+ c = `${a}#${f++}`;
506
+ s.add(c);
507
+ let g = i.children;
508
+ return Array.isArray(g) && (g = re(g, c)), { ...i, key: c, children: g };
507
509
  });
508
510
  }
509
511
  const r = e;
510
512
  let n = r.props?.key ?? r.key ?? t, o = r.children;
511
513
  return Array.isArray(o) && (o = re(o, n)), { ...r, key: n, children: o };
512
514
  }
513
- function Le(e, t, r, n) {
514
- const o = r.directives ?? {}, s = pe(
515
+ function Be(e, t, r, n) {
516
+ const o = r.directives ?? {}, s = he(
515
517
  o,
516
518
  n,
517
519
  e,
@@ -524,19 +526,19 @@ function Le(e, t, r, n) {
524
526
  ...t.attrs,
525
527
  ...r.attrs,
526
528
  ...s.attrs
527
- }, l = t.props ?? {}, f = i;
528
- for (const u in { ...l, ...f }) {
529
- const m = l[u], h = f[u];
530
- m !== h && (u === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) ? e.value !== h && (e.value = h ?? "") : u === "checked" && e instanceof HTMLInputElement ? e.checked = !!h : u.startsWith("on") && typeof h == "function" ? (typeof m == "function" && e.removeEventListener(u.slice(2).toLowerCase(), m), e.addEventListener(u.slice(2).toLowerCase(), h)) : h == null || h === !1 ? e.removeAttribute(u) : e.setAttribute(u, String(h)));
529
+ }, c = t.props ?? {}, f = i;
530
+ for (const u in { ...c, ...f }) {
531
+ const v = c[u], y = f[u];
532
+ v !== y && (u === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) ? e.value !== y && (e.value = y ?? "") : u === "checked" && e instanceof HTMLInputElement ? e.checked = !!y : u.startsWith("on") && typeof y == "function" ? (typeof v == "function" && e.removeEventListener(u.slice(2).toLowerCase(), v), e.addEventListener(u.slice(2).toLowerCase(), y)) : y == null || y === !1 ? e.removeAttribute(u) : e.setAttribute(u, String(y)));
531
533
  }
532
- for (const [u, m] of Object.entries(
534
+ for (const [u, v] of Object.entries(
533
535
  s.listeners || {}
534
536
  ))
535
- e.addEventListener(u, m);
536
- const p = t.attrs ?? {}, d = a;
537
- for (const u in { ...p, ...d }) {
538
- const m = p[u], h = d[u];
539
- m !== h && (h == null || h === !1 ? e.removeAttribute(u) : e.setAttribute(u, String(h)));
537
+ e.addEventListener(u, v);
538
+ const g = t.attrs ?? {}, d = a;
539
+ for (const u in { ...g, ...d }) {
540
+ const v = g[u], y = d[u];
541
+ v !== y && (y == null || y === !1 ? e.removeAttribute(u) : e.setAttribute(u, String(y)));
540
542
  }
541
543
  }
542
544
  function T(e, t, r) {
@@ -549,17 +551,17 @@ function T(e, t, r) {
549
551
  return e.key != null && (d.key = e.key), d;
550
552
  }
551
553
  if (e.tag === "#anchor") {
552
- const d = e, u = Array.isArray(d.children) ? d.children : [], m = document.createTextNode(""), h = document.createTextNode("");
553
- d.key != null && (m.key = `${d.key}:start`, h.key = `${d.key}:end`), d._startNode = m, d._endNode = h;
554
- const C = document.createDocumentFragment();
555
- C.appendChild(m);
556
- for (const y of u)
557
- C.appendChild(T(y, t));
558
- return C.appendChild(h), C;
554
+ const d = e, u = Array.isArray(d.children) ? d.children : [], v = document.createTextNode(""), y = document.createTextNode("");
555
+ d.key != null && (v.key = `${d.key}:start`, y.key = `${d.key}:end`), d._startNode = v, d._endNode = y;
556
+ const b = document.createDocumentFragment();
557
+ b.appendChild(v);
558
+ for (const h of u)
559
+ b.appendChild(T(h, t));
560
+ return b.appendChild(y), b;
559
561
  }
560
562
  const n = document.createElement(e.tag);
561
563
  e.key != null && (n.key = e.key);
562
- const { props: o = {}, attrs: s = {}, directives: i = {} } = e.props ?? {}, a = pe(i, t, n, s), l = {
564
+ const { props: o = {}, attrs: s = {}, directives: i = {} } = e.props ?? {}, a = he(i, t, n, s), c = {
563
565
  ...o,
564
566
  ...a.props
565
567
  }, f = {
@@ -570,8 +572,8 @@ function T(e, t, r) {
570
572
  const u = f[d];
571
573
  typeof u == "boolean" ? u && n.setAttribute(d, "") : u != null && n.setAttribute(d, String(u));
572
574
  }
573
- for (const d in l) {
574
- const u = l[d];
575
+ for (const d in c) {
576
+ const u = c[d];
575
577
  if (d === "value" && (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement))
576
578
  n.value = u ?? "";
577
579
  else if (d === "checked" && n instanceof HTMLInputElement)
@@ -588,117 +590,117 @@ function T(e, t, r) {
588
590
  a.listeners || {}
589
591
  ))
590
592
  n.addEventListener(d, u);
591
- const p = e.props?.ref ?? (e.props?.props && e.props.props.ref);
592
- if (typeof e != "string" && p && r && (r[p] = n), Array.isArray(e.children))
593
+ const g = e.props?.ref ?? (e.props?.props && e.props.props.ref);
594
+ if (typeof e != "string" && g && r && (r[g] = n), Array.isArray(e.children))
593
595
  for (const d of e.children)
594
596
  n.appendChild(T(d, t, r));
595
597
  else typeof e.children == "string" && (n.textContent = e.children);
596
598
  return n;
597
599
  }
598
- function Be(e, t, r, n, o) {
600
+ function ze(e, t, r, n, o) {
599
601
  if (typeof r == "string") {
600
602
  e.textContent !== r && (e.textContent = r);
601
603
  return;
602
604
  }
603
605
  if (!Array.isArray(r)) return;
604
606
  const s = Array.from(e.childNodes), i = Array.isArray(t) ? t : [], a = /* @__PURE__ */ new Map();
605
- for (const m of i)
606
- m && m.key != null && a.set(m.key, m);
607
- const l = /* @__PURE__ */ new Map();
608
- for (const m of s) {
609
- const h = m.key;
610
- h != null && l.set(h, m);
607
+ for (const v of i)
608
+ v && v.key != null && a.set(v.key, v);
609
+ const c = /* @__PURE__ */ new Map();
610
+ for (const v of s) {
611
+ const y = v.key;
612
+ y != null && c.set(y, v);
611
613
  }
612
614
  const f = /* @__PURE__ */ new Set();
613
- let p = e.firstChild;
614
- function d(m, h) {
615
- let C = m;
616
- for (; C && (f.add(C), C !== h); )
617
- C = C.nextSibling;
618
- }
619
- function u(m, h, C, y) {
620
- const c = [];
621
- let b = m.nextSibling;
622
- for (; b && b !== h; )
623
- c.push(b), b = b.nextSibling;
624
- const g = Array.isArray(C) ? C : [];
625
- if (y.some((w) => w && w.key != null) || g.some((w) => w && w.key != null)) {
626
- const w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map();
627
- for (const x of g)
628
- x && x.key != null && w.set(x.key, x);
629
- for (const x of c) {
630
- const $ = x.key;
631
- $ != null && k.set($, x);
615
+ let g = e.firstChild;
616
+ function d(v, y) {
617
+ let b = v;
618
+ for (; b && (f.add(b), b !== y); )
619
+ b = b.nextSibling;
620
+ }
621
+ function u(v, y, b, h) {
622
+ const l = [];
623
+ let p = v.nextSibling;
624
+ for (; p && p !== y; )
625
+ l.push(p), p = p.nextSibling;
626
+ const m = Array.isArray(b) ? b : [];
627
+ if (h.some((k) => k && k.key != null) || m.some((k) => k && k.key != null)) {
628
+ const k = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map();
629
+ for (const w of m)
630
+ w && w.key != null && k.set(w.key, w);
631
+ for (const w of l) {
632
+ const C = w.key;
633
+ C != null && $.set(C, w);
632
634
  }
633
635
  const S = /* @__PURE__ */ new Set();
634
- let _ = m.nextSibling;
635
- for (const x of y) {
636
- let $;
637
- if (x.key != null && k.has(x.key)) {
638
- const A = w.get(x.key);
639
- $ = K(
640
- k.get(x.key),
636
+ let _ = v.nextSibling;
637
+ for (const w of h) {
638
+ let C;
639
+ if (w.key != null && $.has(w.key)) {
640
+ const A = k.get(w.key);
641
+ C = K(
642
+ $.get(w.key),
641
643
  A,
642
- x,
644
+ w,
643
645
  n
644
- ), S.add($), $ !== _ && e.contains($) && e.insertBefore($, _);
646
+ ), S.add(C), C !== _ && e.contains(C) && e.insertBefore(C, _);
645
647
  } else
646
- $ = T(x, n), e.insertBefore($, _), S.add($);
647
- _ = $.nextSibling;
648
+ C = T(w, n), e.insertBefore(C, _), S.add(C);
649
+ _ = C.nextSibling;
648
650
  }
649
- for (const x of c)
650
- !S.has(x) && e.contains(x) && e.removeChild(x);
651
+ for (const w of l)
652
+ !S.has(w) && e.contains(w) && e.removeChild(w);
651
653
  } else {
652
- const w = Math.min(
653
- g.length,
654
- y.length
654
+ const k = Math.min(
655
+ m.length,
656
+ h.length
655
657
  );
656
- for (let k = 0; k < w; k++) {
657
- const S = g[k], _ = y[k], x = K(c[k], S, _, n);
658
- x !== c[k] && (e.insertBefore(x, c[k]), e.removeChild(c[k]));
658
+ for (let $ = 0; $ < k; $++) {
659
+ const S = m[$], _ = h[$], w = K(l[$], S, _, n);
660
+ w !== l[$] && (e.insertBefore(w, l[$]), e.removeChild(l[$]));
659
661
  }
660
- for (let k = w; k < y.length; k++)
661
- e.insertBefore(T(y[k], n), h);
662
- for (let k = w; k < c.length; k++)
663
- e.removeChild(c[k]);
662
+ for (let $ = k; $ < h.length; $++)
663
+ e.insertBefore(T(h[$], n), y);
664
+ for (let $ = k; $ < l.length; $++)
665
+ e.removeChild(l[$]);
664
666
  }
665
667
  }
666
- for (const m of r) {
667
- let h;
668
- if (m.tag === "#anchor") {
669
- const C = m.key, y = `${C}:start`, c = `${C}:end`;
670
- let b = l.get(y), g = l.get(c);
671
- const v = Array.isArray(m.children) ? m.children : [];
672
- if (b || (b = document.createTextNode(""), b.key = y), g || (g = document.createTextNode(""), g.key = c), m._startNode = b, m._endNode = g, !e.contains(b) || !e.contains(g)) {
673
- e.insertBefore(b, p);
674
- for (const w of v)
675
- e.insertBefore(T(w, n), p);
676
- e.insertBefore(g, p);
668
+ for (const v of r) {
669
+ let y;
670
+ if (v.tag === "#anchor") {
671
+ const b = v.key, h = `${b}:start`, l = `${b}:end`;
672
+ let p = c.get(h), m = c.get(l);
673
+ const x = Array.isArray(v.children) ? v.children : [];
674
+ if (p || (p = document.createTextNode(""), p.key = h), m || (m = document.createTextNode(""), m.key = l), v._startNode = p, v._endNode = m, !e.contains(p) || !e.contains(m)) {
675
+ e.insertBefore(p, g);
676
+ for (const k of x)
677
+ e.insertBefore(T(k, n), g);
678
+ e.insertBefore(m, g);
677
679
  } else
678
680
  u(
679
- b,
680
- g,
681
- a.get(C)?.children,
682
- v
681
+ p,
682
+ m,
683
+ a.get(b)?.children,
684
+ x
683
685
  );
684
- d(b, g), p = g.nextSibling;
686
+ d(p, m), g = m.nextSibling;
685
687
  continue;
686
688
  }
687
- if (m.key != null && l.has(m.key)) {
688
- const C = a.get(m.key);
689
- h = K(
690
- l.get(m.key),
691
- C,
692
- m,
689
+ if (v.key != null && c.has(v.key)) {
690
+ const b = a.get(v.key);
691
+ y = K(
692
+ c.get(v.key),
693
+ b,
694
+ v,
693
695
  n,
694
696
  o
695
- ), f.add(h), h !== p && e.contains(h) && (p && !e.contains(p) && (p = null), e.insertBefore(h, p));
697
+ ), f.add(y), y !== g && e.contains(y) && (g && !e.contains(g) && (g = null), e.insertBefore(y, g));
696
698
  } else
697
- h = T(m, n, o), p && !e.contains(p) && (p = null), e.insertBefore(h, p), f.add(h);
698
- p = h.nextSibling;
699
+ y = T(v, n, o), g && !e.contains(g) && (g = null), e.insertBefore(y, g), f.add(y);
700
+ g = y.nextSibling;
699
701
  }
700
- for (const m of s)
701
- !f.has(m) && e.contains(m) && (z(m, o), e.removeChild(m));
702
+ for (const v of s)
703
+ !f.has(v) && e.contains(v) && (z(v, o), e.removeChild(v));
702
704
  }
703
705
  function K(e, t, r, n, o) {
704
706
  if (t && typeof t != "string" && t.props?.ref && o && z(e, o), t === r) return e;
@@ -711,13 +713,13 @@ function K(e, t, r, n, o) {
711
713
  }
712
714
  }
713
715
  if (r && typeof r != "string" && r.tag === "#anchor") {
714
- const i = r, a = Array.isArray(i.children) ? i.children : [], l = i._startNode ?? document.createTextNode(""), f = i._endNode ?? document.createTextNode("");
715
- i.key != null && (l.key = `${i.key}:start`, f.key = `${i.key}:end`), i._startNode = l, i._endNode = f;
716
- const p = document.createDocumentFragment();
717
- p.appendChild(l);
716
+ const i = r, a = Array.isArray(i.children) ? i.children : [], c = i._startNode ?? document.createTextNode(""), f = i._endNode ?? document.createTextNode("");
717
+ i.key != null && (c.key = `${i.key}:start`, f.key = `${i.key}:end`), i._startNode = c, i._endNode = f;
718
+ const g = document.createDocumentFragment();
719
+ g.appendChild(c);
718
720
  for (const d of a)
719
- p.appendChild(T(d, n));
720
- return p.appendChild(f), e.parentNode?.replaceChild(p, e), l;
721
+ g.appendChild(T(d, n));
722
+ return g.appendChild(f), e.parentNode?.replaceChild(g, e), c;
721
723
  }
722
724
  if (!r) {
723
725
  z(e, o);
@@ -730,52 +732,52 @@ function K(e, t, r, n, o) {
730
732
  return typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = i), e.parentNode?.replaceChild(i, e), i;
731
733
  }
732
734
  if (r.tag === "#anchor") {
733
- const i = Array.isArray(r.children) ? r.children : [], a = r._startNode ?? document.createTextNode(""), l = r._endNode ?? document.createTextNode("");
734
- r.key != null && (a.key = `${r.key}:start`, l.key = `${r.key}:end`), r._startNode = a, r._endNode = l;
735
+ const i = Array.isArray(r.children) ? r.children : [], a = r._startNode ?? document.createTextNode(""), c = r._endNode ?? document.createTextNode("");
736
+ r.key != null && (a.key = `${r.key}:start`, c.key = `${r.key}:end`), r._startNode = a, r._endNode = c;
735
737
  const f = document.createDocumentFragment();
736
738
  f.appendChild(a);
737
- for (const p of i)
738
- f.appendChild(T(p, n));
739
- return f.appendChild(l), e.parentNode?.replaceChild(f, e), a;
739
+ for (const g of i)
740
+ f.appendChild(T(g, n));
741
+ return f.appendChild(c), e.parentNode?.replaceChild(f, e), a;
740
742
  }
741
743
  if (typeof t != "string" && typeof r != "string" && t.tag === r.tag && t.key === r.key) {
742
744
  const i = e;
743
- return Le(i, t.props || {}, r.props || {}, n), Be(i, t.children, r.children, n, o), typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = i), i;
745
+ return Be(i, t.props || {}, r.props || {}, n), ze(i, t.children, r.children, n, o), typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = i), i;
744
746
  }
745
747
  z(e, o);
746
748
  const s = T(r, n, o);
747
749
  return typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
748
750
  }
749
- function ze(e, t, r, n) {
751
+ function Re(e, t, r, n) {
750
752
  let o;
751
753
  Array.isArray(t) ? t.length === 1 ? (o = t[0], o && typeof o == "object" && o.key == null && (o = { ...o, key: "__root__" })) : o = { tag: "div", key: "__root__", children: t } : (o = t, o && typeof o == "object" && o.key == null && (o = { ...o, key: "__root__" })), o = re(o, String(o.key ?? "root"));
752
754
  const s = e._prevVNode ?? null, i = e._prevDom ?? e.firstChild ?? null;
753
755
  let a;
754
756
  s && i ? typeof s != "string" && typeof o != "string" && s.tag === o.tag && s.key === o.key ? a = K(i, s, o, r, n) : (a = T(o, r, n), e.replaceChild(a, i)) : (a = T(o, r, n), e.firstChild ? e.replaceChild(a, e.firstChild) : e.appendChild(a));
755
- const l = [];
757
+ const c = [];
756
758
  for (let f = 0; f < e.childNodes.length; f++) {
757
- const p = e.childNodes[f];
758
- p !== a && p.nodeName !== "STYLE" && (z(p, n), l.push(p));
759
+ const g = e.childNodes[f];
760
+ g !== a && g.nodeName !== "STYLE" && (z(g, n), c.push(g));
759
761
  }
760
- l.forEach((f) => e.removeChild(f)), e._prevVNode = o, e._prevDom = a;
762
+ c.forEach((f) => e.removeChild(f)), e._prevVNode = o, e._prevDom = a;
761
763
  }
762
- function he(e, ...t) {
764
+ function ge(e, ...t) {
763
765
  let r = "";
764
766
  for (let n = 0; n < e.length; n++)
765
767
  r += e[n], n < t.length && (r += t[n]);
766
768
  return r;
767
769
  }
768
- function ge(e) {
770
+ function ye(e) {
769
771
  return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
770
772
  }
771
- let q = null;
773
+ let I = null;
772
774
  function ae() {
773
- return q || (q = new CSSStyleSheet(), q.replaceSync(ge(Me))), q;
775
+ return I || (I = new CSSStyleSheet(), I.replaceSync(ye(Me))), I;
774
776
  }
775
- function Re(e) {
777
+ function Ne(e) {
776
778
  return e.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi, "").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, "").replace(/expression\s*\([^)]*\)/gi, "");
777
779
  }
778
- const Me = he`
780
+ const Me = ge`
779
781
  :host, *, ::before, ::after {
780
782
  all: isolate;
781
783
  box-sizing: border-box;
@@ -833,7 +835,7 @@ const Me = he`
833
835
  sup { top: -.5em }
834
836
  [disabled], [aria-disabled=true] { cursor: not-allowed }
835
837
  [hidden] { display: none }
836
- `, Ne = {
838
+ `, Pe = {
837
839
  gray: {
838
840
  50: "var(--color-gray-50, #f9fafb)",
839
841
  100: "var(--color-gray-100, #f3f4f6)",
@@ -1142,7 +1144,7 @@ const Me = he`
1142
1144
  "transition-colors": "transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;",
1143
1145
  "transition-opacity": "transition-property:opacity;",
1144
1146
  "transition-transform": "transition-property:transform;"
1145
- }, Pe = "var(--spacing, 0.25rem)", le = {
1147
+ }, Oe = "var(--spacing, 0.25rem)", le = {
1146
1148
  m: ["margin"],
1147
1149
  mx: ["margin-inline"],
1148
1150
  my: ["margin-block"],
@@ -1173,7 +1175,7 @@ const Me = he`
1173
1175
  gap: ["gap"],
1174
1176
  "gap-x": ["column-gap"],
1175
1177
  "gap-y": ["row-gap"]
1176
- }, Oe = {
1178
+ }, We = {
1177
1179
  // State variants
1178
1180
  before: (e, t) => `${e}::before{${t}}`,
1179
1181
  after: (e, t) => `${e}::after{${t}}`,
@@ -1215,16 +1217,16 @@ function X(e) {
1215
1217
  const o = n.slice(0, -1).join("-"), s = n[n.length - 1], i = parseFloat(s);
1216
1218
  if (Number.isNaN(i) || !le[o]) return null;
1217
1219
  const a = t ? "-" : "";
1218
- return le[o].map((l) => `${l}:calc(${a}${Pe} * ${i});`).join("");
1220
+ return le[o].map((c) => `${c}:calc(${a}${Oe} * ${i});`).join("");
1219
1221
  }
1220
1222
  function fe(e) {
1221
1223
  const t = e.replace("#", ""), r = parseInt(t, 16), n = r >> 16 & 255, o = r >> 8 & 255, s = r & 255;
1222
1224
  return `${n} ${o} ${s}`;
1223
1225
  }
1224
- function We(e) {
1226
+ function De(e) {
1225
1227
  const t = /^(bg|text|border|shadow|outline|caret|accent)-([a-z]+)-?(\d{2,3}|DEFAULT)?$/.exec(e);
1226
1228
  if (!t) return null;
1227
- const [, r, n, o = "DEFAULT"] = t, s = Ne[n]?.[o];
1229
+ const [, r, n, o = "DEFAULT"] = t, s = Pe[n]?.[o];
1228
1230
  return s ? `${{
1229
1231
  bg: "background-color",
1230
1232
  text: "color",
@@ -1235,14 +1237,14 @@ function We(e) {
1235
1237
  accent: "accent-color"
1236
1238
  }[r]}:${s};` : null;
1237
1239
  }
1238
- function De(e) {
1240
+ function He(e) {
1239
1241
  const [t, r] = e.split("/");
1240
1242
  if (!r) return { base: t };
1241
1243
  const n = parseInt(r, 10);
1242
1244
  return isNaN(n) || n < 0 || n > 100 ? { base: t } : { base: t, opacity: n / 100 };
1243
1245
  }
1244
1246
  function Y(e) {
1245
- const { base: t, opacity: r } = De(e), n = We(t);
1247
+ const { base: t, opacity: r } = He(e), n = De(t);
1246
1248
  if (n) {
1247
1249
  if (r !== void 0) {
1248
1250
  const s = /#([0-9a-f]{6})/i.exec(n);
@@ -1253,7 +1255,7 @@ function Y(e) {
1253
1255
  }
1254
1256
  return n;
1255
1257
  }
1256
- const o = V(t);
1258
+ const o = U(t);
1257
1259
  if (o && r !== void 0) {
1258
1260
  const s = /#([0-9a-f]{6})/i.exec(o);
1259
1261
  if (s) {
@@ -1263,7 +1265,7 @@ function Y(e) {
1263
1265
  }
1264
1266
  return o;
1265
1267
  }
1266
- function V(e) {
1268
+ function U(e) {
1267
1269
  const t = e.indexOf("-["), r = e.endsWith("]");
1268
1270
  if (t > 0 && r) {
1269
1271
  const n = e.slice(0, t);
@@ -1313,7 +1315,7 @@ function V(e) {
1313
1315
  }
1314
1316
  return null;
1315
1317
  }
1316
- function He(e) {
1318
+ function qe(e) {
1317
1319
  return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1");
1318
1320
  }
1319
1321
  function Ie(e) {
@@ -1327,81 +1329,81 @@ function Ie(e) {
1327
1329
  }
1328
1330
  return r.filter(Boolean);
1329
1331
  }
1330
- const ue = /* @__PURE__ */ new Map(), qe = 16;
1331
- function Fe(e) {
1332
+ const ue = /* @__PURE__ */ new Map(), Fe = 16;
1333
+ function Ke(e) {
1332
1334
  const t = Date.now(), r = ue.get(e);
1333
- if (r && t - r.timestamp < qe) return r.css;
1334
- const n = Ie(e), o = new Set(n), s = [], i = [], a = [], l = [], f = {};
1335
- function p(h, C = !1) {
1336
- const y = (C ? "dark|" : "") + h;
1337
- if (y in f) return f[y];
1338
- const c = u(h, C);
1339
- return f[y] = c, c;
1340
- }
1341
- function d(h) {
1342
- const C = h.some((c) => Z.includes(c)), y = h.includes("dark");
1343
- return h.length === 0 ? 1 : !C && !y ? 2 : C && !y ? 3 : 4;
1344
- }
1345
- function u(h, C = !1) {
1346
- const y = h.split(":"), c = y.find(
1347
- ($) => Q[$] || X($) || Y($) || V($)
1335
+ if (r && t - r.timestamp < Fe) return r.css;
1336
+ const n = Ie(e), o = new Set(n), s = [], i = [], a = [], c = [], f = {};
1337
+ function g(y, b = !1) {
1338
+ const h = (b ? "dark|" : "") + y;
1339
+ if (h in f) return f[h];
1340
+ const l = u(y, b);
1341
+ return f[h] = l, l;
1342
+ }
1343
+ function d(y) {
1344
+ const b = y.some((l) => Z.includes(l)), h = y.includes("dark");
1345
+ return y.length === 0 ? 1 : !b && !h ? 2 : b && !h ? 3 : 4;
1346
+ }
1347
+ function u(y, b = !1) {
1348
+ const h = y.split(":"), l = h.find(
1349
+ (C) => Q[C] || X(C) || Y(C) || U(C)
1348
1350
  );
1349
- if (!c) return null;
1350
- const b = Q[c] ?? X(c) ?? Y(c) ?? V(c);
1351
- if (!b) return null;
1352
- let g = `.${He(h)}`, v = b;
1353
- const w = y.indexOf(c);
1354
- let k = w >= 0 ? y.slice(0, w) : [];
1355
- C && (k = k.filter(($) => $ !== "dark"));
1356
- const S = k.filter(($) => Z.includes($)), _ = S.length ? S[S.length - 1] : null;
1357
- for (const $ of k) {
1358
- if (Z.includes($)) continue;
1359
- const A = Oe[$];
1360
- typeof A == "function" && (g = A(g, v).replace(/\{.*$/, ""));
1351
+ if (!l) return null;
1352
+ const p = Q[l] ?? X(l) ?? Y(l) ?? U(l);
1353
+ if (!p) return null;
1354
+ let m = `.${qe(y)}`, x = p;
1355
+ const k = h.indexOf(l);
1356
+ let $ = k >= 0 ? h.slice(0, k) : [];
1357
+ b && ($ = $.filter((C) => C !== "dark"));
1358
+ const S = $.filter((C) => Z.includes(C)), _ = S.length ? S[S.length - 1] : null;
1359
+ for (const C of $) {
1360
+ if (Z.includes(C)) continue;
1361
+ const A = We[C];
1362
+ typeof A == "function" && (m = A(m, x).replace(/\{.*$/, ""));
1361
1363
  }
1362
- let x = `${g}{${v}}`;
1363
- return C && _ ? x = `@media (prefers-color-scheme: dark) and ${ce[_]}{${x}}` : C ? x = `@media (prefers-color-scheme: dark){${x}}` : _ && (x = `@media ${ce[_]}{${x}}`), x;
1364
+ let w = `${m}{${x}}`;
1365
+ return b && _ ? w = `@media (prefers-color-scheme: dark) and ${ce[_]}{${w}}` : b ? w = `@media (prefers-color-scheme: dark){${w}}` : _ && (w = `@media ${ce[_]}{${w}}`), w;
1364
1366
  }
1365
- for (const h of o) {
1366
- const C = h.split(":"), y = C.find(
1367
- (v) => Q[v] || X(v) || Y(v) || V(v)
1367
+ for (const y of o) {
1368
+ const b = y.split(":"), h = b.find(
1369
+ (x) => Q[x] || X(x) || Y(x) || U(x)
1368
1370
  );
1369
- if (!y) continue;
1370
- const c = C.indexOf(y), b = c >= 0 ? C.slice(0, c) : [], g = d(b);
1371
- if (g === 4) {
1372
- const v = p(h, !0);
1373
- v && l.push(v);
1371
+ if (!h) continue;
1372
+ const l = b.indexOf(h), p = l >= 0 ? b.slice(0, l) : [], m = d(p);
1373
+ if (m === 4) {
1374
+ const x = g(y, !0);
1375
+ x && c.push(x);
1374
1376
  } else {
1375
- const v = p(h);
1376
- v && (g === 1 ? s.push(v) : g === 2 ? i.push(v) : g === 3 && a.push(v));
1377
+ const x = g(y);
1378
+ x && (m === 1 ? s.push(x) : m === 2 ? i.push(x) : m === 3 && a.push(x));
1377
1379
  }
1378
1380
  }
1379
- const m = [...s, ...i, ...a, ...l].join("");
1380
- return ue.set(e, { css: m, timestamp: t }), m;
1381
+ const v = [...s, ...i, ...a, ...c].join("");
1382
+ return ue.set(e, { css: v, timestamp: t }), v;
1381
1383
  }
1382
- function Ke(e, t, r, n, o, s, i, a) {
1384
+ function Ue(e, t, r, n, o, s, i, a) {
1383
1385
  if (!e) return;
1384
1386
  if (t.loadingTemplate && r.isLoading) {
1385
- M(e, t.loadingTemplate(r), r, n, o);
1387
+ N(e, t.loadingTemplate(r), r, n, o);
1386
1388
  return;
1387
1389
  }
1388
1390
  if (t.errorTemplate && r.hasError) {
1389
- r.error instanceof Error && M(e, t.errorTemplate(r.error, r), r, n, o);
1391
+ r.error instanceof Error && N(e, t.errorTemplate(r.error, r), r, n, o);
1390
1392
  return;
1391
1393
  }
1392
- const l = t.render(r);
1393
- if (l instanceof Promise) {
1394
- s(!0), l.then((f) => {
1395
- s(!1), i(null), M(e, f, r, n, o), a(e.innerHTML);
1394
+ const c = t.render(r);
1395
+ if (c instanceof Promise) {
1396
+ s(!0), c.then((f) => {
1397
+ s(!1), i(null), N(e, f, r, n, o), a(e.innerHTML);
1396
1398
  }).catch((f) => {
1397
- s(!1), i(f), t.errorTemplate && M(e, t.errorTemplate(f, r), r, n, o);
1398
- }), t.loadingTemplate && M(e, t.loadingTemplate(r), r, n, o);
1399
+ s(!1), i(f), t.errorTemplate && N(e, t.errorTemplate(f, r), r, n, o);
1400
+ }), t.loadingTemplate && N(e, t.loadingTemplate(r), r, n, o);
1399
1401
  return;
1400
1402
  }
1401
- M(e, l, r, n, o), a(e.innerHTML);
1403
+ N(e, c, r, n, o), a(e.innerHTML);
1402
1404
  }
1403
- function M(e, t, r, n, o) {
1404
- e && (ze(
1405
+ function N(e, t, r, n, o) {
1406
+ e && (Re(
1405
1407
  e,
1406
1408
  Array.isArray(t) ? t : [t],
1407
1409
  r,
@@ -1416,37 +1418,37 @@ function Ve(e, t, r, n, o, s, i) {
1416
1418
  }
1417
1419
  } else
1418
1420
  o(0);
1419
- const l = setTimeout(() => {
1421
+ const c = setTimeout(() => {
1420
1422
  n(Date.now()), e(), i(null);
1421
1423
  }, 0);
1422
- i(l);
1424
+ i(c);
1423
1425
  }
1424
- function Ue(e, t, r, n, o, s) {
1426
+ function Je(e, t, r, n, o, s) {
1425
1427
  if (!e) return;
1426
- const i = Fe(n);
1428
+ const i = Ke(n);
1427
1429
  if (!t.style && (!i || i.trim() === "")) {
1428
1430
  s(null), e.adoptedStyleSheets = [ae()];
1429
1431
  return;
1430
1432
  }
1431
1433
  let a = "";
1432
1434
  t.style && (typeof t.style == "string" ? a = t.style : typeof t.style == "function" && (a = t.style(r)));
1433
- let l = Re(`${a}
1435
+ let c = Ne(`${a}
1434
1436
  ${i}
1435
1437
  `);
1436
- l = ge(l);
1438
+ c = ye(c);
1437
1439
  let f = o;
1438
- f || (f = new CSSStyleSheet()), (f.cssRules.length === 0 || f.toString() !== l) && f.replaceSync(l), e.adoptedStyleSheets = [ae(), f], s(f);
1440
+ f || (f = new CSSStyleSheet()), (f.cssRules.length === 0 || f.toString() !== c) && f.replaceSync(c), e.adoptedStyleSheets = [ae(), f], s(f);
1439
1441
  }
1440
- const Je = /* @__PURE__ */ new Map();
1442
+ const Qe = /* @__PURE__ */ new Map();
1441
1443
  function de(e, t, r) {
1442
1444
  let n = ne(e);
1443
1445
  n.includes("-") || (n = `cer-${n}`);
1444
1446
  let o;
1445
1447
  typeof t == "function" ? o = { ...r, render: t } : o = t, typeof o.onError != "function" && (o.onError = (s, i) => {
1446
1448
  console.error(`[${n}] Error:`, s, i);
1447
- }), Je.set(n, o), typeof window < "u" && !customElements.get(n) && customElements.define(n, Qe(o));
1449
+ }), Qe.set(n, o), typeof window < "u" && !customElements.get(n) && customElements.define(n, Ze(o));
1448
1450
  }
1449
- function Qe(e) {
1451
+ function Ze(e) {
1450
1452
  if (!e.render)
1451
1453
  throw new Error(
1452
1454
  "Component must have a render function"
@@ -1512,8 +1514,8 @@ function Qe(e) {
1512
1514
  ...o || {}
1513
1515
  })
1514
1516
  );
1515
- const s = `on${r.charAt(0).toUpperCase()}${r.slice(1)}`, i = typeof this[s] == "function" ? this[s] : void 0, a = typeof this.context[s] == "function" ? this.context[s] : void 0, l = typeof e[s] == "function" ? e[s] : void 0;
1516
- i && i(n, this.context), a && a !== i && a(n, this.context), l && l !== i && l !== a && l(n, this.context);
1517
+ const s = `on${r.charAt(0).toUpperCase()}${r.slice(1)}`, i = typeof this[s] == "function" ? this[s] : void 0, a = typeof this.context[s] == "function" ? this.context[s] : void 0, c = typeof e[s] == "function" ? e[s] : void 0;
1518
+ i && i(n, this.context), a && a !== i && a(n, this.context), c && c !== i && c !== a && c(n, this.context);
1517
1519
  },
1518
1520
  writable: !1,
1519
1521
  enumerable: !1,
@@ -1533,7 +1535,7 @@ function Qe(e) {
1533
1535
  }
1534
1536
  connectedCallback() {
1535
1537
  this._runLogicWithinErrorBoundary(e, () => {
1536
- $e(
1538
+ Ce(
1537
1539
  e,
1538
1540
  this.context,
1539
1541
  this._mounted,
@@ -1545,7 +1547,7 @@ function Qe(e) {
1545
1547
  }
1546
1548
  disconnectedCallback() {
1547
1549
  this._runLogicWithinErrorBoundary(e, () => {
1548
- Ce(
1550
+ Se(
1549
1551
  e,
1550
1552
  this.context,
1551
1553
  this._listeners,
@@ -1569,7 +1571,7 @@ function Qe(e) {
1569
1571
  }
1570
1572
  attributeChangedCallback(t, r, n) {
1571
1573
  this._runLogicWithinErrorBoundary(e, () => {
1572
- this._applyProps(e), Se(
1574
+ this._applyProps(e), _e(
1573
1575
  e,
1574
1576
  t,
1575
1577
  r,
@@ -1597,7 +1599,7 @@ function Qe(e) {
1597
1599
  // --- Render ---
1598
1600
  _render(t) {
1599
1601
  this._runLogicWithinErrorBoundary(t, () => {
1600
- Ke(
1602
+ Ue(
1601
1603
  this.shadowRoot,
1602
1604
  t,
1603
1605
  this.context,
@@ -1640,7 +1642,7 @@ function Qe(e) {
1640
1642
  // --- Style ---
1641
1643
  _applyStyle(t, r) {
1642
1644
  this._runLogicWithinErrorBoundary(t, () => {
1643
- Ue(
1645
+ Je(
1644
1646
  this.shadowRoot,
1645
1647
  t,
1646
1648
  this.context,
@@ -1669,8 +1671,8 @@ function Qe(e) {
1669
1671
  try {
1670
1672
  let r = function(o, s = "") {
1671
1673
  return Array.isArray(o) ? new Proxy(o, {
1672
- get(i, a, l) {
1673
- const f = Reflect.get(i, a, l);
1674
+ get(i, a, c) {
1675
+ const f = Reflect.get(i, a, c);
1674
1676
  return typeof f == "function" && typeof a == "string" && [
1675
1677
  "push",
1676
1678
  "pop",
@@ -1682,23 +1684,23 @@ function Qe(e) {
1682
1684
  ].includes(a) ? function(...d) {
1683
1685
  const u = f.apply(i, d);
1684
1686
  if (!n._initializing) {
1685
- const m = s || "root";
1686
- n._triggerWatchers(m, i), n._render(t);
1687
+ const v = s || "root";
1688
+ n._triggerWatchers(v, i), n._render(t);
1687
1689
  }
1688
1690
  return u;
1689
1691
  } : f;
1690
1692
  },
1691
- set(i, a, l) {
1692
- if (i[a] = l, !n._initializing) {
1693
+ set(i, a, c) {
1694
+ if (i[a] = c, !n._initializing) {
1693
1695
  const f = s ? `${s}.${String(a)}` : String(a);
1694
- n._triggerWatchers(f, l), n._render(t);
1696
+ n._triggerWatchers(f, c), n._render(t);
1695
1697
  }
1696
1698
  return !0;
1697
1699
  },
1698
1700
  deleteProperty(i, a) {
1699
1701
  if (delete i[a], !n._initializing) {
1700
- const l = s ? `${s}.${String(a)}` : String(a);
1701
- n._triggerWatchers(l, void 0), n._render(t);
1702
+ const c = s ? `${s}.${String(a)}` : String(a);
1703
+ n._triggerWatchers(c, void 0), n._render(t);
1702
1704
  }
1703
1705
  return !0;
1704
1706
  }
@@ -1706,15 +1708,15 @@ function Qe(e) {
1706
1708
  const a = s ? `${s}.${i}` : i;
1707
1709
  o[i] = r(o[i], a);
1708
1710
  }), new Proxy(o, {
1709
- set(i, a, l) {
1711
+ set(i, a, c) {
1710
1712
  const f = s ? `${s}.${String(a)}` : String(a);
1711
- return i[a] = r(l, f), n._initializing || (n._triggerWatchers(
1713
+ return i[a] = r(c, f), n._initializing || (n._triggerWatchers(
1712
1714
  f,
1713
1715
  i[a]
1714
1716
  ), n._render(t)), !0;
1715
1717
  },
1716
- get(i, a, l) {
1717
- return Reflect.get(i, a, l);
1718
+ get(i, a, c) {
1719
+ return Reflect.get(i, a, c);
1718
1720
  }
1719
1721
  })) : o;
1720
1722
  };
@@ -1726,7 +1728,7 @@ function Qe(e) {
1726
1728
  }
1727
1729
  _initWatchers(t) {
1728
1730
  this._runLogicWithinErrorBoundary(t, () => {
1729
- xe(
1731
+ we(
1730
1732
  this.context,
1731
1733
  this._watchers,
1732
1734
  t.watch || {}
@@ -1734,12 +1736,12 @@ function Qe(e) {
1734
1736
  });
1735
1737
  }
1736
1738
  _triggerWatchers(t, r) {
1737
- we(this.context, this._watchers, t, r);
1739
+ ke(this.context, this._watchers, t, r);
1738
1740
  }
1739
1741
  _applyProps(t) {
1740
1742
  this._runLogicWithinErrorBoundary(t, () => {
1741
1743
  try {
1742
- ke(this, t, this.context);
1744
+ $e(this, t, this.context);
1743
1745
  } catch (r) {
1744
1746
  this._hasError = !0, t.onError && t.onError(r, this.context), t.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = t.errorFallback(r, this.context));
1745
1747
  }
@@ -1751,121 +1753,121 @@ function F(e, t = {}, r, n) {
1751
1753
  const o = n ?? t.key;
1752
1754
  return { tag: e, key: o, props: t, children: r };
1753
1755
  }
1754
- function U(e) {
1756
+ function V(e) {
1755
1757
  return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
1756
1758
  }
1757
- function N(e) {
1758
- return typeof e == "object" && e !== null && "tag" in e && !U(e);
1759
+ function M(e) {
1760
+ return typeof e == "object" && e !== null && "tag" in e && !V(e);
1759
1761
  }
1760
- function Ze(e, t) {
1762
+ function Xe(e, t) {
1761
1763
  return e.key != null ? e : { ...e, key: t };
1762
1764
  }
1763
- function Xe(e, t = [], r = {}) {
1765
+ function Ye(e, t = [], r = {}) {
1764
1766
  const n = {}, o = {}, s = {}, i = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
1765
1767
  let a;
1766
1768
  for (; a = i.exec(e); ) {
1767
- const l = a[1], f = a[2], p = (a[4] || a[6]) ?? "", d = p.match(/^{{(\d+)}}$/);
1768
- let u = d ? t[Number(d[1])] ?? null : p;
1769
- if (d || (u === "true" ? u = !0 : u === "false" ? u = !1 : u === "null" ? u = null : isNaN(Number(u)) || (u = Number(u))), l === ":")
1769
+ const c = a[1], f = a[2], g = (a[4] || a[6]) ?? "", d = g.match(/^{{(\d+)}}$/);
1770
+ let u = d ? t[Number(d[1])] ?? null : g;
1771
+ if (d || (u === "true" ? u = !0 : u === "false" ? u = !1 : u === "null" ? u = null : isNaN(Number(u)) || (u = Number(u))), c === ":")
1770
1772
  typeof u == "boolean" ? o[f] = u : u != null && (n[f] = u);
1771
- else if (l === "@") {
1772
- const m = "on" + f.charAt(0).toUpperCase() + f.slice(1);
1773
- n[m] = typeof u == "function" ? u : typeof r[u] == "function" ? r[u] : void 0;
1774
- } else if (l === "#") {
1775
- const [m, ...h] = f.split("."), C = [...h];
1776
- let y = u, c = [...C];
1777
- if (m === "model" && typeof y == "string" && y.includes(".")) {
1778
- const b = ["trim", "number", "lazy"], g = y.split(".");
1779
- let v = y;
1780
- const w = [];
1781
- for (let k = g.length - 1; k > 0 && b.includes(g[k]); k--)
1782
- w.unshift(g[k]), v = g.slice(0, k).join(".");
1783
- y = v, c.push(...w);
1773
+ else if (c === "@") {
1774
+ const v = "on" + f.charAt(0).toUpperCase() + f.slice(1);
1775
+ n[v] = typeof u == "function" ? u : typeof r[u] == "function" ? r[u] : void 0;
1776
+ } else if (c === "#") {
1777
+ const [v, ...y] = f.split("."), b = [...y];
1778
+ let h = u, l = [...b];
1779
+ if (v === "model" && typeof h == "string" && h.includes(".")) {
1780
+ const p = ["trim", "number", "lazy"], m = h.split(".");
1781
+ let x = h;
1782
+ const k = [];
1783
+ for (let $ = m.length - 1; $ > 0 && p.includes(m[$]); $--)
1784
+ k.unshift(m[$]), x = m.slice(0, $).join(".");
1785
+ h = x, l.push(...k);
1784
1786
  }
1785
- s[m] = {
1786
- value: y,
1787
- modifiers: c
1787
+ s[v] = {
1788
+ value: h,
1789
+ modifiers: l
1788
1790
  };
1789
1791
  } else f === "ref" ? n.ref = u : o[f] = u;
1790
1792
  }
1791
1793
  return { props: n, attrs: o, directives: s };
1792
1794
  }
1793
- function Ye(e, t, r) {
1794
- function n(c, b) {
1795
- return F("#text", {}, c, b);
1795
+ function Ge(e, t, r) {
1796
+ function n(l, p) {
1797
+ return F("#text", {}, l, p);
1796
1798
  }
1797
1799
  let o = "";
1798
- for (let c = 0; c < e.length; c++)
1799
- o += e[c], c < t.length && (o += `{{${c}}}`);
1800
+ for (let l = 0; l < e.length; l++)
1801
+ o += e[l], l < t.length && (o += `{{${l}}}`);
1800
1802
  const s = /<\/?([a-zA-Z0-9-]+)([^>]*)\/?>|{{(\d+)}}|([^<]+)/g, i = [];
1801
- let a = null, l, f = [], p = null, d = {}, u, m = 0, h = [];
1802
- function C(c) {
1803
- !c || typeof c != "object" || U(c) || (c.props || c.attrs ? (c.props && (d.props || (d.props = {}), Object.assign(d.props, c.props)), c.attrs && (d.attrs || (d.attrs = {}), Object.keys(c.attrs).forEach((b) => {
1804
- if (b === "style" && d.attrs.style) {
1805
- const g = d.attrs.style.replace(
1803
+ let a = null, c, f = [], g = null, d = {}, u, v = 0, y = [];
1804
+ function b(l) {
1805
+ !l || typeof l != "object" || V(l) || (l.props || l.attrs ? (l.props && (d.props || (d.props = {}), Object.assign(d.props, l.props)), l.attrs && (d.attrs || (d.attrs = {}), Object.keys(l.attrs).forEach((p) => {
1806
+ if (p === "style" && d.attrs.style) {
1807
+ const m = d.attrs.style.replace(
1806
1808
  /;?\s*$/,
1807
1809
  ""
1808
- ), v = c.attrs.style.replace(/^;?\s*/, "");
1809
- d.attrs.style = g + "; " + v;
1810
- } else if (b === "class" && d.attrs.class) {
1811
- const g = d.attrs.class.trim().split(/\s+/).filter(Boolean), v = c.attrs.class.trim().split(/\s+/).filter(Boolean), w = [
1812
- .../* @__PURE__ */ new Set([...g, ...v])
1810
+ ), x = l.attrs.style.replace(/^;?\s*/, "");
1811
+ d.attrs.style = m + "; " + x;
1812
+ } else if (p === "class" && d.attrs.class) {
1813
+ const m = d.attrs.class.trim().split(/\s+/).filter(Boolean), x = l.attrs.class.trim().split(/\s+/).filter(Boolean), k = [
1814
+ .../* @__PURE__ */ new Set([...m, ...x])
1813
1815
  ];
1814
- d.attrs.class = w.join(" ");
1816
+ d.attrs.class = k.join(" ");
1815
1817
  } else
1816
- d.attrs[b] = c.attrs[b];
1817
- }))) : (d.props || (d.props = {}), Object.assign(d.props, c)));
1818
- }
1819
- function y(c, b) {
1820
- const g = p ? f : h;
1821
- if (U(c)) {
1822
- const v = c.key ?? b;
1823
- let w = c.children;
1824
- g.push({
1825
- ...c,
1826
- key: v,
1827
- children: w
1818
+ d.attrs[p] = l.attrs[p];
1819
+ }))) : (d.props || (d.props = {}), Object.assign(d.props, l)));
1820
+ }
1821
+ function h(l, p) {
1822
+ const m = g ? f : y;
1823
+ if (V(l)) {
1824
+ const x = l.key ?? p;
1825
+ let k = l.children;
1826
+ m.push({
1827
+ ...l,
1828
+ key: x,
1829
+ children: k
1828
1830
  });
1829
1831
  return;
1830
1832
  }
1831
- if (N(c)) {
1832
- g.push(Ze(c, void 0));
1833
+ if (M(l)) {
1834
+ m.push(Xe(l, void 0));
1833
1835
  return;
1834
1836
  }
1835
- if (Array.isArray(c)) {
1836
- if (c.length === 0) return;
1837
- for (let v = 0; v < c.length; v++) {
1838
- const w = c[v];
1839
- U(w) || N(w) || Array.isArray(w) ? y(w, `${b}-${v}`) : w !== null && typeof w == "object" ? C(w) : g.push(n(String(w), `${b}-${v}`));
1837
+ if (Array.isArray(l)) {
1838
+ if (l.length === 0) return;
1839
+ for (let x = 0; x < l.length; x++) {
1840
+ const k = l[x];
1841
+ V(k) || M(k) || Array.isArray(k) ? h(k, `${p}-${x}`) : k !== null && typeof k == "object" ? b(k) : m.push(n(String(k), `${p}-${x}`));
1840
1842
  }
1841
1843
  return;
1842
1844
  }
1843
- if (c !== null && typeof c == "object") {
1844
- C(c);
1845
+ if (l !== null && typeof l == "object") {
1846
+ b(l);
1845
1847
  return;
1846
1848
  }
1847
- g.push(n(String(c), b));
1848
- }
1849
- for (; l = s.exec(o); )
1850
- if (l[1]) {
1851
- const c = l[1], b = l[0][1] === "/", g = l[0][l[0].length - 2] === "/", {
1852
- props: v,
1853
- attrs: w,
1854
- directives: k
1855
- } = Xe(l[2] || "", t, r), S = { props: {}, attrs: {} };
1856
- for (const x in v) S.props[x] = v[x];
1857
- for (const x in w) S.attrs[x] = w[x];
1858
- for (const [x, $] of Object.entries(k))
1859
- if (x === "bind")
1860
- if (typeof $.value == "object" && $.value !== null)
1861
- for (const [A, E] of Object.entries($.value))
1849
+ m.push(n(String(l), p));
1850
+ }
1851
+ for (; c = s.exec(o); )
1852
+ if (c[1]) {
1853
+ const l = c[1], p = c[0][1] === "/", m = c[0][c[0].length - 2] === "/", {
1854
+ props: x,
1855
+ attrs: k,
1856
+ directives: $
1857
+ } = Ye(c[2] || "", t, r), S = { props: {}, attrs: {} };
1858
+ for (const w in x) S.props[w] = x[w];
1859
+ for (const w in k) S.attrs[w] = k[w];
1860
+ for (const [w, C] of Object.entries($))
1861
+ if (w === "bind")
1862
+ if (typeof C.value == "object" && C.value !== null)
1863
+ for (const [A, E] of Object.entries(C.value))
1862
1864
  typeof E == "boolean" ? S.attrs[A] = E : E != null && (S.attrs[A] = String(E));
1863
- else $.value != null && (S.attrs[x] = String($.value));
1864
- else if (x === "show") {
1865
- const A = !!$.value;
1865
+ else C.value != null && (S.attrs[w] = String(C.value));
1866
+ else if (w === "show") {
1867
+ const A = !!C.value;
1866
1868
  S.attrs.style = (S.attrs.style || "") + (A ? "" : "; display: none !important");
1867
- } else if (x === "class") {
1868
- const A = $.value;
1869
+ } else if (w === "class") {
1870
+ const A = C.value;
1869
1871
  let E = [];
1870
1872
  if (typeof A == "string")
1871
1873
  E = A.split(/\s+/).filter(Boolean);
@@ -1874,30 +1876,30 @@ function Ye(e, t, r) {
1874
1876
  if (typeof j == "string")
1875
1877
  E.push(...j.split(/\s+/).filter(Boolean));
1876
1878
  else if (j && typeof j == "object")
1877
- for (const [L, I] of Object.entries(j))
1878
- I && E.push(...L.split(/\s+/).filter(Boolean));
1879
+ for (const [L, q] of Object.entries(j))
1880
+ q && E.push(...L.split(/\s+/).filter(Boolean));
1879
1881
  } else if (A && typeof A == "object")
1880
1882
  for (const [j, L] of Object.entries(A))
1881
1883
  L && E.push(...j.split(/\s+/).filter(Boolean));
1882
- const O = S.attrs.class || "", W = [
1884
+ const W = S.attrs.class || "", D = [
1883
1885
  .../* @__PURE__ */ new Set([
1884
- ...O.split(/\s+/).filter(Boolean),
1886
+ ...W.split(/\s+/).filter(Boolean),
1885
1887
  ...E
1886
1888
  ])
1887
1889
  ];
1888
- S.attrs.class = W.join(" ");
1889
- } else if (x === "style") {
1890
- const A = $.value;
1890
+ S.attrs.class = D.join(" ");
1891
+ } else if (w === "style") {
1892
+ const A = C.value;
1891
1893
  let E = "";
1892
1894
  if (typeof A == "string")
1893
1895
  E = A;
1894
1896
  else if (A && typeof A == "object") {
1895
- const W = [];
1897
+ const D = [];
1896
1898
  for (const [j, L] of Object.entries(A))
1897
1899
  if (L != null && L !== "") {
1898
- const I = j.replace(
1900
+ const q = j.replace(
1899
1901
  /[A-Z]/g,
1900
- (ye) => `-${ye.toLowerCase()}`
1902
+ (be) => `-${be.toLowerCase()}`
1901
1903
  ), me = [
1902
1904
  "width",
1903
1905
  "height",
@@ -1925,71 +1927,71 @@ function Ye(e, t, r) {
1925
1927
  "max-height"
1926
1928
  ];
1927
1929
  let oe = String(L);
1928
- typeof L == "number" && me.includes(I) && (oe = `${L}px`), W.push(`${I}: ${oe}`);
1930
+ typeof L == "number" && me.includes(q) && (oe = `${L}px`), D.push(`${q}: ${oe}`);
1929
1931
  }
1930
- E = W.join("; ") + (W.length > 0 ? ";" : "");
1932
+ E = D.join("; ") + (D.length > 0 ? ";" : "");
1931
1933
  }
1932
- const O = S.attrs.style || "";
1933
- S.attrs.style = O + (O && !O.endsWith(";") ? "; " : "") + E;
1934
+ const W = S.attrs.style || "";
1935
+ S.attrs.style = W + (W && !W.endsWith(";") ? "; " : "") + E;
1934
1936
  }
1935
1937
  const _ = {};
1936
- for (const [x, $] of Object.entries(k))
1937
- ["bind", "show", "class", "style"].includes(x) || (_[x] = $);
1938
- if (Object.keys(_).length > 0 && (S.directives = _), b) {
1939
- const x = F(
1940
- p,
1938
+ for (const [w, C] of Object.entries($))
1939
+ ["bind", "show", "class", "style"].includes(w) || (_[w] = C);
1940
+ if (Object.keys(_).length > 0 && (S.directives = _), p) {
1941
+ const w = F(
1942
+ g,
1941
1943
  d,
1942
- f.length === 1 && N(f[0]) && f[0].tag === "#text" ? typeof f[0].children == "string" ? f[0].children : "" : f.length ? f : void 0,
1944
+ f.length === 1 && M(f[0]) && f[0].tag === "#text" ? typeof f[0].children == "string" ? f[0].children : "" : f.length ? f : void 0,
1943
1945
  u
1944
- ), $ = i.pop();
1945
- $ ? (p = $.tag, d = $.props, u = $.key, f = $.children, f.push(x)) : a = x;
1946
- } else g ? (p ? f : h).push(F(c, S, void 0, void 0)) : (p && i.push({
1947
- tag: p,
1946
+ ), C = i.pop();
1947
+ C ? (g = C.tag, d = C.props, u = C.key, f = C.children, f.push(w)) : a = w;
1948
+ } else m ? (g ? f : y).push(F(l, S, void 0, void 0)) : (g && i.push({
1949
+ tag: g,
1948
1950
  props: d,
1949
1951
  children: f,
1950
1952
  key: u
1951
- }), p = c, d = S, f = []);
1952
- } else if (typeof l[3] < "u") {
1953
- const c = Number(l[3]), b = t[c], g = `interp-${c}`;
1954
- y(b, g);
1955
- } else if (l[4]) {
1956
- const c = l[4], b = p ? f : h, g = c.split(/({{\d+}})/);
1957
- for (const v of g) {
1958
- if (!v) continue;
1959
- const w = v.match(/^{{(\d+)}}$/);
1960
- if (w) {
1961
- const k = Number(w[1]), S = t[k], _ = `interp-${k}`;
1962
- y(S, _);
1953
+ }), g = l, d = S, f = []);
1954
+ } else if (typeof c[3] < "u") {
1955
+ const l = Number(c[3]), p = t[l], m = `interp-${l}`;
1956
+ h(p, m);
1957
+ } else if (c[4]) {
1958
+ const l = c[4], p = g ? f : y, m = l.split(/({{\d+}})/);
1959
+ for (const x of m) {
1960
+ if (!x) continue;
1961
+ const k = x.match(/^{{(\d+)}}$/);
1962
+ if (k) {
1963
+ const $ = Number(k[1]), S = t[$], _ = `interp-${$}`;
1964
+ h(S, _);
1963
1965
  } else {
1964
- const k = `text-${m++}`;
1965
- b.push(n(v, k));
1966
+ const $ = `text-${v++}`;
1967
+ p.push(n(x, $));
1966
1968
  }
1967
1969
  }
1968
1970
  }
1969
1971
  if (a)
1970
- return N(a) && Array.isArray(a.children) && (a.children = a.children.filter(
1971
- (c) => N(c) ? c.tag !== "#text" || typeof c.children == "string" && c.children.trim() !== "" : !0
1972
+ return M(a) && Array.isArray(a.children) && (a.children = a.children.filter(
1973
+ (l) => M(l) ? l.tag !== "#text" || typeof l.children == "string" && l.children.trim() !== "" : !0
1972
1974
  // keep non-element VNodes (including anchors) as-is
1973
1975
  )), a;
1974
- if (h.length > 0) {
1975
- const c = h.filter(
1976
- (b) => N(b) ? b.tag !== "#text" || typeof b.children == "string" && b.children.trim() !== "" : !0
1976
+ if (y.length > 0) {
1977
+ const l = y.filter(
1978
+ (p) => M(p) ? p.tag !== "#text" || typeof p.children == "string" && p.children.trim() !== "" : !0
1977
1979
  );
1978
- return c.length === 1 ? c[0] : c;
1980
+ return l.length === 1 ? l[0] : l;
1979
1981
  }
1980
1982
  return F("div", {}, "", "fallback-root");
1981
1983
  }
1982
- function B(e, ...t) {
1984
+ function P(e, ...t) {
1983
1985
  const r = t[t.length - 1], n = typeof r == "object" && r && !Array.isArray(r) ? r : void 0;
1984
- return Ye(e, t, n);
1986
+ return Ge(e, t, n);
1985
1987
  }
1986
- const Ge = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, D = (e, t) => {
1988
+ const pe = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, B = (e, t) => {
1987
1989
  for (const r of e) {
1988
1990
  const n = [], o = r.path.replace(/:[^/]+/g, (a) => (n.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${o}$`), i = t.match(s);
1989
1991
  if (i) {
1990
1992
  const a = {};
1991
- return n.forEach((l, f) => {
1992
- a[l] = i[f + 1];
1993
+ return n.forEach((c, f) => {
1994
+ a[c] = i[f + 1];
1993
1995
  }), { route: r, params: a };
1994
1996
  }
1995
1997
  }
@@ -2009,66 +2011,111 @@ async function et(e) {
2009
2011
  throw new Error(`No component or loader defined for route: ${e.path}`);
2010
2012
  }
2011
2013
  function tt(e) {
2012
- const { routes: t, base: r = "" } = e;
2013
- let n, o, s, i, a, l, f;
2014
+ const { routes: t, base: r = "", initialUrl: n } = e;
2015
+ let o, s, i, a, c, f, g;
2016
+ const d = async (b, h) => {
2017
+ const l = t.find((p) => B([p], b.path).route !== null);
2018
+ if (l?.beforeEnter)
2019
+ try {
2020
+ const p = await l.beforeEnter(b, h);
2021
+ return typeof p == "string" ? (await y(p, !0), !1) : p !== !1;
2022
+ } catch (p) {
2023
+ return console.error("beforeEnter error", p), !1;
2024
+ }
2025
+ return !0;
2026
+ }, u = async (b, h) => {
2027
+ const l = t.find((p) => B([p], b.path).route !== null);
2028
+ if (l?.onEnter)
2029
+ try {
2030
+ const p = await l.onEnter(b, h);
2031
+ return typeof p == "string" ? (await y(p, !0), !1) : p !== !1;
2032
+ } catch (p) {
2033
+ return console.error("onEnter error", p), !1;
2034
+ }
2035
+ return !0;
2036
+ }, v = (b, h) => {
2037
+ const l = t.find((p) => B([p], b.path).route !== null);
2038
+ if (l?.afterEnter)
2039
+ try {
2040
+ l.afterEnter(b, h);
2041
+ } catch (p) {
2042
+ console.error("afterEnter error", p);
2043
+ }
2044
+ }, y = async (b, h = !1) => {
2045
+ try {
2046
+ const l = {
2047
+ path: b.replace(r, "") || "/",
2048
+ query: {}
2049
+ }, p = B(t, l.path);
2050
+ if (!p) throw new Error(`No route found for ${l.path}`);
2051
+ const m = i.getState(), x = {
2052
+ path: l.path,
2053
+ params: p.params,
2054
+ query: l.query
2055
+ };
2056
+ if (!await d(x, m) || !await u(x, m)) return;
2057
+ typeof window < "u" && typeof document < "u" && (h ? window.history.replaceState({}, "", r + b) : window.history.pushState({}, "", r + b)), i.setState(x), v(x, m);
2058
+ } catch (l) {
2059
+ console.error("Navigation error:", l);
2060
+ }
2061
+ };
2014
2062
  if (typeof window < "u" && typeof document < "u") {
2015
- n = () => {
2016
- const d = new URL(window.location.href), u = d.pathname.replace(r, "") || "/", m = Ge(d.search);
2017
- return { path: u, query: m };
2018
- }, o = n();
2019
- const p = D(t, o.path);
2020
- s = ie({
2021
- path: o.path,
2022
- params: p.params,
2023
- query: o.query
2024
- }), i = () => {
2025
- const d = n(), u = D(t, d.path), m = s.getState();
2026
- m.path = d.path, m.params = u.params, m.query = d.query;
2027
- }, window.addEventListener("popstate", i), a = (d) => {
2028
- window.history.pushState({}, "", r + d), i();
2029
- }, l = (d) => {
2030
- window.history.replaceState({}, "", r + d), i();
2031
- }, f = () => window.history.back();
2063
+ o = () => {
2064
+ const h = new URL(window.location.href), l = h.pathname.replace(r, "") || "/", p = pe(h.search);
2065
+ return { path: l, query: p };
2066
+ }, s = o();
2067
+ const b = B(t, s.path);
2068
+ i = ie({
2069
+ path: s.path,
2070
+ params: b.params,
2071
+ query: s.query
2072
+ }), a = async (h = !1) => {
2073
+ const l = o();
2074
+ await y(l.path, h);
2075
+ }, window.addEventListener("popstate", () => a(!0)), c = (h) => y(h, !1), f = (h) => y(h, !0), g = () => window.history.back();
2032
2076
  } else {
2033
- n = () => ({ path: "/", query: {} }), o = n();
2034
- const p = D(t, o.path);
2035
- s = ie({
2036
- path: o.path,
2037
- params: p.params,
2038
- query: o.query
2039
- }), i = () => {
2040
- }, a = () => {
2041
- }, l = () => {
2042
- }, f = () => {
2077
+ o = () => {
2078
+ const h = new URL(n || "/", "http://localhost"), l = h.pathname.replace(r, "") || "/", p = pe(h.search);
2079
+ return { path: l, query: p };
2080
+ }, s = o();
2081
+ const b = B(t, s.path);
2082
+ i = ie({
2083
+ path: s.path,
2084
+ params: b.params,
2085
+ query: s.query
2086
+ }), a = async () => {
2087
+ }, c = async () => {
2088
+ }, f = async () => {
2089
+ }, g = () => {
2043
2090
  };
2044
2091
  }
2045
2092
  return {
2046
- store: s,
2047
- push: a,
2048
- replace: l,
2049
- back: f,
2050
- subscribe: s.subscribe,
2051
- matchRoute: (p) => D(t, p),
2052
- getCurrent: () => s.getState(),
2093
+ store: i,
2094
+ push: c,
2095
+ replace: f,
2096
+ back: g,
2097
+ subscribe: i.subscribe,
2098
+ matchRoute: (b) => B(t, b),
2099
+ getCurrent: () => i.getState(),
2053
2100
  resolveRouteComponent: et
2054
2101
  };
2055
2102
  }
2056
2103
  function ct(e, t) {
2057
- return D(e, t);
2104
+ return B(e, t);
2058
2105
  }
2059
2106
  function ft(e) {
2060
2107
  const t = tt(e);
2061
2108
  return de("router-view", {
2062
2109
  async render() {
2063
- if (!t) return B`<div>Router not initialized.</div>`;
2110
+ if (!t) return P`<div>Router not initialized.</div>`;
2064
2111
  const r = t.getCurrent(), { path: n } = r, o = t.matchRoute(n);
2065
- if (!o.route) return B`<div>Not found</div>`;
2112
+ if (!o.route) return P`<div>Not found</div>`;
2066
2113
  let s = o.route.component;
2067
2114
  if (o.route.load) {
2068
2115
  const i = await o.route.load();
2069
2116
  typeof i.default == "string" && (s = i.default);
2070
2117
  }
2071
- return typeof s == "string" ? B`<${s}></${s}>` : B`<div>Invalid route component</div>`;
2118
+ return typeof s == "string" ? { tag: s, props: {}, children: [] } : P`<div>Invalid route component</div>`;
2072
2119
  },
2073
2120
  onConnected(r) {
2074
2121
  t && typeof t.subscribe == "function" && t.subscribe(() => {
@@ -2087,7 +2134,7 @@ function ft(e) {
2087
2134
  ariaCurrentValue: { type: String, default: "page" },
2088
2135
  disabled: { type: Boolean, default: !1 },
2089
2136
  external: { type: Boolean, default: !1 },
2090
- style: { type: String, default: he`
2137
+ style: { type: String, default: ge`
2091
2138
  [aria-disabled="true"] {
2092
2139
  pointer-events: none;
2093
2140
  opacity: 0.5;
@@ -2096,58 +2143,58 @@ function ft(e) {
2096
2143
  },
2097
2144
  style: (r) => r.props.style,
2098
2145
  render: (r) => {
2099
- const n = t.getCurrent(), o = r.props.to, s = r.props.exact, i = r.props.exactActiveClass, a = r.props.activeClass, l = r.props.ariaCurrentValue, f = r.props.tag, p = r.props.disabled, d = r.props.external, u = n.path === o, m = s ? u : n && typeof n.path == "string" ? n.path.startsWith(o) : !1, h = u ? i : m ? a : "", C = u ? `aria-current="${l}"` : "", y = f === "button", c = p ? y ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", b = d && (f === "a" || !f) ? 'target="_blank" rel="noopener noreferrer"' : "";
2100
- return B`
2101
- ${be().when(y, B`
2146
+ const n = t.getCurrent(), o = r.props.to, s = r.props.exact, i = r.props.exactActiveClass, a = r.props.activeClass, c = r.props.ariaCurrentValue, f = r.props.tag, g = r.props.disabled, d = r.props.external, u = n.path === o, v = s ? u : n && typeof n.path == "string" ? n.path.startsWith(o) : !1, y = u ? i : v ? a : "", b = u ? `aria-current="${c}"` : "", h = f === "button", l = g ? h ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", p = d && (f === "a" || !f) ? 'target="_blank" rel="noopener noreferrer"' : "";
2147
+ return P`
2148
+ ${ve().when(h, P`
2102
2149
  <button
2103
2150
  part="button"
2104
- class="${h}"
2105
- ${C}
2106
- ${c}
2151
+ class="${y}"
2107
2152
  ${b}
2153
+ ${l}
2154
+ ${p}
2108
2155
  data-on-click="navigate"
2109
2156
  ><slot></slot></button>
2110
- `).otherwise(B`
2157
+ `).otherwise(P`
2111
2158
  <a
2112
2159
  part="link"
2113
2160
  href="${o}"
2114
- class="${h}"
2115
- ${C}
2116
- ${c}
2161
+ class="${y}"
2117
2162
  ${b}
2163
+ ${l}
2164
+ ${p}
2118
2165
  data-on-click="navigate"
2119
2166
  ><slot></slot></a>
2120
2167
  `).done()}
2121
2168
  `;
2122
2169
  },
2123
2170
  navigate: (r, n) => {
2124
- const { disabled: o, external: s, tag: i, replace: a, to: l } = n.props;
2171
+ const { disabled: o, external: s, tag: i, replace: a, to: c } = n.props;
2125
2172
  if (o) {
2126
2173
  r.preventDefault();
2127
2174
  return;
2128
2175
  }
2129
- s && (i === "a" || !i) || (r.preventDefault(), a ? t.replace(l) : t.push(l));
2176
+ s && (i === "a" || !i) || (r.preventDefault(), a ? t.replace(c) : t.push(c));
2130
2177
  }
2131
2178
  }), t;
2132
2179
  }
2133
2180
  export {
2134
- P as GlobalEventBus,
2181
+ O as GlobalEventBus,
2135
2182
  de as component,
2136
2183
  ie as createStore,
2137
- he as css,
2184
+ ge as css,
2138
2185
  nt as each,
2139
2186
  ot as emit,
2140
2187
  H as eventBus,
2141
- B as html,
2188
+ P as html,
2142
2189
  ft as initRouter,
2143
2190
  lt as listen,
2144
- be as match,
2145
- D as matchRoute,
2191
+ ve as match,
2192
+ B as matchRoute,
2146
2193
  ct as matchRouteSSR,
2147
2194
  st as off,
2148
2195
  it as on,
2149
2196
  at as once,
2150
- Ge as parseQuery,
2197
+ pe as parseQuery,
2151
2198
  et as resolveRouteComponent,
2152
2199
  tt as useRouter,
2153
2200
  rt as when