@jasonshimmy/custom-elements-runtime 3.2.0 → 3.2.1

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 (105) hide show
  1. package/dist/{css-utils-Cg4o1MqY.js → css-utils-CC43BbEy.js} +20 -21
  2. package/dist/css-utils-CC43BbEy.js.map +1 -0
  3. package/dist/{css-utils-RqkyBWft.cjs → css-utils-mgjmH8qX.cjs} +5 -4
  4. package/dist/css-utils-mgjmH8qX.cjs.map +1 -0
  5. package/dist/custom-elements-runtime.cjs.js +4 -3
  6. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  7. package/dist/custom-elements-runtime.colors.cjs.js +3 -2
  8. package/dist/custom-elements-runtime.colors.cjs.js.map +1 -1
  9. package/dist/custom-elements-runtime.colors.es.js +3 -2
  10. package/dist/custom-elements-runtime.colors.es.js.map +1 -1
  11. package/dist/custom-elements-runtime.directive-enhancements.cjs.js +3 -2
  12. package/dist/custom-elements-runtime.directive-enhancements.cjs.js.map +1 -1
  13. package/dist/custom-elements-runtime.directive-enhancements.es.js +86 -100
  14. package/dist/custom-elements-runtime.directive-enhancements.es.js.map +1 -1
  15. package/dist/custom-elements-runtime.directives.cjs.js +3 -2
  16. package/dist/custom-elements-runtime.directives.cjs.js.map +1 -1
  17. package/dist/custom-elements-runtime.directives.es.js +40 -43
  18. package/dist/custom-elements-runtime.directives.es.js.map +1 -1
  19. package/dist/custom-elements-runtime.dom-jit-css.cjs.js +7 -6
  20. package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -1
  21. package/dist/custom-elements-runtime.dom-jit-css.es.js +58 -76
  22. package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -1
  23. package/dist/custom-elements-runtime.es.js +162 -186
  24. package/dist/custom-elements-runtime.es.js.map +1 -1
  25. package/dist/custom-elements-runtime.event-bus.cjs.js +3 -2
  26. package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
  27. package/dist/custom-elements-runtime.event-bus.es.js +48 -103
  28. package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
  29. package/dist/custom-elements-runtime.jit-css.cjs.js +3 -2
  30. package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -1
  31. package/dist/custom-elements-runtime.jit-css.es.js +29 -30
  32. package/dist/custom-elements-runtime.jit-css.es.js.map +1 -1
  33. package/dist/custom-elements-runtime.router.cjs.js +20 -19
  34. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  35. package/dist/custom-elements-runtime.router.es.js +585 -603
  36. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  37. package/dist/custom-elements-runtime.ssr-middleware.cjs.js +5 -4
  38. package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -1
  39. package/dist/custom-elements-runtime.ssr-middleware.es.js +44 -37
  40. package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -1
  41. package/dist/custom-elements-runtime.ssr.cjs.js +1 -4
  42. package/dist/custom-elements-runtime.ssr.es.js +11 -176
  43. package/dist/custom-elements-runtime.store.cjs.js +3 -2
  44. package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
  45. package/dist/custom-elements-runtime.store.es.js +17 -11
  46. package/dist/custom-elements-runtime.store.es.js.map +1 -1
  47. package/dist/custom-elements-runtime.transitions.cjs.js +3 -2
  48. package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
  49. package/dist/custom-elements-runtime.transitions.es.js +55 -120
  50. package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
  51. package/dist/custom-elements-runtime.vite-plugin.cjs.js +3 -2
  52. package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -1
  53. package/dist/custom-elements-runtime.vite-plugin.es.js +54 -75
  54. package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -1
  55. package/dist/hooks-_3xP4G2N.js +1189 -0
  56. package/dist/hooks-_3xP4G2N.js.map +1 -0
  57. package/dist/hooks-fYQgZk2g.cjs +7 -0
  58. package/dist/hooks-fYQgZk2g.cjs.map +1 -0
  59. package/dist/logger-BYIN7ysT.cjs +3 -0
  60. package/dist/logger-BYIN7ysT.cjs.map +1 -0
  61. package/dist/logger-L25axmB-.js +41 -0
  62. package/dist/logger-L25axmB-.js.map +1 -0
  63. package/dist/namespace-helpers-Bf7rm9JV.cjs +3 -0
  64. package/dist/namespace-helpers-Bf7rm9JV.cjs.map +1 -0
  65. package/dist/namespace-helpers-BucDdgz_.js +61 -0
  66. package/dist/namespace-helpers-BucDdgz_.js.map +1 -0
  67. package/dist/reset.css +1 -1
  68. package/dist/ssr-B3lxl1vr.js +165 -0
  69. package/dist/ssr-B3lxl1vr.js.map +1 -0
  70. package/dist/ssr-DtD9e5iA.cjs +5 -0
  71. package/dist/ssr-DtD9e5iA.cjs.map +1 -0
  72. package/dist/style-Bjn8zDiZ.cjs +56 -0
  73. package/dist/style-Bjn8zDiZ.cjs.map +1 -0
  74. package/dist/{style-BmyOIMcU.js → style-DuDoj_xK.js} +724 -876
  75. package/dist/style-DuDoj_xK.js.map +1 -0
  76. package/dist/style.css +1 -1
  77. package/dist/template-compiler-BB4JJdqk.cjs +23 -0
  78. package/dist/template-compiler-BB4JJdqk.cjs.map +1 -0
  79. package/dist/template-compiler-Cs5axmn4.js +3236 -0
  80. package/dist/template-compiler-Cs5axmn4.js.map +1 -0
  81. package/dist/variables.css +1 -1
  82. package/package.json +7 -7
  83. package/dist/css-utils-Cg4o1MqY.js.map +0 -1
  84. package/dist/css-utils-RqkyBWft.cjs.map +0 -1
  85. package/dist/custom-elements-runtime.ssr.cjs.js.map +0 -1
  86. package/dist/custom-elements-runtime.ssr.es.js.map +0 -1
  87. package/dist/hooks-BH-CpUun.js +0 -1474
  88. package/dist/hooks-BH-CpUun.js.map +0 -1
  89. package/dist/hooks-NOFG9QRQ.cjs +0 -6
  90. package/dist/hooks-NOFG9QRQ.cjs.map +0 -1
  91. package/dist/logger-BvkEbVM4.js +0 -48
  92. package/dist/logger-BvkEbVM4.js.map +0 -1
  93. package/dist/logger-CSALKaYm.cjs +0 -2
  94. package/dist/logger-CSALKaYm.cjs.map +0 -1
  95. package/dist/namespace-helpers-D4wC2-qA.js +0 -61
  96. package/dist/namespace-helpers-D4wC2-qA.js.map +0 -1
  97. package/dist/namespace-helpers-ckeEOxpR.cjs +0 -2
  98. package/dist/namespace-helpers-ckeEOxpR.cjs.map +0 -1
  99. package/dist/style-BmyOIMcU.js.map +0 -1
  100. package/dist/style-D40DsIqJ.cjs +0 -55
  101. package/dist/style-D40DsIqJ.cjs.map +0 -1
  102. package/dist/template-compiler-CDvhsHia.cjs +0 -22
  103. package/dist/template-compiler-CDvhsHia.cjs.map +0 -1
  104. package/dist/template-compiler-DiE69FLO.js +0 -3724
  105. package/dist/template-compiler-DiE69FLO.js.map +0 -1
