@jasonshimmy/custom-elements-runtime 3.4.0 → 3.6.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 (106) hide show
  1. package/README.md +28 -7
  2. package/dist/css-utils-Bn-dO44e.js +203 -0
  3. package/dist/{css-utils-CC43BbEy.js.map → css-utils-Bn-dO44e.js.map} +1 -1
  4. package/dist/{css-utils-CC43BbEy.js → css-utils-CFeP8SK1.cjs} +5 -71
  5. package/dist/{css-utils-mgjmH8qX.cjs.map → css-utils-CFeP8SK1.cjs.map} +1 -1
  6. package/dist/custom-elements-runtime.cjs.js +3 -4
  7. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  8. package/dist/custom-elements-runtime.colors.cjs.js +1 -2
  9. package/dist/custom-elements-runtime.colors.cjs.js.map +1 -1
  10. package/dist/custom-elements-runtime.colors.es.js +277 -277
  11. package/dist/custom-elements-runtime.colors.es.js.map +1 -1
  12. package/dist/custom-elements-runtime.directive-enhancements.cjs.js +1 -2
  13. package/dist/custom-elements-runtime.directive-enhancements.cjs.js.map +1 -1
  14. package/dist/custom-elements-runtime.directive-enhancements.es.js +106 -122
  15. package/dist/custom-elements-runtime.directive-enhancements.es.js.map +1 -1
  16. package/dist/custom-elements-runtime.directives.cjs.js +1 -2
  17. package/dist/custom-elements-runtime.directives.cjs.js.map +1 -1
  18. package/dist/custom-elements-runtime.directives.es.js +60 -65
  19. package/dist/custom-elements-runtime.directives.es.js.map +1 -1
  20. package/dist/custom-elements-runtime.dom-jit-css.cjs.js +1 -7
  21. package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -1
  22. package/dist/custom-elements-runtime.dom-jit-css.es.js +103 -115
  23. package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -1
  24. package/dist/custom-elements-runtime.es.js +206 -253
  25. package/dist/custom-elements-runtime.es.js.map +1 -1
  26. package/dist/custom-elements-runtime.event-bus.cjs.js +1 -2
  27. package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
  28. package/dist/custom-elements-runtime.event-bus.es.js +102 -108
  29. package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
  30. package/dist/custom-elements-runtime.jit-css.cjs.js +1 -2
  31. package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -1
  32. package/dist/custom-elements-runtime.jit-css.es.js +14 -32
  33. package/dist/custom-elements-runtime.jit-css.es.js.map +1 -1
  34. package/dist/custom-elements-runtime.router.cjs.js +20 -21
  35. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  36. package/dist/custom-elements-runtime.router.es.js +866 -926
  37. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  38. package/dist/custom-elements-runtime.ssr-middleware.cjs.js +3 -4
  39. package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -1
  40. package/dist/custom-elements-runtime.ssr-middleware.es.js +67 -73
  41. package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -1
  42. package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
  43. package/dist/custom-elements-runtime.ssr.es.js +3 -14
  44. package/dist/custom-elements-runtime.store.cjs.js +1 -2
  45. package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
  46. package/dist/custom-elements-runtime.store.es.js +32 -33
  47. package/dist/custom-elements-runtime.store.es.js.map +1 -1
  48. package/dist/custom-elements-runtime.transitions.cjs.js +1 -2
  49. package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
  50. package/dist/custom-elements-runtime.transitions.es.js +200 -210
  51. package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
  52. package/dist/custom-elements-runtime.vite-plugin.cjs.js +4 -2
  53. package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -1
  54. package/dist/custom-elements-runtime.vite-plugin.es.js +155 -78
  55. package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -1
  56. package/dist/helpers-7zLtbh_q.cjs +5 -0
  57. package/dist/helpers-7zLtbh_q.cjs.map +1 -0
  58. package/dist/helpers-kOWgceUQ.js +696 -0
  59. package/dist/helpers-kOWgceUQ.js.map +1 -0
  60. package/dist/hooks-BY_35J9Y.cjs +2 -0
  61. package/dist/hooks-BY_35J9Y.cjs.map +1 -0
  62. package/dist/hooks-Dj1xwqpK.js +407 -0
  63. package/dist/hooks-Dj1xwqpK.js.map +1 -0
  64. package/dist/logger-DIJ0UH3R.js +36 -0
  65. package/dist/{logger-L25axmB-.js.map → logger-DIJ0UH3R.js.map} +1 -1
  66. package/dist/logger-Dkht1dCX.cjs +2 -0
  67. package/dist/{logger-BYIN7ysT.cjs.map → logger-Dkht1dCX.cjs.map} +1 -1
  68. package/dist/namespace-helpers-CIUkG8Mn.js +56 -0
  69. package/dist/{namespace-helpers-BucDdgz_.js.map → namespace-helpers-CIUkG8Mn.js.map} +1 -1
  70. package/dist/namespace-helpers-yYIb7INq.cjs +2 -0
  71. package/dist/{namespace-helpers-Bf7rm9JV.cjs.map → namespace-helpers-yYIb7INq.cjs.map} +1 -1
  72. package/dist/runtime/tag-utils.d.ts +11 -0
  73. package/dist/ssr-Bg9jYXYv.js +171 -0
  74. package/dist/{ssr-H9GDwbTy.js.map → ssr-Bg9jYXYv.js.map} +1 -1
  75. package/dist/ssr-CucZ-Iwz.cjs +4 -0
  76. package/dist/{ssr-DRsGduIK.cjs.map → ssr-CucZ-Iwz.cjs.map} +1 -1
  77. package/dist/ssr.d.ts +2 -0
  78. package/dist/style-A8l3aQ52.cjs +55 -0
  79. package/dist/{style-Bjn8zDiZ.cjs.map → style-A8l3aQ52.cjs.map} +1 -1
  80. package/dist/style-DSSoCbC9.js +1877 -0
  81. package/dist/{style-DuDoj_xK.js.map → style-DSSoCbC9.js.map} +1 -1
  82. package/dist/tag-utils-Dg0vRKq9.js +10 -0
  83. package/dist/tag-utils-Dg0vRKq9.js.map +1 -0
  84. package/dist/tag-utils-ZOoyzCm9.cjs +2 -0
  85. package/dist/tag-utils-ZOoyzCm9.cjs.map +1 -0
  86. package/dist/template-compiler-BJRZoRzZ.js +3044 -0
  87. package/dist/{template-compiler-Cs5axmn4.js.map → template-compiler-BJRZoRzZ.js.map} +1 -1
  88. package/dist/template-compiler-C0SkzB_f.cjs +19 -0
  89. package/dist/{template-compiler-BB4JJdqk.cjs.map → template-compiler-C0SkzB_f.cjs.map} +1 -1
  90. package/dist/vite-plugin.d.ts +96 -2
  91. package/package.json +8 -8
  92. package/dist/css-utils-mgjmH8qX.cjs +0 -577
  93. package/dist/hooks-_3xP4G2N.js +0 -1189
  94. package/dist/hooks-_3xP4G2N.js.map +0 -1
  95. package/dist/hooks-fYQgZk2g.cjs +0 -7
  96. package/dist/hooks-fYQgZk2g.cjs.map +0 -1
  97. package/dist/logger-BYIN7ysT.cjs +0 -3
  98. package/dist/logger-L25axmB-.js +0 -41
  99. package/dist/namespace-helpers-Bf7rm9JV.cjs +0 -3
  100. package/dist/namespace-helpers-BucDdgz_.js +0 -61
  101. package/dist/ssr-DRsGduIK.cjs +0 -5
  102. package/dist/ssr-H9GDwbTy.js +0 -172
  103. package/dist/style-Bjn8zDiZ.cjs +0 -56
  104. package/dist/style-DuDoj_xK.js +0 -1972
  105. package/dist/template-compiler-BB4JJdqk.cjs +0 -23
  106. package/dist/template-compiler-Cs5axmn4.js +0 -3236
