@jasonshimmy/custom-elements-runtime 2.8.1 → 3.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.
Files changed (91) hide show
  1. package/README.md +159 -46
  2. package/dist/css-utils-Cg4o1MqY.js +643 -0
  3. package/dist/css-utils-Cg4o1MqY.js.map +1 -0
  4. package/dist/css-utils-RqkyBWft.cjs +576 -0
  5. package/dist/css-utils-RqkyBWft.cjs.map +1 -0
  6. package/dist/custom-elements-runtime.cjs.js +3 -3
  7. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  8. package/dist/custom-elements-runtime.dom-jit-css.cjs.js +7 -0
  9. package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -0
  10. package/dist/custom-elements-runtime.dom-jit-css.es.js +136 -0
  11. package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -0
  12. package/dist/custom-elements-runtime.es.js +70 -67
  13. package/dist/custom-elements-runtime.es.js.map +1 -1
  14. package/dist/custom-elements-runtime.event-bus.cjs.js +1 -1
  15. package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
  16. package/dist/custom-elements-runtime.event-bus.es.js +62 -46
  17. package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
  18. package/dist/custom-elements-runtime.jit-css.cjs.js +2 -0
  19. package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -0
  20. package/dist/custom-elements-runtime.jit-css.es.js +38 -0
  21. package/dist/custom-elements-runtime.jit-css.es.js.map +1 -0
  22. package/dist/custom-elements-runtime.router.cjs.js +20 -20
  23. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  24. package/dist/custom-elements-runtime.router.es.js +448 -434
  25. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  26. package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
  27. package/dist/custom-elements-runtime.ssr.cjs.js.map +1 -1
  28. package/dist/custom-elements-runtime.ssr.es.js +33 -18
  29. package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
  30. package/dist/custom-elements-runtime.store.cjs.js +1 -1
  31. package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
  32. package/dist/custom-elements-runtime.store.es.js +21 -16
  33. package/dist/custom-elements-runtime.store.es.js.map +1 -1
  34. package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
  35. package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
  36. package/dist/custom-elements-runtime.transitions.es.js +279 -7
  37. package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
  38. package/dist/custom-elements-runtime.vite-plugin.cjs.js +2 -0
  39. package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -0
  40. package/dist/custom-elements-runtime.vite-plugin.es.js +73 -0
  41. package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -0
  42. package/dist/dom-jit-css.d.ts +66 -0
  43. package/dist/event-bus.d.ts +3 -1
  44. package/dist/{namespace-helpers-DhLBqt-7.js → helpers-CweFZFWU.js} +265 -287
  45. package/dist/helpers-CweFZFWU.js.map +1 -0
  46. package/dist/helpers-DeWjSmOl.cjs +5 -0
  47. package/dist/helpers-DeWjSmOl.cjs.map +1 -0
  48. package/dist/hooks-BrrLKSub.cjs +3 -0
  49. package/dist/hooks-BrrLKSub.cjs.map +1 -0
  50. package/dist/hooks-DyShDHKo.js +403 -0
  51. package/dist/hooks-DyShDHKo.js.map +1 -0
  52. package/dist/index.d.ts +3 -3
  53. package/dist/jit-css.d.ts +30 -0
  54. package/dist/namespace-helpers-CnpZ5__p.js +45 -0
  55. package/dist/namespace-helpers-CnpZ5__p.js.map +1 -0
  56. package/dist/namespace-helpers-CyIDtI97.cjs +2 -0
  57. package/dist/namespace-helpers-CyIDtI97.cjs.map +1 -0
  58. package/dist/router/types.d.ts +4 -2
  59. package/dist/runtime/css-utils.d.ts +33 -0
  60. package/dist/runtime/discovery-state.d.ts +3 -0
  61. package/dist/runtime/hooks.d.ts +78 -0
  62. package/dist/runtime/jit-hooks.d.ts +28 -0
  63. package/dist/runtime/render-bridge.d.ts +37 -0
  64. package/dist/runtime/scheduler.d.ts +3 -4
  65. package/dist/runtime/secure-expression-evaluator.d.ts +0 -1
  66. package/dist/runtime/style.d.ts +84 -26
  67. package/dist/runtime/template-compiler/lru-cache.d.ts +0 -3
  68. package/dist/runtime/vdom-helpers.d.ts +0 -1
  69. package/dist/ssr.d.ts +42 -0
  70. package/dist/{transitions-DMJXs_tY.js → style-BmyOIMcU.js} +904 -1344
  71. package/dist/style-BmyOIMcU.js.map +1 -0
  72. package/dist/style-D40DsIqJ.cjs +55 -0
  73. package/dist/style-D40DsIqJ.cjs.map +1 -0
  74. package/dist/style.css +1 -1
  75. package/dist/template-compiler-B5uN1EQw.js +3731 -0
  76. package/dist/template-compiler-B5uN1EQw.js.map +1 -0
  77. package/dist/template-compiler-Cx623BSB.cjs +23 -0
  78. package/dist/template-compiler-Cx623BSB.cjs.map +1 -0
  79. package/dist/variables.css +1 -1
  80. package/dist/vite-plugin.d.ts +52 -0
  81. package/package.json +55 -6
  82. package/dist/namespace-helpers-Ctd_h7j2.cjs +0 -5
  83. package/dist/namespace-helpers-Ctd_h7j2.cjs.map +0 -1
  84. package/dist/namespace-helpers-DhLBqt-7.js.map +0 -1
  85. package/dist/template-compiler-CVBKYu3j.js +0 -3991
  86. package/dist/template-compiler-CVBKYu3j.js.map +0 -1
  87. package/dist/template-compiler-G8h2OJbA.cjs +0 -23
  88. package/dist/template-compiler-G8h2OJbA.cjs.map +0 -1
  89. package/dist/transitions-DMJXs_tY.js.map +0 -1
  90. package/dist/transitions-f4KfN29T.cjs +0 -330
  91. package/dist/transitions-f4KfN29T.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { d as E, a as y } from "./logger-BvkEbVM4.js";
