@pie-element/venn-classification 0.1.1-next.3 → 0.1.1-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,16 +1,16 @@
1
- //#region ../../../node_modules/.bun/svelte@5.56.1/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.1/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
  var NAMESPACE_SVG = "http://www.w3.org/2000/svg";
11
11
  var NAMESPACE_MATHML = "http://www.w3.org/1998/Math/MathML";
12
12
  //#endregion
13
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/shared/utils.js
13
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/shared/utils.js
14
14
  var is_array = Array.isArray;
15
15
  var index_of = Array.prototype.indexOf;
16
16
  var includes = Array.prototype.includes;
@@ -67,7 +67,7 @@ function to_array(value, n) {
67
67
  return array;
68
68
  }
69
69
  //#endregion
70
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
70
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
71
71
  function _typeof(o) {
72
72
  "@babel/helpers - typeof";
73
73
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -77,7 +77,7 @@ function _typeof(o) {
77
77
  }, _typeof(o);
78
78
  }
79
79
  //#endregion
80
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
80
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
81
81
  function toPrimitive(t, r) {
82
82
  if ("object" != _typeof(t) || !t) return t;
83
83
  var e = t[Symbol.toPrimitive];
@@ -89,13 +89,13 @@ function toPrimitive(t, r) {
89
89
  return ("string" === r ? String : Number)(t);
90
90
  }
91
91
  //#endregion
92
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
92
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
93
93
  function toPropertyKey(t) {
94
94
  var i = toPrimitive(t, "string");
95
95
  return "symbol" == _typeof(i) ? i : i + "";
96
96
  }
97
97
  //#endregion
98
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
98
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
99
99
  function _defineProperty(e, r, t) {
100
100
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
101
101
  value: t,
@@ -132,6 +132,8 @@ var REACTION_IS_UPDATING = 1 << 21;
132
132
  var ASYNC = 1 << 22;
133
133
  var ERROR_VALUE = 1 << 23;
134
134
  var STATE_SYMBOL = Symbol("$state");
135
+ /** Marks component export objects, so that `proxy(...)` leaves them untouched */
136
+ var COMPONENT_SYMBOL = Symbol("component");
135
137
  var LEGACY_PROPS = Symbol("legacy props");
136
138
  var LOADING_ATTR_SYMBOL = Symbol("");
137
139
  var ATTRIBUTES_CACHE = Symbol("attributes");
@@ -148,106 +150,6 @@ var STALE_REACTION = new class StaleReactionError extends Error {
148
150
  }();
149
151
  var IS_XHTML = !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml");
150
152
  /**
151
- * `%name%(...)` can only be used during component initialisation
152
- * @param {string} name
153
- * @returns {never}
154
- */
155
- function lifecycle_outside_component(name) {
156
- throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
157
- }
158
- //#endregion
159
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/errors.js
160
- /**
161
- * Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
162
- * @returns {never}
163
- */
164
- function async_derived_orphan() {
165
- throw new Error(`https://svelte.dev/e/async_derived_orphan`);
166
- }
167
- /**
168
- * Keyed each block has duplicate key `%value%` at indexes %a% and %b%
169
- * @param {string} a
170
- * @param {string} b
171
- * @param {string | undefined | null} [value]
172
- * @returns {never}
173
- */
174
- function each_key_duplicate(a, b, value) {
175
- throw new Error(`https://svelte.dev/e/each_key_duplicate`);
176
- }
177
- /**
178
- * `%rune%` cannot be used inside an effect cleanup function
179
- * @param {string} rune
180
- * @returns {never}
181
- */
182
- function effect_in_teardown(rune) {
183
- throw new Error(`https://svelte.dev/e/effect_in_teardown`);
184
- }
185
- /**
186
- * Effect cannot be created inside a `$derived` value that was not itself created inside an effect
187
- * @returns {never}
188
- */
189
- function effect_in_unowned_derived() {
190
- throw new Error(`https://svelte.dev/e/effect_in_unowned_derived`);
191
- }
192
- /**
193
- * `%rune%` can only be used inside an effect (e.g. during component initialisation)
194
- * @param {string} rune
195
- * @returns {never}
196
- */
197
- function effect_orphan(rune) {
198
- throw new Error(`https://svelte.dev/e/effect_orphan`);
199
- }
200
- /**
201
- * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
202
- * @returns {never}
203
- */
204
- function effect_update_depth_exceeded() {
205
- throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
206
- }
207
- /**
208
- * Failed to hydrate the application
209
- * @returns {never}
210
- */
211
- function hydration_failed() {
212
- throw new Error(`https://svelte.dev/e/hydration_failed`);
213
- }
214
- /**
215
- * Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
216
- * @param {string} key
217
- * @returns {never}
218
- */
219
- function props_invalid_value(key) {
220
- throw new Error(`https://svelte.dev/e/props_invalid_value`);
221
- }
222
- /**
223
- * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
224
- * @returns {never}
225
- */
226
- function state_descriptors_fixed() {
227
- throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
228
- }
229
- /**
230
- * Cannot set prototype of `$state` object
231
- * @returns {never}
232
- */
233
- function state_prototype_fixed() {
234
- throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
235
- }
236
- /**
237
- * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
238
- * @returns {never}
239
- */
240
- function state_unsafe_mutation() {
241
- throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
242
- }
243
- /**
244
- * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
245
- * @returns {never}
246
- */
247
- function svelte_boundary_reset_onerror() {
248
- throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
249
- }
250
- /**
251
153
  * Reading a derived belonging to a now-destroyed effect may result in stale values
252
154
  */
253
155
  function derived_inert() {
@@ -267,7 +169,7 @@ function svelte_boundary_reset_noop() {
267
169
  console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
268
170
  }
269
171
  //#endregion
270
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/hydration.js
172
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/hydration.js
271
173
  /** @import { TemplateNode } from '#client' */
272
174
  /**
273
175
  * Use this variable to guard everything related to hydration code so it can be treeshaken out
@@ -346,7 +248,7 @@ function read_hydration_instruction(node) {
346
248
  return node.data;
347
249
  }
348
250
  //#endregion
349
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/equality.js
251
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/equality.js
350
252
  /** @import { Equals } from '#client' */
351
253
  /** @type {Equals} */
352
254
  function equals(value) {
@@ -364,14 +266,114 @@ function safe_not_equal(a, b) {
364
266
  function safe_equals(value) {
365
267
  return !safe_not_equal(value, this.v);
366
268
  }
269
+ /**
270
+ * `%name%(...)` can only be used during component initialisation
271
+ * @param {string} name
272
+ * @returns {never}
273
+ */
274
+ function lifecycle_outside_component(name) {
275
+ throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
276
+ }
277
+ //#endregion
278
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/errors.js
279
+ /**
280
+ * Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
281
+ * @returns {never}
282
+ */
283
+ function async_derived_orphan() {
284
+ throw new Error(`https://svelte.dev/e/async_derived_orphan`);
285
+ }
286
+ /**
287
+ * Keyed each block has duplicate key `%value%` at indexes %a% and %b%
288
+ * @param {string} a
289
+ * @param {string} b
290
+ * @param {string | undefined | null} [value]
291
+ * @returns {never}
292
+ */
293
+ function each_key_duplicate(a, b, value) {
294
+ throw new Error(`https://svelte.dev/e/each_key_duplicate`);
295
+ }
296
+ /**
297
+ * `%rune%` cannot be used inside an effect cleanup function
298
+ * @param {string} rune
299
+ * @returns {never}
300
+ */
301
+ function effect_in_teardown(rune) {
302
+ throw new Error(`https://svelte.dev/e/effect_in_teardown`);
303
+ }
304
+ /**
305
+ * Effect cannot be created inside a `$derived` value that was not itself created inside an effect
306
+ * @returns {never}
307
+ */
308
+ function effect_in_unowned_derived() {
309
+ throw new Error(`https://svelte.dev/e/effect_in_unowned_derived`);
310
+ }
311
+ /**
312
+ * `%rune%` can only be used inside an effect (e.g. during component initialisation)
313
+ * @param {string} rune
314
+ * @returns {never}
315
+ */
316
+ function effect_orphan(rune) {
317
+ throw new Error(`https://svelte.dev/e/effect_orphan`);
318
+ }
319
+ /**
320
+ * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
321
+ * @returns {never}
322
+ */
323
+ function effect_update_depth_exceeded() {
324
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
325
+ }
326
+ /**
327
+ * Failed to hydrate the application
328
+ * @returns {never}
329
+ */
330
+ function hydration_failed() {
331
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
332
+ }
333
+ /**
334
+ * Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
335
+ * @param {string} key
336
+ * @returns {never}
337
+ */
338
+ function props_invalid_value(key) {
339
+ throw new Error(`https://svelte.dev/e/props_invalid_value`);
340
+ }
341
+ /**
342
+ * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
343
+ * @returns {never}
344
+ */
345
+ function state_descriptors_fixed() {
346
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
347
+ }
348
+ /**
349
+ * Cannot set prototype of `$state` object
350
+ * @returns {never}
351
+ */
352
+ function state_prototype_fixed() {
353
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
354
+ }
355
+ /**
356
+ * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
357
+ * @returns {never}
358
+ */
359
+ function state_unsafe_mutation() {
360
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
361
+ }
362
+ /**
363
+ * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
364
+ * @returns {never}
365
+ */
366
+ function svelte_boundary_reset_onerror() {
367
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
368
+ }
367
369
  //#endregion
368
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/flags/index.js
370
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/flags/index.js
369
371
  /** True if experimental.async=true */
370
372
  var async_mode_flag = false;
371
373
  /** True if we're not certain that we only have Svelte 5 code in the compilation */
372
374
  var legacy_mode_flag = false;
373
375
  //#endregion
374
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/context.js
376
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/context.js
375
377
  /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
376
378
  /** @type {ComponentContext | null} */
377
379
  var component_context = null;
@@ -416,14 +418,22 @@ function pop(component) {
416
418
  if (component !== void 0) context.x = component;
417
419
  context.i = true;
418
420
  component_context = context.p;
419
- return component ?? {};
421
+ return mark_as_component(component);
422
+ }
423
+ /**
424
+ * Add a symbol to the object (or create one if undefined) to mark it as a component so it isn't proxified.
425
+ * @param {any} component
426
+ */
427
+ function mark_as_component(component = {}) {
428
+ define_property(component, COMPONENT_SYMBOL, { value: true });
429
+ return component;
420
430
  }
421
431
  /** @returns {boolean} */
422
432
  function is_runes() {
423
433
  return !legacy_mode_flag || component_context !== null && component_context.l === null;
424
434
  }
425
435
  //#endregion
426
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/task.js
436
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/task.js
427
437
  /** @type {Array<() => void>} */
428
438
  var micro_tasks = [];
429
439
  function run_micro_tasks() {
@@ -449,39 +459,8 @@ function queue_micro_task(fn) {
449
459
  function flush_tasks() {
450
460
  while (micro_tasks.length > 0) run_micro_tasks();
451
461
  }
452
- /**
453
- * @param {unknown} error
454
- */
455
- function handle_error(error) {
456
- var effect = active_effect;
457
- if (effect === null) {
458
- /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
459
- return error;
460
- }
461
- if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
462
- invoke_error_boundary(error, effect);
463
- }
464
- /**
465
- * @param {unknown} error
466
- * @param {Effect | null} effect
467
- */
468
- function invoke_error_boundary(error, effect) {
469
- while (effect !== null) {
470
- if ((effect.f & 128) !== 0) {
471
- if ((effect.f & 32768) === 0) throw error;
472
- try {
473
- /** @type {Boundary} */ effect.b.error(error);
474
- return;
475
- } catch (e) {
476
- error = e;
477
- }
478
- }
479
- effect = effect.parent;
480
- }
481
- throw error;
482
- }
483
462
  //#endregion
484
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/status.js
463
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/status.js
485
464
  /** @import { Derived, Signal } from '#client' */
486
465
  var STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
487
466
  /**
@@ -500,7 +479,7 @@ function update_derived_status(derived) {
500
479
  else set_signal_status(derived, MAYBE_DIRTY);
501
480
  }
502
481
  //#endregion
503
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/utils.js
482
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/utils.js
504
483
  /** @import { Derived, Effect, Value } from '#client' */
505
484
  /**
506
485
  * @param {Value[] | null} deps
@@ -528,7 +507,7 @@ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
528
507
  set_signal_status(effect, CLEAN);
529
508
  }
530
509
  //#endregion
531
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/store.js
510
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/store.js
532
511
  /**
533
512
  * We set this to `true` when updating a store so that we correctly
534
513
  * schedule effects if the update takes place inside a `$:` effect
@@ -558,1460 +537,1061 @@ function capture_store_binding(fn) {
558
537
  }
559
538
  }
560
539
  //#endregion
561
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/checkPrivateRedeclaration.js
562
- function _checkPrivateRedeclaration(e, t) {
563
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
564
- }
565
- //#endregion
566
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateMethodInitSpec.js
567
- function _classPrivateMethodInitSpec(e, a) {
568
- _checkPrivateRedeclaration(e, a), a.add(e);
540
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
541
+ /**
542
+ * @template T
543
+ * @param {() => T} fn
544
+ */
545
+ function without_reactive_context(fn) {
546
+ var previous_reaction = active_reaction;
547
+ var previous_effect = active_effect;
548
+ set_active_reaction(null);
549
+ set_active_effect(null);
550
+ try {
551
+ return fn();
552
+ } finally {
553
+ set_active_reaction(previous_reaction);
554
+ set_active_effect(previous_effect);
555
+ }
569
556
  }
570
557
  //#endregion
571
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateFieldInitSpec.js
572
- function _classPrivateFieldInitSpec(e, t, a) {
573
- _checkPrivateRedeclaration(e, t), t.set(e, a);
574
- }
575
- //#endregion
576
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/assertClassBrand.js
577
- function _assertClassBrand(e, t, n) {
578
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
579
- throw new TypeError("Private element is not present on this object");
558
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/async.js
559
+ /** @import { Blocker, Effect, Source, Value } from '#client' */
560
+ /**
561
+ * @param {Blocker[]} blockers
562
+ * @param {Array<() => any>} sync
563
+ * @param {Array<() => Promise<any>>} async
564
+ * @param {(values: Value[]) => any} fn
565
+ */
566
+ function flatten(blockers, sync, async, fn) {
567
+ const d = is_runes() ? derived : derived_safe_equal;
568
+ var pending = blockers.filter((b) => !b.settled);
569
+ var deriveds = sync.map(d);
570
+ if (async.length === 0 && pending.length === 0) {
571
+ fn(deriveds);
572
+ return;
573
+ }
574
+ var parent = active_effect;
575
+ var restore = capture();
576
+ var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b) => b.promise)) : null;
577
+ /**
578
+ * @param {Source[]} async
579
+ */
580
+ function finish(async) {
581
+ if ((parent.f & 16384) !== 0) return;
582
+ restore();
583
+ try {
584
+ fn([...deriveds, ...async]);
585
+ } catch (error) {
586
+ invoke_error_boundary(error, parent);
587
+ }
588
+ unset_context();
589
+ }
590
+ var decrement_pending = increment_pending();
591
+ if (async.length === 0) {
592
+ /** @type {Promise<any>} */ blocker_promise.then(() => finish([])).finally(decrement_pending);
593
+ return;
594
+ }
595
+ function run() {
596
+ Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then(finish).catch((error) => invoke_error_boundary(error, parent)).finally(decrement_pending);
597
+ }
598
+ if (blocker_promise) blocker_promise.then(() => {
599
+ restore();
600
+ run();
601
+ unset_context();
602
+ });
603
+ else run();
580
604
  }
581
- //#endregion
582
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateFieldSet2.js
583
- function _classPrivateFieldSet2(s, a, r) {
584
- return s.set(_assertClassBrand(s, a), r), r;
605
+ /**
606
+ * Captures the current effect context so that we can restore it after
607
+ * some asynchronous work has happened (so that e.g. `await a + b`
608
+ * causes `b` to be registered as a dependency).
609
+ */
610
+ function capture() {
611
+ var previous_effect = active_effect;
612
+ var previous_reaction = active_reaction;
613
+ var previous_component_context = component_context;
614
+ var previous_batch = current_batch;
615
+ return function restore(activate_batch = true) {
616
+ set_active_effect(previous_effect);
617
+ set_active_reaction(previous_reaction);
618
+ set_component_context(previous_component_context);
619
+ if (activate_batch && (previous_effect.f & 16384) === 0) {
620
+ previous_batch?.activate();
621
+ previous_batch?.apply();
622
+ }
623
+ };
585
624
  }
586
- //#endregion
587
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateFieldGet2.js
588
- function _classPrivateFieldGet2(s, a) {
589
- return s.get(_assertClassBrand(s, a));
625
+ function unset_context(deactivate_batch = true) {
626
+ set_active_effect(null);
627
+ set_active_reaction(null);
628
+ set_component_context(null);
629
+ if (deactivate_batch) current_batch?.deactivate();
590
630
  }
591
- //#endregion
592
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/batch.js
593
- /** @import { Fork } from 'svelte' */
594
- /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
595
- var _Batch;
596
- /** @type {Batch | null} */
597
- var first_batch = null;
598
- /** @type {Batch | null} */
599
- var last_batch = null;
600
- /** @type {Batch | null} */
601
- var current_batch = null;
602
631
  /**
603
- * This is needed to avoid overwriting inputs
604
- * @type {Batch | null}
632
+ * @returns {(skip?: boolean) => void}
605
633
  */
606
- var previous_batch = null;
634
+ function increment_pending() {
635
+ var effect = active_effect;
636
+ var boundary = effect.b;
637
+ var batch = current_batch;
638
+ var blocking = !!boundary?.is_rendered();
639
+ boundary?.update_pending_count(1, batch);
640
+ batch.increment(blocking, effect);
641
+ return () => {
642
+ boundary?.update_pending_count(-1, batch);
643
+ batch.decrement(blocking, effect);
644
+ };
645
+ }
607
646
  /**
608
- * When time travelling (i.e. working in one batch, while other batches
609
- * still have ongoing work), we ignore the real values of affected
610
- * signals in favour of their values within the batch
611
- * @type {Map<Value, any> | null}
647
+ * @template V
648
+ * @param {() => V} fn
649
+ * @returns {Derived<V>}
612
650
  */
613
- var batch_values = null;
614
- /** @type {Effect | null} */
615
- var last_scheduled_effect = null;
616
- var is_flushing_sync = false;
617
- var is_processing = false;
651
+ /*#__NO_SIDE_EFFECTS__*/
652
+ function derived(fn) {
653
+ var flags = 2 | DIRTY;
654
+ if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
655
+ return {
656
+ ctx: component_context,
657
+ deps: null,
658
+ effects: null,
659
+ equals,
660
+ f: flags,
661
+ fn,
662
+ reactions: null,
663
+ rv: 0,
664
+ v: UNINITIALIZED,
665
+ wv: 0,
666
+ parent: active_effect,
667
+ ac: null
668
+ };
669
+ }
670
+ var OBSOLETE = Symbol("obsolete");
618
671
  /**
619
- * During traversal, this is an array. Newly created effects are (if not immediately
620
- * executed) pushed to this array, rather than going through the scheduling
621
- * rigamarole that would cause another turn of the flush loop.
622
- * @type {Effect[] | null}
672
+ * @template V
673
+ * @param {() => V | Promise<V>} fn
674
+ * @param {string} [label]
675
+ * @param {string} [location] If provided, print a warning if the value is not read immediately after update
676
+ * @returns {Promise<Source<V>>}
623
677
  */
624
- var collected_effects = null;
678
+ /*#__NO_SIDE_EFFECTS__*/
679
+ function async_derived(fn, label, location) {
680
+ let parent = active_effect;
681
+ if (parent === null) async_derived_orphan();
682
+ var promise = void 0;
683
+ var signal = source(UNINITIALIZED);
684
+ var should_suspend = !active_reaction;
685
+ /** @type {Set<ReturnType<typeof deferred<V>>>} */
686
+ var deferreds = /* @__PURE__ */ new Set();
687
+ async_effect(() => {
688
+ var effect = active_effect;
689
+ /** @type {ReturnType<typeof deferred<V>>} */
690
+ var d = deferred();
691
+ promise = d.promise;
692
+ try {
693
+ Promise.resolve(fn()).then(d.resolve, (e) => {
694
+ if (e !== STALE_REACTION) d.reject(e);
695
+ }).finally(unset_context);
696
+ } catch (error) {
697
+ d.reject(error);
698
+ unset_context();
699
+ }
700
+ var batch = current_batch;
701
+ if (should_suspend) {
702
+ if ((effect.f & 32768) !== 0) var decrement_pending = increment_pending();
703
+ if (parent.b?.is_rendered()) batch.async_deriveds.get(effect)?.reject(OBSOLETE);
704
+ else for (const d of deferreds.values()) d.reject(OBSOLETE);
705
+ deferreds.add(d);
706
+ batch.async_deriveds.set(effect, d);
707
+ }
708
+ /**
709
+ * @param {any} value
710
+ * @param {unknown} error
711
+ */
712
+ const handler = (value, error = void 0) => {
713
+ decrement_pending?.();
714
+ deferreds.delete(d);
715
+ if (error === OBSOLETE) return;
716
+ batch.activate();
717
+ if (error) {
718
+ signal.f |= ERROR_VALUE;
719
+ internal_set(signal, error);
720
+ } else {
721
+ if ((signal.f & 8388608) !== 0) signal.f ^= ERROR_VALUE;
722
+ internal_set(signal, value);
723
+ }
724
+ batch.deactivate();
725
+ };
726
+ d.promise.then(handler, (e) => handler(null, e || "unknown"));
727
+ });
728
+ teardown(() => {
729
+ for (const d of deferreds) d.reject(OBSOLETE);
730
+ });
731
+ return new Promise((fulfil) => {
732
+ /** @param {Promise<V>} p */
733
+ function next(p) {
734
+ function go() {
735
+ if (p === promise) fulfil(signal);
736
+ else next(promise);
737
+ }
738
+ p.then(go, go);
739
+ }
740
+ next(promise);
741
+ });
742
+ }
625
743
  /**
626
- * An array of effects that are marked during traversal as a result of a `set`
627
- * (not `internal_set`) call. These will be added to the next batch and
628
- * trigger another `batch.process()`
629
- * @type {Effect[] | null}
630
- * @deprecated when we get rid of legacy mode and stores, we can get rid of this
744
+ * @template V
745
+ * @param {() => V} fn
746
+ * @returns {Derived<V>}
631
747
  */
632
- var legacy_updates = null;
633
- var flush_count = 0;
634
- var uid = 1;
635
- var _started = /* @__PURE__ */ new WeakMap();
636
- var _prev = /* @__PURE__ */ new WeakMap();
637
- var _next = /* @__PURE__ */ new WeakMap();
638
- var _commit_callbacks = /* @__PURE__ */ new WeakMap();
639
- var _discard_callbacks = /* @__PURE__ */ new WeakMap();
640
- var _pending = /* @__PURE__ */ new WeakMap();
641
- var _blocking_pending = /* @__PURE__ */ new WeakMap();
642
- var _deferred = /* @__PURE__ */ new WeakMap();
643
- var _roots = /* @__PURE__ */ new WeakMap();
644
- var _new_effects = /* @__PURE__ */ new WeakMap();
645
- var _dirty_effects$1 = /* @__PURE__ */ new WeakMap();
646
- var _maybe_dirty_effects$1 = /* @__PURE__ */ new WeakMap();
647
- var _skipped_branches = /* @__PURE__ */ new WeakMap();
648
- var _unskipped_branches = /* @__PURE__ */ new WeakMap();
649
- var _decrement_queued = /* @__PURE__ */ new WeakMap();
650
- var _Batch_brand = /* @__PURE__ */ new WeakSet();
651
- var Batch = class Batch {
652
- constructor() {
653
- _classPrivateMethodInitSpec(this, _Batch_brand);
654
- _defineProperty(this, "id", uid++);
655
- _classPrivateFieldInitSpec(this, _started, false);
656
- _defineProperty(this, "linked", true);
657
- _classPrivateFieldInitSpec(this, _prev, null);
658
- _classPrivateFieldInitSpec(this, _next, null);
659
- _defineProperty(
660
- this,
661
- /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
662
- "async_deriveds",
663
- /* @__PURE__ */ new Map()
664
- );
665
- _defineProperty(
666
- this,
667
- /**
668
- * The current values of any signals that are updated in this batch.
669
- * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
670
- * They keys of this map are identical to `this.#previous`
671
- * @type {Map<Value, [any, boolean]>}
672
- */
673
- "current",
674
- /* @__PURE__ */ new Map()
675
- );
676
- _defineProperty(
677
- this,
678
- /**
679
- * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
680
- * They keys of this map are identical to `this.#current`
681
- * @type {Map<Value, any>}
682
- */
683
- "previous",
684
- /* @__PURE__ */ new Map()
685
- );
686
- _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
687
- _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
688
- _classPrivateFieldInitSpec(this, _pending, 0);
689
- _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
690
- _classPrivateFieldInitSpec(this, _deferred, null);
691
- _classPrivateFieldInitSpec(this, _roots, []);
692
- _classPrivateFieldInitSpec(this, _new_effects, []);
693
- _classPrivateFieldInitSpec(this, _dirty_effects$1, /* @__PURE__ */ new Set());
694
- _classPrivateFieldInitSpec(this, _maybe_dirty_effects$1, /* @__PURE__ */ new Set());
695
- _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
696
- _classPrivateFieldInitSpec(this, _unskipped_branches, /* @__PURE__ */ new Set());
697
- _defineProperty(this, "is_fork", false);
698
- _classPrivateFieldInitSpec(this, _decrement_queued, false);
699
- if (last_batch === null) first_batch = last_batch = this;
700
- else {
701
- _classPrivateFieldSet2(_next, last_batch, this);
702
- _classPrivateFieldSet2(_prev, this, last_batch);
703
- }
704
- last_batch = this;
705
- }
706
- /**
707
- * Add an effect to the #skipped_branches map and reset its children
708
- * @param {Effect} effect
709
- */
710
- skip_effect(effect) {
711
- if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
712
- d: [],
713
- m: []
714
- });
715
- _classPrivateFieldGet2(_unskipped_branches, this).delete(effect);
716
- }
717
- /**
718
- * Remove an effect from the #skipped_branches map and reschedule
719
- * any tracked dirty/maybe_dirty child effects
720
- * @param {Effect} effect
721
- * @param {(e: Effect) => void} callback
722
- */
723
- unskip_effect(effect, callback = (e) => this.schedule(e)) {
724
- var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
725
- if (tracked) {
726
- _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
727
- for (var e of tracked.d) {
728
- set_signal_status(e, DIRTY);
729
- callback(e);
730
- }
731
- for (e of tracked.m) {
732
- set_signal_status(e, MAYBE_DIRTY);
733
- callback(e);
734
- }
735
- }
736
- _classPrivateFieldGet2(_unskipped_branches, this).add(effect);
737
- }
738
- /**
739
- * Associate a change to a given source with the current
740
- * batch, noting its previous and current values
741
- * @param {Value} source
742
- * @param {any} value
743
- * @param {boolean} [is_derived]
744
- */
745
- capture(source, value, is_derived = false) {
746
- if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
747
- if ((source.f & 8388608) === 0) {
748
- this.current.set(source, [value, is_derived]);
749
- batch_values?.set(source, value);
750
- }
751
- if (!this.is_fork) source.v = value;
752
- }
753
- activate() {
754
- current_batch = this;
755
- }
756
- deactivate() {
757
- current_batch = null;
758
- batch_values = null;
759
- }
760
- flush() {
761
- try {
762
- is_processing = true;
763
- current_batch = this;
764
- _assertClassBrand(_Batch_brand, this, _process).call(this);
765
- } finally {
766
- flush_count = 0;
767
- last_scheduled_effect = null;
768
- collected_effects = null;
769
- legacy_updates = null;
770
- is_processing = false;
771
- current_batch = null;
772
- batch_values = null;
773
- old_values.clear();
774
- }
775
- }
776
- discard() {
777
- for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
778
- _classPrivateFieldGet2(_discard_callbacks, this).clear();
779
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
780
- _classPrivateFieldGet2(_deferred, this)?.resolve();
781
- }
782
- /**
783
- * @param {Effect} effect
784
- */
785
- register_created_effect(effect) {
786
- _classPrivateFieldGet2(_new_effects, this).push(effect);
787
- }
788
- /**
789
- * @param {boolean} blocking
790
- * @param {Effect} effect
791
- */
792
- increment(blocking, effect) {
793
- _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) + 1);
794
- if (blocking) {
795
- let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
796
- _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count + 1);
797
- }
798
- }
799
- /**
800
- * @param {boolean} blocking
801
- * @param {Effect} effect
802
- */
803
- decrement(blocking, effect) {
804
- _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) - 1);
805
- if (blocking) {
806
- let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
807
- if (blocking_pending_count === 1) _classPrivateFieldGet2(_blocking_pending, this).delete(effect);
808
- else _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count - 1);
809
- }
810
- if (_classPrivateFieldGet2(_decrement_queued, this)) return;
811
- _classPrivateFieldSet2(_decrement_queued, this, true);
812
- queue_micro_task(() => {
813
- _classPrivateFieldSet2(_decrement_queued, this, false);
814
- if (this.linked) this.flush();
815
- });
816
- }
817
- /**
818
- * @param {Set<Effect>} dirty_effects
819
- * @param {Set<Effect>} maybe_dirty_effects
820
- */
821
- transfer_effects(dirty_effects, maybe_dirty_effects) {
822
- for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects$1, this).add(e);
823
- for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(e);
824
- dirty_effects.clear();
825
- maybe_dirty_effects.clear();
826
- }
827
- /** @param {(batch: Batch) => void} fn */
828
- oncommit(fn) {
829
- _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
830
- }
831
- /** @param {(batch: Batch) => void} fn */
832
- ondiscard(fn) {
833
- _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
834
- }
835
- settled() {
836
- return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
837
- }
838
- static ensure() {
839
- if (current_batch === null) {
840
- const batch = current_batch = new Batch();
841
- if (!is_processing && !is_flushing_sync) queue_micro_task(() => {
842
- if (!_classPrivateFieldGet2(_started, batch)) batch.flush();
843
- });
844
- }
845
- return current_batch;
846
- }
847
- apply() {
848
- if (!async_mode_flag || !this.is_fork && _classPrivateFieldGet2(_prev, this) === null && _classPrivateFieldGet2(_next, this) === null) {
849
- batch_values = null;
850
- return;
851
- }
852
- batch_values = /* @__PURE__ */ new Map();
853
- for (const [source, [value]] of this.current) batch_values.set(source, value);
854
- for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
855
- if (batch === this || batch.is_fork) continue;
856
- var intersects = false;
857
- if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
858
- if (is_derived) continue;
859
- if (this.current.has(source)) {
860
- intersects = true;
861
- break;
862
- }
863
- }
864
- if (!intersects) {
865
- for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
866
- }
867
- }
868
- }
869
- /**
870
- *
871
- * @param {Effect} effect
872
- */
873
- schedule(effect) {
874
- last_scheduled_effect = effect;
875
- if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
876
- effect.b.defer_effect(effect);
877
- return;
878
- }
879
- var e = effect;
880
- while (e.parent !== null) {
881
- e = e.parent;
882
- var flags = e.f;
883
- if (collected_effects !== null && e === active_effect) {
884
- if (async_mode_flag) return;
885
- if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
886
- }
887
- if ((flags & 96) !== 0) {
888
- if ((flags & 1024) === 0) return;
889
- e.f ^= CLEAN;
890
- }
891
- }
892
- _classPrivateFieldGet2(_roots, this).push(e);
893
- }
894
- };
895
- _Batch = Batch;
896
- function _is_deferred() {
897
- if (this.is_fork) return true;
898
- for (const effect of _classPrivateFieldGet2(_blocking_pending, this).keys()) {
899
- var e = effect;
900
- var skipped = false;
901
- while (e.parent !== null) {
902
- if (_classPrivateFieldGet2(_skipped_branches, this).has(e)) {
903
- skipped = true;
904
- break;
905
- }
906
- e = e.parent;
907
- }
908
- if (!skipped) return true;
909
- }
910
- return false;
911
- }
912
- function _process() {
913
- _classPrivateFieldSet2(_started, this, true);
914
- if (flush_count++ > 1e3) {
915
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
916
- infinite_loop_guard();
917
- }
918
- for (const e of _classPrivateFieldGet2(_dirty_effects$1, this)) {
919
- _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(e);
920
- set_signal_status(e, DIRTY);
921
- this.schedule(e);
922
- }
923
- for (const e of _classPrivateFieldGet2(_maybe_dirty_effects$1, this)) {
924
- set_signal_status(e, MAYBE_DIRTY);
925
- this.schedule(e);
926
- }
927
- const roots = _classPrivateFieldGet2(_roots, this);
928
- _classPrivateFieldSet2(_roots, this, []);
929
- this.apply();
930
- /** @type {Effect[]} */
931
- var effects = collected_effects = [];
932
- /** @type {Effect[]} */
933
- var render_effects = [];
934
- /**
935
- * @type {Effect[]}
936
- * @deprecated when we get rid of legacy mode and stores, we can get rid of this
937
- */
938
- var updates = legacy_updates = [];
939
- for (const root of roots) try {
940
- _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
941
- } catch (e) {
942
- reset_all(root);
943
- if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
944
- throw e;
945
- }
946
- current_batch = null;
947
- if (updates.length > 0) {
948
- var batch = _Batch.ensure();
949
- for (const e of updates) batch.schedule(e);
950
- }
951
- collected_effects = null;
952
- legacy_updates = null;
953
- if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
954
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
955
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
956
- for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
957
- if (updates.length > 0)
958
- /** @type {Batch} */ _assertClassBrand(_Batch_brand, current_batch, _process).call(current_batch);
959
- return;
960
- }
961
- const earlier_batch = _assertClassBrand(_Batch_brand, this, _find_earlier_batch).call(this);
962
- if (earlier_batch) {
963
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
964
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
965
- _assertClassBrand(_Batch_brand, earlier_batch, _merge).call(earlier_batch, this);
966
- return;
967
- }
968
- _classPrivateFieldGet2(_dirty_effects$1, this).clear();
969
- _classPrivateFieldGet2(_maybe_dirty_effects$1, this).clear();
970
- for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
971
- _classPrivateFieldGet2(_commit_callbacks, this).clear();
972
- previous_batch = this;
973
- flush_queued_effects(render_effects);
974
- flush_queued_effects(effects);
975
- previous_batch = null;
976
- _classPrivateFieldGet2(_deferred, this)?.resolve();
977
- var next_batch = current_batch;
978
- if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_roots, this).length === 0 || next_batch !== null)) {
979
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
980
- if (async_mode_flag) {
981
- _assertClassBrand(_Batch_brand, this, _commit$1).call(this);
982
- current_batch = next_batch;
983
- }
984
- }
985
- if (_classPrivateFieldGet2(_roots, this).length > 0) if (next_batch !== null) {
986
- const batch = next_batch;
987
- _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
988
- } else next_batch = this;
989
- if (next_batch !== null) _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
990
- }
991
- /**
992
- * Traverse the effect tree, executing effects or stashing
993
- * them for later execution as appropriate
994
- * @param {Effect} root
995
- * @param {Effect[]} effects
996
- * @param {Effect[]} render_effects
997
- */
998
- function _traverse(root, effects, render_effects) {
999
- root.f ^= CLEAN;
1000
- var effect = root.first;
1001
- while (effect !== null) {
1002
- var flags = effect.f;
1003
- var is_branch = (flags & 96) !== 0;
1004
- if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
1005
- if (is_branch) effect.f ^= CLEAN;
1006
- else if ((flags & 4) !== 0) effects.push(effect);
1007
- else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
1008
- else if (is_dirty(effect)) {
1009
- if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(effect);
1010
- update_effect(effect);
1011
- }
1012
- var child = effect.first;
1013
- if (child !== null) {
1014
- effect = child;
1015
- continue;
1016
- }
1017
- }
1018
- while (effect !== null) {
1019
- var next = effect.next;
1020
- if (next !== null) {
1021
- effect = next;
1022
- break;
1023
- }
1024
- effect = effect.parent;
1025
- }
1026
- }
1027
- }
1028
- function _find_earlier_batch() {
1029
- var batch = _classPrivateFieldGet2(_prev, this);
1030
- while (batch !== null) {
1031
- if (!batch.is_fork) {
1032
- for (const [value, [, is_derived]] of this.current) if (batch.current.has(value) && !is_derived) return batch;
1033
- }
1034
- batch = _classPrivateFieldGet2(_prev, batch);
1035
- }
1036
- return null;
1037
- }
1038
- /**
1039
- * @param {Batch} batch
1040
- */
1041
- function _merge(batch) {
1042
- for (const [source, value] of batch.current) {
1043
- if (!this.previous.has(source) && batch.previous.has(source)) this.previous.set(source, batch.previous.get(source));
1044
- this.current.set(source, value);
1045
- }
1046
- for (const [effect, deferred] of batch.async_deriveds) {
1047
- const d = this.async_deriveds.get(effect);
1048
- if (d) deferred.promise.then(d.resolve).catch(d.reject);
1049
- }
1050
- this.transfer_effects(_classPrivateFieldGet2(_dirty_effects$1, batch), _classPrivateFieldGet2(_maybe_dirty_effects$1, batch));
1051
- /**
1052
- * mark all effects that depend on `batch.current`, except the
1053
- * async effects that we just resolved (TODO unless they depend
1054
- * on values in this batch that are NOT in the later batch?).
1055
- * Through this we also will populate the correct #skipped_branches,
1056
- * oncommit callbacks etc, so we don't need to merge them separately.
1057
- * @param {Value} value
1058
- */
1059
- const mark = (value) => {
1060
- var reactions = value.reactions;
1061
- if (reactions === null) return;
1062
- for (const reaction of reactions) {
1063
- var flags = reaction.f;
1064
- if ((flags & 2) !== 0) mark(reaction);
1065
- else {
1066
- var effect = reaction;
1067
- if (flags & 4194320 && !this.async_deriveds.has(effect)) {
1068
- _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(effect);
1069
- set_signal_status(effect, DIRTY);
1070
- this.schedule(effect);
1071
- }
1072
- }
1073
- }
1074
- };
1075
- for (const source of this.current.keys()) mark(source);
1076
- this.oncommit(() => batch.discard());
1077
- _assertClassBrand(_Batch_brand, batch, _unlink).call(batch);
1078
- current_batch = this;
1079
- _assertClassBrand(_Batch_brand, this, _process).call(this);
748
+ /*#__NO_SIDE_EFFECTS__*/
749
+ function user_derived(fn) {
750
+ const d = /* @__PURE__ */ derived(fn);
751
+ if (!async_mode_flag) push_reaction_value(d);
752
+ return d;
1080
753
  }
1081
754
  /**
1082
- * @param {Effect[]} effects
755
+ * @template V
756
+ * @param {() => V} fn
757
+ * @returns {Derived<V>}
1083
758
  */
1084
- function _defer_effects(effects) {
1085
- for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
759
+ /*#__NO_SIDE_EFFECTS__*/
760
+ function derived_safe_equal(fn) {
761
+ const signal = /* @__PURE__ */ derived(fn);
762
+ signal.equals = safe_equals;
763
+ return signal;
1086
764
  }
1087
- function _commit$1() {
1088
- for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1089
- var is_earlier = batch.id < this.id;
1090
- /** @type {Source[]} */
1091
- var sources = [];
1092
- for (const [source, [value, is_derived]] of this.current) {
1093
- if (batch.current.has(source)) {
1094
- var batch_value = batch.current.get(source)[0];
1095
- if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
1096
- else continue;
1097
- }
1098
- sources.push(source);
1099
- }
1100
- if (is_earlier) for (const [effect, deferred] of this.async_deriveds) {
1101
- const d = batch.async_deriveds.get(effect);
1102
- if (d) deferred.promise.then(d.resolve).catch(d.reject);
1103
- }
1104
- if (!_classPrivateFieldGet2(_started, batch)) continue;
1105
- var others = [...batch.current.keys()].filter((s) => !batch.current.get(s)[1] && !this.current.has(s));
1106
- if (others.length === 0) {
1107
- if (is_earlier) batch.discard();
1108
- } else if (sources.length > 0) {
1109
- if (is_earlier) for (const unskipped of _classPrivateFieldGet2(_unskipped_branches, this)) batch.unskip_effect(unskipped, (e) => {
1110
- if ((e.f & 4194320) !== 0) batch.schedule(e);
1111
- else _assertClassBrand(_Batch_brand, batch, _defer_effects).call(batch, [e]);
1112
- });
1113
- batch.activate();
1114
- /** @type {Set<Value>} */
1115
- var marked = /* @__PURE__ */ new Set();
1116
- /** @type {Map<Reaction, boolean>} */
1117
- var checked = /* @__PURE__ */ new Map();
1118
- for (var source of sources) mark_effects(source, others, marked, checked);
1119
- checked = /* @__PURE__ */ new Map();
1120
- var current_unequal = [...batch.current].filter(([c, v1]) => {
1121
- const v2 = this.current.get(c);
1122
- if (!v2) return true;
1123
- return v2[0] !== v1[0] || v2[1] !== v1[1];
1124
- }).map(([c]) => c);
1125
- if (current_unequal.length > 0) {
1126
- for (const effect of _classPrivateFieldGet2(_new_effects, this)) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1127
- set_signal_status(effect, DIRTY);
1128
- batch.schedule(effect);
1129
- } else _classPrivateFieldGet2(_dirty_effects$1, batch).add(effect);
1130
- }
1131
- if (_classPrivateFieldGet2(_roots, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1132
- batch.apply();
1133
- for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1134
- _classPrivateFieldSet2(_roots, batch, []);
1135
- }
1136
- batch.deactivate();
1137
- }
765
+ /**
766
+ * @param {Derived} derived
767
+ * @returns {void}
768
+ */
769
+ function destroy_derived_effects(derived) {
770
+ var effects = derived.effects;
771
+ if (effects !== null) {
772
+ derived.effects = null;
773
+ for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1138
774
  }
1139
775
  }
1140
- function _unlink() {
1141
- if (!this.linked) return;
1142
- var prev = _classPrivateFieldGet2(_prev, this);
1143
- var next = _classPrivateFieldGet2(_next, this);
1144
- if (prev === null) first_batch = next;
1145
- else _classPrivateFieldSet2(_next, prev, next);
1146
- if (next === null) last_batch = prev;
1147
- else _classPrivateFieldSet2(_prev, next, prev);
1148
- this.linked = false;
1149
- }
1150
776
  /**
1151
- * Synchronously flush any pending updates.
1152
- * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1153
- * @template [T=void]
1154
- * @param {(() => T) | undefined} [fn]
777
+ * @template T
778
+ * @param {Derived} derived
1155
779
  * @returns {T}
1156
780
  */
1157
- function flushSync(fn) {
1158
- var was_flushing_sync = is_flushing_sync;
1159
- is_flushing_sync = true;
1160
- try {
1161
- var result;
1162
- if (fn) {
1163
- if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
1164
- result = fn();
1165
- }
1166
- while (true) {
1167
- flush_tasks();
1168
- if (current_batch === null) return result;
1169
- current_batch.flush();
1170
- }
1171
- } finally {
1172
- is_flushing_sync = was_flushing_sync;
781
+ function execute_derived(derived) {
782
+ var value;
783
+ var prev_active_effect = active_effect;
784
+ var parent = derived.parent;
785
+ if (!is_destroying_effect && parent !== null && derived.v !== UNINITIALIZED && (parent.f & 24576) !== 0) {
786
+ derived_inert();
787
+ return derived.v;
1173
788
  }
1174
- }
1175
- function infinite_loop_guard() {
789
+ set_active_effect(parent);
1176
790
  try {
1177
- effect_update_depth_exceeded();
1178
- } catch (error) {
1179
- invoke_error_boundary(error, last_scheduled_effect);
791
+ derived.f &= ~WAS_MARKED;
792
+ destroy_derived_effects(derived);
793
+ value = update_reaction(derived);
794
+ } finally {
795
+ set_active_effect(prev_active_effect);
1180
796
  }
797
+ return value;
1181
798
  }
1182
- /** @type {Set<Effect> | null} */
1183
- var eager_block_effects = null;
1184
799
  /**
1185
- * @param {Array<Effect>} effects
800
+ * @param {Derived} derived
1186
801
  * @returns {void}
1187
802
  */
1188
- function flush_queued_effects(effects) {
1189
- var length = effects.length;
1190
- if (length === 0) return;
1191
- var i = 0;
1192
- while (i < length) {
1193
- var effect = effects[i++];
1194
- if ((effect.f & 24576) === 0 && is_dirty(effect)) {
1195
- eager_block_effects = /* @__PURE__ */ new Set();
1196
- update_effect(effect);
1197
- if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
1198
- if (eager_block_effects?.size > 0) {
1199
- old_values.clear();
1200
- for (const e of eager_block_effects) {
1201
- if ((e.f & 24576) !== 0) continue;
1202
- /** @type {Effect[]} */
1203
- const ordered_effects = [e];
1204
- let ancestor = e.parent;
1205
- while (ancestor !== null) {
1206
- if (eager_block_effects.has(ancestor)) {
1207
- eager_block_effects.delete(ancestor);
1208
- ordered_effects.push(ancestor);
1209
- }
1210
- ancestor = ancestor.parent;
1211
- }
1212
- for (let j = ordered_effects.length - 1; j >= 0; j--) {
1213
- const e = ordered_effects[j];
1214
- if ((e.f & 24576) !== 0) continue;
1215
- update_effect(e);
1216
- }
1217
- }
1218
- eager_block_effects.clear();
803
+ function update_derived(derived) {
804
+ var value = execute_derived(derived);
805
+ if (!derived.equals(value)) {
806
+ derived.wv = increment_write_version();
807
+ if (!current_batch?.is_fork || derived.deps === null) {
808
+ if (current_batch !== null) {
809
+ current_batch.capture(derived, value, true);
810
+ previous_batch?.capture(derived, value, true);
811
+ } else derived.v = value;
812
+ if (derived.deps === null) {
813
+ set_signal_status(derived, CLEAN);
814
+ return;
1219
815
  }
1220
816
  }
1221
817
  }
1222
- eager_block_effects = null;
1223
- }
1224
- /**
1225
- * This is similar to `mark_reactions`, but it only marks async/block effects
1226
- * depending on `value` and at least one of the other `sources`, so that
1227
- * these effects can re-run after another batch has been committed
1228
- * @param {Value} value
1229
- * @param {Source[]} sources
1230
- * @param {Set<Value>} marked
1231
- * @param {Map<Reaction, boolean>} checked
1232
- */
1233
- function mark_effects(value, sources, marked, checked) {
1234
- if (marked.has(value)) return;
1235
- marked.add(value);
1236
- if (value.reactions !== null) for (const reaction of value.reactions) {
1237
- const flags = reaction.f;
1238
- if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
1239
- else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
1240
- set_signal_status(reaction, DIRTY);
1241
- schedule_effect(reaction);
1242
- }
1243
- }
1244
- }
1245
- /**
1246
- * @param {Reaction} reaction
1247
- * @param {Source[]} sources
1248
- * @param {Map<Reaction, boolean>} checked
1249
- */
1250
- function depends_on(reaction, sources, checked) {
1251
- const depends = checked.get(reaction);
1252
- if (depends !== void 0) return depends;
1253
- if (reaction.deps !== null) for (const dep of reaction.deps) {
1254
- if (includes.call(sources, dep)) return true;
1255
- if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
1256
- checked.set(dep, true);
1257
- return true;
1258
- }
1259
- }
1260
- checked.set(reaction, false);
1261
- return false;
1262
- }
1263
- /**
1264
- * @param {Effect} effect
1265
- * @returns {void}
1266
- */
1267
- function schedule_effect(effect) {
1268
- /** @type {Batch} */ current_batch.schedule(effect);
1269
- }
1270
- /**
1271
- * Mark all the effects inside a skipped branch CLEAN, so that
1272
- * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1273
- * effects so they can be rescheduled if the branch survives.
1274
- * @param {Effect} effect
1275
- * @param {{ d: Effect[], m: Effect[] }} tracked
1276
- */
1277
- function reset_branch(effect, tracked) {
1278
- if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1279
- if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1280
- else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1281
- set_signal_status(effect, CLEAN);
1282
- var e = effect.first;
1283
- while (e !== null) {
1284
- reset_branch(e, tracked);
1285
- e = e.next;
1286
- }
818
+ if (is_destroying_effect) return;
819
+ if (batch_values !== null) {
820
+ if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
821
+ } else update_derived_status(derived);
1287
822
  }
1288
823
  /**
1289
- * Mark an entire effect tree clean following an error
1290
- * @param {Effect} effect
824
+ * @param {Derived} derived
1291
825
  */
1292
- function reset_all(effect) {
1293
- set_signal_status(effect, CLEAN);
1294
- var e = effect.first;
1295
- while (e !== null) {
1296
- reset_all(e);
1297
- e = e.next;
826
+ function freeze_derived_effects(derived) {
827
+ if (derived.effects === null) return;
828
+ for (const e of derived.effects) if (e.teardown || e.ac) {
829
+ e.teardown?.();
830
+ if (e.ac !== null) without_reactive_context(() => {
831
+ /** @type {AbortController} */ e.ac.abort(STALE_REACTION);
832
+ e.ac = null;
833
+ });
834
+ if (e.fn !== null) e.teardown = noop;
835
+ remove_reactions(e, 0);
836
+ destroy_effect_children(e);
1298
837
  }
1299
838
  }
1300
- //#endregion
1301
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/reactivity/create-subscriber.js
1302
839
  /**
1303
- * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
1304
- * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
1305
- *
1306
- * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
1307
- * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
1308
- *
1309
- * If `start` returns a cleanup function, it will be called when the effect is destroyed.
1310
- *
1311
- * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
1312
- * are active, and the returned teardown function will only be called when all effects are destroyed.
1313
- *
1314
- * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
1315
- *
1316
- * ```js
1317
- * import { createSubscriber } from 'svelte/reactivity';
1318
- * import { on } from 'svelte/events';
1319
- *
1320
- * export class MediaQuery {
1321
- * #query;
1322
- * #subscribe;
1323
- *
1324
- * constructor(query) {
1325
- * this.#query = window.matchMedia(`(${query})`);
1326
- *
1327
- * this.#subscribe = createSubscriber((update) => {
1328
- * // when the `change` event occurs, re-run any effects that read `this.current`
1329
- * const off = on(this.#query, 'change', update);
1330
- *
1331
- * // stop listening when all the effects are destroyed
1332
- * return () => off();
1333
- * });
1334
- * }
1335
- *
1336
- * get current() {
1337
- * // This makes the getter reactive, if read in an effect
1338
- * this.#subscribe();
1339
- *
1340
- * // Return the current state of the query, whether or not we're in an effect
1341
- * return this.#query.matches;
1342
- * }
1343
- * }
1344
- * ```
1345
- * @param {(update: () => void) => (() => void) | void} start
1346
- * @since 5.7.0
840
+ * @param {Derived} derived
1347
841
  */
1348
- function createSubscriber(start) {
1349
- let subscribers = 0;
1350
- let version = source(0);
1351
- /** @type {(() => void) | void} */
1352
- let stop;
1353
- return () => {
1354
- if (effect_tracking()) {
1355
- get(version);
1356
- render_effect(() => {
1357
- if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
1358
- subscribers += 1;
1359
- return () => {
1360
- queue_micro_task(() => {
1361
- subscribers -= 1;
1362
- if (subscribers === 0) {
1363
- stop?.();
1364
- stop = void 0;
1365
- increment(version);
1366
- }
1367
- });
1368
- };
1369
- });
1370
- }
1371
- };
842
+ function unfreeze_derived_effects(derived) {
843
+ if (derived.effects === null) return;
844
+ for (const e of derived.effects) if (e.teardown && e.fn !== null) update_effect(e);
1372
845
  }
1373
846
  //#endregion
1374
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
1375
- /** @import { Effect, Source, TemplateNode, } from '#client' */
847
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/checkPrivateRedeclaration.js
848
+ function _checkPrivateRedeclaration(e, t) {
849
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
850
+ }
851
+ //#endregion
852
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateMethodInitSpec.js
853
+ function _classPrivateMethodInitSpec(e, a) {
854
+ _checkPrivateRedeclaration(e, a), a.add(e);
855
+ }
856
+ //#endregion
857
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldInitSpec.js
858
+ function _classPrivateFieldInitSpec(e, t, a) {
859
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
860
+ }
861
+ //#endregion
862
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/assertClassBrand.js
863
+ function _assertClassBrand(e, t, n) {
864
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
865
+ throw new TypeError("Private element is not present on this object");
866
+ }
867
+ //#endregion
868
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldSet2.js
869
+ function _classPrivateFieldSet2(s, a, r) {
870
+ return s.set(_assertClassBrand(s, a), r), r;
871
+ }
872
+ //#endregion
873
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldGet2.js
874
+ function _classPrivateFieldGet2(s, a) {
875
+ return s.get(_assertClassBrand(s, a));
876
+ }
877
+ //#endregion
878
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/batch.js
879
+ /** @import { Fork } from 'svelte' */
880
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
881
+ var _Batch;
882
+ /** @type {Batch | null} */
883
+ var first_batch = null;
884
+ /** @type {Batch | null} */
885
+ var last_batch = null;
886
+ /** @type {Batch | null} */
887
+ var current_batch = null;
1376
888
  /**
1377
- * @typedef {{
1378
- * onerror?: ((error: unknown, reset: () => void) => void) | null;
1379
- * failed?: ((anchor: Node, error: () => unknown, reset: () => () => void) => void) | null;
1380
- * pending?: ((anchor: Node) => void) | null;
1381
- * }} BoundaryProps
889
+ * This is needed to avoid overwriting inputs
890
+ * @type {Batch | null}
1382
891
  */
1383
- var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
892
+ var previous_batch = null;
1384
893
  /**
1385
- * @param {TemplateNode} node
1386
- * @param {BoundaryProps} props
1387
- * @param {((anchor: Node) => void)} children
1388
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
1389
- * @returns {void}
894
+ * When time travelling (i.e. working in one batch, while other batches
895
+ * still have ongoing work), we ignore the real values of affected
896
+ * signals in favour of their values within the batch
897
+ * @type {Map<Value, any> | null}
1390
898
  */
1391
- function boundary(node, props, children, transform_error) {
1392
- new Boundary(node, props, children, transform_error);
1393
- }
1394
- var _anchor = /* @__PURE__ */ new WeakMap();
1395
- var _hydrate_open = /* @__PURE__ */ new WeakMap();
1396
- var _props = /* @__PURE__ */ new WeakMap();
1397
- var _children = /* @__PURE__ */ new WeakMap();
1398
- var _effect = /* @__PURE__ */ new WeakMap();
1399
- var _main_effect = /* @__PURE__ */ new WeakMap();
1400
- var _pending_effect = /* @__PURE__ */ new WeakMap();
1401
- var _failed_effect = /* @__PURE__ */ new WeakMap();
1402
- var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
1403
- var _local_pending_count = /* @__PURE__ */ new WeakMap();
1404
- var _pending_count = /* @__PURE__ */ new WeakMap();
1405
- var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
1406
- var _dirty_effects = /* @__PURE__ */ new WeakMap();
1407
- var _maybe_dirty_effects = /* @__PURE__ */ new WeakMap();
1408
- var _effect_pending = /* @__PURE__ */ new WeakMap();
1409
- var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
1410
- var _Boundary_brand = /* @__PURE__ */ new WeakSet();
1411
- var Boundary = class {
1412
- /**
1413
- * @param {TemplateNode} node
1414
- * @param {BoundaryProps} props
1415
- * @param {((anchor: Node) => void)} children
1416
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
1417
- */
1418
- constructor(node, props, children, transform_error) {
1419
- _classPrivateMethodInitSpec(this, _Boundary_brand);
1420
- _defineProperty(
1421
- this,
1422
- /** @type {Boundary | null} */
1423
- "parent",
1424
- void 0
1425
- );
1426
- _defineProperty(this, "is_pending", false);
1427
- _defineProperty(
1428
- this,
1429
- /**
1430
- * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
1431
- * Inherited from parent boundary, or defaults to identity.
1432
- * @type {(error: unknown) => unknown}
1433
- */
1434
- "transform_error",
1435
- void 0
1436
- );
1437
- _classPrivateFieldInitSpec(this, _anchor, void 0);
1438
- _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
1439
- _classPrivateFieldInitSpec(this, _props, void 0);
1440
- _classPrivateFieldInitSpec(this, _children, void 0);
1441
- _classPrivateFieldInitSpec(this, _effect, void 0);
1442
- _classPrivateFieldInitSpec(this, _main_effect, null);
1443
- _classPrivateFieldInitSpec(this, _pending_effect, null);
1444
- _classPrivateFieldInitSpec(this, _failed_effect, null);
1445
- _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
1446
- _classPrivateFieldInitSpec(this, _local_pending_count, 0);
1447
- _classPrivateFieldInitSpec(this, _pending_count, 0);
1448
- _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
1449
- _classPrivateFieldInitSpec(this, _dirty_effects, /* @__PURE__ */ new Set());
1450
- _classPrivateFieldInitSpec(this, _maybe_dirty_effects, /* @__PURE__ */ new Set());
1451
- _classPrivateFieldInitSpec(this, _effect_pending, null);
1452
- _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
1453
- _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
1454
- return () => {
1455
- _classPrivateFieldSet2(_effect_pending, this, null);
1456
- };
1457
- }));
1458
- _classPrivateFieldSet2(_anchor, this, node);
1459
- _classPrivateFieldSet2(_props, this, props);
1460
- _classPrivateFieldSet2(_children, this, (anchor) => {
1461
- var effect = active_effect;
1462
- effect.b = this;
1463
- effect.f |= 128;
1464
- children(anchor);
1465
- });
1466
- this.parent = active_effect.b;
1467
- this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
1468
- _classPrivateFieldSet2(_effect, this, block(() => {
1469
- if (hydrating) {
1470
- const comment = _classPrivateFieldGet2(_hydrate_open, this);
1471
- hydrate_next();
1472
- const server_rendered_pending = comment.data === "[!";
1473
- if (comment.data.startsWith("[?")) {
1474
- const serialized_error = JSON.parse(comment.data.slice(2));
1475
- _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
1476
- } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
1477
- else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
1478
- } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
1479
- }, flags));
1480
- if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
899
+ var batch_values = null;
900
+ /** @type {Effect | null} */
901
+ var last_scheduled_effect = null;
902
+ var is_flushing_sync = false;
903
+ var is_processing = false;
904
+ /**
905
+ * During traversal, this is an array. Newly created effects are (if not immediately
906
+ * executed) pushed to this array, rather than going through the scheduling
907
+ * rigamarole that would cause another turn of the flush loop.
908
+ * @type {Effect[] | null}
909
+ */
910
+ var collected_effects = null;
911
+ /**
912
+ * An array of effects that are marked during traversal as a result of a `set`
913
+ * (not `internal_set`) call. These will be added to the next batch and
914
+ * trigger another `batch.process()`
915
+ * @type {Effect[] | null}
916
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
917
+ */
918
+ var legacy_updates = null;
919
+ var flush_count = 0;
920
+ var uid = 1;
921
+ var _started = /* @__PURE__ */ new WeakMap();
922
+ var _prev = /* @__PURE__ */ new WeakMap();
923
+ var _next = /* @__PURE__ */ new WeakMap();
924
+ var _commit_callbacks = /* @__PURE__ */ new WeakMap();
925
+ var _discard_callbacks = /* @__PURE__ */ new WeakMap();
926
+ var _pending = /* @__PURE__ */ new WeakMap();
927
+ var _blocking_pending = /* @__PURE__ */ new WeakMap();
928
+ var _deferred = /* @__PURE__ */ new WeakMap();
929
+ var _roots = /* @__PURE__ */ new WeakMap();
930
+ var _new_effects = /* @__PURE__ */ new WeakMap();
931
+ var _dirty_effects$1 = /* @__PURE__ */ new WeakMap();
932
+ var _maybe_dirty_effects$1 = /* @__PURE__ */ new WeakMap();
933
+ var _skipped_branches = /* @__PURE__ */ new WeakMap();
934
+ var _unskipped_branches = /* @__PURE__ */ new WeakMap();
935
+ var _decrement_queued = /* @__PURE__ */ new WeakMap();
936
+ var _Batch_brand = /* @__PURE__ */ new WeakSet();
937
+ var Batch = class Batch {
938
+ constructor() {
939
+ _classPrivateMethodInitSpec(this, _Batch_brand);
940
+ _defineProperty(this, "id", uid++);
941
+ _classPrivateFieldInitSpec(this, _started, false);
942
+ _defineProperty(this, "linked", true);
943
+ _classPrivateFieldInitSpec(this, _prev, null);
944
+ _classPrivateFieldInitSpec(this, _next, null);
945
+ _defineProperty(
946
+ this,
947
+ /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
948
+ "async_deriveds",
949
+ /* @__PURE__ */ new Map()
950
+ );
951
+ _defineProperty(
952
+ this,
953
+ /**
954
+ * The current values of any signals that are updated in this batch.
955
+ * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
956
+ * They keys of this map are identical to `this.#previous`
957
+ * @type {Map<Value, [any, boolean]>}
958
+ */
959
+ "current",
960
+ /* @__PURE__ */ new Map()
961
+ );
962
+ _defineProperty(
963
+ this,
964
+ /**
965
+ * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
966
+ * They keys of this map are identical to `this.#current`
967
+ * @type {Map<Value, any>}
968
+ */
969
+ "previous",
970
+ /* @__PURE__ */ new Map()
971
+ );
972
+ _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
973
+ _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
974
+ _classPrivateFieldInitSpec(this, _pending, 0);
975
+ _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
976
+ _classPrivateFieldInitSpec(this, _deferred, null);
977
+ _classPrivateFieldInitSpec(this, _roots, []);
978
+ _classPrivateFieldInitSpec(this, _new_effects, []);
979
+ _classPrivateFieldInitSpec(this, _dirty_effects$1, /* @__PURE__ */ new Set());
980
+ _classPrivateFieldInitSpec(this, _maybe_dirty_effects$1, /* @__PURE__ */ new Set());
981
+ _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
982
+ _classPrivateFieldInitSpec(this, _unskipped_branches, /* @__PURE__ */ new Set());
983
+ _defineProperty(this, "is_fork", false);
984
+ _classPrivateFieldInitSpec(this, _decrement_queued, false);
985
+ if (last_batch === null) first_batch = last_batch = this;
986
+ else {
987
+ _classPrivateFieldSet2(_next, last_batch, this);
988
+ _classPrivateFieldSet2(_prev, this, last_batch);
989
+ }
990
+ last_batch = this;
1481
991
  }
1482
992
  /**
1483
- * Defer an effect inside a pending boundary until the boundary resolves
993
+ * Add an effect to the #skipped_branches map and reset its children
1484
994
  * @param {Effect} effect
1485
995
  */
1486
- defer_effect(effect) {
1487
- defer_effect(effect, _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
996
+ skip_effect(effect) {
997
+ if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
998
+ d: [],
999
+ m: []
1000
+ });
1001
+ _classPrivateFieldGet2(_unskipped_branches, this).delete(effect);
1488
1002
  }
1489
1003
  /**
1490
- * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1491
- * @returns {boolean}
1004
+ * Remove an effect from the #skipped_branches map and reschedule
1005
+ * any tracked dirty/maybe_dirty child effects
1006
+ * @param {Effect} effect
1007
+ * @param {(e: Effect) => void} callback
1492
1008
  */
1493
- is_rendered() {
1494
- return !this.is_pending && (!this.parent || this.parent.is_rendered());
1495
- }
1496
- has_pending_snippet() {
1497
- return !!_classPrivateFieldGet2(_props, this).pending;
1009
+ unskip_effect(effect, callback = (e) => this.schedule(e)) {
1010
+ var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
1011
+ if (tracked) {
1012
+ _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
1013
+ for (var e of tracked.d) {
1014
+ set_signal_status(e, DIRTY);
1015
+ callback(e);
1016
+ }
1017
+ for (e of tracked.m) {
1018
+ set_signal_status(e, MAYBE_DIRTY);
1019
+ callback(e);
1020
+ }
1021
+ }
1022
+ _classPrivateFieldGet2(_unskipped_branches, this).add(effect);
1498
1023
  }
1499
1024
  /**
1500
- * Update the source that powers `$effect.pending()` inside this boundary,
1501
- * and controls when the current `pending` snippet (if any) is removed.
1502
- * Do not call from inside the class
1503
- * @param {1 | -1} d
1504
- * @param {Batch} batch
1025
+ * Associate a change to a given source with the current
1026
+ * batch, noting its previous and current values
1027
+ * @param {Value} source
1028
+ * @param {any} value
1029
+ * @param {boolean} [is_derived]
1505
1030
  */
1506
- update_pending_count(d, batch) {
1507
- _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
1508
- _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
1509
- if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
1510
- _classPrivateFieldSet2(_pending_count_update_queued, this, true);
1511
- queue_micro_task(() => {
1512
- _classPrivateFieldSet2(_pending_count_update_queued, this, false);
1513
- if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
1514
- });
1515
- }
1516
- get_effect_pending() {
1517
- _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
1518
- return get(_classPrivateFieldGet2(_effect_pending, this));
1031
+ capture(source, value, is_derived = false) {
1032
+ if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
1033
+ if ((source.f & 8388608) === 0) {
1034
+ this.current.set(source, [value, is_derived]);
1035
+ batch_values?.set(source, value);
1036
+ }
1037
+ if (!this.is_fork) source.v = value;
1519
1038
  }
1520
- /** @param {unknown} error */
1521
- error(error) {
1522
- if (!_classPrivateFieldGet2(_props, this).onerror && !_classPrivateFieldGet2(_props, this).failed) throw error;
1523
- if (current_batch?.is_fork) {
1524
- if (_classPrivateFieldGet2(_main_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_main_effect, this));
1525
- if (_classPrivateFieldGet2(_pending_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_pending_effect, this));
1526
- if (_classPrivateFieldGet2(_failed_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_failed_effect, this));
1527
- current_batch.oncommit(() => {
1528
- _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
1529
- });
1530
- } else _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
1039
+ activate() {
1040
+ current_batch = this;
1531
1041
  }
1532
- };
1533
- function _hydrate_resolved_content() {
1534
- try {
1535
- _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
1536
- } catch (error) {
1537
- this.error(error);
1042
+ deactivate() {
1043
+ current_batch = null;
1044
+ batch_values = null;
1538
1045
  }
1539
- }
1540
- /**
1541
- * @param {unknown} error The deserialized error from the server's hydration comment
1542
- */
1543
- function _hydrate_failed_content(error) {
1544
- const failed = _classPrivateFieldGet2(_props, this).failed;
1545
- if (!failed) return;
1546
- _classPrivateFieldSet2(_failed_effect, this, branch(() => {
1547
- failed(_classPrivateFieldGet2(_anchor, this), () => error, () => () => {});
1548
- }));
1549
- }
1550
- function _hydrate_pending_content() {
1551
- const pending = _classPrivateFieldGet2(_props, this).pending;
1552
- if (!pending) return;
1553
- this.is_pending = true;
1554
- _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
1555
- queue_micro_task(() => {
1556
- var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
1557
- var anchor = create_text();
1558
- fragment.append(anchor);
1559
- _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1560
- return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
1561
- }));
1562
- if (_classPrivateFieldGet2(_pending_count, this) === 0) {
1563
- _classPrivateFieldGet2(_anchor, this).before(fragment);
1564
- _classPrivateFieldSet2(_offscreen_fragment, this, null);
1565
- pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
1566
- _classPrivateFieldSet2(_pending_effect, this, null);
1567
- });
1568
- _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
1046
+ flush() {
1047
+ try {
1048
+ is_processing = true;
1049
+ current_batch = this;
1050
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
1051
+ } finally {
1052
+ flush_count = 0;
1053
+ last_scheduled_effect = null;
1054
+ collected_effects = null;
1055
+ legacy_updates = null;
1056
+ is_processing = false;
1057
+ current_batch = null;
1058
+ batch_values = null;
1059
+ old_values.clear();
1569
1060
  }
1570
- });
1571
- }
1572
- function _render() {
1573
- try {
1574
- this.is_pending = this.has_pending_snippet();
1575
- _classPrivateFieldSet2(_pending_count, this, 0);
1576
- _classPrivateFieldSet2(_local_pending_count, this, 0);
1577
- _classPrivateFieldSet2(_main_effect, this, branch(() => {
1578
- _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
1579
- }));
1580
- if (_classPrivateFieldGet2(_pending_count, this) > 0) {
1581
- var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
1582
- move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
1583
- const pending = _classPrivateFieldGet2(_props, this).pending;
1584
- _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
1585
- } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
1586
- } catch (error) {
1587
- this.error(error);
1588
1061
  }
1589
- }
1590
- /**
1591
- * @param {Batch} batch
1592
- */
1593
- function _resolve(batch) {
1594
- this.is_pending = false;
1595
- batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
1596
- }
1597
- /**
1598
- * @template T
1599
- * @param {() => T} fn
1600
- */
1601
- function _run(fn) {
1602
- var previous_effect = active_effect;
1603
- var previous_reaction = active_reaction;
1604
- var previous_ctx = component_context;
1605
- set_active_effect(_classPrivateFieldGet2(_effect, this));
1606
- set_active_reaction(_classPrivateFieldGet2(_effect, this));
1607
- set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
1608
- try {
1609
- Batch.ensure();
1610
- return fn();
1611
- } catch (e) {
1612
- handle_error(e);
1613
- return null;
1614
- } finally {
1615
- set_active_effect(previous_effect);
1616
- set_active_reaction(previous_reaction);
1617
- set_component_context(previous_ctx);
1062
+ discard() {
1063
+ for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
1064
+ _classPrivateFieldGet2(_discard_callbacks, this).clear();
1065
+ for (const deferred of this.async_deriveds.values()) deferred.reject(OBSOLETE);
1066
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1067
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
1618
1068
  }
1619
- }
1620
- /**
1621
- * Updates the pending count associated with the currently visible pending snippet,
1622
- * if any, such that we can replace the snippet with content once work is done
1623
- * @param {1 | -1} d
1624
- * @param {Batch} batch
1625
- */
1626
- function _update_pending_count(d, batch) {
1627
- if (!this.has_pending_snippet()) {
1628
- if (this.parent) {
1629
- var _this$parent;
1630
- _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
1069
+ /**
1070
+ * @param {Effect} effect
1071
+ */
1072
+ register_created_effect(effect) {
1073
+ _classPrivateFieldGet2(_new_effects, this).push(effect);
1074
+ }
1075
+ /**
1076
+ * @param {boolean} blocking
1077
+ * @param {Effect} effect
1078
+ */
1079
+ increment(blocking, effect) {
1080
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) + 1);
1081
+ if (blocking) {
1082
+ let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
1083
+ _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count + 1);
1631
1084
  }
1632
- return;
1633
1085
  }
1634
- _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
1635
- if (_classPrivateFieldGet2(_pending_count, this) === 0) {
1636
- _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
1637
- if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
1638
- _classPrivateFieldSet2(_pending_effect, this, null);
1639
- });
1640
- if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
1641
- _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
1642
- _classPrivateFieldSet2(_offscreen_fragment, this, null);
1086
+ /**
1087
+ * @param {boolean} blocking
1088
+ * @param {Effect} effect
1089
+ */
1090
+ decrement(blocking, effect) {
1091
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) - 1);
1092
+ if (blocking) {
1093
+ let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
1094
+ if (blocking_pending_count === 1) _classPrivateFieldGet2(_blocking_pending, this).delete(effect);
1095
+ else _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count - 1);
1643
1096
  }
1097
+ if (_classPrivateFieldGet2(_decrement_queued, this)) return;
1098
+ _classPrivateFieldSet2(_decrement_queued, this, true);
1099
+ queue_micro_task(() => {
1100
+ _classPrivateFieldSet2(_decrement_queued, this, false);
1101
+ if (this.linked) this.flush();
1102
+ });
1644
1103
  }
1645
- }
1646
- /**
1647
- * @param {unknown} error
1648
- */
1649
- function _handle_error(error) {
1650
- if (_classPrivateFieldGet2(_main_effect, this)) {
1651
- destroy_effect(_classPrivateFieldGet2(_main_effect, this));
1652
- _classPrivateFieldSet2(_main_effect, this, null);
1104
+ /**
1105
+ * @param {Set<Effect>} dirty_effects
1106
+ * @param {Set<Effect>} maybe_dirty_effects
1107
+ */
1108
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
1109
+ for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects$1, this).add(e);
1110
+ for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(e);
1111
+ dirty_effects.clear();
1112
+ maybe_dirty_effects.clear();
1653
1113
  }
1654
- if (_classPrivateFieldGet2(_pending_effect, this)) {
1655
- destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
1656
- _classPrivateFieldSet2(_pending_effect, this, null);
1114
+ /** @param {(batch: Batch) => void} fn */
1115
+ oncommit(fn) {
1116
+ _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
1657
1117
  }
1658
- if (_classPrivateFieldGet2(_failed_effect, this)) {
1659
- destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
1660
- _classPrivateFieldSet2(_failed_effect, this, null);
1118
+ /** @param {(batch: Batch) => void} fn */
1119
+ ondiscard(fn) {
1120
+ _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
1661
1121
  }
1662
- if (hydrating) {
1663
- set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
1664
- next();
1665
- set_hydrate_node(skip_nodes());
1122
+ settled() {
1123
+ return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
1666
1124
  }
1667
- var onerror = _classPrivateFieldGet2(_props, this).onerror;
1668
- let failed = _classPrivateFieldGet2(_props, this).failed;
1669
- var did_reset = false;
1670
- var calling_on_error = false;
1671
- const reset = () => {
1672
- if (did_reset) {
1673
- svelte_boundary_reset_noop();
1674
- return;
1125
+ static ensure() {
1126
+ if (current_batch === null) {
1127
+ const batch = current_batch = new Batch();
1128
+ if (!is_processing && !is_flushing_sync) queue_micro_task(() => {
1129
+ if (!_classPrivateFieldGet2(_started, batch)) batch.flush();
1130
+ });
1675
1131
  }
1676
- did_reset = true;
1677
- if (calling_on_error) svelte_boundary_reset_onerror();
1678
- if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
1679
- _classPrivateFieldSet2(_failed_effect, this, null);
1680
- });
1681
- _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1682
- _assertClassBrand(_Boundary_brand, this, _render).call(this);
1683
- });
1684
- };
1685
- /** @param {unknown} transformed_error */
1686
- const handle_error_result = (transformed_error) => {
1687
- try {
1688
- calling_on_error = true;
1689
- onerror?.(transformed_error, reset);
1690
- calling_on_error = false;
1691
- } catch (error) {
1692
- invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1132
+ return current_batch;
1133
+ }
1134
+ apply() {
1135
+ if (!async_mode_flag || !this.is_fork && _classPrivateFieldGet2(_prev, this) === null && _classPrivateFieldGet2(_next, this) === null) {
1136
+ batch_values = null;
1137
+ return;
1693
1138
  }
1694
- if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1695
- try {
1696
- return branch(() => {
1697
- var effect = active_effect;
1698
- effect.b = this;
1699
- effect.f |= 128;
1700
- failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
1701
- });
1702
- } catch (error) {
1703
- invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
1704
- return null;
1139
+ batch_values = /* @__PURE__ */ new Map();
1140
+ for (const [source, [value]] of this.current) batch_values.set(source, value);
1141
+ for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1142
+ if (batch === this || batch.is_fork) continue;
1143
+ var intersects = false;
1144
+ if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
1145
+ if (is_derived) continue;
1146
+ if (this.current.has(source)) {
1147
+ intersects = true;
1148
+ break;
1149
+ }
1705
1150
  }
1706
- }));
1707
- };
1708
- queue_micro_task(() => {
1709
- /** @type {unknown} */
1710
- var result;
1711
- try {
1712
- result = this.transform_error(error);
1713
- } catch (e) {
1714
- invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1151
+ if (!intersects) {
1152
+ for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
1153
+ }
1154
+ }
1155
+ }
1156
+ /**
1157
+ *
1158
+ * @param {Effect} effect
1159
+ */
1160
+ schedule(effect) {
1161
+ last_scheduled_effect = effect;
1162
+ if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
1163
+ effect.b.defer_effect(effect);
1715
1164
  return;
1716
1165
  }
1717
- if (result !== null && typeof result === "object" && typeof result.then === "function")
1718
- /** @type {any} */ result.then(
1719
- handle_error_result,
1720
- /** @param {unknown} e */
1721
- (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
1722
- );
1723
- else handle_error_result(result);
1724
- });
1166
+ var e = effect;
1167
+ while (e.parent !== null) {
1168
+ e = e.parent;
1169
+ var flags = e.f;
1170
+ if (collected_effects !== null && e === active_effect) {
1171
+ if (async_mode_flag) return;
1172
+ if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
1173
+ }
1174
+ if ((flags & 96) !== 0) {
1175
+ if ((flags & 1024) === 0) return;
1176
+ e.f ^= CLEAN;
1177
+ }
1178
+ }
1179
+ _classPrivateFieldGet2(_roots, this).push(e);
1180
+ }
1181
+ };
1182
+ _Batch = Batch;
1183
+ function _is_deferred() {
1184
+ if (this.is_fork) return true;
1185
+ for (const effect of _classPrivateFieldGet2(_blocking_pending, this).keys()) {
1186
+ var e = effect;
1187
+ var skipped = false;
1188
+ while (e.parent !== null) {
1189
+ if (_classPrivateFieldGet2(_skipped_branches, this).has(e)) {
1190
+ skipped = true;
1191
+ break;
1192
+ }
1193
+ e = e.parent;
1194
+ }
1195
+ if (!skipped) return true;
1196
+ }
1197
+ return false;
1725
1198
  }
1726
- //#endregion
1727
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/async.js
1728
- /** @import { Blocker, Effect, Source, Value } from '#client' */
1729
- /**
1730
- * @param {Blocker[]} blockers
1731
- * @param {Array<() => any>} sync
1732
- * @param {Array<() => Promise<any>>} async
1733
- * @param {(values: Value[]) => any} fn
1734
- */
1735
- function flatten(blockers, sync, async, fn) {
1736
- const d = is_runes() ? derived : derived_safe_equal;
1737
- var pending = blockers.filter((b) => !b.settled);
1738
- var deriveds = sync.map(d);
1739
- if (async.length === 0 && pending.length === 0) {
1740
- fn(deriveds);
1741
- return;
1199
+ function _process() {
1200
+ _classPrivateFieldSet2(_started, this, true);
1201
+ if (flush_count++ > 1e3) {
1202
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1203
+ infinite_loop_guard();
1742
1204
  }
1743
- var parent = active_effect;
1744
- var restore = capture();
1745
- var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b) => b.promise)) : null;
1205
+ for (const e of _classPrivateFieldGet2(_dirty_effects$1, this)) {
1206
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(e);
1207
+ set_signal_status(e, DIRTY);
1208
+ this.schedule(e);
1209
+ }
1210
+ for (const e of _classPrivateFieldGet2(_maybe_dirty_effects$1, this)) {
1211
+ set_signal_status(e, MAYBE_DIRTY);
1212
+ this.schedule(e);
1213
+ }
1214
+ const roots = _classPrivateFieldGet2(_roots, this);
1215
+ _classPrivateFieldSet2(_roots, this, []);
1216
+ this.apply();
1217
+ /** @type {Effect[]} */
1218
+ var effects = collected_effects = [];
1219
+ /** @type {Effect[]} */
1220
+ var render_effects = [];
1746
1221
  /**
1747
- * @param {Source[]} async
1222
+ * @type {Effect[]}
1223
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1748
1224
  */
1749
- function finish(async) {
1750
- if ((parent.f & 16384) !== 0) return;
1751
- restore();
1752
- try {
1753
- fn([...deriveds, ...async]);
1754
- } catch (error) {
1755
- invoke_error_boundary(error, parent);
1756
- }
1757
- unset_context();
1225
+ var updates = legacy_updates = [];
1226
+ for (const root of roots) try {
1227
+ _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
1228
+ } catch (e) {
1229
+ reset_all(root);
1230
+ if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
1231
+ throw e;
1232
+ }
1233
+ current_batch = null;
1234
+ if (updates.length > 0) {
1235
+ var batch = _Batch.ensure();
1236
+ for (const e of updates) batch.schedule(e);
1237
+ }
1238
+ collected_effects = null;
1239
+ legacy_updates = null;
1240
+ if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
1241
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
1242
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
1243
+ for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
1244
+ if (updates.length > 0)
1245
+ /** @type {Batch} */ _assertClassBrand(_Batch_brand, current_batch, _process).call(current_batch);
1246
+ return;
1758
1247
  }
1759
- var decrement_pending = increment_pending();
1760
- if (async.length === 0) {
1761
- /** @type {Promise<any>} */ blocker_promise.then(() => finish([])).finally(decrement_pending);
1248
+ const earlier_batch = _assertClassBrand(_Batch_brand, this, _find_earlier_batch).call(this);
1249
+ if (earlier_batch) {
1250
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
1251
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
1252
+ _assertClassBrand(_Batch_brand, earlier_batch, _merge).call(earlier_batch, this);
1762
1253
  return;
1763
1254
  }
1764
- function run() {
1765
- Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then(finish).catch((error) => invoke_error_boundary(error, parent)).finally(decrement_pending);
1255
+ _classPrivateFieldGet2(_dirty_effects$1, this).clear();
1256
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).clear();
1257
+ for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
1258
+ _classPrivateFieldGet2(_commit_callbacks, this).clear();
1259
+ previous_batch = this;
1260
+ flush_queued_effects(render_effects);
1261
+ flush_queued_effects(effects);
1262
+ previous_batch = null;
1263
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
1264
+ var next_batch = current_batch;
1265
+ if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_roots, this).length === 0 || next_batch !== null)) {
1266
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1267
+ if (async_mode_flag) {
1268
+ _assertClassBrand(_Batch_brand, this, _commit$1).call(this);
1269
+ current_batch = next_batch;
1270
+ }
1271
+ }
1272
+ if (_classPrivateFieldGet2(_roots, this).length > 0) if (next_batch !== null) {
1273
+ const batch = next_batch;
1274
+ _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
1275
+ } else next_batch = this;
1276
+ if (next_batch !== null) {
1277
+ old_values.clear();
1278
+ _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
1766
1279
  }
1767
- if (blocker_promise) blocker_promise.then(() => {
1768
- restore();
1769
- run();
1770
- unset_context();
1771
- });
1772
- else run();
1773
1280
  }