@@ -0,0 +1,696 @@
1
+ import { r as e, t } from "./logger-DIJ0UH3R.js";
2
+ //#region src/lib/runtime/scheduler.ts
3
+ function n() {
4
+ let e = (() => {
5
+ try {
6
+ return globalThis.process?.env?.NODE_ENV;
7
+ } catch {
8
+ return;
9
+ }
10
+ })(), t = (() => {
11
+ try {
12
+ if (typeof window > "u") return {
13
+ vitest: !1,
14
+ cypress: !1
15
+ };
16
+ let e = window;
17
+ return {
18
+ vitest: !!e.__vitest__,
19
+ cypress: !!e.Cypress
20
+ };
21
+ } catch {
22
+ return {
23
+ vitest: !1,
24
+ cypress: !1
25
+ };
26
+ }
27
+ })();
28
+ return {
29
+ isTest: e === "test" || t.vitest || t.cypress,
30
+ isVitest: t.vitest,
31
+ isCypress: t.cypress
32
+ };
33
+ }
34
+ var r = new class {
35
+ pendingUpdates = /* @__PURE__ */ new Map();
36
+ isFlushScheduled = !1;
37
+ isFlushing = !1;
38
+ testEnv;
39
+ lastCleanup = 0;
40
+ CLEANUP_INTERVAL = 300 * 1e3;
41
+ MAX_PENDING_SIZE = 1e4;
42
+ pendingIdleUpdates = /* @__PURE__ */ new Map();
43
+ idleCallbackHandle = null;
44
+ constructor() {
45
+ this.testEnv = n(), this.schedulePeriodicCleanup();
46
+ }
47
+ schedule(e, t) {
48
+ let n = t || e;
49
+ this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(n, e), this.isFlushScheduled || this.scheduleFlush();
50
+ }
51
+ scheduleFlush() {
52
+ this.isFlushScheduled = !0, this.testEnv.isTest && !this.isFlushing ? this.flush() : queueMicrotask(() => this.flush());
53
+ }
54
+ flush() {
55
+ if (this.isFlushing) return;
56
+ this.isFlushing = !0;
57
+ let e = this.pendingUpdates;
58
+ this.pendingUpdates = /* @__PURE__ */ new Map(), this.isFlushScheduled = !1;
59
+ try {
60
+ for (let n of e.values()) try {
61
+ n();
62
+ } catch (e) {
63
+ t("Error in batched update:", e);
64
+ }
65
+ } finally {
66
+ this.isFlushing = !1;
67
+ }
68
+ }
69
+ flushImmediately() {
70
+ this.pendingUpdates.size !== 0 && (this.isFlushScheduled = !1, this.flush());
71
+ }
72
+ get pendingCount() {
73
+ return this.pendingUpdates.size;
74
+ }
75
+ get hasPendingUpdates() {
76
+ return this.pendingUpdates.size > 0;
77
+ }
78
+ get isFlushingUpdates() {
79
+ return this.isFlushing;
80
+ }
81
+ schedulePeriodicCleanup() {
82
+ if (this.testEnv.isTest) return;
83
+ let e = () => {
84
+ this.performPeriodicCleanup(), this.testEnv.isTest || setTimeout(e, this.CLEANUP_INTERVAL);
85
+ };
86
+ setTimeout(e, this.CLEANUP_INTERVAL);
87
+ }
88
+ performPeriodicCleanup() {
89
+ let t = Date.now();
90
+ t - this.lastCleanup < this.CLEANUP_INTERVAL || (this.pendingUpdates.size > 100 && e(`Scheduler has ${this.pendingUpdates.size} pending updates. Consider investigating.`), this.lastCleanup = t);
91
+ }
92
+ performEmergencyCleanup(t = this.pendingUpdates) {
93
+ e("Scheduler emergency cleanup: too many pending updates, clearing oldest entries");
94
+ let n = Array.from(t.entries()), r = Math.floor(n.length / 2);
95
+ for (let e = 0; e < r; e++) t.delete(n[e][0]);
96
+ }
97
+ scheduleWithPriority(e, n = "normal", r) {
98
+ if (n === "immediate") {
99
+ try {
100
+ e();
101
+ } catch (e) {
102
+ t("Error in immediate update:", e);
103
+ }
104
+ return;
105
+ }
106
+ if (n === "idle") {
107
+ let t = r ?? e;
108
+ this.pendingIdleUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(this.pendingIdleUpdates), this.pendingIdleUpdates.set(t, e), this.scheduleIdleFlush();
109
+ return;
110
+ }
111
+ let i = r ?? e;
112
+ this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(i, e), this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
113
+ }
114
+ scheduleIdleFlush() {
115
+ if (this.idleCallbackHandle === null) {
116
+ if (this.testEnv.isTest) {
117
+ this.idleCallbackHandle = setTimeout(() => {
118
+ this.idleCallbackHandle = null, this.flushIdleUpdates(null);
119
+ }, 0);
120
+ return;
121
+ }
122
+ typeof requestIdleCallback < "u" ? this.idleCallbackHandle = requestIdleCallback((e) => {
123
+ this.idleCallbackHandle = null, this.flushIdleUpdates(e);
124
+ }, { timeout: 2e3 }) : this.idleCallbackHandle = setTimeout(() => {
125
+ this.idleCallbackHandle = null;
126
+ let e = Date.now();
127
+ this.flushIdleUpdates({
128
+ timeRemaining: () => Math.max(0, 50 - (Date.now() - e)),
129
+ didTimeout: !1
130
+ });
131
+ }, 5);
132
+ }
133
+ }
134
+ flushIdleUpdates(e) {
135
+ let n = Array.from(this.pendingIdleUpdates.entries());
136
+ this.pendingIdleUpdates = /* @__PURE__ */ new Map();
137
+ for (let r = 0; r < n.length; r++) {
138
+ if (e && !e.didTimeout && e.timeRemaining() <= 0) {
139
+ for (let e = r; e < n.length; e++) this.pendingIdleUpdates.set(n[e][0], n[e][1]);
140
+ this.scheduleIdleFlush();
141
+ return;
142
+ }
143
+ try {
144
+ n[r][1]();
145
+ } catch (e) {
146
+ t("Error in idle update:", e);
147
+ }
148
+ }
149
+ }
150
+ }();
151
+ function i(e, t) {
152
+ r.schedule(e, t);
153
+ }
154
+ function a(e, t = "normal", n) {
155
+ r.scheduleWithPriority(e, t, n);
156
+ }
157
+ function o() {
158
+ r.flushImmediately();
159
+ }
160
+ function s() {
161
+ return new Promise((t) => {
162
+ let n = 0;
163
+ for (; r.hasPendingUpdates && n < 100;) r.flushImmediately(), n++;
164
+ n >= 100 && e("[nextTick] Maximum flush iterations reached — possible circular update loop. Check for watchers or computed values that unconditionally mutate reactive state."), queueMicrotask(t);
165
+ });
166
+ }
167
+ //#endregion
168
+ //#region src/lib/runtime/reactive-proxy-cache.ts
169
+ var c = /* @__PURE__ */ new WeakSet(), l = class {
170
+ static cache = /* @__PURE__ */ new WeakMap();
171
+ static arrayHandlerCache = /* @__PURE__ */ new WeakMap();
172
+ static objectHandlerCache = /* @__PURE__ */ new WeakMap();
173
+ static getOrCreateProxy(e, t, n = !1) {
174
+ let r = this.cache.get(e);
175
+ if (r) return r;
176
+ let i = n ? this.getOrCreateArrayHandler(t) : this.getOrCreateObjectHandler(t), a = new Proxy(e, i);
177
+ try {
178
+ u.markAsProxy(a);
179
+ } catch {}
180
+ return this.cache.set(e, a), a;
181
+ }
182
+ static getOrCreateArrayHandler(e) {
183
+ return this.arrayHandlerCache.has(e) || this.arrayHandlerCache.set(e, {
184
+ get: (t, n, r) => {
185
+ let i = Reflect.get(t, n, r);
186
+ return typeof i == "function" && typeof n == "string" && [
187
+ "push",
188
+ "pop",
189
+ "shift",
190
+ "unshift",
191
+ "splice",
192
+ "sort",
193
+ "reverse",
194
+ "fill",
195
+ "copyWithin"
196
+ ].includes(n) ? function(...n) {
197
+ let r = i.apply(t, n);
198
+ return e.triggerUpdate(), r;
199
+ } : typeof i == "object" && i && typeof n == "string" ? e.makeReactiveValue(i) : i;
200
+ },
201
+ set: (t, n, r) => (t[n] = e.makeReactiveValue(r), e.triggerUpdate(), !0),
202
+ deleteProperty: (t, n) => (delete t[n], e.triggerUpdate(), !0)
203
+ }), this.arrayHandlerCache.get(e);
204
+ }
205
+ static getOrCreateObjectHandler(e) {
206
+ return this.objectHandlerCache.has(e) || this.objectHandlerCache.set(e, {
207
+ get: (t, n, r) => {
208
+ let i = Reflect.get(t, n, r);
209
+ return typeof i == "object" && i && typeof n == "string" ? e.makeReactiveValue(i) : i;
210
+ },
211
+ set: (t, n, r) => (t[n] = e.makeReactiveValue(r), e.triggerUpdate(), !0),
212
+ deleteProperty: (t, n) => (delete t[n], e.triggerUpdate(), !0)
213
+ }), this.objectHandlerCache.get(e);
214
+ }
215
+ static hasProxy(e) {
216
+ return this.cache.has(e);
217
+ }
218
+ static clear() {
219
+ this.cache = /* @__PURE__ */ new WeakMap(), this.arrayHandlerCache = /* @__PURE__ */ new WeakMap(), this.objectHandlerCache = /* @__PURE__ */ new WeakMap();
220
+ }
221
+ static getStats() {
222
+ return { hasCachedProxies: this.cache instanceof WeakMap };
223
+ }
224
+ }, u = class {
225
+ static contextCache = /* @__PURE__ */ new WeakMap();
226
+ static createReactiveProxy(e, t, n) {
227
+ try {
228
+ if (c.has(e)) return e;
229
+ } catch {}
230
+ let r = Array.isArray(e), i = this.contextCache.get(t);
231
+ i || (i = /* @__PURE__ */ new WeakMap(), this.contextCache.set(t, i));
232
+ let a = i.get(n);
233
+ return a || (a = {
234
+ triggerUpdate: t,
235
+ makeReactiveValue: n
236
+ }, i.set(n, a)), l.getOrCreateProxy(e, a, r);
237
+ }
238
+ static markAsProxy(e) {
239
+ if (e) try {
240
+ c.add(e);
241
+ } catch {}
242
+ }
243
+ }, d = !1;
244
+ function f() {
245
+ return d;
246
+ }
247
+ function p() {
248
+ d && e("[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."), d = !0;
249
+ }
250
+ function m() {
251
+ d = !1;
252
+ }
253
+ //#endregion
254
+ //#region src/lib/runtime/reactive.ts
255
+ var h = 0;
256
+ function g(e) {
257
+ return `${e}-${++h}`;
258
+ }
259
+ var _ = new class {
260
+ currentComponentStack = [];
261
+ componentData = /* @__PURE__ */ new Map();
262
+ stateStorage = /* @__PURE__ */ new Map();
263
+ trackingDisabled = !1;
264
+ setCurrentComponent(e, t) {
265
+ if (this.currentComponentStack.push(e), !this.componentData.has(e)) this.componentData.set(e, {
266
+ dependencies: /* @__PURE__ */ new Set(),
267
+ renderFn: t,
268
+ stateIndex: 0,
269
+ lastWarnTime: 0,
270
+ watchers: /* @__PURE__ */ new Map()
271
+ });
272
+ else {
273
+ let n = this.componentData.get(e);
274
+ if (n.watchers && n.watchers.size) {
275
+ for (let e of n.watchers.values()) try {
276
+ this.cleanup(e);
277
+ } catch {}
278
+ n.watchers.clear();
279
+ }
280
+ n.renderFn = t, n.stateIndex = 0;
281
+ }
282
+ }
283
+ clearCurrentComponent() {
284
+ this.currentComponentStack.pop();
285
+ }
286
+ getCurrentComponentId() {
287
+ return this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
288
+ }
289
+ registerWatcher(e, t) {
290
+ let n = this.componentData.get(e);
291
+ n && n.watchers.set(t, t);
292
+ }
293
+ disableTracking() {
294
+ this.trackingDisabled = !0;
295
+ }
296
+ enableTracking() {
297
+ this.trackingDisabled = !1;
298
+ }
299
+ isRenderingComponent() {
300
+ return this.currentComponentStack.length > 0;
301
+ }
302
+ shouldEmitRenderWarning() {
303
+ let e = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
304
+ if (!e) return !0;
305
+ let t = this.componentData.get(e);
306
+ if (!t) return !0;
307
+ let n = Date.now();
308
+ return n - t.lastWarnTime < 1e3 ? !1 : (t.lastWarnTime = n, !0);
309
+ }
310
+ withoutTracking(e) {
311
+ let t = this.trackingDisabled;
312
+ this.trackingDisabled = !0;
313
+ try {
314
+ return e();
315
+ } finally {
316
+ this.trackingDisabled = t;
317
+ }
318
+ }
319
+ getOrCreateState(e) {
320
+ let t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
321
+ if (!t) return new v(e);
322
+ let n = this.componentData.get(t);
323
+ if (!n) return new v(e);
324
+ let r = `${t}:${n.stateIndex++}`, i = this.stateStorage.get(r);
325
+ return i || (i = new v(e), this.stateStorage.set(r, i)), i;
326
+ }
327
+ trackDependency(e) {
328
+ if (this.trackingDisabled) return;
329
+ let t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
330
+ if (!t) return;
331
+ let n = this.componentData.get(t);
332
+ n && (n.dependencies.add(e), e.addDependent(t));
333
+ }
334
+ propagateDependencies(e) {
335
+ if (this.trackingDisabled) return;
336
+ let t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
337
+ if (!t || t === e) return;
338
+ let n = this.componentData.get(e);
339
+ if (!n) return;
340
+ let r = this.componentData.get(t);
341
+ if (r) for (let e of n.dependencies) r.dependencies.add(e), e.addDependent(t);
342
+ }
343
+ triggerUpdate(e) {
344
+ let t = e.getDependents();
345
+ for (let e of t) {
346
+ let t = this.componentData.get(e);
347
+ t && i(t.renderFn, e);
348
+ }
349
+ }
350
+ cleanup(e) {
351
+ let t = this.componentData.get(e);
352
+ if (t) {
353
+ if (t.watchers.size) for (let e of t.watchers.values()) try {
354
+ this.cleanup(e);
355
+ } catch {}
356
+ for (let n of t.dependencies) n.removeDependent(e);
357
+ this.componentData.delete(e);
358
+ }
359
+ let n = e + ":";
360
+ for (let e of this.stateStorage.keys()) e.startsWith(n) && this.stateStorage.delete(e);
361
+ }
362
+ }(), v = class {
363
+ _value;
364
+ _rawValue;
365
+ dependents = /* @__PURE__ */ new Set();
366
+ constructor(e) {
367
+ this._rawValue = e, this._value = this.makeReactive(e);
368
+ try {
369
+ Object.defineProperty(this, Symbol.for("@cer/ReactiveState"), {
370
+ value: !0,
371
+ enumerable: !1,
372
+ configurable: !1
373
+ });
374
+ } catch {}
375
+ }
376
+ get value() {
377
+ return _.trackDependency(this), this._value;
378
+ }
379
+ set value(t) {
380
+ Object.is(t, this._rawValue) || (_.isRenderingComponent() && _.shouldEmitRenderWarning() && e("🚨 State modification detected during render! This can cause infinite loops.\n • Move state updates to event handlers\n • Use watchEffect/watch for side effects\n • Ensure computed properties don't modify state"), this._rawValue = t, this._value = this.makeReactive(t), _.triggerUpdate(this));
381
+ }
382
+ peek() {
383
+ return this._value;
384
+ }
385
+ initSilent(e) {
386
+ this._rawValue = e, this._value = e;
387
+ }
388
+ addDependent(e) {
389
+ this.dependents.add(e);
390
+ }
391
+ removeDependent(e) {
392
+ this.dependents.delete(e);
393
+ }
394
+ getDependents() {
395
+ return this.dependents;
396
+ }
397
+ makeReactive(e) {
398
+ return typeof e != "object" || !e || typeof Node < "u" && e instanceof Node || typeof Element < "u" && e instanceof Element || typeof HTMLElement < "u" && e instanceof HTMLElement ? e : u.createReactiveProxy(e, () => _.triggerUpdate(this), (e) => this.makeReactive(e));
399
+ }
400
+ };
401
+ function y(e) {
402
+ return _.getOrCreateState(e === void 0 ? null : e);
403
+ }
404
+ function b(e) {
405
+ if (!e || typeof e != "object") return !1;
406
+ try {
407
+ let t = Symbol.for("@cer/ReactiveState");
408
+ return Object.prototype.hasOwnProperty.call(e, t);
409
+ } catch {
410
+ return !1;
411
+ }
412
+ }
413
+ function x(e) {
414
+ let t, n = !0, r = g("computed"), i = () => {
415
+ n = !0;
416
+ };
417
+ try {
418
+ let e = _.getCurrentComponentId();
419
+ e && _.registerWatcher(e, r);
420
+ } catch {}
421
+ return _.setCurrentComponent(r, i), t = e(), _.clearCurrentComponent(), n = !1, { get value() {
422
+ return n &&= (_.setCurrentComponent(r, i), t = e(), _.clearCurrentComponent(), !1), _.propagateDependencies(r), t;
423
+ } };
424
+ }
425
+ function S(e) {
426
+ if (f()) return () => {};
427
+ let t = g("effect");
428
+ try {
429
+ let e = _.getCurrentComponentId();
430
+ e && _.registerWatcher(e, t);
431
+ } catch {}
432
+ let n = () => {
433
+ _.setCurrentComponent(t, n);
434
+ try {
435
+ e();
436
+ } finally {
437
+ _.clearCurrentComponent();
438
+ }
439
+ };
440
+ return n(), () => {
441
+ _.cleanup(t);
442
+ };
443
+ }
444
+ var C = 50;
445
+ function w(t, n = /* @__PURE__ */ new WeakMap(), r = 0) {
446
+ if (typeof t != "object" || !t) return t;
447
+ let i = t;
448
+ if (n.has(i)) return n.get(i);
449
+ if (r > C) return e(`[watch] Deep clone exceeded ${C} nesting levels. Returning a reference at this depth instead of cloning further. Consider restructuring your state or switching to a shallow watch.`), t;
450
+ if (typeof Node < "u" && i instanceof Node) return t;
451
+ if (i instanceof Date) return new Date(i.getTime());
452
+ if (Array.isArray(i)) {
453
+ let e = [];
454
+ n.set(i, e);
455
+ for (let t = 0; t < i.length; t++) e.push(w(i[t], n, r + 1));
456
+ return e;
457
+ }
458
+ let a = {};
459
+ n.set(i, a);
460
+ for (let e of Object.keys(i)) try {
461
+ a[e] = w(i[e], n, r + 1);
462
+ } catch {}
463
+ return a;
464
+ }
465
+ function T(e, t, n) {
466
+ if (f()) return () => {};
467
+ let r, i = b(e) ? () => e.value : e, a = g("watch");
468
+ try {
469
+ let e = _.getCurrentComponentId();
470
+ e && _.registerWatcher(e, a);
471
+ } catch {}
472
+ let o = () => {
473
+ _.setCurrentComponent(a, o);
474
+ let e = i();
475
+ if (_.clearCurrentComponent(), n?.deep) {
476
+ let n = _.withoutTracking(() => w(e));
477
+ t(n, r), r = n;
478
+ } else e !== r && (t(e, r), r = e);
479
+ };
480
+ return _.setCurrentComponent(a, o), r = i(), _.clearCurrentComponent(), n?.deep && (r = _.withoutTracking(() => w(r))), n && n.immediate && t(r, void 0), () => {
481
+ _.cleanup(a);
482
+ };
483
+ }
484
+ //#endregion
485
+ //#region src/lib/runtime/helpers.ts
486
+ var E = (e) => {
487
+ try {
488
+ e();
489
+ } catch {}
490
+ }, D = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), A = 500, j, M, N = !1, P = !1, F, I = !!globalThis.process?.versions?.node;
491
+ function L(e) {
492
+ if (D.has(e)) return D.get(e);
493
+ let t = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
494
+ return D.size < A && D.set(e, t), t;
495
+ }
496
+ function R(e) {
497
+ if (O.has(e)) return O.get(e);
498
+ let t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase());
499
+ return O.size < A && O.set(e, t), t;
500
+ }
501
+ function z(e) {
502
+ if (typeof e == "string") {
503
+ if (k.has(e)) return k.get(e);
504
+ let t = e.replace(/[&<>"']/g, (e) => ({
505
+ "&": "&amp;",
506
+ "<": "&lt;",
507
+ ">": "&gt;",
508
+ "\"": "&quot;",
509
+ "'": "&#39;"
510
+ })[e]);
511
+ return t !== e && k.size < A && k.set(e, t), t;
512
+ }
513
+ return e;
514
+ }
515
+ function B(t) {
516
+ if (!t) return "";
517
+ let n = String(t);
518
+ if (typeof document < "u" && typeof document.createElement == "function") {
519
+ let e = n.replace(/</g, "").replace(/>/g, ""), t = F ||= document.createElement("div");
520
+ try {
521
+ B._el = t;
522
+ } catch {}
523
+ return t.innerHTML = e, (t.textContent || "").replace(RegExp("", "g"), "<").replace(RegExp("", "g"), ">");
524
+ }
525
+ let r = {
526
+ lt: "<",
527
+ gt: ">",
528
+ amp: "&",
529
+ quot: "\"",
530
+ apos: "'",
531
+ nbsp: "\xA0"
532
+ }, i = j ?? B._namedMap, a = i;
533
+ if (!a && I) try {
534
+ let e = globalThis.require;
535
+ if (typeof e == "function") for (let t of [
536
+ "@jasonshimmy/custom-elements-runtime/entities.json",
537
+ "../../entities.json",
538
+ "../../../entities.json",
539
+ "../entities.json",
540
+ "./entities.json"
541
+ ]) try {
542
+ let n = e(t);
543
+ if (n && typeof n == "object") {
544
+ a = n;
545
+ break;
546
+ }
547
+ } catch {}
548
+ } catch {}
549
+ if (!a) {
550
+ a = r, N = !0;
551
+ try {
552
+ B._usedFallback = !0;
553
+ } catch {}
554
+ let e = B._namedMapLoader ?? M;
555
+ e && e().then((e) => {
556
+ j = e;
557
+ try {
558
+ B._namedMap = e;
559
+ } catch {}
560
+ }).catch(() => {});
561
+ }
562
+ if ((N || B._usedFallback) && !(P || B._warnedFallback)) {
563
+ P = !0;
564
+ try {
565
+ B._warnedFallback = !0;
566
+ } catch {}
567
+ try {
568
+ e("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.");
569
+ } catch {}
570
+ }
571
+ return n.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (e, t) => {
572
+ if (t.charCodeAt(0) === 35) {
573
+ let e = (t.charAt(1) || "").toLowerCase() === "x" ? parseInt(t.slice(2), 16) : parseInt(t.slice(1), 10);
574
+ return Number.isNaN(e) ? `&${t};` : String.fromCodePoint(e);
575
+ }
576
+ let n = a[t] ?? (i && i[t]);
577
+ return n === void 0 ? `&${t};` : n;
578
+ });
579
+ }
580
+ async function V() {
581
+ let e = [
582
+ "@jasonshimmy",
583
+ "custom-elements-runtime",
584
+ "entities.json"
585
+ ].join("/");
586
+ try {
587
+ // @vite-ignore: dynamic import specifier constructed at runtime
588
+ let t = await import(
589
+ /* @vite-ignore */
590
+ e
591
+ );
592
+ return t && (t.default || t);
593
+ } catch {
594
+ try {
595
+ let t = [
596
+ e,
597
+ "./entities.json",
598
+ "../../entities.json",
599
+ "../../../entities.json"
600
+ ];
601
+ for (let e of t) try {
602
+ // @vite-ignore: intentionally dynamic path candidates for dev/local resolution
603
+ let t = await import(
604
+ /* @vite-ignore */
605
+ e
606
+ );
607
+ if (t) return t && (t.default || t);
608
+ } catch {}
609
+ return {
610
+ lt: "<",
611
+ gt: ">",
612
+ amp: "&",
613
+ quot: "\"",
614
+ apos: "'",
615
+ nbsp: "\xA0"
616
+ };
617
+ } catch {
618
+ return {
619
+ lt: "<",
620
+ gt: ">",
621
+ amp: "&",
622
+ quot: "\"",
623
+ apos: "'",
624
+ nbsp: "\xA0"
625
+ };
626
+ }
627
+ }
628
+ }
629
+ M = V, B._namedMapLoader = V;
630
+ function H(e, t) {
631
+ !e || typeof e != "object" || j && !t?.overwrite || (j = e);
632
+ }
633
+ function U() {
634
+ j = void 0;
635
+ }
636
+ function W(e) {
637
+ let t = String(e);
638
+ return {
639
+ __unsafeHTML: t,
640
+ __rawHTML: t
641
+ };
642
+ }
643
+ function G(e) {
644
+ return !!e && (typeof e.__unsafeHTML == "string" || typeof e.__rawHTML == "string");
645
+ }
646
+ function K(e, t) {
647
+ if (typeof t == "string") {
648
+ if (t === "") return;
649
+ let n = t.split("."), r = e;
650
+ for (let e of n) {
651
+ if (typeof r != "object" || !r) {
652
+ r = void 0;
653
+ break;
654
+ }
655
+ r = r[e];
656
+ }
657
+ return b(r) ? r.value : r;
658
+ }
659
+ return t;
660
+ }
661
+ function q(e, t, n) {
662
+ let r = String(t).split("."), i = r.pop();
663
+ if (!i) return;
664
+ let a = r.reduce((e, t) => (e[t] ?? (e[t] = {}), e[t]), e);
665
+ b(a[i]) ? a[i].value = n : a[i] = n;
666
+ }
667
+ function J(e) {
668
+ try {
669
+ if (e && typeof e == "object") {
670
+ if (b(e)) return e.value;
671
+ if ("value" in e) {
672
+ let t = e.value;
673
+ return t == null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : e;
674
+ }
675
+ }
676
+ } catch {}
677
+ return e;
678
+ }
679
+ function Y(e) {
680
+ let t = J(e);
681
+ if (t == null) return null;
682
+ let n = typeof t;
683
+ return n === "string" || n === "number" || n === "boolean" ? String(t) : null;
684
+ }
685
+ function X(e) {
686
+ if (!e || typeof e != "string") return !1;
687
+ if (e === "class" || e.endsWith("Class")) return !0;
688
+ if (e.includes("-")) try {
689
+ if (e.split("-").some((e) => e === "class")) return !0;
690
+ } catch {}
691
+ return !1;
692
+ }
693
+ //#endregion
694
+ export { m as C, s as D, o as E, i as O, p as S, n as T, b as _, X as a, T as b, H as c, q as d, R as f, x as g, v as h, K as i, a as k, E as l, W as m, B as n, G as o, L as p, z as r, V as s, U as t, Y as u, _ as v, f as w, S as x, y };
695
+
696
+ //# sourceMappingURL=helpers-kOWgceUQ.js.map