@jasonshimmy/custom-elements-runtime 0.3.0 → 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,438 +1,1070 @@
1
- function vt(e, t) {
2
- return pe(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 kt(e, t) {
5
- return e.map((r, i) => {
6
- const n = typeof r == "object" ? r?.key ?? r?.id ?? `idx-${i}` : String(r);
7
- return pe(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 ze() {
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 He(...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 He(...e) {
25
- for (let t = 0; t < e.length; t++) {
26
- const [r, i] = e[t];
27
- if (r) return [pe(i, `whenChain-branch-${t}`)];
53
+ return this.cache.set(t, o), o;
54
+ }
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);
82
+ }
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
+ };
28
119
  }
29
- return [pe([], "whenChain-empty")];
30
- }
31
- function pe(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
120
  }
39
- class X extends EventTarget {
40
- handlers = {};
41
- static instance;
42
- 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();
43
127
  /**
44
- * Returns the singleton instance of GlobalEventBus
128
+ * Create an optimized reactive proxy with minimal overhead
45
129
  */
46
- static getInstance() {
47
- return X.instance || (X.instance = new X()), X.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);
48
143
  }
49
144
  /**
50
- * Emit a global event with optional data. Includes event storm protection.
51
- * @param eventName - Name of the event
52
- * @param data - Optional event payload
145
+ * Mark an object as a proxy (for optimization)
53
146
  */
54
- emit(t, r) {
55
- const i = Date.now(), n = this.eventCounters.get(t);
56
- if (!n || i - n.window > 1e3)
57
- this.eventCounters.set(t, { count: 1, window: i });
58
- else if (n.count++, n.count > 50 && n.count > 100)
59
- return;
60
- this.dispatchEvent(new CustomEvent(t, {
61
- detail: r,
62
- bubbles: !1,
63
- // Global events don't need to bubble
64
- cancelable: !0
65
- }));
66
- const o = this.handlers[t];
67
- o && o.forEach((s) => {
147
+ static markAsProxy(t) {
148
+ if (t)
68
149
  try {
69
- s(r);
70
- } catch (a) {
71
- console.error(`Error in global event handler for "${t}":`, a);
150
+ Ue.add(t);
151
+ } catch {
72
152
  }
73
- });
74
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();
75
165
  /**
76
- * Register a handler for a global event. Returns an unsubscribe function.
77
- * @param eventName - Name of the event
78
- * @param handler - Handler function
166
+ * Set the current component being rendered for dependency tracking
79
167
  */
80
- on(t, r) {
81
- 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);
82
170
  }
83
171
  /**
84
- * Remove a specific handler for a global event.
85
- * @param eventName - Name of the event
86
- * @param handler - Handler function to remove
172
+ * Clear the current component after rendering
87
173
  */
88
- off(t, r) {
89
- const i = this.handlers[t];
90
- i && i.delete(r);
174
+ clearCurrentComponent() {
175
+ this.currentComponent = null;
91
176
  }
92
177
  /**
93
- * Remove all handlers for a specific event.
94
- * @param eventName - Name of the event
178
+ * Temporarily disable dependency tracking
95
179
  */
96
- offAll(t) {
97
- delete this.handlers[t];
180
+ disableTracking() {
181
+ this.trackingDisabled = !0;
98
182
  }
99
183
  /**
100
- * Listen for a native CustomEvent. Returns an unsubscribe function.
101
- * @param eventName - Name of the event
102
- * @param handler - CustomEvent handler
103
- * @param options - AddEventListener options
184
+ * Re-enable dependency tracking
104
185
  */
105
- listen(t, r, i) {
106
- return this.addEventListener(t, r, i), () => this.removeEventListener(t, r);
186
+ enableTracking() {
187
+ this.trackingDisabled = !1;
107
188
  }
108
189
  /**
109
- * Register a one-time event handler. Returns a promise that resolves with the event data.
110
- * @param eventName - Name of the event
111
- * @param handler - Handler function
190
+ * Check if a component is currently rendering
112
191
  */
113
- once(t, r) {
114
- return new Promise((i) => {
115
- const n = this.on(t, (o) => {
116
- n(), r(o), i(o);
117
- });
118
- });
192
+ isRenderingComponent() {
193
+ return this.currentComponent !== null;
119
194
  }
120
195
  /**
121
- * 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.
122
198
  */
123
- getActiveEvents() {
124
- return Object.keys(this.handlers).filter(
125
- (t) => this.handlers[t] && this.handlers[t].size > 0
126
- );
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);
127
203
  }
128
204
  /**
129
- * Clear all event handlers (useful for testing or cleanup).
205
+ * Execute a function with tracking disabled
130
206
  */
131
- clear() {
132
- 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
+ }
133
215
  }
134
216
  /**
135
- * Get the number of handlers registered for a specific event.
136
- * @param eventName - Name of the event
217
+ * Get or create a state instance for the current component
137
218
  */
138
- getHandlerCount(t) {
139
- 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;
140
227
  }
141
228
  /**
142
- * Get event statistics for debugging.
229
+ * Track a dependency for the current component
143
230
  */
144
- getEventStats() {
145
- const t = {};
146
- for (const [r, i] of this.eventCounters.entries())
147
- t[r] = {
148
- count: i.count,
149
- handlersCount: this.getHandlerCount(r)
150
- };
151
- return t;
231
+ trackDependency(t) {
232
+ this.trackingDisabled || this.currentComponent && (this.componentDependencies.get(this.currentComponent)?.add(t), t.addDependent(this.currentComponent));
152
233
  }
153
234
  /**
154
- * Reset event counters (useful for testing or after resolving issues).
235
+ * Trigger updates for all components that depend on a state
155
236
  */
156
- resetEventCounters() {
157
- this.eventCounters.clear();
158
- }
159
- }
160
- const ie = X.getInstance(), _t = (e, t) => ie.emit(e, t), $t = (e, t) => ie.on(e, t), St = (e, t) => ie.off(e, t), Et = (e, t) => ie.once(e, t), Ct = (e, t, r) => ie.listen(e, t, r);
161
- function $e(e) {
162
- let t = { ...e };
163
- const r = [];
164
- function i(a) {
165
- 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
+ });
166
242
  }
167
- function n() {
168
- 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
+ );
169
287
  }
170
- function o(a) {
171
- const f = typeof a == "function" ? a(t) : a;
172
- t = { ...t, ...f }, s();
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;
173
340
  }
174
- function s() {
175
- 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;
176
347
  }
177
- return { subscribe: i, getState: n, setState: o };
178
- }
179
- function Y(e) {
180
- return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
181
- }
182
- function J(e) {
183
- return typeof e == "string" ? e.replace(
184
- /[&<>"']/g,
185
- (t) => ({
186
- "&": "&amp;",
187
- "<": "&lt;",
188
- ">": "&gt;",
189
- '"': "&quot;",
190
- "'": "&#39;"
191
- })[t]
192
- ) : e;
193
- }
194
- function W(e, t) {
195
- return typeof t == "string" ? t.split(".").reduce((r, i) => r?.[i], e) : t;
196
- }
197
- function ce(e, t, r) {
198
- const i = String(t).split("."), n = i.pop();
199
- if (!n) return;
200
- const o = i.reduce((s, a) => (s[a] == null && (s[a] = {}), s[a]), e);
201
- o[n] = r;
202
- }
203
- function qe(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) {
204
364
  if (r)
205
- for (const [i, n] of Object.entries(r)) {
206
- let o, s = {};
207
- if (Array.isArray(n) ? (o = n[0], s = n[1] || {}) : o = n, t.set(i, {
208
- callback: o,
209
- options: s,
210
- oldValue: W(e, i)
211
- }), s.immediate)
365
+ for (const [n, i] of Object.entries(r)) {
366
+ let s, o = {};
367
+ if (Array.isArray(i) ? (s = i[0], o = i[1] || {}) : s = i, t.set(n, {
368
+ callback: s,
369
+ options: o,
370
+ oldValue: H(e, n)
371
+ }), o.immediate)
212
372
  try {
213
- const a = W(e, i);
214
- o(a, void 0, e);
373
+ const a = H(e, n);
374
+ s(a, void 0, e);
215
375
  } catch (a) {
216
- console.error(`Error in immediate watcher for "${i}":`, a);
376
+ ie(`Error in immediate watcher for "${n}":`, a);
217
377
  }
218
378
  }
219
379
  }
220
- function Ie(e, t, r, i) {
221
- const n = (s, a) => {
222
- if (s === a) return !0;
223
- if (typeof s != typeof a || typeof s != "object" || s === null || a === null) return !1;
224
- if (Array.isArray(s) && Array.isArray(a))
225
- return s.length !== a.length ? !1 : s.every((h, C) => n(h, a[C]));
226
- const f = Object.keys(s), p = Object.keys(a);
227
- return f.length !== p.length ? !1 : f.every((h) => n(s[h], a[h]));
228
- }, o = t.get(r);
229
- if (o && !n(i, o.oldValue))
380
+ function gt(e, t, r, n) {
381
+ const i = (o, a) => {
382
+ if (o === a) return !0;
383
+ if (typeof o != typeof a || typeof o != "object" || o === null || a === null) return !1;
384
+ if (Array.isArray(o) && Array.isArray(a))
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]));
388
+ }, s = t.get(r);
389
+ if (s && !i(n, s.oldValue))
230
390
  try {
231
- o.callback(i, o.oldValue, e), o.oldValue = i;
232
- } catch (s) {
233
- console.error(`Error in watcher for "${r}":`, s);
391
+ s.callback(n, s.oldValue, e), s.oldValue = n;
392
+ } catch (o) {
393
+ ie(`Error in watcher for "${r}":`, o);
234
394
  }
235
- for (const [s, a] of t.entries())
236
- if (a.options.deep && r.startsWith(s + "."))
395
+ for (const [o, a] of t.entries())
396
+ if (a.options.deep && r.startsWith(o + "."))
237
397
  try {
238
- const f = W(e, s);
239
- n(f, a.oldValue) || (a.callback(f, a.oldValue, e), a.oldValue = f);
240
- } catch (f) {
241
- console.error(`Error in deep watcher for "${s}":`, f);
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);
242
402
  }
243
403
  }
244
- function Ne(e, t, r) {
245
- if (!t.props) return;
246
- function i(n, o) {
247
- return o === Boolean ? n === "true" : o === Number ? Number(n) : n;
248
- }
249
- Object.entries(t.props).forEach(([n, o]) => {
250
- if (o.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")
251
411
  r[n] = e[n];
252
- else {
253
- const s = Y(n), a = e.getAttribute(s);
254
- 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)
255
506
  try {
256
- r[n] = J(i(e[n], o.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);
257
512
  } catch {
258
- r[n] = e[n];
513
+ s[o] = void 0;
259
514
  }
260
- else a !== null ? r[n] = J(i(a, o.type)) : "default" in o && o.default !== void 0 && (r[n] = J(o.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 });
261
525
  }
262
- });
263
- }
264
- function We(e, t, r, i) {
265
- e.onConnected && !r && (e.onConnected(t), i(!0));
266
- }
267
- function De(e, t, r, i, n, o, s, a) {
268
- e.onDisconnected && e.onDisconnected(t), r.forEach((f) => f()), i(), n(), o(!1), s(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
+ }
269
745
  }
270
- function Ue(e, t, r, i, n) {
271
- 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
+ }
272
819
  }
273
- function V(e, t) {
820
+ function ce(e, t) {
274
821
  if (t && e instanceof HTMLElement) {
822
+ se.cleanup(e);
275
823
  for (const r in t)
276
824
  t[r] === e && delete t[r];
277
825
  for (const r of Array.from(e.childNodes))
278
- V(r, t);
279
- }
280
- }
281
- function Fe(e, t, r, i, n, o, s, a) {
282
- if (!o) return;
283
- const f = t.includes("lazy"), p = t.includes("trim"), h = t.includes("number"), C = () => W(o._state || o, e), u = C();
284
- let c = "text";
285
- s instanceof HTMLInputElement ? c = i?.type || s.type || "text" : s instanceof HTMLSelectElement ? c = "select" : s instanceof HTMLTextAreaElement && (c = "textarea");
286
- const w = s instanceof HTMLInputElement || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement, d = w ? c === "checkbox" || c === "radio" ? "checked" : "value" : a ?? "modelValue";
287
- if (c === "checkbox")
288
- if (Array.isArray(u))
289
- r[d] = u.includes(String(s?.getAttribute("value") ?? i?.value ?? ""));
826
+ ce(r, t);
827
+ }
828
+ }
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) {
835
+ if (!s) return;
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 ?? ""));
290
849
  else {
291
- const x = s?.getAttribute("true-value") ?? !0;
292
- r[d] = u === x;
293
- }
294
- else if (c === "radio")
295
- r[d] = u === (i?.value ?? "");
296
- else if (c === "select")
297
- if (s && s.hasAttribute("multiple") && s instanceof HTMLSelectElement) {
298
- const x = Array.isArray(u) ? u.map(String) : [];
850
+ const C = o?.getAttribute("true-value") ?? !0;
851
+ r[c] = l === C;
852
+ }
853
+ else if (d === "radio")
854
+ r[c] = l === (n?.value ?? "");
855
+ else if (d === "select")
856
+ if (o && o.hasAttribute("multiple") && o instanceof HTMLSelectElement) {
857
+ const C = Array.isArray(l) ? l.map(String) : [];
299
858
  setTimeout(() => {
300
- Array.from(s.options).forEach((l) => {
301
- l.selected = x.includes(l.value);
859
+ Array.from(o.options).forEach((k) => {
860
+ k.selected = C.includes(k.value);
302
861
  });
303
- }, 0), r[d] = Array.isArray(u) ? u : [];
862
+ }, 0), r[c] = Array.isArray(l) ? l : [];
304
863
  } else
305
- r[d] = u;
864
+ r[c] = l;
306
865
  else {
307
- r[d] = u;
866
+ r[c] = l;
308
867
  try {
309
- const x = Y(d);
310
- i && (i[x] = u);
868
+ const C = te(c);
869
+ n && (n[C] = l);
311
870
  } catch {
312
871
  }
313
872
  }
314
- const g = f || c === "checkbox" || c === "radio" || c === "select" ? "change" : "input", m = (x) => {
315
- if (x.isComposing || n._isComposing || x.isTrusted === !1) return;
316
- const l = x.target;
317
- if (!l || l._modelUpdating) return;
318
- let b = l.value;
319
- if (c === "checkbox") {
320
- const S = C();
321
- if (Array.isArray(S)) {
322
- const A = l.getAttribute("value") ?? "", $ = Array.from(S);
323
- if (l.checked)
324
- $.includes(A) || $.push(A);
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);
325
886
  else {
326
- const T = $.indexOf(A);
327
- T > -1 && $.splice(T, 1);
887
+ const P = $.indexOf(T);
888
+ P > -1 && $.splice(P, 1);
328
889
  }
329
- b = $;
890
+ x = $;
330
891
  } else {
331
- const A = l.getAttribute("true-value") ?? !0, $ = l.getAttribute("false-value") ?? !1;
332
- b = l.checked ? A : $;
892
+ const T = f.getAttribute("true-value") ?? !0, $ = f.getAttribute("false-value") ?? !1;
893
+ x = f.checked ? T : $;
333
894
  }
334
- } else if (c === "radio")
335
- b = l.getAttribute("value") ?? l.value;
336
- else if (c === "select" && l.multiple)
337
- b = Array.from(l.selectedOptions).map((S) => S.value);
338
- else if (p && typeof b == "string" && (b = b.trim()), h) {
339
- const S = Number(b);
340
- isNaN(S) || (b = S);
341
- }
342
- const y = o._state || o, _ = W(y, e);
343
- if (Array.isArray(b) && Array.isArray(_) ? JSON.stringify([...b].sort()) !== JSON.stringify([..._].sort()) : b !== _) {
344
- l._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;
345
906
  try {
346
- ce(y, e, b), o._requestRender && o._requestRender();
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,
922
+ bubbles: !0,
923
+ composed: !0
924
+ });
925
+ f.dispatchEvent(T);
926
+ }
347
927
  } finally {
348
- setTimeout(() => l._modelUpdating = !1, 0);
928
+ setTimeout(() => f._modelUpdating = !1, 0);
349
929
  }
