@elurjs/core 3.5.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 (191) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -0
  3. package/dist/lib/async.cjs +16 -0
  4. package/dist/lib/async.js +123 -0
  5. package/dist/lib/component.cjs +2 -0
  6. package/dist/lib/component.js +66 -0
  7. package/dist/lib/context.cjs +2 -0
  8. package/dist/lib/context.js +52 -0
  9. package/dist/lib/devtools.cjs +59 -0
  10. package/dist/lib/devtools.js +419 -0
  11. package/dist/lib/elur/async.cjs +16 -0
  12. package/dist/lib/elur/async.cjs.map +1 -0
  13. package/dist/lib/elur/async.d.cts +32 -0
  14. package/dist/lib/elur/async.d.ts +32 -0
  15. package/dist/lib/elur/async.js +123 -0
  16. package/dist/lib/elur/async.js.map +1 -0
  17. package/dist/lib/elur/component.cjs +2 -0
  18. package/dist/lib/elur/component.cjs.map +1 -0
  19. package/dist/lib/elur/component.d.cts +17 -0
  20. package/dist/lib/elur/component.d.ts +17 -0
  21. package/dist/lib/elur/component.js +66 -0
  22. package/dist/lib/elur/component.js.map +1 -0
  23. package/dist/lib/elur/context.cjs +2 -0
  24. package/dist/lib/elur/context.cjs.map +1 -0
  25. package/dist/lib/elur/context.d.cts +29 -0
  26. package/dist/lib/elur/context.d.ts +29 -0
  27. package/dist/lib/elur/context.js +52 -0
  28. package/dist/lib/elur/context.js.map +1 -0
  29. package/dist/lib/elur/devtools.cjs +59 -0
  30. package/dist/lib/elur/devtools.cjs.map +1 -0
  31. package/dist/lib/elur/devtools.d.cts +24 -0
  32. package/dist/lib/elur/devtools.d.ts +24 -0
  33. package/dist/lib/elur/devtools.js +419 -0
  34. package/dist/lib/elur/devtools.js.map +1 -0
  35. package/dist/lib/elur/form.cjs +2 -0
  36. package/dist/lib/elur/form.cjs.map +1 -0
  37. package/dist/lib/elur/form.d.cts +283 -0
  38. package/dist/lib/elur/form.d.ts +283 -0
  39. package/dist/lib/elur/form.js +315 -0
  40. package/dist/lib/elur/form.js.map +1 -0
  41. package/dist/lib/elur/hydrate/index.cjs +2 -0
  42. package/dist/lib/elur/hydrate/index.cjs.map +1 -0
  43. package/dist/lib/elur/hydrate/index.d.cts +13 -0
  44. package/dist/lib/elur/hydrate/index.d.ts +13 -0
  45. package/dist/lib/elur/hydrate/index.js +410 -0
  46. package/dist/lib/elur/hydrate/index.js.map +1 -0
  47. package/dist/lib/elur/index.d.cts +19 -0
  48. package/dist/lib/elur/index.d.ts +19 -0
  49. package/dist/lib/elur/lifecycle.cjs +2 -0
  50. package/dist/lib/elur/lifecycle.cjs.map +1 -0
  51. package/dist/lib/elur/lifecycle.d.cts +45 -0
  52. package/dist/lib/elur/lifecycle.d.ts +45 -0
  53. package/dist/lib/elur/lifecycle.js +39 -0
  54. package/dist/lib/elur/lifecycle.js.map +1 -0
  55. package/dist/lib/elur/plugins.cjs +2 -0
  56. package/dist/lib/elur/plugins.cjs.map +1 -0
  57. package/dist/lib/elur/plugins.d.cts +48 -0
  58. package/dist/lib/elur/plugins.d.ts +48 -0
  59. package/dist/lib/elur/plugins.js +59 -0
  60. package/dist/lib/elur/plugins.js.map +1 -0
  61. package/dist/lib/elur/reactivity.cjs +2 -0
  62. package/dist/lib/elur/reactivity.cjs.map +1 -0
  63. package/dist/lib/elur/reactivity.d.cts +60 -0
  64. package/dist/lib/elur/reactivity.d.ts +60 -0
  65. package/dist/lib/elur/reactivity.js +188 -0
  66. package/dist/lib/elur/reactivity.js.map +1 -0
  67. package/dist/lib/elur/router.cjs +12 -0
  68. package/dist/lib/elur/router.cjs.map +1 -0
  69. package/dist/lib/elur/router.d.cts +137 -0
  70. package/dist/lib/elur/router.d.ts +137 -0
  71. package/dist/lib/elur/router.js +513 -0
  72. package/dist/lib/elur/router.js.map +1 -0
  73. package/dist/lib/elur/server/index.cjs +2 -0
  74. package/dist/lib/elur/server/index.cjs.map +1 -0
  75. package/dist/lib/elur/server/index.d.cts +44 -0
  76. package/dist/lib/elur/server/index.d.ts +44 -0
  77. package/dist/lib/elur/server/index.js +307 -0
  78. package/dist/lib/elur/server/index.js.map +1 -0
  79. package/dist/lib/elur/store.cjs +2 -0
  80. package/dist/lib/elur/store.cjs.map +1 -0
  81. package/dist/lib/elur/store.d.cts +137 -0
  82. package/dist/lib/elur/store.d.ts +137 -0
  83. package/dist/lib/elur/store.js +143 -0
  84. package/dist/lib/elur/store.js.map +1 -0
  85. package/dist/lib/elur/template/bindings.cjs +2 -0
  86. package/dist/lib/elur/template/bindings.cjs.map +1 -0
  87. package/dist/lib/elur/template/bindings.d.cts +40 -0
  88. package/dist/lib/elur/template/bindings.d.ts +40 -0
  89. package/dist/lib/elur/template/bindings.js +214 -0
  90. package/dist/lib/elur/template/bindings.js.map +1 -0
  91. package/dist/lib/elur/template/dom-write.cjs +2 -0
  92. package/dist/lib/elur/template/dom-write.cjs.map +1 -0
  93. package/dist/lib/elur/template/dom-write.d.cts +5 -0
  94. package/dist/lib/elur/template/dom-write.d.ts +5 -0
  95. package/dist/lib/elur/template/dom-write.js +16 -0
  96. package/dist/lib/elur/template/dom-write.js.map +1 -0
  97. package/dist/lib/elur/template/error-boundary.cjs +2 -0
  98. package/dist/lib/elur/template/error-boundary.cjs.map +1 -0
  99. package/dist/lib/elur/template/error-boundary.d.cts +7 -0
  100. package/dist/lib/elur/template/error-boundary.d.ts +7 -0
  101. package/dist/lib/elur/template/error-boundary.js +90 -0
  102. package/dist/lib/elur/template/error-boundary.js.map +1 -0
  103. package/dist/lib/elur/template/html.cjs +2 -0
  104. package/dist/lib/elur/template/html.cjs.map +1 -0
  105. package/dist/lib/elur/template/html.d.cts +8 -0
  106. package/dist/lib/elur/template/html.d.ts +8 -0
  107. package/dist/lib/elur/template/html.js +104 -0
  108. package/dist/lib/elur/template/html.js.map +1 -0
  109. package/dist/lib/elur/template/index.cjs +1 -0
  110. package/dist/lib/elur/template/index.d.cts +15 -0
  111. package/dist/lib/elur/template/index.d.ts +15 -0
  112. package/dist/lib/elur/template/index.js +13 -0
  113. package/dist/lib/elur/template/keyed-diff.cjs +2 -0
  114. package/dist/lib/elur/template/keyed-diff.cjs.map +1 -0
  115. package/dist/lib/elur/template/keyed-diff.d.cts +32 -0
  116. package/dist/lib/elur/template/keyed-diff.d.ts +32 -0
  117. package/dist/lib/elur/template/keyed-diff.js +100 -0
  118. package/dist/lib/elur/template/keyed-diff.js.map +1 -0
  119. package/dist/lib/elur/template/keyed.cjs +2 -0
  120. package/dist/lib/elur/template/keyed.cjs.map +1 -0
  121. package/dist/lib/elur/template/keyed.d.cts +27 -0
  122. package/dist/lib/elur/template/keyed.d.ts +27 -0
  123. package/dist/lib/elur/template/keyed.js +52 -0
  124. package/dist/lib/elur/template/keyed.js.map +1 -0
  125. package/dist/lib/elur/template/mount-helpers.cjs +2 -0
  126. package/dist/lib/elur/template/mount-helpers.cjs.map +1 -0
  127. package/dist/lib/elur/template/mount-helpers.d.cts +29 -0
  128. package/dist/lib/elur/template/mount-helpers.d.ts +29 -0
  129. package/dist/lib/elur/template/mount-helpers.js +132 -0
  130. package/dist/lib/elur/template/mount-helpers.js.map +1 -0
  131. package/dist/lib/elur/template/node-binding.cjs +2 -0
  132. package/dist/lib/elur/template/node-binding.cjs.map +1 -0
  133. package/dist/lib/elur/template/node-binding.d.cts +6 -0
  134. package/dist/lib/elur/template/node-binding.d.ts +6 -0
  135. package/dist/lib/elur/template/node-binding.js +95 -0
  136. package/dist/lib/elur/template/node-binding.js.map +1 -0
  137. package/dist/lib/elur/template/portal.cjs +2 -0
  138. package/dist/lib/elur/template/portal.cjs.map +1 -0
  139. package/dist/lib/elur/template/portal.d.cts +19 -0
  140. package/dist/lib/elur/template/portal.d.ts +19 -0
  141. package/dist/lib/elur/template/portal.js +49 -0
  142. package/dist/lib/elur/template/portal.js.map +1 -0
  143. package/dist/lib/elur/template/raw.cjs +2 -0
  144. package/dist/lib/elur/template/raw.cjs.map +1 -0
  145. package/dist/lib/elur/template/raw.d.cts +9 -0
  146. package/dist/lib/elur/template/raw.d.ts +9 -0
  147. package/dist/lib/elur/template/raw.js +29 -0
  148. package/dist/lib/elur/template/raw.js.map +1 -0
  149. package/dist/lib/elur/template/sanitize.cjs +2 -0
  150. package/dist/lib/elur/template/sanitize.cjs.map +1 -0
  151. package/dist/lib/elur/template/sanitize.d.cts +16 -0
  152. package/dist/lib/elur/template/sanitize.d.ts +16 -0
  153. package/dist/lib/elur/template/sanitize.js +29 -0
  154. package/dist/lib/elur/template/sanitize.js.map +1 -0
  155. package/dist/lib/elur/template/transitions.cjs +2 -0
  156. package/dist/lib/elur/template/transitions.cjs.map +1 -0
  157. package/dist/lib/elur/template/transitions.d.cts +43 -0
  158. package/dist/lib/elur/template/transitions.d.ts +43 -0
  159. package/dist/lib/elur/template/transitions.js +96 -0
  160. package/dist/lib/elur/template/transitions.js.map +1 -0
  161. package/dist/lib/elur/template/types.cjs +2 -0
  162. package/dist/lib/elur/template/types.cjs.map +1 -0
  163. package/dist/lib/elur/template/types.d.cts +114 -0
  164. package/dist/lib/elur/template/types.d.ts +114 -0
  165. package/dist/lib/elur/template/types.js +23 -0
  166. package/dist/lib/elur/template/types.js.map +1 -0
  167. package/dist/lib/elur.cjs +1 -0
  168. package/dist/lib/elur.js +18 -0
  169. package/dist/lib/form.cjs +2 -0
  170. package/dist/lib/form.js +315 -0
  171. package/dist/lib/hydrate.cjs +2 -0
  172. package/dist/lib/hydrate.js +410 -0
  173. package/dist/lib/index.cjs +1 -0
  174. package/dist/lib/index.d.cts +2 -0
  175. package/dist/lib/index.d.ts +2 -0
  176. package/dist/lib/index.js +18 -0
  177. package/dist/lib/lifecycle.cjs +2 -0
  178. package/dist/lib/lifecycle.js +39 -0
  179. package/dist/lib/plugins.cjs +2 -0
  180. package/dist/lib/plugins.js +59 -0
  181. package/dist/lib/router.cjs +12 -0
  182. package/dist/lib/router.js +513 -0
  183. package/dist/lib/server.cjs +2 -0
  184. package/dist/lib/server.js +307 -0
  185. package/dist/lib/signals.cjs +2 -0
  186. package/dist/lib/signals.js +188 -0
  187. package/dist/lib/store.cjs +2 -0
  188. package/dist/lib/store.js +143 -0
  189. package/dist/lib/template.cjs +1 -0
  190. package/dist/lib/template.js +13 -0
  191. package/package.json +216 -0
