@zeus-js/runtime-dom 0.1.0-beta.8 → 0.1.0-beta.9

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.
@@ -1,9 +1,8 @@
1
1
  /**
2
- * runtime-dom v0.1.0-beta.8
2
+ * runtime-dom v0.1.0-beta.9
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
6
- import { effect, effectScope, getCurrentScope, onScopeDispose, scope, state, stop } from "@zeus-js/signal";
7
6
  //#region packages/core/runtime-dom/src/template.ts
8
7
  function template(html, _isImportNode = false, _isSVG = false, _isMathML = false) {
9
8
  const t = document.createElement("template");
@@ -13,6 +12,1418 @@ function template(html, _isImportNode = false, _isSVG = false, _isMathML = false
13
12
  };
14
13
  }
15
14
  //#endregion
15
+ //#region packages/core/shared/src/makeMap.ts
16
+ /**
17
+ * Make a map and return a function for checking if a key
18
+ * is in that map.
19
+ * IMPORTANT: all calls of this function must be prefixed with
20
+ * \/\*#\_\_PURE\_\_\*\/
21
+ * So that rollup can tree-shake them if necessary.
22
+ */
23
+ /*@__NO_SIDE_EFFECTS__*/
24
+ function makeMap(str) {
25
+ const map = Object.create(null);
26
+ for (const key of str.split(",")) map[key] = 1;
27
+ return (val) => val in map;
28
+ }
29
+ Object.freeze({});
30
+ Object.freeze([]);
31
+ const extend = Object.assign;
32
+ const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
33
+ const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
34
+ const isArray = Array.isArray;
35
+ const isMap = (val) => toTypeString(val) === "[object Map]";
36
+ const isString = (val) => typeof val === "string";
37
+ const isSymbol = (val) => typeof val === "symbol";
38
+ const isObject = (val) => val !== null && typeof val === "object";
39
+ const objectToString = Object.prototype.toString;
40
+ const toTypeString = (value) => objectToString.call(value);
41
+ const toRawType = (value) => {
42
+ return toTypeString(value).slice(8, -1);
43
+ };
44
+ const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
45
+ const cacheStringFunction = (fn) => {
46
+ const cache = Object.create(null);
47
+ return ((str) => {
48
+ return cache[str] || (cache[str] = fn(str));
49
+ });
50
+ };
51
+ /**
52
+ * @private
53
+ */
54
+ const capitalize = cacheStringFunction((str) => {
55
+ return str.charAt(0).toUpperCase() + str.slice(1);
56
+ });
57
+ const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
58
+ //#endregion
59
+ //#region packages/core/signal/src/warning.ts
60
+ function warn(msg, ...args) {
61
+ console.warn(`[Zeus warn] ${msg}`, ...args);
62
+ }
63
+ //#endregion
64
+ //#region packages/core/signal/src/effectScope.ts
65
+ let activeEffectScope;
66
+ var EffectScope = class {
67
+ constructor(detached = false) {
68
+ this.detached = detached;
69
+ this._active = true;
70
+ this._on = 0;
71
+ this.effects = [];
72
+ this.cleanups = [];
73
+ this._isPaused = false;
74
+ this._warnOnRun = true;
75
+ this.__v_skip = true;
76
+ if (!detached && activeEffectScope) if (activeEffectScope.active) {
77
+ this.parent = activeEffectScope;
78
+ this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
79
+ } else {
80
+ this._active = false;
81
+ this._warnOnRun = false;
82
+ }
83
+ }
84
+ get active() {
85
+ return this._active;
86
+ }
87
+ pause() {
88
+ if (this._active) {
89
+ this._isPaused = true;
90
+ let i, l;
91
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].pause();
92
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].pause();
93
+ }
94
+ }
95
+ /**
96
+ * Resumes the effect scope, including all child scopes and effects.
97
+ */
98
+ resume() {
99
+ if (this._active) {
100
+ if (this._isPaused) {
101
+ this._isPaused = false;
102
+ let i, l;
103
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].resume();
104
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].resume();
105
+ }
106
+ }
107
+ }
108
+ run(fn) {
109
+ if (this._active) {
110
+ const currentEffectScope = activeEffectScope;
111
+ try {
112
+ activeEffectScope = this;
113
+ return fn();
114
+ } finally {
115
+ activeEffectScope = currentEffectScope;
116
+ }
117
+ } else if (this._warnOnRun) warn(`cannot run an inactive effect scope.`);
118
+ }
119
+ /**
120
+ * This should only be called on non-detached scopes
121
+ * @internal
122
+ */
123
+ on() {
124
+ if (++this._on === 1) {
125
+ this.prevScope = activeEffectScope;
126
+ activeEffectScope = this;
127
+ }
128
+ }
129
+ /**
130
+ * This should only be called on non-detached scopes
131
+ * @internal
132
+ */
133
+ off() {
134
+ if (this._on > 0 && --this._on === 0) {
135
+ if (activeEffectScope === this) activeEffectScope = this.prevScope;
136
+ else {
137
+ let current = activeEffectScope;
138
+ while (current) {
139
+ if (current.prevScope === this) {
140
+ current.prevScope = this.prevScope;
141
+ break;
142
+ }
143
+ current = current.prevScope;
144
+ }
145
+ }
146
+ this.prevScope = void 0;
147
+ }
148
+ }
149
+ stop(fromParent) {
150
+ if (this._active) {
151
+ this._active = false;
152
+ let i, l;
153
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop();
154
+ this.effects.length = 0;
155
+ for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i]();
156
+ this.cleanups.length = 0;
157
+ if (this.scopes) {
158
+ for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true);
159
+ this.scopes.length = 0;
160
+ }
161
+ if (!this.detached && this.parent && !fromParent) {
162
+ const last = this.parent.scopes.pop();
163
+ if (last && last !== this) {
164
+ this.parent.scopes[this.index] = last;
165
+ last.index = this.index;
166
+ }
167
+ }
168
+ this.parent = void 0;
169
+ }
170
+ }
171
+ };
172
+ /**
173
+ * Creates an effect scope object which can capture the reactive effects (i.e.
174
+ * computed and watchers) created within it so that these effects can be
175
+ * disposed together. For detailed use cases of this API, please consult its
176
+ * corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
177
+ *
178
+ * @param detached - Can be used to create a "detached" effect scope.
179
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
180
+ */
181
+ function effectScope(detached) {
182
+ return new EffectScope(detached);
183
+ }
184
+ /**
185
+ * Returns the current active effect scope if there is one.
186
+ *
187
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
188
+ */
189
+ function getCurrentScope() {
190
+ return activeEffectScope;
191
+ }
192
+ /**
193
+ * Registers a dispose callback on the current active effect scope. The
194
+ * callback will be invoked when the associated effect scope is stopped.
195
+ *
196
+ * @param fn - The callback function to attach to the scope's cleanup.
197
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
198
+ */
199
+ function onScopeDispose(fn, failSilently = false) {
200
+ if (activeEffectScope) activeEffectScope.cleanups.push(fn);
201
+ else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
202
+ }
203
+ //#endregion
204
+ //#region packages/core/signal/src/effect.ts
205
+ let activeSub;
206
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
207
+ var ReactiveEffect = class {
208
+ constructor(fn) {
209
+ this.fn = fn;
210
+ this.deps = void 0;
211
+ this.depsTail = void 0;
212
+ this.flags = 5;
213
+ this.next = void 0;
214
+ this.cleanups = void 0;
215
+ this.scheduler = void 0;
216
+ this.scope = activeEffectScope;
217
+ if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
218
+ else this.flags &= -2;
219
+ }
220
+ pause() {
221
+ this.flags |= 64;
222
+ }
223
+ resume() {
224
+ if (this.flags & 64) {
225
+ this.flags &= -65;
226
+ if (pausedQueueEffects.has(this)) {
227
+ pausedQueueEffects.delete(this);
228
+ this.trigger();
229
+ }
230
+ }
231
+ }
232
+ /**
233
+ * @internal
234
+ */
235
+ notify() {
236
+ if (this.flags & 2 && !(this.flags & 32)) return;
237
+ if (!(this.flags & 8)) queueSubscriber(this);
238
+ }
239
+ run() {
240
+ if (!(this.flags & 1)) return this.fn();
241
+ this.flags |= 2;
242
+ cleanupEffect(this);
243
+ prepareDeps(this);
244
+ const prevEffect = activeSub;
245
+ const prevShouldTrack = shouldTrack;
246
+ activeSub = this;
247
+ shouldTrack = true;
248
+ try {
249
+ return this.fn();
250
+ } finally {
251
+ if (activeSub !== this) warn("Active effect was not restored correctly - this is likely a Vue internal bug.");
252
+ cleanupDeps(this);
253
+ activeSub = prevEffect;
254
+ shouldTrack = prevShouldTrack;
255
+ this.flags &= -3;
256
+ }
257
+ }
258
+ stop() {
259
+ if (this.flags & 1) {
260
+ for (let link = this.deps; link; link = link.nextDep) removeSub(link);
261
+ this.deps = this.depsTail = void 0;
262
+ cleanupEffect(this);
263
+ this.onStop && this.onStop();
264
+ this.flags &= -2;
265
+ }
266
+ }
267
+ trigger() {
268
+ if (this.flags & 64) pausedQueueEffects.add(this);
269
+ else if (this.scheduler) this.scheduler();
270
+ else this.runIfDirty();
271
+ }
272
+ /**
273
+ * @internal
274
+ */
275
+ runIfDirty() {
276
+ if (isDirty(this)) this.run();
277
+ }
278
+ get dirty() {
279
+ return isDirty(this);
280
+ }
281
+ };
282
+ /**
283
+ * For debugging
284
+ */
285
+ let batchDepth = 0;
286
+ let batchedSub;
287
+ let batchedComputed;
288
+ /**
289
+ * @internal
290
+ */
291
+ function queueSubscriber(sub, isComputed = false) {
292
+ sub.flags |= 8;
293
+ if (isComputed) {
294
+ sub.next = batchedComputed;
295
+ batchedComputed = sub;
296
+ return;
297
+ }
298
+ sub.next = batchedSub;
299
+ batchedSub = sub;
300
+ }
301
+ /**
302
+ * @internal
303
+ */
304
+ function startBatch() {
305
+ batchDepth++;
306
+ }
307
+ /**
308
+ * Run batched effects when all batches have ended
309
+ * @internal
310
+ */
311
+ function endBatch() {
312
+ if (--batchDepth > 0) return;
313
+ if (batchedComputed) {
314
+ let e = batchedComputed;
315
+ batchedComputed = void 0;
316
+ while (e) {
317
+ const next = e.next;
318
+ e.next = void 0;
319
+ e.flags &= -9;
320
+ e = next;
321
+ }
322
+ }
323
+ let error;
324
+ while (batchedSub) {
325
+ let e = batchedSub;
326
+ batchedSub = void 0;
327
+ while (e) {
328
+ const next = e.next;
329
+ e.next = void 0;
330
+ e.flags &= -9;
331
+ if (e.flags & 1) try {
332
+ e.trigger();
333
+ } catch (err) {
334
+ if (!error) error = err;
335
+ }
336
+ e = next;
337
+ }
338
+ }
339
+ if (error) throw error;
340
+ }
341
+ function prepareDeps(sub) {
342
+ for (let link = sub.deps; link; link = link.nextDep) {
343
+ link.version = -1;
344
+ link.prevActiveLink = link.dep.activeLink;
345
+ link.dep.activeLink = link;
346
+ }
347
+ }
348
+ function cleanupDeps(sub) {
349
+ let head;
350
+ let tail = sub.depsTail;
351
+ let link = tail;
352
+ while (link) {
353
+ const prev = link.prevDep;
354
+ if (link.version === -1) {
355
+ if (link === tail) tail = prev;
356
+ removeSub(link);
357
+ removeDep(link);
358
+ } else head = link;
359
+ link.dep.activeLink = link.prevActiveLink;
360
+ link.prevActiveLink = void 0;
361
+ link = prev;
362
+ }
363
+ sub.deps = head;
364
+ sub.depsTail = tail;
365
+ }
366
+ function isDirty(sub) {
367
+ for (let link = sub.deps; link; link = link.nextDep) if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) return true;
368
+ return false;
369
+ }
370
+ /**
371
+ * Returning false indicates the refresh failed
372
+ * @internal
373
+ */
374
+ function refreshComputed(computed) {
375
+ if (computed.flags & 4 && !(computed.flags & 16)) return;
376
+ computed.flags &= -17;
377
+ if (computed.globalVersion === globalVersion) return;
378
+ computed.globalVersion = globalVersion;
379
+ if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) return;
380
+ computed.flags |= 2;
381
+ const dep = computed.dep;
382
+ const prevSub = activeSub;
383
+ const prevShouldTrack = shouldTrack;
384
+ activeSub = computed;
385
+ shouldTrack = true;
386
+ try {
387
+ prepareDeps(computed);
388
+ const value = computed.fn(computed._value);
389
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
390
+ computed.flags |= 128;
391
+ computed._value = value;
392
+ dep.version++;
393
+ }
394
+ } catch (err) {
395
+ dep.version++;
396
+ throw err;
397
+ } finally {
398
+ activeSub = prevSub;
399
+ shouldTrack = prevShouldTrack;
400
+ cleanupDeps(computed);
401
+ computed.flags &= -3;
402
+ }
403
+ }
404
+ function removeSub(link, soft = false) {
405
+ const { dep, prevSub, nextSub } = link;
406
+ if (prevSub) {
407
+ prevSub.nextSub = nextSub;
408
+ link.prevSub = void 0;
409
+ }
410
+ if (nextSub) {
411
+ nextSub.prevSub = prevSub;
412
+ link.nextSub = void 0;
413
+ }
414
+ if (dep.subsHead === link) dep.subsHead = nextSub;
415
+ if (dep.subs === link) {
416
+ dep.subs = prevSub;
417
+ if (!prevSub && dep.computed) {
418
+ dep.computed.flags &= -5;
419
+ for (let l = dep.computed.deps; l; l = l.nextDep) removeSub(l, true);
420
+ }
421
+ }
422
+ if (!soft && !--dep.sc && dep.map) dep.map.delete(dep.key);
423
+ }
424
+ function removeDep(link) {
425
+ const { prevDep, nextDep } = link;
426
+ if (prevDep) {
427
+ prevDep.nextDep = nextDep;
428
+ link.prevDep = void 0;
429
+ }
430
+ if (nextDep) {
431
+ nextDep.prevDep = prevDep;
432
+ link.nextDep = void 0;
433
+ }
434
+ }
435
+ function effect(fn, options) {
436
+ if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
437
+ const e = new ReactiveEffect(fn);
438
+ if (options) extend(e, options);
439
+ try {
440
+ e.run();
441
+ } catch (err) {
442
+ e.stop();
443
+ throw err;
444
+ }
445
+ const runner = e.run.bind(e);
446
+ runner.effect = e;
447
+ return runner;
448
+ }
449
+ /**
450
+ * Stops the effect associated with the given runner.
451
+ *
452
+ * @param runner - Association with the effect to stop tracking.
453
+ */
454
+ function stop(runner) {
455
+ runner.effect.stop();
456
+ }
457
+ /**
458
+ * @internal
459
+ */
460
+ let shouldTrack = true;
461
+ const trackStack = [];
462
+ /**
463
+ * Temporarily pauses tracking.
464
+ */
465
+ function pauseTracking() {
466
+ trackStack.push(shouldTrack);
467
+ shouldTrack = false;
468
+ }
469
+ /**
470
+ * Resets the previous global effect tracking state.
471
+ */
472
+ function resetTracking() {
473
+ const last = trackStack.pop();
474
+ shouldTrack = last === void 0 ? true : last;
475
+ }
476
+ function cleanupEffect(e) {
477
+ const cleanups = e.cleanups;
478
+ e.cleanups = void 0;
479
+ if (cleanups) {
480
+ const prevSub = activeSub;
481
+ activeSub = void 0;
482
+ try {
483
+ let error;
484
+ for (const cleanup of cleanups) try {
485
+ cleanup();
486
+ } catch (cleanupError) {
487
+ var _error;
488
+ (_error = error) !== null && _error !== void 0 || (error = cleanupError);
489
+ }
490
+ if (error) throw error;
491
+ } finally {
492
+ activeSub = prevSub;
493
+ }
494
+ }
495
+ }
496
+ //#endregion
497
+ //#region packages/core/signal/src/dep.ts
498
+ /**
499
+ * Incremented every time a reactive change happens
500
+ * This is used to give computed a fast path to avoid re-compute when nothing
501
+ * has changed.
502
+ */
503
+ let globalVersion = 0;
504
+ /**
505
+ * Represents a link between a source (Dep) and a subscriber (Effect or Computed).
506
+ * Deps and subs have a many-to-many relationship - each link between a
507
+ * dep and a sub is represented by a Link instance.
508
+ *
509
+ * A Link is also a node in two doubly-linked lists - one for the associated
510
+ * sub to track all its deps, and one for the associated dep to track all its
511
+ * subs.
512
+ *
513
+ * @internal
514
+ */
515
+ var Link = class {
516
+ constructor(sub, dep) {
517
+ this.sub = sub;
518
+ this.dep = dep;
519
+ this.version = dep.version;
520
+ this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
521
+ }
522
+ };
523
+ /**
524
+ * @internal
525
+ */
526
+ var Dep = class {
527
+ constructor(computed) {
528
+ this.computed = computed;
529
+ this.version = 0;
530
+ this.activeLink = void 0;
531
+ this.subs = void 0;
532
+ this.map = void 0;
533
+ this.key = void 0;
534
+ this.sc = 0;
535
+ this.__v_skip = true;
536
+ this.subsHead = void 0;
537
+ }
538
+ track(debugInfo) {
539
+ if (!activeSub || !shouldTrack || activeSub === this.computed) return;
540
+ let link = this.activeLink;
541
+ if (link === void 0 || link.sub !== activeSub) {
542
+ link = this.activeLink = new Link(activeSub, this);
543
+ if (!activeSub.deps) activeSub.deps = activeSub.depsTail = link;
544
+ else {
545
+ link.prevDep = activeSub.depsTail;
546
+ activeSub.depsTail.nextDep = link;
547
+ activeSub.depsTail = link;
548
+ }
549
+ addSub(link);
550
+ } else if (link.version === -1) {
551
+ link.version = this.version;
552
+ if (link.nextDep) {
553
+ const next = link.nextDep;
554
+ next.prevDep = link.prevDep;
555
+ if (link.prevDep) link.prevDep.nextDep = next;
556
+ link.prevDep = activeSub.depsTail;
557
+ link.nextDep = void 0;
558
+ activeSub.depsTail.nextDep = link;
559
+ activeSub.depsTail = link;
560
+ if (activeSub.deps === link) activeSub.deps = next;
561
+ }
562
+ }
563
+ if (activeSub.onTrack) activeSub.onTrack(extend({ effect: activeSub }, debugInfo));
564
+ return link;
565
+ }
566
+ trigger(debugInfo) {
567
+ this.version++;
568
+ globalVersion++;
569
+ this.notify(debugInfo);
570
+ }
571
+ notify(debugInfo) {
572
+ startBatch();
573
+ try {
574
+ for (let head = this.subsHead; head; head = head.nextSub) if (head.sub.onTrigger && !(head.sub.flags & 8)) head.sub.onTrigger(extend({ effect: head.sub }, debugInfo));
575
+ for (let link = this.subs; link; link = link.prevSub) if (link.sub.notify()) link.sub.dep.notify();
576
+ } finally {
577
+ endBatch();
578
+ }
579
+ }
580
+ };
581
+ function addSub(link) {
582
+ link.dep.sc++;
583
+ if (link.sub.flags & 4) {
584
+ const computed = link.dep.computed;
585
+ if (computed && !link.dep.subs) {
586
+ computed.flags |= 20;
587
+ for (let l = computed.deps; l; l = l.nextDep) addSub(l);
588
+ }
589
+ const currentTail = link.dep.subs;
590
+ if (currentTail !== link) {
591
+ link.prevSub = currentTail;
592
+ if (currentTail) currentTail.nextSub = link;
593
+ }
594
+ if (link.dep.subsHead === void 0) link.dep.subsHead = link;
595
+ link.dep.subs = link;
596
+ }
597
+ }
598
+ const targetMap = /* @__PURE__ */ new WeakMap();
599
+ const ITERATE_KEY = Symbol("Object iterate");
600
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
601
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate");
602
+ /**
603
+ * Tracks access to a reactive property.
604
+ *
605
+ * This will check which effect is running at the moment and record it as dep
606
+ * which records all effects that depend on the reactive property.
607
+ *
608
+ * @param target - Object holding the reactive property.
609
+ * @param type - Defines the type of access to the reactive property.
610
+ * @param key - Identifier of the reactive property to track.
611
+ */
612
+ function track(target, type, key) {
613
+ if (shouldTrack && activeSub) {
614
+ let depsMap = targetMap.get(target);
615
+ if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
616
+ let dep = depsMap.get(key);
617
+ if (!dep) {
618
+ depsMap.set(key, dep = new Dep());
619
+ dep.map = depsMap;
620
+ dep.key = key;
621
+ }
622
+ dep.track({
623
+ target,
624
+ type,
625
+ key
626
+ });
627
+ }
628
+ }
629
+ /**
630
+ * Finds all deps associated with the target (or a specific property) and
631
+ * triggers the effects stored within.
632
+ *
633
+ * @param target - The reactive object.
634
+ * @param type - Defines the type of the operation that needs to trigger effects.
635
+ * @param key - Can be used to target a specific reactive property in the target object.
636
+ */
637
+ function trigger(target, type, key, newValue, oldValue, oldTarget) {
638
+ const depsMap = targetMap.get(target);
639
+ if (!depsMap) {
640
+ globalVersion++;
641
+ return;
642
+ }
643
+ const run = (dep) => {
644
+ if (dep) dep.trigger({
645
+ target,
646
+ type,
647
+ key,
648
+ newValue,
649
+ oldValue,
650
+ oldTarget
651
+ });
652
+ };
653
+ startBatch();
654
+ if (type === "clear") depsMap.forEach(run);
655
+ else {
656
+ const targetIsArray = isArray(target);
657
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
658
+ if (targetIsArray && key === "length") {
659
+ const newLength = Number(newValue);
660
+ depsMap.forEach((dep, key) => {
661
+ if (key === "length" || key === ARRAY_ITERATE_KEY || !isSymbol(key) && key >= newLength) run(dep);
662
+ });
663
+ } else {
664
+ if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key));
665
+ if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY));
666
+ switch (type) {
667
+ case "add":
668
+ if (!targetIsArray) {
669
+ run(depsMap.get(ITERATE_KEY));
670
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
671
+ } else if (isArrayIndex) run(depsMap.get("length"));
672
+ break;
673
+ case "delete":
674
+ if (!targetIsArray) {
675
+ run(depsMap.get(ITERATE_KEY));
676
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
677
+ }
678
+ break;
679
+ case "set":
680
+ if (isMap(target)) run(depsMap.get(ITERATE_KEY));
681
+ break;
682
+ }
683
+ }
684
+ }
685
+ endBatch();
686
+ }
687
+ //#endregion
688
+ //#region packages/core/signal/src/arrayInstrumentations.ts
689
+ /**
690
+ * Track array iteration and return:
691
+ * - if input is reactive: a cloned raw array with reactive values
692
+ * - if input is non-reactive or shallowReactive: the original raw array
693
+ */
694
+ function reactiveReadArray(array) {
695
+ const raw = /* @__PURE__ */ toRaw(array);
696
+ if (raw === array) return raw;
697
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
698
+ return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
699
+ }
700
+ /**
701
+ * Track array iteration and return raw array
702
+ */
703
+ function shallowReadArray(arr) {
704
+ track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
705
+ return arr;
706
+ }
707
+ function toWrapped(target, item) {
708
+ if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
709
+ return toReactive(item);
710
+ }
711
+ const arrayInstrumentations = {
712
+ __proto__: null,
713
+ [Symbol.iterator]() {
714
+ return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
715
+ },
716
+ concat(...args) {
717
+ return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
718
+ },
719
+ entries() {
720
+ return iterator(this, "entries", (value) => {
721
+ value[1] = toWrapped(this, value[1]);
722
+ return value;
723
+ });
724
+ },
725
+ every(fn, thisArg) {
726
+ return apply(this, "every", fn, thisArg, void 0, arguments);
727
+ },
728
+ filter(fn, thisArg) {
729
+ return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
730
+ },
731
+ find(fn, thisArg) {
732
+ return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
733
+ },
734
+ findIndex(fn, thisArg) {
735
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
736
+ },
737
+ findLast(fn, thisArg) {
738
+ return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
739
+ },
740
+ findLastIndex(fn, thisArg) {
741
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
742
+ },
743
+ forEach(fn, thisArg) {
744
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
745
+ },
746
+ includes(...args) {
747
+ return searchProxy(this, "includes", args);
748
+ },
749
+ indexOf(...args) {
750
+ return searchProxy(this, "indexOf", args);
751
+ },
752
+ join(separator) {
753
+ return reactiveReadArray(this).join(separator);
754
+ },
755
+ lastIndexOf(...args) {
756
+ return searchProxy(this, "lastIndexOf", args);
757
+ },
758
+ map(fn, thisArg) {
759
+ return apply(this, "map", fn, thisArg, void 0, arguments);
760
+ },
761
+ pop() {
762
+ return noTracking(this, "pop");
763
+ },
764
+ push(...args) {
765
+ return noTracking(this, "push", args);
766
+ },
767
+ reduce(fn, ...args) {
768
+ return reduce(this, "reduce", fn, args);
769
+ },
770
+ reduceRight(fn, ...args) {
771
+ return reduce(this, "reduceRight", fn, args);
772
+ },
773
+ shift() {
774
+ return noTracking(this, "shift");
775
+ },
776
+ some(fn, thisArg) {
777
+ return apply(this, "some", fn, thisArg, void 0, arguments);
778
+ },
779
+ splice(...args) {
780
+ return noTracking(this, "splice", args);
781
+ },
782
+ toReversed() {
783
+ return reactiveReadArray(this).toReversed();
784
+ },
785
+ toSorted(comparer) {
786
+ return reactiveReadArray(this).toSorted(comparer);
787
+ },
788
+ toSpliced(...args) {
789
+ return reactiveReadArray(this).toSpliced(...args);
790
+ },
791
+ unshift(...args) {
792
+ return noTracking(this, "unshift", args);
793
+ },
794
+ values() {
795
+ return iterator(this, "values", (item) => toWrapped(this, item));
796
+ }
797
+ };
798
+ function iterator(self, method, wrapValue) {
799
+ const arr = shallowReadArray(self);
800
+ const iter = arr[method]();
801
+ if (arr !== self && !/* @__PURE__ */ isShallow(self)) {
802
+ iter._next = iter.next;
803
+ iter.next = () => {
804
+ const result = iter._next();
805
+ if (!result.done) result.value = wrapValue(result.value);
806
+ return result;
807
+ };
808
+ }
809
+ return iter;
810
+ }
811
+ const arrayProto = Array.prototype;
812
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
813
+ const arr = shallowReadArray(self);
814
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
815
+ const methodFn = arr[method];
816
+ if (methodFn !== arrayProto[method]) {
817
+ const result = methodFn.apply(self, args);
818
+ return needsWrap ? toReactive(result) : result;
819
+ }
820
+ let wrappedFn = fn;
821
+ if (arr !== self) {
822
+ if (needsWrap) wrappedFn = function(item, index) {
823
+ return fn.call(this, toWrapped(self, item), index, self);
824
+ };
825
+ else if (fn.length > 2) wrappedFn = function(item, index) {
826
+ return fn.call(this, item, index, self);
827
+ };
828
+ }
829
+ const result = methodFn.call(arr, wrappedFn, thisArg);
830
+ return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
831
+ }
832
+ function reduce(self, method, fn, args) {
833
+ const arr = shallowReadArray(self);
834
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
835
+ let wrappedFn = fn;
836
+ let wrapInitialAccumulator = false;
837
+ if (arr !== self) {
838
+ if (needsWrap) {
839
+ wrapInitialAccumulator = args.length === 0;
840
+ wrappedFn = function(acc, item, index) {
841
+ if (wrapInitialAccumulator) {
842
+ wrapInitialAccumulator = false;
843
+ acc = toWrapped(self, acc);
844
+ }
845
+ return fn.call(this, acc, toWrapped(self, item), index, self);
846
+ };
847
+ } else if (fn.length > 3) wrappedFn = function(acc, item, index) {
848
+ return fn.call(this, acc, item, index, self);
849
+ };
850
+ }
851
+ const result = arr[method](wrappedFn, ...args);
852
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
853
+ }
854
+ function searchProxy(self, method, args) {
855
+ const arr = /* @__PURE__ */ toRaw(self);
856
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
857
+ const res = arr[method](...args);
858
+ if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) {
859
+ args[0] = /* @__PURE__ */ toRaw(args[0]);
860
+ return arr[method](...args);
861
+ }
862
+ return res;
863
+ }
864
+ function noTracking(self, method, args = []) {
865
+ pauseTracking();
866
+ startBatch();
867
+ const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args);
868
+ endBatch();
869
+ resetTracking();
870
+ return res;
871
+ }
872
+ //#endregion
873
+ //#region packages/core/signal/src/ref.ts
874
+ let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
875
+ /*@__NO_SIDE_EFFECTS__*/
876
+ function isRef(r) {
877
+ return r ? r["__v_isRef"] === true : false;
878
+ }
879
+ /*@__NO_SIDE_EFFECTS__*/
880
+ function ref(value) {
881
+ return createRef(value, false);
882
+ }
883
+ function createRef(rawValue, shallow) {
884
+ if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
885
+ return new RefImpl(rawValue, shallow);
886
+ }
887
+ _ReactiveFlags$IS_REF = "__v_isRef";
888
+ _ReactiveFlags$IS_SHA = "__v_isShallow";
889
+ /**
890
+ * @internal
891
+ */
892
+ var RefImpl = class {
893
+ constructor(value, isShallow) {
894
+ this.dep = new Dep();
895
+ this[_ReactiveFlags$IS_REF] = true;
896
+ this[_ReactiveFlags$IS_SHA] = false;
897
+ this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
898
+ this._value = isShallow ? value : toReactive(value);
899
+ this["__v_isShallow"] = isShallow;
900
+ }
901
+ get value() {
902
+ this.dep.track({
903
+ target: this,
904
+ type: "get",
905
+ key: "value"
906
+ });
907
+ return this._value;
908
+ }
909
+ set value(newValue) {
910
+ const oldValue = this._rawValue;
911
+ const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
912
+ newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
913
+ if (hasChanged(newValue, oldValue)) {
914
+ this._rawValue = newValue;
915
+ this._value = useDirectValue ? newValue : toReactive(newValue);
916
+ this.dep.trigger({
917
+ target: this,
918
+ type: "set",
919
+ key: "value",
920
+ newValue,
921
+ oldValue
922
+ });
923
+ }
924
+ }
925
+ };
926
+ //#endregion
927
+ //#region packages/core/signal/src/baseHandlers.ts
928
+ const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
929
+ const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
930
+ function hasOwnProperty(key) {
931
+ if (!isSymbol(key)) key = String(key);
932
+ const obj = /* @__PURE__ */ toRaw(this);
933
+ track(obj, "has", key);
934
+ return obj.hasOwnProperty(key);
935
+ }
936
+ var BaseReactiveHandler = class {
937
+ constructor(_isReadonly = false, _isShallow = false) {
938
+ this._isReadonly = _isReadonly;
939
+ this._isShallow = _isShallow;
940
+ }
941
+ get(target, key, receiver) {
942
+ if (key === "__v_skip") return target["__v_skip"];
943
+ const isReadonly = this._isReadonly, isShallow = this._isShallow;
944
+ if (key === "__v_isReactive") return !isReadonly;
945
+ else if (key === "__v_isReadonly") return isReadonly;
946
+ else if (key === "__v_isShallow") return isShallow;
947
+ else if (key === "__v_raw") {
948
+ if (receiver === (isReadonly ? isShallow ? shallowReadonlyMap : readonlyMap : isShallow ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
949
+ return;
950
+ }
951
+ const targetIsArray = isArray(target);
952
+ if (!isReadonly) {
953
+ let fn;
954
+ if (targetIsArray && (fn = arrayInstrumentations[key])) return fn;
955
+ if (key === "hasOwnProperty") return hasOwnProperty;
956
+ }
957
+ const res = Reflect.get(target, key, /* @__PURE__ */ isRef(target) ? target : receiver);
958
+ if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
959
+ if (!isReadonly) track(target, "get", key);
960
+ if (isShallow) return res;
961
+ if (/* @__PURE__ */ isRef(res)) {
962
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
963
+ return isReadonly && isObject(value) ? /* @__PURE__ */ readonly(value) : value;
964
+ }
965
+ if (isObject(res)) return isReadonly ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res);
966
+ return res;
967
+ }
968
+ };
969
+ var MutableReactiveHandler = class extends BaseReactiveHandler {
970
+ constructor(isShallow = false) {
971
+ super(false, isShallow);
972
+ }
973
+ set(target, key, value, receiver) {
974
+ let oldValue = target[key];
975
+ const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
976
+ if (!this._isShallow) {
977
+ const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue);
978
+ if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) {
979
+ oldValue = /* @__PURE__ */ toRaw(oldValue);
980
+ value = /* @__PURE__ */ toRaw(value);
981
+ }
982
+ if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
983
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
984
+ return true;
985
+ } else {
986
+ oldValue.value = value;
987
+ return true;
988
+ }
989
+ }
990
+ const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
991
+ const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
992
+ if (target === /* @__PURE__ */ toRaw(receiver)) {
993
+ if (!hadKey) trigger(target, "add", key, value);
994
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
995
+ }
996
+ return result;
997
+ }
998
+ deleteProperty(target, key) {
999
+ const hadKey = hasOwn(target, key);
1000
+ const oldValue = target[key];
1001
+ const result = Reflect.deleteProperty(target, key);
1002
+ if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
1003
+ return result;
1004
+ }
1005
+ has(target, key) {
1006
+ const result = Reflect.has(target, key);
1007
+ if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
1008
+ return result;
1009
+ }
1010
+ ownKeys(target) {
1011
+ track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
1012
+ return Reflect.ownKeys(target);
1013
+ }
1014
+ };
1015
+ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
1016
+ constructor(isShallow = false) {
1017
+ super(true, isShallow);
1018
+ }
1019
+ set(target, key) {
1020
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
1021
+ return true;
1022
+ }
1023
+ deleteProperty(target, key) {
1024
+ warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
1025
+ return true;
1026
+ }
1027
+ };
1028
+ const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
1029
+ const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
1030
+ //#endregion
1031
+ //#region packages/core/signal/src/collectionHandlers.ts
1032
+ const toShallow = (value) => value;
1033
+ const getProto = (v) => Reflect.getPrototypeOf(v);
1034
+ function createIterableMethod(method, isReadonly, isShallow) {
1035
+ return function(...args) {
1036
+ const target = this["__v_raw"];
1037
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1038
+ const targetIsMap = isMap(rawTarget);
1039
+ const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
1040
+ const isKeyOnly = method === "keys" && targetIsMap;
1041
+ const innerIterator = target[method](...args);
1042
+ const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
1043
+ !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
1044
+ return extend(Object.create(innerIterator), { next() {
1045
+ const { value, done } = innerIterator.next();
1046
+ return done ? {
1047
+ value,
1048
+ done
1049
+ } : {
1050
+ value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1051
+ done
1052
+ };
1053
+ } });
1054
+ };
1055
+ }
1056
+ function createReadonlyMethod(type) {
1057
+ return function(...args) {
1058
+ {
1059
+ const key = args[0] ? `on key "${args[0]}" ` : ``;
1060
+ warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, /* @__PURE__ */ toRaw(this));
1061
+ }
1062
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
1063
+ };
1064
+ }
1065
+ function createInstrumentations(readonly, shallow) {
1066
+ const instrumentations = {
1067
+ get(key) {
1068
+ const target = this["__v_raw"];
1069
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1070
+ const rawKey = /* @__PURE__ */ toRaw(key);
1071
+ if (!readonly) {
1072
+ if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
1073
+ track(rawTarget, "get", rawKey);
1074
+ }
1075
+ const { has } = getProto(rawTarget);
1076
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1077
+ if (has.call(rawTarget, key)) return wrap(target.get(key));
1078
+ else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
1079
+ else if (target !== rawTarget) target.get(key);
1080
+ },
1081
+ get size() {
1082
+ const target = this["__v_raw"];
1083
+ !readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY);
1084
+ return target.size;
1085
+ },
1086
+ has(key) {
1087
+ const target = this["__v_raw"];
1088
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1089
+ const rawKey = /* @__PURE__ */ toRaw(key);
1090
+ if (!readonly) {
1091
+ if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
1092
+ track(rawTarget, "has", rawKey);
1093
+ }
1094
+ return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1095
+ },
1096
+ forEach(callback, thisArg) {
1097
+ const observed = this;
1098
+ const target = observed["__v_raw"];
1099
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1100
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1101
+ !readonly && track(rawTarget, "iterate", ITERATE_KEY);
1102
+ return target.forEach((value, key) => {
1103
+ return callback.call(thisArg, wrap(value), wrap(key), observed);
1104
+ });
1105
+ }
1106
+ };
1107
+ extend(instrumentations, readonly ? {
1108
+ add: createReadonlyMethod("add"),
1109
+ set: createReadonlyMethod("set"),
1110
+ delete: createReadonlyMethod("delete"),
1111
+ clear: createReadonlyMethod("clear")
1112
+ } : {
1113
+ add(value) {
1114
+ const target = /* @__PURE__ */ toRaw(this);
1115
+ const proto = getProto(target);
1116
+ const rawValue = /* @__PURE__ */ toRaw(value);
1117
+ const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value;
1118
+ if (!(proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue))) {
1119
+ target.add(valueToAdd);
1120
+ trigger(target, "add", valueToAdd, valueToAdd);
1121
+ }
1122
+ return this;
1123
+ },
1124
+ set(key, value) {
1125
+ if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
1126
+ const target = /* @__PURE__ */ toRaw(this);
1127
+ const { has, get } = getProto(target);
1128
+ let hadKey = has.call(target, key);
1129
+ if (!hadKey) {
1130
+ key = /* @__PURE__ */ toRaw(key);
1131
+ hadKey = has.call(target, key);
1132
+ } else checkIdentityKeys(target, has, key);
1133
+ const oldValue = get.call(target, key);
1134
+ target.set(key, value);
1135
+ if (!hadKey) trigger(target, "add", key, value);
1136
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
1137
+ return this;
1138
+ },
1139
+ delete(key) {
1140
+ const target = /* @__PURE__ */ toRaw(this);
1141
+ const { has, get } = getProto(target);
1142
+ let hadKey = has.call(target, key);
1143
+ if (!hadKey) {
1144
+ key = /* @__PURE__ */ toRaw(key);
1145
+ hadKey = has.call(target, key);
1146
+ } else checkIdentityKeys(target, has, key);
1147
+ const oldValue = get ? get.call(target, key) : void 0;
1148
+ const result = target.delete(key);
1149
+ if (hadKey) trigger(target, "delete", key, void 0, oldValue);
1150
+ return result;
1151
+ },
1152
+ clear() {
1153
+ const target = /* @__PURE__ */ toRaw(this);
1154
+ const hadItems = target.size !== 0;
1155
+ const oldTarget = isMap(target) ? new Map(target) : new Set(target);
1156
+ const result = target.clear();
1157
+ if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
1158
+ return result;
1159
+ }
1160
+ });
1161
+ [
1162
+ "keys",
1163
+ "values",
1164
+ "entries",
1165
+ Symbol.iterator
1166
+ ].forEach((method) => {
1167
+ instrumentations[method] = createIterableMethod(method, readonly, shallow);
1168
+ });
1169
+ return instrumentations;
1170
+ }
1171
+ function createInstrumentationGetter(isReadonly, shallow) {
1172
+ const instrumentations = createInstrumentations(isReadonly, shallow);
1173
+ return (target, key, receiver) => {
1174
+ if (key === "__v_isReactive") return !isReadonly;
1175
+ else if (key === "__v_isReadonly") return isReadonly;
1176
+ else if (key === "__v_raw") return target;
1177
+ return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
1178
+ };
1179
+ }
1180
+ const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
1181
+ const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
1182
+ function checkIdentityKeys(target, has, key) {
1183
+ const rawKey = /* @__PURE__ */ toRaw(key);
1184
+ if (rawKey !== key && has.call(target, rawKey)) {
1185
+ const type = toRawType(target);
1186
+ warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
1187
+ }
1188
+ }
1189
+ //#endregion
1190
+ //#region packages/core/signal/src/reactive.ts
1191
+ const reactiveMap = /* @__PURE__ */ new WeakMap();
1192
+ const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
1193
+ const readonlyMap = /* @__PURE__ */ new WeakMap();
1194
+ const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
1195
+ function targetTypeMap(rawType) {
1196
+ switch (rawType) {
1197
+ case "Object":
1198
+ case "Array": return 1;
1199
+ case "Map":
1200
+ case "Set":
1201
+ case "WeakMap":
1202
+ case "WeakSet": return 2;
1203
+ default: return 0;
1204
+ }
1205
+ }
1206
+ function getTargetType(value) {
1207
+ return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1208
+ }
1209
+ /*@__NO_SIDE_EFFECTS__*/
1210
+ function reactive(target) {
1211
+ if (/* @__PURE__ */ isReadonly(target)) return target;
1212
+ return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1213
+ }
1214
+ /**
1215
+ * Takes an object (reactive or plain) or a ref and returns a readonly proxy to
1216
+ * the original.
1217
+ *
1218
+ * A readonly proxy is deep: any nested property accessed will be readonly as
1219
+ * well. It also has the same ref-unwrapping behavior as {@link reactive},
1220
+ * except the unwrapped values will also be made readonly.
1221
+ *
1222
+ * @example
1223
+ * ```js
1224
+ * const original = reactive({ count: 0 })
1225
+ *
1226
+ * const copy = readonly(original)
1227
+ *
1228
+ * watchEffect(() => {
1229
+ * // works for reactivity tracking
1230
+ * console.log(copy.count)
1231
+ * })
1232
+ *
1233
+ * // mutating original will trigger watchers relying on the copy
1234
+ * original.count++
1235
+ *
1236
+ * // mutating the copy will fail and result in a warning
1237
+ * copy.count++ // warning!
1238
+ * ```
1239
+ *
1240
+ * @param target - The source object.
1241
+ * @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
1242
+ */
1243
+ /*@__NO_SIDE_EFFECTS__*/
1244
+ function readonly(target) {
1245
+ return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1246
+ }
1247
+ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
1248
+ if (!isObject(target)) {
1249
+ warn(`value cannot be made ${isReadonly ? "readonly" : "reactive"}: ${String(target)}`);
1250
+ return target;
1251
+ }
1252
+ if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
1253
+ const targetType = getTargetType(target);
1254
+ if (targetType === 0) return target;
1255
+ const existingProxy = proxyMap.get(target);
1256
+ if (existingProxy) return existingProxy;
1257
+ const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1258
+ proxyMap.set(target, proxy);
1259
+ return proxy;
1260
+ }
1261
+ /**
1262
+ * Checks if an object is a proxy created by {@link reactive} or
1263
+ * {@link shallowReactive} (or {@link ref} in some cases).
1264
+ *
1265
+ * @example
1266
+ * ```js
1267
+ * isReactive(reactive({})) // => true
1268
+ * isReactive(readonly(reactive({}))) // => true
1269
+ * isReactive(ref({}).value) // => true
1270
+ * isReactive(readonly(ref({})).value) // => true
1271
+ * isReactive(ref(true)) // => false
1272
+ * isReactive(shallowRef({}).value) // => false
1273
+ * isReactive(shallowReactive({})) // => true
1274
+ * ```
1275
+ *
1276
+ * @param value - The value to check.
1277
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
1278
+ */
1279
+ /*@__NO_SIDE_EFFECTS__*/
1280
+ function isReactive(value) {
1281
+ if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
1282
+ return !!(value && value["__v_isReactive"]);
1283
+ }
1284
+ /**
1285
+ * Checks whether the passed value is a readonly object. The properties of a
1286
+ * readonly object can change, but they can't be assigned directly via the
1287
+ * passed object.
1288
+ *
1289
+ * The proxies created by {@link readonly} and {@link shallowReadonly} are
1290
+ * both considered readonly, as is a computed ref without a set function.
1291
+ *
1292
+ * @param value - The value to check.
1293
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
1294
+ */
1295
+ /*@__NO_SIDE_EFFECTS__*/
1296
+ function isReadonly(value) {
1297
+ return !!(value && value["__v_isReadonly"]);
1298
+ }
1299
+ /*@__NO_SIDE_EFFECTS__*/
1300
+ function isShallow(value) {
1301
+ return !!(value && value["__v_isShallow"]);
1302
+ }
1303
+ /**
1304
+ * Checks if an object is a proxy created by {@link reactive},
1305
+ * {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
1306
+ *
1307
+ * @param value - The value to check.
1308
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
1309
+ */
1310
+ /*@__NO_SIDE_EFFECTS__*/
1311
+ function isProxy(value) {
1312
+ return value ? !!value["__v_raw"] : false;
1313
+ }
1314
+ /**
1315
+ * Returns the raw, original object of a Vue-created proxy.
1316
+ *
1317
+ * `toRaw()` can return the original object from proxies created by
1318
+ * {@link reactive}, {@link readonly}, {@link shallowReactive} or
1319
+ * {@link shallowReadonly}.
1320
+ *
1321
+ * This is an escape hatch that can be used to temporarily read without
1322
+ * incurring proxy access / tracking overhead or write without triggering
1323
+ * changes. It is **not** recommended to hold a persistent reference to the
1324
+ * original object. Use with caution.
1325
+ *
1326
+ * @example
1327
+ * ```js
1328
+ * const foo = {}
1329
+ * const reactiveFoo = reactive(foo)
1330
+ *
1331
+ * console.log(toRaw(reactiveFoo) === foo) // true
1332
+ * ```
1333
+ *
1334
+ * @param observed - The object for which the "raw" value is requested.
1335
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
1336
+ */
1337
+ /*@__NO_SIDE_EFFECTS__*/
1338
+ function toRaw(observed) {
1339
+ const raw = observed && observed["__v_raw"];
1340
+ return raw ? /* @__PURE__ */ toRaw(raw) : observed;
1341
+ }
1342
+ /**
1343
+ * Returns a reactive proxy of the given value (if possible).
1344
+ *
1345
+ * If the given value is not an object, the original value itself is returned.
1346
+ *
1347
+ * @param value - The value for which a reactive proxy shall be created.
1348
+ */
1349
+ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
1350
+ /**
1351
+ * Returns a readonly proxy of the given value (if possible).
1352
+ *
1353
+ * If the given value is not an object, the original value itself is returned.
1354
+ *
1355
+ * @param value - The value for which a readonly proxy shall be created.
1356
+ */
1357
+ const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1358
+ //#endregion
1359
+ //#region packages/core/signal/src/state.ts
1360
+ function state(value) {
1361
+ if (arguments.length === 0) return /* @__PURE__ */ ref();
1362
+ return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
1363
+ }
1364
+ function isProxyable(value) {
1365
+ if (value === null || typeof value !== "object") return false;
1366
+ if (Array.isArray(value)) return true;
1367
+ if (value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) return true;
1368
+ return isPlainObject(value);
1369
+ }
1370
+ function isPlainObject(value) {
1371
+ const proto = Object.getPrototypeOf(value);
1372
+ return proto === Object.prototype || proto === null;
1373
+ }
1374
+ //#endregion
1375
+ //#region packages/core/runtime-dom/src/domOwnership.ts
1376
+ const activeLightDomHosts = /* @__PURE__ */ new WeakMap();
1377
+ const runtimeOwnedNodes = /* @__PURE__ */ new WeakSet();
1378
+ function registerLightDomHost(host, lightChildren) {
1379
+ const ownership = { lightChildren };
1380
+ activeLightDomHosts.set(host, ownership);
1381
+ return () => {
1382
+ if (activeLightDomHosts.get(host) === ownership) activeLightDomHosts.delete(host);
1383
+ };
1384
+ }
1385
+ function trackRuntimeDomInsertion(parent, node) {
1386
+ const ownership = activeLightDomHosts.get(parent);
1387
+ if (!ownership) return;
1388
+ if (node.nodeType === 11) {
1389
+ for (const child of node.childNodes) trackRuntimeNode(ownership, child);
1390
+ return;
1391
+ }
1392
+ trackRuntimeNode(ownership, node);
1393
+ }
1394
+ function isRuntimeOwnedNode(node) {
1395
+ return runtimeOwnedNodes.has(node);
1396
+ }
1397
+ function trackRuntimeNode(ownership, node) {
1398
+ if (!ownership.lightChildren.includes(node)) runtimeOwnedNodes.add(node);
1399
+ }
1400
+ //#endregion
1401
+ //#region packages/core/runtime-dom/src/range.ts
1402
+ function insertTracked(parent, value, marker = null) {
1403
+ if (value === void 0 || value == null || value === false || value === true) return [];
1404
+ if (Array.isArray(value)) {
1405
+ const nodes = [];
1406
+ for (const item of value) nodes.push(...insertTracked(parent, item, marker));
1407
+ return nodes;
1408
+ }
1409
+ const node = value instanceof Node ? value : document.createTextNode(String(value));
1410
+ trackRuntimeDomInsertion(parent, node);
1411
+ parent.insertBefore(node, marker);
1412
+ return [node];
1413
+ }
1414
+ function removeNodes$1(nodes) {
1415
+ for (const node of nodes) {
1416
+ var _node$parentNode2;
1417
+ (_node$parentNode2 = node.parentNode) === null || _node$parentNode2 === void 0 || _node$parentNode2.removeChild(node);
1418
+ }
1419
+ }
1420
+ function moveRangeBefore(nodes, parent, marker = null) {
1421
+ for (const node of nodes) {
1422
+ trackRuntimeDomInsertion(parent, node);
1423
+ parent.insertBefore(node, marker);
1424
+ }
1425
+ }
1426
+ //#endregion
16
1427
  //#region packages/core/runtime-dom/src/hostContext.ts
