@pie-element/mc-populated-blank 0.3.0-next.4 → 0.3.0-next.5

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,14 +1,14 @@
1
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/disclose-version.js
1
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/disclose-version.js
2
2
  if (typeof window !== "undefined") {
3
3
  var _window$__svelte, _window;
4
4
  ((_window$__svelte = (_window = window).__svelte ?? (_window.__svelte = {})).v ?? (_window$__svelte.v = /* @__PURE__ */ new Set())).add("5");
5
5
  }
6
6
  //#endregion
7
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/constants.js
7
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/constants.js
8
8
  var HYDRATION_ERROR = {};
9
9
  var UNINITIALIZED = Symbol("uninitialized");
10
10
  //#endregion
11
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/shared/utils.js
11
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/shared/utils.js
12
12
  var is_array = Array.isArray;
13
13
  var index_of = Array.prototype.indexOf;
14
14
  var includes = Array.prototype.includes;
@@ -107,6 +107,8 @@ var WAS_MARKED = 65536;
107
107
  var REACTION_IS_UPDATING = 1 << 21;
108
108
  var ERROR_VALUE = 1 << 23;
109
109
  var STATE_SYMBOL = Symbol("$state");
110
+ /** Marks component export objects, so that `proxy(...)` leaves them untouched */
111
+ var COMPONENT_SYMBOL = Symbol("component");
110
112
  var LEGACY_PROPS = Symbol("legacy props");
111
113
  var ATTRIBUTES_CACHE = Symbol("attributes");
112
114
  var CLASS_CACHE = Symbol("class");
@@ -122,56 +124,6 @@ var STALE_REACTION = new class StaleReactionError extends Error {
122
124
  }();
123
125
  globalThis.document?.contentType;
124
126
  /**
125
- * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
126
- * @returns {never}
127
- */
128
- function effect_update_depth_exceeded() {
129
- throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
130
- }
131
- /**
132
- * Failed to hydrate the application
133
- * @returns {never}
134
- */
135
- function hydration_failed() {
136
- throw new Error(`https://svelte.dev/e/hydration_failed`);
137
- }
138
- /**
139
- * Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
140
- * @param {string} key
141
- * @returns {never}
142
- */
143
- function props_invalid_value(key) {
144
- throw new Error(`https://svelte.dev/e/props_invalid_value`);
145
- }
146
- /**
147
- * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
148
- * @returns {never}
149
- */
150
- function state_descriptors_fixed() {
151
- throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
152
- }
153
- /**
154
- * Cannot set prototype of `$state` object
155
- * @returns {never}
156
- */
157
- function state_prototype_fixed() {
158
- throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
159
- }
160
- /**
161
- * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
162
- * @returns {never}
163
- */
164
- function state_unsafe_mutation() {
165
- throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
166
- }
167
- /**
168
- * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
169
- * @returns {never}
170
- */
171
- function svelte_boundary_reset_onerror() {
172
- throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
173
- }
174
- /**
175
127
  * Reading a derived belonging to a now-destroyed effect may result in stale values
176
128
  */
177
129
  function derived_inert() {
@@ -191,7 +143,7 @@ function svelte_boundary_reset_noop() {
191
143
  console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
192
144
  }
193
145
  //#endregion
194
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/hydration.js
146
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/hydration.js
195
147
  /** @import { TemplateNode } from '#client' */
196
148
  /**
197
149
  * Use this variable to guard everything related to hydration code so it can be treeshaken out
@@ -250,7 +202,7 @@ function skip_nodes(remove = true) {
250
202
  }
251
203
  }
252
204
  //#endregion
253
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/equality.js
205
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/equality.js
254
206
  /** @import { Equals } from '#client' */
255
207
  /** @type {Equals} */
256
208
  function equals(value) {
@@ -268,14 +220,64 @@ function safe_not_equal(a, b) {
268
220
  function safe_equals(value) {
269
221
  return !safe_not_equal(value, this.v);
270
222
  }
223
+ /**
224
+ * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
225
+ * @returns {never}
226
+ */
227
+ function effect_update_depth_exceeded() {
228
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
229
+ }
230
+ /**
231
+ * Failed to hydrate the application
232
+ * @returns {never}
233
+ */
234
+ function hydration_failed() {
235
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
236
+ }
237
+ /**
238
+ * Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
239
+ * @param {string} key
240
+ * @returns {never}
241
+ */
242
+ function props_invalid_value(key) {
243
+ throw new Error(`https://svelte.dev/e/props_invalid_value`);
244
+ }
245
+ /**
246
+ * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
247
+ * @returns {never}
248
+ */
249
+ function state_descriptors_fixed() {
250
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
251
+ }
252
+ /**
253
+ * Cannot set prototype of `$state` object
254
+ * @returns {never}
255
+ */
256
+ function state_prototype_fixed() {
257
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
258
+ }
259
+ /**
260
+ * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
261
+ * @returns {never}
262
+ */
263
+ function state_unsafe_mutation() {
264
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
265
+ }
266
+ /**
267
+ * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
268
+ * @returns {never}
269
+ */
270
+ function svelte_boundary_reset_onerror() {
271
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
272
+ }
271
273
  //#endregion
272
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/flags/index.js
274
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/flags/index.js
273
275
  /** True if experimental.async=true */
274
276
  var async_mode_flag = false;
275
277
  /** True if we're not certain that we only have Svelte 5 code in the compilation */
276
278
  var legacy_mode_flag = false;
277
279
  //#endregion
278
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/context.js
280
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/context.js
279
281
  /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
280
282
  /** @type {ComponentContext | null} */
281
283
  var component_context = null;
@@ -320,14 +322,22 @@ function pop(component) {
320
322
  if (component !== void 0) context.x = component;
321
323
  context.i = true;
322
324
  component_context = context.p;
323
- return component ?? {};
325
+ return mark_as_component(component);
326
+ }
327
+ /**
328
+ * Add a symbol to the object (or create one if undefined) to mark it as a component so it isn't proxified.
329
+ * @param {any} component
330
+ */
331
+ function mark_as_component(component = {}) {
332
+ define_property(component, COMPONENT_SYMBOL, { value: true });
333
+ return component;
324
334
  }
325
335
  /** @returns {boolean} */
326
336
  function is_runes() {
327
337
  return !legacy_mode_flag || component_context !== null && component_context.l === null;
328
338
  }
329
339
  //#endregion
330
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/task.js
340
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/task.js
331
341
  /** @type {Array<() => void>} */
332
342
  var micro_tasks = [];
333
343
  function run_micro_tasks() {
@@ -353,40 +363,8 @@ function queue_micro_task(fn) {
353
363
  function flush_tasks() {
354
364
  while (micro_tasks.length > 0) run_micro_tasks();
355
365
  }
356
- /**
357
- * @param {unknown} error
358
- */
359
- function handle_error(error) {
360
- var effect = active_effect;
361
- if (effect === null) {
362
- /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
363
- return error;
364
- }
365
- if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
366
- invoke_error_boundary(error, effect);
367
- }
368
- /**
369
- * @param {unknown} error
370
- * @param {Effect | null} effect
371
- */
372
- function invoke_error_boundary(error, effect) {
373
- if (effect !== null && (effect.f & 16384) !== 0) return;
374
- while (effect !== null) {
375
- if ((effect.f & 128) !== 0) {
376
- if ((effect.f & 32768) === 0) throw error;
377
- try {
378
- /** @type {Boundary} */ effect.b.error(error);
379
- return;
380
- } catch (e) {
381
- error = e;
382
- }
383
- }
384
- effect = effect.parent;
385
- }
386
- throw error;
387
- }
388
366
  //#endregion
389
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/status.js
367
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/status.js
390
368
  /** @import { Derived, Signal } from '#client' */
391
369
  var STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
392
370
  /**
@@ -405,7 +383,7 @@ function update_derived_status(derived) {
405
383
  else set_signal_status(derived, MAYBE_DIRTY);
406
384
  }
407
385
  //#endregion
408
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/utils.js
386
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/utils.js
409
387
  /** @import { Derived, Effect, Value } from '#client' */
410
388
  /**
411
389
  * @param {Value[] | null} deps
@@ -433,7 +411,7 @@ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
433
411
  set_signal_status(effect, CLEAN);
434
412
  }
435
413
  //#endregion
436
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/store.js
414
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/store.js
437
415
  /**
438
416
  * We set this to `true` when updating a store so that we correctly
439
417
  * schedule effects if the update takes place inside a `$:` effect
@@ -463,7 +441,7 @@ function capture_store_binding(fn) {
463
441
  }
464
442
  }
465
443
  //#endregion
466
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
444
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
467
445
  /**
468
446
  * @template T
469
447
  * @param {() => T} fn
@@ -480,93 +458,137 @@ function without_reactive_context(fn) {
480
458
  set_active_effect(previous_effect);
481
459
  }
482
460
  }
483
- //#endregion
484
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/reactivity/create-subscriber.js
485
461
  /**
486
- * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
487
- * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
488
- *
489
- * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
490
- * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
491
- *
492
- * If `start` returns a cleanup function, it will be called when the effect is destroyed.
493
- *
494
- * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
495
- * are active, and the returned teardown function will only be called when all effects are destroyed.
496
- *
497
- * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
498
- *
499
- * ```js
500
- * import { createSubscriber } from 'svelte/reactivity';
501
- * import { on } from 'svelte/events';
502
- *
503
- * export class MediaQuery {
504
- * #query;
505
- * #subscribe;
506
- *
507
- * constructor(query) {
508
- * this.#query = window.matchMedia(`(${query})`);
509
- *
510
- * this.#subscribe = createSubscriber((update) => {
511
- * // when the `change` event occurs, re-run any effects that read `this.current`
512
- * const off = on(this.#query, 'change', update);
513
- *
514
- * // stop listening when all the effects are destroyed
515
- * return () => off();
516
- * });
517
- * }
518
- *
519
- * get current() {
520
- * // This makes the getter reactive, if read in an effect
521
- * this.#subscribe();
522
- *
523
- * // Return the current state of the query, whether or not we're in an effect
524
- * return this.#query.matches;
525
- * }
526
- * }
527
- * ```
528
- * @param {(update: () => void) => (() => void) | void} start
529
- * @since 5.7.0
462
+ * @template V
463
+ * @param {() => V} fn
464
+ * @returns {Derived<V>}
530
465
  */
531
- function createSubscriber(start) {
532
- let subscribers = 0;
533
- let version = source(0);
534
- /** @type {(() => void) | void} */
535
- let stop;
536
- return () => {
537
- if (effect_tracking()) {
538
- get(version);
539
- render_effect(() => {
540
- if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
541
- subscribers += 1;
542
- return () => {
543
- queue_micro_task(() => {
544
- subscribers -= 1;
545
- if (subscribers === 0) {
546
- stop?.();
547
- stop = void 0;
548
- increment(version);
549
- }
550
- });
551
- };
552
- });
553
- }
466
+ /*#__NO_SIDE_EFFECTS__*/
467
+ function derived(fn) {
468
+ var flags = 2 | DIRTY;
469
+ if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
470
+ return {
471
+ ctx: component_context,
472
+ deps: null,
473
+ effects: null,
474
+ equals,
475
+ f: flags,
476
+ fn,
477
+ reactions: null,
478
+ rv: 0,
479
+ v: UNINITIALIZED,
480
+ wv: 0,
481
+ parent: active_effect,
482
+ ac: null
554
483
  };
555
484
  }
556
- //#endregion
557
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/checkPrivateRedeclaration.js
558
- function _checkPrivateRedeclaration(e, t) {
559
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
485
+ var OBSOLETE = Symbol("obsolete");
486
+ /**
487
+ * @template V
488
+ * @param {() => V} fn
489
+ * @returns {Derived<V>}
490
+ */
491
+ /*#__NO_SIDE_EFFECTS__*/
492
+ function derived_safe_equal(fn) {
493
+ const signal = /* @__PURE__ */ derived(fn);
494
+ signal.equals = safe_equals;
495
+ return signal;
560
496
  }
561
- //#endregion
562
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateMethodInitSpec.js
563
- function _classPrivateMethodInitSpec(e, a) {
564
- _checkPrivateRedeclaration(e, a), a.add(e);
497
+ /**
498
+ * @param {Derived} derived
499
+ * @returns {void}
500
+ */
501
+ function destroy_derived_effects(derived) {
502
+ var effects = derived.effects;
503
+ if (effects !== null) {
504
+ derived.effects = null;
505
+ for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
506
+ }
565
507
  }
566
- //#endregion
567
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldInitSpec.js
568
- function _classPrivateFieldInitSpec(e, t, a) {
569
- _checkPrivateRedeclaration(e, t), t.set(e, a);
508
+ /**
509
+ * @template T
510
+ * @param {Derived} derived
511
+ * @returns {T}
512
+ */
513
+ function execute_derived(derived) {
514
+ var value;
515
+ var prev_active_effect = active_effect;
516
+ var parent = derived.parent;
517
+ if (!is_destroying_effect && parent !== null && derived.v !== UNINITIALIZED && (parent.f & 24576) !== 0) {
518
+ derived_inert();
519
+ return derived.v;
520
+ }
521
+ set_active_effect(parent);
522
+ try {
523
+ derived.f &= ~WAS_MARKED;
524
+ destroy_derived_effects(derived);
525
+ value = update_reaction(derived);
526
+ } finally {
527
+ set_active_effect(prev_active_effect);
528
+ }
529
+ return value;
530
+ }
531
+ /**
532
+ * @param {Derived} derived
533
+ * @returns {void}
534
+ */
535
+ function update_derived(derived) {
536
+ var value = execute_derived(derived);
537
+ if (!derived.equals(value)) {
538
+ derived.wv = increment_write_version();
539
+ if (!current_batch?.is_fork || derived.deps === null) {
540
+ if (current_batch !== null) {
541
+ current_batch.capture(derived, value, true);
542
+ previous_batch?.capture(derived, value, true);
543
+ } else derived.v = value;
544
+ if (derived.deps === null) {
545
+ set_signal_status(derived, CLEAN);
546
+ return;
547
+ }
548
+ }
549
+ }
550
+ if (is_destroying_effect) return;
551
+ if (batch_values !== null) {
552
+ if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
553
+ } else update_derived_status(derived);
554
+ }
555
+ /**
556
+ * @param {Derived} derived
557
+ */
558
+ function freeze_derived_effects(derived) {
559
+ if (derived.effects === null) return;
560
+ for (const e of derived.effects) if (e.teardown || e.ac) {
561
+ e.teardown?.();
562
+ if (e.ac !== null) without_reactive_context(() => {
563
+ /** @type {AbortController} */ e.ac.abort(STALE_REACTION);
564
+ e.ac = null;
565
+ });
566
+ if (e.fn !== null) e.teardown = noop;
567
+ remove_reactions(e, 0);
568
+ destroy_effect_children(e);
569
+ }
570
+ }
571
+ /**
572
+ * @param {Derived} derived
573
+ */
574
+ function unfreeze_derived_effects(derived) {
575
+ if (derived.effects === null) return;
576
+ for (const e of derived.effects) if (e.teardown && e.fn !== null) update_effect(e);
577
+ }
578
+ //#endregion
579
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/checkPrivateRedeclaration.js
580
+ function _checkPrivateRedeclaration(e, t) {
581
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
582
+ }
583
+ //#endregion
584
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateMethodInitSpec.js
585
+ function _classPrivateMethodInitSpec(e, a) {
586
+ _checkPrivateRedeclaration(e, a), a.add(e);
587
+ }
588
+ //#endregion
589
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldInitSpec.js
590
+ function _classPrivateFieldInitSpec(e, t, a) {
591
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
570
592
  }
571
593
  //#endregion
572
594
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/assertClassBrand.js
@@ -585,1942 +607,1494 @@ function _classPrivateFieldGet2(s, a) {
585
607
  return s.get(_assertClassBrand(s, a));
586
608
  }
587
609
  //#endregion
588
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
589
- /** @import { Effect, Source, TemplateNode, } from '#client' */
610
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/batch.js
611
+ /** @import { Fork } from 'svelte' */
612
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
613
+ var _Batch;
614
+ /** @type {Batch | null} */
615
+ var first_batch = null;
616
+ /** @type {Batch | null} */
617
+ var last_batch = null;
618
+ /** @type {Batch | null} */
619
+ var current_batch = null;
590
620
  /**
591
- * @typedef {{
592
- * onerror?: ((error: unknown, reset: () => void) => void) | null;
593
- * failed?: ((anchor: Node, error: () => unknown, reset: () => () => void) => void) | null;
594
- * pending?: ((anchor: Node) => void) | null;
595
- * }} BoundaryProps
621
+ * This is needed to avoid overwriting inputs
622
+ * @type {Batch | null}
596
623
  */
597
- var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
624
+ var previous_batch = null;
598
625
  /**
599
- * @param {TemplateNode} node
600
- * @param {BoundaryProps} props
601
- * @param {((anchor: Node) => void)} children
602
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
603
- * @returns {void}
626
+ * When time travelling (i.e. working in one batch, while other batches
627
+ * still have ongoing work), we ignore the real values of affected
628
+ * signals in favour of their values within the batch
629
+ * @type {Map<Value, any> | null}
604
630
  */
605
- function boundary(node, props, children, transform_error) {
606
- new Boundary(node, props, children, transform_error);
607
- }
608
- var _anchor = /* @__PURE__ */ new WeakMap();
609
- var _hydrate_open = /* @__PURE__ */ new WeakMap();
610
- var _props = /* @__PURE__ */ new WeakMap();
611
- var _children = /* @__PURE__ */ new WeakMap();
612
- var _effect = /* @__PURE__ */ new WeakMap();
613
- var _main_effect = /* @__PURE__ */ new WeakMap();
614
- var _pending_effect = /* @__PURE__ */ new WeakMap();
615
- var _failed_effect = /* @__PURE__ */ new WeakMap();
616
- var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
617
- var _local_pending_count = /* @__PURE__ */ new WeakMap();
618
- var _pending_count = /* @__PURE__ */ new WeakMap();
619
- var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
631
+ var batch_values = null;
632
+ /** @type {Effect | null} */
633
+ var last_scheduled_effect = null;
634
+ var is_flushing_sync = false;
635
+ var is_processing = false;
636
+ /**
637
+ * During traversal, this is an array. Newly created effects are (if not immediately
638
+ * executed) pushed to this array, rather than going through the scheduling
639
+ * rigamarole that would cause another turn of the flush loop.
640
+ * @type {Effect[] | null}
641
+ */
642
+ var collected_effects = null;
643
+ /**
644
+ * An array of effects that are marked during traversal as a result of a `set`
645
+ * (not `internal_set`) call. These will be added to the next batch and
646
+ * trigger another `batch.process()`
647
+ * @type {Effect[] | null}
648
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
649
+ */
650
+ var legacy_updates = null;
651
+ var flush_count = 0;
652
+ var uid = 1;
653
+ var _started = /* @__PURE__ */ new WeakMap();
654
+ var _prev = /* @__PURE__ */ new WeakMap();
655
+ var _next = /* @__PURE__ */ new WeakMap();
656
+ var _commit_callbacks = /* @__PURE__ */ new WeakMap();
657
+ var _discard_callbacks = /* @__PURE__ */ new WeakMap();
658
+ var _pending = /* @__PURE__ */ new WeakMap();
659
+ var _blocking_pending = /* @__PURE__ */ new WeakMap();
660
+ var _deferred = /* @__PURE__ */ new WeakMap();
661
+ var _roots = /* @__PURE__ */ new WeakMap();
662
+ var _new_effects = /* @__PURE__ */ new WeakMap();
620
663
  var _dirty_effects$1 = /* @__PURE__ */ new WeakMap();
621
664
  var _maybe_dirty_effects$1 = /* @__PURE__ */ new WeakMap();
622
- var _effect_pending = /* @__PURE__ */ new WeakMap();
623
- var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
624
- var _Boundary_brand = /* @__PURE__ */ new WeakSet();
625
- var Boundary = class {
626
- /**
627
- * @param {TemplateNode} node
628
- * @param {BoundaryProps} props
629
- * @param {((anchor: Node) => void)} children
630
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
631
- */
632
- constructor(node, props, children, transform_error) {
633
- _classPrivateMethodInitSpec(this, _Boundary_brand);
665
+ var _skipped_branches = /* @__PURE__ */ new WeakMap();
666
+ var _unskipped_branches = /* @__PURE__ */ new WeakMap();
667
+ var _decrement_queued = /* @__PURE__ */ new WeakMap();
668
+ var _Batch_brand = /* @__PURE__ */ new WeakSet();
669
+ var Batch = class Batch {
670
+ constructor() {
671
+ _classPrivateMethodInitSpec(this, _Batch_brand);
672
+ _defineProperty(this, "id", uid++);
673
+ _classPrivateFieldInitSpec(this, _started, false);
674
+ _defineProperty(this, "linked", true);
675
+ _classPrivateFieldInitSpec(this, _prev, null);
676
+ _classPrivateFieldInitSpec(this, _next, null);
634
677
  _defineProperty(
635
678
  this,
636
- /** @type {Boundary | null} */
637
- "parent",
638
- void 0
679
+ /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
680
+ "async_deriveds",
681
+ /* @__PURE__ */ new Map()
639
682
  );
640
- _defineProperty(this, "is_pending", false);
641
683
  _defineProperty(
642
684
  this,
643
685
  /**
644
- * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
645
- * Inherited from parent boundary, or defaults to identity.
646
- * @type {(error: unknown) => unknown}
686
+ * The current values of any signals that are updated in this batch.
687
+ * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
688
+ * They keys of this map are identical to `this.#previous`
689
+ * @type {Map<Value, [any, boolean]>}
647
690
  */
648
- "transform_error",
649
- void 0
691
+ "current",
692
+ /* @__PURE__ */ new Map()
650
693
  );
651
- _classPrivateFieldInitSpec(this, _anchor, void 0);
652
- _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
653
- _classPrivateFieldInitSpec(this, _props, void 0);
654
- _classPrivateFieldInitSpec(this, _children, void 0);
655
- _classPrivateFieldInitSpec(this, _effect, void 0);
656
- _classPrivateFieldInitSpec(this, _main_effect, null);
657
- _classPrivateFieldInitSpec(this, _pending_effect, null);
658
- _classPrivateFieldInitSpec(this, _failed_effect, null);
659
- _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
660
- _classPrivateFieldInitSpec(this, _local_pending_count, 0);
661
- _classPrivateFieldInitSpec(this, _pending_count, 0);
662
- _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
694
+ _defineProperty(
695
+ this,
696
+ /**
697
+ * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
698
+ * They keys of this map are identical to `this.#current`
699
+ * @type {Map<Value, any>}
700
+ */
701
+ "previous",
702
+ /* @__PURE__ */ new Map()
703
+ );
704
+ _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
705
+ _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
706
+ _classPrivateFieldInitSpec(this, _pending, 0);
707
+ _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
708
+ _classPrivateFieldInitSpec(this, _deferred, null);
709
+ _classPrivateFieldInitSpec(this, _roots, []);
710
+ _classPrivateFieldInitSpec(this, _new_effects, []);
663
711
  _classPrivateFieldInitSpec(this, _dirty_effects$1, /* @__PURE__ */ new Set());
664
712
  _classPrivateFieldInitSpec(this, _maybe_dirty_effects$1, /* @__PURE__ */ new Set());
665
- _classPrivateFieldInitSpec(this, _effect_pending, null);
666
- _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
667
- _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
668
- return () => {
669
- _classPrivateFieldSet2(_effect_pending, this, null);
670
- };
671
- }));
672
- _classPrivateFieldSet2(_anchor, this, node);
673
- _classPrivateFieldSet2(_props, this, props);
674
- _classPrivateFieldSet2(_children, this, (anchor) => {
675
- var effect = active_effect;
676
- effect.b = this;
677
- effect.f |= 128;
678
- children(anchor);
679
- });
680
- this.parent = active_effect.b;
681
- this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
682
- _classPrivateFieldSet2(_effect, this, block(() => {
683
- if (hydrating) {
684
- const comment = _classPrivateFieldGet2(_hydrate_open, this);
685
- hydrate_next();
686
- const server_rendered_pending = comment.data === "[!";
687
- if (comment.data.startsWith("[?")) {
688
- const serialized_error = JSON.parse(comment.data.slice(2));
689
- _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
690
- } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
691
- else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
692
- } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
693
- }, flags));
694
- if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
713
+ _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
714
+ _classPrivateFieldInitSpec(this, _unskipped_branches, /* @__PURE__ */ new Set());
715
+ _defineProperty(this, "is_fork", false);
716
+ _classPrivateFieldInitSpec(this, _decrement_queued, false);
717
+ if (last_batch === null) first_batch = last_batch = this;
718
+ else {
719
+ _classPrivateFieldSet2(_next, last_batch, this);
720
+ _classPrivateFieldSet2(_prev, this, last_batch);
721
+ }
722
+ last_batch = this;
695
723
  }
696
724
  /**
697
- * Defer an effect inside a pending boundary until the boundary resolves
725
+ * Add an effect to the #skipped_branches map and reset its children
698
726
  * @param {Effect} effect
699
727
  */
700
- defer_effect(effect) {
701
- defer_effect(effect, _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
728
+ skip_effect(effect) {
729
+ if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
730
+ d: [],
731
+ m: []
732
+ });
733
+ _classPrivateFieldGet2(_unskipped_branches, this).delete(effect);
702
734
  }
703
735
  /**
704
- * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
705
- * @returns {boolean}
736
+ * Remove an effect from the #skipped_branches map and reschedule
737
+ * any tracked dirty/maybe_dirty child effects
738
+ * @param {Effect} effect
739
+ * @param {(e: Effect) => void} callback
706
740
  */
707
- is_rendered() {
708
- return !this.is_pending && (!this.parent || this.parent.is_rendered());
741
+ unskip_effect(effect, callback = (e) => this.schedule(e)) {
742
+ var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
743
+ if (tracked) {
744
+ _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
745
+ for (var e of tracked.d) {
746
+ set_signal_status(e, DIRTY);
747
+ callback(e);
748
+ }
749
+ for (e of tracked.m) {
750
+ set_signal_status(e, MAYBE_DIRTY);
751
+ callback(e);
752
+ }
753
+ }
754
+ _classPrivateFieldGet2(_unskipped_branches, this).add(effect);
709
755
  }
710
- has_pending_snippet() {
711
- return !!_classPrivateFieldGet2(_props, this).pending;
756
+ /**
757
+ * Associate a change to a given source with the current
758
+ * batch, noting its previous and current values
759
+ * @param {Value} source
760
+ * @param {any} value
761
+ * @param {boolean} [is_derived]
762
+ */
763
+ capture(source, value, is_derived = false) {
764
+ if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
765
+ if ((source.f & 8388608) === 0) {
766
+ this.current.set(source, [value, is_derived]);
767
+ batch_values?.set(source, value);
768
+ }
769
+ if (!this.is_fork) source.v = value;
770
+ }
771
+ activate() {
772
+ current_batch = this;
773
+ }
774
+ deactivate() {
775
+ current_batch = null;
776
+ batch_values = null;
777
+ }
778
+ flush() {
779
+ try {
780
+ is_processing = true;
781
+ current_batch = this;
782
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
783
+ } finally {
784
+ flush_count = 0;
785
+ last_scheduled_effect = null;
786
+ collected_effects = null;
787
+ legacy_updates = null;
788
+ is_processing = false;
789
+ current_batch = null;
790
+ batch_values = null;
791
+ old_values.clear();
792
+ }
793
+ }
794
+ discard() {
795
+ for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
796
+ _classPrivateFieldGet2(_discard_callbacks, this).clear();
797
+ for (const deferred of this.async_deriveds.values()) deferred.reject(OBSOLETE);
798
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
799
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
712
800
  }
713
801
  /**
714
- * Update the source that powers `$effect.pending()` inside this boundary,
715
- * and controls when the current `pending` snippet (if any) is removed.
716
- * Do not call from inside the class
717
- * @param {1 | -1} d
718
- * @param {Batch} batch
802
+ * @param {Effect} effect
719
803
  */
720
- update_pending_count(d, batch) {
721
- _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
722
- _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
723
- if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
724
- _classPrivateFieldSet2(_pending_count_update_queued, this, true);
804
+ register_created_effect(effect) {
805
+ _classPrivateFieldGet2(_new_effects, this).push(effect);
806
+ }
807
+ /**
808
+ * @param {boolean} blocking
809
+ * @param {Effect} effect
810
+ */
811
+ increment(blocking, effect) {
812
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) + 1);
813
+ if (blocking) {
814
+ let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
815
+ _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count + 1);
816
+ }
817
+ }
818
+ /**
819
+ * @param {boolean} blocking
820
+ * @param {Effect} effect
821
+ */
822
+ decrement(blocking, effect) {
823
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) - 1);
824
+ if (blocking) {
825
+ let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
826
+ if (blocking_pending_count === 1) _classPrivateFieldGet2(_blocking_pending, this).delete(effect);
827
+ else _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count - 1);
828
+ }
829
+ if (_classPrivateFieldGet2(_decrement_queued, this)) return;
830
+ _classPrivateFieldSet2(_decrement_queued, this, true);
725
831
  queue_micro_task(() => {
726
- _classPrivateFieldSet2(_pending_count_update_queued, this, false);
727
- if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
832
+ _classPrivateFieldSet2(_decrement_queued, this, false);
833
+ if (this.linked) this.flush();
728
834
  });
729
835
  }
730
- get_effect_pending() {
731
- _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
732
- return get(_classPrivateFieldGet2(_effect_pending, this));
836
+ /**
837
+ * @param {Set<Effect>} dirty_effects
838
+ * @param {Set<Effect>} maybe_dirty_effects
839
+ */
840
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
841
+ for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects$1, this).add(e);
842
+ for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(e);
843
+ dirty_effects.clear();
844
+ maybe_dirty_effects.clear();
733
845
  }
734
- /** @param {unknown} error */
735
- error(error) {
736
- if (!_classPrivateFieldGet2(_props, this).onerror && !_classPrivateFieldGet2(_props, this).failed) throw error;
737
- if (current_batch?.is_fork) {
738
- if (_classPrivateFieldGet2(_main_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_main_effect, this));
739
- if (_classPrivateFieldGet2(_pending_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_pending_effect, this));
740
- if (_classPrivateFieldGet2(_failed_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_failed_effect, this));
741
- current_batch.oncommit(() => {
742
- _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
743
- });
744
- } else _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
846
+ /** @param {(batch: Batch) => void} fn */
847
+ oncommit(fn) {
848
+ _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
745
849
  }
746
- };
747
- function _hydrate_resolved_content() {
748
- try {
749
- _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
750
- } catch (error) {
751
- this.error(error);
850
+ /** @param {(batch: Batch) => void} fn */
851
+ ondiscard(fn) {
852
+ _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
752
853
  }
753
- }
754
- /**
755
- * @param {unknown} error The deserialized error from the server's hydration comment
756
- */
757
- function _hydrate_failed_content(error) {
758
- const failed = _classPrivateFieldGet2(_props, this).failed;
759
- const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, error);
760
- queue_micro_task(invoke_onerror);
761
- if (!failed) return;
762
- _classPrivateFieldSet2(_failed_effect, this, branch(() => {
763
- failed(_classPrivateFieldGet2(_anchor, this), () => error, () => reset);
764
- }));
765
- }
766
- /**
767
- * Creates the `reset` function for a failed boundary, along with a function
768
- * that invokes `onerror` with it (if provided)
769
- * @param {unknown} error
770
- * @returns {{ reset: () => void, invoke_onerror: () => void }}
771
- */
772
- function _create_reset(error) {
773
- var did_reset = false;
774
- var calling_on_error = false;
775
- const reset = () => {
776
- if (did_reset) {
777
- svelte_boundary_reset_noop();
854
+ settled() {
855
+ return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
856
+ }
857
+ static ensure() {
858
+ if (current_batch === null) {
859
+ const batch = current_batch = new Batch();
860
+ if (!is_processing && !is_flushing_sync) queue_micro_task(() => {
861
+ if (!_classPrivateFieldGet2(_started, batch)) batch.flush();
862
+ });
863
+ }
864
+ return current_batch;
865
+ }
866
+ apply() {
867
+ if (!async_mode_flag || !this.is_fork && _classPrivateFieldGet2(_prev, this) === null && _classPrivateFieldGet2(_next, this) === null) {
868
+ batch_values = null;
778
869
  return;
779
870
  }
780
- did_reset = true;
781
- if (calling_on_error) svelte_boundary_reset_onerror();
782
- if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
783
- _classPrivateFieldSet2(_failed_effect, this, null);
784
- });
785
- _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
786
- _assertClassBrand(_Boundary_brand, this, _render).call(this);
787
- });
788
- };
789
- const invoke_onerror = () => {
790
- try {
791
- calling_on_error = true;
792
- _classPrivateFieldGet2(_props, this).onerror?.(error, reset);
793
- calling_on_error = false;
794
- } catch (err) {
795
- invoke_error_boundary(err, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
871
+ batch_values = /* @__PURE__ */ new Map();
872
+ for (const [source, [value]] of this.current) batch_values.set(source, value);
873
+ for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
874
+ if (batch === this || batch.is_fork) continue;
875
+ var intersects = false;
876
+ if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
877
+ if (is_derived) continue;
878
+ if (this.current.has(source)) {
879
+ intersects = true;
880
+ break;
881
+ }
882
+ }
883
+ if (!intersects) {
884
+ for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
885
+ }
796
886
  }
797
- };
798
- return {
799
- reset,
800
- invoke_onerror
801
- };
802
- }
803
- function _hydrate_pending_content() {
804
- const pending = _classPrivateFieldGet2(_props, this).pending;
805
- if (!pending) return;
806
- this.is_pending = true;
807
- _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
808
- queue_micro_task(() => {
809
- var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
810
- var anchor = create_text();
811
- fragment.append(anchor);
812
- _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
813
- return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
814
- }));
815
- if (_classPrivateFieldGet2(_pending_count, this) === 0) {
816
- _classPrivateFieldGet2(_anchor, this).before(fragment);
817
- _classPrivateFieldSet2(_offscreen_fragment, this, null);
818
- pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
819
- _classPrivateFieldSet2(_pending_effect, this, null);
820
- });
821
- _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
887
+ }
888
+ /**
889
+ *
890
+ * @param {Effect} effect
891
+ */
892
+ schedule(effect) {
893
+ last_scheduled_effect = effect;
894
+ if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
895
+ effect.b.defer_effect(effect);
896
+ return;
822
897
  }
823
- });
824
- }
825
- function _render() {
826
- try {
827
- this.is_pending = this.has_pending_snippet();
828
- _classPrivateFieldSet2(_pending_count, this, 0);
829
- _classPrivateFieldSet2(_local_pending_count, this, 0);
830
- _classPrivateFieldSet2(_main_effect, this, branch(() => {
831
- _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
832
- }));
833
- if (_classPrivateFieldGet2(_pending_count, this) > 0) {
834
- var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
835
- move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
836
- const pending = _classPrivateFieldGet2(_props, this).pending;
837
- _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
838
- } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
839
- } catch (error) {
840
- this.error(error);
898
+ var e = effect;
899
+ while (e.parent !== null) {
900
+ e = e.parent;
901
+ var flags = e.f;
902
+ if (collected_effects !== null && e === active_effect) {
903
+ if (async_mode_flag) return;
904
+ if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
905
+ }
906
+ if ((flags & 96) !== 0) {
907
+ if ((flags & 1024) === 0) return;
908
+ e.f ^= CLEAN;
909
+ }
910
+ }
911
+ _classPrivateFieldGet2(_roots, this).push(e);
841
912
  }
913
+ };
914
+ _Batch = Batch;
915
+ function _is_deferred() {
916
+ if (this.is_fork) return true;
917
+ for (const effect of _classPrivateFieldGet2(_blocking_pending, this).keys()) {
918
+ var e = effect;
919
+ var skipped = false;
920
+ while (e.parent !== null) {
921
+ if (_classPrivateFieldGet2(_skipped_branches, this).has(e)) {
922
+ skipped = true;
923
+ break;
924
+ }
925
+ e = e.parent;
926
+ }
927
+ if (!skipped) return true;
928
+ }
929
+ return false;
842
930
  }