@@ -1,1474 +0,0 @@
1
- import { a as m, d as N } from "./logger-BvkEbVM4.js";
2
- import { m as G, s as X } from "./css-utils-Cg4o1MqY.js";
3
- function K() {
4
- const r = (() => {
5
- try {
6
- return globalThis.process?.env?.NODE_ENV;
7
- } catch {
8
- return;
9
- }
10
- })(), e = (() => {
11
- try {
12
- if (typeof window > "u")
13
- return { vitest: !1, cypress: !1 };
14
- const t = window;
15
- return {
16
- vitest: !!t.__vitest__,
17
- cypress: !!t.Cypress
18
- };
19
- } catch {
20
- return { vitest: !1, cypress: !1 };
21
- }
22
- })();
23
- return {
24
- isTest: r === "test" || e.vitest || e.cypress,
25
- isVitest: e.vitest,
26
- isCypress: e.cypress
27
- };
28
- }
29
- class Z {
30
- pendingUpdates = /* @__PURE__ */ new Map();
31
- isFlushScheduled = !1;
32
- isFlushing = !1;
33
- testEnv;
34
- lastCleanup = 0;
35
- CLEANUP_INTERVAL = 300 * 1e3;
36
- // 5 minutes
37
- MAX_PENDING_SIZE = 1e4;
38
- // Prevent memory bloat
39
- // Idle / time-sliced priority support
40
- pendingIdleUpdates = /* @__PURE__ */ new Map();
41
- idleCallbackHandle = null;
42
- constructor() {
43
- this.testEnv = K(), this.schedulePeriodicCleanup();
44
- }
45
- /**
46
- * Schedule an update to be executed in the next microtask
47
- * Uses component identity to deduplicate multiple render requests for the same component
48
- */
49
- schedule(e, n) {
50
- const t = n || e;
51
- this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(t, e), this.isFlushScheduled || this.scheduleFlush();
52
- }
53
- /**
54
- * Schedule the flush operation based on environment
55
- */
56
- scheduleFlush() {
57
- this.isFlushScheduled = !0, this.testEnv.isTest && !this.isFlushing ? this.flush() : queueMicrotask(() => this.flush());
58
- }
59
- /**
60
- * Execute all pending updates with priority ordering
61
- */
62
- flush() {
63
- if (this.isFlushing)
64
- return;
65
- this.isFlushing = !0;
66
- const e = this.pendingUpdates;
67
- this.pendingUpdates = /* @__PURE__ */ new Map(), this.isFlushScheduled = !1;
68
- try {
69
- for (const n of e.values())
70
- try {
71
- n();
72
- } catch (t) {
73
- N("Error in batched update:", t);
74
- }
75
- } finally {
76
- this.isFlushing = !1;
77
- }
78
- }
79
- /**
80
- * Force flush any pending DOM updates immediately. This is useful in
81
- * test environments or callers that require synchronous guarantees after
82
- * state changes. Prefer relying on the scheduler's automatic flush when
83
- * possible; use this only when a caller needs to synchronously observe
84
- * rendered DOM changes.
85
- */
86
- flushImmediately() {
87
- this.pendingUpdates.size !== 0 && (this.isFlushScheduled = !1, this.flush());
88
- }
89
- /**
90
- * Get the number of pending updates
91
- */
92
- get pendingCount() {
93
- return this.pendingUpdates.size;
94
- }
95
- /**
96
- * Check if there are pending updates
97
- */
98
- get hasPendingUpdates() {
99
- return this.pendingUpdates.size > 0;
100
- }
101
- /**
102
- * Check if currently flushing updates
103
- */
104
- get isFlushingUpdates() {
105
- return this.isFlushing;
106
- }
107
- /**
108
- * Schedule periodic cleanup to prevent memory leaks
109
- */
110
- schedulePeriodicCleanup() {
111
- if (this.testEnv.isTest) return;
112
- const e = () => {
113
- this.performPeriodicCleanup(), this.testEnv.isTest || setTimeout(e, this.CLEANUP_INTERVAL);
114
- };
115
- setTimeout(e, this.CLEANUP_INTERVAL);
116
- }
117
- /**
118
- * Perform periodic cleanup of stale entries
119
- */
120
- performPeriodicCleanup() {
121
- const e = Date.now();
122
- e - this.lastCleanup < this.CLEANUP_INTERVAL || (this.pendingUpdates.size > 100 && m(
123
- `Scheduler has ${this.pendingUpdates.size} pending updates. Consider investigating.`
124
- ), this.lastCleanup = e);
125
- }
126
- /**
127
- * Emergency cleanup when pending updates exceed safe limits.
128
- * @param queue - The specific map to trim; defaults to the normal queue.
129
- */
130
- performEmergencyCleanup(e = this.pendingUpdates) {
131
- m(
132
- "Scheduler emergency cleanup: too many pending updates, clearing oldest entries"
133
- );
134
- const n = Array.from(e.entries()), t = Math.floor(n.length / 2);
135
- for (let s = 0; s < t; s++)
136
- e.delete(n[s][0]);
137
- }
138
- /**
139
- * Schedule an update with an explicit priority level.
140
- *
141
- * - `'immediate'` — Runs synchronously before returning.
142
- * - `'normal'` — Default microtask batching (same as `schedule()`).
143
- * - `'idle'` — Deferred to browser idle time via `requestIdleCallback`
144
- * with time-slicing to avoid blocking the main thread.
145
- * Falls back to a 5 ms `setTimeout` when
146
- * `requestIdleCallback` is unavailable (e.g. Safari < 16).
147
- *
148
- * @example Defer a low-priority analytics flush
149
- * ```ts
150
- * scheduleWithPriority(() => flushAnalytics(), 'idle');
151
- * ```
152
- */
153
- scheduleWithPriority(e, n = "normal", t) {
154
- if (n === "immediate") {
155
- try {
156
- e();
157
- } catch (o) {
158
- N("Error in immediate update:", o);
159
- }
160
- return;
161
- }
162
- if (n === "idle") {
163
- const o = t ?? e;
164
- this.pendingIdleUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(this.pendingIdleUpdates), this.pendingIdleUpdates.set(o, e), this.scheduleIdleFlush();
165
- return;
166
- }
167
- const s = t ?? e;
168
- this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(s, e), this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
169
- }
170
- /**
171
- * Schedule a flush of idle-priority updates.
172
- * Uses `requestIdleCallback` when available; falls back to a short `setTimeout`.
173
- */
174
- scheduleIdleFlush() {
175
- if (this.idleCallbackHandle === null) {
176
- if (this.testEnv.isTest) {
177
- this.idleCallbackHandle = setTimeout(() => {
178
- this.idleCallbackHandle = null, this.flushIdleUpdates(null);
179
- }, 0);
180
- return;
181
- }
182
- if (typeof requestIdleCallback < "u") {
183
- const e = requestIdleCallback(
184
- (n) => {
185
- this.idleCallbackHandle = null, this.flushIdleUpdates(n);
186
- },
187
- { timeout: 2e3 }
188
- );
189
- this.idleCallbackHandle = e;
190
- } else
191
- this.idleCallbackHandle = setTimeout(() => {
192
- this.idleCallbackHandle = null;
193
- const e = Date.now();
194
- this.flushIdleUpdates({
195
- timeRemaining: () => Math.max(0, 50 - (Date.now() - e)),
196
- didTimeout: !1
197
- });
198
- }, 5);
199
- }
200
- }
201
- /**
202
- * Process pending idle-priority updates in a time-sliced manner.
203
- * Yields back to the browser when the deadline's `timeRemaining()` reaches
204
- * zero and reschedules any unprocessed work.
205
- */
206
- flushIdleUpdates(e) {
207
- const n = Array.from(this.pendingIdleUpdates.entries());
208
- this.pendingIdleUpdates = /* @__PURE__ */ new Map();
209
- for (let t = 0; t < n.length; t++) {
210
- if (e && !e.didTimeout && e.timeRemaining() <= 0) {
211
- for (let s = t; s < n.length; s++)
212
- this.pendingIdleUpdates.set(n[s][0], n[s][1]);
213
- this.scheduleIdleFlush();
214
- return;
215
- }
216
- try {
217
- n[t][1]();
218
- } catch (s) {
219
- N("Error in idle update:", s);
220
- }
221
- }
222
- }
223
- }
224
- const k = new Z();
225
- function B(r, e) {
226
- k.schedule(r, e);
227
- }
228
- function ce(r, e = "normal", n) {
229
- k.scheduleWithPriority(r, e, n);
230
- }
231
- function ue() {
232
- k.flushImmediately();
233
- }
234
- function le() {
235
- return new Promise((r) => {
236
- let n = 0;
237
- for (; k.hasPendingUpdates && n < 100; )
238
- k.flushImmediately(), n++;
239
- n >= 100 && m(
240
- "[nextTick] Maximum flush iterations reached — possible circular update loop. Check for watchers or computed values that unconditionally mutate reactive state."
241
- ), queueMicrotask(r);
242
- });
243
- }
244
- const H = /* @__PURE__ */ new WeakSet();
245
- class Y {
246
- static cache = /* @__PURE__ */ new WeakMap();
247
- static arrayHandlerCache = /* @__PURE__ */ new WeakMap();
248
- static objectHandlerCache = /* @__PURE__ */ new WeakMap();
249
- /**
250
- * Get or create a reactive proxy for an object
251
- */
252
- static getOrCreateProxy(e, n, t = !1) {
253
- const s = this.cache.get(e);
254
- if (s)
255
- return s;
256
- const o = t ? this.getOrCreateArrayHandler(n) : this.getOrCreateObjectHandler(n), i = new Proxy(e, o);
257
- try {
258
- $.markAsProxy(i);
259
- } catch {
260
- }
261
- return this.cache.set(e, i), i;
262
- }
263
- /**
264
- * Get or create a cached array handler
265
- */
266
- static getOrCreateArrayHandler(e) {
267
- if (!this.arrayHandlerCache.has(e)) {
268
- const n = {
269
- get: (t, s, o) => {
270
- const i = Reflect.get(t, s, o);
271
- return typeof i == "function" && typeof s == "string" && [
272
- "push",
273
- "pop",
274
- "shift",
275
- "unshift",
276
- "splice",
277
- "sort",
278
- "reverse",
279
- "fill",
280
- "copyWithin"
281
- ].includes(s) ? function(...l) {
282
- const c = i.apply(t, l);
283
- return e.triggerUpdate(), c;
284
- } : i !== null && typeof i == "object" && typeof s == "string" ? e.makeReactiveValue(i) : i;
285
- },
286
- set: (t, s, o) => (t[s] = e.makeReactiveValue(o), e.triggerUpdate(), !0),
287
- deleteProperty: (t, s) => (delete t[s], e.triggerUpdate(), !0)
288
- };
289
- this.arrayHandlerCache.set(e, n);
290
- }
291
- return this.arrayHandlerCache.get(e);
292
- }
293
- /**
294
- * Get or create a cached object handler
295
- */
296
- static getOrCreateObjectHandler(e) {
297
- if (!this.objectHandlerCache.has(e)) {
298
- const n = {
299
- get: (t, s, o) => {
300
- const i = Reflect.get(t, s, o);
301
- return i !== null && typeof i == "object" && typeof s == "string" ? e.makeReactiveValue(i) : i;
302
- },
303
- set: (t, s, o) => (t[s] = e.makeReactiveValue(o), e.triggerUpdate(), !0),
304
- deleteProperty: (t, s) => (delete t[s], e.triggerUpdate(), !0)
305
- };
306
- this.objectHandlerCache.set(e, n);
307
- }
308
- return this.objectHandlerCache.get(e);
309
- }
310
- /**
311
- * Check if an object already has a cached proxy
312
- */
313
- static hasProxy(e) {
314
- return this.cache.has(e);
315
- }
316
- /**
317
- * Clear all cached proxies (useful for testing)
318
- */
319
- static clear() {
320
- this.cache = /* @__PURE__ */ new WeakMap(), this.arrayHandlerCache = /* @__PURE__ */ new WeakMap(), this.objectHandlerCache = /* @__PURE__ */ new WeakMap();
321
- }
322
- /**
323
- * Get cache statistics (for debugging)
324
- * Note: WeakMap doesn't provide size, so this is limited
325
- */
326
- static getStats() {
327
- return {
328
- hasCachedProxies: this.cache instanceof WeakMap
329
- };
330
- }
331
- }
332
- class $ {
333
- // Cache a stable reactiveContext object keyed by onUpdate -> makeReactive
334
- // This allows handler caches in ReactiveProxyCache to reuse handlers
335
- // for identical reactive contexts instead of creating a new context object
336
- // on each createReactiveProxy call.
337
- static contextCache = /* @__PURE__ */ new WeakMap();
338
- /**
339
- * Create an optimized reactive proxy with minimal overhead
340
- */
341
- static createReactiveProxy(e, n, t) {
342
- try {
343
- if (H.has(e)) return e;
344
- } catch {
345
- }
346
- const s = Array.isArray(e);
347
- let o = this.contextCache.get(n);
348
- o || (o = /* @__PURE__ */ new WeakMap(), this.contextCache.set(n, o));
349
- let i = o.get(t);
350
- return i || (i = {
351
- triggerUpdate: n,
352
- makeReactiveValue: t
353
- }, o.set(t, i)), Y.getOrCreateProxy(e, i, s);
354
- }
355
- /**
356
- * Mark an object as a proxy (for optimization)
357
- */
358
- static markAsProxy(e) {
359
- if (e)
360
- try {
361
- H.add(e);
362
- } catch {
363
- }
364
- }
365
- }
366
- let T = !1;
367
- function g() {
368
- return T;
369
- }
370
- function de() {
371
- T && m(
372
- "[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."
373
- ), T = !0;
374
- }
375
- function fe() {
376
- T = !1;
377
- }
378
- let J = 0;
379
- function A(r) {
380
- return `${r}-${++J}`;
381
- }
382
- class Q {
383
- // Use a stack to support nested callers (component render -> watcher)
384
- // so that watchers can temporarily become the "current component" while
385
- // establishing dependencies without clobbering the outer component id.
386
- currentComponentStack = [];
387
- // Consolidated component data: stores dependencies, render function, state index, and last warning time
388
- componentData = /* @__PURE__ */ new Map();
389
- // Flat storage: compound key `${componentId}:${stateIndex}` -> ReactiveState
390
- stateStorage = /* @__PURE__ */ new Map();
391
- trackingDisabled = !1;
392
- /**
393
- * Set the current component being rendered for dependency tracking
394
- */
395
- setCurrentComponent(e, n) {
396
- if (this.currentComponentStack.push(e), !this.componentData.has(e))
397
- this.componentData.set(e, {
398
- dependencies: /* @__PURE__ */ new Set(),
399
- renderFn: n,
400
- stateIndex: 0,
401
- lastWarnTime: 0,
402
- watchers: /* @__PURE__ */ new Map()
403
- });
404
- else {
405
- const t = this.componentData.get(e);
406
- if (t.watchers && t.watchers.size) {
407
- for (const s of t.watchers.values())
408
- try {
409
- this.cleanup(s);
410
- } catch {
411
- }
412
- t.watchers.clear();
413
- }
414
- t.renderFn = n, t.stateIndex = 0;
415
- }
416
- }
417
- /**
418
- * Clear the current component after rendering
419
- */
420
- clearCurrentComponent() {
421
- this.currentComponentStack.pop();
422
- }
423
- /**
424
- * Get the current component id (top of stack) or null
425
- */
426
- getCurrentComponentId() {
427
- return this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
428
- }
429
- /**
430
- * Register a watcher id under a component so it can be cleaned up on re-render
431
- */
432
- registerWatcher(e, n) {
433
- const t = this.componentData.get(e);
434
- t && t.watchers.set(n, n);
435
- }
436
- /**
437
- * Temporarily disable dependency tracking
438
- */
439
- disableTracking() {
440
- this.trackingDisabled = !0;
441
- }
442
- /**
443
- * Re-enable dependency tracking
444
- */
445
- enableTracking() {
446
- this.trackingDisabled = !1;
447
- }
448
- /**
449
- * Check if a component is currently rendering
450
- */
451
- isRenderingComponent() {
452
- return this.currentComponentStack.length > 0;
453
- }
454
- /**
455
- * Return whether we should emit a render-time warning for the current component.
456
- * This throttles warnings to avoid spamming the console for legitimate rapid updates.
457
- */
458
- shouldEmitRenderWarning() {
459
- const e = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
460
- if (!e) return !0;
461
- const n = this.componentData.get(e);
462
- if (!n) return !0;
463
- const t = Date.now();
464
- return t - n.lastWarnTime < 1e3 ? !1 : (n.lastWarnTime = t, !0);
465
- }
466
- /**
467
- * Execute a function with tracking disabled
468
- */
469
- withoutTracking(e) {
470
- const n = this.trackingDisabled;
471
- this.trackingDisabled = !0;
472
- try {
473
- return e();
474
- } finally {
475
- this.trackingDisabled = n;
476
- }
477
- }
478
- /**
479
- * Get or create a state instance for the current component
480
- */
481
- getOrCreateState(e) {
482
- const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
483
- if (!n)
484
- return new x(e);
485
- const t = this.componentData.get(n);
486
- if (!t)
487
- return new x(e);
488
- const s = `${n}:${t.stateIndex++}`;
489
- let o = this.stateStorage.get(s);
490
- return o || (o = new x(e), this.stateStorage.set(s, o)), o;
491
- }
492
- /**
493
- * Track a dependency for the current component
494
- */
495
- trackDependency(e) {
496
- if (this.trackingDisabled) return;
497
- const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
498
- if (!n) return;
499
- const t = this.componentData.get(n);
500
- t && (t.dependencies.add(e), e.addDependent(n));
501
- }
502
- /**
503
- * Re-register all reactive dependencies that `fromId` tracks into the
504
- * currently-active (outer) component context.
505
- *
506
- * Used by `computed()` to forward its dep-set to the consuming component
507
- * without re-executing the getter function a second time.
508
- */
509
- propagateDependencies(e) {
510
- if (this.trackingDisabled) return;
511
- const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
512
- if (!n || n === e) return;
513
- const t = this.componentData.get(e);
514
- if (!t) return;
515
- const s = this.componentData.get(n);
516
- if (s)
517
- for (const o of t.dependencies)
518
- s.dependencies.add(o), o.addDependent(n);
519
- }
520
- /**
521
- * Trigger updates for all components that depend on a state
522
- */
523
- triggerUpdate(e) {
524
- const n = e.getDependents();
525
- for (const t of n) {
526
- const s = this.componentData.get(t);
527
- s && B(s.renderFn, t);
528
- }
529
- }
530
- /**
531
- * Clean up component dependencies when component is destroyed
532
- */
533
- cleanup(e) {
534
- const n = this.componentData.get(e);
535
- if (n) {
536
- for (const s of n.dependencies)
537
- s.removeDependent(e);
538
- this.componentData.delete(e);
539
- }
540
- const t = e + ":";
541
- for (const s of this.stateStorage.keys())
542
- s.startsWith(t) && this.stateStorage.delete(s);
543
- }
544
- }
545
- const d = new Q();
546
- class x {
547
- _value;
548
- /** The unwrapped value last assigned — used for Object.is equality checks. */
549
- _rawValue;
550
- dependents = /* @__PURE__ */ new Set();
551
- constructor(e) {
552
- this._rawValue = e, this._value = this.makeReactive(e);
553
- try {
554
- Object.defineProperty(this, /* @__PURE__ */ Symbol.for("@cer/ReactiveState"), {
555
- value: !0,
556
- enumerable: !1,
557
- configurable: !1
558
- });
559
- } catch {
560
- }
561
- }
562
- get value() {
563
- return d.trackDependency(this), this._value;
564
- }
565
- set value(e) {
566
- Object.is(e, this._rawValue) || (d.isRenderingComponent() && d.shouldEmitRenderWarning() && m(
567
- `🚨 State modification detected during render! This can cause infinite loops.
568
- • Move state updates to event handlers
569
- • Use watchEffect/watch for side effects
570
- • Ensure computed properties don't modify state`
571
- ), this._rawValue = e, this._value = this.makeReactive(e), d.triggerUpdate(this));
572
- }
573
- /**
574
- * Read the current value without registering a reactive dependency.
575
- * Useful for internal infrastructure (e.g. stable hook slots) that must
576
- * inspect the stored value without re-triggering the containing component.
577
- * @internal
578
- */
579
- peek() {
580
- return this._value;
581
- }
582
- /**
583
- * Set the initial value without triggering any reactive updates or warnings.
584
- * Only intended for internal/infrastructure use (e.g. storing a stable hook
585
- * handle in a reactive slot without causing a spurious re-render).
586
- * The value is stored as-is without reactive proxy wrapping so that opaque
587
- * objects (e.g. TeleportHandle) are not accidentally instrumented.
588
- * @internal
589
- */
590
- initSilent(e) {
591
- this._rawValue = e, this._value = e;
592
- }
593
- addDependent(e) {
594
- this.dependents.add(e);
595
- }
596
- removeDependent(e) {
597
- this.dependents.delete(e);
598
- }
599
- getDependents() {
600
- return this.dependents;
601
- }
602
- makeReactive(e) {
603
- return e === null || typeof e != "object" || typeof Node < "u" && e instanceof Node || typeof Element < "u" && e instanceof Element || typeof HTMLElement < "u" && e instanceof HTMLElement ? e : $.createReactiveProxy(
604
- e,
605
- () => d.triggerUpdate(this),
606
- (n) => this.makeReactive(n)
607
- );
608
- }
609
- }
610
- function he(r) {
611
- return d.getOrCreateState(
612
- r === void 0 ? null : r
613
- );
614
- }
615
- function b(r) {
616
- if (!r || typeof r != "object") return !1;
617
- try {
618
- const e = /* @__PURE__ */ Symbol.for("@cer/ReactiveState");
619
- return Object.prototype.hasOwnProperty.call(r, e);
620
- } catch {
621
- return !1;
622
- }
623
- }
624
- function pe(r) {
625
- let e, n = !0;
626
- const t = A("computed"), s = () => {
627
- n = !0;
628
- };
629
- try {
630
- const o = d.getCurrentComponentId();
631
- o && d.registerWatcher(o, t);
632
- } catch {
633
- }
634
- return d.setCurrentComponent(t, s), e = r(), d.clearCurrentComponent(), n = !1, {
635
- get value() {
636
- return n && (d.setCurrentComponent(t, s), e = r(), d.clearCurrentComponent(), n = !1), d.propagateDependencies(t), e;
637
- }
638
- };
639
- }
640
- function ge(r) {
641
- if (g()) return () => {
642
- };
643
- const e = A("effect");
644
- try {
645
- const t = d.getCurrentComponentId();
646
- t && d.registerWatcher(t, e);
647
- } catch {
648
- }
649
- const n = () => {
650
- d.setCurrentComponent(e, n);
651
- try {
652
- r();
653
- } finally {
654
- d.clearCurrentComponent();
655
- }
656
- };
657
- return n(), () => {
658
- d.cleanup(e);
659
- };
660
- }
661
- const I = 50;
662
- function D(r, e = /* @__PURE__ */ new WeakMap(), n = 0) {
663
- if (r === null || typeof r != "object") return r;
664
- const t = r;
665
- if (e.has(t)) return e.get(t);
666
- if (n > I)
667
- return m(
668
- `[watch] Deep clone exceeded ${I} nesting levels. Returning a reference at this depth instead of cloning further. Consider restructuring your state or switching to a shallow watch.`
669
- ), r;
670
- if (typeof Node < "u" && t instanceof Node) return r;
671
- if (t instanceof Date) return new Date(t.getTime());
672
- if (Array.isArray(t)) {
673
- const o = [];
674
- e.set(t, o);
675
- for (let i = 0; i < t.length; i++)
676
- o.push(D(t[i], e, n + 1));
677
- return o;
678
- }
679
- const s = {};
680
- e.set(t, s);
681
- for (const o of Object.keys(t))
682
- try {
683
- s[o] = D(
684
- t[o],
685
- e,
686
- n + 1
687
- );
688
- } catch {
689
- }
690
- return s;
691
- }
692
- function me(r, e, n) {
693
- if (g()) return () => {
694
- };
695
- let t;
696
- const s = b(r) ? () => r.value : r, o = A("watch");
697
- try {
698
- const a = d.getCurrentComponentId();
699
- a && d.registerWatcher(a, o);
700
- } catch {
701
- }
702
- const i = () => {
703
- d.setCurrentComponent(o, i);
704
- const a = s();
705
- if (d.clearCurrentComponent(), n?.deep) {
706
- const l = d.withoutTracking(
707
- () => D(a)
708
- );
709
- e(l, t), t = l;
710
- } else a !== t && (e(a, t), t = a);
711
- };
712
- return d.setCurrentComponent(o, i), t = s(), d.clearCurrentComponent(), n?.deep && (t = d.withoutTracking(() => D(t))), n && n.immediate && e(t, void 0), () => {
713
- d.cleanup(o);
714
- };
715
- }
716
- const ye = (r) => {
717
- try {
718
- r();
719
- } catch {
720
- }
721
- }, _ = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), O = 500;
722
- let E, V, j = !1, L = !1, U;
723
- const ee = !!globalThis.process?.versions?.node;
724
- function te(r) {
725
- if (_.has(r))
726
- return _.get(r);
727
- const e = r.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
728
- return _.size < O && _.set(r, e), e;
729
- }
730
- function F(r) {
731
- if (v.has(r))
732
- return v.get(r);
733
- const e = r.replace(/-([a-z])/g, (n, t) => t.toUpperCase());
734
- return v.size < O && v.set(r, e), e;
735
- }
736
- function be(r) {
737
- if (typeof r == "string") {
738
- if (M.has(r))
739
- return M.get(r);
740
- const e = r.replace(
741
- /[&<>"']/g,
742
- (n) => ({
743
- "&": "&amp;",
744
- "<": "&lt;",
745
- ">": "&gt;",
746
- '"': "&quot;",
747
- "'": "&#39;"
748
- })[n]
749
- );
750
- return e !== r && M.size < O && M.set(r, e), e;
751
- }
752
- return r;
753
- }
754
- function y(r) {
755
- if (!r) return "";
756
- const e = String(r);
757
- if (typeof document < "u" && typeof document.createElement == "function") {
758
- const a = e.replace(/</g, "").replace(/>/g, ""), l = U || (U = document.createElement("div"));
759
- try {
760
- y._el = l;
761
- } catch {
762
- }
763
- return l.innerHTML = a, (l.textContent || "").replace(new RegExp("", "g"), "<").replace(new RegExp("", "g"), ">");
764
- }
765
- const n = {
766
- lt: "<",
767
- gt: ">",
768
- amp: "&",
769
- quot: '"',
770
- apos: "'",
771
- nbsp: " "
772
- }, t = E ?? y._namedMap;
773
- let s = t;
774
- if (!s && ee)
775
- try {
776
- const o = globalThis.require;
777
- if (typeof o == "function") {
778
- const i = [
779
- "@jasonshimmy/custom-elements-runtime/entities.json",
780
- // installed package export
781
- "../../entities.json",
782
- // dist/runtime -> ../../entities.json
783
- "../../../entities.json",
784
- // src/lib/runtime -> ../../../entities.json
785
- "../entities.json",
786
- "./entities.json"
787
- ];
788
- for (const a of i)
789
- try {
790
- const l = o(a);
791
- if (l && typeof l == "object") {
792
- s = l;
793
- break;
794
- }
795
- } catch {
796
- }
797
- }
798
- } catch {
799
- }
800
- if (!s) {
801
- s = n, j = !0;
802
- try {
803
- y._usedFallback = !0;
804
- } catch {
805
- }
806
- const o = y._namedMapLoader ?? V;
807
- o && o().then((i) => {
808
- E = i;
809
- try {
810
- y._namedMap = i;
811
- } catch {
812
- }
813
- }).catch(() => {
814
- });
815
- }
816
- if ((j || y._usedFallback) && !(L || y._warnedFallback)) {
817
- L = !0;
818
- try {
819
- y._warnedFallback = !0;
820
- } catch {
821
- }
822
- try {
823
- m(
824
- "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."
825
- );
826
- } catch {
827
- }
828
- }
829
- return e.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (o, i) => {
830
- if (i.charCodeAt(0) === 35) {
831
- const c = (i.charAt(1) || "").toLowerCase() === "x" ? parseInt(i.slice(2), 16) : parseInt(i.slice(1), 10);
832
- return Number.isNaN(c) ? `&${i};` : String.fromCodePoint(c);
833
- }
834
- const a = s[i] ?? (t && t[i]);
835
- return a !== void 0 ? a : `&${i};`;
836
- });
837
- }
838
- async function z() {
839
- const r = [
840
- "@jasonshimmy",
841
- "custom-elements-runtime",
842
- "entities.json"
843
- ].join("/");
844
- try {
845
- const e = await import(
846
- /* @vite-ignore */
847
- r
848
- );
849
- return e && (e.default || e);
850
- } catch {
851
- try {
852
- const e = [
853
- r,
854
- // try package export via dynamic import too (best for installed packages)
855
- "./entities.json",
856
- "../../entities.json",
857
- "../../../entities.json"
858
- ];
859
- for (const n of e)
860
- try {
861
- const t = await import(
862
- /* @vite-ignore */
863
- n
864
- );
865
- if (t)
866
- return t && (t.default || t);
867
- } catch {
868
- }
869
- return {
870
- lt: "<",
871
- gt: ">",
872
- amp: "&",
873
- quot: '"',
874
- apos: "'",
875
- nbsp: " "
876
- };
877
- } catch {
878
- return {
879
- lt: "<",
880
- gt: ">",
881
- amp: "&",
882
- quot: '"',
883
- apos: "'",
884
- nbsp: " "
885
- };
886
- }
887
- }
888
- }
889
- V = z;
890
- y._namedMapLoader = z;
891
- function Ce(r, e) {
892
- !r || typeof r != "object" || E && !e?.overwrite || (E = r);
893
- }
894
- function we() {
895
- E = void 0;
896
- }
897
- function Se(r) {
898
- const e = String(r);
899
- return { __unsafeHTML: e, __rawHTML: e };
900
- }
901
- function ke(r) {
902
- return !!r && (typeof r.__unsafeHTML == "string" || typeof r.__rawHTML == "string");
903
- }
904
- function Ee(r, e) {
905
- if (typeof e == "string") {
906
- if (e === "") return;
907
- const n = e.split(".");
908
- let t = r;
909
- for (const s of n) {
910
- if (t == null || typeof t != "object") {
911
- t = void 0;
912
- break;
913
- }
914
- t = t[s];
915
- }
916
- return b(t) ? t.value : t;
917
- }
918
- return e;
919
- }
920
- function _e(r, e, n) {
921
- const t = String(e).split("."), s = t.pop();
922
- if (!s) return;
923
- const o = t.reduce(
924
- (i, a) => (i[a] == null && (i[a] = {}), i[a]),
925
- r
926
- );
927
- b(o[s]) ? o[s].value = n : o[s] = n;
928
- }
929
- function ne(r) {
930
- try {
931
- if (r && typeof r == "object") {
932
- if (b(r)) return r.value;
933
- if ("value" in r) {
934
- const e = r.value;
935
- return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : r;
936
- }
937
- }
938
- } catch {
939
- }
940
- return r;
941
- }
942
- function ve(r) {
943
- const e = ne(r);
944
- if (e == null) return null;
945
- const n = typeof e;
946
- return n === "string" || n === "number" || n === "boolean" ? String(e) : null;
947
- }
948
- function Me(r) {
949
- if (!r || typeof r != "string") return !1;
950
- if (r === "class" || r.endsWith("Class")) return !0;
951
- if (r.includes("-"))
952
- try {
953
- if (r.split("-").some((n) => n === "class")) return !0;
954
- } catch {
955
- }
956
- return !1;
957
- }
958
- let C = null;
959
- function Ne() {
960
- if (C !== null)
961
- throw new Error(
962
- "[CER] Concurrent SSR render detected: beginSSRGlobalStyleCollection() called while a collection is already active. For concurrent request handling, use worker threads or multiple Node.js processes."
963
- );
964
- C = [];
965
- }
966
- function Te() {
967
- const r = C ?? [];
968
- return C = null, r;
969
- }
970
- function re(r) {
971
- return C !== null ? (r && !C.includes(r) && C.push(r), !0) : !1;
972
- }
973
- let se = 0;
974
- function De(r, e, n = "unknown", t) {
975
- const s = {};
976
- for (const [h, p] of Object.entries(e ?? {}))
977
- s[F(h)] = p;
978
- const o = {
979
- getAttribute(h) {
980
- const p = F(h);
981
- if (s[p] !== void 0 && s[p] !== null)
982
- return String(s[p]);
983
- const f = (e ?? {})[h];
984
- return f != null ? String(f) : null;
985
- },
986
- hasAttribute(h) {
987
- return this.getAttribute(h) !== null;
988
- },
989
- // shadowRoot must be null so useJITCSS() doesn't try to registerJITCSSComponent
990
- shadowRoot: null,
991
- tagName: "",
992
- parentElement: null
993
- }, i = {
994
- ...s,
995
- // Unique ID per SSR render prevents the reactive system's stateStorage from
996
- // returning cached ref/computed values from a previous request. Using a
997
- // monotonic counter is cheaper than crypto.randomUUID() and avoids the
998
- // Node.js version compatibility concern noted in the original comment.
999
- _componentId: `cer-ssr-${Object.keys(s).join("-") || "root"}-${++se}`,
1000
- requestRender: () => {
1001
- },
1002
- _requestRender: () => {
1003
- },
1004
- emit: () => !0,
1005
- refs: {}
1006
- };
1007
- Object.defineProperty(i, "_host", {
1008
- value: o,
1009
- writable: !0,
1010
- enumerable: !1,
1011
- configurable: !0
1012
- }), t !== void 0 && Object.defineProperty(i, "_router", {
1013
- value: t,
1014
- writable: !1,
1015
- enumerable: !1,
1016
- configurable: !0
1017
- }), R(i);
1018
- let a = null, l;
1019
- try {
1020
- const h = r.render(
1021
- i
1022
- );
1023
- h instanceof Promise ? l = h : a = h;
1024
- } catch (h) {
1025
- m(
1026
- `[SSR] Component "${n}" threw during SSR render. The shadow DOM will be empty. Error:`,
1027
- h
1028
- );
1029
- } finally {
1030
- q();
1031
- }
1032
- const c = String(
1033
- i._computedStyle ?? ""
1034
- );
1035
- return { shadowVNode: a, useStyleCSS: c, asyncPromise: l };
1036
- }
1037
- function xe() {
1038
- return g();
1039
- }
1040
- let u = null;
1041
- const S = /* @__PURE__ */ Symbol("cer:provides");
1042
- function R(r) {
1043
- u = r;
1044
- }
1045
- function q() {
1046
- u = null;
1047
- }
1048
- function Re() {
1049
- return u;
1050
- }
1051
- function Ae() {
1052
- if (!u)
1053
- throw new Error("useEmit must be called during component render");
1054
- if (g())
1055
- return () => !1;
1056
- const r = u.emit;
1057
- if (typeof r != "function")
1058
- throw new Error(
1059
- "useEmit requires an emit function on the component context"
1060
- );
1061
- const e = r;
1062
- return (n, t, s) => e(n, t, s);
1063
- }
1064
- function w(r) {
1065
- r._hookCallbacks || Object.defineProperty(r, "_hookCallbacks", {
1066
- value: {},
1067
- writable: !0,
1068
- enumerable: !1,
1069
- configurable: !0
1070
- });
1071
- }
1072
- function Oe(r) {
1073
- if (!u)
1074
- throw new Error("useOnConnected must be called during component render");
1075
- if (g()) return;
1076
- w(u);
1077
- const e = u._hookCallbacks;
1078
- e.onConnected || (e.onConnected = []), e.onConnected.push(r);
1079
- }
1080
- function Pe(r) {
1081
- if (!u)
1082
- throw new Error("useOnDisconnected must be called during component render");
1083
- if (g()) return;
1084
- w(u);
1085
- const e = u._hookCallbacks;
1086
- e.onDisconnected || (e.onDisconnected = []), e.onDisconnected.push(r);
1087
- }
1088
- function He(r) {
1089
- if (!u)
1090
- throw new Error(
1091
- "useOnAttributeChanged must be called during component render"
1092
- );
1093
- if (g()) return;
1094
- w(u);
1095
- const e = u._hookCallbacks;
1096
- e.onAttributeChanged || (e.onAttributeChanged = []), e.onAttributeChanged.push(r);
1097
- }
1098
- function Ie(r) {
1099
- if (!u)
1100
- throw new Error("useOnError must be called during component render");
1101
- if (g()) return;
1102
- w(u);
1103
- const e = u._hookCallbacks;
1104
- e.onError || (e.onError = []), e.onError.push((n) => {
1105
- try {
1106
- n instanceof Error ? r(n) : r(new Error(String(n)));
1107
- } catch (t) {
1108
- N("[useOnError] The error handler itself threw an exception:", t);
1109
- }
1110
- });
1111
- }
1112
- function oe(r) {
1113
- if (!u)
1114
- throw new Error("useProps must be called during component render");
1115
- w(u);
1116
- const e = u._hookCallbacks;
1117
- e.props = {
1118
- ...e.props || {},
1119
- ...r
1120
- };
1121
- const n = u;
1122
- try {
1123
- const s = Object.keys(r || {});
1124
- for (const o of s) {
1125
- if (typeof o != "string" || o.startsWith("_")) continue;
1126
- const i = Object.getOwnPropertyDescriptor(n, o);
1127
- if (!(i && !i.configurable))
1128
- try {
1129
- let l = Object.prototype.hasOwnProperty.call(n, o) ? n[o] : void 0;
1130
- Object.defineProperty(n, o, {
1131
- configurable: !0,
1132
- enumerable: !0,
1133
- get() {
1134
- try {
1135
- const c = n && n._host;
1136
- if (c) {
1137
- const h = te(o), p = c.getAttribute(h);
1138
- if (p !== null) {
1139
- const f = typeof r[o];
1140
- return f === "boolean" ? p === "" || p === "true" : f === "number" ? Number(p) : p;
1141
- }
1142
- if (typeof c[o] < "u") {
1143
- const f = c[o];
1144
- if (b(f) || f && typeof f == "object" && "value" in f && !(typeof Node < "u" && f instanceof Node))
1145
- return f.value;
1146
- const P = typeof r[o];
1147
- if (!(P === "string" && f && typeof f == "object"))
1148
- return P === "boolean" && typeof f == "string" ? f === "" || f === "true" : f;
1149
- }
1150
- }
1151
- } catch {
1152
- }
1153
- return l;
1154
- },
1155
- set(c) {
1156
- l = c;
1157
- }
1158
- });
1159
- } catch {
1160
- }
1161
- }
1162
- } catch {
1163
- }
1164
- return new Proxy({}, {
1165
- get(s, o) {
1166
- if (typeof o != "string") return;
1167
- const i = r[o];
1168
- try {
1169
- const l = n && n._host;
1170
- if (l) {
1171
- if (typeof HTMLElement < "u" && l instanceof HTMLElement || typeof l.getAttribute == "function" && typeof l.hasAttribute == "function") {
1172
- const h = o.replace(/([A-Z])/g, "-$1").toLowerCase(), p = l.getAttribute(h);
1173
- if (p !== null)
1174
- return typeof i == "boolean" ? p === "" || p === "true" : typeof i == "number" ? Number(p) : p;
1175
- }
1176
- const c = l[o];
1177
- if (typeof c < "u" && c !== "") {
1178
- const h = c && typeof c == "object" && "value" in c && !(typeof Node < "u" && c instanceof Node);
1179
- if (!(typeof i == "string" && c && typeof c == "object" && !h && !b(c)))
1180
- return typeof i == "boolean" && i === !1 && c === "" ? i : b(c) || h ? c.value : typeof i == "boolean" && typeof c == "string" ? c === "" || c === "true" : typeof i == "number" && typeof c == "string" && !Number.isNaN(Number(c)) ? Number(c) : c;
1181
- }
1182
- }
1183
- } catch {
1184
- }
1185
- const a = n[o];
1186
- return typeof i == "boolean" && a === "" ? i === !1 ? i : !0 : b(a) || a && typeof a == "object" && "value" in a && !(typeof Node < "u" && a instanceof Node) ? a.value : a != null && a !== "" ? typeof i == "boolean" && typeof a == "string" ? a === "true" : typeof i == "number" && typeof a == "string" && !Number.isNaN(Number(a)) ? Number(a) : a : i;
1187
- },
1188
- has(s, o) {
1189
- return typeof o == "string" && (o in n || o in r);
1190
- },
1191
- ownKeys() {
1192
- return Array.from(
1193
- /* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(n || {})])
1194
- );
1195
- },
1196
- getOwnPropertyDescriptor() {
1197
- return { configurable: !0, enumerable: !0 };
1198
- }
1199
- });
1200
- }
1201
- function je(r) {
1202
- if (!u)
1203
- throw new Error("useStyle must be called during component render");
1204
- if (!g()) {
1205
- w(u);
1206
- try {
1207
- const e = r();
1208
- Object.defineProperty(u, "_computedStyle", {
1209
- value: e,
1210
- writable: !0,
1211
- enumerable: !1,
1212
- configurable: !0
1213
- });
1214
- } catch (e) {
1215
- m("Error in useStyle callback:", e), Object.defineProperty(u, "_computedStyle", {
1216
- value: "",
1217
- writable: !0,
1218
- enumerable: !1,
1219
- configurable: !0
1220
- });
1221
- }
1222
- }
1223
- }
1224
- const W = /* @__PURE__ */ new Map();
1225
- function Le(r) {
1226
- let e;
1227
- try {
1228
- e = r();
1229
- } catch {
1230
- return;
1231
- }
1232
- if (re(e) || typeof document > "u" || typeof CSSStyleSheet > "u")
1233
- return;
1234
- m(
1235
- "[useGlobalStyle] Injecting global styles from a component. This escapes Shadow DOM encapsulation — use sparingly."
1236
- );
1237
- const n = G(X(e));
1238
- if (!(!n || W.has(n)))
1239
- try {
1240
- const t = new CSSStyleSheet();
1241
- t.replaceSync(n), document.adoptedStyleSheets = [...document.adoptedStyleSheets, t], W.set(n, t);
1242
- } catch {
1243
- const t = document.createElement("style");
1244
- t.textContent = n, (document.head ?? document.documentElement).appendChild(t);
1245
- }
1246
- }
1247
- function Ue(r) {
1248
- if (!u)
1249
- throw new Error("useDesignTokens must be called during component render");
1250
- if (g()) return;
1251
- const e = [], n = {
1252
- primary: "--cer-color-primary-500",
1253
- secondary: "--cer-color-secondary-500",
1254
- neutral: "--cer-color-neutral-500",
1255
- success: "--cer-color-success-500",
1256
- info: "--cer-color-info-500",
1257
- warning: "--cer-color-warning-500",
1258
- error: "--cer-color-error-500"
1259
- }, t = {
1260
- fontSans: "--cer-font-sans",
1261
- fontSerif: "--cer-font-serif",
1262
- fontMono: "--cer-font-mono"
1263
- };
1264
- for (const [l, c] of Object.entries(r))
1265
- c !== void 0 && (l in n ? e.push(`${n[l]}:${c}`) : l in t ? e.push(`${t[l]}:${c}`) : l.startsWith("--") && e.push(`${l}:${c}`));
1266
- if (e.length === 0) return;
1267
- const s = `:host{${e.join(";")}}`, i = u._computedStyle ?? "", a = i ? `${i}
1268
- ${s}` : s;
1269
- Object.defineProperty(u, "_computedStyle", {
1270
- value: a,
1271
- writable: !0,
1272
- enumerable: !1,
1273
- configurable: !0
1274
- });
1275
- }
1276
- function Fe(r, e) {
1277
- if (!u)
1278
- throw new Error("provide must be called during component render");
1279
- if (g()) return;
1280
- const n = u;
1281
- n[S] || Object.defineProperty(n, S, {
1282
- value: /* @__PURE__ */ new Map(),
1283
- writable: !1,
1284
- enumerable: !1,
1285
- configurable: !0
1286
- }), n[S].set(r, e);
1287
- }
1288
- function We(r, e) {
1289
- if (!u)
1290
- throw new Error("inject must be called during component render");
1291
- if (g()) return e;
1292
- try {
1293
- const n = u._host;
1294
- if (n) {
1295
- let t = n.parentNode;
1296
- t || (t = n.getRootNode());
1297
- let s = 0;
1298
- const o = 50;
1299
- for (; t && s < o; )
1300
- if (s++, typeof ShadowRoot < "u" && t instanceof ShadowRoot) {
1301
- const i = t.host, a = i.context;
1302
- if (a) {
1303
- const c = a[S];
1304
- if (c?.has(r))
1305
- return c.get(r);
1306
- }
1307
- if (t = i.parentNode ?? i.getRootNode(), t === document || t === i) break;
1308
- } else {
1309
- if (typeof Element < "u" && t instanceof Element) {
1310
- const l = t.context;
1311
- if (l) {
1312
- const c = l[S];
1313
- if (c?.has(r))
1314
- return c.get(r);
1315
- }
1316
- }
1317
- const i = t;
1318
- if (t = t.parentNode ?? t.getRootNode?.(), t === document || t === i) break;
1319
- }
1320
- }
1321
- } catch {
1322
- }
1323
- return e;
1324
- }
1325
- function $e(r) {
1326
- return (e) => {
1327
- const n = e ?? u;
1328
- if (!n)
1329
- throw new Error(
1330
- "createComposable: no component context available. Pass a context explicitly or call inside a render function."
1331
- );
1332
- const t = u;
1333
- R(n);
1334
- try {
1335
- return r();
1336
- } finally {
1337
- t ? R(t) : q();
1338
- }
1339
- };
1340
- }
1341
- function Ve(r) {
1342
- if (!u)
1343
- throw new Error("useExpose must be called during component render");
1344
- if (g()) return;
1345
- w(u);
1346
- const e = u._hookCallbacks;
1347
- e.expose = { ...e.expose ?? {}, ...r };
1348
- const n = u._host;
1349
- if (n)
1350
- for (const [t, s] of Object.entries(r))
1351
- try {
1352
- n[t] = s;
1353
- } catch {
1354
- }
1355
- }
1356
- function ze() {
1357
- if (!u)
1358
- throw new Error("useSlots must be called during component render");
1359
- if (g())
1360
- return { has: () => !1, getNodes: () => [], names: () => [] };
1361
- const r = u._host, e = () => {
1362
- const n = /* @__PURE__ */ new Map();
1363
- if (!r) return n;
1364
- for (const t of r.children) {
1365
- const s = t.getAttribute("slot") ?? "default", o = n.get(s);
1366
- o ? o.push(t) : n.set(s, [t]);
1367
- }
1368
- return n;
1369
- };
1370
- return {
1371
- /**
1372
- * Returns true if the named slot (or the default slot when name is
1373
- * omitted) has at least one slotted child element.
1374
- */
1375
- has(n) {
1376
- if (!r) return !1;
1377
- const t = !n || n === "default" ? "default" : n, s = e().get(t);
1378
- return s !== void 0 && s.length > 0;
1379
- },
1380
- /**
1381
- * Returns all child elements assigned to the named slot (or the default
1382
- * slot when name is omitted).
1383
- */
1384
- getNodes(n) {
1385
- if (!r) return [];
1386
- const t = !n || n === "default" ? "default" : n;
1387
- return e().get(t) ?? [];
1388
- },
1389
- /** Returns the names of all slots that have content, including 'default'. */
1390
- names() {
1391
- return r ? Array.from(e().keys()) : [];
1392
- }
1393
- };
1394
- }
1395
- function qe(...r) {
1396
- if (!u)
1397
- throw new Error("defineModel must be called during component render");
1398
- const e = r.length === 2 ? r[0] : "modelValue", n = r.length === 2 ? r[1] : r.length === 1 ? r[0] : void 0, t = oe({
1399
- [e]: n
1400
- }), o = g() ? null : (() => {
1401
- const a = u.emit;
1402
- return typeof a != "function" ? null : a;
1403
- })(), i = {
1404
- get value() {
1405
- return t[e];
1406
- },
1407
- set value(a) {
1408
- o && o(`update:${e}`, a);
1409
- }
1410
- };
1411
- try {
1412
- Object.defineProperty(i, /* @__PURE__ */ Symbol.for("@cer/ReactiveState"), {
1413
- value: !0,
1414
- enumerable: !1,
1415
- configurable: !1
1416
- });
1417
- } catch {
1418
- }
1419
- return i;
1420
- }
1421
- export {
1422
- me as A,
1423
- ge as B,
1424
- Ee as C,
1425
- te as D,
1426
- _e as E,
1427
- ye as F,
1428
- ve as G,
1429
- F as H,
1430
- Me as I,
1431
- K as J,
1432
- B as K,
1433
- R as L,
1434
- de as M,
1435
- fe as N,
1436
- q as O,
1437
- ke as P,
1438
- g as Q,
1439
- x as R,
1440
- be as S,
1441
- De as T,
1442
- Ne as U,
1443
- Te as V,
1444
- we as W,
1445
- z as X,
1446
- Ce as Y,
1447
- Ve as a,
1448
- oe as b,
1449
- d as c,
1450
- pe as d,
1451
- $e as e,
1452
- y as f,
1453
- Re as g,
1454
- qe as h,
1455
- xe as i,
1456
- ue as j,
1457
- We as k,
1458
- b as l,
1459
- Se as m,
1460
- le as n,
1461
- Ue as o,
1462
- Fe as p,
1463
- Ae as q,
1464
- he as r,
1465
- ce as s,
1466
- Le as t,
1467
- Ie as u,
1468
- He as v,
1469
- Oe as w,
1470
- Pe as x,
1471
- ze as y,
1472
- je as z
1473
- };
1474
- //# sourceMappingURL=hooks-BH-CpUun.js.map