17
1428
  let currentHostContext;
18
1429
  function getCurrentHostContext() {
@@ -37,48 +1448,50 @@ function withCapturedHostContext(fn) {
37
1448
  });
38
1449
  }
39
1450
  //#endregion
40
- //#region packages/core/runtime-dom/src/range.ts
41
- var DynamicRange = class {
42
- constructor(parent, marker) {
1451
+ //#region packages/core/runtime-dom/src/scopedSubtree.ts
1452
+ function captureScopedSubtreeContext() {
1453
+ return {
1454
+ owner: getCurrentOwner(),
1455
+ host: captureCurrentHostContext()
1456
+ };
1457
+ }
1458
+ var ScopedSubtree = class {
1459
+ constructor(parent, marker, context) {
43
1460
  this.parent = parent;
44
1461
  this.marker = marker;
1462
+ this.context = context;
45
1463
  this.nodes = [];
46
1464
  }
47
- replace(value) {
48
- this.clear();
49
- this.nodes = insertTracked(this.parent, value, this.marker);
50
- }
51
- clear() {
52
- for (const node of this.nodes) {
53
- var _node$parentNode;
54
- (_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 || _node$parentNode.removeChild(node);
1465
+ replace(render) {
1466
+ this.dispose();
1467
+ const scope = effectScope(true);
1468
+ let nodes = [];
1469
+ try {
1470
+ scope.run(() => {
1471
+ nodes = runWithOwner(this.context.owner, () => withHostContext(this.context.host, () => insertTracked(this.parent, render(), this.marker)));
1472
+ });
1473
+ } catch (error) {
1474
+ scope.stop();
1475
+ removeNodes$1(nodes);
1476
+ throw error;
55
1477
  }
1478
+ this.scope = scope;
1479
+ this.nodes = nodes;
1480
+ }
1481
+ dispose() {
1482
+ var _this$scope;
1483
+ (_this$scope = this.scope) === null || _this$scope === void 0 || _this$scope.stop();
1484
+ this.scope = void 0;
1485
+ removeNodes$1(this.nodes);
56
1486
  this.nodes = [];
57
1487
  }
1488
+ moveBefore(marker) {
1489
+ moveRangeBefore(this.nodes, this.parent, marker);
1490
+ }
58
1491
  current() {
59
1492
  return this.nodes;
60
1493
  }
61
1494
  };
62
- function insertTracked(parent, value, marker = null) {
63
- if (value === void 0 || value == null || value === false || value === true) return [];
64
- if (Array.isArray(value)) {
65
- const nodes = [];
66
- for (const item of value) nodes.push(...insertTracked(parent, item, marker));
67
- return nodes;
68
- }
69
- const node = value instanceof Node ? value : document.createTextNode(String(value));
70
- parent.insertBefore(node, marker);
71
- return [node];
72
- }
73
- function removeNodes$1(nodes) {
74
- for (const node of nodes) {
75
- var _node$parentNode2;
76
- (_node$parentNode2 = node.parentNode) === null || _node$parentNode2 === void 0 || _node$parentNode2.removeChild(node);
77
- }
78
- }
79
- function moveRangeBefore(nodes, parent, marker = null) {
80
- for (const node of nodes) parent.insertBefore(node, marker);
81
- }
82
1495
  //#endregion
83
1496
  //#region packages/core/runtime-dom/src/insert.ts
84
1497
  function insert(parent, value, marker = null) {
@@ -89,16 +1502,13 @@ function insert(parent, value, marker = null) {
89
1502
  insertTracked(parent, value, marker);
90
1503
  }
91
1504
  function mountDynamic(parent, marker, value) {
92
- const range = new DynamicRange(parent, marker);
93
- const hostContext = captureCurrentHostContext();
94
- const owner = getCurrentOwner();
1505
+ const subtree = new ScopedSubtree(parent, marker, captureScopedSubtreeContext());
95
1506
  const runner = effect(() => {
96
- const next = runWithOwner(owner, () => withHostContext(hostContext, value));
97
- range.replace(next);
1507
+ subtree.replace(value);
98
1508
  });
99
1509
  onScopeDispose(() => {
100
1510
  stop(runner);
101
- range.clear();
1511
+ subtree.dispose();
102
1512
  }, true);
103
1513
  }
104
1514
  //#endregion
@@ -241,7 +1651,7 @@ function emitDevtoolsEvent(event) {
241
1651
  //#region packages/core/runtime-dom/src/render.ts
242
1652
  function render(value, container, options = {}) {
243
1653
  var _options$owner;
244
- const renderScope = scope();
1654
+ const renderScope = effectScope();
245
1655
  const owner = (_options$owner = options.owner) !== null && _options$owner !== void 0 ? _options$owner : createOwner();
246
1656
  renderScope.run(() => {
247
1657
  container.textContent = "";
@@ -395,11 +1805,11 @@ function bindStyle(el, value) {
395
1805
  function patchStyle(el, prev, next) {
396
1806
  const style = el.style;
397
1807
  if (prev) {
398
- for (const key in prev) if (!(key in next)) style.setProperty(toKebabCase$1(key), "");
1808
+ for (const key in prev) if (!(key in next)) style.setProperty(toKebabCase$2(key), "");
399
1809
  }
400
1810
  for (const key in next) {
401
1811
  const value = next[key];
402
- const name = toKebabCase$1(key);
1812
+ const name = toKebabCase$2(key);
403
1813
  if (value == null) style.setProperty(name, "");
404
1814
  else style.setProperty(name, normalizeStyleValue(key, value));
405
1815
  }
@@ -421,7 +1831,7 @@ const unitlessNumbers = /* @__PURE__ */ new Set([
421
1831
  function isUnitlessNumber(key) {
422
1832
  return unitlessNumbers.has(key);
423
1833
  }
424
- function toKebabCase$1(value) {
1834
+ function toKebabCase$2(value) {
425
1835
  return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
426
1836
  }
427
1837
  //#endregion
@@ -531,8 +1941,7 @@ function createComponent(component, props) {
531
1941
  //#endregion
532
1942
  //#region packages/core/runtime-dom/src/list.ts
533
1943
  function disposeListRecord(record) {
534
- record.scope.stop();
535
- removeNodes$1(record.nodes);
1944
+ record.subtree.dispose();
536
1945
  }
537
1946
  function mountFor$1(parent, marker, each, key, render) {
538
1947
  if (!key) {
@@ -542,24 +1951,20 @@ function mountFor$1(parent, marker, each, key, render) {
542
1951
  mountKeyedFor(parent, marker, each, key, render);
543
1952
  }
544
1953
  function mountIndexFor(parent, marker, each, render) {
545
- let current = [];
546
- const owner = getCurrentOwner();
1954
+ const subtree = new ScopedSubtree(parent, marker, captureScopedSubtreeContext());
547
1955
  const runner = effect(() => {
548
1956
  var _each;
549
- removeNodes$1(current);
550
- current = [];
551
1957
  const list = (_each = each()) !== null && _each !== void 0 ? _each : [];
552
- for (let i = 0; i < list.length; i++) current.push(...insertTracked(parent, runWithOwner(owner, () => render(list[i], i)), marker));
1958
+ subtree.replace(() => list.map((item, index) => render(item, index)));
553
1959
  });
554
1960
  onScopeDispose(() => {
555
1961
  stop(runner);
556
- removeNodes$1(current);
557
- current = [];
1962
+ subtree.dispose();
558
1963
  }, true);
559
1964
  }
560
1965
  function mountKeyedFor(parent, marker, each, key, render) {
561
1966
  let records = [];
562
- const owner = getCurrentOwner();
1967
+ const subtreeContext = captureScopedSubtreeContext();
563
1968
  const runner = effect(() => {
564
1969
  var _each2;
565
1970
  const nextItems = (_each2 = each()) !== null && _each2 !== void 0 ? _each2 : [];
@@ -576,31 +1981,22 @@ function mountKeyedFor(parent, marker, each, key, render) {
576
1981
  oldRecord.index = i;
577
1982
  nextRecords.push(oldRecord);
578
1983
  } else {
579
- const itemScope = effectScope(true);
580
- let nodes = [];
581
- try {
582
- itemScope.run(() => {
583
- nodes = insertTracked(parent, runWithOwner(owner, () => render(item, i)), marker);
584
- });
585
- } catch (error) {
586
- itemScope.stop();
587
- throw error;
588
- }
1984
+ const subtree = new ScopedSubtree(parent, marker, subtreeContext);
1985
+ subtree.replace(() => render(item, i));
589
1986
  nextRecords.push({
590
1987
  key: itemKey,
591
1988
  item,
592
1989
  index: i,
593
- nodes,
594
- scope: itemScope
1990
+ subtree
595
1991
  });
596
1992
  }
597
1993
  }
598
1994
  for (const record of oldMap.values()) disposeListRecord(record);
599
1995
  for (let i = nextRecords.length - 1; i >= 0; i--) {
600
- var _nextRecords$nodes$;
1996
+ var _nextRecords$subtree$;
601
1997
  const record = nextRecords[i];
602
- const anchor = i === nextRecords.length - 1 ? marker : (_nextRecords$nodes$ = nextRecords[i + 1].nodes[0]) !== null && _nextRecords$nodes$ !== void 0 ? _nextRecords$nodes$ : marker;
603
- moveRangeBefore(record.nodes, parent, anchor);
1998
+ const anchor = i === nextRecords.length - 1 ? marker : (_nextRecords$subtree$ = nextRecords[i + 1].subtree.current()[0]) !== null && _nextRecords$subtree$ !== void 0 ? _nextRecords$subtree$ : marker;
1999
+ record.subtree.moveBefore(anchor);
604
2000
  }
605
2001
  emitDevtoolsEvent({
606
2002
  type: "mount-for",
@@ -634,6 +2030,254 @@ function mountFor(parent, marker, each, key, render) {
634
2030
  mountFor$1(parent, marker, each, key, render);
635
2031
  }
636
2032
  //#endregion
2033
+ //#region packages/core/runtime-dom/src/customElementContract.ts
2034
+ function getCustomElementAttributeName(prop) {
2035
+ var _prop$attrName;
2036
+ if (prop.attrName === false) return void 0;
2037
+ if (!isAttributeBackedType(prop.type) && !prop.deserialize) return;
2038
+ return normalizeAttributeName((_prop$attrName = prop.attrName) !== null && _prop$attrName !== void 0 ? _prop$attrName : toKebabCase$1(prop.name));
2039
+ }
2040
+ function getCustomElementObservedAttributes(props) {
2041
+ const attributes = /* @__PURE__ */ new Set();
2042
+ for (const prop of props) {
2043
+ const attrName = getCustomElementAttributeName(prop);
2044
+ if (attrName) attributes.add(attrName);
2045
+ }
2046
+ return Array.from(attributes);
2047
+ }
2048
+ function findCustomElementPropByAttribute(props, attrName) {
2049
+ const normalizedName = normalizeAttributeName(attrName);
2050
+ return props.find((prop) => {
2051
+ return getCustomElementAttributeName(prop) === normalizedName;
2052
+ });
2053
+ }
2054
+ function coerceCustomElementAttribute(prop, value) {
2055
+ if (typeof prop.deserialize === "function") return prop.deserialize(value);
2056
+ if (prop.deserialize === true) return value;
2057
+ switch (prop.type) {
2058
+ case "boolean": return value !== null;
2059
+ case "number": return value === null ? void 0 : Number(value);
2060
+ case "string": return value !== null && value !== void 0 ? value : void 0;
2061
+ case "object":
2062
+ case "array": return coerceStructuredAttribute(prop, value);
2063
+ case "function": return;
2064
+ default: return value;
2065
+ }
2066
+ }
2067
+ function reflectCustomElementProperty(element, prop, value, reflectingAttrs) {
2068
+ const attrName = getCustomElementAttributeName(prop);
2069
+ if (!attrName || prop.serialize === true) return;
2070
+ reflectingAttrs === null || reflectingAttrs === void 0 || reflectingAttrs.add(attrName);
2071
+ try {
2072
+ const serialized = serializeCustomElementProperty(prop, value);
2073
+ if (serialized == null) element.removeAttribute(attrName);
2074
+ else element.setAttribute(attrName, serialized);
2075
+ } finally {
2076
+ reflectingAttrs === null || reflectingAttrs === void 0 || reflectingAttrs.delete(attrName);
2077
+ }
2078
+ }
2079
+ function createCustomElementMountLifecycle(mount) {
2080
+ let mounted;
2081
+ return {
2082
+ connect() {
2083
+ var _mounted;
2084
+ (_mounted = mounted) !== null && _mounted !== void 0 || (mounted = mount());
2085
+ return mounted;
2086
+ },
2087
+ disconnect() {
2088
+ const current = mounted;
2089
+ mounted = void 0;
2090
+ current === null || current === void 0 || current.dispose();
2091
+ },
2092
+ current() {
2093
+ return mounted;
2094
+ }
2095
+ };
2096
+ }
2097
+ function serializeCustomElementProperty(prop, value) {
2098
+ if (typeof prop.serialize === "function") return prop.serialize(value);
2099
+ if (prop.type === "boolean") return value ? "" : null;
2100
+ if (value == null) return null;
2101
+ if (prop.type === "object" || prop.type === "array") return JSON.stringify(value);
2102
+ if (prop.type === "function") return void 0;
2103
+ return String(value);
2104
+ }
2105
+ function coerceStructuredAttribute(prop, value) {
2106
+ if (value === null) return void 0;
2107
+ try {
2108
+ return JSON.parse(value);
2109
+ } catch (_unused) {
2110
+ console.warn(`[Zeus custom-element] Failed to parse JSON attribute "${getCustomElementAttributeName(prop)}".`);
2111
+ return prop.type === "array" ? [] : {};
2112
+ }
2113
+ }
2114
+ function isAttributeBackedType(type) {
2115
+ return type === "string" || type === "number" || type === "boolean";
2116
+ }
2117
+ function normalizeAttributeName(value) {
2118
+ return value.toLowerCase();
2119
+ }
2120
+ function toKebabCase$1(value) {
2121
+ return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
2122
+ }
2123
+ //#endregion
2124
+ //#region packages/core/runtime-dom/src/slot.ts
2125
+ function createSlot(name, fallback) {
2126
+ const context = getCurrentHostContext();
2127
+ if (!context) return createNativeSlot(name, fallback);
2128
+ if (context.mode === "shadow") return createNativeSlot(name, fallback);
2129
+ if (context.projection) return context.projection.createSlot(name, fallback);
2130
+ const assigned = findLightSlotNodes(context.lightChildren, name);
2131
+ if (assigned.length > 0) return Array.from(assigned);
2132
+ return fallback ? fallback() : null;
2133
+ }
2134
+ function createLightDomProjection(host, lightChildren) {
2135
+ const outlets = [];
2136
+ let observer;
2137
+ let unregisterHost;
2138
+ const observe = () => {
2139
+ observer === null || observer === void 0 || observer.observe(host, {
2140
+ attributes: true,
2141
+ attributeFilter: ["slot"],
2142
+ childList: true,
2143
+ subtree: true
2144
+ });
2145
+ for (const node of lightChildren) {
2146
+ if (node.nodeType !== Node.ELEMENT_NODE || host.contains(node)) continue;
2147
+ observer === null || observer === void 0 || observer.observe(node, {
2148
+ attributes: true,
2149
+ attributeFilter: ["slot"]
2150
+ });
2151
+ }
2152
+ };
2153
+ const reconcile = () => {
2154
+ observer === null || observer === void 0 || observer.disconnect();
2155
+ const claimed = /* @__PURE__ */ new Set();
2156
+ for (const outlet of outlets) {
2157
+ const assigned = lightChildren.filter((node) => {
2158
+ if (claimed.has(node) || !matchesLightSlot(node, outlet.name)) return false;
2159
+ claimed.add(node);
2160
+ return true;
2161
+ });
2162
+ replaceOutletNodes(outlet, assigned.length > 0 ? assigned : outlet.fallbackNodes);
2163
+ }
2164
+ for (const node of lightChildren) if (!claimed.has(node) && host.contains(node)) {
2165
+ var _node$parentNode;
2166
+ (_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 || _node$parentNode.removeChild(node);
2167
+ }
2168
+ observer === null || observer === void 0 || observer.takeRecords();
2169
+ observe();
2170
+ };
2171
+ const handleMutations = (records) => {
2172
+ const added = /* @__PURE__ */ new Set();
2173
+ const removed = /* @__PURE__ */ new Set();
2174
+ let changed = false;
2175
+ for (const record of records) {
2176
+ if (record.type === "attributes") {
2177
+ if (lightChildren.includes(record.target)) changed = true;
2178
+ continue;
2179
+ }
2180
+ for (const node of record.removedNodes) if (lightChildren.includes(node)) removed.add(node);
2181
+ if (record.target !== host) continue;
2182
+ const additions = Array.from(record.addedNodes).filter((node) => {
2183
+ return !isRuntimeOwnedNode(node);
2184
+ });
2185
+ if (additions.length === 0) continue;
2186
+ for (const node of additions) added.add(node);
2187
+ insertLightChildren(lightChildren, additions, record);
2188
+ changed = true;
2189
+ }
2190
+ for (const node of removed) {
2191
+ if (added.has(node) || host.contains(node)) continue;
2192
+ const index = lightChildren.indexOf(node);
2193
+ if (index >= 0) {
2194
+ lightChildren.splice(index, 1);
2195
+ changed = true;
2196
+ }
2197
+ }
2198
+ if (changed) reconcile();
2199
+ };
2200
+ return {
2201
+ createSlot(name, fallback) {
2202
+ const fragment = document.createDocumentFragment();
2203
+ const start = document.createComment(name ? `zeus-slot:${name}` : "zeus-slot");
2204
+ const end = document.createComment("/zeus-slot");
2205
+ fragment.append(start, end);
2206
+ const outlet = {
2207
+ name,
2208
+ start,
2209
+ end,
2210
+ fallbackNodes: fallback ? insertTracked(fragment, fallback(), end) : []
2211
+ };
2212
+ outlets.push(outlet);
2213
+ reconcile();
2214
+ return fragment;
2215
+ },
2216
+ connect() {
2217
+ var _host$ownerDocument$d;
2218
+ if (observer) return;
2219
+ const Observer = (_host$ownerDocument$d = host.ownerDocument.defaultView) === null || _host$ownerDocument$d === void 0 ? void 0 : _host$ownerDocument$d.MutationObserver;
2220
+ if (!Observer) return;
2221
+ unregisterHost = registerLightDomHost(host, lightChildren);
2222
+ observer = new Observer(handleMutations);
2223
+ observe();
2224
+ },
2225
+ disconnect() {
2226
+ observer === null || observer === void 0 || observer.disconnect();
2227
+ observer = void 0;
2228
+ unregisterHost === null || unregisterHost === void 0 || unregisterHost();
2229
+ unregisterHost = void 0;
2230
+ }
2231
+ };
2232
+ }
2233
+ function replaceOutletNodes(outlet, nextNodes) {
2234
+ const parent = outlet.end.parentNode;
2235
+ if (!parent || parent !== outlet.start.parentNode) return;
2236
+ let current = outlet.start.nextSibling;
2237
+ while (current && current !== outlet.end) {
2238
+ const next = current.nextSibling;
2239
+ parent.removeChild(current);
2240
+ current = next;
2241
+ }
2242
+ for (const node of nextNodes) parent.insertBefore(node, outlet.end);
2243
+ }
2244
+ function insertLightChildren(lightChildren, additions, record) {
2245
+ for (const node of additions) {
2246
+ const currentIndex = lightChildren.indexOf(node);
2247
+ if (currentIndex >= 0) lightChildren.splice(currentIndex, 1);
2248
+ }
2249
+ let insertionIndex = lightChildren.length;
2250
+ const previousIndex = record.previousSibling ? lightChildren.indexOf(record.previousSibling) : -1;
2251
+ const nextIndex = record.nextSibling ? lightChildren.indexOf(record.nextSibling) : -1;
2252
+ if (previousIndex >= 0) insertionIndex = previousIndex + 1;
2253
+ else if (nextIndex >= 0) insertionIndex = nextIndex;
2254
+ else if (record.previousSibling === null) insertionIndex = 0;
2255
+ lightChildren.splice(insertionIndex, 0, ...additions);
2256
+ }
2257
+ function createNativeSlot(name, fallback) {
2258
+ const slot = document.createElement("slot");
2259
+ if (name) slot.setAttribute("name", name);
2260
+ const fallbackValue = fallback === null || fallback === void 0 ? void 0 : fallback();
2261
+ if (fallbackValue != null) insert(slot, fallbackValue);
2262
+ return slot;
2263
+ }
2264
+ function findLightSlotNodes(nodes, name) {
2265
+ return nodes.filter((node) => matchesLightSlot(node, name));
2266
+ }
2267
+ function matchesLightSlot(node, name) {
2268
+ if (name) {
2269
+ if (node.nodeType !== Node.ELEMENT_NODE) return false;
2270
+ return node.getAttribute("slot") === name;
2271
+ }
2272
+ if (node.nodeType === Node.ELEMENT_NODE) return !node.hasAttribute("slot");
2273
+ return isMeaningfulTextNode(node);
2274
+ }
2275
+ function isMeaningfulTextNode(node) {
2276
+ var _node$textContent;
2277
+ if (node.nodeType !== Node.TEXT_NODE) return false;
2278
+ return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
2279
+ }
2280
+ //#endregion
637
2281
  //#region packages/core/runtime-dom/src/defineElement.ts
638
2282
  const ZEUS_ELEMENT_DEFINITION = Symbol.for("zeus.element.definition");
639
2283
  function prop(input, options = {}) {
@@ -675,8 +2319,8 @@ function createPropStore(defs) {
675
2319
  const props = {};
676
2320
  for (const def of defs) {
677
2321
  const slot = state();
678
- slots.set(def.key, slot);
679
- Object.defineProperty(props, def.key, {
2322
+ slots.set(def.name, slot);
2323
+ Object.defineProperty(props, def.name, {
680
2324
  configurable: false,
681
2325
  enumerable: true,
682
2326
  get() {
@@ -715,7 +2359,7 @@ function defineElement(tagName, options, setup) {
715
2359
  setup,
716
2360
  propDefs
717
2361
  };
718
- const observedAttributes = propDefs.filter((def) => def.attr !== false).map((def) => def.attr);
2362
+ const observedAttributes = getCustomElementObservedAttributes(propDefs);
719
2363
  class ZeusElement extends HTMLElement {
720
2364
  static get observedAttributes() {
721
2365
  return observedAttributes;
@@ -724,7 +2368,8 @@ function defineElement(tagName, options, setup) {
724
2368
  super();
725
2369
  this.lightChildren = [];
726
2370
  this.capturedLightChildren = false;
727
- this.reflecting = false;
2371
+ this.attributeProps = /* @__PURE__ */ new Set();
2372
+ this.reflectingAttrs = /* @__PURE__ */ new Set();
728
2373
  this.propStore = createPropStore(propDefs);
729
2374
  this.props = this.propStore.props;
730
2375
  applyPropDefaults(this.propStore, propDefs);
@@ -736,17 +2381,23 @@ function defineElement(tagName, options, setup) {
736
2381
  emit: createEmitApi(this, options.emits),
737
2382
  expose: createExpose(this)
738
2383
  };
2384
+ this.mountLifecycle = createCustomElementMountLifecycle(() => this.mountElement());
739
2385
  }
740
2386
  connectedCallback() {
2387
+ this.mountLifecycle.connect();
2388
+ }
2389
+ disconnectedCallback() {
2390
+ this.mountLifecycle.disconnect();
2391
+ }
2392
+ mountElement() {
741
2393
  var _options$shadow, _options$consumes;
742
- if (this.dispose) return;
743
2394
  const shadow = (_options$shadow = options.shadow) !== null && _options$shadow !== void 0 ? _options$shadow : false;
744
2395
  const mode = shadow ? "shadow" : "light";
745
2396
  if (mode === "light" && !this.capturedLightChildren) {
746
2397
  this.lightChildren = Array.from(this.childNodes);
747
2398
  this.capturedLightChildren = true;
748
2399
  }
749
- this.syncAttributesToProps(propDefs);
2400
+ const projection = mode === "light" ? createLightDomProjection(this, this.lightChildren) : void 0;
750
2401
  const owner = createOwner();
751
2402
  for (const context of (_options$consumes = options.consumes) !== null && _options$consumes !== void 0 ? _options$consumes : []) {
752
2403
  const resolved = resolveDOMContext(this, context);
@@ -757,18 +2408,19 @@ function defineElement(tagName, options, setup) {
757
2408
  const hostContext = {
758
2409
  host: this,
759
2410
  mode,
760
- lightChildren: this.lightChildren
2411
+ lightChildren: this.lightChildren,
2412
+ projection
761
2413
  };
762
- this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => {
2414
+ const dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => {
763
2415
  syncFormValue(this.props, this.setupContext, options.form);
764
2416
  return setup(this.props, this.setupContext);
765
2417
  })), target, { owner });
766
2418
  mountStyles(target, options.styles);
767
- }
768
- disconnectedCallback() {
769
- var _this$dispose;
770
- (_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
771
- this.dispose = void 0;
2419
+ projection === null || projection === void 0 || projection.connect();
2420
+ return { dispose() {
2421
+ projection === null || projection === void 0 || projection.disconnect();
2422
+ dispose();
2423
+ } };
772
2424
  }
773
2425
  formAssociatedCallback(form) {
774
2426
  var _options$form, _options$form$associa;
@@ -787,10 +2439,11 @@ function defineElement(tagName, options, setup) {
787
2439
  (_options$form4 = options.form) === null || _options$form4 === void 0 || (_options$form4$stateR = _options$form4.stateRestore) === null || _options$form4$stateR === void 0 || _options$form4$stateR.call(_options$form4, state, mode, this.props, this.setupContext);
788
2440
  }
789
2441
  attributeChangedCallback(name, oldValue, newValue) {
790
- if (oldValue === newValue || this.reflecting) return;
791
- const def = propDefs.find((item) => item.attr === name);
2442
+ if (oldValue === newValue || this.reflectingAttrs.has(name)) return;
2443
+ const def = propDefs.find((item) => item.attrName === name);
792
2444
  if (!def) return;
793
- this.propStore.set(def.key, castAttributeValue(newValue, def));
2445
+ this.attributeProps.add(def.name);
2446
+ this.propStore.set(def.name, coerceCustomElementAttribute(def, newValue));
794
2447
  }
795
2448
  resolveRenderTarget(shadow) {
796
2449
  if (this.target) return this.target;
@@ -801,24 +2454,11 @@ function defineElement(tagName, options, setup) {
801
2454
  this.target = this.attachShadow(typeof shadow === "object" ? shadow : { mode: "open" });
802
2455
  return this.target;
803
2456
  }
804
- syncAttributesToProps(defs) {
805
- for (const def of defs) {
806
- if (def.attr === false) continue;
807
- const value = this.getAttribute(def.attr);
808
- if (value !== null || def.type === Boolean) this.propStore.set(def.key, castAttributeValue(value, def));
809
- }
810
- }
811
2457
  _writePropFromProperty(key, value) {
812
- const def = propDefs.find((item) => item.key === key);
2458
+ const def = propDefs.find((item) => item.name === key);
2459
+ this.attributeProps.delete(key);
813
2460
  this.propStore.set(key, value);
814
- if ((def === null || def === void 0 ? void 0 : def.reflect) && def.attr !== false) {
815
- this.reflecting = true;
816
- try {
817
- reflectPropToAttribute(this, def, value);
818
- } finally {
819
- this.reflecting = false;
820
- }
821
- }
2461
+ if (def === null || def === void 0 ? void 0 : def.reflect) reflectCustomElementProperty(this, def, value, this.reflectingAttrs);
822
2462
  }
823
2463
  }
824
2464
  ZeusElement.formAssociated = Boolean(options.formAssociated);
@@ -841,13 +2481,13 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
841
2481
  applyPropDefaults(propStore, propDefs);
842
2482
  for (const def of propDefs) {
843
2483
  var _mountState$attribute;
844
- if (def.attr !== false && ((_mountState$attribute = mountState.attributeProps) === null || _mountState$attribute === void 0 ? void 0 : _mountState$attribute.has(def.key))) {
845
- propStore.set(def.key, castAttributeValue(host.getAttribute(def.attr), def));
846
- initialValues.set(def.key, propStore.get(def.key));
2484
+ if (def.attrName !== false && ((_mountState$attribute = mountState.attributeProps) === null || _mountState$attribute === void 0 ? void 0 : _mountState$attribute.has(def.name))) {
2485
+ propStore.set(def.name, coerceCustomElementAttribute(def, host.getAttribute(def.attrName)));
2486
+ initialValues.set(def.name, propStore.get(def.name));
847
2487
  continue;
848
2488
  }
849
- if (initialValues.has(def.key)) {
850
- propStore.set(def.key, initialValues.get(def.key));
2489
+ if (initialValues.has(def.name)) {
2490
+ propStore.set(def.name, initialValues.get(def.name));
851
2491
  continue;
852
2492
  }
853
2493
  /**
@@ -855,11 +2495,11 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
855
2495
  * back to the lazy host value map so that `element.propName` returns the
856
2496
  * correct default value rather than undefined.
857
2497
  */
858
- initialValues.set(def.key, propStore.get(def.key));
2498
+ initialValues.set(def.name, propStore.get(def.name));
859
2499
  }
860
2500
  for (const def of propDefs) {
861
2501
  var _mountState$attribute2;
862
- if (def.reflect && def.serialize && !((_mountState$attribute2 = mountState.attributeProps) === null || _mountState$attribute2 === void 0 ? void 0 : _mountState$attribute2.has(def.key))) reflectExternalProp(host, def, propStore.get(def.key), mountState.reflectingAttrs);
2502
+ if (def.reflect && def.serialize && !((_mountState$attribute2 = mountState.attributeProps) === null || _mountState$attribute2 === void 0 ? void 0 : _mountState$attribute2.has(def.name))) reflectCustomElementProperty(host, def, propStore.get(def.name), mountState.reflectingAttrs);
863
2503
  }
864
2504
  const shadow = (_options$shadow2 = options.shadow) !== null && _options$shadow2 !== void 0 ? _options$shadow2 : false;
865
2505
  const mode = shadow ? "shadow" : "light";
@@ -868,6 +2508,7 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
868
2508
  mountState.capturedLightChildren = true;
869
2509
  }
870
2510
  const lightChildren = (_mountState$lightChil = mountState.lightChildren) !== null && _mountState$lightChil !== void 0 ? _mountState$lightChil : [];
2511
+ const projection = mode === "light" ? createLightDomProjection(host, lightChildren) : void 0;
871
2512
  const owner = createOwner();
872
2513
  for (const context of (_options$consumes2 = options.consumes) !== null && _options$consumes2 !== void 0 ? _options$consumes2 : []) {
873
2514
  const resolved = resolveDOMContext(host, context);
@@ -878,7 +2519,8 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
878
2519
  const hostContext = {
879
2520
  host,
880
2521
  mode,
881
- lightChildren
2522
+ lightChildren,
2523
+ projection
882
2524
  };
883
2525
  const setupContext = {
884
2526
  host,
@@ -892,15 +2534,16 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
892
2534
  return setup(propStore.props, setupContext);
893
2535
  })), target, { owner });
894
2536
  mountStyles(target, options.styles);
2537
+ projection === null || projection === void 0 || projection.connect();
895
2538
  return {
896
2539
  propertyChanged(name, _oldValue, newValue) {
897
2540
  var _mountState$attribute3;
898
- const def = propDefs.find((item) => item.key === name);
899
- const fromAttribute = Boolean((def === null || def === void 0 ? void 0 : def.attr) !== false && ((_mountState$attribute3 = mountState.attributeProps) === null || _mountState$attribute3 === void 0 ? void 0 : _mountState$attribute3.has(name)));
900
- const value = fromAttribute && def ? castAttributeValue(typeof newValue === "string" ? newValue : null, def) : newValue;
2541
+ const def = propDefs.find((item) => item.name === name);
2542
+ const fromAttribute = Boolean((def === null || def === void 0 ? void 0 : def.attrName) !== false && ((_mountState$attribute3 = mountState.attributeProps) === null || _mountState$attribute3 === void 0 ? void 0 : _mountState$attribute3.has(name)));
2543
+ const value = fromAttribute && def ? coerceCustomElementAttribute(def, typeof newValue === "string" ? newValue : null) : newValue;
901
2544
  propStore.set(name, value);
902
2545
  initialValues.set(name, value);
903
- if ((def === null || def === void 0 ? void 0 : def.reflect) && !fromAttribute) reflectExternalProp(host, def, value, mountState.reflectingAttrs);
2546
+ if ((def === null || def === void 0 ? void 0 : def.reflect) && !fromAttribute) reflectCustomElementProperty(host, def, value, mountState.reflectingAttrs);
904
2547
  },
905
2548
  formAssociated(form) {
906
2549
  var _options$form5, _options$form5$associ;
@@ -919,6 +2562,7 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
919
2562
  (_options$form8 = options.form) === null || _options$form8 === void 0 || (_options$form8$stateR = _options$form8.stateRestore) === null || _options$form8$stateR === void 0 || _options$form8$stateR.call(_options$form8, state, mode, propStore.props, setupContext);
920
2563
  },
921
2564
  dispose() {
2565
+ projection === null || projection === void 0 || projection.disconnect();
922
2566
  dispose();
923
2567
  }
924
2568
  };
@@ -930,18 +2574,18 @@ function normalizePropDefinitions(props) {
930
2574
  if (typeof input === "function") {
931
2575
  const type = input;
932
2576
  return {
933
- key: propKey,
934
- attr: isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false,
935
- type,
2577
+ name: propKey,
2578
+ attrName: isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false,
2579
+ type: normalizePropType(type),
936
2580
  reflect: false
937
2581
  };
938
2582
  }
939
2583
  const type = input === null || input === void 0 ? void 0 : input.type;
940
2584
  const defaultAttr = isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false;
941
2585
  return {
942
- key: propKey,
943
- attr: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? defaultAttr : input.attr,
944
- type,
2586
+ name: propKey,
2587
+ attrName: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? defaultAttr : input.attr,
2588
+ type: normalizePropType(type),
945
2589
  reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
946
2590
  default: input === null || input === void 0 ? void 0 : input.default,
947
2591
  serialize: input === null || input === void 0 ? void 0 : input.serialize,
@@ -953,12 +2597,12 @@ function applyPropDefaults(store, defs) {
953
2597
  for (const def of defs) {
954
2598
  if (!("default" in def)) continue;
955
2599
  const value = typeof def.default === "function" ? def.default() : def.default;
956
- store.set(def.key, value);
2600
+ store.set(def.name, value);
957
2601
  }
958
2602
  }
959
2603
  function definePropAccessors(element, store, defs) {
960
2604
  for (const def of defs) {
961
- const key = def.key;
2605
+ const key = def.name;
962
2606
  const hadOwnValue = Object.prototype.hasOwnProperty.call(element, key);
963
2607
  const ownValue = hadOwnValue ? element[key] : void 0;
964
2608
  if (hadOwnValue) delete element[key];
@@ -980,54 +2624,6 @@ function definePropAccessors(element, store, defs) {
980
2624
  if (hadOwnValue) element._writePropFromProperty(key, ownValue);
981
2625
  }
982
2626
  }
983
- function castAttributeValue(value, def) {
984
- if (def.deserialize) return def.deserialize(value);
985
- if (def.type === Boolean) return value !== null;
986
- if (value === null) return;
987
- if (def.type === Number) return Number(value);
988
- if (def.type === Object || def.type === Array) try {
989
- return JSON.parse(value);
990
- } catch (_unused) {
991
- console.warn(`[Zeus custom-element] Failed to parse JSON attribute "${def.attr}".`);
992
- return def.type === Array ? [] : {};
993
- }
994
- if (def.type === Function) return;
995
- return value;
996
- }
997
- function reflectPropToAttribute(element, def, value) {
998
- if (def.attr === false) return;
999
- if (def.serialize) {
1000
- const serialized = def.serialize(value);
1001
- if (serialized == null) element.removeAttribute(def.attr);
1002
- else element.setAttribute(def.attr, serialized);
1003
- return;
1004
- }
1005
- if (def.type === Boolean) {
1006
- if (value) element.setAttribute(def.attr, "");
1007
- else element.removeAttribute(def.attr);
1008
- return;
1009
- }
1010
- if (value == null) {
1011
- element.removeAttribute(def.attr);
1012
- return;
1013
- }
1014
- if (def.type === Object || def.type === Array) {
1015
- element.setAttribute(def.attr, JSON.stringify(value));
1016
- return;
1017
- }
1018
- if (def.type === Function) return;
1019
- element.setAttribute(def.attr, String(value));
1020
- }
1021
- function reflectExternalProp(element, def, value, reflectingAttrs) {
1022
- if (def.attr === false) return;
1023
- const attrName = def.attr.toLowerCase();
1024
- reflectingAttrs === null || reflectingAttrs === void 0 || reflectingAttrs.add(attrName);
1025
- try {
1026
- reflectPropToAttribute(element, def, value);
1027
- } finally {
1028
- reflectingAttrs === null || reflectingAttrs === void 0 || reflectingAttrs.delete(attrName);
1029
- }
1030
- }
1031
2627
  function syncFormValue(props, context, form) {
1032
2628
  const valueResolver = form === null || form === void 0 ? void 0 : form.value;
1033
2629
  const stateResolver = form === null || form === void 0 ? void 0 : form.state;
@@ -1089,6 +2685,15 @@ function createExpose(host) {
1089
2685
  function isAttributeBackedConstructor(type) {
1090
2686
  return type === String || type === Number || type === Boolean;
1091
2687
  }
2688
+ function normalizePropType(type) {
2689
+ if (type === String) return "string";
2690
+ if (type === Number) return "number";
2691
+ if (type === Boolean) return "boolean";
2692
+ if (type === Object) return "object";
2693
+ if (type === Array) return "array";
2694
+ if (type === Function) return "function";
2695
+ return "unknown";
2696
+ }
1092
2697
  function resolveExternalRenderTarget(host, shadow) {
1093
2698
  var _host$shadowRoot;
1094
2699
  if (!shadow) return host;
@@ -1107,38 +2712,6 @@ function toKebabCase(value) {
1107
2712
  return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
1108
2713
  }
1109
2714
  //#endregion
1110
- //#region packages/core/runtime-dom/src/slot.ts
1111
- function createSlot(name, fallback) {
1112
- const context = getCurrentHostContext();
1113
- if (!context) return createNativeSlot(name, fallback);
1114
- if (context.mode === "shadow") return createNativeSlot(name, fallback);
1115
- const assigned = findLightSlotNodes(context.lightChildren, name);
1116
- if (assigned.length > 0) return Array.from(assigned);
1117
- return fallback ? fallback() : null;
1118
- }
1119
- function createNativeSlot(name, fallback) {
1120
- const slot = document.createElement("slot");
1121
- if (name) slot.setAttribute("name", name);
1122
- const fallbackValue = fallback === null || fallback === void 0 ? void 0 : fallback();
1123
- if (fallbackValue != null) insert(slot, fallbackValue);
1124
- return slot;
1125
- }
1126
- function findLightSlotNodes(nodes, name) {
1127
- if (name) return nodes.filter((node) => {
1128
- if (node.nodeType !== Node.ELEMENT_NODE) return false;
1129
- return node.getAttribute("slot") === name;
1130
- });
1131
- return nodes.filter((node) => {
1132
- if (node.nodeType === Node.ELEMENT_NODE) return !node.hasAttribute("slot");
1133
- return isMeaningfulTextNode(node);
1134
- });
1135
- }
1136
- function isMeaningfulTextNode(node) {
1137
- var _node$textContent;
1138
- if (node.nodeType !== Node.TEXT_NODE) return false;
1139
- return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
1140
- }
1141
- //#endregion
1142
2715
  //#region packages/core/runtime-dom/src/webComponents.ts
1143
2716
  const HOST_RESERVED_KEYS = /* @__PURE__ */ new Set([
1144
2717
  "children",
@@ -1230,4 +2803,4 @@ function normalizeHostAttrName(name) {
1230
2803
  }
1231
2804
  }
1232
2805
  //#endregion
1233
- export { For, Host, Show, Slot, ZEUS_CONTEXT_REQUEST, ZEUS_ELEMENT_DEFINITION, bindAttr, bindClass, bindEvent, bindProp, bindRef, bindStyle, bindText, bindTextContent, captureCurrentHostContext, child, createComponent, createContext, createDOMContextBoundary, createOwner, createSlot, defineElement, delegateEvents, event, getCurrentHostContext, getCurrentOwner, getElementDefinition, inject, insert, insertTracked, marker, mountDynamic, mountElementDefinition, mountFor, mountShow, normalizeClass, prop, provide, provideDOMContext, removeNodes, render, resolveDOMContext, resolveValue, runWithOwner, setAttr, setRef, template, useContext, withCapturedHostContext, withHostContext };
2806
+ export { For, Host, Show, Slot, ZEUS_CONTEXT_REQUEST, ZEUS_ELEMENT_DEFINITION, bindAttr, bindClass, bindEvent, bindProp, bindRef, bindStyle, bindText, bindTextContent, captureCurrentHostContext, child, coerceCustomElementAttribute, createComponent, createContext, createCustomElementMountLifecycle, createDOMContextBoundary, createOwner, createSlot, defineElement, delegateEvents, event, findCustomElementPropByAttribute, getCurrentHostContext, getCurrentOwner, getCustomElementAttributeName, getCustomElementObservedAttributes, getElementDefinition, inject, insert, insertTracked, marker, mountDynamic, mountElementDefinition, mountFor, mountShow, normalizeClass, prop, provide, provideDOMContext, reflectCustomElementProperty, removeNodes, render, resolveDOMContext, resolveValue, runWithOwner, setAttr, setRef, template, useContext, withCapturedHostContext, withHostContext };