843
- /**
844
- * @param {Batch} batch
845
- */
846
- function _resolve(batch) {
847
- this.is_pending = false;
848
- batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
849
- }
850
- /**
851
- * @template T
852
- * @param {() => T} fn
853
- */
854
- function _run(fn) {
855
- var previous_effect = active_effect;
856
- var previous_reaction = active_reaction;
857
- var previous_ctx = component_context;
858
- set_active_effect(_classPrivateFieldGet2(_effect, this));
859
- set_active_reaction(_classPrivateFieldGet2(_effect, this));
860
- set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
861
- try {
862
- Batch.ensure();
863
- return fn();
931
+ function _process() {
932
+ _classPrivateFieldSet2(_started, this, true);
933
+ if (flush_count++ > 1e3) {
934
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
935
+ infinite_loop_guard();
936
+ }
937
+ for (const e of _classPrivateFieldGet2(_dirty_effects$1, this)) {
938
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(e);
939
+ set_signal_status(e, DIRTY);
940
+ this.schedule(e);
941
+ }
942
+ for (const e of _classPrivateFieldGet2(_maybe_dirty_effects$1, this)) {
943
+ set_signal_status(e, MAYBE_DIRTY);
944
+ this.schedule(e);
945
+ }
946
+ const roots = _classPrivateFieldGet2(_roots, this);
947
+ _classPrivateFieldSet2(_roots, this, []);
948
+ this.apply();
949
+ /** @type {Effect[]} */
950
+ var effects = collected_effects = [];
951
+ /** @type {Effect[]} */
952
+ var render_effects = [];
953
+ /**
954
+ * @type {Effect[]}
955
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
956
+ */
957
+ var updates = legacy_updates = [];
958
+ for (const root of roots) try {
959
+ _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
864
960
  } catch (e) {
865
- handle_error(e);
866
- return null;
867
- } finally {
868
- set_active_effect(previous_effect);
869
- set_active_reaction(previous_reaction);
870
- set_component_context(previous_ctx);
961
+ reset_all(root);
962
+ if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
963
+ throw e;
964
+ }
965
+ current_batch = null;
966
+ if (updates.length > 0) {
967
+ var batch = _Batch.ensure();
968
+ for (const e of updates) batch.schedule(e);
969
+ }
970
+ collected_effects = null;
971
+ legacy_updates = null;
972
+ if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
973
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
974
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
975
+ for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
976
+ if (updates.length > 0)
977
+ /** @type {Batch} */ _assertClassBrand(_Batch_brand, current_batch, _process).call(current_batch);
978
+ return;
979
+ }
980
+ const earlier_batch = _assertClassBrand(_Batch_brand, this, _find_earlier_batch).call(this);
981
+ if (earlier_batch) {
982
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
983
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
984
+ _assertClassBrand(_Batch_brand, earlier_batch, _merge).call(earlier_batch, this);
985
+ return;
986
+ }
987
+ _classPrivateFieldGet2(_dirty_effects$1, this).clear();
988
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).clear();
989
+ for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
990
+ _classPrivateFieldGet2(_commit_callbacks, this).clear();
991
+ previous_batch = this;
992
+ flush_queued_effects(render_effects);
993
+ flush_queued_effects(effects);
994
+ previous_batch = null;
995
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
996
+ var next_batch = current_batch;
997
+ if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_roots, this).length === 0 || next_batch !== null)) {
998
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
999
+ if (async_mode_flag) {
1000
+ _assertClassBrand(_Batch_brand, this, _commit).call(this);
1001
+ current_batch = next_batch;
1002
+ }
1003
+ }
1004
+ if (_classPrivateFieldGet2(_roots, this).length > 0) if (next_batch !== null) {
1005
+ const batch = next_batch;
1006
+ _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
1007
+ } else next_batch = this;
1008
+ if (next_batch !== null) {
1009
+ old_values.clear();
1010
+ _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
871
1011
  }
872
1012
  }
873
1013
  /**
874
- * Updates the pending count associated with the currently visible pending snippet,
875
- * if any, such that we can replace the snippet with content once work is done
876
- * @param {1 | -1} d
877
- * @param {Batch} batch
1014
+ * Traverse the effect tree, executing effects or stashing
1015
+ * them for later execution as appropriate
1016
+ * @param {Effect} root
1017
+ * @param {Effect[]} effects
1018
+ * @param {Effect[]} render_effects
878
1019
  */