350
930
  }
351
931
  };
352
- w ? n[g] = m : n[`update:${Y(d)}`] = (x) => {
353
- const l = o._state || o, b = x.detail !== void 0 ? x.detail : x.target?.value, y = W(l, e);
354
- (Array.isArray(b) && Array.isArray(y) ? JSON.stringify([...b].sort()) !== JSON.stringify([...y].sort()) : b !== y) && (ce(l, e, b), o._requestRender && o._requestRender());
355
- }, (c === "text" || c === "textarea") && (n.compositionstart = (() => n._isComposing = !0), n.compositionend = (x) => {
356
- n._isComposing = !1;
357
- const l = x.target;
358
- l && setTimeout(() => {
359
- const b = l.value, y = o._state || o, _ = W(y, e);
360
- let E = b;
361
- if (p && (E = E.trim()), h) {
362
- const A = Number(E);
363
- isNaN(A) || (E = A);
932
+ if (v) {
933
+ if (i[p]) {
934
+ const C = i[p];
935
+ o && se.removeListener(o, p, C);
936
+ }
937
+ i[p] = y;
938
+ } else {
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;
949
+ if (S) {
950
+ S[c] = x;
951
+ try {
952
+ const R = te(c);
953
+ typeof x == "boolean" ? x ? S.setAttribute(R, "true") : S.setAttribute(R, "false") : S.setAttribute(R, String(x));
954
+ } catch {
955
+ }
956
+ queueMicrotask(() => {
957
+ typeof S._applyProps == "function" && S._applyProps(S._cfg), typeof S._requestRender == "function" && S._requestRender();
958
+ });
959
+ }
364
960
  }
365
- if (Array.isArray(E) && Array.isArray(_) ? JSON.stringify([...E].sort()) !== JSON.stringify([..._].sort()) : E !== _) {
366
- l._modelUpdating = !0;
961
+ };
962
+ }
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);
972
+ }
973
+ if (Array.isArray(_) && Array.isArray(A) ? JSON.stringify([..._].sort()) !== JSON.stringify([...A].sort()) : _ !== A) {
974
+ k._modelUpdating = !0;
367
975
  try {
368
- ce(y, e, E), o._requestRender && o._requestRender();
976
+ Ce(x, e, _), s._requestRender && s._requestRender(), s._triggerWatchers && s._triggerWatchers(e, _);
369
977
  } finally {
370
- setTimeout(() => l._modelUpdating = !1, 0);
978
+ setTimeout(() => k._modelUpdating = !1, 0);
371
979
  }
372
980
  }
373
981
  }, 0);
374
982
  });
375
983
  }