1774
1281
  /**
1775
- * Captures the current effect context so that we can restore it after
1776
- * some asynchronous work has happened (so that e.g. `await a + b`
1777
- * causes `b` to be registered as a dependency).
1282
+ * Traverse the effect tree, executing effects or stashing
1283
+ * them for later execution as appropriate
1284
+ * @param {Effect} root
1285
+ * @param {Effect[]} effects
1286
+ * @param {Effect[]} render_effects
1778
1287
  */
1779
- function capture() {
1780
- var previous_effect = active_effect;
1781
- var previous_reaction = active_reaction;
1782
- var previous_component_context = component_context;
1783
- var previous_batch = current_batch;
1784
- return function restore(activate_batch = true) {
1785
- set_active_effect(previous_effect);
1786
- set_active_reaction(previous_reaction);
1787
- set_component_context(previous_component_context);
1788
- if (activate_batch && (previous_effect.f & 16384) === 0) {
1789
- previous_batch?.activate();
1790
- previous_batch?.apply();
1288
+ function _traverse(root, effects, render_effects) {
1289
+ root.f ^= CLEAN;
1290
+ var effect = root.first;
1291
+ while (effect !== null) {
1292
+ var flags = effect.f;
1293
+ var is_branch = (flags & 96) !== 0;
1294
+ if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
1295
+ if (is_branch) effect.f ^= CLEAN;
1296
+ else if ((flags & 4) !== 0) effects.push(effect);
1297
+ else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
1298
+ else if (is_dirty(effect)) {
1299
+ if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(effect);
1300
+ update_effect(effect);
1301
+ }
1302
+ var child = effect.first;
1303
+ if (child !== null) {
1304
+ effect = child;
1305
+ continue;
1306
+ }
1791
1307
  }
1792
- };
1308
+ while (effect !== null) {
1309
+ var next = effect.next;
1310
+ if (next !== null) {
1311
+ effect = next;
1312
+ break;
1313
+ }
1314
+ effect = effect.parent;
1315
+ }
1316
+ }
1793
1317
  }
1794
- function unset_context(deactivate_batch = true) {
1795
- set_active_effect(null);
1796
- set_active_reaction(null);
1797
- set_component_context(null);
1798
- if (deactivate_batch) current_batch?.deactivate();
1318
+ function _find_earlier_batch() {
1319
+ var batch = _classPrivateFieldGet2(_prev, this);
1320
+ while (batch !== null) {
1321
+ if (!batch.is_fork) {
1322
+ for (const [value, [, is_derived]] of this.current) if (batch.current.has(value) && !is_derived) return batch;
1323
+ }
1324
+ batch = _classPrivateFieldGet2(_prev, batch);
1325
+ }
1326
+ return null;
1799
1327
  }
1800
1328
  /**
1801
- * @returns {(skip?: boolean) => void}
1329
+ * @param {Batch} batch
1802
1330
  */
1803
- function increment_pending() {
1804
- var effect = active_effect;
1805
- var boundary = effect.b;
1806
- var batch = current_batch;
1807
- var blocking = !!boundary?.is_rendered();
1808
- boundary?.update_pending_count(1, batch);
1809
- batch.increment(blocking, effect);
1810
- return () => {
1811
- boundary?.update_pending_count(-1, batch);
1812
- batch.decrement(blocking, effect);
1331
+ function _merge(batch) {
1332
+ for (const [source, value] of batch.current) {
1333
+ if (!this.previous.has(source) && batch.previous.has(source)) this.previous.set(source, batch.previous.get(source));
1334
+ this.current.set(source, value);
1335
+ }
1336
+ for (const [effect, deferred] of batch.async_deriveds) {
1337
+ const d = this.async_deriveds.get(effect);
1338
+ if (d) deferred.promise.then(d.resolve).catch(d.reject);
1339
+ }
1340
+ batch.async_deriveds.clear();
1341
+ this.transfer_effects(_classPrivateFieldGet2(_dirty_effects$1, batch), _classPrivateFieldGet2(_maybe_dirty_effects$1, batch));
1342
+ /**
1343
+ * mark all effects that depend on `batch.current`, except the
1344
+ * async effects that we just resolved (TODO unless they depend
1345
+ * on values in this batch that are NOT in the later batch?).
1346
+ * Through this we also will populate the correct #skipped_branches,
1347
+ * oncommit callbacks etc, so we don't need to merge them separately.
1348
+ * @param {Value} value
1349
+ */
1350
+ const mark = (value) => {
1351
+ var reactions = value.reactions;
1352
+ if (reactions === null) return;
1353
+ if ((value.f & 2) !== 0 && (value.f & 6144) === 0) return;
1354
+ for (const reaction of reactions) {
1355
+ var flags = reaction.f;
1356
+ if ((flags & 2) !== 0) mark(reaction);
1357
+ else {
1358
+ var effect = reaction;
1359
+ if (flags & 4194320 && !this.async_deriveds.has(effect)) {
1360
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(effect);
1361
+ set_signal_status(effect, DIRTY);
1362
+ this.schedule(effect);
1363
+ }
1364
+ }
1365
+ }
1813
1366
  };
1367
+ for (const source of this.current.keys()) mark(source);
1368
+ this.oncommit(() => batch.discard());
1369
+ _assertClassBrand(_Batch_brand, batch, _unlink).call(batch);
1370
+ current_batch = this;
1371
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
1814
1372
  }
1815
1373
  /**
1816
- * @template V
1817
- * @param {() => V} fn
1818
- * @returns {Derived<V>}
1374
+ * @param {Effect[]} effects
1819
1375
  */
1820
- /*#__NO_SIDE_EFFECTS__*/
1821
- function derived(fn) {
1822
- var flags = 2 | DIRTY;
1823
- if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
1824
- return {
1825
- ctx: component_context,
1826
- deps: null,
1827
- effects: null,
1828
- equals,
1829
- f: flags,
1830
- fn,
1831
- reactions: null,
1832
- rv: 0,
1833
- v: UNINITIALIZED,
1834
- wv: 0,
1835
- parent: active_effect,
1836
- ac: null
1837
- };
1376
+ function _defer_effects(effects) {
1377
+ for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
1838
1378
  }
1839
- var OBSOLETE = Symbol("obsolete");
1840
- /**
1841
- * @template V
1842
- * @param {() => V | Promise<V>} fn
1843
- * @param {string} [label]
1844
- * @param {string} [location] If provided, print a warning if the value is not read immediately after update
1845
- * @returns {Promise<Source<V>>}
1846
- */
1847
- /*#__NO_SIDE_EFFECTS__*/
1848
- function async_derived(fn, label, location) {
1849
- let parent = active_effect;
1850
- if (parent === null) async_derived_orphan();
1851
- var promise = void 0;
1852
- var signal = source(UNINITIALIZED);
1853
- var should_suspend = !active_reaction;
1854
- /** @type {Set<ReturnType<typeof deferred<V>>>} */
1855
- var deferreds = /* @__PURE__ */ new Set();
1856
- async_effect(() => {
1857
- var effect = active_effect;
1858
- /** @type {ReturnType<typeof deferred<V>>} */
1859
- var d = deferred();
1860
- promise = d.promise;
1861
- try {
1862
- Promise.resolve(fn()).then(d.resolve, (e) => {
1863
- if (e !== STALE_REACTION) d.reject(e);
1864
- }).finally(unset_context);
1865
- } catch (error) {
1866
- d.reject(error);
1867
- unset_context();
1379
+ function _commit$1() {
1380
+ for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1381
+ var is_earlier = batch.id < this.id;
1382
+ /** @type {Source[]} */
1383
+ var sources = [];
1384
+ for (const [source, [value, is_derived]] of this.current) {
1385
+ if (batch.current.has(source)) {
1386
+ var batch_value = batch.current.get(source)[0];
1387
+ if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
1388
+ else continue;
1389
+ }
1390
+ sources.push(source);
1868
1391
  }
1869
- var batch = current_batch;
1870
- if (should_suspend) {
1871
- if ((effect.f & 32768) !== 0) var decrement_pending = increment_pending();
1872
- if (parent.b?.is_rendered()) batch.async_deriveds.get(effect)?.reject(OBSOLETE);
1873
- else for (const d of deferreds.values()) d.reject(OBSOLETE);
1874
- deferreds.add(d);
1875
- batch.async_deriveds.set(effect, d);
1392
+ if (is_earlier) for (const [effect, deferred] of this.async_deriveds) {
1393
+ const d = batch.async_deriveds.get(effect);
1394
+ if (d) deferred.promise.then(d.resolve).catch(d.reject);
1876
1395
  }
1877
- /**
1878
- * @param {any} value
1879
- * @param {unknown} error
1880
- */
1881
- const handler = (value, error = void 0) => {
1882
- decrement_pending?.();
1883
- deferreds.delete(d);
1884
- if (error === OBSOLETE) return;
1396
+ var current = [...batch.current.keys()].filter((source) => !batch.current.get(source)[1]);
1397
+ if (!_classPrivateFieldGet2(_started, batch) || current.length === 0) continue;
1398
+ var others = current.filter((source) => !this.current.has(source));
1399
+ if (others.length === 0) {
1400
+ if (is_earlier) batch.discard();
1401
+ } else if (sources.length > 0) {
1402
+ if (is_earlier) for (const unskipped of _classPrivateFieldGet2(_unskipped_branches, this)) batch.unskip_effect(unskipped, (e) => {
1403
+ if ((e.f & 4194320) !== 0) batch.schedule(e);
1404
+ else _assertClassBrand(_Batch_brand, batch, _defer_effects).call(batch, [e]);
1405
+ });
1885
1406
  batch.activate();
1886
- if (error) {
1887
- signal.f |= ERROR_VALUE;
1888
- internal_set(signal, error);
1889
- } else {
1890
- if ((signal.f & 8388608) !== 0) signal.f ^= ERROR_VALUE;
1891
- internal_set(signal, value);
1407
+ /** @type {Set<Value>} */
1408
+ var marked = /* @__PURE__ */ new Set();
1409
+ /** @type {Map<Reaction, boolean>} */
1410
+ var checked = /* @__PURE__ */ new Map();
1411
+ for (var source of sources) mark_effects(source, others, marked, checked);
1412
+ checked = /* @__PURE__ */ new Map();
1413
+ var current_unequal = [...batch.current].filter(([c, v1]) => {
1414
+ const v2 = this.current.get(c);
1415
+ if (!v2) return true;
1416
+ return v2[0] !== v1[0] || v2[1] !== v1[1];
1417
+ }).map(([c]) => c);
1418
+ if (current_unequal.length > 0) {
1419
+ for (const effect of _classPrivateFieldGet2(_new_effects, this)) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1420
+ set_signal_status(effect, DIRTY);
1421
+ batch.schedule(effect);
1422
+ } else _classPrivateFieldGet2(_dirty_effects$1, batch).add(effect);
1892
1423
  }
1893
- batch.deactivate();
1894
- };
1895
- d.promise.then(handler, (e) => handler(null, e || "unknown"));
1896
- });
1897
- teardown(() => {
1898
- for (const d of deferreds) d.reject(OBSOLETE);
1899
- });
1900
- return new Promise((fulfil) => {
1901
- /** @param {Promise<V>} p */
1902
- function next(p) {
1903
- function go() {
1904
- if (p === promise) fulfil(signal);
1905
- else next(promise);
1424
+ if (_classPrivateFieldGet2(_roots, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1425
+ batch.apply();
1426
+ for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1427
+ _classPrivateFieldSet2(_roots, batch, []);
1906
1428
  }
1907
- p.then(go, go);
1429
+ batch.deactivate();
1908
1430
  }
1909
- next(promise);
1910
- });
1431
+ }
1911
1432
  }
1912
- /**
1913
- * @template V
1914
- * @param {() => V} fn
1915
- * @returns {Derived<V>}
1916
- */
1917
- /*#__NO_SIDE_EFFECTS__*/
1918
- function user_derived(fn) {
1919
- const d = /* @__PURE__ */ derived(fn);
1920
- if (!async_mode_flag) push_reaction_value(d);
1921
- return d;
1433
+ function _unlink() {
1434
+ if (!this.linked) return;
1435
+ var prev = _classPrivateFieldGet2(_prev, this);
1436
+ var next = _classPrivateFieldGet2(_next, this);
1437
+ if (prev === null) first_batch = next;
1438
+ else _classPrivateFieldSet2(_next, prev, next);
1439
+ if (next === null) last_batch = prev;
1440
+ else _classPrivateFieldSet2(_prev, next, prev);
1441
+ this.linked = false;
1922
1442
  }
1923
1443
  /**
1924
- * @template V
1925
- * @param {() => V} fn
1926
- * @returns {Derived<V>}
1444
+ * Synchronously flush any pending updates.
1445
+ * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1446
+ * @template [T=void]
1447
+ * @param {(() => T) | undefined} [fn]
1448
+ * @returns {T}
1927
1449
  */
1928
- /*#__NO_SIDE_EFFECTS__*/
1929
- function derived_safe_equal(fn) {
1930
- const signal = /* @__PURE__ */ derived(fn);
1931
- signal.equals = safe_equals;
1932
- return signal;
1450
+ function flushSync(fn) {
1451
+ var was_flushing_sync = is_flushing_sync;
1452
+ is_flushing_sync = true;
1453
+ try {
1454
+ var result;
1455
+ if (fn) {
1456
+ if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
1457
+ result = fn();
1458
+ }
1459
+ while (true) {
1460
+ flush_tasks();
1461
+ if (current_batch === null) return result;
1462
+ current_batch.flush();
1463
+ }
1464
+ } finally {
1465
+ is_flushing_sync = was_flushing_sync;
1466
+ }
1467
+ }
1468
+ function infinite_loop_guard() {
1469
+ try {
1470
+ effect_update_depth_exceeded();
1471
+ } catch (error) {
1472
+ invoke_error_boundary(error, last_scheduled_effect);
1473
+ }
1933
1474
  }
1475
+ /** @type {Set<Effect> | null} */
1476
+ var eager_block_effects = null;
1934
1477
  /**
1935
- * @param {Derived} derived
1478
+ * @param {Array<Effect>} effects
1936
1479
  * @returns {void}
1937
1480
  */
1938
- function destroy_derived_effects(derived) {
1939
- var effects = derived.effects;
1940
- if (effects !== null) {
1941
- derived.effects = null;
1942
- for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1481
+ function flush_queued_effects(effects) {
1482
+ var length = effects.length;
1483
+ if (length === 0) return;
1484
+ var i = 0;
1485
+ while (i < length) {
1486
+ var effect = effects[i++];
1487
+ if ((effect.f & 24576) === 0 && is_dirty(effect)) {
1488
+ eager_block_effects = /* @__PURE__ */ new Set();
1489
+ update_effect(effect);
1490
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
1491
+ if (eager_block_effects?.size > 0) {
1492
+ old_values.clear();
1493
+ for (const e of eager_block_effects) {
1494
+ if ((e.f & 24576) !== 0) continue;
1495
+ /** @type {Effect[]} */
1496
+ const ordered_effects = [e];
1497
+ let ancestor = e.parent;
1498
+ while (ancestor !== null) {
1499
+ if (eager_block_effects.has(ancestor)) {
1500
+ eager_block_effects.delete(ancestor);
1501
+ ordered_effects.push(ancestor);
1502
+ }
1503
+ ancestor = ancestor.parent;
1504
+ }
1505
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
1506
+ const e = ordered_effects[j];
1507
+ if ((e.f & 24576) !== 0) continue;
1508
+ update_effect(e);
1509
+ }
1510
+ }
1511
+ eager_block_effects.clear();
1512
+ }
1513
+ }
1943
1514
  }
1515
+ eager_block_effects = null;
1944
1516
  }
1945
1517
  /**
1946
- * @template T
1947
- * @param {Derived} derived
1948
- * @returns {T}
1518
+ * This is similar to `mark_reactions`, but it only marks async/block effects
1519
+ * depending on `value` and at least one of the other `sources`, so that
1520
+ * these effects can re-run after another batch has been committed
1521
+ * @param {Value} value
1522
+ * @param {Source[]} sources
1523
+ * @param {Set<Value>} marked
1524
+ * @param {Map<Reaction, boolean>} checked
1949
1525
  */
1950
- function execute_derived(derived) {
1951
- var value;
1952
- var prev_active_effect = active_effect;
1953
- var parent = derived.parent;
1954
- if (!is_destroying_effect && parent !== null && derived.v !== UNINITIALIZED && (parent.f & 24576) !== 0) {
1955
- derived_inert();
1956
- return derived.v;
1957
- }
1958
- set_active_effect(parent);
1959
- try {
1960
- derived.f &= ~WAS_MARKED;
1961
- destroy_derived_effects(derived);
1962
- value = update_reaction(derived);
1963
- } finally {
1964
- set_active_effect(prev_active_effect);
1526
+ function mark_effects(value, sources, marked, checked) {
1527
+ if (marked.has(value)) return;
1528
+ marked.add(value);
1529
+ if (value.reactions !== null) for (const reaction of value.reactions) {
1530
+ const flags = reaction.f;
1531
+ if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
1532
+ else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
1533
+ set_signal_status(reaction, DIRTY);
1534
+ schedule_effect(reaction);
1535
+ }
1965
1536
  }
1966
- return value;
1967
1537
  }
1968
1538
  /**
1969
- * @param {Derived} derived
1970
- * @returns {void}
1539
+ * @param {Reaction} reaction
1540
+ * @param {Source[]} sources
1541
+ * @param {Map<Reaction, boolean>} checked
1971
1542
  */
1972
- function update_derived(derived) {
1973
- var value = execute_derived(derived);
1974
- if (!derived.equals(value)) {
1975
- derived.wv = increment_write_version();
1976
- if (!current_batch?.is_fork || derived.deps === null) {
1977
- if (current_batch !== null) {
1978
- current_batch.capture(derived, value, true);
1979
- previous_batch?.capture(derived, value, true);
1980
- } else derived.v = value;
1981
- if (derived.deps === null) {
1982
- set_signal_status(derived, CLEAN);
1983
- return;
1984
- }
1543
+ function depends_on(reaction, sources, checked) {
1544
+ const depends = checked.get(reaction);
1545
+ if (depends !== void 0) return depends;
1546
+ if (reaction.deps !== null) for (const dep of reaction.deps) {
1547
+ if (includes.call(sources, dep)) return true;
1548
+ if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
1549
+ checked.set(dep, true);
1550
+ return true;
1985
1551
  }
1986
1552
  }
1987
- if (is_destroying_effect) return;
1988
- if (batch_values !== null) {
1989
- if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
1990
- } else update_derived_status(derived);
1553
+ checked.set(reaction, false);
1554
+ return false;
1991
1555
  }
1992
1556
  /**
1993
- * @param {Derived} derived
1557
+ * @param {Effect} effect
1558
+ * @returns {void}
1994
1559
  */
1995
- function freeze_derived_effects(derived) {
1996
- if (derived.effects === null) return;
1997
- for (const e of derived.effects) if (e.teardown || e.ac) {
1998
- e.teardown?.();
1999
- e.ac?.abort(STALE_REACTION);
2000
- if (e.fn !== null) e.teardown = noop;
2001
- e.ac = null;
2002
- remove_reactions(e, 0);
2003
- destroy_effect_children(e);
1560
+ function schedule_effect(effect) {
1561
+ /** @type {Batch} */ current_batch.schedule(effect);
1562
+ }
1563
+ /**
1564
+ * Mark all the effects inside a skipped branch CLEAN, so that
1565
+ * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1566
+ * effects so they can be rescheduled if the branch survives.
1567
+ * @param {Effect} effect
1568
+ * @param {{ d: Effect[], m: Effect[] }} tracked
1569
+ */
1570
+ function reset_branch(effect, tracked) {
1571
+ if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1572
+ if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1573
+ else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1574
+ set_signal_status(effect, CLEAN);
1575
+ var e = effect.first;
1576
+ while (e !== null) {
1577
+ reset_branch(e, tracked);
1578
+ e = e.next;
2004
1579
  }
2005
1580
  }
2006
1581
  /**
2007
- * @param {Derived} derived
1582
+ * Mark an entire effect tree clean following an error
1583
+ * @param {Effect} effect
2008
1584
  */
2009
- function unfreeze_derived_effects(derived) {
2010
- if (derived.effects === null) return;
2011
- for (const e of derived.effects) if (e.teardown && e.fn !== null) update_effect(e);
1585
+ function reset_all(effect) {
1586
+ set_signal_status(effect, CLEAN);
1587
+ var e = effect.first;
1588
+ while (e !== null) {
1589
+ reset_all(e);
1590
+ e = e.next;
1591
+ }
2012
1592
  }
2013
1593
  //#endregion
2014
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/sources.js
1594
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/sources.js
2015
1595
  /** @import { Derived, Effect, Source, Value } from '#client' */
2016
1596
  /** @type {Set<Effect>} */
2017
1597
  var eager_effects = /* @__PURE__ */ new Set();
@@ -2081,7 +1661,8 @@ function set(source, value, should_proxy = false) {
2081
1661
  */
2082
1662
  function internal_set(source, value, updated_during_traversal = null) {
2083
1663
  if (!source.equals(value)) {
2084
- old_values.set(source, is_destroying_effect ? value : source.v);
1664
+ if (is_destroying_effect) old_values.set(source, value);
1665
+ else if (!old_values.has(source)) old_values.set(source, source.v);
2085
1666
  var batch = Batch.ensure();
2086
1667
  batch.capture(source, value);
2087
1668
  if ((source.f & 2) !== 0) {
@@ -2157,7 +1738,7 @@ function mark_reactions(signal, status, updated_during_traversal) {
2157
1738
  * @returns {T}
2158
1739
  */
2159
1740
  function proxy(value) {
2160
- if (typeof value !== "object" || value === null || STATE_SYMBOL in value) return value;
1741
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value || COMPONENT_SYMBOL in value) return value;
2161
1742
  const prototype = get_prototype_of(value);
2162
1743
  if (prototype !== object_prototype && prototype !== array_prototype) return value;
2163
1744
  /** @type {Map<any, Source<any>>} */
@@ -2309,19 +1890,8 @@ function proxy(value) {
2309
1890
  }
2310
1891
  });
2311
1892
  }
2312
- new Set([
2313
- "copyWithin",
2314
- "fill",
2315
- "pop",
2316
- "push",
2317
- "reverse",
2318
- "shift",
2319
- "sort",
2320
- "splice",
2321
- "unshift"
2322
- ]);
2323
1893
  //#endregion
2324
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/operations.js
1894
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/operations.js
2325
1895
  /** @import { Effect, TemplateNode } from '#client' */
2326
1896
  /** @type {Window} */
2327
1897
  var $window;
@@ -2421,6 +1991,21 @@ function first_child(node, is_text = false) {
2421
1991
  return hydrate_node;
2422
1992
  }
2423
1993
  /**
1994
+ * `child`, for the very common case of an element with exactly one child. Resetting the
1995
+ * hydration cursor is part of the same step, so the compiler doesn't have to emit a
1996
+ * separate `reset` call for every `<p>{text}</p>` in an app.
1997
+ * Don't mark this as side-effect-free, hydration needs to walk all nodes
1998
+ * @param {TemplateNode} node
1999
+ * @param {boolean} [is_text]
2000
+ * @returns {TemplateNode | null}
2001
+ */
2002
+ function only_child(node, is_text = false) {
2003
+ if (!hydrating) return /* @__PURE__ */ get_first_child(node);
2004
+ var first = child(node, is_text);
2005
+ reset(node);
2006
+ return first;
2007
+ }
2008
+ /**
2424
2009
  * Don't mark this as side-effect-free, hydration needs to walk all nodes
2425
2010
  * @param {TemplateNode} node
2426
2011
  * @param {number} count
@@ -2498,26 +2083,40 @@ function merge_text_nodes(text) {
2498
2083
  next = text.nextSibling;
2499
2084
  }
2500
2085
  }
2501
- //#endregion
2502
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
2503
2086
  /**
2504
- * @template T
2505
- * @param {() => T} fn
2087
+ * @param {unknown} error
2088
+ */
2089
+ function handle_error(error) {
2090
+ var effect = active_effect;
2091
+ if (effect === null) {
2092
+ /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
2093
+ return error;
2094
+ }
2095
+ if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
2096
+ invoke_error_boundary(error, effect);
2097
+ }
2098
+ /**
2099
+ * @param {unknown} error
2100
+ * @param {Effect | null} effect
2506
2101
  */
2507
- function without_reactive_context(fn) {
2508
- var previous_reaction = active_reaction;
2509
- var previous_effect = active_effect;
2510
- set_active_reaction(null);
2511
- set_active_effect(null);
2512
- try {
2513
- return fn();
2514
- } finally {
2515
- set_active_reaction(previous_reaction);
2516
- set_active_effect(previous_effect);
2102
+ function invoke_error_boundary(error, effect) {
2103
+ if (effect !== null && (effect.f & 16384) !== 0) return;
2104
+ while (effect !== null) {
2105
+ if ((effect.f & 128) !== 0 && (effect.f & 33570816) === 0) {
2106
+ if ((effect.f & 32768) === 0) throw error;
2107
+ try {
2108
+ /** @type {Boundary} */ effect.b.error(error);
2109
+ return;
2110
+ } catch (e) {
2111
+ error = e;
2112
+ }
2113
+ }
2114
+ effect = effect.parent;
2517
2115
  }
2116
+ throw error;
2518
2117
  }
2519
2118
  //#endregion
2520
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/reactivity/effects.js
2119
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/effects.js
2521
2120
  /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
2522
2121
  /**
2523
2122
  * @param {'$effect' | '$effect.pre' | '$inspect'} rune
@@ -2720,6 +2319,8 @@ function execute_effect_teardown(effect) {
2720
2319
  set_active_reaction(null);
2721
2320
  try {
2722
2321
  teardown.call(null);
2322
+ } catch (error) {
2323
+ invoke_error_boundary(error, effect.parent);
2723
2324
  } finally {
2724
2325
  set_is_destroying_effect(previously_destroying_effect);
2725
2326
  set_active_reaction(previous_reaction);
@@ -2822,6 +2423,7 @@ function unlink_effect(effect) {
2822
2423
  function pause_effect(effect, callback, destroy = true) {
2823
2424
  /** @type {TransitionManager[]} */
2824
2425
  var transitions = [];
2426
+ effect.f |= 256;
2825
2427
  pause_children(effect, transitions, true);
2826
2428
  var fn = () => {
2827
2429
  if (destroy) destroy_effect(effect);
@@ -2861,6 +2463,7 @@ function pause_children(effect, transitions, local) {
2861
2463
  * @param {Effect} effect
2862
2464
  */
2863
2465
  function resume_effect(effect) {
2466
+ effect.f &= -257;
2864
2467
  resume_children(effect, true);
2865
2468
  }
2866
2469
  /**
@@ -2868,6 +2471,7 @@ function resume_effect(effect) {
2868
2471
  * @param {boolean} local
2869
2472
  */
2870
2473
  function resume_children(effect, local) {
2474
+ if ((effect.f & 256) !== 0) return;
2871
2475
  if ((effect.f & 8192) === 0) return;
2872
2476
  effect.f ^= INERT;
2873
2477
  if ((effect.f & 1024) === 0) {
@@ -2903,15 +2507,18 @@ function move_effect(effect, fragment) {
2903
2507
  }
2904
2508
  }
2905
2509
  //#endregion
2906
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/legacy.js
2510
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/legacy.js
2907
2511
  /**
2908
2512
  * @type {Set<Value> | null}
2909
2513
  * @deprecated
2910
2514
  */
2911
2515
  var captured_signals = null;
2912
2516
  //#endregion
2913
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/runtime.js
2517
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/runtime.js
2914
2518
  /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
2519
+ /**
2520
+ * True if updating in an effect context that is reactive (i.e. not branch/root effects)
2521
+ */
2915
2522
  var is_updating_effect = false;
2916
2523
  var is_destroying_effect = false;
2917
2524
  /** @param {boolean} value */
@@ -2964,7 +2571,7 @@ function set_untracked_writes(value) {
2964
2571
  * Version starts from 1 so that unowned deriveds differentiate between a created effect and a run one for tracing
2965
2572
  **/
2966
2573
  var write_version = 1;
2967
- /** @type {number} Used to version each read of a source of derived to avoid duplicating depedencies inside a reaction */
2574
+ /** @type {number} Used to version each read of a source of derived to avoid duplicating dependencies inside a reaction */
2968
2575
  var read_version = 0;
2969
2576
  var update_version = read_version;
2970
2577
  /** @param {number} value */
@@ -3045,24 +2652,8 @@ function update_reaction(reaction) {
3045
2652
  var fn = reaction.fn;
3046
2653
  var result = fn();
3047
2654
  reaction.f |= REACTION_RAN;
3048
- var deps = reaction.deps;
3049
- var is_fork = current_batch?.is_fork;
3050
- if (new_deps !== null) {
3051
- var i;
3052
- if (!is_fork) remove_reactions(reaction, skipped_deps);
3053
- if (deps !== null && skipped_deps > 0) {
3054
- deps.length = skipped_deps + new_deps.length;
3055
- for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
3056
- } else reaction.deps = deps = new_deps;
3057
- if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) {
3058
- var _deps$i;
3059
- ((_deps$i = deps[i]).reactions ?? (_deps$i.reactions = [])).push(reaction);
3060
- }
3061
- } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
3062
- remove_reactions(reaction, skipped_deps);
3063
- deps.length = skipped_deps;
3064
- }
3065
- 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);
2655
+ var deps = update_dependencies(reaction);
2656
+ 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);
3066
2657
  if (previous_reaction !== null && previous_reaction !== reaction) {
3067
2658
  read_version++;
3068
2659
  if (previous_reaction.deps !== null) for (let i = 0; i < previous_skipped_deps; i += 1) previous_reaction.deps[i].rv = read_version;
@@ -3073,6 +2664,7 @@ function update_reaction(reaction) {
3073
2664
  if ((reaction.f & 8388608) !== 0) reaction.f ^= ERROR_VALUE;
3074
2665
  return result;
3075
2666
  } catch (error) {
2667
+ update_dependencies(reaction);
3076
2668
  return handle_error(error);
3077
2669
  } finally {
3078
2670
  reaction.f ^= REACTION_IS_UPDATING;
@@ -3087,6 +2679,29 @@ function update_reaction(reaction) {
3087
2679
  }
3088
2680
  }
3089
2681
  /**
2682
+ * @param {Reaction} reaction
2683
+ */
2684
+ function update_dependencies(reaction) {
2685
+ var deps = reaction.deps;
2686
+ var is_fork = current_batch?.is_fork;
2687
+ if (new_deps !== null) {
2688
+ var i;
2689
+ if (!is_fork) remove_reactions(reaction, skipped_deps);
2690
+ if (deps !== null && skipped_deps > 0) {
2691
+ deps.length = skipped_deps + new_deps.length;
2692
+ for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
2693
+ } else reaction.deps = deps = new_deps;
2694
+ if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) {
2695
+ var _deps$i;
2696
+ ((_deps$i = deps[i]).reactions ?? (_deps$i.reactions = [])).push(reaction);
2697
+ }
2698
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2699
+ remove_reactions(reaction, skipped_deps);
2700
+ deps.length = skipped_deps;
2701
+ }
2702
+ return deps;
2703
+ }
2704
+ /**
3090
2705
  * @template V
3091
2706
  * @param {Reaction} signal
3092
2707
  * @param {Value<V>} dependency
@@ -3112,6 +2727,11 @@ function remove_reaction(signal, dependency) {
3112
2727
  derived.f &= ~WAS_MARKED;
3113
2728
  }
3114
2729
  if (derived.v !== UNINITIALIZED) update_derived_status(derived);
2730
+ if (derived.ac !== null) without_reactive_context(() => {
2731
+ /** @type {AbortController} */ derived.ac.abort(STALE_REACTION);
2732
+ derived.ac = null;
2733
+ set_signal_status(derived, DIRTY);
2734
+ });
3115
2735
  freeze_derived_effects(derived);
3116
2736
  remove_reactions(derived, 0);
3117
2737
  }
@@ -3137,7 +2757,7 @@ function update_effect(effect) {
3137
2757
  var previous_effect = active_effect;
3138
2758
  var was_updating_effect = is_updating_effect;
3139
2759
  active_effect = effect;
3140
- is_updating_effect = true;
2760
+ is_updating_effect = (flags & 96) === 0;
3141
2761
  try {
3142
2762
  if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
3143
2763
  else destroy_effect_children(effect);
@@ -3266,7 +2886,7 @@ function untrack(fn) {
3266
2886
  }
3267
2887
  }
3268
2888
  //#endregion
3269
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/events.js
2889
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/events.js
3270
2890
  /**
3271
2891
  * Used on elements, as a map of event type -> event handler,
3272
2892
  * and on events themselves to track which element handled an event
@@ -3334,6 +2954,7 @@ function delegate(events) {
3334
2954
  for (var fn of root_event_handles) fn(events);
3335
2955
  }
3336
2956
  var last_propagated_event = null;
2957
+ var last_propagated_event_clear_scheduled = false;
3337
2958
  /**
3338
2959
  * @this {EventTarget}
3339
2960
  * @param {Event} event
@@ -3346,6 +2967,13 @@ function handle_event_propagation(event) {
3346
2967
  var path = event.composedPath?.() || [];
3347
2968
  var current_target = path[0] || event.target;
3348
2969
  last_propagated_event = event;
2970
+ if (!last_propagated_event_clear_scheduled) {
2971
+ last_propagated_event_clear_scheduled = true;
2972
+ setTimeout(() => {
2973
+ last_propagated_event_clear_scheduled = false;
2974
+ last_propagated_event = null;
2975
+ });
2976
+ }
3349
2977
  var path_idx = 0;
3350
2978
  var handled_at = last_propagated_event === event && event[event_symbol];
3351
2979
  if (handled_at) {
@@ -3396,178 +3024,634 @@ function handle_event_propagation(event) {
3396
3024
  for (let error of other_errors) queueMicrotask(() => {
3397
3025
  throw error;
3398
3026
  });
3399
- throw throw_error;
3027
+ throw throw_error;
3028
+ }
3029
+ } finally {
3030
+ event[event_symbol] = handler_element;
3031
+ delete event.currentTarget;
3032
+ set_active_reaction(previous_reaction);
3033
+ set_active_effect(previous_effect);
3034
+ }
3035
+ }
3036
+ //#endregion
3037
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/reconciler.js
3038
+ var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
3039
+ /** @param {string} html */
3040
+ createHTML: (html) => {
3041
+ return html;
3042
+ } });
3043
+ /** @param {string} html */
3044
+ function create_trusted_html(html) {
3045
+ return policy?.createHTML(html) ?? html;
3046
+ }
3047
+ /**
3048
+ * @param {string} html
3049
+ */
3050
+ function create_fragment_from_html(html) {
3051
+ var elem = create_element("template");
3052
+ elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
3053
+ return elem.content;
3054
+ }
3055
+ //#endregion
3056
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/template.js
3057
+ /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
3058
+ /** @import { TemplateStructure } from './types' */
3059
+ /**
3060
+ * @param {TemplateNode} start
3061
+ * @param {TemplateNode | null} end
3062
+ */
3063
+ function assign_nodes(start, end) {
3064
+ var effect = active_effect;
3065
+ if (effect.nodes === null) effect.nodes = {
3066
+ start,
3067
+ end,
3068
+ a: null,
3069
+ t: null
3070
+ };
3071
+ }
3072
+ /**
3073
+ * @param {string} content
3074
+ * @param {number} flags
3075
+ * @returns {() => Node | Node[]}
3076
+ */
3077
+ /*#__NO_SIDE_EFFECTS__*/
3078
+ function from_html(content, flags) {
3079
+ var is_fragment = (flags & 1) !== 0;
3080
+ var use_import_node = (flags & 2) !== 0;
3081
+ /** @type {Node} */
3082
+ var node;
3083
+ /**
3084
+ * Whether or not the first item is a text/element node. If not, we need to
3085
+ * create an additional comment node to act as `effect.nodes.start`
3086
+ */
3087
+ var has_start = !content.startsWith("<!>");
3088
+ return () => {
3089
+ if (hydrating) {
3090
+ assign_nodes(hydrate_node, null);
3091
+ return hydrate_node;
3092
+ }
3093
+ if (node === void 0) {
3094
+ node = create_fragment_from_html(has_start ? content : "<!>" + content);
3095
+ if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
3096
+ }
3097
+ var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
3098
+ if (is_fragment) {
3099
+ var start = /* @__PURE__ */ get_first_child(clone);
3100
+ var end = clone.lastChild;
3101
+ assign_nodes(start, end);
3102
+ } else assign_nodes(clone, clone);
3103
+ return clone;
3104
+ };
3105
+ }
3106
+ /**
3107
+ * @param {string} content
3108
+ * @param {number} flags
3109
+ * @param {'svg' | 'math'} ns
3110
+ * @returns {() => Node | Node[]}
3111
+ */
3112
+ /*#__NO_SIDE_EFFECTS__*/
3113
+ function from_namespace(content, flags, ns = "svg") {
3114
+ /**
3115
+ * Whether or not the first item is a text/element node. If not, we need to
3116
+ * create an additional comment node to act as `effect.nodes.start`
3117
+ */
3118
+ var has_start = !content.startsWith("<!>");
3119
+ var is_fragment = (flags & 1) !== 0;
3120
+ var wrapped = `<${ns}>${has_start ? content : "<!>" + content}</${ns}>`;
3121
+ /** @type {Element | DocumentFragment} */
3122
+ var node;
3123
+ return () => {
3124
+ if (hydrating) {
3125
+ assign_nodes(hydrate_node, null);
3126
+ return hydrate_node;
3127
+ }
3128
+ if (!node) {
3129
+ var root = /* @__PURE__ */ get_first_child(create_fragment_from_html(wrapped));
3130
+ if (is_fragment) {
3131
+ node = document.createDocumentFragment();
3132
+ while (/* @__PURE__ */ get_first_child(root)) node.appendChild(/* @__PURE__ */ get_first_child(root));
3133
+ } else node = /* @__PURE__ */ get_first_child(root);
3134
+ }
3135
+ var clone = node.cloneNode(true);
3136
+ if (is_fragment) {
3137
+ var start = /* @__PURE__ */ get_first_child(clone);
3138
+ var end = clone.lastChild;
3139
+ assign_nodes(start, end);
3140
+ } else assign_nodes(clone, clone);
3141
+ return clone;
3142
+ };
3143
+ }
3144
+ /**
3145
+ * @param {string} content
3146
+ * @param {number} flags
3147
+ */
3148
+ /*#__NO_SIDE_EFFECTS__*/
3149
+ function from_svg(content, flags) {
3150
+ return /* @__PURE__ */ from_namespace(content, flags, "svg");
3151
+ }
3152
+ /**
3153
+ * @returns {TemplateNode | DocumentFragment}
3154
+ */
3155
+ function comment() {
3156
+ if (hydrating) {
3157
+ assign_nodes(hydrate_node, null);
3158
+ return hydrate_node;
3159
+ }
3160
+ var frag = document.createDocumentFragment();
3161
+ var start = document.createComment("");
3162
+ var anchor = create_text();
3163
+ frag.append(start, anchor);
3164
+ assign_nodes(start, anchor);
3165
+ return frag;
3166
+ }
3167
+ /**
3168
+ * Assign the created (or in hydration mode, traversed) dom elements to the current block
3169
+ * and insert the elements into the dom (in client mode).
3170
+ * @param {Text | Comment | Element} anchor
3171
+ * @param {DocumentFragment | Element} dom
3172
+ */
3173
+ function append(anchor, dom) {
3174
+ if (hydrating) {
3175
+ var effect = active_effect;
3176
+ if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
3177
+ hydrate_next();
3178
+ return;
3179
+ }
3180
+ if (anchor === null) return;
3181
+ anchor.before(dom);
3182
+ }
3183
+ /**
3184
+ * Subset of delegated events which should be passive by default.
3185
+ * These two are already passive via browser defaults on window, document and body.
3186
+ * But since
3187
+ * - we're delegating them
3188
+ * - they happen often
3189
+ * - they apply to mobile which is generally less performant
3190
+ * we're marking them as passive by default for other elements, too.
3191
+ */
3192
+ var PASSIVE_EVENTS = ["touchstart", "touchmove"];
3193
+ /**
3194
+ * Returns `true` if `name` is a passive event
3195
+ * @param {string} name
3196
+ */
3197
+ function is_passive_event(name) {
3198
+ return PASSIVE_EVENTS.includes(name);
3199
+ }
3200
+ //#endregion
3201
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/reactivity/create-subscriber.js
3202
+ /**
3203
+ * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
3204
+ * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
3205
+ *
3206
+ * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
3207
+ * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
3208
+ *
3209
+ * If `start` returns a cleanup function, it will be called when the effect is destroyed.
3210
+ *
3211
+ * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
3212
+ * are active, and the returned teardown function will only be called when all effects are destroyed.
3213
+ *
3214
+ * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
3215
+ *
3216
+ * ```js
3217
+ * import { createSubscriber } from 'svelte/reactivity';
3218
+ * import { on } from 'svelte/events';
3219
+ *
3220
+ * export class MediaQuery {
3221
+ * #query;
3222
+ * #subscribe;
3223
+ *
3224
+ * constructor(query) {
3225
+ * this.#query = window.matchMedia(`(${query})`);
3226
+ *
3227
+ * this.#subscribe = createSubscriber((update) => {
3228
+ * // when the `change` event occurs, re-run any effects that read `this.current`
3229
+ * const off = on(this.#query, 'change', update);
3230
+ *
3231
+ * // stop listening when all the effects are destroyed
3232
+ * return () => off();
3233
+ * });
3234
+ * }
3235
+ *
3236
+ * get current() {
3237
+ * // This makes the getter reactive, if read in an effect
3238
+ * this.#subscribe();
3239
+ *
3240
+ * // Return the current state of the query, whether or not we're in an effect
3241
+ * return this.#query.matches;
3242
+ * }
3243
+ * }
3244
+ * ```
3245
+ * @param {(update: () => void) => (() => void) | void} start
3246
+ * @since 5.7.0
3247
+ */
3248
+ function createSubscriber(start) {
3249
+ let subscribers = 0;
3250
+ let version = source(0);
3251
+ /** @type {(() => void) | void} */
3252
+ let stop;
3253
+ return () => {
3254
+ if (effect_tracking()) {
3255
+ get(version);
3256
+ render_effect(() => {
3257
+ if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
3258
+ subscribers += 1;
3259
+ return () => {
3260
+ queue_micro_task(() => {
3261
+ subscribers -= 1;
3262
+ if (subscribers === 0) {
3263
+ stop?.();
3264
+ stop = void 0;
3265
+ increment(version);
3266
+ }
3267
+ });
3268
+ };
3269
+ });
3400
3270
  }
3401
- } finally {
3402
- event[event_symbol] = handler_element;
3403
- delete event.currentTarget;
3404
- set_active_reaction(previous_reaction);
3405
- set_active_effect(previous_effect);
3406
- }
3271
+ };
3407
3272
  }
3408
3273
  //#endregion
3409
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/reconciler.js
3410
- var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
3411
- /** @param {string} html */
3412
- createHTML: (html) => {
3413
- return html;
3414
- } });
3415
- /** @param {string} html */
3416
- function create_trusted_html(html) {
3417
- return policy?.createHTML(html) ?? html;
3418
- }
3274
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
3275
+ /** @import { Effect, Source, TemplateNode, } from '#client' */
3419
3276
  /**
3420
- * @param {string} html
3277
+ * @typedef {{
3278
+ * onerror?: ((error: unknown, reset: () => void) => void) | null;
3279
+ * failed?: ((anchor: Node, error: () => unknown, reset: () => () => void) => void) | null;
3280
+ * pending?: ((anchor: Node) => void) | null;
3281
+ * }} BoundaryProps
3421
3282
  */
3422
- function create_fragment_from_html(html) {
3423
- var elem = create_element("template");
3424
- elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
3425
- return elem.content;
3426
- }
3427
- //#endregion
3428
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/template.js
3429
- /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
3430
- /** @import { TemplateStructure } from './types' */
3283
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
3431
3284
  /**
3432
- * @param {TemplateNode} start
3433
- * @param {TemplateNode | null} end
3285
+ * @param {TemplateNode} node
3286
+ * @param {BoundaryProps} props
3287
+ * @param {((anchor: Node) => void)} children
3288
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
3289
+ * @returns {void}
3434
3290
  */
3435
- function assign_nodes(start, end) {
3436
- var effect = active_effect;
3437
- if (effect.nodes === null) effect.nodes = {
3438
- start,
3439
- end,
3440
- a: null,
3441
- t: null
3442
- };
3291
+ function boundary(node, props, children, transform_error) {
3292
+ new Boundary(node, props, children, transform_error);
3443
3293
  }
3444
- /**
3445
- * @param {string} content
3446
- * @param {number} flags
3447
- * @returns {() => Node | Node[]}
3448
- */
3449
- /*#__NO_SIDE_EFFECTS__*/
3450
- function from_html(content, flags) {
3451
- var is_fragment = (flags & 1) !== 0;
3452
- var use_import_node = (flags & 2) !== 0;
3453
- /** @type {Node} */
3454
- var node;
3294
+ var _anchor = /* @__PURE__ */ new WeakMap();
3295
+ var _hydrate_open = /* @__PURE__ */ new WeakMap();
3296
+ var _props = /* @__PURE__ */ new WeakMap();
3297
+ var _children = /* @__PURE__ */ new WeakMap();
3298
+ var _effect = /* @__PURE__ */ new WeakMap();
3299
+ var _main_effect = /* @__PURE__ */ new WeakMap();
3300
+ var _pending_effect = /* @__PURE__ */ new WeakMap();
3301
+ var _failed_effect = /* @__PURE__ */ new WeakMap();
3302
+ var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
3303
+ var _local_pending_count = /* @__PURE__ */ new WeakMap();
3304
+ var _pending_count = /* @__PURE__ */ new WeakMap();
3305
+ var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
3306
+ var _dirty_effects = /* @__PURE__ */ new WeakMap();
3307
+ var _maybe_dirty_effects = /* @__PURE__ */ new WeakMap();
3308
+ var _effect_pending = /* @__PURE__ */ new WeakMap();
3309
+ var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
3310
+ var _Boundary_brand = /* @__PURE__ */ new WeakSet();
3311
+ var Boundary = class {
3455
3312
  /**
3456
- * Whether or not the first item is a text/element node. If not, we need to
3457
- * create an additional comment node to act as `effect.nodes.start`
3313
+ * @param {TemplateNode} node
3314
+ * @param {BoundaryProps} props
3315
+ * @param {((anchor: Node) => void)} children
3316
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
3458
3317
  */
3459
- var has_start = !content.startsWith("<!>");
3460
- return () => {
3461
- if (hydrating) {
3462
- assign_nodes(hydrate_node, null);
3463
- return hydrate_node;
3464
- }
3465
- if (node === void 0) {
3466
- node = create_fragment_from_html(has_start ? content : "<!>" + content);
3467
- if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
3468
- }
3469
- var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
3470
- if (is_fragment) {
3471
- var start = /* @__PURE__ */ get_first_child(clone);
3472
- var end = clone.lastChild;
3473
- assign_nodes(start, end);
3474
- } else assign_nodes(clone, clone);
3475
- return clone;
3476
- };
3318
+ constructor(node, props, children, transform_error) {
3319
+ _classPrivateMethodInitSpec(this, _Boundary_brand);
3320
+ _defineProperty(
3321
+ this,
3322
+ /** @type {Boundary | null} */
3323
+ "parent",
3324
+ void 0
3325
+ );
3326
+ _defineProperty(this, "is_pending", false);
3327
+ _defineProperty(
3328
+ this,
3329
+ /**
3330
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
3331
+ * Inherited from parent boundary, or defaults to identity.
3332
+ * @type {(error: unknown) => unknown}
3333
+ */
3334
+ "transform_error",
3335
+ void 0
3336
+ );
3337
+ _classPrivateFieldInitSpec(this, _anchor, void 0);
3338
+ _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
3339
+ _classPrivateFieldInitSpec(this, _props, void 0);
3340
+ _classPrivateFieldInitSpec(this, _children, void 0);
3341
+ _classPrivateFieldInitSpec(this, _effect, void 0);
3342
+ _classPrivateFieldInitSpec(this, _main_effect, null);
3343
+ _classPrivateFieldInitSpec(this, _pending_effect, null);
3344
+ _classPrivateFieldInitSpec(this, _failed_effect, null);
3345
+ _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
3346
+ _classPrivateFieldInitSpec(this, _local_pending_count, 0);
3347
+ _classPrivateFieldInitSpec(this, _pending_count, 0);
3348
+ _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
3349
+ _classPrivateFieldInitSpec(this, _dirty_effects, /* @__PURE__ */ new Set());
3350
+ _classPrivateFieldInitSpec(this, _maybe_dirty_effects, /* @__PURE__ */ new Set());
3351
+ _classPrivateFieldInitSpec(this, _effect_pending, null);
3352
+ _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
3353
+ _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
3354
+ return () => {
3355
+ _classPrivateFieldSet2(_effect_pending, this, null);
3356
+ };
3357
+ }));
3358
+ _classPrivateFieldSet2(_anchor, this, node);
3359
+ _classPrivateFieldSet2(_props, this, props);
3360
+ _classPrivateFieldSet2(_children, this, (anchor) => {
3361
+ var effect = active_effect;
3362
+ effect.b = this;
3363
+ effect.f |= 128;
3364
+ children(anchor);
3365
+ });
3366
+ this.parent = active_effect.b;
3367
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
3368
+ _classPrivateFieldSet2(_effect, this, block(() => {
3369
+ if (hydrating) {
3370
+ const comment = _classPrivateFieldGet2(_hydrate_open, this);
3371
+ hydrate_next();
3372
+ const server_rendered_pending = comment.data === "[!";
3373
+ if (comment.data.startsWith("[?")) {
3374
+ const serialized_error = JSON.parse(comment.data.slice(2));
3375
+ _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
3376
+ } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
3377
+ else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
3378
+ } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
3379
+ }, flags));
3380
+ if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
3381
+ }
3382
+ /**
3383
+ * Defer an effect inside a pending boundary until the boundary resolves
3384
+ * @param {Effect} effect
3385
+ */
3386
+ defer_effect(effect) {
3387
+ defer_effect(effect, _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
3388
+ }
3389
+ /**
3390
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
3391
+ * @returns {boolean}
3392
+ */
3393
+ is_rendered() {
3394
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
3395
+ }
3396
+ has_pending_snippet() {
3397
+ return !!_classPrivateFieldGet2(_props, this).pending;
3398
+ }
3399
+ /**
3400
+ * Update the source that powers `$effect.pending()` inside this boundary,
3401
+ * and controls when the current `pending` snippet (if any) is removed.
3402
+ * Do not call from inside the class
3403
+ * @param {1 | -1} d
3404
+ * @param {Batch} batch
3405
+ */
3406
+ update_pending_count(d, batch) {
3407
+ _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
3408
+ _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
3409
+ if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
3410
+ _classPrivateFieldSet2(_pending_count_update_queued, this, true);
3411
+ queue_micro_task(() => {
3412
+ _classPrivateFieldSet2(_pending_count_update_queued, this, false);
3413
+ if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
3414
+ });
3415
+ }
3416
+ get_effect_pending() {
3417
+ _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
3418
+ return get(_classPrivateFieldGet2(_effect_pending, this));
3419
+ }
3420
+ /** @param {unknown} error */
3421
+ error(error) {
3422
+ if (!_classPrivateFieldGet2(_props, this).onerror && !_classPrivateFieldGet2(_props, this).failed) throw error;
3423
+ if (current_batch?.is_fork) {
3424
+ if (_classPrivateFieldGet2(_main_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_main_effect, this));
3425
+ if (_classPrivateFieldGet2(_pending_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_pending_effect, this));
3426
+ if (_classPrivateFieldGet2(_failed_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_failed_effect, this));
3427
+ current_batch.oncommit(() => {
3428
+ _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
3429
+ });
3430
+ } else _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
3431
+ }
3432
+ };
3433
+ function _hydrate_resolved_content() {
3434
+ try {
3435
+ _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
3436
+ } catch (error) {
3437
+ this.error(error);
3438
+ }
3477
3439
  }
3478
3440
  /**
3479
- * @param {string} content
3480
- * @param {number} flags
3481
- * @param {'svg' | 'math'} ns
3482
- * @returns {() => Node | Node[]}
3441
+ * @param {unknown} error The deserialized error from the server's hydration comment
3483
3442
  */
3484
- /*#__NO_SIDE_EFFECTS__*/
3485
- function from_namespace(content, flags, ns = "svg") {
3486
- /**
3487
- * Whether or not the first item is a text/element node. If not, we need to
3488
- * create an additional comment node to act as `effect.nodes.start`
3489
- */
3490
- var has_start = !content.startsWith("<!>");
3491
- var is_fragment = (flags & 1) !== 0;
3492
- var wrapped = `<${ns}>${has_start ? content : "<!>" + content}</${ns}>`;
3493
- /** @type {Element | DocumentFragment} */
3494
- var node;
3495
- return () => {
3496
- if (hydrating) {
3497
- assign_nodes(hydrate_node, null);
3498
- return hydrate_node;
3443
+ function _hydrate_failed_content(error) {
3444
+ const failed = _classPrivateFieldGet2(_props, this).failed;
3445
+ const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, error);
3446
+ queue_micro_task(invoke_onerror);
3447
+ if (!failed) return;
3448
+ _classPrivateFieldSet2(_failed_effect, this, branch(() => {
3449
+ failed(_classPrivateFieldGet2(_anchor, this), () => error, () => reset);
3450
+ }));
3451
+ }
3452
+ /**
3453
+ * Creates the `reset` function for a failed boundary, along with a function
3454
+ * that invokes `onerror` with it (if provided)
3455
+ * @param {unknown} error
3456
+ * @returns {{ reset: () => void, invoke_onerror: () => void }}
3457
+ */
3458
+ function _create_reset(error) {
3459
+ var did_reset = false;
3460
+ var calling_on_error = false;
3461
+ const reset = () => {
3462
+ if (did_reset) {
3463
+ svelte_boundary_reset_noop();
3464
+ return;
3499
3465
  }
3500
- if (!node) {
3501
- var root = /* @__PURE__ */ get_first_child(create_fragment_from_html(wrapped));
3502
- if (is_fragment) {
3503
- node = document.createDocumentFragment();
3504
- while (/* @__PURE__ */ get_first_child(root)) node.appendChild(/* @__PURE__ */ get_first_child(root));
3505
- } else node = /* @__PURE__ */ get_first_child(root);
3466
+ did_reset = true;
3467
+ if (calling_on_error) svelte_boundary_reset_onerror();
3468
+ if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
3469
+ _classPrivateFieldSet2(_failed_effect, this, null);
3470
+ });
3471
+ _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
3472
+ _assertClassBrand(_Boundary_brand, this, _render).call(this);
3473
+ });
3474
+ };
3475
+ const invoke_onerror = () => {
3476
+ try {
3477
+ calling_on_error = true;
3478
+ _classPrivateFieldGet2(_props, this).onerror?.(error, reset);
3479
+ calling_on_error = false;
3480
+ } catch (err) {
3481
+ invoke_error_boundary(err, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
3506
3482
  }
3507
- var clone = node.cloneNode(true);
3508
- if (is_fragment) {
3509
- var start = /* @__PURE__ */ get_first_child(clone);
3510
- var end = clone.lastChild;
3511
- assign_nodes(start, end);
3512
- } else assign_nodes(clone, clone);
3513
- return clone;
3514
3483
  };
3484
+ return {
3485
+ reset,
3486
+ invoke_onerror
3487
+ };
3488
+ }
3489
+ function _hydrate_pending_content() {
3490
+ const pending = _classPrivateFieldGet2(_props, this).pending;
3491
+ if (!pending) return;
3492
+ this.is_pending = true;
3493
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
3494
+ queue_micro_task(() => {
3495
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
3496
+ var anchor = create_text();
3497
+ var handled = false;
3498
+ fragment.append(anchor);
3499
+ _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
3500
+ try {
3501
+ return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
3502
+ } catch (error) {
3503
+ try {
3504
+ this.error(error);
3505
+ handled = true;
3506
+ } catch (error) {
3507
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
3508
+ }
3509
+ return null;
3510
+ }
3511
+ }));
3512
+ if (_classPrivateFieldGet2(_main_effect, this) === null) {
3513
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
3514
+ if (handled) _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
3515
+ return;
3516
+ }
3517
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
3518
+ _classPrivateFieldGet2(_anchor, this).before(fragment);
3519
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
3520
+ pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
3521
+ _classPrivateFieldSet2(_pending_effect, this, null);
3522
+ });
3523
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
3524
+ }
3525
+ });
3526
+ }
3527
+ function _render() {
3528
+ try {
3529
+ this.is_pending = this.has_pending_snippet();
3530
+ _classPrivateFieldSet2(_pending_count, this, 0);
3531
+ _classPrivateFieldSet2(_local_pending_count, this, 0);
3532
+ _classPrivateFieldSet2(_main_effect, this, branch(() => {
3533
+ _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
3534
+ }));
3535
+ if (_classPrivateFieldGet2(_pending_count, this) > 0) {
3536
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
3537
+ move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
3538
+ const pending = _classPrivateFieldGet2(_props, this).pending;
3539
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
3540
+ } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
3541
+ } catch (error) {
3542
+ this.error(error);
3543
+ }
3515
3544
  }
3516
3545
  /**
3517
- * @param {string} content
3518
- * @param {number} flags
3546
+ * @param {Batch} batch
3519
3547
  */
3520
- /*#__NO_SIDE_EFFECTS__*/
3521
- function from_svg(content, flags) {
3522
- return /* @__PURE__ */ from_namespace(content, flags, "svg");
3548
+ function _resolve(batch) {
3549
+ this.is_pending = false;
3550
+ batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
3523
3551
  }
3524
3552
  /**
3525
- * @returns {TemplateNode | DocumentFragment}
3553
+ * @template T
3554
+ * @param {() => T} fn
3526
3555
  */
3527
- function comment() {
3528
- if (hydrating) {
3529
- assign_nodes(hydrate_node, null);
3530
- return hydrate_node;
3556
+ function _run(fn) {
3557
+ var previous_effect = active_effect;
3558
+ var previous_reaction = active_reaction;
3559
+ var previous_ctx = component_context;
3560
+ set_active_effect(_classPrivateFieldGet2(_effect, this));
3561
+ set_active_reaction(_classPrivateFieldGet2(_effect, this));
3562
+ set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
3563
+ try {
3564
+ Batch.ensure();
3565
+ return fn();
3566
+ } finally {
3567
+ set_active_effect(previous_effect);
3568
+ set_active_reaction(previous_reaction);
3569
+ set_component_context(previous_ctx);
3531
3570
  }
3532
- var frag = document.createDocumentFragment();
3533
- var start = document.createComment("");
3534
- var anchor = create_text();
3535
- frag.append(start, anchor);
3536
- assign_nodes(start, anchor);
3537
- return frag;
3538
3571
  }
3539
3572
  /**
3540
- * Assign the created (or in hydration mode, traversed) dom elements to the current block
3541
- * and insert the elements into the dom (in client mode).
3542
- * @param {Text | Comment | Element} anchor
3543
- * @param {DocumentFragment | Element} dom
3573
+ * Updates the pending count associated with the currently visible pending snippet,
3574
+ * if any, such that we can replace the snippet with content once work is done
3575
+ * @param {1 | -1} d
3576
+ * @param {Batch} batch
3544
3577
  */
3545
- function append(anchor, dom) {
3546
- if (hydrating) {
3547
- var effect = active_effect;
3548
- if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
3549
- hydrate_next();
3578
+ function _update_pending_count(d, batch) {
3579
+ if (!this.has_pending_snippet()) {
3580
+ if (this.parent) {
3581
+ var _this$parent;
3582
+ _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
3583
+ }
3550
3584
  return;
3551
3585
  }
3552
- if (anchor === null) return;
3553
- anchor.before(dom);
3586
+ _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
3587
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
3588
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
3589
+ if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
3590
+ _classPrivateFieldSet2(_pending_effect, this, null);
3591
+ });
3592
+ if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
3593
+ _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
3594
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
3595
+ }
3596
+ }
3554
3597
  }
3555
3598
  /**
3556
- * Subset of delegated events which should be passive by default.
3557
- * These two are already passive via browser defaults on window, document and body.
3558
- * But since
3559
- * - we're delegating them
3560
- * - they happen often
3561
- * - they apply to mobile which is generally less performant
3562
- * we're marking them as passive by default for other elements, too.
3563
- */
3564
- var PASSIVE_EVENTS = ["touchstart", "touchmove"];
3565
- /**
3566
- * Returns `true` if `name` is a passive event
3567
- * @param {string} name
3599
+ * @param {unknown} error
3568
3600
  */
3569
- function is_passive_event(name) {
3570
- return PASSIVE_EVENTS.includes(name);
3601
+ function _handle_error(error) {
3602
+ if (_classPrivateFieldGet2(_main_effect, this)) {
3603
+ destroy_effect(_classPrivateFieldGet2(_main_effect, this));
3604
+ _classPrivateFieldSet2(_main_effect, this, null);
3605
+ }
3606
+ if (_classPrivateFieldGet2(_pending_effect, this)) {
3607
+ destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
3608
+ _classPrivateFieldSet2(_pending_effect, this, null);
3609
+ }
3610
+ if (_classPrivateFieldGet2(_failed_effect, this)) {
3611
+ destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
3612
+ _classPrivateFieldSet2(_failed_effect, this, null);
3613
+ }
3614
+ if (hydrating) {
3615
+ set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
3616
+ next();
3617
+ set_hydrate_node(skip_nodes());
3618
+ }
3619
+ let failed = _classPrivateFieldGet2(_props, this).failed;
3620
+ /** @param {unknown} transformed_error */
3621
+ const handle_error_result = (transformed_error) => {
3622
+ const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, transformed_error);
3623
+ invoke_onerror();
3624
+ if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
3625
+ try {
3626
+ return branch(() => {
3627
+ var effect = active_effect;
3628
+ effect.b = this;
3629
+ effect.f |= 128;
3630
+ failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
3631
+ });
3632
+ } catch (error) {
3633
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
3634
+ return null;
3635
+ }
3636
+ }));
3637
+ };
3638
+ queue_micro_task(() => {
3639
+ /** @type {unknown} */
3640
+ var result;
3641
+ try {
3642
+ result = this.transform_error(error);
3643
+ } catch (e) {
3644
+ invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
3645
+ return;
3646
+ }
3647
+ if (result !== null && typeof result === "object" && typeof result.then === "function")
3648
+ /** @type {any} */ result.then(
3649
+ handle_error_result,
3650
+ /** @param {unknown} e */
3651
+ (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
3652
+ );
3653
+ else handle_error_result(result);
3654
+ });
3571
3655
  }
3572
3656
  /**
3573
3657
  * @param {Element} text
@@ -3575,9 +3659,8 @@ function is_passive_event(name) {
3575
3659
  * @returns {void}
3576
3660
  */
3577
3661
  function set_text(text, value) {
3578
- var _text;
3579
3662
  var str = value == null ? "" : typeof value === "object" ? `${value}` : value;
3580
- if (str !== ((_text = text)[TEXT_CACHE] ?? (_text[TEXT_CACHE] = text.nodeValue))) {
3663
+ if (str !== (text[TEXT_CACHE] ?? (text[TEXT_CACHE] = text.nodeValue))) {
3581
3664
  /** @type {any} */ text[TEXT_CACHE] = str;
3582
3665
  text.nodeValue = `${str}`;
3583
3666
  }
@@ -3672,7 +3755,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
3672
3755
  if (events)
3673
3756
  /** @type {any} */ props.$$events = events;
3674
3757
  if (hydrating) assign_nodes(anchor_node, null);
3675
- component = Component(anchor_node, props) || {};
3758
+ component = Component(anchor_node, props) || mark_as_component();
3676
3759
  if (hydrating) {
3677
3760
  /** @type {Effect & { nodes: EffectNodes }} */ active_effect.nodes.end = hydrate_node;
3678
3761
  if (hydrate_node === null || hydrate_node.nodeType !== 8 || hydrate_node.data !== "]") {
@@ -3758,7 +3841,7 @@ function unmount(component, options) {
3758
3841
  return Promise.resolve();
3759
3842
  }
3760
3843
  //#endregion
3761
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3844
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3762
3845
  /** @import { Effect, TemplateNode } from '#client' */
3763
3846
  var _batches = /* @__PURE__ */ new WeakMap();
3764
3847
  var _onscreen = /* @__PURE__ */ new WeakMap();
@@ -3881,7 +3964,7 @@ var BranchManager = class {
3881
3964
  }
3882
3965
  };
3883
3966
  //#endregion
3884
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/snippet.js
3967
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/snippet.js
3885
3968
  /** @import { Snippet } from 'svelte' */
3886
3969
  /** @import { TemplateNode } from '#client' */
3887
3970
  /** @import { Getters } from '#shared' */
@@ -3934,7 +4017,7 @@ function init_update_callbacks(context) {
3934
4017
  });
3935
4018
  }
3936
4019
  //#endregion
3937
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/if.js
4020
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/if.js
3938
4021
  /** @import { TemplateNode } from '#client' */
3939
4022
  /**
3940
4023
  * @param {TemplateNode} node
@@ -3980,7 +4063,7 @@ function if_block(node, fn, elseif = false) {
3980
4063
  }, flags);
3981
4064
  }
3982
4065
  //#endregion
3983
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/blocks/each.js
4066
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/each.js
3984
4067
  /** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */
3985
4068
  /** @import { Batch } from '../../reactivity/batch.js'; */
3986
4069
  /**
@@ -4020,7 +4103,7 @@ function pause_effects(state, to_destroy, controlled_anchor) {
4020
4103
  }, false);
4021
4104
  }
4022
4105
  if (remaining === 0) {
4023
- var fast_path = transitions.length === 0 && controlled_anchor !== null;
4106
+ var fast_path = transitions.length === 0 && controlled_anchor !== null && state.pending.size === 0;
4024
4107
  if (fast_path) {
4025
4108
  var anchor = controlled_anchor;
4026
4109
  var parent_node = anchor.parentNode;
@@ -4452,13 +4535,14 @@ function html(node, get_value, is_controlled = false, svg = false, mathml = fals
4452
4535
  });
4453
4536
  }
4454
4537
  //#endregion
4455
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/css.js
4538
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/css.js
4456
4539
  /**
4457
4540
  * @param {Node} anchor
4458
4541
  * @param {{ hash: string, code: string }} css
4459
4542
  */
4460
4543
  function append_styles$1(anchor, css) {
4461
4544
  effect(() => {
4545
+ anchor = active_effect?.parent?.nodes?.start ?? anchor;
4462
4546
  var root = anchor.getRootNode();
4463
4547
  var target = root.host ? root : /** @type {Document} */ root.head ?? root.ownerDocument.head;
4464
4548
  if (!target.querySelector("#" + css.hash)) {
@@ -4470,7 +4554,7 @@ function append_styles$1(anchor, css) {
4470
4554
  });
4471
4555
  }
4472
4556
  //#endregion
4473
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/shared/attributes.js
4557
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/shared/attributes.js
4474
4558
  var whitespace = [..." \n\r\f\xA0\v"];
4475
4559
  /**
4476
4560
  * @param {any} value
@@ -4534,7 +4618,7 @@ function to_style(value, styles) {
4534
4618
  important_styles = styles[1];
4535
4619
  } else normal_styles = styles;
4536
4620
  if (value) {
4537
- value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
4621
+ value = String(value).replaceAll(/\/\*.*?\*\//g, "").trim();
4538
4622
  /** @type {boolean | '"' | "'"} */
4539
4623
  var in_str = false;
4540
4624
  var in_apo = 0;
@@ -4580,7 +4664,7 @@ function to_style(value, styles) {
4580
4664
  return value == null ? null : String(value);
4581
4665
  }
4582
4666
  //#endregion
4583
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/class.js
4667
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/class.js
4584
4668
  /**
4585
4669
  * @param {Element} dom
4586
4670
  * @param {boolean | number} is_html
@@ -4605,7 +4689,7 @@ function set_class(dom, is_html, value, hash, prev_classes, next_classes) {
4605
4689
  return next_classes;
4606
4690
  }
4607
4691
  //#endregion
4608
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/style.js
4692
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/style.js
4609
4693
  /**
4610
4694
  * @param {Element & ElementCSSInlineStyle} dom
4611
4695
  * @param {Record<string, any>} prev
@@ -4639,7 +4723,7 @@ function set_style(dom, value, prev_styles, next_styles) {
4639
4723
  return next_styles;
4640
4724
  }
4641
4725
  //#endregion
4642
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/attributes.js
4726
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/attributes.js
4643
4727
  /** @import { Blocker, Effect } from '#client' */
4644
4728
  var IS_CUSTOM_ELEMENT = Symbol("is custom element");
4645
4729
  var IS_HTML = Symbol("is html");
@@ -4662,7 +4746,7 @@ function set_attribute(element, attribute, value, skip_warning) {
4662
4746
  if (attributes[attribute] === (attributes[attribute] = value)) return;
4663
4747
  if (attribute === "loading") element[LOADING_ATTR_SYMBOL] = value;
4664
4748
  if (value == null) element.removeAttribute(attribute);
4665
- else if (typeof value !== "string" && get_setters(element).includes(attribute)) element[attribute] = value;
4749
+ else if (typeof value !== "string" && get_setters(element).has(attribute)) element[attribute] = value;
4666
4750
  else element.setAttribute(attribute, value);
4667
4751
  }
4668
4752
  /**
@@ -4670,32 +4754,31 @@ function set_attribute(element, attribute, value, skip_warning) {
4670
4754
  * @param {Element} element
4671
4755
  */
4672
4756
  function get_attributes(element) {
4673
- var _element;
4674
- return (_element = element)[ATTRIBUTES_CACHE] ?? (_element[ATTRIBUTES_CACHE] = {
4757
+ return element[ATTRIBUTES_CACHE] ?? (element[ATTRIBUTES_CACHE] = {
4675
4758
  [IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"),
4676
4759
  [IS_HTML]: element.namespaceURI === "http://www.w3.org/1999/xhtml"
4677
4760
  });
4678
4761
  }
4679
- /** @type {Map<string, string[]>} */
4762
+ /** @type {Map<string, Set<string>>} */
4680
4763
  var setters_cache = /* @__PURE__ */ new Map();
4681
4764
  /** @param {Element} element */
4682
4765
  function get_setters(element) {
4683
4766
  var cache_key = element.getAttribute("is") || element.nodeName;
4684
4767
  var setters = setters_cache.get(cache_key);
4685
4768
  if (setters) return setters;
4686
- setters_cache.set(cache_key, setters = []);
4769
+ setters_cache.set(cache_key, setters = /* @__PURE__ */ new Set());
4687
4770
  var descriptors;
4688
4771
  var proto = element;
4689
4772
  var element_proto = Element.prototype;
4690
4773
  while (element_proto !== proto) {
4691
4774
  descriptors = get_descriptors(proto);
4692
- for (var key in descriptors) if (descriptors[key].set && key !== "innerHTML" && key !== "textContent" && key !== "innerText") setters.push(key);
4775
+ for (var key in descriptors) if (descriptors[key].set && key !== "innerHTML" && key !== "textContent" && key !== "innerText") setters.add(key);
4693
4776
  proto = get_prototype_of(proto);
4694
4777
  }
4695
4778
  return setters;
4696
4779
  }
4697
4780
  //#endregion
4698
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
4781
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
4699
4782
  var _ResizeObserverSingleton;
4700
4783
  var _listeners = /* @__PURE__ */ new WeakMap();
4701
4784
  var _observer = /* @__PURE__ */ new WeakMap();
@@ -4747,7 +4830,7 @@ function _getObserver() {
4747
4830
  }
4748
4831
  _defineProperty(ResizeObserverSingleton, "entries", /* @__PURE__ */ new WeakMap());
4749
4832
  //#endregion
4750
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/bindings/this.js
4833
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/this.js
4751
4834
  /** @import { ComponentContext, Effect } from '#client' */
4752
4835
  /**
4753
4836
  * @param {any} bound_value
@@ -4765,7 +4848,7 @@ function is_bound_this(bound_value, element_or_component) {
4765
4848
  * returns all the parts of the each block context that are used in the expression
4766
4849
  * @returns {void}
4767
4850
  */
4768
- function bind_this(element_or_component = {}, update, get_value, get_parts) {
4851
+ function bind_this(element_or_component = mark_as_component(), update, get_value, get_parts) {
4769
4852
  var component_effect = component_context.r;
4770
4853
  var parent = active_effect;
4771
4854
  effect(() => {
@@ -4889,7 +4972,7 @@ function prop(props, key, flags, fallback) {
4889
4972
  });
4890
4973
  }
4891
4974
  //#endregion
4892
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/legacy/legacy-client.js
4975
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/legacy/legacy-client.js
4893
4976
  /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
4894
4977
  /**
4895
4978
  * Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
@@ -5008,7 +5091,7 @@ var Svelte4Component = class {
5008
5091
  }
5009
5092
  };
5010
5093
  //#endregion
5011
- //#region ../../../node_modules/.bun/svelte@5.56.1/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
5094
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
5012
5095
  /**
5013
5096
  * @typedef {Object} CustomElementPropDefinition
5014
5097
  * @property {string} [attribute]
@@ -5294,7 +5377,8 @@ function create_custom_element(Component, props_definition, slots, exports, shad
5294
5377
  }
5295
5378
  //#endregion
5296
5379
  //#region ../../lib-svelte/delivery-events/dist/index2.js
5297
- var _e, _e2;
5380
+ var _e;
5381
+ var _e2;
5298
5382
  var e$1 = (_e = class e extends CustomEvent {
5299
5383
  constructor(t, n, r) {
5300
5384
  super(e.TYPE, {
@@ -5307,7 +5391,8 @@ var e$1 = (_e = class e extends CustomEvent {
5307
5391
  }
5308
5392
  }), this.component = t, this.complete = n;
5309
5393
  }
5310
- }, _e.TYPE = "model-set", _e), t$2 = (_e2 = class e extends CustomEvent {
5394
+ }, _e.TYPE = "model-set", _e);
5395
+ var t$2 = (_e2 = class e extends CustomEvent {
5311
5396
  constructor(t, n) {
5312
5397
  super(e.TYPE, {
5313
5398
  bubbles: !0,
@@ -5337,17 +5422,31 @@ function n$1(e, n = {}) {
5337
5422
  }
5338
5423
  return null;
5339
5424
  }
5340
- function r$1({ sourceEl: t, fallbackSelector: r, component: i, complete: a, session: o }) {
5425
+ function r$1(e) {
5426
+ return !!e && typeof e == "object" && !Array.isArray(e);
5427
+ }
5428
+ function i(e, t) {
5429
+ if (e === t) return e;
5430
+ if (!r$1(e) || !r$1(t) || Object.isFrozen(e) || !Object.isExtensible(e)) return t;
5431
+ try {
5432
+ for (let n of Object.keys(e)) n in t || delete e[n];
5433
+ Object.assign(e, t);
5434
+ } catch {
5435
+ return t;
5436
+ }
5437
+ return e;
5438
+ }
5439
+ function a$1({ sourceEl: t, fallbackSelector: r, component: i, complete: a, session: o }) {
5341
5440
  let s = n$1(t, { fallbackSelector: r });
5342
5441
  return s ? typeof s.onSessionChange == "function" ? (s.onSessionChange(o), s) : (s.dispatchEvent(new t$2(i, a)), s) : null;
5343
5442
  }
5344
5443
  //#endregion
5345
5444
  //#region ../../shared/math-rendering-mathjax/dist/index.js
5346
- var e = "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", t = null;
5347
- function n(n) {
5348
- return typeof window > "u" || window.MathJax?.typesetPromise ? Promise.resolve() : t || (t = new Promise((t, r) => {
5349
- let { useSingleDollar: i = !1, accessibility: a = !0, loadFonts: o = !0, srcUrl: s } = n, c = {
5350
- loader: { load: a ? ["a11y/assistive-mml"] : [] },
5445
+ var e = null;
5446
+ function t(t) {
5447
+ return typeof window > "u" || window.MathJax?.typesetPromise ? Promise.resolve() : e || (e = new Promise((e, n) => {
5448
+ let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = t, s = {
5449
+ loader: { load: i ? ["a11y/assistive-mml"] : [] },
5351
5450
  tex: {
5352
5451
  packages: [
5353
5452
  "base",
@@ -5362,27 +5461,27 @@ function n(n) {
5362
5461
  }
5363
5462
  },
5364
5463
  options: {
5365
- enableMenu: a,
5366
- enableExplorer: a,
5367
- enableAssistiveMml: a
5464
+ enableMenu: i,
5465
+ enableExplorer: i,
5466
+ enableAssistiveMml: i
5368
5467
  },
5369
5468
  startup: {
5370
5469
  ready: () => {
5371
- window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), t());
5470
+ window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), e());
5372
5471
  },
5373
5472
  defaultReady: () => {}
5374
5473
  }
5375
5474
  };
5376
- i && c.tex && (c.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], c.tex.processEscapes = !0), o || (c.chtml = { fontURL: "" }), window.MathJax = c;
5377
- let l = document.createElement("script");
5378
- l.src = s || e, l.async = !0, l.onload = () => {
5379
- setTimeout(t, 100);
5380
- }, l.onerror = () => {
5381
- r(/* @__PURE__ */ Error("Failed to load MathJax"));
5382
- }, document.head.appendChild(l);
5383
- }), t);
5384
- }
5385
- function r() {
5475
+ r && s.tex && (s.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], s.tex.processEscapes = !0), a || (s.chtml = { fontURL: "" }), window.MathJax = s;
5476
+ let c = document.createElement("script");
5477
+ c.src = o || "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", c.async = !0, c.onload = () => {
5478
+ setTimeout(e, 100);
5479
+ }, c.onerror = () => {
5480
+ n(/* @__PURE__ */ Error("Failed to load MathJax"));
5481
+ }, document.head.appendChild(c);
5482
+ }), e);
5483
+ }
5484
+ function n() {
5386
5485
  let e = window.MathJax?.startup?.document;
5387
5486
  if (typeof e?.assistiveMml == "function") try {
5388
5487
  e.assistiveMml().updateDocument?.();
@@ -5390,33 +5489,33 @@ function r() {
5390
5489
  console.warn("[mathjax-renderer] Failed to attach assistive MathML:", e);
5391
5490
  }
5392
5491
  }
5393
- function i(e = {}) {
5394
- return async (t) => {
5395
- if (await n(e), !window.MathJax?.typesetPromise) {
5492
+ function r(e = {}) {
5493
+ return async (r) => {
5494
+ if (await t(e), !window.MathJax?.typesetPromise) {
5396
5495
  console.warn("[mathjax-renderer] MathJax not loaded or missing typesetPromise.");
5397
5496
  return;
5398
5497
  }
5399
- await window.MathJax.typesetPromise([t]), r();
5498
+ await window.MathJax.typesetPromise([r]), n();
5400
5499
  };
5401
5500
  }
5402
- var o = "@pie-lib/math-rendering", s = null;
5403
- function c() {
5404
- return s || (s = i({
5501
+ var a = null;
5502
+ function o() {
5503
+ return a || (a = r({
5405
5504
  accessibility: !0,
5406
5505
  useSingleDollar: !0
5407
- })), s;
5506
+ })), a;
5408
5507
  }
5409
- function l() {
5508
+ function s() {
5410
5509
  if (typeof window > "u") return null;
5411
- let e = window[o];
5510
+ let e = window["@pie-lib/math-rendering"];
5412
5511
  return typeof e?.renderMath == "function" ? e : null;
5413
5512
  }
5414
- var u = async (e) => {
5513
+ var c = async (e) => {
5415
5514
  if (typeof window > "u") return;
5416
5515
  let t = typeof e == "string", n;
5417
5516
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
5418
- let r = l();
5419
- return r ? await r.renderMath?.(n) : await c()(n), t ? n.innerHTML : void 0;
5517
+ let r = s();
5518
+ return r ? await r.renderMath?.(n) : await o()(n), t ? n.innerHTML : void 0;
5420
5519
  };
5421
5520
  //#endregion
5422
5521
  //#region src/delivery/tile-accessible-name.ts
@@ -5438,7 +5537,7 @@ var root_3$1 = /* @__PURE__ */ from_html(`<span class="badge badge-incorrect sve
5438
5537
  var root_4$1 = /* @__PURE__ */ from_html(`<button type="button"><span><!> <!></span> <!></button>`);
5439
5538
  var $$css$2 = {
5440
5539
  hash: "svelte-1hgaksk",
5441
- code: ".venn-tile.svelte-1hgaksk {position:relative;display:inline-flex;align-items:center;justify-content:center;min-width:64px;min-height:44px;padding:8px 14px;border:1.5px solid #334155;border-radius:10px;background:#ffffff;color:#0f172a;font-size:14px;font-weight:500;box-shadow:0 1px 2px rgba(15, 23, 42, 0.06);cursor:grab;touch-action:none;user-select:none;transition:box-shadow 120ms ease, transform 120ms ease, background 120ms ease;}.venn-tile.svelte-1hgaksk:focus-visible,\n .venn-tile.focused.svelte-1hgaksk {outline:2px solid #2563eb;outline-offset:2px;}.venn-tile.svelte-1hgaksk:hover:not(:disabled) {background:#f8fafc;}.venn-tile.held.svelte-1hgaksk {cursor:grabbing;box-shadow:0 6px 18px rgba(15, 23, 42, 0.18);transform:translateY(-1px);background:#eef2ff;}.venn-tile.invisible.svelte-1hgaksk {visibility:hidden;}.venn-tile.ghost.svelte-1hgaksk {pointer-events:none;cursor:grabbing;box-shadow:0 10px 24px rgba(15, 23, 42, 0.22);transform:rotate(-1.5deg);background:#ffffff;opacity:0.96;}.venn-tile.correct.svelte-1hgaksk {border-color:#0ea449;}.venn-tile.incorrect.svelte-1hgaksk {border-color:#bf0d00;}.venn-tile.svelte-1hgaksk:disabled {cursor:default;}.tile-body.svelte-1hgaksk {display:inline-flex;flex-direction:row;align-items:center;justify-content:center;gap:8px;pointer-events:none;max-width:220px;}.tile-body-image.svelte-1hgaksk {flex-direction:column;gap:4px;}.tile-img.svelte-1hgaksk {width:40px;height:40px;object-fit:contain;flex-shrink:0;}.tile-label.svelte-1hgaksk {pointer-events:none;text-align:center;line-height:1.25;word-break:break-word;}.tile-label-below.svelte-1hgaksk {font-size:12px;font-weight:600;}.badge.svelte-1hgaksk {position:absolute;top:-8px;right:-8px;width:20px;height:20px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:#ffffff;}.badge-correct.svelte-1hgaksk {background:#0ea449;}.badge-incorrect.svelte-1hgaksk {background:#bf0d00;}\n @media (prefers-reduced-motion: reduce) {.venn-tile.svelte-1hgaksk {transition:none;}\n }"
5540
+ code: ".venn-tile.svelte-1hgaksk {position:relative;display:inline-flex;align-items:center;justify-content:center;min-width:64px;min-height:44px;padding:8px 14px;border:1.5px solid #334155;border-radius:10px;background:#ffffff;color:#0f172a;font-size:14px;font-weight:500;box-shadow:0 1px 2px rgba(15, 23, 42, 0.06);cursor:grab;touch-action:none;user-select:none;transition:box-shadow 120ms ease, transform 120ms ease, background 120ms ease;}.venn-tile.svelte-1hgaksk:focus-visible,\n .venn-tile.focused.svelte-1hgaksk {outline:2px solid var(--vc-focus-ring, #1565c0);outline-offset:2px;}.venn-tile.svelte-1hgaksk:hover:not(:disabled) {background:#f8fafc;}.venn-tile.held.svelte-1hgaksk {cursor:grabbing;box-shadow:0 6px 18px rgba(15, 23, 42, 0.18);transform:translateY(-1px);background:#eef2ff;}.venn-tile.invisible.svelte-1hgaksk {visibility:hidden;}.venn-tile.ghost.svelte-1hgaksk {pointer-events:none;cursor:grabbing;box-shadow:0 10px 24px rgba(15, 23, 42, 0.22);transform:rotate(-1.5deg);background:#ffffff;opacity:0.96;}.venn-tile.correct.svelte-1hgaksk {border-color:#0ea449;}.venn-tile.incorrect.svelte-1hgaksk {border-color:#bf0d00;}.venn-tile.svelte-1hgaksk:disabled {cursor:default;}.tile-body.svelte-1hgaksk {display:inline-flex;flex-direction:row;align-items:center;justify-content:center;gap:8px;pointer-events:none;max-width:220px;}.tile-body-image.svelte-1hgaksk {flex-direction:column;gap:4px;}.tile-img.svelte-1hgaksk {width:40px;height:40px;object-fit:contain;flex-shrink:0;}.tile-label.svelte-1hgaksk {pointer-events:none;text-align:center;line-height:1.25;word-break:break-word;}.tile-label-below.svelte-1hgaksk {font-size:12px;font-weight:600;}.badge.svelte-1hgaksk {position:absolute;top:-8px;right:-8px;width:20px;height:20px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:#ffffff;}.badge-correct.svelte-1hgaksk {background:#0ea449;}.badge-incorrect.svelte-1hgaksk {background:#bf0d00;}\n @media (prefers-reduced-motion: reduce) {.venn-tile.svelte-1hgaksk {transition:none;}\n }"
5442
5541
  };
5443
5542
  function Tile($$anchor, $$props) {
5444
5543
  push($$props, true);
@@ -5649,7 +5748,7 @@ create_custom_element(Tile, {
5649
5748
  var root$1 = /* @__PURE__ */ from_html(`<div role="region" data-region-key="tray"><div class="tray-label svelte-1ogsh8s"> </div> <div class="tray-items svelte-1ogsh8s"><!></div></div>`);
5650
5749
  var $$css$1 = {
5651
5750
  hash: "svelte-1ogsh8s",
5652
- code: ".venn-tray.svelte-1ogsh8s {border:1.5px dashed #94a3b8;border-radius:12px;padding:14px 16px;background:#f8fafc;min-height:120px;transition:background 120ms ease, border-color 120ms ease;}.venn-tray.drop-target.svelte-1ogsh8s {background:#e0f2fe;border-color:#0ea5e9;}.venn-tray.focused.svelte-1ogsh8s {outline:2px solid #2563eb;outline-offset:2px;}.tray-label.svelte-1ogsh8s {font-size:12px;font-weight:600;color:#475569;text-transform:uppercase;letter-spacing:0.05em;margin-bottom:8px;}.tray-items.svelte-1ogsh8s {display:flex;flex-wrap:wrap;gap:10px;}\n @media (prefers-reduced-motion: reduce) {.venn-tray.svelte-1ogsh8s {transition:none;}\n }"
5751
+ code: ".venn-tray.svelte-1ogsh8s {border:1.5px dashed #94a3b8;border-radius:12px;padding:14px 16px;background:#f8fafc;min-height:120px;transition:background 120ms ease, border-color 120ms ease;}.venn-tray.drop-target.svelte-1ogsh8s {background:#e0f2fe;border-color:#0ea5e9;}.venn-tray.focused.svelte-1ogsh8s {outline:2px solid var(--vc-focus-ring, #1565c0);outline-offset:2px;}.tray-label.svelte-1ogsh8s {font-size:12px;font-weight:600;color:#475569;text-transform:uppercase;letter-spacing:0.05em;margin-bottom:8px;}.tray-items.svelte-1ogsh8s {display:flex;flex-wrap:wrap;gap:10px;}\n @media (prefers-reduced-motion: reduce) {.venn-tray.svelte-1ogsh8s {transition:none;}\n }"
5653
5752
  };
5654
5753
  function Tray($$anchor, $$props) {
5655
5754
  push($$props, true);
@@ -5702,8 +5801,7 @@ function Tray($$anchor, $$props) {
5702
5801
  var div = root$1();
5703
5802
  let classes;
5704
5803
  var div_1 = child(div);
5705
- var text = child(div_1, true);
5706
- reset(div_1);
5804
+ var text = only_child(div_1, true);
5707
5805
  var div_2 = sibling(div_1, 2);
5708
5806
  var node = child(div_2);
5709
5807
  var consequent = ($$anchor) => {
@@ -5856,7 +5954,7 @@ function makeGridSlot(center, slotsPerRow) {
5856
5954
  * compose accessible names, and `model.regionLabels` for overrides).
5857
5955
  */
5858
5956
  function buildLayout2Set(model, geometry = defaultGeometry2Set()) {
5859
- if (!model.circles || model.circles.length !== 2) throw new Error(`buildLayout2Set requires exactly 2 circles (got ${model.circles?.length ?? 0})`);
5957
+ if (model.circles?.length !== 2) throw new Error(`buildLayout2Set requires exactly 2 circles (got ${model.circles?.length ?? 0})`);
5860
5958
  const [c0, c1] = geometry.circles;
5861
5959
  const regions = enumerateRegions(2);
5862
5960
  const circleBottom = Math.max(c0.cy + c0.r, c1.cy + c1.r);
@@ -6051,12 +6149,6 @@ function groupTilesByRegion(model, session) {
6051
6149
  }
6052
6150
  return groups;
6053
6151
  }
6054
- new Set([
6055
- "$$slots",
6056
- "$$events",
6057
- "$$legacy",
6058
- "$$host"
6059
- ]);
6060
6152
  var root = /* @__PURE__ */ from_html(`<div class="venn-prompt prose svelte-gkcqor"></div>`);
6061
6153
  var root_1 = /* @__PURE__ */ from_svg(`<svg class="toggle-icon svelte-gkcqor" preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-283 359 34 35" aria-hidden="true"><circle cx="-266" cy="375.9" r="14" fill="#bce2ff"></circle><path d="M-280.5,375.9c0-8,6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5s-6.5,14.5-14.5,14.5S-280.5,383.9-280.5,375.9z M-279.5,375.9c0,7.4,6.1,13.5,13.5,13.5c7.4,0,13.5-6.1,13.5-13.5s-6.1-13.5-13.5-13.5C-273.4,362.4-279.5,368.5-279.5,375.9z" fill="#bce2ff"></path><polygon points="-265.4,383.1 -258.6,377.2 -261.2,374.2 -264.3,376.9 -268.9,368.7 -272.4,370.6" fill="#1a9cff"></polygon></svg>`);
6062
6154
  var root_2 = /* @__PURE__ */ from_svg(`<svg class="toggle-icon svelte-gkcqor" preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-129.5 127 34 35" aria-hidden="true"><path style="fill: #D0CAC5; stroke: #E6E3E0; stroke-width: 0.75; stroke-miterlimit: 10;" d="M-112.9,160.4c-8.5,0-15.5-6.9-15.5-15.5c0-8.5,6.9-15.5,15.5-15.5s15.5,6.9,15.5,15.5 C-97.4,153.5-104.3,160.4-112.9,160.4z"></path><path style="fill: #B3ABA4; stroke: #CDC7C2; stroke-width: 0.5; stroke-miterlimit: 10;" d="M-113.2,159c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-105.2,159-113.2,159z"></path><circle cx="-114.2" cy="143.5" r="14" fill="white"></circle><path d="M-114.2,158c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-106.2,158-114.2,158z M-114.2,130c-7.4,0-13.5,6.1-13.5,13.5s6.1,13.5,13.5,13.5s13.5-6.1,13.5-13.5S-106.8,130-114.2,130z" fill="#bce2ff"></path><polygon points="-114.8,150.7 -121.6,144.8 -119,141.8 -115.9,144.5 -111.3,136.3 -107.8,138.2" fill="#1a9cff"></polygon></svg>`);
@@ -6074,7 +6166,7 @@ var root_13 = /* @__PURE__ */ from_html(`<div class="drag-ghost svelte-gkcqor"><
6074
6166
  var root_14 = /* @__PURE__ */ from_html(`<div class="venn-root svelte-gkcqor"><!> <!> <div class="venn-diagram svelte-gkcqor"><svg preserveAspectRatio="xMidYMid meet" aria-hidden="true" class="svelte-gkcqor"><defs><mask id="venn-mask-left-only" maskUnits="userSpaceOnUse" x="0" y="0"><rect x="0" y="0" fill="black"></rect><circle fill="white"></circle><circle fill="black"></circle></mask><mask id="venn-mask-right-only" maskUnits="userSpaceOnUse" x="0" y="0"><rect x="0" y="0" fill="black"></rect><circle fill="white"></circle><circle fill="black"></circle></mask><clipPath id="venn-clip-left" clipPathUnits="userSpaceOnUse"><circle></circle></clipPath><mask id="venn-mask-outside" maskUnits="userSpaceOnUse" x="0" y="0"><rect x="0" y="0" fill="white"></rect><circle fill="black"></circle><circle fill="black"></circle></mask></defs><rect x="1" y="1" fill="#ffffff" stroke="#cbd5e1" stroke-width="1.5" rx="12"></rect><!><!><!><!><!><!><!><line x1="16" stroke="#cbd5e1" stroke-width="1" stroke-dasharray="4 6"></line></svg> <div class="region-labels svelte-gkcqor" aria-hidden="false"></div> <div class="placed-tiles svelte-gkcqor"></div></div> <!> <!> <div class="sr-only svelte-gkcqor" aria-live="polite" aria-atomic="true"></div></div>`);
6075
6167
  var $$css = {
6076
6168
  hash: "svelte-gkcqor",
6077
- code: ".venn-root.svelte-gkcqor {display:flex;flex-direction:column;gap:16px;padding:16px;color:#0f172a;font-family:system-ui, -apple-system, Segoe UI, Roboto, sans-serif;}.venn-prompt.svelte-gkcqor {font-size:16px;line-height:1.5;}.venn-prompt.svelte-gkcqor p {margin:0 0 8px 0;}.toggle-correct.svelte-gkcqor {align-self:center;display:inline-flex;align-items:center;gap:8px;margin:0 0 4px 0;padding:0;background:transparent;border:0;color:inherit;font:inherit;font-size:14px;cursor:pointer;user-select:none;}.toggle-correct.svelte-gkcqor:focus-visible {outline:2px solid #2563eb;outline-offset:2px;border-radius:2px;}.toggle-icon.svelte-gkcqor {width:25px;height:25px;flex-shrink:0;}.toggle-label.svelte-gkcqor {line-height:1.2;}.toggle-correct.svelte-gkcqor:hover .toggle-label:where(.svelte-gkcqor),\n .toggle-correct.svelte-gkcqor:focus-visible .toggle-label:where(.svelte-gkcqor) {text-decoration:underline;}.venn-diagram.svelte-gkcqor {position:relative;width:100%;\n /*\n * Keep the diagram \"smart\" about vertical space: it should not monopolise\n * the viewport and force the tray below the fold.\n * - aspect-ratio preserves the 3:2 geometry the SVG is tuned for\n * - max-width keeps the diagram from dominating wide layouts\n * - max-height (viewport-relative) shrinks it further in short windows\n * so the prompt, toggle, and tray remain in view without scrolling\n * whenever possible. The SVG uses preserveAspectRatio=\"xMidYMid meet\",\n * so when max-height wins the width reduces in lockstep.\n */max-width:720px;aspect-ratio:900 / 540;max-height:min(60vh, 430px);margin:0 auto;}.venn-diagram.svelte-gkcqor svg:where(.svelte-gkcqor) {width:100%;height:100%;display:block;}.placed-tiles.svelte-gkcqor,\n .region-labels.svelte-gkcqor {position:absolute;inset:0;pointer-events:none;}.tile-wrapper.svelte-gkcqor {position:absolute;transform:translate(-50%, -50%);pointer-events:auto;}.region-aria.svelte-gkcqor {position:absolute;width:1px;height:1px;transform:translate(-50%, -50%);opacity:0;pointer-events:none;}.sr-only.svelte-gkcqor {position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;}.drag-ghost.svelte-gkcqor {position:fixed;top:0;left:0;transform:translate(-50%, -50%);pointer-events:none;z-index:1000;}"
6169
+ code: ".venn-root.svelte-gkcqor {display:flex;flex-direction:column;gap:16px;padding:16px;color:#0f172a;font-family:system-ui, -apple-system, Segoe UI, Roboto, sans-serif;--vc-focus-ring: var(\n --pie-focus-outline,\n var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565c0))\n );}.venn-prompt.svelte-gkcqor {font-size:16px;line-height:1.5;}.venn-prompt.svelte-gkcqor p {margin:0 0 8px 0;}.toggle-correct.svelte-gkcqor {align-self:center;display:inline-flex;align-items:center;gap:8px;margin:0 0 4px 0;padding:0;background:transparent;border:0;color:inherit;font:inherit;font-size:14px;cursor:pointer;user-select:none;}.toggle-correct.svelte-gkcqor:focus-visible {outline:2px solid var(--vc-focus-ring, #1565c0);outline-offset:2px;border-radius:2px;}.toggle-icon.svelte-gkcqor {width:25px;height:25px;flex-shrink:0;}.toggle-label.svelte-gkcqor {line-height:1.2;}.toggle-correct.svelte-gkcqor:hover .toggle-label:where(.svelte-gkcqor),\n .toggle-correct.svelte-gkcqor:focus-visible .toggle-label:where(.svelte-gkcqor) {text-decoration:underline;}.venn-diagram.svelte-gkcqor {position:relative;width:100%;\n /*\n * Keep the diagram \"smart\" about vertical space: it should not monopolise\n * the viewport and force the tray below the fold.\n * - aspect-ratio preserves the 3:2 geometry the SVG is tuned for\n * - max-width keeps the diagram from dominating wide layouts\n * - max-height (viewport-relative) shrinks it further in short windows\n * so the prompt, toggle, and tray remain in view without scrolling\n * whenever possible. The SVG uses preserveAspectRatio=\"xMidYMid meet\",\n * so when max-height wins the width reduces in lockstep.\n */max-width:720px;aspect-ratio:900 / 540;max-height:min(60vh, 430px);margin:0 auto;}.venn-diagram.svelte-gkcqor svg:where(.svelte-gkcqor) {width:100%;height:100%;display:block;}.placed-tiles.svelte-gkcqor,\n .region-labels.svelte-gkcqor {position:absolute;inset:0;pointer-events:none;}.tile-wrapper.svelte-gkcqor {position:absolute;transform:translate(-50%, -50%);pointer-events:auto;}.region-aria.svelte-gkcqor {position:absolute;width:1px;height:1px;transform:translate(-50%, -50%);opacity:0;pointer-events:none;}.sr-only.svelte-gkcqor {position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;}.drag-ghost.svelte-gkcqor {position:fixed;top:0;left:0;transform:translate(-50%, -50%);pointer-events:none;z-index:1000;}"
6078
6170
  };
6079
6171
  function VennClassification($$anchor, $$props) {
6080
6172
  push($$props, true);
@@ -6151,7 +6243,7 @@ function VennClassification($$anchor, $$props) {
6151
6243
  tileId,
6152
6244
  placement
6153
6245
  });
6154
- r$1({
6246
+ a$1({
6155
6247
  sourceEl: containerEl,
6156
6248
  fallbackSelector: "venn-classification",
6157
6249
  component: "venn-classification",
@@ -6282,7 +6374,7 @@ function VennClassification($$anchor, $$props) {
6282
6374
  function typeset() {
6283
6375
  if (!containerEl) return;
6284
6376
  try {
6285
- u(containerEl);
6377
+ c(containerEl);
6286
6378
  } catch (err) {
6287
6379
  console.warn("venn-classification: MathJax render failed", err);
6288
6380
  }
@@ -6328,9 +6420,7 @@ function VennClassification($$anchor, $$props) {
6328
6420
  if (get(showCorrect)) $$render(consequent_1);
6329
6421
  else $$render(alternate, -1);
6330
6422
  });
6331
- var span = sibling(node_2, 2);
6332
- var text = child(span);
6333
- reset(span);
6423
+ var text = only_child(sibling(node_2, 2));
6334
6424
  reset(button);
6335
6425
  template_effect(() => {
6336
6426
  set_attribute(button, "aria-pressed", get(showCorrect));
@@ -6356,8 +6446,7 @@ function VennClassification($$anchor, $$props) {
6356
6446
  var circle_3 = sibling(circle_2);
6357
6447
  reset(mask_1);
6358
6448
  var clipPath = sibling(mask_1);
6359
- var circle_4 = child(clipPath);
6360
- reset(clipPath);
6449
+ var circle_4 = only_child(clipPath);
6361
6450
  var mask_2 = sibling(clipPath);
6362
6451
  var rect_3 = child(mask_2);
6363
6452
  var circle_5 = sibling(rect_3);
@@ -6442,8 +6531,7 @@ function VennClassification($$anchor, $$props) {
6442
6531
  each(node_9, 17, () => geometry.circles, index, ($$anchor, c, idx) => {
6443
6532
  var text_1 = root_10();
6444
6533
  set_attribute(text_1, "text-anchor", idx === 0 ? "start" : "end");
6445
- var text_2 = child(text_1, true);
6446
- reset(text_1);
6534
+ var text_2 = only_child(text_1, true);
6447
6535
  template_effect(($0, $1) => {
6448
6536
  set_attribute(text_1, "x", $0);
6449
6537
  set_attribute(text_1, "y", $1);
@@ -6660,6 +6748,16 @@ var VennClassificationElement = class extends SvelteElementClass {
6660
6748
  constructor(..._args) {
6661
6749
  super(..._args);
6662
6750
  _defineProperty(this, "_internalSession", null);
6751
+ _defineProperty(
6752
+ this,
6753
+ /**
6754
+ * The session object the player handed us. A player reads the learner's
6755
+ * response back off this object, so every update is written into it as well
6756
+ * as into the copy the component renders from.
6757
+ */
6758
+ "_playerSession",
6759
+ null
6760
+ );
6663
6761
  _defineProperty(this, "_model", null);
6664
6762
  _defineProperty(this, "_isComplete", () => {
6665
6763
  return isComplete(this._model, this._internalSession);
@@ -6671,6 +6769,7 @@ var VennClassificationElement = class extends SvelteElementClass {
6671
6769
  this.dispatchEvent(new t$2(this.tagName.toLowerCase(), this._isComplete()));
6672
6770
  });
6673
6771
  _defineProperty(this, "onSessionChange", (updatedSession) => {
6772
+ i(this._playerSession, updatedSession);
6674
6773
  this._internalSession = updatedSession;
6675
6774
  super.session = updatedSession;
6676
6775
  this._dispatchSessionChanged();
@@ -6686,6 +6785,7 @@ var VennClassificationElement = class extends SvelteElementClass {
6686
6785
  }
6687
6786
  set session(s) {
6688
6787
  if (s === this._internalSession) return;
6788
+ this._playerSession = s;
6689
6789
  this._internalSession = s;
6690
6790
  super.session = s;
6691
6791
  this._dispatchSessionChanged();