879
- function _update_pending_count(d, batch) {
880
- if (!this.has_pending_snippet()) {
881
- if (this.parent) {
882
- var _this$parent;
883
- _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
1020
+ function _traverse(root, effects, render_effects) {
1021
+ root.f ^= CLEAN;
1022
+ var effect = root.first;
1023
+ while (effect !== null) {
1024
+ var flags = effect.f;
1025
+ var is_branch = (flags & 96) !== 0;
1026
+ if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
1027
+ if (is_branch) effect.f ^= CLEAN;
1028
+ else if ((flags & 4) !== 0) effects.push(effect);
1029
+ else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
1030
+ else if (is_dirty(effect)) {
1031
+ if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(effect);
1032
+ update_effect(effect);
1033
+ }
1034
+ var child = effect.first;
1035
+ if (child !== null) {
1036
+ effect = child;
1037
+ continue;
1038
+ }
1039
+ }
1040
+ while (effect !== null) {
1041
+ var next = effect.next;
1042
+ if (next !== null) {
1043
+ effect = next;
1044
+ break;
1045
+ }
1046
+ effect = effect.parent;
884
1047
  }
885
- return;
886
1048
  }
887
- _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
888
- if (_classPrivateFieldGet2(_pending_count, this) === 0) {
889
- _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
890
- if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
891
- _classPrivateFieldSet2(_pending_effect, this, null);
892
- });
893
- if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
894
- _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
895
- _classPrivateFieldSet2(_offscreen_fragment, this, null);
1049
+ }
1050
+ function _find_earlier_batch() {
1051
+ var batch = _classPrivateFieldGet2(_prev, this);
1052
+ while (batch !== null) {
1053
+ if (!batch.is_fork) {
1054
+ for (const [value, [, is_derived]] of this.current) if (batch.current.has(value) && !is_derived) return batch;
896
1055
  }
1056
+ batch = _classPrivateFieldGet2(_prev, batch);
897
1057
  }
1058
+ return null;
898
1059
  }
899
1060
  /**
900
- * @param {unknown} error
1061
+ * @param {Batch} batch
901
1062
  */
902
- function _handle_error(error) {
903
- if (_classPrivateFieldGet2(_main_effect, this)) {
904
- destroy_effect(_classPrivateFieldGet2(_main_effect, this));
905
- _classPrivateFieldSet2(_main_effect, this, null);
906
- }
907
- if (_classPrivateFieldGet2(_pending_effect, this)) {
908
- destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
909
- _classPrivateFieldSet2(_pending_effect, this, null);
910
- }
911
- if (_classPrivateFieldGet2(_failed_effect, this)) {
912
- destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
913
- _classPrivateFieldSet2(_failed_effect, this, null);
1063
+ function _merge(batch) {
1064
+ for (const [source, value] of batch.current) {
1065
+ if (!this.previous.has(source) && batch.previous.has(source)) this.previous.set(source, batch.previous.get(source));
1066
+ this.current.set(source, value);
914
1067
  }
915
- if (hydrating) {
916
- set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
917
- next();
918
- set_hydrate_node(skip_nodes());
1068
+ for (const [effect, deferred] of batch.async_deriveds) {
1069
+ const d = this.async_deriveds.get(effect);
1070
+ if (d) deferred.promise.then(d.resolve).catch(d.reject);
919
1071
  }
920
- let failed = _classPrivateFieldGet2(_props, this).failed;
921
- /** @param {unknown} transformed_error */
922
- const handle_error_result = (transformed_error) => {
923
- const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, transformed_error);
924
- invoke_onerror();
925
- if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
926
- try {
927
- return branch(() => {
928
- var effect = active_effect;
929
- effect.b = this;
930
- effect.f |= 128;
931
- failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
932
- });
933
- } catch (error) {
934
- invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
935
- return null;
1072
+ batch.async_deriveds.clear();
1073
+ this.transfer_effects(_classPrivateFieldGet2(_dirty_effects$1, batch), _classPrivateFieldGet2(_maybe_dirty_effects$1, batch));
1074
+ /**
1075
+ * mark all effects that depend on `batch.current`, except the
1076
+ * async effects that we just resolved (TODO unless they depend
1077
+ * on values in this batch that are NOT in the later batch?).
1078
+ * Through this we also will populate the correct #skipped_branches,
1079
+ * oncommit callbacks etc, so we don't need to merge them separately.
1080
+ * @param {Value} value
1081
+ */
1082
+ const mark = (value) => {
1083
+ var reactions = value.reactions;
1084
+ if (reactions === null) return;
1085
+ if ((value.f & 2) !== 0 && (value.f & 6144) === 0) return;
1086
+ for (const reaction of reactions) {
1087
+ var flags = reaction.f;
1088
+ if ((flags & 2) !== 0) mark(reaction);
1089
+ else {
1090
+ var effect = reaction;
1091
+ if (flags & 4194320 && !this.async_deriveds.has(effect)) {
1092
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(effect);
1093
+ set_signal_status(effect, DIRTY);
1094
+ this.schedule(effect);
1095
+ }
936
1096
  }
937
- }));
938
- };
939
- queue_micro_task(() => {
940
- /** @type {unknown} */
941
- var result;
942
- try {
943
- result = this.transform_error(error);
944
- } catch (e) {
945
- invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
946
- return;
947
1097
  }
948
- if (result !== null && typeof result === "object" && typeof result.then === "function")
949
- /** @type {any} */ result.then(
950
- handle_error_result,
951
- /** @param {unknown} e */
952
- (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
953
- );
954
- else handle_error_result(result);
955
- });
956
- }
957
- /**
958
- * @template V
959
- * @param {() => V} fn
960
- * @returns {Derived<V>}
961
- */
962
- /*#__NO_SIDE_EFFECTS__*/
963
- function derived(fn) {
964
- var flags = 2 | DIRTY;
965
- if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
966
- return {
967
- ctx: component_context,
968
- deps: null,
969
- effects: null,
970
- equals,
971
- f: flags,
972
- fn,
973
- reactions: null,
974
- rv: 0,
975
- v: UNINITIALIZED,
976
- wv: 0,
977
- parent: active_effect,
978
- ac: null
979
1098
  };
1099
+ for (const source of this.current.keys()) mark(source);
1100
+ this.oncommit(() => batch.discard());
1101
+ _assertClassBrand(_Batch_brand, batch, _unlink).call(batch);
1102
+ current_batch = this;
1103
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
980
1104
  }
981
- var OBSOLETE = Symbol("obsolete");
982
1105
  /**
983
- * @template V
984
- * @param {() => V} fn
985
- * @returns {Derived<V>}
1106
+ * @param {Effect[]} effects
986
1107
  */
987
- /*#__NO_SIDE_EFFECTS__*/
988
- function derived_safe_equal(fn) {
989
- const signal = /* @__PURE__ */ derived(fn);
990
- signal.equals = safe_equals;
991
- return signal;
1108
+ function _defer_effects(effects) {
1109
+ for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
992
1110
  }
993
- /**
994
- * @param {Derived} derived
995
- * @returns {void}
996
- */
997
- function destroy_derived_effects(derived) {
998
- var effects = derived.effects;
999
- if (effects !== null) {
1000
- derived.effects = null;
1001
- for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1111
+ function _commit() {
1112
+ for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1113
+ var is_earlier = batch.id < this.id;
1114
+ /** @type {Source[]} */
1115
+ var sources = [];
1116
+ for (const [source, [value, is_derived]] of this.current) {
1117
+ if (batch.current.has(source)) {
1118
+ var batch_value = batch.current.get(source)[0];
1119
+ if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
1120
+ else continue;
1121
+ }
1122
+ sources.push(source);
1123
+ }
1124
+ if (is_earlier) for (const [effect, deferred] of this.async_deriveds) {
1125
+ const d = batch.async_deriveds.get(effect);
1126
+ if (d) deferred.promise.then(d.resolve).catch(d.reject);
1127
+ }
1128
+ var current = [...batch.current.keys()].filter((source) => !batch.current.get(source)[1]);
1129
+ if (!_classPrivateFieldGet2(_started, batch) || current.length === 0) continue;
1130
+ var others = current.filter((source) => !this.current.has(source));
1131
+ if (others.length === 0) {
1132
+ if (is_earlier) batch.discard();
1133
+ } else if (sources.length > 0) {
1134
+ if (is_earlier) for (const unskipped of _classPrivateFieldGet2(_unskipped_branches, this)) batch.unskip_effect(unskipped, (e) => {
1135
+ if ((e.f & 4194320) !== 0) batch.schedule(e);
1136
+ else _assertClassBrand(_Batch_brand, batch, _defer_effects).call(batch, [e]);
1137
+ });
1138
+ batch.activate();
1139
+ /** @type {Set<Value>} */
1140
+ var marked = /* @__PURE__ */ new Set();
1141
+ /** @type {Map<Reaction, boolean>} */
1142
+ var checked = /* @__PURE__ */ new Map();
1143
+ for (var source of sources) mark_effects(source, others, marked, checked);
1144
+ checked = /* @__PURE__ */ new Map();
1145
+ var current_unequal = [...batch.current].filter(([c, v1]) => {
1146
+ const v2 = this.current.get(c);
1147
+ if (!v2) return true;
1148
+ return v2[0] !== v1[0] || v2[1] !== v1[1];
1149
+ }).map(([c]) => c);
1150
+ if (current_unequal.length > 0) {
1151
+ for (const effect of _classPrivateFieldGet2(_new_effects, this)) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1152
+ set_signal_status(effect, DIRTY);
1153
+ batch.schedule(effect);
1154
+ } else _classPrivateFieldGet2(_dirty_effects$1, batch).add(effect);
1155
+ }
1156
+ if (_classPrivateFieldGet2(_roots, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1157
+ batch.apply();
1158
+ for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1159
+ _classPrivateFieldSet2(_roots, batch, []);
1160
+ }
1161
+ batch.deactivate();
1162
+ }
1002
1163
  }
1003
1164
  }
1165
+ function _unlink() {
1166
+ if (!this.linked) return;
1167
+ var prev = _classPrivateFieldGet2(_prev, this);
1168
+ var next = _classPrivateFieldGet2(_next, this);
1169
+ if (prev === null) first_batch = next;
1170
+ else _classPrivateFieldSet2(_next, prev, next);
1171
+ if (next === null) last_batch = prev;
1172
+ else _classPrivateFieldSet2(_prev, next, prev);
1173
+ this.linked = false;
1174
+ }
1004
1175
  /**
1005
- * @template T
1006
- * @param {Derived} derived
1176
+ * Synchronously flush any pending updates.
1177
+ * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1178
+ * @template [T=void]
1179
+ * @param {(() => T) | undefined} [fn]
1007
1180
  * @returns {T}
1008
1181
  */
1009
- function execute_derived(derived) {
1010
- var value;
1011
- var prev_active_effect = active_effect;
1012
- var parent = derived.parent;
1013
- if (!is_destroying_effect && parent !== null && derived.v !== UNINITIALIZED && (parent.f & 24576) !== 0) {
1014
- derived_inert();
1015
- return derived.v;
1016
- }
1017
- set_active_effect(parent);
1182
+ function flushSync(fn) {
1183
+ var was_flushing_sync = is_flushing_sync;
1184
+ is_flushing_sync = true;
1018
1185
  try {
1019
- derived.f &= ~WAS_MARKED;
1020
- destroy_derived_effects(derived);
1021
- value = update_reaction(derived);
1186
+ var result;
1187
+ if (fn) {
1188
+ if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
1189
+ result = fn();
1190
+ }
1191
+ while (true) {
1192
+ flush_tasks();
1193
+ if (current_batch === null) return result;
1194
+ current_batch.flush();
1195
+ }
1022
1196
  } finally {
1023
- set_active_effect(prev_active_effect);
1197
+ is_flushing_sync = was_flushing_sync;
1198
+ }
1199
+ }
1200
+ function infinite_loop_guard() {
1201
+ try {
1202
+ effect_update_depth_exceeded();
1203
+ } catch (error) {
1204
+ invoke_error_boundary(error, last_scheduled_effect);
1024
1205
  }
1025
- return value;
1026
1206
  }
1207
+ /** @type {Set<Effect> | null} */
1208
+ var eager_block_effects = null;
1027
1209
  /**
1028
- * @param {Derived} derived
1210
+ * @param {Array<Effect>} effects
1029
1211
  * @returns {void}
1030
1212
  */
1031
- function update_derived(derived) {
1032
- var value = execute_derived(derived);
1033
- if (!derived.equals(value)) {
1034
- derived.wv = increment_write_version();
1035
- if (!current_batch?.is_fork || derived.deps === null) {
1036
- if (current_batch !== null) {
1037
- current_batch.capture(derived, value, true);
1038
- previous_batch?.capture(derived, value, true);
1039
- } else derived.v = value;
1040
- if (derived.deps === null) {
1041
- set_signal_status(derived, CLEAN);
1042
- return;
1213
+ function flush_queued_effects(effects) {
1214
+ var length = effects.length;
1215
+ if (length === 0) return;
1216
+ var i = 0;
1217
+ while (i < length) {
1218
+ var effect = effects[i++];
1219
+ if ((effect.f & 24576) === 0 && is_dirty(effect)) {
1220
+ eager_block_effects = /* @__PURE__ */ new Set();
1221
+ update_effect(effect);
1222
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
1223
+ if (eager_block_effects?.size > 0) {
1224
+ old_values.clear();
1225
+ for (const e of eager_block_effects) {
1226
+ if ((e.f & 24576) !== 0) continue;
1227
+ /** @type {Effect[]} */
1228
+ const ordered_effects = [e];
1229
+ let ancestor = e.parent;
1230
+ while (ancestor !== null) {
1231
+ if (eager_block_effects.has(ancestor)) {
1232
+ eager_block_effects.delete(ancestor);
1233
+ ordered_effects.push(ancestor);
1234
+ }
1235
+ ancestor = ancestor.parent;
1236
+ }
1237
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
1238
+ const e = ordered_effects[j];
1239
+ if ((e.f & 24576) !== 0) continue;
1240
+ update_effect(e);
1241
+ }
1242
+ }
1243
+ eager_block_effects.clear();
1043
1244
  }
1044
1245
  }
1045
1246
  }
1046
- if (is_destroying_effect) return;
1047
- if (batch_values !== null) {
1048
- if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
1049
- } else update_derived_status(derived);
1247
+ eager_block_effects = null;
1050
1248
  }
1051
1249
  /**
1052
- * @param {Derived} derived
1250
+ * This is similar to `mark_reactions`, but it only marks async/block effects
1251
+ * depending on `value` and at least one of the other `sources`, so that
1252
+ * these effects can re-run after another batch has been committed
1253
+ * @param {Value} value
1254
+ * @param {Source[]} sources
1255
+ * @param {Set<Value>} marked
1256
+ * @param {Map<Reaction, boolean>} checked
1053
1257
  */
1054
- function freeze_derived_effects(derived) {
1055
- if (derived.effects === null) return;
1056
- for (const e of derived.effects) if (e.teardown || e.ac) {
1057
- e.teardown?.();
1058
- if (e.ac !== null) without_reactive_context(() => {
1059
- /** @type {AbortController} */ e.ac.abort(STALE_REACTION);
1060
- e.ac = null;
1061
- });
1062
- if (e.fn !== null) e.teardown = noop;
1063
- remove_reactions(e, 0);
1064
- destroy_effect_children(e);
1258
+ function mark_effects(value, sources, marked, checked) {
1259
+ if (marked.has(value)) return;
1260
+ marked.add(value);
1261
+ if (value.reactions !== null) for (const reaction of value.reactions) {
1262
+ const flags = reaction.f;
1263
+ if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
1264
+ else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
1265
+ set_signal_status(reaction, DIRTY);
1266
+ schedule_effect(reaction);
1267
+ }
1065
1268
  }
1066
1269
  }
1067
1270
  /**
1068
- * @param {Derived} derived
1271
+ * @param {Reaction} reaction
1272
+ * @param {Source[]} sources
1273
+ * @param {Map<Reaction, boolean>} checked
1069
1274
  */
1070
- function unfreeze_derived_effects(derived) {
1071
- if (derived.effects === null) return;
1072
- for (const e of derived.effects) if (e.teardown && e.fn !== null) update_effect(e);
1275
+ function depends_on(reaction, sources, checked) {
1276
+ const depends = checked.get(reaction);
1277
+ if (depends !== void 0) return depends;
1278
+ if (reaction.deps !== null) for (const dep of reaction.deps) {
1279
+ if (includes.call(sources, dep)) return true;
1280
+ if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
1281
+ checked.set(dep, true);
1282
+ return true;
1283
+ }
1284
+ }
1285
+ checked.set(reaction, false);
1286
+ return false;
1287
+ }
1288
+ /**
1289
+ * @param {Effect} effect
1290
+ * @returns {void}
1291
+ */
1292
+ function schedule_effect(effect) {
1293
+ /** @type {Batch} */ current_batch.schedule(effect);
1294
+ }
1295
+ /**
1296
+ * Mark all the effects inside a skipped branch CLEAN, so that
1297
+ * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1298
+ * effects so they can be rescheduled if the branch survives.
1299
+ * @param {Effect} effect
1300
+ * @param {{ d: Effect[], m: Effect[] }} tracked
1301
+ */
1302
+ function reset_branch(effect, tracked) {
1303
+ if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1304
+ if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1305
+ else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1306
+ set_signal_status(effect, CLEAN);
1307
+ var e = effect.first;
1308
+ while (e !== null) {
1309
+ reset_branch(e, tracked);
1310
+ e = e.next;
1311
+ }
1312
+ }
1313
+ /**
1314
+ * Mark an entire effect tree clean following an error
1315
+ * @param {Effect} effect
1316
+ */
1317
+ function reset_all(effect) {
1318
+ set_signal_status(effect, CLEAN);
1319
+ var e = effect.first;
1320
+ while (e !== null) {
1321
+ reset_all(e);
1322
+ e = e.next;
1323
+ }
1073
1324
  }
1074
1325
  //#endregion
1075
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/batch.js
1076
- /** @import { Fork } from 'svelte' */
1077
- /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
1078
- var _Batch;
1079
- /** @type {Batch | null} */
1080
- var first_batch = null;
1081
- /** @type {Batch | null} */
1082
- var last_batch = null;
1083
- /** @type {Batch | null} */
1084
- var current_batch = null;
1326
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/sources.js
1327
+ /** @import { Derived, Effect, Source, Value } from '#client' */
1328
+ /** @type {Set<Effect>} */
1329
+ var eager_effects = /* @__PURE__ */ new Set();
1330
+ /** @type {Map<Source, any>} */
1331
+ var old_values = /* @__PURE__ */ new Map();
1332
+ var eager_effects_deferred = false;
1085
1333
  /**
1086
- * This is needed to avoid overwriting inputs
1087
- * @type {Batch | null}
1334
+ * @template V
1335
+ * @param {V} v
1336
+ * @param {Error | null} [stack]
1337
+ * @returns {Source<V>}
1088
1338
  */
1089
- var previous_batch = null;
1339
+ function source(v, stack) {
1340
+ return {
1341
+ f: 0,
1342
+ v,
1343
+ reactions: null,
1344
+ equals,
1345
+ rv: 0,
1346
+ wv: 0
1347
+ };
1348
+ }
1090
1349
  /**
1091
- * When time travelling (i.e. working in one batch, while other batches
1092
- * still have ongoing work), we ignore the real values of affected
1093
- * signals in favour of their values within the batch
1094
- * @type {Map<Value, any> | null}
1350
+ * @template V
1351
+ * @param {V} v
1352
+ * @param {Error | null} [stack]
1095
1353
  */
1096
- var batch_values = null;
1097
- /** @type {Effect | null} */
1098
- var last_scheduled_effect = null;
1099
- var is_flushing_sync = false;
1100
- var is_processing = false;
1354
+ /*#__NO_SIDE_EFFECTS__*/
1355
+ function state(v, stack) {
1356
+ const s = source(v, stack);
1357
+ push_reaction_value(s);
1358
+ return s;
1359
+ }
1101
1360
  /**
1102
- * During traversal, this is an array. Newly created effects are (if not immediately
1103
- * executed) pushed to this array, rather than going through the scheduling
1104
- * rigamarole that would cause another turn of the flush loop.
1105
- * @type {Effect[] | null}
1361
+ * @template V
1362
+ * @param {V} initial_value
1363
+ * @param {boolean} [immutable]
1364
+ * @returns {Source<V>}
1106
1365
  */
1107
- var collected_effects = null;
1366
+ /*#__NO_SIDE_EFFECTS__*/
1367
+ function mutable_source(initial_value, immutable = false, trackable = true) {
1368
+ const s = source(initial_value);
1369
+ if (!immutable) s.equals = safe_equals;
1370
+ if (legacy_mode_flag && trackable && component_context !== null && component_context.l !== null) {
1371
+ var _component_context$l;
1372
+ ((_component_context$l = component_context.l).s ?? (_component_context$l.s = [])).push(s);
1373
+ }
1374
+ return s;
1375
+ }
1108
1376
  /**
1109
- * An array of effects that are marked during traversal as a result of a `set`
1110
- * (not `internal_set`) call. These will be added to the next batch and
1111
- * trigger another `batch.process()`
1112
- * @type {Effect[] | null}
1113
- * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1377
+ * @template V
1378
+ * @param {Source<V>} source
1379
+ * @param {V} value
1380
+ * @param {boolean} [should_proxy]
1381
+ * @returns {V}
1114
1382
  */
1115
- var legacy_updates = null;
1116
- var flush_count = 0;
1117
- var uid = 1;
1118
- var _started = /* @__PURE__ */ new WeakMap();
1119
- var _prev = /* @__PURE__ */ new WeakMap();
1120
- var _next = /* @__PURE__ */ new WeakMap();
1121
- var _commit_callbacks = /* @__PURE__ */ new WeakMap();
1122
- var _discard_callbacks = /* @__PURE__ */ new WeakMap();
1123
- var _pending = /* @__PURE__ */ new WeakMap();
1124
- var _blocking_pending = /* @__PURE__ */ new WeakMap();
1125
- var _deferred = /* @__PURE__ */ new WeakMap();
1126
- var _roots = /* @__PURE__ */ new WeakMap();
1127
- var _new_effects = /* @__PURE__ */ new WeakMap();
1128
- var _dirty_effects = /* @__PURE__ */ new WeakMap();
1129
- var _maybe_dirty_effects = /* @__PURE__ */ new WeakMap();
1130
- var _skipped_branches = /* @__PURE__ */ new WeakMap();
1131
- var _unskipped_branches = /* @__PURE__ */ new WeakMap();
1132
- var _decrement_queued = /* @__PURE__ */ new WeakMap();
1133
- var _Batch_brand = /* @__PURE__ */ new WeakSet();
1134
- var Batch = class Batch {
1135
- constructor() {
1136
- _classPrivateMethodInitSpec(this, _Batch_brand);
1137
- _defineProperty(this, "id", uid++);
1138
- _classPrivateFieldInitSpec(this, _started, false);
1139
- _defineProperty(this, "linked", true);
1140
- _classPrivateFieldInitSpec(this, _prev, null);
1141
- _classPrivateFieldInitSpec(this, _next, null);
1142
- _defineProperty(
1143
- this,
1144
- /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
1145
- "async_deriveds",
1146
- /* @__PURE__ */ new Map()
1147
- );
1148
- _defineProperty(
1149
- this,
1150
- /**
1151
- * The current values of any signals that are updated in this batch.
1152
- * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
1153
- * They keys of this map are identical to `this.#previous`
1154
- * @type {Map<Value, [any, boolean]>}
1155
- */
1156
- "current",
1157
- /* @__PURE__ */ new Map()
1158
- );
1159
- _defineProperty(
1160
- this,
1161
- /**
1162
- * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
1163
- * They keys of this map are identical to `this.#current`
1164
- * @type {Map<Value, any>}
1165
- */
1166
- "previous",
1167
- /* @__PURE__ */ new Map()
1168
- );
1169
- _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
1170
- _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
1171
- _classPrivateFieldInitSpec(this, _pending, 0);
1172
- _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
1173
- _classPrivateFieldInitSpec(this, _deferred, null);
1174
- _classPrivateFieldInitSpec(this, _roots, []);
1175
- _classPrivateFieldInitSpec(this, _new_effects, []);
1176
- _classPrivateFieldInitSpec(this, _dirty_effects, /* @__PURE__ */ new Set());
1177
- _classPrivateFieldInitSpec(this, _maybe_dirty_effects, /* @__PURE__ */ new Set());
1178
- _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
1179
- _classPrivateFieldInitSpec(this, _unskipped_branches, /* @__PURE__ */ new Set());
1180
- _defineProperty(this, "is_fork", false);
1181
- _classPrivateFieldInitSpec(this, _decrement_queued, false);
1182
- if (last_batch === null) first_batch = last_batch = this;
1183
- else {
1184
- _classPrivateFieldSet2(_next, last_batch, this);
1185
- _classPrivateFieldSet2(_prev, this, last_batch);
1383
+ function set(source, value, should_proxy = false) {
1384
+ if (active_reaction !== null && (!untracking || (active_reaction.f & 131072) !== 0) && is_runes() && (active_reaction.f & 4325394) !== 0 && (current_sources === null || !current_sources.has(source))) state_unsafe_mutation();
1385
+ return internal_set(source, should_proxy ? proxy(value) : value, legacy_updates);
1386
+ }
1387
+ /**
1388
+ * @template V
1389
+ * @param {Source<V>} source
1390
+ * @param {V} value
1391
+ * @param {Effect[] | null} [updated_during_traversal]
1392
+ * @returns {V}
1393
+ */
1394
+ function internal_set(source, value, updated_during_traversal = null) {
1395
+ if (!source.equals(value)) {
1396
+ if (is_destroying_effect) old_values.set(source, value);
1397
+ else if (!old_values.has(source)) old_values.set(source, source.v);
1398
+ var batch = Batch.ensure();
1399
+ batch.capture(source, value);
1400
+ if ((source.f & 2) !== 0) {
1401
+ const derived = source;
1402
+ if ((source.f & 2048) !== 0) execute_derived(derived);
1403
+ if (batch_values === null) update_derived_status(derived);
1186
1404
  }
1187
- last_batch = this;
1405
+ source.wv = increment_write_version();
1406
+ mark_reactions(source, DIRTY, updated_during_traversal);
1407
+ if (is_runes() && active_effect !== null && (active_effect.f & 1024) !== 0 && (active_effect.f & 96) === 0) if (untracked_writes === null) set_untracked_writes([source]);
1408
+ else untracked_writes.push(source);
1409
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) flush_eager_effects();
1188
1410
  }
1189
- /**
1190
- * Add an effect to the #skipped_branches map and reset its children
1191
- * @param {Effect} effect
1192
- */
1193
- skip_effect(effect) {
1194
- if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
1195
- d: [],
1196
- m: []
1197
- });
1198
- _classPrivateFieldGet2(_unskipped_branches, this).delete(effect);
1199
- }
1200
- /**
1201
- * Remove an effect from the #skipped_branches map and reschedule
1202
- * any tracked dirty/maybe_dirty child effects
1203
- * @param {Effect} effect
1204
- * @param {(e: Effect) => void} callback
1205
- */
1206
- unskip_effect(effect, callback = (e) => this.schedule(e)) {
1207
- var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
1208
- if (tracked) {
1209
- _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
1210
- for (var e of tracked.d) {
1211
- set_signal_status(e, DIRTY);
1212
- callback(e);
1213
- }
1214
- for (e of tracked.m) {
1215
- set_signal_status(e, MAYBE_DIRTY);
1216
- callback(e);
1217
- }
1218
- }
1219
- _classPrivateFieldGet2(_unskipped_branches, this).add(effect);
1220
- }
1221
- /**
1222
- * Associate a change to a given source with the current
1223
- * batch, noting its previous and current values
1224
- * @param {Value} source
1225
- * @param {any} value
1226
- * @param {boolean} [is_derived]
1227
- */
1228
- capture(source, value, is_derived = false) {
1229
- if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
1230
- if ((source.f & 8388608) === 0) {
1231
- this.current.set(source, [value, is_derived]);
1232
- batch_values?.set(source, value);
1233
- }
1234
- if (!this.is_fork) source.v = value;
1235
- }
1236
- activate() {
1237
- current_batch = this;
1238
- }
1239
- deactivate() {
1240
- current_batch = null;
1241
- batch_values = null;
1242
- }
1243
- flush() {
1411
+ return value;
1412
+ }
1413
+ function flush_eager_effects() {
1414
+ eager_effects_deferred = false;
1415
+ for (const effect of eager_effects) {
1416
+ if ((effect.f & 1024) !== 0) set_signal_status(effect, MAYBE_DIRTY);
1417
+ let dirty;
1244
1418
  try {
1245
- is_processing = true;
1246
- current_batch = this;
1247
- _assertClassBrand(_Batch_brand, this, _process).call(this);
1248
- } finally {
1249
- flush_count = 0;
1250
- last_scheduled_effect = null;
1251
- collected_effects = null;
1252
- legacy_updates = null;
1253
- is_processing = false;
1254
- current_batch = null;
1255
- batch_values = null;
1256
- old_values.clear();
1257
- }
1258
- }
1259
- discard() {
1260
- for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
1261
- _classPrivateFieldGet2(_discard_callbacks, this).clear();
1262
- for (const deferred of this.async_deriveds.values()) deferred.reject(OBSOLETE);
1263
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1264
- _classPrivateFieldGet2(_deferred, this)?.resolve();
1265
- }
1266
- /**
1267
- * @param {Effect} effect
1268
- */
1269
- register_created_effect(effect) {
1270
- _classPrivateFieldGet2(_new_effects, this).push(effect);
1271
- }
1272
- /**
1273
- * @param {boolean} blocking
1274
- * @param {Effect} effect
1275
- */
1276
- increment(blocking, effect) {
1277
- _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) + 1);
1278
- if (blocking) {
1279
- let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
1280
- _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count + 1);
1419
+ dirty = is_dirty(effect);
1420
+ } catch {
1421
+ dirty = true;
1281
1422
  }
1423
+ if (dirty) update_effect(effect);
1282
1424
  }
1283
- /**
1284
- * @param {boolean} blocking
1285
- * @param {Effect} effect
1286
- */
1287
- decrement(blocking, effect) {
1288
- _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) - 1);
1289
- if (blocking) {
1290
- let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
1291
- if (blocking_pending_count === 1) _classPrivateFieldGet2(_blocking_pending, this).delete(effect);
1292
- else _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count - 1);
1425
+ eager_effects.clear();
1426
+ }
1427
+ /**
1428
+ * Silently (without using `get`) increment a source
1429
+ * @param {Source<number>} source
1430
+ */
1431
+ function increment(source) {
1432
+ set(source, source.v + 1);
1433
+ }
1434
+ /**
1435
+ * @param {Value} signal
1436
+ * @param {number} status should be DIRTY or MAYBE_DIRTY
1437
+ * @param {Effect[] | null} updated_during_traversal
1438
+ * @returns {void}
1439
+ */
1440
+ function mark_reactions(signal, status, updated_during_traversal) {
1441
+ var reactions = signal.reactions;
1442
+ if (reactions === null) return;
1443
+ var runes = is_runes();
1444
+ var length = reactions.length;
1445
+ for (var i = 0; i < length; i++) {
1446
+ var reaction = reactions[i];
1447
+ var flags = reaction.f;
1448
+ if (!runes && reaction === active_effect) continue;
1449
+ var not_dirty = (flags & DIRTY) === 0;
1450
+ if (not_dirty) set_signal_status(reaction, status);
1451
+ if ((flags & 131072) !== 0) eager_effects.add(reaction);
1452
+ else if ((flags & 2) !== 0) {
1453
+ var derived = reaction;
1454
+ batch_values?.delete(derived);
1455
+ if ((flags & 65536) === 0) {
1456
+ if (flags & 512 && (active_effect === null || (active_effect.f & 2097152) === 0)) reaction.f |= WAS_MARKED;
1457
+ mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
1458
+ }
1459
+ } else if (not_dirty) {
1460
+ var effect = reaction;
1461
+ if ((flags & 16) !== 0 && eager_block_effects !== null) eager_block_effects.add(effect);
1462
+ if (updated_during_traversal !== null) updated_during_traversal.push(effect);
1463
+ else schedule_effect(effect);
1293
1464
  }
1294
- if (_classPrivateFieldGet2(_decrement_queued, this)) return;
1295
- _classPrivateFieldSet2(_decrement_queued, this, true);
1296
- queue_micro_task(() => {
1297
- _classPrivateFieldSet2(_decrement_queued, this, false);
1298
- if (this.linked) this.flush();
1299
- });
1300
1465
  }
1466
+ }
1467
+ /**
1468
+ * @template T
1469
+ * @param {T} value
1470
+ * @returns {T}
1471
+ */
1472
+ function proxy(value) {
1473
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value || COMPONENT_SYMBOL in value) return value;
1474
+ const prototype = get_prototype_of(value);
1475
+ if (prototype !== object_prototype && prototype !== array_prototype) return value;
1476
+ /** @type {Map<any, Source<any>>} */
1477
+ var sources = /* @__PURE__ */ new Map();
1478
+ var is_proxied_array = is_array(value);
1479
+ var version = /* @__PURE__ */ state(0);
1480
+ var stack = null;
1481
+ var parent_version = update_version;
1301
1482
  /**
1302
- * @param {Set<Effect>} dirty_effects
1303
- * @param {Set<Effect>} maybe_dirty_effects
1483
+ * Executes the proxy in the context of the reaction it was originally created in, if any
1484
+ * @template T
1485
+ * @param {() => T} fn
1304
1486
  */
1305
- transfer_effects(dirty_effects, maybe_dirty_effects) {
1306
- for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects, this).add(e);
1307
- for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects, this).add(e);
1308
- dirty_effects.clear();
1309
- maybe_dirty_effects.clear();
1310
- }
1311
- /** @param {(batch: Batch) => void} fn */
1312
- oncommit(fn) {
1313
- _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
1314
- }
1315
- /** @param {(batch: Batch) => void} fn */
1316
- ondiscard(fn) {
1317
- _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
1318
- }
1319
- settled() {
1320
- return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
1321
- }
1322
- static ensure() {
1323
- if (current_batch === null) {
1324
- const batch = current_batch = new Batch();
1325
- if (!is_processing && !is_flushing_sync) queue_micro_task(() => {
1326
- if (!_classPrivateFieldGet2(_started, batch)) batch.flush();
1487
+ var with_parent = (fn) => {
1488
+ if (update_version === parent_version) return fn();
1489
+ var reaction = active_reaction;
1490
+ var version = update_version;
1491
+ set_active_reaction(null);
1492
+ set_update_version(parent_version);
1493
+ var result = fn();
1494
+ set_active_reaction(reaction);
1495
+ set_update_version(version);
1496
+ return result;
1497
+ };
1498
+ if (is_proxied_array) sources.set("length", /* @__PURE__ */ state(
1499
+ /** @type {any[]} */
1500
+ value.length,
1501
+ stack
1502
+ ));
1503
+ return new Proxy(value, {
1504
+ defineProperty(_, prop, descriptor) {
1505
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) state_descriptors_fixed();
1506
+ var s = sources.get(prop);
1507
+ if (s === void 0) with_parent(() => {
1508
+ var s = /* @__PURE__ */ state(descriptor.value, stack);
1509
+ sources.set(prop, s);
1510
+ return s;
1327
1511
  });
1328
- }
1329
- return current_batch;
1330
- }
1331
- apply() {
1332
- if (!async_mode_flag || !this.is_fork && _classPrivateFieldGet2(_prev, this) === null && _classPrivateFieldGet2(_next, this) === null) {
1333
- batch_values = null;
1334
- return;
1335
- }
1336
- batch_values = /* @__PURE__ */ new Map();
1337
- for (const [source, [value]] of this.current) batch_values.set(source, value);
1338
- for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1339
- if (batch === this || batch.is_fork) continue;
1340
- var intersects = false;
1341
- if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
1342
- if (is_derived) continue;
1343
- if (this.current.has(source)) {
1344
- intersects = true;
1345
- break;
1512
+ else set(s, descriptor.value, true);
1513
+ return true;
1514
+ },
1515
+ deleteProperty(target, prop) {
1516
+ var s = sources.get(prop);
1517
+ if (s === void 0) {
1518
+ if (prop in target) {
1519
+ const s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED, stack));
1520
+ sources.set(prop, s);
1521
+ increment(version);
1346
1522
  }
1523
+ } else {
1524
+ set(s, UNINITIALIZED);
1525
+ increment(version);
1347
1526
  }
1348
- if (!intersects) {
1349
- for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
1350
- }
1351
- }
1352
- }
1353
- /**
1354
- *
1355
- * @param {Effect} effect
1356
- */
1357
- schedule(effect) {
1358
- last_scheduled_effect = effect;
1359
- if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
1360
- effect.b.defer_effect(effect);
1361
- return;
1362
- }
1363
- var e = effect;
1364
- while (e.parent !== null) {
1365
- e = e.parent;
1366
- var flags = e.f;
1367
- if (collected_effects !== null && e === active_effect) {
1368
- if (async_mode_flag) return;
1369
- if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
1527
+ return true;
1528
+ },
1529
+ get(target, prop, receiver) {
1530
+ if (prop === STATE_SYMBOL) return value;
1531
+ var s = sources.get(prop);
1532
+ var exists = prop in target;
1533
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1534
+ s = with_parent(() => {
1535
+ return /* @__PURE__ */ state(proxy(exists ? target[prop] : UNINITIALIZED), stack);
1536
+ });
1537
+ sources.set(prop, s);
1370
1538
  }
1371
- if ((flags & 96) !== 0) {
1372
- if ((flags & 1024) === 0) return;
1373
- e.f ^= CLEAN;
1539
+ if (s !== void 0) {
1540
+ var v = get(s);
1541
+ return v === UNINITIALIZED ? void 0 : v;
1374
1542
  }
1375
- }
1376
- _classPrivateFieldGet2(_roots, this).push(e);
1377
- }
1378
- };
1379
- _Batch = Batch;
1380
- function _is_deferred() {
1381
- if (this.is_fork) return true;
1382
- for (const effect of _classPrivateFieldGet2(_blocking_pending, this).keys()) {
1383
- var e = effect;
1384
- var skipped = false;
1385
- while (e.parent !== null) {
1386
- if (_classPrivateFieldGet2(_skipped_branches, this).has(e)) {
1387
- skipped = true;
1388
- break;
1543
+ return Reflect.get(target, prop, receiver);
1544
+ },
1545
+ getOwnPropertyDescriptor(target, prop) {
1546
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1547
+ if (descriptor && "value" in descriptor) {
1548
+ var s = sources.get(prop);
1549
+ if (s) descriptor.value = get(s);
1550
+ } else if (descriptor === void 0) {
1551
+ var source = sources.get(prop);
1552
+ var value = source?.v;
1553
+ if (source !== void 0 && value !== UNINITIALIZED) return {
1554
+ enumerable: true,
1555
+ configurable: true,
1556
+ value,
1557
+ writable: true
1558
+ };
1389
1559
  }
1390
- e = e.parent;
1391
- }
1392
- if (!skipped) return true;
1393
- }
1394
- return false;
1395
- }
1396
- function _process() {
1397
- _classPrivateFieldSet2(_started, this, true);
1398
- if (flush_count++ > 1e3) {
1399
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1400
- infinite_loop_guard();
1401
- }
1402
- for (const e of _classPrivateFieldGet2(_dirty_effects, this)) {
1403
- _classPrivateFieldGet2(_maybe_dirty_effects, this).delete(e);
1404
- set_signal_status(e, DIRTY);
1405
- this.schedule(e);
1406
- }
1407
- for (const e of _classPrivateFieldGet2(_maybe_dirty_effects, this)) {
1408
- set_signal_status(e, MAYBE_DIRTY);
1409
- this.schedule(e);
1410
- }
1411
- const roots = _classPrivateFieldGet2(_roots, this);
1412
- _classPrivateFieldSet2(_roots, this, []);
1413
- this.apply();
1414
- /** @type {Effect[]} */
1415
- var effects = collected_effects = [];
1416
- /** @type {Effect[]} */
1417
- var render_effects = [];
1418
- /**
1419
- * @type {Effect[]}
1420
- * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1421
- */
1422
- var updates = legacy_updates = [];
1423
- for (const root of roots) try {
1424
- _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
1425
- } catch (e) {
1426
- reset_all(root);
1427
- if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
1428
- throw e;
1429
- }
1430
- current_batch = null;
1431
- if (updates.length > 0) {
1432
- var batch = _Batch.ensure();
1433
- for (const e of updates) batch.schedule(e);
1434
- }
1435
- collected_effects = null;
1436
- legacy_updates = null;
1437
- if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
1438
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
1439
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
1440
- for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
1441
- if (updates.length > 0)
1442
- /** @type {Batch} */ _assertClassBrand(_Batch_brand, current_batch, _process).call(current_batch);
1443
- return;
1444
- }
1445
- const earlier_batch = _assertClassBrand(_Batch_brand, this, _find_earlier_batch).call(this);
1446
- if (earlier_batch) {
1447
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
1448
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
1449
- _assertClassBrand(_Batch_brand, earlier_batch, _merge).call(earlier_batch, this);
1450
- return;
1451
- }
1452
- _classPrivateFieldGet2(_dirty_effects, this).clear();
1453
- _classPrivateFieldGet2(_maybe_dirty_effects, this).clear();
1454
- for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
1455
- _classPrivateFieldGet2(_commit_callbacks, this).clear();
1456
- previous_batch = this;
1457
- flush_queued_effects(render_effects);
1458
- flush_queued_effects(effects);
1459
- previous_batch = null;
1460
- _classPrivateFieldGet2(_deferred, this)?.resolve();
1461
- var next_batch = current_batch;
1462
- if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_roots, this).length === 0 || next_batch !== null)) {
1463
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1464
- if (async_mode_flag) {
1465
- _assertClassBrand(_Batch_brand, this, _commit).call(this);
1466
- current_batch = next_batch;
1467
- }
1468
- }
1469
- if (_classPrivateFieldGet2(_roots, this).length > 0) if (next_batch !== null) {
1470
- const batch = next_batch;
1471
- _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
1472
- } else next_batch = this;
1473
- if (next_batch !== null) _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
1474
- }
1475
- /**
1476
- * Traverse the effect tree, executing effects or stashing
1477
- * them for later execution as appropriate
1478
- * @param {Effect} root
1479
- * @param {Effect[]} effects
1480
- * @param {Effect[]} render_effects
1481
- */
1482
- function _traverse(root, effects, render_effects) {
1483
- root.f ^= CLEAN;
1484
- var effect = root.first;
1485
- while (effect !== null) {
1486
- var flags = effect.f;
1487
- var is_branch = (flags & 96) !== 0;
1488
- if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
1489
- if (is_branch) effect.f ^= CLEAN;
1490
- else if ((flags & 4) !== 0) effects.push(effect);
1491
- else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
1492
- else if (is_dirty(effect)) {
1493
- if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects, this).add(effect);
1494
- update_effect(effect);
1560
+ return descriptor;
1561
+ },
1562
+ has(target, prop) {
1563
+ if (prop === STATE_SYMBOL) return true;
1564
+ var s = sources.get(prop);
1565
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
1566
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
1567
+ if (s === void 0) {
1568
+ s = with_parent(() => {
1569
+ return /* @__PURE__ */ state(has ? proxy(target[prop]) : UNINITIALIZED, stack);
1570
+ });
1571
+ sources.set(prop, s);
1572
+ }
1573
+ if (get(s) === UNINITIALIZED) return false;
1495
1574
  }
1496
- var child = effect.first;
1497
- if (child !== null) {
1498
- effect = child;
1499
- continue;
1575
+ return has;
1576
+ },
1577
+ set(target, prop, value, receiver) {
1578
+ var s = sources.get(prop);
1579
+ var has = prop in target;
1580
+ if (is_proxied_array && prop === "length") for (var i = value; i < s.v; i += 1) {
1581
+ var other_s = sources.get(i + "");
1582
+ if (other_s !== void 0) set(other_s, UNINITIALIZED);
1583
+ else if (i in target) {
1584
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED, stack));
1585
+ sources.set(i + "", other_s);
1586
+ }
1500
1587
  }
1501
- }
1502
- while (effect !== null) {
1503
- var next = effect.next;
1504
- if (next !== null) {
1505
- effect = next;
1506
- break;
1588
+ if (s === void 0) {
1589
+ if (!has || get_descriptor(target, prop)?.writable) {
1590
+ s = with_parent(() => /* @__PURE__ */ state(void 0, stack));
1591
+ set(s, proxy(value));
1592
+ sources.set(prop, s);
1593
+ }
1594
+ } else {
1595
+ has = s.v !== UNINITIALIZED;
1596
+ var p = with_parent(() => proxy(value));
1597
+ set(s, p);
1507
1598
  }
1508
- effect = effect.parent;
1509
- }
1510
- }
1511
- }
1512
- function _find_earlier_batch() {
1513
- var batch = _classPrivateFieldGet2(_prev, this);
1514
- while (batch !== null) {
1515
- if (!batch.is_fork) {
1516
- for (const [value, [, is_derived]] of this.current) if (batch.current.has(value) && !is_derived) return batch;
1599
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1600
+ if (descriptor?.set) descriptor.set.call(receiver, value);
1601
+ if (!has) {
1602
+ if (is_proxied_array && typeof prop === "string") {
1603
+ var ls = sources.get("length");
1604
+ var n = Number(prop);
1605
+ if (Number.isInteger(n) && n >= ls.v) set(ls, n + 1);
1606
+ }
1607
+ increment(version);
1608
+ }
1609
+ return true;
1610
+ },
1611
+ ownKeys(target) {
1612
+ get(version);
1613
+ var own_keys = Reflect.ownKeys(target).filter((key) => {
1614
+ var source = sources.get(key);
1615
+ return source === void 0 || source.v !== UNINITIALIZED;
1616
+ });
1617
+ for (var [key, source] of sources) if (source.v !== UNINITIALIZED && !(key in target)) own_keys.push(key);
1618
+ return own_keys;
1619
+ },
1620
+ setPrototypeOf() {
1621
+ state_prototype_fixed();
1517
1622
  }
1518
- batch = _classPrivateFieldGet2(_prev, batch);
1519
- }
1520
- return null;
1623
+ });
1521
1624
  }
