@fictjs/runtime 0.3.0 → 0.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 (70) hide show
  1. package/dist/advanced.cjs +10 -8
  2. package/dist/advanced.cjs.map +1 -1
  3. package/dist/advanced.d.cts +4 -3
  4. package/dist/advanced.d.ts +4 -3
  5. package/dist/advanced.js +10 -8
  6. package/dist/advanced.js.map +1 -1
  7. package/dist/{chunk-TWELIZRY.js → chunk-5AA7HP4S.js} +5 -3
  8. package/dist/{chunk-TWELIZRY.js.map → chunk-5AA7HP4S.js.map} +1 -1
  9. package/dist/chunk-6SOPF5LZ.cjs +2363 -0
  10. package/dist/chunk-6SOPF5LZ.cjs.map +1 -0
  11. package/dist/{chunk-SO6X7G5S.js → chunk-BQG7VEBY.js} +501 -1880
  12. package/dist/chunk-BQG7VEBY.js.map +1 -0
  13. package/dist/chunk-FKDMDAUR.js +2363 -0
  14. package/dist/chunk-FKDMDAUR.js.map +1 -0
  15. package/dist/{chunk-L4DIV3RC.cjs → chunk-GHUV2FLD.cjs} +9 -7
  16. package/dist/chunk-GHUV2FLD.cjs.map +1 -0
  17. package/dist/{chunk-XLIZJMMJ.js → chunk-KKKYW54Z.js} +8 -6
  18. package/dist/{chunk-XLIZJMMJ.js.map → chunk-KKKYW54Z.js.map} +1 -1
  19. package/dist/{chunk-M2TSXZ4C.cjs → chunk-KYLNC4CD.cjs} +18 -16
  20. package/dist/chunk-KYLNC4CD.cjs.map +1 -0
  21. package/dist/chunk-TKWN42TA.cjs +2259 -0
  22. package/dist/chunk-TKWN42TA.cjs.map +1 -0
  23. package/dist/{context-B25xyQrJ.d.cts → context-CTBE00S_.d.cts} +1 -1
  24. package/dist/{context-CGdP7_Jb.d.ts → context-lkLhbkFJ.d.ts} +1 -1
  25. package/dist/{effect-D6kaLM2-.d.cts → effect-BpSNEJJz.d.cts} +7 -67
  26. package/dist/{effect-D6kaLM2-.d.ts → effect-BpSNEJJz.d.ts} +7 -67
  27. package/dist/index.cjs +40 -38
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +5 -4
  30. package/dist/index.d.ts +5 -4
  31. package/dist/index.dev.js +92 -4
  32. package/dist/index.dev.js.map +1 -1
  33. package/dist/index.js +19 -17
  34. package/dist/index.js.map +1 -1
  35. package/dist/internal.cjs +189 -202
  36. package/dist/internal.cjs.map +1 -1
  37. package/dist/internal.d.cts +13 -23
  38. package/dist/internal.d.ts +13 -23
  39. package/dist/internal.js +195 -208
  40. package/dist/internal.js.map +1 -1
  41. package/dist/loader.cjs +280 -0
  42. package/dist/loader.cjs.map +1 -0
  43. package/dist/loader.d.cts +57 -0
  44. package/dist/loader.d.ts +57 -0
  45. package/dist/loader.js +280 -0
  46. package/dist/loader.js.map +1 -0
  47. package/dist/{props-BIfromL0.d.cts → props-XTHYD19o.d.cts} +13 -2
  48. package/dist/{props-BEgIVMRx.d.ts → props-x-HbI-jX.d.ts} +13 -2
  49. package/dist/resume-BrAkmSTY.d.cts +79 -0
  50. package/dist/resume-Dx8_l72o.d.ts +79 -0
  51. package/dist/{scope-CzNkn587.d.ts → scope-CdbGmsFf.d.ts} +1 -1
  52. package/dist/{scope-Cx_3CjIZ.d.cts → scope-DfcP9I-A.d.cts} +1 -1
  53. package/dist/signal-C4ISF17w.d.cts +66 -0
  54. package/dist/signal-C4ISF17w.d.ts +66 -0
  55. package/package.json +8 -3
  56. package/src/binding.ts +254 -5
  57. package/src/dom.ts +103 -5
  58. package/src/hooks.ts +15 -2
  59. package/src/hydration.ts +75 -0
  60. package/src/internal.ts +34 -2
  61. package/src/list-helpers.ts +113 -12
  62. package/src/loader.ts +437 -0
  63. package/src/node-ops.ts +65 -0
  64. package/src/resume.ts +517 -0
  65. package/src/store.ts +8 -0
  66. package/dist/chunk-ID3WBWNO.cjs +0 -3638
  67. package/dist/chunk-ID3WBWNO.cjs.map +0 -1
  68. package/dist/chunk-L4DIV3RC.cjs.map +0 -1
  69. package/dist/chunk-M2TSXZ4C.cjs.map +0 -1
  70. package/dist/chunk-SO6X7G5S.js.map +0 -1