@@ -0,0 +1,410 @@
1
+ import { effect as e } from "./signals.js";
2
+ import { ELUR_RENDER_PROTOCOL as t, ELUR_TEMPLATE_DESCRIPTOR as n, isElurTemplate as r, isKeyedList as i } from "./elur/template/types.js";
3
+ import { isElurComponent as a } from "./lifecycle.js";
4
+ import { _captureContextSnapshot as o, _popComponentContext as s, _pushComponentContext as c } from "./context.js";
5
+ import { deserializeRepeatKey as l, normalizeRepeatKey as u, serializeRepeatKey as d } from "./elur/template/keyed.js";
6
+ import { createKeyedMount as f, reconcileKeyedList as p } from "./elur/template/keyed-diff.js";
7
+ import { sanitizeUrl as m } from "./elur/template/sanitize.js";
8
+ import { activateDelegatedEvent as h, isDelegableEvent as g } from "./elur/template/bindings.js";
9
+ //#region src/elur/hydrate/index.ts
10
+ function _(e, t, r = {}) {
11
+ try {
12
+ if (a(e)) return v(e, t, r);
13
+ let i = e[n];
14
+ return i || j(r, -1, "descriptor", "Template has no hydration descriptor"), { unmount: y(i, t, r) };
15
+ } catch (n) {
16
+ if (r.mismatch === "throw") throw n;
17
+ return r.mismatch !== "remount" && console.warn("[elur] Hydration mismatch; remounting root:", n), t.replaceChildren(), { unmount: a(e) ? e.render()._render(t, null) : e._render(t, null) };
18
+ }
19
+ }
20
+ function v(e, t, r) {
21
+ c();
22
+ let i = () => {};
23
+ try {
24
+ try {
25
+ e.onInit?.();
26
+ } catch (t) {
27
+ if (e.onError) e.onError(t);
28
+ else throw t;
29
+ }
30
+ let a = e.render()[n];
31
+ a || j(r, -1, "descriptor", "Component template has no hydration descriptor"), i = y(a, t, r);
32
+ } finally {
33
+ s();
34
+ }
35
+ let a = e.onMount?.();
36
+ return { unmount() {
37
+ e.onUnmount?.(), typeof a == "function" && a(), i();
38
+ } };
39
+ }
40
+ function y(e, t, n, r) {
41
+ let i = b(t, r), a = [];
42
+ for (let t = 0; t < e.contexts.length; t++) {
43
+ let r = e.contexts[t], o = e.values[t];
44
+ if (r.type === "event") {
45
+ let e = i.events.get(t);
46
+ e || j(n, t, "event", `Missing event marker ${t}`), e.removeAttribute(`data-elur-e-${t}`), a.push(S(e, r.eventName, r.modifiers, o));
47
+ continue;
48
+ }
49
+ if (r.type === "attr") {
50
+ let e = i.attributes.get(t);
51
+ e || j(n, t, "attribute", `Missing attribute marker ${t}`), e.removeAttribute(`data-elur-a-${t}`), a.push(C(e, r.attrName, r.url === !0, o));
52
+ continue;
53
+ }
54
+ let s = i.nodes.get(t);
55
+ s || j(n, t, "node", `Missing node marker ${t}`);
56
+ let c = w(s, o, n, i.keyed.get(t), i.arrayItems.get(t));
57
+ c && a.push(c);
58
+ }
59
+ return () => {
60
+ for (let e = a.length - 1; e >= 0; e--) a[e]();
61
+ };
62
+ }
63
+ function b(e, t) {
64
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = [], l = [], u = [], d = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT), f;
65
+ for (; f = d.nextNode();) {
66
+ if (t && !x(f, t)) continue;
67
+ if (f.nodeType === Node.COMMENT_NODE) {
68
+ let e = f, t = /^elur-(\d+)$/.exec(e.data);
69
+ if (t) {
70
+ let n = Number(t[1]);
71
+ c.length === 0 && r.set(n, e), c.push(n);
72
+ continue;
73
+ }
74
+ let i = /^elur-end-(\d+)$/.exec(e.data);
75
+ if (i) {
76
+ let t = Number(i[1]);
77
+ if (c.pop() === t && c.length === 0) {
78
+ let i = r.get(t);
79
+ i && n.set(t, {
80
+ start: i,
81
+ end: e
82
+ });
83
+ }
84
+ continue;
85
+ }
86
+ let a = /^elur-ki:(.+)$/.exec(e.data);
87
+ if (a) {
88
+ let t = a[1];
89
+ l.length === 0 && c.length === 1 ? l.push({
90
+ start: e,
91
+ serializedKey: t,
92
+ parentIndex: c[c.length - 1]
93
+ }) : l.push({
94
+ start: e,
95
+ serializedKey: t,
96
+ parentIndex: -1
97
+ });
98
+ continue;
99
+ }
100
+ if (e.data === "elur-ke") {
101
+ let t = l.pop();
102
+ if (t) {
103
+ if (t.parentIndex >= 0) {
104
+ let n = o.get(t.parentIndex) ?? [];
105
+ n.push({
106
+ start: t.start,
107
+ end: e,
108
+ serializedKey: t.serializedKey
109
+ }), o.set(t.parentIndex, n);
110
+ }
111
+ } else throw Error("[elur] Hydration marker mismatch: orphan keyed end marker (elur-ke)");
112
+ continue;
113
+ }
114
+ if (e.data === "elur-ai") {
115
+ u.length === 0 && c.length === 1 ? u.push({
116
+ start: e,
117
+ parentIndex: c[c.length - 1]
118
+ }) : u.push({
119
+ start: e,
120
+ parentIndex: -1
121
+ });
122
+ continue;
123
+ }
124
+ if (e.data === "elur-aiend") {
125
+ let t = u.pop();
126
+ if (t && t.parentIndex >= 0) {
127
+ let n = s.get(t.parentIndex) ?? [];
128
+ n.push({
129
+ start: t.start,
130
+ end: e
131
+ }), s.set(t.parentIndex, n);
132
+ }
133
+ continue;
134
+ }
135
+ continue;
136
+ }
137
+ if (c.length > 0) continue;
138
+ let e = f;
139
+ for (let t of Array.from(e.attributes)) {
140
+ let n = /^data-elur-e-(\d+)$/.exec(t.name);
141
+ n && a.set(Number(n[1]), e);
142
+ let r = /^data-elur-a-(\d+)$/.exec(t.name);
143
+ r && i.set(Number(r[1]), e);
144
+ }
145
+ }
146
+ return {
147
+ nodes: n,
148
+ attributes: i,
149
+ events: a,
150
+ keyed: o,
151
+ arrayItems: s
152
+ };
153
+ }
154
+ function x(e, t) {
155
+ let n = document.createRange();
156
+ return n.setStartAfter(t.start), n.setEndBefore(t.end), n.intersectsNode(e);
157
+ }
158
+ function S(e, t, n, r) {
159
+ if (typeof r != "function") throw TypeError(`Event "${t}" requires a function`);
160
+ let i = r;
161
+ if (g(t) && !n.includes("capture") && !n.includes("once") && document.body.contains(e)) return h(e, t, n, i);
162
+ let a = {
163
+ once: n.includes("once"),
164
+ capture: n.includes("capture"),
165
+ passive: n.includes("passive")
166
+ }, o = (e) => {
167
+ n.includes("prevent") && e.preventDefault(), n.includes("stop") && e.stopPropagation(), !(n.includes("self") && e.target !== e.currentTarget) && i(e);
168
+ };
169
+ return e.addEventListener(t, o, a), () => e.removeEventListener(t, o, a);
170
+ }
171
+ function C(t, n, r, i) {
172
+ if (n === "ref") {
173
+ let e = i;
174
+ return e.el = t, () => {
175
+ e.el = null;
176
+ };
177
+ }
178
+ let a = (n === "value" || n === "checked" || n === "selected") && n in t, o = !0, s = !1, c = (e) => {
179
+ if (a) if (!o) t[n] = e ?? "";
180
+ else {
181
+ let r = t[n];
182
+ if (String(r) !== String(e ?? "") && !s) {
183
+ s = !0;
184
+ let e = n === "checked" || n === "selected" ? "change" : "input";
185
+ queueMicrotask(() => {
186
+ s = !1, t.dispatchEvent(new Event(e, { bubbles: !0 }));
187
+ });
188
+ }
189
+ }
190
+ else if (e == null || e === !1) t.removeAttribute(n);
191
+ else {
192
+ let i = r ? m(String(e)) : String(e);
193
+ t.setAttribute(n, i);
194
+ }
195
+ o = !1;
196
+ };
197
+ return typeof i == "function" ? e(() => c(i())) : (c(i), () => {});
198
+ }
199
+ function w(t, n, r, a, s) {
200
+ if (typeof n != "function") return T(t, n, r, a, s);
201
+ let c = !0, l, u = k(t), d = null, m = o(), h = f(m), g = (e) => {
202
+ console.warn(`[elur] repeat(): duplicate key "${e}". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`);
203
+ }, _ = e(() => {
204
+ let e = n();
205
+ if (i(e)) {
206
+ if (c && !d) {
207
+ let n = E(e, a, r);
208
+ d = {
209
+ state: n.state,
210
+ prevOrder: n.prevOrder
211
+ }, l = n.cleanup, p({
212
+ zoneStart: t.start,
213
+ anchor: t.end,
214
+ state: d.state,
215
+ prevOrder: d.prevOrder,
216
+ list: e,
217
+ mount: h,
218
+ ctxSnapshot: m,
219
+ onDuplicateKey: g
220
+ }), u = null, c = !1;
221
+ return;
222
+ }
223
+ d || (l?.(), A(t), d = {
224
+ state: /* @__PURE__ */ new Map(),
225
+ prevOrder: []
226
+ }, l = () => {
227
+ for (let e of d.state.values()) e.cleanup();
228
+ }), p({
229
+ zoneStart: t.start,
230
+ anchor: t.end,
231
+ state: d.state,
232
+ prevOrder: d.prevOrder,
233
+ list: e,
234
+ mount: h,
235
+ ctxSnapshot: m,
236
+ onDuplicateKey: g
237
+ }), u = null, c = !1;
238
+ return;
239
+ }
240
+ d && (l?.(), A(t), d = null, l = void 0), typeof e == "string" || typeof e == "number" || typeof e == "bigint" ? u ? u.nodeValue !== String(e) && (u.nodeValue = String(e)) : (u = document.createTextNode(String(e)), t.end.parentNode.insertBefore(u, t.end)) : c ? l = T(t, e, r, a, s) : (l?.(), A(t), l = O(t, e), u = k(t)), c = !1;
241
+ });
242
+ return () => {
243
+ _(), l?.();
244
+ };
245
+ }
246
+ function T(e, l, u, d, m) {
247
+ if (i(l)) {
248
+ let t = o(), n = E(l, d, u);
249
+ return p({
250
+ zoneStart: e.start,
251
+ anchor: e.end,
252
+ state: n.state,
253
+ prevOrder: n.prevOrder,
254
+ list: l,
255
+ mount: f(t),
256
+ ctxSnapshot: t,
257
+ onDuplicateKey: (e) => {
258
+ console.warn(`[elur] repeat(): duplicate key "${e}". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`);
259
+ }
260
+ }), n.cleanup;
261
+ }
262
+ if (Array.isArray(l)) {
263
+ let t = [], n = m !== void 0 && m.length > 0;
264
+ for (let r = 0; r < l.length; r++) {
265
+ let i = l[r], a = m?.[r];
266
+ if (n && a) {
267
+ let e = T(a, i, u);
268
+ e && t.push(e);
269
+ } else if (n) {
270
+ let n = O(e, i);
271
+ n && t.push(n);
272
+ } else {
273
+ let n = T(e, i, u);
274
+ n && t.push(n);
275
+ }
276
+ }
277
+ return t.length ? () => {
278
+ for (let e = t.length - 1; e >= 0; e--) t[e]();
279
+ } : void 0;
280
+ }
281
+ if (r(l)) {
282
+ let t = l[n];
283
+ return t || j(u, -1, "descriptor", "Nested template has no hydration descriptor"), y(t, e.start.parentNode, u, e);
284
+ }
285
+ if (a(l)) {
286
+ c();
287
+ let t;
288
+ try {
289
+ try {
290
+ l.onInit?.();
291
+ } catch (e) {
292
+ if (l.onError) l.onError(e);
293
+ else throw e;
294
+ }
295
+ let r = l.render()[n];
296
+ r || j(u, -1, "descriptor", "Nested component has no hydration descriptor");
297
+ let i = y(r, e.start.parentNode, u, e), a = l.onMount?.();
298
+ t = () => {
299
+ l.onUnmount?.(), typeof a == "function" && a(), i();
300
+ };
301
+ } finally {
302
+ s();
303
+ }
304
+ return t;
305
+ }
306
+ if (typeof l == "object" && l) {
307
+ let n = l[t];
308
+ if (n?.hydrateDom) return n.hydrateDom({
309
+ parent: e.start.parentNode,
310
+ bounds: e,
311
+ context: u.context,
312
+ render: (t) => T(e, t, u)
313
+ }) ?? void 0;
314
+ }
315
+ }
316
+ function E(e, t, n) {
317
+ let r = /* @__PURE__ */ new Map(), i = [];
318
+ if (!t || t.length === 0) return {
319
+ state: r,
320
+ prevOrder: i,
321
+ cleanup: () => {}
322
+ };
323
+ let a = /* @__PURE__ */ new Map();
324
+ for (let t = 0; t < e.items.length; t++) {
325
+ let n = u(e.keyFn(e.items[t], t), t), r = d(n);
326
+ a.has(r) && console.warn(`[elur] repeat(): duplicate client key "${n}" during hydration. Keys must be unique; entries after the first leak.`), a.set(r, t);
327
+ }
328
+ for (let o of t) {
329
+ let t = a.get(o.serializedKey);
330
+ if (t === void 0) {
331
+ D(o);
332
+ continue;
333
+ }
334
+ let s = e.items[t], c = u(e.keyFn(s, t), t);
335
+ if (d(c) !== o.serializedKey && console.warn(`[elur] repeat(): hydration key mismatch at index ${t} (${l(o.serializedKey)} != ${c}). The SSR item is adopted by position.`), r.has(c)) {
336
+ console.warn(`[elur] repeat(): duplicate key "${c}" during hydration; removing duplicate SSR node.`), D(o);
337
+ continue;
338
+ }
339
+ let f = e.renderFn(s, t), p = T({
340
+ start: o.start,
341
+ end: o.end
342
+ }, f, n);
343
+ r.set(c, {
344
+ start: o.start,
345
+ end: o.end,
346
+ cleanup: p ?? (() => {})
347
+ }), i.push(c);
348
+ }
349
+ return {
350
+ state: r,
351
+ prevOrder: i,
352
+ cleanup: () => {
353
+ for (let e of r.values()) e.cleanup();
354
+ }
355
+ };
356
+ }
357
+ function D(e) {
358
+ let t = e.start.nextSibling;
359
+ for (; t && t !== e.end;) {
360
+ let e = t.nextSibling;
361
+ t.parentNode?.removeChild(t), t = e;
362
+ }
363
+ e.start.parentNode?.removeChild(e.start), e.end.parentNode?.removeChild(e.end);
364
+ }
365
+ function O(e, t) {
366
+ if (t == null || t === !1 || t === !0) return;
367
+ if (Array.isArray(t)) {
368
+ let n = [];
369
+ for (let r of t) {
370
+ let t = O(e, r);
371
+ t && n.push(t);
372
+ }
373
+ return n.length ? () => {
374
+ for (let e = n.length - 1; e >= 0; e--) n[e]();
375
+ } : void 0;
376
+ }
377
+ if (r(t)) return t._render(e.end.parentNode, e.end);
378
+ if (a(t)) return t.render()._render(e.end.parentNode, e.end);
379
+ let n = document.createTextNode(String(t));
380
+ return e.end.parentNode.insertBefore(n, e.end), () => n.parentNode?.removeChild(n);
381
+ }
382
+ function k(e) {
383
+ let t = e.start.nextSibling;
384
+ for (; t && t !== e.end;) {
385
+ if (t.nodeType === Node.TEXT_NODE) return t;
386
+ t = t.nextSibling;
387
+ }
388
+ return null;
389
+ }
390
+ function A(e) {
391
+ let t = e.start.nextSibling;
392
+ for (; t && t !== e.end;) {
393
+ let e = t.nextSibling;
394
+ t.parentNode?.removeChild(t), t = e;
395
+ }
396
+ }
397
+ function j(e, t, n, r) {
398
+ let i = {
399
+ index: t,
400
+ kind: n,
401
+ message: r
402
+ };
403
+ e.onMismatch?.(i);
404
+ let a = /* @__PURE__ */ Error(`[elur] Hydration marker mismatch: ${r}`);
405
+ throw Object.assign(a, { mismatch: i }), a;
406
+ }
407
+ //#endregion
408
+ export { _ as hydrate };
409
+
410
+ //# sourceMappingURL=hydrate.js.map
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./signals.cjs`),t=require(`./elur/template/types.cjs`),n=require(`./lifecycle.cjs`),r=require(`./context.cjs`),i=require(`./elur/template/keyed.cjs`),a=require(`./elur/template/bindings.cjs`),o=require(`./elur/template/html.cjs`),s=require(`./elur/template/raw.cjs`),c=require(`./elur/template/transitions.cjs`),l=require(`./elur/template/portal.cjs`),u=require(`./elur/template/error-boundary.cjs`),d=require(`./router.cjs`),f=require(`./component.cjs`),p=require(`./store.cjs`),m=require(`./plugins.cjs`),h=require(`./async.cjs`),g=require(`./form.cjs`);exports.ELUR_RENDER_PROTOCOL=t.ELUR_RENDER_PROTOCOL,exports.ELUR_TEMPLATE_DESCRIPTOR=t.ELUR_TEMPLATE_DESCRIPTOR,exports.ElurComponent=n.ElurComponent,exports.Link=d.Link,exports.RouterKey=d.RouterKey,exports.RouterView=d.RouterView,exports.Signal=e.Signal,exports._hasActiveRouter=d._hasActiveRouter,exports.batch=e.batch,exports.bridgePlugin=m.bridgePlugin,exports.computed=e.computed,exports.createErrorBoundary=u.createErrorBoundary,exports.createForm=g.createForm,exports.createInjectionKey=r.createInjectionKey,exports.createPortalOutlet=l.createPortalOutlet,exports.createRouter=d.createRouter,exports.createStore=p.createStore,exports.createValidator=g.createValidator,exports.effect=e.effect,exports.elurField=g.elurField,exports.elurFieldArray=g.elurFieldArray,exports.elurRouter=d.elurRouter,exports.email=g.email,exports.extendValidators=g.extendValidators,exports.guardPlugin=m.guardPlugin,exports.html=o.html,exports.inject=r.inject,exports.injectOutlet=l.injectOutlet,exports.lazy=h.lazy,exports.loggerPlugin=m.loggerPlugin,exports.max=g.max,exports.maxLength=g.maxLength,exports.min=g.min,exports.minLength=g.minLength,exports.mount=f.mount,exports.nextTick=e.nextTick,exports.pattern=g.pattern,exports.persistPlugin=m.persistPlugin,exports.portal=l.portal,exports.portalOutlet=l.portalOutlet,exports.provide=r.provide,exports.provideOutlet=l.provideOutlet,exports.raw=s.raw,exports.ref=t.ref,exports.repeat=i.repeat,exports.required=g.required,exports.showWhen=a.showWhen,exports.signal=e.signal,exports.suspend=h.suspend,exports.templateFeatures=t.templateFeatures,exports.transition=c.transition,exports.untrack=e.untrack,exports.validators=g.validators,exports.watch=e.watch;
@@ -0,0 +1,2 @@
1
+ export { Signal, signal, effect, computed, batch, watch, untrack, nextTick, html, repeat, raw, ref, showWhen, portal, createPortalOutlet, portalOutlet, provideOutlet, injectOutlet, createErrorBoundary, transition, ELUR_TEMPLATE_DESCRIPTOR, ELUR_RENDER_PROTOCOL, templateFeatures, mount, ElurComponent, createStore, persistPlugin, loggerPlugin, guardPlugin, bridgePlugin, createRouter, RouterView, Link, elurRouter, RouterKey, _hasActiveRouter, suspend, lazy, provide, inject, createInjectionKey, elurField, elurFieldArray, createForm, required, minLength, maxLength, email, pattern, min, max, createValidator, validators, extendValidators, } from "./elur/index.js";
2
+ export type { WatchOptions, ElurTemplate, ElurMountHandle, TemplateBindingContext, TemplateDescriptor, ElurRenderProtocol, ServerRenderProtocolContext, DomProtocolContext, HydrationProtocolContext, MountOptions, KeyedList, ElurRef, PortalOutlet, ErrorFallback, TransitionOptions, TransitionContent, Store, StoreSignals, ElurPlugin, Router, NamedRouteLocation, RouteLocation, RouteRecord, RouterOptions, NavigationGuard, NavigationGuardResult, AfterEachHook, ResolvedRoute, ScrollPosition, ScrollBehavior, RouterMode, NavigationDirection, NavigationIntent, NavigationAction, NavigateOptions, SuspenseOptions, InjectionKey, DeepPartial, Validator, ValidateOn, FieldState, FieldArrayState, FieldErrors, FormState, FormOptions, ValidatorsBase, ElurChildren, } from "./elur/index.js";
@@ -0,0 +1,2 @@
1
+ export { Signal, signal, effect, computed, batch, watch, untrack, nextTick, html, repeat, raw, ref, showWhen, portal, createPortalOutlet, portalOutlet, provideOutlet, injectOutlet, createErrorBoundary, transition, ELUR_TEMPLATE_DESCRIPTOR, ELUR_RENDER_PROTOCOL, templateFeatures, mount, ElurComponent, createStore, persistPlugin, loggerPlugin, guardPlugin, bridgePlugin, createRouter, RouterView, Link, elurRouter, RouterKey, _hasActiveRouter, suspend, lazy, provide, inject, createInjectionKey, elurField, elurFieldArray, createForm, required, minLength, maxLength, email, pattern, min, max, createValidator, validators, extendValidators, } from "./elur/index.js";
2
+ export type { WatchOptions, ElurTemplate, ElurMountHandle, TemplateBindingContext, TemplateDescriptor, ElurRenderProtocol, ServerRenderProtocolContext, DomProtocolContext, HydrationProtocolContext, MountOptions, KeyedList, ElurRef, PortalOutlet, ErrorFallback, TransitionOptions, TransitionContent, Store, StoreSignals, ElurPlugin, Router, NamedRouteLocation, RouteLocation, RouteRecord, RouterOptions, NavigationGuard, NavigationGuardResult, AfterEachHook, ResolvedRoute, ScrollPosition, ScrollBehavior, RouterMode, NavigationDirection, NavigationIntent, NavigationAction, NavigateOptions, SuspenseOptions, InjectionKey, DeepPartial, Validator, ValidateOn, FieldState, FieldArrayState, FieldErrors, FormState, FormOptions, ValidatorsBase, ElurChildren, } from "./elur/index.js";
@@ -0,0 +1,18 @@
1
+ import { Signal as e, batch as t, computed as n, effect as r, nextTick as i, signal as a, untrack as o, watch as s } from "./signals.js";
2
+ import { ELUR_RENDER_PROTOCOL as c, ELUR_TEMPLATE_DESCRIPTOR as l, ref as u, templateFeatures as d } from "./elur/template/types.js";
3
+ import { ElurComponent as f } from "./lifecycle.js";
4
+ import { createInjectionKey as p, inject as m, provide as h } from "./context.js";
5
+ import { repeat as g } from "./elur/template/keyed.js";
6
+ import { showWhen as _ } from "./elur/template/bindings.js";
7
+ import { html as v } from "./elur/template/html.js";
8
+ import { raw as y } from "./elur/template/raw.js";
9
+ import { transition as b } from "./elur/template/transitions.js";
10
+ import { createPortalOutlet as x, injectOutlet as S, portal as C, portalOutlet as w, provideOutlet as T } from "./elur/template/portal.js";
11
+ import { createErrorBoundary as E } from "./elur/template/error-boundary.js";
12
+ import { Link as D, RouterKey as O, RouterView as k, _hasActiveRouter as A, createRouter as j, elurRouter as M } from "./router.js";
13
+ import { mount as N } from "./component.js";
14
+ import { createStore as P } from "./store.js";
15
+ import { bridgePlugin as F, guardPlugin as I, loggerPlugin as L, persistPlugin as R } from "./plugins.js";
16
+ import { lazy as z, suspend as B } from "./async.js";
17
+ import { createForm as V, createValidator as H, elurField as U, elurFieldArray as W, email as G, extendValidators as K, max as q, maxLength as J, min as Y, minLength as X, pattern as Z, required as Q, validators as $ } from "./form.js";
18
+ export { c as ELUR_RENDER_PROTOCOL, l as ELUR_TEMPLATE_DESCRIPTOR, f as ElurComponent, D as Link, O as RouterKey, k as RouterView, e as Signal, A as _hasActiveRouter, t as batch, F as bridgePlugin, n as computed, E as createErrorBoundary, V as createForm, p as createInjectionKey, x as createPortalOutlet, j as createRouter, P as createStore, H as createValidator, r as effect, U as elurField, W as elurFieldArray, M as elurRouter, G as email, K as extendValidators, I as guardPlugin, v as html, m as inject, S as injectOutlet, z as lazy, L as loggerPlugin, q as max, J as maxLength, Y as min, X as minLength, N as mount, i as nextTick, Z as pattern, R as persistPlugin, C as portal, w as portalOutlet, h as provide, T as provideOutlet, y as raw, u as ref, g as repeat, Q as required, _ as showWhen, a as signal, B as suspend, d as templateFeatures, b as transition, o as untrack, $ as validators, s as watch };
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{__isElurComponent=!0;children;_debugName;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}setDebugName(e){return this._debugName=e,this}};function t(e){return typeof e==`object`&&!!e&&e.__isElurComponent===!0}var n=null;function r(e){n=e}function i(e){n?.onMountStart?.(e)}function a(e){n?.onMountEnd?.(e)}function o(e){n?.onUnmount?.(e)}exports.ElurComponent=e,exports._debugComponentMountEnd=a,exports._debugComponentMountStart=i,exports._debugComponentUnmount=o,exports._setComponentDebugHooks=r,exports.isElurComponent=t;
2
+ //# sourceMappingURL=lifecycle.cjs.map
@@ -0,0 +1,39 @@
1
+ //#region src/elur/lifecycle.ts
2
+ var e = class {
3
+ __isElurComponent = !0;
4
+ children;
5
+ _debugName;
6
+ _slots = /* @__PURE__ */ new Map();
7
+ setChildren(e) {
8
+ return this.children = e, this;
9
+ }
10
+ setSlot(e, t) {
11
+ return this._slots.set(e, t), this;
12
+ }
13
+ slot(e) {
14
+ return this._slots.get(e);
15
+ }
16
+ setDebugName(e) {
17
+ return this._debugName = e, this;
18
+ }
19
+ };
20
+ function t(e) {
21
+ return typeof e == "object" && !!e && e.__isElurComponent === !0;
22
+ }
23
+ var n = null;
24
+ function r(e) {
25
+ n = e;
26
+ }
27
+ function i(e) {
28
+ n?.onMountStart?.(e);
29
+ }
30
+ function a(e) {
31
+ n?.onMountEnd?.(e);
32
+ }
33
+ function o(e) {
34
+ n?.onUnmount?.(e);
35
+ }
36
+ //#endregion
37
+ export { e as ElurComponent, a as _debugComponentMountEnd, i as _debugComponentMountStart, o as _debugComponentUnmount, r as _setComponentDebugHooks, t as isElurComponent };
38
+
39
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./signals.cjs`);function t(t,n={}){let{storage:r=localStorage,exclude:i=[],serialize:a=JSON.stringify,deserialize:o=JSON.parse,debounce:s=0}=n;return n=>{e.untrack(async()=>{try{let e=await r.getItem(t);if(!e)return;let a=o(e),s={};for(let e of Object.keys(a))e in n.$state&&!i.includes(e)&&(s[e]=a[e]);Object.keys(s).length>0&&n.$patch(s)}catch{}});let c;return e.watch(n.$stateSignal,e=>{let n=()=>{try{let n=i.length===0?e:Object.fromEntries(Object.entries(e).filter(([e])=>!i.includes(e)));r.setItem(t,a(n))}catch{}};s>0?(clearTimeout(c),c=setTimeout(n,s)):n()})}}function n(t={}){let{collapsed:n=!0,filter:r}=t;return t=>{let i=n?console.groupCollapsed:console.group;return e.watch(t.$stateSignal,(e,n)=>{if(!n)return;let a={};for(let t of Object.keys(e))Object.is(e[t],n[t])||(a[t]=e[t]);Object.keys(a).length!==0&&(r&&!r(a)||(i(`%c[elur:${t.$id}]%c ${Object.keys(a).join(`, `)}`,`color:#7F77DD;font-weight:500`,`color:inherit;font-weight:400`),console.log(`prev →`,n),console.log(`next →`,e),console.log(`diff →`,a),console.groupEnd()))},{immediate:!0})}}function r(e){return t=>{let n=t._guardFns;for(let t of e)n.push(t);return()=>{for(let t of e){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}}}function i(t,n){return r=>e.watch(t.$stateSignal,e=>{n(e,r)})}exports.bridgePlugin=i,exports.guardPlugin=r,exports.loggerPlugin=n,exports.persistPlugin=t;
2
+ //# sourceMappingURL=plugins.cjs.map
@@ -0,0 +1,59 @@
1
+ import { untrack as e, watch as t } from "./signals.js";
2
+ //#region src/elur/plugins.ts
3
+ function n(n, r = {}) {
4
+ let { storage: i = localStorage, exclude: a = [], serialize: o = JSON.stringify, deserialize: s = JSON.parse, debounce: c = 0 } = r;
5
+ return (r) => {
6
+ e(async () => {
7
+ try {
8
+ let e = await i.getItem(n);
9
+ if (!e) return;
10
+ let t = s(e), o = {};
11
+ for (let e of Object.keys(t)) e in r.$state && !a.includes(e) && (o[e] = t[e]);
12
+ Object.keys(o).length > 0 && r.$patch(o);
13
+ } catch {}
14
+ });
15
+ let l;
16
+ return t(r.$stateSignal, (e) => {
17
+ let t = () => {
18
+ try {
19
+ let t = a.length === 0 ? e : Object.fromEntries(Object.entries(e).filter(([e]) => !a.includes(e)));
20
+ i.setItem(n, o(t));
21
+ } catch {}
22
+ };
23
+ c > 0 ? (clearTimeout(l), l = setTimeout(t, c)) : t();
24
+ });
25
+ };
26
+ }
27
+ function r(e = {}) {
28
+ let { collapsed: n = !0, filter: r } = e;
29
+ return (e) => {
30
+ let i = n ? console.groupCollapsed : console.group;
31
+ return t(e.$stateSignal, (t, n) => {
32
+ if (!n) return;
33
+ let a = {};
34
+ for (let e of Object.keys(t)) Object.is(t[e], n[e]) || (a[e] = t[e]);
35
+ Object.keys(a).length !== 0 && (r && !r(a) || (i(`%c[elur:${e.$id}]%c ${Object.keys(a).join(", ")}`, "color:#7F77DD;font-weight:500", "color:inherit;font-weight:400"), console.log("prev →", n), console.log("next →", t), console.log("diff →", a), console.groupEnd()));
36
+ }, { immediate: !0 });
37
+ };
38
+ }
39
+ function i(e) {
40
+ return (t) => {
41
+ let n = t._guardFns;
42
+ for (let t of e) n.push(t);
43
+ return () => {
44
+ for (let t of e) {
45
+ let e = n.indexOf(t);
46
+ e >= 0 && n.splice(e, 1);
47
+ }
48
+ };
49
+ };
50
+ }
51
+ function a(e, n) {
52
+ return (r) => t(e.$stateSignal, (e) => {
53
+ n(e, r);
54
+ });
55
+ }
56
+ //#endregion
57
+ export { a as bridgePlugin, i as guardPlugin, r as loggerPlugin, n as persistPlugin };
58
+
59
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1,12 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./signals.cjs`),t=require(`./lifecycle.cjs`),n=require(`./context.cjs`),r=require(`./elur/template/html.cjs`);var i=n.createInjectionKey(`elur:router`),a=null,o=null,s=[],c=`__elur_scroll`,l=`__elur_pos`;function u(){if(!a)throw Error(`[elur] No active router. Call createRouter() first, or instantiate an outlet that auto-bootstraps one (e.g. IonRouterOutlet).`);return a}function d(){return a!==null}function f(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function ee(e){if(!e||typeof e!=`object`)return null;let t=e[c];if(!t||typeof t!=`object`)return null;let n=t.left,r=t.top;return typeof n!=`number`||typeof r!=`number`?null:{left:n,top:r}}function p(e){if(!e||typeof e!=`object`)return null;let t=e[l];return typeof t==`number`?t:null}function m(e,t,n){let r=e&&typeof e==`object`?{...e}:{};return r[c]={left:t.left,top:t.top},r[l]=n,r}function h(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function g(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!=null&&r!==!1&&t.set(n,String(r));let n=t.toString();return n?`?`+n:``}function _(e){return e===`*`?[{kind:`wildcard`}]:e.split(`/`).filter(Boolean).map(e=>e===`*`?{kind:`wildcard`}:e.startsWith(`:`)?{kind:`param`,name:e.slice(1)}:{kind:`literal`,value:e})}function v(e,t){return t===`*`?e===``?`*`:e+`/*`:(e+(t.startsWith(`/`)?t:`/`+t)).replace(/\/+/g,`/`)||`/`}function y(e,t=``,n=[]){let r=[];for(let i of e){let e=v(t,i.path),a=[...n,i.component],o=_(e);r.push({fullPath:e,segments:o,chain:a,name:i.name,meta:i.meta,beforeEnter:i.beforeEnter,record:i}),i.children?.length&&r.push(...y(i.children,e,a))}return r}function b(e,t){let n=e.split(`/`).filter(Boolean),r=t.segments;if(r.length===1&&r[0].kind===`wildcard`)return{};let i=r.length>0&&r[r.length-1].kind===`wildcard`,a=i?r.slice(0,-1):r;if(i){if(n.length<a.length)return null}else if(n.length!==a.length)return null;let o={};for(let e=0;e<a.length;e++){let t=a[e];if(t.kind===`literal`){if(n[e]!==t.value)return null}else if(t.kind===`param`)try{o[t.name]=decodeURIComponent(n[e]??``)}catch{o[t.name]=n[e]??``}}return o}function x(e){return e.segments.reduce((e,t)=>t.kind===`literal`?e+2:t.kind===`param`?e+1:e,0)}function S(e,t){let n,r={},i=-1;for(let a of t){let t=b(e,a);if(t===null)continue;let o=x(a);o>i&&(n=a,r=t,i=o)}return n?{route:n,params:r}:void 0}function C(e){let t=e.trim();return!t||t===`/`?``:(t.startsWith(`/`)||(t=`/`+t),t.endsWith(`/`)&&(t=t.slice(0,-1)),t)}function w(){if(typeof document>`u`)return``;let e=document.querySelector(`base`);if(!e)return``;let t=e.getAttribute(`href`)||``;try{return C(new URL(t,window.location.origin).pathname)}catch{return C(t)}}function te(e){return e===!1?{allow:!1}:e===!0||e==null?{allow:!0}:typeof e==`string`?{allow:!1,redirect:e}:typeof e==`object`&&`redirect`in e&&typeof e.redirect==`string`?{allow:!1,redirect:e.redirect}:{allow:!0}}function T(t,n){let r=n?.base==null?w():C(n.base),i=n?.mode??`history`,s=i===`hash`,c=n?.scrollBehavior,l=new Map,u=!1;function d(e){return e?e.startsWith(`/`)?e:`/`+e:`/`}function _(e){let t=d(e||`/`);if(r&&t.startsWith(r)){let e=t.slice(r.length);return e===``?`/`:d(e)}return t}function v(e){let t=d(e);return r?(r+t).replace(/\/+/g,`/`)||`/`:t}function b(){let e=window.location.hash||``;if(e.startsWith(`#`)&&(e=e.slice(1)),!e)return{pathname:`/`,search:``};e.startsWith(`/`)||(e=`/`+e);let t=e.indexOf(`?`),n=t===-1?e:e.slice(0,t),r=t===-1?``:e.slice(t);return{pathname:_(n),search:r}}function x(){return s?b():{pathname:_(window.location.pathname||`/`),search:window.location.search||``}}function T(e,t){let n=v(e)+g(t);return s?`#`+n:n}function E(e,t){return d(e)+g(t)}let D=x(),O=D.pathname,k=h(D.search),A=y(t),j=new Map;for(let e of A)e.name&&(j.has(e.name)&&console.warn(`[Elur Router] Duplicate route name: "${e.name}"`),j.set(e.name,e));let M=S(O,A),N=e.signal(O),P=e.signal(M?.params??{}),F=e.signal(k),I=p(history.state)??0,L=e.signal({action:`initial`,direction:`none`}),R=e.signal(I>0);s?l.set(E(O,k),f()):history.replaceState(m(history.state,f(),I),``);function z(e){window.scrollTo(e.left,e.top)}function B(e,t,n){if(c){let r=c(e,t,n);if(!r)return;z(r);return}z(n??{left:0,top:0})}function V(e,t){let n=f();if(s){l.set(E(e,t),n);return}history.replaceState(m(history.state,n,I),``)}let H=[],U=[],W=0;function G(e,t,n,r,i){let a=[...H];n&&a.push(n);let o=++W;if(a.length===0){r();return}let s=0;function c(n){if(o!==W)return;let l=te(n);if(!l.allow){if(l.redirect&&l.redirect!==e){Q(l.redirect);return}if(l.redirect===e){r();return}i?.();return}if(s>=a.length){r();return}let u=a[s++](e,t);if(u instanceof Promise){u.then(c);return}c(u)}c(void 0)}let K=!1;function q(e,t){let n=e.indexOf(`?`),r=d((n===-1?e:e.slice(0,n))||`/`),i=n===-1?{}:h(e.slice(n)),a=t?{...i,...t}:i,o={};for(let[e,t]of Object.entries(a))t!=null&&t!==!1&&(o[e]=String(t));return{pathname:r,stringQuery:o}}function ne(e){let t=j.get(e.name);if(!t)throw Error(`[Elur Router] No route with name "${e.name}"`);return`/`+t.segments.map(t=>{if(t.kind===`literal`)return t.value;if(t.kind===`wildcard`)return``;let n=e.params?.[t.name];if(n==null)throw Error(`[Elur Router] Missing param "${t.name}" for route "${e.name}"`);return encodeURIComponent(String(n))}).filter(Boolean).join(`/`)}function J(e,t){return typeof e==`string`?q(e,t?.query):q(ne(e),{...e.query??{},...t?.query??{}})}o&&=(o(),null);let Y=(e,t,n,r,i)=>{let a=N.value,o={...F.value},s=S(e,A),c=`none`;r!=null&&(r<I?c=`back`:r>I&&(c=`forward`)),G(e,a,s?.route.beforeEnter,()=>{r!=null&&(I=r);let i=Z;Z=void 0,L.value={action:`pop`,direction:c,animation:i},P.value=s?.params??{},F.value=t,N.value=e,R.value=I>0,B(e,a,n);for(let t of U)try{t(e,a)}catch{}},()=>i(a,o))};if(s){let e=()=>{if(u){u=!1;return}let e=x(),t=h(e.search),n=l.get(E(e.pathname,t))??null;Y(e.pathname,t,n,null,(e,t)=>{u=!0,window.location.hash=T(e,t).slice(1),queueMicrotask(()=>{u=!1})})};window.addEventListener(`hashchange`,e),o=()=>window.removeEventListener(`hashchange`,e)}else{let e=e=>{let t=x(),n=h(t.search),r=ee(e.state??history.state),i=p(e.state??history.state);Y(t.pathname,n,r,i,(e,t)=>{history.pushState(m({},f(),I),``,T(e,t))})};window.addEventListener(`popstate`,e),o=()=>window.removeEventListener(`popstate`,e)}function X(e,t,n,r,i,a,o){o||(V(n,r),I+=1),L.value=a,P.value=i?.params??{},F.value=t,N.value=e,R.value=I>0;let c=T(e,t);if(s)l.set(E(e,t),{left:0,top:0}),o?history.replaceState(history.state,``,c):(u=!0,window.location.hash=c.slice(1),queueMicrotask(()=>{u=!1}));else{let e=m({},{left:0,top:0},I);o?history.replaceState(e,``,c):history.pushState(e,``,c)}B(e,n,null);for(let t of U)try{t(e,n)}catch{}}let Z;function Q(e,t){K=!0;let{pathname:n,stringQuery:r}=J(e,t),i=N.value,a={...F.value},o=S(n,A),s={action:`push`,direction:t?.direction??`forward`,animation:t?.animation};G(n,i,o?.route.beforeEnter,()=>X(n,r,i,a,o,s,!1))}function re(e,t){K=!0;let{pathname:n,stringQuery:r}=J(e,t),i=N.value,a={...F.value},o=S(n,A),s={action:`replace`,direction:t?.direction??`root`,animation:t?.animation};G(n,i,o?.route.beforeEnter,()=>X(n,r,i,a,o,s,!0))}function ie(e){e!==void 0&&(Z=e),history.back()}function ae(e){e!==void 0&&(Z=e),history.forward()}function oe(e){history.go(e)}function se(e,t=!0){let n=N.value;return t?n===e:n===e||n.startsWith(e.endsWith(`/`)?e:e+`/`)}function ce(e){let t=S(e,A);return t?{matched:!0,params:t.params,route:t.route.record}:{matched:!1,params:{},route:void 0}}function le(e){return H.push(e),()=>{let t=H.indexOf(e);t!==-1&&H.splice(t,1)}}function ue(e){return U.push(e),()=>{let t=U.indexOf(e);t!==-1&&U.splice(t,1)}}let $={current:N,params:P,query:F,intent:L,canGoBack:R,base:r||`/`,navigate:Q,replace:re,back:ie,forward:ae,go:oe,isActive:se,resolve:ce,beforeEach:le,afterEach:ue,routes:t,_flat:A,_guards:H,_base:r,_mode:i};return a&&console.warn(`[elur] A router already exists. The previous router is being replaced. Only one router instance should be active at a time.`),a=$,queueMicrotask(()=>{K||G(O,``,S(O,A)?.route.beforeEnter,()=>{},()=>{let e=T(`/`,{});s?(l.set(E(`/`,{}),{left:0,top:0}),history.replaceState(history.state,``,e)):history.replaceState(m({},{left:0,top:0},I),``,e);let t=S(`/`,A);L.value={action:`replace`,direction:`root`},N.value=`/`,P.value=t?.params??{},F.value={},R.value=I>0,B(`/`,O,null)})}),$}function E(){return n.inject(i)||u()}function D(){o&&=(o(),null),a=null,s.length=0}var O=class extends t.ElurComponent{_depth;_router;constructor(e=0,t){super(),this._depth=e,this._router=t}render(){let e=this._depth,t=this._router;return r.html`<div class="router-view">${()=>{let n=t??E(),i=S(n.current.value,n._flat);if(!i)return r.html`
2
+ <div style="color:#f87171;padding:16px 0">
3
+ 404 — Route not found: <strong>${n.current.value}</strong>
4
+ </div>
5
+ `;if(e>=i.route.chain.length)return r.html`
6
+ <span></span>
7
+ `;let a=i.route.chain[e];return a?a():r.html`
8
+ <span></span>
9
+ `}}</div>`}},k=class extends t.ElurComponent{_to;_label;_router;constructor(e,t,n){super(),this._to=e,this._label=t,this._router=n}render(){let e=this._to,t=this._label,n=this._router??E(),i=e.startsWith(`/`)?e:`/`+e,a=(n._base?n._base+i:i).replace(/\/+/g,`/`);return r.html`
10
+ <a href=${n._mode===`hash`?`#`+a:a} style=${()=>n.current.value===e?`color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a`:`color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px`} @click=${t=>{t.preventDefault(),n.navigate(e)}}>${t}</a>
11
+ `}};function A(e){let t=s.indexOf(e);t>=0&&s.splice(t,1),s.push(e)}function j(e){let t=s.indexOf(e);t>=0&&s.splice(t,1)}function M(){let e=s.length?s[s.length-1]:a;if(!e)return null;let t=e,n=t.current.value,r=S(n,t._flat),i=r?.route.beforeEnter,o=t._guards.map((e,t)=>e.name||`beforeEach#${t+1}`);return i&&o.push(i.name||`beforeEnter`),{mode:t._mode,base:t._base||`/`,currentPath:n,params:{...t.params.value},query:{...t.query.value},matchedPath:r?.route.fullPath??null,activeGuards:{globalCount:t._guards.length,hasRouteGuard:!!i,names:o}}}exports.Link=k,exports.RouterKey=i,exports.RouterView=O,exports._debugGetRouterInternal=M,exports._debugRegisterRouter=A,exports._debugUnregisterRouter=j,exports._hasActiveRouter=d,exports._resetRouter=D,exports.createRouter=T,exports.elurRouter=E;
12
+ //# sourceMappingURL=router.cjs.map