2
- function x() {
1
+ import { a as d, d as w } from "./logger-BvkEbVM4.js";
2
+ function N() {
3
3
  const s = (() => {
4
4
  try {
5
5
  return globalThis.process?.env?.NODE_ENV;
@@ -10,10 +10,10 @@ function x() {
10
10
  try {
11
11
  if (typeof window > "u")
12
12
  return { vitest: !1, cypress: !1 };
13
- const n = window;
13
+ const t = window;
14
14
  return {
15
- vitest: !!n.__vitest__,
16
- cypress: !!n.Cypress
15
+ vitest: !!t.__vitest__,
16
+ cypress: !!t.Cypress
17
17
  };
18
18
  } catch {
19
19
  return { vitest: !1, cypress: !1 };
@@ -25,7 +25,7 @@ function x() {
25
25
  isCypress: e.cypress
26
26
  };
27
27
  }
28
- class H {
28
+ class L {
29
29
  pendingUpdates = /* @__PURE__ */ new Map();
30
30
  isFlushScheduled = !1;
31
31
  isFlushing = !1;
@@ -39,15 +39,15 @@ class H {
39
39
  pendingIdleUpdates = /* @__PURE__ */ new Map();
40
40
  idleCallbackHandle = null;
41
41
  constructor() {
42
- this.testEnv = x(), this.schedulePeriodicCleanup();
42
+ this.testEnv = N(), this.schedulePeriodicCleanup();
43
43
  }
44
44
  /**
45
45
  * Schedule an update to be executed in the next microtask
46
46
  * Uses component identity to deduplicate multiple render requests for the same component
47
47
  */
48
- schedule(e, t) {
49
- const n = t || e;
50
- this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(n, e), this.isFlushScheduled || this.scheduleFlush();
48
+ schedule(e, n) {
49
+ const t = n || e;
50
+ this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(t, e), this.isFlushScheduled || this.scheduleFlush();
51
51
  }
52
52
  /**
53
53
  * Schedule the flush operation based on environment
@@ -56,7 +56,6 @@ class H {
56
56
  this.isFlushScheduled = !0, this.testEnv.isTest && !this.isFlushing ? this.flush() : queueMicrotask(() => this.flush());
57
57
  }
58
58
  /**
59
- * Execute all pending updates with priority ordering
60
59
  * Execute all pending updates with priority ordering
61
60
  */
62
61
  flush() {
@@ -66,11 +65,11 @@ class H {
66
65
  const e = this.pendingUpdates;
67
66
  this.pendingUpdates = /* @__PURE__ */ new Map(), this.isFlushScheduled = !1;
68
67
  try {
69
- for (const t of e.values())
68
+ for (const n of e.values())
70
69
  try {
71
- t();
72
- } catch (n) {
73
- E("Error in batched update:", n);
70
+ n();
71
+ } catch (t) {
72
+ w("Error in batched update:", t);
74
73
  }
75
74
  } finally {
76
75
  this.isFlushing = !1;
@@ -119,20 +118,21 @@ class H {
119
118
  */
120
119
  performPeriodicCleanup() {
121
120
  const e = Date.now();
122
- e - this.lastCleanup < this.CLEANUP_INTERVAL || (this.pendingUpdates.size > 100 && y(
121
+ e - this.lastCleanup < this.CLEANUP_INTERVAL || (this.pendingUpdates.size > 100 && d(
123
122
  `Scheduler has ${this.pendingUpdates.size} pending updates. Consider investigating.`
124
123
  ), this.lastCleanup = e);
125
124
  }
126
125
  /**
127
- * Emergency cleanup when pending updates exceed safe limits
126
+ * Emergency cleanup when pending updates exceed safe limits.
127
+ * @param queue - The specific map to trim; defaults to the normal queue.
128
128
  */
129
- performEmergencyCleanup() {
130
- y(
129
+ performEmergencyCleanup(e = this.pendingUpdates) {
130
+ d(
131
131
  "Scheduler emergency cleanup: too many pending updates, clearing oldest entries"
132
132
  );
133
- const e = Array.from(this.pendingUpdates.entries()), t = Math.floor(e.length / 2);
134
- for (let n = 0; n < t; n++)
135
- this.pendingUpdates.delete(e[n][0]);
133
+ const n = Array.from(e.entries()), t = Math.floor(n.length / 2);
134
+ for (let r = 0; r < t; r++)
135
+ e.delete(n[r][0]);
136
136
  }
137
137
  /**
138
138
  * Schedule an update with an explicit priority level.
@@ -149,21 +149,21 @@ class H {
149
149
  * scheduleWithPriority(() => flushAnalytics(), 'idle');
150
150
  * ```
151
151
  */
152
- scheduleWithPriority(e, t = "normal", n) {
153
- if (t === "immediate") {
152
+ scheduleWithPriority(e, n = "normal", t) {
153
+ if (n === "immediate") {
154
154
  try {
155
155
  e();
156
156
  } catch (i) {
157
- E("Error in immediate update:", i);
157
+ w("Error in immediate update:", i);
158
158
  }
159
159
  return;
160
160
  }
161
- if (t === "idle") {
162
- const i = n ?? e;
163
- this.pendingIdleUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingIdleUpdates.set(i, e), this.scheduleIdleFlush();
161
+ if (n === "idle") {
162
+ const i = t ?? e;
163
+ this.pendingIdleUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(this.pendingIdleUpdates), this.pendingIdleUpdates.set(i, e), this.scheduleIdleFlush();
164
164
  return;
165
165
  }
166
- const r = n ?? e;
166
+ const r = t ?? e;
167
167
  this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(r, e), this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
168
168
  }
169
169
  /**
@@ -180,8 +180,8 @@ class H {
180
180
  }
181
181
  if (typeof requestIdleCallback < "u") {
182
182
  const e = requestIdleCallback(
183
- (t) => {
184
- this.idleCallbackHandle = null, this.flushIdleUpdates(t);
183
+ (n) => {
184
+ this.idleCallbackHandle = null, this.flushIdleUpdates(n);
185
185
  },
186
186
  { timeout: 2e3 }
187
187
  );
@@ -203,53 +203,58 @@ class H {
203
203
  * zero and reschedules any unprocessed work.
204
204
  */
205
205
  flushIdleUpdates(e) {
206
- const t = Array.from(this.pendingIdleUpdates.entries());
206
+ const n = Array.from(this.pendingIdleUpdates.entries());
207
207
  this.pendingIdleUpdates = /* @__PURE__ */ new Map();
208
- for (let n = 0; n < t.length; n++) {
208
+ for (let t = 0; t < n.length; t++) {
209
209
  if (e && !e.didTimeout && e.timeRemaining() <= 0) {
210
- for (let r = n; r < t.length; r++)
211
- this.pendingIdleUpdates.set(t[r][0], t[r][1]);
210
+ for (let r = t; r < n.length; r++)
211
+ this.pendingIdleUpdates.set(n[r][0], n[r][1]);
212
212
  this.scheduleIdleFlush();
213
213
  return;
214
214
  }
215
215
  try {
216
- t[n][1]();
216
+ n[t][1]();
217
217
  } catch (r) {
218
- E("Error in idle update:", r);
218
+ w("Error in idle update:", r);
219
219
  }
220
220
  }
221
221
  }
222
222
  }
223
- const h = new H();
224
- function R(s, e) {
225
- h.schedule(s, e);
223
+ const p = new L();
224
+ function x(s, e) {
225
+ p.schedule(s, e);
226
226
  }
227
- function V(s, e = "normal", t) {
228
- h.scheduleWithPriority(s, e, t);
227
+ function V(s, e = "normal", n) {
228
+ p.scheduleWithPriority(s, e, n);
229
229
  }
230
230
  function q() {
231
- h.flushImmediately();
231
+ p.flushImmediately();
232
232
  }
233
233
  function $() {
234
234
  return new Promise((s) => {
235
- h.hasPendingUpdates && h.flushImmediately(), queueMicrotask(s);
235
+ let n = 0;
236
+ for (; p.hasPendingUpdates && n < 100; )
237
+ p.flushImmediately(), n++;
238
+ n >= 100 && d(
239
+ "[nextTick] Maximum flush iterations reached — possible circular update loop. Check for watchers or computed values that unconditionally mutate reactive state."
240
+ ), queueMicrotask(s);
236
241
  });
237
242
  }
238
- const S = /* @__PURE__ */ new WeakSet();
239
- class L {
243
+ const T = /* @__PURE__ */ new WeakSet();
244
+ class P {
240
245
  static cache = /* @__PURE__ */ new WeakMap();
241
246
  static arrayHandlerCache = /* @__PURE__ */ new WeakMap();
242
247
  static objectHandlerCache = /* @__PURE__ */ new WeakMap();
243
248
  /**
244
249
  * Get or create a reactive proxy for an object
245
250
  */
246
- static getOrCreateProxy(e, t, n = !1) {
251
+ static getOrCreateProxy(e, n, t = !1) {
247
252
  const r = this.cache.get(e);
248
253
  if (r)
249
254
  return r;
250
- const i = n ? this.getOrCreateArrayHandler(t) : this.getOrCreateObjectHandler(t), a = new Proxy(e, i);
255
+ const i = t ? this.getOrCreateArrayHandler(n) : this.getOrCreateObjectHandler(n), a = new Proxy(e, i);
251
256
  try {
252
- v.markAsProxy(a);
257
+ A.markAsProxy(a);
253
258
  } catch {
254
259
  }
255
260
  return this.cache.set(e, a), a;
@@ -259,9 +264,9 @@ class L {
259
264
  */
260
265
  static getOrCreateArrayHandler(e) {
261
266
  if (!this.arrayHandlerCache.has(e)) {
262
- const t = {
263
- get: (n, r, i) => {
264
- const a = Reflect.get(n, r, i);
267
+ const n = {
268
+ get: (t, r, i) => {
269
+ const a = Reflect.get(t, r, i);
265
270
  return typeof a == "function" && typeof r == "string" && [
266
271
  "push",
267
272
  "pop",
@@ -272,15 +277,15 @@ class L {
272
277
  "reverse",
273
278
  "fill",
274
279
  "copyWithin"
275
- ].includes(r) ? function(...u) {
276
- const d = a.apply(n, u);
277
- return e.triggerUpdate(), d;
280
+ ].includes(r) ? function(...l) {
281
+ const h = a.apply(t, l);
282
+ return e.triggerUpdate(), h;
278
283
  } : a !== null && typeof a == "object" && typeof r == "string" ? e.makeReactiveValue(a) : a;
279
284
  },
280
- set: (n, r, i) => (n[r] = e.makeReactiveValue(i), e.triggerUpdate(), !0),
281
- deleteProperty: (n, r) => (delete n[r], e.triggerUpdate(), !0)
285
+ set: (t, r, i) => (t[r] = e.makeReactiveValue(i), e.triggerUpdate(), !0),
286
+ deleteProperty: (t, r) => (delete t[r], e.triggerUpdate(), !0)
282
287
  };
283
- this.arrayHandlerCache.set(e, t);
288
+ this.arrayHandlerCache.set(e, n);
284
289
  }
285
290
  return this.arrayHandlerCache.get(e);
286
291
  }
@@ -289,15 +294,15 @@ class L {
289
294
  */
290
295
  static getOrCreateObjectHandler(e) {
291
296
  if (!this.objectHandlerCache.has(e)) {
292
- const t = {
293
- get: (n, r, i) => {
294
- const a = Reflect.get(n, r, i);
297
+ const n = {
298
+ get: (t, r, i) => {
299
+ const a = Reflect.get(t, r, i);
295
300
  return a !== null && typeof a == "object" && typeof r == "string" ? e.makeReactiveValue(a) : a;
296
301
  },
297
- set: (n, r, i) => (n[r] = e.makeReactiveValue(i), e.triggerUpdate(), !0),
298
- deleteProperty: (n, r) => (delete n[r], e.triggerUpdate(), !0)
302
+ set: (t, r, i) => (t[r] = e.makeReactiveValue(i), e.triggerUpdate(), !0),
303
+ deleteProperty: (t, r) => (delete t[r], e.triggerUpdate(), !0)
299
304
  };
300
- this.objectHandlerCache.set(e, t);
305
+ this.objectHandlerCache.set(e, n);
301
306
  }
302
307
  return this.objectHandlerCache.get(e);
303
308
  }
@@ -323,7 +328,7 @@ class L {
323
328
  };
324
329
  }
325
330
  }
326
- class v {
331
+ class A {
327
332
  // Cache a stable reactiveContext object keyed by onUpdate -> makeReactive
328
333
  // This allows handler caches in ReactiveProxyCache to reuse handlers
329
334
  // for identical reactive contexts instead of creating a new context object
@@ -332,19 +337,19 @@ class v {
332
337
  /**
333
338
  * Create an optimized reactive proxy with minimal overhead
334
339
  */
335
- static createReactiveProxy(e, t, n) {
340
+ static createReactiveProxy(e, n, t) {
336
341
  try {
337
- if (S.has(e)) return e;
342
+ if (T.has(e)) return e;
338
343
  } catch {
339
344
  }
340
345
  const r = Array.isArray(e);
341
- let i = this.contextCache.get(t);
342
- i || (i = /* @__PURE__ */ new WeakMap(), this.contextCache.set(t, i));
343
- let a = i.get(n);
346
+ let i = this.contextCache.get(n);
347
+ i || (i = /* @__PURE__ */ new WeakMap(), this.contextCache.set(n, i));
348
+ let a = i.get(t);
344
349
  return a || (a = {
345
- triggerUpdate: t,
346
- makeReactiveValue: n
347
- }, i.set(n, a)), L.getOrCreateProxy(e, a, r);
350
+ triggerUpdate: n,
351
+ makeReactiveValue: t
352
+ }, i.set(t, a)), P.getOrCreateProxy(e, a, r);
348
353
  }
349
354
  /**
350
355
  * Mark an object as a proxy (for optimization)
@@ -352,22 +357,28 @@ class v {
352
357
  static markAsProxy(e) {
353
358
  if (e)
354
359
  try {
355
- S.add(e);
360
+ T.add(e);
356
361
  } catch {
357
362
  }
358
363
  }
359
364
  }
360
- let _ = !1;
361
- function D() {
362
- return _;
365
+ let C = !1;
366
+ function R() {
367
+ return C;
368
+ }
369
+ function X() {
370
+ C && d(
371
+ "[CER] beginDiscoveryRender() called while a discovery render is already active. This usually means a component was registered inside another component's render function. Ensure component() calls are at module top-level."
372
+ ), C = !0;
363
373
  }
364
374
  function G() {
365
- _ = !0;
375
+ C = !1;
366
376
  }
367
- function Z() {
368
- _ = !1;
377
+ let F = 0;
378
+ function S(s) {
379
+ return `${s}-${++F}`;
369
380
  }
370
- class P {
381
+ class W {
371
382
  // Use a stack to support nested callers (component render -> watcher)
372
383
  // so that watchers can temporarily become the "current component" while
373
384
  // establishing dependencies without clobbering the outer component id.
@@ -380,26 +391,26 @@ class P {
380
391
  /**
381
392
  * Set the current component being rendered for dependency tracking
382
393
  */
383
- setCurrentComponent(e, t) {
394
+ setCurrentComponent(e, n) {
384
395
  if (this.currentComponentStack.push(e), !this.componentData.has(e))
385
396
  this.componentData.set(e, {
386
397
  dependencies: /* @__PURE__ */ new Set(),
387
- renderFn: t,
398
+ renderFn: n,
388
399
  stateIndex: 0,
389
400
  lastWarnTime: 0,
390
401
  watchers: /* @__PURE__ */ new Map()
391
402
  });
392
403
  else {
393
- const n = this.componentData.get(e);
394
- if (n.watchers && n.watchers.size) {
395
- for (const r of n.watchers.values())
404
+ const t = this.componentData.get(e);
405
+ if (t.watchers && t.watchers.size) {
406
+ for (const r of t.watchers.values())
396
407
  try {
397
408
  this.cleanup(r);
398
409
  } catch {
399
410
  }
400
- n.watchers.clear();
411
+ t.watchers.clear();
401
412
  }
402
- n.renderFn = t, n.stateIndex = 0;
413
+ t.renderFn = n, t.stateIndex = 0;
403
414
  }
404
415
  }
405
416
  /**
@@ -417,9 +428,9 @@ class P {
417
428
  /**
418
429
  * Register a watcher id under a component so it can be cleaned up on re-render
419
430
  */
420
- registerWatcher(e, t) {
421
- const n = this.componentData.get(e);
422
- n && n.watchers.set(t, t);
431
+ registerWatcher(e, n) {
432
+ const t = this.componentData.get(e);
433
+ t && t.watchers.set(n, n);
423
434
  }
424
435
  /**
425
436
  * Temporarily disable dependency tracking
@@ -446,46 +457,46 @@ class P {
446
457
  shouldEmitRenderWarning() {
447
458
  const e = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
448
459
  if (!e) return !0;
449
- const t = this.componentData.get(e);
450
- if (!t) return !0;
451
- const n = Date.now();
452
- return n - t.lastWarnTime < 1e3 ? !1 : (t.lastWarnTime = n, !0);
460
+ const n = this.componentData.get(e);
461
+ if (!n) return !0;
462
+ const t = Date.now();
463
+ return t - n.lastWarnTime < 1e3 ? !1 : (n.lastWarnTime = t, !0);
453
464
  }
454
465
  /**
455
466
  * Execute a function with tracking disabled
456
467
  */
457
468
  withoutTracking(e) {
458
- const t = this.trackingDisabled;
469
+ const n = this.trackingDisabled;
459
470
  this.trackingDisabled = !0;
460
471
  try {
461
472
  return e();
462
473
  } finally {
463
- this.trackingDisabled = t;
474
+ this.trackingDisabled = n;
464
475
  }
465
476
  }
466
477
  /**
467
478
  * Get or create a state instance for the current component
468
479
  */
469
480
  getOrCreateState(e) {
470
- const t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
471
- if (!t)
472
- return new k(e);
473
- const n = this.componentData.get(t);
481
+ const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
474
482
  if (!n)
475
- return new k(e);
476
- const r = `${t}:${n.stateIndex++}`;
483
+ return new _(e);
484
+ const t = this.componentData.get(n);
485
+ if (!t)
486
+ return new _(e);
487
+ const r = `${n}:${t.stateIndex++}`;
477
488
  let i = this.stateStorage.get(r);
478
- return i || (i = new k(e), this.stateStorage.set(r, i)), i;
489
+ return i || (i = new _(e), this.stateStorage.set(r, i)), i;
479
490
  }
480
491
  /**
481
492
  * Track a dependency for the current component
482
493
  */
483
494
  trackDependency(e) {
484
495
  if (this.trackingDisabled) return;
485
- const t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
486
- if (!t) return;
487
- const n = this.componentData.get(t);
488
- n && (n.dependencies.add(e), e.addDependent(t));
496
+ const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
497
+ if (!n) return;
498
+ const t = this.componentData.get(n);
499
+ t && (t.dependencies.add(e), e.addDependent(n));
489
500
  }
490
501
  /**
491
502
  * Re-register all reactive dependencies that `fromId` tracks into the
@@ -496,42 +507,42 @@ class P {
496
507
  */
497
508
  propagateDependencies(e) {
498
509
  if (this.trackingDisabled) return;
499
- const t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
500
- if (!t || t === e) return;
501
- const n = this.componentData.get(e);
502
- if (!n) return;
503
- const r = this.componentData.get(t);
510
+ const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
511
+ if (!n || n === e) return;
512
+ const t = this.componentData.get(e);
513
+ if (!t) return;
514
+ const r = this.componentData.get(n);
504
515
  if (r)
505
- for (const i of n.dependencies)
506
- r.dependencies.add(i), i.addDependent(t);
516
+ for (const i of t.dependencies)
517
+ r.dependencies.add(i), i.addDependent(n);
507
518
  }
508
519
  /**
509
520
  * Trigger updates for all components that depend on a state
510
521
  */
511
522
  triggerUpdate(e) {
512
- const t = e.getDependents();
513
- for (const n of t) {
514
- const r = this.componentData.get(n);
515
- r && R(r.renderFn, n);
523
+ const n = e.getDependents();
524
+ for (const t of n) {
525
+ const r = this.componentData.get(t);
526
+ r && x(r.renderFn, t);
516
527
  }
517
528
  }
518
529
  /**
519
530
  * Clean up component dependencies when component is destroyed
520
531
  */
521
532
  cleanup(e) {
522
- const t = this.componentData.get(e);
523
- if (t) {
524
- for (const r of t.dependencies)
533
+ const n = this.componentData.get(e);
534
+ if (n) {
535
+ for (const r of n.dependencies)
525
536
  r.removeDependent(e);
526
537
  this.componentData.delete(e);
527
538
  }
528
- const n = e + ":";
539
+ const t = e + ":";
529
540
  for (const r of this.stateStorage.keys())
530
- r.startsWith(n) && this.stateStorage.delete(r);
541
+ r.startsWith(t) && this.stateStorage.delete(r);
531
542
  }
532
543
  }
533
- const c = new P();
534
- class k {
544
+ const c = new W();
545
+ class _ {
535
546
  _value;
536
547
  /** The unwrapped value last assigned — used for Object.is equality checks. */
537
548
  _rawValue;
@@ -551,7 +562,7 @@ class k {
551
562
  return c.trackDependency(this), this._value;
552
563
  }
553
564
  set value(e) {
554
- Object.is(e, this._rawValue) || (c.isRenderingComponent() && c.shouldEmitRenderWarning() && y(
565
+ Object.is(e, this._rawValue) || (c.isRenderingComponent() && c.shouldEmitRenderWarning() && d(
555
566
  `🚨 State modification detected during render! This can cause infinite loops.
556
567
  • Move state updates to event handlers
557
568
  • Use watchEffect/watch for side effects
@@ -588,19 +599,19 @@ class k {
588
599
  return this.dependents;
589
600
  }
590
601
  makeReactive(e) {
591
- return e === null || typeof e != "object" || e instanceof Node || e instanceof Element || e instanceof HTMLElement ? e : v.createReactiveProxy(
602
+ return e === null || typeof e != "object" || e instanceof Node || e instanceof Element || e instanceof HTMLElement ? e : A.createReactiveProxy(
592
603
  e,
593
604
  () => c.triggerUpdate(this),
594
- (t) => this.makeReactive(t)
605
+ (n) => this.makeReactive(n)
595
606
  );
596
607
  }
597
608
  }
598
- function X(s) {
609
+ function Z(s) {
599
610
  return c.getOrCreateState(
600
611
  s === void 0 ? null : s
601
612
  );
602
613
  }
603
- function w(s) {
614
+ function E(s) {
604
615
  if (!s || typeof s != "object") return !1;
605
616
  try {
606
617
  const e = /* @__PURE__ */ Symbol.for("@cer/ReactiveState");
@@ -610,69 +621,78 @@ function w(s) {
610
621
  }
611
622
  }
612
623
  function B(s) {
613
- let e, t = !0;
614
- const n = `computed-${crypto.randomUUID()}`, r = () => {
615
- t = !0;
624
+ let e, n = !0;
625
+ const t = S("computed"), r = () => {
626
+ n = !0;
616
627
  };
617
628
  try {
618
629
  const i = c.getCurrentComponentId();
619
- i && c.registerWatcher(i, n);
630
+ i && c.registerWatcher(i, t);
620
631
  } catch {
621
632
  }
622
- return c.setCurrentComponent(n, r), e = s(), c.clearCurrentComponent(), t = !1, {
633
+ return c.setCurrentComponent(t, r), e = s(), c.clearCurrentComponent(), n = !1, {
623
634
  get value() {
624
- return t && (c.setCurrentComponent(n, r), e = s(), c.clearCurrentComponent(), t = !1), c.propagateDependencies(n), e;
635
+ return n && (c.setCurrentComponent(t, r), e = s(), c.clearCurrentComponent(), n = !1), c.propagateDependencies(t), e;
625
636
  }
626
637
  };
627
638
  }
628
639
  function K(s) {
629
- if (D()) return () => {
640
+ if (R()) return () => {
630
641
  };
631
- const e = `effect-${crypto.randomUUID()}`;
642
+ const e = S("effect");
632
643
  try {
633
- const n = c.getCurrentComponentId();
634
- n && c.registerWatcher(n, e);
644
+ const t = c.getCurrentComponentId();
645
+ t && c.registerWatcher(t, e);
635
646
  } catch {
636
647
  }
637
- const t = () => {
638
- c.setCurrentComponent(e, t);
648
+ const n = () => {
649
+ c.setCurrentComponent(e, n);
639
650
  try {
640
651
  s();
641
652
  } finally {
642
653
  c.clearCurrentComponent();
643
654
  }
644
655
  };
645
- return t(), () => {
656
+ return n(), () => {
646
657
  c.cleanup(e);
647
658
  };
648
659
  }
649
- function C(s, e = /* @__PURE__ */ new WeakMap()) {
660
+ const b = 50;
661
+ function k(s, e = /* @__PURE__ */ new WeakMap(), n = 0) {
650
662
  if (s === null || typeof s != "object") return s;
651
663
  const t = s;
652
664
  if (e.has(t)) return e.get(t);
665
+ if (n > b)
666
+ return d(
667
+ `[watch] Deep clone exceeded ${b} nesting levels. Returning a reference at this depth instead of cloning further. Consider restructuring your state or switching to a shallow watch.`
668
+ ), s;
653
669
  if (typeof Node < "u" && t instanceof Node) return s;
654
670
  if (t instanceof Date) return new Date(t.getTime());
655
671
  if (Array.isArray(t)) {
656
- const r = [];
657
- e.set(t, r);
658
- for (let i = 0; i < t.length; i++)
659
- r.push(C(t[i], e));
660
- return r;
661
- }
662
- const n = {};
663
- e.set(t, n);
664
- for (const r of Object.keys(t))
672
+ const i = [];
673
+ e.set(t, i);
674
+ for (let a = 0; a < t.length; a++)
675
+ i.push(k(t[a], e, n + 1));
676
+ return i;
677
+ }
678
+ const r = {};
679
+ e.set(t, r);
680
+ for (const i of Object.keys(t))
665
681
  try {
666
- n[r] = C(t[r], e);
682
+ r[i] = k(
683
+ t[i],
684
+ e,
685
+ n + 1
686
+ );
667
687
  } catch {
668
688
  }
669
- return n;
689
+ return r;
670
690
  }
671
- function J(s, e, t) {
672
- if (D()) return () => {
691
+ function J(s, e, n) {
692
+ if (R()) return () => {
673
693
  };
674
- let n;
675
- const r = w(s) ? () => s.value : s, i = `watch-${crypto.randomUUID()}`;
694
+ let t;
695
+ const r = E(s) ? () => s.value : s, i = S("watch");
676
696
  try {
677
697
  const o = c.getCurrentComponentId();
678
698
  o && c.registerWatcher(o, i);
@@ -681,14 +701,14 @@ function J(s, e, t) {
681
701
  const a = () => {
682
702
  c.setCurrentComponent(i, a);
683
703
  const o = r();
684
- if (c.clearCurrentComponent(), t?.deep) {
685
- const u = c.withoutTracking(
686
- () => C(o)
704
+ if (c.clearCurrentComponent(), n?.deep) {
705
+ const l = c.withoutTracking(
706
+ () => k(o)
687
707
  );
688
- e(u, n), n = u;
689
- } else o !== n && (e(o, n), n = o);
708
+ e(l, t), t = l;
709
+ } else o !== t && (e(o, t), t = o);
690
710
  };
691
- return c.setCurrentComponent(i, a), n = r(), c.clearCurrentComponent(), t?.deep && (n = c.withoutTracking(() => C(n))), t && t.immediate && e(n, void 0), () => {
711
+ return c.setCurrentComponent(i, a), t = r(), c.clearCurrentComponent(), n?.deep && (t = c.withoutTracking(() => k(t))), n && n.immediate && e(t, void 0), () => {
692
712
  c.cleanup(i);
693
713
  };
694
714
  }
@@ -697,60 +717,60 @@ const Q = (s) => {
697
717
  s();
698
718
  } catch {
699
719
  }
700
- }, f = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), b = 500;
701
- let p, U, M = !1, A = !1, T;
702
- const W = !!globalThis.process?.versions?.node;
720
+ }, g = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), M = 500;
721
+ let f, U, v = !1, D = !1, I;
722
+ const O = !!globalThis.process?.versions?.node;
703
723
  function Y(s) {
704
- if (f.has(s))
705
- return f.get(s);
724
+ if (g.has(s))
725
+ return g.get(s);
706
726
  const e = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
707
- return f.size < b && f.set(s, e), e;
727
+ return g.size < M && g.set(s, e), e;
708
728
  }
709
729
  function ee(s) {
710
- if (g.has(s))
711
- return g.get(s);
712
- const e = s.replace(/-([a-z])/g, (t, n) => n.toUpperCase());
713
- return g.size < b && g.set(s, e), e;
730
+ if (m.has(s))
731
+ return m.get(s);
732
+ const e = s.replace(/-([a-z])/g, (n, t) => t.toUpperCase());
733
+ return m.size < M && m.set(s, e), e;
714
734
  }
715
735
  function te(s) {
716
736
  if (typeof s == "string") {
717
- if (m.has(s))
718
- return m.get(s);
737
+ if (y.has(s))
738
+ return y.get(s);
719
739
  const e = s.replace(
720
740
  /[&<>"']/g,
721
- (t) => ({
741
+ (n) => ({
722
742
  "&": "&amp;",
723
743
  "<": "&lt;",
724
744
  ">": "&gt;",
725
745
  '"': "&quot;",
726
746
  "'": "&#39;"
727
- })[t]
747
+ })[n]
728
748
  );
729
- return e !== s && m.size < b && m.set(s, e), e;
749
+ return e !== s && y.size < M && y.set(s, e), e;
730
750
  }
731
751
  return s;
732
752
  }
733
- function l(s) {
753
+ function u(s) {
734
754
  if (!s) return "";
735
755
  const e = String(s);
736
756
  if (typeof document < "u" && typeof document.createElement == "function") {
737
- const o = e.replace(/</g, "").replace(/>/g, ""), u = T || (T = document.createElement("div"));
757
+ const o = e.replace(/</g, "").replace(/>/g, ""), l = I || (I = document.createElement("div"));
738
758
  try {
739
- l._el = u;
759
+ u._el = l;
740
760
  } catch {
741
761
  }
742
- return u.innerHTML = o, (u.textContent || "").replace(new RegExp("", "g"), "<").replace(new RegExp("", "g"), ">");
762
+ return l.innerHTML = o, (l.textContent || "").replace(new RegExp("", "g"), "<").replace(new RegExp("", "g"), ">");
743
763
  }
744
- const t = {
764
+ const n = {
745
765
  lt: "<",
746
766
  gt: ">",
747
767
  amp: "&",
748
768
  quot: '"',
749
769
  apos: "'",
750
770
  nbsp: " "
751
- }, n = p ?? l._namedMap;
752
- let r = n;
753
- if (!r && W)
771
+ }, t = f ?? u._namedMap;
772
+ let r = t;
773
+ if (!r && O)
754
774
  try {
755
775
  const i = globalThis.require;
756
776
  if (typeof i == "function") {
@@ -766,9 +786,9 @@ function l(s) {
766
786
  ];
767
787
  for (const o of a)
768
788
  try {
769
- const u = i(o);
770
- if (u && typeof u == "object") {
771
- r = u;
789
+ const l = i(o);
790
+ if (l && typeof l == "object") {
791
+ r = l;
772
792
  break;
773
793
  }
774
794
  } catch {
@@ -777,29 +797,29 @@ function l(s) {
777
797
  } catch {
778
798
  }
779
799
  if (!r) {
780
- r = t, M = !0;
800
+ r = n, v = !0;
781
801
  try {
782
- l._usedFallback = !0;
802
+ u._usedFallback = !0;
783
803
  } catch {
784
804
  }
785
- const i = l._namedMapLoader ?? U;
805
+ const i = u._namedMapLoader ?? U;
786
806
  i && i().then((a) => {
787
- p = a;
807
+ f = a;
788
808
  try {
789
- l._namedMap = a;
809
+ u._namedMap = a;
790
810
  } catch {
791
811
  }
792
812
  }).catch(() => {
793
813
  });
794
814
  }
795
- if ((M || l._usedFallback) && !(A || l._warnedFallback)) {
796
- A = !0;
815
+ if ((v || u._usedFallback) && !(D || u._warnedFallback)) {
816
+ D = !0;
797
817
  try {
798
- l._warnedFallback = !0;
818
+ u._warnedFallback = !0;
799
819
  } catch {
800
820
  }
801
821
  try {
802
- y(
822
+ d(
803
823
  "decodeEntities: using small SSR fallback entity map. Register the full entities.json via registerEntityMap(entities) on the server to enable full HTML5 named-entity decoding."
804
824
  );
805
825
  } catch {
@@ -807,14 +827,14 @@ function l(s) {
807
827
  }
808
828
  return e.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (i, a) => {
809
829
  if (a.charCodeAt(0) === 35) {
810
- const d = (a.charAt(1) || "").toLowerCase() === "x" ? parseInt(a.slice(2), 16) : parseInt(a.slice(1), 10);
811
- return Number.isNaN(d) ? `&${a};` : String.fromCodePoint(d);
830
+ const h = (a.charAt(1) || "").toLowerCase() === "x" ? parseInt(a.slice(2), 16) : parseInt(a.slice(1), 10);
831
+ return Number.isNaN(h) ? `&${a};` : String.fromCodePoint(h);
812
832
  }
813
- const o = r[a] ?? (n && n[a]);
833
+ const o = r[a] ?? (t && t[a]);
814
834
  return o !== void 0 ? o : `&${a};`;
815
835
  });
816
836
  }
817
- async function I() {
837
+ async function H() {
818
838
  const s = [
819
839
  "@jasonshimmy",
820
840
  "custom-elements-runtime",
@@ -835,14 +855,14 @@ async function I() {
835
855
  "../../entities.json",
836
856
  "../../../entities.json"
837
857
  ];
838
- for (const t of e)
858
+ for (const n of e)
839
859
  try {
840
- const n = await import(
860
+ const t = await import(
841
861
  /* @vite-ignore */
842
- t
862
+ n
843
863
  );
844
- if (n)
845
- return n && (n.default || n);
864
+ if (t)
865
+ return t && (t.default || t);
846
866
  } catch {
847
867
  }
848
868
  return {
@@ -865,13 +885,13 @@ async function I() {
865
885
  }
866
886
  }
867
887
  }
868
- U = I;
869
- l._namedMapLoader = I;
888
+ U = H;
889
+ u._namedMapLoader = H;
870
890
  function ne(s, e) {
871
- !s || typeof s != "object" || p && !e?.overwrite || (p = s);
891
+ !s || typeof s != "object" || f && !e?.overwrite || (f = s);
872
892
  }
873
893
  function se() {
874
- p = void 0;
894
+ f = void 0;
875
895
  }
876
896
  function re(s) {
877
897
  const e = String(s);
@@ -883,32 +903,32 @@ function ie(s) {
883
903
  function ae(s, e) {
884
904
  if (typeof e == "string") {
885
905
  if (e === "") return;
886
- const t = e.split(".");
887
- let n = s;
888
- for (const r of t) {
889
- if (n == null || typeof n != "object") {
890
- n = void 0;
906
+ const n = e.split(".");
907
+ let t = s;
908
+ for (const r of n) {
909
+ if (t == null || typeof t != "object") {
910
+ t = void 0;
891
911
  break;
892
912
  }
893
- n = n[r];
913
+ t = t[r];
894
914
  }
895
- return w(n) ? n.value : n;
915
+ return E(t) ? t.value : t;
896
916
  }
897
917
  return e;
898
918
  }
899
- function ce(s, e, t) {
900
- const n = String(e).split("."), r = n.pop();
919
+ function ce(s, e, n) {
920
+ const t = String(e).split("."), r = t.pop();
901
921
  if (!r) return;
902
- const i = n.reduce(
922
+ const i = t.reduce(
903
923
  (a, o) => (a[o] == null && (a[o] = {}), a[o]),
904
924
  s
905
925
  );
906
- w(i[r]) ? i[r].value = t : i[r] = t;
926
+ E(i[r]) ? i[r].value = n : i[r] = n;
907
927
  }
908
- function F(s) {
928
+ function j(s) {
909
929
  try {
910
930
  if (s && typeof s == "object") {
911
- if (w(s)) return s.value;
931
+ if (E(s)) return s.value;
912
932
  if ("value" in s) {
913
933
  const e = s.value;
914
934
  return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : s;
@@ -919,91 +939,49 @@ function F(s) {
919
939
  return s;
920
940
  }
921
941
  function oe(s) {
922
- const e = F(s);
942
+ const e = j(s);
923
943
  if (e == null) return null;
924
- const t = typeof e;
925
- return t === "string" || t === "number" || t === "boolean" ? String(e) : null;
944
+ const n = typeof e;
945
+ return n === "string" || n === "number" || n === "boolean" ? String(e) : null;
926
946
  }
927
- function ue(s) {
947
+ function le(s) {
928
948
  if (!s || typeof s != "string") return !1;
929
949
  if (s === "class" || s.endsWith("Class")) return !0;
930
950
  if (s.includes("-"))
931
951
  try {
932
- if (s.split("-").some((t) => t === "class")) return !0;
952
+ if (s.split("-").some((n) => n === "class")) return !0;
933
953
  } catch {
934
954
  }
935
955
  return !1;
936
956
  }
937
- const N = {
938
- xlink: "http://www.w3.org/1999/xlink",
939
- xml: "http://www.w3.org/XML/1998/namespace"
940
- };
941
- function le(s, e, t) {
942
- try {
943
- if (!e || !e.includes(":")) {
944
- s.setAttribute(e, t);
945
- return;
946
- }
947
- const n = e.indexOf(":"), r = e.substring(0, n), i = e.substring(n + 1), a = N[r];
948
- a ? s.setAttributeNS(a, i, t) : s.setAttribute(e, t);
949
- } catch {
950
- try {
951
- s.setAttribute(e, t);
952
- } catch {
953
- }
954
- }
955
- }
956
- function de(s, e) {
957
- try {
958
- if (!e || !e.includes(":")) {
959
- s.removeAttribute(e);
960
- return;
961
- }
962
- const t = e.indexOf(":"), n = e.substring(0, t), r = e.substring(t + 1), i = N[n];
963
- i ? s.removeAttributeNS(i, r) : s.removeAttribute(e);
964
- } catch {
965
- try {
966
- s.removeAttribute(e);
967
- } catch {
968
- }
969
- }
970
- }
971
- const j = "http://www.w3.org/2000/svg", O = "http://www.w3.org/1998/Math/MathML", he = {
972
- svg: j,
973
- math: O
974
- };
975
957
  export {
976
- G as A,
977
- Z as B,
978
- ie as C,
979
- k as R,
980
- j as S,
981
- he as T,
958
+ R as A,
959
+ _ as R,
982
960
  c as a,
983
961
  K as b,
984
962
  B as c,
985
- l as d,
963
+ u as d,
986
964
  te as e,
987
965
  q as f,
988
966
  se as g,
989
967
  ne as h,
990
- w as i,
968
+ E as i,
991
969
  ae as j,
992
970
  ce as k,
993
- I as l,
971
+ H as l,
994
972
  Q as m,
995
973
  $ as n,
996
974
  oe as o,
997
- le as p,
998
- de as q,
999
- X as r,
975
+ ee as p,
976
+ le as q,
977
+ Z as r,
1000
978
  V as s,
1001
979
  Y as t,
1002
980
  re as u,
1003
- ee as v,
981
+ x as v,
1004
982
  J as w,
1005
- ue as x,
1006
- R as y,
1007
- D as z
983
+ X as x,
984
+ G as y,
985
+ ie as z
1008
986
  };
1009
- //# sourceMappingURL=namespace-helpers-DhLBqt-7.js.map
987
+ //# sourceMappingURL=helpers-CweFZFWU.js.map