376
- function Me(e) {
984
+ function it(e) {
377
985
  const t = e.slice(2);
378
986
  return t ? t.charAt(0).toLowerCase() + t.slice(1) : "";
379
987
  }
380
- function Ke(e, t, r, i) {
381
- if (i) {
382
- if (typeof e == "object" && e !== null)
383
- for (const [n, o] of Object.entries(e))
384
- t[n] = o;
385
- else if (typeof e == "string")
386
- try {
387
- const n = JSON.parse(e);
388
- if (typeof n == "object" && n !== null) {
389
- for (const [o, s] of Object.entries(n))
390
- t[o] = s;
391
- return;
392
- }
393
- } catch {
394
- const n = W(i, e);
395
- r[e] = n;
988
+ function Ct(e, t, r, n) {
989
+ if (typeof e == "object" && e !== null)
990
+ for (const [i, s] of Object.entries(e))
991
+ i.startsWith("data-") || i.startsWith("aria-") || i === "class" ? r[i] = s : t[i] = s;
992
+ else if (typeof e == "string") {
993
+ if (!n) return;
994
+ try {
995
+ const i = he(e, n);
996
+ if (typeof i == "object" && i !== null) {
997
+ for (const [s, o] of Object.entries(i))
998
+ s.startsWith("data-") || s.startsWith("aria-") || s === "class" ? r[s] = o : t[s] = o;
999
+ return;
1000
+ } else {
1001
+ r[e] = i;
1002
+ return;
396
1003
  }
1004
+ } catch {
1005
+ const i = H(n, e);
1006
+ r[e] = i;
1007
+ }
397
1008
  }
398
1009
  }
399
- function Je(e, t, r) {
400
- if (!r) return;
401
- const i = W(r, e), n = t.style || "", o = i ? "" : "none";
1010
+ function _t(e, t, r) {
1011
+ let n;
1012
+ if (typeof e == "string") {
1013
+ if (!r) return;
1014
+ n = he(e, r);
1015
+ } else
1016
+ n = e;
1017
+ const i = t.style || "";
1018
+ let s = i;
402
1019
  if (n) {
403
- const s = n.split(";").filter(Boolean), a = s.findIndex(
404
- (f) => f.trim().startsWith("display:")
1020
+ if (i) {
1021
+ const o = i.split(";").map((u) => u.trim()).filter(Boolean), a = o.findIndex(
1022
+ (u) => u.startsWith("display:")
1023
+ );
1024
+ a >= 0 && o[a] === "display: none" && (o.splice(a, 1), s = o.length > 0 ? o.join("; ") + ";" : "");
1025
+ }
1026
+ } else if (i) {
1027
+ const o = i.split(";").filter(Boolean), a = o.findIndex(
1028
+ (u) => u.trim().startsWith("display:")
405
1029
  );
406
- a >= 0 ? s[a] = `display: ${o}` : s.push(`display: ${o}`), t.style = s.join("; ");
1030
+ a >= 0 ? o[a] = "display: none" : o.push("display: none"), s = o.join("; ");
407
1031
  } else
408
- t.style = `display: ${o}`;
1032
+ s = "display: none";
1033
+ s !== i && (s ? t.style = s : delete t.style);
409
1034
  }
410
- function Ge(e, t, r) {
411
- if (!r) return;
412
- const i = W(r, e);
413
- let n = [];
414
- typeof i == "string" ? n = [i] : Array.isArray(i) ? n = i.filter(Boolean) : typeof i == "object" && (n = Object.entries(i).filter(([, a]) => !!a).flatMap(([a]) => a.split(/\s+/).filter(Boolean)));
415
- const o = t.class || "", s = o ? `${o} ${n.join(" ")}`.trim() : n.join(" ");
416
- s && (t.class = s);
1035
+ function he(e, t) {
1036
+ return xt.evaluate(e, t);
417
1037
  }
418
- function Ze(e, t, r) {
419
- let i;
1038
+ function Et(e, t, r) {
1039
+ let n;
420
1040
  if (typeof e == "string") {
421
1041
  if (!r) return;
422
- i = W(r, e);
1042
+ n = he(e, r);
423
1043
  } else
424
- i = e;
425
- let n = "";
426
- if (typeof i == "string")
427
- n = i;
428
- else if (i && typeof i == "object") {
429
- const s = [];
430
- for (const [a, f] of Object.entries(i))
431
- if (f != null && f !== "") {
432
- const p = a.replace(
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(" ");
1048
+ o && (t.class = o);
1049
+ }
1050
+ function St(e, t, r) {
1051
+ let n;
1052
+ if (typeof e == "string") {
1053
+ if (!r) return;
1054
+ n = he(e, r);
1055
+ } else
1056
+ n = e;
1057
+ let i = "";
1058
+ if (typeof n == "string")
1059
+ i = n;
1060
+ else if (n && typeof n == "object") {
1061
+ const o = [];
1062
+ for (const [a, u] of Object.entries(n))
1063
+ if (u != null && u !== "") {
1064
+ const m = a.replace(
433
1065
  /[A-Z]/g,
434
- (u) => `-${u.toLowerCase()}`
435
- ), h = [
1066
+ (h) => `-${h.toLowerCase()}`
1067
+ ), g = [
436
1068
  "width",
437
1069
  "height",
438
1070
  "top",
@@ -458,126 +1090,136 @@ function Ze(e, t, r) {
458
1090
  "min-height",
459
1091
  "max-height"
460
1092
  ];
461
- let C = String(f);
462
- typeof f == "number" && h.includes(p) && (C = `${f}px`), s.push(`${p}: ${C}`);
1093
+ let w = String(u);
1094
+ typeof u == "number" && g.includes(m) && (w = `${u}px`), o.push(`${m}: ${w}`);
463
1095
  }
464
- n = s.join("; ") + (s.length > 0 ? ";" : "");
1096
+ i = o.join("; ") + (o.length > 0 ? ";" : "");
465
1097
  }
466
- const o = t.style || "";
467
- t.style = o + (o && !o.endsWith(";") ? "; " : "") + n;
1098
+ const s = t.style || "";
1099
+ t.style = s + (s && !s.endsWith(";") ? "; " : "") + i;
1100
+ }
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;
468
1104
  }
469
- function Oe(e, t, r, i) {
470
- const n = {}, o = { ...i || {} }, s = {};
471
- for (const [a, f] of Object.entries(e)) {
472
- const { value: p, modifiers: h, arg: C } = f;
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;
473
1109
  if (a === "model" || a.startsWith("model:")) {
474
- const u = a.split(":"), c = u.length > 1 ? u[1] : C;
475
- Fe(
476
- typeof p == "string" ? p : String(p),
477
- h,
478
- n,
479
- o,
1110
+ const h = a.split(":"), l = h.length > 1 ? h[1] : w;
1111
+ kt(
1112
+ m,
1113
+ // Pass the original value (could be string or reactive state object)
1114
+ g,
1115
+ i,
480
1116
  s,
1117
+ o,
481
1118
  t,
482
1119
  r,
483
- c
1120
+ l
484
1121
  );
485
1122
  continue;
486
1123
  }
487
1124
  switch (a) {
488
1125
  case "bind":
489
- Ke(p, n, o, t);
1126
+ Ct(m, i, s, t);
490
1127
  break;
491
1128
  case "show":
492
- Je(p, o, t);
1129
+ _t(m, s, t);
493
1130
  break;
494
1131
  case "class":
495
- Ge(p, o, t);
1132
+ Et(m, s, t);
496
1133
  break;
497
1134
  case "style":
498
- Ze(p, o, t);
1135
+ St(m, s, t);
1136
+ break;
1137
+ case "ref":
1138
+ $t(m, i, t);
499
1139
  break;
500
1140
  }
501
1141
  }
502
- return { props: n, attrs: o, listeners: s };
1142
+ return { props: i, attrs: s, listeners: o };
503
1143
  }
504
- function _e(e, t) {
1144
+ function Ie(e, t) {
505
1145
  if (Array.isArray(e)) {
506
- const o = /* @__PURE__ */ new Set();
507
- return e.map((s) => {
508
- if (!s || typeof s != "object") return s;
509
- let a = s.props?.key ?? s.key;
1146
+ const s = /* @__PURE__ */ new Set();
1147
+ return e.map((o) => {
1148
+ if (!o || typeof o != "object") return o;
1149
+ let a = o.props?.key ?? o.key;
510
1150
  if (!a) {
511
- const C = s.tag || "node", c = [
1151
+ const w = o.tag || "node", l = [
512
1152
  // attrs (kebab-case)
513
- s.props?.attrs?.id,
514
- s.props?.attrs?.name,
515
- s.props?.attrs?.["data-key"],
1153
+ o.props?.attrs?.id,
1154
+ o.props?.attrs?.name,
1155
+ o.props?.attrs?.["data-key"],
516
1156
  // promoted JS props (camelCase or original)
517
- s.props?.props?.id,
518
- s.props?.props?.name,
519
- s.props?.props?.dataKey,
520
- s.props?.props?.["data-key"]
521
- ].find((w) => w != null) ?? "";
522
- a = c ? `${t}:${C}:${c}` : `${t}:${C}`;
1157
+ o.props?.props?.id,
1158
+ o.props?.props?.name,
1159
+ o.props?.props?.dataKey,
1160
+ o.props?.props?.["data-key"]
1161
+ ].find((d) => d != null) ?? "";
1162
+ a = l ? `${t}:${w}:${l}` : `${t}:${w}`;
523
1163
  }
524
- let f = a, p = 1;
525
- for (; o.has(f); )
526
- f = `${a}#${p++}`;
527
- o.add(f);
528
- let h = s.children;
529
- return Array.isArray(h) && (h = _e(h, f)), { ...s, key: f, children: h };
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 };
530
1170
  });
531
1171
  }
532
1172
  const r = e;
533
- let i = r.props?.key ?? r.key ?? t, n = r.children;
534
- return Array.isArray(n) && (n = _e(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 };
535
1175
  }
536
- function Se(e, t, r, i) {
537
- const n = r.directives ?? {}, o = Oe(
538
- n,
1176
+ function Fe(e, t, r, n) {
1177
+ const i = r.directives ?? {}, s = st(
539
1178
  i,
1179
+ n,
540
1180
  e,
541
1181
  r.attrs
542
- ), s = {
1182
+ ), o = {
543
1183
  ...t.props,
544
1184
  ...r.props,
545
- ...o.props
1185
+ ...s.props
546
1186
  }, a = {
547
1187
  ...t.attrs,
548
1188
  ...r.attrs,
549
- ...o.attrs
550
- }, f = t.props ?? {}, p = s, h = r?.isCustomElement ?? t?.isCustomElement ?? !1;
551
- let C = !1;
552
- for (const w in { ...f, ...p }) {
553
- const v = f[w], d = p[w];
554
- if (v !== d) {
555
- if (C = !0, w === "value" && (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement))
556
- e.value !== d && (e.value = d ?? "");
557
- else if (w === "checked" && e instanceof HTMLInputElement)
558
- e.checked = !!d;
559
- else if (w.startsWith("on") && typeof d == "function") {
560
- const g = Me(w);
561
- typeof v == "function" && e.removeEventListener(g, v), e.addEventListener(g, d);
562
- } else if (d == null || d === !1)
563
- e.removeAttribute(w);
564
- else if ((r?.isCustomElement ?? t?.isCustomElement ?? !1) || w in e)
1189
+ ...s.attrs
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)
565
1205
  try {
566
- e[w] = d;
1206
+ e[d] = b;
567
1207
  } catch {
568
1208
  }
569
- }
1209
+ else
1210
+ b === !1 && e.removeAttribute(d);
570
1211
  }
571
- for (const [w, v] of Object.entries(
572
- o.listeners || {}
1212
+ for (const [d, v] of Object.entries(
1213
+ s.listeners || {}
573
1214
  ))
574
- e.addEventListener(w, v);
575
- const u = t.attrs ?? {}, c = a;
576
- for (const w in { ...u, ...c }) {
577
- const v = u[w], d = c[w];
578
- if (v !== d)
579
- if (C = !0, d == null || d === !1) {
580
- 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") {
581
1223
  if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement)
582
1224
  try {
583
1225
  e.value = "";
@@ -594,57 +1236,69 @@ function Se(e, t, r, i) {
594
1236
  } catch {
595
1237
  }
596
1238
  }
597
- if (w === "checked" && e instanceof HTMLInputElement)
1239
+ if (d === "checked" && e instanceof HTMLInputElement)
598
1240
  try {
599
1241
  e.checked = !1;
600
1242
  } catch {
601
1243
  }
602
- if (w === "disabled")
1244
+ if (d === "disabled")
603
1245
  try {
604
1246
  e.disabled = !1;
605
1247
  } catch {
606
1248
  }
607
1249
  } else {
608
- if (w === "value") {
1250
+ if (d === "value") {
609
1251
  if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement) {
610
1252
  try {
611
- e.value = d ?? "";
1253
+ e.value = p ?? "";
612
1254
  } catch {
613
- e.setAttribute(w, String(d));
1255
+ e.setAttribute(d, String(p));
614
1256
  }
615
1257
  continue;
616
1258
  } else if (e instanceof HTMLSelectElement) {
617
1259
  try {
618
- e.value = d ?? "";
1260
+ e.value = p ?? "";
619
1261
  } catch {
620
1262
  }
621
1263
  continue;
622
1264
  } else if (e instanceof HTMLProgressElement) {
623
1265
  try {
624
- e.value = Number(d);
1266
+ e.value = Number(p);
625
1267
  } catch {
626
1268
  }
627
1269
  continue;
628
1270
  }
629
1271
  }
630
- if (w === "checked" && e instanceof HTMLInputElement) {
1272
+ if (d === "checked" && e instanceof HTMLInputElement) {
631
1273
  try {
632
- e.checked = !!d;
1274
+ e.checked = !!p;
633
1275
  } catch {
634
1276
  }
635
1277
  continue;
636
1278
  }
637
- if (!(e.namespaceURI === "http://www.w3.org/2000/svg") && w in e)
1279
+ if (d === "style") {
1280
+ e.setAttribute(d, String(p));
1281
+ continue;
1282
+ }
1283
+ const y = e.namespaceURI === "http://www.w3.org/2000/svg";
1284
+ if (g && !y && d.includes("-")) {
1285
+ const C = rt(d);
638
1286
  try {
639
- e[w] = d;
1287
+ e[C] = p;
640
1288
  } catch {
641
- e.setAttribute(w, String(d));
1289
+ e.setAttribute(d, String(p));
1290
+ }
1291
+ } else if (!y && d in e)
1292
+ try {
1293
+ e[d] = p;
1294
+ } catch {
1295
+ e.setAttribute(d, String(p));
642
1296
  }
643
1297
  else
644
- e.setAttribute(w, String(d));
1298
+ e.setAttribute(d, String(p));
645
1299
  }
646
1300
  }
647
- if (h && C)
1301
+ if (g && w)
648
1302
  try {
649
1303
  if (typeof e._applyProps == "function")
650
1304
  try {
@@ -655,320 +1309,336 @@ function Se(e, t, r, i) {
655
1309
  } catch {
656
1310
  }
657
1311
  }
658
- function D(e, t, r) {
1312
+ function X(e, t, r) {
659
1313
  if (typeof e == "string")
660
1314
  return document.createTextNode(e);
661
1315
  if (e.tag === "#text") {
662
- const u = document.createTextNode(
1316
+ const h = document.createTextNode(
663
1317
  typeof e.children == "string" ? e.children : ""
664
1318
  );
665
- return e.key != null && (u.key = e.key), u;
1319
+ return e.key != null && (h.key = e.key), h;
666
1320
  }
667
1321
  if (e.tag === "#anchor") {
668
- const u = e, c = Array.isArray(u.children) ? u.children : [], w = document.createTextNode(""), v = document.createTextNode("");
669
- u.key != null && (w.key = `${u.key}:start`, v.key = `${u.key}:end`), u._startNode = w, u._endNode = v;
670
- const d = document.createDocumentFragment();
671
- d.appendChild(w);
672
- for (const g of c) {
673
- const m = D(g, t);
674
- d.appendChild(m);
675
- }
676
- return d.appendChild(v), d;
677
- }
678
- const i = document.createElement(e.tag);
679
- e.key != null && (i.key = e.key);
680
- const { props: n = {}, attrs: o = {}, directives: s = {} } = e.props ?? {}, a = Oe(s, t, i, o), f = {
681
- ...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,
682
1336
  ...a.props
683
- }, p = {
684
- ...o,
1337
+ }, m = {
1338
+ ...s,
685
1339
  ...a.attrs
686
- }, h = i.namespaceURI === "http://www.w3.org/2000/svg";
687
- for (const u in p) {
688
- const c = p[u];
689
- if (!(typeof u != "string" || /\[object Object\]/.test(u))) {
690
- if (typeof c == "boolean")
691
- c && i.setAttribute(u, "");
692
- else if (c != null)
693
- if (!h && u === "value" && (i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement || i instanceof HTMLSelectElement || i instanceof HTMLProgressElement))
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))) {
1344
+ if (typeof l == "boolean")
1345
+ l && n.setAttribute(h, "");
1346
+ else if (l != null)
1347
+ if (!g && h === "value" && (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement || n instanceof HTMLProgressElement))
694
1348
  try {
695
- i instanceof HTMLProgressElement ? i.value = Number(c) : i.value = c ?? "";
1349
+ n instanceof HTMLProgressElement ? n.value = Number(l) : n.value = l ?? "";
696
1350
  } catch {
697
- i.setAttribute(u, String(c));
1351
+ n.setAttribute(h, String(l));
698
1352
  }
699
- else if (!h && u === "checked" && i instanceof HTMLInputElement)
1353
+ else if (!g && h === "checked" && n instanceof HTMLInputElement)
700
1354
  try {
701
- i.checked = !!c;
1355
+ n.checked = !!l;
702
1356
  } catch {
703
- i.setAttribute(u, String(c));
1357
+ n.setAttribute(h, String(l));
704
1358
  }
705
- else if (!h && u in i)
1359
+ else if (!g && h in n)
706
1360
  try {
707
- i[u] = c;
1361
+ n[h] = l;
708
1362
  } catch {
709
- i.setAttribute(u, String(c));
1363
+ n.setAttribute(h, String(l));
710
1364
  }
711
- else
712
- i.setAttribute(u, String(c));
713
- }
714
- }
715
- for (const u in f) {
716
- const c = f[u];
717
- if (!(typeof u != "string" || /\[object Object\]/.test(u)))
718
- if (u === "value" && (i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement || i instanceof HTMLSelectElement))
719
- i.value = c ?? "";
720
- else if (u === "checked" && i instanceof HTMLInputElement)
721
- i.checked = !!c;
722
- else if (u.startsWith("on") && typeof c == "function")
723
- i.addEventListener(Me(u), c);
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);
724
1387
  else {
725
- if (u.startsWith("on") && c === void 0)
1388
+ if (h.startsWith("on") && l === void 0)
726
1389
  continue;
727
- if (c == null || c === !1)
728
- i.removeAttribute(u);
729
- else if ((e.props?.isCustomElement ?? !1) || u in i)
1390
+ if (l == null || l === !1)
1391
+ n.removeAttribute(h);
1392
+ else if ((e.props?.isCustomElement ?? !1) || h in n)
730
1393
  try {
731
- i[u] = c;
1394
+ const v = typeof l == "object" && l !== null && typeof l.value < "u" ? l.value : l;
1395
+ n[h] = v;
732
1396
  } catch {
733
1397
  }
734
1398
  }
735
1399
  }
736
- for (const [u, c] of Object.entries(
1400
+ for (const [h, l] of Object.entries(
737
1401
  a.listeners || {}
738
1402
  ))
739
- i.addEventListener(u, c);
740
- const C = e.props?.ref ?? (e.props?.props && e.props.props.ref);
741
- typeof e != "string" && C && r && (r[C] = 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);
742
1412
  try {
743
- if (typeof i._applyProps == "function")
1413
+ if (typeof n._applyProps == "function")
744
1414
  try {
745
- i._applyProps(i._cfg);
1415
+ n._applyProps(n._cfg);
746
1416
  } catch {
747
1417
  }
748
- 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);
749
1419
  } catch {
750
1420
  }
751
1421
  if (Array.isArray(e.children))
752
- for (const u of e.children)
753
- i.appendChild(D(u, t, r));
754
- 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);
755
1425
  try {
756
- if (i instanceof HTMLSelectElement && p && p.hasOwnProperty("value"))
1426
+ if (n instanceof HTMLSelectElement && m && m.hasOwnProperty("value"))
757
1427
  try {
758
- i.value = p.value ?? "";
1428
+ n.value = m.value ?? "";
759
1429
  } catch {
760
1430
  }
761
1431
  } catch {
762
1432
  }
763
- return i;
1433
+ return n;
764
1434
  }
765
- function Ve(e, t, r, i, n) {
1435
+ function At(e, t, r, n, i) {
766
1436
  if (typeof r == "string") {
767
1437
  e.textContent !== r && (e.textContent = r);
768
1438
  return;
769
1439
  }
770
1440
  if (!Array.isArray(r)) return;
771
- const o = Array.from(e.childNodes), s = Array.isArray(t) ? t : [], a = /* @__PURE__ */ new Map();
772
- for (const c of s)
773
- c && c.key != null && a.set(c.key, c);
774
- const f = /* @__PURE__ */ new Map();
775
- for (const c of o) {
776
- const w = c.key;
777
- w != null && f.set(w, c);
778
- }
779
- const p = /* @__PURE__ */ new Set();
780
- let h = e.firstChild;
781
- function C(c, w) {
782
- let v = c;
783
- for (; v && (p.add(v), v !== w); )
1441
+ const s = Array.from(e.childNodes), o = Array.isArray(t) ? t : [], a = /* @__PURE__ */ new Map();
1442
+ for (const l of o)
1443
+ l && l.key != null && a.set(l.key, l);
1444
+ const u = /* @__PURE__ */ new Map();
1445
+ for (const l of s) {
1446
+ const d = l.key;
1447
+ d != null && u.set(d, l);
1448
+ }
1449
+ const m = /* @__PURE__ */ new Set();
1450
+ let g = e.firstChild;
1451
+ function w(l, d) {
1452
+ let v = l;
1453
+ for (; v && (m.add(v), v !== d); )
784
1454
  v = v.nextSibling;
785
1455
  }
786
- function u(c, w, v, d) {
787
- const g = [];
788
- let m = c.nextSibling;
789
- for (; m && m !== w; )
790
- g.push(m), m = m.nextSibling;
791
- const x = Array.isArray(v) ? v : [];
792
- if (d.some((b) => b && b.key != null) || x.some((b) => b && b.key != null)) {
793
- const b = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
794
- for (const S of x)
795
- S && S.key != null && b.set(S.key, S);
796
- for (const S of g) {
797
- const A = S.key;
798
- A != null && y.set(A, 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, _);
799
1469
  }
800
- const _ = /* @__PURE__ */ new Set();
801
- let E = c.nextSibling;
802
- for (const S of d) {
803
- let A;
804
- if (S.key != null && y.has(S.key)) {
805
- const $ = b.get(S.key);
806
- A = le(
807
- y.get(S.key),
808
- $,
809
- S,
810
- i
811
- ), _.add(A), A !== E && e.contains(A) && e.insertBefore(A, 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);
812
1482
  } else
813
- A = D(S, i), e.insertBefore(A, E), _.add(A);
814
- E = A.nextSibling;
1483
+ S = X(_, n), e.insertBefore(S, A), x.add(S);
1484
+ A = S.nextSibling;
815
1485
  }
816
- for (const S of g)
817
- !_.has(S) && e.contains(S) && e.removeChild(S);
1486
+ for (const _ of c)
1487
+ !x.has(_) && e.contains(_) && e.removeChild(_);
818
1488
  } else {
819
- const b = Math.min(
820
- x.length,
821
- d.length
1489
+ const k = Math.min(
1490
+ y.length,
1491
+ b.length
822
1492
  );
823
- for (let y = 0; y < b; y++) {
824
- const _ = x[y], E = d[y], S = le(g[y], _, E, i);
825
- S !== g[y] && (e.insertBefore(S, g[y]), e.removeChild(g[y]));
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]));
826
1496
  }
827
- for (let y = b; y < d.length; y++)
828
- e.insertBefore(D(d[y], i), w);
829
- for (let y = b; y < g.length; y++)
830
- e.removeChild(g[y]);
831
- }
832
- }
833
- for (const c of r) {
834
- let w;
835
- if (c.tag === "#anchor") {
836
- const v = c.key, d = `${v}:start`, g = `${v}:end`;
837
- let m = f.get(d), x = f.get(g);
838
- const l = Array.isArray(c.children) ? c.children : [];
839
- if (m || (m = document.createTextNode(""), m.key = d), x || (x = document.createTextNode(""), x.key = g), c._startNode = m, c._endNode = x, !e.contains(m) || !e.contains(x)) {
840
- e.insertBefore(m, h);
841
- for (const b of l)
842
- e.insertBefore(D(b, i), h);
843
- e.insertBefore(x, 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]);
1501
+ }
1502
+ }
1503
+ for (const l of r) {
1504
+ let d;
1505
+ if (l.tag === "#anchor") {
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);
844
1514
  } else
845
- u(
846
- m,
847
- x,
1515
+ h(
1516
+ p,
1517
+ y,
848
1518
  a.get(v)?.children,
849
- l
1519
+ C
850
1520
  );
851
- C(m, x), h = x.nextSibling;
1521
+ w(p, y), g = y.nextSibling;
852
1522
  continue;
853
1523
  }
854
- if (c.key != null && f.has(c.key)) {
855
- const v = a.get(c.key);
856
- w = le(
857
- f.get(c.key),
1524
+ if (l.key != null && u.has(l.key)) {
1525
+ const v = a.get(l.key);
1526
+ d = _e(
1527
+ u.get(l.key),
858
1528
  v,
859
- c,
860
- i,
861
- n
862
- ), p.add(w), w !== h && e.contains(w) && (h && !e.contains(h) && (h = null), e.insertBefore(w, h));
1529
+ l,
1530
+ n,
1531
+ i
1532
+ ), m.add(d), d !== g && e.contains(d) && (g && !e.contains(g) && (g = null), e.insertBefore(d, g));
863
1533
  } else
864
- w = D(c, i, n), h && !e.contains(h) && (h = null), e.insertBefore(w, h), p.add(w);
865
- h = 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;
866
1536
  }
867
- for (const c of o)
868
- !p.has(c) && e.contains(c) && (V(c, n), e.removeChild(c));
1537
+ for (const l of s)
1538
+ !m.has(l) && e.contains(l) && (ce(l, i), e.removeChild(l));
869
1539
  }
870
- function le(e, t, r, i, n) {
871
- if (t && typeof t != "string" && t.props?.ref && n && V(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;
872
1542
  if (typeof r == "string") {
873
1543
  if (e.nodeType === Node.TEXT_NODE)
874
1544
  return e.textContent !== r && (e.textContent = r), e;
875
1545
  {
876
- const s = document.createTextNode(r);
877
- return e.parentNode?.replaceChild(s, e), s;
1546
+ const o = document.createTextNode(r);
1547
+ return e.parentNode?.replaceChild(o, e), o;
878
1548
  }
879
1549
  }
880
1550
  if (r && typeof r != "string" && r.tag === "#anchor") {
881
- const s = r, a = Array.isArray(s.children) ? s.children : [], f = s._startNode ?? document.createTextNode(""), p = s._endNode ?? document.createTextNode("");
882
- s.key != null && (f.key = `${s.key}:start`, p.key = `${s.key}:end`), s._startNode = f, s._endNode = p;
883
- const h = document.createDocumentFragment();
884
- h.appendChild(f);
885
- for (const C of a) {
886
- const u = D(C, i);
887
- h.appendChild(u);
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);
888
1558
  }
889
- return h.appendChild(p), e.parentNode?.replaceChild(h, e), f;
1559
+ return g.appendChild(m), e.parentNode?.replaceChild(g, e), u;
890
1560
  }
891
1561
  if (!r) {
892
- V(e, n);
893
- const s = document.createComment("removed");
894
- return e.parentNode?.replaceChild(s, e), s;
1562
+ ce(e, i);
1563
+ const o = document.createComment("removed");
1564
+ return e.parentNode?.replaceChild(o, e), o;
895
1565
  }
896
1566
  if (!t || typeof t == "string") {
897
- V(e, n);
898
- const s = D(r, i, n);
899
- return typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
1567
+ ce(e, i);
1568
+ const o = X(r, n, i);
1569
+ return de(r, o, i), e.parentNode?.replaceChild(o, e), o;
900
1570
  }
901
1571
  if (r.tag === "#anchor") {
902
- const s = Array.isArray(r.children) ? r.children : [], a = r._startNode ?? document.createTextNode(""), f = r._endNode ?? document.createTextNode("");
903
- r.key != null && (a.key = `${r.key}:start`, f.key = `${r.key}:end`), r._startNode = a, r._endNode = f;
904
- const p = document.createDocumentFragment();
905
- p.appendChild(a);
906
- for (const h of s)
907
- p.appendChild(D(h, i));
908
- return p.appendChild(f), e.parentNode?.replaceChild(p, 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;
909
1579
  }
910
1580
  if (typeof t != "string" && typeof r != "string" && t.tag === r.tag && t.key === r.key) {
911
- const s = e;
912
- return Se(s, t.props || {}, r.props || {}, i), Ve(s, t.children, r.children, i, n), typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = s), s;
1581
+ const o = e;
1582
+ return Fe(o, t.props || {}, r.props || {}, n), At(o, t.children, r.children, n, i), de(r, o, i), o;
913
1583
  }
914
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))
915
1585
  try {
916
1586
  const a = e;
917
- return Se(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;
918
1588
  } catch {
919
1589
  }
920
- V(e, n);
921
- const o = D(r, i, n);
922
- return typeof r != "string" && r.props?.ref && n && (n[r.props.ref] = o), e.parentNode?.replaceChild(o, e), o;
1590
+ ce(e, i);
1591
+ const s = X(r, n, i);
1592
+ return de(r, s, i), e.parentNode?.replaceChild(s, e), s;
923
1593
  }
924
- function Ye(e, t, r, i) {
925
- let n;
926
- 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 = {
927
1597
  tag: "div",
928
1598
  key: "__anchor_root__",
929
1599
  props: { attrs: { "data-anchor-block-root": "", key: "__anchor_root__" } },
930
- children: [n]
931
- }), n = _e(n, String(n.key ?? "root"));
932
- const o = e._prevVNode ?? null, s = e._prevDom ?? e.firstChild ?? null;
1600
+ children: [i]
1601
+ }), i = Ie(i, String(i.key ?? "root"));
1602
+ const s = e._prevVNode ?? null, o = e._prevDom ?? e.firstChild ?? null;
933
1603
  let a;
934
- o && s ? typeof o != "string" && typeof n != "string" && o.tag === n.tag && o.key === n.key ? a = le(s, o, n, r, i) : (a = D(n, r, i), e.replaceChild(a, s)) : (a = D(n, r, i), e.firstChild ? e.replaceChild(a, e.firstChild) : e.appendChild(a));
935
- const f = [];
936
- for (let p = 0; p < e.childNodes.length; p++) {
937
- const h = e.childNodes[p];
938
- h !== a && h.nodeName !== "STYLE" && (V(h, i), f.push(h));
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));
939
1609
  }
940
- f.forEach((p) => e.removeChild(p)), e._prevVNode = n, e._prevDom = a;
1610
+ u.forEach((m) => e.removeChild(m)), e._prevVNode = i, e._prevDom = a;
941
1611
  }
942
- function ge(e) {
943
- if (typeof e == "string") return J(e);
1612
+ function Te(e) {
1613
+ if (typeof e == "string") return ne(e);
944
1614
  if (e.tag === "#text")
945
- return typeof e.children == "string" ? J(e.children) : "";
1615
+ return typeof e.children == "string" ? ne(e.children) : "";
946
1616
  if (e.tag === "#anchor")
947
- return (Array.isArray(e.children) ? e.children.filter(Boolean) : []).map(ge).join("");
1617
+ return (Array.isArray(e.children) ? e.children.filter(Boolean) : []).map(Te).join("");
948
1618
  let t = "";
949
- e.props && e.props.attrs && (t = Object.entries(e.props.attrs).map(([n, o]) => ` ${n}="${J(String(o))}"`).join(""));
1619
+ e.props && e.props.attrs && (t = Object.entries(e.props.attrs).map(([i, s]) => ` ${i}="${ne(String(s))}"`).join(""));
950
1620
  let r = "";
951
- e.props && (r = Object.entries(e.props).filter(([n]) => n !== "attrs" && n !== "directives" && n !== "ref" && n !== "key").map(([n, o]) => ` ${n}="${J(String(o))}"`).join(""));
952
- const i = Array.isArray(e.children) ? e.children.filter(Boolean).map(ge).join("") : typeof e.children == "string" ? J(e.children) : e.children ? ge(e.children) : "";
953
- 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}>`;
954
1624
  }
955
- function Pe(e, ...t) {
1625
+ function Tt(e, ...t) {
956
1626
  let r = "";
957
- for (let i = 0; i < e.length; i++)
958
- 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]);
959
1629
  return r;
960
1630
  }
961
- function Be(e) {
1631
+ function ot(e) {
962
1632
  return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
963
1633
  }
964
- let oe = null;
965
- function Ee() {
966
- return oe || (oe = new CSSStyleSheet(), oe.replaceSync(Be(Xe))), oe;
1634
+ let xe = null;
1635
+ function Ke() {
1636
+ return xe || (xe = new CSSStyleSheet(), xe.replaceSync(ot(Pt))), xe;
967
1637
  }
968
- function Qe(e) {
1638
+ function Ot(e) {
969
1639
  return e.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi, "").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, "").replace(/expression\s*\([^)]*\)/gi, "");
970
1640
  }
971
- const Xe = Pe`
1641
+ const Pt = Tt`
972
1642
  :host, *, ::before, ::after {
973
1643
  all: isolate;
974
1644
  box-sizing: border-box;
@@ -1026,7 +1696,7 @@ const Xe = Pe`
1026
1696
  sup { top: -.5em }
1027
1697
  [disabled], [aria-disabled=true] { cursor: not-allowed }
1028
1698
  [hidden] { display: none }
1029
- `, et = {
1699
+ `, Lt = {
1030
1700
  neutral: {
1031
1701
  50: "#fafafa",
1032
1702
  100: "#f4f4f5",
@@ -1122,17 +1792,17 @@ const Xe = Pe`
1122
1792
  black: { DEFAULT: "#000000" },
1123
1793
  transparent: { DEFAULT: "transparent" },
1124
1794
  current: { DEFAULT: "currentColor" }
1125
- }, tt = Object.fromEntries(
1126
- Object.entries(et).map(([e, t]) => [
1795
+ }, jt = Object.fromEntries(
1796
+ Object.entries(Lt).map(([e, t]) => [
1127
1797
  e,
1128
1798
  Object.fromEntries(
1129
- Object.entries(t).map(([r, i]) => [
1799
+ Object.entries(t).map(([r, n]) => [
1130
1800
  r,
1131
- `var(--color-${e}${r === "DEFAULT" ? "" : `-${r}`}, ${i})`
1801
+ `var(--color-${e}${r === "DEFAULT" ? "" : `-${r}`}, ${n})`
1132
1802
  ])
1133
1803
  )
1134
1804
  ])
1135
- ), me = {
1805
+ ), Oe = {
1136
1806
  /* Display */
1137
1807
  block: "display:block;",
1138
1808
  inline: "display:inline;",
@@ -1347,7 +2017,7 @@ const Xe = Pe`
1347
2017
  "z-30": "z-index:30;",
1348
2018
  "z-40": "z-index:40;",
1349
2019
  "z-50": "z-index:50;"
1350
- }, rt = "0.25rem", Ce = {
2020
+ }, Mt = "0.25rem", Ve = {
1351
2021
  m: ["margin"],
1352
2022
  mx: ["margin-inline"],
1353
2023
  my: ["margin-block"],
@@ -1379,34 +2049,34 @@ const Xe = Pe`
1379
2049
  "gap-x": ["column-gap"],
1380
2050
  "gap-y": ["row-gap"]
1381
2051
  };
1382
- function N(e, t) {
1383
- let r = 0, i = 0;
1384
- for (let n = 0; n < e.length; n++) {
1385
- const o = e[n];
1386
- if (o === "[") r++;
1387
- else if (o === "]" && r > 0) r--;
1388
- else if (o === "(") i++;
1389
- else if (o === ")" && i > 0) i--;
1390
- else if (r === 0 && i === 0 && (o === ">" || o === "+" || o === "~" || o === " "))
1391
- return e.slice(0, n) + t + e.slice(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];
2056
+ if (s === "[") r++;
2057
+ else if (s === "]" && r > 0) r--;
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);
1392
2062
  }
1393
2063
  return e + t;
1394
2064
  }
1395
- const nt = {
2065
+ const Nt = {
1396
2066
  before: (e, t) => `${e}::before{${t}}`,
1397
2067
  after: (e, t) => `${e}::after{${t}}`,
1398
- hover: (e, t) => `${N(e, ":hover")}{${t}}`,
1399
- focus: (e, t) => `${N(e, ":focus")}{${t}}`,
1400
- active: (e, t) => `${N(e, ":active")}{${t}}`,
1401
- disabled: (e, t) => `${N(e, ":disabled")}{${t}}`,
1402
- visited: (e, t) => `${N(e, ":visited")}{${t}}`,
1403
- checked: (e, t) => `${N(e, ":checked")}{${t}}`,
1404
- first: (e, t) => `${N(e, ":first-child")}{${t}}`,
1405
- last: (e, t) => `${N(e, ":last-child")}{${t}}`,
1406
- odd: (e, t) => `${N(e, ":nth-child(odd)")}{${t}}`,
1407
- even: (e, t) => `${N(e, ":nth-child(even)")}{${t}}`,
1408
- "focus-within": (e, t) => `${N(e, ":focus-within")}{${t}}`,
1409
- "focus-visible": (e, t) => `${N(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}}`,
1410
2080
  "group-hover": (e, t) => `.group:hover ${e}{${t}}`,
1411
2081
  "group-focus": (e, t) => `.group:focus ${e}{${t}}`,
1412
2082
  "group-active": (e, t) => `.group:active ${e}{${t}}`,
@@ -1415,7 +2085,7 @@ const nt = {
1415
2085
  "peer-focus": (e, t) => `.peer:focus ~ ${e}{${t}}`,
1416
2086
  "peer-checked": (e, t) => `.peer:checked ~ ${e}{${t}}`,
1417
2087
  "peer-disabled": (e, t) => `.peer:disabled ~ ${e}{${t}}`
1418
- }, ye = {
2088
+ }, Pe = {
1419
2089
  // Responsive
1420
2090
  sm: "(min-width:640px)",
1421
2091
  md: "(min-width:768px)",
@@ -1424,25 +2094,25 @@ const nt = {
1424
2094
  "2xl": "(min-width:1536px)",
1425
2095
  // Dark mode (now plain string)
1426
2096
  dark: "(prefers-color-scheme: dark)"
1427
- }, be = ["sm", "md", "lg", "xl", "2xl"];
1428
- function we(e) {
1429
- const t = e.startsWith("-"), i = (t ? e.slice(1) : e).split("-");
1430
- if (i.length < 2) return null;
1431
- const n = i.slice(0, -1).join("-"), o = i[i.length - 1], s = parseFloat(o);
1432
- if (Number.isNaN(s) || !Ce[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;
1433
2103
  const a = t ? "-" : "";
1434
- return Ce[n].map((f) => `${f}:calc(${a}${rt} * ${s});`).join("");
2104
+ return Ve[i].map((u) => `${u}:calc(${a}${Mt} * ${o});`).join("");
1435
2105
  }
1436
- function Ae(e) {
1437
- const t = e.replace("#", ""), r = parseInt(t, 16), i = r >> 16 & 255, n = r >> 8 & 255, o = r & 255;
1438
- return `${i} ${n} ${o}`;
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}`;
1439
2109
  }
1440
- function it(e) {
2110
+ function Wt(e) {
1441
2111
  const t = /^(bg|text|border|decoration|shadow|outline|caret|accent|fill|stroke)-([a-z]+)-?(\d{2,3}|DEFAULT)?$/.exec(e);
1442
2112
  if (!t) return null;
1443
- const [, r, i, n = "DEFAULT"] = t, o = tt[i]?.[n];
1444
- if (!o) return null;
1445
- if (r === "shadow") return `--ce-shadow-color:${o};`;
2113
+ const [, r, n, i = "DEFAULT"] = t, s = jt[n]?.[i];
2114
+ if (!s) return null;
2115
+ if (r === "shadow") return `--ce-shadow-color:${s};`;
1446
2116
  const a = {
1447
2117
  bg: "background-color",
1448
2118
  decoration: "text-decoration-color",
@@ -1454,58 +2124,58 @@ function it(e) {
1454
2124
  fill: "fill",
1455
2125
  stroke: "stroke"
1456
2126
  }[r];
1457
- return a ? `${a}:${o};` : null;
2127
+ return a ? `${a}:${s};` : null;
1458
2128
  }
1459
- function st(e) {
2129
+ function zt(e) {
1460
2130
  const [t, r] = e.split("/");
1461
2131
  if (!r) return { base: t };
1462
- const i = parseInt(r, 10);
1463
- 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 };
1464
2134
  }
1465
- function xe(e) {
1466
- const { base: t, opacity: r } = st(e), i = it(t);
1467
- if (i) {
2135
+ function Me(e) {
2136
+ const { base: t, opacity: r } = zt(e), n = Wt(t);
2137
+ if (n) {
1468
2138
  if (r !== void 0) {
1469
- const o = /#([0-9a-f]{6})/i.exec(i);
1470
- if (o) {
1471
- const s = Ae(o[0]);
1472
- return i.replace(/#([0-9a-f]{6})/i, `rgb(${s} / ${r})`);
2139
+ const s = /#([0-9a-f]{6})/i.exec(n);
2140
+ if (s) {
2141
+ const o = Je(s[0]);
2142
+ return n.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${r})`);
1473
2143
  }
1474
2144
  }
1475
- return i;
2145
+ return n;
1476
2146
  }
1477
- const n = fe(t);
1478
- if (n && r !== void 0) {
1479
- const o = /#([0-9a-f]{6})/i.exec(n);
1480
- if (o) {
1481
- const s = Ae(o[0]);
1482
- return n.replace(/#([0-9a-f]{6})/i, `rgb(${s} / ${r})`);
2147
+ const i = Ee(t);
2148
+ if (i && r !== void 0) {
2149
+ const s = /#([0-9a-f]{6})/i.exec(i);
2150
+ if (s) {
2151
+ const o = Je(s[0]);
2152
+ return i.replace(/#([0-9a-f]{6})/i, `rgb(${o} / ${r})`);
1483
2153
  }
1484
2154
  }
1485
- return n;
2155
+ return i;
1486
2156
  }
1487
- function ve(e) {
2157
+ function Ne(e) {
1488
2158
  const t = /^opacity-(\d{1,3})$/.exec(e);
1489
2159
  if (!t) return null;
1490
2160
  const r = parseInt(t[1], 10);
1491
2161
  return r < 0 || r > 100 ? null : `opacity:${r / 100};`;
1492
2162
  }
1493
- function fe(e) {
2163
+ function Ee(e) {
1494
2164
  if (e.startsWith("[") && e.endsWith("]") && !e.includes("-[")) {
1495
- const n = e.slice(1, -1).trim().match(/^([a-zA-Z][a-zA-Z0-9-]*)\s*:(.*)$/);
1496
- if (n) {
1497
- const o = n[1].trim();
1498
- let s = n[2].trim();
1499
- return s = s.replace(/url\('\s*([^']*?)\s*'\)/g, 'url("$1")'), s = s.replace(/^'([^']*)'$/g, '"$1"'), `${o}:${s};`;
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();
2169
+ return o = o.replace(/url\('\s*([^']*?)\s*'\)/g, 'url("$1")'), o = o.replace(/^'([^']*)'$/g, '"$1"'), `${s}:${o};`;
1500
2170
  }
1501
2171
  return null;
1502
2172
  }
1503
2173
  const t = e.indexOf("-["), r = e.endsWith("]");
1504
2174
  if (t > 0 && r) {
1505
- const i = e.slice(0, t);
1506
- let n = e.slice(t + 2, -1);
1507
- n = n.replace(/_/g, " ");
1508
- const o = {
2175
+ const n = e.slice(0, t);
2176
+ let i = e.slice(t + 2, -1);
2177
+ i = i.replace(/_/g, " ");
2178
+ const s = {
1509
2179
  bg: "background-color",
1510
2180
  text: "color",
1511
2181
  shadow: "box-shadow",
@@ -1547,14 +2217,14 @@ function fe(e) {
1547
2217
  leading: "line-height",
1548
2218
  z: "z-index"
1549
2219
  };
1550
- if (i === "rotate")
1551
- return `transform:rotate(${n});`;
1552
- const s = o[i] ?? i.replace(/_/g, "-");
1553
- if (s && n) return `${s}:${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};`;
1554
2224
  }
1555
2225
  return null;
1556
2226
  }
1557
- function ot(e) {
2227
+ function Dt(e) {
1558
2228
  if (e.startsWith("[") && e.endsWith("]")) {
1559
2229
  const r = e.slice(1, -1);
1560
2230
  return r.includes("&") ? r : e;
@@ -1566,44 +2236,44 @@ function ot(e) {
1566
2236
  }
1567
2237
  return null;
1568
2238
  }
1569
- function at(e) {
2239
+ function It(e) {
1570
2240
  return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1");
1571
2241
  }
1572
- function ct(e) {
2242
+ function Ht(e) {
1573
2243
  const t = /class\s*=\s*(['"])(.*?)\1/g, r = [];
1574
- let i;
1575
- for (; i = t.exec(e); ) {
1576
- const n = i[2].split(/\s+/).filter(Boolean);
1577
- 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);
1578
2248
  }
1579
2249
  return r.filter(Boolean);
1580
2250
  }
1581
- const Te = /* @__PURE__ */ new Map(), lt = 16;
1582
- function ft(e) {
1583
- const t = Date.now(), r = Te.get(e);
1584
- if (r && t - r.timestamp < lt) return r.css;
1585
- const i = ct(e), n = new Set(i), o = [], s = [], a = [], f = [], p = {};
1586
- function h(d, g = !1) {
1587
- const m = (g ? "dark|" : "") + d;
1588
- if (m in p) return p[m];
1589
- const x = w(d, g);
1590
- return p[m] = x, x;
1591
- }
1592
- function C(d) {
1593
- const g = d.some((x) => be.includes(x)), m = d.includes("dark");
1594
- return d.length === 0 ? 1 : !g && !m ? 2 : g && !m ? 3 : 4;
1595
- }
1596
- function u(d) {
1597
- const g = [];
1598
- let m = "", x = 0, l = 0;
1599
- for (let b = 0; b < d.length; b++) {
1600
- const y = d[b];
1601
- y === "[" ? x++ : y === "]" && x > 0 ? x-- : y === "(" ? l++ : y === ")" && l > 0 && l--, y === ":" && x === 0 && l === 0 ? (g.push(m), m = "") : m += y;
1602
- }
1603
- return m && g.push(m), g;
1604
- }
1605
- function c(d) {
1606
- 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) {
1607
2277
  case "hover":
1608
2278
  return ":hover";
1609
2279
  case "focus":
@@ -1632,210 +2302,234 @@ function ft(e) {
1632
2302
  return null;
1633
2303
  }
1634
2304
  }
1635
- function w(d, g = !1) {
1636
- const m = u(d);
1637
- let x = !1;
1638
- const l = m.find((k) => (k.startsWith("!") && (x = !0, k = k.slice(1)), me[k] || we(k) || ve(k) || xe(k) || fe(k)));
1639
- if (!l) return null;
1640
- const b = l.replace(/^!/, ""), y = me[b] ?? we(b) ?? ve(b) ?? xe(b) ?? fe(b);
1641
- if (!y) return null;
1642
- const _ = m.indexOf(l);
1643
- let E = _ >= 0 ? m.slice(0, _) : [];
1644
- g && (E = E.filter((k) => k !== "dark"));
1645
- const S = `.${at(d)}`, A = "__SUBJECT__", $ = x ? y.replace(/;$/, " !important;") : y;
1646
- let T = A;
1647
- const B = [];
1648
- for (const k of E)
1649
- k.startsWith("group-") ? (T = `.group:${k.slice(6)} ${T}`, B.push(k)) : k.startsWith("peer-") && (T = T.replace(A, `.peer:${k.slice(5)}~${A}`), B.push(k));
1650
- E = E.filter((k) => !B.includes(k));
1651
- const G = [], ee = [];
1652
- let M = null;
1653
- for (const k of E) {
1654
- if (k === "dark" || be.includes(k)) continue;
1655
- const P = ot(k);
1656
- if (P) {
1657
- M = P;
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);
2311
+ if (!f) return null;
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;
1658
2328
  continue;
1659
2329
  }
1660
- const R = c(k);
1661
- if (R) {
1662
- M ? ee.push(R) : G.push(R);
2330
+ const D = l(E);
2331
+ if (D) {
2332
+ J ? B.push(D) : P.push(D);
1663
2333
  continue;
1664
2334
  }
1665
- const O = nt[k];
1666
- typeof O == "function" && (T = O(T, $).split("{")[0]);
1667
- }
1668
- function U(k, P) {
1669
- if (!P) return k;
1670
- let R = 0, O = 0;
1671
- if (k.length && (k[0] === ">" || k[0] === "+" || k[0] === "~" || k[0] === " ")) {
1672
- let j = 1;
1673
- for (; j < k.length && k[j] === " "; ) j++;
1674
- for (; j < k.length; j++) {
1675
- const L = k[j];
1676
- if (L === "[" ? R++ : L === "]" && R > 0 ? R-- : L === "(" ? O++ : L === ")" && O > 0 && O--, R === 0 && O === 0 && (k[j] === ">" || k[j] === "+" || k[j] === "~" || k[j] === " "))
1677
- return k.slice(0, j) + P + 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);
1678
2348
  }
1679
- return k + P;
2349
+ return E + U;
1680
2350
  }
1681
- for (let j = 0; j < k.length; j++) {
1682
- const L = k[j];
1683
- if (L === "[" ? R++ : L === "]" && R > 0 ? R-- : L === "(" ? O++ : L === ")" && O > 0 && O--, R === 0 && O === 0 && (L === ">" || L === "+" || L === "~" || L === " "))
1684
- return k.slice(0, j) + P + 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);
1685
2355
  }
1686
- return k + P;
1687
- }
1688
- const q = G.join(""), I = ee.join("");
1689
- if (M)
1690
- if (M.includes("&")) {
1691
- const k = M.indexOf("&"), P = M.slice(0, k), R = M.slice(k + 1), O = A + q, j = T;
1692
- if (G.length === 0)
1693
- T = j.replace(A, P + O + I + 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);
1694
2364
  else {
1695
- const L = U(R, I);
1696
- T = j.replace(A, P + O + L);
2365
+ const I = ye(D, L);
2366
+ T = O.replace(S, U + z + I);
1697
2367
  }
1698
2368
  } else
1699
- T = T.replace(A, `${M}${A + q}`), I && (T = T.replace(A, `${A}${I}`));
2369
+ T = T.replace(S, `${J}${S + K}`), L && (T = T.replace(S, `${S}${L}`));
1700
2370
  else
1701
- T = A + q + I;
1702
- T = T.replace(new RegExp(A, "g"), S);
1703
- let z = `${T}{${$}}`;
1704
- const H = E.filter((k) => be.includes(k)), F = H.length ? H[H.length - 1] : null, te = E.includes("dark");
1705
- return g && F ? z = `@media (prefers-color-scheme: dark) and ${ye[F]}{${z}}` : g ? z = `@media (prefers-color-scheme: dark){${z}}` : te && F ? z = `@media (prefers-color-scheme: dark) and ${ye[F]}{${z}}` : te ? z = `@media (prefers-color-scheme: dark){${z}}` : F && (z = `@media ${ye[F]}{${z}}`), z;
1706
- }
1707
- for (const d of n) {
1708
- const g = u(d), m = g.find(
1709
- (y) => me[y] || we(y) || ve(y) || xe(y) || fe(y)
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)
1710
2380
  );
1711
- if (!m) continue;
1712
- const x = g.indexOf(m), l = x >= 0 ? g.slice(0, x) : [], b = C(l);
1713
- if (b === 4) {
1714
- const y = h(d, !0);
1715
- y && f.push(y);
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);
1716
2386
  } else {
1717
- const y = h(d);
1718
- y && (b === 1 ? o.push(y) : b === 2 ? s.push(y) : b === 3 && a.push(y));
2387
+ const f = g(b);
2388
+ f && (k === 1 ? s.push(f) : k === 2 ? o.push(f) : k === 3 && a.push(f));
1719
2389
  }
1720
2390
  }
1721
- const v = [...o, ...s, ...a, ...f].join("");
1722
- return Te.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;
1723
2393
  }
1724
- const ne = [];
1725
- function ut(e, t, r, i, n, o, s, a) {
2394
+ const pe = [];
2395
+ function qt(e, t, r, n, i, s, o, a) {
1726
2396
  if (e) {
1727
- ne.push(r);
2397
+ pe.push(r);
1728
2398
  try {
1729
- if (t.loadingTemplate && r.isLoading) {
1730
- Q(e, t.loadingTemplate(r), r, i, n);
1731
- return;
1732
- }
1733
- if (t.errorTemplate && r.hasError) {
1734
- r.error instanceof Error && Q(e, t.errorTemplate(r.error, r), r, i, n);
1735
- return;
1736
- }
1737
- const f = t.render(r);
1738
- if (f instanceof Promise) {
1739
- o(!0), f.then((p) => {
1740
- o(!1), s(null), Q(e, p, r, i, n), a(e.innerHTML);
1741
- }).catch((p) => {
1742
- o(!1), s(p), t.errorTemplate && Q(e, t.errorTemplate(p, r), r, i, n);
1743
- }), t.loadingTemplate && Q(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
+ });
1744
2406
  return;
1745
2407
  }
1746
- Q(e, f, r, i, n), a(e.innerHTML);
2408
+ Ge(e, u, r, n, i), a(e.innerHTML);
1747
2409
  } finally {
1748
- ne.pop();
2410
+ pe.pop();
1749
2411
  }
1750
2412
  }
1751
2413
  }
1752
- function Q(e, t, r, i, n) {
1753
- e && (Ye(
2414
+ function Ge(e, t, r, n, i) {
2415
+ e && (Rt(
1754
2416
  e,
1755
2417
  Array.isArray(t) ? t : [t],
1756
2418
  r,
1757
- i
1758
- ), n(e.innerHTML));
2419
+ n
2420
+ ), i(e.innerHTML));
1759
2421
  }
1760
- function pt(e, t, r, i, n, o, s) {
1761
- if (o !== null && clearTimeout(o), Date.now() - t < 16) {
1762
- if (n(r + 1), r > 10) {
1763
- s(null);
2422
+ function Ft(e, t, r, n, i, s, o) {
2423
+ if (s !== null && clearTimeout(s), Date.now() - t < 16) {
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);
1764
2440
  return;
1765
2441
  }
1766
2442
  } else
1767
- n(0);
1768
- const f = setTimeout(() => {
1769
- i(Date.now()), e(), s(null);
1770
- }, 0);
1771
- s(f);
2443
+ i(0);
2444
+ const m = setTimeout(() => {
2445
+ n(Date.now()), e(), o(null);
2446
+ }, r > 10 ? 100 : 0);
2447
+ o(m);
1772
2448
  }
1773
- function dt(e, t, r, i, n, o) {
2449
+ function Kt(e, t, r, n, i) {
1774
2450
  if (!e) return;
1775
- const s = ft(i);
1776
- if (!t.style && (!s || s.trim() === "")) {
1777
- o(null), e.adoptedStyleSheets = [Ee()];
2451
+ const s = Ut(r);
2452
+ if ((!s || s.trim() === "") && !t._computedStyle) {
2453
+ i(null), e.adoptedStyleSheets = [Ke()];
1778
2454
  return;
1779
2455
  }
1780
- let a = "";
1781
- t.style && (typeof t.style == "string" ? a = t.style : typeof t.style == "function" && (a = t.style(r)));
1782
- let f = Qe(`${a}
2456
+ let o = "";
2457
+ t._computedStyle && (o = t._computedStyle);
2458
+ let a = Ot(`${o}
1783
2459
  ${s}
1784
2460
  `);
1785
- f = Be(f);
1786
- let p = n;
1787
- p || (p = new CSSStyleSheet()), (p.cssRules.length === 0 || p.toString() !== f) && p.replaceSync(f), e.adoptedStyleSheets = [Ee(), p], o(p);
2461
+ a = ot(a);
2462
+ let u = n;
2463
+ u || (u = new CSSStyleSheet()), (u.cssRules.length === 0 || u.toString() !== a) && u.replaceSync(a), e.adoptedStyleSheets = [Ke(), u], i(u);
1788
2464
  }
1789
- const de = /* @__PURE__ */ new Map(), je = Symbol.for("cer.registry");
1790
- if (typeof window < "u") {
1791
- const e = globalThis;
1792
- e[je] || (e[je] = de);
2465
+ let N = null;
2466
+ function Vt(e) {
2467
+ N = e;
1793
2468
  }
1794
- function Le(e, t, r) {
1795
- let i = Y(e);
1796
- i.includes("-") || (i = `cer-${i}`);
1797
- let n;
1798
- typeof t == "function" ? n = { ...r, render: t } : n = t, typeof n.onError != "function" && (n.onError = (o, s) => {
1799
- console.error(`[${i}] Error:`, o, s);
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
1800
2484
  });
2485
+ }
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);
1801
2510
  try {
1802
- const o = /* @__PURE__ */ new Set([
1803
- "refs",
1804
- "requestRender",
1805
- "error",
1806
- "hasError",
1807
- "isLoading",
1808
- "emit"
1809
- ]), s = [];
1810
- if (n.state && typeof n.state == "object" && Object.keys(n.state).forEach((a) => {
1811
- o.has(a) && s.push(a);
1812
- }), n.props && typeof n.props == "object" && Object.keys(n.props).forEach((a) => {
1813
- o.has(a) && s.push(a);
1814
- }), n.computed && typeof n.computed == "object" && Object.keys(n.computed).forEach((a) => {
1815
- o.has(a) && s.push(a);
1816
- }), s.length > 0) {
1817
- const a = Array.from(new Set(s));
1818
- console.warn(
1819
- `[${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.`
1820
- );
1821
- }
1822
- } catch {
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
+ });
1823
2525
  }
1824
- if (de.set(i, n), typeof window < "u")
1825
- if (!customElements.get(i))
1826
- customElements.define(i, ht(i, n));
1827
- else
1828
- try {
1829
- document.querySelectorAll(i).forEach((o) => {
1830
- try {
1831
- typeof o._cfg < "u" && (o._cfg = n), typeof o._render == "function" && o._render(n);
1832
- } catch {
1833
- }
1834
- });
1835
- } catch {
1836
- }
1837
2526
  }
1838
- function ht(e, t) {
2527
+ const $e = /* @__PURE__ */ new Map(), Xe = Symbol.for("cer.registry");
2528
+ if (typeof window < "u") {
2529
+ const e = globalThis;
2530
+ e[Xe] || (e[Xe] = $e);
2531
+ }
2532
+ function Zt(e, t) {
1839
2533
  if (!t.render)
1840
2534
  throw new Error(
1841
2535
  "Component must have a render function"
@@ -1853,6 +2547,7 @@ function ht(e, t) {
1853
2547
  _mounted = !1;
1854
2548
  _hasError = !1;
1855
2549
  _initializing = !0;
2550
+ _componentId;
1856
2551
  _styleSheet = null;
1857
2552
  _lastHtmlStringForJitCSS = "";
1858
2553
  /**
@@ -1879,7 +2574,7 @@ function ht(e, t) {
1879
2574
  _templateLoading = !1;
1880
2575
  _templateError = null;
1881
2576
  constructor() {
1882
- super(), this.attachShadow({ mode: "open" }), this._cfg = de.get(e) || t;
2577
+ super(), this.attachShadow({ mode: "open" }), this._cfg = $e.get(e) || t, this._componentId = `${e}-${Math.random().toString(36).substr(2, 9)}`;
1883
2578
  const r = this._initContext(t);
1884
2579
  Object.defineProperty(r, "refs", {
1885
2580
  value: this._refs,
@@ -1891,13 +2586,28 @@ function ht(e, t) {
1891
2586
  writable: !1,
1892
2587
  enumerable: !1,
1893
2588
  configurable: !1
2589
+ }), Object.defineProperty(r, "_requestRender", {
2590
+ value: () => this._requestRender(),
2591
+ writable: !1,
2592
+ enumerable: !1,
2593
+ configurable: !1
2594
+ }), Object.defineProperty(r, "_componentId", {
2595
+ value: this._componentId,
2596
+ writable: !1,
2597
+ enumerable: !1,
2598
+ configurable: !1
2599
+ }), Object.defineProperty(r, "_triggerWatchers", {
2600
+ value: (i, s) => this._triggerWatchers(i, s),
2601
+ writable: !1,
2602
+ enumerable: !1,
2603
+ configurable: !1
1894
2604
  }), this.context = r, Object.defineProperty(this.context, "emit", {
1895
- value: (n, o, s) => {
1896
- const a = new CustomEvent(n, {
1897
- detail: o,
2605
+ value: (i, s, o) => {
2606
+ const a = new CustomEvent(i, {
2607
+ detail: s,
1898
2608
  bubbles: !0,
1899
2609
  composed: !0,
1900
- ...s || {}
2610
+ ...o || {}
1901
2611
  });
1902
2612
  return this.dispatchEvent(a), !a.defaultPrevented;
1903
2613
  },
@@ -1905,15 +2615,28 @@ function ht(e, t) {
1905
2615
  enumerable: !1,
1906
2616
  configurable: !1
1907
2617
  });
1908
- const i = de.get(e) || t;
1909
- Object.keys(i).forEach((n) => {
1910
- const o = i[n];
1911
- typeof o == "function" && (this.context[n] = (...s) => o(...s, this.context));
1912
- }), this._applyComputed(i), this._initializing = !1, this._initWatchers(i), this._render(i);
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, {
2625
+ get() {
2626
+ return s;
2627
+ },
2628
+ set(o) {
2629
+ const a = s;
2630
+ s = o, this.context[i] = o, this._initializing || (this._applyProps(n), a !== o && this._requestRender());
2631
+ },
2632
+ enumerable: !0,
2633
+ configurable: !0
2634
+ });
2635
+ }), this._initializing = !1, this._initWatchers(n), this._applyProps(n), this._render(n);
1913
2636
  }
1914
2637
  connectedCallback() {
1915
2638
  this._runLogicWithinErrorBoundary(t, () => {
1916
- this._applyProps(t), We(
2639
+ this._applyProps(t), this._requestRender(), bt(
1917
2640
  t,
1918
2641
  this.context,
1919
2642
  this._mounted,
@@ -1925,7 +2648,7 @@ function ht(e, t) {
1925
2648
  }
1926
2649
  disconnectedCallback() {
1927
2650
  this._runLogicWithinErrorBoundary(t, () => {
1928
- De(
2651
+ wt(
1929
2652
  t,
1930
2653
  this.context,
1931
2654
  this._listeners,
@@ -1947,51 +2670,40 @@ function ht(e, t) {
1947
2670
  );
1948
2671
  });
1949
2672
  }
1950
- attributeChangedCallback(r, i, n) {
2673
+ attributeChangedCallback(r, n, i) {
1951
2674
  this._runLogicWithinErrorBoundary(t, () => {
1952
- this._applyProps(t), Ue(
2675
+ this._applyProps(t), n !== i && this._requestRender(), vt(
1953
2676
  t,
1954
2677
  r,
1955
- i,
1956
2678
  n,
2679
+ i,
1957
2680
  this.context
1958
2681
  );
1959
2682
  });
1960
2683
  }
1961
2684
  static get observedAttributes() {
1962
- return t.props ? Object.keys(t.props).map(Y) : [];
2685
+ return t.props ? Object.keys(t.props).map(te) : [];
1963
2686
  }
1964
2687
  _applyComputed(r) {
1965
- this._runLogicWithinErrorBoundary(t, () => {
1966
- r.computed && Object.entries(r.computed).forEach(([i, n]) => {
1967
- Object.defineProperty(this.context, i, {
1968
- get: () => {
1969
- const o = n(this.context);
1970
- return J(o);
1971
- },
1972
- enumerable: !0
1973
- });
1974
- });
1975
- });
1976
2688
  }
1977
2689
  // --- Render ---
1978
2690
  _render(r) {
1979
2691
  this._runLogicWithinErrorBoundary(r, () => {
1980
- ut(
2692
+ qt(
1981
2693
  this.shadowRoot,
1982
2694
  r,
1983
2695
  this.context,
1984
2696
  this._refs,
1985
- (i) => {
1986
- this._lastHtmlStringForJitCSS = i, typeof this.onHtmlStringUpdate == "function" && this.onHtmlStringUpdate(i);
2697
+ (n) => {
2698
+ this._lastHtmlStringForJitCSS = n, typeof this.onHtmlStringUpdate == "function" && this.onHtmlStringUpdate(n);
1987
2699
  },
1988
- (i) => {
1989
- this._templateLoading = i, typeof this.onLoadingStateChange == "function" && this.onLoadingStateChange(i);
2700
+ (n) => {
2701
+ this._templateLoading = n, typeof this.onLoadingStateChange == "function" && this.onLoadingStateChange(n);
1990
2702
  },
1991
- (i) => {
1992
- this._templateError = i, typeof this.onErrorStateChange == "function" && this.onErrorStateChange(i);
2703
+ (n) => {
2704
+ this._templateError = n, typeof this.onErrorStateChange == "function" && this.onErrorStateChange(n);
1993
2705
  },
1994
- (i) => this._applyStyle(r, i)
2706
+ (n) => this._applyStyle(r, n)
1995
2707
  );
1996
2708
  });
1997
2709
  }
@@ -2000,58 +2712,56 @@ function ht(e, t) {
2000
2712
  }
2001
2713
  _requestRender() {
2002
2714
  this._runLogicWithinErrorBoundary(this._cfg, () => {
2003
- pt(
2004
- () => this._render(this._cfg),
2005
- this._lastRenderTime,
2006
- this._renderCount,
2007
- (r) => {
2008
- this._lastRenderTime = r;
2009
- },
2010
- (r) => {
2011
- this._renderCount = r;
2012
- },
2013
- this._renderTimeoutId,
2014
- (r) => {
2015
- this._renderTimeoutId = r;
2016
- }
2017
- );
2715
+ le(() => {
2716
+ Ft(
2717
+ () => this._render(this._cfg),
2718
+ this._lastRenderTime,
2719
+ this._renderCount,
2720
+ (r) => {
2721
+ this._lastRenderTime = r;
2722
+ },
2723
+ (r) => {
2724
+ this._renderCount = r;
2725
+ },
2726
+ this._renderTimeoutId,
2727
+ (r) => {
2728
+ this._renderTimeoutId = r;
2729
+ }
2730
+ );
2731
+ }, this._componentId);
2018
2732
  });
2019
2733
  }
2020
2734
  // --- Style ---
2021
- _applyStyle(r, i) {
2735
+ _applyStyle(r, n) {
2022
2736
  this._runLogicWithinErrorBoundary(r, () => {
2023
- dt(
2737
+ Kt(
2024
2738
  this.shadowRoot,
2025
- r,
2026
2739
  this.context,
2027
- i,
2740
+ n,
2028
2741
  this._styleSheet,
2029
- (n) => {
2030
- this._styleSheet = n;
2742
+ (i) => {
2743
+ this._styleSheet = i;
2031
2744
  }
2032
2745
  );
2033
2746
  });
2034
2747
  }
2035
2748
  // --- Error Boundary function ---
2036
- _runLogicWithinErrorBoundary(r, i) {
2749
+ _runLogicWithinErrorBoundary(r, n) {
2037
2750
  this._hasError && (this._hasError = !1);
2038
2751
  try {
2039
- i();
2040
- } catch (n) {
2041
- this._hasError = !0, r.onError && r.onError(n, this.context), r.errorFallback && this.shadowRoot && (this.shadowRoot.innerHTML = r.errorFallback(
2042
- n,
2043
- this.context
2044
- ));
2752
+ n();
2753
+ } catch (i) {
2754
+ this._hasError = !0, r.onError && r.onError(i, this.context);
2045
2755
  }
2046
2756
  }
2047
2757
  // --- State, props, computed ---
2048
2758
  _initContext(r) {
2049
2759
  try {
2050
- let i = function(o, s = "") {
2051
- return Array.isArray(o) ? new Proxy(o, {
2052
- get(a, f, p) {
2053
- const h = Reflect.get(a, f, p);
2054
- return typeof h == "function" && typeof f == "string" && [
2760
+ let n = function(s, o = "") {
2761
+ return Array.isArray(s) ? new Proxy(s, {
2762
+ get(a, u, m) {
2763
+ const g = Reflect.get(a, u, m);
2764
+ return typeof g == "function" && typeof u == "string" && [
2055
2765
  "push",
2056
2766
  "pop",
2057
2767
  "shift",
@@ -2059,171 +2769,303 @@ function ht(e, t) {
2059
2769
  "splice",
2060
2770
  "sort",
2061
2771
  "reverse"
2062
- ].includes(f) ? function(...u) {
2063
- const c = h.apply(a, u);
2064
- if (!n._initializing) {
2065
- const w = s || "root";
2066
- n._triggerWatchers(w, a), n._render(r);
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);
2067
2777
  }
2068
- return c;
2069
- } : h;
2778
+ return l;
2779
+ } : g;
2070
2780
  },
2071
- set(a, f, p) {
2072
- if (a[f] = p, !n._initializing) {
2073
- const h = s ? `${s}.${String(f)}` : String(f);
2074
- n._triggerWatchers(h, p), n._render(r);
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);
2075
2785
  }
2076
2786
  return !0;
2077
2787
  },
2078
- deleteProperty(a, f) {
2079
- if (delete a[f], !n._initializing) {
2080
- const p = s ? `${s}.${String(f)}` : String(f);
2081
- n._triggerWatchers(p, void 0), n._render(r);
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);
2082
2792
  }
2083
2793
  return !0;
2084
2794
  }
2085
- }) : o && typeof o == "object" ? (Object.keys(o).forEach((a) => {
2086
- const f = s ? `${s}.${a}` : a;
2087
- o[a] = i(o[a], f);
2088
- }), new Proxy(o, {
2089
- set(a, f, p) {
2090
- const h = s ? `${s}.${String(f)}` : String(f);
2091
- return a[f] = i(p, h), n._initializing || (n._triggerWatchers(
2092
- h,
2093
- a[f]
2094
- ), n._render(r)), !0;
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);
2798
+ }), new Proxy(s, {
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;
2095
2805
  },
2096
- get(a, f, p) {
2097
- return Reflect.get(a, f, p);
2806
+ get(a, u, m) {
2807
+ return Reflect.get(a, u, m);
2098
2808
  }
2099
- })) : o;
2809
+ })) : s;
2100
2810
  };
2101
- const n = this;
2102
- 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
+ });
2103
2819
  } catch {
2104
2820
  return {};
2105
2821
  }
2106
2822
  }
2107
2823
  _initWatchers(r) {
2108
2824
  this._runLogicWithinErrorBoundary(r, () => {
2109
- qe(
2825
+ ht(
2110
2826
  this.context,
2111
2827
  this._watchers,
2112
- r.watch || {}
2828
+ {}
2829
+ // Watchers are now handled by the watch() function in functional API
2113
2830
  );
2114
2831
  });
2115
2832
  }
2116
- _triggerWatchers(r, i) {
2117
- Ie(this.context, this._watchers, r, i);
2833
+ _triggerWatchers(r, n) {
2834
+ gt(this.context, this._watchers, r, n);
2118
2835
  }
2119
2836
  _applyProps(r) {
2120
2837
  this._runLogicWithinErrorBoundary(r, () => {
2121
2838
  try {
2122
- Ne(this, r, this.context);
2123
- } catch (i) {
2124
- 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
+ }
2125
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();
2126
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
+ }
2127
2916
  }
2128
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
+ }
2943
+ }
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
+ );
2129
2957
  }
2130
- function re(e, t = {}, r, i) {
2131
- const n = i ?? t.key;
2132
- return { tag: e, key: n, props: t, children: r };
2958
+ function fe(e, t = {}, r, n) {
2959
+ const i = n ?? t.key;
2960
+ return { tag: e, key: i, props: t, children: r };
2133
2961
  }
2134
- function ue(e) {
2962
+ function Se(e) {
2135
2963
  return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
2136
2964
  }
2137
- function ae(e) {
2138
- return typeof e == "object" && e !== null && "tag" in e && !ue(e);
2965
+ function ke(e) {
2966
+ return typeof e == "object" && e !== null && "tag" in e && !Se(e);
2139
2967
  }
2140
- function gt(e, t) {
2968
+ function Yt(e, t) {
2141
2969
  return e.key != null ? e : { ...e, key: t };
2142
2970
  }
2143
- function mt(e, t = [], r = {}) {
2144
- const i = {}, n = {}, o = {}, s = [], a = /([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;
2145
- let f;
2146
- for (; f = a.exec(e); ) {
2147
- const p = f[1], h = f[2], C = (f[4] || f[6]) ?? "", u = C.match(/^{{(\d+)}}$/);
2148
- let c = u ? t[Number(u[1])] ?? null : C;
2149
- u || (c === "true" ? c = !0 : c === "false" ? c = !1 : c === "null" ? c = null : isNaN(Number(c)) || (c = Number(c)));
2150
- const w = ["model", "bind", "show", "class", "style"];
2151
- if (p === ":") {
2152
- const [v, d] = h.split(":"), [g, ...m] = v.split(".");
2153
- if (w.includes(g)) {
2154
- const x = [...m], l = g === "model" && d ? `model:${d}` : g;
2155
- o[l] = {
2156
- value: c,
2157
- modifiers: x,
2158
- arg: d
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] = {
2984
+ value: l,
2985
+ modifiers: y,
2986
+ arg: b
2159
2987
  };
2160
- } else
2161
- n[h] = c, s.push(h);
2162
- } else if (p === "@") {
2163
- const v = "on" + h.charAt(0).toUpperCase() + h.slice(1);
2164
- i[v] = typeof c == "function" ? c : typeof r[c] == "function" ? r[c] : void 0;
2165
- } else h === "ref" ? i.ref = c : n[h] = c;
2166
- }
2167
- return { props: i, attrs: n, directives: o, bound: s };
2168
- }
2169
- function yt(e, t, r) {
2170
- const i = ne.length > 0 ? ne[ne.length - 1] : void 0, n = r ?? i;
2171
- function o(l, b) {
2172
- return re("#text", {}, l, b);
2173
- }
2174
- let s = "";
2175
- for (let l = 0; l < e.length; l++)
2176
- s += e[l], l < t.length && (s += `{{${l}}}`);
2177
- const a = /<\/?([a-zA-Z0-9-]+)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s>]+))?)*)\s*\/?>|{{(\d+)}}|([^<]+)/g, f = [];
2178
- let p, h = [], C = null, u = {}, c, w = 0, v = [];
2179
- function d(l) {
2180
- !l || typeof l != "object" || ue(l) || (l.props || l.attrs ? (l.props && (u.props || (u.props = {}), Object.assign(u.props, l.props)), l.attrs && (u.attrs || (u.attrs = {}), Object.keys(l.attrs).forEach((b) => {
2181
- if (b === "style" && u.attrs.style) {
2182
- const y = u.attrs.style.replace(
2988
+ } else {
2989
+ let y = l;
2990
+ y && typeof y == "object" && y.constructor?.name === "ReactiveState" && (y = y.value), i[g] = y, o.push(g);
2991
+ }
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;
3004
+ }
3005
+ return { props: n, attrs: i, directives: s, bound: o };
3006
+ }
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;
3012
+ }
3013
+ function a(f, x) {
3014
+ return fe("#text", {}, f, x);
3015
+ }
3016
+ let u = "";
3017
+ for (let f = 0; f < e.length; f++)
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(
2183
3025
  /;?\s*$/,
2184
3026
  ""
2185
- ), _ = l.attrs.style.replace(/^;?\s*/, "");
2186
- u.attrs.style = y + "; " + _;
2187
- } else if (b === "class" && u.attrs.class) {
2188
- const y = u.attrs.class.trim().split(/\s+/).filter(Boolean), _ = l.attrs.class.trim().split(/\s+/).filter(Boolean), E = [
2189
- .../* @__PURE__ */ new Set([...y, ..._])
3027
+ ), _ = f.attrs.style.replace(/^;?\s*/, "");
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, ..._])
2190
3032
  ];
2191
- u.attrs.class = E.join(" ");
3033
+ d.attrs.class = S.join(" ");
2192
3034
  } else
2193
- u.attrs[b] = l.attrs[b];
2194
- }))) : (u.props || (u.props = {}), Object.assign(u.props, l)));
2195
- }
2196
- function g(l, b) {
2197
- const y = C ? h : v;
2198
- if (ue(l)) {
2199
- const _ = l.key ?? b;
2200
- let E = l.children;
2201
- y.push({
2202
- ...l,
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({
3044
+ ...f,
2203
3045
  key: _,
2204
- children: E
3046
+ children: S
2205
3047
  });
2206
3048
  return;
2207
3049
  }
2208
- if (ae(l)) {
2209
- y.push(gt(l, void 0));
3050
+ if (ke(f)) {
3051
+ A.push(Yt(f, void 0));
2210
3052
  return;
2211
3053
  }
2212
- if (Array.isArray(l)) {
2213
- if (l.length === 0) return;
2214
- for (let _ = 0; _ < l.length; _++) {
2215
- const E = l[_];
2216
- ue(E) || ae(E) || Array.isArray(E) ? g(E, `${b}-${_}`) : E !== null && typeof E == "object" ? d(E) : y.push(o(String(E), `${b}-${_}`));
3054
+ if (Array.isArray(f)) {
3055
+ if (f.length === 0) return;
3056
+ for (let _ = 0; _ < f.length; _++) {
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}-${_}`));
2217
3059
  }
2218
3060
  return;
2219
3061
  }
2220
- if (l !== null && typeof l == "object") {
2221
- d(l);
3062
+ if (f !== null && typeof f == "object") {
3063
+ p(f);
2222
3064
  return;
2223
3065
  }
2224
- y.push(o(String(l), b));
3066
+ A.push(a(String(f), x));
2225
3067
  }
2226
- const m = /* @__PURE__ */ new Set([
3068
+ const C = /* @__PURE__ */ new Set([
2227
3069
  "area",
2228
3070
  "base",
2229
3071
  "br",
@@ -2239,378 +3081,697 @@ function yt(e, t, r) {
2239
3081
  "track",
2240
3082
  "wbr"
2241
3083
  ]);
2242
- for (; p = a.exec(s); )
2243
- if (p[1]) {
2244
- const l = p[1], b = p[0][1] === "/", y = p[0][p[0].length - 2] === "/" || m.has(l), {
2245
- props: _,
2246
- attrs: E,
2247
- directives: S,
2248
- bound: A
2249
- } = mt(p[2] || "", t, n), $ = { props: {}, attrs: {} };
2250
- for (const T in _) $.props[T] = _[T];
2251
- for (const T in E) $.attrs[T] = E[T];
2252
- if ($.attrs && Object.prototype.hasOwnProperty.call($.attrs, "key") && !($.props && Object.prototype.hasOwnProperty.call($.props, "key")))
2253
- try {
2254
- $.props.key = $.attrs.key;
2255
- } catch {
2256
- }
2257
- try {
2258
- const T = {
2259
- input: ["value", "checked", "disabled", "readonly", "required", "placeholder", "maxlength", "minlength"],
2260
- textarea: ["value", "disabled", "readonly", "required", "placeholder", "maxlength", "minlength"],
2261
- select: ["value", "disabled", "required", "multiple"],
2262
- option: ["selected", "disabled", "value"],
2263
- video: ["muted", "autoplay", "controls", "loop", "playsinline"],
2264
- audio: ["muted", "autoplay", "controls", "loop"],
2265
- img: ["src", "alt", "width", "height"],
2266
- button: ["type", "name", "value", "disabled", "autofocus", "form"]
2267
- }, B = l.toLowerCase(), G = T[B] ?? [];
2268
- if ($.attrs)
2269
- for (const M of G)
2270
- A && A.includes(M) && M in $.attrs && !($.props && M in $.props) && ($.props[M] = $.attrs[M], delete $.attrs[M]);
2271
- if ((l.includes("-") || !!n?.__customElements?.has?.(l)) && A && $.attrs) {
2272
- const M = /* @__PURE__ */ new Set(["id", "name", "data-key", "key"]);
2273
- for (const U of A)
2274
- if (U in $.attrs && !($.props && U in $.props)) {
2275
- const q = U.includes("-") ? U.split("-").map((I, z) => z === 0 ? I : I.charAt(0).toUpperCase() + I.slice(1)).join("") : U;
2276
- $.props[q] = $.attrs[U], M.has(U) || delete $.attrs[U];
2277
- }
2278
- $.isCustomElement = !0;
2279
- }
2280
- } catch {
2281
- }
2282
- if (S && Object.keys(S).some((T) => T === "model" || T.startsWith("model:")))
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), {
3088
+ props: _,
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")))
3096
+ try {
3097
+ $.props.key = $.attrs.key;
3098
+ } catch {
3099
+ }
2283
3100
  try {
2284
- const T = Symbol.for("cer.registry"), B = globalThis[T], G = !!(B && typeof B.has == "function" && B.has(l)), ee = !!(n && (n.__customElements instanceof Set && n.__customElements.has(l) || Array.isArray(n.__isCustomElements) && n.__isCustomElements.includes(l)));
2285
- if (!!(l.includes("-") || ee || G))
2286
- for (const q of Object.keys(S)) {
2287
- if (q !== "model" && !q.startsWith("model:")) continue;
2288
- const I = S[q], z = I.arg ?? (q.includes(":") ? q.split(":", 2)[1] : void 0), H = I.value, F = z ?? "modelValue", te = W, k = ce, P = n ? n._state || n : void 0;
2289
- let R;
2290
- typeof H == "string" && n ? R = te(P, H) : R = H, $.props[F] = R;
2291
- try {
2292
- const L = Y(F);
2293
- $.attrs || ($.attrs = {}), R !== void 0 && ($.attrs[L] = R);
2294
- } catch {
3101
+ const P = {
3102
+ input: ["value", "checked", "disabled", "readonly", "required", "placeholder", "maxlength", "minlength"],
3103
+ textarea: ["value", "disabled", "readonly", "required", "placeholder", "maxlength", "minlength"],
3104
+ select: ["value", "disabled", "required", "multiple"],
3105
+ option: ["selected", "disabled", "value"],
3106
+ video: ["muted", "autoplay", "controls", "loop", "playsinline"],
3107
+ audio: ["muted", "autoplay", "controls", "loop"],
3108
+ img: ["src", "alt", "width", "height"],
3109
+ button: ["type", "name", "value", "disabled", "autofocus", "form"]
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];
2295
3116
  }
2296
- $.isCustomElement = !0;
2297
- const O = `update:${Y(F)}`, j = "on" + O.charAt(0).toUpperCase() + O.slice(1);
2298
- $.props[j] = function(L) {
2299
- const se = L.detail !== void 0 ? L.detail : L.target ? L.target.value : void 0;
2300
- if (!P) return;
2301
- const he = te(P, typeof H == "string" ? H : String(H));
2302
- (Array.isArray(se) && Array.isArray(he) ? JSON.stringify([...se].sort()) !== JSON.stringify([...he].sort()) : se !== he) && (k(P, typeof H == "string" ? H : String(H), se), n?.requestRender ? n.requestRender() : n?._requestRender && n._requestRender());
2303
- }, delete S[q];
2304
- }
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];
3125
+ }
3126
+ }
2305
3127
  } catch {
2306
3128
  }
2307
- if (Object.keys(S).length > 0 && ($.directives = { ...S }), b) {
2308
- const T = re(
2309
- C,
2310
- u,
2311
- h.length === 1 && ae(h[0]) && h[0].tag === "#text" ? typeof h[0].children == "string" ? h[0].children : "" : h.length ? h : void 0,
2312
- c
2313
- ), B = f.pop();
2314
- B ? (C = B.tag, u = B.props, c = B.key, h = B.children, h.push(T)) : (v.push(T), C = null, u = {}, c = void 0, h = []);
2315
- } else y ? C ? h.push(re(l, $, void 0, void 0)) : v.push(re(l, $, void 0, void 0)) : (C && f.push({
2316
- tag: C,
2317
- props: u,
2318
- children: h,
2319
- key: c
2320
- }), C = l, u = $, h = []);
2321
- } else if (typeof p[3] < "u") {
2322
- const l = Number(p[3]), b = t[l], y = `interp-${l}`;
2323
- g(b, y);
2324
- } else if (p[4]) {
2325
- const l = p[4], b = C ? h : v, y = l.split(/({{\d+}})/);
2326
- for (const _ of y) {
2327
- if (!_) continue;
2328
- const E = _.match(/^{{(\d+)}}$/);
2329
- if (E) {
2330
- const S = Number(E[1]), A = t[S], $ = `interp-${S}`;
2331
- g(A, $);
2332
- } else {
2333
- const S = `text-${w++}`;
2334
- b.push(o(_, S));
3129
+ if (R && Object.keys(R).some((P) => P === "model" || P.startsWith("model:")))
3130
+ try {
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;
3138
+ try {
3139
+ const re = te(E);
3140
+ $.attrs || ($.attrs = {}), O !== void 0 && ($.attrs[re] = O);
3141
+ } catch {
3142
+ }
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];
3156
+ }
3157
+ } catch {
3158
+ }
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) {
3179
+ if (!_) continue;
3180
+ const S = _.match(/^{{(\d+)}}$/);
3181
+ if (S) {
3182
+ const R = Number(S[1]), T = t[R], $ = `interp-${R}`;
3183
+ y(T, $);
3184
+ } else {
3185
+ const R = `text-${b++}`;
3186
+ x.push(a(_, R));
3187
+ }
2335
3188
  }
2336
3189
  }
2337
3190
  }
2338
- const x = v.filter((l) => ae(l) && l.tag === "#text" ? typeof l.children == "string" && l.children.trim() !== "" : !0);
2339
- return x.length === 1 ? x[0] : x.length > 1 ? x : re("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
+ }
2340
3480
  }
2341
- function Z(e, ...t) {
2342
- const r = t[t.length - 1], i = typeof r == "object" && r && !Array.isArray(r) ? r : void 0;
2343
- return yt(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 };
2344
3499
  }
2345
- const Re = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, K = (e, t) => {
3500
+ const et = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, Q = (e, t) => {
2346
3501
  for (const r of e) {
2347
- const i = [], n = r.path.replace(/:[^/]+/g, (a) => (i.push(a.slice(1)), "([^/]+)")), o = new RegExp(`^${n}$`), s = t.match(o);
2348
- if (s) {
3502
+ const n = [], i = r.path.replace(/:[^/]+/g, (a) => (n.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${i}$`), o = t.match(s);
3503
+ if (o) {
2349
3504
  const a = {};
2350
- return i.forEach((f, p) => {
2351
- a[f] = s[p + 1];
3505
+ return n.forEach((u, m) => {
3506
+ a[u] = o[m + 1];
2352
3507
  }), { route: r, params: a };
2353
3508
  }
2354
3509
  }
2355
3510
  return { route: null, params: {} };
2356
- }, ke = {};
2357
- async function bt(e) {
3511
+ }, ze = {};
3512
+ async function ir(e) {
2358
3513
  if (e.component) return e.component;
2359
3514
  if (e.load) {
2360
- if (ke[e.path]) return ke[e.path];
3515
+ if (ze[e.path]) return ze[e.path];
2361
3516
  try {
2362
3517
  const t = await e.load();
2363
- return ke[e.path] = t.default, t.default;
3518
+ return ze[e.path] = t.default, t.default;
2364
3519
  } catch {
2365
3520
  throw new Error(`Failed to load component for route: ${e.path}`);
2366
3521
  }
2367
3522
  }
2368
3523
  throw new Error(`No component or loader defined for route: ${e.path}`);
2369
3524
  }
2370
- function wt(e) {
2371
- const { routes: t, base: r = "", initialUrl: i } = e;
2372
- let n, o, s, a, f, p, h;
2373
- const C = async (v, d) => {
2374
- const g = t.find((m) => K([m], v.path).route !== null);
2375
- 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)
2376
3531
  try {
2377
- const m = await g.beforeEnter(v, d);
2378
- return typeof m == "string" ? (await w(m, !0), !1) : m !== !1;
2379
- } catch (m) {
2380
- return console.error("beforeEnter error", m), !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;
2381
3536
  }
2382
3537
  return !0;
2383
- }, u = async (v, d) => {
2384
- const g = t.find((m) => K([m], v.path).route !== null);
2385
- if (g?.onEnter)
3538
+ }, h = async (v, b) => {
3539
+ const c = t.find((p) => Q([p], v.path).route !== null);
3540
+ if (c?.onEnter)
2386
3541
  try {
2387
- const m = await g.onEnter(v, d);
2388
- return typeof m == "string" ? (await w(m, !0), !1) : m !== !1;
2389
- } catch (m) {
2390
- return console.error("onEnter error", m), !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;
2391
3546
  }
2392
3547
  return !0;
2393
- }, c = (v, d) => {
2394
- const g = t.find((m) => K([m], v.path).route !== null);
2395
- if (g?.afterEnter)
3548
+ }, l = (v, b) => {
3549
+ const c = t.find((p) => Q([p], v.path).route !== null);
3550
+ if (c?.afterEnter)
2396
3551
  try {
2397
- g.afterEnter(v, d);
2398
- } catch (m) {
2399
- console.error("afterEnter error", m);
3552
+ c.afterEnter(v, b);
3553
+ } catch (p) {
3554
+ ie("afterEnter error", p);
2400
3555
  }
2401
- }, w = async (v, d = !1) => {
3556
+ }, d = async (v, b = !1) => {
2402
3557
  try {
2403
- const g = {
3558
+ const c = {
2404
3559
  path: v.replace(r, "") || "/",
2405
3560
  query: {}
2406
- }, m = K(t, g.path);
2407
- if (!m) throw new Error(`No route found for ${g.path}`);
2408
- const x = s.getState(), l = {
2409
- path: g.path,
2410
- params: m.params,
2411
- 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
2412
3567
  };
2413
- if (!await C(l, x) || !await u(l, x)) return;
2414
- typeof window < "u" && typeof document < "u" && (d ? window.history.replaceState({}, "", r + v) : window.history.pushState({}, "", r + v)), s.setState(l), c(l, x);
2415
- } catch (g) {
2416
- console.error("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);
2417
3572
  }
2418
3573
  };
2419
- if (typeof window < "u" && typeof document < "u") {
2420
- n = () => {
2421
- const d = new URL(window.location.href), g = d.pathname.replace(r, "") || "/", m = Re(d.search);
2422
- return { path: g, query: m };
2423
- }, o = n();
2424
- const v = K(t, o.path);
2425
- s = $e({
2426
- path: o.path,
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({
3581
+ path: s.path,
2427
3582
  params: v.params,
2428
- query: o.query
2429
- }), a = async (d = !1) => {
2430
- const g = n();
2431
- await w(g.path, d);
2432
- }, window.addEventListener("popstate", () => a(!0)), f = (d) => w(d, !1), p = (d) => w(d, !0), h = () => window.history.back();
3583
+ query: s.query
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();
2433
3588
  } else {
2434
- n = () => {
2435
- const g = new URL(i || "/", "http://localhost"), m = g.pathname.replace(r, "") || "/", x = Re(g.search);
2436
- return { path: m, query: x };
2437
- }, o = n();
2438
- const v = K(t, o.path);
2439
- s = $e({
2440
- path: o.path,
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({
3595
+ path: s.path,
2441
3596
  params: v.params,
2442
- query: o.query
3597
+ query: s.query
2443
3598
  }), a = async () => {
2444
- const g = n();
2445
- await d(g.path);
3599
+ const c = i();
3600
+ await b(c.path);
2446
3601
  };
2447
- const d = async (g) => {
3602
+ const b = async (c) => {
2448
3603
  try {
2449
- const m = {
2450
- path: g.replace(r, "") || "/",
3604
+ const p = {
3605
+ path: c.replace(r, "") || "/",
2451
3606
  query: {}
2452
- }, x = K(t, m.path);
2453
- if (!x) throw new Error(`No route found for ${m.path}`);
2454
- const l = s.getState(), b = {
2455
- path: m.path,
2456
- params: x.params,
2457
- query: m.query
2458
- }, y = t.find((_) => K([_], b.path).route !== null);
2459
- if (y?.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)
2460
3615
  try {
2461
- const _ = await y.beforeEnter(b, l);
2462
- if (typeof _ == "string") {
2463
- await d(_);
3616
+ const x = await f.beforeEnter(k, C);
3617
+ if (typeof x == "string") {
3618
+ await b(x);
2464
3619
  return;
2465
3620
  }
2466
- if (_ === !1) return;
3621
+ if (x === !1) return;
2467
3622
  } catch {
2468
3623
  return;
2469
3624
  }
2470
- if (y?.onEnter)
3625
+ if (f?.onEnter)
2471
3626
  try {
2472
- const _ = await y.onEnter(b, l);
2473
- if (typeof _ == "string") {
2474
- await d(_);
3627
+ const x = await f.onEnter(k, C);
3628
+ if (typeof x == "string") {
3629
+ await b(x);
2475
3630
  return;
2476
3631
  }
2477
- if (_ === !1) return;
3632
+ if (x === !1) return;
2478
3633
  } catch {
2479
3634
  return;
2480
3635
  }
2481
- if (s.setState(b), y?.afterEnter)
3636
+ if (o.setState(k), f?.afterEnter)
2482
3637
  try {
2483
- y.afterEnter(b, l);
3638
+ f.afterEnter(k, C);
2484
3639
  } catch {
2485
3640
  }
2486
3641
  } catch {
2487
3642
  }
2488
3643
  };
2489
- f = async (g) => d(g), p = async (g) => d(g), h = () => {
3644
+ u = async (c) => b(c), m = async (c) => b(c), g = () => {
2490
3645
  };
2491
3646
  }
2492
3647
  return {
2493
- store: s,
2494
- push: f,
2495
- replace: p,
2496
- back: h,
2497
- subscribe: s.subscribe,
2498
- matchRoute: (v) => K(t, v),
2499
- getCurrent: () => s.getState(),
2500
- resolveRouteComponent: bt
3648
+ store: o,
3649
+ push: u,
3650
+ replace: m,
3651
+ back: g,
3652
+ subscribe: o.subscribe,
3653
+ matchRoute: (v) => Q(t, v),
3654
+ getCurrent: () => o.getState(),
3655
+ resolveRouteComponent: ir
2501
3656
  };
2502
3657
  }
2503
- function At(e, t) {
2504
- return K(e, t);
3658
+ function Pr(e, t) {
3659
+ return Q(e, t);
2505
3660
  }
2506
- function Tt(e) {
2507
- const t = wt(e);
2508
- return Le("router-view", {
2509
- async render() {
2510
- if (!t) return Z`<div>Router not initialized.</div>`;
2511
- const r = t.getCurrent(), { path: i } = r, n = t.matchRoute(i);
2512
- if (!n.route) return Z`<div>Not found</div>`;
2513
- try {
2514
- const o = await t.resolveRouteComponent(n.route);
2515
- if (typeof o == "string")
2516
- return { tag: o, props: {}, children: [] };
2517
- if (typeof o == "function") {
2518
- const s = o(), a = s instanceof Promise ? await s : s;
2519
- return typeof a == "string" ? { tag: a, props: {}, children: [] } : a;
2520
- }
2521
- return Z`<div>Invalid route component</div>`;
2522
- } catch {
2523
- return Z`<div>Invalid route component</div>`;
2524
- }
2525
- },
2526
- onConnected(r) {
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(() => {
2527
3666
  t && typeof t.subscribe == "function" && t.subscribe(() => {
2528
- typeof r.requestRender == "function" && r.requestRender();
2529
3667
  });
2530
- }
2531
- }), Le("router-link", {
2532
- state: {},
2533
- props: {
2534
- to: { type: String, default: "" },
2535
- tag: { type: String, default: "a" },
2536
- replace: { type: Boolean, default: !1 },
2537
- exact: { type: Boolean, default: !1 },
2538
- activeClass: { type: String, default: "active" },
2539
- exactActiveClass: { type: String, default: "exact-active" },
2540
- ariaCurrentValue: { type: String, default: "page" },
2541
- disabled: { type: Boolean, default: !1 },
2542
- external: { type: Boolean, default: !1 },
2543
- class: { type: String, default: "" },
2544
- style: { type: String, default: Pe`
2545
- [aria-disabled="true"] {
2546
- pointer-events: none;
2547
- opacity: 0.5;
2548
- }
2549
- ` }
2550
- },
2551
- style: (r) => r.style,
2552
- render: (r) => {
2553
- const i = t.getCurrent(), n = r.to, o = r.exact, s = r.exactActiveClass, a = r.activeClass, f = r.ariaCurrentValue, p = r.tag, h = r.disabled, C = r.external, u = i.path === n, c = o ? u : i && typeof i.path == "string" ? i.path.startsWith(n) : !1, w = u ? `aria-current="${f}"` : "", v = (r.class || "").split(/\s+/).filter(Boolean), d = {};
2554
- for (const b of v) d[b] = !0;
2555
- const g = {
2556
- ...d,
2557
- // Also include the configurable names (may duplicate the above)
2558
- [a]: c,
2559
- [s]: u
2560
- }, m = p === "button", x = h ? m ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", l = C && (p === "a" || !p) ? 'target="_blank" rel="noopener noreferrer"' : "";
2561
- return Z`
2562
- ${ze().when(m, Z`
2563
- <button
2564
- part="button"
2565
- :class="${g}"
2566
- ${w}
2567
- ${x}
2568
- ${l}
2569
- @click="navigate"
2570
- ><slot></slot></button>
2571
- `).otherwise(Z`
2572
- <a
2573
- part="link"
2574
- href="${n}"
2575
- :class="${g}"
2576
- ${w}
2577
- ${x}
2578
- ${l}
2579
- @click="navigate"
2580
- ><slot></slot></a>
2581
- `).done()}
2582
- `;
2583
- },
2584
- navigate: (r, i) => {
2585
- if (i.disabled) {
2586
- 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();
2587
3701
  return;
2588
3702
  }
2589
- i.external && (i.tag === "a" || !i.tag) || (r.preventDefault(), i.replace ? t.replace(i.to) : t.push(i.to));
2590
- }
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
+ `;
2591
3727
  }), t;
2592
3728
  }
2593
3729
  export {
2594
- X as GlobalEventBus,
2595
- Le as component,
2596
- $e as createStore,
2597
- Pe as css,
2598
- kt as each,
2599
- _t as emit,
2600
- ie as eventBus,
2601
- Z as html,
2602
- Tt as initRouter,
2603
- Ct as listen,
2604
- ze as match,
2605
- K as matchRoute,
2606
- At as matchRouteSSR,
2607
- St as off,
2608
- $t as on,
2609
- Et as once,
2610
- Re as parseQuery,
2611
- ge as renderToString,
2612
- bt as resolveRouteComponent,
2613
- wt as useRouter,
2614
- vt as when
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,
3773
+ q as whenMedia,
3774
+ br as whenNotEmpty,
3775
+ _r as whenVariants
2615
3776
  };
2616
3777
  //# sourceMappingURL=custom-elements-runtime.es.js.map