@jasonshimmy/custom-elements-runtime 0.0.6 → 0.0.7

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,16 +1,16 @@
1
- function $(e) {
2
- let t = new Proxy(e, {
1
+ function j(t) {
2
+ let e = new Proxy(t, {
3
3
  set: (i, a, c) => (i[a] = c, s(), !0)
4
4
  });
5
5
  const n = [];
6
6
  function r(i) {
7
- n.push(i), i(t);
7
+ n.push(i), i(e);
8
8
  }
9
9
  function o() {
10
- return t;
10
+ return e;
11
11
  }
12
12
  function s() {
13
- n.forEach((i) => i(t));
13
+ n.forEach((i) => i(e));
14
14
  }
15
15
  return { subscribe: r, getState: o };
16
16
  }
@@ -30,26 +30,26 @@ class y extends EventTarget {
30
30
  * @param eventName - Name of the event
31
31
  * @param data - Optional event payload
32
32
  */
33
- emit(t, n) {
34
- const r = Date.now(), o = this.eventCounters.get(t);
33
+ emit(e, n) {
34
+ const r = Date.now(), o = this.eventCounters.get(e);
35
35
  if (!o || r - o.window > 1e3)
36
- this.eventCounters.set(t, { count: 1, window: r });
37
- else if (o.count++, o.count > 50 && (console.error(`Event storm detected for "${t}": ${o.count} events in 1 second. Throttling...`), o.count > 100)) {
38
- console.warn(`Blocking further "${t}" events to prevent infinite loop`);
36
+ this.eventCounters.set(e, { count: 1, window: r });
37
+ else if (o.count++, o.count > 50 && (console.error(`Event storm detected for "${e}": ${o.count} events in 1 second. Throttling...`), o.count > 100)) {
38
+ console.warn(`Blocking further "${e}" events to prevent infinite loop`);
39
39
  return;
40
40
  }
41
- this.dispatchEvent(new CustomEvent(t, {
41
+ this.dispatchEvent(new CustomEvent(e, {
42
42
  detail: n,
43
43
  bubbles: !1,
44
44
  // Global events don't need to bubble
45
45
  cancelable: !0
46
46
  }));
47
- const s = this.handlers[t];
47
+ const s = this.handlers[e];
48
48
  s && s.forEach((i) => {
49
49
  try {
50
50
  i(n);
51
51
  } catch (a) {
52
- console.error(`Error in global event handler for "${t}":`, a);
52
+ console.error(`Error in global event handler for "${e}":`, a);
53
53
  }
54
54
  });
55
55
  }
@@ -58,24 +58,24 @@ class y extends EventTarget {
58
58
  * @param eventName - Name of the event
59
59
  * @param handler - Handler function
60
60
  */
61
- on(t, n) {
62
- return this.handlers[t] || (this.handlers[t] = /* @__PURE__ */ new Set()), this.handlers[t].add(n), () => this.off(t, n);
61
+ on(e, n) {
62
+ return this.handlers[e] || (this.handlers[e] = /* @__PURE__ */ new Set()), this.handlers[e].add(n), () => this.off(e, n);
63
63
  }
64
64
  /**
65
65
  * Remove a specific handler for a global event.
66
66
  * @param eventName - Name of the event
67
67
  * @param handler - Handler function to remove
68
68
  */
69
- off(t, n) {
70
- const r = this.handlers[t];
69
+ off(e, n) {
70
+ const r = this.handlers[e];
71
71
  r && r.delete(n);
72
72
  }
73
73
  /**
74
74
  * Remove all handlers for a specific event.
75
75
  * @param eventName - Name of the event
76
76
  */
77
- offAll(t) {
78
- delete this.handlers[t];
77
+ offAll(e) {
78
+ delete this.handlers[e];
79
79
  }
80
80
  /**
81
81
  * Listen for a native CustomEvent. Returns an unsubscribe function.
@@ -83,17 +83,17 @@ class y extends EventTarget {
83
83
  * @param handler - CustomEvent handler
84
84
  * @param options - AddEventListener options
85
85
  */
86
- listen(t, n, r) {
87
- return this.addEventListener(t, n, r), () => this.removeEventListener(t, n);
86
+ listen(e, n, r) {
87
+ return this.addEventListener(e, n, r), () => this.removeEventListener(e, n);
88
88
  }
89
89
  /**
90
90
  * Register a one-time event handler. Returns a promise that resolves with the event data.
91
91
  * @param eventName - Name of the event
92
92
  * @param handler - Handler function
93
93
  */
94
- once(t, n) {
94
+ once(e, n) {
95
95
  return new Promise((r) => {
96
- const o = this.on(t, (s) => {
96
+ const o = this.on(e, (s) => {
97
97
  o(), n(s), r(s);
98
98
  });
99
99
  });
@@ -103,7 +103,7 @@ class y extends EventTarget {
103
103
  */
104
104
  getActiveEvents() {
105
105
  return Object.keys(this.handlers).filter(
106
- (t) => this.handlers[t] && this.handlers[t].size > 0
106
+ (e) => this.handlers[e] && this.handlers[e].size > 0
107
107
  );
108
108
  }
109
109
  /**
@@ -116,20 +116,20 @@ class y extends EventTarget {
116
116
  * Get the number of handlers registered for a specific event.
117
117
  * @param eventName - Name of the event
118
118
  */
119
- getHandlerCount(t) {
120
- return this.handlers[t]?.size || 0;
119
+ getHandlerCount(e) {
120
+ return this.handlers[e]?.size || 0;
121
121
  }
122
122
  /**
123
123
  * Get event statistics for debugging.
124
124
  */
125
125
  getEventStats() {
126
- const t = {};
126
+ const e = {};
127
127
  for (const [n, r] of this.eventCounters.entries())
128
- t[n] = {
128
+ e[n] = {
129
129
  count: r.count,
130
130
  handlersCount: this.getHandlerCount(n)
131
131
  };
132
- return t;
132
+ return e;
133
133
  }
134
134
  /**
135
135
  * Reset event counters (useful for testing or after resolving issues).
@@ -138,10 +138,10 @@ class y extends EventTarget {
138
138
  this.eventCounters.clear();
139
139
  }
140
140
  }
141
- const w = y.getInstance(), F = typeof window > "u" || typeof document > "u";
142
- function K(e) {
141
+ const w = y.getInstance(), K = typeof window > "u" || typeof document > "u";
142
+ function U(t) {
143
143
  return {
144
- state: e,
144
+ state: t,
145
145
  emit: () => {
146
146
  },
147
147
  // No-op on server
@@ -153,29 +153,29 @@ function K(e) {
153
153
  }
154
154
  };
155
155
  }
156
- function U(e, t = {}) {
157
- F || console.warn("[SSR] renderToString should only be used on the server");
156
+ function G(t, e = {}) {
157
+ K || console.warn("[SSR] renderToString should only be used on the server");
158
158
  try {
159
- const n = e.state, r = K(n), o = e.template(n, r);
159
+ const n = t.state, r = U(n), o = t.template(n, r);
160
160
  let s = "";
161
- t.includeStyles && e.style && (s = `<style>${typeof e.style == "function" ? e.style(n) : e.style}</style>`);
162
- const i = t.sanitizeAttributes ? t.sanitizeAttributes(e.attrs || {}) : e.attrs || {}, a = Object.entries(i).map(([u, d]) => `${j(u)}="${j(d)}"`).join(" "), l = `${a ? `<${e.tag} ${a}>` : `<${e.tag}>`}${s}${o}</${e.tag}>`;
163
- return t.prettyPrint ? Z(l) : l;
161
+ e.includeStyles && t.style && (s = `<style>${typeof t.style == "function" ? t.style(n) : t.style}</style>`);
162
+ const i = e.sanitizeAttributes ? e.sanitizeAttributes(t.attrs || {}) : t.attrs || {}, a = Object.entries(i).map(([d, u]) => `${x(d)}="${x(u)}"`).join(" "), l = `${a ? `<${t.tag} ${a}>` : `<${t.tag}>`}${s}${o}</${t.tag}>`;
163
+ return e.prettyPrint ? B(l) : l;
164
164
  } catch (n) {
165
- return console.error(`[SSR] Error rendering ${e.tag}:`, n), `<${e.tag}><div style="color: red;">SSR Error: ${G(String(n))}</div></${e.tag}>`;
165
+ return console.error(`[SSR] Error rendering ${t.tag}:`, n), `<${t.tag}><div style="color: red;">SSR Error: ${Z(String(n))}</div></${t.tag}>`;
166
166
  }
167
167
  }
168
- function st(e, t = {}) {
168
+ function ot(t, e = {}) {
169
169
  const n = {
170
170
  components: /* @__PURE__ */ new Map(),
171
171
  styles: /* @__PURE__ */ new Set()
172
172
  }, r = [];
173
- e.forEach((i) => {
173
+ t.forEach((i) => {
174
174
  if (n.components.set(i.tag, i), i.style) {
175
175
  const c = typeof i.style == "function" ? i.style(i.state) : i.style;
176
176
  n.styles.add(c);
177
177
  }
178
- const a = U(i, { ...t, includeStyles: !1 });
178
+ const a = G(i, { ...e, includeStyles: !1 });
179
179
  r.push(a);
180
180
  });
181
181
  const o = Array.from(n.styles).join(`
@@ -183,15 +183,15 @@ function st(e, t = {}) {
183
183
  return { html: r.join(`
184
184
  `), styles: o, context: n };
185
185
  }
186
- function it(e) {
187
- const t = Array.from(e.components.entries()).map(([n, r]) => ({
186
+ function at(t) {
187
+ const e = Array.from(t.components.entries()).map(([n, r]) => ({
188
188
  tag: n,
189
189
  state: r.state
190
190
  }));
191
191
  return `
192
192
  <script type="module">
193
193
  // Hydration data from SSR
194
- window.__SSR_CONTEXT__ = ${JSON.stringify({ components: t })};
194
+ window.__SSR_CONTEXT__ = ${JSON.stringify({ components: e })};
195
195
 
196
196
  // Auto-hydrate when DOM is ready
197
197
  if (document.readyState === 'loading') {
@@ -223,33 +223,33 @@ function it(e) {
223
223
  }
224
224
  <\/script>`.trim();
225
225
  }
226
- const G = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), j = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Z = (e) => e.replace(/></g, `>
226
+ const Z = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), x = (t) => t.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), B = (t) => t.replace(/></g, `>
227
227
  <`).split(`
228
- `).map((t) => {
229
- const n = (t.match(/^<[^\/]/g) || []).length - (t.match(/<\//g) || []).length;
230
- return " ".repeat(Math.max(0, n)) + t.trim();
228
+ `).map((e) => {
229
+ const n = (e.match(/^<[^\/]/g) || []).length - (e.match(/<\//g) || []).length;
230
+ return " ".repeat(Math.max(0, n)) + e.trim();
231
231
  }).join(`
232
232
  `);
233
- function x(e) {
234
- return String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
233
+ function D(t) {
234
+ return String(t).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
235
235
  }
236
- function O(e, t) {
237
- if (typeof e != "string" || !t) return String(e);
238
- for (const n in t) {
239
- if (typeof t[n] == "string" && e === t[n])
240
- return x(e);
241
- if (Array.isArray(t[n])) {
242
- for (const r of t[n])
236
+ function k(t, e) {
237
+ if (typeof t != "string" || !e) return String(t);
238
+ for (const n in e) {
239
+ if (typeof e[n] == "string" && t === e[n])
240
+ return D(t);
241
+ if (Array.isArray(e[n])) {
242
+ for (const r of e[n])
243
243
  if (r && typeof r == "object") {
244
244
  for (const o in r)
245
- if (typeof r[o] == "string" && e === r[o])
246
- return x(e);
245
+ if (typeof r[o] == "string" && t === r[o])
246
+ return D(t);
247
247
  }
248
248
  }
249
249
  }
250
- return String(e);
250
+ return String(t);
251
251
  }
252
- function ot(e, ...t) {
252
+ function ct(t, ...e) {
253
253
  function n(r, o, s) {
254
254
  if (Array.isArray(r)) {
255
255
  const i = r.map((a) => n(a, o, s));
@@ -264,91 +264,91 @@ function ot(e, ...t) {
264
264
  return (r, o) => {
265
265
  let s = "", i = !1;
266
266
  const a = [];
267
- for (let c = 0; c < e.length; c++)
268
- if (s += e[c], c < t.length) {
269
- let l = t[c];
270
- const u = e[c], d = /data-on-[a-z]+="?$/.test(u);
271
- l = n(l, r, o), l instanceof Promise ? (i = !0, a.push(l)) : /=\s*"?$/.test(u) && typeof l == "string" && !d ? (l = l.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), s += l) : !d && !/=\s*"?$/.test(u) ? s += O(l, r) : s += l;
267
+ for (let c = 0; c < t.length; c++)
268
+ if (s += t[c], c < e.length) {
269
+ let l = e[c];
270
+ const d = t[c], u = /data-on-[a-z]+="?$/.test(d);
271
+ l = n(l, r, o), l instanceof Promise ? (i = !0, a.push(l)) : /=\s*"?$/.test(d) && typeof l == "string" && !u ? (l = l.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), s += l) : !u && !/=\s*"?$/.test(d) ? s += k(l, r) : s += l;
272
272
  }
273
273
  return i ? Promise.all(a).then((c) => {
274
- let l = "", u = 0;
275
- for (let d = 0; d < e.length; d++)
276
- if (l += e[d], d < t.length) {
277
- let f = t[d];
278
- const h = e[d], m = /data-on-[a-z]+="?$/.test(h);
279
- f = n(f, r, o), f instanceof Promise ? l += c[u++] : /=\s*"?$/.test(h) && typeof f == "string" && !m ? (f = f.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), l += f) : !m && !/=\s*"?$/.test(h) ? l += O(f, r) : l += f;
274
+ let l = "", d = 0;
275
+ for (let u = 0; u < t.length; u++)
276
+ if (l += t[u], u < e.length) {
277
+ let f = e[u];
278
+ const h = t[u], m = /data-on-[a-z]+="?$/.test(h);
279
+ f = n(f, r, o), f instanceof Promise ? l += c[d++] : /=\s*"?$/.test(h) && typeof f == "string" && !m ? (f = f.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), l += f) : !m && !/=\s*"?$/.test(h) ? l += k(f, r) : l += f;
280
280
  }
281
281
  return l;
282
282
  }) : s;
283
283
  };
284
284
  }
285
- function at(e, ...t) {
285
+ function lt(t, ...e) {
286
286
  const n = "compiled-" + Math.random().toString(36).slice(2);
287
287
  function r(s, i, a) {
288
288
  return Array.isArray(s) ? s.map((c) => r(c, i, a)).join("") : typeof s == "function" ? r(s(i, a), i, a) : s == null ? "" : String(s);
289
289
  }
290
290
  const o = (s, i) => {
291
291
  let a = "";
292
- for (let c = 0; c < e.length; c++)
293
- if (a += e[c], c < t.length) {
294
- let l = t[c];
295
- const u = e[c], d = /data-on-[a-z]+="?$/.test(u);
296
- l = r(l, s, i), /=\s*"?$/.test(u) && typeof l == "string" && !d ? (l = l.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), a += l) : !d && !/=\s*"?$/.test(u) ? a += O(l, s) : a += l ?? "";
292
+ for (let c = 0; c < t.length; c++)
293
+ if (a += t[c], c < e.length) {
294
+ let l = e[c];
295
+ const d = t[c], u = /data-on-[a-z]+="?$/.test(d);
296
+ l = r(l, s, i), /=\s*"?$/.test(d) && typeof l == "string" && !u ? (l = l.replace(/"/g, "&quot;").replace(/'/g, "&#39;"), a += l) : !u && !/=\s*"?$/.test(d) ? a += k(l, s) : a += l ?? "";
297
297
  }
298
298
  return a;
299
299
  };
300
300
  return o.id = n, o;
301
301
  }
302
- function ct(e, ...t) {
302
+ function dt(t, ...e) {
303
303
  let n = "";
304
- for (let r = 0; r < e.length; r++)
305
- n += e[r], r < t.length && (n += t[r] ?? "");
304
+ for (let r = 0; r < t.length; r++)
305
+ n += t[r], r < e.length && (n += e[r] ?? "");
306
306
  return n;
307
307
  }
308
- function lt(e) {
309
- return Object.keys(e).filter((t) => e[t]).join(" ");
308
+ function ut(t) {
309
+ return Object.keys(t).filter((e) => t[e]).join(" ");
310
310
  }
311
- function ut(e) {
312
- return Object.entries(e).map(([t, n]) => `${t}: ${n}`).join("; ");
311
+ function ft(t) {
312
+ return Object.entries(t).map(([e, n]) => `${e}: ${n}`).join("; ");
313
313
  }
314
- function B(e, t, n) {
314
+ function X(t, e, n) {
315
315
  const [r, ...o] = n.split("|").map((a) => a.trim());
316
316
  if (!r || r === "__proto__" || r === "constructor" || r === "prototype") return;
317
317
  function s(a, c, l) {
318
- const u = c.split(".");
319
- let d = a;
320
- for (let f = 0; f < u.length - 1; f++)
321
- u[f] in d || (d[u[f]] = {}), d = d[u[f]];
322
- d[u[u.length - 1]] = l;
318
+ const d = c.split(".");
319
+ let u = a;
320
+ for (let f = 0; f < d.length - 1; f++)
321
+ d[f] in u || (u[d[f]] = {}), u = u[d[f]];
322
+ u[d[d.length - 1]] = l;
323
323
  }
324
324
  const i = (a) => {
325
325
  let c;
326
- if (e instanceof HTMLInputElement && e.type === "checkbox") {
327
- c = e.value;
328
- const l = e.getAttribute("data-true-value"), u = e.getAttribute("data-false-value");
329
- let d = Array.isArray(t[r]) ? t[r] : void 0;
330
- if (d) {
331
- if (e.checked)
332
- d.includes(c) || d.push(c);
326
+ if (t instanceof HTMLInputElement && t.type === "checkbox") {
327
+ c = t.value;
328
+ const l = t.getAttribute("data-true-value"), d = t.getAttribute("data-false-value");
329
+ let u = Array.isArray(e[r]) ? e[r] : void 0;
330
+ if (u) {
331
+ if (t.checked)
332
+ u.includes(c) || u.push(c);
333
333
  else {
334
- const f = d.indexOf(c);
335
- f !== -1 && d.splice(f, 1);
334
+ const f = u.indexOf(c);
335
+ f !== -1 && u.splice(f, 1);
336
336
  }
337
- s(t, r, [...d]);
337
+ s(e, r, [...u]);
338
338
  } else
339
- l !== null || u !== null ? e.checked ? s(t, r, l) : s(t, r, u !== null ? u : !1) : s(t, r, e.checked);
340
- } else e instanceof HTMLInputElement && e.type === "radio" ? (c = e.value, s(t, r, c), ((e.form || e.closest("form") || e.getRootNode()) instanceof Element ? (e.form || e.closest("form") || e.getRootNode()).querySelectorAll(`input[type="radio"][name="${e.name}"][data-model="${n}"]`) : []).forEach((u) => {
341
- u.checked = u.value === String(c);
342
- })) : (c = e.value, e instanceof HTMLInputElement && e.type === "number" && (c = Number(c)), o.includes("trim") && typeof c == "string" && (c = c.trim()), o.includes("number") && (c = Number(c)), s(t, r, c));
343
- if ("_vnode" in e && typeof e._vnode == "object" && e._vnode?.props && (e._vnode.props.value = c), a.type === "input" && (e._isDirty = !0), a.type === "keydown" && a.key === "Enter" && (e._isDirty = !1, e instanceof HTMLElement && e.isConnected)) {
344
- let l = e.parentElement;
339
+ l !== null || d !== null ? t.checked ? s(e, r, l) : s(e, r, d !== null ? d : !1) : s(e, r, t.checked);
340
+ } else t instanceof HTMLInputElement && t.type === "radio" ? (c = t.value, s(e, r, c), ((t.form || t.closest("form") || t.getRootNode()) instanceof Element ? (t.form || t.closest("form") || t.getRootNode()).querySelectorAll(`input[type="radio"][name="${t.name}"][data-model="${n}"]`) : []).forEach((d) => {
341
+ d.checked = d.value === String(c);
342
+ })) : (c = t.value, t instanceof HTMLInputElement && t.type === "number" && (c = Number(c)), o.includes("trim") && typeof c == "string" && (c = c.trim()), o.includes("number") && (c = Number(c)), s(e, r, c));
343
+ if ("_vnode" in t && typeof t._vnode == "object" && t._vnode?.props && (t._vnode.props.value = c), a.type === "input" && (t._isDirty = !0), a.type === "keydown" && a.key === "Enter" && (t._isDirty = !1, t instanceof HTMLElement && t.isConnected)) {
344
+ let l = t.parentElement;
345
345
  for (; l && !(l instanceof HTMLElement && l.shadowRoot); )
346
346
  l = l.parentElement;
347
347
  l && typeof l == "object" && l !== null && "render" in l && typeof l.render == "function" && l.render();
348
348
  }
349
- a.type === "blur" && (e._isDirty = !1);
349
+ a.type === "blur" && (t._isDirty = !1);
350
350
  };
351
- e.addEventListener("input", i), e.addEventListener("change", i), e.addEventListener("keydown", i), e.addEventListener("blur", i);
351
+ t.addEventListener("input", i), t.addEventListener("change", i), t.addEventListener("keydown", i), t.addEventListener("blur", i);
352
352
  }
353
353
  const H = (() => {
354
354
  try {
@@ -358,8 +358,8 @@ const H = (() => {
358
358
  }
359
359
  return typeof window < "u" ? window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" : !1;
360
360
  })();
361
- function dt(e, t = {}) {
362
- const { development: n = H, cache: r = !0, optimize: o = !0 } = t, s = q(e);
361
+ function ht(t, e = {}) {
362
+ const { development: n = H, cache: r = !0, optimize: o = !0 } = e, s = z(t);
363
363
  if (r && T.has(s)) {
364
364
  if (n) {
365
365
  const i = v.get(s) || {
@@ -384,31 +384,31 @@ function dt(e, t = {}) {
384
384
  i.cacheMisses++, v.set(s, i);
385
385
  }
386
386
  try {
387
- const i = V(e, { development: n, optimize: o });
387
+ const i = Y(t, { development: n, optimize: o });
388
388
  return r && T.set(s, i), i;
389
389
  } catch (i) {
390
- return n && (console.error("[Template Compiler] Error compiling template:", i), console.error("[Template Compiler] Template:", e)), {
391
- statics: [e],
390
+ return n && (console.error("[Template Compiler] Error compiling template:", i), console.error("[Template Compiler] Template:", t)), {
391
+ statics: [t],
392
392
  dynamics: [],
393
393
  fragment: null,
394
394
  id: s,
395
395
  hasDynamics: !1,
396
- render: () => e
396
+ render: () => t
397
397
  };
398
398
  }
399
399
  }
400
- function X(e, t) {
400
+ function V(t, e) {
401
401
  if (typeof document > "u")
402
402
  return [0];
403
403
  try {
404
404
  let n = function(a, c = []) {
405
405
  if (a.nodeType === Node.TEXT_NODE) {
406
- if (a.textContent?.includes(t))
406
+ if (a.textContent?.includes(e))
407
407
  return c;
408
408
  } else if (a.nodeType === Node.ELEMENT_NODE) {
409
409
  let l = 0;
410
- for (let u = 0; u < a.childNodes.length; u++) {
411
- const d = a.childNodes[u], f = n(d, [...c, l]);
410
+ for (let d = 0; d < a.childNodes.length; d++) {
411
+ const u = a.childNodes[d], f = n(u, [...c, l]);
412
412
  if (f)
413
413
  return f;
414
414
  l++;
@@ -416,39 +416,39 @@ function X(e, t) {
416
416
  }
417
417
  return null;
418
418
  };
419
- const s = new DOMParser().parseFromString(`<div>${e}</div>`, "text/html").body.firstElementChild;
419
+ const s = new DOMParser().parseFromString(`<div>${t}</div>`, "text/html").body.firstElementChild;
420
420
  return n(s) || [0];
421
421
  } catch (n) {
422
- return H && console.warn("[Template Compiler] Error finding DOM path for placeholder:", t, n), [0];
422
+ return H && console.warn("[Template Compiler] Error finding DOM path for placeholder:", e, n), [0];
423
423
  }
424
424
  }
425
- function V(e, t) {
426
- return new Y(e, t).compile();
425
+ function Y(t, e) {
426
+ return new J(t, e).compile();
427
427
  }
428
- class Y {
428
+ class J {
429
429
  template;
430
430
  options;
431
431
  dynamics = [];
432
432
  statics = [];
433
- constructor(t, n) {
434
- this.template = t, this.options = n;
433
+ constructor(e, n) {
434
+ this.template = e, this.options = n;
435
435
  }
436
436
  compile() {
437
437
  this.parseTemplate();
438
- const t = this.createStaticFragment(), n = q(this.template), r = (o, s) => {
438
+ const e = this.createStaticFragment(), n = z(this.template), r = (o, s) => {
439
439
  let i = "";
440
440
  for (let a = 0; a < this.statics.length; a++)
441
441
  if (i += this.statics[a], a < this.dynamics.length) {
442
442
  let c = this.dynamics[a].getValue(o, s);
443
443
  if (c instanceof Promise)
444
444
  return Promise.all(this.dynamics.map((l) => {
445
- const u = l.getValue(o, s);
446
- return u instanceof Promise ? u : Promise.resolve(u);
445
+ const d = l.getValue(o, s);
446
+ return d instanceof Promise ? d : Promise.resolve(d);
447
447
  })).then((l) => {
448
- let u = "";
449
- for (let d = 0; d < this.statics.length; d++)
450
- u += this.statics[d], d < l.length && (u += l[d]);
451
- return u;
448
+ let d = "";
449
+ for (let u = 0; u < this.statics.length; u++)
450
+ d += this.statics[u], u < l.length && (d += l[u]);
451
+ return d;
452
452
  });
453
453
  i += c;
454
454
  }
@@ -457,24 +457,24 @@ class Y {
457
457
  return {
458
458
  statics: this.statics,
459
459
  dynamics: this.dynamics,
460
- fragment: t,
460
+ fragment: e,
461
461
  id: n,
462
462
  hasDynamics: this.dynamics.length > 0,
463
463
  render: r
464
464
  };
465
465
  }
466
466
  parseTemplate() {
467
- const t = /\{\{([^}]+)\}\}/g;
467
+ const e = /\{\{([^}]+)\}\}/g;
468
468
  let n = 0, r;
469
- for (; (r = t.exec(this.template)) !== null; ) {
469
+ for (; (r = e.exec(this.template)) !== null; ) {
470
470
  const s = this.template.slice(n, r.index);
471
471
  this.statics.push(s);
472
472
  let i = s.match(/([a-zA-Z0-9_-]+)\s*=\s*"?$/), a = i ? i[1] : void 0, c;
473
473
  if (s.endsWith('style="color:'))
474
474
  a = "style", c = "color";
475
475
  else if (a === "style") {
476
- const u = s.match(/style\s*=\s*"?([^:;]+):\s*$/);
477
- u && (c = u[1].trim());
476
+ const d = s.match(/style\s*=\s*"?([^:;]+):\s*$/);
477
+ d && (c = d[1].trim());
478
478
  }
479
479
  const l = r[1].trim();
480
480
  this.analyzeDynamicExpression(l, this.dynamics.length, a, c), n = r.index + r[0].length;
@@ -482,31 +482,31 @@ class Y {
482
482
  const o = this.template.slice(n);
483
483
  this.statics.push(o);
484
484
  }
485
- analyzeDynamicExpression(t, n, r, o) {
485
+ analyzeDynamicExpression(e, n, r, o) {
486
486
  let s = "text", i;
487
- r ? r === "class" ? (s = "class", i = "class") : r === "style" ? (s = "style", i = o || "style") : r === "value" ? (s = "property", i = "value") : (s = "attribute", i = r) : t.includes("class.") ? (s = "class", i = t.split(".")[1]) : t.includes("style.") ? (s = "style", i = t.split(".")[1]) : t.includes("@") ? (s = "event", i = t.split("@")[1]) : t === "class" ? (s = "class", i = "class") : t === "style" ? (s = "style", i = "style") : t === "value" ? (s = "property", i = "value") : t === "title" && (s = "attribute", i = "title");
487
+ r ? r === "class" ? (s = "class", i = "class") : r === "style" ? (s = "style", i = o || "style") : r === "value" ? (s = "property", i = "value") : (s = "attribute", i = r) : e.includes("class.") ? (s = "class", i = e.split(".")[1]) : e.includes("style.") ? (s = "style", i = e.split(".")[1]) : e.includes("@") ? (s = "event", i = e.split("@")[1]) : e === "class" ? (s = "class", i = "class") : e === "style" ? (s = "style", i = "style") : e === "value" ? (s = "property", i = "value") : e === "title" && (s = "attribute", i = "title");
488
488
  const a = `__DYNAMIC_${n}__`, c = this.statics.join(a);
489
- let l = X(c, a);
489
+ let l = V(c, a);
490
490
  this.statics.length === 2 && s !== "text" ? l = [0] : this.statics.length === 2 && l.length === 0 && (l = [0]), this.dynamics.push({
491
491
  path: l,
492
492
  type: s,
493
493
  target: i,
494
- getValue: this.createValueGetter(t)
494
+ getValue: this.createValueGetter(e)
495
495
  });
496
496
  }
497
- createValueGetter(t) {
497
+ createValueGetter(e) {
498
498
  return (n, r) => {
499
499
  try {
500
500
  let o;
501
- if (t && typeof t == "function")
502
- o = t(n);
503
- else if (typeof t == "string" && t.startsWith("state.")) {
504
- const s = t.slice(6);
501
+ if (e && typeof e == "function")
502
+ o = e(n);
503
+ else if (typeof e == "string" && e.startsWith("state.")) {
504
+ const s = e.slice(6);
505
505
  o = n[s];
506
- } else typeof t == "string" && /^[a-zA-Z0-9_$]+$/.test(t) ? o = n[t] : (typeof t == "string" && t.includes("("), o = "");
506
+ } else typeof e == "string" && /^[a-zA-Z0-9_$]+$/.test(e) ? o = n[e] : (typeof e == "string" && e.includes("("), o = "");
507
507
  return o;
508
508
  } catch (o) {
509
- return this.options.development && console.warn(`[Template Compiler] Error evaluating expression: ${t}`, o), "";
509
+ return this.options.development && console.warn(`[Template Compiler] Error evaluating expression: ${e}`, o), "";
510
510
  }
511
511
  };
512
512
  }
@@ -514,25 +514,25 @@ class Y {
514
514
  if (typeof document > "u")
515
515
  return null;
516
516
  try {
517
- const t = this.statics.join("");
518
- if (!t.trim())
517
+ const e = this.statics.join("");
518
+ if (!e.trim())
519
519
  return null;
520
- const r = new DOMParser().parseFromString(t, "text/html"), o = document.createDocumentFragment();
520
+ const r = new DOMParser().parseFromString(e, "text/html"), o = document.createDocumentFragment();
521
521
  for (; r.body.firstChild; )
522
522
  o.appendChild(r.body.firstChild);
523
523
  return o;
524
- } catch (t) {
525
- return this.options.development && console.warn("[Template Compiler] Could not create static fragment:", t), null;
524
+ } catch (e) {
525
+ return this.options.development && console.warn("[Template Compiler] Could not create static fragment:", e), null;
526
526
  }
527
527
  }
528
528
  }
529
- function k(e, t) {
529
+ function L(t, e) {
530
530
  try {
531
- if (t.length === 1 && t[0] === 0 && e instanceof Element)
532
- return e;
533
- let n = e;
534
- for (let r = 0; r < t.length; r++) {
535
- const o = t[r];
531
+ if (e.length === 1 && e[0] === 0 && t instanceof Element)
532
+ return t;
533
+ let n = t;
534
+ for (let r = 0; r < e.length; r++) {
535
+ const o = e[r];
536
536
  if (!n.childNodes || n.childNodes.length <= o)
537
537
  return null;
538
538
  n = n.childNodes[o];
@@ -542,29 +542,29 @@ function k(e, t) {
542
542
  return null;
543
543
  }
544
544
  }
545
- function D(e, t, n) {
545
+ function I(t, e, n) {
546
546
  let r;
547
- return e.fragment && !e.hasDynamics ? r = e.fragment.cloneNode(!0) : r = Q(e, t, n), r;
547
+ return t.fragment && !t.hasDynamics ? r = t.fragment.cloneNode(!0) : r = tt(t, e, n), r;
548
548
  }
549
- function J(e, t, n, r, o) {
550
- if (e.hasDynamics)
551
- for (const s of e.dynamics)
549
+ function Q(t, e, n, r, o) {
550
+ if (t.hasDynamics)
551
+ for (const s of t.dynamics)
552
552
  try {
553
553
  const i = s.getValue(n, r);
554
554
  if (o !== void 0 && s.getValue(o, r) === i)
555
555
  continue;
556
- P(t, s, i);
556
+ q(e, s, i);
557
557
  } catch (i) {
558
558
  console.warn("[Template Compiler] Error applying update:", i);
559
559
  }
560
560
  }
561
- function Q(e, t, n) {
561
+ function tt(t, e, n) {
562
562
  let r = "";
563
- for (let a = 0; a < e.statics.length; a++)
564
- if (r += e.statics[a], a < e.dynamics.length) {
565
- const c = e.dynamics[a];
563
+ for (let a = 0; a < t.statics.length; a++)
564
+ if (r += t.statics[a], a < t.dynamics.length) {
565
+ const c = t.dynamics[a];
566
566
  if (c.type === "text" || c.type === "attribute") {
567
- const l = c.getValue(t, n);
567
+ const l = c.getValue(e, n);
568
568
  r += String(l ?? "");
569
569
  } else (c.type === "property" || c.type === "class" || c.type === "style") && (r += "");
570
570
  }
@@ -573,17 +573,17 @@ function Q(e, t, n) {
573
573
  const s = new DOMParser().parseFromString(r, "text/html"), i = document.createDocumentFragment();
574
574
  for (; s.body.firstChild; )
575
575
  i.appendChild(s.body.firstChild);
576
- for (const a of e.dynamics) {
577
- const c = a.getValue(t, n), l = k(i, a.path);
578
- P(l, a, c);
576
+ for (const a of t.dynamics) {
577
+ const c = a.getValue(e, n), l = L(i, a.path);
578
+ q(l, a, c);
579
579
  }
580
580
  return i;
581
581
  }
582
- function P(e, t, n) {
582
+ function q(t, e, n) {
583
583
  try {
584
- if (t.type === "text") {
584
+ if (e.type === "text") {
585
585
  const o = document.createTreeWalker(
586
- e,
586
+ t,
587
587
  NodeFilter.SHOW_TEXT
588
588
  );
589
589
  let s = !1, i;
@@ -595,117 +595,117 @@ function P(e, t, n) {
595
595
  }
596
596
  }
597
597
  if (s) return;
598
- const a = k(e, t.path);
598
+ const a = L(t, e.path);
599
599
  a && a.nodeType === Node.TEXT_NODE && (a.textContent = n == null ? "" : String(n));
600
600
  return;
601
601
  }
602
- const r = k(e, t.path);
602
+ const r = L(t, e.path);
603
603
  if (!r)
604
604
  return;
605
- switch (t.type) {
605
+ switch (e.type) {
606
606
  case "attribute":
607
- if (r.nodeType === Node.ELEMENT_NODE && t.target) {
607
+ if (r.nodeType === Node.ELEMENT_NODE && e.target) {
608
608
  const o = r;
609
- n == null || n === "" ? o.removeAttribute(t.target) : o.setAttribute(t.target, String(n));
609
+ n == null || n === "" ? o.removeAttribute(e.target) : o.setAttribute(e.target, String(n));
610
610
  }
611
611
  break;
612
612
  case "property":
613
- r.nodeType === Node.ELEMENT_NODE && t.target && (r[t.target] = n ?? "", r.setAttribute(t.target, n == null ? "" : String(n)));
613
+ r.nodeType === Node.ELEMENT_NODE && e.target && (r[e.target] = n ?? "", r.setAttribute(e.target, n == null ? "" : String(n)));
614
614
  break;
615
615
  case "class":
616
- if (r.nodeType === Node.ELEMENT_NODE && t.target) {
616
+ if (r.nodeType === Node.ELEMENT_NODE && e.target) {
617
617
  const o = r;
618
618
  o.className = n == null ? "" : String(n), o.setAttribute("class", n == null ? "" : String(n));
619
619
  }
620
620
  break;
621
621
  case "style":
622
- if (r.nodeType === Node.ELEMENT_NODE && t.target) {
622
+ if (r.nodeType === Node.ELEMENT_NODE && e.target) {
623
623
  const o = r;
624
- o.style[t.target] = n == null ? "" : String(n), o.setAttribute("style", n == null ? `${t.target}:` : `${t.target}:${n}`);
624
+ o.style[e.target] = n == null ? "" : String(n), o.setAttribute("style", n == null ? `${e.target}:` : `${e.target}:${n}`);
625
625
  }
626
626
  break;
627
627
  default:
628
- throw new Error(`Unknown update type: ${t.type}`);
628
+ throw new Error(`Unknown update type: ${e.type}`);
629
629
  }
630
630
  } catch (r) {
631
- (typeof globalThis < "u" ? globalThis.isDevelopment : H) && console.warn("[Template Compiler] Error applying update:", t, r);
631
+ (typeof globalThis < "u" ? globalThis.isDevelopment : H) && console.warn("[Template Compiler] Error applying update:", e, r);
632
632
  }
633
633
  }
634
634
  const T = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
635
- function q(e) {
636
- let t = 0;
637
- for (let n = 0; n < e.length; n++) {
638
- const r = e.charCodeAt(n);
639
- t = (t << 5) - t + r, t = t & t;
635
+ function z(t) {
636
+ let e = 0;
637
+ for (let n = 0; n < t.length; n++) {
638
+ const r = t.charCodeAt(n);
639
+ e = (e << 5) - e + r, e = e & e;
640
640
  }
641
- return `tpl_${Math.abs(t).toString(36)}`;
641
+ return `tpl_${Math.abs(e).toString(36)}`;
642
642
  }
643
- function I(e, t, n, r, o) {
644
- return r && o ? `${t}.${e}[${n}]:${r}:${o}` : r ? `${t}.${e}[${n}]:${r}` : `${t}.${e}[${n}]`;
643
+ function N(t, e, n, r, o) {
644
+ return r && o ? `${e}.${t}[${n}]:${r}:${o}` : r ? `${e}.${t}[${n}]:${r}` : `${e}.${t}[${n}]`;
645
645
  }
646
- function N(e, t, n) {
647
- if (!(!e || !(e instanceof Element)) && e.contains(n) && n.parentNode === e)
646
+ function P(t, e, n) {
647
+ if (!(!t || !(t instanceof Element)) && t.contains(n) && n.parentNode === t)
648
648
  try {
649
- e.replaceChild(t, n);
649
+ t.replaceChild(e, n);
650
650
  } catch (r) {
651
651
  console.error("[VDOM] safeReplaceChild: error replacing child", r, {
652
- parent: e,
653
- newChild: t,
652
+ parent: t,
653
+ newChild: e,
654
654
  oldChild: n,
655
- parentHTML: e.outerHTML,
656
- newChildHTML: t.outerHTML,
655
+ parentHTML: t.outerHTML,
656
+ newChildHTML: e.outerHTML,
657
657
  oldChildHTML: n.outerHTML
658
658
  });
659
659
  }
660
660
  }
661
- function g(e) {
662
- if (e.type === "#whitespace")
661
+ function g(t) {
662
+ if (t.type === "#whitespace")
663
663
  return null;
664
- if (e.type === "#text") {
665
- const n = document.createTextNode(e.props.nodeValue ?? "");
666
- return e.dom = n, n;
667
- }
668
- const t = document.createElement(e.type);
669
- for (const [n, r] of Object.entries(e.props))
670
- n === "value" && t instanceof HTMLInputElement ? t.type === "radio" ? t.setAttribute("value", r) : (t.type, t.value = r, t.setAttribute("value", r)) : t.setAttribute(n, r);
671
- e.dom = t;
672
- for (const n of e.children) {
664
+ if (t.type === "#text") {
665
+ const n = document.createTextNode(t.props.nodeValue ?? "");
666
+ return t.dom = n, n;
667
+ }
668
+ const e = document.createElement(t.type);
669
+ for (const [n, r] of Object.entries(t.props))
670
+ n === "value" && e instanceof HTMLInputElement ? e.type === "radio" ? e.setAttribute("value", r) : (e.type, e.value = r, e.setAttribute("value", r)) : e.setAttribute(n, r);
671
+ t.dom = e;
672
+ for (const n of t.children) {
673
673
  const r = g(n);
674
- r && t.appendChild(r);
674
+ r && e.appendChild(r);
675
675
  }
676
- return t;
676
+ return e;
677
677
  }
678
- function tt(e) {
679
- const t = document.createElement("template");
680
- t.innerHTML = e.trim();
681
- const n = Array.from(t.content.childNodes);
682
- return n.length === 1 ? L(n[0]) : {
678
+ function et(t) {
679
+ const e = document.createElement("template");
680
+ e.innerHTML = t.trim();
681
+ const n = Array.from(e.content.childNodes);
682
+ return n.length === 1 ? R(n[0]) : {
683
683
  type: "#fragment",
684
684
  key: void 0,
685
685
  props: {},
686
- children: n.map((o, s) => L(o, "#fragment", s)),
686
+ children: n.map((o, s) => R(o, "#fragment", s)),
687
687
  dom: void 0
688
688
  };
689
689
  }
690
- function L(e, t = "", n = 0) {
691
- if (!e)
690
+ function R(t, e = "", n = 0) {
691
+ if (!t)
692
692
  return { type: "#unknown", key: void 0, props: {}, children: [], dom: void 0 };
693
- if (e.nodeType === Node.TEXT_NODE)
694
- return !e.nodeValue || /^\s*$/.test(e.nodeValue) ? { type: "#whitespace", key: void 0, props: {}, children: [], dom: void 0 } : { type: "#text", key: I("#text", t, n), props: { nodeValue: e.nodeValue }, children: [], dom: e };
695
- if (e.nodeType === Node.ELEMENT_NODE) {
696
- const r = e, o = {};
693
+ if (t.nodeType === Node.TEXT_NODE)
694
+ return !t.nodeValue || /^\s*$/.test(t.nodeValue) ? { type: "#whitespace", key: void 0, props: {}, children: [], dom: void 0 } : { type: "#text", key: N("#text", e, n), props: { nodeValue: t.nodeValue }, children: [], dom: t };
695
+ if (t.nodeType === Node.ELEMENT_NODE) {
696
+ const r = t, o = {};
697
697
  Array.from(r.attributes).forEach((l) => {
698
698
  o[l.name] = l.value;
699
699
  });
700
700
  const s = r.tagName.toLowerCase();
701
701
  let i;
702
702
  if ((s === "input" || s === "select" || s === "textarea") && r.hasAttribute("data-model")) {
703
- const l = r.getAttribute("data-model"), u = r.getAttribute("type") ?? "";
704
- i = `${s}:${l}:${u}`, o["data-uid"] = i, r.setAttribute("data-uid", i);
705
- let d = r.getAttribute("value"), f = r.getAttribute("checked");
706
- d && (o.value = d), f && (o.checked = f);
707
- } else s === "input" || s === "textarea" || s === "select" || r.hasAttribute("contenteditable") ? (i = `${s}:${t}:${n}`, o["data-uid"] = i, r.setAttribute("data-uid", i)) : (i = I(s, t, n), s === "li" && (o["data-uid"] = i, r.setAttribute("data-uid", i)));
708
- const a = Array.from(r.childNodes).map((l, u) => L(l, i, u));
703
+ const l = r.getAttribute("data-model"), d = r.getAttribute("type") ?? "";
704
+ i = `${s}:${l}:${d}`, o["data-uid"] = i, r.setAttribute("data-uid", i);
705
+ let u = r.getAttribute("value"), f = r.getAttribute("checked");
706
+ u && (o.value = u), f && (o.checked = f);
707
+ } else s === "input" || s === "textarea" || s === "select" || r.hasAttribute("contenteditable") ? (i = `${s}:${e}:${n}`, o["data-uid"] = i, r.setAttribute("data-uid", i)) : (i = N(s, e, n), s === "li" && (o["data-uid"] = i, r.setAttribute("data-uid", i)));
708
+ const a = Array.from(r.childNodes).map((l, d) => R(l, i, d));
709
709
  return {
710
710
  type: s,
711
711
  key: i,
@@ -716,23 +716,23 @@ function L(e, t = "", n = 0) {
716
716
  }
717
717
  return { type: "#unknown", key: void 0, props: {}, children: [], dom: void 0 };
718
718
  }
719
- function R(e, t, n) {
720
- if (!t || !n) return;
719
+ function M(t, e, n) {
720
+ if (!e || !n) return;
721
721
  function r(c) {
722
722
  return !!c && c.type !== "#whitespace" && !(c.type === "#text" && (!c.props?.nodeValue || /^\s*$/.test(c.props.nodeValue)));
723
723
  }
724
- const o = Array.isArray(t.children) ? t.children.filter(r) : [], s = Array.isArray(n.children) ? n.children.filter(r) : [], i = n.type === "input" || n.type === "select" || n.type === "textarea";
725
- if (t.type !== n.type || t.key !== n.key) {
724
+ const o = Array.isArray(e.children) ? e.children.filter(r) : [], s = Array.isArray(n.children) ? n.children.filter(r) : [], i = n.type === "input" || n.type === "select" || n.type === "textarea";
725
+ if (e.type !== n.type || e.key !== n.key) {
726
726
  const c = g(n);
727
- if (c instanceof Node && t.dom instanceof Node && e.contains(t.dom)) {
728
- if (N(e, c, t.dom), i && n.props && e.firstChild instanceof HTMLInputElement) {
729
- const l = e.firstChild;
727
+ if (c instanceof Node && e.dom instanceof Node && t.contains(e.dom)) {
728
+ if (P(t, c, e.dom), i && n.props && t.firstChild instanceof HTMLInputElement) {
729
+ const l = t.firstChild;
730
730
  l.type === "radio" || l.type, l.value = n.props.value, l.setAttribute("value", n.props.value), "checked" in n.props && (l.checked = n.props.checked === !0 || n.props.checked === "true");
731
731
  }
732
732
  } else if (c instanceof Node)
733
733
  if (c) {
734
- if (e.appendChild(c), n.dom = c, i && n.props && e.firstChild instanceof HTMLInputElement) {
735
- const l = e.firstChild;
734
+ if (t.appendChild(c), n.dom = c, i && n.props && t.firstChild instanceof HTMLInputElement) {
735
+ const l = t.firstChild;
736
736
  l.type === "radio" ? l.setAttribute("value", n.props.value) : (l.type, l.value = n.props.value, l.setAttribute("value", n.props.value)), "checked" in n.props && (l.checked = n.props.checked === !0 || n.props.checked === "true");
737
737
  }
738
738
  } else
@@ -741,41 +741,41 @@ function R(e, t, n) {
741
741
  n.dom = void 0;
742
742
  return;
743
743
  }
744
- if (i && t.dom instanceof HTMLElement && n.props) {
744
+ if (i && e.dom instanceof HTMLElement && n.props) {
745
745
  for (const [c, l] of Object.entries(n.props))
746
- if (c === "value" && e.firstChild instanceof HTMLInputElement)
747
- e.firstChild.value = l;
748
- else if (c === "checked" && e.firstChild instanceof HTMLInputElement)
749
- e.firstChild.checked = l === !0 || l === "true";
750
- else if (c in t.dom)
746
+ if (c === "value" && t.firstChild instanceof HTMLInputElement)
747
+ t.firstChild.value = l;
748
+ else if (c === "checked" && t.firstChild instanceof HTMLInputElement)
749
+ t.firstChild.checked = l === !0 || l === "true";
750
+ else if (c in e.dom)
751
751
  try {
752
- t.dom[c] = l;
752
+ e.dom[c] = l;
753
753
  } catch {
754
754
  }
755
755
  else
756
- t.dom.setAttribute(c, l);
756
+ e.dom.setAttribute(c, l);
757
757
  for (let c = n.children.length; c < o.length; c++)
758
- o[c] && o[c].dom && t.dom && t.dom.contains(o[c].dom) && t.dom.removeChild(o[c].dom);
758
+ o[c] && o[c].dom && e.dom && e.dom.contains(o[c].dom) && e.dom.removeChild(o[c].dom);
759
759
  return;
760
760
  }
761
- const a = t.dom;
761
+ const a = e.dom;
762
762
  if (a && a instanceof Element && n.props) {
763
763
  const c = a.tagName.toLowerCase() === "input" ? a.getAttribute("type") : void 0, l = a.tagName.includes("-");
764
- for (const [u, d] of Object.entries(n.props))
765
- if (!(c === "radio" && u === "value")) {
766
- if (c === "checkbox" && u === "value") {
767
- a.setAttribute("value", d);
764
+ for (const [d, u] of Object.entries(n.props))
765
+ if (!(c === "radio" && d === "value")) {
766
+ if (c === "checkbox" && d === "value") {
767
+ a.setAttribute("value", u);
768
768
  continue;
769
769
  }
770
- a.setAttribute(u, d);
770
+ a.setAttribute(d, u);
771
771
  }
772
772
  if (l)
773
- for (const [u, d] of Object.entries(n.props))
774
- a.setAttribute(u, d);
775
- for (const u of Array.from(a.attributes).map((d) => d.name))
776
- if (!(u in n.props)) {
777
- if (c === "radio" && u === "value" || c === "checkbox" && u === "value") continue;
778
- a.removeAttribute(u);
773
+ for (const [d, u] of Object.entries(n.props))
774
+ a.setAttribute(d, u);
775
+ for (const d of Array.from(a.attributes).map((u) => u.name))
776
+ if (!(d in n.props)) {
777
+ if (c === "radio" && d === "value" || c === "checkbox" && d === "value") continue;
778
+ a.removeAttribute(d);
779
779
  }
780
780
  }
781
781
  if (n.type === "#text") {
@@ -783,7 +783,7 @@ function R(e, t, n) {
783
783
  a.nodeValue !== n.props.nodeValue && (a.nodeValue = n.props.nodeValue), n.dom = a;
784
784
  else {
785
785
  const c = document.createTextNode(n.props.nodeValue ?? "");
786
- a && e.contains(a) && a.parentNode === e ? N(e, c, a) : e.appendChild(c), n.dom = c;
786
+ a && t.contains(a) && a.parentNode === t ? P(t, c, a) : t.appendChild(c), n.dom = c;
787
787
  }
788
788
  return;
789
789
  }
@@ -791,13 +791,13 @@ function R(e, t, n) {
791
791
  const c = /* @__PURE__ */ new Map();
792
792
  o.forEach((f) => f.key && c.set(f.key, f));
793
793
  const l = new Set(s.map((f) => f.key));
794
- let u = [];
794
+ let d = [];
795
795
  for (let f = 0; f < s.length; f++) {
796
796
  const h = s[f], m = h.key ? c.get(h.key) : o[f];
797
797
  let p;
798
798
  const C = h.type === "input" || h.type === "select" || h.type === "textarea";
799
799
  if (m && m.dom && (!C || m.type === h.type && m.key === h.key))
800
- R(a, m, h), p = m.dom;
800
+ M(a, m, h), p = m.dom;
801
801
  else {
802
802
  const E = g(h);
803
803
  if (p = E instanceof Node ? E : void 0, p) {
@@ -813,29 +813,29 @@ function R(e, t, n) {
813
813
  a.insertBefore(p, a.childNodes[f] || null);
814
814
  }
815
815
  }
816
- h.dom = p, p && u.push(p);
816
+ h.dom = p, p && d.push(p);
817
817
  }
818
818
  for (o.forEach((f) => {
819
819
  !l.has(f.key) && f.dom && a.contains(f.dom) && a.removeChild(f.dom);
820
820
  }); a.childNodes.length > s.length; )
821
821
  a.removeChild(a.lastChild);
822
- for (let f = 0; f < u.length; f++)
823
- if (a.childNodes[f] !== u[f]) {
824
- if ((u[f] instanceof Element || u[f] instanceof Node) && u[f].contains(a))
822
+ for (let f = 0; f < d.length; f++)
823
+ if (a.childNodes[f] !== d[f]) {
824
+ if ((d[f] instanceof Element || d[f] instanceof Node) && d[f].contains(a))
825
825
  throw new Error("VDOM patch error: Attempted to insert a parent into its own child");
826
- a.insertBefore(u[f], a.childNodes[f] || null);
826
+ a.insertBefore(d[f], a.childNodes[f] || null);
827
827
  }
828
828
  n.dom = a;
829
- const d = new Set(s.map((f) => f.key));
829
+ const u = new Set(s.map((f) => f.key));
830
830
  Array.from(a.childNodes).forEach((f, h) => {
831
831
  const m = f.getAttribute?.("data-uid");
832
- (m && !d.has(m) || h >= s.length) && a.removeChild(f);
832
+ (m && !u.has(m) || h >= s.length) && a.removeChild(f);
833
833
  });
834
834
  }
835
835
  }
836
- const et = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, b = (e, t) => {
837
- for (const n of e) {
838
- const r = [], o = n.path.replace(/:[^/]+/g, (a) => (r.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${o}$`), i = t.match(s);
836
+ const nt = (t) => t ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(t)) : {}, b = (t, e) => {
837
+ for (const n of t) {
838
+ const r = [], o = n.path.replace(/:[^/]+/g, (a) => (r.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${o}$`), i = e.match(s);
839
839
  if (i) {
840
840
  const a = {};
841
841
  return r.forEach((c, l) => {
@@ -844,34 +844,47 @@ const et = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new
844
844
  }
845
845
  }
846
846
  return { route: null, params: {} };
847
- };
848
- function nt(e) {
849
- const { routes: t, base: n = "" } = e;
847
+ }, S = {};
848
+ async function rt(t) {
849
+ if (t.component) return t.component;
850
+ if (t.load) {
851
+ if (S[t.path]) return S[t.path];
852
+ try {
853
+ const e = await t.load();
854
+ return S[t.path] = e.default, e.default;
855
+ } catch {
856
+ throw new Error(`Failed to load component for route: ${t.path}`);
857
+ }
858
+ }
859
+ throw new Error(`No component or loader defined for route: ${t.path}`);
860
+ }
861
+ function st(t) {
862
+ const { routes: e, base: n = "" } = t;
850
863
  let r, o, s, i, a, c, l;
851
864
  if (typeof window < "u" && typeof document < "u") {
852
865
  r = () => {
853
- const d = new URL(window.location.href), f = d.pathname.replace(n, "") || "/", h = et(d.search);
866
+ const u = new URL(window.location.href), f = u.pathname.replace(n, "") || "/", h = nt(u.search);
854
867
  return { path: f, query: h };
855
868
  }, o = r();
856
- const u = b(t, o.path);
857
- s = $({
869
+ const d = b(e, o.path);
870
+ s = j({
858
871
  path: o.path,
859
- params: u.params,
872
+ params: d.params,
860
873
  query: o.query
861
874
  }), i = () => {
862
- const d = r(), f = b(t, d.path), h = s.getState();
863
- h.path = d.path, h.params = f.params, h.query = d.query;
864
- }, window.addEventListener("popstate", i), a = (d) => {
865
- window.history.pushState({}, "", n + d), i();
866
- }, c = (d) => {
867
- window.history.replaceState({}, "", n + d), i();
875
+ const u = r(), f = b(e, u.path), h = s.getState();
876
+ h.path = u.path, h.params = f.params, h.query = u.query;
877
+ }, window.addEventListener("popstate", i), a = (u) => {
878
+ window.history.pushState({}, "", n + u), i();
879
+ }, c = (u) => {
880
+ window.history.replaceState({}, "", n + u), i();
868
881
  }, l = () => window.history.back();
869
882
  } else {
870
883
  r = () => ({ path: "/", query: {} }), o = r();
871
- const u = b(t, o.path);
872
- s = $({
884
+ const d = b(e, o.path);
885
+ s = j({
873
886
  path: o.path,
874
- params: u.params,
887
+ params: d.params,
875
888
  query: o.query
876
889
  }), i = () => {
877
890
  }, a = () => {
@@ -885,99 +898,100 @@ function nt(e) {
885
898
  replace: c,
886
899
  back: l,
887
900
  subscribe: s.subscribe,
888
- matchRoute: (u) => b(t, u),
889
- getCurrent: () => s.getState()
901
+ matchRoute: (d) => b(e, d),
902
+ getCurrent: () => s.getState(),
903
+ resolveRouteComponent: rt
890
904
  };
891
905
  }
892
- function ft(e) {
893
- const t = nt(e);
894
- return typeof window < "u" && (window.__routerInstance = t), t;
906
+ function pt(t) {
907
+ const e = st(t);
908
+ return typeof window < "u" && (window.__routerInstance = e), e;
895
909
  }
896
- function ht(e, t) {
897
- return b(e, t);
910
+ function mt(t, e) {
911
+ return b(t, e);
898
912
  }
899
- function M(e, t) {
900
- const n = [], r = t ? Object.keys(t) : [], o = { ...e };
913
+ function $(t, e) {
914
+ const n = [], r = e ? Object.keys(e) : [], o = { ...t };
901
915
  let s = null;
902
- function i(u) {
903
- return n.push(u), () => {
904
- const d = n.indexOf(u);
905
- d !== -1 && n.splice(d, 1);
916
+ function i(d) {
917
+ return n.push(d), () => {
918
+ const u = n.indexOf(d);
919
+ u !== -1 && n.splice(u, 1);
906
920
  };
907
921
  }
908
- function a(u) {
909
- Object.assign(s, u), n.forEach((d) => d(s));
922
+ function a(d) {
923
+ Object.assign(s, d), n.forEach((u) => u(s));
910
924
  }
911
925
  const c = /* @__PURE__ */ new WeakMap();
912
- function l(u) {
913
- if (c.has(u)) return c.get(u);
914
- const d = new Proxy(u, {
926
+ function l(d) {
927
+ if (c.has(d)) return c.get(d);
928
+ const u = new Proxy(d, {
915
929
  get(f, h, m) {
916
930
  if (h === "subscribe") return i;
917
931
  if (h === "set") return a;
918
- if (t && r.includes(h))
919
- return t[h](s);
932
+ if (e && r.includes(h))
933
+ return e[h](s);
920
934
  const p = Reflect.get(f, h, m);
921
935
  return typeof p == "object" && p !== null ? l(p) : p;
922
936
  },
923
937
  set(f, h, m, p) {
924
- if (t && r.includes(h))
938
+ if (e && r.includes(h))
925
939
  return !1;
926
940
  const C = f[h], E = Reflect.set(f, h, m, p);
927
- return C !== m && n.forEach((W) => W(s)), E;
941
+ return C !== m && n.forEach((F) => F(s)), E;
928
942
  },
929
943
  deleteProperty(f, h) {
930
- if (t && r.includes(h))
944
+ if (e && r.includes(h))
931
945
  return !1;
932
946
  const m = Reflect.deleteProperty(f, h);
933
947
  return n.forEach((p) => p(s)), m;
934
948
  }
935
949
  });
936
- return c.set(u, d), d;
950
+ return c.set(d, u), u;
937
951
  }
938
952
  return s = l(o), s;
939
953
  }
940
954
  const _ = [];
941
- function pt(e) {
942
- _.push(e);
955
+ function yt(t) {
956
+ _.push(t);
943
957
  }
944
- function A(e, t = /* @__PURE__ */ new WeakSet()) {
945
- if (e === null || typeof e != "object" || t.has(e)) return e;
946
- if (t.add(e), Array.isArray(e)) return e.map((o) => A(o, t));
947
- Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null && Object.setPrototypeOf(e, null);
958
+ function A(t, e = /* @__PURE__ */ new WeakSet()) {
959
+ if (t === null || typeof t != "object" || e.has(t)) return t;
960
+ if (e.add(t), Array.isArray(t)) return t.map((o) => A(o, e));
961
+ Object.getPrototypeOf(t) !== Object.prototype && Object.getPrototypeOf(t) !== null && Object.setPrototypeOf(t, null);
948
962
  const n = ["__proto__", "constructor", "prototype"], r = /* @__PURE__ */ Object.create(null);
949
- for (const o of Object.keys(e))
950
- n.includes(o) || (r[o] = A(e[o], t));
963
+ for (const o of Object.keys(t))
964
+ n.includes(o) || (r[o] = A(t[o], e));
951
965
  return r;
952
966
  }
953
- function S(e) {
954
- return !!e && typeof e.then == "function";
967
+ function O(t) {
968
+ return !!t && typeof t.then == "function";
955
969
  }
956
- let z;
957
- typeof HTMLElement < "u" && (z = class extends HTMLElement {
970
+ let W;
971
+ typeof HTMLElement < "u" && (W = class extends HTMLElement {
958
972
  /**
959
973
  * Syncs whitelisted state properties to attributes after render.
960
974
  * Only keys listed in config.reflect are reflected.
961
975
  */
962
976
  syncStateToAttributes() {
963
977
  if (!this.stateObj || !this.config?.reflect || !Array.isArray(this.config.reflect)) return;
964
- const e = ["__proto__", "constructor", "prototype"];
965
- this.config.reflect.forEach((t) => {
966
- if (e.includes(t)) {
967
- this.removeAttribute(t);
978
+ const t = ["__proto__", "constructor", "prototype"];
979
+ this.config.reflect.forEach((e) => {
980
+ if (t.includes(e)) {
981
+ this.removeAttribute(e);
968
982
  return;
969
983
  }
970
- const n = this.stateObj[t];
971
- ["string", "number", "boolean"].includes(typeof n) ? n == null ? this.removeAttribute(t) : this.setAttribute(t, String(n)) : this.removeAttribute(t);
984
+ const n = this.stateObj[e];
985
+ ["string", "number", "boolean"].includes(typeof n) ? n == null ? this.removeAttribute(e) : this.setAttribute(e, String(n)) : this.removeAttribute(e);
972
986
  });
973
987
  }
974
988
  /**
975
989
  * Allows updating the template function at runtime and triggers a re-render.
976
990
  * @param newTemplate - New template function or string
977
991
  */
978
- setTemplate(e) {
979
- const t = this.config;
980
- typeof e == "function" ? t.template = e : t.template = () => e, this.render();
992
+ setTemplate(t) {
993
+ const e = this.config;
994
+ typeof t == "function" ? e.template = t : e.template = () => t, this.render();
981
995
  }
982
996
  _hasError = !1;
983
997
  _mountedCalled = !1;
@@ -989,47 +1003,47 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
989
1003
  /**
990
1004
  * Override removeEventListener to support auto-wired config handler removal
991
1005
  */
992
- removeEventListener(e, t, n) {
993
- super.removeEventListener(e, t, n), this._autoWiredHandlers[e] && (this._autoWiredHandlers[e] = this._autoWiredHandlers[e].filter((r) => r === t ? (super.removeEventListener(e, r, n), !1) : !0), this._autoWiredHandlers[e].length === 0 && delete this._autoWiredHandlers[e]);
1006
+ removeEventListener(t, e, n) {
1007
+ super.removeEventListener(t, e, n), this._autoWiredHandlers[t] && (this._autoWiredHandlers[t] = this._autoWiredHandlers[t].filter((r) => r === e ? (super.removeEventListener(t, r, n), !1) : !0), this._autoWiredHandlers[t].length === 0 && delete this._autoWiredHandlers[t]);
994
1008
  }
995
1009
  /**
996
1010
  * observedAttributes automatically returns all primitive keys from static state.
997
1011
  * This enables automatic attribute observation for all primitive state properties.
998
1012
  */
999
1013
  static get observedAttributes() {
1000
- const e = this.stateObj || {};
1001
- return Object.keys(e).filter(
1002
- (t) => ["string", "number", "boolean"].includes(typeof e[t])
1014
+ const t = this.stateObj || {};
1015
+ return Object.keys(t).filter(
1016
+ (e) => ["string", "number", "boolean"].includes(typeof t[e])
1003
1017
  );
1004
1018
  }
1005
1019
  /**
1006
1020
  * Called when an observed attribute changes. Syncs attribute to state and triggers render.
1007
1021
  */
1008
- attributeChangedCallback(e, t, n) {
1009
- if (!(e === "__proto__" || e === "constructor" || e === "prototype") && this.stateObj && e in this.stateObj) {
1010
- const r = typeof this.config?.state?.[e];
1022
+ attributeChangedCallback(t, e, n) {
1023
+ if (!(t === "__proto__" || t === "constructor" || t === "prototype") && this.stateObj && t in this.stateObj) {
1024
+ const r = typeof this.config?.state?.[t];
1011
1025
  let o = n;
1012
1026
  if (n === null)
1013
1027
  o = void 0;
1014
1028
  else if (r === "number")
1015
1029
  if (o === void 0 || o === "")
1016
- o = this.config?.state?.[e];
1030
+ o = this.config?.state?.[t];
1017
1031
  else {
1018
1032
  const s = Number(o);
1019
- o = isNaN(s) ? this.config?.state?.[e] : s;
1033
+ o = isNaN(s) ? this.config?.state?.[t] : s;
1020
1034
  }
1021
1035
  else r === "boolean" && (o = o === "true");
1022
- o = A(o), this.stateObj[e] !== o && (this.config?.debug && console.log("[runtime] state update:", { name: e, value: o }), this.stateObj[e] = o, this.render());
1036
+ o = A(o), this.stateObj[t] !== o && (this.config?.debug && console.log("[runtime] state update:", { name: t, value: o }), this.stateObj[t] = o, this.render());
1023
1037
  }
1024
1038
  }
1025
1039
  /**
1026
1040
  * Force sync all controlled input values and event listeners after VDOM patching.
1027
1041
  */
1028
1042
  forceSyncControlledInputs() {
1029
- this.shadowRoot && (this.shadowRoot.querySelectorAll("input[data-model]").forEach((e) => {
1030
- const t = e.getAttribute("data-model");
1031
- if (!t || !this.stateObj || typeof this.stateObj[t] > "u") return;
1032
- const n = e, r = String(this.stateObj[t]), o = document.activeElement === n;
1043
+ this.shadowRoot && (this.shadowRoot.querySelectorAll("input[data-model]").forEach((t) => {
1044
+ const e = t.getAttribute("data-model");
1045
+ if (!e || !this.stateObj || typeof this.stateObj[e] > "u") return;
1046
+ const n = t, r = String(this.stateObj[e]), o = document.activeElement === n;
1033
1047
  n._hasDirtyListener || (n.addEventListener("input", () => {
1034
1048
  n._isDirty = !0;
1035
1049
  }), n.addEventListener("blur", () => {
@@ -1043,18 +1057,18 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1043
1057
  * Sync all controlled inputs and event listeners after render
1044
1058
  */
1045
1059
  syncControlledInputsAndEvents() {
1046
- this.shadowRoot && (this.shadowRoot.querySelectorAll('input[type="radio"][data-model]').forEach((e) => {
1047
- const t = e.getAttribute("data-model");
1048
- if (!t || !this.stateObj || typeof this.stateObj[t] > "u")
1060
+ this.shadowRoot && (this.shadowRoot.querySelectorAll('input[type="radio"][data-model]').forEach((t) => {
1061
+ const e = t.getAttribute("data-model");
1062
+ if (!e || !this.stateObj || typeof this.stateObj[e] > "u")
1049
1063
  return;
1050
- const n = e, r = String(this.stateObj[t]);
1064
+ const n = t, r = String(this.stateObj[e]);
1051
1065
  n.checked = n.value === r;
1052
- }), this.shadowRoot.querySelectorAll("input[data-model]").forEach((e) => {
1053
- const t = e.getAttribute("data-model");
1054
- if (!t || !this.stateObj || typeof this.stateObj[t] > "u") return;
1055
- const n = e, r = String(this.stateObj[t]);
1066
+ }), this.shadowRoot.querySelectorAll("input[data-model]").forEach((t) => {
1067
+ const e = t.getAttribute("data-model");
1068
+ if (!e || !this.stateObj || typeof this.stateObj[e] > "u") return;
1069
+ const n = t, r = String(this.stateObj[e]);
1056
1070
  if (n.type === "checkbox") {
1057
- const o = this.stateObj[t];
1071
+ const o = this.stateObj[e];
1058
1072
  if (Array.isArray(o))
1059
1073
  n.checked = o.includes(n.value);
1060
1074
  else {
@@ -1062,42 +1076,42 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1062
1076
  s !== null || i !== null ? String(o) === s ? n.checked = !0 : String(o) === i ? n.checked = !1 : o === !0 ? n.checked = !0 : n.checked = !1 : n.checked = o === !0 || o === "true" || o === 1;
1063
1077
  }
1064
1078
  } else n.type === "radio" || (n.value = r);
1065
- }), this.shadowRoot.querySelectorAll("textarea[data-model]").forEach((e) => {
1066
- const t = e.getAttribute("data-model");
1067
- !t || !this.stateObj || typeof this.stateObj[t] > "u" || (e.value = String(this.stateObj[t]));
1068
- }), this.shadowRoot.querySelectorAll("select[data-model]").forEach((e) => {
1069
- const t = e.getAttribute("data-model");
1070
- !t || !this.stateObj || typeof this.stateObj[t] > "u" || (e.value = String(this.stateObj[t]));
1079
+ }), this.shadowRoot.querySelectorAll("textarea[data-model]").forEach((t) => {
1080
+ const e = t.getAttribute("data-model");
1081
+ !e || !this.stateObj || typeof this.stateObj[e] > "u" || (t.value = String(this.stateObj[e]));
1082
+ }), this.shadowRoot.querySelectorAll("select[data-model]").forEach((t) => {
1083
+ const e = t.getAttribute("data-model");
1084
+ !e || !this.stateObj || typeof this.stateObj[e] > "u" || (t.value = String(this.stateObj[e]));
1071
1085
  }));
1072
1086
  }
1073
1087
  /**
1074
1088
  * Attach event listeners for input[data-bind] after VDOM patching
1075
1089
  */
1076
1090
  attachListItemModelListeners() {
1077
- this.shadowRoot && this.shadowRoot.querySelectorAll("input[data-bind]").forEach((e) => {
1078
- const t = e.getAttribute("data-bind");
1079
- if (!t) return;
1080
- e._listItemModelListener && (e.removeEventListener("input", e._listItemModelListener), e.removeEventListener("change", e._listItemModelListener), delete e._listItemModelListener);
1081
- const n = t.match(/^([a-zA-Z0-9_]+)\[(\d+)\]\.([a-zA-Z0-9_]+)$/);
1091
+ this.shadowRoot && this.shadowRoot.querySelectorAll("input[data-bind]").forEach((t) => {
1092
+ const e = t.getAttribute("data-bind");
1093
+ if (!e) return;
1094
+ t._listItemModelListener && (t.removeEventListener("input", t._listItemModelListener), t.removeEventListener("change", t._listItemModelListener), delete t._listItemModelListener);
1095
+ const n = e.match(/^([a-zA-Z0-9_]+)\[(\d+)\]\.([a-zA-Z0-9_]+)$/);
1082
1096
  if (n) {
1083
1097
  const [, o, s, i] = n, a = parseInt(s, 10), c = this.stateObj[o];
1084
- e instanceof HTMLInputElement && e.type === "checkbox" && (e.checked = !!(Array.isArray(c) && c[a] && c[a][i]));
1085
- const l = (u) => {
1086
- !Array.isArray(c) || !c[a] || (e instanceof HTMLInputElement && e.type === "checkbox" ? c[a][i] = e.checked : c[a][i] = e.value);
1098
+ t instanceof HTMLInputElement && t.type === "checkbox" && (t.checked = !!(Array.isArray(c) && c[a] && c[a][i]));
1099
+ const l = (d) => {
1100
+ !Array.isArray(c) || !c[a] || (t instanceof HTMLInputElement && t.type === "checkbox" ? c[a][i] = t.checked : c[a][i] = t.value);
1087
1101
  };
1088
- e.addEventListener("input", l), e.addEventListener("change", l), e._listItemModelListener = l;
1102
+ t.addEventListener("input", l), t.addEventListener("change", l), t._listItemModelListener = l;
1089
1103
  return;
1090
1104
  }
1091
- const r = t.match(/^([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)((?:\|[a-zA-Z0-9_]+)*)$/);
1105
+ const r = e.match(/^([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)((?:\|[a-zA-Z0-9_]+)*)$/);
1092
1106
  if (r) {
1093
- const [, o, s, i] = r, a = this.stateObj[o], c = i ? i.split("|").map((u) => u.trim()).filter(Boolean) : [];
1094
- e instanceof HTMLInputElement && e.type === "checkbox" ? e.checked = !!(a && a[s]) : e instanceof HTMLInputElement && (e.value = a ? String(a[s] ?? "") : "");
1095
- const l = (u) => {
1107
+ const [, o, s, i] = r, a = this.stateObj[o], c = i ? i.split("|").map((d) => d.trim()).filter(Boolean) : [];
1108
+ t instanceof HTMLInputElement && t.type === "checkbox" ? t.checked = !!(a && a[s]) : t instanceof HTMLInputElement && (t.value = a ? String(a[s] ?? "") : "");
1109
+ const l = (d) => {
1096
1110
  if (!a) return;
1097
- let d;
1098
- e instanceof HTMLInputElement && e.type === "checkbox" ? d = e.checked : (d = e.value, c.includes("number") && (d = Number(d)), c.includes("trim") && typeof d == "string" && (d = d.trim())), a[s] = d;
1111
+ let u;
1112
+ t instanceof HTMLInputElement && t.type === "checkbox" ? u = t.checked : (u = t.value, c.includes("number") && (u = Number(u)), c.includes("trim") && typeof u == "string" && (u = u.trim())), a[s] = u;
1099
1113
  };
1100
- e.addEventListener("input", l), e.addEventListener("change", l), e._listItemModelListener = l;
1114
+ t.addEventListener("input", l), t.addEventListener("change", l), t._listItemModelListener = l;
1101
1115
  }
1102
1116
  });
1103
1117
  }
@@ -1105,19 +1119,19 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1105
1119
  * Attach controlled input listeners to sync DOM value to state
1106
1120
  */
1107
1121
  attachControlledInputListeners() {
1108
- const e = this.shadowRoot;
1109
- e && (e.querySelectorAll("[data-model]").forEach((t) => {
1110
- const n = t.getAttribute("data-model");
1111
- n && (t._dataModelBound || (B(t, this.stateObj, n), t._dataModelBound = !0));
1112
- }), e.querySelectorAll("[data-model]").forEach((t) => {
1113
- const [n] = t.getAttribute("data-model")?.split("|").map((r) => r.trim()) ?? [];
1122
+ const t = this.shadowRoot;
1123
+ t && (t.querySelectorAll("[data-model]").forEach((e) => {
1124
+ const n = e.getAttribute("data-model");
1125
+ n && (e._dataModelBound || (X(e, this.stateObj, n), e._dataModelBound = !0));
1126
+ }), t.querySelectorAll("[data-model]").forEach((e) => {
1127
+ const [n] = e.getAttribute("data-model")?.split("|").map((r) => r.trim()) ?? [];
1114
1128
  if (!(!n || !(n in this.stateObj)))
1115
- if (t instanceof HTMLInputElement)
1116
- if (t.type === "checkbox") {
1117
- const r = this.stateObj[n], o = t.getAttribute("data-true-value"), s = t.getAttribute("data-false-value");
1118
- Array.isArray(r) ? t.checked = r.includes(t.value) : o !== null || s !== null ? String(r) === o ? t.checked = !0 : String(r) === s ? t.checked = !1 : r === !0 ? t.checked = !0 : t.checked = !1 : t.checked = r === !0 || r === "true" || r === 1;
1119
- } else t.type === "radio" ? t.checked = t.value === String(this.stateObj[n]) : t.value = String(this.stateObj[n] ?? "");
1120
- else (t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement) && (t.value = String(this.stateObj[n] ?? ""));
1129
+ if (e instanceof HTMLInputElement)
1130
+ if (e.type === "checkbox") {
1131
+ const r = this.stateObj[n], o = e.getAttribute("data-true-value"), s = e.getAttribute("data-false-value");
1132
+ Array.isArray(r) ? e.checked = r.includes(e.value) : o !== null || s !== null ? String(r) === o ? e.checked = !0 : String(r) === s ? e.checked = !1 : r === !0 ? e.checked = !0 : e.checked = !1 : e.checked = r === !0 || r === "true" || r === 1;
1133
+ } else e.type === "radio" ? e.checked = e.value === String(this.stateObj[n]) : e.value = String(this.stateObj[n] ?? "");
1134
+ else (e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) && (e.value = String(this.stateObj[n] ?? ""));
1121
1135
  }));
1122
1136
  }
1123
1137
  config;
@@ -1137,13 +1151,13 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1137
1151
  }
1138
1152
  initializeConfig() {
1139
1153
  if (this.config) return;
1140
- const e = this.tagName.toLowerCase(), n = (window.__componentRegistry || {})[e];
1154
+ const t = this.tagName.toLowerCase(), n = (window.__componentRegistry || {})[t];
1141
1155
  if (!n || typeof n != "object")
1142
1156
  throw new Error("Invalid component config: must be an object");
1143
1157
  if (!n.state || typeof n.state != "object")
1144
1158
  throw new Error("Invalid component config: state must be an object");
1145
1159
  this.config = n;
1146
- const r = n.computed ? M(n.state, n.computed) : M(n.state);
1160
+ const r = n.computed ? $(n.state, n.computed) : $(n.state);
1147
1161
  if (this.stateObj = r, typeof this.stateObj.subscribe == "function" && this.unsubscribes.push(this.stateObj.subscribe(() => {
1148
1162
  this.scheduleRender();
1149
1163
  })), this.api = {
@@ -1184,7 +1198,7 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1184
1198
  if (this.hasAttribute("data-hydrated") ? this.processRefs() : this.render(), !this._mountedCalled && typeof this.config.onMounted == "function")
1185
1199
  try {
1186
1200
  const s = this.config.onMounted(this.api.state, this.api);
1187
- S(s) ? s.catch((i) => {
1201
+ O(s) ? s.catch((i) => {
1188
1202
  typeof this.config.onError == "function" && this.config.onError(i, this.api.state, this.api), this._handleRenderError(i);
1189
1203
  }).finally(() => {
1190
1204
  this._mountedCalled = !0;
@@ -1195,23 +1209,23 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1195
1209
  }
1196
1210
  connectedCallback() {
1197
1211
  if (this.initializeConfig(), this.stateObj) {
1198
- for (const e of this.getAttributeNames())
1199
- if (e in this.stateObj) {
1200
- const t = typeof this.config?.state?.[e];
1201
- let n = this.getAttribute(e);
1202
- t === "number" ? n = Number(n) : t === "boolean" && (n = n === "true"), this.stateObj[e] = n === null ? void 0 : n;
1212
+ for (const t of this.getAttributeNames())
1213
+ if (t in this.stateObj) {
1214
+ const e = typeof this.config?.state?.[t];
1215
+ let n = this.getAttribute(t);
1216
+ e === "number" ? n = Number(n) : e === "boolean" && (n = n === "true"), this.stateObj[t] = n === null ? void 0 : n;
1203
1217
  }
1204
1218
  }
1205
1219
  if (!this._mountedCalled && typeof this.config.onMounted == "function")
1206
1220
  try {
1207
- const e = this.config.onMounted(this.api.state, this.api);
1208
- S(e) ? e.catch((t) => {
1209
- typeof this.config.onError == "function" && this.config.onError(t, this.api.state, this.api), this._handleRenderError(t);
1221
+ const t = this.config.onMounted(this.api.state, this.api);
1222
+ O(t) ? t.catch((e) => {
1223
+ typeof this.config.onError == "function" && this.config.onError(e, this.api.state, this.api), this._handleRenderError(e);
1210
1224
  }).finally(() => {
1211
1225
  this._mountedCalled = !0;
1212
1226
  }) : this._mountedCalled = !0;
1213
- } catch (e) {
1214
- typeof this.config.onError == "function" && this.config.onError(e, this.api.state, this.api), this._handleRenderError(e), this._mountedCalled = !0;
1227
+ } catch (t) {
1228
+ typeof this.config.onError == "function" && this.config.onError(t, this.api.state, this.api), this._handleRenderError(t), this._mountedCalled = !0;
1215
1229
  }
1216
1230
  typeof this.render == "function" && this.render();
1217
1231
  }
@@ -1219,20 +1233,20 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1219
1233
  * Lifecycle: called when element is removed from DOM.
1220
1234
  */
1221
1235
  disconnectedCallback() {
1222
- if (Object.entries(this._autoWiredHandlers).forEach(([e, t]) => {
1223
- t.forEach((n) => {
1224
- super.removeEventListener(e, n);
1236
+ if (Object.entries(this._autoWiredHandlers).forEach(([t, e]) => {
1237
+ e.forEach((n) => {
1238
+ super.removeEventListener(t, n);
1225
1239
  });
1226
- }), this._autoWiredHandlers = {}, this.unsubscribes.forEach((e) => e()), this.unsubscribes = [], this._globalUnsubscribes.forEach((e) => e()), this._globalUnsubscribes = [], !this._unmountedCalled && typeof this.config.onUnmounted == "function")
1240
+ }), this._autoWiredHandlers = {}, this.unsubscribes.forEach((t) => t()), this.unsubscribes = [], this._globalUnsubscribes.forEach((t) => t()), this._globalUnsubscribes = [], !this._unmountedCalled && typeof this.config.onUnmounted == "function")
1227
1241
  try {
1228
- const e = this.config.onUnmounted(this.api.state, this.api);
1229
- S(e) ? e.catch((t) => {
1230
- typeof this.config.onError == "function" && this.config.onError(t, this.api.state, this.api), this._handleRenderError(t);
1242
+ const t = this.config.onUnmounted(this.api.state, this.api);
1243
+ O(t) ? t.catch((e) => {
1244
+ typeof this.config.onError == "function" && this.config.onError(e, this.api.state, this.api), this._handleRenderError(e);
1231
1245
  }).finally(() => {
1232
1246
  this._unmountedCalled = !0;
1233
1247
  }) : this._unmountedCalled = !0;
1234
- } catch (e) {
1235
- typeof this.config.onError == "function" && this.config.onError(e, this.api.state, this.api), this._handleRenderError(e), this._unmountedCalled = !0;
1248
+ } catch (t) {
1249
+ typeof this.config.onError == "function" && this.config.onError(t, this.api.state, this.api), this._handleRenderError(t), this._unmountedCalled = !0;
1236
1250
  }
1237
1251
  this._mountedCalled = !1, this._unmountedCalled = !1;
1238
1252
  }
@@ -1242,27 +1256,27 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1242
1256
  render() {
1243
1257
  this._hasError = !1, this.syncControlledInputsAndEvents(), setTimeout(() => this.attachControlledInputListeners(), 0);
1244
1258
  try {
1245
- _.forEach((t) => {
1259
+ _.forEach((e) => {
1246
1260
  try {
1247
- t.onRender?.(this.stateObj, this.api);
1261
+ e.onRender?.(this.stateObj, this.api);
1248
1262
  } catch (n) {
1249
1263
  this._handleRenderError(n);
1250
1264
  }
1251
- }), this.config.computed && Object.values(this.config.computed).forEach((t) => {
1265
+ }), this.config.computed && Object.values(this.config.computed).forEach((e) => {
1252
1266
  try {
1253
- t(this.stateObj);
1267
+ e(this.stateObj);
1254
1268
  } catch (n) {
1255
1269
  this._handleRenderError(n);
1256
1270
  }
1257
1271
  });
1258
- const e = this.config.template(this.stateObj, this.api);
1259
- e instanceof Promise ? e.then((t) => {
1260
- this._hasError || (this._renderTemplateResult(t), this.syncStateToAttributes(), setTimeout(() => this.attachListItemModelListeners(), 0));
1261
- }).catch((t) => {
1262
- this._handleRenderError(t);
1263
- }) : this._hasError || (this._renderTemplateResult(e), this.syncStateToAttributes(), setTimeout(() => this.attachListItemModelListeners(), 0));
1264
- } catch (e) {
1265
- this._handleRenderError(e), this.renderError(e instanceof Error ? e : new Error(String(e)));
1272
+ const t = this.config.template(this.stateObj, this.api);
1273
+ t instanceof Promise ? t.then((e) => {
1274
+ this._hasError || (this._renderTemplateResult(e), this.syncStateToAttributes(), setTimeout(() => this.attachListItemModelListeners(), 0));
1275
+ }).catch((e) => {
1276
+ this._handleRenderError(e);
1277
+ }) : this._hasError || (this._renderTemplateResult(t), this.syncStateToAttributes(), setTimeout(() => this.attachListItemModelListeners(), 0));
1278
+ } catch (t) {
1279
+ this._handleRenderError(t), this.renderError(t instanceof Error ? t : new Error(String(t)));
1266
1280
  }
1267
1281
  }
1268
1282
  /**
@@ -1274,16 +1288,16 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1274
1288
  */
1275
1289
  rebindEventListeners() {
1276
1290
  if (!this.shadowRoot) return;
1277
- ["data-on-input", "data-on-change", "data-on-blur", "data-on-click"].forEach((t) => {
1278
- this.shadowRoot.querySelectorAll(`[${t}]`).forEach((n) => {
1279
- const r = t.replace("data-on-", ""), o = n.getAttribute(t);
1291
+ ["data-on-input", "data-on-change", "data-on-blur", "data-on-click"].forEach((e) => {
1292
+ this.shadowRoot.querySelectorAll(`[${e}]`).forEach((n) => {
1293
+ const r = e.replace("data-on-", ""), o = n.getAttribute(e);
1280
1294
  if (!o || typeof this.config[o] != "function") return;
1281
1295
  n._boundHandlers && n._boundHandlers[r] && n.removeEventListener(r, n._boundHandlers[r]);
1282
1296
  const s = this.config[o], i = (a) => s.call(this, a);
1283
1297
  n.addEventListener(r, i), n._boundHandlers || (n._boundHandlers = {}), n._boundHandlers[r] = i;
1284
1298
  });
1285
- }), Array.from(this.shadowRoot.children).forEach((t) => {
1286
- t instanceof HTMLElement && typeof t.rebindEventListeners == "function" && t.rebindEventListeners();
1299
+ }), Array.from(this.shadowRoot.children).forEach((e) => {
1300
+ e instanceof HTMLElement && typeof e.rebindEventListeners == "function" && e.rebindEventListeners();
1287
1301
  });
1288
1302
  }
1289
1303
  /**
@@ -1291,10 +1305,10 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1291
1305
  * Handles VDOM patching, style updates, refs, and event binding.
1292
1306
  * @param templateResult - HTML string or compiled template
1293
1307
  */
1294
- _renderTemplateResult(e) {
1308
+ _renderTemplateResult(t) {
1295
1309
  if (!this._hasError)
1296
1310
  try {
1297
- let t = function(n) {
1311
+ let e = function(n) {
1298
1312
  const r = /* @__PURE__ */ new WeakSet();
1299
1313
  function o(s) {
1300
1314
  if (s === null || typeof s != "object" || r.has(s)) return s;
@@ -1306,16 +1320,16 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1306
1320
  }
1307
1321
  return o(n);
1308
1322
  };
1309
- if (typeof e == "string") {
1323
+ if (typeof t == "string") {
1310
1324
  let n = function(c) {
1311
- return c.replace(/<([a-zA-Z0-9]+)([^>]*)>/g, (l, u, d) => {
1312
- const f = d.replace(/\s+on[a-zA-Z]+\s*=\s*(['"][^'"]*['"]|[^\s>]*)/gi, "");
1313
- return `<${u}${f}>`;
1325
+ return c.replace(/<([a-zA-Z0-9]+)([^>]*)>/g, (l, d, u) => {
1326
+ const f = u.replace(/\s+on[a-zA-Z]+\s*=\s*(['"][^'"]*['"]|[^\s>]*)/gi, "");
1327
+ return `<${d}${f}>`;
1314
1328
  });
1315
1329
  }, r = function(c) {
1316
1330
  c.children.forEach(r);
1317
1331
  };
1318
- const o = n(e), s = tt(o);
1332
+ const o = n(t), s = et(o);
1319
1333
  r(s);
1320
1334
  const i = this.shadowRoot;
1321
1335
  if (!i)
@@ -1326,8 +1340,8 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1326
1340
  (l) => l.nodeType === 1 && l !== a
1327
1341
  );
1328
1342
  if (c) {
1329
- Array.from(c.childNodes).forEach((d) => {
1330
- d.nodeType === 1 && d.nodeName === "STYLE" || c.removeChild(d);
1343
+ Array.from(c.childNodes).forEach((u) => {
1344
+ u.nodeType === 1 && u.nodeName === "STYLE" || c.removeChild(u);
1331
1345
  });
1332
1346
  const l = {
1333
1347
  type: "#fragment",
@@ -1335,12 +1349,12 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1335
1349
  children: s.children,
1336
1350
  props: {},
1337
1351
  key: void 0
1338
- }, u = this._prevVNode && this._prevVNode.type === "#fragment" ? { ...this._prevVNode, dom: c } : l;
1339
- R(c, u, l);
1352
+ }, d = this._prevVNode && this._prevVNode.type === "#fragment" ? { ...this._prevVNode, dom: c } : l;
1353
+ M(c, d, l);
1340
1354
  } else
1341
1355
  s.children.forEach((l) => {
1342
- const u = g(l);
1343
- u && i.appendChild(u), l.dom = u ?? void 0;
1356
+ const d = g(l);
1357
+ d && i.appendChild(d), l.dom = d ?? void 0;
1344
1358
  });
1345
1359
  } else {
1346
1360
  let c = Array.from(this.shadowRoot.childNodes).find(
@@ -1351,22 +1365,22 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1351
1365
  const l = g(s);
1352
1366
  l && (this.shadowRoot.contains(c) && this.shadowRoot.replaceChild(l, c), c = l);
1353
1367
  } else
1354
- R(c, this._prevVNode, s);
1368
+ M(c, this._prevVNode, s);
1355
1369
  else
1356
1370
  c = g(s), c && this.shadowRoot.appendChild(c);
1357
1371
  s.dom = c;
1358
1372
  }
1359
1373
  this._prevVNode = s, this.forceSyncControlledInputs(), this.lastCompiledTemplate = null;
1360
1374
  } else {
1361
- const n = !this.shadowRoot.firstElementChild, r = this.lastCompiledTemplate?.id === e.id;
1375
+ const n = !this.shadowRoot.firstElementChild, r = this.lastCompiledTemplate?.id === t.id;
1362
1376
  if (n) {
1363
- const o = D(e, this.stateObj, this.api);
1377
+ const o = I(t, this.stateObj, this.api);
1364
1378
  this.shadowRoot.appendChild(o);
1365
1379
  } else if (r && this.shadowRoot.firstElementChild) {
1366
1380
  const o = this.lastState;
1367
- J(e, this.shadowRoot.firstElementChild, this.stateObj, this.api, o || void 0);
1381
+ Q(t, this.shadowRoot.firstElementChild, this.stateObj, this.api, o || void 0);
1368
1382
  } else {
1369
- const o = D(e, this.stateObj, this.api);
1383
+ const o = I(t, this.stateObj, this.api);
1370
1384
  let s = this.shadowRoot.querySelector("style");
1371
1385
  s || (s = document.createElement("style"), this.shadowRoot.insertBefore(s, this.shadowRoot.firstChild)), this.config.style ? s.textContent = typeof this.config.style == "function" ? this.config.style(this.stateObj) : this.config.style : s.textContent = "";
1372
1386
  let i = this.shadowRoot.querySelector("[data-root]");
@@ -1374,11 +1388,11 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1374
1388
  i.removeChild(i.firstChild);
1375
1389
  i.appendChild(o);
1376
1390
  }
1377
- this.lastCompiledTemplate = e;
1391
+ this.lastCompiledTemplate = t;
1378
1392
  }
1379
- this.lastState = t(this.stateObj), this.updateStyle(), this.processRefs(), this.bindEvents(), this.syncControlledInputsAndEvents();
1380
- } catch (t) {
1381
- this._handleRenderError(t);
1393
+ this.lastState = e(this.stateObj), this.updateStyle(), this.processRefs(), this.bindEvents(), this.syncControlledInputsAndEvents();
1394
+ } catch (e) {
1395
+ this._handleRenderError(e);
1382
1396
  }
1383
1397
  }
1384
1398
  /**
@@ -1386,14 +1400,14 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1386
1400
  * Logs details and allows fallback UI.
1387
1401
  * @param error - Error object
1388
1402
  */
1389
- _handleRenderError(e) {
1390
- if (this._hasError = !0, this.config.debug && console.error(`[runtime] Render error in <${this.tagName.toLowerCase()}>:`, e), _.forEach((t) => t.onError?.(e instanceof Error ? e : new Error(String(e)), this.stateObj, this.api)), "onError" in this.config && typeof this.config.onError == "function")
1403
+ _handleRenderError(t) {
1404
+ if (this._hasError = !0, this.config.debug && console.error(`[runtime] Render error in <${this.tagName.toLowerCase()}>:`, t), _.forEach((e) => e.onError?.(t instanceof Error ? t : new Error(String(t)), this.stateObj, this.api)), "onError" in this.config && typeof this.config.onError == "function")
1391
1405
  try {
1392
- this.config.onError(e instanceof Error ? e : new Error(String(e)), this.api.state, this.api);
1393
- } catch (t) {
1394
- this.config.debug && console.error("[runtime] Error in onError handler:", t);
1406
+ this.config.onError(t instanceof Error ? t : new Error(String(t)), this.api.state, this.api);
1407
+ } catch (e) {
1408
+ this.config.debug && console.error("[runtime] Error in onError handler:", e);
1395
1409
  }
1396
- this.renderError(e instanceof Error ? e : new Error(String(e)));
1410
+ this.renderError(t instanceof Error ? t : new Error(String(t)));
1397
1411
  }
1398
1412
  /**
1399
1413
  * Schedule a render using requestAnimationFrame, batching multiple state changes.
@@ -1407,22 +1421,22 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1407
1421
  * Updates the style element in the shadow root based on the current state.
1408
1422
  */
1409
1423
  updateStyle() {
1410
- const e = this.shadowRoot.querySelector("style");
1411
- if (!e || !this.config.style) return;
1412
- const t = typeof this.config.style == "function" ? this.config.style(this.api.state) : this.config.style;
1413
- e.textContent = t;
1424
+ const t = this.shadowRoot.querySelector("style");
1425
+ if (!t || !this.config.style) return;
1426
+ const e = typeof this.config.style == "function" ? this.config.style(this.api.state) : this.config.style;
1427
+ t.textContent = e;
1414
1428
  }
1415
1429
  /**
1416
1430
  * Processes and attaches ref handlers for elements with data-ref attributes.
1417
1431
  */
1418
1432
  processRefs() {
1419
1433
  if (!this.config.refs) return;
1420
- const e = /* @__PURE__ */ new WeakMap();
1421
- Object.entries(this.config.refs).forEach(([t, n]) => {
1422
- const r = this.shadowRoot.querySelector(`[data-ref="${t}"]`);
1434
+ const t = /* @__PURE__ */ new WeakMap();
1435
+ Object.entries(this.config.refs).forEach(([e, n]) => {
1436
+ const r = this.shadowRoot.querySelector(`[data-ref="${e}"]`);
1423
1437
  if (r) {
1424
- e.has(r) || e.set(r, /* @__PURE__ */ new Set());
1425
- const o = e.get(r), s = r.addEventListener;
1438
+ t.has(r) || t.set(r, /* @__PURE__ */ new Set());
1439
+ const o = t.get(r), s = r.addEventListener;
1426
1440
  r.addEventListener = function(i, a, c) {
1427
1441
  const l = `${i}`;
1428
1442
  o.has(l) || (o.add(l), s.call(r, i, a, c));
@@ -1441,10 +1455,10 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1441
1455
  */
1442
1456
  bindEvents() {
1443
1457
  if (!this.shadowRoot) return;
1444
- const e = document.createTreeWalker(this.shadowRoot, NodeFilter.SHOW_ELEMENT);
1445
- let t = e.nextNode();
1446
- for (; t; ) {
1447
- const n = t;
1458
+ const t = document.createTreeWalker(this.shadowRoot, NodeFilter.SHOW_ELEMENT);
1459
+ let e = t.nextNode();
1460
+ for (; e; ) {
1461
+ const n = e;
1448
1462
  Array.from(n.attributes).forEach((r) => {
1449
1463
  if (r.name.startsWith("data-on-")) {
1450
1464
  const o = r.name.slice(8), s = r.value, i = this.config[s];
@@ -1457,28 +1471,28 @@ typeof HTMLElement < "u" && (z = class extends HTMLElement {
1457
1471
  } else
1458
1472
  this.config.debug && console.warn(`[runtime] Handler '${s}' not found on config for event '${o}'`, n);
1459
1473
  }
1460
- }), t = e.nextNode();
1474
+ }), e = t.nextNode();
1461
1475
  }
1462
1476
  }
1463
1477
  /**
1464
1478
  * Renders a fallback error UI in the shadow root.
1465
1479
  * @param error - Error object
1466
1480
  */
1467
- renderError(e) {
1468
- const t = this.config.style ? typeof this.config.style == "function" ? this.config.style(this.api.state) : this.config.style : "";
1481
+ renderError(t) {
1482
+ const e = this.config.style ? typeof this.config.style == "function" ? this.config.style(this.api.state) : this.config.style : "";
1469
1483
  this.shadowRoot.innerHTML = `
1470
- <style>${t}</style>
1484
+ <style>${e}</style>
1471
1485
  <div style="color: red; border: 1px solid red; padding: 1rem; border-radius: 4px;">
1472
1486
  <h3>Error Boundary</h3>
1473
- <div>Error: ${e.message}</div>
1487
+ <div>Error: ${t.message}</div>
1474
1488
  </div>
1475
1489
  `;
1476
1490
  }
1477
1491
  });
1478
- function rt(e, t) {
1479
- if (t = A(t), t.debug && console.log(`[runtime] Debugging component: ${e}`, t), !e || !t.template) {
1480
- t && typeof t.onError == "function" && t.onError(new Error("Component requires tag and template"), t.state ?? {}, {
1481
- state: t.state ?? {},
1492
+ function it(t, e) {
1493
+ if (e = A(e), e.debug && console.log(`[runtime] Debugging component: ${t}`, e), !t || !e.template) {
1494
+ e && typeof e.onError == "function" && e.onError(new Error("Component requires tag and template"), e.state ?? {}, {
1495
+ state: e.state ?? {},
1482
1496
  emit: () => {
1483
1497
  },
1484
1498
  onGlobal: () => () => {
@@ -1487,15 +1501,15 @@ function rt(e, t) {
1487
1501
  },
1488
1502
  emitGlobal: () => {
1489
1503
  }
1490
- }), t && t.debug && console.error("[runtime] Malformed config:", { tag: e, config: t });
1504
+ }), e && e.debug && console.error("[runtime] Malformed config:", { tag: t, config: e });
1491
1505
  return;
1492
1506
  }
1493
- if (_.forEach((u) => {
1507
+ if (_.forEach((d) => {
1494
1508
  try {
1495
- u.onInit?.(t);
1496
- } catch (d) {
1497
- t && typeof t.onError == "function" && t.onError(d instanceof Error ? d : new Error(String(d)), t.state, {
1498
- state: t.state,
1509
+ d.onInit?.(e);
1510
+ } catch (u) {
1511
+ e && typeof e.onError == "function" && e.onError(u instanceof Error ? u : new Error(String(u)), e.state, {
1512
+ state: e.state,
1499
1513
  emit: () => {
1500
1514
  },
1501
1515
  onGlobal: () => () => {
@@ -1504,23 +1518,23 @@ function rt(e, t) {
1504
1518
  },
1505
1519
  emitGlobal: () => {
1506
1520
  }
1507
- }), t && t.debug && console.error("[runtime] Plugin onInit error:", d);
1521
+ }), e && e.debug && console.error("[runtime] Plugin onInit error:", u);
1508
1522
  }
1509
- }), (typeof window < "u" && window.VITE_DEV_HMR || typeof import.meta < "u" && void 0) && customElements.get(e))
1523
+ }), (typeof window < "u" && window.VITE_DEV_HMR || typeof import.meta < "u" && void 0) && customElements.get(t))
1510
1524
  try {
1511
- document.querySelectorAll(e).forEach((u) => u.remove()), window.customElements._definitions && delete window.customElements._definitions[e];
1525
+ document.querySelectorAll(t).forEach((d) => d.remove()), window.customElements._definitions && delete window.customElements._definitions[t];
1512
1526
  } catch {
1513
1527
  }
1514
- if (customElements.get(e)) {
1515
- t.debug && console.warn(`[runtime] Component "${e}" already registered`);
1528
+ if (customElements.get(t)) {
1529
+ e.debug && console.warn(`[runtime] Component "${t}" already registered`);
1516
1530
  return;
1517
1531
  }
1518
- const s = M(t.state ?? {}, t.computed);
1519
- t.state = s, t._subscribe = s.subscribe;
1520
- const i = t.state ?? {}, a = Object.keys(i).filter(
1521
- (u) => ["string", "number", "boolean"].includes(typeof i[u])
1532
+ const s = $(e.state ?? {}, e.computed);
1533
+ e.state = s, e._subscribe = s.subscribe;
1534
+ const i = e.state ?? {}, a = Object.keys(i).filter(
1535
+ (d) => ["string", "number", "boolean"].includes(typeof i[d])
1522
1536
  );
1523
- class c extends z {
1537
+ class c extends W {
1524
1538
  static get observedAttributes() {
1525
1539
  return a;
1526
1540
  }
@@ -1529,10 +1543,10 @@ function rt(e, t) {
1529
1543
  }
1530
1544
  }
1531
1545
  const l = c;
1532
- typeof customElements < "u" && !customElements.get(e) && (window.__componentRegistry = window.__componentRegistry || {}, window.__componentRegistry[e] = t, customElements.define(e, l));
1546
+ typeof customElements < "u" && !customElements.get(t) && (window.__componentRegistry = window.__componentRegistry || {}, window.__componentRegistry[t] = e, customElements.define(t, l));
1533
1547
  }
1534
- rt("router-view", {
1535
- template: (e, t) => {
1548
+ it("router-view", {
1549
+ template: (t, e) => {
1536
1550
  const n = window.__routerInstance;
1537
1551
  if (!n) return "<div>Router not initialized.</div>";
1538
1552
  const { path: r } = n.getCurrent(), o = n.matchRoute(r);
@@ -1540,33 +1554,33 @@ rt("router-view", {
1540
1554
  }
1541
1555
  });
1542
1556
  export {
1543
- $ as Store,
1544
- lt as classes,
1545
- at as compile,
1546
- dt as compileTemplate,
1547
- rt as component,
1548
- L as createVNodeFromElement,
1549
- ct as css,
1557
+ j as Store,
1558
+ ut as classes,
1559
+ lt as compile,
1560
+ ht as compileTemplate,
1561
+ it as component,
1562
+ R as createVNodeFromElement,
1563
+ dt as css,
1550
1564
  A as deepSanitizeObject,
1551
1565
  w as eventBus,
1552
- it as generateHydrationScript,
1553
- I as getVNodeKey,
1554
- ot as html,
1555
- ft as initRouter,
1556
- S as isPromise,
1557
- ht as matchRouteSSR,
1566
+ at as generateHydrationScript,
1567
+ N as getVNodeKey,
1568
+ ct as html,
1569
+ pt as initRouter,
1570
+ O as isPromise,
1571
+ mt as matchRouteSSR,
1558
1572
  g as mountVNode,
1559
- tt as parseVNodeFromHTML,
1560
- R as patchVNode,
1561
- D as renderCompiledTemplate,
1562
- st as renderComponentsToString,
1563
- U as renderToString,
1573
+ et as parseVNodeFromHTML,
1574
+ M as patchVNode,
1575
+ I as renderCompiledTemplate,
1576
+ ot as renderComponentsToString,
1577
+ G as renderToString,
1564
1578
  _ as runtimePlugins,
1565
- N as safeReplaceChild,
1566
- ut as styles,
1567
- J as updateCompiledTemplate,
1568
- B as useDataModel,
1569
- nt as useRouter,
1570
- pt as useRuntimePlugin
1579
+ P as safeReplaceChild,
1580
+ ft as styles,
1581
+ Q as updateCompiledTemplate,
1582
+ X as useDataModel,
1583
+ st as useRouter,
1584
+ yt as useRuntimePlugin
1571
1585
  };
1572
1586
  //# sourceMappingURL=custom-elements-runtime.es.js.map