1625
+ //#endregion
1626
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/operations.js
1627
+ /** @type {Window} */
1628
+ var $window;
1629
+ /** @type {boolean} */
1630
+ var is_firefox;
1631
+ /** @type {() => Node | null} */
1632
+ var first_child_getter;
1633
+ /** @type {() => Node | null} */
1634
+ var next_sibling_getter;
1522
1635
  /**
1523
- * @param {Batch} batch
1636
+ * Initialize these lazily to avoid issues when using the runtime in a server context
1637
+ * where these globals are not available while avoiding a separate server entry point
1524
1638
  */
1525
- function _merge(batch) {
1526
- for (const [source, value] of batch.current) {
1527
- if (!this.previous.has(source) && batch.previous.has(source)) this.previous.set(source, batch.previous.get(source));
1528
- this.current.set(source, value);
1529
- }
1530
- for (const [effect, deferred] of batch.async_deriveds) {
1531
- const d = this.async_deriveds.get(effect);
1532
- if (d) deferred.promise.then(d.resolve).catch(d.reject);
1639
+ function init_operations() {
1640
+ if ($window !== void 0) return;
1641
+ $window = window;
1642
+ is_firefox = /Firefox/.test(navigator.userAgent);
1643
+ var element_prototype = Element.prototype;
1644
+ var node_prototype = Node.prototype;
1645
+ var text_prototype = Text.prototype;
1646
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
1647
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
1648
+ if (is_extensible(element_prototype)) {
1649
+ /** @type {any} */ element_prototype[CLASS_CACHE] = void 0;
1650
+ /** @type {any} */ element_prototype[ATTRIBUTES_CACHE] = null;
1651
+ /** @type {any} */ element_prototype[STYLE_CACHE] = void 0;
1652
+ element_prototype.__e = void 0;
1533
1653
  }
1534
- batch.async_deriveds.clear();
1535
- this.transfer_effects(_classPrivateFieldGet2(_dirty_effects, batch), _classPrivateFieldGet2(_maybe_dirty_effects, batch));
1536
- /**
1537
- * mark all effects that depend on `batch.current`, except the
1538
- * async effects that we just resolved (TODO unless they depend
1539
- * on values in this batch that are NOT in the later batch?).
1540
- * Through this we also will populate the correct #skipped_branches,
1541
- * oncommit callbacks etc, so we don't need to merge them separately.
1542
- * @param {Value} value
1543
- */
1544
- const mark = (value) => {
1545
- var reactions = value.reactions;
1546
- if (reactions === null) return;
1547
- if ((value.f & 2) !== 0 && (value.f & 6144) === 0) return;
1548
- for (const reaction of reactions) {
1549
- var flags = reaction.f;
1550
- if ((flags & 2) !== 0) mark(reaction);
1551
- else {
1552
- var effect = reaction;
1553
- if (flags & 4194320 && !this.async_deriveds.has(effect)) {
1554
- _classPrivateFieldGet2(_maybe_dirty_effects, this).delete(effect);
1555
- set_signal_status(effect, DIRTY);
1556
- this.schedule(effect);
1557
- }
1558
- }
1559
- }
1560
- };
1561
- for (const source of this.current.keys()) mark(source);
1562
- this.oncommit(() => batch.discard());
1563
- _assertClassBrand(_Batch_brand, batch, _unlink).call(batch);
1564
- current_batch = this;
1565
- _assertClassBrand(_Batch_brand, this, _process).call(this);
1654
+ if (is_extensible(text_prototype))
1655
+ /** @type {any} */ text_prototype[TEXT_CACHE] = void 0;
1566
1656
  }
1567
1657
  /**
1568
- * @param {Effect[]} effects
1658
+ * @param {string} value
1659
+ * @returns {Text}
1569
1660
  */
1570
- function _defer_effects(effects) {
1571
- for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
1572
- }
1573
- function _commit() {
1574
- for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1575
- var is_earlier = batch.id < this.id;
1576
- /** @type {Source[]} */
1577
- var sources = [];
1578
- for (const [source, [value, is_derived]] of this.current) {
1579
- if (batch.current.has(source)) {
1580
- var batch_value = batch.current.get(source)[0];
1581
- if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
1582
- else continue;
1583
- }
1584
- sources.push(source);
1585
- }
1586
- if (is_earlier) for (const [effect, deferred] of this.async_deriveds) {
1587
- const d = batch.async_deriveds.get(effect);
1588
- if (d) deferred.promise.then(d.resolve).catch(d.reject);
1589
- }
1590
- var current = [...batch.current.keys()].filter((source) => !batch.current.get(source)[1]);
1591
- if (!_classPrivateFieldGet2(_started, batch) || current.length === 0) continue;
1592
- var others = current.filter((source) => !this.current.has(source));
1593
- if (others.length === 0) {
1594
- if (is_earlier) batch.discard();
1595
- } else if (sources.length > 0) {
1596
- if (is_earlier) for (const unskipped of _classPrivateFieldGet2(_unskipped_branches, this)) batch.unskip_effect(unskipped, (e) => {
1597
- if ((e.f & 4194320) !== 0) batch.schedule(e);
1598
- else _assertClassBrand(_Batch_brand, batch, _defer_effects).call(batch, [e]);
1599
- });
1600
- batch.activate();
1601
- /** @type {Set<Value>} */
1602
- var marked = /* @__PURE__ */ new Set();
1603
- /** @type {Map<Reaction, boolean>} */
1604
- var checked = /* @__PURE__ */ new Map();
1605
- for (var source of sources) mark_effects(source, others, marked, checked);
1606
- checked = /* @__PURE__ */ new Map();
1607
- var current_unequal = [...batch.current].filter(([c, v1]) => {
1608
- const v2 = this.current.get(c);
1609
- if (!v2) return true;
1610
- return v2[0] !== v1[0] || v2[1] !== v1[1];
1611
- }).map(([c]) => c);
1612
- if (current_unequal.length > 0) {
1613
- for (const effect of _classPrivateFieldGet2(_new_effects, this)) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1614
- set_signal_status(effect, DIRTY);
1615
- batch.schedule(effect);
1616
- } else _classPrivateFieldGet2(_dirty_effects, batch).add(effect);
1617
- }
1618
- if (_classPrivateFieldGet2(_roots, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1619
- batch.apply();
1620
- for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1621
- _classPrivateFieldSet2(_roots, batch, []);
1622
- }
1623
- batch.deactivate();
1624
- }
1625
- }
1626
- }
1627
- function _unlink() {
1628
- if (!this.linked) return;
1629
- var prev = _classPrivateFieldGet2(_prev, this);
1630
- var next = _classPrivateFieldGet2(_next, this);
1631
- if (prev === null) first_batch = next;
1632
- else _classPrivateFieldSet2(_next, prev, next);
1633
- if (next === null) last_batch = prev;
1634
- else _classPrivateFieldSet2(_prev, next, prev);
1635
- this.linked = false;
1661
+ function create_text(value = "") {
1662
+ return document.createTextNode(value);
1636
1663
  }
1637
1664
  /**
1638
- * Synchronously flush any pending updates.
1639
- * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1640
- * @template [T=void]
1641
- * @param {(() => T) | undefined} [fn]
1642
- * @returns {T}
1665
+ * @template {Node} N
1666
+ * @param {N} node
1643
1667
  */
1644
- function flushSync(fn) {
1645
- var was_flushing_sync = is_flushing_sync;
1646
- is_flushing_sync = true;
1647
- try {
1648
- var result;
1649
- if (fn) {
1650
- if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
1651
- result = fn();
1652
- }
1653
- while (true) {
1654
- flush_tasks();
1655
- if (current_batch === null) return result;
1656
- current_batch.flush();
1657
- }
1658
- } finally {
1659
- is_flushing_sync = was_flushing_sync;
1660
- }
1668
+ /*@__NO_SIDE_EFFECTS__*/
1669
+ function get_first_child(node) {
1670
+ return first_child_getter.call(node);
1661
1671
  }
1662
- function infinite_loop_guard() {
1663
- try {
1664
- effect_update_depth_exceeded();
1665
- } catch (error) {
1666
- invoke_error_boundary(error, last_scheduled_effect);
1667
- }
1672
+ /**
1673
+ * @template {Node} N
1674
+ * @param {N} node
1675
+ */
1676
+ /*@__NO_SIDE_EFFECTS__*/
1677
+ function get_next_sibling(node) {
1678
+ return next_sibling_getter.call(node);
1668
1679
  }
1669
- /** @type {Set<Effect> | null} */
1670
- var eager_block_effects = null;
1671
1680
  /**
1672
- * @param {Array<Effect>} effects
1681
+ * @template {Node} N
1682
+ * @param {N} node
1673
1683
  * @returns {void}
1674
1684
  */
1675
- function flush_queued_effects(effects) {
1676
- var length = effects.length;
1677
- if (length === 0) return;
1678
- var i = 0;
1679
- while (i < length) {
1680
- var effect = effects[i++];
1681
- if ((effect.f & 24576) === 0 && is_dirty(effect)) {
1682
- eager_block_effects = /* @__PURE__ */ new Set();
1683
- update_effect(effect);
1684
- if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
1685
- if (eager_block_effects?.size > 0) {
1686
- old_values.clear();
1687
- for (const e of eager_block_effects) {
1688
- if ((e.f & 24576) !== 0) continue;
1689
- /** @type {Effect[]} */
1690
- const ordered_effects = [e];
1691
- let ancestor = e.parent;
1692
- while (ancestor !== null) {
1693
- if (eager_block_effects.has(ancestor)) {
1694
- eager_block_effects.delete(ancestor);
1695
- ordered_effects.push(ancestor);
1696
- }
1697
- ancestor = ancestor.parent;
1698
- }
1699
- for (let j = ordered_effects.length - 1; j >= 0; j--) {
1700
- const e = ordered_effects[j];
1701
- if ((e.f & 24576) !== 0) continue;
1702
- update_effect(e);
1703
- }
1704
- }
1705
- eager_block_effects.clear();
1706
- }
1707
- }
1708
- }
1709
- eager_block_effects = null;
1685
+ function clear_text_content(node) {
1686
+ node.textContent = "";
1710
1687
  }
1711
1688
  /**
1712
- * This is similar to `mark_reactions`, but it only marks async/block effects
1713
- * depending on `value` and at least one of the other `sources`, so that
1714
- * these effects can re-run after another batch has been committed
1715
- * @param {Value} value
1716
- * @param {Source[]} sources
1717
- * @param {Set<Value>} marked
1718
- * @param {Map<Reaction, boolean>} checked
1689
+ * Branching here is intentional and load-bearing for perf. `createElement(tag)`
1690
+ * hits a fast path in Blink that `createElementNS(NAMESPACE_HTML, tag)` doesn't,
1691
+ * and passing an explicit `undefined` as the trailing options arg measurably
1692
+ * slows both APIs. Funnelling every case through a single `createElementNS(ns,
1693
+ * tag, options)` call would be smaller but slower on the HTML path.
1694
+ *
1695
+ * @template {keyof HTMLElementTagNameMap | string} T
1696
+ * @param {T} tag
1697
+ * @param {string} [namespace]
1698
+ * @param {string} [is]
1699
+ * @returns {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element}
1719
1700
  */
1720
- function mark_effects(value, sources, marked, checked) {
1721
- if (marked.has(value)) return;
1722
- marked.add(value);
1723
- if (value.reactions !== null) for (const reaction of value.reactions) {
1724
- const flags = reaction.f;
1725
- if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
1726
- else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
1727
- set_signal_status(reaction, DIRTY);
1728
- schedule_effect(reaction);
1729
- }
1730
- }
1701
+ function create_element(tag, namespace, is) {
1702
+ if (namespace == null || namespace === "http://www.w3.org/1999/xhtml") return is ? document.createElement(tag, { is }) : document.createElement(tag);
1703
+ return is ? document.createElementNS(namespace, tag, { is }) : document.createElementNS(namespace, tag);
1731
1704
  }
1732
1705
  /**
1733
- * @param {Reaction} reaction
1734
- * @param {Source[]} sources
1735
- * @param {Map<Reaction, boolean>} checked
1706
+ * @param {unknown} error
1736
1707
  */
1737
- function depends_on(reaction, sources, checked) {
1738
- const depends = checked.get(reaction);
1739
- if (depends !== void 0) return depends;
1740
- if (reaction.deps !== null) for (const dep of reaction.deps) {
1741
- if (includes.call(sources, dep)) return true;
1742
- if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
1743
- checked.set(dep, true);
1744
- return true;
1745
- }
1708
+ function handle_error(error) {
1709
+ var effect = active_effect;
1710
+ if (effect === null) {
1711
+ /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
1712
+ return error;
1746
1713
  }
1747
- checked.set(reaction, false);
1748
- return false;
1714
+ if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
1715
+ invoke_error_boundary(error, effect);
1749
1716
  }
1750
1717
  /**
1751
- * @param {Effect} effect
1752
- * @returns {void}
1718
+ * @param {unknown} error
1719
+ * @param {Effect | null} effect
1753
1720
  */
1754
- function schedule_effect(effect) {
1755
- /** @type {Batch} */ current_batch.schedule(effect);
1721
+ function invoke_error_boundary(error, effect) {
1722
+ if (effect !== null && (effect.f & 16384) !== 0) return;
1723
+ while (effect !== null) {
1724
+ if ((effect.f & 128) !== 0 && (effect.f & 33570816) === 0) {
1725
+ if ((effect.f & 32768) === 0) throw error;
1726
+ try {
1727
+ /** @type {Boundary} */ effect.b.error(error);
1728
+ return;
1729
+ } catch (e) {
1730
+ error = e;
1731
+ }
1732
+ }
1733
+ effect = effect.parent;
1734
+ }
1735
+ throw error;
1756
1736
  }
1737
+ //#endregion
1738
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/effects.js
1739
+ /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
1757
1740
  /**
1758
- * Mark all the effects inside a skipped branch CLEAN, so that
1759
- * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1760
- * effects so they can be rescheduled if the branch survives.
1761
1741
  * @param {Effect} effect
1762
- * @param {{ d: Effect[], m: Effect[] }} tracked
1742
+ * @param {Effect} parent_effect
1763
1743
  */
1764
- function reset_branch(effect, tracked) {
1765
- if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1766
- if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1767
- else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1768
- set_signal_status(effect, CLEAN);
1769
- var e = effect.first;
1770
- while (e !== null) {
1771
- reset_branch(e, tracked);
1772
- e = e.next;
1744
+ function push_effect(effect, parent_effect) {
1745
+ var parent_last = parent_effect.last;
1746
+ if (parent_last === null) parent_effect.last = parent_effect.first = effect;
1747
+ else {
1748
+ parent_last.next = effect;
1749
+ effect.prev = parent_last;
1750
+ parent_effect.last = effect;
1773
1751
  }
1774
1752
  }
1775
1753
  /**
1776
- * Mark an entire effect tree clean following an error
1777
- * @param {Effect} effect
1754
+ * @param {number} type
1755
+ * @param {null | (() => void | (() => void))} fn
1756
+ * @returns {Effect}
1778
1757
  */
1779
- function reset_all(effect) {
1780
- set_signal_status(effect, CLEAN);
1781
- var e = effect.first;
1782
- while (e !== null) {
1783
- reset_all(e);
1784
- e = e.next;
1758
+ function create_effect(type, fn) {
1759
+ var parent = active_effect;
1760
+ if (parent !== null && (parent.f & 8192) !== 0) type |= INERT;
1761
+ /** @type {Effect} */
1762
+ var effect = {
1763
+ ctx: component_context,
1764
+ deps: null,
1765
+ nodes: null,
1766
+ f: type | DIRTY | 512,
1767
+ first: null,
1768
+ fn,
1769
+ last: null,
1770
+ next: null,
1771
+ parent,
1772
+ b: parent && parent.b,
1773
+ prev: null,
1774
+ teardown: null,
1775
+ wv: 0,
1776
+ ac: null
1777
+ };
1778
+ current_batch?.register_created_effect(effect);
1779
+ /** @type {Effect | null} */
1780
+ var e = effect;
1781
+ if ((type & 4) !== 0) if (collected_effects !== null) collected_effects.push(effect);
1782
+ else Batch.ensure().schedule(effect);
1783
+ else if (fn !== null) {
1784
+ try {
1785
+ update_effect(effect);
1786
+ } catch (e) {
1787
+ destroy_effect(effect);
1788
+ throw e;
1789
+ }
1790
+ if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && (e.f & 524288) === 0) {
1791
+ e = e.first;
1792
+ if ((type & 16) !== 0 && (type & 65536) !== 0 && e !== null) e.f |= EFFECT_TRANSPARENT;
1793
+ }
1794
+ }
1795
+ if (e !== null) {
1796
+ e.parent = parent;
1797
+ if (parent !== null) push_effect(e, parent);
1798
+ if (active_reaction !== null && (active_reaction.f & 2) !== 0 && (type & 64) === 0) {
1799
+ var derived = active_reaction;
1800
+ (derived.effects ?? (derived.effects = [])).push(e);
1801
+ }
1785
1802
  }
1803
+ return effect;
1786
1804
  }
1787
- //#endregion
1788
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/sources.js
1789
- /** @import { Derived, Effect, Source, Value } from '#client' */
1790
- /** @type {Set<Effect>} */
1791
- var eager_effects = /* @__PURE__ */ new Set();
1792
- /** @type {Map<Source, any>} */
1793
- var old_values = /* @__PURE__ */ new Map();
1794
- var eager_effects_deferred = false;
1795
1805
  /**
1796
- * @template V
1797
- * @param {V} v
1798
- * @param {Error | null} [stack]
1799
- * @returns {Source<V>}
1806
+ * Internal representation of `$effect.tracking()`
1807
+ * @returns {boolean}
1800
1808
  */
1801
- function source(v, stack) {
1802
- return {
1803
- f: 0,
1804
- v,
1805
- reactions: null,
1806
- equals,
1807
- rv: 0,
1808
- wv: 0
1809
+ function effect_tracking() {
1810
+ return active_reaction !== null && !untracking;
1811
+ }
1812
+ /**
1813
+ * @param {() => void | (() => void)} fn
1814
+ */
1815
+ function create_user_effect(fn) {
1816
+ return create_effect(4 | USER_EFFECT, fn);
1817
+ }
1818
+ /**
1819
+ * Internal representation of `$effect.root(...)`
1820
+ * @param {() => void | (() => void)} fn
1821
+ * @returns {() => void}
1822
+ */
1823
+ function effect_root(fn) {
1824
+ Batch.ensure();
1825
+ const effect = create_effect(64 | EFFECT_PRESERVED, fn);
1826
+ return () => {
1827
+ destroy_effect(effect);
1809
1828
  };
1810
1829
  }
1811
1830
  /**
1812
- * @template V
1813
- * @param {V} v
1814
- * @param {Error | null} [stack]
1831
+ * An effect root whose children can transition out
1832
+ * @param {() => void} fn
1833
+ * @returns {(options?: { outro?: boolean }) => Promise<void>}
1815
1834
  */
1816
- /*#__NO_SIDE_EFFECTS__*/
1817
- function state(v, stack) {
1818
- const s = source(v, stack);
1819
- push_reaction_value(s);
1820
- return s;
1835
+ function component_root(fn) {
1836
+ Batch.ensure();
1837
+ const effect = create_effect(64 | EFFECT_PRESERVED, fn);
1838
+ return (options = {}) => {
1839
+ return new Promise((fulfil) => {
1840
+ if (options.outro) pause_effect(effect, () => {
1841
+ destroy_effect(effect);
1842
+ fulfil(void 0);
1843
+ });
1844
+ else {
1845
+ destroy_effect(effect);
1846
+ fulfil(void 0);
1847
+ }
1848
+ });
1849
+ };
1821
1850
  }
1822
1851
  /**
1823
- * @template V
1824
- * @param {V} initial_value
1825
- * @param {boolean} [immutable]
1826
- * @returns {Source<V>}
1852
+ * @param {() => void | (() => void)} fn
1853
+ * @returns {Effect}
1827
1854
  */
1828
- /*#__NO_SIDE_EFFECTS__*/
1829
- function mutable_source(initial_value, immutable = false, trackable = true) {
1830
- const s = source(initial_value);
1831
- if (!immutable) s.equals = safe_equals;
1832
- if (legacy_mode_flag && trackable && component_context !== null && component_context.l !== null) {
1833
- var _component_context$l;
1834
- ((_component_context$l = component_context.l).s ?? (_component_context$l.s = [])).push(s);
1835
- }
1836
- return s;
1855
+ function effect(fn) {
1856
+ return create_effect(4, fn);
1837
1857
  }
1838
1858
  /**
1839
- * @template V
1840
- * @param {Source<V>} source
1841
- * @param {V} value
1842
- * @param {boolean} [should_proxy]
1843
- * @returns {V}
1859
+ * @param {() => void | (() => void)} fn
1860
+ * @returns {Effect}
1844
1861
  */
1845
- function set(source, value, should_proxy = false) {
1846
- if (active_reaction !== null && (!untracking || (active_reaction.f & 131072) !== 0) && is_runes() && (active_reaction.f & 4325394) !== 0 && (current_sources === null || !current_sources.has(source))) state_unsafe_mutation();
1847
- return internal_set(source, should_proxy ? proxy(value) : value, legacy_updates);
1862
+ function render_effect(fn, flags = 0) {
1863
+ return create_effect(8 | flags, fn);
1848
1864
  }
1849
1865
  /**
1850
- * @template V
1851
- * @param {Source<V>} source
1852
- * @param {V} value
1853
- * @param {Effect[] | null} [updated_during_traversal]
1854
- * @returns {V}
1866
+ * @param {(() => void)} fn
1867
+ * @param {number} flags
1855
1868
  */
1856
- function internal_set(source, value, updated_during_traversal = null) {
1857
- if (!source.equals(value)) {
1858
- old_values.set(source, is_destroying_effect ? value : source.v);
1859
- var batch = Batch.ensure();
1860
- batch.capture(source, value);
1861
- if ((source.f & 2) !== 0) {
1862
- const derived = source;
1863
- if ((source.f & 2048) !== 0) execute_derived(derived);
1864
- if (batch_values === null) update_derived_status(derived);
1865
- }
1866
- source.wv = increment_write_version();
1867
- mark_reactions(source, DIRTY, updated_during_traversal);
1868
- if (is_runes() && active_effect !== null && (active_effect.f & 1024) !== 0 && (active_effect.f & 96) === 0) if (untracked_writes === null) set_untracked_writes([source]);
1869
- else untracked_writes.push(source);
1870
- if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) flush_eager_effects();
1871
- }
1872
- return value;
1869
+ function block(fn, flags = 0) {
1870
+ return create_effect(16 | flags, fn);
1873
1871
  }
1874
- function flush_eager_effects() {
1875
- eager_effects_deferred = false;
1876
- for (const effect of eager_effects) {
1877
- if ((effect.f & 1024) !== 0) set_signal_status(effect, MAYBE_DIRTY);
1878
- let dirty;
1872
+ /**
1873
+ * @param {(() => void)} fn
1874
+ */
1875
+ function branch(fn) {
1876
+ return create_effect(32 | EFFECT_PRESERVED, fn);
1877
+ }
1878
+ /**
1879
+ * @param {Effect} effect
1880
+ */
1881
+ function execute_effect_teardown(effect) {
1882
+ var teardown = effect.teardown;
1883
+ if (teardown !== null) {
1884
+ const previously_destroying_effect = is_destroying_effect;
1885
+ const previous_reaction = active_reaction;
1886
+ set_is_destroying_effect(true);
1887
+ set_active_reaction(null);
1879
1888
  try {
1880
- dirty = is_dirty(effect);
1881
- } catch {
1882
- dirty = true;
1889
+ teardown.call(null);
1890
+ } catch (error) {
1891
+ invoke_error_boundary(error, effect.parent);
1892
+ } finally {
1893
+ set_is_destroying_effect(previously_destroying_effect);
1894
+ set_active_reaction(previous_reaction);
1883
1895
  }
1884
- if (dirty) update_effect(effect);
1885
1896
  }
1886
- eager_effects.clear();
1887
1897
  }
1888
1898
  /**
1889
- * Silently (without using `get`) increment a source
1890
- * @param {Source<number>} source
1899
+ * @param {Effect} signal
1900
+ * @param {boolean} remove_dom
1901
+ * @returns {void}
1891
1902
  */
1892
- function increment(source) {
1893
- set(source, source.v + 1);
1894
- }
1895
- /**
1896
- * @param {Value} signal
1897
- * @param {number} status should be DIRTY or MAYBE_DIRTY
1898
- * @param {Effect[] | null} updated_during_traversal
1899
- * @returns {void}
1900
- */
1901
- function mark_reactions(signal, status, updated_during_traversal) {
1902
- var reactions = signal.reactions;
1903
- if (reactions === null) return;
1904
- var runes = is_runes();
1905
- var length = reactions.length;
1906
- for (var i = 0; i < length; i++) {
1907
- var reaction = reactions[i];
1908
- var flags = reaction.f;
1909
- if (!runes && reaction === active_effect) continue;
1910
- var not_dirty = (flags & DIRTY) === 0;
1911
- if (not_dirty) set_signal_status(reaction, status);
1912
- if ((flags & 131072) !== 0) eager_effects.add(reaction);
1913
- else if ((flags & 2) !== 0) {
1914
- var derived = reaction;
1915
- batch_values?.delete(derived);
1916
- if ((flags & 65536) === 0) {
1917
- if (flags & 512 && (active_effect === null || (active_effect.f & 2097152) === 0)) reaction.f |= WAS_MARKED;
1918
- mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
1919
- }
1920
- } else if (not_dirty) {
1921
- var effect = reaction;
1922
- if ((flags & 16) !== 0 && eager_block_effects !== null) eager_block_effects.add(effect);
1923
- if (updated_during_traversal !== null) updated_during_traversal.push(effect);
1924
- else schedule_effect(effect);
1925
- }
1903
+ function destroy_effect_children(signal, remove_dom = false) {
1904
+ var effect = signal.first;
1905
+ signal.first = signal.last = null;
1906
+ while (effect !== null) {
1907
+ const controller = effect.ac;
1908
+ if (controller !== null) without_reactive_context(() => {
1909
+ controller.abort(STALE_REACTION);
1910
+ });
1911
+ var next = effect.next;
1912
+ if ((effect.f & 64) !== 0) effect.parent = null;
1913
+ else destroy_effect(effect, remove_dom);
1914
+ effect = next;
1926
1915
  }
1927
1916
  }
1928
1917
  /**
1929
- * @template T
1930
- * @param {T} value
1931
- * @returns {T}
1918
+ * @param {Effect} signal
1919
+ * @returns {void}
1932
1920
  */
1933
- function proxy(value) {
1934
- if (typeof value !== "object" || value === null || STATE_SYMBOL in value) return value;
1935
- const prototype = get_prototype_of(value);
1936
- if (prototype !== object_prototype && prototype !== array_prototype) return value;
1937
- /** @type {Map<any, Source<any>>} */
1938
- var sources = /* @__PURE__ */ new Map();
1939
- var is_proxied_array = is_array(value);
1940
- var version = /* @__PURE__ */ state(0);
1941
- var stack = null;
1942
- var parent_version = update_version;
1943
- /**
1944
- * Executes the proxy in the context of the reaction it was originally created in, if any
1945
- * @template T
1946
- * @param {() => T} fn
1947
- */
1948
- var with_parent = (fn) => {
1949
- if (update_version === parent_version) return fn();
1950
- var reaction = active_reaction;
1951
- var version = update_version;
1952
- set_active_reaction(null);
1953
- set_update_version(parent_version);
1954
- var result = fn();
1955
- set_active_reaction(reaction);
1956
- set_update_version(version);
1957
- return result;
1958
- };
1959
- if (is_proxied_array) sources.set("length", /* @__PURE__ */ state(
1960
- /** @type {any[]} */
1961
- value.length,
1962
- stack
1963
- ));
1964
- return new Proxy(value, {
1965
- defineProperty(_, prop, descriptor) {
1966
- if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) state_descriptors_fixed();
1967
- var s = sources.get(prop);
1968
- if (s === void 0) with_parent(() => {
1969
- var s = /* @__PURE__ */ state(descriptor.value, stack);
1970
- sources.set(prop, s);
1971
- return s;
1972
- });
1973
- else set(s, descriptor.value, true);
1974
- return true;
1975
- },
1976
- deleteProperty(target, prop) {
1977
- var s = sources.get(prop);
1978
- if (s === void 0) {
1979
- if (prop in target) {
1980
- const s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED, stack));
1981
- sources.set(prop, s);
1982
- increment(version);
1983
- }
1984
- } else {
1985
- set(s, UNINITIALIZED);
1986
- increment(version);
1987
- }
1988
- return true;
1989
- },
1990
- get(target, prop, receiver) {
1991
- if (prop === STATE_SYMBOL) return value;
1992
- var s = sources.get(prop);
1993
- var exists = prop in target;
1994
- if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1995
- s = with_parent(() => {
1996
- return /* @__PURE__ */ state(proxy(exists ? target[prop] : UNINITIALIZED), stack);
1997
- });
1998
- sources.set(prop, s);
1999
- }
2000
- if (s !== void 0) {
2001
- var v = get(s);
2002
- return v === UNINITIALIZED ? void 0 : v;
2003
- }
2004
- return Reflect.get(target, prop, receiver);
2005
- },
2006
- getOwnPropertyDescriptor(target, prop) {
2007
- var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
2008
- if (descriptor && "value" in descriptor) {
2009
- var s = sources.get(prop);
2010
- if (s) descriptor.value = get(s);
2011
- } else if (descriptor === void 0) {
2012
- var source = sources.get(prop);
2013
- var value = source?.v;
2014
- if (source !== void 0 && value !== UNINITIALIZED) return {
2015
- enumerable: true,
2016
- configurable: true,
2017
- value,
2018
- writable: true
2019
- };
2020
- }
2021
- return descriptor;
2022
- },
2023
- has(target, prop) {
2024
- if (prop === STATE_SYMBOL) return true;
2025
- var s = sources.get(prop);
2026
- var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
2027
- if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
2028
- if (s === void 0) {
2029
- s = with_parent(() => {
2030
- return /* @__PURE__ */ state(has ? proxy(target[prop]) : UNINITIALIZED, stack);
2031
- });
2032
- sources.set(prop, s);
2033
- }
2034
- if (get(s) === UNINITIALIZED) return false;
2035
- }
2036
- return has;
2037
- },
2038
- set(target, prop, value, receiver) {
2039
- var s = sources.get(prop);
2040
- var has = prop in target;
2041
- if (is_proxied_array && prop === "length") for (var i = value; i < s.v; i += 1) {
2042
- var other_s = sources.get(i + "");
2043
- if (other_s !== void 0) set(other_s, UNINITIALIZED);
2044
- else if (i in target) {
2045
- other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED, stack));
2046
- sources.set(i + "", other_s);
2047
- }
2048
- }
2049
- if (s === void 0) {
2050
- if (!has || get_descriptor(target, prop)?.writable) {
2051
- s = with_parent(() => /* @__PURE__ */ state(void 0, stack));
2052
- set(s, proxy(value));
2053
- sources.set(prop, s);
2054
- }
2055
- } else {
2056
- has = s.v !== UNINITIALIZED;
2057
- var p = with_parent(() => proxy(value));
2058
- set(s, p);
2059
- }
2060
- var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
2061
- if (descriptor?.set) descriptor.set.call(receiver, value);
2062
- if (!has) {
2063
- if (is_proxied_array && typeof prop === "string") {
2064
- var ls = sources.get("length");
2065
- var n = Number(prop);
2066
- if (Number.isInteger(n) && n >= ls.v) set(ls, n + 1);
2067
- }
2068
- increment(version);
2069
- }
2070
- return true;
2071
- },
2072
- ownKeys(target) {
2073
- get(version);
2074
- var own_keys = Reflect.ownKeys(target).filter((key) => {
2075
- var source = sources.get(key);
2076
- return source === void 0 || source.v !== UNINITIALIZED;
2077
- });
2078
- for (var [key, source] of sources) if (source.v !== UNINITIALIZED && !(key in target)) own_keys.push(key);
2079
- return own_keys;
2080
- },
2081
- setPrototypeOf() {
2082
- state_prototype_fixed();
2083
- }
2084
- });
1921
+ function destroy_block_effect_children(signal) {
1922
+ var effect = signal.first;
1923
+ while (effect !== null) {
1924
+ var next = effect.next;
1925
+ if ((effect.f & 32) === 0) destroy_effect(effect);
1926
+ effect = next;
1927
+ }
2085
1928
  }
2086
- //#endregion
2087
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/operations.js
2088
- /** @type {Window} */
2089
- var $window;
2090
- /** @type {boolean} */
2091
- var is_firefox;
2092
- /** @type {() => Node | null} */
2093
- var first_child_getter;
2094
- /** @type {() => Node | null} */
2095
- var next_sibling_getter;
2096
1929
  /**
2097
- * Initialize these lazily to avoid issues when using the runtime in a server context
2098
- * where these globals are not available while avoiding a separate server entry point
1930
+ * @param {Effect} effect
1931
+ * @param {boolean} [remove_dom]
1932
+ * @returns {void}
2099
1933
  */
2100
- function init_operations() {
2101
- if ($window !== void 0) return;
2102
- $window = window;
2103
- is_firefox = /Firefox/.test(navigator.userAgent);
2104
- var element_prototype = Element.prototype;
2105
- var node_prototype = Node.prototype;
2106
- var text_prototype = Text.prototype;
2107
- first_child_getter = get_descriptor(node_prototype, "firstChild").get;
2108
- next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
2109
- if (is_extensible(element_prototype)) {
2110
- /** @type {any} */ element_prototype[CLASS_CACHE] = void 0;
2111
- /** @type {any} */ element_prototype[ATTRIBUTES_CACHE] = null;
2112
- /** @type {any} */ element_prototype[STYLE_CACHE] = void 0;
2113
- element_prototype.__e = void 0;
1934
+ function destroy_effect(effect, remove_dom = true) {
1935
+ var removed = false;
1936
+ if ((remove_dom || (effect.f & 262144) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
1937
+ remove_effect_dom(effect.nodes.start, effect.nodes.end);
1938
+ removed = true;
2114
1939
  }
2115
- if (is_extensible(text_prototype))
2116
- /** @type {any} */ text_prototype[TEXT_CACHE] = void 0;
1940
+ effect.f |= DESTROYING;
1941
+ destroy_effect_children(effect, remove_dom && !removed);
1942
+ remove_reactions(effect, 0);
1943
+ var transitions = effect.nodes && effect.nodes.t;
1944
+ if (transitions !== null) for (const transition of transitions) transition.stop();
1945
+ execute_effect_teardown(effect);
1946
+ effect.f ^= DESTROYING;
1947
+ effect.f |= DESTROYED;
1948
+ var parent = effect.parent;
1949
+ if (parent !== null && parent.first !== null) unlink_effect(effect);
1950
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = effect.b = null;
2117
1951
  }
2118
1952
  /**
2119
- * @param {string} value
2120
- * @returns {Text}
1953
+ *
1954
+ * @param {TemplateNode | null} node
1955
+ * @param {TemplateNode} end
2121
1956
  */
2122
- function create_text(value = "") {
2123
- return document.createTextNode(value);
2124
- }
2125
- /**
2126
- * @template {Node} N
2127
- * @param {N} node
2128
- */
2129
- /*@__NO_SIDE_EFFECTS__*/
2130
- function get_first_child(node) {
2131
- return first_child_getter.call(node);
2132
- }
2133
- /**
2134
- * @template {Node} N
2135
- * @param {N} node
2136
- */
2137
- /*@__NO_SIDE_EFFECTS__*/
2138
- function get_next_sibling(node) {
2139
- return next_sibling_getter.call(node);
2140
- }
2141
- /**
2142
- * @template {Node} N
2143
- * @param {N} node
2144
- * @returns {void}
2145
- */
2146
- function clear_text_content(node) {
2147
- node.textContent = "";
1957
+ function remove_effect_dom(node, end) {
1958
+ while (node !== null) {
1959
+ /** @type {TemplateNode | null} */
1960
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1961
+ node.remove();
1962
+ node = next;
1963
+ }
2148
1964
  }
2149
1965
  /**
2150
- * Branching here is intentional and load-bearing for perf. `createElement(tag)`
2151
- * hits a fast path in Blink that `createElementNS(NAMESPACE_HTML, tag)` doesn't,
2152
- * and passing an explicit `undefined` as the trailing options arg measurably
2153
- * slows both APIs. Funnelling every case through a single `createElementNS(ns,
2154
- * tag, options)` call would be smaller but slower on the HTML path.
2155
- *
2156
- * @template {keyof HTMLElementTagNameMap | string} T
2157
- * @param {T} tag
2158
- * @param {string} [namespace]
2159
- * @param {string} [is]
2160
- * @returns {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element}
1966
+ * Detach an effect from the effect tree, freeing up memory and
1967
+ * reducing the amount of work that happens on subsequent traversals
1968
+ * @param {Effect} effect
2161
1969
  */
2162
- function create_element(tag, namespace, is) {
2163
- if (namespace == null || namespace === "http://www.w3.org/1999/xhtml") return is ? document.createElement(tag, { is }) : document.createElement(tag);
2164
- return is ? document.createElementNS(namespace, tag, { is }) : document.createElementNS(namespace, tag);
1970
+ function unlink_effect(effect) {
1971
+ var parent = effect.parent;
1972
+ var prev = effect.prev;
1973
+ var next = effect.next;
1974
+ if (prev !== null) prev.next = next;
1975
+ if (next !== null) next.prev = prev;
1976
+ if (parent !== null) {
1977
+ if (parent.first === effect) parent.first = next;
1978
+ if (parent.last === effect) parent.last = prev;
1979
+ }
2165
1980
  }
2166
- //#endregion
2167
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/effects.js
2168
- /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
2169
1981
  /**
1982
+ * When a block effect is removed, we don't immediately destroy it or yank it
1983
+ * out of the DOM, because it might have transitions. Instead, we 'pause' it.
1984
+ * It stays around (in memory, and in the DOM) until outro transitions have
1985
+ * completed, and if the state change is reversed then we _resume_ it.
1986
+ * A paused effect does not update, and the DOM subtree becomes inert.
2170
1987
  * @param {Effect} effect
2171
- * @param {Effect} parent_effect
1988
+ * @param {() => void} [callback]
1989
+ * @param {boolean} [destroy]
2172
1990
  */
2173
- function push_effect(effect, parent_effect) {
2174
- var parent_last = parent_effect.last;
2175
- if (parent_last === null) parent_effect.last = parent_effect.first = effect;
2176
- else {
2177
- parent_last.next = effect;
2178
- effect.prev = parent_last;
2179
- parent_effect.last = effect;
2180
- }
1991
+ function pause_effect(effect, callback, destroy = true) {
1992
+ /** @type {TransitionManager[]} */
1993
+ var transitions = [];
1994
+ effect.f |= 256;
1995
+ pause_children(effect, transitions, true);
1996
+ var fn = () => {
1997
+ if (destroy) destroy_effect(effect);
1998
+ if (callback) callback();
1999
+ };
2000
+ var remaining = transitions.length;
2001
+ if (remaining > 0) {
2002
+ var check = () => --remaining || fn();
2003
+ for (var transition of transitions) transition.out(check);
2004
+ } else fn();
2181
2005
  }
2182
2006
  /**
2183
- * @param {number} type
2184
- * @param {null | (() => void | (() => void))} fn
2185
- * @returns {Effect}
2007
+ * @param {Effect} effect
2008
+ * @param {TransitionManager[]} transitions
2009
+ * @param {boolean} local
2186
2010
  */
2187
- function create_effect(type, fn) {
2188
- var parent = active_effect;
2189
- if (parent !== null && (parent.f & 8192) !== 0) type |= INERT;
2190
- /** @type {Effect} */
2191
- var effect = {
2192
- ctx: component_context,
2193
- deps: null,
2194
- nodes: null,
2195
- f: type | DIRTY | 512,
2196
- first: null,
2197
- fn,
2198
- last: null,
2199
- next: null,
2200
- parent,
2201
- b: parent && parent.b,
2202
- prev: null,
2203
- teardown: null,
2204
- wv: 0,
2205
- ac: null
2206
- };
2207
- current_batch?.register_created_effect(effect);
2208
- /** @type {Effect | null} */
2209
- var e = effect;
2210
- if ((type & 4) !== 0) if (collected_effects !== null) collected_effects.push(effect);
2211
- else Batch.ensure().schedule(effect);
2212
- else if (fn !== null) {
2213
- try {
2214
- update_effect(effect);
2215
- } catch (e) {
2216
- destroy_effect(effect);
2217
- throw e;
2218
- }
2219
- if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && (e.f & 524288) === 0) {
2220
- e = e.first;
2221
- if ((type & 16) !== 0 && (type & 65536) !== 0 && e !== null) e.f |= EFFECT_TRANSPARENT;
2222
- }
2011
+ function pause_children(effect, transitions, local) {
2012
+ if ((effect.f & 8192) !== 0) return;
2013
+ effect.f ^= INERT;
2014
+ var t = effect.nodes && effect.nodes.t;
2015
+ if (t !== null) {
2016
+ for (const transition of t) if (transition.is_global || local) transitions.push(transition);
2223
2017
  }
2224
- if (e !== null) {
2225
- e.parent = parent;
2226
- if (parent !== null) push_effect(e, parent);
2227
- if (active_reaction !== null && (active_reaction.f & 2) !== 0 && (type & 64) === 0) {
2228
- var derived = active_reaction;
2229
- (derived.effects ?? (derived.effects = [])).push(e);
2018
+ var child = effect.first;
2019
+ while (child !== null) {
2020
+ var sibling = child.next;
2021
+ if ((child.f & 64) === 0) {
2022
+ var transparent = (child.f & 65536) !== 0 || (child.f & 32) !== 0 && (effect.f & 16) !== 0;
2023
+ pause_children(child, transitions, transparent ? local : false);
2230
2024
  }
2025
+ child = sibling;
2231
2026
  }
2232
- return effect;
2233
2027
  }
2234
2028
  /**
2235
- * Internal representation of `$effect.tracking()`
2236
- * @returns {boolean}
2029
+ * @param {Effect} effect
2030
+ * @param {DocumentFragment} fragment
2237
2031
  */
2238
- function effect_tracking() {
2239
- return active_reaction !== null && !untracking;
2032
+ function move_effect(effect, fragment) {
2033
+ if (!effect.nodes) return;
2034
+ /** @type {TemplateNode | null} */
2035
+ var node = effect.nodes.start;
2036
+ var end = effect.nodes.end;
2037
+ while (node !== null) {
2038
+ /** @type {TemplateNode | null} */
2039
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2040
+ fragment.append(node);
2041
+ node = next;
2042
+ }
2240
2043
  }
2044
+ //#endregion
2045
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/legacy.js
2241
2046
  /**
2242
- * @param {() => void | (() => void)} fn
2047
+ * @type {Set<Value> | null}
2048
+ * @deprecated
2243
2049
  */
2244
- function create_user_effect(fn) {
2245
- return create_effect(4 | USER_EFFECT, fn);
2246
- }
2050
+ var captured_signals = null;
2051
+ //#endregion
2052
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/runtime.js
2053
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
2247
2054
  /**
2248
- * Internal representation of `$effect.root(...)`
2249
- * @param {() => void | (() => void)} fn
2250
- * @returns {() => void}
2055
+ * True if updating in an effect context that is reactive (i.e. not branch/root effects)
2251
2056
  */
2252
- function effect_root(fn) {
2253
- Batch.ensure();
2254
- const effect = create_effect(64 | EFFECT_PRESERVED, fn);
2255
- return () => {
2256
- destroy_effect(effect);
2257
- };
2057
+ var is_updating_effect = false;
2058
+ var is_destroying_effect = false;
2059
+ /** @param {boolean} value */
2060
+ function set_is_destroying_effect(value) {
2061
+ is_destroying_effect = value;
2258
2062
  }
2259
- /**
2260
- * An effect root whose children can transition out
2261
- * @param {() => void} fn
2262
- * @returns {(options?: { outro?: boolean }) => Promise<void>}
2263
- */
2264
- function component_root(fn) {
2265
- Batch.ensure();
2266
- const effect = create_effect(64 | EFFECT_PRESERVED, fn);
2267
- return (options = {}) => {
2268
- return new Promise((fulfil) => {
2269
- if (options.outro) pause_effect(effect, () => {
2270
- destroy_effect(effect);
2271
- fulfil(void 0);
2272
- });
2273
- else {
2274
- destroy_effect(effect);
2275
- fulfil(void 0);
2276
- }
2277
- });
2278
- };
2063
+ /** @type {null | Reaction} */
2064
+ var active_reaction = null;
2065
+ var untracking = false;
2066
+ /** @param {null | Reaction} reaction */
2067
+ function set_active_reaction(reaction) {
2068
+ active_reaction = reaction;
2279
2069
  }
2280
- /**
2281
- * @param {() => void | (() => void)} fn
2282
- * @returns {Effect}
2283
- */
2284
- function effect(fn) {
2285
- return create_effect(4, fn);
2070
+ /** @type {null | Effect} */
2071
+ var active_effect = null;
2072
+ /** @param {null | Effect} effect */
2073
+ function set_active_effect(effect) {
2074
+ active_effect = effect;
2286
2075
  }
2287
2076
  /**
2288
- * @param {() => void | (() => void)} fn
2289
- * @returns {Effect}
2077
+ * When sources are created within a reaction, reading and writing
2078
+ * them within that reaction should not cause a re-run
2079
+ * @type {null | Set<Source>}
2290
2080
  */
2291
- function render_effect(fn, flags = 0) {
2292
- return create_effect(8 | flags, fn);
2081
+ var current_sources = null;
2082
+ /** @param {Value} value */
2083
+ function push_reaction_value(value) {
2084
+ if (active_reaction !== null && (!async_mode_flag || (active_reaction.f & 2) !== 0)) (current_sources ?? (current_sources = /* @__PURE__ */ new Set())).add(value);
2293
2085
  }
2294
2086
  /**
2295
- * @param {(() => void)} fn
2296
- * @param {number} flags
2087
+ * The dependencies of the reaction that is currently being executed. In many cases,
2088
+ * the dependencies are unchanged between runs, and so this will be `null` unless
2089
+ * and until a new dependency is accessed — we track this via `skipped_deps`
2090
+ * @type {null | Value[]}
2297
2091
  */
2298
- function block(fn, flags = 0) {
2299
- return create_effect(16 | flags, fn);
2300
- }
2092
+ var new_deps = null;
2093
+ var skipped_deps = 0;
2301
2094
  /**
2302
- * @param {(() => void)} fn
2303
- */
2304
- function branch(fn) {
2305
- return create_effect(32 | EFFECT_PRESERVED, fn);
2306
- }
2307
- /**
2308
- * @param {Effect} effect
2309
- */
2310
- function execute_effect_teardown(effect) {
2311
- var teardown = effect.teardown;
2312
- if (teardown !== null) {
2313
- const previously_destroying_effect = is_destroying_effect;
2314
- const previous_reaction = active_reaction;
2315
- set_is_destroying_effect(true);
2316
- set_active_reaction(null);
2317
- try {
2318
- teardown.call(null);
2319
- } finally {
2320
- set_is_destroying_effect(previously_destroying_effect);
2321
- set_active_reaction(previous_reaction);
2322
- }
2323
- }
2324
- }
2325
- /**
2326
- * @param {Effect} signal
2327
- * @param {boolean} remove_dom
2328
- * @returns {void}
2329
- */
2330
- function destroy_effect_children(signal, remove_dom = false) {
2331
- var effect = signal.first;
2332
- signal.first = signal.last = null;
2333
- while (effect !== null) {
2334
- const controller = effect.ac;
2335
- if (controller !== null) without_reactive_context(() => {
2336
- controller.abort(STALE_REACTION);
2337
- });
2338
- var next = effect.next;
2339
- if ((effect.f & 64) !== 0) effect.parent = null;
2340
- else destroy_effect(effect, remove_dom);
2341
- effect = next;
2342
- }
2343
- }
2344
- /**
2345
- * @param {Effect} signal
2346
- * @returns {void}
2347
- */
2348
- function destroy_block_effect_children(signal) {
2349
- var effect = signal.first;
2350
- while (effect !== null) {
2351
- var next = effect.next;
2352
- if ((effect.f & 32) === 0) destroy_effect(effect);
2353
- effect = next;
2354
- }
2355
- }
2356
- /**
2357
- * @param {Effect} effect
2358
- * @param {boolean} [remove_dom]
2359
- * @returns {void}
2360
- */
2361
- function destroy_effect(effect, remove_dom = true) {
2362
- var removed = false;
2363
- if ((remove_dom || (effect.f & 262144) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
2364
- remove_effect_dom(effect.nodes.start, effect.nodes.end);
2365
- removed = true;
2366
- }
2367
- effect.f |= DESTROYING;
2368
- destroy_effect_children(effect, remove_dom && !removed);
2369
- remove_reactions(effect, 0);
2370
- var transitions = effect.nodes && effect.nodes.t;
2371
- if (transitions !== null) for (const transition of transitions) transition.stop();
2372
- execute_effect_teardown(effect);
2373
- effect.f ^= DESTROYING;
2374
- effect.f |= DESTROYED;
2375
- var parent = effect.parent;
2376
- if (parent !== null && parent.first !== null) unlink_effect(effect);
2377
- effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = effect.b = null;
2378
- }
2379
- /**
2380
- *
2381
- * @param {TemplateNode | null} node
2382
- * @param {TemplateNode} end
2383
- */
2384
- function remove_effect_dom(node, end) {
2385
- while (node !== null) {
2386
- /** @type {TemplateNode | null} */
2387
- var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2388
- node.remove();
2389
- node = next;
2390
- }
2391
- }
2392
- /**
2393
- * Detach an effect from the effect tree, freeing up memory and
2394
- * reducing the amount of work that happens on subsequent traversals
2395
- * @param {Effect} effect
2396
- */
2397
- function unlink_effect(effect) {
2398
- var parent = effect.parent;
2399
- var prev = effect.prev;
2400
- var next = effect.next;
2401
- if (prev !== null) prev.next = next;
2402
- if (next !== null) next.prev = prev;
2403
- if (parent !== null) {
2404
- if (parent.first === effect) parent.first = next;
2405
- if (parent.last === effect) parent.last = prev;
2406
- }
2407
- }
2408
- /**
2409
- * When a block effect is removed, we don't immediately destroy it or yank it
2410
- * out of the DOM, because it might have transitions. Instead, we 'pause' it.
2411
- * It stays around (in memory, and in the DOM) until outro transitions have
2412
- * completed, and if the state change is reversed then we _resume_ it.
2413
- * A paused effect does not update, and the DOM subtree becomes inert.
2414
- * @param {Effect} effect
2415
- * @param {() => void} [callback]
2416
- * @param {boolean} [destroy]
2417
- */
2418
- function pause_effect(effect, callback, destroy = true) {
2419
- /** @type {TransitionManager[]} */
2420
- var transitions = [];
2421
- pause_children(effect, transitions, true);
2422
- var fn = () => {
2423
- if (destroy) destroy_effect(effect);
2424
- if (callback) callback();
2425
- };
2426
- var remaining = transitions.length;
2427
- if (remaining > 0) {
2428
- var check = () => --remaining || fn();
2429
- for (var transition of transitions) transition.out(check);
2430
- } else fn();
2431
- }
2432
- /**
2433
- * @param {Effect} effect
2434
- * @param {TransitionManager[]} transitions
2435
- * @param {boolean} local
2436
- */
2437
- function pause_children(effect, transitions, local) {
2438
- if ((effect.f & 8192) !== 0) return;
2439
- effect.f ^= INERT;
2440
- var t = effect.nodes && effect.nodes.t;
2441
- if (t !== null) {
2442
- for (const transition of t) if (transition.is_global || local) transitions.push(transition);
2443
- }
2444
- var child = effect.first;
2445
- while (child !== null) {
2446
- var sibling = child.next;
2447
- if ((child.f & 64) === 0) {
2448
- var transparent = (child.f & 65536) !== 0 || (child.f & 32) !== 0 && (effect.f & 16) !== 0;
2449
- pause_children(child, transitions, transparent ? local : false);
2450
- }
2451
- child = sibling;
2452
- }
2453
- }
2454
- /**
2455
- * @param {Effect} effect
2456
- * @param {DocumentFragment} fragment
2457
- */
2458
- function move_effect(effect, fragment) {
2459
- if (!effect.nodes) return;
2460
- /** @type {TemplateNode | null} */
2461
- var node = effect.nodes.start;
2462
- var end = effect.nodes.end;
2463
- while (node !== null) {
2464
- /** @type {TemplateNode | null} */
2465
- var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2466
- fragment.append(node);
2467
- node = next;
2468
- }
2469
- }
2470
- //#endregion
2471
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/legacy.js
2472
- /**
2473
- * @type {Set<Value> | null}
2474
- * @deprecated
2475
- */
2476
- var captured_signals = null;
2477
- //#endregion
2478
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/runtime.js
2479
- /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
2480
- /**
2481
- * True if updating in an effect context that is reactive (i.e. not branch/root effects)
2482
- */
2483
- var is_updating_effect = false;
2484
- var is_destroying_effect = false;
2485
- /** @param {boolean} value */
2486
- function set_is_destroying_effect(value) {
2487
- is_destroying_effect = value;
2488
- }
2489
- /** @type {null | Reaction} */
2490
- var active_reaction = null;
2491
- var untracking = false;
2492
- /** @param {null | Reaction} reaction */
2493
- function set_active_reaction(reaction) {
2494
- active_reaction = reaction;
2495
- }
2496
- /** @type {null | Effect} */
2497
- var active_effect = null;
2498
- /** @param {null | Effect} effect */
2499
- function set_active_effect(effect) {
2500
- active_effect = effect;
2501
- }
2502
- /**
2503
- * When sources are created within a reaction, reading and writing
2504
- * them within that reaction should not cause a re-run
2505
- * @type {null | Set<Source>}
2506
- */
2507
- var current_sources = null;
2508
- /** @param {Value} value */
2509
- function push_reaction_value(value) {
2510
- if (active_reaction !== null && (!async_mode_flag || (active_reaction.f & 2) !== 0)) (current_sources ?? (current_sources = /* @__PURE__ */ new Set())).add(value);
2511
- }
2512
- /**
2513
- * The dependencies of the reaction that is currently being executed. In many cases,
2514
- * the dependencies are unchanged between runs, and so this will be `null` unless
2515
- * and until a new dependency is accessed — we track this via `skipped_deps`
2516
- * @type {null | Value[]}
2517
- */
2518
- var new_deps = null;
2519
- var skipped_deps = 0;
2520
- /**
2521
- * Tracks writes that the effect it's executed in doesn't listen to yet,
2522
- * so that the dependency can be added to the effect later on if it then reads it
2523
- * @type {null | Source[]}
2095
+ * Tracks writes that the effect it's executed in doesn't listen to yet,
2096
+ * so that the dependency can be added to the effect later on if it then reads it
2097
+ * @type {null | Source[]}
2524
2098
  */
2525
2099
  var untracked_writes = null;
2526
2100
  /** @param {null | Source[]} value */
@@ -2532,7 +2106,7 @@ function set_untracked_writes(value) {
2532
2106
  * Version starts from 1 so that unowned deriveds differentiate between a created effect and a run one for tracing
2533
2107
  **/
2534
2108
  var write_version = 1;
2535
- /** @type {number} Used to version each read of a source of derived to avoid duplicating depedencies inside a reaction */
2109
+ /** @type {number} Used to version each read of a source of derived to avoid duplicating dependencies inside a reaction */
2536
2110
  var read_version = 0;
2537
2111
  var update_version = read_version;
2538
2112
  /** @param {number} value */
@@ -2613,24 +2187,8 @@ function update_reaction(reaction) {
2613
2187
  var fn = reaction.fn;
2614
2188
  var result = fn();
2615
2189
  reaction.f |= REACTION_RAN;
2616
- var deps = reaction.deps;
2617
- var is_fork = current_batch?.is_fork;
2618
- if (new_deps !== null) {
2619
- var i;
2620
- if (!is_fork) remove_reactions(reaction, skipped_deps);
2621
- if (deps !== null && skipped_deps > 0) {
2622
- deps.length = skipped_deps + new_deps.length;
2623
- for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
2624
- } else reaction.deps = deps = new_deps;
2625
- if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) {
2626
- var _deps$i;
2627
- ((_deps$i = deps[i]).reactions ?? (_deps$i.reactions = [])).push(reaction);
2628
- }
2629
- } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2630
- remove_reactions(reaction, skipped_deps);
2631
- deps.length = skipped_deps;
2632
- }
2633
- if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & 6146) === 0) for (i = 0; i < untracked_writes.length; i++) schedule_possible_effect_self_invalidation(untracked_writes[i], reaction);
2190
+ var deps = update_dependencies(reaction);
2191
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & 6146) === 0) for (var i = 0; i < untracked_writes.length; i++) schedule_possible_effect_self_invalidation(untracked_writes[i], reaction);
2634
2192
  if (previous_reaction !== null && previous_reaction !== reaction) {
2635
2193
  read_version++;
2636
2194
  if (previous_reaction.deps !== null) for (let i = 0; i < previous_skipped_deps; i += 1) previous_reaction.deps[i].rv = read_version;
@@ -2641,6 +2199,7 @@ function update_reaction(reaction) {
2641
2199
  if ((reaction.f & 8388608) !== 0) reaction.f ^= ERROR_VALUE;
2642
2200
  return result;
2643
2201
  } catch (error) {
2202
+ update_dependencies(reaction);
2644
2203
  return handle_error(error);
2645
2204
  } finally {
2646
2205
  reaction.f ^= REACTION_IS_UPDATING;
@@ -2655,6 +2214,29 @@ function update_reaction(reaction) {
2655
2214
  }
2656
2215
  }
2657
2216
  /**
2217
+ * @param {Reaction} reaction
2218
+ */
2219
+ function update_dependencies(reaction) {
2220
+ var deps = reaction.deps;
2221
+ var is_fork = current_batch?.is_fork;
2222
+ if (new_deps !== null) {
2223
+ var i;
2224
+ if (!is_fork) remove_reactions(reaction, skipped_deps);
2225
+ if (deps !== null && skipped_deps > 0) {
2226
+ deps.length = skipped_deps + new_deps.length;
2227
+ for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
2228
+ } else reaction.deps = deps = new_deps;
2229
+ if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) {
2230
+ var _deps$i;
2231
+ ((_deps$i = deps[i]).reactions ?? (_deps$i.reactions = [])).push(reaction);
2232
+ }
2233
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2234
+ remove_reactions(reaction, skipped_deps);
2235
+ deps.length = skipped_deps;
2236
+ }
2237
+ return deps;
2238
+ }
2239
+ /**
2658
2240
  * @template V
2659
2241
  * @param {Reaction} signal
2660
2242
  * @param {Value<V>} dependency
@@ -2688,329 +2270,793 @@ function remove_reaction(signal, dependency) {
2688
2270
  freeze_derived_effects(derived);
2689
2271
  remove_reactions(derived, 0);
2690
2272
  }
2691
- }
2692
- /**
2693
- * @param {Reaction} signal
2694
- * @param {number} start_index
2695
- * @returns {void}
2696
- */
2697
- function remove_reactions(signal, start_index) {
2698
- var dependencies = signal.deps;
2699
- if (dependencies === null) return;
2700
- for (var i = start_index; i < dependencies.length; i++) remove_reaction(signal, dependencies[i]);
2701
- }
2702
- /**
2703
- * @param {Effect} effect
2704
- * @returns {void}
2705
- */
2706
- function update_effect(effect) {
2707
- var flags = effect.f;
2708
- if ((flags & 16384) !== 0) return;
2709
- set_signal_status(effect, CLEAN);
2710
- var previous_effect = active_effect;
2711
- var was_updating_effect = is_updating_effect;
2712
- active_effect = effect;
2713
- is_updating_effect = (flags & 96) === 0;
2714
- try {
2715
- if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
2716
- else destroy_effect_children(effect);
2717
- execute_effect_teardown(effect);
2718
- var teardown = update_reaction(effect);
2719
- effect.teardown = typeof teardown === "function" ? teardown : null;
2720
- effect.wv = write_version;
2721
- } finally {
2722
- is_updating_effect = was_updating_effect;
2723
- active_effect = previous_effect;
2273
+ }
2274
+ /**
2275
+ * @param {Reaction} signal
2276
+ * @param {number} start_index
2277
+ * @returns {void}
2278
+ */
2279
+ function remove_reactions(signal, start_index) {
2280
+ var dependencies = signal.deps;
2281
+ if (dependencies === null) return;
2282
+ for (var i = start_index; i < dependencies.length; i++) remove_reaction(signal, dependencies[i]);
2283
+ }
2284
+ /**
2285
+ * @param {Effect} effect
2286
+ * @returns {void}
2287
+ */
2288
+ function update_effect(effect) {
2289
+ var flags = effect.f;
2290
+ if ((flags & 16384) !== 0) return;
2291
+ set_signal_status(effect, CLEAN);
2292
+ var previous_effect = active_effect;
2293
+ var was_updating_effect = is_updating_effect;
2294
+ active_effect = effect;
2295
+ is_updating_effect = (flags & 96) === 0;
2296
+ try {
2297
+ if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
2298
+ else destroy_effect_children(effect);
2299
+ execute_effect_teardown(effect);
2300
+ var teardown = update_reaction(effect);
2301
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2302
+ effect.wv = write_version;
2303
+ } finally {
2304
+ is_updating_effect = was_updating_effect;
2305
+ active_effect = previous_effect;
2306
+ }
2307
+ }
2308
+ /**
2309
+ * @template V
2310
+ * @param {Value<V>} signal
2311
+ * @returns {V}
2312
+ */
2313
+ function get(signal) {
2314
+ var is_derived = (signal.f & 2) !== 0;
2315
+ captured_signals?.add(signal);
2316
+ if (active_reaction !== null && !untracking) {
2317
+ if (!(active_effect !== null && (active_effect.f & 16384) !== 0) && (current_sources === null || !current_sources.has(signal))) {
2318
+ var deps = active_reaction.deps;
2319
+ if ((active_reaction.f & 2097152) !== 0) {
2320
+ if (signal.rv < read_version) {
2321
+ signal.rv = read_version;
2322
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) skipped_deps++;
2323
+ else if (new_deps === null) new_deps = [signal];
2324
+ else new_deps.push(signal);
2325
+ }
2326
+ } else {
2327
+ var _active_reaction;
2328
+ (_active_reaction = active_reaction).deps ?? (_active_reaction.deps = []);
2329
+ if (!includes.call(active_reaction.deps, signal)) active_reaction.deps.push(signal);
2330
+ var reactions = signal.reactions;
2331
+ if (reactions === null) signal.reactions = [active_reaction];
2332
+ else if (!includes.call(reactions, active_reaction)) reactions.push(active_reaction);
2333
+ }
2334
+ }
2335
+ }
2336
+ if (is_destroying_effect && old_values.has(signal)) return old_values.get(signal);
2337
+ if (is_derived) {
2338
+ var derived = signal;
2339
+ if (is_destroying_effect) {
2340
+ var value = derived.v;
2341
+ if ((derived.f & 1024) === 0 && derived.reactions !== null || depends_on_old_values(derived)) value = execute_derived(derived);
2342
+ old_values.set(derived, value);
2343
+ return value;
2344
+ }
2345
+ var should_connect = (derived.f & 512) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & 512) !== 0);
2346
+ var is_new = (derived.f & REACTION_RAN) === 0;
2347
+ if (is_dirty(derived)) {
2348
+ if (should_connect) derived.f |= 512;
2349
+ update_derived(derived);
2350
+ }
2351
+ if (should_connect && !is_new) {
2352
+ unfreeze_derived_effects(derived);
2353
+ reconnect(derived);
2354
+ }
2355
+ }
2356
+ if (batch_values?.has(signal)) return batch_values.get(signal);
2357
+ if ((signal.f & 8388608) !== 0) throw signal.v;
2358
+ return signal.v;
2359
+ }
2360
+ /**
2361
+ * (Re)connect a disconnected derived, so that it is notified
2362
+ * of changes in `mark_reactions`
2363
+ * @param {Derived} derived
2364
+ */
2365
+ function reconnect(derived) {
2366
+ derived.f |= 512;
2367
+ if (derived.deps === null) return;
2368
+ for (const dep of derived.deps) {
2369
+ (dep.reactions ?? (dep.reactions = [])).push(derived);
2370
+ if ((dep.f & 2) !== 0 && (dep.f & 512) === 0) {
2371
+ unfreeze_derived_effects(dep);
2372
+ reconnect(dep);
2373
+ }
2374
+ }
2375
+ }
2376
+ /** @param {Derived} derived */
2377
+ function depends_on_old_values(derived) {
2378
+ if (derived.v === UNINITIALIZED) return true;
2379
+ if (derived.deps === null) return false;
2380
+ for (const dep of derived.deps) {
2381
+ if (old_values.has(dep)) return true;
2382
+ if ((dep.f & 2) !== 0 && depends_on_old_values(dep)) return true;
2383
+ }
2384
+ return false;
2385
+ }
2386
+ /**
2387
+ * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect),
2388
+ * any state read inside `fn` will not be treated as a dependency.
2389
+ *
2390
+ * ```ts
2391
+ * $effect(() => {
2392
+ * // this will run when `data` changes, but not when `time` changes
2393
+ * save(data, {
2394
+ * timestamp: untrack(() => time)
2395
+ * });
2396
+ * });
2397
+ * ```
2398
+ * @template T
2399
+ * @param {() => T} fn
2400
+ * @returns {T}
2401
+ */
2402
+ function untrack(fn) {
2403
+ var previous_untracking = untracking;
2404
+ try {
2405
+ untracking = true;
2406
+ return fn();
2407
+ } finally {
2408
+ untracking = previous_untracking;
2409
+ }
2410
+ }
2411
+ //#endregion
2412
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/events.js
2413
+ /**
2414
+ * Used on elements, as a map of event type -> event handler,
2415
+ * and on events themselves to track which element handled an event
2416
+ */
2417
+ var event_symbol = Symbol("events");
2418
+ /** @type {Set<string>} */
2419
+ var all_registered_events = /* @__PURE__ */ new Set();
2420
+ /** @type {Set<(events: Array<string>) => void>} */
2421
+ var root_event_handles = /* @__PURE__ */ new Set();
2422
+ var last_propagated_event = null;
2423
+ var last_propagated_event_clear_scheduled = false;
2424
+ /**
2425
+ * @this {EventTarget}
2426
+ * @param {Event} event
2427
+ * @returns {void}
2428
+ */
2429
+ function handle_event_propagation(event) {
2430
+ var handler_element = this;
2431
+ var owner_document = handler_element.ownerDocument;
2432
+ var event_name = event.type;
2433
+ var path = event.composedPath?.() || [];
2434
+ var current_target = path[0] || event.target;
2435
+ last_propagated_event = event;
2436
+ if (!last_propagated_event_clear_scheduled) {
2437
+ last_propagated_event_clear_scheduled = true;
2438
+ setTimeout(() => {
2439
+ last_propagated_event_clear_scheduled = false;
2440
+ last_propagated_event = null;
2441
+ });
2442
+ }
2443
+ var path_idx = 0;
2444
+ var handled_at = last_propagated_event === event && event[event_symbol];
2445
+ if (handled_at) {
2446
+ var at_idx = path.indexOf(handled_at);
2447
+ if (at_idx !== -1 && (handler_element === document || handler_element === window)) {
2448
+ event[event_symbol] = handler_element;
2449
+ return;
2450
+ }
2451
+ var handler_idx = path.indexOf(handler_element);
2452
+ if (handler_idx === -1) return;
2453
+ if (at_idx <= handler_idx) path_idx = at_idx;
2454
+ }
2455
+ current_target = path[path_idx] || event.target;
2456
+ if (current_target === handler_element) return;
2457
+ define_property(event, "currentTarget", {
2458
+ configurable: true,
2459
+ get() {
2460
+ return current_target || owner_document;
2461
+ }
2462
+ });
2463
+ var previous_reaction = active_reaction;
2464
+ var previous_effect = active_effect;
2465
+ set_active_reaction(null);
2466
+ set_active_effect(null);
2467
+ try {
2468
+ /**
2469
+ * @type {unknown}
2470
+ */
2471
+ var throw_error;
2472
+ /**
2473
+ * @type {unknown[]}
2474
+ */
2475
+ var other_errors = [];
2476
+ while (current_target !== null) {
2477
+ if (current_target === handler_element) break;
2478
+ try {
2479
+ var delegated = current_target[event_symbol]?.[event_name];
2480
+ if (delegated != null && (!current_target.disabled || event.target === current_target)) delegated.call(current_target, event);
2481
+ } catch (error) {
2482
+ if (throw_error) other_errors.push(error);
2483
+ else throw_error = error;
2484
+ }
2485
+ if (event.cancelBubble) break;
2486
+ path_idx++;
2487
+ current_target = path_idx < path.length ? path[path_idx] : null;
2488
+ }
2489
+ if (throw_error) {
2490
+ for (let error of other_errors) queueMicrotask(() => {
2491
+ throw error;
2492
+ });
2493
+ throw throw_error;
2494
+ }
2495
+ } finally {
2496
+ event[event_symbol] = handler_element;
2497
+ delete event.currentTarget;
2498
+ set_active_reaction(previous_reaction);
2499
+ set_active_effect(previous_effect);
2500
+ }
2501
+ }
2502
+ //#endregion
2503
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/reconciler.js
2504
+ var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
2505
+ /** @param {string} html */
2506
+ createHTML: (html) => {
2507
+ return html;
2508
+ } });
2509
+ /** @param {string} html */
2510
+ function create_trusted_html(html) {
2511
+ return policy?.createHTML(html) ?? html;
2512
+ }
2513
+ /**
2514
+ * @param {string} html
2515
+ */
2516
+ function create_fragment_from_html(html) {
2517
+ var elem = create_element("template");
2518
+ elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
2519
+ return elem.content;
2520
+ }
2521
+ //#endregion
2522
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/template.js
2523
+ /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
2524
+ /** @import { TemplateStructure } from './types' */
2525
+ /**
2526
+ * @param {TemplateNode} start
2527
+ * @param {TemplateNode | null} end
2528
+ */
2529
+ function assign_nodes(start, end) {
2530
+ var effect = active_effect;
2531
+ if (effect.nodes === null) effect.nodes = {
2532
+ start,
2533
+ end,
2534
+ a: null,
2535
+ t: null
2536
+ };
2537
+ }
2538
+ /**
2539
+ * @param {string} content
2540
+ * @param {number} flags
2541
+ * @returns {() => Node | Node[]}
2542
+ */
2543
+ /*#__NO_SIDE_EFFECTS__*/
2544
+ function from_html(content, flags) {
2545
+ var is_fragment = (flags & 1) !== 0;
2546
+ var use_import_node = (flags & 2) !== 0;
2547
+ /** @type {Node} */
2548
+ var node;
2549
+ /**
2550
+ * Whether or not the first item is a text/element node. If not, we need to
2551
+ * create an additional comment node to act as `effect.nodes.start`
2552
+ */
2553
+ var has_start = !content.startsWith("<!>");
2554
+ return () => {
2555
+ if (hydrating) {
2556
+ assign_nodes(hydrate_node, null);
2557
+ return hydrate_node;
2558
+ }
2559
+ if (node === void 0) {
2560
+ node = create_fragment_from_html(has_start ? content : "<!>" + content);
2561
+ if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
2562
+ }
2563
+ var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
2564
+ if (is_fragment) {
2565
+ var start = /* @__PURE__ */ get_first_child(clone);
2566
+ var end = clone.lastChild;
2567
+ assign_nodes(start, end);
2568
+ } else assign_nodes(clone, clone);
2569
+ return clone;
2570
+ };
2571
+ }
2572
+ /**
2573
+ * Assign the created (or in hydration mode, traversed) dom elements to the current block
2574
+ * and insert the elements into the dom (in client mode).
2575
+ * @param {Text | Comment | Element} anchor
2576
+ * @param {DocumentFragment | Element} dom
2577
+ */
2578
+ function append(anchor, dom) {
2579
+ if (hydrating) {
2580
+ var effect = active_effect;
2581
+ if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
2582
+ hydrate_next();
2583
+ return;
2584
+ }
2585
+ if (anchor === null) return;
2586
+ anchor.before(dom);
2587
+ }
2588
+ /**
2589
+ * Subset of delegated events which should be passive by default.
2590
+ * These two are already passive via browser defaults on window, document and body.
2591
+ * But since
2592
+ * - we're delegating them
2593
+ * - they happen often
2594
+ * - they apply to mobile which is generally less performant
2595
+ * we're marking them as passive by default for other elements, too.
2596
+ */
2597
+ var PASSIVE_EVENTS = ["touchstart", "touchmove"];
2598
+ /**
2599
+ * Returns `true` if `name` is a passive event
2600
+ * @param {string} name
2601
+ */
2602
+ function is_passive_event(name) {
2603
+ return PASSIVE_EVENTS.includes(name);
2604
+ }
2605
+ //#endregion
2606
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/reactivity/create-subscriber.js
2607
+ /**
2608
+ * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
2609
+ * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
2610
+ *
2611
+ * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
2612
+ * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
2613
+ *
2614
+ * If `start` returns a cleanup function, it will be called when the effect is destroyed.
2615
+ *
2616
+ * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
2617
+ * are active, and the returned teardown function will only be called when all effects are destroyed.
2618
+ *
2619
+ * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
2620
+ *
2621
+ * ```js
2622
+ * import { createSubscriber } from 'svelte/reactivity';
2623
+ * import { on } from 'svelte/events';
2624
+ *
2625
+ * export class MediaQuery {
2626
+ * #query;
2627
+ * #subscribe;
2628
+ *
2629
+ * constructor(query) {
2630
+ * this.#query = window.matchMedia(`(${query})`);
2631
+ *
2632
+ * this.#subscribe = createSubscriber((update) => {
2633
+ * // when the `change` event occurs, re-run any effects that read `this.current`
2634
+ * const off = on(this.#query, 'change', update);
2635
+ *
2636
+ * // stop listening when all the effects are destroyed
2637
+ * return () => off();
2638
+ * });
2639
+ * }
2640
+ *
2641
+ * get current() {
2642
+ * // This makes the getter reactive, if read in an effect
2643
+ * this.#subscribe();
2644
+ *
2645
+ * // Return the current state of the query, whether or not we're in an effect
2646
+ * return this.#query.matches;
2647
+ * }
2648
+ * }
2649
+ * ```
2650
+ * @param {(update: () => void) => (() => void) | void} start
2651
+ * @since 5.7.0
2652
+ */
2653
+ function createSubscriber(start) {
2654
+ let subscribers = 0;
2655
+ let version = source(0);
2656
+ /** @type {(() => void) | void} */
2657
+ let stop;
2658
+ return () => {
2659
+ if (effect_tracking()) {
2660
+ get(version);
2661
+ render_effect(() => {
2662
+ if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
2663
+ subscribers += 1;
2664
+ return () => {
2665
+ queue_micro_task(() => {
2666
+ subscribers -= 1;
2667
+ if (subscribers === 0) {
2668
+ stop?.();
2669
+ stop = void 0;
2670
+ increment(version);
2671
+ }
2672
+ });
2673
+ };
2674
+ });
2675
+ }
2676
+ };
2677
+ }
2678
+ //#endregion
2679
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
2680
+ /** @import { Effect, Source, TemplateNode, } from '#client' */
2681
+ /**
2682
+ * @typedef {{
2683
+ * onerror?: ((error: unknown, reset: () => void) => void) | null;
2684
+ * failed?: ((anchor: Node, error: () => unknown, reset: () => () => void) => void) | null;
2685
+ * pending?: ((anchor: Node) => void) | null;
2686
+ * }} BoundaryProps
2687
+ */
2688
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
2689
+ /**
2690
+ * @param {TemplateNode} node
2691
+ * @param {BoundaryProps} props
2692
+ * @param {((anchor: Node) => void)} children
2693
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
2694
+ * @returns {void}
2695
+ */
2696
+ function boundary(node, props, children, transform_error) {
2697
+ new Boundary(node, props, children, transform_error);
2698
+ }
2699
+ var _anchor = /* @__PURE__ */ new WeakMap();
2700
+ var _hydrate_open = /* @__PURE__ */ new WeakMap();
2701
+ var _props = /* @__PURE__ */ new WeakMap();
2702
+ var _children = /* @__PURE__ */ new WeakMap();
2703
+ var _effect = /* @__PURE__ */ new WeakMap();
2704
+ var _main_effect = /* @__PURE__ */ new WeakMap();
2705
+ var _pending_effect = /* @__PURE__ */ new WeakMap();
2706
+ var _failed_effect = /* @__PURE__ */ new WeakMap();
2707
+ var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
2708
+ var _local_pending_count = /* @__PURE__ */ new WeakMap();
2709
+ var _pending_count = /* @__PURE__ */ new WeakMap();
2710
+ var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
2711
+ var _dirty_effects = /* @__PURE__ */ new WeakMap();
2712
+ var _maybe_dirty_effects = /* @__PURE__ */ new WeakMap();
2713
+ var _effect_pending = /* @__PURE__ */ new WeakMap();
2714
+ var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
2715
+ var _Boundary_brand = /* @__PURE__ */ new WeakSet();
2716
+ var Boundary = class {
2717
+ /**
2718
+ * @param {TemplateNode} node
2719
+ * @param {BoundaryProps} props
2720
+ * @param {((anchor: Node) => void)} children
2721
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
2722
+ */
2723
+ constructor(node, props, children, transform_error) {
2724
+ _classPrivateMethodInitSpec(this, _Boundary_brand);
2725
+ _defineProperty(
2726
+ this,
2727
+ /** @type {Boundary | null} */
2728
+ "parent",
2729
+ void 0
2730
+ );
2731
+ _defineProperty(this, "is_pending", false);
2732
+ _defineProperty(
2733
+ this,
2734
+ /**
2735
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
2736
+ * Inherited from parent boundary, or defaults to identity.
2737
+ * @type {(error: unknown) => unknown}
2738
+ */
2739
+ "transform_error",
2740
+ void 0
2741
+ );
2742
+ _classPrivateFieldInitSpec(this, _anchor, void 0);
2743
+ _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
2744
+ _classPrivateFieldInitSpec(this, _props, void 0);
2745
+ _classPrivateFieldInitSpec(this, _children, void 0);
2746
+ _classPrivateFieldInitSpec(this, _effect, void 0);
2747
+ _classPrivateFieldInitSpec(this, _main_effect, null);
2748
+ _classPrivateFieldInitSpec(this, _pending_effect, null);
2749
+ _classPrivateFieldInitSpec(this, _failed_effect, null);
2750
+ _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
2751
+ _classPrivateFieldInitSpec(this, _local_pending_count, 0);
2752
+ _classPrivateFieldInitSpec(this, _pending_count, 0);
2753
+ _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
2754
+ _classPrivateFieldInitSpec(this, _dirty_effects, /* @__PURE__ */ new Set());
2755
+ _classPrivateFieldInitSpec(this, _maybe_dirty_effects, /* @__PURE__ */ new Set());
2756
+ _classPrivateFieldInitSpec(this, _effect_pending, null);
2757
+ _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
2758
+ _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
2759
+ return () => {
2760
+ _classPrivateFieldSet2(_effect_pending, this, null);
2761
+ };
2762
+ }));
2763
+ _classPrivateFieldSet2(_anchor, this, node);
2764
+ _classPrivateFieldSet2(_props, this, props);
2765
+ _classPrivateFieldSet2(_children, this, (anchor) => {
2766
+ var effect = active_effect;
2767
+ effect.b = this;
2768
+ effect.f |= 128;
2769
+ children(anchor);
2770
+ });
2771
+ this.parent = active_effect.b;
2772
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
2773
+ _classPrivateFieldSet2(_effect, this, block(() => {
2774
+ if (hydrating) {
2775
+ const comment = _classPrivateFieldGet2(_hydrate_open, this);
2776
+ hydrate_next();
2777
+ const server_rendered_pending = comment.data === "[!";
2778
+ if (comment.data.startsWith("[?")) {
2779
+ const serialized_error = JSON.parse(comment.data.slice(2));
2780
+ _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
2781
+ } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
2782
+ else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
2783
+ } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
2784
+ }, flags));
2785
+ if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
2786
+ }
2787
+ /**
2788
+ * Defer an effect inside a pending boundary until the boundary resolves
2789
+ * @param {Effect} effect
2790
+ */
2791
+ defer_effect(effect) {
2792
+ defer_effect(effect, _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
2724
2793
  }
2725
- }
2726
- /**
2727
- * @template V
2728
- * @param {Value<V>} signal
2729
- * @returns {V}
2730
- */
2731
- function get(signal) {
2732
- var is_derived = (signal.f & 2) !== 0;
2733
- captured_signals?.add(signal);
2734
- if (active_reaction !== null && !untracking) {
2735
- if (!(active_effect !== null && (active_effect.f & 16384) !== 0) && (current_sources === null || !current_sources.has(signal))) {
2736
- var deps = active_reaction.deps;
2737
- if ((active_reaction.f & 2097152) !== 0) {
2738
- if (signal.rv < read_version) {
2739
- signal.rv = read_version;
2740
- if (new_deps === null && deps !== null && deps[skipped_deps] === signal) skipped_deps++;
2741
- else if (new_deps === null) new_deps = [signal];
2742
- else new_deps.push(signal);
2743
- }
2744
- } else {
2745
- var _active_reaction;
2746
- (_active_reaction = active_reaction).deps ?? (_active_reaction.deps = []);
2747
- if (!includes.call(active_reaction.deps, signal)) active_reaction.deps.push(signal);
2748
- var reactions = signal.reactions;
2749
- if (reactions === null) signal.reactions = [active_reaction];
2750
- else if (!includes.call(reactions, active_reaction)) reactions.push(active_reaction);
2751
- }
2752
- }
2794
+ /**
2795
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
2796
+ * @returns {boolean}
2797
+ */
2798
+ is_rendered() {
2799
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
2753
2800
  }
2754
- if (is_destroying_effect && old_values.has(signal)) return old_values.get(signal);
2755
- if (is_derived) {
2756
- var derived = signal;
2757
- if (is_destroying_effect) {
2758
- var value = derived.v;
2759
- if ((derived.f & 1024) === 0 && derived.reactions !== null || depends_on_old_values(derived)) value = execute_derived(derived);
2760
- old_values.set(derived, value);
2761
- return value;
2762
- }
2763
- var should_connect = (derived.f & 512) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & 512) !== 0);
2764
- var is_new = (derived.f & REACTION_RAN) === 0;
2765
- if (is_dirty(derived)) {
2766
- if (should_connect) derived.f |= 512;
2767
- update_derived(derived);
2768
- }
2769
- if (should_connect && !is_new) {
2770
- unfreeze_derived_effects(derived);
2771
- reconnect(derived);
2772
- }
2801
+ has_pending_snippet() {
2802
+ return !!_classPrivateFieldGet2(_props, this).pending;
2773
2803
  }
2774
- if (batch_values?.has(signal)) return batch_values.get(signal);
2775
- if ((signal.f & 8388608) !== 0) throw signal.v;
2776
- return signal.v;
2777
- }
2778
- /**
2779
- * (Re)connect a disconnected derived, so that it is notified
2780
- * of changes in `mark_reactions`
2781
- * @param {Derived} derived
2782
- */
2783
- function reconnect(derived) {
2784
- derived.f |= 512;
2785
- if (derived.deps === null) return;
2786
- for (const dep of derived.deps) {
2787
- (dep.reactions ?? (dep.reactions = [])).push(derived);
2788
- if ((dep.f & 2) !== 0 && (dep.f & 512) === 0) {
2789
- unfreeze_derived_effects(dep);
2790
- reconnect(dep);
2791
- }
2804
+ /**
2805
+ * Update the source that powers `$effect.pending()` inside this boundary,
2806
+ * and controls when the current `pending` snippet (if any) is removed.
2807
+ * Do not call from inside the class
2808
+ * @param {1 | -1} d
2809
+ * @param {Batch} batch
2810
+ */
2811
+ update_pending_count(d, batch) {
2812
+ _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
2813
+ _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
2814
+ if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
2815
+ _classPrivateFieldSet2(_pending_count_update_queued, this, true);
2816
+ queue_micro_task(() => {
2817
+ _classPrivateFieldSet2(_pending_count_update_queued, this, false);
2818
+ if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
2819
+ });
2792
2820
  }
2793
- }
2794
- /** @param {Derived} derived */
2795
- function depends_on_old_values(derived) {
2796
- if (derived.v === UNINITIALIZED) return true;
2797
- if (derived.deps === null) return false;
2798
- for (const dep of derived.deps) {
2799
- if (old_values.has(dep)) return true;
2800
- if ((dep.f & 2) !== 0 && depends_on_old_values(dep)) return true;
2821
+ get_effect_pending() {
2822
+ _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
2823
+ return get(_classPrivateFieldGet2(_effect_pending, this));
2801
2824
  }
2802
- return false;
2803
- }
2804
- /**
2805
- * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect),
2806
- * any state read inside `fn` will not be treated as a dependency.
2807
- *
2808
- * ```ts
2809
- * $effect(() => {
2810
- * // this will run when `data` changes, but not when `time` changes
2811
- * save(data, {
2812
- * timestamp: untrack(() => time)
2813
- * });
2814
- * });
2815
- * ```
2816
- * @template T
2817
- * @param {() => T} fn
2818
- * @returns {T}
2819
- */
2820
- function untrack(fn) {
2821
- var previous_untracking = untracking;
2825
+ /** @param {unknown} error */
2826
+ error(error) {
2827
+ if (!_classPrivateFieldGet2(_props, this).onerror && !_classPrivateFieldGet2(_props, this).failed) throw error;
2828
+ if (current_batch?.is_fork) {
2829
+ if (_classPrivateFieldGet2(_main_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_main_effect, this));
2830
+ if (_classPrivateFieldGet2(_pending_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_pending_effect, this));
2831
+ if (_classPrivateFieldGet2(_failed_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_failed_effect, this));
2832
+ current_batch.oncommit(() => {
2833
+ _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
2834
+ });
2835
+ } else _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
2836
+ }
2837
+ };
2838
+ function _hydrate_resolved_content() {
2822
2839
  try {
2823
- untracking = true;
2824
- return fn();
2825
- } finally {
2826
- untracking = previous_untracking;
2840
+ _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
2841
+ } catch (error) {
2842
+ this.error(error);
2827
2843
  }
2828
2844
  }
2829
- //#endregion
2830
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/events.js
2831
2845
  /**
2832
- * Used on elements, as a map of event type -> event handler,
2833
- * and on events themselves to track which element handled an event
2846
+ * @param {unknown} error The deserialized error from the server's hydration comment
2834
2847
  */
2835
- var event_symbol = Symbol("events");
2836
- /** @type {Set<string>} */
2837
- var all_registered_events = /* @__PURE__ */ new Set();
2838
- /** @type {Set<(events: Array<string>) => void>} */
2839
- var root_event_handles = /* @__PURE__ */ new Set();
2840
- var last_propagated_event = null;
2848
+ function _hydrate_failed_content(error) {
2849
+ const failed = _classPrivateFieldGet2(_props, this).failed;
2850
+ const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, error);
2851
+ queue_micro_task(invoke_onerror);
2852
+ if (!failed) return;
2853
+ _classPrivateFieldSet2(_failed_effect, this, branch(() => {
2854
+ failed(_classPrivateFieldGet2(_anchor, this), () => error, () => reset);
2855
+ }));
2856
+ }
2841
2857
  /**
2842
- * @this {EventTarget}
2843
- * @param {Event} event
2844
- * @returns {void}
2858
+ * Creates the `reset` function for a failed boundary, along with a function
2859
+ * that invokes `onerror` with it (if provided)
2860
+ * @param {unknown} error
2861
+ * @returns {{ reset: () => void, invoke_onerror: () => void }}
2845
2862
  */
2846
- function handle_event_propagation(event) {
2847
- var handler_element = this;
2848
- var owner_document = handler_element.ownerDocument;
2849
- var event_name = event.type;
2850
- var path = event.composedPath?.() || [];
2851
- var current_target = path[0] || event.target;
2852
- last_propagated_event = event;
2853
- var path_idx = 0;
2854
- var handled_at = last_propagated_event === event && event[event_symbol];
2855
- if (handled_at) {
2856
- var at_idx = path.indexOf(handled_at);
2857
- if (at_idx !== -1 && (handler_element === document || handler_element === window)) {
2858
- event[event_symbol] = handler_element;
2863
+ function _create_reset(error) {
2864
+ var did_reset = false;
2865
+ var calling_on_error = false;
2866
+ const reset = () => {
2867
+ if (did_reset) {
2868
+ svelte_boundary_reset_noop();
2859
2869
  return;
2860
2870
  }
2861
- var handler_idx = path.indexOf(handler_element);
2862
- if (handler_idx === -1) return;
2863
- if (at_idx <= handler_idx) path_idx = at_idx;
2864
- }
2865
- current_target = path[path_idx] || event.target;
2866
- if (current_target === handler_element) return;
2867
- define_property(event, "currentTarget", {
2868
- configurable: true,
2869
- get() {
2870
- return current_target || owner_document;
2871
+ did_reset = true;
2872
+ if (calling_on_error) svelte_boundary_reset_onerror();
2873
+ if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
2874
+ _classPrivateFieldSet2(_failed_effect, this, null);
2875
+ });
2876
+ _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
2877
+ _assertClassBrand(_Boundary_brand, this, _render).call(this);
2878
+ });
2879
+ };
2880
+ const invoke_onerror = () => {
2881
+ try {
2882
+ calling_on_error = true;
2883
+ _classPrivateFieldGet2(_props, this).onerror?.(error, reset);
2884
+ calling_on_error = false;
2885
+ } catch (err) {
2886
+ invoke_error_boundary(err, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
2871
2887
  }
2872
- });
2873
- var previous_reaction = active_reaction;
2874
- var previous_effect = active_effect;
2875
- set_active_reaction(null);
2876
- set_active_effect(null);
2877
- try {
2878
- /**
2879
- * @type {unknown}
2880
- */
2881
- var throw_error;
2882
- /**
2883
- * @type {unknown[]}
2884
- */
2885
- var other_errors = [];
2886
- while (current_target !== null) {
2887
- if (current_target === handler_element) break;
2888
+ };
2889
+ return {
2890
+ reset,
2891
+ invoke_onerror
2892
+ };
2893
+ }
2894
+ function _hydrate_pending_content() {
2895
+ const pending = _classPrivateFieldGet2(_props, this).pending;
2896
+ if (!pending) return;
2897
+ this.is_pending = true;
2898
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
2899
+ queue_micro_task(() => {
2900
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
2901
+ var anchor = create_text();
2902
+ var handled = false;
2903
+ fragment.append(anchor);
2904
+ _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
2888
2905
  try {
2889
- var delegated = current_target[event_symbol]?.[event_name];
2890
- if (delegated != null && (!current_target.disabled || event.target === current_target)) delegated.call(current_target, event);
2906
+ return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
2891
2907
  } catch (error) {
2892
- if (throw_error) other_errors.push(error);
2893
- else throw_error = error;
2908
+ try {
2909
+ this.error(error);
2910
+ handled = true;
2911
+ } catch (error) {
2912
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
2913
+ }
2914
+ return null;
2894
2915
  }
2895
- if (event.cancelBubble) break;
2896
- path_idx++;
2897
- current_target = path_idx < path.length ? path[path_idx] : null;
2916
+ }));
2917
+ if (_classPrivateFieldGet2(_main_effect, this) === null) {
2918
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
2919
+ if (handled) _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
2920
+ return;
2898
2921
  }
2899
- if (throw_error) {
2900
- for (let error of other_errors) queueMicrotask(() => {
2901
- throw error;
2922
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
2923
+ _classPrivateFieldGet2(_anchor, this).before(fragment);
2924
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
2925
+ pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
2926
+ _classPrivateFieldSet2(_pending_effect, this, null);
2902
2927
  });
2903
- throw throw_error;
2928
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
2904
2929
  }
2905
- } finally {
2906
- event[event_symbol] = handler_element;
2907
- delete event.currentTarget;
2908
- set_active_reaction(previous_reaction);
2909
- set_active_effect(previous_effect);
2910
- }
2930
+ });
2911
2931
  }
2912
- //#endregion
2913
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/reconciler.js
2914
- var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
2915
- /** @param {string} html */
2916
- createHTML: (html) => {
2917
- return html;
2918
- } });
2919
- /** @param {string} html */
2920
- function create_trusted_html(html) {
2921
- return policy?.createHTML(html) ?? html;
2932
+ function _render() {
2933
+ try {
2934
+ this.is_pending = this.has_pending_snippet();
2935
+ _classPrivateFieldSet2(_pending_count, this, 0);
2936
+ _classPrivateFieldSet2(_local_pending_count, this, 0);
2937
+ _classPrivateFieldSet2(_main_effect, this, branch(() => {
2938
+ _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
2939
+ }));
2940
+ if (_classPrivateFieldGet2(_pending_count, this) > 0) {
2941
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
2942
+ move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
2943
+ const pending = _classPrivateFieldGet2(_props, this).pending;
2944
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
2945
+ } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
2946
+ } catch (error) {
2947
+ this.error(error);
2948
+ }
2922
2949
  }
2923
2950
  /**
2924
- * @param {string} html
2951
+ * @param {Batch} batch
2925
2952
  */
2926
- function create_fragment_from_html(html) {
2927
- var elem = create_element("template");
2928
- elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
2929
- return elem.content;
2953
+ function _resolve(batch) {
2954
+ this.is_pending = false;
2955
+ batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
2930
2956
  }
2931
- //#endregion
2932
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/template.js
2933
- /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
2934
- /** @import { TemplateStructure } from './types' */
2935
2957
  /**
2936
- * @param {TemplateNode} start
2937
- * @param {TemplateNode | null} end
2958
+ * @template T
2959
+ * @param {() => T} fn
2938
2960
  */
2939
- function assign_nodes(start, end) {
2940
- var effect = active_effect;
2941
- if (effect.nodes === null) effect.nodes = {
2942
- start,
2943
- end,
2944
- a: null,
2945
- t: null
2946
- };
2961
+ function _run(fn) {
2962
+ var previous_effect = active_effect;
2963
+ var previous_reaction = active_reaction;
2964
+ var previous_ctx = component_context;
2965
+ set_active_effect(_classPrivateFieldGet2(_effect, this));
2966
+ set_active_reaction(_classPrivateFieldGet2(_effect, this));
2967
+ set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
2968
+ try {
2969
+ Batch.ensure();
2970
+ return fn();
2971
+ } finally {
2972
+ set_active_effect(previous_effect);
2973
+ set_active_reaction(previous_reaction);
2974
+ set_component_context(previous_ctx);
2975
+ }
2947
2976
  }
2948
2977
  /**
2949
- * @param {string} content
2950
- * @param {number} flags
2951
- * @returns {() => Node | Node[]}
2978
+ * Updates the pending count associated with the currently visible pending snippet,
2979
+ * if any, such that we can replace the snippet with content once work is done
2980
+ * @param {1 | -1} d
2981
+ * @param {Batch} batch
2952
2982
  */
2953
- /*#__NO_SIDE_EFFECTS__*/
2954
- function from_html(content, flags) {
2955
- var is_fragment = (flags & 1) !== 0;
2956
- var use_import_node = (flags & 2) !== 0;
2957
- /** @type {Node} */
2958
- var node;
2959
- /**
2960
- * Whether or not the first item is a text/element node. If not, we need to
2961
- * create an additional comment node to act as `effect.nodes.start`
2962
- */
2963
- var has_start = !content.startsWith("<!>");
2964
- return () => {
2965
- if (hydrating) {
2966
- assign_nodes(hydrate_node, null);
2967
- return hydrate_node;
2983
+ function _update_pending_count(d, batch) {
2984
+ if (!this.has_pending_snippet()) {
2985
+ if (this.parent) {
2986
+ var _this$parent;
2987
+ _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
2968
2988
  }
2969
- if (node === void 0) {
2970
- node = create_fragment_from_html(has_start ? content : "<!>" + content);
2971
- if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
2989
+ return;
2990
+ }
2991
+ _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
2992
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
2993
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
2994
+ if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
2995
+ _classPrivateFieldSet2(_pending_effect, this, null);
2996
+ });
2997
+ if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
2998
+ _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
2999
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
2972
3000
  }
2973
- var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
2974
- if (is_fragment) {
2975
- var start = /* @__PURE__ */ get_first_child(clone);
2976
- var end = clone.lastChild;
2977
- assign_nodes(start, end);
2978
- } else assign_nodes(clone, clone);
2979
- return clone;
2980
- };
3001
+ }
2981
3002
  }
2982
3003
  /**
2983
- * Assign the created (or in hydration mode, traversed) dom elements to the current block
2984
- * and insert the elements into the dom (in client mode).
2985
- * @param {Text | Comment | Element} anchor
2986
- * @param {DocumentFragment | Element} dom
3004
+ * @param {unknown} error
2987
3005
  */
2988
- function append(anchor, dom) {
3006
+ function _handle_error(error) {
3007
+ if (_classPrivateFieldGet2(_main_effect, this)) {
3008
+ destroy_effect(_classPrivateFieldGet2(_main_effect, this));
3009
+ _classPrivateFieldSet2(_main_effect, this, null);
3010
+ }
3011
+ if (_classPrivateFieldGet2(_pending_effect, this)) {
3012
+ destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
3013
+ _classPrivateFieldSet2(_pending_effect, this, null);
3014
+ }
3015
+ if (_classPrivateFieldGet2(_failed_effect, this)) {
3016
+ destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
3017
+ _classPrivateFieldSet2(_failed_effect, this, null);
3018
+ }
2989
3019
  if (hydrating) {
2990
- var effect = active_effect;
2991
- if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
2992
- hydrate_next();
2993
- return;
3020
+ set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
3021
+ next();
3022
+ set_hydrate_node(skip_nodes());
2994
3023
  }
2995
- if (anchor === null) return;
2996
- anchor.before(dom);
2997
- }
2998
- /**
2999
- * Subset of delegated events which should be passive by default.
3000
- * These two are already passive via browser defaults on window, document and body.
3001
- * But since
3002
- * - we're delegating them
3003
- * - they happen often
3004
- * - they apply to mobile which is generally less performant
3005
- * we're marking them as passive by default for other elements, too.
3006
- */
3007
- var PASSIVE_EVENTS = ["touchstart", "touchmove"];
3008
- /**
3009
- * Returns `true` if `name` is a passive event
3010
- * @param {string} name
3011
- */
3012
- function is_passive_event(name) {
3013
- return PASSIVE_EVENTS.includes(name);
3024
+ let failed = _classPrivateFieldGet2(_props, this).failed;
3025
+ /** @param {unknown} transformed_error */
3026
+ const handle_error_result = (transformed_error) => {
3027
+ const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, transformed_error);
3028
+ invoke_onerror();
3029
+ if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
3030
+ try {
3031
+ return branch(() => {
3032
+ var effect = active_effect;
3033
+ effect.b = this;
3034
+ effect.f |= 128;
3035
+ failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
3036
+ });
3037
+ } catch (error) {
3038
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
3039
+ return null;
3040
+ }
3041
+ }));
3042
+ };
3043
+ queue_micro_task(() => {
3044
+ /** @type {unknown} */
3045
+ var result;
3046
+ try {
3047
+ result = this.transform_error(error);
3048
+ } catch (e) {
3049
+ invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
3050
+ return;
3051
+ }
3052
+ if (result !== null && typeof result === "object" && typeof result.then === "function")
3053
+ /** @type {any} */ result.then(
3054
+ handle_error_result,
3055
+ /** @param {unknown} e */
3056
+ (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
3057
+ );
3058
+ else handle_error_result(result);
3059
+ });
3014
3060
  }
3015
3061
  /**
3016
3062
  * Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component.
@@ -3102,7 +3148,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
3102
3148
  if (events)
3103
3149
  /** @type {any} */ props.$$events = events;
3104
3150
  if (hydrating) assign_nodes(anchor_node, null);
3105
- component = Component(anchor_node, props) || {};
3151
+ component = Component(anchor_node, props) || mark_as_component();
3106
3152
  if (hydrating) {
3107
3153
  /** @type {Effect & { nodes: EffectNodes }} */ active_effect.nodes.end = hydrate_node;
3108
3154
  if (hydrate_node === null || hydrate_node.nodeType !== 8 || hydrate_node.data !== "]") {
@@ -3188,13 +3234,14 @@ function unmount(component, options) {
3188
3234
  return Promise.resolve();
3189
3235
  }
3190
3236
  //#endregion
3191
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/css.js
3237
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/css.js
3192
3238
  /**
3193
3239
  * @param {Node} anchor
3194
3240
  * @param {{ hash: string, code: string }} css
3195
3241
  */
3196
3242
  function append_styles(anchor, css) {
3197
3243
  effect(() => {
3244
+ anchor = active_effect?.parent?.nodes?.start ?? anchor;
3198
3245
  var root = anchor.getRootNode();
3199
3246
  var target = root.host ? root : /** @type {Document} */ root.head ?? root.ownerDocument.head;
3200
3247
  if (!target.querySelector("#" + css.hash)) {
@@ -3206,7 +3253,7 @@ function append_styles(anchor, css) {
3206
3253
  });
3207
3254
  }
3208
3255
  //#endregion
3209
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
3256
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
3210
3257
  var _ResizeObserverSingleton;
3211
3258
  var _listeners = /* @__PURE__ */ new WeakMap();
3212
3259
  var _observer = /* @__PURE__ */ new WeakMap();
@@ -3258,7 +3305,7 @@ function _getObserver() {
3258
3305
  }
3259
3306
  _defineProperty(ResizeObserverSingleton, "entries", /* @__PURE__ */ new WeakMap());
3260
3307
  //#endregion
3261
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/reactivity/props.js
3308
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/props.js
3262
3309
  /** @import { Derived, Effect, Source } from './types.js' */
3263
3310
  /**
3264
3311
  * This function is responsible for synchronizing a possibly bound prop with the inner component state.
@@ -3351,7 +3398,7 @@ function prop(props, key, flags, fallback) {
3351
3398
  });
3352
3399
  }
3353
3400
  //#endregion
3354
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/legacy/legacy-client.js
3401
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/legacy/legacy-client.js
3355
3402
  /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
3356
3403
  /**
3357
3404
  * Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
@@ -3470,7 +3517,7 @@ var Svelte4Component = class {
3470
3517
  }
3471
3518
  };
3472
3519
  //#endregion
3473
- //#region ../../../node_modules/.bun/svelte@5.56.8/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
3520
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
3474
3521
  /**
3475
3522
  * @typedef {Object} CustomElementPropDefinition
3476
3523
  * @property {string} [attribute]