@jasonshimmy/custom-elements-runtime 0.3.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,510 +1,956 @@
1
- function we(e, t) {
2
- return O(e ? t : [], "when-block");
1
+ class ut {
2
+ pendingUpdates = /* @__PURE__ */ new Map();
3
+ isFlushScheduled = !1;
4
+ /**
5
+ * Schedule an update to be executed in the next microtask
6
+ * Uses component identity to deduplicate multiple render requests for the same component
7
+ */
8
+ schedule(t, r) {
9
+ const n = r || t.toString();
10
+ this.pendingUpdates.set(n, t), this.isFlushScheduled || (this.isFlushScheduled = !0, typeof globalThis.process < "u" && globalThis.process.env?.NODE_ENV === "test" || typeof window < "u" && (window.__vitest__ || window.Cypress) ? this.flush() : queueMicrotask(() => this.flush()));
11
+ }
12
+ /**
13
+ * Execute all pending updates
14
+ */
15
+ flush() {
16
+ const t = Array.from(this.pendingUpdates.values());
17
+ this.pendingUpdates.clear(), this.isFlushScheduled = !1;
18
+ for (const r of t)
19
+ try {
20
+ r();
21
+ } catch (n) {
22
+ typeof console < "u" && console.error && console.error("Error in batched update:", n);
23
+ }
24
+ }
25
+ /**
26
+ * Get the number of pending updates
27
+ */
28
+ get pendingCount() {
29
+ return this.pendingUpdates.size;
30
+ }
3
31
  }
4
- function Ot(e, t) {
5
- return e.map((r, i) => {
6
- const n = typeof r == "object" ? r?.key ?? r?.id ?? `idx-${i}` : String(r);
7
- return O(t(r, i), `each-${n}`);
8
- });
32
+ const ft = new ut();
33
+ function le(e, t) {
34
+ ft.schedule(e, t);
9
35
  }
10
- function Ke() {
11
- const e = [];
12
- return {
13
- when(t, r) {
14
- return e.push([t, r]), this;
15
- },
16
- otherwise(t) {
17
- return e.push([!0, t]), this;
18
- },
19
- done() {
20
- return Je(...e);
36
+ const Ue = /* @__PURE__ */ new WeakSet();
37
+ class dt {
38
+ static cache = /* @__PURE__ */ new WeakMap();
39
+ static arrayHandlerCache = /* @__PURE__ */ new WeakMap();
40
+ static objectHandlerCache = /* @__PURE__ */ new WeakMap();
41
+ /**
42
+ * Get or create a reactive proxy for an object
43
+ */
44
+ static getOrCreateProxy(t, r, n = !1) {
45
+ const i = this.cache.get(t);
46
+ if (i)
47
+ return i;
48
+ const s = n ? this.getOrCreateArrayHandler(r) : this.getOrCreateObjectHandler(r), o = new Proxy(t, s);
49
+ try {
50
+ tt.markAsProxy(o);
51
+ } catch {
21
52
  }
22
- };
23
- }
24
- function Je(...e) {
25
- for (let t = 0; t < e.length; t++) {
26
- const [r, i] = e[t];
27
- if (r) return [O(i, `whenChain-branch-${t}`)];
53
+ return this.cache.set(t, o), o;
28
54
  }
29
- return [O([], "whenChain-empty")];
30
- }
31
- function O(e, t) {
32
- const r = e ? Array.isArray(e) ? e.filter(Boolean) : [e].filter(Boolean) : [];
33
- return {
34
- tag: "#anchor",
35
- key: t,
36
- children: r
37
- };
38
- }
39
- function Pt(e, t) {
40
- return we(!e, t);
41
- }
42
- function Mt(e, t) {
43
- const r = !e || e.length === 0;
44
- return we(r, t);
45
- }
46
- function Bt(e, t) {
47
- const r = !!(e && e.length > 0);
48
- return we(r, t);
49
- }
50
- function Wt(e, t, r) {
51
- const i = [];
52
- return e.forEach((n, s) => {
53
- t(n, s) && i.push({ item: n, originalIndex: s });
54
- }), i.map(({ item: n, originalIndex: s }, o) => {
55
- const a = typeof n == "object" && n != null ? n?.key ?? n?.id ?? `filtered-${s}` : `filtered-${s}`;
56
- return O(r(n, s, o), `each-where-${a}`);
57
- });
58
- }
59
- function It(e, t) {
60
- const r = e?.length ?? 0;
61
- return r === 0 && t.empty ? O(t.empty, "switch-length-empty") : r === 1 && t.one ? O(t.one(e[0]), "switch-length-one") : t.exactly?.[r] ? O(t.exactly[r](e), `switch-length-${r}`) : r > 1 && t.many ? O(t.many(e), "switch-length-many") : O([], "switch-length-fallback");
62
- }
63
- function qt(e, t, r) {
64
- const i = /* @__PURE__ */ new Map();
65
- return e.forEach((n) => {
66
- const s = t(n);
67
- i.has(s) || i.set(s, []), i.get(s).push(n);
68
- }), Array.from(i.entries()).map(([n, s], o) => O(
69
- r(n, s, o),
70
- `each-group-${n}`
71
- ));
72
- }
73
- function zt(e, t, r, i) {
74
- const n = r * t, s = Math.min(n + t, e.length);
75
- return e.slice(n, s).map((a, c) => {
76
- const u = n + c, m = typeof a == "object" && a != null ? a?.key ?? a?.id ?? `page-${u}` : `page-${u}`;
77
- return O(i(a, u, c), `each-page-${m}`);
78
- });
79
- }
80
- function Ht(e, t) {
81
- return e.loading && t.loading ? O(t.loading, "promise-loading") : e.error && t.error ? O(t.error(e.error), "promise-error") : e.data !== void 0 && t.success ? O(t.success(e.data), "promise-success") : t.idle ? O(t.idle, "promise-idle") : O([], "promise-fallback");
82
- }
83
- function q(e, t) {
84
- const r = typeof window < "u" && window.matchMedia?.(e)?.matches;
85
- return we(!!r, t);
86
- }
87
- const G = {
88
- // Responsive breakpoints (matching style.ts)
89
- sm: "(min-width:640px)",
90
- md: "(min-width:768px)",
91
- lg: "(min-width:1024px)",
92
- xl: "(min-width:1280px)",
93
- "2xl": "(min-width:1536px)",
94
- // Dark mode (matching style.ts)
95
- dark: "(prefers-color-scheme: dark)"
96
- }, ze = ["sm", "md", "lg", "xl", "2xl"], Ve = {
97
- // Breakpoint-based rendering (matching style.ts exactly)
98
- sm: (e) => q(G.sm, e),
99
- md: (e) => q(G.md, e),
100
- lg: (e) => q(G.lg, e),
101
- xl: (e) => q(G.xl, e),
102
- "2xl": (e) => q(G["2xl"], e),
103
- // Dark mode (matching style.ts)
104
- dark: (e) => q(G.dark, e),
105
- light: (e) => q("(prefers-color-scheme: light)", e),
106
- // Accessibility and interaction preferences
107
- touch: (e) => q("(hover: none) and (pointer: coarse)", e),
108
- mouse: (e) => q("(hover: hover) and (pointer: fine)", e),
109
- reducedMotion: (e) => q("(prefers-reduced-motion: reduce)", e),
110
- highContrast: (e) => q("(prefers-contrast: high)", e),
111
- // Orientation
112
- portrait: (e) => q("(orientation: portrait)", e),
113
- landscape: (e) => q("(orientation: landscape)", e)
114
- };
115
- function Nt(e, t) {
116
- const r = [];
117
- e.includes("dark") ? r.push(G.dark) : e.includes("light") && r.push("(prefers-color-scheme: light)");
118
- const i = e.filter(
119
- (o) => ze.includes(o)
120
- ), n = i[i.length - 1];
121
- n && n in G && r.push(G[n]);
122
- const s = r.length > 0 ? r.join(" and ") : "all";
123
- return q(s, t);
124
- }
125
- function Dt(e) {
126
- const t = [];
127
- return e.base && t.push(O(e.base, "responsive-base")), ze.forEach((r) => {
128
- const i = e[r];
129
- i && t.push(Ve[r](i));
130
- }), t;
131
- }
132
- function Ut(e) {
133
- const t = [];
134
- let r = null;
135
- return {
136
- case(i, n) {
137
- const s = typeof i == "function" ? i : (o) => o === i;
138
- return t.push({ condition: s, content: n }), this;
139
- },
140
- when(i, n) {
141
- return t.push({ condition: i, content: n }), this;
142
- },
143
- otherwise(i) {
144
- return r = i, this;
145
- },
146
- done() {
147
- for (let i = 0; i < t.length; i++) {
148
- const { condition: n, content: s } = t[i];
149
- if (n(e))
150
- return O(s, `switch-case-${i}`);
151
- }
152
- return O(r || [], "switch-otherwise");
55
+ /**
56
+ * Get or create a cached array handler
57
+ */
58
+ static getOrCreateArrayHandler(t) {
59
+ if (!this.arrayHandlerCache.has(t)) {
60
+ const r = {
61
+ get: (n, i, s) => {
62
+ const o = Reflect.get(n, i, s);
63
+ return typeof o == "function" && typeof i == "string" && [
64
+ "push",
65
+ "pop",
66
+ "shift",
67
+ "unshift",
68
+ "splice",
69
+ "sort",
70
+ "reverse",
71
+ "fill",
72
+ "copyWithin"
73
+ ].includes(i) ? function(...u) {
74
+ const m = o.apply(n, u);
75
+ return t.triggerUpdate(), m;
76
+ } : o;
77
+ },
78
+ set: (n, i, s) => (n[i] = t.makeReactiveValue(s), t.triggerUpdate(), !0),
79
+ deleteProperty: (n, i) => (delete n[i], t.triggerUpdate(), !0)
80
+ };
81
+ this.arrayHandlerCache.set(t, r);
153
82
  }
154
- };
155
- }
156
- const He = typeof process < "u" && process.env?.NODE_ENV !== "production";
157
- function Y(e, ...t) {
158
- He && console.error(e, ...t);
159
- }
160
- function pe(e, ...t) {
161
- He && console.warn(e, ...t);
83
+ return this.arrayHandlerCache.get(t);
84
+ }
85
+ /**
86
+ * Get or create a cached object handler
87
+ */
88
+ static getOrCreateObjectHandler(t) {
89
+ if (!this.objectHandlerCache.has(t)) {
90
+ const r = {
91
+ get: (n, i, s) => Reflect.get(n, i, s),
92
+ set: (n, i, s) => (n[i] = t.makeReactiveValue(s), t.triggerUpdate(), !0),
93
+ deleteProperty: (n, i) => (delete n[i], t.triggerUpdate(), !0)
94
+ };
95
+ this.objectHandlerCache.set(t, r);
96
+ }
97
+ return this.objectHandlerCache.get(t);
98
+ }
99
+ /**
100
+ * Check if an object already has a cached proxy
101
+ */
102
+ static hasProxy(t) {
103
+ return this.cache.has(t);
104
+ }
105
+ /**
106
+ * Clear all cached proxies (useful for testing)
107
+ */
108
+ static clear() {
109
+ this.cache = /* @__PURE__ */ new WeakMap(), this.arrayHandlerCache = /* @__PURE__ */ new WeakMap(), this.objectHandlerCache = /* @__PURE__ */ new WeakMap();
110
+ }
111
+ /**
112
+ * Get cache statistics (for debugging)
113
+ * Note: WeakMap doesn't provide size, so this is limited
114
+ */
115
+ static getStats() {
116
+ return {
117
+ hasCachedProxies: this.cache instanceof WeakMap
118
+ };
119
+ }
162
120
  }
163
- class ne extends EventTarget {
164
- handlers = {};
165
- static instance;
166
- eventCounters = /* @__PURE__ */ new Map();
121
+ class tt {
122
+ // Cache a stable reactiveContext object keyed by onUpdate -> makeReactive
123
+ // This allows handler caches in ReactiveProxyCache to reuse handlers
124
+ // for identical reactive contexts instead of creating a new context object
125
+ // on each createReactiveProxy call.
126
+ static contextCache = /* @__PURE__ */ new WeakMap();
167
127
  /**
168
- * Returns the singleton instance of GlobalEventBus
128
+ * Create an optimized reactive proxy with minimal overhead
169
129
  */
170
- static getInstance() {
171
- return ne.instance || (ne.instance = new ne()), ne.instance;
130
+ static createReactiveProxy(t, r, n) {
131
+ try {
132
+ if (Ue.has(t)) return t;
133
+ } catch {
134
+ }
135
+ const i = Array.isArray(t);
136
+ let s = this.contextCache.get(r);
137
+ s || (s = /* @__PURE__ */ new WeakMap(), this.contextCache.set(r, s));
138
+ let o = s.get(n);
139
+ return o || (o = {
140
+ triggerUpdate: r,
141
+ makeReactiveValue: n
142
+ }, s.set(n, o)), dt.getOrCreateProxy(t, o, i);
172
143
  }
173
144
  /**
174
- * Emit a global event with optional data. Includes event storm protection.
175
- * @param eventName - Name of the event
176
- * @param data - Optional event payload
145
+ * Mark an object as a proxy (for optimization)
177
146
  */
178
- emit(t, r) {
179
- const i = Date.now(), n = this.eventCounters.get(t);
180
- if (!n || i - n.window > 1e3)
181
- this.eventCounters.set(t, { count: 1, window: i });
182
- else if (n.count++, n.count > 50 && n.count > 100)
183
- return;
184
- this.dispatchEvent(new CustomEvent(t, {
185
- detail: r,
186
- bubbles: !1,
187
- // Global events don't need to bubble
188
- cancelable: !0
189
- }));
190
- const s = this.handlers[t];
191
- s && s.forEach((o) => {
147
+ static markAsProxy(t) {
148
+ if (t)
192
149
  try {
193
- o(r);
194
- } catch (a) {
195
- Y(`Error in global event handler for "${t}":`, a);
150
+ Ue.add(t);
151
+ } catch {
196
152
  }
197
- });
198
153
  }
154
+ }
155
+ class pt {
156
+ currentComponent = null;
157
+ componentDependencies = /* @__PURE__ */ new Map();
158
+ componentRenderFunctions = /* @__PURE__ */ new Map();
159
+ // Flat storage: compound key `${componentId}:${stateIndex}` -> ReactiveState
160
+ stateStorage = /* @__PURE__ */ new Map();
161
+ stateIndexCounter = /* @__PURE__ */ new Map();
162
+ trackingDisabled = !1;
163
+ // Per-component last warning timestamp to throttle repeated warnings
164
+ lastWarningTime = /* @__PURE__ */ new Map();
199
165
  /**
200
- * Register a handler for a global event. Returns an unsubscribe function.
201
- * @param eventName - Name of the event
202
- * @param handler - Handler function
166
+ * Set the current component being rendered for dependency tracking
203
167
  */
204
- on(t, r) {
205
- return this.handlers[t] || (this.handlers[t] = /* @__PURE__ */ new Set()), this.handlers[t].add(r), () => this.off(t, r);
168
+ setCurrentComponent(t, r) {
169
+ this.currentComponent = t, this.componentRenderFunctions.set(t, r), this.componentDependencies.has(t) || this.componentDependencies.set(t, /* @__PURE__ */ new Set()), this.stateIndexCounter.set(t, 0);
206
170
  }
207
171
  /**
208
- * Remove a specific handler for a global event.
209
- * @param eventName - Name of the event
210
- * @param handler - Handler function to remove
172
+ * Clear the current component after rendering
211
173
  */
212
- off(t, r) {
213
- const i = this.handlers[t];
214
- i && i.delete(r);
174
+ clearCurrentComponent() {
175
+ this.currentComponent = null;
215
176
  }
216
177
  /**
217
- * Remove all handlers for a specific event.
218
- * @param eventName - Name of the event
178
+ * Temporarily disable dependency tracking
219
179
  */
220
- offAll(t) {
221
- delete this.handlers[t];
180
+ disableTracking() {
181
+ this.trackingDisabled = !0;
222
182
  }
223
183
  /**
224
- * Listen for a native CustomEvent. Returns an unsubscribe function.
225
- * @param eventName - Name of the event
226
- * @param handler - CustomEvent handler
227
- * @param options - AddEventListener options
184
+ * Re-enable dependency tracking
228
185
  */
229
- listen(t, r, i) {
230
- return this.addEventListener(t, r, i), () => this.removeEventListener(t, r);
186
+ enableTracking() {
187
+ this.trackingDisabled = !1;
231
188
  }
232
189
  /**
233
- * Register a one-time event handler. Returns a promise that resolves with the event data.
234
- * @param eventName - Name of the event
235
- * @param handler - Handler function
190
+ * Check if a component is currently rendering
236
191
  */
237
- once(t, r) {
238
- return new Promise((i) => {
239
- const n = this.on(t, (s) => {
240
- n(), r(s), i(s);
241
- });
242
- });
192
+ isRenderingComponent() {
193
+ return this.currentComponent !== null;
243
194
  }
244
195
  /**
245
- * Get a list of all active event names with registered handlers.
196
+ * Return whether we should emit a render-time warning for the current component.
197
+ * This throttles warnings to avoid spamming the console for legitimate rapid updates.
246
198
  */
247
- getActiveEvents() {
248
- return Object.keys(this.handlers).filter(
249
- (t) => this.handlers[t] && this.handlers[t].size > 0
250
- );
199
+ shouldEmitRenderWarning() {
200
+ if (!this.currentComponent) return !0;
201
+ const t = this.currentComponent, r = this.lastWarningTime.get(t) || 0, n = Date.now();
202
+ return n - r < 1e3 ? !1 : (this.lastWarningTime.set(t, n), !0);
251
203
  }
252
204
  /**
253
- * Clear all event handlers (useful for testing or cleanup).
205
+ * Execute a function with tracking disabled
254
206
  */
255
- clear() {
256
- this.handlers = {};
207
+ withoutTracking(t) {
208
+ const r = this.trackingDisabled;
209
+ this.trackingDisabled = !0;
210
+ try {
211
+ return t();
212
+ } finally {
213
+ this.trackingDisabled = r;
214
+ }
257
215
  }
258
216
  /**
259
- * Get the number of handlers registered for a specific event.
260
- * @param eventName - Name of the event
217
+ * Get or create a state instance for the current component
261
218
  */
262
- getHandlerCount(t) {
263
- return this.handlers[t]?.size || 0;
219
+ getOrCreateState(t) {
220
+ if (!this.currentComponent)
221
+ return new De(t);
222
+ const r = this.currentComponent, n = this.stateIndexCounter.get(r) || 0, i = `${r}:${n}`;
223
+ if (this.stateIndexCounter.set(r, n + 1), this.stateStorage.has(i))
224
+ return this.stateStorage.get(i);
225
+ const s = new De(t);
226
+ return this.stateStorage.set(i, s), s;
264
227
  }
265
228
  /**
266
- * Get event statistics for debugging.
229
+ * Track a dependency for the current component
267
230
  */
268
- getEventStats() {
269
- const t = {};
270
- for (const [r, i] of this.eventCounters.entries())
271
- t[r] = {
272
- count: i.count,
273
- handlersCount: this.getHandlerCount(r)
274
- };
275
- return t;
231
+ trackDependency(t) {
232
+ this.trackingDisabled || this.currentComponent && (this.componentDependencies.get(this.currentComponent)?.add(t), t.addDependent(this.currentComponent));
276
233
  }
277
234
  /**
278
- * Reset event counters (useful for testing or after resolving issues).
235
+ * Trigger updates for all components that depend on a state
279
236
  */
280
- resetEventCounters() {
281
- this.eventCounters.clear();
282
- }
283
- }
284
- const le = ne.getInstance(), Ft = (e, t) => le.emit(e, t), Kt = (e, t) => le.on(e, t), Jt = (e, t) => le.off(e, t), Vt = (e, t) => le.once(e, t), Gt = (e, t, r) => le.listen(e, t, r);
285
- function Le(e) {
286
- let t = { ...e };
287
- const r = [];
288
- function i(a) {
289
- r.push(a), a(t);
237
+ triggerUpdate(t) {
238
+ t.getDependents().forEach((r) => {
239
+ const n = this.componentRenderFunctions.get(r);
240
+ n && le(n, r);
241
+ });
290
242
  }
291
- function n() {
292
- return t;
243
+ /**
244
+ * Clean up component dependencies when component is destroyed
245
+ */
246
+ cleanup(t) {
247
+ const r = this.componentDependencies.get(t);
248
+ r && (r.forEach((n) => n.removeDependent(t)), this.componentDependencies.delete(t)), this.componentRenderFunctions.delete(t);
249
+ for (const n of Array.from(this.stateStorage.keys()))
250
+ n.startsWith(t + ":") && this.stateStorage.delete(n);
251
+ this.stateIndexCounter.delete(t);
252
+ }
253
+ }
254
+ const F = new pt();
255
+ class De {
256
+ _value;
257
+ dependents = /* @__PURE__ */ new Set();
258
+ constructor(t) {
259
+ this._value = this.makeReactive(t);
260
+ }
261
+ get value() {
262
+ return F.trackDependency(this), this._value;
263
+ }
264
+ set value(t) {
265
+ F.isRenderingComponent() && F.shouldEmitRenderWarning() && console.warn(
266
+ `🚨 State modification detected during render! This can cause infinite loops.
267
+ • Move state updates to event handlers
268
+ • Use useEffect/watch for side effects
269
+ • Ensure computed properties don't modify state`
270
+ ), this._value = this.makeReactive(t), F.triggerUpdate(this);
271
+ }
272
+ addDependent(t) {
273
+ this.dependents.add(t);
274
+ }
275
+ removeDependent(t) {
276
+ this.dependents.delete(t);
277
+ }
278
+ getDependents() {
279
+ return this.dependents;
280
+ }
281
+ makeReactive(t) {
282
+ return t === null || typeof t != "object" || t instanceof Node || t instanceof Element || t instanceof HTMLElement ? t : tt.createReactiveProxy(
283
+ t,
284
+ () => F.triggerUpdate(this),
285
+ (r) => this.makeReactive(r)
286
+ );
293
287
  }
294
- function s(a) {
295
- const c = typeof a == "function" ? a(t) : a;
296
- t = { ...t, ...c }, o();
288
+ }
289
+ function or(e) {
290
+ return F.getOrCreateState(e === void 0 ? null : e);
291
+ }
292
+ function ar(e) {
293
+ const t = new De(e());
294
+ return {
295
+ get value() {
296
+ return F.trackDependency(t), e();
297
+ }
298
+ };
299
+ }
300
+ function cr(e, t, r = {}) {
301
+ let n = e();
302
+ r.immediate && t(n, n);
303
+ const i = `watch-${Math.random().toString(36).substr(2, 9)}`, s = () => {
304
+ F.setCurrentComponent(i, s);
305
+ const o = e();
306
+ F.clearCurrentComponent(), o !== n && (t(o, n), n = o);
307
+ };
308
+ return F.setCurrentComponent(i, s), e(), F.clearCurrentComponent(), () => {
309
+ F.cleanup(i);
310
+ };
311
+ }
312
+ const be = /* @__PURE__ */ new Map(), we = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ new Map(), He = 500;
313
+ function te(e) {
314
+ if (be.has(e))
315
+ return be.get(e);
316
+ const t = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
317
+ return be.size < He && be.set(e, t), t;
318
+ }
319
+ function rt(e) {
320
+ if (we.has(e))
321
+ return we.get(e);
322
+ const t = e.replace(/-([a-z])/g, (r, n) => n.toUpperCase());
323
+ return we.size < He && we.set(e, t), t;
324
+ }
325
+ function ne(e) {
326
+ if (typeof e == "string") {
327
+ if (ve.has(e))
328
+ return ve.get(e);
329
+ const t = e.replace(
330
+ /[&<>"']/g,
331
+ (r) => ({
332
+ "&": "&amp;",
333
+ "<": "&lt;",
334
+ ">": "&gt;",
335
+ '"': "&quot;",
336
+ "'": "&#39;"
337
+ })[r]
338
+ );
339
+ return t !== e && ve.size < He && ve.set(e, t), t;
297
340
  }
298
- function o() {
299
- r.forEach((a) => a(t));
341
+ return e;
342
+ }
343
+ function H(e, t) {
344
+ if (typeof t == "string") {
345
+ const r = t.split(".").reduce((n, i) => n?.[i], e);
346
+ return r && typeof r == "object" && r.constructor && r.constructor.name === "ReactiveState" ? r.value : r;
300
347
  }
301
- return { subscribe: i, getState: n, setState: s };
302
- }
303
- function Q(e) {
304
- return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
305
- }
306
- function Z(e) {
307
- return typeof e == "string" ? e.replace(
308
- /[&<>"']/g,
309
- (t) => ({
310
- "&": "&amp;",
311
- "<": "&lt;",
312
- ">": "&gt;",
313
- '"': "&quot;",
314
- "'": "&#39;"
315
- })[t]
316
- ) : e;
317
- }
318
- function K(e, t) {
319
- return typeof t == "string" ? t.split(".").reduce((r, i) => r?.[i], e) : t;
320
- }
321
- function he(e, t, r) {
322
- const i = String(t).split("."), n = i.pop();
323
- if (!n) return;
324
- const s = i.reduce((o, a) => (o[a] == null && (o[a] = {}), o[a]), e);
325
- s[n] = r;
326
- }
327
- function Ge(e, t, r) {
348
+ return t;
349
+ }
350
+ function Ce(e, t, r) {
351
+ const n = String(t).split("."), i = n.pop();
352
+ if (!i) return;
353
+ const s = n.reduce((o, a) => (o[a] == null && (o[a] = {}), o[a]), e);
354
+ s[i] && typeof s[i] == "object" && s[i].constructor && s[i].constructor.name === "ReactiveState" ? s[i].value = r : s[i] = r;
355
+ }
356
+ const nt = typeof process < "u" && process.env?.NODE_ENV !== "production";
357
+ function ie(e, ...t) {
358
+ nt && console.error(e, ...t);
359
+ }
360
+ function Re(e, ...t) {
361
+ nt && console.warn(e, ...t);
362
+ }
363
+ function ht(e, t, r) {
328
364
  if (r)
329
- for (const [i, n] of Object.entries(r)) {
365
+ for (const [n, i] of Object.entries(r)) {
330
366
  let s, o = {};
331
- if (Array.isArray(n) ? (s = n[0], o = n[1] || {}) : s = n, t.set(i, {
367
+ if (Array.isArray(i) ? (s = i[0], o = i[1] || {}) : s = i, t.set(n, {
332
368
  callback: s,
333
369
  options: o,
334
- oldValue: K(e, i)
370
+ oldValue: H(e, n)
335
371
  }), o.immediate)
336
372
  try {
337
- const a = K(e, i);
373
+ const a = H(e, n);
338
374
  s(a, void 0, e);
339
375
  } catch (a) {
340
- Y(`Error in immediate watcher for "${i}":`, a);
376
+ ie(`Error in immediate watcher for "${n}":`, a);
341
377
  }
342
378
  }
343
379
  }
344
- function Ze(e, t, r, i) {
345
- const n = (o, a) => {
380
+ function gt(e, t, r, n) {
381
+ const i = (o, a) => {
346
382
  if (o === a) return !0;
347
383
  if (typeof o != typeof a || typeof o != "object" || o === null || a === null) return !1;
348
384
  if (Array.isArray(o) && Array.isArray(a))
349
- return o.length !== a.length ? !1 : o.every((m, T) => n(m, a[T]));
350
- const c = Object.keys(o), u = Object.keys(a);
351
- return c.length !== u.length ? !1 : c.every((m) => n(o[m], a[m]));
385
+ return o.length !== a.length ? !1 : o.every((g, w) => i(g, a[w]));
386
+ const u = Object.keys(o), m = Object.keys(a);
387
+ return u.length !== m.length ? !1 : u.every((g) => i(o[g], a[g]));
352
388
  }, s = t.get(r);
353
- if (s && !n(i, s.oldValue))
389
+ if (s && !i(n, s.oldValue))
354
390
  try {
355
- s.callback(i, s.oldValue, e), s.oldValue = i;
391
+ s.callback(n, s.oldValue, e), s.oldValue = n;
356
392
  } catch (o) {
357
- Y(`Error in watcher for "${r}":`, o);
393
+ ie(`Error in watcher for "${r}":`, o);
358
394
  }
359
395
  for (const [o, a] of t.entries())
360
396
  if (a.options.deep && r.startsWith(o + "."))
361
397
  try {
362
- const c = K(e, o);
363
- n(c, a.oldValue) || (a.callback(c, a.oldValue, e), a.oldValue = c);
364
- } catch (c) {
365
- Y(`Error in deep watcher for "${o}":`, c);
398
+ const u = H(e, o);
399
+ i(u, a.oldValue) || (a.callback(u, a.oldValue, e), a.oldValue = u);
400
+ } catch (u) {
401
+ ie(`Error in deep watcher for "${o}":`, u);
366
402
  }
367
403
  }
368
- function Ye(e, t, r) {
369
- if (!t.props) return;
370
- function i(n, s) {
371
- return s === Boolean ? n === "true" : s === Number ? Number(n) : n;
372
- }
373
- Object.entries(t.props).forEach(([n, s]) => {
374
- if (s.type === Function && typeof e[n] == "function")
404
+ function qe(e, t) {
405
+ return t === Boolean ? e === "true" : t === Number ? Number(e) : e;
406
+ }
407
+ function mt(e, t, r) {
408
+ t && Object.entries(t).forEach(([n, i]) => {
409
+ const s = te(n), o = e.getAttribute(s);
410
+ if (i.type === Function && typeof e[n] == "function")
375
411
  r[n] = e[n];
376
- else {
377
- const o = Q(n), a = e.getAttribute(o);
378
- if (typeof e[n] < "u")
412
+ else if (typeof e[n] < "u")
413
+ try {
414
+ const a = e[n];
415
+ i.type === Boolean && typeof a == "boolean" || i.type === Number && typeof a == "number" || i.type === Function && typeof a == "function" ? r[n] = a : r[n] = ne(qe(String(a), i.type));
416
+ } catch {
417
+ r[n] = e[n];
418
+ }
419
+ else o !== null ? r[n] = ne(qe(o, i.type)) : "default" in i && i.default !== void 0 && (r[n] = ne(i.default));
420
+ });
421
+ }
422
+ function yt(e, t, r) {
423
+ t.props && mt(e, t.props, r);
424
+ }
425
+ function bt(e, t, r, n) {
426
+ e.onConnected && !r && (e.onConnected(t), n(!0));
427
+ }
428
+ function wt(e, t, r, n, i, s, o, a) {
429
+ e.onDisconnected && e.onDisconnected(t), r.forEach((u) => u()), n(), i(), s(!1), o(null), a(!1);
430
+ }
431
+ function vt(e, t, r, n, i) {
432
+ e.onAttributeChanged && e.onAttributeChanged(t, r, n, i);
433
+ }
434
+ class xt {
435
+ static cache = /* @__PURE__ */ new Map();
436
+ static maxCacheSize = 1e3;
437
+ // Dangerous patterns to block
438
+ static dangerousPatterns = [
439
+ /constructor/i,
440
+ /prototype/i,
441
+ /__proto__/i,
442
+ /function/i,
443
+ /eval/i,
444
+ /import/i,
445
+ /require/i,
446
+ /window/i,
447
+ /document/i,
448
+ /global/i,
449
+ /process/i,
450
+ /setTimeout/i,
451
+ /setInterval/i,
452
+ /fetch/i,
453
+ /XMLHttpRequest/i
454
+ ];
455
+ static evaluate(t, r) {
456
+ const n = this.cache.get(t);
457
+ if (n) {
458
+ if (!n.isSecure) {
459
+ Re("Blocked cached dangerous expression:", t);
460
+ return;
461
+ }
462
+ return n.evaluator(r);
463
+ }
464
+ const i = this.createEvaluator(t);
465
+ if (this.cache.size >= this.maxCacheSize) {
466
+ const s = this.cache.keys().next().value;
467
+ s && this.cache.delete(s);
468
+ }
469
+ if (this.cache.set(t, i), !i.isSecure) {
470
+ Re("Blocked dangerous expression:", t);
471
+ return;
472
+ }
473
+ return i.evaluator(r);
474
+ }
475
+ static createEvaluator(t) {
476
+ if (this.hasDangerousPatterns(t))
477
+ return { evaluator: () => {
478
+ }, isSecure: !1 };
479
+ if (t.length > 1e3)
480
+ return { evaluator: () => {
481
+ }, isSecure: !1 };
482
+ try {
483
+ return { evaluator: this.createSafeEvaluator(t), isSecure: !0 };
484
+ } catch (r) {
485
+ return Re("Failed to create evaluator for expression:", t, r), { evaluator: () => {
486
+ }, isSecure: !1 };
487
+ }
488
+ }
489
+ static hasDangerousPatterns(t) {
490
+ return this.dangerousPatterns.some((r) => r.test(t));
491
+ }
492
+ static createSafeEvaluator(t) {
493
+ if (t.trim().startsWith("{") && t.trim().endsWith("}"))
494
+ return this.createObjectEvaluator(t);
495
+ if (/^ctx\.[a-zA-Z0-9_\.]+$/.test(t.trim())) {
496
+ const r = t.trim().slice(4);
497
+ return (n) => H(n, r);
498
+ }
499
+ return t.includes("ctx") || /[+\-*/%<>=&|?:\[\]]/.test(t) ? this.createSimpleEvaluator(t) : (r) => H(r, t);
500
+ }
501
+ static createObjectEvaluator(t) {
502
+ const r = t.trim().slice(1, -1), n = this.parseObjectProperties(r);
503
+ return (i) => {
504
+ const s = {};
505
+ for (const { key: o, value: a } of n)
379
506
  try {
380
- const c = e[n];
381
- s.type === Boolean && typeof c == "boolean" || s.type === Number && typeof c == "number" || s.type === Function && typeof c == "function" ? r[n] = c : r[n] = Z(i(String(c), s.type));
507
+ if (a.startsWith("ctx.")) {
508
+ const u = a.slice(4);
509
+ s[o] = H(i, u);
510
+ } else
511
+ s[o] = this.evaluateSimpleValue(a, i);
382
512
  } catch {
383
- r[n] = e[n];
513
+ s[o] = void 0;
384
514
  }
385
- else a !== null ? r[n] = Z(i(a, s.type)) : "default" in s && s.default !== void 0 && (r[n] = Z(s.default));
515
+ return s;
516
+ };
517
+ }
518
+ static parseObjectProperties(t) {
519
+ const r = [], n = t.split(",");
520
+ for (const i of n) {
521
+ const s = i.indexOf(":");
522
+ if (s === -1) continue;
523
+ const o = i.slice(0, s).trim(), a = i.slice(s + 1).trim(), u = o.replace(/^['"]|['"]$/g, "");
524
+ r.push({ key: u, value: a });
386
525
  }
387
- });
388
- }
389
- function Qe(e, t, r, i) {
390
- e.onConnected && !r && (e.onConnected(t), i(!0));
391
- }
392
- function Xe(e, t, r, i, n, s, o, a) {
393
- e.onDisconnected && e.onDisconnected(t), r.forEach((c) => c()), i(), n(), s(!1), o(null), a(!1);
526
+ return r;
527
+ }
528
+ static createSimpleEvaluator(t) {
529
+ return (r) => {
530
+ try {
531
+ let n = t;
532
+ const i = [];
533
+ n = n.replace(/("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*')/g, (w) => `<<#${i.push(w) - 1}#>>`);
534
+ const s = n.match(/ctx\.[\w.]+/g) || [];
535
+ for (const w of s) {
536
+ const h = w.slice(4), l = H(r, h);
537
+ if (l === void 0) return;
538
+ const d = i.push(JSON.stringify(l)) - 1;
539
+ n = n.replace(new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), `<<#${d}#>>`);
540
+ }
541
+ const o = /\b[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)+\b/g, a = n.match(o) || [];
542
+ for (const w of a) {
543
+ if (w.startsWith("ctx.")) continue;
544
+ const h = H(r, w);
545
+ if (h === void 0) return;
546
+ const l = i.push(JSON.stringify(h)) - 1;
547
+ n = n.replace(new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), `<<#${l}#>>`);
548
+ }
549
+ const u = /\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g;
550
+ let m;
551
+ const g = /* @__PURE__ */ new Set();
552
+ for (; (m = u.exec(n)) !== null; ) {
553
+ const w = m[1];
554
+ if (["true", "false", "null", "undefined"].includes(w) || /^[0-9]+$/.test(w) || w === "ctx" || g.has(w)) continue;
555
+ g.add(w);
556
+ const h = H(r, w);
557
+ if (h === void 0) return;
558
+ const l = JSON.stringify(h), d = i.push(l) - 1;
559
+ w.includes(".") ? n = n.replace(new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), `<<#${d}#>>`) : n = n.replace(new RegExp("\\b" + w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "\\b", "g"), `<<#${d}#>>`);
560
+ }
561
+ n = n.replace(/<<#(\d+)#>>/g, (w, h) => i[Number(h)]);
562
+ try {
563
+ return this.evaluateBasicExpression(n);
564
+ } catch {
565
+ return;
566
+ }
567
+ } catch {
568
+ return;
569
+ }
570
+ };
571
+ }
572
+ /**
573
+ * Evaluate a very small, safe expression grammar without using eval/Function.
574
+ * Supports: numbers, string literals, true/false, null, arrays, unary !,
575
+ * arithmetic (+ - * / %), comparisons, logical && and ||, parentheses, and ternary `a ? b : c`.
576
+ */
577
+ static evaluateBasicExpression(t) {
578
+ const r = this.tokenize(t);
579
+ let n = 0;
580
+ function i() {
581
+ return r[n];
582
+ }
583
+ function s(c) {
584
+ const p = r[n++];
585
+ if (c && !p)
586
+ throw new Error(`Unexpected token EOF, expected ${c}`);
587
+ if (c && p && p.type !== c && p.value !== c)
588
+ throw new Error(`Unexpected token ${p.type}/${p.value}, expected ${c}`);
589
+ return p;
590
+ }
591
+ function o() {
592
+ return a();
593
+ }
594
+ function a() {
595
+ let c = u();
596
+ if (i() && i().value === "?") {
597
+ s("?");
598
+ const p = o();
599
+ s(":");
600
+ const y = o();
601
+ return c ? p : y;
602
+ }
603
+ return c;
604
+ }
605
+ function u() {
606
+ let c = m();
607
+ for (; i() && i().value === "||"; ) {
608
+ s("OP");
609
+ const p = m();
610
+ c = c || p;
611
+ }
612
+ return c;
613
+ }
614
+ function m() {
615
+ let c = g();
616
+ for (; i() && i().value === "&&"; ) {
617
+ s("OP");
618
+ const p = g();
619
+ c = c && p;
620
+ }
621
+ return c;
622
+ }
623
+ function g() {
624
+ let c = w();
625
+ for (; i() && ["==", "!=", "===", "!=="].includes(i().value); ) {
626
+ const p = s("OP").value, y = w();
627
+ switch (p) {
628
+ case "==":
629
+ c = c == y;
630
+ break;
631
+ case "!=":
632
+ c = c != y;
633
+ break;
634
+ case "===":
635
+ c = c === y;
636
+ break;
637
+ case "!==":
638
+ c = c !== y;
639
+ break;
640
+ }
641
+ }
642
+ return c;
643
+ }
644
+ function w() {
645
+ let c = h();
646
+ for (; i() && [">", "<", ">=", "<="].includes(i().value); ) {
647
+ const p = s("OP").value, y = h();
648
+ switch (p) {
649
+ case ">":
650
+ c = c > y;
651
+ break;
652
+ case "<":
653
+ c = c < y;
654
+ break;
655
+ case ">=":
656
+ c = c >= y;
657
+ break;
658
+ case "<=":
659
+ c = c <= y;
660
+ break;
661
+ }
662
+ }
663
+ return c;
664
+ }
665
+ function h() {
666
+ let c = l();
667
+ for (; i() && (i().value === "+" || i().value === "-"); ) {
668
+ const p = s("OP").value, y = l();
669
+ c = p === "+" ? c + y : c - y;
670
+ }
671
+ return c;
672
+ }
673
+ function l() {
674
+ let c = d();
675
+ for (; i() && (i().value === "*" || i().value === "/" || i().value === "%"); ) {
676
+ const p = s("OP").value, y = d();
677
+ switch (p) {
678
+ case "*":
679
+ c = c * y;
680
+ break;
681
+ case "/":
682
+ c = c / y;
683
+ break;
684
+ case "%":
685
+ c = c % y;
686
+ break;
687
+ }
688
+ }
689
+ return c;
690
+ }
691
+ function d() {
692
+ return i() && i().value === "!" ? (s("OP"), !d()) : i() && i().value === "-" ? (s("OP"), -d()) : v();
693
+ }
694
+ function v() {
695
+ const c = i();
696
+ if (c) {
697
+ if (c.type === "NUMBER")
698
+ return s("NUMBER"), Number(c.value);
699
+ if (c.type === "STRING")
700
+ return s("STRING"), c.value.slice(1, -1);
701
+ if (c.type === "IDENT")
702
+ return s("IDENT"), c.value === "true" ? !0 : c.value === "false" ? !1 : c.value === "null" ? null : void 0;
703
+ if (c.value === "[") {
704
+ s("PUNC");
705
+ const p = [];
706
+ for (; i() && i().value !== "]"; )
707
+ p.push(o()), i() && i().value === "," && s("PUNC");
708
+ return s("PUNC"), p;
709
+ }
710
+ if (c.value === "(") {
711
+ s("PUNC");
712
+ const p = o();
713
+ return s("PUNC"), p;
714
+ }
715
+ throw new Error("Unexpected token in expression");
716
+ }
717
+ }
718
+ return o();
719
+ }
720
+ static tokenize(t) {
721
+ const r = [], n = /\s*(=>|===|!==|==|!=|>=|<=|\|\||&&|[()?:,\[\]]|\+|-|\*|\/|%|>|<|!|\d+\.?\d*|"[^"]*"|'[^']*'|[a-zA-Z_][a-zA-Z0-9_]*|\S)\s*/g;
722
+ let i;
723
+ for (; (i = n.exec(t)) !== null; ) {
724
+ const s = i[1];
725
+ s && (/^\d/.test(s) ? r.push({ type: "NUMBER", value: s }) : /^"/.test(s) || /^'/.test(s) ? r.push({ type: "STRING", value: s }) : /^[a-zA-Z_]/.test(s) ? r.push({ type: "IDENT", value: s }) : /^[()?:,\[\]]$/.test(s) ? r.push({ type: "PUNC", value: s }) : r.push({ type: "OP", value: s }));
726
+ }
727
+ return r;
728
+ }
729
+ static evaluateSimpleValue(t, r) {
730
+ if (t === "true") return !0;
731
+ if (t === "false") return !1;
732
+ if (!isNaN(Number(t))) return Number(t);
733
+ if (t.startsWith("ctx.")) {
734
+ const n = t.slice(4);
735
+ return H(r, n);
736
+ }
737
+ return t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'") ? t.slice(1, -1) : t;
738
+ }
739
+ static clearCache() {
740
+ this.cache.clear();
741
+ }
742
+ static getCacheSize() {
743
+ return this.cache.size;
744
+ }
394
745
  }
395
- function et(e, t, r, i, n) {
396
- e.onAttributeChanged && e.onAttributeChanged(t, r, i, n);
746
+ class se {
747
+ static cleanupFunctions = /* @__PURE__ */ new WeakMap();
748
+ /**
749
+ * Add an event listener with automatic cleanup tracking
750
+ */
751
+ static addListener(t, r, n, i) {
752
+ t.addEventListener(r, n, i);
753
+ const o = { event: r, handler: n, options: i, cleanup: () => t.removeEventListener(r, n, i), addedAt: Date.now() };
754
+ this.cleanupFunctions.has(t) || this.cleanupFunctions.set(t, []);
755
+ const a = this.cleanupFunctions.get(t);
756
+ a.push(o), this.cleanupFunctions.get(t).__metaList = a;
757
+ }
758
+ /**
759
+ * Remove a specific event listener
760
+ */
761
+ static removeListener(t, r, n, i) {
762
+ t.removeEventListener(r, n, i);
763
+ const s = this.cleanupFunctions.get(t);
764
+ if (s) {
765
+ const o = s.__metaList || null;
766
+ if (o) {
767
+ const a = o.findIndex((u) => u.event === r && u.handler === n && JSON.stringify(u.options) === JSON.stringify(i));
768
+ if (a >= 0) {
769
+ try {
770
+ o[a].cleanup();
771
+ } catch {
772
+ }
773
+ o.splice(a, 1);
774
+ }
775
+ o.length === 0 && this.cleanupFunctions.delete(t);
776
+ } else {
777
+ const a = s.findIndex(() => !0);
778
+ a >= 0 && (s.splice(a, 1), s.length === 0 && this.cleanupFunctions.delete(t));
779
+ }
780
+ }
781
+ }
782
+ /**
783
+ * Clean up all event listeners for an element
784
+ */
785
+ static cleanup(t) {
786
+ const r = this.cleanupFunctions.get(t);
787
+ r && ((r.__metaList || r).forEach((i) => {
788
+ try {
789
+ typeof i == "function" ? i() : i && typeof i.cleanup == "function" && i.cleanup();
790
+ } catch (s) {
791
+ console.error("Error during event cleanup:", s);
792
+ }
793
+ }), this.cleanupFunctions.delete(t));
794
+ }
795
+ /**
796
+ * Clean up all tracked event listeners (useful for testing)
797
+ */
798
+ static cleanupAll() {
799
+ try {
800
+ this.cleanupFunctions = /* @__PURE__ */ new WeakMap();
801
+ } catch (t) {
802
+ console.error("Error during global cleanup:", t);
803
+ }
804
+ }
805
+ /**
806
+ * Check if an element has any tracked event listeners
807
+ */
808
+ static hasListeners(t) {
809
+ const r = this.cleanupFunctions.get(t), n = r ? r.__metaList || r : void 0;
810
+ return !!(n && n.length > 0);
811
+ }
812
+ /**
813
+ * Get the number of tracked event listeners for an element
814
+ */
815
+ static getListenerCount(t) {
816
+ const r = this.cleanupFunctions.get(t), n = r ? r.__metaList || r : void 0;
817
+ return n ? n.length : 0;
818
+ }
397
819
  }
398
- function te(e, t) {
820
+ function ce(e, t) {
399
821
  if (t && e instanceof HTMLElement) {
822
+ se.cleanup(e);
400
823
  for (const r in t)
401
824
  t[r] === e && delete t[r];
402
825
  for (const r of Array.from(e.childNodes))
403
- te(r, t);
826
+ ce(r, t);
404
827
  }
405
828
  }
406
- function tt(e, t, r, i, n, s, o, a) {
829
+ function de(e, t, r) {
830
+ if (typeof e == "string") return;
831
+ const n = e.props?.reactiveRef ?? (e.props?.props && e.props.props.reactiveRef), i = e.props?.ref ?? (e.props?.props && e.props.props.ref);
832
+ n ? n.value = t : i && r && (r[i] = t);
833
+ }
834
+ function kt(e, t, r, n, i, s, o, a) {
407
835
  if (!s) return;
408
- const c = t.includes("lazy"), u = t.includes("trim"), m = t.includes("number"), T = () => K(s._state || s, e), p = T();
409
- let l = "text";
410
- o instanceof HTMLInputElement ? l = i?.type || o.type || "text" : o instanceof HTMLSelectElement ? l = "select" : o instanceof HTMLTextAreaElement && (l = "textarea");
411
- const w = o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement || o instanceof HTMLSelectElement, d = w ? l === "checkbox" || l === "radio" ? "checked" : "value" : a ?? "modelValue";
412
- if (l === "checkbox")
413
- if (Array.isArray(p))
414
- r[d] = p.includes(String(o?.getAttribute("value") ?? i?.value ?? ""));
836
+ const u = t.includes("lazy"), m = t.includes("trim"), g = t.includes("number"), w = e && typeof e == "object" && "value" in e && typeof e.value < "u", h = () => {
837
+ if (w) {
838
+ const C = e.value;
839
+ return a && typeof C == "object" && C !== null ? C[a] : C;
840
+ }
841
+ return H(s._state || s, e);
842
+ }, l = h();
843
+ let d = "text";
844
+ o instanceof HTMLInputElement ? d = n?.type || o.type || "text" : o instanceof HTMLSelectElement ? d = "select" : o instanceof HTMLTextAreaElement && (d = "textarea");
845
+ const v = o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement || o instanceof HTMLSelectElement, c = v ? d === "checkbox" || d === "radio" ? "checked" : "value" : a ?? "modelValue";
846
+ if (d === "checkbox")
847
+ if (Array.isArray(l))
848
+ r[c] = l.includes(String(o?.getAttribute("value") ?? n?.value ?? ""));
415
849
  else {
416
- const x = o?.getAttribute("true-value") ?? !0;
417
- r[d] = p === x;
850
+ const C = o?.getAttribute("true-value") ?? !0;
851
+ r[c] = l === C;
418
852
  }
419
- else if (l === "radio")
420
- r[d] = p === (i?.value ?? "");
421
- else if (l === "select")
853
+ else if (d === "radio")
854
+ r[c] = l === (n?.value ?? "");
855
+ else if (d === "select")
422
856
  if (o && o.hasAttribute("multiple") && o instanceof HTMLSelectElement) {
423
- const x = Array.isArray(p) ? p.map(String) : [];
857
+ const C = Array.isArray(l) ? l.map(String) : [];
424
858
  setTimeout(() => {
425
- Array.from(o.options).forEach((f) => {
426
- f.selected = x.includes(f.value);
859
+ Array.from(o.options).forEach((k) => {
860
+ k.selected = C.includes(k.value);
427
861
  });
428
- }, 0), r[d] = Array.isArray(p) ? p : [];
862
+ }, 0), r[c] = Array.isArray(l) ? l : [];
429
863
  } else
430
- r[d] = p;
864
+ r[c] = l;
431
865
  else {
432
- r[d] = p;
866
+ r[c] = l;
433
867
  try {
434
- const x = Q(d);
435
- i && (i[x] = p);
868
+ const C = te(c);
869
+ n && (n[C] = l);
436
870
  } catch {
437
871
  }
438
872
  }
439
- const g = c || l === "checkbox" || l === "radio" || l === "select" ? "change" : "input", y = (x) => {
440
- if (x.isComposing || n._isComposing) return;
441
- const f = typeof globalThis.process < "u" && globalThis.process.env?.NODE_ENV === "test" || typeof window < "u" && window.__vitest__;
442
- if (x.isTrusted === !1 && !f) return;
443
- const b = x.target;
444
- if (!b || b._modelUpdating) return;
445
- let h = b.value;
446
- if (l === "checkbox") {
447
- const E = T();
448
- if (Array.isArray(E)) {
449
- const C = b.getAttribute("value") ?? "", A = Array.from(E);
450
- if (b.checked)
451
- A.includes(C) || A.push(C);
873
+ const p = u || d === "checkbox" || d === "radio" || d === "select" ? "change" : "input", y = (C) => {
874
+ if (C.isComposing || i._isComposing) return;
875
+ const k = typeof globalThis.process < "u" && globalThis.process.env?.NODE_ENV === "test" || typeof window < "u" && window.__vitest__;
876
+ if (C.isTrusted === !1 && !k) return;
877
+ const f = C.target;
878
+ if (!f || f._modelUpdating) return;
879
+ let x = f.value;
880
+ if (d === "checkbox") {
881
+ const R = h();
882
+ if (Array.isArray(R)) {
883
+ const T = f.getAttribute("value") ?? "", $ = Array.from(R);
884
+ if (f.checked)
885
+ $.includes(T) || $.push(T);
452
886
  else {
453
- const P = A.indexOf(C);
454
- P > -1 && A.splice(P, 1);
887
+ const P = $.indexOf(T);
888
+ P > -1 && $.splice(P, 1);
455
889
  }
456
- h = A;
890
+ x = $;
457
891
  } else {
458
- const C = b.getAttribute("true-value") ?? !0, A = b.getAttribute("false-value") ?? !1;
459
- h = b.checked ? C : A;
892
+ const T = f.getAttribute("true-value") ?? !0, $ = f.getAttribute("false-value") ?? !1;
893
+ x = f.checked ? T : $;
460
894
  }
461
- } else if (l === "radio")
462
- h = b.getAttribute("value") ?? b.value;
463
- else if (l === "select" && b.multiple)
464
- h = Array.from(b.selectedOptions).map((E) => E.value);
465
- else if (u && typeof h == "string" && (h = h.trim()), m) {
466
- const E = Number(h);
467
- isNaN(E) || (h = E);
468
- }
469
- const _ = s._state || s, $ = K(_, e);
470
- if (Array.isArray(h) && Array.isArray($) ? JSON.stringify([...h].sort()) !== JSON.stringify([...$].sort()) : h !== $) {
471
- b._modelUpdating = !0;
895
+ } else if (d === "radio")
896
+ x = f.getAttribute("value") ?? f.value;
897
+ else if (d === "select" && f.multiple)
898
+ x = Array.from(f.selectedOptions).map((R) => R.value);
899
+ else if (m && typeof x == "string" && (x = x.trim()), g) {
900
+ const R = Number(x);
901
+ isNaN(R) || (x = R);
902
+ }
903
+ const A = s._state || s, _ = h();
904
+ if (Array.isArray(x) && Array.isArray(_) ? JSON.stringify([...x].sort()) !== JSON.stringify([..._].sort()) : x !== _) {
905
+ f._modelUpdating = !0;
472
906
  try {
473
- if (he(_, e, h), s._requestRender && s._requestRender(), s._triggerWatchers && s._triggerWatchers(e, h), b) {
474
- const E = `update:${Q(d)}`, C = new CustomEvent(E, {
475
- detail: h,
907
+ if (w)
908
+ if (a && typeof e.value == "object" && e.value !== null) {
909
+ const R = { ...e.value };
910
+ R[a] = x, e.value = R;
911
+ } else
912
+ e.value = x;
913
+ else
914
+ Ce(A, e, x);
915
+ if (s._requestRender && s._requestRender(), s._triggerWatchers) {
916
+ const R = w ? "reactiveState" : e;
917
+ s._triggerWatchers(R, x);
918
+ }
919
+ if (f) {
920
+ const R = `update:${te(c)}`, T = new CustomEvent(R, {
921
+ detail: x,
476
922
  bubbles: !0,
477
923
  composed: !0
478
924
  });
479
- b.dispatchEvent(C);
925
+ f.dispatchEvent(T);
480
926
  }
481
927
  } finally {
482
- setTimeout(() => b._modelUpdating = !1, 0);
928
+ setTimeout(() => f._modelUpdating = !1, 0);
483
929
  }
484
930
  }
485
931
  };
486
- if (w) {
487
- if (n[g]) {
488
- const x = n[g];
489
- o && o.removeEventListener(g, x);
932
+ if (v) {
933
+ if (i[p]) {
934
+ const C = i[p];
935
+ o && se.removeListener(o, p, C);
490
936
  }
491
- n[g] = y;
937
+ i[p] = y;
492
938
  } else {
493
- const x = `update:${Q(d)}`;
494
- if (n[x]) {
495
- const f = n[x];
496
- o && o.removeEventListener(x, f);
497
- }
498
- n[x] = (f) => {
499
- const b = s._state || s, h = f.detail !== void 0 ? f.detail : f.target?.value, _ = K(b, e);
500
- if (Array.isArray(h) && Array.isArray(_) ? JSON.stringify([...h].sort()) !== JSON.stringify([..._].sort()) : h !== _) {
501
- he(b, e, h), s._requestRender && s._requestRender(), s._triggerWatchers && s._triggerWatchers(e, h);
502
- const S = f.target;
939
+ const C = `update:${te(c)}`;
940
+ if (i[C]) {
941
+ const k = i[C];
942
+ o && se.removeListener(o, C, k);
943
+ }
944
+ i[C] = (k) => {
945
+ const f = s._state || s, x = k.detail !== void 0 ? k.detail : k.target?.value, A = H(f, e);
946
+ if (Array.isArray(x) && Array.isArray(A) ? JSON.stringify([...x].sort()) !== JSON.stringify([...A].sort()) : x !== A) {
947
+ Ce(f, e, x), s._requestRender && s._requestRender(), s._triggerWatchers && s._triggerWatchers(e, x);
948
+ const S = k.target;
503
949
  if (S) {
504
- S[d] = h;
950
+ S[c] = x;
505
951
  try {
506
- const E = Q(d);
507
- typeof h == "boolean" ? h ? S.setAttribute(E, "true") : S.setAttribute(E, "false") : S.setAttribute(E, String(h));
952
+ const R = te(c);
953
+ typeof x == "boolean" ? x ? S.setAttribute(R, "true") : S.setAttribute(R, "false") : S.setAttribute(R, String(x));
508
954
  } catch {
509
955
  }
510
956
  queueMicrotask(() => {
@@ -514,143 +960,111 @@ function tt(e, t, r, i, n, s, o, a) {
514
960
  }
515
961
  };
516
962
  }
517
- (l === "text" || l === "textarea") && (n.compositionstart = (() => n._isComposing = !0), n.compositionend = (x) => {
518
- n._isComposing = !1;
519
- const f = x.target;
520
- f && setTimeout(() => {
521
- const b = f.value, h = s._state || s, _ = K(h, e);
522
- let $ = b;
523
- if (u && ($ = $.trim()), m) {
524
- const E = Number($);
525
- isNaN(E) || ($ = E);
963
+ (d === "text" || d === "textarea") && (i.compositionstart = (() => i._isComposing = !0), i.compositionend = (C) => {
964
+ i._isComposing = !1;
965
+ const k = C.target;
966
+ k && setTimeout(() => {
967
+ const f = k.value, x = s._state || s, A = H(x, e);
968
+ let _ = f;
969
+ if (m && (_ = _.trim()), g) {
970
+ const R = Number(_);
971
+ isNaN(R) || (_ = R);
526
972
  }
527
- if (Array.isArray($) && Array.isArray(_) ? JSON.stringify([...$].sort()) !== JSON.stringify([..._].sort()) : $ !== _) {
528
- f._modelUpdating = !0;
973
+ if (Array.isArray(_) && Array.isArray(A) ? JSON.stringify([..._].sort()) !== JSON.stringify([...A].sort()) : _ !== A) {
974
+ k._modelUpdating = !0;
529
975
  try {
530
- he(h, e, $), s._requestRender && s._requestRender(), s._triggerWatchers && s._triggerWatchers(e, $);
976
+ Ce(x, e, _), s._requestRender && s._requestRender(), s._triggerWatchers && s._triggerWatchers(e, _);
531
977
  } finally {
532
- setTimeout(() => f._modelUpdating = !1, 0);
978
+ setTimeout(() => k._modelUpdating = !1, 0);
533
979
  }
534
980
  }
535
981
  }, 0);
536
982
  });
537
983
  }
538
- function Ne(e) {
984
+ function it(e) {
539
985
  const t = e.slice(2);
540
986
  return t ? t.charAt(0).toLowerCase() + t.slice(1) : "";
541
987
  }
542
- function rt(e, t, r, i) {
988
+ function Ct(e, t, r, n) {
543
989
  if (typeof e == "object" && e !== null)
544
- for (const [n, s] of Object.entries(e))
545
- n.startsWith("data-") || n.startsWith("aria-") || n === "class" ? r[n] = s : t[n] = s;
990
+ for (const [i, s] of Object.entries(e))
991
+ i.startsWith("data-") || i.startsWith("aria-") || i === "class" ? r[i] = s : t[i] = s;
546
992
  else if (typeof e == "string") {
547
- if (!i) return;
993
+ if (!n) return;
548
994
  try {
549
- const n = xe(e, i);
550
- if (typeof n == "object" && n !== null) {
551
- for (const [s, o] of Object.entries(n))
995
+ const i = he(e, n);
996
+ if (typeof i == "object" && i !== null) {
997
+ for (const [s, o] of Object.entries(i))
552
998
  s.startsWith("data-") || s.startsWith("aria-") || s === "class" ? r[s] = o : t[s] = o;
553
999
  return;
554
1000
  } else {
555
- r[e] = n;
1001
+ r[e] = i;
556
1002
  return;
557
1003
  }
558
1004
  } catch {
559
- const n = K(i, e);
560
- r[e] = n;
1005
+ const i = H(n, e);
1006
+ r[e] = i;
561
1007
  }
562
1008
  }
563
1009
  }
564
- function nt(e, t, r) {
565
- let i;
1010
+ function _t(e, t, r) {
1011
+ let n;
566
1012
  if (typeof e == "string") {
567
1013
  if (!r) return;
568
- i = xe(e, r);
1014
+ n = he(e, r);
569
1015
  } else
570
- i = e;
571
- const n = t.style || "";
572
- let s = n;
573
- if (i) {
574
- if (n) {
575
- const o = n.split(";").map((c) => c.trim()).filter(Boolean), a = o.findIndex(
576
- (c) => c.startsWith("display:")
1016
+ n = e;
1017
+ const i = t.style || "";
1018
+ let s = i;
1019
+ if (n) {
1020
+ if (i) {
1021
+ const o = i.split(";").map((u) => u.trim()).filter(Boolean), a = o.findIndex(
1022
+ (u) => u.startsWith("display:")
577
1023
  );
578
1024
  a >= 0 && o[a] === "display: none" && (o.splice(a, 1), s = o.length > 0 ? o.join("; ") + ";" : "");
579
1025
  }
580
- } else if (n) {
581
- const o = n.split(";").filter(Boolean), a = o.findIndex(
582
- (c) => c.trim().startsWith("display:")
1026
+ } else if (i) {
1027
+ const o = i.split(";").filter(Boolean), a = o.findIndex(
1028
+ (u) => u.trim().startsWith("display:")
583
1029
  );
584
1030
  a >= 0 ? o[a] = "display: none" : o.push("display: none"), s = o.join("; ");
585
1031
  } else
586
1032
  s = "display: none";
587
- s !== n && (s ? t.style = s : delete t.style);
1033
+ s !== i && (s ? t.style = s : delete t.style);
588
1034
  }
589
- function xe(e, t) {
590
- if ([
591
- /constructor/i,
592
- /prototype/i,
593
- /__proto__/i,
594
- /function/i,
595
- /eval/i,
596
- /import/i,
597
- /require/i,
598
- /window/i,
599
- /document/i,
600
- /global/i,
601
- /process/i
602
- ].some((i) => i.test(e))) {
603
- pe("Potentially dangerous expression blocked:", e);
604
- return;
605
- }
606
- if (e.trim().startsWith("{") && e.trim().endsWith("}"))
607
- try {
608
- const i = Object.keys(t), n = i.map((a) => t[a]), s = e.replace(/ctx\./g, "");
609
- if (s.length > 1e3) {
610
- pe("Expression too long, blocked for security:", e);
611
- return;
612
- }
613
- return new Function(...i, `return ${s}`)(...n);
614
- } catch (i) {
615
- pe("Failed to evaluate expression:", e, i);
616
- return;
617
- }
618
- if (e.startsWith("ctx.")) {
619
- const i = e.slice(4);
620
- return K(t, i);
621
- }
622
- return K(t, e);
1035
+ function he(e, t) {
1036
+ return xt.evaluate(e, t);
623
1037
  }
624
- function it(e, t, r) {
625
- let i;
1038
+ function Et(e, t, r) {
1039
+ let n;
626
1040
  if (typeof e == "string") {
627
1041
  if (!r) return;
628
- i = xe(e, r);
1042
+ n = he(e, r);
629
1043
  } else
630
- i = e;
631
- let n = [];
632
- typeof i == "string" ? n = [i] : Array.isArray(i) ? n = i.filter(Boolean) : typeof i == "object" && i !== null && (n = Object.entries(i).filter(([, a]) => !!a).flatMap(([a]) => a.split(/\s+/).filter(Boolean)));
633
- const s = t.class || "", o = s ? `${s} ${n.join(" ")}`.trim() : n.join(" ");
1044
+ n = e;
1045
+ let i = [];
1046
+ typeof n == "string" ? i = [n] : Array.isArray(n) ? i = n.filter(Boolean) : typeof n == "object" && n !== null && (i = Object.entries(n).filter(([, a]) => !!a).flatMap(([a]) => a.split(/\s+/).filter(Boolean)));
1047
+ const s = t.class || "", o = s ? `${s} ${i.join(" ")}`.trim() : i.join(" ");
634
1048
  o && (t.class = o);
635
1049
  }
636
- function st(e, t, r) {
637
- let i;
1050
+ function St(e, t, r) {
1051
+ let n;
638
1052
  if (typeof e == "string") {
639
1053
  if (!r) return;
640
- i = xe(e, r);
1054
+ n = he(e, r);
641
1055
  } else
642
- i = e;
643
- let n = "";
644
- if (typeof i == "string")
645
- n = i;
646
- else if (i && typeof i == "object") {
1056
+ n = e;
1057
+ let i = "";
1058
+ if (typeof n == "string")
1059
+ i = n;
1060
+ else if (n && typeof n == "object") {
647
1061
  const o = [];
648
- for (const [a, c] of Object.entries(i))
649
- if (c != null && c !== "") {
650
- const u = a.replace(
1062
+ for (const [a, u] of Object.entries(n))
1063
+ if (u != null && u !== "") {
1064
+ const m = a.replace(
651
1065
  /[A-Z]/g,
652
- (p) => `-${p.toLowerCase()}`
653
- ), m = [
1066
+ (h) => `-${h.toLowerCase()}`
1067
+ ), g = [
654
1068
  "width",
655
1069
  "height",
656
1070
  "top",
@@ -676,24 +1090,29 @@ function st(e, t, r) {
676
1090
  "min-height",
677
1091
  "max-height"
678
1092
  ];
679
- let T = String(c);
680
- typeof c == "number" && m.includes(u) && (T = `${c}px`), o.push(`${u}: ${T}`);
1093
+ let w = String(u);
1094
+ typeof u == "number" && g.includes(m) && (w = `${u}px`), o.push(`${m}: ${w}`);
681
1095
  }
682
- n = o.join("; ") + (o.length > 0 ? ";" : "");
1096
+ i = o.join("; ") + (o.length > 0 ? ";" : "");
683
1097
  }
684
1098
  const s = t.style || "";
685
- t.style = s + (s && !s.endsWith(";") ? "; " : "") + n;
1099
+ t.style = s + (s && !s.endsWith(";") ? "; " : "") + i;
686
1100
  }
687
- function De(e, t, r, i) {
688
- const n = {}, s = { ...i || {} }, o = {};
689
- for (const [a, c] of Object.entries(e)) {
690
- const { value: u, modifiers: m, arg: T } = c;
1101
+ function $t(e, t, r) {
1102
+ let n = e;
1103
+ typeof e == "string" && r && (n = he(e, r)), n && typeof n == "object" && n.constructor?.name === "ReactiveState" ? t.reactiveRef = n : t.ref = n;
1104
+ }
1105
+ function st(e, t, r, n) {
1106
+ const i = {}, s = { ...n || {} }, o = {};
1107
+ for (const [a, u] of Object.entries(e)) {
1108
+ const { value: m, modifiers: g, arg: w } = u;
691
1109
  if (a === "model" || a.startsWith("model:")) {
692
- const p = a.split(":"), l = p.length > 1 ? p[1] : T;
693
- tt(
694
- typeof u == "string" ? u : String(u),
1110
+ const h = a.split(":"), l = h.length > 1 ? h[1] : w;
1111
+ kt(
695
1112
  m,
696
- n,
1113
+ // Pass the original value (could be string or reactive state object)
1114
+ g,
1115
+ i,
697
1116
  s,
698
1117
  o,
699
1118
  t,
@@ -704,29 +1123,32 @@ function De(e, t, r, i) {
704
1123
  }
705
1124
  switch (a) {
706
1125
  case "bind":
707
- rt(u, n, s, t);
1126
+ Ct(m, i, s, t);
708
1127
  break;
709
1128
  case "show":
710
- nt(u, s, t);
1129
+ _t(m, s, t);
711
1130
  break;
712
1131
  case "class":
713
- it(u, s, t);
1132
+ Et(m, s, t);
714
1133
  break;
715
1134
  case "style":
716
- st(u, s, t);
1135
+ St(m, s, t);
1136
+ break;
1137
+ case "ref":
1138
+ $t(m, i, t);
717
1139
  break;
718
1140
  }
719
1141
  }
720
- return { props: n, attrs: s, listeners: o };
1142
+ return { props: i, attrs: s, listeners: o };
721
1143
  }
722
- function je(e, t) {
1144
+ function Ie(e, t) {
723
1145
  if (Array.isArray(e)) {
724
1146
  const s = /* @__PURE__ */ new Set();
725
1147
  return e.map((o) => {
726
1148
  if (!o || typeof o != "object") return o;
727
1149
  let a = o.props?.key ?? o.key;
728
1150
  if (!a) {
729
- const T = o.tag || "node", l = [
1151
+ const w = o.tag || "node", l = [
730
1152
  // attrs (kebab-case)
731
1153
  o.props?.attrs?.id,
732
1154
  o.props?.attrs?.name,
@@ -736,25 +1158,25 @@ function je(e, t) {
736
1158
  o.props?.props?.name,
737
1159
  o.props?.props?.dataKey,
738
1160
  o.props?.props?.["data-key"]
739
- ].find((w) => w != null) ?? "";
740
- a = l ? `${t}:${T}:${l}` : `${t}:${T}`;
1161
+ ].find((d) => d != null) ?? "";
1162
+ a = l ? `${t}:${w}:${l}` : `${t}:${w}`;
741
1163
  }
742
- let c = a, u = 1;
743
- for (; s.has(c); )
744
- c = `${a}#${u++}`;
745
- s.add(c);
746
- let m = o.children;
747
- return Array.isArray(m) && (m = je(m, c)), { ...o, key: c, children: m };
1164
+ let u = a, m = 1;
1165
+ for (; s.has(u); )
1166
+ u = `${a}#${m++}`;
1167
+ s.add(u);
1168
+ let g = o.children;
1169
+ return Array.isArray(g) && (g = Ie(g, u)), { ...o, key: u, children: g };
748
1170
  });
749
1171
  }
750
1172
  const r = e;
751
- let i = r.props?.key ?? r.key ?? t, n = r.children;
752
- return Array.isArray(n) && (n = je(n, i)), { ...r, key: i, children: n };
1173
+ let n = r.props?.key ?? r.key ?? t, i = r.children;
1174
+ return Array.isArray(i) && (i = Ie(i, n)), { ...r, key: n, children: i };
753
1175
  }
754
- function Re(e, t, r, i) {
755
- const n = r.directives ?? {}, s = De(
756
- n,
1176
+ function Fe(e, t, r, n) {
1177
+ const i = r.directives ?? {}, s = st(
757
1178
  i,
1179
+ n,
758
1180
  e,
759
1181
  r.attrs
760
1182
  ), o = {
@@ -765,38 +1187,39 @@ function Re(e, t, r, i) {
765
1187
  ...t.attrs,
766
1188
  ...r.attrs,
767
1189
  ...s.attrs
768
- }, c = t.props ?? {}, u = o, m = r?.isCustomElement ?? t?.isCustomElement ?? !1;
769
- let T = !1;
770
- for (const w in { ...c, ...u }) {
771
- const v = c[w], d = u[w];
772
- if (v !== d)
773
- if (T = !0, w === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement))
774
- e.value !== d && (e.value = d ?? "");
775
- else if (w === "checked" && e instanceof HTMLInputElement)
776
- e.checked = !!d;
777
- else if (w.startsWith("on") && typeof d == "function") {
778
- const g = Ne(w);
779
- typeof v == "function" && e.removeEventListener(g, v), e.addEventListener(g, d);
780
- } else if (d == null)
781
- e.removeAttribute(w);
782
- else if ((r?.isCustomElement ?? t?.isCustomElement ?? !1) || w in e)
1190
+ }, u = t.props ?? {}, m = o, g = r?.isCustomElement ?? t?.isCustomElement ?? !1;
1191
+ let w = !1;
1192
+ for (const d in { ...u, ...m }) {
1193
+ const v = u[d], b = m[d];
1194
+ if (v !== b)
1195
+ if (w = !0, d === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement))
1196
+ e.value !== b && (e.value = b ?? "");
1197
+ else if (d === "checked" && e instanceof HTMLInputElement)
1198
+ e.checked = !!b;
1199
+ else if (d.startsWith("on") && typeof b == "function") {
1200
+ const c = it(d);
1201
+ typeof v == "function" && se.removeListener(e, c, v), se.addListener(e, c, b);
1202
+ } else if (b == null)
1203
+ e.removeAttribute(d);
1204
+ else if ((r?.isCustomElement ?? t?.isCustomElement ?? !1) || d in e)
783
1205
  try {
784
- e[w] = d;
1206
+ e[d] = b;
785
1207
  } catch {
786
1208
  }
787
1209
  else
788
- d === !1 && e.removeAttribute(w);
1210
+ b === !1 && e.removeAttribute(d);
789
1211
  }
790
- for (const [w, v] of Object.entries(
1212
+ for (const [d, v] of Object.entries(
791
1213
  s.listeners || {}
792
1214
  ))
793
- e.addEventListener(w, v);
794
- const p = t.attrs ?? {}, l = a;
795
- for (const w in { ...p, ...l }) {
796
- const v = p[w], d = l[w];
797
- if (v !== d)
798
- if (T = !0, d == null || d === !1) {
799
- if (e.removeAttribute(w), w === "value") {
1215
+ se.addListener(e, d, v);
1216
+ const h = t.attrs ?? {}, l = a;
1217
+ for (const d in { ...h, ...l }) {
1218
+ const v = h[d], b = l[d];
1219
+ let c = v, p = b;
1220
+ if (v && typeof v == "object" && v.constructor?.name === "ReactiveState" && (c = v.value), b && typeof b == "object" && b.constructor?.name === "ReactiveState" && (p = b.value), c !== p)
1221
+ if (w = !0, p == null || p === !1) {
1222
+ if (e.removeAttribute(d), d === "value") {
800
1223
  if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement)
801
1224
  try {
802
1225
  e.value = "";
@@ -813,61 +1236,69 @@ function Re(e, t, r, i) {
813
1236
  } catch {
814
1237
  }
815
1238
  }
816
- if (w === "checked" && e instanceof HTMLInputElement)
1239
+ if (d === "checked" && e instanceof HTMLInputElement)
817
1240
  try {
818
1241
  e.checked = !1;
819
1242
  } catch {
820
1243
  }
821
- if (w === "disabled")
1244
+ if (d === "disabled")
822
1245
  try {
823
1246
  e.disabled = !1;
824
1247
  } catch {
825
1248
  }
826
1249
  } else {
827
- if (w === "value") {
1250
+ if (d === "value") {
828
1251
  if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement) {
829
1252
  try {
830
- e.value = d ?? "";
1253
+ e.value = p ?? "";
831
1254
  } catch {
832
- e.setAttribute(w, String(d));
1255
+ e.setAttribute(d, String(p));
833
1256
  }
834
1257
  continue;
835
1258
  } else if (e instanceof HTMLSelectElement) {
836
1259
  try {
837
- e.value = d ?? "";
1260
+ e.value = p ?? "";
838
1261
  } catch {
839
1262
  }
840
1263
  continue;
841
1264
  } else if (e instanceof HTMLProgressElement) {
842
1265
  try {
843
- e.value = Number(d);
1266
+ e.value = Number(p);
844
1267
  } catch {
845
1268
  }
846
1269
  continue;
847
1270
  }
848
1271
  }
849
- if (w === "checked" && e instanceof HTMLInputElement) {
1272
+ if (d === "checked" && e instanceof HTMLInputElement) {
850
1273
  try {
851
- e.checked = !!d;
1274
+ e.checked = !!p;
852
1275
  } catch {
853
1276
  }
854
1277
  continue;
855
1278
  }
856
- if (w === "style") {
857
- e.setAttribute(w, String(d));
1279
+ if (d === "style") {
1280
+ e.setAttribute(d, String(p));
858
1281
  continue;
859
1282
  }
860
- if (!(e.namespaceURI === "http://www.w3.org/2000/svg") && w in e)
1283
+ const y = e.namespaceURI === "http://www.w3.org/2000/svg";
1284
+ if (g && !y && d.includes("-")) {
1285
+ const C = rt(d);
1286
+ try {
1287
+ e[C] = p;
1288
+ } catch {
1289
+ e.setAttribute(d, String(p));
1290
+ }
1291
+ } else if (!y && d in e)
861
1292
  try {
862
- e[w] = d;
1293
+ e[d] = p;
863
1294
  } catch {
864
- e.setAttribute(w, String(d));
1295
+ e.setAttribute(d, String(p));
865
1296
  }
866
1297
  else
867
- e.setAttribute(w, String(d));
1298
+ e.setAttribute(d, String(p));
868
1299
  }
869
1300
  }
870
- if (m && T)
1301
+ if (g && w)
871
1302
  try {
872
1303
  if (typeof e._applyProps == "function")
873
1304
  try {
@@ -878,114 +1309,130 @@ function Re(e, t, r, i) {
878
1309
  } catch {
879
1310
  }
880
1311
  }
881
- function U(e, t, r) {
1312
+ function X(e, t, r) {
882
1313
  if (typeof e == "string")
883
1314
  return document.createTextNode(e);
884
1315
  if (e.tag === "#text") {
885
- const p = document.createTextNode(
1316
+ const h = document.createTextNode(
886
1317
  typeof e.children == "string" ? e.children : ""
887
1318
  );
888
- return e.key != null && (p.key = e.key), p;
1319
+ return e.key != null && (h.key = e.key), h;
889
1320
  }
890
1321
  if (e.tag === "#anchor") {
891
- const p = e, l = Array.isArray(p.children) ? p.children : [], w = document.createTextNode(""), v = document.createTextNode("");
892
- p.key != null && (w.key = `${p.key}:start`, v.key = `${p.key}:end`), p._startNode = w, p._endNode = v;
893
- const d = document.createDocumentFragment();
894
- d.appendChild(w);
895
- for (const g of l) {
896
- const y = U(g, t);
897
- d.appendChild(y);
898
- }
899
- return d.appendChild(v), d;
900
- }
901
- const i = document.createElement(e.tag);
902
- e.key != null && (i.key = e.key);
903
- const { props: n = {}, attrs: s = {}, directives: o = {} } = e.props ?? {}, a = De(o, t, i, s), c = {
904
- ...n,
1322
+ const h = e, l = Array.isArray(h.children) ? h.children : [], d = document.createTextNode(""), v = document.createTextNode("");
1323
+ h.key != null && (d.key = `${h.key}:start`, v.key = `${h.key}:end`), h._startNode = d, h._endNode = v;
1324
+ const b = document.createDocumentFragment();
1325
+ b.appendChild(d);
1326
+ for (const c of l) {
1327
+ const p = X(c, t);
1328
+ b.appendChild(p);
1329
+ }
1330
+ return b.appendChild(v), b;
1331
+ }
1332
+ const n = document.createElement(e.tag);
1333
+ e.key != null && (n.key = e.key);
1334
+ const { props: i = {}, attrs: s = {}, directives: o = {} } = e.props ?? {}, a = st(o, t, n, s), u = {
1335
+ ...i,
905
1336
  ...a.props
906
- }, u = {
1337
+ }, m = {
907
1338
  ...s,
908
1339
  ...a.attrs
909
- }, m = i.namespaceURI === "http://www.w3.org/2000/svg";
910
- for (const p in u) {
911
- const l = u[p];
912
- if (!(typeof p != "string" || /\[object Object\]/.test(p))) {
1340
+ }, g = n.namespaceURI === "http://www.w3.org/2000/svg";
1341
+ for (const h in m) {
1342
+ const l = m[h];
1343
+ if (!(typeof h != "string" || /\[object Object\]/.test(h))) {
913
1344
  if (typeof l == "boolean")
914
- l && i.setAttribute(p, "");
1345
+ l && n.setAttribute(h, "");
915
1346
  else if (l != null)
916
- if (!m && p === "value" && (i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement || i instanceof HTMLSelectElement || i instanceof HTMLProgressElement))
1347
+ if (!g && h === "value" && (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement || n instanceof HTMLProgressElement))
917
1348
  try {
918
- i instanceof HTMLProgressElement ? i.value = Number(l) : i.value = l ?? "";
1349
+ n instanceof HTMLProgressElement ? n.value = Number(l) : n.value = l ?? "";
919
1350
  } catch {
920
- i.setAttribute(p, String(l));
1351
+ n.setAttribute(h, String(l));
921
1352
  }
922
- else if (!m && p === "checked" && i instanceof HTMLInputElement)
1353
+ else if (!g && h === "checked" && n instanceof HTMLInputElement)
923
1354
  try {
924
- i.checked = !!l;
1355
+ n.checked = !!l;
925
1356
  } catch {
926
- i.setAttribute(p, String(l));
1357
+ n.setAttribute(h, String(l));
927
1358
  }
928
- else if (!m && p in i)
1359
+ else if (!g && h in n)
929
1360
  try {
930
- i[p] = l;
1361
+ n[h] = l;
931
1362
  } catch {
932
- i.setAttribute(p, String(l));
1363
+ n.setAttribute(h, String(l));
933
1364
  }
934
- else
935
- i.setAttribute(p, String(l));
936
- }
937
- }
938
- for (const p in c) {
939
- const l = c[p];
940
- if (!(typeof p != "string" || /\[object Object\]/.test(p)))
941
- if (p === "value" && (i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement || i instanceof HTMLSelectElement))
942
- i.value = l ?? "";
943
- else if (p === "checked" && i instanceof HTMLInputElement)
944
- i.checked = !!l;
945
- else if (p.startsWith("on") && typeof l == "function")
946
- i.addEventListener(Ne(p), l);
1365
+ else if ((e.props?.isCustomElement ?? !1) && !g && h.includes("-")) {
1366
+ const v = rt(h);
1367
+ try {
1368
+ n[v] = l;
1369
+ } catch {
1370
+ n.setAttribute(h, String(l));
1371
+ }
1372
+ } else
1373
+ n.setAttribute(h, String(l));
1374
+ }
1375
+ }
1376
+ for (const h in u) {
1377
+ const l = u[h];
1378
+ if (!(typeof h != "string" || /\[object Object\]/.test(h)))
1379
+ if (h === "value" && (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement)) {
1380
+ const d = typeof l == "object" && l !== null && typeof l.value < "u" ? l.value : l;
1381
+ n.value = d ?? "";
1382
+ } else if (h === "checked" && n instanceof HTMLInputElement) {
1383
+ const d = typeof l == "object" && l !== null && typeof l.value < "u" ? l.value : l;
1384
+ n.checked = !!d;
1385
+ } else if (h.startsWith("on") && typeof l == "function")
1386
+ se.addListener(n, it(h), l);
947
1387
  else {
948
- if (p.startsWith("on") && l === void 0)
1388
+ if (h.startsWith("on") && l === void 0)
949
1389
  continue;
950
1390
  if (l == null || l === !1)
951
- i.removeAttribute(p);
952
- else if ((e.props?.isCustomElement ?? !1) || p in i)
1391
+ n.removeAttribute(h);
1392
+ else if ((e.props?.isCustomElement ?? !1) || h in n)
953
1393
  try {
954
- i[p] = l;
1394
+ const v = typeof l == "object" && l !== null && typeof l.value < "u" ? l.value : l;
1395
+ n[h] = v;
955
1396
  } catch {
956
1397
  }
957
1398
  }
958
1399
  }
959
- for (const [p, l] of Object.entries(
1400
+ for (const [h, l] of Object.entries(
960
1401
  a.listeners || {}
961
1402
  ))
962
- i.addEventListener(p, l);
963
- const T = e.props?.ref ?? (e.props?.props && e.props.props.ref);
964
- typeof e != "string" && T && r && (r[T] = i);
1403
+ se.addListener(n, h, l);
1404
+ const w = {
1405
+ ...e,
1406
+ props: {
1407
+ ...e.props,
1408
+ ...a.props
1409
+ }
1410
+ };
1411
+ de(w, n, r);
965
1412
  try {
966
- if (typeof i._applyProps == "function")
1413
+ if (typeof n._applyProps == "function")
967
1414
  try {
968
- i._applyProps(i._cfg);
1415
+ n._applyProps(n._cfg);
969
1416
  } catch {
970
1417
  }
971
- typeof i.requestRender == "function" ? i.requestRender() : typeof i._render == "function" && i._render(i._cfg);
1418
+ typeof n.requestRender == "function" ? n.requestRender() : typeof n._render == "function" && n._render(n._cfg);
972
1419
  } catch {
973
1420
  }
974
1421
  if (Array.isArray(e.children))
975
- for (const p of e.children)
976
- i.appendChild(U(p, t, r));
977
- else typeof e.children == "string" && (i.textContent = e.children);
1422
+ for (const h of e.children)
1423
+ n.appendChild(X(h, t, r));
1424
+ else typeof e.children == "string" && (n.textContent = e.children);
978
1425
  try {
979
- if (i instanceof HTMLSelectElement && u && u.hasOwnProperty("value"))
1426
+ if (n instanceof HTMLSelectElement && m && m.hasOwnProperty("value"))
980
1427
  try {
981
- i.value = u.value ?? "";
1428
+ n.value = m.value ?? "";
982
1429
  } catch {
983
1430
  }
984
1431
  } catch {
985
1432
  }
986
- return i;
1433
+ return n;
987
1434
  }
988
- function ot(e, t, r, i, n) {
1435
+ function At(e, t, r, n, i) {
989
1436
  if (typeof r == "string") {
990
1437
  e.textContent !== r && (e.textContent = r);
991
1438
  return;
@@ -994,104 +1441,104 @@ function ot(e, t, r, i, n) {
994
1441
  const s = Array.from(e.childNodes), o = Array.isArray(t) ? t : [], a = /* @__PURE__ */ new Map();
995
1442
  for (const l of o)
996
1443
  l && l.key != null && a.set(l.key, l);
997
- const c = /* @__PURE__ */ new Map();
1444
+ const u = /* @__PURE__ */ new Map();
998
1445
  for (const l of s) {
999
- const w = l.key;
1000
- w != null && c.set(w, l);
1446
+ const d = l.key;
1447
+ d != null && u.set(d, l);
1001
1448
  }
1002
- const u = /* @__PURE__ */ new Set();
1003
- let m = e.firstChild;
1004
- function T(l, w) {
1449
+ const m = /* @__PURE__ */ new Set();
1450
+ let g = e.firstChild;
1451
+ function w(l, d) {
1005
1452
  let v = l;
1006
- for (; v && (u.add(v), v !== w); )
1453
+ for (; v && (m.add(v), v !== d); )
1007
1454
  v = v.nextSibling;
1008
1455
  }
1009
- function p(l, w, v, d) {
1010
- const g = [];
1011
- let y = l.nextSibling;
1012
- for (; y && y !== w; )
1013
- g.push(y), y = y.nextSibling;
1014
- const x = Array.isArray(v) ? v : [];
1015
- if (d.some((b) => b && b.key != null) || x.some((b) => b && b.key != null)) {
1016
- const b = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
1017
- for (const S of x)
1018
- S && S.key != null && b.set(S.key, S);
1019
- for (const S of g) {
1020
- const E = S.key;
1021
- E != null && h.set(E, S);
1456
+ function h(l, d, v, b) {
1457
+ const c = [];
1458
+ let p = l.nextSibling;
1459
+ for (; p && p !== d; )
1460
+ c.push(p), p = p.nextSibling;
1461
+ const y = Array.isArray(v) ? v : [];
1462
+ if (b.some((k) => k && k.key != null) || y.some((k) => k && k.key != null)) {
1463
+ const k = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
1464
+ for (const _ of y)
1465
+ _ && _.key != null && k.set(_.key, _);
1466
+ for (const _ of c) {
1467
+ const S = _.key;
1468
+ S != null && f.set(S, _);
1022
1469
  }
1023
- const _ = /* @__PURE__ */ new Set();
1024
- let $ = l.nextSibling;
1025
- for (const S of d) {
1026
- let E;
1027
- if (S.key != null && h.has(S.key)) {
1028
- const C = b.get(S.key);
1029
- E = ge(
1030
- h.get(S.key),
1031
- C,
1032
- S,
1033
- i
1034
- ), _.add(E), E !== $ && e.contains(E) && e.insertBefore(E, $);
1470
+ const x = /* @__PURE__ */ new Set();
1471
+ let A = l.nextSibling;
1472
+ for (const _ of b) {
1473
+ let S;
1474
+ if (_.key != null && f.has(_.key)) {
1475
+ const R = k.get(_.key);
1476
+ S = _e(
1477
+ f.get(_.key),
1478
+ R,
1479
+ _,
1480
+ n
1481
+ ), x.add(S), S !== A && e.contains(S) && e.insertBefore(S, A);
1035
1482
  } else
1036
- E = U(S, i), e.insertBefore(E, $), _.add(E);
1037
- $ = E.nextSibling;
1483
+ S = X(_, n), e.insertBefore(S, A), x.add(S);
1484
+ A = S.nextSibling;
1038
1485
  }
1039
- for (const S of g)
1040
- !_.has(S) && e.contains(S) && e.removeChild(S);
1486
+ for (const _ of c)
1487
+ !x.has(_) && e.contains(_) && e.removeChild(_);
1041
1488
  } else {
1042
- const b = Math.min(
1043
- x.length,
1044
- d.length
1489
+ const k = Math.min(
1490
+ y.length,
1491
+ b.length
1045
1492
  );
1046
- for (let h = 0; h < b; h++) {
1047
- const _ = x[h], $ = d[h], S = ge(g[h], _, $, i);
1048
- S !== g[h] && (e.insertBefore(S, g[h]), e.removeChild(g[h]));
1493
+ for (let f = 0; f < k; f++) {
1494
+ const x = y[f], A = b[f], _ = _e(c[f], x, A, n);
1495
+ _ !== c[f] && (e.insertBefore(_, c[f]), e.removeChild(c[f]));
1049
1496
  }
1050
- for (let h = b; h < d.length; h++)
1051
- e.insertBefore(U(d[h], i), w);
1052
- for (let h = b; h < g.length; h++)
1053
- e.removeChild(g[h]);
1497
+ for (let f = k; f < b.length; f++)
1498
+ e.insertBefore(X(b[f], n), d);
1499
+ for (let f = k; f < c.length; f++)
1500
+ e.removeChild(c[f]);
1054
1501
  }
1055
1502
  }
1056
1503
  for (const l of r) {
1057
- let w;
1504
+ let d;
1058
1505
  if (l.tag === "#anchor") {
1059
- const v = l.key, d = `${v}:start`, g = `${v}:end`;
1060
- let y = c.get(d), x = c.get(g);
1061
- const f = Array.isArray(l.children) ? l.children : [];
1062
- if (y || (y = document.createTextNode(""), y.key = d), x || (x = document.createTextNode(""), x.key = g), l._startNode = y, l._endNode = x, !e.contains(y) || !e.contains(x)) {
1063
- e.insertBefore(y, m);
1064
- for (const b of f)
1065
- e.insertBefore(U(b, i), m);
1066
- e.insertBefore(x, m);
1506
+ const v = l.key, b = `${v}:start`, c = `${v}:end`;
1507
+ let p = u.get(b), y = u.get(c);
1508
+ const C = Array.isArray(l.children) ? l.children : [];
1509
+ if (p || (p = document.createTextNode(""), p.key = b), y || (y = document.createTextNode(""), y.key = c), l._startNode = p, l._endNode = y, !e.contains(p) || !e.contains(y)) {
1510
+ e.insertBefore(p, g);
1511
+ for (const k of C)
1512
+ e.insertBefore(X(k, n), g);
1513
+ e.insertBefore(y, g);
1067
1514
  } else
1068
- p(
1515
+ h(
1516
+ p,
1069
1517
  y,
1070
- x,
1071
1518
  a.get(v)?.children,
1072
- f
1519
+ C
1073
1520
  );
1074
- T(y, x), m = x.nextSibling;
1521
+ w(p, y), g = y.nextSibling;
1075
1522
  continue;
1076
1523
  }
1077
- if (l.key != null && c.has(l.key)) {
1524
+ if (l.key != null && u.has(l.key)) {
1078
1525
  const v = a.get(l.key);
1079
- w = ge(
1080
- c.get(l.key),
1526
+ d = _e(
1527
+ u.get(l.key),
1081
1528
  v,
1082
1529
  l,
1083
- i,
1084
- n
1085
- ), u.add(w), w !== m && e.contains(w) && (m && !e.contains(m) && (m = null), e.insertBefore(w, m));
1530
+ n,
1531
+ i
1532
+ ), m.add(d), d !== g && e.contains(d) && (g && !e.contains(g) && (g = null), e.insertBefore(d, g));
1086
1533
  } else
1087
- w = U(l, i, n), m && !e.contains(m) && (m = null), e.insertBefore(w, m), u.add(w);
1088
- m = w.nextSibling;
1534
+ d = X(l, n, i), g && !e.contains(g) && (g = null), e.insertBefore(d, g), m.add(d);
1535
+ g = d.nextSibling;
1089
1536
  }
1090
1537
  for (const l of s)
1091
- !u.has(l) && e.contains(l) && (te(l, n), e.removeChild(l));
1538
+ !m.has(l) && e.contains(l) && (ce(l, i), e.removeChild(l));
1092
1539
  }
1093
- function ge(e, t, r, i, n) {
1094
- if (t && typeof t != "string" && t.props?.ref && n && te(e, n), t === r) return e;
1540
+ function _e(e, t, r, n, i) {
1541
+ if (t && typeof t != "string" && t.props?.ref && i && ce(e, i), t === r) return e;
1095
1542
  if (typeof r == "string") {
1096
1543
  if (e.nodeType === Node.TEXT_NODE)
1097
1544
  return e.textContent !== r && (e.textContent = r), e;
@@ -1101,97 +1548,97 @@ function ge(e, t, r, i, n) {
1101
1548
  }
1102
1549
  }
1103
1550
  if (r && typeof r != "string" && r.tag === "#anchor") {
1104
- const o = r, a = Array.isArray(o.children) ? o.children : [], c = o._startNode ?? document.createTextNode(""), u = o._endNode ?? document.createTextNode("");
1105
- o.key != null && (c.key = `${o.key}:start`, u.key = `${o.key}:end`), o._startNode = c, o._endNode = u;
1106
- const m = document.createDocumentFragment();
1107
- m.appendChild(c);
1108
- for (const T of a) {
1109
- const p = U(T, i);
1110
- m.appendChild(p);
1551
+ const o = r, a = Array.isArray(o.children) ? o.children : [], u = o._startNode ?? document.createTextNode(""), m = o._endNode ?? document.createTextNode("");
1552
+ o.key != null && (u.key = `${o.key}:start`, m.key = `${o.key}:end`), o._startNode = u, o._endNode = m;
1553
+ const g = document.createDocumentFragment();
1554
+ g.appendChild(u);
1555
+ for (const w of a) {
1556
+ const h = X(w, n);
1557
+ g.appendChild(h);
1111
1558
  }
1112
- return m.appendChild(u), e.parentNode?.replaceChild(m, e), c;
1559
+ return g.appendChild(m), e.parentNode?.replaceChild(g, e), u;
1113
1560
  }
1114
1561
  if (!r) {
1115
- te(e, n);
1562
+ ce(e, i);
1116
1563
  const o = document.createComment("removed");
1117
1564
  return e.parentNode?.replaceChild(o, e), o;
1118
1565
  }
1119
1566
  if (!t || typeof t == "string") {
1120
- te(e, n);
1121
- const o = U(r, i, n);
1122
- return typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = o), e.parentNode?.replaceChild(o, e), o;
1567
+ ce(e, i);
1568
+ const o = X(r, n, i);
1569
+ return de(r, o, i), e.parentNode?.replaceChild(o, e), o;
1123
1570
  }
1124
1571
  if (r.tag === "#anchor") {
1125
- const o = Array.isArray(r.children) ? r.children : [], a = r._startNode ?? document.createTextNode(""), c = r._endNode ?? document.createTextNode("");
1126
- r.key != null && (a.key = `${r.key}:start`, c.key = `${r.key}:end`), r._startNode = a, r._endNode = c;
1127
- const u = document.createDocumentFragment();
1128
- u.appendChild(a);
1129
- for (const m of o)
1130
- u.appendChild(U(m, i));
1131
- return u.appendChild(c), e.parentNode?.replaceChild(u, e), a;
1572
+ const o = Array.isArray(r.children) ? r.children : [], a = r._startNode ?? document.createTextNode(""), u = r._endNode ?? document.createTextNode("");
1573
+ r.key != null && (a.key = `${r.key}:start`, u.key = `${r.key}:end`), r._startNode = a, r._endNode = u;
1574
+ const m = document.createDocumentFragment();
1575
+ m.appendChild(a);
1576
+ for (const g of o)
1577
+ m.appendChild(X(g, n));
1578
+ return m.appendChild(u), e.parentNode?.replaceChild(m, e), a;
1132
1579
  }
1133
1580
  if (typeof t != "string" && typeof r != "string" && t.tag === r.tag && t.key === r.key) {
1134
1581
  const o = e;
1135
- return Re(o, t.props || {}, r.props || {}, i), ot(o, t.children, r.children, i, n), typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = o), o;
1582
+ return Fe(o, t.props || {}, r.props || {}, n), At(o, t.children, r.children, n, i), de(r, o, i), o;
1136
1583
  }
1137
1584
  if (typeof t != "string" && typeof r != "string" && t.tag === r.tag && (t.tag && String(t.tag).includes("-") || r.props && r.props.isCustomElement || t.props && t.props.isCustomElement))
1138
1585
  try {
1139
1586
  const a = e;
1140
- return Re(a, t.props || {}, r.props || {}, i), typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = a), a;
1587
+ return Fe(a, t.props || {}, r.props || {}, n), de(r, a, i), a;
1141
1588
  } catch {
1142
1589
  }
1143
- te(e, n);
1144
- const s = U(r, i, n);
1145
- return typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
1590
+ ce(e, i);
1591
+ const s = X(r, n, i);
1592
+ return de(r, s, i), e.parentNode?.replaceChild(s, e), s;
1146
1593
  }
1147
- function at(e, t, r, i) {
1148
- let n;
1149
- Array.isArray(t) ? t.length === 1 ? (n = t[0], n && typeof n == "object" && n.key == null && (n = { ...n, key: "__root__" })) : n = { tag: "div", key: "__root__", children: t } : (n = t, n && typeof n == "object" && n.key == null && (n = { ...n, key: "__root__" })), n && typeof n == "object" && n.tag === "#anchor" && (n = {
1594
+ function Rt(e, t, r, n) {
1595
+ let i;
1596
+ Array.isArray(t) ? t.length === 1 ? (i = t[0], i && typeof i == "object" && i.key == null && (i = { ...i, key: "__root__" })) : i = { tag: "div", key: "__root__", children: t } : (i = t, i && typeof i == "object" && i.key == null && (i = { ...i, key: "__root__" })), i && typeof i == "object" && i.tag === "#anchor" && (i = {
1150
1597
  tag: "div",
1151
1598
  key: "__anchor_root__",
1152
1599
  props: { attrs: { "data-anchor-block-root": "", key: "__anchor_root__" } },
1153
- children: [n]
1154
- }), n = je(n, String(n.key ?? "root"));
1600
+ children: [i]
1601
+ }), i = Ie(i, String(i.key ?? "root"));
1155
1602
  const s = e._prevVNode ?? null, o = e._prevDom ?? e.firstChild ?? null;
1156
1603
  let a;
1157
- s && o ? typeof s != "string" && typeof n != "string" && s.tag === n.tag && s.key === n.key ? a = ge(o, s, n, r, i) : (a = U(n, r, i), e.replaceChild(a, o)) : (a = U(n, r, i), e.firstChild ? e.replaceChild(a, e.firstChild) : e.appendChild(a));
1158
- const c = [];
1159
- for (let u = 0; u < e.childNodes.length; u++) {
1160
- const m = e.childNodes[u];
1161
- m !== a && m.nodeName !== "STYLE" && (te(m, i), c.push(m));
1604
+ s && o ? typeof s != "string" && typeof i != "string" && s.tag === i.tag && s.key === i.key ? a = _e(o, s, i, r, n) : (a = X(i, r, n), e.replaceChild(a, o)) : (a = X(i, r, n), e.firstChild ? e.replaceChild(a, e.firstChild) : e.appendChild(a));
1605
+ const u = [];
1606
+ for (let m = 0; m < e.childNodes.length; m++) {
1607
+ const g = e.childNodes[m];
1608
+ g !== a && g.nodeName !== "STYLE" && (ce(g, n), u.push(g));
1162
1609
  }
1163
- c.forEach((u) => e.removeChild(u)), e._prevVNode = n, e._prevDom = a;
1610
+ u.forEach((m) => e.removeChild(m)), e._prevVNode = i, e._prevDom = a;
1164
1611
  }
1165
- function ke(e) {
1166
- if (typeof e == "string") return Z(e);
1612
+ function Te(e) {
1613
+ if (typeof e == "string") return ne(e);
1167
1614
  if (e.tag === "#text")
1168
- return typeof e.children == "string" ? Z(e.children) : "";
1615
+ return typeof e.children == "string" ? ne(e.children) : "";
1169
1616
  if (e.tag === "#anchor")
1170
- return (Array.isArray(e.children) ? e.children.filter(Boolean) : []).map(ke).join("");
1617
+ return (Array.isArray(e.children) ? e.children.filter(Boolean) : []).map(Te).join("");
1171
1618
  let t = "";
1172
- e.props && e.props.attrs && (t = Object.entries(e.props.attrs).map(([n, s]) => ` ${n}="${Z(String(s))}"`).join(""));
1619
+ e.props && e.props.attrs && (t = Object.entries(e.props.attrs).map(([i, s]) => ` ${i}="${ne(String(s))}"`).join(""));
1173
1620
  let r = "";
1174
- e.props && (r = Object.entries(e.props).filter(([n]) => n !== "attrs" && n !== "directives" && n !== "ref" && n !== "key").map(([n, s]) => ` ${n}="${Z(String(s))}"`).join(""));
1175
- const i = Array.isArray(e.children) ? e.children.filter(Boolean).map(ke).join("") : typeof e.children == "string" ? Z(e.children) : e.children ? ke(e.children) : "";
1176
- return `<${e.tag}${t}${r}>${i}</${e.tag}>`;
1621
+ e.props && (r = Object.entries(e.props).filter(([i]) => i !== "attrs" && i !== "directives" && i !== "ref" && i !== "key").map(([i, s]) => ` ${i}="${ne(String(s))}"`).join(""));
1622
+ const n = Array.isArray(e.children) ? e.children.filter(Boolean).map(Te).join("") : typeof e.children == "string" ? ne(e.children) : e.children ? Te(e.children) : "";
1623
+ return `<${e.tag}${t}${r}>${n}</${e.tag}>`;
1177
1624
  }
1178
- function Ue(e, ...t) {
1625
+ function Tt(e, ...t) {
1179
1626
  let r = "";
1180
- for (let i = 0; i < e.length; i++)
1181
- r += e[i], i < t.length && (r += t[i]);
1627
+ for (let n = 0; n < e.length; n++)
1628
+ r += e[n], n < t.length && (r += t[n]);
1182
1629
  return r;
1183
1630
  }
1184
- function Fe(e) {
1631
+ function ot(e) {
1185
1632
  return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
1186
1633
  }
1187
- let ue = null;
1188
- function Oe() {
1189
- return ue || (ue = new CSSStyleSheet(), ue.replaceSync(Fe(lt))), ue;
1634
+ let xe = null;
1635
+ function Ke() {
1636
+ return xe || (xe = new CSSStyleSheet(), xe.replaceSync(ot(Pt))), xe;
1190
1637
  }
1191
- function ct(e) {
1638
+ function Ot(e) {
1192
1639
  return e.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi, "").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, "").replace(/expression\s*\([^)]*\)/gi, "");
1193
1640
  }
1194
- const lt = Ue`
1641
+ const Pt = Tt`
1195
1642
  :host, *, ::before, ::after {
1196
1643
  all: isolate;
1197
1644
  box-sizing: border-box;
@@ -1249,7 +1696,7 @@ const lt = Ue`
1249
1696
  sup { top: -.5em }
1250
1697
  [disabled], [aria-disabled=true] { cursor: not-allowed }
1251
1698
  [hidden] { display: none }
1252
- `, ft = {
1699
+ `, Lt = {
1253
1700
  neutral: {
1254
1701
  50: "#fafafa",
1255
1702
  100: "#f4f4f5",
@@ -1345,17 +1792,17 @@ const lt = Ue`
1345
1792
  black: { DEFAULT: "#000000" },
1346
1793
  transparent: { DEFAULT: "transparent" },
1347
1794
  current: { DEFAULT: "currentColor" }
1348
- }, ut = Object.fromEntries(
1349
- Object.entries(ft).map(([e, t]) => [
1795
+ }, jt = Object.fromEntries(
1796
+ Object.entries(Lt).map(([e, t]) => [
1350
1797
  e,
1351
1798
  Object.fromEntries(
1352
- Object.entries(t).map(([r, i]) => [
1799
+ Object.entries(t).map(([r, n]) => [
1353
1800
  r,
1354
- `var(--color-${e}${r === "DEFAULT" ? "" : `-${r}`}, ${i})`
1801
+ `var(--color-${e}${r === "DEFAULT" ? "" : `-${r}`}, ${n})`
1355
1802
  ])
1356
1803
  )
1357
1804
  ])
1358
- ), _e = {
1805
+ ), Oe = {
1359
1806
  /* Display */
1360
1807
  block: "display:block;",
1361
1808
  inline: "display:inline;",
@@ -1570,7 +2017,7 @@ const lt = Ue`
1570
2017
  "z-30": "z-index:30;",
1571
2018
  "z-40": "z-index:40;",
1572
2019
  "z-50": "z-index:50;"
1573
- }, dt = "0.25rem", Pe = {
2020
+ }, Mt = "0.25rem", Ve = {
1574
2021
  m: ["margin"],
1575
2022
  mx: ["margin-inline"],
1576
2023
  my: ["margin-block"],
@@ -1602,34 +2049,34 @@ const lt = Ue`
1602
2049
  "gap-x": ["column-gap"],
1603
2050
  "gap-y": ["row-gap"]
1604
2051
  };
1605
- function D(e, t) {
1606
- let r = 0, i = 0;
1607
- for (let n = 0; n < e.length; n++) {
1608
- const s = e[n];
2052
+ function G(e, t) {
2053
+ let r = 0, n = 0;
2054
+ for (let i = 0; i < e.length; i++) {
2055
+ const s = e[i];
1609
2056
  if (s === "[") r++;
1610
2057
  else if (s === "]" && r > 0) r--;
1611
- else if (s === "(") i++;
1612
- else if (s === ")" && i > 0) i--;
1613
- else if (r === 0 && i === 0 && (s === ">" || s === "+" || s === "~" || s === " "))
1614
- return e.slice(0, n) + t + e.slice(n);
2058
+ else if (s === "(") n++;
2059
+ else if (s === ")" && n > 0) n--;
2060
+ else if (r === 0 && n === 0 && (s === ">" || s === "+" || s === "~" || s === " "))
2061
+ return e.slice(0, i) + t + e.slice(i);
1615
2062
  }
1616
2063
  return e + t;
1617
2064
  }
1618
- const pt = {
2065
+ const Nt = {
1619
2066
  before: (e, t) => `${e}::before{${t}}`,
1620
2067
  after: (e, t) => `${e}::after{${t}}`,
1621
- hover: (e, t) => `${D(e, ":hover")}{${t}}`,
1622
- focus: (e, t) => `${D(e, ":focus")}{${t}}`,
1623
- active: (e, t) => `${D(e, ":active")}{${t}}`,
1624
- disabled: (e, t) => `${D(e, ":disabled")}{${t}}`,
1625
- visited: (e, t) => `${D(e, ":visited")}{${t}}`,
1626
- checked: (e, t) => `${D(e, ":checked")}{${t}}`,
1627
- first: (e, t) => `${D(e, ":first-child")}{${t}}`,
1628
- last: (e, t) => `${D(e, ":last-child")}{${t}}`,
1629
- odd: (e, t) => `${D(e, ":nth-child(odd)")}{${t}}`,
1630
- even: (e, t) => `${D(e, ":nth-child(even)")}{${t}}`,
1631
- "focus-within": (e, t) => `${D(e, ":focus-within")}{${t}}`,
1632
- "focus-visible": (e, t) => `${D(e, ":focus-visible")}{${t}}`,
2068
+ hover: (e, t) => `${G(e, ":hover")}{${t}}`,
2069
+ focus: (e, t) => `${G(e, ":focus")}{${t}}`,
2070
+ active: (e, t) => `${G(e, ":active")}{${t}}`,
2071
+ disabled: (e, t) => `${G(e, ":disabled")}{${t}}`,
2072
+ visited: (e, t) => `${G(e, ":visited")}{${t}}`,
2073
+ checked: (e, t) => `${G(e, ":checked")}{${t}}`,
2074
+ first: (e, t) => `${G(e, ":first-child")}{${t}}`,
2075
+ last: (e, t) => `${G(e, ":last-child")}{${t}}`,
2076
+ odd: (e, t) => `${G(e, ":nth-child(odd)")}{${t}}`,
2077
+ even: (e, t) => `${G(e, ":nth-child(even)")}{${t}}`,
2078
+ "focus-within": (e, t) => `${G(e, ":focus-within")}{${t}}`,
2079
+ "focus-visible": (e, t) => `${G(e, ":focus-visible")}{${t}}`,
1633
2080
  "group-hover": (e, t) => `.group:hover ${e}{${t}}`,
1634
2081
  "group-focus": (e, t) => `.group:focus ${e}{${t}}`,
1635
2082
  "group-active": (e, t) => `.group:active ${e}{${t}}`,
@@ -1638,7 +2085,7 @@ const pt = {
1638
2085
  "peer-focus": (e, t) => `.peer:focus ~ ${e}{${t}}`,
1639
2086
  "peer-checked": (e, t) => `.peer:checked ~ ${e}{${t}}`,
1640
2087
  "peer-disabled": (e, t) => `.peer:disabled ~ ${e}{${t}}`
1641
- }, Ee = {
2088
+ }, Pe = {
1642
2089
  // Responsive
1643
2090
  sm: "(min-width:640px)",
1644
2091
  md: "(min-width:768px)",
@@ -1647,23 +2094,23 @@ const pt = {
1647
2094
  "2xl": "(min-width:1536px)",
1648
2095
  // Dark mode (now plain string)
1649
2096
  dark: "(prefers-color-scheme: dark)"
1650
- }, $e = ["sm", "md", "lg", "xl", "2xl"];
1651
- function Se(e) {
1652
- const t = e.startsWith("-"), i = (t ? e.slice(1) : e).split("-");
1653
- if (i.length < 2) return null;
1654
- const n = i.slice(0, -1).join("-"), s = i[i.length - 1], o = parseFloat(s);
1655
- if (Number.isNaN(o) || !Pe[n]) return null;
2097
+ }, Le = ["sm", "md", "lg", "xl", "2xl"];
2098
+ function je(e) {
2099
+ const t = e.startsWith("-"), n = (t ? e.slice(1) : e).split("-");
2100
+ if (n.length < 2) return null;
2101
+ const i = n.slice(0, -1).join("-"), s = n[n.length - 1], o = parseFloat(s);
2102
+ if (Number.isNaN(o) || !Ve[i]) return null;
1656
2103
  const a = t ? "-" : "";
1657
- return Pe[n].map((c) => `${c}:calc(${a}${dt} * ${o});`).join("");
2104
+ return Ve[i].map((u) => `${u}:calc(${a}${Mt} * ${o});`).join("");
1658
2105
  }
1659
- function Me(e) {
1660
- const t = e.replace("#", ""), r = parseInt(t, 16), i = r >> 16 & 255, n = r >> 8 & 255, s = r & 255;
1661
- return `${i} ${n} ${s}`;
2106
+ function Je(e) {
2107
+ const t = e.replace("#", ""), r = parseInt(t, 16), n = r >> 16 & 255, i = r >> 8 & 255, s = r & 255;
2108
+ return `${n} ${i} ${s}`;
1662
2109
  }
1663
- function ht(e) {
2110
+ function Wt(e) {
1664
2111
  const t = /^(bg|text|border|decoration|shadow|outline|caret|accent|fill|stroke)-([a-z]+)-?(\d{2,3}|DEFAULT)?$/.exec(e);
1665
2112
  if (!t) return null;
1666
- const [, r, i, n = "DEFAULT"] = t, s = ut[i]?.[n];
2113
+ const [, r, n, i = "DEFAULT"] = t, s = jt[n]?.[i];
1667
2114
  if (!s) return null;
1668
2115
  if (r === "shadow") return `--ce-shadow-color:${s};`;
1669
2116
  const a = {
@@ -1679,55 +2126,55 @@ function ht(e) {
1679
2126
  }[r];
1680
2127
  return a ? `${a}:${s};` : null;
1681
2128
  }
1682
- function gt(e) {
2129
+ function zt(e) {
1683
2130
  const [t, r] = e.split("/");
1684
2131
  if (!r) return { base: t };
1685
- const i = parseInt(r, 10);
1686
- return isNaN(i) || i < 0 || i > 100 ? { base: t } : { base: t, opacity: i / 100 };
2132
+ const n = parseInt(r, 10);
2133
+ return isNaN(n) || n < 0 || n > 100 ? { base: t } : { base: t, opacity: n / 100 };
1687
2134
  }
1688
- function Ce(e) {
1689
- const { base: t, opacity: r } = gt(e), i = ht(t);
1690
- if (i) {
2135
+ function Me(e) {
2136
+ const { base: t, opacity: r } = zt(e), n = Wt(t);
2137
+ if (n) {
1691
2138
  if (r !== void 0) {
1692
- const s = /#([0-9a-f]{6})/i.exec(i);
2139
+ const s = /#([0-9a-f]{6})/i.exec(n);
1693
2140
  if (s) {
1694
- const o = Me(s[0]);
1695
- return i.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${r})`);
2141
+ const o = Je(s[0]);
2142
+ return n.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${r})`);
1696
2143
  }
1697
2144
  }
1698
- return i;
2145
+ return n;
1699
2146
  }
1700
- const n = me(t);
1701
- if (n && r !== void 0) {
1702
- const s = /#([0-9a-f]{6})/i.exec(n);
2147
+ const i = Ee(t);
2148
+ if (i && r !== void 0) {
2149
+ const s = /#([0-9a-f]{6})/i.exec(i);
1703
2150
  if (s) {
1704
- const o = Me(s[0]);
1705
- return n.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${r})`);
2151
+ const o = Je(s[0]);
2152
+ return i.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${r})`);
1706
2153
  }
1707
2154
  }
1708
- return n;
2155
+ return i;
1709
2156
  }
1710
- function Ae(e) {
2157
+ function Ne(e) {
1711
2158
  const t = /^opacity-(\d{1,3})$/.exec(e);
1712
2159
  if (!t) return null;
1713
2160
  const r = parseInt(t[1], 10);
1714
2161
  return r < 0 || r > 100 ? null : `opacity:${r / 100};`;
1715
2162
  }
1716
- function me(e) {
2163
+ function Ee(e) {
1717
2164
  if (e.startsWith("[") && e.endsWith("]") && !e.includes("-[")) {
1718
- const n = e.slice(1, -1).trim().match(/^([a-zA-Z][a-zA-Z0-9-]*)\s*:(.*)$/);
1719
- if (n) {
1720
- const s = n[1].trim();
1721
- let o = n[2].trim();
2165
+ const i = e.slice(1, -1).trim().match(/^([a-zA-Z][a-zA-Z0-9-]*)\s*:(.*)$/);
2166
+ if (i) {
2167
+ const s = i[1].trim();
2168
+ let o = i[2].trim();
1722
2169
  return o = o.replace(/url\('\s*([^']*?)\s*'\)/g, 'url("$1")'), o = o.replace(/^'([^']*)'$/g, '"$1"'), `${s}:${o};`;
1723
2170
  }
1724
2171
  return null;
1725
2172
  }
1726
2173
  const t = e.indexOf("-["), r = e.endsWith("]");
1727
2174
  if (t > 0 && r) {
1728
- const i = e.slice(0, t);
1729
- let n = e.slice(t + 2, -1);
1730
- n = n.replace(/_/g, " ");
2175
+ const n = e.slice(0, t);
2176
+ let i = e.slice(t + 2, -1);
2177
+ i = i.replace(/_/g, " ");
1731
2178
  const s = {
1732
2179
  bg: "background-color",
1733
2180
  text: "color",
@@ -1770,14 +2217,14 @@ function me(e) {
1770
2217
  leading: "line-height",
1771
2218
  z: "z-index"
1772
2219
  };
1773
- if (i === "rotate")
1774
- return `transform:rotate(${n});`;
1775
- const o = s[i] ?? i.replace(/_/g, "-");
1776
- if (o && n) return `${o}:${n};`;
2220
+ if (n === "rotate")
2221
+ return `transform:rotate(${i});`;
2222
+ const o = s[n] ?? n.replace(/_/g, "-");
2223
+ if (o && i) return `${o}:${i};`;
1777
2224
  }
1778
2225
  return null;
1779
2226
  }
1780
- function mt(e) {
2227
+ function Dt(e) {
1781
2228
  if (e.startsWith("[") && e.endsWith("]")) {
1782
2229
  const r = e.slice(1, -1);
1783
2230
  return r.includes("&") ? r : e;
@@ -1789,44 +2236,44 @@ function mt(e) {
1789
2236
  }
1790
2237
  return null;
1791
2238
  }
1792
- function yt(e) {
2239
+ function It(e) {
1793
2240
  return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1");
1794
2241
  }
1795
- function bt(e) {
2242
+ function Ht(e) {
1796
2243
  const t = /class\s*=\s*(['"])(.*?)\1/g, r = [];
1797
- let i;
1798
- for (; i = t.exec(e); ) {
1799
- const n = i[2].split(/\s+/).filter(Boolean);
1800
- n.length && r.push(...n);
2244
+ let n;
2245
+ for (; n = t.exec(e); ) {
2246
+ const i = n[2].split(/\s+/).filter(Boolean);
2247
+ i.length && r.push(...i);
1801
2248
  }
1802
2249
  return r.filter(Boolean);
1803
2250
  }
1804
- const Be = /* @__PURE__ */ new Map(), wt = 16;
1805
- function xt(e) {
1806
- const t = Date.now(), r = Be.get(e);
1807
- if (r && t - r.timestamp < wt) return r.css;
1808
- const i = bt(e), n = new Set(i), s = [], o = [], a = [], c = [], u = {};
1809
- function m(d, g = !1) {
1810
- const y = (g ? "dark|" : "") + d;
1811
- if (y in u) return u[y];
1812
- const x = w(d, g);
1813
- return u[y] = x, x;
1814
- }
1815
- function T(d) {
1816
- const g = d.some((x) => $e.includes(x)), y = d.includes("dark");
1817
- return d.length === 0 ? 1 : !g && !y ? 2 : g && !y ? 3 : 4;
1818
- }
1819
- function p(d) {
1820
- const g = [];
1821
- let y = "", x = 0, f = 0;
1822
- for (let b = 0; b < d.length; b++) {
1823
- const h = d[b];
1824
- h === "[" ? x++ : h === "]" && x > 0 ? x-- : h === "(" ? f++ : h === ")" && f > 0 && f--, h === ":" && x === 0 && f === 0 ? (g.push(y), y = "") : y += h;
1825
- }
1826
- return y && g.push(y), g;
1827
- }
1828
- function l(d) {
1829
- switch (d) {
2251
+ const Ze = /* @__PURE__ */ new Map(), Bt = 16;
2252
+ function Ut(e) {
2253
+ const t = Date.now(), r = Ze.get(e);
2254
+ if (r && t - r.timestamp < Bt) return r.css;
2255
+ const n = Ht(e), i = new Set(n), s = [], o = [], a = [], u = [], m = {};
2256
+ function g(b, c = !1) {
2257
+ const p = (c ? "dark|" : "") + b;
2258
+ if (p in m) return m[p];
2259
+ const y = d(b, c);
2260
+ return m[p] = y, y;
2261
+ }
2262
+ function w(b) {
2263
+ const c = b.some((y) => Le.includes(y)), p = b.includes("dark");
2264
+ return b.length === 0 ? 1 : !c && !p ? 2 : c && !p ? 3 : 4;
2265
+ }
2266
+ function h(b) {
2267
+ const c = [];
2268
+ let p = "", y = 0, C = 0;
2269
+ for (let k = 0; k < b.length; k++) {
2270
+ const f = b[k];
2271
+ f === "[" ? y++ : f === "]" && y > 0 ? y-- : f === "(" ? C++ : f === ")" && C > 0 && C--, f === ":" && y === 0 && C === 0 ? (c.push(p), p = "") : p += f;
2272
+ }
2273
+ return p && c.push(p), c;
2274
+ }
2275
+ function l(b) {
2276
+ switch (b) {
1830
2277
  case "hover":
1831
2278
  return ":hover";
1832
2279
  case "focus":
@@ -1855,245 +2302,234 @@ function xt(e) {
1855
2302
  return null;
1856
2303
  }
1857
2304
  }
1858
- function w(d, g = !1) {
1859
- const y = p(d);
1860
- let x = !1;
1861
- const f = y.find((k) => (k.startsWith("!") && (x = !0, k = k.slice(1)), _e[k] || Se(k) || Ae(k) || Ce(k) || me(k)));
2305
+ function d(b, c = !1) {
2306
+ const p = h(b);
2307
+ let y = !1;
2308
+ const C = p.find((E) => (E.startsWith("!") && (y = !0, E = E.slice(1)), Oe[E] || je(E) || Ne(E) || Me(E) || Ee(E)));
2309
+ if (!C) return null;
2310
+ const k = C.replace(/^!/, ""), f = Oe[k] ?? je(k) ?? Ne(k) ?? Me(k) ?? Ee(k);
1862
2311
  if (!f) return null;
1863
- const b = f.replace(/^!/, ""), h = _e[b] ?? Se(b) ?? Ae(b) ?? Ce(b) ?? me(b);
1864
- if (!h) return null;
1865
- const _ = y.indexOf(f);
1866
- let $ = _ >= 0 ? y.slice(0, _) : [];
1867
- g && ($ = $.filter((k) => k !== "dark"));
1868
- const S = `.${yt(d)}`, E = "__SUBJECT__", C = x ? h.replace(/;$/, " !important;") : h;
1869
- let A = E;
1870
- const P = [];
1871
- for (const k of $)
1872
- k.startsWith("group-") ? (A = `.group:${k.slice(6)} ${A}`, P.push(k)) : k.startsWith("peer-") && (A = A.replace(E, `.peer:${k.slice(5)}~${E}`), P.push(k));
1873
- $ = $.filter((k) => !P.includes(k));
1874
- const X = [], ie = [];
1875
- let M = null;
1876
- for (const k of $) {
1877
- if (k === "dark" || $e.includes(k)) continue;
1878
- const W = mt(k);
1879
- if (W) {
1880
- M = W;
2312
+ const x = p.indexOf(C);
2313
+ let A = x >= 0 ? p.slice(0, x) : [];
2314
+ c && (A = A.filter((E) => E !== "dark"));
2315
+ const _ = `.${It(b)}`, S = "__SUBJECT__", R = y ? f.replace(/;$/, " !important;") : f;
2316
+ let T = S;
2317
+ const $ = [];
2318
+ for (const E of A)
2319
+ E.startsWith("group-") ? (T = `.group:${E.slice(6)} ${T}`, $.push(E)) : E.startsWith("peer-") && (T = T.replace(S, `.peer:${E.slice(5)}~${S}`), $.push(E));
2320
+ A = A.filter((E) => !$.includes(E));
2321
+ const P = [], B = [];
2322
+ let J = null;
2323
+ for (const E of A) {
2324
+ if (E === "dark" || Le.includes(E)) continue;
2325
+ const U = Dt(E);
2326
+ if (U) {
2327
+ J = U;
1881
2328
  continue;
1882
2329
  }
1883
- const R = l(k);
1884
- if (R) {
1885
- M ? ie.push(R) : X.push(R);
2330
+ const D = l(E);
2331
+ if (D) {
2332
+ J ? B.push(D) : P.push(D);
1886
2333
  continue;
1887
2334
  }
1888
- const B = pt[k];
1889
- typeof B == "function" && (A = B(A, C).split("{")[0]);
1890
- }
1891
- function F(k, W) {
1892
- if (!W) return k;
1893
- let R = 0, B = 0;
1894
- if (k.length && (k[0] === ">" || k[0] === "+" || k[0] === "~" || k[0] === " ")) {
1895
- let j = 1;
1896
- for (; j < k.length && k[j] === " "; ) j++;
1897
- for (; j < k.length; j++) {
1898
- const L = k[j];
1899
- if (L === "[" ? R++ : L === "]" && R > 0 ? R-- : L === "(" ? B++ : L === ")" && B > 0 && B--, R === 0 && B === 0 && (k[j] === ">" || k[j] === "+" || k[j] === "~" || k[j] === " "))
1900
- return k.slice(0, j) + W + k.slice(j);
2335
+ const z = Nt[E];
2336
+ typeof z == "function" && (T = z(T, R).split("{")[0]);
2337
+ }
2338
+ function ye(E, U) {
2339
+ if (!U) return E;
2340
+ let D = 0, z = 0;
2341
+ if (E.length && (E[0] === ">" || E[0] === "+" || E[0] === "~" || E[0] === " ")) {
2342
+ let O = 1;
2343
+ for (; O < E.length && E[O] === " "; ) O++;
2344
+ for (; O < E.length; O++) {
2345
+ const I = E[O];
2346
+ if (I === "[" ? D++ : I === "]" && D > 0 ? D-- : I === "(" ? z++ : I === ")" && z > 0 && z--, D === 0 && z === 0 && (E[O] === ">" || E[O] === "+" || E[O] === "~" || E[O] === " "))
2347
+ return E.slice(0, O) + U + E.slice(O);
1901
2348
  }
1902
- return k + W;
2349
+ return E + U;
1903
2350
  }
1904
- for (let j = 0; j < k.length; j++) {
1905
- const L = k[j];
1906
- if (L === "[" ? R++ : L === "]" && R > 0 ? R-- : L === "(" ? B++ : L === ")" && B > 0 && B--, R === 0 && B === 0 && (L === ">" || L === "+" || L === "~" || L === " "))
1907
- return k.slice(0, j) + W + k.slice(j);
2351
+ for (let O = 0; O < E.length; O++) {
2352
+ const I = E[O];
2353
+ if (I === "[" ? D++ : I === "]" && D > 0 ? D-- : I === "(" ? z++ : I === ")" && z > 0 && z--, D === 0 && z === 0 && (I === ">" || I === "+" || I === "~" || I === " "))
2354
+ return E.slice(0, O) + U + E.slice(O);
1908
2355
  }
1909
- return k + W;
1910
- }
1911
- const H = X.join(""), N = ie.join("");
1912
- if (M)
1913
- if (M.includes("&")) {
1914
- const k = M.indexOf("&"), W = M.slice(0, k), R = M.slice(k + 1), B = E + H, j = A;
1915
- if (X.length === 0)
1916
- A = j.replace(E, W + B + N + R);
2356
+ return E + U;
2357
+ }
2358
+ const K = P.join(""), L = B.join("");
2359
+ if (J)
2360
+ if (J.includes("&")) {
2361
+ const E = J.indexOf("&"), U = J.slice(0, E), D = J.slice(E + 1), z = S + K, O = T;
2362
+ if (P.length === 0)
2363
+ T = O.replace(S, U + z + L + D);
1917
2364
  else {
1918
- const L = F(R, N);
1919
- A = j.replace(E, W + B + L);
2365
+ const I = ye(D, L);
2366
+ T = O.replace(S, U + z + I);
1920
2367
  }
1921
2368
  } else
1922
- A = A.replace(E, `${M}${E + H}`), N && (A = A.replace(E, `${E}${N}`));
2369
+ T = T.replace(S, `${J}${S + K}`), L && (T = T.replace(S, `${S}${L}`));
1923
2370
  else
1924
- A = E + H + N;
1925
- A = A.replace(new RegExp(E, "g"), S);
1926
- let I = `${A}{${C}}`;
1927
- const z = $.filter((k) => $e.includes(k)), J = z.length ? z[z.length - 1] : null, se = $.includes("dark");
1928
- return g && J ? I = `@media (prefers-color-scheme: dark) and ${Ee[J]}{${I}}` : g ? I = `@media (prefers-color-scheme: dark){${I}}` : se && J ? I = `@media (prefers-color-scheme: dark) and ${Ee[J]}{${I}}` : se ? I = `@media (prefers-color-scheme: dark){${I}}` : J && (I = `@media ${Ee[J]}{${I}}`), I;
1929
- }
1930
- for (const d of n) {
1931
- const g = p(d), y = g.find(
1932
- (h) => _e[h] || Se(h) || Ae(h) || Ce(h) || me(h)
2371
+ T = S + K + L;
2372
+ T = T.replace(new RegExp(S, "g"), _);
2373
+ let j = `${T}{${R}}`;
2374
+ const V = A.filter((E) => Le.includes(E)), Z = V.length ? V[V.length - 1] : null, W = A.includes("dark");
2375
+ return c && Z ? j = `@media (prefers-color-scheme: dark) and ${Pe[Z]}{${j}}` : c ? j = `@media (prefers-color-scheme: dark){${j}}` : W && Z ? j = `@media (prefers-color-scheme: dark) and ${Pe[Z]}{${j}}` : W ? j = `@media (prefers-color-scheme: dark){${j}}` : Z && (j = `@media ${Pe[Z]}{${j}}`), j;
2376
+ }
2377
+ for (const b of i) {
2378
+ const c = h(b), p = c.find(
2379
+ (f) => Oe[f] || je(f) || Ne(f) || Me(f) || Ee(f)
1933
2380
  );
1934
- if (!y) continue;
1935
- const x = g.indexOf(y), f = x >= 0 ? g.slice(0, x) : [], b = T(f);
1936
- if (b === 4) {
1937
- const h = m(d, !0);
1938
- h && c.push(h);
2381
+ if (!p) continue;
2382
+ const y = c.indexOf(p), C = y >= 0 ? c.slice(0, y) : [], k = w(C);
2383
+ if (k === 4) {
2384
+ const f = g(b, !0);
2385
+ f && u.push(f);
1939
2386
  } else {
1940
- const h = m(d);
1941
- h && (b === 1 ? s.push(h) : b === 2 ? o.push(h) : b === 3 && a.push(h));
2387
+ const f = g(b);
2388
+ f && (k === 1 ? s.push(f) : k === 2 ? o.push(f) : k === 3 && a.push(f));
1942
2389
  }
1943
2390
  }
1944
- const v = [...s, ...o, ...a, ...c].join("");
1945
- return Be.set(e, { css: v, timestamp: t }), v;
2391
+ const v = [...s, ...o, ...a, ...u].join("");
2392
+ return Ze.set(e, { css: v, timestamp: t }), v;
1946
2393
  }
1947
- const ce = [];
1948
- function vt(e, t, r, i, n, s, o, a) {
2394
+ const pe = [];
2395
+ function qt(e, t, r, n, i, s, o, a) {
1949
2396
  if (e) {
1950
- ce.push(r);
2397
+ pe.push(r);
1951
2398
  try {
1952
- if (t.loadingTemplate && r.isLoading) {
1953
- re(e, t.loadingTemplate(r), r, i, n);
1954
- return;
1955
- }
1956
- if (t.errorTemplate && r.hasError) {
1957
- r.error instanceof Error && re(e, t.errorTemplate(r.error, r), r, i, n);
1958
- return;
1959
- }
1960
- const c = t.render(r);
1961
- if (c instanceof Promise) {
1962
- s(!0), c.then((u) => {
1963
- s(!1), o(null), re(e, u, r, i, n), a(e.innerHTML);
1964
- }).catch((u) => {
1965
- s(!1), o(u), t.errorTemplate && re(e, t.errorTemplate(u, r), r, i, n);
1966
- }), t.loadingTemplate && re(e, t.loadingTemplate(r), r, i, n);
2399
+ const u = t.render(r);
2400
+ if (u instanceof Promise) {
2401
+ s(!0), u.then((m) => {
2402
+ s(!1), o(null), Ge(e, m, r, n, i), a(e.innerHTML);
2403
+ }).catch((m) => {
2404
+ s(!1), o(m);
2405
+ });
1967
2406
  return;
1968
2407
  }
1969
- re(e, c, r, i, n), a(e.innerHTML);
2408
+ Ge(e, u, r, n, i), a(e.innerHTML);
1970
2409
  } finally {
1971
- ce.pop();
2410
+ pe.pop();
1972
2411
  }
1973
2412
  }
1974
2413
  }
1975
- function re(e, t, r, i, n) {
1976
- e && (at(
2414
+ function Ge(e, t, r, n, i) {
2415
+ e && (Rt(
1977
2416
  e,
1978
2417
  Array.isArray(t) ? t : [t],
1979
2418
  r,
1980
- i
1981
- ), n(e.innerHTML));
2419
+ n
2420
+ ), i(e.innerHTML));
1982
2421
  }
1983
- function kt(e, t, r, i, n, s, o) {
2422
+ function Ft(e, t, r, n, i, s, o) {
1984
2423
  if (s !== null && clearTimeout(s), Date.now() - t < 16) {
1985
- if (n(r + 1), r > 10) {
1986
- o(null);
2424
+ if (i(r + 1), r === 15)
2425
+ console.warn(
2426
+ `⚠️ Component is re-rendering rapidly. This might indicate:
2427
+ Common causes:
2428
+ • Event handler calling a function immediately: @click="\${fn()}" should be @click="\${fn}"
2429
+ • State modification during render
2430
+ • Missing dependencies in computed/watch
2431
+ Component rendering will be throttled to prevent browser freeze.`
2432
+ );
2433
+ else if (r > 20) {
2434
+ console.error(
2435
+ `🛑 Infinite loop detected in component render:
2436
+ • This might be caused by state updates during render
2437
+ • Ensure all state modifications are done in event handlers or effects
2438
+ Stopping runaway component render to prevent browser freeze`
2439
+ ), o(null);
1987
2440
  return;
1988
2441
  }
1989
2442
  } else
1990
- n(0);
1991
- const c = setTimeout(() => {
1992
- i(Date.now()), e(), o(null);
1993
- }, 0);
1994
- o(c);
2443
+ i(0);
2444
+ const m = setTimeout(() => {
2445
+ n(Date.now()), e(), o(null);
2446
+ }, r > 10 ? 100 : 0);
2447
+ o(m);
1995
2448
  }
1996
- function _t(e, t, r, i, n, s) {
2449
+ function Kt(e, t, r, n, i) {
1997
2450
  if (!e) return;
1998
- const o = xt(i);
1999
- if (!t.style && (!o || o.trim() === "")) {
2000
- s(null), e.adoptedStyleSheets = [Oe()];
2451
+ const s = Ut(r);
2452
+ if ((!s || s.trim() === "") && !t._computedStyle) {
2453
+ i(null), e.adoptedStyleSheets = [Ke()];
2001
2454
  return;
2002
2455
  }
2003
- let a = "";
2004
- t.style && (typeof t.style == "string" ? a = t.style : typeof t.style == "function" && (a = t.style(r)));
2005
- let c = ct(`${a}
2006
- ${o}
2456
+ let o = "";
2457
+ t._computedStyle && (o = t._computedStyle);
2458
+ let a = Ot(`${o}
2459
+ ${s}
2007
2460
  `);
2008
- c = Fe(c);
2461
+ a = ot(a);
2009
2462
  let u = n;
2010
- u || (u = new CSSStyleSheet()), (u.cssRules.length === 0 || u.toString() !== c) && u.replaceSync(c), e.adoptedStyleSheets = [Oe(), u], s(u);
2463
+ u || (u = new CSSStyleSheet()), (u.cssRules.length === 0 || u.toString() !== a) && u.replaceSync(a), e.adoptedStyleSheets = [Ke(), u], i(u);
2464
+ }
2465
+ let N = null;
2466
+ function Vt(e) {
2467
+ N = e;
2468
+ }
2469
+ function Jt() {
2470
+ N = null;
2471
+ }
2472
+ function lr() {
2473
+ if (!N)
2474
+ throw new Error("useEmit must be called during component render");
2475
+ const e = N.emit;
2476
+ return (t, r) => e(t, r);
2477
+ }
2478
+ function ge(e) {
2479
+ e._hookCallbacks || Object.defineProperty(e, "_hookCallbacks", {
2480
+ value: {},
2481
+ writable: !0,
2482
+ enumerable: !1,
2483
+ configurable: !1
2484
+ });
2011
2485
  }
2012
- class Et {
2013
- pendingUpdates = /* @__PURE__ */ new Map();
2014
- isFlushScheduled = !1;
2015
- /**
2016
- * Schedule an update to be executed in the next microtask
2017
- * Uses component identity to deduplicate multiple render requests for the same component
2018
- */
2019
- schedule(t, r) {
2020
- const i = r || t.toString();
2021
- this.pendingUpdates.set(i, t), this.isFlushScheduled || (this.isFlushScheduled = !0, typeof globalThis.process < "u" && globalThis.process.env?.NODE_ENV === "test" || typeof window < "u" && (window.__vitest__ || window.Cypress) ? this.flush() : queueMicrotask(() => this.flush()));
2022
- }
2023
- /**
2024
- * Execute all pending updates
2025
- */
2026
- flush() {
2027
- const t = Array.from(this.pendingUpdates.values());
2028
- this.pendingUpdates.clear(), this.isFlushScheduled = !1;
2029
- for (const r of t)
2030
- try {
2031
- r();
2032
- } catch (i) {
2033
- typeof console < "u" && console.error && console.error("Error in batched update:", i);
2034
- }
2035
- }
2036
- /**
2037
- * Get the number of pending updates
2038
- */
2039
- get pendingCount() {
2040
- return this.pendingUpdates.size;
2486
+ function ur(e) {
2487
+ if (!N)
2488
+ throw new Error("useOnConnected must be called during component render");
2489
+ ge(N), N._hookCallbacks.onConnected = e;
2490
+ }
2491
+ function fr(e) {
2492
+ if (!N)
2493
+ throw new Error("useOnDisconnected must be called during component render");
2494
+ ge(N), N._hookCallbacks.onDisconnected = e;
2495
+ }
2496
+ function dr(e) {
2497
+ if (!N)
2498
+ throw new Error("useOnAttributeChanged must be called during component render");
2499
+ ge(N), N._hookCallbacks.onAttributeChanged = e;
2500
+ }
2501
+ function pr(e) {
2502
+ if (!N)
2503
+ throw new Error("useOnError must be called during component render");
2504
+ ge(N), N._hookCallbacks.onError = e;
2505
+ }
2506
+ function hr(e) {
2507
+ if (!N)
2508
+ throw new Error("useStyle must be called during component render");
2509
+ ge(N);
2510
+ try {
2511
+ const t = e();
2512
+ Object.defineProperty(N, "_computedStyle", {
2513
+ value: t,
2514
+ writable: !0,
2515
+ enumerable: !1,
2516
+ configurable: !0
2517
+ });
2518
+ } catch (t) {
2519
+ console.warn("Error in useStyle callback:", t), Object.defineProperty(N, "_computedStyle", {
2520
+ value: "",
2521
+ writable: !0,
2522
+ enumerable: !1,
2523
+ configurable: !0
2524
+ });
2041
2525
  }
2042
2526
  }
2043
- const $t = new Et();
2044
- function oe(e, t) {
2045
- $t.schedule(e, t);
2046
- }
2047
- const be = /* @__PURE__ */ new Map(), We = Symbol.for("cer.registry");
2527
+ const $e = /* @__PURE__ */ new Map(), Xe = Symbol.for("cer.registry");
2048
2528
  if (typeof window < "u") {
2049
2529
  const e = globalThis;
2050
- e[We] || (e[We] = be);
2051
- }
2052
- function Ie(e, t, r) {
2053
- let i = Q(e);
2054
- i.includes("-") || (i = `cer-${i}`);
2055
- let n;
2056
- typeof t == "function" ? n = { ...r, render: t } : n = t, typeof n.onError != "function" && (n.onError = (s, o) => {
2057
- Y(`[${i}] Error:`, s, o);
2058
- });
2059
- try {
2060
- const s = /* @__PURE__ */ new Set([
2061
- "refs",
2062
- "requestRender",
2063
- "error",
2064
- "hasError",
2065
- "isLoading",
2066
- "emit"
2067
- ]), o = [];
2068
- if (n.state && typeof n.state == "object" && Object.keys(n.state).forEach((a) => {
2069
- s.has(a) && o.push(a);
2070
- }), n.props && typeof n.props == "object" && Object.keys(n.props).forEach((a) => {
2071
- s.has(a) && o.push(a);
2072
- }), n.computed && typeof n.computed == "object" && Object.keys(n.computed).forEach((a) => {
2073
- s.has(a) && o.push(a);
2074
- }), o.length > 0) {
2075
- const a = Array.from(new Set(o));
2076
- pe(
2077
- `[${i}] Reserved runtime context keys used in component config: ${a.join(", ")}. These names are provided by the runtime (for example: refs, error, emit). Rename your state/prop/computed keys (e.g. 'error' -> 'errorMessage') to avoid collisions and TypeScript type conflicts.`
2078
- );
2079
- }
2080
- } catch {
2081
- }
2082
- if (be.set(i, n), typeof window < "u")
2083
- if (!customElements.get(i))
2084
- customElements.define(i, St(i, n));
2085
- else
2086
- try {
2087
- document.querySelectorAll(i).forEach((s) => {
2088
- try {
2089
- typeof s._cfg < "u" && (s._cfg = n), typeof s._render == "function" && s._render(n);
2090
- } catch {
2091
- }
2092
- });
2093
- } catch {
2094
- }
2530
+ e[Xe] || (e[Xe] = $e);
2095
2531
  }
2096
- function St(e, t) {
2532
+ function Zt(e, t) {
2097
2533
  if (!t.render)
2098
2534
  throw new Error(
2099
2535
  "Component must have a render function"
@@ -2138,7 +2574,7 @@ function St(e, t) {
2138
2574
  _templateLoading = !1;
2139
2575
  _templateError = null;
2140
2576
  constructor() {
2141
- super(), this.attachShadow({ mode: "open" }), this._cfg = be.get(e) || t, this._componentId = `${e}-${Math.random().toString(36).substr(2, 9)}`;
2577
+ super(), this.attachShadow({ mode: "open" }), this._cfg = $e.get(e) || t, this._componentId = `${e}-${Math.random().toString(36).substr(2, 9)}`;
2142
2578
  const r = this._initContext(t);
2143
2579
  Object.defineProperty(r, "refs", {
2144
2580
  value: this._refs,
@@ -2155,14 +2591,19 @@ function St(e, t) {
2155
2591
  writable: !1,
2156
2592
  enumerable: !1,
2157
2593
  configurable: !1
2594
+ }), Object.defineProperty(r, "_componentId", {
2595
+ value: this._componentId,
2596
+ writable: !1,
2597
+ enumerable: !1,
2598
+ configurable: !1
2158
2599
  }), Object.defineProperty(r, "_triggerWatchers", {
2159
- value: (n, s) => this._triggerWatchers(n, s),
2600
+ value: (i, s) => this._triggerWatchers(i, s),
2160
2601
  writable: !1,
2161
2602
  enumerable: !1,
2162
2603
  configurable: !1
2163
2604
  }), this.context = r, Object.defineProperty(this.context, "emit", {
2164
- value: (n, s, o) => {
2165
- const a = new CustomEvent(n, {
2605
+ value: (i, s, o) => {
2606
+ const a = new CustomEvent(i, {
2166
2607
  detail: s,
2167
2608
  bubbles: !0,
2168
2609
  composed: !0,
@@ -2174,28 +2615,28 @@ function St(e, t) {
2174
2615
  enumerable: !1,
2175
2616
  configurable: !1
2176
2617
  });
2177
- const i = be.get(e) || t;
2178
- Object.keys(i).forEach((n) => {
2179
- const s = i[n];
2180
- typeof s == "function" && (this.context[n] = (...o) => s(...o, this.context));
2181
- }), this._applyComputed(i), i.props && Object.keys(i.props).forEach((n) => {
2182
- let s = this[n];
2183
- Object.defineProperty(this, n, {
2618
+ const n = $e.get(e) || t;
2619
+ Object.keys(n).forEach((i) => {
2620
+ const s = n[i];
2621
+ typeof s == "function" && (this.context[i] = (...o) => s(...o, this.context));
2622
+ }), this._applyComputed(n), n.props && Object.keys(n.props).forEach((i) => {
2623
+ let s = this[i];
2624
+ Object.defineProperty(this, i, {
2184
2625
  get() {
2185
2626
  return s;
2186
2627
  },
2187
2628
  set(o) {
2188
2629
  const a = s;
2189
- s = o, this.context[n] = o, this._initializing || (this._applyProps(i), a !== o && this._requestRender());
2630
+ s = o, this.context[i] = o, this._initializing || (this._applyProps(n), a !== o && this._requestRender());
2190
2631
  },
2191
2632
  enumerable: !0,
2192
2633
  configurable: !0
2193
2634
  });
2194
- }), this._initializing = !1, this._initWatchers(i), this._render(i);
2635
+ }), this._initializing = !1, this._initWatchers(n), this._applyProps(n), this._render(n);
2195
2636
  }
2196
2637
  connectedCallback() {
2197
2638
  this._runLogicWithinErrorBoundary(t, () => {
2198
- this._applyProps(t), Qe(
2639
+ this._applyProps(t), this._requestRender(), bt(
2199
2640
  t,
2200
2641
  this.context,
2201
2642
  this._mounted,
@@ -2207,7 +2648,7 @@ function St(e, t) {
2207
2648
  }
2208
2649
  disconnectedCallback() {
2209
2650
  this._runLogicWithinErrorBoundary(t, () => {
2210
- Xe(
2651
+ wt(
2211
2652
  t,
2212
2653
  this.context,
2213
2654
  this._listeners,
@@ -2229,51 +2670,40 @@ function St(e, t) {
2229
2670
  );
2230
2671
  });
2231
2672
  }
2232
- attributeChangedCallback(r, i, n) {
2673
+ attributeChangedCallback(r, n, i) {
2233
2674
  this._runLogicWithinErrorBoundary(t, () => {
2234
- this._applyProps(t), et(
2675
+ this._applyProps(t), n !== i && this._requestRender(), vt(
2235
2676
  t,
2236
2677
  r,
2237
- i,
2238
2678
  n,
2679
+ i,
2239
2680
  this.context
2240
2681
  );
2241
2682
  });
2242
2683
  }
2243
2684
  static get observedAttributes() {
2244
- return t.props ? Object.keys(t.props).map(Q) : [];
2685
+ return t.props ? Object.keys(t.props).map(te) : [];
2245
2686
  }
2246
2687
  _applyComputed(r) {
2247
- this._runLogicWithinErrorBoundary(t, () => {
2248
- r.computed && Object.entries(r.computed).forEach(([i, n]) => {
2249
- Object.defineProperty(this.context, i, {
2250
- get: () => {
2251
- const s = n(this.context);
2252
- return Z(s);
2253
- },
2254
- enumerable: !0
2255
- });
2256
- });
2257
- });
2258
2688
  }
2259
2689
  // --- Render ---
2260
2690
  _render(r) {
2261
2691
  this._runLogicWithinErrorBoundary(r, () => {
2262
- vt(
2692
+ qt(
2263
2693
  this.shadowRoot,
2264
2694
  r,
2265
2695
  this.context,
2266
2696
  this._refs,
2267
- (i) => {
2268
- this._lastHtmlStringForJitCSS = i, typeof this.onHtmlStringUpdate == "function" && this.onHtmlStringUpdate(i);
2697
+ (n) => {
2698
+ this._lastHtmlStringForJitCSS = n, typeof this.onHtmlStringUpdate == "function" && this.onHtmlStringUpdate(n);
2269
2699
  },
2270
- (i) => {
2271
- this._templateLoading = i, typeof this.onLoadingStateChange == "function" && this.onLoadingStateChange(i);
2700
+ (n) => {
2701
+ this._templateLoading = n, typeof this.onLoadingStateChange == "function" && this.onLoadingStateChange(n);
2272
2702
  },
2273
- (i) => {
2274
- this._templateError = i, typeof this.onErrorStateChange == "function" && this.onErrorStateChange(i);
2703
+ (n) => {
2704
+ this._templateError = n, typeof this.onErrorStateChange == "function" && this.onErrorStateChange(n);
2275
2705
  },
2276
- (i) => this._applyStyle(r, i)
2706
+ (n) => this._applyStyle(r, n)
2277
2707
  );
2278
2708
  });
2279
2709
  }
@@ -2282,8 +2712,8 @@ function St(e, t) {
2282
2712
  }
2283
2713
  _requestRender() {
2284
2714
  this._runLogicWithinErrorBoundary(this._cfg, () => {
2285
- oe(() => {
2286
- kt(
2715
+ le(() => {
2716
+ Ft(
2287
2717
  () => this._render(this._cfg),
2288
2718
  this._lastRenderTime,
2289
2719
  this._renderCount,
@@ -2302,40 +2732,36 @@ function St(e, t) {
2302
2732
  });
2303
2733
  }
2304
2734
  // --- Style ---
2305
- _applyStyle(r, i) {
2735
+ _applyStyle(r, n) {
2306
2736
  this._runLogicWithinErrorBoundary(r, () => {
2307
- _t(
2737
+ Kt(
2308
2738
  this.shadowRoot,
2309
- r,
2310
2739
  this.context,
2311
- i,
2740
+ n,
2312
2741
  this._styleSheet,
2313
- (n) => {
2314
- this._styleSheet = n;
2742
+ (i) => {
2743
+ this._styleSheet = i;
2315
2744
  }
2316
2745
  );
2317
2746
  });
2318
2747
  }
2319
2748
  // --- Error Boundary function ---
2320
- _runLogicWithinErrorBoundary(r, i) {
2749
+ _runLogicWithinErrorBoundary(r, n) {
2321
2750
  this._hasError && (this._hasError = !1);
2322
2751
  try {
2323
- i();
2324
- } catch (n) {
2325
- this._hasError = !0, r.onError && r.onError(n, this.context), r.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = r.errorFallback(
2326
- n,
2327
- this.context
2328
- ));
2752
+ n();
2753
+ } catch (i) {
2754
+ this._hasError = !0, r.onError && r.onError(i, this.context);
2329
2755
  }
2330
2756
  }
2331
2757
  // --- State, props, computed ---
2332
2758
  _initContext(r) {
2333
2759
  try {
2334
- let i = function(s, o = "") {
2760
+ let n = function(s, o = "") {
2335
2761
  return Array.isArray(s) ? new Proxy(s, {
2336
- get(a, c, u) {
2337
- const m = Reflect.get(a, c, u);
2338
- return typeof m == "function" && typeof c == "string" && [
2762
+ get(a, u, m) {
2763
+ const g = Reflect.get(a, u, m);
2764
+ return typeof g == "function" && typeof u == "string" && [
2339
2765
  "push",
2340
2766
  "pop",
2341
2767
  "shift",
@@ -2343,177 +2769,303 @@ function St(e, t) {
2343
2769
  "splice",
2344
2770
  "sort",
2345
2771
  "reverse"
2346
- ].includes(c) ? function(...p) {
2347
- const l = m.apply(a, p);
2348
- if (!n._initializing) {
2349
- const w = o || "root";
2350
- n._triggerWatchers(w, a), oe(() => n._render(r), n._componentId);
2772
+ ].includes(u) ? function(...h) {
2773
+ const l = g.apply(a, h);
2774
+ if (!i._initializing) {
2775
+ const d = o || "root";
2776
+ i._triggerWatchers(d, a), le(() => i._render(r), i._componentId);
2351
2777
  }
2352
2778
  return l;
2353
- } : m;
2779
+ } : g;
2354
2780
  },
2355
- set(a, c, u) {
2356
- if (a[c] = u, !n._initializing) {
2357
- const m = o ? `${o}.${String(c)}` : String(c);
2358
- n._triggerWatchers(m, u), oe(() => n._render(r), n._componentId);
2781
+ set(a, u, m) {
2782
+ if (a[u] = m, !i._initializing) {
2783
+ const g = o ? `${o}.${String(u)}` : String(u);
2784
+ i._triggerWatchers(g, m), le(() => i._render(r), i._componentId);
2359
2785
  }
2360
2786
  return !0;
2361
2787
  },
2362
- deleteProperty(a, c) {
2363
- if (delete a[c], !n._initializing) {
2364
- const u = o ? `${o}.${String(c)}` : String(c);
2365
- n._triggerWatchers(u, void 0), oe(() => n._render(r), n._componentId);
2788
+ deleteProperty(a, u) {
2789
+ if (delete a[u], !i._initializing) {
2790
+ const m = o ? `${o}.${String(u)}` : String(u);
2791
+ i._triggerWatchers(m, void 0), le(() => i._render(r), i._componentId);
2366
2792
  }
2367
2793
  return !0;
2368
2794
  }
2369
- }) : s && typeof s == "object" ? (Object.keys(s).forEach((a) => {
2370
- const c = o ? `${o}.${a}` : a;
2371
- s[a] = i(s[a], c);
2795
+ }) : s && typeof s == "object" ? s.constructor && s.constructor.name === "ReactiveState" ? s : (Object.keys(s).forEach((a) => {
2796
+ const u = o ? `${o}.${a}` : a;
2797
+ s[a] = n(s[a], u);
2372
2798
  }), new Proxy(s, {
2373
- set(a, c, u) {
2374
- const m = o ? `${o}.${String(c)}` : String(c);
2375
- return a[c] = i(u, m), n._initializing || (n._triggerWatchers(
2376
- m,
2377
- a[c]
2378
- ), oe(() => n._render(r), n._componentId)), !0;
2799
+ set(a, u, m) {
2800
+ const g = o ? `${o}.${String(u)}` : String(u);
2801
+ return a[u] = n(m, g), i._initializing || (i._triggerWatchers(
2802
+ g,
2803
+ a[u]
2804
+ ), le(() => i._render(r), i._componentId)), !0;
2379
2805
  },
2380
- get(a, c, u) {
2381
- return Reflect.get(a, c, u);
2806
+ get(a, u, m) {
2807
+ return Reflect.get(a, u, m);
2382
2808
  }
2383
2809
  })) : s;
2384
2810
  };
2385
- const n = this;
2386
- return i({ ...r.state });
2811
+ const i = this;
2812
+ return n({
2813
+ // For functional components, state is managed by state() function calls
2814
+ // Include prop defaults in initial reactive context so prop updates trigger reactivity
2815
+ ...r.props ? Object.fromEntries(
2816
+ Object.entries(r.props).map(([s, o]) => [s, o.default])
2817
+ ) : {}
2818
+ });
2387
2819
  } catch {
2388
2820
  return {};
2389
2821
  }
2390
2822
  }
2391
2823
  _initWatchers(r) {
2392
2824
  this._runLogicWithinErrorBoundary(r, () => {
2393
- Ge(
2825
+ ht(
2394
2826
  this.context,
2395
2827
  this._watchers,
2396
- r.watch || {}
2828
+ {}
2829
+ // Watchers are now handled by the watch() function in functional API
2397
2830
  );
2398
2831
  });
2399
2832
  }
2400
- _triggerWatchers(r, i) {
2401
- Ze(this.context, this._watchers, r, i);
2833
+ _triggerWatchers(r, n) {
2834
+ gt(this.context, this._watchers, r, n);
2402
2835
  }
2403
2836
  _applyProps(r) {
2404
2837
  this._runLogicWithinErrorBoundary(r, () => {
2405
2838
  try {
2406
- Ye(this, r, this.context);
2407
- } catch (i) {
2408
- this._hasError = !0, r.onError && r.onError(i, this.context), r.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = r.errorFallback(i, this.context));
2839
+ yt(this, r, this.context);
2840
+ } catch (n) {
2841
+ this._hasError = !0, r.onError && r.onError(n, this.context);
2842
+ }
2843
+ });
2844
+ }
2845
+ };
2846
+ }
2847
+ function Ye(e, t) {
2848
+ let r = te(e);
2849
+ r.includes("-") || (r = `cer-${r}`);
2850
+ let n = {};
2851
+ if (typeof window < "u")
2852
+ try {
2853
+ const a = t.toString().match(/\(\s*{\s*([^}]+)\s*}/);
2854
+ if (a) {
2855
+ const m = a[1].split(",").map((g) => g.trim());
2856
+ for (const g of m) {
2857
+ const w = g.indexOf("=");
2858
+ if (w !== -1) {
2859
+ const h = g.substring(0, w).trim(), l = g.substring(w + 1).trim();
2860
+ try {
2861
+ l === "true" ? n[h] = !0 : l === "false" ? n[h] = !1 : l === "[]" ? n[h] = [] : l === "{}" ? n[h] = {} : /^\d+$/.test(l) ? n[h] = parseInt(l) : /^'.*'$/.test(l) || /^".*"$/.test(l) ? n[h] = l.slice(1, -1) : n[h] = l;
2862
+ } catch {
2863
+ n[h] = "";
2864
+ }
2865
+ } else {
2866
+ const h = g.split(":")[0].trim();
2867
+ h && !h.includes("}") && (n[h] = "");
2868
+ }
2409
2869
  }
2870
+ }
2871
+ } catch {
2872
+ }
2873
+ let i = {};
2874
+ const s = {
2875
+ // Generate props config from defaults
2876
+ props: Object.fromEntries(
2877
+ Object.entries(n).map(([o, a]) => [o, { type: typeof a == "boolean" ? Boolean : typeof a == "number" ? Number : typeof a == "string" ? String : Function, default: a }])
2878
+ ),
2879
+ // Add lifecycle hooks from the stored functions
2880
+ onConnected: (o) => {
2881
+ i.onConnected && i.onConnected();
2882
+ },
2883
+ onDisconnected: (o) => {
2884
+ i.onDisconnected && i.onDisconnected();
2885
+ },
2886
+ onAttributeChanged: (o, a, u, m) => {
2887
+ i.onAttributeChanged && i.onAttributeChanged(o, a, u);
2888
+ },
2889
+ onError: (o, a) => {
2890
+ i.onError && o && i.onError(o);
2891
+ },
2892
+ render: (o) => {
2893
+ const a = o._componentId || `${r}-${Math.random().toString(36).substr(2, 9)}`;
2894
+ F.setCurrentComponent(a, () => {
2895
+ o.requestRender && o.requestRender();
2410
2896
  });
2897
+ try {
2898
+ Vt(o);
2899
+ const u = Object.keys(n).length > 0;
2900
+ let m;
2901
+ if (u) {
2902
+ const g = {};
2903
+ Object.keys(n).forEach((w) => {
2904
+ g[w] = o[w] ?? n[w];
2905
+ }), m = t(g);
2906
+ } else
2907
+ m = t();
2908
+ if (o._hookCallbacks) {
2909
+ const g = o._hookCallbacks;
2910
+ g.onConnected && (i.onConnected = g.onConnected), g.onDisconnected && (i.onDisconnected = g.onDisconnected), g.onAttributeChanged && (i.onAttributeChanged = g.onAttributeChanged), g.onError && (i.onError = g.onError), g.style && (o._styleCallback = g.style);
2911
+ }
2912
+ return m;
2913
+ } finally {
2914
+ Jt(), F.clearCurrentComponent();
2915
+ }
2411
2916
  }
2412
2917
  };
2918
+ $e.set(r, s), typeof window < "u" && (customElements.get(r) || customElements.define(r, Zt(r, s)));
2919
+ }
2920
+ class Gt {
2921
+ map = /* @__PURE__ */ new Map();
2922
+ maxSize;
2923
+ constructor(t) {
2924
+ this.maxSize = t;
2925
+ }
2926
+ get(t) {
2927
+ const r = this.map.get(t);
2928
+ if (r !== void 0)
2929
+ return this.map.delete(t), this.map.set(t, r), r;
2930
+ }
2931
+ set(t, r) {
2932
+ if (this.map.has(t) && this.map.delete(t), this.map.set(t, r), this.map.size > this.maxSize) {
2933
+ const n = this.map.keys().next().value;
2934
+ n !== void 0 && this.map.delete(n);
2935
+ }
2936
+ }
2937
+ has(t) {
2938
+ return this.map.has(t);
2939
+ }
2940
+ clear() {
2941
+ this.map.clear();
2942
+ }
2413
2943
  }
2414
- function ae(e, t = {}, r, i) {
2415
- const n = i ?? t.key;
2416
- return { tag: e, key: n, props: t, children: r };
2944
+ const We = new Gt(500);
2945
+ function Xt(e, t) {
2946
+ if (e == null) {
2947
+ console.warn(
2948
+ `⚠️ Event handler for '@${t}' is ${e}. This will prevent the event from working. Use a function reference instead: @${t}="\${functionName}"`
2949
+ );
2950
+ return;
2951
+ }
2952
+ typeof e != "function" && console.warn(
2953
+ `🚨 Potential infinite loop detected! Event handler for '@${t}' appears to be the result of a function call (${typeof e}) instead of a function reference. Change @${t}="\${functionName()}" to @${t}="\${functionName}" to pass the function reference instead of calling it immediately.`
2954
+ ), e === void 0 && typeof e != "function" && console.warn(
2955
+ `💡 Tip: If your event handler function returns undefined, make sure you're passing the function reference, not calling it. Use @${t}="\${fn}" not @${t}="\${fn()}"`
2956
+ );
2957
+ }
2958
+ function fe(e, t = {}, r, n) {
2959
+ const i = n ?? t.key;
2960
+ return { tag: e, key: i, props: t, children: r };
2417
2961
  }
2418
- function ye(e) {
2962
+ function Se(e) {
2419
2963
  return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
2420
2964
  }
2421
- function de(e) {
2422
- return typeof e == "object" && e !== null && "tag" in e && !ye(e);
2965
+ function ke(e) {
2966
+ return typeof e == "object" && e !== null && "tag" in e && !Se(e);
2423
2967
  }
2424
- function Ct(e, t) {
2968
+ function Yt(e, t) {
2425
2969
  return e.key != null ? e : { ...e, key: t };
2426
2970
  }
2427
- function At(e, t = [], r = {}) {
2428
- const i = {}, n = {}, s = {}, o = [], a = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
2429
- let c;
2430
- for (; c = a.exec(e); ) {
2431
- const u = c[1], m = c[2], T = (c[4] || c[6]) ?? "", p = T.match(/^{{(\d+)}}$/);
2432
- let l = p ? t[Number(p[1])] ?? null : T;
2433
- p || (l === "true" ? l = !0 : l === "false" ? l = !1 : l === "null" ? l = null : isNaN(Number(l)) || (l = Number(l)));
2434
- const w = ["model", "bind", "show", "class", "style"];
2435
- if (u === ":") {
2436
- const [v, d] = m.split(":"), [g, ...y] = v.split(".");
2437
- if (w.includes(g)) {
2438
- const x = [...y], f = g === "model" && d ? `model:${d}` : g;
2439
- s[f] = {
2971
+ function Qt(e, t = [], r = {}) {
2972
+ const n = {}, i = {}, s = {}, o = [], a = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
2973
+ let u;
2974
+ for (; u = a.exec(e); ) {
2975
+ const m = u[1], g = u[2], w = (u[4] || u[6]) ?? "", h = w.match(/^{{(\d+)}}$/);
2976
+ let l = h ? t[Number(h[1])] ?? null : w;
2977
+ h || (l === "true" ? l = !0 : l === "false" ? l = !1 : l === "null" ? l = null : isNaN(Number(l)) || (l = Number(l)));
2978
+ const d = ["model", "bind", "show", "class", "style", "ref"];
2979
+ if (m === ":") {
2980
+ const [v, b] = g.split(":"), [c, ...p] = v.split(".");
2981
+ if (d.includes(c)) {
2982
+ const y = [...p], C = c === "model" && b ? `model:${b}` : c;
2983
+ s[C] = {
2440
2984
  value: l,
2441
- modifiers: x,
2442
- arg: d
2985
+ modifiers: y,
2986
+ arg: b
2443
2987
  };
2444
- } else
2445
- n[m] = l, o.push(m);
2446
- } else if (u === "@") {
2447
- const [v, ...d] = m.split("."), g = d, y = typeof l == "function" ? l : typeof r[l] == "function" ? r[l] : void 0;
2448
- if (y) {
2449
- const x = (b) => {
2450
- if (g.includes("prevent") && b.preventDefault(), g.includes("stop") && b.stopPropagation(), !(g.includes("self") && b.target !== b.currentTarget))
2451
- return g.includes("once") && b.currentTarget?.removeEventListener(v, x), y(b);
2452
- }, f = "on" + v.charAt(0).toUpperCase() + v.slice(1);
2453
- i[f] = x;
2988
+ } else {
2989
+ let y = l;
2990
+ y && typeof y == "object" && y.constructor?.name === "ReactiveState" && (y = y.value), i[g] = y, o.push(g);
2454
2991
  }
2455
- } else m === "ref" ? i.ref = l : n[m] = l;
2992
+ } else if (m === "@") {
2993
+ const [v, ...b] = g.split("."), c = b;
2994
+ Xt(l, v);
2995
+ const p = typeof l == "function" ? l : typeof r[l] == "function" ? r[l] : void 0;
2996
+ if (p) {
2997
+ const y = (k) => {
2998
+ if (c.includes("prevent") && k.preventDefault(), c.includes("stop") && k.stopPropagation(), !(c.includes("self") && k.target !== k.currentTarget))
2999
+ return c.includes("once") && k.currentTarget?.removeEventListener(v, y), p(k);
3000
+ }, C = "on" + v.charAt(0).toUpperCase() + v.slice(1);
3001
+ n[C] = y;
3002
+ }
3003
+ } else g === "ref" ? n.ref = l : i[g] = l;
2456
3004
  }
2457
- return { props: i, attrs: n, directives: s, bound: o };
3005
+ return { props: n, attrs: i, directives: s, bound: o };
2458
3006
  }
2459
- function Tt(e, t, r) {
2460
- const i = ce.length > 0 ? ce[ce.length - 1] : void 0, n = r ?? i;
2461
- function s(f, b) {
2462
- return ae("#text", {}, f, b);
3007
+ function er(e, t, r) {
3008
+ const n = pe.length > 0 ? pe[pe.length - 1] : void 0, i = r ?? n, s = !r && t.length === 0, o = s ? e.join("<!--TEMPLATE_DELIM-->") : null;
3009
+ if (s && o) {
3010
+ const f = We.get(o);
3011
+ if (f) return f;
2463
3012
  }
2464
- let o = "";
3013
+ function a(f, x) {
3014
+ return fe("#text", {}, f, x);
3015
+ }
3016
+ let u = "";
2465
3017
  for (let f = 0; f < e.length; f++)
2466
- o += e[f], f < t.length && (o += `{{${f}}}`);
2467
- const a = /<!--[\s\S]*?-->|<\/?([a-zA-Z0-9-]+)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s>]+))?)*)\s*\/?>|{{(\d+)}}|([^<]+)/g, c = [];
2468
- let u, m = [], T = null, p = {}, l, w = 0, v = [];
2469
- function d(f) {
2470
- !f || typeof f != "object" || ye(f) || (f.props || f.attrs ? (f.props && (p.props || (p.props = {}), Object.assign(p.props, f.props)), f.attrs && (p.attrs || (p.attrs = {}), Object.keys(f.attrs).forEach((b) => {
2471
- if (b === "style" && p.attrs.style) {
2472
- const h = p.attrs.style.replace(
3018
+ u += e[f], f < t.length && (u += `{{${f}}}`);
3019
+ const m = /<!--[\s\S]*?-->|<\/?([a-zA-Z0-9-]+)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s>]+))?)*)\s*\/?>|{{(\d+)}}|([^<]+)/g, g = [];
3020
+ let w, h = [], l = null, d = {}, v, b = 0, c = [];
3021
+ function p(f) {
3022
+ !f || typeof f != "object" || Se(f) || (f.props || f.attrs ? (f.props && (d.props || (d.props = {}), Object.assign(d.props, f.props)), f.attrs && (d.attrs || (d.attrs = {}), Object.keys(f.attrs).forEach((x) => {
3023
+ if (x === "style" && d.attrs.style) {
3024
+ const A = d.attrs.style.replace(
2473
3025
  /;?\s*$/,
2474
3026
  ""
2475
3027
  ), _ = f.attrs.style.replace(/^;?\s*/, "");
2476
- p.attrs.style = h + "; " + _;
2477
- } else if (b === "class" && p.attrs.class) {
2478
- const h = p.attrs.class.trim().split(/\s+/).filter(Boolean), _ = f.attrs.class.trim().split(/\s+/).filter(Boolean), $ = [
2479
- .../* @__PURE__ */ new Set([...h, ..._])
3028
+ d.attrs.style = A + "; " + _;
3029
+ } else if (x === "class" && d.attrs.class) {
3030
+ const A = d.attrs.class.trim().split(/\s+/).filter(Boolean), _ = f.attrs.class.trim().split(/\s+/).filter(Boolean), S = [
3031
+ .../* @__PURE__ */ new Set([...A, ..._])
2480
3032
  ];
2481
- p.attrs.class = $.join(" ");
3033
+ d.attrs.class = S.join(" ");
2482
3034
  } else
2483
- p.attrs[b] = f.attrs[b];
2484
- }))) : (p.props || (p.props = {}), Object.assign(p.props, f)));
2485
- }
2486
- function g(f, b) {
2487
- const h = T ? m : v;
2488
- if (ye(f)) {
2489
- const _ = f.key ?? b;
2490
- let $ = f.children;
2491
- h.push({
3035
+ d.attrs[x] = f.attrs[x];
3036
+ }))) : (d.props || (d.props = {}), Object.assign(d.props, f)));
3037
+ }
3038
+ function y(f, x) {
3039
+ const A = l ? h : c;
3040
+ if (Se(f)) {
3041
+ const _ = f.key ?? x;
3042
+ let S = f.children;
3043
+ A.push({
2492
3044
  ...f,
2493
3045
  key: _,
2494
- children: $
3046
+ children: S
2495
3047
  });
2496
3048
  return;
2497
3049
  }
2498
- if (de(f)) {
2499
- h.push(Ct(f, void 0));
3050
+ if (ke(f)) {
3051
+ A.push(Yt(f, void 0));
2500
3052
  return;
2501
3053
  }
2502
3054
  if (Array.isArray(f)) {
2503
3055
  if (f.length === 0) return;
2504
3056
  for (let _ = 0; _ < f.length; _++) {
2505
- const $ = f[_];
2506
- ye($) || de($) || Array.isArray($) ? g($, `${b}-${_}`) : $ !== null && typeof $ == "object" ? d($) : h.push(s(String($), `${b}-${_}`));
3057
+ const S = f[_];
3058
+ Se(S) || ke(S) || Array.isArray(S) ? y(S, `${x}-${_}`) : S !== null && typeof S == "object" ? p(S) : A.push(a(String(S), `${x}-${_}`));
2507
3059
  }
2508
3060
  return;
2509
3061
  }
2510
3062
  if (f !== null && typeof f == "object") {
2511
- d(f);
3063
+ p(f);
2512
3064
  return;
2513
3065
  }
2514
- h.push(s(String(f), b));
3066
+ A.push(a(String(f), x));
2515
3067
  }
2516
- const y = /* @__PURE__ */ new Set([
3068
+ const C = /* @__PURE__ */ new Set([
2517
3069
  "area",
2518
3070
  "base",
2519
3071
  "br",
@@ -2529,24 +3081,24 @@ function Tt(e, t, r) {
2529
3081
  "track",
2530
3082
  "wbr"
2531
3083
  ]);
2532
- for (; u = a.exec(o); )
2533
- if (!(u[0].startsWith("<!--") && u[0].endsWith("-->"))) {
2534
- if (u[1]) {
2535
- const f = u[1], b = u[0][1] === "/", h = u[0][u[0].length - 2] === "/" || y.has(f), {
3084
+ for (; w = m.exec(u); )
3085
+ if (!(w[0].startsWith("<!--") && w[0].endsWith("-->"))) {
3086
+ if (w[1]) {
3087
+ const f = w[1], x = w[0][1] === "/", A = w[0][w[0].length - 2] === "/" || C.has(f), {
2536
3088
  props: _,
2537
- attrs: $,
2538
- directives: S,
2539
- bound: E
2540
- } = At(u[2] || "", t, n), C = { props: {}, attrs: {} };
2541
- for (const A in _) C.props[A] = _[A];
2542
- for (const A in $) C.attrs[A] = $[A];
2543
- if (C.attrs && Object.prototype.hasOwnProperty.call(C.attrs, "key") && !(C.props && Object.prototype.hasOwnProperty.call(C.props, "key")))
3089
+ attrs: S,
3090
+ directives: R,
3091
+ bound: T
3092
+ } = Qt(w[2] || "", t, i), $ = { props: {}, attrs: {} };
3093
+ for (const P in _) $.props[P] = _[P];
3094
+ for (const P in S) $.attrs[P] = S[P];
3095
+ if ($.attrs && Object.prototype.hasOwnProperty.call($.attrs, "key") && !($.props && Object.prototype.hasOwnProperty.call($.props, "key")))
2544
3096
  try {
2545
- C.props.key = C.attrs.key;
3097
+ $.props.key = $.attrs.key;
2546
3098
  } catch {
2547
3099
  }
2548
3100
  try {
2549
- const A = {
3101
+ const P = {
2550
3102
  input: ["value", "checked", "disabled", "readonly", "required", "placeholder", "maxlength", "minlength"],
2551
3103
  textarea: ["value", "disabled", "readonly", "required", "placeholder", "maxlength", "minlength"],
2552
3104
  select: ["value", "disabled", "required", "multiple"],
@@ -2555,370 +3107,671 @@ function Tt(e, t, r) {
2555
3107
  audio: ["muted", "autoplay", "controls", "loop"],
2556
3108
  img: ["src", "alt", "width", "height"],
2557
3109
  button: ["type", "name", "value", "disabled", "autofocus", "form"]
2558
- }, P = f.toLowerCase(), X = A[P] ?? [];
2559
- if (C.attrs)
2560
- for (const M of X)
2561
- E && E.includes(M) && M in C.attrs && !(C.props && M in C.props) && (C.props[M] = C.attrs[M], delete C.attrs[M]);
2562
- if ((f.includes("-") || !!n?.__customElements?.has?.(f)) && E && C.attrs) {
2563
- const M = /* @__PURE__ */ new Set(["id", "name", "data-key", "key"]);
2564
- for (const F of E)
2565
- if (F in C.attrs && !(C.props && F in C.props)) {
2566
- const H = F.includes("-") ? F.split("-").map((N, I) => I === 0 ? N : N.charAt(0).toUpperCase() + N.slice(1)).join("") : F;
2567
- C.props[H] = C.attrs[F], M.has(F) || delete C.attrs[F];
3110
+ }, B = f.toLowerCase(), J = P[B] ?? [];
3111
+ if ($.attrs) {
3112
+ for (const K of J)
3113
+ if (T && T.includes(K) && K in $.attrs && !($.props && K in $.props)) {
3114
+ let L = $.attrs[K];
3115
+ L && typeof L == "object" && L.constructor?.name === "ReactiveState" && (L = L.value), $.props[K] = L, delete $.attrs[K];
3116
+ }
3117
+ }
3118
+ if ((f.includes("-") || !!i?.__customElements?.has?.(f)) && ($.isCustomElement = !0, T && $.attrs)) {
3119
+ const K = /* @__PURE__ */ new Set(["id", "name", "data-key", "key"]);
3120
+ for (const L of T)
3121
+ if (L in $.attrs && !($.props && L in $.props)) {
3122
+ const j = L.includes("-") ? L.split("-").map((Z, W) => W === 0 ? Z : Z.charAt(0).toUpperCase() + Z.slice(1)).join("") : L;
3123
+ let V = $.attrs[L];
3124
+ V && typeof V == "object" && V.constructor?.name === "ReactiveState" && (V = V.value), $.props[j] = V, K.has(L) || delete $.attrs[L];
2568
3125
  }
2569
- C.isCustomElement = !0;
2570
3126
  }
2571
3127
  } catch {
2572
3128
  }
2573
- if (S && Object.keys(S).some((A) => A === "model" || A.startsWith("model:")))
3129
+ if (R && Object.keys(R).some((P) => P === "model" || P.startsWith("model:")))
2574
3130
  try {
2575
- const A = Symbol.for("cer.registry"), P = globalThis[A], X = !!(P && typeof P.has == "function" && P.has(f)), ie = !!(n && (n.__customElements instanceof Set && n.__customElements.has(f) || Array.isArray(n.__isCustomElements) && n.__isCustomElements.includes(f)));
2576
- if (!!(f.includes("-") || ie || X))
2577
- for (const H of Object.keys(S)) {
2578
- if (H !== "model" && !H.startsWith("model:")) continue;
2579
- const N = S[H], I = N.arg ?? (H.includes(":") ? H.split(":", 2)[1] : void 0), z = N.value, J = I ?? "modelValue", se = K, k = he, W = n ? n._state || n : void 0;
2580
- let R;
2581
- typeof z == "string" && n ? R = se(W, z) : R = z, C.props[J] = R;
3131
+ const P = Symbol.for("cer.registry"), B = globalThis[P], J = !!(B && typeof B.has == "function" && B.has(f)), ye = !!(i && (i.__customElements instanceof Set && i.__customElements.has(f) || Array.isArray(i.__isCustomElements) && i.__isCustomElements.includes(f)));
3132
+ if (!!(f.includes("-") || ye || J))
3133
+ for (const j of Object.keys(R)) {
3134
+ if (j !== "model" && !j.startsWith("model:")) continue;
3135
+ const V = R[j], Z = V.arg ?? (j.includes(":") ? j.split(":", 2)[1] : void 0), W = V.value, E = Z ?? "modelValue", U = H, D = Ce, z = i ? i._state || i : void 0;
3136
+ let O;
3137
+ typeof W == "string" && i ? O = U(z, W) : (O = W, O && typeof O == "object" && O.constructor?.name === "ReactiveState" && (O = O.value)), $.props[E] = O;
2582
3138
  try {
2583
- const L = Q(J);
2584
- C.attrs || (C.attrs = {}), R !== void 0 && (C.attrs[L] = R);
3139
+ const re = te(E);
3140
+ $.attrs || ($.attrs = {}), O !== void 0 && ($.attrs[re] = O);
2585
3141
  } catch {
2586
3142
  }
2587
- C.isCustomElement = !0;
2588
- const B = `update:${Q(J)}`, j = "on" + B.charAt(0).toUpperCase() + B.slice(1);
2589
- C.props[j] = function(L) {
2590
- const fe = L.detail !== void 0 ? L.detail : L.target ? L.target.value : void 0;
2591
- if (!W) return;
2592
- const ve = se(W, typeof z == "string" ? z : String(z));
2593
- (Array.isArray(fe) && Array.isArray(ve) ? JSON.stringify([...fe].sort()) !== JSON.stringify([...ve].sort()) : fe !== ve) && (k(W, typeof z == "string" ? z : String(z), fe), n?.requestRender ? n.requestRender() : n?._requestRender && n._requestRender());
2594
- }, delete S[H];
3143
+ $.isCustomElement = !0;
3144
+ const Be = `update:${te(E)}`.replace(/-([a-z])/g, (re, Y) => Y.toUpperCase()), ct = "on" + Be.charAt(0).toUpperCase() + Be.slice(1);
3145
+ $.props[ct] = function(re) {
3146
+ const Y = re.detail !== void 0 ? re.detail : re.target ? re.target.value : void 0;
3147
+ if (z)
3148
+ if (W && typeof W == "object" && W.constructor?.name === "ReactiveState") {
3149
+ const oe = W.value;
3150
+ (Array.isArray(Y) && Array.isArray(oe) ? JSON.stringify([...Y].sort()) !== JSON.stringify([...oe].sort()) : Y !== oe) && (W.value = Y, i?.requestRender ? i.requestRender() : i?._requestRender && i._requestRender());
3151
+ } else {
3152
+ const oe = U(z, typeof W == "string" ? W : String(W));
3153
+ (Array.isArray(Y) && Array.isArray(oe) ? JSON.stringify([...Y].sort()) !== JSON.stringify([...oe].sort()) : Y !== oe) && (D(z, typeof W == "string" ? W : String(W), Y), i?.requestRender ? i.requestRender() : i?._requestRender && i._requestRender());
3154
+ }
3155
+ }, delete R[j];
2595
3156
  }
2596
3157
  } catch {
2597
3158
  }
2598
- if (Object.keys(S).length > 0 && (C.directives = { ...S }), b) {
2599
- const A = ae(
2600
- T,
2601
- p,
2602
- m.length === 1 && de(m[0]) && m[0].tag === "#text" ? typeof m[0].children == "string" ? m[0].children : "" : m.length ? m : void 0,
2603
- l
2604
- ), P = c.pop();
2605
- P ? (T = P.tag, p = P.props, l = P.key, m = P.children, m.push(A)) : (v.push(A), T = null, p = {}, l = void 0, m = []);
2606
- } else h ? T ? m.push(ae(f, C, void 0, void 0)) : v.push(ae(f, C, void 0, void 0)) : (T && c.push({
2607
- tag: T,
2608
- props: p,
2609
- children: m,
2610
- key: l
2611
- }), T = f, p = C, m = []);
2612
- } else if (typeof u[3] < "u") {
2613
- const f = Number(u[3]), b = t[f], h = `interp-${f}`;
2614
- g(b, h);
2615
- } else if (u[4]) {
2616
- const f = u[4], b = T ? m : v, h = f.split(/({{\d+}})/);
2617
- for (const _ of h) {
3159
+ if (Object.keys(R).length > 0 && ($.directives = { ...R }), x) {
3160
+ const P = fe(
3161
+ l,
3162
+ d,
3163
+ h.length === 1 && ke(h[0]) && h[0].tag === "#text" ? typeof h[0].children == "string" ? h[0].children : "" : h.length ? h : void 0,
3164
+ v
3165
+ ), B = g.pop();
3166
+ B ? (l = B.tag, d = B.props, v = B.key, h = B.children, h.push(P)) : (c.push(P), l = null, d = {}, v = void 0, h = []);
3167
+ } else A ? l ? h.push(fe(f, $, void 0, void 0)) : c.push(fe(f, $, void 0, void 0)) : (l && g.push({
3168
+ tag: l,
3169
+ props: d,
3170
+ children: h,
3171
+ key: v
3172
+ }), l = f, d = $, h = []);
3173
+ } else if (typeof w[3] < "u") {
3174
+ const f = Number(w[3]), x = t[f], A = `interp-${f}`;
3175
+ y(x, A);
3176
+ } else if (w[4]) {
3177
+ const f = w[4], x = l ? h : c, A = f.split(/({{\d+}})/);
3178
+ for (const _ of A) {
2618
3179
  if (!_) continue;
2619
- const $ = _.match(/^{{(\d+)}}$/);
2620
- if ($) {
2621
- const S = Number($[1]), E = t[S], C = `interp-${S}`;
2622
- g(E, C);
3180
+ const S = _.match(/^{{(\d+)}}$/);
3181
+ if (S) {
3182
+ const R = Number(S[1]), T = t[R], $ = `interp-${R}`;
3183
+ y(T, $);
2623
3184
  } else {
2624
- const S = `text-${w++}`;
2625
- b.push(s(_, S));
3185
+ const R = `text-${b++}`;
3186
+ x.push(a(_, R));
2626
3187
  }
2627
3188
  }
2628
3189
  }
2629
3190
  }
2630
- const x = v.filter((f) => de(f) && f.tag === "#text" ? typeof f.children == "string" && f.children.trim() !== "" : !0);
2631
- return x.length === 1 ? x[0] : x.length > 1 ? x : ae("div", {}, "", "fallback-root");
3191
+ const k = c.filter((f) => ke(f) && f.tag === "#text" ? typeof f.children == "string" && f.children.trim() !== "" : !0);
3192
+ if (k.length === 1) {
3193
+ const f = k[0];
3194
+ return s && o && We.set(o, f), f;
3195
+ } else if (k.length > 1) {
3196
+ const f = k;
3197
+ return s && o && We.set(o, f), f;
3198
+ }
3199
+ return fe("div", {}, "", "fallback-root");
3200
+ }
3201
+ function ae(e, ...t) {
3202
+ const r = t[t.length - 1], n = typeof r == "object" && r && !Array.isArray(r) ? r : void 0;
3203
+ return er(e, t, n);
3204
+ }
3205
+ function Ae(e, t) {
3206
+ return M(e ? t : [], "when-block");
3207
+ }
3208
+ function gr(e, t) {
3209
+ return e.map((r, n) => {
3210
+ const i = typeof r == "object" ? r?.key ?? r?.id ?? `idx-${n}` : String(r);
3211
+ return M(t(r, n), `each-${i}`);
3212
+ });
3213
+ }
3214
+ function tr() {
3215
+ const e = [];
3216
+ return {
3217
+ when(t, r) {
3218
+ return e.push([t, r]), this;
3219
+ },
3220
+ otherwise(t) {
3221
+ return e.push([!0, t]), this;
3222
+ },
3223
+ done() {
3224
+ return rr(...e);
3225
+ }
3226
+ };
3227
+ }
3228
+ function rr(...e) {
3229
+ for (let t = 0; t < e.length; t++) {
3230
+ const [r, n] = e[t];
3231
+ if (r) return [M(n, `whenChain-branch-${t}`)];
3232
+ }
3233
+ return [M([], "whenChain-empty")];
3234
+ }
3235
+ function M(e, t) {
3236
+ const r = e ? Array.isArray(e) ? e.filter(Boolean) : [e].filter(Boolean) : [];
3237
+ return {
3238
+ tag: "#anchor",
3239
+ key: t,
3240
+ children: r
3241
+ };
3242
+ }
3243
+ function mr(e, t) {
3244
+ return Ae(!e, t);
3245
+ }
3246
+ function yr(e, t) {
3247
+ const r = !e || e.length === 0;
3248
+ return Ae(r, t);
3249
+ }
3250
+ function br(e, t) {
3251
+ const r = !!(e && e.length > 0);
3252
+ return Ae(r, t);
3253
+ }
3254
+ function wr(e, t, r) {
3255
+ const n = [];
3256
+ return e.forEach((i, s) => {
3257
+ t(i, s) && n.push({ item: i, originalIndex: s });
3258
+ }), n.map(({ item: i, originalIndex: s }, o) => {
3259
+ const a = typeof i == "object" && i != null ? i?.key ?? i?.id ?? `filtered-${s}` : `filtered-${s}`;
3260
+ return M(r(i, s, o), `each-where-${a}`);
3261
+ });
3262
+ }
3263
+ function vr(e, t) {
3264
+ const r = e?.length ?? 0;
3265
+ return r === 0 && t.empty ? M(t.empty, "switch-length-empty") : r === 1 && t.one ? M(t.one(e[0]), "switch-length-one") : t.exactly?.[r] ? M(t.exactly[r](e), `switch-length-${r}`) : r > 1 && t.many ? M(t.many(e), "switch-length-many") : M([], "switch-length-fallback");
3266
+ }
3267
+ function xr(e, t, r) {
3268
+ const n = /* @__PURE__ */ new Map();
3269
+ return e.forEach((i) => {
3270
+ const s = t(i);
3271
+ n.has(s) || n.set(s, []), n.get(s).push(i);
3272
+ }), Array.from(n.entries()).map(([i, s], o) => M(
3273
+ r(i, s, o),
3274
+ `each-group-${i}`
3275
+ ));
3276
+ }
3277
+ function kr(e, t, r, n) {
3278
+ const i = r * t, s = Math.min(i + t, e.length);
3279
+ return e.slice(i, s).map((a, u) => {
3280
+ const m = i + u, g = typeof a == "object" && a != null ? a?.key ?? a?.id ?? `page-${m}` : `page-${m}`;
3281
+ return M(n(a, m, u), `each-page-${g}`);
3282
+ });
3283
+ }
3284
+ function Cr(e, t) {
3285
+ return e.loading && t.loading ? M(t.loading, "promise-loading") : e.error && t.error ? M(t.error(e.error), "promise-error") : e.data !== void 0 && t.success ? M(t.success(e.data), "promise-success") : t.idle ? M(t.idle, "promise-idle") : M([], "promise-fallback");
3286
+ }
3287
+ function q(e, t) {
3288
+ const r = typeof window < "u" && window.matchMedia?.(e)?.matches;
3289
+ return Ae(!!r, t);
3290
+ }
3291
+ const ee = {
3292
+ // Responsive breakpoints (matching style.ts)
3293
+ sm: "(min-width:640px)",
3294
+ md: "(min-width:768px)",
3295
+ lg: "(min-width:1024px)",
3296
+ xl: "(min-width:1280px)",
3297
+ "2xl": "(min-width:1536px)",
3298
+ // Dark mode (matching style.ts)
3299
+ dark: "(prefers-color-scheme: dark)"
3300
+ }, at = ["sm", "md", "lg", "xl", "2xl"], nr = {
3301
+ // Breakpoint-based rendering (matching style.ts exactly)
3302
+ sm: (e) => q(ee.sm, e),
3303
+ md: (e) => q(ee.md, e),
3304
+ lg: (e) => q(ee.lg, e),
3305
+ xl: (e) => q(ee.xl, e),
3306
+ "2xl": (e) => q(ee["2xl"], e),
3307
+ // Dark mode (matching style.ts)
3308
+ dark: (e) => q(ee.dark, e),
3309
+ light: (e) => q("(prefers-color-scheme: light)", e),
3310
+ // Accessibility and interaction preferences
3311
+ touch: (e) => q("(hover: none) and (pointer: coarse)", e),
3312
+ mouse: (e) => q("(hover: hover) and (pointer: fine)", e),
3313
+ reducedMotion: (e) => q("(prefers-reduced-motion: reduce)", e),
3314
+ highContrast: (e) => q("(prefers-contrast: high)", e),
3315
+ // Orientation
3316
+ portrait: (e) => q("(orientation: portrait)", e),
3317
+ landscape: (e) => q("(orientation: landscape)", e)
3318
+ };
3319
+ function _r(e, t) {
3320
+ const r = [];
3321
+ e.includes("dark") ? r.push(ee.dark) : e.includes("light") && r.push("(prefers-color-scheme: light)");
3322
+ const n = e.filter(
3323
+ (o) => at.includes(o)
3324
+ ), i = n[n.length - 1];
3325
+ i && i in ee && r.push(ee[i]);
3326
+ const s = r.length > 0 ? r.join(" and ") : "all";
3327
+ return q(s, t);
3328
+ }
3329
+ function Er(e) {
3330
+ const t = [];
3331
+ return e.base && t.push(M(e.base, "responsive-base")), at.forEach((r) => {
3332
+ const n = e[r];
3333
+ n && t.push(nr[r](n));
3334
+ }), t;
3335
+ }
3336
+ function Sr(e) {
3337
+ const t = [];
3338
+ let r = null;
3339
+ return {
3340
+ case(n, i) {
3341
+ const s = typeof n == "function" ? n : (o) => o === n;
3342
+ return t.push({ condition: s, content: i }), this;
3343
+ },
3344
+ when(n, i) {
3345
+ return t.push({ condition: n, content: i }), this;
3346
+ },
3347
+ otherwise(n) {
3348
+ return r = n, this;
3349
+ },
3350
+ done() {
3351
+ for (let n = 0; n < t.length; n++) {
3352
+ const { condition: i, content: s } = t[n];
3353
+ if (i(e))
3354
+ return M(s, `switch-case-${n}`);
3355
+ }
3356
+ return M(r || [], "switch-otherwise");
3357
+ }
3358
+ };
3359
+ }
3360
+ class ue extends EventTarget {
3361
+ handlers = {};
3362
+ static instance;
3363
+ eventCounters = /* @__PURE__ */ new Map();
3364
+ /**
3365
+ * Returns the singleton instance of GlobalEventBus
3366
+ */
3367
+ static getInstance() {
3368
+ return ue.instance || (ue.instance = new ue()), ue.instance;
3369
+ }
3370
+ /**
3371
+ * Emit a global event with optional data. Includes event storm protection.
3372
+ * @param eventName - Name of the event
3373
+ * @param data - Optional event payload
3374
+ */
3375
+ emit(t, r) {
3376
+ const n = Date.now(), i = this.eventCounters.get(t);
3377
+ if (!i || n - i.window > 1e3)
3378
+ this.eventCounters.set(t, { count: 1, window: n });
3379
+ else if (i.count++, i.count > 50 && i.count > 100)
3380
+ return;
3381
+ this.dispatchEvent(new CustomEvent(t, {
3382
+ detail: r,
3383
+ bubbles: !1,
3384
+ // Global events don't need to bubble
3385
+ cancelable: !0
3386
+ }));
3387
+ const s = this.handlers[t];
3388
+ s && s.forEach((o) => {
3389
+ try {
3390
+ o(r);
3391
+ } catch (a) {
3392
+ ie(`Error in global event handler for "${t}":`, a);
3393
+ }
3394
+ });
3395
+ }
3396
+ /**
3397
+ * Register a handler for a global event. Returns an unsubscribe function.
3398
+ * @param eventName - Name of the event
3399
+ * @param handler - Handler function
3400
+ */
3401
+ on(t, r) {
3402
+ return this.handlers[t] || (this.handlers[t] = /* @__PURE__ */ new Set()), this.handlers[t].add(r), () => this.off(t, r);
3403
+ }
3404
+ /**
3405
+ * Remove a specific handler for a global event.
3406
+ * @param eventName - Name of the event
3407
+ * @param handler - Handler function to remove
3408
+ */
3409
+ off(t, r) {
3410
+ const n = this.handlers[t];
3411
+ n && n.delete(r);
3412
+ }
3413
+ /**
3414
+ * Remove all handlers for a specific event.
3415
+ * @param eventName - Name of the event
3416
+ */
3417
+ offAll(t) {
3418
+ delete this.handlers[t];
3419
+ }
3420
+ /**
3421
+ * Listen for a native CustomEvent. Returns an unsubscribe function.
3422
+ * @param eventName - Name of the event
3423
+ * @param handler - CustomEvent handler
3424
+ * @param options - AddEventListener options
3425
+ */
3426
+ listen(t, r, n) {
3427
+ return this.addEventListener(t, r, n), () => this.removeEventListener(t, r);
3428
+ }
3429
+ /**
3430
+ * Register a one-time event handler. Returns a promise that resolves with the event data.
3431
+ * @param eventName - Name of the event
3432
+ * @param handler - Handler function
3433
+ */
3434
+ once(t, r) {
3435
+ return new Promise((n) => {
3436
+ const i = this.on(t, (s) => {
3437
+ i(), r(s), n(s);
3438
+ });
3439
+ });
3440
+ }
3441
+ /**
3442
+ * Get a list of all active event names with registered handlers.
3443
+ */
3444
+ getActiveEvents() {
3445
+ return Object.keys(this.handlers).filter(
3446
+ (t) => this.handlers[t] && this.handlers[t].size > 0
3447
+ );
3448
+ }
3449
+ /**
3450
+ * Clear all event handlers (useful for testing or cleanup).
3451
+ */
3452
+ clear() {
3453
+ this.handlers = {};
3454
+ }
3455
+ /**
3456
+ * Get the number of handlers registered for a specific event.
3457
+ * @param eventName - Name of the event
3458
+ */
3459
+ getHandlerCount(t) {
3460
+ return this.handlers[t]?.size || 0;
3461
+ }
3462
+ /**
3463
+ * Get event statistics for debugging.
3464
+ */
3465
+ getEventStats() {
3466
+ const t = {};
3467
+ for (const [r, n] of this.eventCounters.entries())
3468
+ t[r] = {
3469
+ count: n.count,
3470
+ handlersCount: this.getHandlerCount(r)
3471
+ };
3472
+ return t;
3473
+ }
3474
+ /**
3475
+ * Reset event counters (useful for testing or after resolving issues).
3476
+ */
3477
+ resetEventCounters() {
3478
+ this.eventCounters.clear();
3479
+ }
2632
3480
  }
2633
- function ee(e, ...t) {
2634
- const r = t[t.length - 1], i = typeof r == "object" && r && !Array.isArray(r) ? r : void 0;
2635
- return Tt(e, t, i);
3481
+ const me = ue.getInstance(), $r = (e, t) => me.emit(e, t), Ar = (e, t) => me.on(e, t), Rr = (e, t) => me.off(e, t), Tr = (e, t) => me.once(e, t), Or = (e, t, r) => me.listen(e, t, r);
3482
+ function Qe(e) {
3483
+ let t = { ...e };
3484
+ const r = [];
3485
+ function n(a) {
3486
+ r.push(a), a(t);
3487
+ }
3488
+ function i() {
3489
+ return t;
3490
+ }
3491
+ function s(a) {
3492
+ const u = typeof a == "function" ? a(t) : a;
3493
+ t = { ...t, ...u }, o();
3494
+ }
3495
+ function o() {
3496
+ r.forEach((a) => a(t));
3497
+ }
3498
+ return { subscribe: n, getState: i, setState: s };
2636
3499
  }
2637
- const qe = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, V = (e, t) => {
3500
+ const et = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, Q = (e, t) => {
2638
3501
  for (const r of e) {
2639
- const i = [], n = r.path.replace(/:[^/]+/g, (a) => (i.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${n}$`), o = t.match(s);
3502
+ const n = [], i = r.path.replace(/:[^/]+/g, (a) => (n.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${i}$`), o = t.match(s);
2640
3503
  if (o) {
2641
3504
  const a = {};
2642
- return i.forEach((c, u) => {
2643
- a[c] = o[u + 1];
3505
+ return n.forEach((u, m) => {
3506
+ a[u] = o[m + 1];
2644
3507
  }), { route: r, params: a };
2645
3508
  }
2646
3509
  }
2647
3510
  return { route: null, params: {} };
2648
- }, Te = {};
2649
- async function jt(e) {
3511
+ }, ze = {};
3512
+ async function ir(e) {
2650
3513
  if (e.component) return e.component;
2651
3514
  if (e.load) {
2652
- if (Te[e.path]) return Te[e.path];
3515
+ if (ze[e.path]) return ze[e.path];
2653
3516
  try {
2654
3517
  const t = await e.load();
2655
- return Te[e.path] = t.default, t.default;
3518
+ return ze[e.path] = t.default, t.default;
2656
3519
  } catch {
2657
3520
  throw new Error(`Failed to load component for route: ${e.path}`);
2658
3521
  }
2659
3522
  }
2660
3523
  throw new Error(`No component or loader defined for route: ${e.path}`);
2661
3524
  }
2662
- function Lt(e) {
2663
- const { routes: t, base: r = "", initialUrl: i } = e;
2664
- let n, s, o, a, c, u, m;
2665
- const T = async (v, d) => {
2666
- const g = t.find((y) => V([y], v.path).route !== null);
2667
- if (g?.beforeEnter)
3525
+ function sr(e) {
3526
+ const { routes: t, base: r = "", initialUrl: n } = e;
3527
+ let i, s, o, a, u, m, g;
3528
+ const w = async (v, b) => {
3529
+ const c = t.find((p) => Q([p], v.path).route !== null);
3530
+ if (c?.beforeEnter)
2668
3531
  try {
2669
- const y = await g.beforeEnter(v, d);
2670
- return typeof y == "string" ? (await w(y, !0), !1) : y !== !1;
2671
- } catch (y) {
2672
- return Y("beforeEnter error", y), !1;
3532
+ const p = await c.beforeEnter(v, b);
3533
+ return typeof p == "string" ? (await d(p, !0), !1) : p !== !1;
3534
+ } catch (p) {
3535
+ return ie("beforeEnter error", p), !1;
2673
3536
  }
2674
3537
  return !0;
2675
- }, p = async (v, d) => {
2676
- const g = t.find((y) => V([y], v.path).route !== null);
2677
- if (g?.onEnter)
3538
+ }, h = async (v, b) => {
3539
+ const c = t.find((p) => Q([p], v.path).route !== null);
3540
+ if (c?.onEnter)
2678
3541
  try {
2679
- const y = await g.onEnter(v, d);
2680
- return typeof y == "string" ? (await w(y, !0), !1) : y !== !1;
2681
- } catch (y) {
2682
- return Y("onEnter error", y), !1;
3542
+ const p = await c.onEnter(v, b);
3543
+ return typeof p == "string" ? (await d(p, !0), !1) : p !== !1;
3544
+ } catch (p) {
3545
+ return ie("onEnter error", p), !1;
2683
3546
  }
2684
3547
  return !0;
2685
- }, l = (v, d) => {
2686
- const g = t.find((y) => V([y], v.path).route !== null);
2687
- if (g?.afterEnter)
3548
+ }, l = (v, b) => {
3549
+ const c = t.find((p) => Q([p], v.path).route !== null);
3550
+ if (c?.afterEnter)
2688
3551
  try {
2689
- g.afterEnter(v, d);
2690
- } catch (y) {
2691
- Y("afterEnter error", y);
3552
+ c.afterEnter(v, b);
3553
+ } catch (p) {
3554
+ ie("afterEnter error", p);
2692
3555
  }
2693
- }, w = async (v, d = !1) => {
3556
+ }, d = async (v, b = !1) => {
2694
3557
  try {
2695
- const g = {
3558
+ const c = {
2696
3559
  path: v.replace(r, "") || "/",
2697
3560
  query: {}
2698
- }, y = V(t, g.path);
2699
- if (!y) throw new Error(`No route found for ${g.path}`);
2700
- const x = o.getState(), f = {
2701
- path: g.path,
2702
- params: y.params,
2703
- query: g.query
3561
+ }, p = Q(t, c.path);
3562
+ if (!p) throw new Error(`No route found for ${c.path}`);
3563
+ const y = o.getState(), C = {
3564
+ path: c.path,
3565
+ params: p.params,
3566
+ query: c.query
2704
3567
  };
2705
- if (!await T(f, x) || !await p(f, x)) return;
2706
- typeof window < "u" && typeof document < "u" && (d ? window.history.replaceState({}, "", r + v) : window.history.pushState({}, "", r + v)), o.setState(f), l(f, x);
2707
- } catch (g) {
2708
- Y("Navigation error:", g);
3568
+ if (!await w(C, y) || !await h(C, y)) return;
3569
+ typeof window < "u" && typeof document < "u" && (b ? window.history.replaceState({}, "", r + v) : window.history.pushState({}, "", r + v)), o.setState(C), l(C, y);
3570
+ } catch (c) {
3571
+ ie("Navigation error:", c);
2709
3572
  }
2710
3573
  };
2711
- if (typeof window < "u" && typeof document < "u") {
2712
- n = () => {
2713
- const d = new URL(window.location.href), g = d.pathname.replace(r, "") || "/", y = qe(d.search);
2714
- return { path: g, query: y };
2715
- }, s = n();
2716
- const v = V(t, s.path);
2717
- o = Le({
3574
+ if (typeof window < "u" && typeof document < "u" && typeof n > "u") {
3575
+ i = () => {
3576
+ const b = new URL(window.location.href), c = b.pathname.replace(r, "") || "/", p = et(b.search);
3577
+ return { path: c, query: p };
3578
+ }, s = i();
3579
+ const v = Q(t, s.path);
3580
+ o = Qe({
2718
3581
  path: s.path,
2719
3582
  params: v.params,
2720
3583
  query: s.query
2721
- }), a = async (d = !1) => {
2722
- const g = n();
2723
- await w(g.path, d);
2724
- }, window.addEventListener("popstate", () => a(!0)), c = (d) => w(d, !1), u = (d) => w(d, !0), m = () => window.history.back();
3584
+ }), a = async (b = !1) => {
3585
+ const c = i();
3586
+ await d(c.path, b);
3587
+ }, window.addEventListener("popstate", () => a(!0)), u = (b) => d(b, !1), m = (b) => d(b, !0), g = () => window.history.back();
2725
3588
  } else {
2726
- n = () => {
2727
- const g = new URL(i || "/", "http://localhost"), y = g.pathname.replace(r, "") || "/", x = qe(g.search);
2728
- return { path: y, query: x };
2729
- }, s = n();
2730
- const v = V(t, s.path);
2731
- o = Le({
3589
+ i = () => {
3590
+ const c = new URL(n || "/", "http://localhost"), p = c.pathname.replace(r, "") || "/", y = et(c.search);
3591
+ return { path: p, query: y };
3592
+ }, s = i();
3593
+ const v = Q(t, s.path);
3594
+ o = Qe({
2732
3595
  path: s.path,
2733
3596
  params: v.params,
2734
3597
  query: s.query
2735
3598
  }), a = async () => {
2736
- const g = n();
2737
- await d(g.path);
3599
+ const c = i();
3600
+ await b(c.path);
2738
3601
  };
2739
- const d = async (g) => {
3602
+ const b = async (c) => {
2740
3603
  try {
2741
- const y = {
2742
- path: g.replace(r, "") || "/",
3604
+ const p = {
3605
+ path: c.replace(r, "") || "/",
2743
3606
  query: {}
2744
- }, x = V(t, y.path);
2745
- if (!x) throw new Error(`No route found for ${y.path}`);
2746
- const f = o.getState(), b = {
2747
- path: y.path,
2748
- params: x.params,
2749
- query: y.query
2750
- }, h = t.find((_) => V([_], b.path).route !== null);
2751
- if (h?.beforeEnter)
3607
+ }, y = Q(t, p.path);
3608
+ if (!y) throw new Error(`No route found for ${p.path}`);
3609
+ const C = o.getState(), k = {
3610
+ path: p.path,
3611
+ params: y.params,
3612
+ query: p.query
3613
+ }, f = t.find((x) => Q([x], k.path).route !== null);
3614
+ if (f?.beforeEnter)
2752
3615
  try {
2753
- const _ = await h.beforeEnter(b, f);
2754
- if (typeof _ == "string") {
2755
- await d(_);
3616
+ const x = await f.beforeEnter(k, C);
3617
+ if (typeof x == "string") {
3618
+ await b(x);
2756
3619
  return;
2757
3620
  }
2758
- if (_ === !1) return;
3621
+ if (x === !1) return;
2759
3622
  } catch {
2760
3623
  return;
2761
3624
  }
2762
- if (h?.onEnter)
3625
+ if (f?.onEnter)
2763
3626
  try {
2764
- const _ = await h.onEnter(b, f);
2765
- if (typeof _ == "string") {
2766
- await d(_);
3627
+ const x = await f.onEnter(k, C);
3628
+ if (typeof x == "string") {
3629
+ await b(x);
2767
3630
  return;
2768
3631
  }
2769
- if (_ === !1) return;
3632
+ if (x === !1) return;
2770
3633
  } catch {
2771
3634
  return;
2772
3635
  }
2773
- if (o.setState(b), h?.afterEnter)
3636
+ if (o.setState(k), f?.afterEnter)
2774
3637
  try {
2775
- h.afterEnter(b, f);
3638
+ f.afterEnter(k, C);
2776
3639
  } catch {
2777
3640
  }
2778
3641
  } catch {
2779
3642
  }
2780
3643
  };
2781
- c = async (g) => d(g), u = async (g) => d(g), m = () => {
3644
+ u = async (c) => b(c), m = async (c) => b(c), g = () => {
2782
3645
  };
2783
3646
  }
2784
3647
  return {
2785
3648
  store: o,
2786
- push: c,
2787
- replace: u,
2788
- back: m,
3649
+ push: u,
3650
+ replace: m,
3651
+ back: g,
2789
3652
  subscribe: o.subscribe,
2790
- matchRoute: (v) => V(t, v),
3653
+ matchRoute: (v) => Q(t, v),
2791
3654
  getCurrent: () => o.getState(),
2792
- resolveRouteComponent: jt
3655
+ resolveRouteComponent: ir
2793
3656
  };
2794
3657
  }
2795
- function Zt(e, t) {
2796
- return V(e, t);
2797
- }
2798
- function Yt(e) {
2799
- const t = Lt(e);
2800
- return Ie("router-view", {
2801
- async render() {
2802
- if (!t) return ee`<div>Router not initialized.</div>`;
2803
- const r = t.getCurrent(), { path: i } = r, n = t.matchRoute(i);
2804
- if (!n.route) return ee`<div>Not found</div>`;
2805
- try {
2806
- const s = await t.resolveRouteComponent(n.route);
2807
- if (typeof s == "string")
2808
- return { tag: s, props: {}, children: [] };
2809
- if (typeof s == "function") {
2810
- const o = s(), a = o instanceof Promise ? await o : o;
2811
- return typeof a == "string" ? { tag: a, props: {}, children: [] } : a;
2812
- }
2813
- return ee`<div>Invalid route component</div>`;
2814
- } catch {
2815
- return ee`<div>Invalid route component</div>`;
2816
- }
2817
- },
2818
- onConnected(r) {
3658
+ function Pr(e, t) {
3659
+ return Q(e, t);
3660
+ }
3661
+ function Lr(e) {
3662
+ const t = sr(e);
3663
+ return Ye("router-view", (r = {}, n = {}) => {
3664
+ const { onConnected: i } = n;
3665
+ if (i && i(() => {
2819
3666
  t && typeof t.subscribe == "function" && t.subscribe(() => {
2820
- typeof r.requestRender == "function" && r.requestRender();
2821
3667
  });
2822
- }
2823
- }), Ie("router-link", {
2824
- state: {},
2825
- props: {
2826
- to: { type: String, default: "" },
2827
- tag: { type: String, default: "a" },
2828
- replace: { type: Boolean, default: !1 },
2829
- exact: { type: Boolean, default: !1 },
2830
- activeClass: { type: String, default: "active" },
2831
- exactActiveClass: { type: String, default: "exact-active" },
2832
- ariaCurrentValue: { type: String, default: "page" },
2833
- disabled: { type: Boolean, default: !1 },
2834
- external: { type: Boolean, default: !1 },
2835
- class: { type: String, default: "" },
2836
- style: { type: String, default: Ue`
2837
- [aria-disabled="true"] {
2838
- pointer-events: none;
2839
- opacity: 0.5;
2840
- }
2841
- ` }
2842
- },
2843
- style: (r) => r.style,
2844
- render: (r) => {
2845
- const i = t.getCurrent(), n = r.to, s = r.exact, o = r.exactActiveClass, a = r.activeClass, c = r.ariaCurrentValue, u = r.tag, m = r.disabled, T = r.external, p = i.path === n, l = s ? p : i && typeof i.path == "string" ? i.path.startsWith(n) : !1, w = p ? `aria-current="${c}"` : "", v = (r.class || "").split(/\s+/).filter(Boolean), d = {};
2846
- for (const b of v) d[b] = !0;
2847
- const g = {
2848
- ...d,
2849
- // Also include the configurable names (may duplicate the above)
2850
- [a]: l,
2851
- [o]: p
2852
- }, y = u === "button", x = m ? y ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", f = T && (u === "a" || !u) ? 'target="_blank" rel="noopener noreferrer"' : "";
2853
- return ee`
2854
- ${Ke().when(y, ee`
2855
- <button
2856
- part="button"
2857
- :class="${g}"
2858
- ${w}
2859
- ${x}
2860
- ${f}
2861
- @click="navigate"
2862
- ><slot></slot></button>
2863
- `).otherwise(ee`
2864
- <a
2865
- part="link"
2866
- href="${n}"
2867
- :class="${g}"
2868
- ${w}
2869
- ${x}
2870
- ${f}
2871
- @click="navigate"
2872
- ><slot></slot></a>
2873
- `).done()}
2874
- `;
2875
- },
2876
- navigate: (r, i) => {
2877
- if (i.disabled) {
2878
- r.preventDefault();
3668
+ }), !t) return ae`<div>Router not initialized.</div>`;
3669
+ const s = t.getCurrent(), { path: o } = s, a = t.matchRoute(o);
3670
+ return a.route ? t.resolveRouteComponent(a.route).then((u) => {
3671
+ if (typeof u == "string")
3672
+ return { tag: u, props: {}, children: [] };
3673
+ if (typeof u == "function") {
3674
+ const m = u();
3675
+ return (m instanceof Promise ? m : Promise.resolve(m)).then((w) => typeof w == "string" ? { tag: w, props: {}, children: [] } : w);
3676
+ }
3677
+ return ae`<div>Invalid route component</div>`;
3678
+ }).catch(() => ae`<div>Invalid route component</div>`) : ae`<div>Not found</div>`;
3679
+ }), Ye("router-link", (r = {}, n = {}) => {
3680
+ const {
3681
+ to: i = "",
3682
+ tag: s = "a",
3683
+ replace: o = !1,
3684
+ exact: a = !1,
3685
+ activeClass: u = "active",
3686
+ exactActiveClass: m = "exact-active",
3687
+ ariaCurrentValue: g = "page",
3688
+ disabled: w = !1,
3689
+ external: h = !1,
3690
+ class: l = ""
3691
+ } = r, d = t.getCurrent(), v = d.path === i, b = a ? v : d && typeof d.path == "string" ? d.path.startsWith(i) : !1, c = v ? `aria-current="${g}"` : "", p = (l || "").split(/\s+/).filter(Boolean), y = {};
3692
+ for (const _ of p) y[_] = !0;
3693
+ const C = {
3694
+ ...y,
3695
+ // Also include the configurable names (may duplicate the above)
3696
+ [u]: b,
3697
+ [m]: v
3698
+ }, k = s === "button", f = w ? k ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", x = h && (s === "a" || !s) ? 'target="_blank" rel="noopener noreferrer"' : "", A = (_) => {
3699
+ if (w) {
3700
+ _.preventDefault();
2879
3701
  return;
2880
3702
  }
2881
- i.external && (i.tag === "a" || !i.tag) || (r.preventDefault(), i.replace ? t.replace(i.to) : t.push(i.to));
2882
- }
3703
+ h && (s === "a" || !s) || (_.preventDefault(), o ? t.replace(i) : t.push(i));
3704
+ };
3705
+ return ae`
3706
+ ${tr().when(k, ae`
3707
+ <button
3708
+ part="button"
3709
+ :class="${C}"
3710
+ ${c}
3711
+ ${f}
3712
+ ${x}
3713
+ @click="${A}"
3714
+ ><slot></slot></button>
3715
+ `).otherwise(ae`
3716
+ <a
3717
+ part="link"
3718
+ href="${i}"
3719
+ :class="${C}"
3720
+ ${c}
3721
+ ${f}
3722
+ ${x}
3723
+ @click="${A}"
3724
+ ><slot></slot></a>
3725
+ `).done()}
3726
+ `;
2883
3727
  }), t;
2884
3728
  }
2885
3729
  export {
2886
- ne as GlobalEventBus,
2887
- O as anchorBlock,
2888
- Ie as component,
2889
- Le as createStore,
2890
- Ue as css,
2891
- Ot as each,
2892
- qt as eachGroup,
2893
- zt as eachPage,
2894
- Wt as eachWhere,
2895
- Ft as emit,
2896
- le as eventBus,
2897
- ee as html,
2898
- Yt as initRouter,
2899
- Gt as listen,
2900
- Ke as match,
2901
- V as matchRoute,
2902
- Zt as matchRouteSSR,
2903
- G as mediaVariants,
2904
- Jt as off,
2905
- Kt as on,
2906
- Vt as once,
2907
- qe as parseQuery,
2908
- ke as renderToString,
2909
- jt as resolveRouteComponent,
2910
- Ve as responsive,
2911
- ze as responsiveOrder,
2912
- Dt as responsiveSwitch,
2913
- Ut as switchOn,
2914
- It as switchOnLength,
2915
- Ht as switchOnPromise,
2916
- Pt as unless,
2917
- Lt as useRouter,
2918
- we as when,
2919
- Mt as whenEmpty,
3730
+ ue as GlobalEventBus,
3731
+ M as anchorBlock,
3732
+ Ye as component,
3733
+ ar as computed,
3734
+ Qe as createStore,
3735
+ Tt as css,
3736
+ gr as each,
3737
+ xr as eachGroup,
3738
+ kr as eachPage,
3739
+ wr as eachWhere,
3740
+ $r as emit,
3741
+ me as eventBus,
3742
+ ae as html,
3743
+ Lr as initRouter,
3744
+ Or as listen,
3745
+ tr as match,
3746
+ Q as matchRoute,
3747
+ Pr as matchRouteSSR,
3748
+ ee as mediaVariants,
3749
+ Rr as off,
3750
+ Ar as on,
3751
+ Tr as once,
3752
+ et as parseQuery,
3753
+ or as ref,
3754
+ Te as renderToString,
3755
+ ir as resolveRouteComponent,
3756
+ nr as responsive,
3757
+ at as responsiveOrder,
3758
+ Er as responsiveSwitch,
3759
+ Sr as switchOn,
3760
+ vr as switchOnLength,
3761
+ Cr as switchOnPromise,
3762
+ mr as unless,
3763
+ lr as useEmit,
3764
+ dr as useOnAttributeChanged,
3765
+ ur as useOnConnected,
3766
+ fr as useOnDisconnected,
3767
+ pr as useOnError,
3768
+ sr as useRouter,
3769
+ hr as useStyle,
3770
+ cr as watch,
3771
+ Ae as when,
3772
+ yr as whenEmpty,
2920
3773
  q as whenMedia,
2921
- Bt as whenNotEmpty,
2922
- Nt as whenVariants
3774
+ br as whenNotEmpty,
3775
+ _r as whenVariants
2923
3776
  };
2924
3777
  //# sourceMappingURL=custom-elements-runtime.es.js.map