@zeus-js/zeus 0.0.2

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.
@@ -0,0 +1,2190 @@
1
+ /**
2
+ * zeus v0.0.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ //#region packages/shared/src/makeMap.ts
7
+ /**
8
+ * Make a map and return a function for checking if a key
9
+ * is in that map.
10
+ * IMPORTANT: all calls of this function must be prefixed with
11
+ * \/\*#\_\_PURE\_\_\*\/
12
+ * So that rollup can tree-shake them if necessary.
13
+ */
14
+ /*@__NO_SIDE_EFFECTS__*/
15
+ function makeMap(str) {
16
+ const map = Object.create(null);
17
+ for (const key of str.split(",")) map[key] = 1;
18
+ return (val) => val in map;
19
+ }
20
+ //#endregion
21
+ //#region packages/shared/src/general.ts
22
+ const EMPTY_OBJ = Object.freeze({});
23
+ Object.freeze([]);
24
+ const NOOP = () => {};
25
+ const extend = Object.assign;
26
+ const remove = (arr, el) => {
27
+ const i = arr.indexOf(el);
28
+ if (i > -1) arr.splice(i, 1);
29
+ };
30
+ const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
31
+ const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
32
+ const isArray = Array.isArray;
33
+ const isMap = (val) => toTypeString(val) === "[object Map]";
34
+ const isSet = (val) => toTypeString(val) === "[object Set]";
35
+ const isFunction = (val) => typeof val === "function";
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 isPlainObject$1 = (val) => toTypeString(val) === "[object Object]";
45
+ const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
46
+ const cacheStringFunction = (fn) => {
47
+ const cache = Object.create(null);
48
+ return ((str) => {
49
+ return cache[str] || (cache[str] = fn(str));
50
+ });
51
+ };
52
+ /**
53
+ * @private
54
+ */
55
+ const capitalize = cacheStringFunction((str) => {
56
+ return str.charAt(0).toUpperCase() + str.slice(1);
57
+ });
58
+ const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
59
+ //#endregion
60
+ //#region packages/signal/src/warning.ts
61
+ function warn(msg, ...args) {
62
+ console.warn(`[Zeus warn] ${msg}`, ...args);
63
+ }
64
+ //#endregion
65
+ //#region packages/signal/src/effectScope.ts
66
+ let activeEffectScope;
67
+ var EffectScope = class {
68
+ constructor(detached = false) {
69
+ this.detached = detached;
70
+ this._active = true;
71
+ this._on = 0;
72
+ this.effects = [];
73
+ this.cleanups = [];
74
+ this._isPaused = false;
75
+ this._warnOnRun = true;
76
+ this.__v_skip = true;
77
+ if (!detached && activeEffectScope) if (activeEffectScope.active) {
78
+ this.parent = activeEffectScope;
79
+ this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
80
+ } else {
81
+ this._active = false;
82
+ this._warnOnRun = false;
83
+ }
84
+ }
85
+ get active() {
86
+ return this._active;
87
+ }
88
+ pause() {
89
+ if (this._active) {
90
+ this._isPaused = true;
91
+ let i, l;
92
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].pause();
93
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].pause();
94
+ }
95
+ }
96
+ /**
97
+ * Resumes the effect scope, including all child scopes and effects.
98
+ */
99
+ resume() {
100
+ if (this._active) {
101
+ if (this._isPaused) {
102
+ this._isPaused = false;
103
+ let i, l;
104
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].resume();
105
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].resume();
106
+ }
107
+ }
108
+ }
109
+ run(fn) {
110
+ if (this._active) {
111
+ const currentEffectScope = activeEffectScope;
112
+ try {
113
+ activeEffectScope = this;
114
+ return fn();
115
+ } finally {
116
+ activeEffectScope = currentEffectScope;
117
+ }
118
+ } else if (this._warnOnRun) warn(`cannot run an inactive effect scope.`);
119
+ }
120
+ /**
121
+ * This should only be called on non-detached scopes
122
+ * @internal
123
+ */
124
+ on() {
125
+ if (++this._on === 1) {
126
+ this.prevScope = activeEffectScope;
127
+ activeEffectScope = this;
128
+ }
129
+ }
130
+ /**
131
+ * This should only be called on non-detached scopes
132
+ * @internal
133
+ */
134
+ off() {
135
+ if (this._on > 0 && --this._on === 0) {
136
+ if (activeEffectScope === this) activeEffectScope = this.prevScope;
137
+ else {
138
+ let current = activeEffectScope;
139
+ while (current) {
140
+ if (current.prevScope === this) {
141
+ current.prevScope = this.prevScope;
142
+ break;
143
+ }
144
+ current = current.prevScope;
145
+ }
146
+ }
147
+ this.prevScope = void 0;
148
+ }
149
+ }
150
+ stop(fromParent) {
151
+ if (this._active) {
152
+ this._active = false;
153
+ let i, l;
154
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop();
155
+ this.effects.length = 0;
156
+ for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i]();
157
+ this.cleanups.length = 0;
158
+ if (this.scopes) {
159
+ for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true);
160
+ this.scopes.length = 0;
161
+ }
162
+ if (!this.detached && this.parent && !fromParent) {
163
+ const last = this.parent.scopes.pop();
164
+ if (last && last !== this) {
165
+ this.parent.scopes[this.index] = last;
166
+ last.index = this.index;
167
+ }
168
+ }
169
+ this.parent = void 0;
170
+ }
171
+ }
172
+ };
173
+ /**
174
+ * Creates an effect scope object which can capture the reactive effects (i.e.
175
+ * computed and watchers) created within it so that these effects can be
176
+ * disposed together. For detailed use cases of this API, please consult its
177
+ * corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
178
+ *
179
+ * @param detached - Can be used to create a "detached" effect scope.
180
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
181
+ */
182
+ function effectScope(detached) {
183
+ return new EffectScope(detached);
184
+ }
185
+ /**
186
+ * Returns the current active effect scope if there is one.
187
+ *
188
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
189
+ */
190
+ function getCurrentScope() {
191
+ return activeEffectScope;
192
+ }
193
+ /**
194
+ * Registers a dispose callback on the current active effect scope. The
195
+ * callback will be invoked when the associated effect scope is stopped.
196
+ *
197
+ * @param fn - The callback function to attach to the scope's cleanup.
198
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
199
+ */
200
+ function onScopeDispose(fn, failSilently = false) {
201
+ if (activeEffectScope) activeEffectScope.cleanups.push(fn);
202
+ else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
203
+ }
204
+ //#endregion
205
+ //#region packages/signal/src/effect.ts
206
+ let activeSub;
207
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
208
+ var ReactiveEffect = class {
209
+ constructor(fn) {
210
+ this.fn = fn;
211
+ this.deps = void 0;
212
+ this.depsTail = void 0;
213
+ this.flags = 5;
214
+ this.next = void 0;
215
+ this.cleanup = void 0;
216
+ this.scheduler = void 0;
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
+ if (sub._dirty) return true;
369
+ return false;
370
+ }
371
+ /**
372
+ * Returning false indicates the refresh failed
373
+ * @internal
374
+ */
375
+ function refreshComputed(computed) {
376
+ if (computed.flags & 4 && !(computed.flags & 16)) return;
377
+ computed.flags &= -17;
378
+ if (computed.globalVersion === globalVersion) return;
379
+ computed.globalVersion = globalVersion;
380
+ if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) return;
381
+ computed.flags |= 2;
382
+ const dep = computed.dep;
383
+ const prevSub = activeSub;
384
+ const prevShouldTrack = shouldTrack;
385
+ activeSub = computed;
386
+ shouldTrack = true;
387
+ try {
388
+ prepareDeps(computed);
389
+ const value = computed.fn(computed._value);
390
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
391
+ computed.flags |= 128;
392
+ computed._value = value;
393
+ dep.version++;
394
+ }
395
+ } catch (err) {
396
+ dep.version++;
397
+ throw err;
398
+ } finally {
399
+ activeSub = prevSub;
400
+ shouldTrack = prevShouldTrack;
401
+ cleanupDeps(computed);
402
+ computed.flags &= -3;
403
+ }
404
+ }
405
+ function removeSub(link, soft = false) {
406
+ const { dep, prevSub, nextSub } = link;
407
+ if (prevSub) {
408
+ prevSub.nextSub = nextSub;
409
+ link.prevSub = void 0;
410
+ }
411
+ if (nextSub) {
412
+ nextSub.prevSub = prevSub;
413
+ link.nextSub = void 0;
414
+ }
415
+ if (dep.subsHead === link) dep.subsHead = nextSub;
416
+ if (dep.subs === link) {
417
+ dep.subs = prevSub;
418
+ if (!prevSub && dep.computed) {
419
+ dep.computed.flags &= -5;
420
+ for (let l = dep.computed.deps; l; l = l.nextDep) removeSub(l, true);
421
+ }
422
+ }
423
+ if (!soft && !--dep.sc && dep.map) dep.map.delete(dep.key);
424
+ }
425
+ function removeDep(link) {
426
+ const { prevDep, nextDep } = link;
427
+ if (prevDep) {
428
+ prevDep.nextDep = nextDep;
429
+ link.prevDep = void 0;
430
+ }
431
+ if (nextDep) {
432
+ nextDep.prevDep = prevDep;
433
+ link.nextDep = void 0;
434
+ }
435
+ }
436
+ function effect(fn, options) {
437
+ if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
438
+ const e = new ReactiveEffect(fn);
439
+ if (options) extend(e, options);
440
+ try {
441
+ e.run();
442
+ } catch (err) {
443
+ e.stop();
444
+ throw err;
445
+ }
446
+ const runner = e.run.bind(e);
447
+ runner.effect = e;
448
+ return runner;
449
+ }
450
+ /**
451
+ * @internal
452
+ */
453
+ let shouldTrack = true;
454
+ const trackStack = [];
455
+ /**
456
+ * Temporarily pauses tracking.
457
+ */
458
+ function pauseTracking() {
459
+ trackStack.push(shouldTrack);
460
+ shouldTrack = false;
461
+ }
462
+ /**
463
+ * Resets the previous global effect tracking state.
464
+ */
465
+ function resetTracking() {
466
+ const last = trackStack.pop();
467
+ shouldTrack = last === void 0 ? true : last;
468
+ }
469
+ /**
470
+ * Registers a cleanup function for the current active effect.
471
+ * The cleanup function is called right before the next effect run, or when the
472
+ * effect is stopped.
473
+ *
474
+ * Throws a warning if there is no current active effect. The warning can be
475
+ * suppressed by passing `true` to the second argument.
476
+ *
477
+ * @param fn - the cleanup function to be registered
478
+ * @param failSilently - if `true`, will not throw warning when called without
479
+ * an active effect.
480
+ */
481
+ function onEffectCleanup(fn, failSilently = false) {
482
+ if (activeSub instanceof ReactiveEffect) activeSub.cleanup = fn;
483
+ else if (!failSilently) warn("onEffectCleanup() was called when there was no active effect to associate with.");
484
+ }
485
+ function cleanupEffect(e) {
486
+ const { cleanup } = e;
487
+ e.cleanup = void 0;
488
+ if (cleanup) {
489
+ const prevSub = activeSub;
490
+ activeSub = void 0;
491
+ try {
492
+ cleanup();
493
+ } finally {
494
+ activeSub = prevSub;
495
+ }
496
+ }
497
+ }
498
+ /**
499
+ * Batches reactive updates synchronously within the given function.
500
+ * All updates triggered inside `fn` are deferred until the function completes,
501
+ * then flushed together in a single batch.
502
+ */
503
+ function batch(fn) {
504
+ startBatch();
505
+ try {
506
+ return fn();
507
+ } finally {
508
+ endBatch();
509
+ }
510
+ }
511
+ /**
512
+ * Executes the given function without tracking reactive dependencies.
513
+ * Any reactive reads inside `fn` will not trigger effect re-runs.
514
+ */
515
+ function untrack(fn) {
516
+ pauseTracking();
517
+ try {
518
+ return fn();
519
+ } finally {
520
+ resetTracking();
521
+ }
522
+ }
523
+ /**
524
+ * Returns the currently executing reactive effect, if any.
525
+ */
526
+ function getCurrentEffect() {
527
+ return activeSub instanceof ReactiveEffect ? activeSub : void 0;
528
+ }
529
+ //#endregion
530
+ //#region packages/signal/src/dep.ts
531
+ /**
532
+ * Incremented every time a reactive change happens
533
+ * This is used to give computed a fast path to avoid re-compute when nothing
534
+ * has changed.
535
+ */
536
+ let globalVersion = 0;
537
+ /**
538
+ * Represents a link between a source (Dep) and a subscriber (Effect or Computed).
539
+ * Deps and subs have a many-to-many relationship - each link between a
540
+ * dep and a sub is represented by a Link instance.
541
+ *
542
+ * A Link is also a node in two doubly-linked lists - one for the associated
543
+ * sub to track all its deps, and one for the associated dep to track all its
544
+ * subs.
545
+ *
546
+ * @internal
547
+ */
548
+ var Link = class {
549
+ constructor(sub, dep) {
550
+ this.sub = sub;
551
+ this.dep = dep;
552
+ this.version = dep.version;
553
+ this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
554
+ }
555
+ };
556
+ /**
557
+ * @internal
558
+ */
559
+ var Dep = class {
560
+ constructor(computed) {
561
+ this.computed = computed;
562
+ this.version = 0;
563
+ this.activeLink = void 0;
564
+ this.subs = void 0;
565
+ this.map = void 0;
566
+ this.key = void 0;
567
+ this.sc = 0;
568
+ this.__v_skip = true;
569
+ this.subsHead = void 0;
570
+ }
571
+ track(debugInfo) {
572
+ if (!activeSub || !shouldTrack || activeSub === this.computed) return;
573
+ let link = this.activeLink;
574
+ if (link === void 0 || link.sub !== activeSub) {
575
+ link = this.activeLink = new Link(activeSub, this);
576
+ if (!activeSub.deps) activeSub.deps = activeSub.depsTail = link;
577
+ else {
578
+ link.prevDep = activeSub.depsTail;
579
+ activeSub.depsTail.nextDep = link;
580
+ activeSub.depsTail = link;
581
+ }
582
+ addSub(link);
583
+ } else if (link.version === -1) {
584
+ link.version = this.version;
585
+ if (link.nextDep) {
586
+ const next = link.nextDep;
587
+ next.prevDep = link.prevDep;
588
+ if (link.prevDep) link.prevDep.nextDep = next;
589
+ link.prevDep = activeSub.depsTail;
590
+ link.nextDep = void 0;
591
+ activeSub.depsTail.nextDep = link;
592
+ activeSub.depsTail = link;
593
+ if (activeSub.deps === link) activeSub.deps = next;
594
+ }
595
+ }
596
+ if (activeSub.onTrack) activeSub.onTrack(extend({ effect: activeSub }, debugInfo));
597
+ return link;
598
+ }
599
+ trigger(debugInfo) {
600
+ this.version++;
601
+ globalVersion++;
602
+ this.notify(debugInfo);
603
+ }
604
+ notify(debugInfo) {
605
+ startBatch();
606
+ try {
607
+ 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));
608
+ for (let link = this.subs; link; link = link.prevSub) if (link.sub.notify()) link.sub.dep.notify();
609
+ } finally {
610
+ endBatch();
611
+ }
612
+ }
613
+ };
614
+ function addSub(link) {
615
+ link.dep.sc++;
616
+ if (link.sub.flags & 4) {
617
+ const computed = link.dep.computed;
618
+ if (computed && !link.dep.subs) {
619
+ computed.flags |= 20;
620
+ for (let l = computed.deps; l; l = l.nextDep) addSub(l);
621
+ }
622
+ const currentTail = link.dep.subs;
623
+ if (currentTail !== link) {
624
+ link.prevSub = currentTail;
625
+ if (currentTail) currentTail.nextSub = link;
626
+ }
627
+ if (link.dep.subsHead === void 0) link.dep.subsHead = link;
628
+ link.dep.subs = link;
629
+ }
630
+ }
631
+ const targetMap = /* @__PURE__ */ new WeakMap();
632
+ const ITERATE_KEY = Symbol("Object iterate");
633
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
634
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate");
635
+ /**
636
+ * Tracks access to a reactive property.
637
+ *
638
+ * This will check which effect is running at the moment and record it as dep
639
+ * which records all effects that depend on the reactive property.
640
+ *
641
+ * @param target - Object holding the reactive property.
642
+ * @param type - Defines the type of access to the reactive property.
643
+ * @param key - Identifier of the reactive property to track.
644
+ */
645
+ function track(target, type, key) {
646
+ if (shouldTrack && activeSub) {
647
+ let depsMap = targetMap.get(target);
648
+ if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
649
+ let dep = depsMap.get(key);
650
+ if (!dep) {
651
+ depsMap.set(key, dep = new Dep());
652
+ dep.map = depsMap;
653
+ dep.key = key;
654
+ }
655
+ dep.track({
656
+ target,
657
+ type,
658
+ key
659
+ });
660
+ }
661
+ }
662
+ /**
663
+ * Finds all deps associated with the target (or a specific property) and
664
+ * triggers the effects stored within.
665
+ *
666
+ * @param target - The reactive object.
667
+ * @param type - Defines the type of the operation that needs to trigger effects.
668
+ * @param key - Can be used to target a specific reactive property in the target object.
669
+ */
670
+ function trigger(target, type, key, newValue, oldValue, oldTarget) {
671
+ const depsMap = targetMap.get(target);
672
+ if (!depsMap) {
673
+ globalVersion++;
674
+ return;
675
+ }
676
+ const run = (dep) => {
677
+ if (dep) dep.trigger({
678
+ target,
679
+ type,
680
+ key,
681
+ newValue,
682
+ oldValue,
683
+ oldTarget
684
+ });
685
+ };
686
+ startBatch();
687
+ if (type === "clear") depsMap.forEach(run);
688
+ else {
689
+ const targetIsArray = isArray(target);
690
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
691
+ if (targetIsArray && key === "length") {
692
+ const newLength = Number(newValue);
693
+ depsMap.forEach((dep, key) => {
694
+ if (key === "length" || key === ARRAY_ITERATE_KEY || !isSymbol(key) && key >= newLength) run(dep);
695
+ });
696
+ } else {
697
+ if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key));
698
+ if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY));
699
+ switch (type) {
700
+ case "add":
701
+ if (!targetIsArray) {
702
+ run(depsMap.get(ITERATE_KEY));
703
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
704
+ } else if (isArrayIndex) run(depsMap.get("length"));
705
+ break;
706
+ case "delete":
707
+ if (!targetIsArray) {
708
+ run(depsMap.get(ITERATE_KEY));
709
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
710
+ }
711
+ break;
712
+ case "set":
713
+ if (isMap(target)) run(depsMap.get(ITERATE_KEY));
714
+ break;
715
+ }
716
+ }
717
+ }
718
+ endBatch();
719
+ }
720
+ //#endregion
721
+ //#region packages/signal/src/arrayInstrumentations.ts
722
+ /**
723
+ * Track array iteration and return:
724
+ * - if input is reactive: a cloned raw array with reactive values
725
+ * - if input is non-reactive or shallowReactive: the original raw array
726
+ */
727
+ function reactiveReadArray(array) {
728
+ const raw = /* @__PURE__ */ toRaw(array);
729
+ if (raw === array) return raw;
730
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
731
+ return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
732
+ }
733
+ /**
734
+ * Track array iteration and return raw array
735
+ */
736
+ function shallowReadArray(arr) {
737
+ track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
738
+ return arr;
739
+ }
740
+ function toWrapped(target, item) {
741
+ if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
742
+ return toReactive(item);
743
+ }
744
+ const arrayInstrumentations = {
745
+ __proto__: null,
746
+ [Symbol.iterator]() {
747
+ return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
748
+ },
749
+ concat(...args) {
750
+ return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
751
+ },
752
+ entries() {
753
+ return iterator(this, "entries", (value) => {
754
+ value[1] = toWrapped(this, value[1]);
755
+ return value;
756
+ });
757
+ },
758
+ every(fn, thisArg) {
759
+ return apply(this, "every", fn, thisArg, void 0, arguments);
760
+ },
761
+ filter(fn, thisArg) {
762
+ return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
763
+ },
764
+ find(fn, thisArg) {
765
+ return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
766
+ },
767
+ findIndex(fn, thisArg) {
768
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
769
+ },
770
+ findLast(fn, thisArg) {
771
+ return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
772
+ },
773
+ findLastIndex(fn, thisArg) {
774
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
775
+ },
776
+ forEach(fn, thisArg) {
777
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
778
+ },
779
+ includes(...args) {
780
+ return searchProxy(this, "includes", args);
781
+ },
782
+ indexOf(...args) {
783
+ return searchProxy(this, "indexOf", args);
784
+ },
785
+ join(separator) {
786
+ return reactiveReadArray(this).join(separator);
787
+ },
788
+ lastIndexOf(...args) {
789
+ return searchProxy(this, "lastIndexOf", args);
790
+ },
791
+ map(fn, thisArg) {
792
+ return apply(this, "map", fn, thisArg, void 0, arguments);
793
+ },
794
+ pop() {
795
+ return noTracking(this, "pop");
796
+ },
797
+ push(...args) {
798
+ return noTracking(this, "push", args);
799
+ },
800
+ reduce(fn, ...args) {
801
+ return reduce(this, "reduce", fn, args);
802
+ },
803
+ reduceRight(fn, ...args) {
804
+ return reduce(this, "reduceRight", fn, args);
805
+ },
806
+ shift() {
807
+ return noTracking(this, "shift");
808
+ },
809
+ some(fn, thisArg) {
810
+ return apply(this, "some", fn, thisArg, void 0, arguments);
811
+ },
812
+ splice(...args) {
813
+ return noTracking(this, "splice", args);
814
+ },
815
+ toReversed() {
816
+ return reactiveReadArray(this).toReversed();
817
+ },
818
+ toSorted(comparer) {
819
+ return reactiveReadArray(this).toSorted(comparer);
820
+ },
821
+ toSpliced(...args) {
822
+ return reactiveReadArray(this).toSpliced(...args);
823
+ },
824
+ unshift(...args) {
825
+ return noTracking(this, "unshift", args);
826
+ },
827
+ values() {
828
+ return iterator(this, "values", (item) => toWrapped(this, item));
829
+ }
830
+ };
831
+ function iterator(self, method, wrapValue) {
832
+ const arr = shallowReadArray(self);
833
+ const iter = arr[method]();
834
+ if (arr !== self && !/* @__PURE__ */ isShallow(self)) {
835
+ iter._next = iter.next;
836
+ iter.next = () => {
837
+ const result = iter._next();
838
+ if (!result.done) result.value = wrapValue(result.value);
839
+ return result;
840
+ };
841
+ }
842
+ return iter;
843
+ }
844
+ const arrayProto = Array.prototype;
845
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
846
+ const arr = shallowReadArray(self);
847
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
848
+ const methodFn = arr[method];
849
+ if (methodFn !== arrayProto[method]) {
850
+ const result = methodFn.apply(self, args);
851
+ return needsWrap ? toReactive(result) : result;
852
+ }
853
+ let wrappedFn = fn;
854
+ if (arr !== self) {
855
+ if (needsWrap) wrappedFn = function(item, index) {
856
+ return fn.call(this, toWrapped(self, item), index, self);
857
+ };
858
+ else if (fn.length > 2) wrappedFn = function(item, index) {
859
+ return fn.call(this, item, index, self);
860
+ };
861
+ }
862
+ const result = methodFn.call(arr, wrappedFn, thisArg);
863
+ return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
864
+ }
865
+ function reduce(self, method, fn, args) {
866
+ const arr = shallowReadArray(self);
867
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
868
+ let wrappedFn = fn;
869
+ let wrapInitialAccumulator = false;
870
+ if (arr !== self) {
871
+ if (needsWrap) {
872
+ wrapInitialAccumulator = args.length === 0;
873
+ wrappedFn = function(acc, item, index) {
874
+ if (wrapInitialAccumulator) {
875
+ wrapInitialAccumulator = false;
876
+ acc = toWrapped(self, acc);
877
+ }
878
+ return fn.call(this, acc, toWrapped(self, item), index, self);
879
+ };
880
+ } else if (fn.length > 3) wrappedFn = function(acc, item, index) {
881
+ return fn.call(this, acc, item, index, self);
882
+ };
883
+ }
884
+ const result = arr[method](wrappedFn, ...args);
885
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
886
+ }
887
+ function searchProxy(self, method, args) {
888
+ const arr = /* @__PURE__ */ toRaw(self);
889
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
890
+ const res = arr[method](...args);
891
+ if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) {
892
+ args[0] = /* @__PURE__ */ toRaw(args[0]);
893
+ return arr[method](...args);
894
+ }
895
+ return res;
896
+ }
897
+ function noTracking(self, method, args = []) {
898
+ pauseTracking();
899
+ startBatch();
900
+ const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args);
901
+ endBatch();
902
+ resetTracking();
903
+ return res;
904
+ }
905
+ //#endregion
906
+ //#region packages/signal/src/ref.ts
907
+ let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
908
+ /*@__NO_SIDE_EFFECTS__*/
909
+ function isRef(r) {
910
+ return r ? r["__v_isRef"] === true : false;
911
+ }
912
+ /*@__NO_SIDE_EFFECTS__*/
913
+ function ref(value) {
914
+ return createRef(value, false);
915
+ }
916
+ function createRef(rawValue, shallow) {
917
+ if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
918
+ return new RefImpl(rawValue, shallow);
919
+ }
920
+ _ReactiveFlags$IS_REF = "__v_isRef";
921
+ _ReactiveFlags$IS_SHA = "__v_isShallow";
922
+ /**
923
+ * @internal
924
+ */
925
+ var RefImpl = class {
926
+ constructor(value, isShallow) {
927
+ this.dep = new Dep();
928
+ this[_ReactiveFlags$IS_REF] = true;
929
+ this[_ReactiveFlags$IS_SHA] = false;
930
+ this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
931
+ this._value = isShallow ? value : toReactive(value);
932
+ this["__v_isShallow"] = isShallow;
933
+ }
934
+ get value() {
935
+ this.dep.track({
936
+ target: this,
937
+ type: "get",
938
+ key: "value"
939
+ });
940
+ return this._value;
941
+ }
942
+ set value(newValue) {
943
+ const oldValue = this._rawValue;
944
+ const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
945
+ newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
946
+ if (hasChanged(newValue, oldValue)) {
947
+ this._rawValue = newValue;
948
+ this._value = useDirectValue ? newValue : toReactive(newValue);
949
+ this.dep.trigger({
950
+ target: this,
951
+ type: "set",
952
+ key: "value",
953
+ newValue,
954
+ oldValue
955
+ });
956
+ }
957
+ }
958
+ };
959
+ //#endregion
960
+ //#region packages/signal/src/baseHandlers.ts
961
+ const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
962
+ const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
963
+ function hasOwnProperty(key) {
964
+ if (!isSymbol(key)) key = String(key);
965
+ const obj = /* @__PURE__ */ toRaw(this);
966
+ track(obj, "has", key);
967
+ return obj.hasOwnProperty(key);
968
+ }
969
+ var BaseReactiveHandler = class {
970
+ constructor(_isReadonly = false, _isShallow = false) {
971
+ this._isReadonly = _isReadonly;
972
+ this._isShallow = _isShallow;
973
+ }
974
+ get(target, key, receiver) {
975
+ if (key === "__v_skip") return target["__v_skip"];
976
+ const isReadonly = this._isReadonly, isShallow = this._isShallow;
977
+ if (key === "__v_isReactive") return !isReadonly;
978
+ else if (key === "__v_isReadonly") return isReadonly;
979
+ else if (key === "__v_isShallow") return isShallow;
980
+ else if (key === "__v_raw") {
981
+ if (receiver === (isReadonly ? isShallow ? shallowReadonlyMap : readonlyMap : isShallow ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
982
+ return;
983
+ }
984
+ const targetIsArray = isArray(target);
985
+ if (!isReadonly) {
986
+ let fn;
987
+ if (targetIsArray && (fn = arrayInstrumentations[key])) return fn;
988
+ if (key === "hasOwnProperty") return hasOwnProperty;
989
+ }
990
+ const res = Reflect.get(target, key, /* @__PURE__ */ isRef(target) ? target : receiver);
991
+ if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
992
+ if (!isReadonly) track(target, "get", key);
993
+ if (isShallow) return res;
994
+ if (/* @__PURE__ */ isRef(res)) {
995
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
996
+ return isReadonly && isObject(value) ? /* @__PURE__ */ readonly(value) : value;
997
+ }
998
+ if (isObject(res)) return isReadonly ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res);
999
+ return res;
1000
+ }
1001
+ };
1002
+ var MutableReactiveHandler = class extends BaseReactiveHandler {
1003
+ constructor(isShallow = false) {
1004
+ super(false, isShallow);
1005
+ }
1006
+ set(target, key, value, receiver) {
1007
+ let oldValue = target[key];
1008
+ const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
1009
+ if (!this._isShallow) {
1010
+ const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue);
1011
+ if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) {
1012
+ oldValue = /* @__PURE__ */ toRaw(oldValue);
1013
+ value = /* @__PURE__ */ toRaw(value);
1014
+ }
1015
+ if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
1016
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
1017
+ return true;
1018
+ } else {
1019
+ oldValue.value = value;
1020
+ return true;
1021
+ }
1022
+ }
1023
+ const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
1024
+ const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
1025
+ if (target === /* @__PURE__ */ toRaw(receiver)) {
1026
+ if (!hadKey) trigger(target, "add", key, value);
1027
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
1028
+ }
1029
+ return result;
1030
+ }
1031
+ deleteProperty(target, key) {
1032
+ const hadKey = hasOwn(target, key);
1033
+ const oldValue = target[key];
1034
+ const result = Reflect.deleteProperty(target, key);
1035
+ if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
1036
+ return result;
1037
+ }
1038
+ has(target, key) {
1039
+ const result = Reflect.has(target, key);
1040
+ if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
1041
+ return result;
1042
+ }
1043
+ ownKeys(target) {
1044
+ track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
1045
+ return Reflect.ownKeys(target);
1046
+ }
1047
+ };
1048
+ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
1049
+ constructor(isShallow = false) {
1050
+ super(true, isShallow);
1051
+ }
1052
+ set(target, key) {
1053
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
1054
+ return true;
1055
+ }
1056
+ deleteProperty(target, key) {
1057
+ warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
1058
+ return true;
1059
+ }
1060
+ };
1061
+ const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
1062
+ const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
1063
+ //#endregion
1064
+ //#region packages/signal/src/collectionHandlers.ts
1065
+ const toShallow = (value) => value;
1066
+ const getProto = (v) => Reflect.getPrototypeOf(v);
1067
+ function createIterableMethod(method, isReadonly, isShallow) {
1068
+ return function(...args) {
1069
+ const target = this["__v_raw"];
1070
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1071
+ const targetIsMap = isMap(rawTarget);
1072
+ const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
1073
+ const isKeyOnly = method === "keys" && targetIsMap;
1074
+ const innerIterator = target[method](...args);
1075
+ const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
1076
+ !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
1077
+ return extend(Object.create(innerIterator), { next() {
1078
+ const { value, done } = innerIterator.next();
1079
+ return done ? {
1080
+ value,
1081
+ done
1082
+ } : {
1083
+ value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1084
+ done
1085
+ };
1086
+ } });
1087
+ };
1088
+ }
1089
+ function createReadonlyMethod(type) {
1090
+ return function(...args) {
1091
+ {
1092
+ const key = args[0] ? `on key "${args[0]}" ` : ``;
1093
+ warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, /* @__PURE__ */ toRaw(this));
1094
+ }
1095
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
1096
+ };
1097
+ }
1098
+ function createInstrumentations(readonly, shallow) {
1099
+ const instrumentations = {
1100
+ get(key) {
1101
+ const target = this["__v_raw"];
1102
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1103
+ const rawKey = /* @__PURE__ */ toRaw(key);
1104
+ if (!readonly) {
1105
+ if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
1106
+ track(rawTarget, "get", rawKey);
1107
+ }
1108
+ const { has } = getProto(rawTarget);
1109
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1110
+ if (has.call(rawTarget, key)) return wrap(target.get(key));
1111
+ else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
1112
+ else if (target !== rawTarget) target.get(key);
1113
+ },
1114
+ get size() {
1115
+ const target = this["__v_raw"];
1116
+ !readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY);
1117
+ return target.size;
1118
+ },
1119
+ has(key) {
1120
+ const target = this["__v_raw"];
1121
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1122
+ const rawKey = /* @__PURE__ */ toRaw(key);
1123
+ if (!readonly) {
1124
+ if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
1125
+ track(rawTarget, "has", rawKey);
1126
+ }
1127
+ return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1128
+ },
1129
+ forEach(callback, thisArg) {
1130
+ const observed = this;
1131
+ const target = observed["__v_raw"];
1132
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1133
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1134
+ !readonly && track(rawTarget, "iterate", ITERATE_KEY);
1135
+ return target.forEach((value, key) => {
1136
+ return callback.call(thisArg, wrap(value), wrap(key), observed);
1137
+ });
1138
+ }
1139
+ };
1140
+ extend(instrumentations, readonly ? {
1141
+ add: createReadonlyMethod("add"),
1142
+ set: createReadonlyMethod("set"),
1143
+ delete: createReadonlyMethod("delete"),
1144
+ clear: createReadonlyMethod("clear")
1145
+ } : {
1146
+ add(value) {
1147
+ const target = /* @__PURE__ */ toRaw(this);
1148
+ const proto = getProto(target);
1149
+ const rawValue = /* @__PURE__ */ toRaw(value);
1150
+ const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value;
1151
+ if (!(proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue))) {
1152
+ target.add(valueToAdd);
1153
+ trigger(target, "add", valueToAdd, valueToAdd);
1154
+ }
1155
+ return this;
1156
+ },
1157
+ set(key, value) {
1158
+ if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
1159
+ const target = /* @__PURE__ */ toRaw(this);
1160
+ const { has, get } = getProto(target);
1161
+ let hadKey = has.call(target, key);
1162
+ if (!hadKey) {
1163
+ key = /* @__PURE__ */ toRaw(key);
1164
+ hadKey = has.call(target, key);
1165
+ } else checkIdentityKeys(target, has, key);
1166
+ const oldValue = get.call(target, key);
1167
+ target.set(key, value);
1168
+ if (!hadKey) trigger(target, "add", key, value);
1169
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
1170
+ return this;
1171
+ },
1172
+ delete(key) {
1173
+ const target = /* @__PURE__ */ toRaw(this);
1174
+ const { has, get } = getProto(target);
1175
+ let hadKey = has.call(target, key);
1176
+ if (!hadKey) {
1177
+ key = /* @__PURE__ */ toRaw(key);
1178
+ hadKey = has.call(target, key);
1179
+ } else checkIdentityKeys(target, has, key);
1180
+ const oldValue = get ? get.call(target, key) : void 0;
1181
+ const result = target.delete(key);
1182
+ if (hadKey) trigger(target, "delete", key, void 0, oldValue);
1183
+ return result;
1184
+ },
1185
+ clear() {
1186
+ const target = /* @__PURE__ */ toRaw(this);
1187
+ const hadItems = target.size !== 0;
1188
+ const oldTarget = isMap(target) ? new Map(target) : new Set(target);
1189
+ const result = target.clear();
1190
+ if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
1191
+ return result;
1192
+ }
1193
+ });
1194
+ [
1195
+ "keys",
1196
+ "values",
1197
+ "entries",
1198
+ Symbol.iterator
1199
+ ].forEach((method) => {
1200
+ instrumentations[method] = createIterableMethod(method, readonly, shallow);
1201
+ });
1202
+ return instrumentations;
1203
+ }
1204
+ function createInstrumentationGetter(isReadonly, shallow) {
1205
+ const instrumentations = createInstrumentations(isReadonly, shallow);
1206
+ return (target, key, receiver) => {
1207
+ if (key === "__v_isReactive") return !isReadonly;
1208
+ else if (key === "__v_isReadonly") return isReadonly;
1209
+ else if (key === "__v_raw") return target;
1210
+ return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
1211
+ };
1212
+ }
1213
+ const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
1214
+ const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
1215
+ function checkIdentityKeys(target, has, key) {
1216
+ const rawKey = /* @__PURE__ */ toRaw(key);
1217
+ if (rawKey !== key && has.call(target, rawKey)) {
1218
+ const type = toRawType(target);
1219
+ 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.`);
1220
+ }
1221
+ }
1222
+ //#endregion
1223
+ //#region packages/signal/src/reactive.ts
1224
+ const reactiveMap = /* @__PURE__ */ new WeakMap();
1225
+ const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
1226
+ const readonlyMap = /* @__PURE__ */ new WeakMap();
1227
+ const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
1228
+ function targetTypeMap(rawType) {
1229
+ switch (rawType) {
1230
+ case "Object":
1231
+ case "Array": return 1;
1232
+ case "Map":
1233
+ case "Set":
1234
+ case "WeakMap":
1235
+ case "WeakSet": return 2;
1236
+ default: return 0;
1237
+ }
1238
+ }
1239
+ function getTargetType(value) {
1240
+ return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1241
+ }
1242
+ /*@__NO_SIDE_EFFECTS__*/
1243
+ function reactive(target) {
1244
+ if (/* @__PURE__ */ isReadonly(target)) return target;
1245
+ return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1246
+ }
1247
+ /**
1248
+ * Takes an object (reactive or plain) or a ref and returns a readonly proxy to
1249
+ * the original.
1250
+ *
1251
+ * A readonly proxy is deep: any nested property accessed will be readonly as
1252
+ * well. It also has the same ref-unwrapping behavior as {@link reactive},
1253
+ * except the unwrapped values will also be made readonly.
1254
+ *
1255
+ * @example
1256
+ * ```js
1257
+ * const original = reactive({ count: 0 })
1258
+ *
1259
+ * const copy = readonly(original)
1260
+ *
1261
+ * watchEffect(() => {
1262
+ * // works for reactivity tracking
1263
+ * console.log(copy.count)
1264
+ * })
1265
+ *
1266
+ * // mutating original will trigger watchers relying on the copy
1267
+ * original.count++
1268
+ *
1269
+ * // mutating the copy will fail and result in a warning
1270
+ * copy.count++ // warning!
1271
+ * ```
1272
+ *
1273
+ * @param target - The source object.
1274
+ * @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
1275
+ */
1276
+ /*@__NO_SIDE_EFFECTS__*/
1277
+ function readonly(target) {
1278
+ return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1279
+ }
1280
+ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
1281
+ if (!isObject(target)) {
1282
+ warn(`value cannot be made ${isReadonly ? "readonly" : "reactive"}: ${String(target)}`);
1283
+ return target;
1284
+ }
1285
+ if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
1286
+ const targetType = getTargetType(target);
1287
+ if (targetType === 0) return target;
1288
+ const existingProxy = proxyMap.get(target);
1289
+ if (existingProxy) return existingProxy;
1290
+ const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1291
+ proxyMap.set(target, proxy);
1292
+ return proxy;
1293
+ }
1294
+ /**
1295
+ * Checks if an object is a proxy created by {@link reactive} or
1296
+ * {@link shallowReactive} (or {@link ref} in some cases).
1297
+ *
1298
+ * @example
1299
+ * ```js
1300
+ * isReactive(reactive({})) // => true
1301
+ * isReactive(readonly(reactive({}))) // => true
1302
+ * isReactive(ref({}).value) // => true
1303
+ * isReactive(readonly(ref({})).value) // => true
1304
+ * isReactive(ref(true)) // => false
1305
+ * isReactive(shallowRef({}).value) // => false
1306
+ * isReactive(shallowReactive({})) // => true
1307
+ * ```
1308
+ *
1309
+ * @param value - The value to check.
1310
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
1311
+ */
1312
+ /*@__NO_SIDE_EFFECTS__*/
1313
+ function isReactive(value) {
1314
+ if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
1315
+ return !!(value && value["__v_isReactive"]);
1316
+ }
1317
+ /**
1318
+ * Checks whether the passed value is a readonly object. The properties of a
1319
+ * readonly object can change, but they can't be assigned directly via the
1320
+ * passed object.
1321
+ *
1322
+ * The proxies created by {@link readonly} and {@link shallowReadonly} are
1323
+ * both considered readonly, as is a computed ref without a set function.
1324
+ *
1325
+ * @param value - The value to check.
1326
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
1327
+ */
1328
+ /*@__NO_SIDE_EFFECTS__*/
1329
+ function isReadonly(value) {
1330
+ return !!(value && value["__v_isReadonly"]);
1331
+ }
1332
+ /*@__NO_SIDE_EFFECTS__*/
1333
+ function isShallow(value) {
1334
+ return !!(value && value["__v_isShallow"]);
1335
+ }
1336
+ /**
1337
+ * Checks if an object is a proxy created by {@link reactive},
1338
+ * {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
1339
+ *
1340
+ * @param value - The value to check.
1341
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
1342
+ */
1343
+ /*@__NO_SIDE_EFFECTS__*/
1344
+ function isProxy(value) {
1345
+ return value ? !!value["__v_raw"] : false;
1346
+ }
1347
+ /**
1348
+ * Returns the raw, original object of a Vue-created proxy.
1349
+ *
1350
+ * `toRaw()` can return the original object from proxies created by
1351
+ * {@link reactive}, {@link readonly}, {@link shallowReactive} or
1352
+ * {@link shallowReadonly}.
1353
+ *
1354
+ * This is an escape hatch that can be used to temporarily read without
1355
+ * incurring proxy access / tracking overhead or write without triggering
1356
+ * changes. It is **not** recommended to hold a persistent reference to the
1357
+ * original object. Use with caution.
1358
+ *
1359
+ * @example
1360
+ * ```js
1361
+ * const foo = {}
1362
+ * const reactiveFoo = reactive(foo)
1363
+ *
1364
+ * console.log(toRaw(reactiveFoo) === foo) // true
1365
+ * ```
1366
+ *
1367
+ * @param observed - The object for which the "raw" value is requested.
1368
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
1369
+ */
1370
+ /*@__NO_SIDE_EFFECTS__*/
1371
+ function toRaw(observed) {
1372
+ const raw = observed && observed["__v_raw"];
1373
+ return raw ? /* @__PURE__ */ toRaw(raw) : observed;
1374
+ }
1375
+ /**
1376
+ * Returns a reactive proxy of the given value (if possible).
1377
+ *
1378
+ * If the given value is not an object, the original value itself is returned.
1379
+ *
1380
+ * @param value - The value for which a reactive proxy shall be created.
1381
+ */
1382
+ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
1383
+ /**
1384
+ * Returns a readonly proxy of the given value (if possible).
1385
+ *
1386
+ * If the given value is not an object, the original value itself is returned.
1387
+ *
1388
+ * @param value - The value for which a readonly proxy shall be created.
1389
+ */
1390
+ const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1391
+ //#endregion
1392
+ //#region packages/signal/src/state.ts
1393
+ function state(value) {
1394
+ if (arguments.length === 0) return /* @__PURE__ */ ref();
1395
+ return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
1396
+ }
1397
+ function isProxyable(value) {
1398
+ if (value === null || typeof value !== "object") return false;
1399
+ if (Array.isArray(value)) return true;
1400
+ if (value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) return true;
1401
+ return isPlainObject(value);
1402
+ }
1403
+ function isPlainObject(value) {
1404
+ const proto = Object.getPrototypeOf(value);
1405
+ return proto === Object.prototype || proto === null;
1406
+ }
1407
+ //#endregion
1408
+ //#region packages/signal/src/computed.ts
1409
+ /**
1410
+ * @private exported by @vue/reactivity for Vue core use, but not exported from
1411
+ * the main vue package
1412
+ */
1413
+ var ComputedRefImpl = class {
1414
+ constructor(fn, setter, isSSR) {
1415
+ this.fn = fn;
1416
+ this.setter = setter;
1417
+ this._value = void 0;
1418
+ this.dep = new Dep(this);
1419
+ this.__v_isRef = true;
1420
+ this.deps = void 0;
1421
+ this.depsTail = void 0;
1422
+ this.flags = 16;
1423
+ this.globalVersion = globalVersion - 1;
1424
+ this.next = void 0;
1425
+ this.effect = this;
1426
+ this["__v_isReadonly"] = !setter;
1427
+ this.isSSR = isSSR;
1428
+ }
1429
+ /**
1430
+ * @internal
1431
+ */
1432
+ notify() {
1433
+ this.flags |= 16;
1434
+ if (!(this.flags & 8) && activeSub !== this) {
1435
+ queueSubscriber(this, true);
1436
+ return true;
1437
+ }
1438
+ }
1439
+ get value() {
1440
+ const link = this.dep.track({
1441
+ target: this,
1442
+ type: "get",
1443
+ key: "value"
1444
+ });
1445
+ refreshComputed(this);
1446
+ if (link) link.version = this.dep.version;
1447
+ return this._value;
1448
+ }
1449
+ set value(newValue) {
1450
+ if (this.setter) this.setter(newValue);
1451
+ else warn("Write operation failed: computed value is readonly");
1452
+ }
1453
+ };
1454
+ /*@__NO_SIDE_EFFECTS__*/
1455
+ function computed(getterOrOptions, debugOptions, isSSR = false) {
1456
+ let getter;
1457
+ let setter;
1458
+ if (isFunction(getterOrOptions)) getter = getterOrOptions;
1459
+ else {
1460
+ getter = getterOrOptions.get;
1461
+ setter = getterOrOptions.set;
1462
+ }
1463
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1464
+ if (debugOptions && !isSSR) {
1465
+ cRef.onTrack = debugOptions.onTrack;
1466
+ cRef.onTrigger = debugOptions.onTrigger;
1467
+ }
1468
+ return cRef;
1469
+ }
1470
+ //#endregion
1471
+ //#region packages/signal/src/scheduler.ts
1472
+ function nextTick() {
1473
+ return Promise.resolve();
1474
+ }
1475
+ //#endregion
1476
+ //#region packages/signal/src/watch.ts
1477
+ const INITIAL_WATCHER_VALUE = {};
1478
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1479
+ let activeWatcher = void 0;
1480
+ /**
1481
+ * Registers a cleanup callback on the current active effect. This
1482
+ * registered cleanup callback will be invoked right before the
1483
+ * associated effect re-runs.
1484
+ *
1485
+ * @param cleanupFn - The callback function to attach to the effect's cleanup.
1486
+ * @param failSilently - if `true`, will not throw warning when called without
1487
+ * an active effect.
1488
+ * @param owner - The effect that this cleanup function should be attached to.
1489
+ * By default, the current active effect.
1490
+ */
1491
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1492
+ if (owner) {
1493
+ let cleanups = cleanupMap.get(owner);
1494
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1495
+ cleanups.push(cleanupFn);
1496
+ } else if (!failSilently) warn("onWatcherCleanup() was called when there was no active watcher to associate with.");
1497
+ }
1498
+ function watch(source, cb, options = EMPTY_OBJ) {
1499
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1500
+ const warnInvalidSource = (s) => {
1501
+ (options.onWarn || warn)(`Invalid watch source: `, s, "A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.");
1502
+ };
1503
+ const reactiveGetter = (source) => {
1504
+ if (deep) return source;
1505
+ if (/* @__PURE__ */ isShallow(source) || deep === false || deep === 0) return traverse(source, 1);
1506
+ return traverse(source);
1507
+ };
1508
+ let effect;
1509
+ let getter;
1510
+ let cleanup;
1511
+ let boundCleanup;
1512
+ let forceTrigger = false;
1513
+ let isMultiSource = false;
1514
+ if (/* @__PURE__ */ isRef(source)) {
1515
+ getter = () => source.value;
1516
+ forceTrigger = /* @__PURE__ */ isShallow(source);
1517
+ } else if (/* @__PURE__ */ isReactive(source)) {
1518
+ getter = () => reactiveGetter(source);
1519
+ forceTrigger = true;
1520
+ } else if (isArray(source)) {
1521
+ isMultiSource = true;
1522
+ forceTrigger = source.some((s) => /* @__PURE__ */ isReactive(s) || /* @__PURE__ */ isShallow(s));
1523
+ getter = () => source.map((s) => {
1524
+ if (/* @__PURE__ */ isRef(s)) return s.value;
1525
+ else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s);
1526
+ else if (isFunction(s)) return call ? call(s, 2) : s();
1527
+ else warnInvalidSource(s);
1528
+ });
1529
+ } else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
1530
+ else getter = () => {
1531
+ if (cleanup) {
1532
+ pauseTracking();
1533
+ try {
1534
+ cleanup();
1535
+ } finally {
1536
+ resetTracking();
1537
+ }
1538
+ }
1539
+ const currentEffect = activeWatcher;
1540
+ activeWatcher = effect;
1541
+ try {
1542
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1543
+ } finally {
1544
+ activeWatcher = currentEffect;
1545
+ }
1546
+ };
1547
+ else {
1548
+ getter = NOOP;
1549
+ warnInvalidSource(source);
1550
+ }
1551
+ if (cb && deep) {
1552
+ const baseGetter = getter;
1553
+ const depth = deep === true ? Infinity : deep;
1554
+ getter = () => traverse(baseGetter(), depth);
1555
+ }
1556
+ const scope = getCurrentScope();
1557
+ const watchHandle = () => {
1558
+ effect.stop();
1559
+ if (scope && scope.active) remove(scope.effects, effect);
1560
+ };
1561
+ if (once && cb) {
1562
+ const _cb = cb;
1563
+ cb = (...args) => {
1564
+ _cb(...args);
1565
+ watchHandle();
1566
+ };
1567
+ }
1568
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1569
+ const job = (immediateFirstRun) => {
1570
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) return;
1571
+ if (cb) {
1572
+ const newValue = effect.run();
1573
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1574
+ if (cleanup) cleanup();
1575
+ const currentWatcher = activeWatcher;
1576
+ activeWatcher = effect;
1577
+ try {
1578
+ const args = [
1579
+ newValue,
1580
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1581
+ boundCleanup
1582
+ ];
1583
+ oldValue = newValue;
1584
+ call ? call(cb, 3, args) : cb(...args);
1585
+ } finally {
1586
+ activeWatcher = currentWatcher;
1587
+ }
1588
+ }
1589
+ } else effect.run();
1590
+ };
1591
+ if (augmentJob) augmentJob(job);
1592
+ effect = new ReactiveEffect(getter);
1593
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
1594
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
1595
+ cleanup = effect.onStop = () => {
1596
+ const cleanups = cleanupMap.get(effect);
1597
+ if (cleanups) {
1598
+ if (call) call(cleanups, 4);
1599
+ else for (const cleanup of cleanups) cleanup();
1600
+ cleanupMap.delete(effect);
1601
+ }
1602
+ };
1603
+ effect.onTrack = options.onTrack;
1604
+ effect.onTrigger = options.onTrigger;
1605
+ if (cb) if (immediate) job(true);
1606
+ else oldValue = effect.run();
1607
+ else if (scheduler) scheduler(job.bind(null, true), true);
1608
+ else effect.run();
1609
+ watchHandle.pause = effect.pause.bind(effect);
1610
+ watchHandle.resume = effect.resume.bind(effect);
1611
+ watchHandle.stop = watchHandle;
1612
+ return watchHandle;
1613
+ }
1614
+ function traverse(value, depth = Infinity, seen) {
1615
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) return value;
1616
+ seen = seen || /* @__PURE__ */ new Map();
1617
+ if ((seen.get(value) || 0) >= depth) return value;
1618
+ seen.set(value, depth);
1619
+ depth--;
1620
+ if (/* @__PURE__ */ isRef(value)) traverse(value.value, depth, seen);
1621
+ else if (isArray(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, seen);
1622
+ else if (isSet(value) || isMap(value)) value.forEach((v) => {
1623
+ traverse(v, depth, seen);
1624
+ });
1625
+ else if (isPlainObject$1(value)) {
1626
+ for (const key in value) traverse(value[key], depth, seen);
1627
+ for (const key of Object.getOwnPropertySymbols(value)) if (Object.prototype.propertyIsEnumerable.call(value, key)) traverse(value[key], depth, seen);
1628
+ }
1629
+ return value;
1630
+ }
1631
+ //#endregion
1632
+ //#region packages/signal/src/lifecycle.ts
1633
+ function onCleanup(fn) {
1634
+ if (getCurrentEffect()) {
1635
+ onEffectCleanup(fn, true);
1636
+ return;
1637
+ }
1638
+ if (getCurrentScope()) {
1639
+ onScopeDispose(fn, true);
1640
+ return;
1641
+ }
1642
+ warn("onCleanup() was called without active effect or scope.");
1643
+ }
1644
+ //#endregion
1645
+ //#region packages/runtime-dom/src/hostContext.ts
1646
+ let currentHostContext;
1647
+ function getCurrentHostContext() {
1648
+ return currentHostContext;
1649
+ }
1650
+ function withHostContext(context, fn) {
1651
+ const previous = currentHostContext;
1652
+ currentHostContext = context;
1653
+ try {
1654
+ return fn();
1655
+ } finally {
1656
+ currentHostContext = previous;
1657
+ }
1658
+ }
1659
+ //#endregion
1660
+ //#region packages/runtime-dom/src/range.ts
1661
+ function insertTracked(parent, value, marker) {
1662
+ if (value === void 0 || value == null || value === false || value === true) return [];
1663
+ if (Array.isArray(value)) {
1664
+ const nodes = [];
1665
+ for (const item of value) nodes.push(...insertTracked(parent, item, marker));
1666
+ return nodes;
1667
+ }
1668
+ const node = value instanceof Node ? value : document.createTextNode(String(value));
1669
+ parent.insertBefore(node, marker);
1670
+ return [node];
1671
+ }
1672
+ //#endregion
1673
+ //#region packages/runtime-dom/src/insert.ts
1674
+ function insert(parent, value, marker = null) {
1675
+ if (value === void 0) {
1676
+ console.warn("[Zeus runtime] insert received `undefined`, which is ignored. Use `null` or a fallback value explicitly if you want to suppress this warning.");
1677
+ return;
1678
+ }
1679
+ insertTracked(parent, value, marker);
1680
+ }
1681
+ //#endregion
1682
+ //#region packages/runtime-dom/src/context.ts
1683
+ let currentOwner;
1684
+ function createOwner(parent = currentOwner) {
1685
+ return {
1686
+ parent,
1687
+ provides: /* @__PURE__ */ new Map()
1688
+ };
1689
+ }
1690
+ function runWithOwner(owner, fn) {
1691
+ const previous = currentOwner;
1692
+ currentOwner = owner;
1693
+ try {
1694
+ return fn();
1695
+ } finally {
1696
+ currentOwner = previous;
1697
+ }
1698
+ }
1699
+ function createContext(defaultValue) {
1700
+ const hasDefaultValue = arguments.length > 0;
1701
+ const context = {
1702
+ id: Symbol("ZeusContext"),
1703
+ defaultValue,
1704
+ hasDefaultValue,
1705
+ Provider(props) {
1706
+ const owner = createOwner(currentOwner);
1707
+ owner.provides.set(context.id, props.value);
1708
+ return runWithOwner(owner, () => {
1709
+ const children = resolveValue$3(props.children);
1710
+ if (props.bridge) return createDOMContextBoundary(context, props.value, children);
1711
+ return children;
1712
+ });
1713
+ },
1714
+ Bridge(props) {
1715
+ return createDOMContextBoundary(context, props.value, resolveValue$3(props.children));
1716
+ }
1717
+ };
1718
+ return context;
1719
+ }
1720
+ function provide(context, value) {
1721
+ const owner = currentOwner;
1722
+ if (!owner) {
1723
+ console.warn("[Zeus context] provide() was called without an active component owner.");
1724
+ return;
1725
+ }
1726
+ owner.provides.set(context.id, value);
1727
+ }
1728
+ function inject(context, fallback) {
1729
+ let owner = currentOwner;
1730
+ while (owner) {
1731
+ if (owner.provides.has(context.id)) return owner.provides.get(context.id);
1732
+ owner = owner.parent;
1733
+ }
1734
+ if (arguments.length >= 2) return fallback;
1735
+ if (context.hasDefaultValue) return context.defaultValue;
1736
+ throw new Error(`[Zeus context] No provider found for context.`);
1737
+ }
1738
+ function useContext(context, fallback) {
1739
+ if (arguments.length >= 2) return inject(context, fallback);
1740
+ return inject(context);
1741
+ }
1742
+ const ZEUS_CONTEXT_REQUEST = "zeus:context-request";
1743
+ /**
1744
+ * Creates a transparent DOM element that acts as a context boundary.
1745
+ * Native custom elements inside it can use `requestDOMContext` to receive
1746
+ * context values via the DOM event protocol.
1747
+ */
1748
+ function createDOMContextBoundary(context, value, children) {
1749
+ const boundary = document.createElement("zeus-context");
1750
+ boundary.style.cssText = "display:contents;position:unset;width:0;height:0;overflow:hidden";
1751
+ provideDOMContext(boundary, context, value);
1752
+ insert(boundary, children);
1753
+ return boundary;
1754
+ }
1755
+ /**
1756
+ * Registers a context value on a DOM target so that any descendant custom
1757
+ * element can pick it up via `requestDOMContext`.
1758
+ */
1759
+ function provideDOMContext(target, context, value) {
1760
+ const handler = (event) => {
1761
+ const request = event;
1762
+ if (request.type !== "zeus:context-request") return;
1763
+ if (request.detail.id !== context.id) return;
1764
+ request.stopPropagation();
1765
+ request.detail.resolve(value);
1766
+ };
1767
+ target.addEventListener(ZEUS_CONTEXT_REQUEST, handler);
1768
+ onScopeDispose(() => {
1769
+ target.removeEventListener(ZEUS_CONTEXT_REQUEST, handler);
1770
+ }, true);
1771
+ }
1772
+ /**
1773
+ * Internal precise DOM context resolver.
1774
+ *
1775
+ * Unlike requestDOMContext(), this can distinguish:
1776
+ * - found: false, value: undefined
1777
+ * - found: true, value: undefined
1778
+ */
1779
+ function resolveDOMContext(host, context) {
1780
+ let found = false;
1781
+ let value;
1782
+ const event = new CustomEvent(ZEUS_CONTEXT_REQUEST, {
1783
+ bubbles: true,
1784
+ composed: true,
1785
+ cancelable: true,
1786
+ detail: {
1787
+ id: context.id,
1788
+ resolved: false,
1789
+ value: void 0,
1790
+ resolve(nextValue) {
1791
+ found = true;
1792
+ value = nextValue;
1793
+ this.resolved = true;
1794
+ this.value = nextValue;
1795
+ }
1796
+ }
1797
+ });
1798
+ host.dispatchEvent(event);
1799
+ return {
1800
+ found,
1801
+ value
1802
+ };
1803
+ }
1804
+ function resolveValue$3(value) {
1805
+ return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
1806
+ }
1807
+ //#endregion
1808
+ //#region packages/runtime-dom/src/devtools.ts
1809
+ function emitDevtoolsEvent(event) {
1810
+ var _window$__ZEUS_DEVTOO;
1811
+ if (typeof window === "undefined") return;
1812
+ (_window$__ZEUS_DEVTOO = window.__ZEUS_DEVTOOLS_HOOK__) === null || _window$__ZEUS_DEVTOO === void 0 || _window$__ZEUS_DEVTOO.emit(event);
1813
+ }
1814
+ //#endregion
1815
+ //#region packages/runtime-dom/src/render.ts
1816
+ function render(value, container, options = {}) {
1817
+ var _options$owner;
1818
+ const renderScope = effectScope();
1819
+ const owner = (_options$owner = options.owner) !== null && _options$owner !== void 0 ? _options$owner : createOwner();
1820
+ renderScope.run(() => {
1821
+ container.textContent = "";
1822
+ runWithOwner(owner, () => {
1823
+ insert(container, resolveValue$2(value));
1824
+ });
1825
+ });
1826
+ emitDevtoolsEvent({
1827
+ type: "render",
1828
+ target: container
1829
+ });
1830
+ let disposed = false;
1831
+ return () => {
1832
+ if (disposed) return;
1833
+ disposed = true;
1834
+ renderScope.stop();
1835
+ container.textContent = "";
1836
+ };
1837
+ }
1838
+ function resolveValue$2(value) {
1839
+ return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
1840
+ }
1841
+ //#endregion
1842
+ //#region packages/runtime-dom/src/component.ts
1843
+ function createComponent(component, props) {
1844
+ return runWithOwner(createOwner(), () => component(props));
1845
+ }
1846
+ //#endregion
1847
+ //#region packages/runtime-dom/src/controlFlow.ts
1848
+ function Show(props) {
1849
+ return resolveValue$1(props.when ? props.children : props.fallback);
1850
+ }
1851
+ function resolveValue$1(value) {
1852
+ if (typeof value === "function") return value();
1853
+ return value !== null && value !== void 0 ? value : null;
1854
+ }
1855
+ function For(props) {
1856
+ var _props$each$map, _props$each;
1857
+ return (_props$each$map = (_props$each = props.each) === null || _props$each === void 0 ? void 0 : _props$each.map((item, index) => props.children(item, index))) !== null && _props$each$map !== void 0 ? _props$each$map : null;
1858
+ }
1859
+ //#endregion
1860
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
1861
+ function _typeof(o) {
1862
+ "@babel/helpers - typeof";
1863
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1864
+ return typeof o;
1865
+ } : function(o) {
1866
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1867
+ }, _typeof(o);
1868
+ }
1869
+ //#endregion
1870
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
1871
+ function toPrimitive(t, r) {
1872
+ if ("object" != _typeof(t) || !t) return t;
1873
+ var e = t[Symbol.toPrimitive];
1874
+ if (void 0 !== e) {
1875
+ var i = e.call(t, r || "default");
1876
+ if ("object" != _typeof(i)) return i;
1877
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1878
+ }
1879
+ return ("string" === r ? String : Number)(t);
1880
+ }
1881
+ //#endregion
1882
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
1883
+ function toPropertyKey(t) {
1884
+ var i = toPrimitive(t, "string");
1885
+ return "symbol" == _typeof(i) ? i : i + "";
1886
+ }
1887
+ //#endregion
1888
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
1889
+ function _defineProperty(e, r, t) {
1890
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1891
+ value: t,
1892
+ enumerable: !0,
1893
+ configurable: !0,
1894
+ writable: !0
1895
+ }) : e[r] = t, e;
1896
+ }
1897
+ //#endregion
1898
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectSpread2.js
1899
+ function ownKeys(e, r) {
1900
+ var t = Object.keys(e);
1901
+ if (Object.getOwnPropertySymbols) {
1902
+ var o = Object.getOwnPropertySymbols(e);
1903
+ r && (o = o.filter(function(r) {
1904
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
1905
+ })), t.push.apply(t, o);
1906
+ }
1907
+ return t;
1908
+ }
1909
+ function _objectSpread2(e) {
1910
+ for (var r = 1; r < arguments.length; r++) {
1911
+ var t = null != arguments[r] ? arguments[r] : {};
1912
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
1913
+ _defineProperty(e, r, t[r]);
1914
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
1915
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1916
+ });
1917
+ }
1918
+ return e;
1919
+ }
1920
+ //#endregion
1921
+ //#region packages/runtime-dom/src/defineElement.ts
1922
+ function defineElement(tagName, options, setup) {
1923
+ var _options$props;
1924
+ const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
1925
+ const observedAttributes = propDefs.filter((def) => def.attr !== false).map((def) => def.attr);
1926
+ class ZeusElement extends HTMLElement {
1927
+ static get observedAttributes() {
1928
+ return observedAttributes;
1929
+ }
1930
+ constructor() {
1931
+ super();
1932
+ this.props = state({});
1933
+ this.lightChildren = [];
1934
+ this.capturedLightChildren = false;
1935
+ this.reflecting = false;
1936
+ applyPropDefaults(this.props, propDefs);
1937
+ definePropAccessors(this, this.props, propDefs);
1938
+ }
1939
+ connectedCallback() {
1940
+ var _options$shadow, _options$consumes;
1941
+ if (this.dispose) return;
1942
+ const shadow = (_options$shadow = options.shadow) !== null && _options$shadow !== void 0 ? _options$shadow : false;
1943
+ const mode = shadow ? "shadow" : "light";
1944
+ if (mode === "light" && !this.capturedLightChildren) {
1945
+ this.lightChildren = Array.from(this.childNodes);
1946
+ this.capturedLightChildren = true;
1947
+ }
1948
+ this.syncAttributesToProps(propDefs);
1949
+ const owner = createOwner();
1950
+ for (const context of (_options$consumes = options.consumes) !== null && _options$consumes !== void 0 ? _options$consumes : []) {
1951
+ const resolved = resolveDOMContext(this, context);
1952
+ if (resolved.found) owner.provides.set(context.id, resolved.value);
1953
+ else if (context.hasDefaultValue) owner.provides.set(context.id, context.defaultValue);
1954
+ }
1955
+ const target = this.resolveRenderTarget(shadow);
1956
+ const hostContext = {
1957
+ host: this,
1958
+ mode,
1959
+ lightChildren: this.lightChildren
1960
+ };
1961
+ const setupContext = {
1962
+ host: this,
1963
+ emit: (name, detail, eventOptions) => {
1964
+ return this.dispatchEvent(new CustomEvent(name, _objectSpread2(_objectSpread2({
1965
+ bubbles: true,
1966
+ composed: true,
1967
+ cancelable: true
1968
+ }, eventOptions), {}, { detail })));
1969
+ }
1970
+ };
1971
+ this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
1972
+ mountStyles(target, options.styles);
1973
+ onScopeDispose(() => {
1974
+ var _this$dispose;
1975
+ (_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
1976
+ this.dispose = void 0;
1977
+ }, true);
1978
+ }
1979
+ disconnectedCallback() {
1980
+ var _this$dispose2;
1981
+ (_this$dispose2 = this.dispose) === null || _this$dispose2 === void 0 || _this$dispose2.call(this);
1982
+ this.dispose = void 0;
1983
+ }
1984
+ attributeChangedCallback(name, oldValue, newValue) {
1985
+ if (oldValue === newValue || this.reflecting) return;
1986
+ const def = propDefs.find((item) => item.attr === name);
1987
+ if (!def) return;
1988
+ this.props[def.key] = castAttributeValue(newValue, def);
1989
+ }
1990
+ resolveRenderTarget(shadow) {
1991
+ if (this.target) return this.target;
1992
+ if (!shadow) {
1993
+ this.target = this;
1994
+ return this.target;
1995
+ }
1996
+ this.target = this.attachShadow(typeof shadow === "object" ? shadow : { mode: "open" });
1997
+ return this.target;
1998
+ }
1999
+ syncAttributesToProps(defs) {
2000
+ for (const def of defs) {
2001
+ if (def.attr === false) continue;
2002
+ const value = this.getAttribute(def.attr);
2003
+ if (value !== null || def.type === Boolean) this.props[def.key] = castAttributeValue(value, def);
2004
+ }
2005
+ }
2006
+ _writePropFromProperty(key, value) {
2007
+ const def = propDefs.find((item) => item.key === key);
2008
+ this.props[key] = value;
2009
+ if ((def === null || def === void 0 ? void 0 : def.reflect) && def.attr !== false) {
2010
+ this.reflecting = true;
2011
+ try {
2012
+ reflectPropToAttribute(this, def, value);
2013
+ } finally {
2014
+ this.reflecting = false;
2015
+ }
2016
+ }
2017
+ }
2018
+ }
2019
+ if (!customElements.get(tagName)) customElements.define(tagName, ZeusElement);
2020
+ return ZeusElement;
2021
+ }
2022
+ function normalizePropDefinitions(props) {
2023
+ return Object.keys(props).map((key) => {
2024
+ const input = props[key];
2025
+ if (typeof input === "function") return {
2026
+ key,
2027
+ attr: toKebabCase(key),
2028
+ type: input,
2029
+ reflect: false
2030
+ };
2031
+ return {
2032
+ key,
2033
+ attr: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? toKebabCase(key) : input.attr,
2034
+ type: input === null || input === void 0 ? void 0 : input.type,
2035
+ reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
2036
+ default: input === null || input === void 0 ? void 0 : input.default
2037
+ };
2038
+ });
2039
+ }
2040
+ function applyPropDefaults(props, defs) {
2041
+ for (const def of defs) {
2042
+ if (!("default" in def)) continue;
2043
+ const value = typeof def.default === "function" ? def.default() : def.default;
2044
+ props[def.key] = value;
2045
+ }
2046
+ }
2047
+ function definePropAccessors(element, props, defs) {
2048
+ for (const def of defs) {
2049
+ if (def.key in element) continue;
2050
+ Object.defineProperty(element, def.key, {
2051
+ configurable: true,
2052
+ enumerable: true,
2053
+ get() {
2054
+ return props[def.key];
2055
+ },
2056
+ set(value) {
2057
+ element._writePropFromProperty(def.key, value);
2058
+ }
2059
+ });
2060
+ }
2061
+ }
2062
+ function castAttributeValue(value, def) {
2063
+ if (def.type === Boolean) return value !== null;
2064
+ if (value === null) return;
2065
+ if (def.type === Number) return Number(value);
2066
+ if (def.type === Object || def.type === Array) try {
2067
+ return JSON.parse(value);
2068
+ } catch (_unused) {
2069
+ console.warn(`[Zeus custom-element] Failed to parse JSON attribute "${def.attr}".`);
2070
+ return def.type === Array ? [] : {};
2071
+ }
2072
+ return value;
2073
+ }
2074
+ function reflectPropToAttribute(element, def, value) {
2075
+ if (def.attr === false) return;
2076
+ if (def.type === Boolean) {
2077
+ if (value) element.setAttribute(def.attr, "");
2078
+ else element.removeAttribute(def.attr);
2079
+ return;
2080
+ }
2081
+ if (value == null) {
2082
+ element.removeAttribute(def.attr);
2083
+ return;
2084
+ }
2085
+ if (def.type === Object || def.type === Array) {
2086
+ element.setAttribute(def.attr, JSON.stringify(value));
2087
+ return;
2088
+ }
2089
+ element.setAttribute(def.attr, String(value));
2090
+ }
2091
+ function mountStyles(target, styles) {
2092
+ if (!styles) return;
2093
+ const list = Array.isArray(styles) ? styles : [styles];
2094
+ for (const css of list) {
2095
+ const style = document.createElement("style");
2096
+ style.textContent = css;
2097
+ target.appendChild(style);
2098
+ }
2099
+ }
2100
+ function toKebabCase(value) {
2101
+ return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
2102
+ }
2103
+ //#endregion
2104
+ //#region packages/runtime-dom/src/slot.ts
2105
+ function createSlot(name, fallback) {
2106
+ const context = getCurrentHostContext();
2107
+ if (!context) return createNativeSlot(name, fallback);
2108
+ if (context.mode === "shadow") return createNativeSlot(name, fallback);
2109
+ const assigned = findLightSlotNodes(context.lightChildren, name);
2110
+ if (assigned.length > 0) return Array.from(assigned);
2111
+ return fallback ? fallback() : null;
2112
+ }
2113
+ function createNativeSlot(name, fallback) {
2114
+ const slot = document.createElement("slot");
2115
+ if (name) slot.setAttribute("name", name);
2116
+ const fallbackValue = fallback === null || fallback === void 0 ? void 0 : fallback();
2117
+ if (fallbackValue != null) insert(slot, fallbackValue);
2118
+ return slot;
2119
+ }
2120
+ function findLightSlotNodes(nodes, name) {
2121
+ if (name) return nodes.filter((node) => {
2122
+ if (node.nodeType !== Node.ELEMENT_NODE) return false;
2123
+ return node.getAttribute("slot") === name;
2124
+ });
2125
+ return nodes.filter((node) => {
2126
+ if (node.nodeType === Node.ELEMENT_NODE) return !node.hasAttribute("slot");
2127
+ return isMeaningfulTextNode(node);
2128
+ });
2129
+ }
2130
+ function isMeaningfulTextNode(node) {
2131
+ var _node$textContent;
2132
+ if (node.nodeType !== Node.TEXT_NODE) return false;
2133
+ return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
2134
+ }
2135
+ //#endregion
2136
+ //#region packages/runtime-dom/src/webComponents.ts
2137
+ function Host(props) {
2138
+ return resolveValue(props.children);
2139
+ }
2140
+ function Slot(props) {
2141
+ return createSlot(props.name, () => resolveValue(props.children));
2142
+ }
2143
+ function resolveValue(value) {
2144
+ return typeof value === "function" ? value() : value;
2145
+ }
2146
+ //#endregion
2147
+ //#region packages/zeus/src/jsx-runtime.ts
2148
+ const Fragment = Symbol.for("zeus.fragment");
2149
+ function jsx(type, props) {
2150
+ return createJSXNode(type, props);
2151
+ }
2152
+ function jsxs(type, props) {
2153
+ return createJSXNode(type, props);
2154
+ }
2155
+ function jsxDEV(type, props) {
2156
+ return createJSXNode(type, props);
2157
+ }
2158
+ function createJSXNode(type, props) {
2159
+ if (typeof type === "function") return createComponent(type, props !== null && props !== void 0 ? props : {});
2160
+ if (typeof type !== "string") return null;
2161
+ const el = document.createElement(type);
2162
+ if (props) {
2163
+ const children = props.children;
2164
+ for (const key of Object.keys(props)) {
2165
+ if (key === "children") continue;
2166
+ const value = props[key];
2167
+ if (key.startsWith("on") && typeof value === "function") el.addEventListener(key.slice(2).toLowerCase(), value);
2168
+ else if (key === "ref") setFallbackRef(value, el);
2169
+ else if (value != null && value !== false) el.setAttribute(key === "className" ? "class" : key, String(value));
2170
+ }
2171
+ if (children !== void 0) insert(el, children);
2172
+ }
2173
+ return el;
2174
+ }
2175
+ function setFallbackRef(target, el) {
2176
+ if (target == null) return;
2177
+ if (typeof target === "function") {
2178
+ target(el);
2179
+ return;
2180
+ }
2181
+ if (typeof target === "object") {
2182
+ if ("value" in target) {
2183
+ target.value = el;
2184
+ return;
2185
+ }
2186
+ if ("current" in target) target.current = el;
2187
+ }
2188
+ }
2189
+ //#endregion
2190
+ export { For, Fragment, Host, Show, Slot, batch, computed, createContext, defineElement, effect, inject, jsx, jsxDEV, jsxs, nextTick, onCleanup, provide, render, effectScope as scope, state, untrack, useContext, watch };