@@ -0,0 +1,2259 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ var _chunk6SOPF5LZcjs = require('./chunk-6SOPF5LZ.cjs');
44
+
45
+ // src/jsx.ts
46
+ var Fragment = Symbol("Fragment");
47
+
48
+ // src/node-ops.ts
49
+ function toNodeArray(node) {
50
+ try {
51
+ if (Array.isArray(node)) {
52
+ let allNodes = true;
53
+ for (const item of node) {
54
+ let isItemNode = false;
55
+ try {
56
+ isItemNode = item instanceof Node;
57
+ } catch (e2) {
58
+ isItemNode = false;
59
+ }
60
+ if (!isItemNode) {
61
+ allNodes = false;
62
+ break;
63
+ }
64
+ }
65
+ if (allNodes) {
66
+ return node;
67
+ }
68
+ const result = [];
69
+ for (const item of node) {
70
+ result.push(...toNodeArray(item));
71
+ }
72
+ return result;
73
+ }
74
+ if (node === null || node === void 0 || node === false) {
75
+ return [];
76
+ }
77
+ } catch (e3) {
78
+ return [];
79
+ }
80
+ let isNode = false;
81
+ try {
82
+ isNode = node instanceof Node;
83
+ } catch (e4) {
84
+ isNode = false;
85
+ }
86
+ if (isNode) {
87
+ try {
88
+ if (node instanceof DocumentFragment) {
89
+ return Array.from(node.childNodes);
90
+ }
91
+ } catch (e5) {
92
+ }
93
+ return [node];
94
+ }
95
+ try {
96
+ if (typeof node === "object" && node !== null && "marker" in node) {
97
+ return toNodeArray(node.marker);
98
+ }
99
+ } catch (e6) {
100
+ }
101
+ try {
102
+ return [document.createTextNode(String(node))];
103
+ } catch (e7) {
104
+ return [document.createTextNode("")];
105
+ }
106
+ }
107
+ function insertNodesBefore(parent, nodes, anchor) {
108
+ if (nodes.length === 0) return;
109
+ if (nodes.length === 1) {
110
+ const node = nodes[0];
111
+ if (node === void 0 || node === null) return;
112
+ if (node.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {
113
+ parent.ownerDocument.adoptNode(node);
114
+ }
115
+ try {
116
+ parent.insertBefore(node, anchor);
117
+ } catch (e) {
118
+ if (parent.ownerDocument) {
119
+ try {
120
+ const clone = parent.ownerDocument.importNode(node, true);
121
+ parent.insertBefore(clone, anchor);
122
+ return;
123
+ } catch (e8) {
124
+ }
125
+ }
126
+ throw e;
127
+ }
128
+ return;
129
+ }
130
+ const doc = parent.ownerDocument;
131
+ if (doc) {
132
+ const frag = doc.createDocumentFragment();
133
+ for (let i = 0; i < nodes.length; i++) {
134
+ const node = nodes[i];
135
+ if (node === void 0 || node === null) continue;
136
+ if (node.nodeType === 11) {
137
+ const childrenArr = Array.from(node.childNodes);
138
+ for (let j = 0; j < childrenArr.length; j++) {
139
+ frag.appendChild(childrenArr[j]);
140
+ }
141
+ } else {
142
+ if (node.ownerDocument !== doc) {
143
+ doc.adoptNode(node);
144
+ }
145
+ frag.appendChild(node);
146
+ }
147
+ }
148
+ parent.insertBefore(frag, anchor);
149
+ return;
150
+ }
151
+ const insertSingle = (nodeToInsert, anchorNode) => {
152
+ if (nodeToInsert.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {
153
+ parent.ownerDocument.adoptNode(nodeToInsert);
154
+ }
155
+ try {
156
+ parent.insertBefore(nodeToInsert, anchorNode);
157
+ return nodeToInsert;
158
+ } catch (e) {
159
+ if (parent.ownerDocument) {
160
+ try {
161
+ const clone = parent.ownerDocument.importNode(nodeToInsert, true);
162
+ parent.insertBefore(clone, anchorNode);
163
+ return clone;
164
+ } catch (e9) {
165
+ }
166
+ }
167
+ throw e;
168
+ }
169
+ };
170
+ for (let i = nodes.length - 1; i >= 0; i--) {
171
+ const node = nodes[i];
172
+ if (node === void 0 || node === null) continue;
173
+ const isFrag = node.nodeType === 11;
174
+ if (isFrag) {
175
+ const childrenArr = Array.from(node.childNodes);
176
+ for (let j = childrenArr.length - 1; j >= 0; j--) {
177
+ const child = childrenArr[j];
178
+ anchor = insertSingle(child, anchor);
179
+ }
180
+ } else {
181
+ anchor = insertSingle(node, anchor);
182
+ }
183
+ }
184
+ }
185
+ function removeNodes(nodes) {
186
+ for (const node of nodes) {
187
+ _optionalChain([node, 'access', _2 => _2.parentNode, 'optionalAccess', _3 => _3.removeChild, 'call', _4 => _4(node)]);
188
+ }
189
+ }
190
+ var SLOT_START = "fict:slot:start";
191
+ var SLOT_END = "fict:slot:end";
192
+ function isSlotStart(node) {
193
+ return !!(node && node.nodeType === 8 && node.data === SLOT_START);
194
+ }
195
+ function isSlotEnd(node) {
196
+ return !!(node && node.nodeType === 8 && node.data === SLOT_END);
197
+ }
198
+ function getSlotEnd(start) {
199
+ let depth = 1;
200
+ let cursor = start.nextSibling;
201
+ while (cursor) {
202
+ if (isSlotStart(cursor)) {
203
+ depth++;
204
+ } else if (isSlotEnd(cursor)) {
205
+ depth--;
206
+ if (depth === 0) {
207
+ return cursor;
208
+ }
209
+ }
210
+ cursor = cursor.nextSibling;
211
+ }
212
+ const owner = _nullishCoalesce(start.ownerDocument, () => ( document));
213
+ const end = owner.createComment(SLOT_END);
214
+ if (start.parentNode) {
215
+ start.parentNode.insertBefore(end, start.nextSibling);
216
+ }
217
+ return end;
218
+ }
219
+ function resolvePath(root, path) {
220
+ let current = root;
221
+ for (const index of path) {
222
+ if (!current) return null;
223
+ let child = current.firstChild;
224
+ let currentIndex = 0;
225
+ while (child) {
226
+ if (isSlotStart(child)) {
227
+ if (currentIndex === index) {
228
+ current = child;
229
+ break;
230
+ }
231
+ const end = getSlotEnd(child);
232
+ child = end.nextSibling;
233
+ currentIndex++;
234
+ continue;
235
+ }
236
+ if (currentIndex === index) {
237
+ current = child;
238
+ break;
239
+ }
240
+ currentIndex++;
241
+ child = child.nextSibling;
242
+ }
243
+ if (!child) {
244
+ return null;
245
+ }
246
+ }
247
+ return current;
248
+ }
249
+
250
+ // src/transition.ts
251
+ function startTransition(fn) {
252
+ const prev = _chunk6SOPF5LZcjs.setTransitionContext.call(void 0, true);
253
+ try {
254
+ fn();
255
+ } finally {
256
+ _chunk6SOPF5LZcjs.setTransitionContext.call(void 0, prev);
257
+ _chunk6SOPF5LZcjs.scheduleFlush.call(void 0, );
258
+ }
259
+ }
260
+ function useTransition() {
261
+ const pending = _chunk6SOPF5LZcjs.signal.call(void 0, false);
262
+ const start = (fn) => {
263
+ startTransition(() => {
264
+ pending(true);
265
+ try {
266
+ fn();
267
+ } finally {
268
+ pending(false);
269
+ }
270
+ });
271
+ };
272
+ return [() => pending(), start];
273
+ }
274
+ function useDeferredValue(getValue) {
275
+ const deferredValue = _chunk6SOPF5LZcjs.signal.call(void 0, getValue());
276
+ _chunk6SOPF5LZcjs.createEffect.call(void 0, () => {
277
+ const newValue = getValue();
278
+ const currentDeferred = _chunk6SOPF5LZcjs.untrack.call(void 0, () => deferredValue());
279
+ if (currentDeferred !== newValue) {
280
+ startTransition(() => {
281
+ deferredValue(newValue);
282
+ });
283
+ }
284
+ });
285
+ return () => deferredValue();
286
+ }
287
+
288
+ // src/scheduler.ts
289
+ function batch2(fn) {
290
+ return _chunk6SOPF5LZcjs.batch.call(void 0, fn);
291
+ }
292
+ function untrack2(fn) {
293
+ return _chunk6SOPF5LZcjs.untrack.call(void 0, fn);
294
+ }
295
+
296
+ // src/hydration.ts
297
+ var hydrationStack = [];
298
+ function withHydration(root, fn) {
299
+ const owner = _nullishCoalesce(root.ownerDocument, () => ( document));
300
+ hydrationStack.push({
301
+ cursor: root.firstChild,
302
+ boundary: null,
303
+ owner
304
+ });
305
+ try {
306
+ fn();
307
+ } finally {
308
+ hydrationStack.pop();
309
+ }
310
+ }
311
+ function withHydrationRange(start, end, owner, fn) {
312
+ hydrationStack.push({
313
+ cursor: start,
314
+ boundary: end,
315
+ owner
316
+ });
317
+ try {
318
+ fn();
319
+ } finally {
320
+ hydrationStack.pop();
321
+ }
322
+ }
323
+ function claimNodes(templateRoot, fallback) {
324
+ const ctx = hydrationStack[hydrationStack.length - 1];
325
+ if (!ctx || !ctx.cursor) {
326
+ return fallback();
327
+ }
328
+ const count = templateRoot.nodeType === 11 ? templateRoot.childNodes.length : 1;
329
+ if (count === 0) return fallback();
330
+ const claimed = [];
331
+ let cursor = ctx.cursor;
332
+ for (let i = 0; i < count; i++) {
333
+ if (!cursor || cursor === ctx.boundary) {
334
+ return fallback();
335
+ }
336
+ claimed.push(cursor);
337
+ cursor = cursor.nextSibling;
338
+ }
339
+ ctx.cursor = cursor;
340
+ if (claimed.length === 1) {
341
+ return claimed[0];
342
+ }
343
+ const frag = ctx.owner.createDocumentFragment();
344
+ for (const node of claimed) {
345
+ frag.appendChild(node);
346
+ }
347
+ return frag;
348
+ }
349
+ function isHydratingActive() {
350
+ return hydrationStack.length > 0;
351
+ }
352
+
353
+ // src/binding.ts
354
+ var isDev = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _5 => _5.env, 'optionalAccess', _6 => _6.NODE_ENV]) !== "production";
355
+ function isReactive(value) {
356
+ if (typeof value !== "function") return false;
357
+ if (_chunk6SOPF5LZcjs.isSignal.call(void 0, value) || _chunk6SOPF5LZcjs.isComputed.call(void 0, value)) return true;
358
+ if (_chunk6SOPF5LZcjs.isEffect.call(void 0, value) || _chunk6SOPF5LZcjs.isEffectScope.call(void 0, value)) return false;
359
+ return value.length === 0;
360
+ }
361
+ function isStrictlyReactive(value) {
362
+ if (typeof value !== "function") return false;
363
+ return _chunk6SOPF5LZcjs.isSignal.call(void 0, value) || _chunk6SOPF5LZcjs.isComputed.call(void 0, value) || isPropGetterFn(value);
364
+ }
365
+ var PROP_GETTER_MARKER = Symbol.for("fict:prop-getter");
366
+ function isPropGetterFn(value) {
367
+ if (typeof value !== "function") return false;
368
+ return value[PROP_GETTER_MARKER] === true;
369
+ }
370
+ function unwrap(value) {
371
+ return isReactive(value) ? value() : value;
372
+ }
373
+ function callEventHandler(handler, event, node, data) {
374
+ if (!handler) return;
375
+ const context = _nullishCoalesce(_nullishCoalesce(node, () => ( event.currentTarget)), () => ( void 0));
376
+ const invoke = (fn) => {
377
+ if (typeof fn === "function") {
378
+ const result = data === void 0 ? fn.call(context, event) : fn.call(context, data, event);
379
+ if (typeof result === "function" && result !== fn) {
380
+ if (data === void 0) {
381
+ ;
382
+ result.call(context, event);
383
+ } else {
384
+ ;
385
+ result.call(context, data, event);
386
+ }
387
+ } else if (result && typeof result.handleEvent === "function") {
388
+ ;
389
+ result.handleEvent.call(result, event);
390
+ }
391
+ } else if (fn && typeof fn.handleEvent === "function") {
392
+ fn.handleEvent.call(fn, event);
393
+ }
394
+ };
395
+ invoke(handler);
396
+ }
397
+ function createTextBinding(value) {
398
+ const text = document.createTextNode("");
399
+ if (isReactive(value)) {
400
+ _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
401
+ const v = value();
402
+ const fmt = formatTextValue(v);
403
+ if (text.data !== fmt) {
404
+ text.data = fmt;
405
+ }
406
+ });
407
+ } else {
408
+ text.data = formatTextValue(value);
409
+ }
410
+ return text;
411
+ }
412
+ function bindText(textNode, getValue) {
413
+ return _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
414
+ const value = formatTextValue(getValue());
415
+ if (textNode.data !== value) {
416
+ textNode.data = value;
417
+ }
418
+ });
419
+ }
420
+ function formatTextValue(value) {
421
+ if (value == null || value === false) {
422
+ return "";
423
+ }
424
+ return String(value);
425
+ }
426
+ function createAttributeBinding(el, key, value, setter) {
427
+ if (isReactive(value)) {
428
+ _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
429
+ setter(el, key, value());
430
+ });
431
+ } else {
432
+ setter(el, key, value);
433
+ }
434
+ }
435
+ function bindAttribute(el, key, getValue) {
436
+ let prevValue = void 0;
437
+ return _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
438
+ const value = getValue();
439
+ if (value === prevValue) return;
440
+ prevValue = value;
441
+ if (value === void 0 || value === null || value === false) {
442
+ el.removeAttribute(key);
443
+ } else if (value === true) {
444
+ el.setAttribute(key, "");
445
+ } else {
446
+ el.setAttribute(key, String(value));
447
+ }
448
+ });
449
+ }
450
+ function bindProperty(el, key, getValue) {
451
+ const PROPERTY_BINDING_KEYS = /* @__PURE__ */ new Set([
452
+ "value",
453
+ "checked",
454
+ "selected",
455
+ "disabled",
456
+ "readOnly",
457
+ "multiple",
458
+ "muted"
459
+ ]);
460
+ let prevValue = void 0;
461
+ return _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
462
+ const next = getValue();
463
+ if (next === prevValue) return;
464
+ prevValue = next;
465
+ if (PROPERTY_BINDING_KEYS.has(key) && (next === void 0 || next === null)) {
466
+ const fallback = key === "checked" || key === "selected" ? false : "";
467
+ el[key] = fallback;
468
+ return;
469
+ }
470
+ ;
471
+ el[key] = next;
472
+ });
473
+ }
474
+ function createStyleBinding(el, value) {
475
+ const target = el;
476
+ if (isReactive(value)) {
477
+ let prev;
478
+ _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
479
+ const next = value();
480
+ applyStyle(target, next, prev);
481
+ prev = next;
482
+ });
483
+ } else {
484
+ applyStyle(target, value, void 0);
485
+ }
486
+ }
487
+ function bindStyle(el, getValue) {
488
+ const target = el;
489
+ let prev;
490
+ return _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
491
+ const next = getValue();
492
+ applyStyle(target, next, prev);
493
+ prev = next;
494
+ });
495
+ }
496
+ function applyStyle(el, value, prev) {
497
+ if (typeof value === "string") {
498
+ el.style.cssText = value;
499
+ } else if (value && typeof value === "object") {
500
+ const styles = value;
501
+ if (typeof prev === "string") {
502
+ el.style.cssText = "";
503
+ }
504
+ if (prev && typeof prev === "object") {
505
+ const prevStyles = prev;
506
+ for (const key of Object.keys(prevStyles)) {
507
+ if (!(key in styles)) {
508
+ const cssProperty = key.replace(/([A-Z])/g, "-$1").toLowerCase();
509
+ el.style.removeProperty(cssProperty);
510
+ }
511
+ }
512
+ }
513
+ for (const [prop2, v] of Object.entries(styles)) {
514
+ if (v != null) {
515
+ const cssProperty = prop2.replace(/([A-Z])/g, "-$1").toLowerCase();
516
+ const unitless = isUnitlessStyleProperty(prop2) || isUnitlessStyleProperty(cssProperty);
517
+ const valueStr = typeof v === "number" && !unitless ? `${v}px` : String(v);
518
+ el.style.setProperty(cssProperty, valueStr);
519
+ } else {
520
+ const cssProperty = prop2.replace(/([A-Z])/g, "-$1").toLowerCase();
521
+ el.style.removeProperty(cssProperty);
522
+ }
523
+ }
524
+ } else {
525
+ if (prev && typeof prev === "object") {
526
+ const prevStyles = prev;
527
+ for (const key of Object.keys(prevStyles)) {
528
+ const cssProperty = key.replace(/([A-Z])/g, "-$1").toLowerCase();
529
+ el.style.removeProperty(cssProperty);
530
+ }
531
+ } else if (typeof prev === "string") {
532
+ el.style.cssText = "";
533
+ }
534
+ }
535
+ }
536
+ var isUnitlessStyleProperty = isDev ? (prop2) => _chunk6SOPF5LZcjs.UnitlessStyles.has(prop2) : (prop2) => prop2 === "opacity" || prop2 === "zIndex";
537
+ function createClassBinding(el, value) {
538
+ if (isReactive(value)) {
539
+ let prev = {};
540
+ _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
541
+ const next = value();
542
+ prev = applyClass(el, next, prev);
543
+ });
544
+ } else {
545
+ applyClass(el, value, {});
546
+ }
547
+ }
548
+ function bindClass(el, getValue) {
549
+ let prev = {};
550
+ let prevString;
551
+ return _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
552
+ const next = getValue();
553
+ if (typeof next === "string") {
554
+ if (next === prevString) return;
555
+ prevString = next;
556
+ el.className = next;
557
+ prev = {};
558
+ return;
559
+ }
560
+ prevString = void 0;
561
+ prev = applyClass(el, next, prev);
562
+ });
563
+ }
564
+ function toggleClassKey(node, key, value) {
565
+ const classNames = key.trim().split(/\s+/);
566
+ for (let i = 0, len = classNames.length; i < len; i++) {
567
+ node.classList.toggle(classNames[i], value);
568
+ }
569
+ }
570
+ function applyClass(el, value, prev) {
571
+ const prevState = prev && typeof prev === "object" ? prev : {};
572
+ if (typeof value === "string") {
573
+ el.className = value;
574
+ return {};
575
+ }
576
+ if (value && typeof value === "object") {
577
+ const classes = value;
578
+ const classKeys = Object.keys(classes);
579
+ const prevKeys = Object.keys(prevState);
580
+ for (let i = 0, len = prevKeys.length; i < len; i++) {
581
+ const key = prevKeys[i];
582
+ if (!key || key === "undefined" || classes[key]) continue;
583
+ toggleClassKey(el, key, false);
584
+ delete prevState[key];
585
+ }
586
+ for (let i = 0, len = classKeys.length; i < len; i++) {
587
+ const key = classKeys[i];
588
+ const classValue = !!classes[key];
589
+ if (!key || key === "undefined" || prevState[key] === classValue || !classValue) continue;
590
+ toggleClassKey(el, key, true);
591
+ prevState[key] = classValue;
592
+ }
593
+ return prevState;
594
+ }
595
+ if (!value) {
596
+ for (const key of Object.keys(prevState)) {
597
+ if (key && key !== "undefined") {
598
+ toggleClassKey(el, key, false);
599
+ }
600
+ }
601
+ return {};
602
+ }
603
+ return prevState;
604
+ }
605
+ function classList(node, value, prev = {}) {
606
+ return applyClass(node, value, prev);
607
+ }
608
+ function insert(parent, getValue, markerOrCreateElement, createElementFn) {
609
+ const hostRoot = _chunk6SOPF5LZcjs.getCurrentRoot.call(void 0, );
610
+ let marker;
611
+ let ownsMarker = false;
612
+ let createFn = createElementFn;
613
+ if (markerOrCreateElement instanceof Node) {
614
+ marker = markerOrCreateElement;
615
+ createFn = createElementFn;
616
+ } else {
617
+ marker = document.createComment("fict:insert");
618
+ parent.appendChild(marker);
619
+ createFn = markerOrCreateElement;
620
+ ownsMarker = true;
621
+ }
622
+ let currentNodes = [];
623
+ let currentText = null;
624
+ let currentRoot = null;
625
+ const clearCurrentNodes = () => {
626
+ if (currentNodes.length > 0) {
627
+ removeNodes(currentNodes);
628
+ currentNodes = [];
629
+ }
630
+ };
631
+ const setTextNode = (textValue, shouldInsert, parentNode) => {
632
+ if (!currentText) {
633
+ currentText = document.createTextNode(textValue);
634
+ } else if (currentText.data !== textValue) {
635
+ currentText.data = textValue;
636
+ }
637
+ if (!shouldInsert) {
638
+ clearCurrentNodes();
639
+ return;
640
+ }
641
+ if (currentNodes.length === 1 && currentNodes[0] === currentText) {
642
+ return;
643
+ }
644
+ clearCurrentNodes();
645
+ insertNodesBefore(parentNode, [currentText], marker);
646
+ currentNodes = [currentText];
647
+ };
648
+ const dispose = _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
649
+ const value = getValue();
650
+ const parentNode = marker.parentNode;
651
+ const isPrimitive = value == null || value === false || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
652
+ if (isPrimitive) {
653
+ if (currentRoot) {
654
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
655
+ currentRoot = null;
656
+ }
657
+ if (!parentNode) {
658
+ clearCurrentNodes();
659
+ return;
660
+ }
661
+ const textValue = value == null || value === false ? "" : String(value);
662
+ const shouldInsert = value != null && value !== false;
663
+ setTextNode(textValue, shouldInsert, parentNode);
664
+ return;
665
+ }
666
+ if (currentRoot) {
667
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
668
+ currentRoot = null;
669
+ }
670
+ clearCurrentNodes();
671
+ const root = _chunk6SOPF5LZcjs.createRootContext.call(void 0, hostRoot);
672
+ const prev = _chunk6SOPF5LZcjs.pushRoot.call(void 0, root);
673
+ let nodes = [];
674
+ let handledError = false;
675
+ try {
676
+ let newNode;
677
+ if (value instanceof Node) {
678
+ newNode = value;
679
+ } else if (Array.isArray(value)) {
680
+ if (value.every((v) => v instanceof Node)) {
681
+ newNode = value;
682
+ } else {
683
+ if (createFn) {
684
+ const mapped = [];
685
+ for (const item of value) {
686
+ mapped.push(...toNodeArray(createFn(item)));
687
+ }
688
+ newNode = mapped;
689
+ } else {
690
+ newNode = document.createTextNode(String(value));
691
+ }
692
+ }
693
+ } else {
694
+ newNode = createFn ? createFn(value) : document.createTextNode(String(value));
695
+ }
696
+ nodes = toNodeArray(newNode);
697
+ if (root.suspended) {
698
+ handledError = true;
699
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
700
+ return;
701
+ }
702
+ if (parentNode) {
703
+ insertNodesBefore(parentNode, nodes, marker);
704
+ }
705
+ } catch (err) {
706
+ if (_chunk6SOPF5LZcjs.handleSuspend.call(void 0, err, root)) {
707
+ handledError = true;
708
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
709
+ return;
710
+ }
711
+ if (_chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "renderChild" }, root)) {
712
+ handledError = true;
713
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
714
+ return;
715
+ }
716
+ throw err;
717
+ } finally {
718
+ _chunk6SOPF5LZcjs.popRoot.call(void 0, prev);
719
+ if (!handledError) {
720
+ _chunk6SOPF5LZcjs.flushOnMount.call(void 0, root);
721
+ }
722
+ }
723
+ currentRoot = root;
724
+ currentNodes = nodes;
725
+ });
726
+ return () => {
727
+ dispose();
728
+ if (currentRoot) {
729
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
730
+ currentRoot = null;
731
+ }
732
+ clearCurrentNodes();
733
+ if (ownsMarker) {
734
+ _optionalChain([marker, 'access', _7 => _7.parentNode, 'optionalAccess', _8 => _8.removeChild, 'call', _9 => _9(marker)]);
735
+ }
736
+ };
737
+ }
738
+ function insertBetween(start, end, getValue, createElementFn) {
739
+ const hostRoot = _chunk6SOPF5LZcjs.getCurrentRoot.call(void 0, );
740
+ let currentNodes = [];
741
+ let currentText = null;
742
+ let currentRoot = null;
743
+ let initialHydrating = _chunk6SOPF5LZcjs.__fictIsHydrating.call(void 0, );
744
+ const collectBetween = () => {
745
+ const nodes = [];
746
+ let cursor = start.nextSibling;
747
+ while (cursor && cursor !== end) {
748
+ nodes.push(cursor);
749
+ cursor = cursor.nextSibling;
750
+ }
751
+ return nodes;
752
+ };
753
+ const clearCurrentNodes = () => {
754
+ if (currentNodes.length > 0) {
755
+ removeNodes(currentNodes);
756
+ currentNodes = [];
757
+ }
758
+ };
759
+ const setTextNode = (textValue, shouldInsert) => {
760
+ if (!currentText) {
761
+ currentText = document.createTextNode(textValue);
762
+ } else if (currentText.data !== textValue) {
763
+ currentText.data = textValue;
764
+ }
765
+ if (!shouldInsert) {
766
+ clearCurrentNodes();
767
+ return;
768
+ }
769
+ if (currentNodes.length === 1 && currentNodes[0] === currentText) {
770
+ return;
771
+ }
772
+ clearCurrentNodes();
773
+ const parentNode = start.parentNode;
774
+ if (parentNode) {
775
+ insertNodesBefore(parentNode, [currentText], end);
776
+ currentNodes = [currentText];
777
+ }
778
+ };
779
+ const dispose = _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
780
+ const value = getValue();
781
+ const parentNode = start.parentNode;
782
+ const isPrimitive = value == null || value === false || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
783
+ if (isPrimitive) {
784
+ if (initialHydrating && isHydratingActive() && parentNode) {
785
+ const existing = collectBetween();
786
+ if (existing.length > 0) {
787
+ currentNodes = existing;
788
+ const only = existing.length === 1 ? existing[0] : null;
789
+ currentText = only && only.nodeType === 3 ? only : null;
790
+ }
791
+ }
792
+ if (currentRoot) {
793
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
794
+ currentRoot = null;
795
+ }
796
+ if (!parentNode) {
797
+ clearCurrentNodes();
798
+ return;
799
+ }
800
+ const textValue = value == null || value === false ? "" : String(value);
801
+ const shouldInsert = value != null && value !== false;
802
+ setTextNode(textValue, shouldInsert);
803
+ initialHydrating = false;
804
+ return;
805
+ }
806
+ if (currentRoot) {
807
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
808
+ currentRoot = null;
809
+ }
810
+ clearCurrentNodes();
811
+ const root = _chunk6SOPF5LZcjs.createRootContext.call(void 0, hostRoot);
812
+ const prev = _chunk6SOPF5LZcjs.pushRoot.call(void 0, root);
813
+ let nodes = [];
814
+ let handledError = false;
815
+ try {
816
+ let newNode = void 0;
817
+ const createValue = () => {
818
+ if (value instanceof Node) {
819
+ return value;
820
+ }
821
+ if (Array.isArray(value)) {
822
+ if (value.every((v) => v instanceof Node)) {
823
+ return value;
824
+ }
825
+ if (createElementFn) {
826
+ const mapped = [];
827
+ for (const item of value) {
828
+ mapped.push(...toNodeArray(createElementFn(item)));
829
+ }
830
+ return mapped;
831
+ }
832
+ return document.createTextNode(String(value));
833
+ }
834
+ return createElementFn ? createElementFn(value) : document.createTextNode(String(value));
835
+ };
836
+ if (initialHydrating && isHydratingActive() && parentNode) {
837
+ withHydrationRange(start.nextSibling, end, _nullishCoalesce(parentNode.ownerDocument, () => ( document)), () => {
838
+ newNode = createValue();
839
+ });
840
+ } else {
841
+ newNode = createValue();
842
+ }
843
+ nodes = toNodeArray(newNode);
844
+ if (root.suspended) {
845
+ handledError = true;
846
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
847
+ return;
848
+ }
849
+ if (parentNode && !initialHydrating) {
850
+ insertNodesBefore(parentNode, nodes, end);
851
+ }
852
+ } catch (err) {
853
+ if (_chunk6SOPF5LZcjs.handleSuspend.call(void 0, err, root)) {
854
+ handledError = true;
855
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
856
+ return;
857
+ }
858
+ if (_chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "renderChild" }, root)) {
859
+ handledError = true;
860
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
861
+ return;
862
+ }
863
+ throw err;
864
+ } finally {
865
+ _chunk6SOPF5LZcjs.popRoot.call(void 0, prev);
866
+ if (!handledError) {
867
+ _chunk6SOPF5LZcjs.flushOnMount.call(void 0, root);
868
+ }
869
+ }
870
+ currentRoot = root;
871
+ currentNodes = initialHydrating ? collectBetween() : nodes;
872
+ initialHydrating = false;
873
+ });
874
+ return () => {
875
+ dispose();
876
+ if (currentRoot) {
877
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
878
+ currentRoot = null;
879
+ }
880
+ clearCurrentNodes();
881
+ };
882
+ }
883
+ function createChildBinding(parent, getValue, createElementFn) {
884
+ const marker = document.createComment("fict:child");
885
+ parent.appendChild(marker);
886
+ const hostRoot = _chunk6SOPF5LZcjs.getCurrentRoot.call(void 0, );
887
+ const dispose = _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
888
+ const root = _chunk6SOPF5LZcjs.createRootContext.call(void 0, hostRoot);
889
+ const prev = _chunk6SOPF5LZcjs.pushRoot.call(void 0, root);
890
+ let nodes = [];
891
+ let handledError = false;
892
+ try {
893
+ const value = getValue();
894
+ if (value == null || value === false) {
895
+ return;
896
+ }
897
+ const output = createElementFn(value);
898
+ nodes = toNodeArray(output);
899
+ const parentNode = marker.parentNode;
900
+ if (parentNode) {
901
+ insertNodesBefore(parentNode, nodes, marker);
902
+ }
903
+ return () => {
904
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
905
+ removeNodes(nodes);
906
+ };
907
+ } catch (err) {
908
+ if (_chunk6SOPF5LZcjs.handleSuspend.call(void 0, err, root)) {
909
+ handledError = true;
910
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
911
+ return;
912
+ }
913
+ if (_chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "renderChild" }, root)) {
914
+ handledError = true;
915
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
916
+ return;
917
+ }
918
+ throw err;
919
+ } finally {
920
+ _chunk6SOPF5LZcjs.popRoot.call(void 0, prev);
921
+ if (!handledError) {
922
+ _chunk6SOPF5LZcjs.flushOnMount.call(void 0, root);
923
+ }
924
+ }
925
+ });
926
+ return {
927
+ marker,
928
+ dispose: () => {
929
+ dispose();
930
+ _optionalChain([marker, 'access', _10 => _10.parentNode, 'optionalAccess', _11 => _11.removeChild, 'call', _12 => _12(marker)]);
931
+ }
932
+ };
933
+ }
934
+ function delegateEvents(eventNames, doc = window.document) {
935
+ const e = doc[_chunk6SOPF5LZcjs.$$EVENTS] || (doc[_chunk6SOPF5LZcjs.$$EVENTS] = /* @__PURE__ */ new Set());
936
+ for (let i = 0, l = eventNames.length; i < l; i++) {
937
+ const name = eventNames[i];
938
+ if (!e.has(name)) {
939
+ e.add(name);
940
+ doc.addEventListener(name, globalEventHandler);
941
+ }
942
+ }
943
+ }
944
+ function clearDelegatedEvents(doc = window.document) {
945
+ const e = doc[_chunk6SOPF5LZcjs.$$EVENTS];
946
+ if (e) {
947
+ for (const name of e.keys()) {
948
+ doc.removeEventListener(name, globalEventHandler);
949
+ }
950
+ delete doc[_chunk6SOPF5LZcjs.$$EVENTS];
951
+ }
952
+ }
953
+ function globalEventHandler(e) {
954
+ const asNode = (value) => value && typeof value.nodeType === "number" ? value : null;
955
+ const asElement = (value) => {
956
+ const n = asNode(value);
957
+ if (!n) return null;
958
+ if (n.nodeType === 1) return n;
959
+ return n.parentElement;
960
+ };
961
+ let node = asElement(e.target);
962
+ const key = `$$${e.type}`;
963
+ const dataKey = `${key}Data`;
964
+ const oriTarget = e.target;
965
+ const oriCurrentTarget = e.currentTarget;
966
+ let lastHandled = null;
967
+ const retarget = (value) => Object.defineProperty(e, "target", {
968
+ configurable: true,
969
+ value
970
+ });
971
+ const handleNode = () => {
972
+ if (!node) return false;
973
+ const handler = node[key];
974
+ if (handler && !node.disabled) {
975
+ const resolveData = (value) => {
976
+ if (typeof value === "function") {
977
+ try {
978
+ const fn = value;
979
+ return fn.length > 0 ? fn(e) : fn();
980
+ } catch (e10) {
981
+ return value();
982
+ }
983
+ }
984
+ return value;
985
+ };
986
+ const rawData = node[dataKey];
987
+ const hasData = rawData !== void 0;
988
+ const resolvedNodeData = hasData ? resolveData(rawData) : void 0;
989
+ batch2(() => {
990
+ if (typeof handler === "function") {
991
+ callEventHandler(handler, e, node, hasData ? resolvedNodeData : void 0);
992
+ } else if (Array.isArray(handler)) {
993
+ const tupleData = resolveData(handler[1]);
994
+ callEventHandler(handler[0], e, node, tupleData);
995
+ }
996
+ });
997
+ if (e.cancelBubble) return false;
998
+ }
999
+ const shadowHost = node.host;
1000
+ if (shadowHost && typeof shadowHost !== "string" && !shadowHost._$host && (() => {
1001
+ const targetNode = asNode(e.target);
1002
+ return targetNode ? node.contains(targetNode) : false;
1003
+ })()) {
1004
+ retarget(shadowHost);
1005
+ }
1006
+ return true;
1007
+ };
1008
+ const walkUpTree = () => {
1009
+ while (handleNode() && node) {
1010
+ node = asElement(node._$host || node.parentNode || node.host);
1011
+ }
1012
+ };
1013
+ Object.defineProperty(e, "currentTarget", {
1014
+ configurable: true,
1015
+ get() {
1016
+ return node || document;
1017
+ }
1018
+ });
1019
+ if (e.composedPath) {
1020
+ const path = e.composedPath();
1021
+ retarget(path[0]);
1022
+ for (let i = 0; i < path.length - 2; i++) {
1023
+ const nextNode = asElement(path[i]);
1024
+ if (!nextNode || nextNode === lastHandled) continue;
1025
+ node = nextNode;
1026
+ if (!handleNode()) break;
1027
+ lastHandled = node;
1028
+ if (node._$host) {
1029
+ node = node._$host;
1030
+ walkUpTree();
1031
+ break;
1032
+ }
1033
+ if (node.parentNode === oriCurrentTarget) {
1034
+ break;
1035
+ }
1036
+ }
1037
+ } else {
1038
+ walkUpTree();
1039
+ }
1040
+ retarget(oriTarget);
1041
+ }
1042
+ function addEventListener(node, name, handler, delegate) {
1043
+ if (handler == null) return;
1044
+ if (delegate) {
1045
+ if (Array.isArray(handler)) {
1046
+ ;
1047
+ node[`$$${name}`] = handler[0];
1048
+ node[`$$${name}Data`] = handler[1];
1049
+ } else {
1050
+ ;
1051
+ node[`$$${name}`] = handler;
1052
+ }
1053
+ } else if (Array.isArray(handler)) {
1054
+ const handlerFn = handler[0];
1055
+ node.addEventListener(name, (e) => handlerFn.call(node, handler[1], e));
1056
+ } else {
1057
+ node.addEventListener(name, handler);
1058
+ }
1059
+ }
1060
+ function bindEvent(el, eventName, handler, options) {
1061
+ if (handler == null) return () => {
1062
+ };
1063
+ const rootRef = _chunk6SOPF5LZcjs.getCurrentRoot.call(void 0, );
1064
+ const shouldDelegate = options == null && _chunk6SOPF5LZcjs.DelegatedEvents.has(eventName);
1065
+ if (shouldDelegate) {
1066
+ const key = `$$${eventName}`;
1067
+ delegateEvents([eventName]);
1068
+ const resolveHandler = isStrictlyReactive(handler) ? handler : () => handler;
1069
+ el[key] = function(...args) {
1070
+ try {
1071
+ const fn = resolveHandler();
1072
+ callEventHandler(fn, args[0], el);
1073
+ } catch (err) {
1074
+ if (!_chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "event", eventName }, rootRef)) {
1075
+ throw err;
1076
+ }
1077
+ }
1078
+ };
1079
+ return () => {
1080
+ el[key] = void 0;
1081
+ };
1082
+ }
1083
+ const getHandler = isStrictlyReactive(handler) ? handler : () => handler;
1084
+ const wrapped = (event) => {
1085
+ try {
1086
+ const resolved = getHandler();
1087
+ callEventHandler(resolved, event, el);
1088
+ } catch (err) {
1089
+ if (_chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "event", eventName }, rootRef)) {
1090
+ return;
1091
+ }
1092
+ throw err;
1093
+ }
1094
+ };
1095
+ el.addEventListener(eventName, wrapped, options);
1096
+ const cleanup = () => el.removeEventListener(eventName, wrapped, options);
1097
+ _chunk6SOPF5LZcjs.registerRootCleanup.call(void 0, cleanup);
1098
+ return cleanup;
1099
+ }
1100
+ function bindRef(el, ref) {
1101
+ if (ref == null) return () => {
1102
+ };
1103
+ const getRef = isReactive(ref) ? ref : () => ref;
1104
+ const applyRef2 = (refValue) => {
1105
+ if (refValue == null) return;
1106
+ if (typeof refValue === "function") {
1107
+ ;
1108
+ refValue(el);
1109
+ } else if (typeof refValue === "object" && "current" in refValue) {
1110
+ ;
1111
+ refValue.current = el;
1112
+ }
1113
+ };
1114
+ const initialRef = getRef();
1115
+ applyRef2(initialRef);
1116
+ if (isReactive(ref)) {
1117
+ const cleanup2 = _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
1118
+ const currentRef = getRef();
1119
+ applyRef2(currentRef);
1120
+ });
1121
+ _chunk6SOPF5LZcjs.registerRootCleanup.call(void 0, cleanup2);
1122
+ const nullifyCleanup = () => {
1123
+ const currentRef = getRef();
1124
+ if (currentRef && typeof currentRef === "object" && "current" in currentRef) {
1125
+ ;
1126
+ currentRef.current = null;
1127
+ }
1128
+ };
1129
+ _chunk6SOPF5LZcjs.registerRootCleanup.call(void 0, nullifyCleanup);
1130
+ return () => {
1131
+ cleanup2();
1132
+ nullifyCleanup();
1133
+ };
1134
+ }
1135
+ const cleanup = () => {
1136
+ const refValue = getRef();
1137
+ if (refValue && typeof refValue === "object" && "current" in refValue) {
1138
+ ;
1139
+ refValue.current = null;
1140
+ }
1141
+ };
1142
+ _chunk6SOPF5LZcjs.registerRootCleanup.call(void 0, cleanup);
1143
+ return cleanup;
1144
+ }
1145
+ function spread(node, props = {}, isSVG = false, skipChildren = false) {
1146
+ const prevProps = {};
1147
+ if (!skipChildren && "children" in props) {
1148
+ _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
1149
+ prevProps.children = props.children;
1150
+ });
1151
+ }
1152
+ _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
1153
+ if (typeof props.ref === "function") {
1154
+ ;
1155
+ props.ref(node);
1156
+ }
1157
+ });
1158
+ _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
1159
+ assign(node, props, isSVG, true, prevProps, true);
1160
+ });
1161
+ return prevProps;
1162
+ }
1163
+ function assign(node, props, isSVG = false, skipChildren = false, prevProps = {}, skipRef = false) {
1164
+ props = props || {};
1165
+ for (const prop2 in prevProps) {
1166
+ if (!(prop2 in props)) {
1167
+ if (prop2 === "children") continue;
1168
+ prevProps[prop2] = assignProp(node, prop2, null, prevProps[prop2], isSVG, skipRef, props);
1169
+ }
1170
+ }
1171
+ for (const prop2 in props) {
1172
+ if (prop2 === "children") {
1173
+ if (!skipChildren) {
1174
+ prevProps.children = props.children;
1175
+ }
1176
+ continue;
1177
+ }
1178
+ const value = props[prop2];
1179
+ prevProps[prop2] = assignProp(node, prop2, value, prevProps[prop2], isSVG, skipRef, props);
1180
+ }
1181
+ }
1182
+ function assignProp(node, prop2, value, prev, isSVG, skipRef, props) {
1183
+ if (prop2 === "style") {
1184
+ applyStyle(node, value, prev);
1185
+ return value;
1186
+ }
1187
+ if (prop2 === "classList") {
1188
+ return applyClass(node, value, prev);
1189
+ }
1190
+ if (value === prev) return prev;
1191
+ if (prop2 === "ref") {
1192
+ if (!skipRef && typeof value === "function") {
1193
+ ;
1194
+ value(node);
1195
+ }
1196
+ return value;
1197
+ }
1198
+ if (prop2.slice(0, 3) === "on:") {
1199
+ const eventName = prop2.slice(3);
1200
+ if (typeof value === "string") {
1201
+ node.setAttribute(prop2, value);
1202
+ return value;
1203
+ }
1204
+ if (prev && typeof prev !== "string") node.removeEventListener(eventName, prev);
1205
+ if (value) node.addEventListener(eventName, value);
1206
+ return value;
1207
+ }
1208
+ if (prop2.slice(0, 10) === "oncapture:") {
1209
+ const eventName = prop2.slice(10);
1210
+ if (prev) node.removeEventListener(eventName, prev, true);
1211
+ if (value) node.addEventListener(eventName, value, true);
1212
+ return value;
1213
+ }
1214
+ if (prop2.slice(0, 2) === "on") {
1215
+ const eventName = prop2.slice(2).toLowerCase();
1216
+ const shouldDelegate = _chunk6SOPF5LZcjs.DelegatedEvents.has(eventName);
1217
+ if (!shouldDelegate && prev) {
1218
+ const handler = Array.isArray(prev) ? prev[0] : prev;
1219
+ node.removeEventListener(eventName, handler);
1220
+ }
1221
+ if (shouldDelegate || value) {
1222
+ addEventListener(node, eventName, value, shouldDelegate);
1223
+ if (shouldDelegate) delegateEvents([eventName]);
1224
+ }
1225
+ return value;
1226
+ }
1227
+ if (prop2.slice(0, 5) === "attr:") {
1228
+ if (value == null) node.removeAttribute(prop2.slice(5));
1229
+ else node.setAttribute(prop2.slice(5), String(value));
1230
+ return value;
1231
+ }
1232
+ if (prop2.slice(0, 5) === "bool:") {
1233
+ if (value) node.setAttribute(prop2.slice(5), "");
1234
+ else node.removeAttribute(prop2.slice(5));
1235
+ return value;
1236
+ }
1237
+ if (prop2.slice(0, 5) === "prop:") {
1238
+ ;
1239
+ node[prop2.slice(5)] = value;
1240
+ return value;
1241
+ }
1242
+ if (prop2 === "class" || prop2 === "className") {
1243
+ if (value == null) node.removeAttribute("class");
1244
+ else node.className = String(value);
1245
+ return value;
1246
+ }
1247
+ const isCE = node.nodeName.includes("-") || "is" in props;
1248
+ if (!isSVG) {
1249
+ const propAlias = isDev ? _chunk6SOPF5LZcjs.getPropAlias.call(void 0, prop2, node.tagName) : void 0;
1250
+ const isProperty = isDev ? _chunk6SOPF5LZcjs.Properties.has(prop2) : prop2 in node;
1251
+ const isChildProp = isDev ? _chunk6SOPF5LZcjs.ChildProperties.has(prop2) : prop2 === "innerHTML" || prop2 === "textContent" || prop2 === "innerText" || prop2 === "children";
1252
+ if (propAlias || isProperty || isChildProp || isCE) {
1253
+ const propName = propAlias || prop2;
1254
+ if (isCE && !isProperty && !isChildProp && !propAlias) {
1255
+ ;
1256
+ node[toPropertyName(propName)] = value;
1257
+ } else {
1258
+ ;
1259
+ node[propName] = value;
1260
+ }
1261
+ return value;
1262
+ }
1263
+ }
1264
+ if (isSVG && prop2.indexOf(":") > -1) {
1265
+ const [prefix, name] = prop2.split(":");
1266
+ const ns = _chunk6SOPF5LZcjs.SVGNamespace[prefix];
1267
+ if (ns) {
1268
+ if (value == null) node.removeAttributeNS(ns, name);
1269
+ else node.setAttributeNS(ns, name, String(value));
1270
+ return value;
1271
+ }
1272
+ }
1273
+ const attrName = prop2 === "htmlFor" ? "for" : prop2;
1274
+ if (value == null) node.removeAttribute(attrName);
1275
+ else node.setAttribute(attrName, String(value));
1276
+ return value;
1277
+ }
1278
+ function toPropertyName(name) {
1279
+ return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
1280
+ }
1281
+ function createConditional(condition, renderTrue, createElementFn, renderFalse, startOverride, endOverride) {
1282
+ const useProvided = !!(startOverride && endOverride);
1283
+ const startMarker = useProvided ? startOverride : document.createComment("fict:cond:start");
1284
+ const endMarker = useProvided ? endOverride : document.createComment("fict:cond:end");
1285
+ const fragment = useProvided ? startMarker : document.createDocumentFragment();
1286
+ if (!useProvided) {
1287
+ ;
1288
+ fragment.append(startMarker, endMarker);
1289
+ }
1290
+ const hostRoot = _chunk6SOPF5LZcjs.getCurrentRoot.call(void 0, );
1291
+ let currentNodes = [];
1292
+ let currentRoot = null;
1293
+ let lastCondition = void 0;
1294
+ let pendingRender = false;
1295
+ let initialHydrating = _chunk6SOPF5LZcjs.__fictIsHydrating.call(void 0, );
1296
+ const collectBetween = () => {
1297
+ const nodes = [];
1298
+ let cursor = startMarker.nextSibling;
1299
+ while (cursor && cursor !== endMarker) {
1300
+ nodes.push(cursor);
1301
+ cursor = cursor.nextSibling;
1302
+ }
1303
+ return nodes;
1304
+ };
1305
+ const conditionMemo = _chunk6SOPF5LZcjs.computed.call(void 0, condition);
1306
+ const runConditional = () => {
1307
+ const cond = conditionMemo();
1308
+ const parent = startMarker.parentNode;
1309
+ if (!parent) {
1310
+ pendingRender = true;
1311
+ return;
1312
+ }
1313
+ pendingRender = false;
1314
+ if (initialHydrating && isHydratingActive()) {
1315
+ initialHydrating = false;
1316
+ lastCondition = cond;
1317
+ const render3 = cond ? renderTrue : renderFalse;
1318
+ if (!render3) {
1319
+ currentNodes = collectBetween();
1320
+ return;
1321
+ }
1322
+ const root2 = _chunk6SOPF5LZcjs.createRootContext.call(void 0, hostRoot);
1323
+ const prev2 = _chunk6SOPF5LZcjs.pushRoot.call(void 0, root2);
1324
+ let handledError2 = false;
1325
+ try {
1326
+ withHydrationRange(
1327
+ startMarker.nextSibling,
1328
+ endMarker,
1329
+ _nullishCoalesce(parent.ownerDocument, () => ( document)),
1330
+ () => {
1331
+ const output = _chunk6SOPF5LZcjs.untrack.call(void 0, render3);
1332
+ if (output == null || output === false) {
1333
+ return;
1334
+ }
1335
+ createElementFn(output);
1336
+ }
1337
+ );
1338
+ currentNodes = collectBetween();
1339
+ } catch (err) {
1340
+ if (_chunk6SOPF5LZcjs.handleSuspend.call(void 0, err, root2)) {
1341
+ handledError2 = true;
1342
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root2);
1343
+ return;
1344
+ }
1345
+ if (_chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "renderChild" }, root2)) {
1346
+ handledError2 = true;
1347
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root2);
1348
+ return;
1349
+ }
1350
+ throw err;
1351
+ } finally {
1352
+ _chunk6SOPF5LZcjs.popRoot.call(void 0, prev2);
1353
+ if (!handledError2) {
1354
+ _chunk6SOPF5LZcjs.flushOnMount.call(void 0, root2);
1355
+ currentRoot = root2;
1356
+ } else {
1357
+ currentRoot = null;
1358
+ }
1359
+ }
1360
+ return;
1361
+ }
1362
+ if (lastCondition === cond && currentNodes.length > 0) {
1363
+ return;
1364
+ }
1365
+ if (lastCondition === cond && lastCondition === false && renderFalse === void 0) {
1366
+ return;
1367
+ }
1368
+ lastCondition = cond;
1369
+ if (currentRoot) {
1370
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
1371
+ currentRoot = null;
1372
+ }
1373
+ removeNodes(currentNodes);
1374
+ currentNodes = [];
1375
+ const render2 = cond ? renderTrue : renderFalse;
1376
+ if (!render2) {
1377
+ return;
1378
+ }
1379
+ const root = _chunk6SOPF5LZcjs.createRootContext.call(void 0, hostRoot);
1380
+ const prev = _chunk6SOPF5LZcjs.pushRoot.call(void 0, root);
1381
+ let handledError = false;
1382
+ try {
1383
+ const output = _chunk6SOPF5LZcjs.untrack.call(void 0, render2);
1384
+ if (output == null || output === false) {
1385
+ return;
1386
+ }
1387
+ const el = createElementFn(output);
1388
+ const nodes = toNodeArray(el);
1389
+ insertNodesBefore(parent, nodes, endMarker);
1390
+ currentNodes = nodes;
1391
+ } catch (err) {
1392
+ if (_chunk6SOPF5LZcjs.handleSuspend.call(void 0, err, root)) {
1393
+ handledError = true;
1394
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
1395
+ return;
1396
+ }
1397
+ if (_chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "renderChild" }, root)) {
1398
+ handledError = true;
1399
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
1400
+ return;
1401
+ }
1402
+ throw err;
1403
+ } finally {
1404
+ _chunk6SOPF5LZcjs.popRoot.call(void 0, prev);
1405
+ if (!handledError) {
1406
+ _chunk6SOPF5LZcjs.flushOnMount.call(void 0, root);
1407
+ currentRoot = root;
1408
+ } else {
1409
+ currentRoot = null;
1410
+ }
1411
+ }
1412
+ };
1413
+ const dispose = _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, runConditional);
1414
+ return {
1415
+ marker: fragment,
1416
+ flush: () => {
1417
+ if (pendingRender) {
1418
+ runConditional();
1419
+ }
1420
+ },
1421
+ dispose: () => {
1422
+ dispose();
1423
+ if (currentRoot) {
1424
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
1425
+ }
1426
+ removeNodes(currentNodes);
1427
+ currentNodes = [];
1428
+ _optionalChain([startMarker, 'access', _13 => _13.parentNode, 'optionalAccess', _14 => _14.removeChild, 'call', _15 => _15(startMarker)]);
1429
+ _optionalChain([endMarker, 'access', _16 => _16.parentNode, 'optionalAccess', _17 => _17.removeChild, 'call', _18 => _18(endMarker)]);
1430
+ }
1431
+ };
1432
+ }
1433
+ function createShow(el, condition, displayValue) {
1434
+ const originalDisplay = _nullishCoalesce(displayValue, () => ( el.style.display));
1435
+ _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
1436
+ el.style.display = condition() ? originalDisplay : "none";
1437
+ });
1438
+ }
1439
+ function createPortal(container, render2, createElementFn) {
1440
+ const parentRoot = _chunk6SOPF5LZcjs.getCurrentRoot.call(void 0, );
1441
+ const marker = document.createComment("fict:portal");
1442
+ container.appendChild(marker);
1443
+ let currentNodes = [];
1444
+ let currentRoot = null;
1445
+ const dispose = _chunk6SOPF5LZcjs.createRenderEffect.call(void 0, () => {
1446
+ if (currentRoot) {
1447
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
1448
+ currentRoot = null;
1449
+ }
1450
+ if (currentNodes.length > 0) {
1451
+ removeNodes(currentNodes);
1452
+ currentNodes = [];
1453
+ }
1454
+ const root = _chunk6SOPF5LZcjs.createRootContext.call(void 0, parentRoot);
1455
+ const prev = _chunk6SOPF5LZcjs.pushRoot.call(void 0, root);
1456
+ let handledError = false;
1457
+ try {
1458
+ const output = render2();
1459
+ if (output != null && output !== false) {
1460
+ const el = createElementFn(output);
1461
+ const nodes = toNodeArray(el);
1462
+ if (marker.parentNode) {
1463
+ insertNodesBefore(marker.parentNode, nodes, marker);
1464
+ }
1465
+ currentNodes = nodes;
1466
+ }
1467
+ } catch (err) {
1468
+ if (_chunk6SOPF5LZcjs.handleSuspend.call(void 0, err, root)) {
1469
+ handledError = true;
1470
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
1471
+ currentNodes = [];
1472
+ return;
1473
+ }
1474
+ if (_chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "renderChild" }, root)) {
1475
+ handledError = true;
1476
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
1477
+ currentNodes = [];
1478
+ return;
1479
+ }
1480
+ throw err;
1481
+ } finally {
1482
+ _chunk6SOPF5LZcjs.popRoot.call(void 0, prev);
1483
+ if (!handledError) {
1484
+ _chunk6SOPF5LZcjs.flushOnMount.call(void 0, root);
1485
+ currentRoot = root;
1486
+ } else {
1487
+ currentRoot = null;
1488
+ }
1489
+ }
1490
+ });
1491
+ const portalDispose = () => {
1492
+ dispose();
1493
+ if (currentRoot) {
1494
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, currentRoot);
1495
+ }
1496
+ if (currentNodes.length > 0) {
1497
+ removeNodes(currentNodes);
1498
+ }
1499
+ _optionalChain([marker, 'access', _19 => _19.parentNode, 'optionalAccess', _20 => _20.removeChild, 'call', _21 => _21(marker)]);
1500
+ };
1501
+ if (parentRoot) {
1502
+ parentRoot.destroyCallbacks.push(portalDispose);
1503
+ }
1504
+ return {
1505
+ marker,
1506
+ dispose: portalDispose
1507
+ };
1508
+ }
1509
+
1510
+ // src/props.ts
1511
+ var PROP_GETTER_MARKER2 = Symbol.for("fict:prop-getter");
1512
+ var propGetters = /* @__PURE__ */ new WeakSet();
1513
+ var rawToProxy = /* @__PURE__ */ new WeakMap();
1514
+ var proxyToRaw = /* @__PURE__ */ new WeakMap();
1515
+ function __fictProp(getter) {
1516
+ if (typeof getter === "function" && getter.length === 0) {
1517
+ propGetters.add(getter);
1518
+ if (Object.isExtensible(getter)) {
1519
+ try {
1520
+ ;
1521
+ getter[PROP_GETTER_MARKER2] = true;
1522
+ } catch (e11) {
1523
+ }
1524
+ }
1525
+ }
1526
+ return getter;
1527
+ }
1528
+ function isPropGetter(value) {
1529
+ if (typeof value !== "function") return false;
1530
+ const fn = value;
1531
+ return propGetters.has(fn) || fn[PROP_GETTER_MARKER2] === true;
1532
+ }
1533
+ function createPropsProxy(props) {
1534
+ if (!props || typeof props !== "object") {
1535
+ return props;
1536
+ }
1537
+ if (proxyToRaw.has(props)) {
1538
+ return props;
1539
+ }
1540
+ const cached = rawToProxy.get(props);
1541
+ if (cached) {
1542
+ return cached;
1543
+ }
1544
+ const proxy = new Proxy(props, {
1545
+ get(target, prop2, receiver) {
1546
+ const value = Reflect.get(target, prop2, receiver);
1547
+ if (isPropGetter(value)) {
1548
+ return value();
1549
+ }
1550
+ return value;
1551
+ },
1552
+ set(target, prop2, value, receiver) {
1553
+ return Reflect.set(target, prop2, value, receiver);
1554
+ },
1555
+ has(target, prop2) {
1556
+ return prop2 in target;
1557
+ },
1558
+ ownKeys(target) {
1559
+ return Reflect.ownKeys(target);
1560
+ },
1561
+ getOwnPropertyDescriptor(target, prop2) {
1562
+ return Object.getOwnPropertyDescriptor(target, prop2);
1563
+ }
1564
+ });
1565
+ rawToProxy.set(props, proxy);
1566
+ proxyToRaw.set(proxy, props);
1567
+ return proxy;
1568
+ }
1569
+ function unwrapProps(props) {
1570
+ if (!props || typeof props !== "object") {
1571
+ return props;
1572
+ }
1573
+ return _nullishCoalesce(proxyToRaw.get(props), () => ( props));
1574
+ }
1575
+ function __fictPropsRest(props, exclude) {
1576
+ const raw = unwrapProps(props);
1577
+ const out = {};
1578
+ const excludeSet = new Set(exclude);
1579
+ for (const key of Reflect.ownKeys(raw)) {
1580
+ if (excludeSet.has(key)) continue;
1581
+ out[key] = raw[key];
1582
+ }
1583
+ return createPropsProxy(out);
1584
+ }
1585
+ function mergeProps(...sources) {
1586
+ const validSources = sources.filter(
1587
+ (s) => s != null && (typeof s === "object" || typeof s === "function")
1588
+ );
1589
+ if (validSources.length === 0) {
1590
+ return {};
1591
+ }
1592
+ if (validSources.length === 1 && typeof validSources[0] === "object") {
1593
+ return validSources[0];
1594
+ }
1595
+ const resolveSource = (src) => {
1596
+ const value = typeof src === "function" ? src() : src;
1597
+ if (!value || typeof value !== "object") return void 0;
1598
+ return unwrapProps(value);
1599
+ };
1600
+ const hasProp = (prop2) => {
1601
+ for (const src of validSources) {
1602
+ const raw = resolveSource(src);
1603
+ if (raw && prop2 in raw) {
1604
+ return true;
1605
+ }
1606
+ }
1607
+ return false;
1608
+ };
1609
+ const readProp = (prop2) => {
1610
+ for (let i = validSources.length - 1; i >= 0; i--) {
1611
+ const src = validSources[i];
1612
+ const raw = resolveSource(src);
1613
+ if (!raw || !(prop2 in raw)) continue;
1614
+ const value = raw[prop2];
1615
+ if (typeof src === "function" && !isPropGetter(value)) {
1616
+ return __fictProp(() => {
1617
+ const latest = resolveSource(src);
1618
+ if (!latest || !(prop2 in latest)) return void 0;
1619
+ return latest[prop2];
1620
+ });
1621
+ }
1622
+ return value;
1623
+ }
1624
+ return void 0;
1625
+ };
1626
+ return new Proxy({}, {
1627
+ get(_, prop2) {
1628
+ return readProp(prop2);
1629
+ },
1630
+ has(_, prop2) {
1631
+ return hasProp(prop2);
1632
+ },
1633
+ ownKeys() {
1634
+ const keys = /* @__PURE__ */ new Set();
1635
+ for (const src of validSources) {
1636
+ const raw = resolveSource(src);
1637
+ if (raw) {
1638
+ for (const key of Reflect.ownKeys(raw)) {
1639
+ keys.add(key);
1640
+ }
1641
+ }
1642
+ }
1643
+ return Array.from(keys);
1644
+ },
1645
+ getOwnPropertyDescriptor(_, prop2) {
1646
+ if (!hasProp(prop2)) return void 0;
1647
+ return {
1648
+ enumerable: true,
1649
+ configurable: true,
1650
+ get: () => readProp(prop2)
1651
+ };
1652
+ }
1653
+ });
1654
+ }
1655
+ function keyed(target, key, options) {
1656
+ return prop(() => {
1657
+ const resolvedTarget = isPropGetter(target) ? target() : target;
1658
+ const resolvedKey = typeof key === "function" ? key() : key;
1659
+ return resolvedTarget[resolvedKey];
1660
+ }, options);
1661
+ }
1662
+ function prop(getter, options) {
1663
+ if (isPropGetter(getter)) {
1664
+ return getter;
1665
+ }
1666
+ const fn = getter;
1667
+ const unwrap2 = _optionalChain([options, 'optionalAccess', _22 => _22.unwrap]) !== false;
1668
+ return __fictProp(
1669
+ _chunk6SOPF5LZcjs.createMemo.call(void 0, () => {
1670
+ const value = fn();
1671
+ if (unwrap2 && isPropGetter(value)) {
1672
+ return value();
1673
+ }
1674
+ return value;
1675
+ })
1676
+ );
1677
+ }
1678
+
1679
+ // src/dom.ts
1680
+ var SVG_NS = "http://www.w3.org/2000/svg";
1681
+ var MATHML_NS = "http://www.w3.org/1998/Math/MathML";
1682
+ var isDev2 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _23 => _23.env, 'optionalAccess', _24 => _24.NODE_ENV]) !== "production";
1683
+ var nextComponentId = 1;
1684
+ function render(view, container) {
1685
+ const root = _chunk6SOPF5LZcjs.createRootContext.call(void 0, );
1686
+ const prev = _chunk6SOPF5LZcjs.pushRoot.call(void 0, root);
1687
+ let dom = void 0;
1688
+ try {
1689
+ const output = view();
1690
+ if (_chunk6SOPF5LZcjs.__fictIsHydrating.call(void 0, )) {
1691
+ withHydration(container, () => {
1692
+ dom = createElement(output);
1693
+ });
1694
+ } else {
1695
+ dom = createElement(output);
1696
+ }
1697
+ } finally {
1698
+ _chunk6SOPF5LZcjs.popRoot.call(void 0, prev);
1699
+ }
1700
+ if (!_chunk6SOPF5LZcjs.__fictIsHydrating.call(void 0, )) {
1701
+ container.replaceChildren(dom);
1702
+ }
1703
+ container.setAttribute("data-fict-fine-grained", "1");
1704
+ _chunk6SOPF5LZcjs.flushOnMount.call(void 0, root);
1705
+ const teardown = () => {
1706
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
1707
+ container.innerHTML = "";
1708
+ };
1709
+ return teardown;
1710
+ }
1711
+ function hydrateComponent(view, container) {
1712
+ const root = _chunk6SOPF5LZcjs.createRootContext.call(void 0, );
1713
+ const prev = _chunk6SOPF5LZcjs.pushRoot.call(void 0, root);
1714
+ _chunk6SOPF5LZcjs.__fictEnterHydration.call(void 0, );
1715
+ try {
1716
+ withHydration(container, () => {
1717
+ view();
1718
+ });
1719
+ } finally {
1720
+ _chunk6SOPF5LZcjs.__fictExitHydration.call(void 0, );
1721
+ _chunk6SOPF5LZcjs.popRoot.call(void 0, prev);
1722
+ }
1723
+ container.setAttribute("data-fict-fine-grained", "1");
1724
+ _chunk6SOPF5LZcjs.flushOnMount.call(void 0, root);
1725
+ const teardown = () => {
1726
+ _chunk6SOPF5LZcjs.destroyRoot.call(void 0, root);
1727
+ };
1728
+ return teardown;
1729
+ }
1730
+ function createElement(node) {
1731
+ return createElementWithContext(node, null);
1732
+ }
1733
+ function resolveNamespace(tagName, namespace) {
1734
+ if (tagName === "svg") return "svg";
1735
+ if (tagName === "math") return "mathml";
1736
+ if (namespace === "mathml") return "mathml";
1737
+ if (namespace === "svg") return "svg";
1738
+ if (isDev2 && _chunk6SOPF5LZcjs.SVGElements.has(tagName)) return "svg";
1739
+ return null;
1740
+ }
1741
+ function createElementWithContext(node, namespace) {
1742
+ if (node instanceof Node) {
1743
+ return node;
1744
+ }
1745
+ if (node === null || node === void 0 || node === false) {
1746
+ return document.createTextNode("");
1747
+ }
1748
+ if (isReactive(node)) {
1749
+ const resolved = node();
1750
+ if (resolved === node) {
1751
+ return document.createTextNode("");
1752
+ }
1753
+ return createElementWithContext(resolved, namespace);
1754
+ }
1755
+ if (typeof node === "object" && node !== null && !(node instanceof Node)) {
1756
+ if ("marker" in node) {
1757
+ const handle = node;
1758
+ if (typeof handle.dispose === "function") {
1759
+ _chunk6SOPF5LZcjs.registerRootCleanup.call(void 0, handle.dispose);
1760
+ }
1761
+ if (typeof handle.flush === "function") {
1762
+ const runFlush = () => handle.flush && handle.flush();
1763
+ if (typeof queueMicrotask === "function") {
1764
+ queueMicrotask(runFlush);
1765
+ } else {
1766
+ Promise.resolve().then(runFlush).catch(() => void 0);
1767
+ }
1768
+ }
1769
+ return createElement(handle.marker);
1770
+ }
1771
+ }
1772
+ if (Array.isArray(node)) {
1773
+ const frag = document.createDocumentFragment();
1774
+ for (const child of node) {
1775
+ appendChildNode(frag, child, namespace);
1776
+ }
1777
+ return frag;
1778
+ }
1779
+ if (typeof node === "string" || typeof node === "number") {
1780
+ return document.createTextNode(String(node));
1781
+ }
1782
+ if (typeof node === "boolean") {
1783
+ return document.createTextNode("");
1784
+ }
1785
+ const vnode = node;
1786
+ if (typeof vnode.type === "function") {
1787
+ const rawProps = unwrapProps(_nullishCoalesce(vnode.props, () => ( {})));
1788
+ const baseProps = vnode.key === void 0 ? rawProps : new Proxy(rawProps, {
1789
+ get(target, prop2, receiver) {
1790
+ if (prop2 === "key") return vnode.key;
1791
+ return Reflect.get(target, prop2, receiver);
1792
+ },
1793
+ has(target, prop2) {
1794
+ if (prop2 === "key") return true;
1795
+ return prop2 in target;
1796
+ },
1797
+ ownKeys(target) {
1798
+ const keys = new Set(Reflect.ownKeys(target));
1799
+ keys.add("key");
1800
+ return Array.from(keys);
1801
+ },
1802
+ getOwnPropertyDescriptor(target, prop2) {
1803
+ if (prop2 === "key") {
1804
+ return { enumerable: true, configurable: true, value: vnode.key };
1805
+ }
1806
+ return Object.getOwnPropertyDescriptor(target, prop2);
1807
+ }
1808
+ });
1809
+ const props = createPropsProxy(baseProps);
1810
+ const hook = isDev2 ? _chunk6SOPF5LZcjs.getDevtoolsHook.call(void 0, ) : void 0;
1811
+ const parentId = hook ? _chunk6SOPF5LZcjs.__fictGetCurrentComponentId.call(void 0, ) : void 0;
1812
+ const componentId = hook ? nextComponentId++ : void 0;
1813
+ if (_optionalChain([hook, 'optionalAccess', _25 => _25.registerComponent]) && componentId !== void 0) {
1814
+ hook.registerComponent(componentId, vnode.type.name || "Anonymous", parentId);
1815
+ }
1816
+ const ctx = _chunk6SOPF5LZcjs.__fictPushContext.call(void 0, );
1817
+ if (componentId !== void 0) {
1818
+ ctx.componentId = componentId;
1819
+ if (parentId !== void 0) {
1820
+ ctx.parentId = parentId;
1821
+ }
1822
+ }
1823
+ try {
1824
+ const rendered = vnode.type(props);
1825
+ if (hook && componentId !== void 0) {
1826
+ _chunk6SOPF5LZcjs.onMount.call(void 0, () => {
1827
+ _optionalChain([hook, 'access', _26 => _26.componentMount, 'optionalCall', _27 => _27(componentId)]);
1828
+ });
1829
+ _chunk6SOPF5LZcjs.onCleanup.call(void 0, () => _optionalChain([hook, 'access', _28 => _28.componentUnmount, 'optionalCall', _29 => _29(componentId)]));
1830
+ }
1831
+ if (_chunk6SOPF5LZcjs.__fictIsResumable.call(void 0, ) && !_chunk6SOPF5LZcjs.__fictIsHydrating.call(void 0, )) {
1832
+ const content = createElementWithContext(rendered, namespace);
1833
+ const host = namespace === "svg" ? document.createElementNS(SVG_NS, "fict-host") : namespace === "mathml" ? document.createElementNS(MATHML_NS, "fict-host") : document.createElement("fict-host");
1834
+ host.setAttribute("data-fict-host", "");
1835
+ if (namespace === null && host.style) {
1836
+ ;
1837
+ host.style.display = "contents";
1838
+ }
1839
+ const meta = vnode.type.__fictMeta;
1840
+ const typeKey = (_nullishCoalesce(_optionalChain([meta, 'optionalAccess', _30 => _30.id]), () => ( vnode.type.name))) || "Anonymous";
1841
+ _chunk6SOPF5LZcjs.__fictRegisterScope.call(void 0, ctx, host, typeKey, rawProps);
1842
+ if (_optionalChain([meta, 'optionalAccess', _31 => _31.resume])) {
1843
+ host.setAttribute("data-fict-h", meta.resume);
1844
+ }
1845
+ if (content instanceof DocumentFragment) {
1846
+ host.append(...Array.from(content.childNodes));
1847
+ } else {
1848
+ host.appendChild(content);
1849
+ }
1850
+ return host;
1851
+ }
1852
+ return createElementWithContext(rendered, namespace);
1853
+ } catch (err) {
1854
+ if (_chunk6SOPF5LZcjs.handleSuspend.call(void 0, err)) {
1855
+ return document.createComment("fict:suspend");
1856
+ }
1857
+ _chunk6SOPF5LZcjs.handleError.call(void 0, err, { source: "render", componentName: vnode.type.name });
1858
+ throw err;
1859
+ } finally {
1860
+ _chunk6SOPF5LZcjs.__fictPopContext.call(void 0, );
1861
+ }
1862
+ }
1863
+ if (vnode.type === Fragment) {
1864
+ const frag = document.createDocumentFragment();
1865
+ const children = _optionalChain([vnode, 'access', _32 => _32.props, 'optionalAccess', _33 => _33.children]);
1866
+ appendChildren(frag, children, namespace);
1867
+ return frag;
1868
+ }
1869
+ const tagName = typeof vnode.type === "string" ? vnode.type : "div";
1870
+ const resolvedNamespace = resolveNamespace(tagName, namespace);
1871
+ const el = resolvedNamespace === "svg" ? document.createElementNS(SVG_NS, tagName) : resolvedNamespace === "mathml" ? document.createElementNS(MATHML_NS, tagName) : document.createElement(tagName);
1872
+ applyProps(el, _nullishCoalesce(vnode.props, () => ( {})), resolvedNamespace === "svg");
1873
+ appendChildren(
1874
+ el,
1875
+ _optionalChain([vnode, 'access', _34 => _34.props, 'optionalAccess', _35 => _35.children]),
1876
+ tagName === "foreignObject" ? null : resolvedNamespace
1877
+ );
1878
+ return el;
1879
+ }
1880
+ function template(html, isImportNode, isSVG, isMathML) {
1881
+ let node = null;
1882
+ const create = () => {
1883
+ const t = document.createElement("template");
1884
+ if (isSVG) {
1885
+ t.innerHTML = `<svg>${html}</svg>`;
1886
+ const wrapper = t.content.firstChild;
1887
+ if (isDev2 && wrapper.childNodes.length !== 1) {
1888
+ console.warn(
1889
+ `[fict] template() received multi-root SVG content (${wrapper.childNodes.length} nodes). Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`
1890
+ );
1891
+ }
1892
+ if (wrapper.childNodes.length === 1) {
1893
+ return wrapper.firstChild;
1894
+ }
1895
+ const fragment = document.createDocumentFragment();
1896
+ fragment.append(...Array.from(wrapper.childNodes));
1897
+ return fragment;
1898
+ }
1899
+ if (isMathML) {
1900
+ t.innerHTML = `<math>${html}</math>`;
1901
+ const wrapper = t.content.firstChild;
1902
+ if (isDev2 && wrapper.childNodes.length !== 1) {
1903
+ console.warn(
1904
+ `[fict] template() received multi-root MathML content (${wrapper.childNodes.length} nodes). Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`
1905
+ );
1906
+ }
1907
+ if (wrapper.childNodes.length === 1) {
1908
+ return wrapper.firstChild;
1909
+ }
1910
+ const fragment = document.createDocumentFragment();
1911
+ fragment.append(...Array.from(wrapper.childNodes));
1912
+ return fragment;
1913
+ }
1914
+ t.innerHTML = html;
1915
+ const content = t.content;
1916
+ if (isDev2 && content.childNodes.length !== 1) {
1917
+ console.warn(
1918
+ `[fict] template() received multi-root content (${content.childNodes.length} nodes). Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`
1919
+ );
1920
+ }
1921
+ if (content.childNodes.length === 1) {
1922
+ return content.firstChild;
1923
+ }
1924
+ return content;
1925
+ };
1926
+ const fn = isImportNode ? () => untrack2(() => {
1927
+ const base = node || (node = create());
1928
+ return isHydratingActive() ? claimNodes(base, () => document.importNode(base, true)) : document.importNode(base, true);
1929
+ }) : () => {
1930
+ const base = node || (node = create());
1931
+ return isHydratingActive() ? claimNodes(base, () => base.cloneNode(true)) : base.cloneNode(true);
1932
+ };
1933
+ fn.cloneNode = fn;
1934
+ return fn;
1935
+ }
1936
+ function isBindingHandle(node) {
1937
+ return node !== null && typeof node === "object" && "marker" in node && "dispose" in node && typeof node.dispose === "function";
1938
+ }
1939
+ function appendChildNode(parent, child, namespace) {
1940
+ if (child === null || child === void 0 || child === false) {
1941
+ return;
1942
+ }
1943
+ if (isBindingHandle(child)) {
1944
+ appendChildNode(parent, child.marker, namespace);
1945
+ _optionalChain([child, 'access', _36 => _36.flush, 'optionalCall', _37 => _37()]);
1946
+ return;
1947
+ }
1948
+ if (typeof child === "function" && child.length === 0) {
1949
+ const childGetter = child;
1950
+ createChildBinding(parent, childGetter, (node) => createElementWithContext(node, namespace));
1951
+ return;
1952
+ }
1953
+ if (Array.isArray(child)) {
1954
+ for (const item of child) {
1955
+ appendChildNode(parent, item, namespace);
1956
+ }
1957
+ return;
1958
+ }
1959
+ let domNode;
1960
+ if (typeof child !== "object" || child === null) {
1961
+ domNode = document.createTextNode(String(_nullishCoalesce(child, () => ( ""))));
1962
+ } else {
1963
+ domNode = createElementWithContext(child, namespace);
1964
+ }
1965
+ if (domNode.nodeType === 11) {
1966
+ const children = Array.from(domNode.childNodes);
1967
+ for (const node of children) {
1968
+ appendChildNode(parent, node, namespace);
1969
+ }
1970
+ return;
1971
+ }
1972
+ if (domNode.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {
1973
+ parent.ownerDocument.adoptNode(domNode);
1974
+ }
1975
+ try {
1976
+ parent.appendChild(domNode);
1977
+ } catch (e) {
1978
+ if (parent.ownerDocument) {
1979
+ const clone = parent.ownerDocument.importNode(domNode, true);
1980
+ parent.appendChild(clone);
1981
+ return;
1982
+ }
1983
+ throw e;
1984
+ }
1985
+ }
1986
+ function appendChildren(parent, children, namespace) {
1987
+ if (children === void 0) return;
1988
+ if (Array.isArray(children)) {
1989
+ for (const child of children) {
1990
+ appendChildren(parent, child, namespace);
1991
+ }
1992
+ return;
1993
+ }
1994
+ appendChildNode(parent, children, namespace);
1995
+ }
1996
+ function applyRef(el, value) {
1997
+ if (typeof value === "function") {
1998
+ const refFn = value;
1999
+ refFn(el);
2000
+ const root = _chunk6SOPF5LZcjs.getCurrentRoot.call(void 0, );
2001
+ if (root) {
2002
+ _chunk6SOPF5LZcjs.registerRootCleanup.call(void 0, () => {
2003
+ refFn(null);
2004
+ });
2005
+ } else if (isDev2) {
2006
+ console.warn(
2007
+ "[fict] Ref applied outside of a root context. The ref cleanup (setting to null) will not run automatically. Consider using createRoot() or ensure the element is created within a component."
2008
+ );
2009
+ }
2010
+ } else if (value && typeof value === "object" && "current" in value) {
2011
+ const refObj = value;
2012
+ refObj.current = el;
2013
+ const root = _chunk6SOPF5LZcjs.getCurrentRoot.call(void 0, );
2014
+ if (root) {
2015
+ _chunk6SOPF5LZcjs.registerRootCleanup.call(void 0, () => {
2016
+ refObj.current = null;
2017
+ });
2018
+ } else if (isDev2) {
2019
+ console.warn(
2020
+ "[fict] Ref applied outside of a root context. The ref cleanup (setting to null) will not run automatically. Consider using createRoot() or ensure the element is created within a component."
2021
+ );
2022
+ }
2023
+ }
2024
+ }
2025
+ function applyProps(el, props, isSVG = false) {
2026
+ props = unwrapProps(props);
2027
+ const tagName = el.tagName;
2028
+ const isCE = tagName.includes("-") || "is" in props;
2029
+ for (const [key, value] of Object.entries(props)) {
2030
+ if (key === "children") continue;
2031
+ if (key === "ref") {
2032
+ applyRef(el, value);
2033
+ continue;
2034
+ }
2035
+ if (isEventKey(key)) {
2036
+ bindEvent(
2037
+ el,
2038
+ eventNameFromProp(key),
2039
+ value
2040
+ );
2041
+ continue;
2042
+ }
2043
+ if (key.slice(0, 3) === "on:") {
2044
+ bindEvent(
2045
+ el,
2046
+ key.slice(3),
2047
+ value,
2048
+ false
2049
+ // Non-delegated
2050
+ );
2051
+ continue;
2052
+ }
2053
+ if (key.slice(0, 10) === "oncapture:") {
2054
+ bindEvent(
2055
+ el,
2056
+ key.slice(10),
2057
+ value,
2058
+ true
2059
+ // Capture
2060
+ );
2061
+ continue;
2062
+ }
2063
+ if (key === "class" || key === "className") {
2064
+ createClassBinding(el, value);
2065
+ continue;
2066
+ }
2067
+ if (key === "classList") {
2068
+ createClassBinding(el, value);
2069
+ continue;
2070
+ }
2071
+ if (key === "style") {
2072
+ createStyleBinding(
2073
+ el,
2074
+ value
2075
+ );
2076
+ continue;
2077
+ }
2078
+ if (key === "dangerouslySetInnerHTML" && value && typeof value === "object") {
2079
+ const htmlValue = value.__html;
2080
+ if (htmlValue !== void 0) {
2081
+ if (isReactive(htmlValue)) {
2082
+ createAttributeBinding(el, "innerHTML", htmlValue, setInnerHTML);
2083
+ } else {
2084
+ el.innerHTML = htmlValue;
2085
+ }
2086
+ }
2087
+ continue;
2088
+ }
2089
+ if (isDev2 && _chunk6SOPF5LZcjs.ChildProperties.has(key) || key === "innerHTML" || key === "textContent" || key === "innerText" || key === "children") {
2090
+ createAttributeBinding(el, key, value, setProperty);
2091
+ continue;
2092
+ }
2093
+ if (key.slice(0, 5) === "attr:") {
2094
+ createAttributeBinding(el, key.slice(5), value, setAttribute);
2095
+ continue;
2096
+ }
2097
+ if (key.slice(0, 5) === "bool:") {
2098
+ createAttributeBinding(el, key.slice(5), value, setBoolAttribute);
2099
+ continue;
2100
+ }
2101
+ if (key.slice(0, 5) === "prop:") {
2102
+ createAttributeBinding(el, key.slice(5), value, setProperty);
2103
+ continue;
2104
+ }
2105
+ const propAlias = !isSVG && isDev2 ? _chunk6SOPF5LZcjs.getPropAlias.call(void 0, key, tagName) : void 0;
2106
+ const isProperty = !isSVG ? isDev2 ? _chunk6SOPF5LZcjs.Properties.has(key) : key in el : false;
2107
+ if (propAlias || isProperty || isCE && !isSVG) {
2108
+ const propName = propAlias || key;
2109
+ if (isCE && !isProperty && !propAlias) {
2110
+ createAttributeBinding(
2111
+ el,
2112
+ toPropertyName2(propName),
2113
+ value,
2114
+ setProperty
2115
+ );
2116
+ } else {
2117
+ createAttributeBinding(el, propName, value, setProperty);
2118
+ }
2119
+ continue;
2120
+ }
2121
+ if (isSVG && key.indexOf(":") > -1) {
2122
+ const [prefix, name] = key.split(":");
2123
+ const ns = _chunk6SOPF5LZcjs.SVGNamespace[prefix];
2124
+ if (ns) {
2125
+ createAttributeBinding(
2126
+ el,
2127
+ key,
2128
+ value,
2129
+ (el2, _key, val) => setAttributeNS(el2, ns, name, val)
2130
+ );
2131
+ continue;
2132
+ }
2133
+ }
2134
+ const attrName = key === "htmlFor" ? "for" : key;
2135
+ createAttributeBinding(el, attrName, value, setAttribute);
2136
+ }
2137
+ }
2138
+ function toPropertyName2(name) {
2139
+ return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
2140
+ }
2141
+ var setAttribute = (el, key, value) => {
2142
+ if (value === void 0 || value === null || value === false) {
2143
+ el.removeAttribute(key);
2144
+ return;
2145
+ }
2146
+ if (value === true) {
2147
+ el.setAttribute(key, "");
2148
+ return;
2149
+ }
2150
+ const valueType = typeof value;
2151
+ if (valueType === "string" || valueType === "number") {
2152
+ el.setAttribute(key, String(value));
2153
+ return;
2154
+ }
2155
+ if (key in el) {
2156
+ ;
2157
+ el[key] = value;
2158
+ return;
2159
+ }
2160
+ el.setAttribute(key, String(value));
2161
+ };
2162
+ var setProperty = (el, key, value) => {
2163
+ if (value === void 0 || value === null) {
2164
+ const fallback = key === "checked" || key === "selected" ? false : "";
2165
+ el[key] = fallback;
2166
+ return;
2167
+ }
2168
+ if (key === "style" && typeof value === "object" && value !== null) {
2169
+ for (const k in value) {
2170
+ const v = value[k];
2171
+ if (v !== void 0) {
2172
+ ;
2173
+ el.style[k] = String(v);
2174
+ }
2175
+ }
2176
+ return;
2177
+ }
2178
+ ;
2179
+ el[key] = value;
2180
+ };
2181
+ var setInnerHTML = (el, _key, value) => {
2182
+ const next = value == null ? "" : String(value);
2183
+ const node = el;
2184
+ if (node.innerHTML === next) return;
2185
+ node.innerHTML = next;
2186
+ };
2187
+ var setBoolAttribute = (el, key, value) => {
2188
+ if (value) {
2189
+ el.setAttribute(key, "");
2190
+ } else {
2191
+ el.removeAttribute(key);
2192
+ }
2193
+ };
2194
+ function setAttributeNS(el, namespace, name, value) {
2195
+ if (value == null) {
2196
+ el.removeAttributeNS(namespace, name);
2197
+ } else {
2198
+ el.setAttributeNS(namespace, name, String(value));
2199
+ }
2200
+ }
2201
+ function isEventKey(key) {
2202
+ return key.startsWith("on") && key.length > 2 && key[2].toUpperCase() === key[2];
2203
+ }
2204
+ function eventNameFromProp(key) {
2205
+ return key.slice(2).toLowerCase();
2206
+ }
2207
+
2208
+
2209
+
2210
+
2211
+
2212
+
2213
+
2214
+
2215
+
2216
+
2217
+
2218
+
2219
+
2220
+
2221
+
2222
+
2223
+
2224
+
2225
+
2226
+
2227
+
2228
+
2229
+
2230
+
2231
+
2232
+
2233
+
2234
+
2235
+
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+
2242
+
2243
+
2244
+
2245
+
2246
+
2247
+
2248
+
2249
+
2250
+
2251
+
2252
+
2253
+
2254
+
2255
+
2256
+
2257
+
2258
+ exports.withHydrationRange = withHydrationRange; exports.isHydratingActive = isHydratingActive; exports.Fragment = Fragment; exports.toNodeArray = toNodeArray; exports.insertNodesBefore = insertNodesBefore; exports.removeNodes = removeNodes; exports.getSlotEnd = getSlotEnd; exports.resolvePath = resolvePath; exports.startTransition = startTransition; exports.useTransition = useTransition; exports.useDeferredValue = useDeferredValue; exports.batch = batch2; exports.untrack = untrack2; exports.isReactive = isReactive; exports.unwrap = unwrap; exports.callEventHandler = callEventHandler; exports.createTextBinding = createTextBinding; exports.bindText = bindText; exports.createAttributeBinding = createAttributeBinding; exports.bindAttribute = bindAttribute; exports.bindProperty = bindProperty; exports.createStyleBinding = createStyleBinding; exports.bindStyle = bindStyle; exports.createClassBinding = createClassBinding; exports.bindClass = bindClass; exports.classList = classList; exports.insert = insert; exports.insertBetween = insertBetween; exports.createChildBinding = createChildBinding; exports.delegateEvents = delegateEvents; exports.clearDelegatedEvents = clearDelegatedEvents; exports.addEventListener = addEventListener; exports.bindEvent = bindEvent; exports.bindRef = bindRef; exports.spread = spread; exports.assign = assign; exports.createConditional = createConditional; exports.createShow = createShow; exports.createPortal = createPortal; exports.__fictProp = __fictProp; exports.createPropsProxy = createPropsProxy; exports.__fictPropsRest = __fictPropsRest; exports.mergeProps = mergeProps; exports.keyed = keyed; exports.prop = prop; exports.render = render; exports.hydrateComponent = hydrateComponent; exports.createElement = createElement; exports.template = template;
2259
+ //# sourceMappingURL=chunk-TKWN42TA.cjs.map