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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/configure.js +2 -0
  3. package/dist/author/index.d.ts +0 -1
  4. package/dist/author/index.js +1730 -1540
  5. package/dist/author/index.js.map +1 -1
  6. package/dist/browser/author/index.js +50 -0
  7. package/dist/browser/author/index.js.map +1 -0
  8. package/dist/browser/client-BmZWrsT3.js +2388 -0
  9. package/dist/browser/client-BmZWrsT3.js.map +1 -0
  10. package/dist/browser/controller/index.js +220 -0
  11. package/dist/browser/controller/index.js.map +1 -0
  12. package/dist/browser/delivery/index.js +1058 -0
  13. package/dist/browser/delivery/index.js.map +1 -0
  14. package/dist/browser/layoutLimits-ATKOwLHb.js +42 -0
  15. package/dist/browser/layoutLimits-ATKOwLHb.js.map +1 -0
  16. package/dist/browser/print/index.js +123 -0
  17. package/dist/browser/print/index.js.map +1 -0
  18. package/dist/controller/defaults.d.ts +1 -2
  19. package/dist/controller/index.d.ts +0 -3
  20. package/dist/controller/index.js +1 -2
  21. package/dist/controller/index.js.map +1 -1
  22. package/dist/delivery/computeAudioMode.d.ts +0 -1
  23. package/dist/delivery/computeChoiceCorrectness.d.ts +0 -1
  24. package/dist/delivery/computeDisplayState.d.ts +0 -1
  25. package/dist/delivery/computeLayoutProfile.d.ts +0 -1
  26. package/dist/delivery/computeLayoutStyle.d.ts +0 -2
  27. package/dist/delivery/index.d.ts +0 -1
  28. package/dist/delivery/index.js +1946 -1940
  29. package/dist/delivery/index.js.map +1 -1
  30. package/dist/delivery/variant-css-map.d.ts +0 -1
  31. package/dist/index.d.ts +0 -1
  32. package/dist/index.iife.d.ts +0 -3
  33. package/dist/index.iife.js +14 -15
  34. package/dist/index.js +1946 -1940
  35. package/dist/index.js.map +1 -1
  36. package/dist/print/index.d.ts +0 -1
  37. package/dist/print/index.js +1985 -1778
  38. package/dist/print/index.js.map +1 -1
  39. package/dist/runtime-support.d.ts +12 -0
  40. package/dist/runtime-support.js +14 -0
  41. package/dist/runtime-support.js.map +1 -0
  42. package/dist/shared/layoutLimits.d.ts +0 -1
  43. package/dist/shared/types.d.ts +10 -2
  44. package/module/print.js +2340 -0
  45. package/module/print.js.map +1 -0
  46. package/package.json +40 -8
  47. package/dist/author/index.d.ts.map +0 -1
  48. package/dist/controller/defaults.d.ts.map +0 -1
  49. package/dist/controller/index.d.ts.map +0 -1
  50. package/dist/delivery/computeAudioMode.d.ts.map +0 -1
  51. package/dist/delivery/computeChoiceCorrectness.d.ts.map +0 -1
  52. package/dist/delivery/computeDisplayState.d.ts.map +0 -1
  53. package/dist/delivery/computeLayoutProfile.d.ts.map +0 -1
  54. package/dist/delivery/computeLayoutStyle.d.ts.map +0 -1
  55. package/dist/delivery/index.d.ts.map +0 -1
  56. package/dist/delivery/variant-css-map.d.ts.map +0 -1
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/index.iife.d.ts.map +0 -1
  59. package/dist/print/index.d.ts.map +0 -1
  60. package/dist/shared/layoutLimits.d.ts.map +0 -1
  61. package/dist/shared/types.d.ts.map +0 -1
@@ -1,16 +1,16 @@
1
- //#region ../../../node_modules/.bun/svelte@5.55.5/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.55.5/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
- var UNINITIALIZED = Symbol();
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.55.5/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;
@@ -47,7 +47,7 @@ function deferred() {
47
47
  };
48
48
  }
49
49
  //#endregion
50
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
50
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
51
51
  function _typeof(o) {
52
52
  "@babel/helpers - typeof";
53
53
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -57,7 +57,7 @@ function _typeof(o) {
57
57
  }, _typeof(o);
58
58
  }
59
59
  //#endregion
60
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
60
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
61
61
  function toPrimitive(t, r) {
62
62
  if ("object" != _typeof(t) || !t) return t;
63
63
  var e = t[Symbol.toPrimitive];
@@ -69,13 +69,13 @@ function toPrimitive(t, r) {
69
69
  return ("string" === r ? String : Number)(t);
70
70
  }
71
71
  //#endregion
72
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
72
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
73
73
  function toPropertyKey(t) {
74
74
  var i = toPrimitive(t, "string");
75
75
  return "symbol" == _typeof(i) ? i : i + "";
76
76
  }
77
77
  //#endregion
78
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
78
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
79
79
  function _defineProperty(e, r, t) {
80
80
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
81
81
  value: t,
@@ -112,8 +112,14 @@ var REACTION_IS_UPDATING = 1 << 21;
112
112
  var ASYNC = 1 << 22;
113
113
  var ERROR_VALUE = 1 << 23;
114
114
  var STATE_SYMBOL = Symbol("$state");
115
+ /** Marks component export objects, so that `proxy(...)` leaves them untouched */
116
+ var COMPONENT_SYMBOL = Symbol("component");
115
117
  var LEGACY_PROPS = Symbol("legacy props");
116
118
  var LOADING_ATTR_SYMBOL = Symbol("");
119
+ var ATTRIBUTES_CACHE = Symbol("attributes");
120
+ var CLASS_CACHE = Symbol("class");
121
+ var STYLE_CACHE = Symbol("style");
122
+ var TEXT_CACHE = Symbol("text");
117
123
  /** allow users to ignore aborted signal errors if `reason.name === 'StaleReactionError` */
118
124
  var STALE_REACTION = new class StaleReactionError extends Error {
119
125
  constructor(..._args) {
@@ -123,98 +129,6 @@ var STALE_REACTION = new class StaleReactionError extends Error {
123
129
  }
124
130
  }();
125
131
  var IS_XHTML = !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml");
126
- //#endregion
127
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/errors.js
128
- /**
129
- * Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
130
- * @returns {never}
131
- */
132
- function async_derived_orphan() {
133
- throw new Error(`https://svelte.dev/e/async_derived_orphan`);
134
- }
135
- /**
136
- * Keyed each block has duplicate key `%value%` at indexes %a% and %b%
137
- * @param {string} a
138
- * @param {string} b
139
- * @param {string | undefined | null} [value]
140
- * @returns {never}
141
- */
142
- function each_key_duplicate(a, b, value) {
143
- throw new Error(`https://svelte.dev/e/each_key_duplicate`);
144
- }
145
- /**
146
- * `%rune%` cannot be used inside an effect cleanup function
147
- * @param {string} rune
148
- * @returns {never}
149
- */
150
- function effect_in_teardown(rune) {
151
- throw new Error(`https://svelte.dev/e/effect_in_teardown`);
152
- }
153
- /**
154
- * Effect cannot be created inside a `$derived` value that was not itself created inside an effect
155
- * @returns {never}
156
- */
157
- function effect_in_unowned_derived() {
158
- throw new Error(`https://svelte.dev/e/effect_in_unowned_derived`);
159
- }
160
- /**
161
- * `%rune%` can only be used inside an effect (e.g. during component initialisation)
162
- * @param {string} rune
163
- * @returns {never}
164
- */
165
- function effect_orphan(rune) {
166
- throw new Error(`https://svelte.dev/e/effect_orphan`);
167
- }
168
- /**
169
- * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
170
- * @returns {never}
171
- */
172
- function effect_update_depth_exceeded() {
173
- throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
174
- }
175
- /**
176
- * Failed to hydrate the application
177
- * @returns {never}
178
- */
179
- function hydration_failed() {
180
- throw new Error(`https://svelte.dev/e/hydration_failed`);
181
- }
182
- /**
183
- * Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
184
- * @param {string} key
185
- * @returns {never}
186
- */
187
- function props_invalid_value(key) {
188
- throw new Error(`https://svelte.dev/e/props_invalid_value`);
189
- }
190
- /**
191
- * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
192
- * @returns {never}
193
- */
194
- function state_descriptors_fixed() {
195
- throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
196
- }
197
- /**
198
- * Cannot set prototype of `$state` object
199
- * @returns {never}
200
- */
201
- function state_prototype_fixed() {
202
- throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
203
- }
204
- /**
205
- * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
206
- * @returns {never}
207
- */
208
- function state_unsafe_mutation() {
209
- throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
210
- }
211
- /**
212
- * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
213
- * @returns {never}
214
- */
215
- function svelte_boundary_reset_onerror() {
216
- throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
217
- }
218
132
  /**
219
133
  * Reading a derived belonging to a now-destroyed effect may result in stale values
220
134
  */
@@ -235,7 +149,7 @@ function svelte_boundary_reset_noop() {
235
149
  console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
236
150
  }
237
151
  //#endregion
238
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/hydration.js
152
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/hydration.js
239
153
  /** @import { TemplateNode } from '#client' */
240
154
  /**
241
155
  * Use this variable to guard everything related to hydration code so it can be treeshaken out
@@ -314,7 +228,7 @@ function read_hydration_instruction(node) {
314
228
  return node.data;
315
229
  }
316
230
  //#endregion
317
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/equality.js
231
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/equality.js
318
232
  /** @import { Equals } from '#client' */
319
233
  /** @type {Equals} */
320
234
  function equals(value) {
@@ -333,13 +247,105 @@ function safe_equals(value) {
333
247
  return !safe_not_equal(value, this.v);
334
248
  }
335
249
  //#endregion
336
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/flags/index.js
250
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/errors.js
251
+ /**
252
+ * Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
253
+ * @returns {never}
254
+ */
255
+ function async_derived_orphan() {
256
+ throw new Error(`https://svelte.dev/e/async_derived_orphan`);
257
+ }
258
+ /**
259
+ * Keyed each block has duplicate key `%value%` at indexes %a% and %b%
260
+ * @param {string} a
261
+ * @param {string} b
262
+ * @param {string | undefined | null} [value]
263
+ * @returns {never}
264
+ */
265
+ function each_key_duplicate(a, b, value) {
266
+ throw new Error(`https://svelte.dev/e/each_key_duplicate`);
267
+ }
268
+ /**
269
+ * `%rune%` cannot be used inside an effect cleanup function
270
+ * @param {string} rune
271
+ * @returns {never}
272
+ */
273
+ function effect_in_teardown(rune) {
274
+ throw new Error(`https://svelte.dev/e/effect_in_teardown`);
275
+ }
276
+ /**
277
+ * Effect cannot be created inside a `$derived` value that was not itself created inside an effect
278
+ * @returns {never}
279
+ */
280
+ function effect_in_unowned_derived() {
281
+ throw new Error(`https://svelte.dev/e/effect_in_unowned_derived`);
282
+ }
283
+ /**
284
+ * `%rune%` can only be used inside an effect (e.g. during component initialisation)
285
+ * @param {string} rune
286
+ * @returns {never}
287
+ */
288
+ function effect_orphan(rune) {
289
+ throw new Error(`https://svelte.dev/e/effect_orphan`);
290
+ }
291
+ /**
292
+ * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
293
+ * @returns {never}
294
+ */
295
+ function effect_update_depth_exceeded() {
296
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
297
+ }
298
+ /**
299
+ * Failed to hydrate the application
300
+ * @returns {never}
301
+ */
302
+ function hydration_failed() {
303
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
304
+ }
305
+ /**
306
+ * Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
307
+ * @param {string} key
308
+ * @returns {never}
309
+ */
310
+ function props_invalid_value(key) {
311
+ throw new Error(`https://svelte.dev/e/props_invalid_value`);
312
+ }
313
+ /**
314
+ * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
315
+ * @returns {never}
316
+ */
317
+ function state_descriptors_fixed() {
318
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
319
+ }
320
+ /**
321
+ * Cannot set prototype of `$state` object
322
+ * @returns {never}
323
+ */
324
+ function state_prototype_fixed() {
325
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
326
+ }
327
+ /**
328
+ * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
329
+ * @returns {never}
330
+ */
331
+ function state_unsafe_mutation() {
332
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
333
+ }
334
+ /**
335
+ * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
336
+ * @returns {never}
337
+ */
338
+ function svelte_boundary_reset_onerror() {
339
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
340
+ }
341
+ //#endregion
342
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/flags/index.js
337
343
  /** True if experimental.async=true */
338
344
  var async_mode_flag = false;
339
345
  /** True if we're not certain that we only have Svelte 5 code in the compilation */
340
346
  var legacy_mode_flag = false;
341
347
  //#endregion
342
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/context.js
348
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/context.js
343
349
  /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
344
350
  /** @type {ComponentContext | null} */
345
351
  var component_context = null;
@@ -384,14 +390,22 @@ function pop(component) {
384
390
  if (component !== void 0) context.x = component;
385
391
  context.i = true;
386
392
  component_context = context.p;
387
- return component ?? {};
393
+ return mark_as_component(component);
394
+ }
395
+ /**
396
+ * Add a symbol to the object (or create one if undefined) to mark it as a component so it isn't proxified.
397
+ * @param {any} component
398
+ */
399
+ function mark_as_component(component = {}) {
400
+ define_property(component, COMPONENT_SYMBOL, { value: true });
401
+ return component;
388
402
  }
389
403
  /** @returns {boolean} */
390
404
  function is_runes() {
391
405
  return !legacy_mode_flag || component_context !== null && component_context.l === null;
392
406
  }
393
407
  //#endregion
394
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/task.js
408
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/task.js
395
409
  /** @type {Array<() => void>} */
396
410
  var micro_tasks = [];
397
411
  function run_micro_tasks() {
@@ -417,39 +431,8 @@ function queue_micro_task(fn) {
417
431
  function flush_tasks() {
418
432
  while (micro_tasks.length > 0) run_micro_tasks();
419
433
  }
420
- /**
421
- * @param {unknown} error
422
- */
423
- function handle_error(error) {
424
- var effect = active_effect;
425
- if (effect === null) {
426
- /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
427
- return error;
428
- }
429
- if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
430
- invoke_error_boundary(error, effect);
431
- }
432
- /**
433
- * @param {unknown} error
434
- * @param {Effect | null} effect
435
- */
436
- function invoke_error_boundary(error, effect) {
437
- while (effect !== null) {
438
- if ((effect.f & 128) !== 0) {
439
- if ((effect.f & 32768) === 0) throw error;
440
- try {
441
- /** @type {Boundary} */ effect.b.error(error);
442
- return;
443
- } catch (e) {
444
- error = e;
445
- }
446
- }
447
- effect = effect.parent;
448
- }
449
- throw error;
450
- }
451
434
  //#endregion
452
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/status.js
435
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/status.js
453
436
  /** @import { Derived, Signal } from '#client' */
454
437
  var STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
455
438
  /**
@@ -468,7 +451,7 @@ function update_derived_status(derived) {
468
451
  else set_signal_status(derived, MAYBE_DIRTY);
469
452
  }
470
453
  //#endregion
471
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/utils.js
454
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/utils.js
472
455
  /** @import { Derived, Effect, Value } from '#client' */
473
456
  /**
474
457
  * @param {Value[] | null} deps
@@ -496,7 +479,7 @@ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
496
479
  set_signal_status(effect, CLEAN);
497
480
  }
498
481
  //#endregion
499
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/store.js
482
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/store.js
500
483
  /**
501
484
  * We set this to `true` when updating a store so that we correctly
502
485
  * schedule effects if the update takes place inside a `$:` effect
@@ -526,1375 +509,1063 @@ function capture_store_binding(fn) {
526
509
  }
527
510
  }
528
511
  //#endregion
529
- //#region \0@oxc-project+runtime@0.129.0/helpers/checkPrivateRedeclaration.js
530
- function _checkPrivateRedeclaration(e, t) {
531
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
532
- }
533
- //#endregion
534
- //#region \0@oxc-project+runtime@0.129.0/helpers/classPrivateMethodInitSpec.js
535
- function _classPrivateMethodInitSpec(e, a) {
536
- _checkPrivateRedeclaration(e, a), a.add(e);
537
- }
538
- //#endregion
539
- //#region \0@oxc-project+runtime@0.129.0/helpers/classPrivateFieldInitSpec.js
540
- function _classPrivateFieldInitSpec(e, t, a) {
541
- _checkPrivateRedeclaration(e, t), t.set(e, a);
542
- }
543
- //#endregion
544
- //#region \0@oxc-project+runtime@0.129.0/helpers/assertClassBrand.js
545
- function _assertClassBrand(e, t, n) {
546
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
547
- throw new TypeError("Private element is not present on this object");
548
- }
549
- //#endregion
550
- //#region \0@oxc-project+runtime@0.129.0/helpers/classPrivateFieldGet2.js
551
- function _classPrivateFieldGet2(s, a) {
552
- return s.get(_assertClassBrand(s, a));
553
- }
554
- //#endregion
555
- //#region \0@oxc-project+runtime@0.129.0/helpers/classPrivateFieldSet2.js
556
- function _classPrivateFieldSet2(s, a, r) {
557
- return s.set(_assertClassBrand(s, a), r), r;
558
- }
559
- //#endregion
560
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/batch.js
561
- /** @import { Fork } from 'svelte' */
562
- /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
563
- var _Batch;
564
- /** @type {Set<Batch>} */
565
- var batches = /* @__PURE__ */ new Set();
566
- /** @type {Batch | null} */
567
- var current_batch = null;
512
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
568
513
  /**
569
- * When time travelling (i.e. working in one batch, while other batches
570
- * still have ongoing work), we ignore the real values of affected
571
- * signals in favour of their values within the batch
572
- * @type {Map<Value, any> | null}
514
+ * @template T
515
+ * @param {() => T} fn
573
516
  */
574
- var batch_values = null;
575
- /** @type {Effect | null} */
576
- var last_scheduled_effect = null;
577
- var is_flushing_sync = false;
578
- var is_processing = false;
579
- /**
580
- * During traversal, this is an array. Newly created effects are (if not immediately
581
- * executed) pushed to this array, rather than going through the scheduling
582
- * rigamarole that would cause another turn of the flush loop.
583
- * @type {Effect[] | null}
584
- */
585
- var collected_effects = null;
517
+ function without_reactive_context(fn) {
518
+ var previous_reaction = active_reaction;
519
+ var previous_effect = active_effect;
520
+ set_active_reaction(null);
521
+ set_active_effect(null);
522
+ try {
523
+ return fn();
524
+ } finally {
525
+ set_active_reaction(previous_reaction);
526
+ set_active_effect(previous_effect);
527
+ }
528
+ }
529
+ //#endregion
530
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/async.js
531
+ /** @import { Blocker, Effect, Source, Value } from '#client' */
586
532
  /**
587
- * An array of effects that are marked during traversal as a result of a `set`
588
- * (not `internal_set`) call. These will be added to the next batch and
589
- * trigger another `batch.process()`
590
- * @type {Effect[] | null}
591
- * @deprecated when we get rid of legacy mode and stores, we can get rid of this
533
+ * @param {Blocker[]} blockers
534
+ * @param {Array<() => any>} sync
535
+ * @param {Array<() => Promise<any>>} async
536
+ * @param {(values: Value[]) => any} fn
592
537
  */
593
- var legacy_updates = null;
594
- var flush_count = 0;
595
- var uid = 1;
596
- var _commit_callbacks = /* @__PURE__ */ new WeakMap();
597
- var _discard_callbacks = /* @__PURE__ */ new WeakMap();
598
- var _fork_commit_callbacks = /* @__PURE__ */ new WeakMap();
599
- var _pending = /* @__PURE__ */ new WeakMap();
600
- var _blocking_pending = /* @__PURE__ */ new WeakMap();
601
- var _deferred = /* @__PURE__ */ new WeakMap();
602
- var _roots = /* @__PURE__ */ new WeakMap();
603
- var _new_effects = /* @__PURE__ */ new WeakMap();
604
- var _dirty_effects$1 = /* @__PURE__ */ new WeakMap();
605
- var _maybe_dirty_effects$1 = /* @__PURE__ */ new WeakMap();
606
- var _skipped_branches = /* @__PURE__ */ new WeakMap();
607
- var _unskipped_branches = /* @__PURE__ */ new WeakMap();
608
- var _decrement_queued = /* @__PURE__ */ new WeakMap();
609
- var _blockers = /* @__PURE__ */ new WeakMap();
610
- var _Batch_brand = /* @__PURE__ */ new WeakSet();
611
- var Batch = class Batch {
612
- constructor() {
613
- _classPrivateMethodInitSpec(this, _Batch_brand);
614
- _defineProperty(this, "id", uid++);
615
- _defineProperty(
616
- this,
617
- /**
618
- * The current values of any signals that are updated in this batch.
619
- * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
620
- * They keys of this map are identical to `this.#previous`
621
- * @type {Map<Value, [any, boolean]>}
622
- */
623
- "current",
624
- /* @__PURE__ */ new Map()
625
- );
626
- _defineProperty(
627
- this,
628
- /**
629
- * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
630
- * They keys of this map are identical to `this.#current`
631
- * @type {Map<Value, any>}
632
- */
633
- "previous",
634
- /* @__PURE__ */ new Map()
635
- );
636
- _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
637
- _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
638
- _classPrivateFieldInitSpec(this, _fork_commit_callbacks, /* @__PURE__ */ new Set());
639
- _classPrivateFieldInitSpec(this, _pending, /* @__PURE__ */ new Map());
640
- _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
641
- _classPrivateFieldInitSpec(this, _deferred, null);
642
- _classPrivateFieldInitSpec(this, _roots, []);
643
- _classPrivateFieldInitSpec(this, _new_effects, []);
644
- _classPrivateFieldInitSpec(this, _dirty_effects$1, /* @__PURE__ */ new Set());
645
- _classPrivateFieldInitSpec(this, _maybe_dirty_effects$1, /* @__PURE__ */ new Set());
646
- _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
647
- _classPrivateFieldInitSpec(this, _unskipped_branches, /* @__PURE__ */ new Set());
648
- _defineProperty(this, "is_fork", false);
649
- _classPrivateFieldInitSpec(this, _decrement_queued, false);
650
- _classPrivateFieldInitSpec(this, _blockers, /* @__PURE__ */ new Set());
651
- }
652
- /**
653
- * Add an effect to the #skipped_branches map and reset its children
654
- * @param {Effect} effect
655
- */
656
- skip_effect(effect) {
657
- if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
658
- d: [],
659
- m: []
660
- });
661
- _classPrivateFieldGet2(_unskipped_branches, this).delete(effect);
662
- }
663
- /**
664
- * Remove an effect from the #skipped_branches map and reschedule
665
- * any tracked dirty/maybe_dirty child effects
666
- * @param {Effect} effect
667
- * @param {(e: Effect) => void} callback
668
- */
669
- unskip_effect(effect, callback = (e) => this.schedule(e)) {
670
- var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
671
- if (tracked) {
672
- _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
673
- for (var e of tracked.d) {
674
- set_signal_status(e, DIRTY);
675
- callback(e);
676
- }
677
- for (e of tracked.m) {
678
- set_signal_status(e, MAYBE_DIRTY);
679
- callback(e);
680
- }
681
- }
682
- _classPrivateFieldGet2(_unskipped_branches, this).add(effect);
538
+ function flatten(blockers, sync, async, fn) {
539
+ const d = is_runes() ? derived : derived_safe_equal;
540
+ var pending = blockers.filter((b) => !b.settled);
541
+ var deriveds = sync.map(d);
542
+ if (async.length === 0 && pending.length === 0) {
543
+ fn(deriveds);
544
+ return;
683
545
  }
546
+ var parent = active_effect;
547
+ var restore = capture();
548
+ var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b) => b.promise)) : null;
684
549
  /**
685
- * Associate a change to a given source with the current
686
- * batch, noting its previous and current values
687
- * @param {Value} source
688
- * @param {any} value
689
- * @param {boolean} [is_derived]
550
+ * @param {Source[]} async
690
551
  */
691
- capture(source, value, is_derived = false) {
692
- if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
693
- if ((source.f & 8388608) === 0) {
694
- this.current.set(source, [value, is_derived]);
695
- batch_values?.set(source, value);
696
- }
697
- if (!this.is_fork) source.v = value;
698
- }
699
- activate() {
700
- current_batch = this;
701
- }
702
- deactivate() {
703
- current_batch = null;
704
- batch_values = null;
705
- }
706
- flush() {
552
+ function finish(async) {
553
+ if ((parent.f & 16384) !== 0) return;
554
+ restore();
707
555
  try {
708
- is_processing = true;
709
- current_batch = this;
710
- _assertClassBrand(_Batch_brand, this, _process).call(this);
711
- } finally {
712
- flush_count = 0;
713
- last_scheduled_effect = null;
714
- collected_effects = null;
715
- legacy_updates = null;
716
- is_processing = false;
717
- current_batch = null;
718
- batch_values = null;
719
- old_values.clear();
720
- }
721
- }
722
- discard() {
723
- for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
724
- _classPrivateFieldGet2(_discard_callbacks, this).clear();
725
- _classPrivateFieldGet2(_fork_commit_callbacks, this).clear();
726
- batches.delete(this);
727
- }
728
- /**
729
- * @param {Effect} effect
730
- */
731
- register_created_effect(effect) {
732
- _classPrivateFieldGet2(_new_effects, this).push(effect);
733
- }
734
- /**
735
- * @param {boolean} blocking
736
- * @param {Effect} effect
737
- */
738
- increment(blocking, effect) {
739
- let pending_count = _classPrivateFieldGet2(_pending, this).get(effect) ?? 0;
740
- _classPrivateFieldGet2(_pending, this).set(effect, pending_count + 1);
741
- if (blocking) {
742
- let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
743
- _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count + 1);
744
- }
745
- }
746
- /**
747
- * @param {boolean} blocking
748
- * @param {Effect} effect
749
- * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
750
- */
751
- decrement(blocking, effect, skip) {
752
- let pending_count = _classPrivateFieldGet2(_pending, this).get(effect) ?? 0;
753
- if (pending_count === 1) _classPrivateFieldGet2(_pending, this).delete(effect);
754
- else _classPrivateFieldGet2(_pending, this).set(effect, pending_count - 1);
755
- if (blocking) {
756
- let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
757
- if (blocking_pending_count === 1) _classPrivateFieldGet2(_blocking_pending, this).delete(effect);
758
- else _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count - 1);
556
+ fn([...deriveds, ...async]);
557
+ } catch (error) {
558
+ invoke_error_boundary(error, parent);
759
559
  }
760
- if (_classPrivateFieldGet2(_decrement_queued, this) || skip) return;
761
- _classPrivateFieldSet2(_decrement_queued, this, true);
762
- queue_micro_task(() => {
763
- _classPrivateFieldSet2(_decrement_queued, this, false);
764
- this.flush();
765
- });
766
- }
767
- /**
768
- * @param {Set<Effect>} dirty_effects
769
- * @param {Set<Effect>} maybe_dirty_effects
770
- */
771
- transfer_effects(dirty_effects, maybe_dirty_effects) {
772
- for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects$1, this).add(e);
773
- for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(e);
774
- dirty_effects.clear();
775
- maybe_dirty_effects.clear();
776
- }
777
- /** @param {(batch: Batch) => void} fn */
778
- oncommit(fn) {
779
- _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
780
- }
781
- /** @param {(batch: Batch) => void} fn */
782
- ondiscard(fn) {
783
- _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
784
- }
785
- /** @param {(batch: Batch) => void} fn */
786
- on_fork_commit(fn) {
787
- _classPrivateFieldGet2(_fork_commit_callbacks, this).add(fn);
788
- }
789
- run_fork_commit_callbacks() {
790
- for (const fn of _classPrivateFieldGet2(_fork_commit_callbacks, this)) fn(this);
791
- _classPrivateFieldGet2(_fork_commit_callbacks, this).clear();
560
+ unset_context();
792
561
  }
793
- settled() {
794
- return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
562
+ var decrement_pending = increment_pending();
563
+ if (async.length === 0) {
564
+ /** @type {Promise<any>} */ blocker_promise.then(() => finish([])).finally(decrement_pending);
565
+ return;
795
566
  }
796
- static ensure() {
797
- if (current_batch === null) {
798
- const batch = current_batch = new Batch();
799
- if (!is_processing) {
800
- batches.add(current_batch);
801
- if (!is_flushing_sync) queue_micro_task(() => {
802
- if (current_batch !== batch) return;
803
- batch.flush();
804
- });
805
- }
806
- }
807
- return current_batch;
567
+ function run() {
568
+ Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then(finish).catch((error) => invoke_error_boundary(error, parent)).finally(decrement_pending);
808
569
  }
809
- apply() {
810
- if (!async_mode_flag || !this.is_fork && batches.size === 1) {
811
- batch_values = null;
812
- return;
570
+ if (blocker_promise) blocker_promise.then(() => {
571
+ restore();
572
+ run();
573
+ unset_context();
574
+ });
575
+ else run();
576
+ }
577
+ /**
578
+ * Captures the current effect context so that we can restore it after
579
+ * some asynchronous work has happened (so that e.g. `await a + b`
580
+ * causes `b` to be registered as a dependency).
581
+ */
582
+ function capture() {
583
+ var previous_effect = active_effect;
584
+ var previous_reaction = active_reaction;
585
+ var previous_component_context = component_context;
586
+ var previous_batch = current_batch;
587
+ return function restore(activate_batch = true) {
588
+ set_active_effect(previous_effect);
589
+ set_active_reaction(previous_reaction);
590
+ set_component_context(previous_component_context);
591
+ if (activate_batch && (previous_effect.f & 16384) === 0) {
592
+ previous_batch?.activate();
593
+ previous_batch?.apply();
813
594
  }
814
- batch_values = /* @__PURE__ */ new Map();
815
- for (const [source, [value]] of this.current) batch_values.set(source, value);
816
- for (const batch of batches) {
817
- if (batch === this || batch.is_fork) continue;
818
- var intersects = false;
819
- var differs = false;
820
- if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
821
- if (is_derived) continue;
822
- intersects || (intersects = this.current.has(source));
823
- differs || (differs = !this.current.has(source));
824
- }
825
- if (intersects && differs) _classPrivateFieldGet2(_blockers, this).add(batch);
826
- else for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
827
- }
828
- }
829
- /**
830
- *
831
- * @param {Effect} effect
832
- */
833
- schedule(effect) {
834
- last_scheduled_effect = effect;
835
- if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
836
- effect.b.defer_effect(effect);
837
- return;
838
- }
839
- var e = effect;
840
- while (e.parent !== null) {
841
- e = e.parent;
842
- var flags = e.f;
843
- if (collected_effects !== null && e === active_effect) {
844
- if (async_mode_flag) return;
845
- if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
846
- }
847
- if ((flags & 96) !== 0) {
848
- if ((flags & 1024) === 0) return;
849
- e.f ^= CLEAN;
850
- }
851
- }
852
- _classPrivateFieldGet2(_roots, this).push(e);
853
- }
854
- };
855
- _Batch = Batch;
856
- function _is_deferred() {
857
- return this.is_fork || _classPrivateFieldGet2(_blocking_pending, this).size > 0;
858
- }
859
- function _is_blocked() {
860
- for (const batch of _classPrivateFieldGet2(_blockers, this)) for (const effect of _classPrivateFieldGet2(_blocking_pending, batch).keys()) {
861
- var skipped = false;
862
- var e = effect;
863
- while (e.parent !== null) {
864
- if (_classPrivateFieldGet2(_skipped_branches, this).has(e)) {
865
- skipped = true;
866
- break;
867
- }
868
- e = e.parent;
869
- }
870
- if (!skipped) return true;
871
- }
872
- return false;
595
+ };
873
596
  }
874
- function _process() {
875
- if (flush_count++ > 1e3) {
876
- batches.delete(this);
877
- infinite_loop_guard();
878
- }
879
- if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
880
- for (const e of _classPrivateFieldGet2(_dirty_effects$1, this)) {
881
- _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(e);
882
- set_signal_status(e, DIRTY);
883
- this.schedule(e);
884
- }
885
- for (const e of _classPrivateFieldGet2(_maybe_dirty_effects$1, this)) {
886
- set_signal_status(e, MAYBE_DIRTY);
887
- this.schedule(e);
888
- }
889
- }
890
- const roots = _classPrivateFieldGet2(_roots, this);
891
- _classPrivateFieldSet2(_roots, this, []);
892
- this.apply();
893
- /** @type {Effect[]} */
894
- var effects = collected_effects = [];
895
- /** @type {Effect[]} */
896
- var render_effects = [];
897
- /**
898
- * @type {Effect[]}
899
- * @deprecated when we get rid of legacy mode and stores, we can get rid of this
900
- */
901
- var updates = legacy_updates = [];
902
- for (const root of roots) try {
903
- _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
904
- } catch (e) {
905
- reset_all(root);
906
- throw e;
907
- }
908
- current_batch = null;
909
- if (updates.length > 0) {
910
- var batch = _Batch.ensure();
911
- for (const e of updates) batch.schedule(e);
912
- }
913
- collected_effects = null;
914
- legacy_updates = null;
915
- if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this) || _assertClassBrand(_Batch_brand, this, _is_blocked).call(this)) {
916
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
917
- _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
918
- for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
919
- } else {
920
- if (_classPrivateFieldGet2(_pending, this).size === 0) batches.delete(this);
921
- _classPrivateFieldGet2(_dirty_effects$1, this).clear();
922
- _classPrivateFieldGet2(_maybe_dirty_effects$1, this).clear();
923
- for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
924
- _classPrivateFieldGet2(_commit_callbacks, this).clear();
925
- flush_queued_effects(render_effects);
926
- flush_queued_effects(effects);
927
- _classPrivateFieldGet2(_deferred, this)?.resolve();
928
- }
929
- var next_batch = current_batch;
930
- if (_classPrivateFieldGet2(_roots, this).length > 0) {
931
- const batch = next_batch ?? (next_batch = this);
932
- _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
933
- }
934
- if (next_batch !== null) {
935
- batches.add(next_batch);
936
- _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
937
- }
938
- if (async_mode_flag && !batches.has(this)) _assertClassBrand(_Batch_brand, this, _commit$1).call(this);
597
+ function unset_context(deactivate_batch = true) {
598
+ set_active_effect(null);
599
+ set_active_reaction(null);
600
+ set_component_context(null);
601
+ if (deactivate_batch) current_batch?.deactivate();
939
602
  }
940
603
  /**
941
- * Traverse the effect tree, executing effects or stashing
942
- * them for later execution as appropriate
943
- * @param {Effect} root
944
- * @param {Effect[]} effects
945
- * @param {Effect[]} render_effects
604
+ * @returns {(skip?: boolean) => void}
946
605
  */
947
- function _traverse(root, effects, render_effects) {
948
- root.f ^= CLEAN;
949
- var effect = root.first;
950
- while (effect !== null) {
951
- var flags = effect.f;
952
- var is_branch = (flags & 96) !== 0;
953
- if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
954
- if (is_branch) effect.f ^= CLEAN;
955
- else if ((flags & 4) !== 0) effects.push(effect);
956
- else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
957
- else if (is_dirty(effect)) {
958
- if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(effect);
959
- update_effect(effect);
960
- }
961
- var child = effect.first;
962
- if (child !== null) {
963
- effect = child;
964
- continue;
965
- }
966
- }
967
- while (effect !== null) {
968
- var next = effect.next;
969
- if (next !== null) {
970
- effect = next;
971
- break;
972
- }
973
- effect = effect.parent;
974
- }
975
- }
606
+ function increment_pending() {
607
+ var effect = active_effect;
608
+ var boundary = effect.b;
609
+ var batch = current_batch;
610
+ var blocking = !!boundary?.is_rendered();
611
+ boundary?.update_pending_count(1, batch);
612
+ batch.increment(blocking, effect);
613
+ return () => {
614
+ boundary?.update_pending_count(-1, batch);
615
+ batch.decrement(blocking, effect);
616
+ };
976
617
  }
977
618
  /**
978
- * @param {Effect[]} effects
619
+ * @template V
620
+ * @param {() => V} fn
621
+ * @returns {Derived<V>}
979
622
  */
980
- function _defer_effects(effects) {
981
- for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
623
+ /*#__NO_SIDE_EFFECTS__*/
624
+ function derived(fn) {
625
+ var flags = 2 | DIRTY;
626
+ if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
627
+ return {
628
+ ctx: component_context,
629
+ deps: null,
630
+ effects: null,
631
+ equals,
632
+ f: flags,
633
+ fn,
634
+ reactions: null,
635
+ rv: 0,
636
+ v: UNINITIALIZED,
637
+ wv: 0,
638
+ parent: active_effect,
639
+ ac: null
640
+ };
982
641
  }
983
- function _commit$1() {
984
- for (const batch of batches) {
985
- var is_earlier = batch.id < this.id;
986
- /** @type {Source[]} */
987
- var sources = [];
988
- for (const [source, [value, is_derived]] of this.current) {
989
- if (batch.current.has(source)) {
990
- var batch_value = batch.current.get(source)[0];
991
- if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
992
- else continue;
993
- }
994
- sources.push(source);
642
+ var OBSOLETE = Symbol("obsolete");
643
+ /**
644
+ * @template V
645
+ * @param {() => V | Promise<V>} fn
646
+ * @param {string} [label]
647
+ * @param {string} [location] If provided, print a warning if the value is not read immediately after update
648
+ * @returns {Promise<Source<V>>}
649
+ */
650
+ /*#__NO_SIDE_EFFECTS__*/
651
+ function async_derived(fn, label, location) {
652
+ let parent = active_effect;
653
+ if (parent === null) async_derived_orphan();
654
+ var promise = void 0;
655
+ var signal = source(UNINITIALIZED);
656
+ var should_suspend = !active_reaction;
657
+ /** @type {Set<ReturnType<typeof deferred<V>>>} */
658
+ var deferreds = /* @__PURE__ */ new Set();
659
+ async_effect(() => {
660
+ var effect = active_effect;
661
+ /** @type {ReturnType<typeof deferred<V>>} */
662
+ var d = deferred();
663
+ promise = d.promise;
664
+ try {
665
+ Promise.resolve(fn()).then(d.resolve, (e) => {
666
+ if (e !== STALE_REACTION) d.reject(e);
667
+ }).finally(unset_context);
668
+ } catch (error) {
669
+ d.reject(error);
670
+ unset_context();
995
671
  }
996
- var others = [...batch.current.keys()].filter((s) => !this.current.has(s));
997
- if (others.length === 0) {
998
- if (is_earlier) batch.discard();
999
- } else if (sources.length > 0) {
1000
- if (is_earlier) for (const unskipped of _classPrivateFieldGet2(_unskipped_branches, this)) batch.unskip_effect(unskipped, (e) => {
1001
- if ((e.f & 4194320) !== 0) batch.schedule(e);
1002
- else _assertClassBrand(_Batch_brand, batch, _defer_effects).call(batch, [e]);
1003
- });
672
+ var batch = current_batch;
673
+ if (should_suspend) {
674
+ if ((effect.f & 32768) !== 0) var decrement_pending = increment_pending();
675
+ if (parent.b?.is_rendered()) batch.async_deriveds.get(effect)?.reject(OBSOLETE);
676
+ else for (const d of deferreds.values()) d.reject(OBSOLETE);
677
+ deferreds.add(d);
678
+ batch.async_deriveds.set(effect, d);
679
+ }
680
+ /**
681
+ * @param {any} value
682
+ * @param {unknown} error
683
+ */
684
+ const handler = (value, error = void 0) => {
685
+ decrement_pending?.();
686
+ deferreds.delete(d);
687
+ if (error === OBSOLETE) return;
1004
688
  batch.activate();
1005
- /** @type {Set<Value>} */
1006
- var marked = /* @__PURE__ */ new Set();
1007
- /** @type {Map<Reaction, boolean>} */
1008
- var checked = /* @__PURE__ */ new Map();
1009
- for (var source of sources) mark_effects(source, others, marked, checked);
1010
- checked = /* @__PURE__ */ new Map();
1011
- var current_unequal = [...batch.current.keys()].filter((c) => this.current.has(c) ? this.current.get(c)[0] !== c : true);
1012
- for (const effect of _classPrivateFieldGet2(_new_effects, this)) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1013
- set_signal_status(effect, DIRTY);
1014
- batch.schedule(effect);
1015
- } else _classPrivateFieldGet2(_dirty_effects$1, batch).add(effect);
1016
- if (_classPrivateFieldGet2(_roots, batch).length > 0) {
1017
- batch.apply();
1018
- for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1019
- _classPrivateFieldSet2(_roots, batch, []);
689
+ if (error) {
690
+ signal.f |= ERROR_VALUE;
691
+ internal_set(signal, error);
692
+ } else {
693
+ if ((signal.f & 8388608) !== 0) signal.f ^= ERROR_VALUE;
694
+ internal_set(signal, value);
1020
695
  }
1021
696
  batch.deactivate();
697
+ };
698
+ d.promise.then(handler, (e) => handler(null, e || "unknown"));
699
+ });
700
+ teardown(() => {
701
+ for (const d of deferreds) d.reject(OBSOLETE);
702
+ });
703
+ return new Promise((fulfil) => {
704
+ /** @param {Promise<V>} p */
705
+ function next(p) {
706
+ function go() {
707
+ if (p === promise) fulfil(signal);
708
+ else next(promise);
709
+ }
710
+ p.then(go, go);
1022
711
  }
1023
- }
1024
- for (const batch of batches) if (_classPrivateFieldGet2(_blockers, batch).has(this)) {
1025
- _classPrivateFieldGet2(_blockers, batch).delete(this);
1026
- if (_classPrivateFieldGet2(_blockers, batch).size === 0 && !_assertClassBrand(_Batch_brand, batch, _is_deferred).call(batch)) {
1027
- batch.activate();
1028
- _assertClassBrand(_Batch_brand, batch, _process).call(batch);
1029
- }
1030
- }
712
+ next(promise);
713
+ });
1031
714
  }
1032
715
  /**
1033
- * Synchronously flush any pending updates.
1034
- * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1035
- * @template [T=void]
1036
- * @param {(() => T) | undefined} [fn]
1037
- * @returns {T}
716
+ * @template V
717
+ * @param {() => V} fn
718
+ * @returns {Derived<V>}
1038
719
  */
1039
- function flushSync(fn) {
1040
- var was_flushing_sync = is_flushing_sync;
1041
- is_flushing_sync = true;
1042
- try {
1043
- var result;
1044
- if (fn) {
1045
- if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
1046
- result = fn();
1047
- }
1048
- while (true) {
1049
- flush_tasks();
1050
- if (current_batch === null) return result;
1051
- current_batch.flush();
1052
- }
1053
- } finally {
1054
- is_flushing_sync = was_flushing_sync;
1055
- }
1056
- }
1057
- function infinite_loop_guard() {
1058
- try {
1059
- effect_update_depth_exceeded();
1060
- } catch (error) {
1061
- invoke_error_boundary(error, last_scheduled_effect);
1062
- }
720
+ /*#__NO_SIDE_EFFECTS__*/
721
+ function user_derived(fn) {
722
+ const d = /* @__PURE__ */ derived(fn);
723
+ if (!async_mode_flag) push_reaction_value(d);
724
+ return d;
1063
725
  }
1064
- /** @type {Set<Effect> | null} */
1065
- var eager_block_effects = null;
1066
726
  /**
1067
- * @param {Array<Effect>} effects
1068
- * @returns {void}
727
+ * @template V
728
+ * @param {() => V} fn
729
+ * @returns {Derived<V>}
1069
730
  */
1070
- function flush_queued_effects(effects) {
1071
- var length = effects.length;
1072
- if (length === 0) return;
1073
- var i = 0;
1074
- while (i < length) {
1075
- var effect = effects[i++];
1076
- if ((effect.f & 24576) === 0 && is_dirty(effect)) {
1077
- eager_block_effects = /* @__PURE__ */ new Set();
1078
- update_effect(effect);
1079
- if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
1080
- if (eager_block_effects?.size > 0) {
1081
- old_values.clear();
1082
- for (const e of eager_block_effects) {
1083
- if ((e.f & 24576) !== 0) continue;
1084
- /** @type {Effect[]} */
1085
- const ordered_effects = [e];
1086
- let ancestor = e.parent;
1087
- while (ancestor !== null) {
1088
- if (eager_block_effects.has(ancestor)) {
1089
- eager_block_effects.delete(ancestor);
1090
- ordered_effects.push(ancestor);
1091
- }
1092
- ancestor = ancestor.parent;
1093
- }
1094
- for (let j = ordered_effects.length - 1; j >= 0; j--) {
1095
- const e = ordered_effects[j];
1096
- if ((e.f & 24576) !== 0) continue;
1097
- update_effect(e);
1098
- }
1099
- }
1100
- eager_block_effects.clear();
1101
- }
1102
- }
1103
- }
1104
- eager_block_effects = null;
731
+ /*#__NO_SIDE_EFFECTS__*/
732
+ function derived_safe_equal(fn) {
733
+ const signal = /* @__PURE__ */ derived(fn);
734
+ signal.equals = safe_equals;
735
+ return signal;
1105
736
  }
1106
737
  /**
1107
- * This is similar to `mark_reactions`, but it only marks async/block effects
1108
- * depending on `value` and at least one of the other `sources`, so that
1109
- * these effects can re-run after another batch has been committed
1110
- * @param {Value} value
1111
- * @param {Source[]} sources
1112
- * @param {Set<Value>} marked
1113
- * @param {Map<Reaction, boolean>} checked
738
+ * @param {Derived} derived
739
+ * @returns {void}
1114
740
  */
1115
- function mark_effects(value, sources, marked, checked) {
1116
- if (marked.has(value)) return;
1117
- marked.add(value);
1118
- if (value.reactions !== null) for (const reaction of value.reactions) {
1119
- const flags = reaction.f;
1120
- if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
1121
- else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
1122
- set_signal_status(reaction, DIRTY);
1123
- schedule_effect(reaction);
1124
- }
741
+ function destroy_derived_effects(derived) {
742
+ var effects = derived.effects;
743
+ if (effects !== null) {
744
+ derived.effects = null;
745
+ for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1125
746
  }
1126
747
  }
1127
748
  /**
1128
- * @param {Reaction} reaction
1129
- * @param {Source[]} sources
1130
- * @param {Map<Reaction, boolean>} checked
749
+ * @template T
750
+ * @param {Derived} derived
751
+ * @returns {T}
1131
752
  */
1132
- function depends_on(reaction, sources, checked) {
1133
- const depends = checked.get(reaction);
1134
- if (depends !== void 0) return depends;
1135
- if (reaction.deps !== null) for (const dep of reaction.deps) {
1136
- if (includes.call(sources, dep)) return true;
1137
- if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
1138
- checked.set(dep, true);
1139
- return true;
1140
- }
753
+ function execute_derived(derived) {
754
+ var value;
755
+ var prev_active_effect = active_effect;
756
+ var parent = derived.parent;
757
+ if (!is_destroying_effect && parent !== null && derived.v !== UNINITIALIZED && (parent.f & 24576) !== 0) {
758
+ derived_inert();
759
+ return derived.v;
1141
760
  }
1142
- checked.set(reaction, false);
1143
- return false;
761
+ set_active_effect(parent);
762
+ try {
763
+ derived.f &= ~WAS_MARKED;
764
+ destroy_derived_effects(derived);
765
+ value = update_reaction(derived);
766
+ } finally {
767
+ set_active_effect(prev_active_effect);
768
+ }
769
+ return value;
1144
770
  }
1145
771
  /**
1146
- * @param {Effect} effect
772
+ * @param {Derived} derived
1147
773
  * @returns {void}
1148
774
  */
1149
- function schedule_effect(effect) {
1150
- /** @type {Batch} */ current_batch.schedule(effect);
775
+ function update_derived(derived) {
776
+ var value = execute_derived(derived);
777
+ if (!derived.equals(value)) {
778
+ derived.wv = increment_write_version();
779
+ if (!current_batch?.is_fork || derived.deps === null) {
780
+ if (current_batch !== null) {
781
+ current_batch.capture(derived, value, true);
782
+ previous_batch?.capture(derived, value, true);
783
+ } else derived.v = value;
784
+ if (derived.deps === null) {
785
+ set_signal_status(derived, CLEAN);
786
+ return;
787
+ }
788
+ }
789
+ }
790
+ if (is_destroying_effect) return;
791
+ if (batch_values !== null) {
792
+ if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
793
+ } else update_derived_status(derived);
1151
794
  }
1152
795
  /**
1153
- * Mark all the effects inside a skipped branch CLEAN, so that
1154
- * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1155
- * effects so they can be rescheduled if the branch survives.
1156
- * @param {Effect} effect
1157
- * @param {{ d: Effect[], m: Effect[] }} tracked
796
+ * @param {Derived} derived
1158
797
  */
1159
- function reset_branch(effect, tracked) {
1160
- if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1161
- if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1162
- else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1163
- set_signal_status(effect, CLEAN);
1164
- var e = effect.first;
1165
- while (e !== null) {
1166
- reset_branch(e, tracked);
1167
- e = e.next;
798
+ function freeze_derived_effects(derived) {
799
+ if (derived.effects === null) return;
800
+ for (const e of derived.effects) if (e.teardown || e.ac) {
801
+ e.teardown?.();
802
+ if (e.ac !== null) without_reactive_context(() => {
803
+ /** @type {AbortController} */ e.ac.abort(STALE_REACTION);
804
+ e.ac = null;
805
+ });
806
+ if (e.fn !== null) e.teardown = noop;
807
+ remove_reactions(e, 0);
808
+ destroy_effect_children(e);
1168
809
  }
1169
810
  }
1170
811
  /**
1171
- * Mark an entire effect tree clean following an error
1172
- * @param {Effect} effect
812
+ * @param {Derived} derived
1173
813
  */
1174
- function reset_all(effect) {
1175
- set_signal_status(effect, CLEAN);
1176
- var e = effect.first;
1177
- while (e !== null) {
1178
- reset_all(e);
1179
- e = e.next;
1180
- }
814
+ function unfreeze_derived_effects(derived) {
815
+ if (derived.effects === null) return;
816
+ for (const e of derived.effects) if (e.teardown && e.fn !== null) update_effect(e);
1181
817
  }
1182
818
  //#endregion
1183
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/reactivity/create-subscriber.js
1184
- /**
1185
- * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
1186
- * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
1187
- *
1188
- * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
1189
- * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
1190
- *
1191
- * If `start` returns a cleanup function, it will be called when the effect is destroyed.
1192
- *
1193
- * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
1194
- * are active, and the returned teardown function will only be called when all effects are destroyed.
1195
- *
1196
- * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
1197
- *
1198
- * ```js
1199
- * import { createSubscriber } from 'svelte/reactivity';
1200
- * import { on } from 'svelte/events';
1201
- *
1202
- * export class MediaQuery {
1203
- * #query;
1204
- * #subscribe;
1205
- *
1206
- * constructor(query) {
1207
- * this.#query = window.matchMedia(`(${query})`);
1208
- *
1209
- * this.#subscribe = createSubscriber((update) => {
1210
- * // when the `change` event occurs, re-run any effects that read `this.current`
1211
- * const off = on(this.#query, 'change', update);
1212
- *
1213
- * // stop listening when all the effects are destroyed
1214
- * return () => off();
1215
- * });
1216
- * }
1217
- *
1218
- * get current() {
1219
- * // This makes the getter reactive, if read in an effect
1220
- * this.#subscribe();
1221
- *
1222
- * // Return the current state of the query, whether or not we're in an effect
1223
- * return this.#query.matches;
1224
- * }
1225
- * }
1226
- * ```
1227
- * @param {(update: () => void) => (() => void) | void} start
1228
- * @since 5.7.0
1229
- */
1230
- function createSubscriber(start) {
1231
- let subscribers = 0;
1232
- let version = source(0);
1233
- /** @type {(() => void) | void} */
1234
- let stop;
1235
- return () => {
1236
- if (effect_tracking()) {
1237
- get(version);
1238
- render_effect(() => {
1239
- if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
1240
- subscribers += 1;
1241
- return () => {
1242
- queue_micro_task(() => {
1243
- subscribers -= 1;
1244
- if (subscribers === 0) {
1245
- stop?.();
1246
- stop = void 0;
1247
- increment(version);
1248
- }
1249
- });
1250
- };
1251
- });
1252
- }
1253
- };
819
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/checkPrivateRedeclaration.js
820
+ function _checkPrivateRedeclaration(e, t) {
821
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
1254
822
  }
1255
823
  //#endregion
1256
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
1257
- /** @import { Effect, Source, TemplateNode, } from '#client' */
1258
- /**
1259
- * @typedef {{
1260
- * onerror?: (error: unknown, reset: () => void) => void;
1261
- * failed?: (anchor: Node, error: () => unknown, reset: () => () => void) => void;
1262
- * pending?: (anchor: Node) => void;
1263
- * }} BoundaryProps
824
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateMethodInitSpec.js
825
+ function _classPrivateMethodInitSpec(e, a) {
826
+ _checkPrivateRedeclaration(e, a), a.add(e);
827
+ }
828
+ //#endregion
829
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldInitSpec.js
830
+ function _classPrivateFieldInitSpec(e, t, a) {
831
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
832
+ }
833
+ //#endregion
834
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/assertClassBrand.js
835
+ function _assertClassBrand(e, t, n) {
836
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
837
+ throw new TypeError("Private element is not present on this object");
838
+ }
839
+ //#endregion
840
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldSet2.js
841
+ function _classPrivateFieldSet2(s, a, r) {
842
+ return s.set(_assertClassBrand(s, a), r), r;
843
+ }
844
+ //#endregion
845
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/classPrivateFieldGet2.js
846
+ function _classPrivateFieldGet2(s, a) {
847
+ return s.get(_assertClassBrand(s, a));
848
+ }
849
+ //#endregion
850
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/batch.js
851
+ /** @import { Fork } from 'svelte' */
852
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
853
+ var _Batch;
854
+ /** @type {Batch | null} */
855
+ var first_batch = null;
856
+ /** @type {Batch | null} */
857
+ var last_batch = null;
858
+ /** @type {Batch | null} */
859
+ var current_batch = null;
860
+ /**
861
+ * This is needed to avoid overwriting inputs
862
+ * @type {Batch | null}
1264
863
  */
1265
- var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
864
+ var previous_batch = null;
1266
865
  /**
1267
- * @param {TemplateNode} node
1268
- * @param {BoundaryProps} props
1269
- * @param {((anchor: Node) => void)} children
1270
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
1271
- * @returns {void}
866
+ * When time travelling (i.e. working in one batch, while other batches
867
+ * still have ongoing work), we ignore the real values of affected
868
+ * signals in favour of their values within the batch
869
+ * @type {Map<Value, any> | null}
1272
870
  */
1273
- function boundary(node, props, children, transform_error) {
1274
- new Boundary(node, props, children, transform_error);
1275
- }
1276
- var _anchor = /* @__PURE__ */ new WeakMap();
1277
- var _hydrate_open = /* @__PURE__ */ new WeakMap();
1278
- var _props = /* @__PURE__ */ new WeakMap();
1279
- var _children = /* @__PURE__ */ new WeakMap();
1280
- var _effect = /* @__PURE__ */ new WeakMap();
1281
- var _main_effect = /* @__PURE__ */ new WeakMap();
1282
- var _pending_effect = /* @__PURE__ */ new WeakMap();
1283
- var _failed_effect = /* @__PURE__ */ new WeakMap();
1284
- var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
1285
- var _local_pending_count = /* @__PURE__ */ new WeakMap();
1286
- var _pending_count = /* @__PURE__ */ new WeakMap();
1287
- var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
1288
- var _dirty_effects = /* @__PURE__ */ new WeakMap();
1289
- var _maybe_dirty_effects = /* @__PURE__ */ new WeakMap();
1290
- var _effect_pending = /* @__PURE__ */ new WeakMap();
1291
- var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
1292
- var _Boundary_brand = /* @__PURE__ */ new WeakSet();
1293
- var Boundary = class {
1294
- /**
1295
- * @param {TemplateNode} node
1296
- * @param {BoundaryProps} props
1297
- * @param {((anchor: Node) => void)} children
1298
- * @param {((error: unknown) => unknown) | undefined} [transform_error]
1299
- */
1300
- constructor(node, props, children, transform_error) {
1301
- _classPrivateMethodInitSpec(this, _Boundary_brand);
871
+ var batch_values = null;
872
+ /** @type {Effect | null} */
873
+ var last_scheduled_effect = null;
874
+ var is_flushing_sync = false;
875
+ var is_processing = false;
876
+ /**
877
+ * During traversal, this is an array. Newly created effects are (if not immediately
878
+ * executed) pushed to this array, rather than going through the scheduling
879
+ * rigamarole that would cause another turn of the flush loop.
880
+ * @type {Effect[] | null}
881
+ */
882
+ var collected_effects = null;
883
+ /**
884
+ * An array of effects that are marked during traversal as a result of a `set`
885
+ * (not `internal_set`) call. These will be added to the next batch and
886
+ * trigger another `batch.process()`
887
+ * @type {Effect[] | null}
888
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
889
+ */
890
+ var legacy_updates = null;
891
+ var flush_count = 0;
892
+ var uid = 1;
893
+ var _started = /* @__PURE__ */ new WeakMap();
894
+ var _prev = /* @__PURE__ */ new WeakMap();
895
+ var _next = /* @__PURE__ */ new WeakMap();
896
+ var _commit_callbacks = /* @__PURE__ */ new WeakMap();
897
+ var _discard_callbacks = /* @__PURE__ */ new WeakMap();
898
+ var _pending = /* @__PURE__ */ new WeakMap();
899
+ var _blocking_pending = /* @__PURE__ */ new WeakMap();
900
+ var _deferred = /* @__PURE__ */ new WeakMap();
901
+ var _roots = /* @__PURE__ */ new WeakMap();
902
+ var _new_effects = /* @__PURE__ */ new WeakMap();
903
+ var _dirty_effects$1 = /* @__PURE__ */ new WeakMap();
904
+ var _maybe_dirty_effects$1 = /* @__PURE__ */ new WeakMap();
905
+ var _skipped_branches = /* @__PURE__ */ new WeakMap();
906
+ var _unskipped_branches = /* @__PURE__ */ new WeakMap();
907
+ var _decrement_queued = /* @__PURE__ */ new WeakMap();
908
+ var _Batch_brand = /* @__PURE__ */ new WeakSet();
909
+ var Batch = class Batch {
910
+ constructor() {
911
+ _classPrivateMethodInitSpec(this, _Batch_brand);
912
+ _defineProperty(this, "id", uid++);
913
+ _classPrivateFieldInitSpec(this, _started, false);
914
+ _defineProperty(this, "linked", true);
915
+ _classPrivateFieldInitSpec(this, _prev, null);
916
+ _classPrivateFieldInitSpec(this, _next, null);
1302
917
  _defineProperty(
1303
918
  this,
1304
- /** @type {Boundary | null} */
1305
- "parent",
1306
- void 0
919
+ /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
920
+ "async_deriveds",
921
+ /* @__PURE__ */ new Map()
1307
922
  );
1308
- _defineProperty(this, "is_pending", false);
1309
923
  _defineProperty(
1310
924
  this,
1311
925
  /**
1312
- * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
1313
- * Inherited from parent boundary, or defaults to identity.
1314
- * @type {(error: unknown) => unknown}
926
+ * The current values of any signals that are updated in this batch.
927
+ * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
928
+ * They keys of this map are identical to `this.#previous`
929
+ * @type {Map<Value, [any, boolean]>}
1315
930
  */
1316
- "transform_error",
1317
- void 0
931
+ "current",
932
+ /* @__PURE__ */ new Map()
1318
933
  );
1319
- _classPrivateFieldInitSpec(this, _anchor, void 0);
1320
- _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
1321
- _classPrivateFieldInitSpec(this, _props, void 0);
1322
- _classPrivateFieldInitSpec(this, _children, void 0);
1323
- _classPrivateFieldInitSpec(this, _effect, void 0);
1324
- _classPrivateFieldInitSpec(this, _main_effect, null);
1325
- _classPrivateFieldInitSpec(this, _pending_effect, null);
1326
- _classPrivateFieldInitSpec(this, _failed_effect, null);
1327
- _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
1328
- _classPrivateFieldInitSpec(this, _local_pending_count, 0);
1329
- _classPrivateFieldInitSpec(this, _pending_count, 0);
1330
- _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
1331
- _classPrivateFieldInitSpec(this, _dirty_effects, /* @__PURE__ */ new Set());
1332
- _classPrivateFieldInitSpec(this, _maybe_dirty_effects, /* @__PURE__ */ new Set());
1333
- _classPrivateFieldInitSpec(this, _effect_pending, null);
1334
- _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
1335
- _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
1336
- return () => {
1337
- _classPrivateFieldSet2(_effect_pending, this, null);
1338
- };
1339
- }));
1340
- _classPrivateFieldSet2(_anchor, this, node);
1341
- _classPrivateFieldSet2(_props, this, props);
1342
- _classPrivateFieldSet2(_children, this, (anchor) => {
1343
- var effect = active_effect;
1344
- effect.b = this;
1345
- effect.f |= 128;
1346
- children(anchor);
1347
- });
1348
- this.parent = active_effect.b;
1349
- this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
1350
- _classPrivateFieldSet2(_effect, this, block(() => {
1351
- if (hydrating) {
1352
- const comment = _classPrivateFieldGet2(_hydrate_open, this);
1353
- hydrate_next();
1354
- const server_rendered_pending = comment.data === "[!";
1355
- if (comment.data.startsWith("[?")) {
1356
- const serialized_error = JSON.parse(comment.data.slice(2));
1357
- _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
1358
- } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
1359
- else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
1360
- } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
1361
- }, flags));
1362
- if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
934
+ _defineProperty(
935
+ this,
936
+ /**
937
+ * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
938
+ * They keys of this map are identical to `this.#current`
939
+ * @type {Map<Value, any>}
940
+ */
941
+ "previous",
942
+ /* @__PURE__ */ new Map()
943
+ );
944
+ _classPrivateFieldInitSpec(this, _commit_callbacks, /* @__PURE__ */ new Set());
945
+ _classPrivateFieldInitSpec(this, _discard_callbacks, /* @__PURE__ */ new Set());
946
+ _classPrivateFieldInitSpec(this, _pending, 0);
947
+ _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
948
+ _classPrivateFieldInitSpec(this, _deferred, null);
949
+ _classPrivateFieldInitSpec(this, _roots, []);
950
+ _classPrivateFieldInitSpec(this, _new_effects, []);
951
+ _classPrivateFieldInitSpec(this, _dirty_effects$1, /* @__PURE__ */ new Set());
952
+ _classPrivateFieldInitSpec(this, _maybe_dirty_effects$1, /* @__PURE__ */ new Set());
953
+ _classPrivateFieldInitSpec(this, _skipped_branches, /* @__PURE__ */ new Map());
954
+ _classPrivateFieldInitSpec(this, _unskipped_branches, /* @__PURE__ */ new Set());
955
+ _defineProperty(this, "is_fork", false);
956
+ _classPrivateFieldInitSpec(this, _decrement_queued, false);
957
+ if (last_batch === null) first_batch = last_batch = this;
958
+ else {
959
+ _classPrivateFieldSet2(_next, last_batch, this);
960
+ _classPrivateFieldSet2(_prev, this, last_batch);
961
+ }
962
+ last_batch = this;
1363
963
  }
1364
964
  /**
1365
- * Defer an effect inside a pending boundary until the boundary resolves
965
+ * Add an effect to the #skipped_branches map and reset its children
1366
966
  * @param {Effect} effect
1367
967
  */
1368
- defer_effect(effect) {
1369
- defer_effect(effect, _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
968
+ skip_effect(effect) {
969
+ if (!_classPrivateFieldGet2(_skipped_branches, this).has(effect)) _classPrivateFieldGet2(_skipped_branches, this).set(effect, {
970
+ d: [],
971
+ m: []
972
+ });
973
+ _classPrivateFieldGet2(_unskipped_branches, this).delete(effect);
1370
974
  }
1371
975
  /**
1372
- * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1373
- * @returns {boolean}
976
+ * Remove an effect from the #skipped_branches map and reschedule
977
+ * any tracked dirty/maybe_dirty child effects
978
+ * @param {Effect} effect
979
+ * @param {(e: Effect) => void} callback
1374
980
  */
1375
- is_rendered() {
1376
- return !this.is_pending && (!this.parent || this.parent.is_rendered());
1377
- }
1378
- has_pending_snippet() {
1379
- return !!_classPrivateFieldGet2(_props, this).pending;
981
+ unskip_effect(effect, callback = (e) => this.schedule(e)) {
982
+ var tracked = _classPrivateFieldGet2(_skipped_branches, this).get(effect);
983
+ if (tracked) {
984
+ _classPrivateFieldGet2(_skipped_branches, this).delete(effect);
985
+ for (var e of tracked.d) {
986
+ set_signal_status(e, DIRTY);
987
+ callback(e);
988
+ }
989
+ for (e of tracked.m) {
990
+ set_signal_status(e, MAYBE_DIRTY);
991
+ callback(e);
992
+ }
993
+ }
994
+ _classPrivateFieldGet2(_unskipped_branches, this).add(effect);
1380
995
  }
1381
996
  /**
1382
- * Update the source that powers `$effect.pending()` inside this boundary,
1383
- * and controls when the current `pending` snippet (if any) is removed.
1384
- * Do not call from inside the class
1385
- * @param {1 | -1} d
1386
- * @param {Batch} batch
997
+ * Associate a change to a given source with the current
998
+ * batch, noting its previous and current values
999
+ * @param {Value} source
1000
+ * @param {any} value
1001
+ * @param {boolean} [is_derived]
1387
1002
  */
1388
- update_pending_count(d, batch) {
1389
- _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
1390
- _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
1391
- if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
1392
- _classPrivateFieldSet2(_pending_count_update_queued, this, true);
1393
- queue_micro_task(() => {
1394
- _classPrivateFieldSet2(_pending_count_update_queued, this, false);
1395
- if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
1396
- });
1003
+ capture(source, value, is_derived = false) {
1004
+ if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
1005
+ if ((source.f & 8388608) === 0) {
1006
+ this.current.set(source, [value, is_derived]);
1007
+ batch_values?.set(source, value);
1008
+ }
1009
+ if (!this.is_fork) source.v = value;
1397
1010
  }
1398
- get_effect_pending() {
1399
- _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
1400
- return get(_classPrivateFieldGet2(_effect_pending, this));
1401
- }
1402
- /** @param {unknown} error */
1403
- error(error) {
1404
- if (!_classPrivateFieldGet2(_props, this).onerror && !_classPrivateFieldGet2(_props, this).failed) throw error;
1405
- if (current_batch?.is_fork) {
1406
- if (_classPrivateFieldGet2(_main_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_main_effect, this));
1407
- if (_classPrivateFieldGet2(_pending_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_pending_effect, this));
1408
- if (_classPrivateFieldGet2(_failed_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_failed_effect, this));
1409
- current_batch.on_fork_commit(() => {
1410
- _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
1411
- });
1412
- } else _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
1011
+ activate() {
1012
+ current_batch = this;
1413
1013
  }
1414
- };
1415
- function _hydrate_resolved_content() {
1416
- try {
1417
- _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
1418
- } catch (error) {
1419
- this.error(error);
1014
+ deactivate() {
1015
+ current_batch = null;
1016
+ batch_values = null;
1420
1017
  }
1421
- }
1422
- /**
1423
- * @param {unknown} error The deserialized error from the server's hydration comment
1424
- */
1425
- function _hydrate_failed_content(error) {
1426
- const failed = _classPrivateFieldGet2(_props, this).failed;
1427
- if (!failed) return;
1428
- _classPrivateFieldSet2(_failed_effect, this, branch(() => {
1429
- failed(_classPrivateFieldGet2(_anchor, this), () => error, () => () => {});
1430
- }));
1431
- }
1432
- function _hydrate_pending_content() {
1433
- const pending = _classPrivateFieldGet2(_props, this).pending;
1434
- if (!pending) return;
1435
- this.is_pending = true;
1436
- _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
1437
- queue_micro_task(() => {
1438
- var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
1439
- var anchor = create_text();
1440
- fragment.append(anchor);
1441
- _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1442
- return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
1443
- }));
1444
- if (_classPrivateFieldGet2(_pending_count, this) === 0) {
1445
- _classPrivateFieldGet2(_anchor, this).before(fragment);
1446
- _classPrivateFieldSet2(_offscreen_fragment, this, null);
1447
- pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
1448
- _classPrivateFieldSet2(_pending_effect, this, null);
1449
- });
1450
- _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
1018
+ flush() {
1019
+ try {
1020
+ is_processing = true;
1021
+ current_batch = this;
1022
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
1023
+ } finally {
1024
+ flush_count = 0;
1025
+ last_scheduled_effect = null;
1026
+ collected_effects = null;
1027
+ legacy_updates = null;
1028
+ is_processing = false;
1029
+ current_batch = null;
1030
+ batch_values = null;
1031
+ old_values.clear();
1451
1032
  }
1452
- });
1453
- }
1454
- function _render() {
1455
- try {
1456
- this.is_pending = this.has_pending_snippet();
1457
- _classPrivateFieldSet2(_pending_count, this, 0);
1458
- _classPrivateFieldSet2(_local_pending_count, this, 0);
1459
- _classPrivateFieldSet2(_main_effect, this, branch(() => {
1460
- _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
1461
- }));
1462
- if (_classPrivateFieldGet2(_pending_count, this) > 0) {
1463
- var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
1464
- move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
1465
- const pending = _classPrivateFieldGet2(_props, this).pending;
1466
- _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
1467
- } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
1468
- } catch (error) {
1469
- this.error(error);
1470
1033
  }
1471
- }
1472
- /**
1473
- * @param {Batch} batch
1474
- */
1475
- function _resolve(batch) {
1476
- this.is_pending = false;
1477
- batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
1478
- }
1479
- /**
1480
- * @template T
1481
- * @param {() => T} fn
1482
- */
1483
- function _run(fn) {
1484
- var previous_effect = active_effect;
1485
- var previous_reaction = active_reaction;
1486
- var previous_ctx = component_context;
1487
- set_active_effect(_classPrivateFieldGet2(_effect, this));
1488
- set_active_reaction(_classPrivateFieldGet2(_effect, this));
1489
- set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
1490
- try {
1491
- Batch.ensure();
1492
- return fn();
1493
- } catch (e) {
1494
- handle_error(e);
1495
- return null;
1496
- } finally {
1497
- set_active_effect(previous_effect);
1498
- set_active_reaction(previous_reaction);
1499
- set_component_context(previous_ctx);
1034
+ discard() {
1035
+ for (const fn of _classPrivateFieldGet2(_discard_callbacks, this)) fn(this);
1036
+ _classPrivateFieldGet2(_discard_callbacks, this).clear();
1037
+ for (const deferred of this.async_deriveds.values()) deferred.reject(OBSOLETE);
1038
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1039
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
1500
1040
  }
1501
- }
1502
- /**
1503
- * Updates the pending count associated with the currently visible pending snippet,
1504
- * if any, such that we can replace the snippet with content once work is done
1505
- * @param {1 | -1} d
1506
- * @param {Batch} batch
1507
- */
1508
- function _update_pending_count(d, batch) {
1509
- if (!this.has_pending_snippet()) {
1510
- if (this.parent) {
1511
- var _this$parent;
1512
- _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
1041
+ /**
1042
+ * @param {Effect} effect
1043
+ */
1044
+ register_created_effect(effect) {
1045
+ _classPrivateFieldGet2(_new_effects, this).push(effect);
1046
+ }
1047
+ /**
1048
+ * @param {boolean} blocking
1049
+ * @param {Effect} effect
1050
+ */
1051
+ increment(blocking, effect) {
1052
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) + 1);
1053
+ if (blocking) {
1054
+ let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
1055
+ _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count + 1);
1513
1056
  }
1514
- return;
1515
1057
  }
1516
- _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
1517
- if (_classPrivateFieldGet2(_pending_count, this) === 0) {
1518
- _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
1519
- if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
1520
- _classPrivateFieldSet2(_pending_effect, this, null);
1521
- });
1522
- if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
1523
- _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
1524
- _classPrivateFieldSet2(_offscreen_fragment, this, null);
1058
+ /**
1059
+ * @param {boolean} blocking
1060
+ * @param {Effect} effect
1061
+ */
1062
+ decrement(blocking, effect) {
1063
+ _classPrivateFieldSet2(_pending, this, _classPrivateFieldGet2(_pending, this) - 1);
1064
+ if (blocking) {
1065
+ let blocking_pending_count = _classPrivateFieldGet2(_blocking_pending, this).get(effect) ?? 0;
1066
+ if (blocking_pending_count === 1) _classPrivateFieldGet2(_blocking_pending, this).delete(effect);
1067
+ else _classPrivateFieldGet2(_blocking_pending, this).set(effect, blocking_pending_count - 1);
1525
1068
  }
1069
+ if (_classPrivateFieldGet2(_decrement_queued, this)) return;
1070
+ _classPrivateFieldSet2(_decrement_queued, this, true);
1071
+ queue_micro_task(() => {
1072
+ _classPrivateFieldSet2(_decrement_queued, this, false);
1073
+ if (this.linked) this.flush();
1074
+ });
1526
1075
  }
1527
- }
1528
- /**
1529
- * @param {unknown} error
1530
- */
1531
- function _handle_error(error) {
1532
- if (_classPrivateFieldGet2(_main_effect, this)) {
1533
- destroy_effect(_classPrivateFieldGet2(_main_effect, this));
1534
- _classPrivateFieldSet2(_main_effect, this, null);
1076
+ /**
1077
+ * @param {Set<Effect>} dirty_effects
1078
+ * @param {Set<Effect>} maybe_dirty_effects
1079
+ */
1080
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
1081
+ for (const e of dirty_effects) _classPrivateFieldGet2(_dirty_effects$1, this).add(e);
1082
+ for (const e of maybe_dirty_effects) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(e);
1083
+ dirty_effects.clear();
1084
+ maybe_dirty_effects.clear();
1535
1085
  }
1536
- if (_classPrivateFieldGet2(_pending_effect, this)) {
1537
- destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
1538
- _classPrivateFieldSet2(_pending_effect, this, null);
1086
+ /** @param {(batch: Batch) => void} fn */
1087
+ oncommit(fn) {
1088
+ _classPrivateFieldGet2(_commit_callbacks, this).add(fn);
1539
1089
  }
1540
- if (_classPrivateFieldGet2(_failed_effect, this)) {
1541
- destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
1542
- _classPrivateFieldSet2(_failed_effect, this, null);
1090
+ /** @param {(batch: Batch) => void} fn */
1091
+ ondiscard(fn) {
1092
+ _classPrivateFieldGet2(_discard_callbacks, this).add(fn);
1543
1093
  }
1544
- if (hydrating) {
1545
- set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
1546
- next();
1547
- set_hydrate_node(skip_nodes());
1094
+ settled() {
1095
+ return (_classPrivateFieldGet2(_deferred, this) ?? _classPrivateFieldSet2(_deferred, this, deferred())).promise;
1548
1096
  }
1549
- var onerror = _classPrivateFieldGet2(_props, this).onerror;
1550
- let failed = _classPrivateFieldGet2(_props, this).failed;
1551
- var did_reset = false;
1552
- var calling_on_error = false;
1553
- const reset = () => {
1554
- if (did_reset) {
1555
- svelte_boundary_reset_noop();
1556
- return;
1097
+ static ensure() {
1098
+ if (current_batch === null) {
1099
+ const batch = current_batch = new Batch();
1100
+ if (!is_processing && !is_flushing_sync) queue_micro_task(() => {
1101
+ if (!_classPrivateFieldGet2(_started, batch)) batch.flush();
1102
+ });
1557
1103
  }
1558
- did_reset = true;
1559
- if (calling_on_error) svelte_boundary_reset_onerror();
1560
- if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
1561
- _classPrivateFieldSet2(_failed_effect, this, null);
1562
- });
1563
- _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1564
- _assertClassBrand(_Boundary_brand, this, _render).call(this);
1565
- });
1566
- };
1567
- /** @param {unknown} transformed_error */
1568
- const handle_error_result = (transformed_error) => {
1569
- try {
1570
- calling_on_error = true;
1571
- onerror?.(transformed_error, reset);
1572
- calling_on_error = false;
1573
- } catch (error) {
1574
- invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1104
+ return current_batch;
1105
+ }
1106
+ apply() {
1107
+ if (!async_mode_flag || !this.is_fork && _classPrivateFieldGet2(_prev, this) === null && _classPrivateFieldGet2(_next, this) === null) {
1108
+ batch_values = null;
1109
+ return;
1575
1110
  }
1576
- if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
1577
- try {
1578
- return branch(() => {
1579
- var effect = active_effect;
1580
- effect.b = this;
1581
- effect.f |= 128;
1582
- failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
1583
- });
1584
- } catch (error) {
1585
- invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
1586
- return null;
1111
+ batch_values = /* @__PURE__ */ new Map();
1112
+ for (const [source, [value]] of this.current) batch_values.set(source, value);
1113
+ for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1114
+ if (batch === this || batch.is_fork) continue;
1115
+ var intersects = false;
1116
+ if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
1117
+ if (is_derived) continue;
1118
+ if (this.current.has(source)) {
1119
+ intersects = true;
1120
+ break;
1121
+ }
1122
+ }
1123
+ if (!intersects) {
1124
+ for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
1587
1125
  }
1588
- }));
1589
- };
1590
- queue_micro_task(() => {
1591
- /** @type {unknown} */
1592
- var result;
1593
- try {
1594
- result = this.transform_error(error);
1595
- } catch (e) {
1596
- invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
1597
- return;
1598
1126
  }
1599
- if (result !== null && typeof result === "object" && typeof result.then === "function")
1600
- /** @type {any} */ result.then(
1601
- handle_error_result,
1602
- /** @param {unknown} e */
1603
- (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
1604
- );
1605
- else handle_error_result(result);
1606
- });
1607
- }
1608
- //#endregion
1609
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/async.js
1610
- /** @import { Blocker, Effect, Value } from '#client' */
1611
- /**
1612
- * @param {Blocker[]} blockers
1613
- * @param {Array<() => any>} sync
1614
- * @param {Array<() => Promise<any>>} async
1615
- * @param {(values: Value[]) => any} fn
1616
- */
1617
- function flatten(blockers, sync, async, fn) {
1618
- const d = is_runes() ? derived : derived_safe_equal;
1619
- var pending = blockers.filter((b) => !b.settled);
1620
- if (async.length === 0 && pending.length === 0) {
1621
- fn(sync.map(d));
1622
- return;
1623
1127
  }
1624
- var parent = active_effect;
1625
- var restore = capture();
1626
- var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b) => b.promise)) : null;
1627
- /** @param {Value[]} values */
1628
- function finish(values) {
1629
- restore();
1630
- try {
1631
- fn(values);
1632
- } catch (error) {
1633
- if ((parent.f & 16384) === 0) invoke_error_boundary(error, parent);
1128
+ /**
1129
+ *
1130
+ * @param {Effect} effect
1131
+ */
1132
+ schedule(effect) {
1133
+ last_scheduled_effect = effect;
1134
+ if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
1135
+ effect.b.defer_effect(effect);
1136
+ return;
1634
1137
  }
1635
- unset_context();
1138
+ var e = effect;
1139
+ while (e.parent !== null) {
1140
+ e = e.parent;
1141
+ var flags = e.f;
1142
+ if (collected_effects !== null && e === active_effect) {
1143
+ if (async_mode_flag) return;
1144
+ if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
1145
+ }
1146
+ if ((flags & 96) !== 0) {
1147
+ if ((flags & 1024) === 0) return;
1148
+ e.f ^= CLEAN;
1149
+ }
1150
+ }
1151
+ _classPrivateFieldGet2(_roots, this).push(e);
1636
1152
  }
1637
- if (async.length === 0) {
1638
- /** @type {Promise<any>} */ blocker_promise.then(() => finish(sync.map(d)));
1153
+ };
1154
+ _Batch = Batch;
1155
+ function _is_deferred() {
1156
+ if (this.is_fork) return true;
1157
+ for (const effect of _classPrivateFieldGet2(_blocking_pending, this).keys()) {
1158
+ var e = effect;
1159
+ var skipped = false;
1160
+ while (e.parent !== null) {
1161
+ if (_classPrivateFieldGet2(_skipped_branches, this).has(e)) {
1162
+ skipped = true;
1163
+ break;
1164
+ }
1165
+ e = e.parent;
1166
+ }
1167
+ if (!skipped) return true;
1168
+ }
1169
+ return false;
1170
+ }
1171
+ function _process() {
1172
+ _classPrivateFieldSet2(_started, this, true);
1173
+ if (flush_count++ > 1e3) {
1174
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1175
+ infinite_loop_guard();
1176
+ }
1177
+ for (const e of _classPrivateFieldGet2(_dirty_effects$1, this)) {
1178
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(e);
1179
+ set_signal_status(e, DIRTY);
1180
+ this.schedule(e);
1181
+ }
1182
+ for (const e of _classPrivateFieldGet2(_maybe_dirty_effects$1, this)) {
1183
+ set_signal_status(e, MAYBE_DIRTY);
1184
+ this.schedule(e);
1185
+ }
1186
+ const roots = _classPrivateFieldGet2(_roots, this);
1187
+ _classPrivateFieldSet2(_roots, this, []);
1188
+ this.apply();
1189
+ /** @type {Effect[]} */
1190
+ var effects = collected_effects = [];
1191
+ /** @type {Effect[]} */
1192
+ var render_effects = [];
1193
+ /**
1194
+ * @type {Effect[]}
1195
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1196
+ */
1197
+ var updates = legacy_updates = [];
1198
+ for (const root of roots) try {
1199
+ _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
1200
+ } catch (e) {
1201
+ reset_all(root);
1202
+ if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
1203
+ throw e;
1204
+ }
1205
+ current_batch = null;
1206
+ if (updates.length > 0) {
1207
+ var batch = _Batch.ensure();
1208
+ for (const e of updates) batch.schedule(e);
1209
+ }
1210
+ collected_effects = null;
1211
+ legacy_updates = null;
1212
+ if (_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) {
1213
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
1214
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
1215
+ for (const [e, t] of _classPrivateFieldGet2(_skipped_branches, this)) reset_branch(e, t);
1216
+ if (updates.length > 0)
1217
+ /** @type {Batch} */ _assertClassBrand(_Batch_brand, current_batch, _process).call(current_batch);
1639
1218
  return;
1640
1219
  }
1641
- var decrement_pending = increment_pending();
1642
- function run() {
1643
- Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then((result) => finish([...sync.map(d), ...result])).catch((error) => invoke_error_boundary(error, parent)).finally(() => decrement_pending());
1220
+ const earlier_batch = _assertClassBrand(_Batch_brand, this, _find_earlier_batch).call(this);
1221
+ if (earlier_batch) {
1222
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, render_effects);
1223
+ _assertClassBrand(_Batch_brand, this, _defer_effects).call(this, effects);
1224
+ _assertClassBrand(_Batch_brand, earlier_batch, _merge).call(earlier_batch, this);
1225
+ return;
1226
+ }
1227
+ _classPrivateFieldGet2(_dirty_effects$1, this).clear();
1228
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).clear();
1229
+ for (const fn of _classPrivateFieldGet2(_commit_callbacks, this)) fn(this);
1230
+ _classPrivateFieldGet2(_commit_callbacks, this).clear();
1231
+ previous_batch = this;
1232
+ flush_queued_effects(render_effects);
1233
+ flush_queued_effects(effects);
1234
+ previous_batch = null;
1235
+ _classPrivateFieldGet2(_deferred, this)?.resolve();
1236
+ var next_batch = current_batch;
1237
+ if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_roots, this).length === 0 || next_batch !== null)) {
1238
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1239
+ if (async_mode_flag) {
1240
+ _assertClassBrand(_Batch_brand, this, _commit$1).call(this);
1241
+ current_batch = next_batch;
1242
+ }
1243
+ }
1244
+ if (_classPrivateFieldGet2(_roots, this).length > 0) if (next_batch !== null) {
1245
+ const batch = next_batch;
1246
+ _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
1247
+ } else next_batch = this;
1248
+ if (next_batch !== null) {
1249
+ old_values.clear();
1250
+ _assertClassBrand(_Batch_brand, next_batch, _process).call(next_batch);
1644
1251
  }
1645
- if (blocker_promise) blocker_promise.then(() => {
1646
- restore();
1647
- run();
1648
- unset_context();
1649
- });
1650
- else run();
1651
1252
  }
1652
1253
  /**
1653
- * Captures the current effect context so that we can restore it after
1654
- * some asynchronous work has happened (so that e.g. `await a + b`
1655
- * causes `b` to be registered as a dependency).
1254
+ * Traverse the effect tree, executing effects or stashing
1255
+ * them for later execution as appropriate
1256
+ * @param {Effect} root
1257
+ * @param {Effect[]} effects
1258
+ * @param {Effect[]} render_effects
1656
1259
  */
1657
- function capture() {
1658
- var previous_effect = active_effect;
1659
- var previous_reaction = active_reaction;
1660
- var previous_component_context = component_context;
1661
- var previous_batch = current_batch;
1662
- return function restore(activate_batch = true) {
1663
- set_active_effect(previous_effect);
1664
- set_active_reaction(previous_reaction);
1665
- set_component_context(previous_component_context);
1666
- if (activate_batch && (previous_effect.f & 16384) === 0) {
1667
- previous_batch?.activate();
1668
- previous_batch?.apply();
1260
+ function _traverse(root, effects, render_effects) {
1261
+ root.f ^= CLEAN;
1262
+ var effect = root.first;
1263
+ while (effect !== null) {
1264
+ var flags = effect.f;
1265
+ var is_branch = (flags & 96) !== 0;
1266
+ if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || _classPrivateFieldGet2(_skipped_branches, this).has(effect)) && effect.fn !== null) {
1267
+ if (is_branch) effect.f ^= CLEAN;
1268
+ else if ((flags & 4) !== 0) effects.push(effect);
1269
+ else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
1270
+ else if (is_dirty(effect)) {
1271
+ if ((flags & 16) !== 0) _classPrivateFieldGet2(_maybe_dirty_effects$1, this).add(effect);
1272
+ update_effect(effect);
1273
+ }
1274
+ var child = effect.first;
1275
+ if (child !== null) {
1276
+ effect = child;
1277
+ continue;
1278
+ }
1669
1279
  }
1670
- };
1280
+ while (effect !== null) {
1281
+ var next = effect.next;
1282
+ if (next !== null) {
1283
+ effect = next;
1284
+ break;
1285
+ }
1286
+ effect = effect.parent;
1287
+ }
1288
+ }
1671
1289
  }
1672
- function unset_context(deactivate_batch = true) {
1673
- set_active_effect(null);
1674
- set_active_reaction(null);
1675
- set_component_context(null);
1676
- if (deactivate_batch) current_batch?.deactivate();
1290
+ function _find_earlier_batch() {
1291
+ var batch = _classPrivateFieldGet2(_prev, this);
1292
+ while (batch !== null) {
1293
+ if (!batch.is_fork) {
1294
+ for (const [value, [, is_derived]] of this.current) if (batch.current.has(value) && !is_derived) return batch;
1295
+ }
1296
+ batch = _classPrivateFieldGet2(_prev, batch);
1297
+ }
1298
+ return null;
1677
1299
  }
1678
1300
  /**
1679
- * @returns {(skip?: boolean) => void}
1301
+ * @param {Batch} batch
1680
1302
  */
1681
- function increment_pending() {
1682
- var effect = active_effect;
1683
- var boundary = effect.b;
1684
- var batch = current_batch;
1685
- var blocking = boundary.is_rendered();
1686
- boundary.update_pending_count(1, batch);
1687
- batch.increment(blocking, effect);
1688
- return (skip = false) => {
1689
- boundary.update_pending_count(-1, batch);
1690
- batch.decrement(blocking, effect, skip);
1303
+ function _merge(batch) {
1304
+ for (const [source, value] of batch.current) {
1305
+ if (!this.previous.has(source) && batch.previous.has(source)) this.previous.set(source, batch.previous.get(source));
1306
+ this.current.set(source, value);
1307
+ }
1308
+ for (const [effect, deferred] of batch.async_deriveds) {
1309
+ const d = this.async_deriveds.get(effect);
1310
+ if (d) deferred.promise.then(d.resolve).catch(d.reject);
1311
+ }
1312
+ batch.async_deriveds.clear();
1313
+ this.transfer_effects(_classPrivateFieldGet2(_dirty_effects$1, batch), _classPrivateFieldGet2(_maybe_dirty_effects$1, batch));
1314
+ /**
1315
+ * mark all effects that depend on `batch.current`, except the
1316
+ * async effects that we just resolved (TODO unless they depend
1317
+ * on values in this batch that are NOT in the later batch?).
1318
+ * Through this we also will populate the correct #skipped_branches,
1319
+ * oncommit callbacks etc, so we don't need to merge them separately.
1320
+ * @param {Value} value
1321
+ */
1322
+ const mark = (value) => {
1323
+ var reactions = value.reactions;
1324
+ if (reactions === null) return;
1325
+ if ((value.f & 2) !== 0 && (value.f & 6144) === 0) return;
1326
+ for (const reaction of reactions) {
1327
+ var flags = reaction.f;
1328
+ if ((flags & 2) !== 0) mark(reaction);
1329
+ else {
1330
+ var effect = reaction;
1331
+ if (flags & 4194320 && !this.async_deriveds.has(effect)) {
1332
+ _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(effect);
1333
+ set_signal_status(effect, DIRTY);
1334
+ this.schedule(effect);
1335
+ }
1336
+ }
1337
+ }
1691
1338
  };
1339
+ for (const source of this.current.keys()) mark(source);
1340
+ this.oncommit(() => batch.discard());
1341
+ _assertClassBrand(_Batch_brand, batch, _unlink).call(batch);
1342
+ current_batch = this;
1343
+ _assertClassBrand(_Batch_brand, this, _process).call(this);
1692
1344
  }
1693
1345
  /**
1694
- * @template V
1695
- * @param {() => V} fn
1696
- * @returns {Derived<V>}
1346
+ * @param {Effect[]} effects
1697
1347
  */
1698
- /* @__NO_SIDE_EFFECTS__ */
1699
- function derived(fn) {
1700
- var flags = 2 | DIRTY;
1701
- if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
1702
- return {
1703
- ctx: component_context,
1704
- deps: null,
1705
- effects: null,
1706
- equals,
1707
- f: flags,
1708
- fn,
1709
- reactions: null,
1710
- rv: 0,
1711
- v: UNINITIALIZED,
1712
- wv: 0,
1713
- parent: active_effect,
1714
- ac: null
1715
- };
1348
+ function _defer_effects(effects) {
1349
+ for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], _classPrivateFieldGet2(_dirty_effects$1, this), _classPrivateFieldGet2(_maybe_dirty_effects$1, this));
1716
1350
  }
1717
- /**
1718
- * @template V
1719
- * @param {() => V | Promise<V>} fn
1720
- * @param {string} [label]
1721
- * @param {string} [location] If provided, print a warning if the value is not read immediately after update
1722
- * @returns {Promise<Source<V>>}
1723
- */
1724
- /* @__NO_SIDE_EFFECTS__ */
1725
- function async_derived(fn, label, location) {
1726
- let parent = active_effect;
1727
- if (parent === null) async_derived_orphan();
1728
- var promise = void 0;
1729
- var signal = source(UNINITIALIZED);
1730
- var should_suspend = !active_reaction;
1731
- /** @type {Map<Batch, ReturnType<typeof deferred<V>>>} */
1732
- var deferreds = /* @__PURE__ */ new Map();
1733
- async_effect(() => {
1734
- var effect = active_effect;
1735
- /** @type {ReturnType<typeof deferred<V>>} */
1736
- var d = deferred();
1737
- promise = d.promise;
1738
- try {
1739
- Promise.resolve(fn()).then(d.resolve, d.reject).finally(unset_context);
1740
- } catch (error) {
1741
- d.reject(error);
1742
- unset_context();
1743
- }
1744
- var batch = current_batch;
1745
- if (should_suspend) {
1746
- if ((effect.f & 32768) !== 0) var decrement_pending = increment_pending();
1747
- if (parent.b.is_rendered()) {
1748
- deferreds.get(batch)?.reject(STALE_REACTION);
1749
- deferreds.delete(batch);
1750
- } else {
1751
- for (const d of deferreds.values()) d.reject(STALE_REACTION);
1752
- deferreds.clear();
1351
+ function _commit$1() {
1352
+ for (let batch = first_batch; batch !== null; batch = _classPrivateFieldGet2(_next, batch)) {
1353
+ var is_earlier = batch.id < this.id;
1354
+ /** @type {Source[]} */
1355
+ var sources = [];
1356
+ for (const [source, [value, is_derived]] of this.current) {
1357
+ if (batch.current.has(source)) {
1358
+ var batch_value = batch.current.get(source)[0];
1359
+ if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
1360
+ else continue;
1753
1361
  }
1754
- deferreds.set(batch, d);
1362
+ sources.push(source);
1755
1363
  }
1756
- /**
1757
- * @param {any} value
1758
- * @param {unknown} error
1759
- */
1760
- const handler = (value, error = void 0) => {
1761
- if (decrement_pending) decrement_pending(error === STALE_REACTION);
1762
- if (error === STALE_REACTION || (effect.f & 16384) !== 0) return;
1364
+ if (is_earlier) for (const [effect, deferred] of this.async_deriveds) {
1365
+ const d = batch.async_deriveds.get(effect);
1366
+ if (d) deferred.promise.then(d.resolve).catch(d.reject);
1367
+ }
1368
+ var current = [...batch.current.keys()].filter((source) => !batch.current.get(source)[1]);
1369
+ if (!_classPrivateFieldGet2(_started, batch) || current.length === 0) continue;
1370
+ var others = current.filter((source) => !this.current.has(source));
1371
+ if (others.length === 0) {
1372
+ if (is_earlier) batch.discard();
1373
+ } else if (sources.length > 0) {
1374
+ if (is_earlier) for (const unskipped of _classPrivateFieldGet2(_unskipped_branches, this)) batch.unskip_effect(unskipped, (e) => {
1375
+ if ((e.f & 4194320) !== 0) batch.schedule(e);
1376
+ else _assertClassBrand(_Batch_brand, batch, _defer_effects).call(batch, [e]);
1377
+ });
1763
1378
  batch.activate();
1764
- if (error) {
1765
- signal.f |= ERROR_VALUE;
1766
- internal_set(signal, error);
1767
- } else {
1768
- if ((signal.f & 8388608) !== 0) signal.f ^= ERROR_VALUE;
1769
- internal_set(signal, value);
1770
- for (const [b, d] of deferreds) {
1771
- deferreds.delete(b);
1772
- if (b === batch) break;
1773
- d.reject(STALE_REACTION);
1774
- }
1379
+ /** @type {Set<Value>} */
1380
+ var marked = /* @__PURE__ */ new Set();
1381
+ /** @type {Map<Reaction, boolean>} */
1382
+ var checked = /* @__PURE__ */ new Map();
1383
+ for (var source of sources) mark_effects(source, others, marked, checked);
1384
+ checked = /* @__PURE__ */ new Map();
1385
+ var current_unequal = [...batch.current].filter(([c, v1]) => {
1386
+ const v2 = this.current.get(c);
1387
+ if (!v2) return true;
1388
+ return v2[0] !== v1[0] || v2[1] !== v1[1];
1389
+ }).map(([c]) => c);
1390
+ if (current_unequal.length > 0) {
1391
+ for (const effect of _classPrivateFieldGet2(_new_effects, this)) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1392
+ set_signal_status(effect, DIRTY);
1393
+ batch.schedule(effect);
1394
+ } else _classPrivateFieldGet2(_dirty_effects$1, batch).add(effect);
1775
1395
  }
1776
- batch.deactivate();
1777
- };
1778
- d.promise.then(handler, (e) => handler(null, e || "unknown"));
1779
- });
1780
- teardown(() => {
1781
- for (const d of deferreds.values()) d.reject(STALE_REACTION);
1782
- });
1783
- return new Promise((fulfil) => {
1784
- /** @param {Promise<V>} p */
1785
- function next(p) {
1786
- function go() {
1787
- if (p === promise) fulfil(signal);
1788
- else next(promise);
1396
+ if (_classPrivateFieldGet2(_roots, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1397
+ batch.apply();
1398
+ for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1399
+ _classPrivateFieldSet2(_roots, batch, []);
1789
1400
  }
1790
- p.then(go, go);
1401
+ batch.deactivate();
1791
1402
  }
1792
- next(promise);
1793
- });
1403
+ }
1794
1404
  }
1795
- /**
1796
- * @template V
1797
- * @param {() => V} fn
1798
- * @returns {Derived<V>}
1799
- */
1800
- /* @__NO_SIDE_EFFECTS__ */
1801
- function user_derived(fn) {
1802
- const d = /* @__PURE__ */ derived(fn);
1803
- if (!async_mode_flag) push_reaction_value(d);
1804
- return d;
1405
+ function _unlink() {
1406
+ if (!this.linked) return;
1407
+ var prev = _classPrivateFieldGet2(_prev, this);
1408
+ var next = _classPrivateFieldGet2(_next, this);
1409
+ if (prev === null) first_batch = next;
1410
+ else _classPrivateFieldSet2(_next, prev, next);
1411
+ if (next === null) last_batch = prev;
1412
+ else _classPrivateFieldSet2(_prev, next, prev);
1413
+ this.linked = false;
1805
1414
  }
1806
1415
  /**
1807
- * @template V
1808
- * @param {() => V} fn
1809
- * @returns {Derived<V>}
1416
+ * Synchronously flush any pending updates.
1417
+ * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1418
+ * @template [T=void]
1419
+ * @param {(() => T) | undefined} [fn]
1420
+ * @returns {T}
1810
1421
  */
1811
- /* @__NO_SIDE_EFFECTS__ */
1812
- function derived_safe_equal(fn) {
1813
- const signal = /* @__PURE__ */ derived(fn);
1814
- signal.equals = safe_equals;
1815
- return signal;
1422
+ function flushSync(fn) {
1423
+ var was_flushing_sync = is_flushing_sync;
1424
+ is_flushing_sync = true;
1425
+ try {
1426
+ var result;
1427
+ if (fn) {
1428
+ if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
1429
+ result = fn();
1430
+ }
1431
+ while (true) {
1432
+ flush_tasks();
1433
+ if (current_batch === null) return result;
1434
+ current_batch.flush();
1435
+ }
1436
+ } finally {
1437
+ is_flushing_sync = was_flushing_sync;
1438
+ }
1439
+ }
1440
+ function infinite_loop_guard() {
1441
+ try {
1442
+ effect_update_depth_exceeded();
1443
+ } catch (error) {
1444
+ invoke_error_boundary(error, last_scheduled_effect);
1445
+ }
1816
1446
  }
1447
+ /** @type {Set<Effect> | null} */
1448
+ var eager_block_effects = null;
1817
1449
  /**
1818
- * @param {Derived} derived
1450
+ * @param {Array<Effect>} effects
1819
1451
  * @returns {void}
1820
1452
  */
1821
- function destroy_derived_effects(derived) {
1822
- var effects = derived.effects;
1823
- if (effects !== null) {
1824
- derived.effects = null;
1825
- for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1453
+ function flush_queued_effects(effects) {
1454
+ var length = effects.length;
1455
+ if (length === 0) return;
1456
+ var i = 0;
1457
+ while (i < length) {
1458
+ var effect = effects[i++];
1459
+ if ((effect.f & 24576) === 0 && is_dirty(effect)) {
1460
+ eager_block_effects = /* @__PURE__ */ new Set();
1461
+ update_effect(effect);
1462
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
1463
+ if (eager_block_effects?.size > 0) {
1464
+ old_values.clear();
1465
+ for (const e of eager_block_effects) {
1466
+ if ((e.f & 24576) !== 0) continue;
1467
+ /** @type {Effect[]} */
1468
+ const ordered_effects = [e];
1469
+ let ancestor = e.parent;
1470
+ while (ancestor !== null) {
1471
+ if (eager_block_effects.has(ancestor)) {
1472
+ eager_block_effects.delete(ancestor);
1473
+ ordered_effects.push(ancestor);
1474
+ }
1475
+ ancestor = ancestor.parent;
1476
+ }
1477
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
1478
+ const e = ordered_effects[j];
1479
+ if ((e.f & 24576) !== 0) continue;
1480
+ update_effect(e);
1481
+ }
1482
+ }
1483
+ eager_block_effects.clear();
1484
+ }
1485
+ }
1826
1486
  }
1487
+ eager_block_effects = null;
1827
1488
  }
1828
1489
  /**
1829
- * @template T
1830
- * @param {Derived} derived
1831
- * @returns {T}
1490
+ * This is similar to `mark_reactions`, but it only marks async/block effects
1491
+ * depending on `value` and at least one of the other `sources`, so that
1492
+ * these effects can re-run after another batch has been committed
1493
+ * @param {Value} value
1494
+ * @param {Source[]} sources
1495
+ * @param {Set<Value>} marked
1496
+ * @param {Map<Reaction, boolean>} checked
1832
1497
  */
1833
- function execute_derived(derived) {
1834
- var value;
1835
- var prev_active_effect = active_effect;
1836
- var parent = derived.parent;
1837
- if (!is_destroying_effect && parent !== null && (parent.f & 24576) !== 0) {
1838
- derived_inert();
1839
- return derived.v;
1840
- }
1841
- set_active_effect(parent);
1842
- try {
1843
- derived.f &= ~WAS_MARKED;
1844
- destroy_derived_effects(derived);
1845
- value = update_reaction(derived);
1846
- } finally {
1847
- set_active_effect(prev_active_effect);
1498
+ function mark_effects(value, sources, marked, checked) {
1499
+ if (marked.has(value)) return;
1500
+ marked.add(value);
1501
+ if (value.reactions !== null) for (const reaction of value.reactions) {
1502
+ const flags = reaction.f;
1503
+ if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
1504
+ else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
1505
+ set_signal_status(reaction, DIRTY);
1506
+ schedule_effect(reaction);
1507
+ }
1848
1508
  }
1849
- return value;
1850
1509
  }
1851
1510
  /**
1852
- * @param {Derived} derived
1853
- * @returns {void}
1511
+ * @param {Reaction} reaction
1512
+ * @param {Source[]} sources
1513
+ * @param {Map<Reaction, boolean>} checked
1854
1514
  */
1855
- function update_derived(derived) {
1856
- var value = execute_derived(derived);
1857
- if (!derived.equals(value)) {
1858
- derived.wv = increment_write_version();
1859
- if (!current_batch?.is_fork || derived.deps === null) {
1860
- if (current_batch !== null) current_batch.capture(derived, value, true);
1861
- else derived.v = value;
1862
- if (derived.deps === null) {
1863
- set_signal_status(derived, CLEAN);
1864
- return;
1865
- }
1515
+ function depends_on(reaction, sources, checked) {
1516
+ const depends = checked.get(reaction);
1517
+ if (depends !== void 0) return depends;
1518
+ if (reaction.deps !== null) for (const dep of reaction.deps) {
1519
+ if (includes.call(sources, dep)) return true;
1520
+ if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
1521
+ checked.set(dep, true);
1522
+ return true;
1866
1523
  }
1867
1524
  }
1868
- if (is_destroying_effect) return;
1869
- if (batch_values !== null) {
1870
- if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
1871
- } else update_derived_status(derived);
1525
+ checked.set(reaction, false);
1526
+ return false;
1872
1527
  }
1873
1528
  /**
1874
- * @param {Derived} derived
1529
+ * @param {Effect} effect
1530
+ * @returns {void}
1875
1531
  */
1876
- function freeze_derived_effects(derived) {
1877
- if (derived.effects === null) return;
1878
- for (const e of derived.effects) if (e.teardown || e.ac) {
1879
- e.teardown?.();
1880
- e.ac?.abort(STALE_REACTION);
1881
- e.teardown = noop;
1882
- e.ac = null;
1883
- remove_reactions(e, 0);
1884
- destroy_effect_children(e);
1532
+ function schedule_effect(effect) {
1533
+ /** @type {Batch} */ current_batch.schedule(effect);
1534
+ }
1535
+ /**
1536
+ * Mark all the effects inside a skipped branch CLEAN, so that
1537
+ * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1538
+ * effects so they can be rescheduled if the branch survives.
1539
+ * @param {Effect} effect
1540
+ * @param {{ d: Effect[], m: Effect[] }} tracked
1541
+ */
1542
+ function reset_branch(effect, tracked) {
1543
+ if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1544
+ if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1545
+ else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1546
+ set_signal_status(effect, CLEAN);
1547
+ var e = effect.first;
1548
+ while (e !== null) {
1549
+ reset_branch(e, tracked);
1550
+ e = e.next;
1885
1551
  }
1886
1552
  }
1887
1553
  /**
1888
- * @param {Derived} derived
1554
+ * Mark an entire effect tree clean following an error
1555
+ * @param {Effect} effect
1889
1556
  */
1890
- function unfreeze_derived_effects(derived) {
1891
- if (derived.effects === null) return;
1892
- for (const e of derived.effects) if (e.teardown) update_effect(e);
1557
+ function reset_all(effect) {
1558
+ set_signal_status(effect, CLEAN);
1559
+ var e = effect.first;
1560
+ while (e !== null) {
1561
+ reset_all(e);
1562
+ e = e.next;
1563
+ }
1893
1564
  }
1894
1565
  //#endregion
1895
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/sources.js
1566
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/sources.js
1896
1567
  /** @import { Derived, Effect, Source, Value } from '#client' */
1897
- /** @type {Set<any>} */
1568
+ /** @type {Set<Effect>} */
1898
1569
  var eager_effects = /* @__PURE__ */ new Set();
1899
1570
  /** @type {Map<Source, any>} */
1900
1571
  var old_values = /* @__PURE__ */ new Map();
@@ -1920,7 +1591,7 @@ function source(v, stack) {
1920
1591
  * @param {V} v
1921
1592
  * @param {Error | null} [stack]
1922
1593
  */
1923
- /* @__NO_SIDE_EFFECTS__ */
1594
+ /*#__NO_SIDE_EFFECTS__*/
1924
1595
  function state(v, stack) {
1925
1596
  const s = source(v, stack);
1926
1597
  push_reaction_value(s);
@@ -1932,7 +1603,7 @@ function state(v, stack) {
1932
1603
  * @param {boolean} [immutable]
1933
1604
  * @returns {Source<V>}
1934
1605
  */
1935
- /* @__NO_SIDE_EFFECTS__ */
1606
+ /*#__NO_SIDE_EFFECTS__*/
1936
1607
  function mutable_source(initial_value, immutable = false, trackable = true) {
1937
1608
  const s = source(initial_value);
1938
1609
  if (!immutable) s.equals = safe_equals;
@@ -1950,7 +1621,7 @@ function mutable_source(initial_value, immutable = false, trackable = true) {
1950
1621
  * @returns {V}
1951
1622
  */
1952
1623
  function set(source, value, should_proxy = false) {
1953
- if (active_reaction !== null && (!untracking || (active_reaction.f & 131072) !== 0) && is_runes() && (active_reaction.f & 4325394) !== 0 && (current_sources === null || !includes.call(current_sources, source))) state_unsafe_mutation();
1624
+ if (active_reaction !== null && (!untracking || (active_reaction.f & 131072) !== 0) && is_runes() && (active_reaction.f & 4325394) !== 0 && (current_sources === null || !current_sources.has(source))) state_unsafe_mutation();
1954
1625
  return internal_set(source, should_proxy ? proxy(value) : value, legacy_updates);
1955
1626
  }
1956
1627
  /**
@@ -1962,7 +1633,8 @@ function set(source, value, should_proxy = false) {
1962
1633
  */
1963
1634
  function internal_set(source, value, updated_during_traversal = null) {
1964
1635
  if (!source.equals(value)) {
1965
- old_values.set(source, is_destroying_effect ? value : source.v);
1636
+ if (is_destroying_effect) old_values.set(source, value);
1637
+ else if (!old_values.has(source)) old_values.set(source, source.v);
1966
1638
  var batch = Batch.ensure();
1967
1639
  batch.capture(source, value);
1968
1640
  if ((source.f & 2) !== 0) {
@@ -1982,7 +1654,13 @@ function flush_eager_effects() {
1982
1654
  eager_effects_deferred = false;
1983
1655
  for (const effect of eager_effects) {
1984
1656
  if ((effect.f & 1024) !== 0) set_signal_status(effect, MAYBE_DIRTY);
1985
- if (is_dirty(effect)) update_effect(effect);
1657
+ let dirty;
1658
+ try {
1659
+ dirty = is_dirty(effect);
1660
+ } catch {
1661
+ dirty = true;
1662
+ }
1663
+ if (dirty) update_effect(effect);
1986
1664
  }
1987
1665
  eager_effects.clear();
1988
1666
  }
@@ -2010,7 +1688,8 @@ function mark_reactions(signal, status, updated_during_traversal) {
2010
1688
  if (!runes && reaction === active_effect) continue;
2011
1689
  var not_dirty = (flags & DIRTY) === 0;
2012
1690
  if (not_dirty) set_signal_status(reaction, status);
2013
- if ((flags & 2) !== 0) {
1691
+ if ((flags & 131072) !== 0) eager_effects.add(reaction);
1692
+ else if ((flags & 2) !== 0) {
2014
1693
  var derived = reaction;
2015
1694
  batch_values?.delete(derived);
2016
1695
  if ((flags & 65536) === 0) {
@@ -2031,7 +1710,7 @@ function mark_reactions(signal, status, updated_during_traversal) {
2031
1710
  * @returns {T}
2032
1711
  */
2033
1712
  function proxy(value) {
2034
- if (typeof value !== "object" || value === null || STATE_SYMBOL in value) return value;
1713
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value || COMPONENT_SYMBOL in value) return value;
2035
1714
  const prototype = get_prototype_of(value);
2036
1715
  if (prototype !== object_prototype && prototype !== array_prototype) return value;
2037
1716
  /** @type {Map<any, Source<any>>} */
@@ -2184,7 +1863,7 @@ function proxy(value) {
2184
1863
  });
2185
1864
  }
2186
1865
  //#endregion
2187
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/operations.js
1866
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/operations.js
2188
1867
  /** @import { Effect, TemplateNode } from '#client' */
2189
1868
  /** @type {Window} */
2190
1869
  var $window;
@@ -2208,13 +1887,13 @@ function init_operations() {
2208
1887
  first_child_getter = get_descriptor(node_prototype, "firstChild").get;
2209
1888
  next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
2210
1889
  if (is_extensible(element_prototype)) {
2211
- element_prototype.__click = void 0;
2212
- element_prototype.__className = void 0;
2213
- element_prototype.__attributes = null;
2214
- element_prototype.__style = void 0;
1890
+ /** @type {any} */ element_prototype[CLASS_CACHE] = void 0;
1891
+ /** @type {any} */ element_prototype[ATTRIBUTES_CACHE] = null;
1892
+ /** @type {any} */ element_prototype[STYLE_CACHE] = void 0;
2215
1893
  element_prototype.__e = void 0;
2216
1894
  }
2217
- if (is_extensible(text_prototype)) text_prototype.__t = void 0;
1895
+ if (is_extensible(text_prototype))
1896
+ /** @type {any} */ text_prototype[TEXT_CACHE] = void 0;
2218
1897
  }
2219
1898
  /**
2220
1899
  * @param {string} value
@@ -2227,7 +1906,7 @@ function create_text(value = "") {
2227
1906
  * @template {Node} N
2228
1907
  * @param {N} node
2229
1908
  */
2230
- /* @__NO_SIDE_EFFECTS__ */
1909
+ /*@__NO_SIDE_EFFECTS__*/
2231
1910
  function get_first_child(node) {
2232
1911
  return first_child_getter.call(node);
2233
1912
  }
@@ -2235,7 +1914,7 @@ function get_first_child(node) {
2235
1914
  * @template {Node} N
2236
1915
  * @param {N} node
2237
1916
  */
2238
- /* @__NO_SIDE_EFFECTS__ */
1917
+ /*@__NO_SIDE_EFFECTS__*/
2239
1918
  function get_next_sibling(node) {
2240
1919
  return next_sibling_getter.call(node);
2241
1920
  }
@@ -2284,6 +1963,21 @@ function first_child(node, is_text = false) {
2284
1963
  return hydrate_node;
2285
1964
  }
2286
1965
  /**
1966
+ * `child`, for the very common case of an element with exactly one child. Resetting the
1967
+ * hydration cursor is part of the same step, so the compiler doesn't have to emit a
1968
+ * separate `reset` call for every `<p>{text}</p>` in an app.
1969
+ * Don't mark this as side-effect-free, hydration needs to walk all nodes
1970
+ * @param {TemplateNode} node
1971
+ * @param {boolean} [is_text]
1972
+ * @returns {TemplateNode | null}
1973
+ */
1974
+ function only_child(node, is_text = false) {
1975
+ if (!hydrating) return /* @__PURE__ */ get_first_child(node);
1976
+ var first = child(node, is_text);
1977
+ reset(node);
1978
+ return first;
1979
+ }
1980
+ /**
2287
1981
  * Don't mark this as side-effect-free, hydration needs to walk all nodes
2288
1982
  * @param {TemplateNode} node
2289
1983
  * @param {number} count
@@ -2331,6 +2025,12 @@ function should_defer_append() {
2331
2025
  return (active_effect.f & REACTION_RAN) !== 0;
2332
2026
  }
2333
2027
  /**
2028
+ * Branching here is intentional and load-bearing for perf. `createElement(tag)`
2029
+ * hits a fast path in Blink that `createElementNS(NAMESPACE_HTML, tag)` doesn't,
2030
+ * and passing an explicit `undefined` as the trailing options arg measurably
2031
+ * slows both APIs. Funnelling every case through a single `createElementNS(ns,
2032
+ * tag, options)` call would be smaller but slower on the HTML path.
2033
+ *
2334
2034
  * @template {keyof HTMLElementTagNameMap | string} T
2335
2035
  * @param {T} tag
2336
2036
  * @param {string} [namespace]
@@ -2338,8 +2038,8 @@ function should_defer_append() {
2338
2038
  * @returns {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element}
2339
2039
  */
2340
2040
  function create_element(tag, namespace, is) {
2341
- let options = is ? { is } : void 0;
2342
- return document.createElementNS(namespace ?? "http://www.w3.org/1999/xhtml", tag, options);
2041
+ if (namespace == null || namespace === "http://www.w3.org/1999/xhtml") return is ? document.createElement(tag, { is }) : document.createElement(tag);
2042
+ return is ? document.createElementNS(namespace, tag, { is }) : document.createElementNS(namespace, tag);
2343
2043
  }
2344
2044
  /**
2345
2045
  * Browsers split text nodes larger than 65536 bytes when parsing.
@@ -2355,26 +2055,40 @@ function merge_text_nodes(text) {
2355
2055
  next = text.nextSibling;
2356
2056
  }
2357
2057
  }
2358
- //#endregion
2359
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
2360
2058
  /**
2361
- * @template T
2362
- * @param {() => T} fn
2059
+ * @param {unknown} error
2363
2060
  */
2364
- function without_reactive_context(fn) {
2365
- var previous_reaction = active_reaction;
2366
- var previous_effect = active_effect;
2367
- set_active_reaction(null);
2368
- set_active_effect(null);
2369
- try {
2370
- return fn();
2371
- } finally {
2372
- set_active_reaction(previous_reaction);
2373
- set_active_effect(previous_effect);
2061
+ function handle_error(error) {
2062
+ var effect = active_effect;
2063
+ if (effect === null) {
2064
+ /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
2065
+ return error;
2066
+ }
2067
+ if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
2068
+ invoke_error_boundary(error, effect);
2069
+ }
2070
+ /**
2071
+ * @param {unknown} error
2072
+ * @param {Effect | null} effect
2073
+ */
2074
+ function invoke_error_boundary(error, effect) {
2075
+ if (effect !== null && (effect.f & 16384) !== 0) return;
2076
+ while (effect !== null) {
2077
+ if ((effect.f & 128) !== 0 && (effect.f & 33570816) === 0) {
2078
+ if ((effect.f & 32768) === 0) throw error;
2079
+ try {
2080
+ /** @type {Boundary} */ effect.b.error(error);
2081
+ return;
2082
+ } catch (e) {
2083
+ error = e;
2084
+ }
2085
+ }
2086
+ effect = effect.parent;
2374
2087
  }
2088
+ throw error;
2375
2089
  }
2376
2090
  //#endregion
2377
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/effects.js
2091
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/effects.js
2378
2092
  /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
2379
2093
  /**
2380
2094
  * @param {'$effect' | '$effect.pre' | '$inspect'} rune
@@ -2474,7 +2188,7 @@ function teardown(fn) {
2474
2188
  function user_effect(fn) {
2475
2189
  validate_effect("$effect");
2476
2190
  var flags = active_effect.f;
2477
- if (!active_reaction && (flags & 32) !== 0 && (flags & 32768) === 0) {
2191
+ if (!active_reaction && (flags & 32) !== 0 && component_context !== null && !component_context.i) {
2478
2192
  var context = component_context;
2479
2193
  (context.e ?? (context.e = [])).push(fn);
2480
2194
  } else return create_user_effect(fn);
@@ -2547,7 +2261,9 @@ function render_effect(fn, flags = 0) {
2547
2261
  */
2548
2262
  function template_effect(fn, sync = [], async = [], blockers = []) {
2549
2263
  flatten(blockers, sync, async, (values) => {
2550
- create_effect(8, () => fn(...values.map(get)));
2264
+ create_effect(8, () => {
2265
+ fn(...values.map(get));
2266
+ });
2551
2267
  });
2552
2268
  }
2553
2269
  /**
@@ -2575,6 +2291,8 @@ function execute_effect_teardown(effect) {
2575
2291
  set_active_reaction(null);
2576
2292
  try {
2577
2293
  teardown.call(null);
2294
+ } catch (error) {
2295
+ invoke_error_boundary(error, effect.parent);
2578
2296
  } finally {
2579
2297
  set_is_destroying_effect(previously_destroying_effect);
2580
2298
  set_active_reaction(previous_reaction);
@@ -2623,7 +2341,7 @@ function destroy_effect(effect, remove_dom = true) {
2623
2341
  remove_effect_dom(effect.nodes.start, effect.nodes.end);
2624
2342
  removed = true;
2625
2343
  }
2626
- set_signal_status(effect, DESTROYING);
2344
+ effect.f |= DESTROYING;
2627
2345
  destroy_effect_children(effect, remove_dom && !removed);
2628
2346
  remove_reactions(effect, 0);
2629
2347
  var transitions = effect.nodes && effect.nodes.t;
@@ -2677,6 +2395,7 @@ function unlink_effect(effect) {
2677
2395
  function pause_effect(effect, callback, destroy = true) {
2678
2396
  /** @type {TransitionManager[]} */
2679
2397
  var transitions = [];
2398
+ effect.f |= 256;
2680
2399
  pause_children(effect, transitions, true);
2681
2400
  var fn = () => {
2682
2401
  if (destroy) destroy_effect(effect);
@@ -2716,6 +2435,7 @@ function pause_children(effect, transitions, local) {
2716
2435
  * @param {Effect} effect
2717
2436
  */
2718
2437
  function resume_effect(effect) {
2438
+ effect.f &= -257;
2719
2439
  resume_children(effect, true);
2720
2440
  }
2721
2441
  /**
@@ -2723,6 +2443,7 @@ function resume_effect(effect) {
2723
2443
  * @param {boolean} local
2724
2444
  */
2725
2445
  function resume_children(effect, local) {
2446
+ if ((effect.f & 256) !== 0) return;
2726
2447
  if ((effect.f & 8192) === 0) return;
2727
2448
  effect.f ^= INERT;
2728
2449
  if ((effect.f & 1024) === 0) {
@@ -2758,15 +2479,18 @@ function move_effect(effect, fragment) {
2758
2479
  }
2759
2480
  }
2760
2481
  //#endregion
2761
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/legacy.js
2482
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/legacy.js
2762
2483
  /**
2763
2484
  * @type {Set<Value> | null}
2764
2485
  * @deprecated
2765
2486
  */
2766
2487
  var captured_signals = null;
2767
2488
  //#endregion
2768
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/runtime.js
2489
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/runtime.js
2769
2490
  /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
2491
+ /**
2492
+ * True if updating in an effect context that is reactive (i.e. not branch/root effects)
2493
+ */
2770
2494
  var is_updating_effect = false;
2771
2495
  var is_destroying_effect = false;
2772
2496
  /** @param {boolean} value */
@@ -2789,13 +2513,12 @@ function set_active_effect(effect) {
2789
2513
  /**
2790
2514
  * When sources are created within a reaction, reading and writing
2791
2515
  * them within that reaction should not cause a re-run
2792
- * @type {null | Source[]}
2516
+ * @type {null | Set<Source>}
2793
2517
  */
2794
2518
  var current_sources = null;
2795
2519
  /** @param {Value} value */
2796
2520
  function push_reaction_value(value) {
2797
- if (active_reaction !== null && (!async_mode_flag || (active_reaction.f & 2) !== 0)) if (current_sources === null) current_sources = [value];
2798
- else current_sources.push(value);
2521
+ if (active_reaction !== null && (!async_mode_flag || (active_reaction.f & 2) !== 0)) (current_sources ?? (current_sources = /* @__PURE__ */ new Set())).add(value);
2799
2522
  }
2800
2523
  /**
2801
2524
  * The dependencies of the reaction that is currently being executed. In many cases,
@@ -2820,7 +2543,7 @@ function set_untracked_writes(value) {
2820
2543
  * Version starts from 1 so that unowned deriveds differentiate between a created effect and a run one for tracing
2821
2544
  **/
2822
2545
  var write_version = 1;
2823
- /** @type {number} Used to version each read of a source of derived to avoid duplicating depedencies inside a reaction */
2546
+ /** @type {number} Used to version each read of a source of derived to avoid duplicating dependencies inside a reaction */
2824
2547
  var read_version = 0;
2825
2548
  var update_version = read_version;
2826
2549
  /** @param {number} value */
@@ -2860,7 +2583,7 @@ function is_dirty(reaction) {
2860
2583
  function schedule_possible_effect_self_invalidation(signal, effect, root = true) {
2861
2584
  var reactions = signal.reactions;
2862
2585
  if (reactions === null) return;
2863
- if (!async_mode_flag && current_sources !== null && includes.call(current_sources, signal)) return;
2586
+ if (!async_mode_flag && current_sources !== null && current_sources.has(signal)) return;
2864
2587
  for (var i = 0; i < reactions.length; i++) {
2865
2588
  var reaction = reactions[i];
2866
2589
  if ((reaction.f & 2) !== 0) schedule_possible_effect_self_invalidation(reaction, effect, false);
@@ -2901,24 +2624,8 @@ function update_reaction(reaction) {
2901
2624
  var fn = reaction.fn;
2902
2625
  var result = fn();
2903
2626
  reaction.f |= REACTION_RAN;
2904
- var deps = reaction.deps;
2905
- var is_fork = current_batch?.is_fork;
2906
- if (new_deps !== null) {
2907
- var i;
2908
- if (!is_fork) remove_reactions(reaction, skipped_deps);
2909
- if (deps !== null && skipped_deps > 0) {
2910
- deps.length = skipped_deps + new_deps.length;
2911
- for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
2912
- } else reaction.deps = deps = new_deps;
2913
- if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) {
2914
- var _deps$i;
2915
- ((_deps$i = deps[i]).reactions ?? (_deps$i.reactions = [])).push(reaction);
2916
- }
2917
- } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2918
- remove_reactions(reaction, skipped_deps);
2919
- deps.length = skipped_deps;
2920
- }
2921
- 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);
2627
+ var deps = update_dependencies(reaction);
2628
+ 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);
2922
2629
  if (previous_reaction !== null && previous_reaction !== reaction) {
2923
2630
  read_version++;
2924
2631
  if (previous_reaction.deps !== null) for (let i = 0; i < previous_skipped_deps; i += 1) previous_reaction.deps[i].rv = read_version;
@@ -2929,6 +2636,7 @@ function update_reaction(reaction) {
2929
2636
  if ((reaction.f & 8388608) !== 0) reaction.f ^= ERROR_VALUE;
2930
2637
  return result;
2931
2638
  } catch (error) {
2639
+ update_dependencies(reaction);
2932
2640
  return handle_error(error);
2933
2641
  } finally {
2934
2642
  reaction.f ^= REACTION_IS_UPDATING;
@@ -2943,6 +2651,29 @@ function update_reaction(reaction) {
2943
2651
  }
2944
2652
  }
2945
2653
  /**
2654
+ * @param {Reaction} reaction
2655
+ */
2656
+ function update_dependencies(reaction) {
2657
+ var deps = reaction.deps;
2658
+ var is_fork = current_batch?.is_fork;
2659
+ if (new_deps !== null) {
2660
+ var i;
2661
+ if (!is_fork) remove_reactions(reaction, skipped_deps);
2662
+ if (deps !== null && skipped_deps > 0) {
2663
+ deps.length = skipped_deps + new_deps.length;
2664
+ for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
2665
+ } else reaction.deps = deps = new_deps;
2666
+ if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) {
2667
+ var _deps$i;
2668
+ ((_deps$i = deps[i]).reactions ?? (_deps$i.reactions = [])).push(reaction);
2669
+ }
2670
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2671
+ remove_reactions(reaction, skipped_deps);
2672
+ deps.length = skipped_deps;
2673
+ }
2674
+ return deps;
2675
+ }
2676
+ /**
2946
2677
  * @template V
2947
2678
  * @param {Reaction} signal
2948
2679
  * @param {Value<V>} dependency
@@ -2968,364 +2699,834 @@ function remove_reaction(signal, dependency) {
2968
2699
  derived.f &= ~WAS_MARKED;
2969
2700
  }
2970
2701
  if (derived.v !== UNINITIALIZED) update_derived_status(derived);
2702
+ if (derived.ac !== null) without_reactive_context(() => {
2703
+ /** @type {AbortController} */ derived.ac.abort(STALE_REACTION);
2704
+ derived.ac = null;
2705
+ set_signal_status(derived, DIRTY);
2706
+ });
2971
2707
  freeze_derived_effects(derived);
2972
2708
  remove_reactions(derived, 0);
2973
2709
  }
2974
- }
2975
- /**
2976
- * @param {Reaction} signal
2977
- * @param {number} start_index
2978
- * @returns {void}
2979
- */
2980
- function remove_reactions(signal, start_index) {
2981
- var dependencies = signal.deps;
2982
- if (dependencies === null) return;
2983
- for (var i = start_index; i < dependencies.length; i++) remove_reaction(signal, dependencies[i]);
2984
- }
2985
- /**
2986
- * @param {Effect} effect
2987
- * @returns {void}
2988
- */
2989
- function update_effect(effect) {
2990
- var flags = effect.f;
2991
- if ((flags & 16384) !== 0) return;
2992
- set_signal_status(effect, CLEAN);
2993
- var previous_effect = active_effect;
2994
- var was_updating_effect = is_updating_effect;
2995
- active_effect = effect;
2996
- is_updating_effect = true;
2997
- try {
2998
- if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
2999
- else destroy_effect_children(effect);
3000
- execute_effect_teardown(effect);
3001
- var teardown = update_reaction(effect);
3002
- effect.teardown = typeof teardown === "function" ? teardown : null;
3003
- effect.wv = write_version;
3004
- } finally {
3005
- is_updating_effect = was_updating_effect;
3006
- active_effect = previous_effect;
2710
+ }
2711
+ /**
2712
+ * @param {Reaction} signal
2713
+ * @param {number} start_index
2714
+ * @returns {void}
2715
+ */
2716
+ function remove_reactions(signal, start_index) {
2717
+ var dependencies = signal.deps;
2718
+ if (dependencies === null) return;
2719
+ for (var i = start_index; i < dependencies.length; i++) remove_reaction(signal, dependencies[i]);
2720
+ }
2721
+ /**
2722
+ * @param {Effect} effect
2723
+ * @returns {void}
2724
+ */
2725
+ function update_effect(effect) {
2726
+ var flags = effect.f;
2727
+ if ((flags & 16384) !== 0) return;
2728
+ set_signal_status(effect, CLEAN);
2729
+ var previous_effect = active_effect;
2730
+ var was_updating_effect = is_updating_effect;
2731
+ active_effect = effect;
2732
+ is_updating_effect = (flags & 96) === 0;
2733
+ try {
2734
+ if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
2735
+ else destroy_effect_children(effect);
2736
+ execute_effect_teardown(effect);
2737
+ var teardown = update_reaction(effect);
2738
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2739
+ effect.wv = write_version;
2740
+ } finally {
2741
+ is_updating_effect = was_updating_effect;
2742
+ active_effect = previous_effect;
2743
+ }
2744
+ }
2745
+ /**
2746
+ * @template V
2747
+ * @param {Value<V>} signal
2748
+ * @returns {V}
2749
+ */
2750
+ function get(signal) {
2751
+ var is_derived = (signal.f & 2) !== 0;
2752
+ captured_signals?.add(signal);
2753
+ if (active_reaction !== null && !untracking) {
2754
+ if (!(active_effect !== null && (active_effect.f & 16384) !== 0) && (current_sources === null || !current_sources.has(signal))) {
2755
+ var deps = active_reaction.deps;
2756
+ if ((active_reaction.f & 2097152) !== 0) {
2757
+ if (signal.rv < read_version) {
2758
+ signal.rv = read_version;
2759
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) skipped_deps++;
2760
+ else if (new_deps === null) new_deps = [signal];
2761
+ else new_deps.push(signal);
2762
+ }
2763
+ } else {
2764
+ var _active_reaction;
2765
+ (_active_reaction = active_reaction).deps ?? (_active_reaction.deps = []);
2766
+ if (!includes.call(active_reaction.deps, signal)) active_reaction.deps.push(signal);
2767
+ var reactions = signal.reactions;
2768
+ if (reactions === null) signal.reactions = [active_reaction];
2769
+ else if (!includes.call(reactions, active_reaction)) reactions.push(active_reaction);
2770
+ }
2771
+ }
2772
+ }
2773
+ if (is_destroying_effect && old_values.has(signal)) return old_values.get(signal);
2774
+ if (is_derived) {
2775
+ var derived = signal;
2776
+ if (is_destroying_effect) {
2777
+ var value = derived.v;
2778
+ if ((derived.f & 1024) === 0 && derived.reactions !== null || depends_on_old_values(derived)) value = execute_derived(derived);
2779
+ old_values.set(derived, value);
2780
+ return value;
2781
+ }
2782
+ var should_connect = (derived.f & 512) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & 512) !== 0);
2783
+ var is_new = (derived.f & REACTION_RAN) === 0;
2784
+ if (is_dirty(derived)) {
2785
+ if (should_connect) derived.f |= 512;
2786
+ update_derived(derived);
2787
+ }
2788
+ if (should_connect && !is_new) {
2789
+ unfreeze_derived_effects(derived);
2790
+ reconnect(derived);
2791
+ }
2792
+ }
2793
+ if (batch_values?.has(signal)) return batch_values.get(signal);
2794
+ if ((signal.f & 8388608) !== 0) throw signal.v;
2795
+ return signal.v;
2796
+ }
2797
+ /**
2798
+ * (Re)connect a disconnected derived, so that it is notified
2799
+ * of changes in `mark_reactions`
2800
+ * @param {Derived} derived
2801
+ */
2802
+ function reconnect(derived) {
2803
+ derived.f |= 512;
2804
+ if (derived.deps === null) return;
2805
+ for (const dep of derived.deps) {
2806
+ (dep.reactions ?? (dep.reactions = [])).push(derived);
2807
+ if ((dep.f & 2) !== 0 && (dep.f & 512) === 0) {
2808
+ unfreeze_derived_effects(dep);
2809
+ reconnect(dep);
2810
+ }
2811
+ }
2812
+ }
2813
+ /** @param {Derived} derived */
2814
+ function depends_on_old_values(derived) {
2815
+ if (derived.v === UNINITIALIZED) return true;
2816
+ if (derived.deps === null) return false;
2817
+ for (const dep of derived.deps) {
2818
+ if (old_values.has(dep)) return true;
2819
+ if ((dep.f & 2) !== 0 && depends_on_old_values(dep)) return true;
2820
+ }
2821
+ return false;
2822
+ }
2823
+ /**
2824
+ * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect),
2825
+ * any state read inside `fn` will not be treated as a dependency.
2826
+ *
2827
+ * ```ts
2828
+ * $effect(() => {
2829
+ * // this will run when `data` changes, but not when `time` changes
2830
+ * save(data, {
2831
+ * timestamp: untrack(() => time)
2832
+ * });
2833
+ * });
2834
+ * ```
2835
+ * @template T
2836
+ * @param {() => T} fn
2837
+ * @returns {T}
2838
+ */
2839
+ function untrack(fn) {
2840
+ var previous_untracking = untracking;
2841
+ try {
2842
+ untracking = true;
2843
+ return fn();
2844
+ } finally {
2845
+ untracking = previous_untracking;
2846
+ }
2847
+ }
2848
+ //#endregion
2849
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/events.js
2850
+ /**
2851
+ * Used on elements, as a map of event type -> event handler,
2852
+ * and on events themselves to track which element handled an event
2853
+ */
2854
+ var event_symbol = Symbol("events");
2855
+ /** @type {Set<string>} */
2856
+ var all_registered_events = /* @__PURE__ */ new Set();
2857
+ /** @type {Set<(events: Array<string>) => void>} */
2858
+ var root_event_handles = /* @__PURE__ */ new Set();
2859
+ var last_propagated_event = null;
2860
+ var last_propagated_event_clear_scheduled = false;
2861
+ /**
2862
+ * @this {EventTarget}
2863
+ * @param {Event} event
2864
+ * @returns {void}
2865
+ */
2866
+ function handle_event_propagation(event) {
2867
+ var handler_element = this;
2868
+ var owner_document = handler_element.ownerDocument;
2869
+ var event_name = event.type;
2870
+ var path = event.composedPath?.() || [];
2871
+ var current_target = path[0] || event.target;
2872
+ last_propagated_event = event;
2873
+ if (!last_propagated_event_clear_scheduled) {
2874
+ last_propagated_event_clear_scheduled = true;
2875
+ setTimeout(() => {
2876
+ last_propagated_event_clear_scheduled = false;
2877
+ last_propagated_event = null;
2878
+ });
2879
+ }
2880
+ var path_idx = 0;
2881
+ var handled_at = last_propagated_event === event && event[event_symbol];
2882
+ if (handled_at) {
2883
+ var at_idx = path.indexOf(handled_at);
2884
+ if (at_idx !== -1 && (handler_element === document || handler_element === window)) {
2885
+ event[event_symbol] = handler_element;
2886
+ return;
2887
+ }
2888
+ var handler_idx = path.indexOf(handler_element);
2889
+ if (handler_idx === -1) return;
2890
+ if (at_idx <= handler_idx) path_idx = at_idx;
2891
+ }
2892
+ current_target = path[path_idx] || event.target;
2893
+ if (current_target === handler_element) return;
2894
+ define_property(event, "currentTarget", {
2895
+ configurable: true,
2896
+ get() {
2897
+ return current_target || owner_document;
2898
+ }
2899
+ });
2900
+ var previous_reaction = active_reaction;
2901
+ var previous_effect = active_effect;
2902
+ set_active_reaction(null);
2903
+ set_active_effect(null);
2904
+ try {
2905
+ /**
2906
+ * @type {unknown}
2907
+ */
2908
+ var throw_error;
2909
+ /**
2910
+ * @type {unknown[]}
2911
+ */
2912
+ var other_errors = [];
2913
+ while (current_target !== null) {
2914
+ if (current_target === handler_element) break;
2915
+ try {
2916
+ var delegated = current_target[event_symbol]?.[event_name];
2917
+ if (delegated != null && (!current_target.disabled || event.target === current_target)) delegated.call(current_target, event);
2918
+ } catch (error) {
2919
+ if (throw_error) other_errors.push(error);
2920
+ else throw_error = error;
2921
+ }
2922
+ if (event.cancelBubble) break;
2923
+ path_idx++;
2924
+ current_target = path_idx < path.length ? path[path_idx] : null;
2925
+ }
2926
+ if (throw_error) {
2927
+ for (let error of other_errors) queueMicrotask(() => {
2928
+ throw error;
2929
+ });
2930
+ throw throw_error;
2931
+ }
2932
+ } finally {
2933
+ event[event_symbol] = handler_element;
2934
+ delete event.currentTarget;
2935
+ set_active_reaction(previous_reaction);
2936
+ set_active_effect(previous_effect);
2937
+ }
2938
+ }
2939
+ //#endregion
2940
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/reconciler.js
2941
+ var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
2942
+ /** @param {string} html */
2943
+ createHTML: (html) => {
2944
+ return html;
2945
+ } });
2946
+ /** @param {string} html */
2947
+ function create_trusted_html(html) {
2948
+ return policy?.createHTML(html) ?? html;
2949
+ }
2950
+ /**
2951
+ * @param {string} html
2952
+ */
2953
+ function create_fragment_from_html(html) {
2954
+ var elem = create_element("template");
2955
+ elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
2956
+ return elem.content;
2957
+ }
2958
+ //#endregion
2959
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/template.js
2960
+ /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
2961
+ /** @import { TemplateStructure } from './types' */
2962
+ /**
2963
+ * @param {TemplateNode} start
2964
+ * @param {TemplateNode | null} end
2965
+ */
2966
+ function assign_nodes(start, end) {
2967
+ var effect = active_effect;
2968
+ if (effect.nodes === null) effect.nodes = {
2969
+ start,
2970
+ end,
2971
+ a: null,
2972
+ t: null
2973
+ };
2974
+ }
2975
+ /**
2976
+ * @param {string} content
2977
+ * @param {number} flags
2978
+ * @returns {() => Node | Node[]}
2979
+ */
2980
+ /*#__NO_SIDE_EFFECTS__*/
2981
+ function from_html(content, flags) {
2982
+ var is_fragment = (flags & 1) !== 0;
2983
+ var use_import_node = (flags & 2) !== 0;
2984
+ /** @type {Node} */
2985
+ var node;
2986
+ /**
2987
+ * Whether or not the first item is a text/element node. If not, we need to
2988
+ * create an additional comment node to act as `effect.nodes.start`
2989
+ */
2990
+ var has_start = !content.startsWith("<!>");
2991
+ return () => {
2992
+ if (hydrating) {
2993
+ assign_nodes(hydrate_node, null);
2994
+ return hydrate_node;
2995
+ }
2996
+ if (node === void 0) {
2997
+ node = create_fragment_from_html(has_start ? content : "<!>" + content);
2998
+ if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
2999
+ }
3000
+ var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
3001
+ if (is_fragment) {
3002
+ var start = /* @__PURE__ */ get_first_child(clone);
3003
+ var end = clone.lastChild;
3004
+ assign_nodes(start, end);
3005
+ } else assign_nodes(clone, clone);
3006
+ return clone;
3007
+ };
3008
+ }
3009
+ /**
3010
+ * Don't mark this as side-effect-free, hydration needs to walk all nodes
3011
+ * @param {any} value
3012
+ */
3013
+ function text(value = "") {
3014
+ if (!hydrating) {
3015
+ var t = create_text(value + "");
3016
+ assign_nodes(t, t);
3017
+ return t;
3018
+ }
3019
+ var node = hydrate_node;
3020
+ if (node.nodeType !== 3) {
3021
+ node.before(node = create_text());
3022
+ set_hydrate_node(node);
3023
+ } else merge_text_nodes(node);
3024
+ assign_nodes(node, node);
3025
+ return node;
3026
+ }
3027
+ /**
3028
+ * @returns {TemplateNode | DocumentFragment}
3029
+ */
3030
+ function comment() {
3031
+ if (hydrating) {
3032
+ assign_nodes(hydrate_node, null);
3033
+ return hydrate_node;
3034
+ }
3035
+ var frag = document.createDocumentFragment();
3036
+ var start = document.createComment("");
3037
+ var anchor = create_text();
3038
+ frag.append(start, anchor);
3039
+ assign_nodes(start, anchor);
3040
+ return frag;
3041
+ }
3042
+ /**
3043
+ * Assign the created (or in hydration mode, traversed) dom elements to the current block
3044
+ * and insert the elements into the dom (in client mode).
3045
+ * @param {Text | Comment | Element} anchor
3046
+ * @param {DocumentFragment | Element} dom
3047
+ */
3048
+ function append(anchor, dom) {
3049
+ if (hydrating) {
3050
+ var effect = active_effect;
3051
+ if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
3052
+ hydrate_next();
3053
+ return;
3054
+ }
3055
+ if (anchor === null) return;
3056
+ anchor.before(dom);
3057
+ }
3058
+ /**
3059
+ * Subset of delegated events which should be passive by default.
3060
+ * These two are already passive via browser defaults on window, document and body.
3061
+ * But since
3062
+ * - we're delegating them
3063
+ * - they happen often
3064
+ * - they apply to mobile which is generally less performant
3065
+ * we're marking them as passive by default for other elements, too.
3066
+ */
3067
+ var PASSIVE_EVENTS = ["touchstart", "touchmove"];
3068
+ /**
3069
+ * Returns `true` if `name` is a passive event
3070
+ * @param {string} name
3071
+ */
3072
+ function is_passive_event(name) {
3073
+ return PASSIVE_EVENTS.includes(name);
3074
+ }
3075
+ //#endregion
3076
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/reactivity/create-subscriber.js
3077
+ /**
3078
+ * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
3079
+ * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
3080
+ *
3081
+ * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
3082
+ * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
3083
+ *
3084
+ * If `start` returns a cleanup function, it will be called when the effect is destroyed.
3085
+ *
3086
+ * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
3087
+ * are active, and the returned teardown function will only be called when all effects are destroyed.
3088
+ *
3089
+ * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
3090
+ *
3091
+ * ```js
3092
+ * import { createSubscriber } from 'svelte/reactivity';
3093
+ * import { on } from 'svelte/events';
3094
+ *
3095
+ * export class MediaQuery {
3096
+ * #query;
3097
+ * #subscribe;
3098
+ *
3099
+ * constructor(query) {
3100
+ * this.#query = window.matchMedia(`(${query})`);
3101
+ *
3102
+ * this.#subscribe = createSubscriber((update) => {
3103
+ * // when the `change` event occurs, re-run any effects that read `this.current`
3104
+ * const off = on(this.#query, 'change', update);
3105
+ *
3106
+ * // stop listening when all the effects are destroyed
3107
+ * return () => off();
3108
+ * });
3109
+ * }
3110
+ *
3111
+ * get current() {
3112
+ * // This makes the getter reactive, if read in an effect
3113
+ * this.#subscribe();
3114
+ *
3115
+ * // Return the current state of the query, whether or not we're in an effect
3116
+ * return this.#query.matches;
3117
+ * }
3118
+ * }
3119
+ * ```
3120
+ * @param {(update: () => void) => (() => void) | void} start
3121
+ * @since 5.7.0
3122
+ */
3123
+ function createSubscriber(start) {
3124
+ let subscribers = 0;
3125
+ let version = source(0);
3126
+ /** @type {(() => void) | void} */
3127
+ let stop;
3128
+ return () => {
3129
+ if (effect_tracking()) {
3130
+ get(version);
3131
+ render_effect(() => {
3132
+ if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
3133
+ subscribers += 1;
3134
+ return () => {
3135
+ queue_micro_task(() => {
3136
+ subscribers -= 1;
3137
+ if (subscribers === 0) {
3138
+ stop?.();
3139
+ stop = void 0;
3140
+ increment(version);
3141
+ }
3142
+ });
3143
+ };
3144
+ });
3145
+ }
3146
+ };
3147
+ }
3148
+ //#endregion
3149
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
3150
+ /** @import { Effect, Source, TemplateNode, } from '#client' */
3151
+ /**
3152
+ * @typedef {{
3153
+ * onerror?: ((error: unknown, reset: () => void) => void) | null;
3154
+ * failed?: ((anchor: Node, error: () => unknown, reset: () => () => void) => void) | null;
3155
+ * pending?: ((anchor: Node) => void) | null;
3156
+ * }} BoundaryProps
3157
+ */
3158
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
3159
+ /**
3160
+ * @param {TemplateNode} node
3161
+ * @param {BoundaryProps} props
3162
+ * @param {((anchor: Node) => void)} children
3163
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
3164
+ * @returns {void}
3165
+ */
3166
+ function boundary(node, props, children, transform_error) {
3167
+ new Boundary(node, props, children, transform_error);
3168
+ }
3169
+ var _anchor = /* @__PURE__ */ new WeakMap();
3170
+ var _hydrate_open = /* @__PURE__ */ new WeakMap();
3171
+ var _props = /* @__PURE__ */ new WeakMap();
3172
+ var _children = /* @__PURE__ */ new WeakMap();
3173
+ var _effect = /* @__PURE__ */ new WeakMap();
3174
+ var _main_effect = /* @__PURE__ */ new WeakMap();
3175
+ var _pending_effect = /* @__PURE__ */ new WeakMap();
3176
+ var _failed_effect = /* @__PURE__ */ new WeakMap();
3177
+ var _offscreen_fragment = /* @__PURE__ */ new WeakMap();
3178
+ var _local_pending_count = /* @__PURE__ */ new WeakMap();
3179
+ var _pending_count = /* @__PURE__ */ new WeakMap();
3180
+ var _pending_count_update_queued = /* @__PURE__ */ new WeakMap();
3181
+ var _dirty_effects = /* @__PURE__ */ new WeakMap();
3182
+ var _maybe_dirty_effects = /* @__PURE__ */ new WeakMap();
3183
+ var _effect_pending = /* @__PURE__ */ new WeakMap();
3184
+ var _effect_pending_subscriber = /* @__PURE__ */ new WeakMap();
3185
+ var _Boundary_brand = /* @__PURE__ */ new WeakSet();
3186
+ var Boundary = class {
3187
+ /**
3188
+ * @param {TemplateNode} node
3189
+ * @param {BoundaryProps} props
3190
+ * @param {((anchor: Node) => void)} children
3191
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
3192
+ */
3193
+ constructor(node, props, children, transform_error) {
3194
+ _classPrivateMethodInitSpec(this, _Boundary_brand);
3195
+ _defineProperty(
3196
+ this,
3197
+ /** @type {Boundary | null} */
3198
+ "parent",
3199
+ void 0
3200
+ );
3201
+ _defineProperty(this, "is_pending", false);
3202
+ _defineProperty(
3203
+ this,
3204
+ /**
3205
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
3206
+ * Inherited from parent boundary, or defaults to identity.
3207
+ * @type {(error: unknown) => unknown}
3208
+ */
3209
+ "transform_error",
3210
+ void 0
3211
+ );
3212
+ _classPrivateFieldInitSpec(this, _anchor, void 0);
3213
+ _classPrivateFieldInitSpec(this, _hydrate_open, hydrating ? hydrate_node : null);
3214
+ _classPrivateFieldInitSpec(this, _props, void 0);
3215
+ _classPrivateFieldInitSpec(this, _children, void 0);
3216
+ _classPrivateFieldInitSpec(this, _effect, void 0);
3217
+ _classPrivateFieldInitSpec(this, _main_effect, null);
3218
+ _classPrivateFieldInitSpec(this, _pending_effect, null);
3219
+ _classPrivateFieldInitSpec(this, _failed_effect, null);
3220
+ _classPrivateFieldInitSpec(this, _offscreen_fragment, null);
3221
+ _classPrivateFieldInitSpec(this, _local_pending_count, 0);
3222
+ _classPrivateFieldInitSpec(this, _pending_count, 0);
3223
+ _classPrivateFieldInitSpec(this, _pending_count_update_queued, false);
3224
+ _classPrivateFieldInitSpec(this, _dirty_effects, /* @__PURE__ */ new Set());
3225
+ _classPrivateFieldInitSpec(this, _maybe_dirty_effects, /* @__PURE__ */ new Set());
3226
+ _classPrivateFieldInitSpec(this, _effect_pending, null);
3227
+ _classPrivateFieldInitSpec(this, _effect_pending_subscriber, createSubscriber(() => {
3228
+ _classPrivateFieldSet2(_effect_pending, this, source(_classPrivateFieldGet2(_local_pending_count, this)));
3229
+ return () => {
3230
+ _classPrivateFieldSet2(_effect_pending, this, null);
3231
+ };
3232
+ }));
3233
+ _classPrivateFieldSet2(_anchor, this, node);
3234
+ _classPrivateFieldSet2(_props, this, props);
3235
+ _classPrivateFieldSet2(_children, this, (anchor) => {
3236
+ var effect = active_effect;
3237
+ effect.b = this;
3238
+ effect.f |= 128;
3239
+ children(anchor);
3240
+ });
3241
+ this.parent = active_effect.b;
3242
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
3243
+ _classPrivateFieldSet2(_effect, this, block(() => {
3244
+ if (hydrating) {
3245
+ const comment = _classPrivateFieldGet2(_hydrate_open, this);
3246
+ hydrate_next();
3247
+ const server_rendered_pending = comment.data === "[!";
3248
+ if (comment.data.startsWith("[?")) {
3249
+ const serialized_error = JSON.parse(comment.data.slice(2));
3250
+ _assertClassBrand(_Boundary_brand, this, _hydrate_failed_content).call(this, serialized_error);
3251
+ } else if (server_rendered_pending) _assertClassBrand(_Boundary_brand, this, _hydrate_pending_content).call(this);
3252
+ else _assertClassBrand(_Boundary_brand, this, _hydrate_resolved_content).call(this);
3253
+ } else _assertClassBrand(_Boundary_brand, this, _render).call(this);
3254
+ }, flags));
3255
+ if (hydrating) _classPrivateFieldSet2(_anchor, this, hydrate_node);
3256
+ }
3257
+ /**
3258
+ * Defer an effect inside a pending boundary until the boundary resolves
3259
+ * @param {Effect} effect
3260
+ */
3261
+ defer_effect(effect) {
3262
+ defer_effect(effect, _classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
3263
+ }
3264
+ /**
3265
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
3266
+ * @returns {boolean}
3267
+ */
3268
+ is_rendered() {
3269
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
3007
3270
  }
3008
- }
3009
- /**
3010
- * @template V
3011
- * @param {Value<V>} signal
3012
- * @returns {V}
3013
- */
3014
- function get(signal) {
3015
- var is_derived = (signal.f & 2) !== 0;
3016
- captured_signals?.add(signal);
3017
- if (active_reaction !== null && !untracking) {
3018
- if (!(active_effect !== null && (active_effect.f & 16384) !== 0) && (current_sources === null || !includes.call(current_sources, signal))) {
3019
- var deps = active_reaction.deps;
3020
- if ((active_reaction.f & 2097152) !== 0) {
3021
- if (signal.rv < read_version) {
3022
- signal.rv = read_version;
3023
- if (new_deps === null && deps !== null && deps[skipped_deps] === signal) skipped_deps++;
3024
- else if (new_deps === null) new_deps = [signal];
3025
- else new_deps.push(signal);
3026
- }
3027
- } else {
3028
- var _active_reaction;
3029
- ((_active_reaction = active_reaction).deps ?? (_active_reaction.deps = [])).push(signal);
3030
- var reactions = signal.reactions;
3031
- if (reactions === null) signal.reactions = [active_reaction];
3032
- else if (!includes.call(reactions, active_reaction)) reactions.push(active_reaction);
3033
- }
3034
- }
3271
+ has_pending_snippet() {
3272
+ return !!_classPrivateFieldGet2(_props, this).pending;
3035
3273
  }
3036
- if (is_destroying_effect && old_values.has(signal)) return old_values.get(signal);
3037
- if (is_derived) {
3038
- var derived = signal;
3039
- if (is_destroying_effect) {
3040
- var value = derived.v;
3041
- if ((derived.f & 1024) === 0 && derived.reactions !== null || depends_on_old_values(derived)) value = execute_derived(derived);
3042
- old_values.set(derived, value);
3043
- return value;
3044
- }
3045
- var should_connect = (derived.f & 512) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & 512) !== 0);
3046
- var is_new = (derived.f & REACTION_RAN) === 0;
3047
- if (is_dirty(derived)) {
3048
- if (should_connect) derived.f |= 512;
3049
- update_derived(derived);
3050
- }
3051
- if (should_connect && !is_new) {
3052
- unfreeze_derived_effects(derived);
3053
- reconnect(derived);
3054
- }
3274
+ /**
3275
+ * Update the source that powers `$effect.pending()` inside this boundary,
3276
+ * and controls when the current `pending` snippet (if any) is removed.
3277
+ * Do not call from inside the class
3278
+ * @param {1 | -1} d
3279
+ * @param {Batch} batch
3280
+ */
3281
+ update_pending_count(d, batch) {
3282
+ _assertClassBrand(_Boundary_brand, this, _update_pending_count).call(this, d, batch);
3283
+ _classPrivateFieldSet2(_local_pending_count, this, _classPrivateFieldGet2(_local_pending_count, this) + d);
3284
+ if (!_classPrivateFieldGet2(_effect_pending, this) || _classPrivateFieldGet2(_pending_count_update_queued, this)) return;
3285
+ _classPrivateFieldSet2(_pending_count_update_queued, this, true);
3286
+ queue_micro_task(() => {
3287
+ _classPrivateFieldSet2(_pending_count_update_queued, this, false);
3288
+ if (_classPrivateFieldGet2(_effect_pending, this)) internal_set(_classPrivateFieldGet2(_effect_pending, this), _classPrivateFieldGet2(_local_pending_count, this));
3289
+ });
3055
3290
  }
3056
- if (batch_values?.has(signal)) return batch_values.get(signal);
3057
- if ((signal.f & 8388608) !== 0) throw signal.v;
3058
- return signal.v;
3059
- }
3060
- /**
3061
- * (Re)connect a disconnected derived, so that it is notified
3062
- * of changes in `mark_reactions`
3063
- * @param {Derived} derived
3064
- */
3065
- function reconnect(derived) {
3066
- derived.f |= 512;
3067
- if (derived.deps === null) return;
3068
- for (const dep of derived.deps) {
3069
- (dep.reactions ?? (dep.reactions = [])).push(derived);
3070
- if ((dep.f & 2) !== 0 && (dep.f & 512) === 0) {
3071
- unfreeze_derived_effects(dep);
3072
- reconnect(dep);
3073
- }
3291
+ get_effect_pending() {
3292
+ _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
3293
+ return get(_classPrivateFieldGet2(_effect_pending, this));
3074
3294
  }
3075
- }
3076
- /** @param {Derived} derived */
3077
- function depends_on_old_values(derived) {
3078
- if (derived.v === UNINITIALIZED) return true;
3079
- if (derived.deps === null) return false;
3080
- for (const dep of derived.deps) {
3081
- if (old_values.has(dep)) return true;
3082
- if ((dep.f & 2) !== 0 && depends_on_old_values(dep)) return true;
3295
+ /** @param {unknown} error */
3296
+ error(error) {
3297
+ if (!_classPrivateFieldGet2(_props, this).onerror && !_classPrivateFieldGet2(_props, this).failed) throw error;
3298
+ if (current_batch?.is_fork) {
3299
+ if (_classPrivateFieldGet2(_main_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_main_effect, this));
3300
+ if (_classPrivateFieldGet2(_pending_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_pending_effect, this));
3301
+ if (_classPrivateFieldGet2(_failed_effect, this)) current_batch.skip_effect(_classPrivateFieldGet2(_failed_effect, this));
3302
+ current_batch.oncommit(() => {
3303
+ _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
3304
+ });
3305
+ } else _assertClassBrand(_Boundary_brand, this, _handle_error).call(this, error);
3083
3306
  }
3084
- return false;
3085
- }
3086
- /**
3087
- * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect),
3088
- * any state read inside `fn` will not be treated as a dependency.
3089
- *
3090
- * ```ts
3091
- * $effect(() => {
3092
- * // this will run when `data` changes, but not when `time` changes
3093
- * save(data, {
3094
- * timestamp: untrack(() => time)
3095
- * });
3096
- * });
3097
- * ```
3098
- * @template T
3099
- * @param {() => T} fn
3100
- * @returns {T}
3101
- */
3102
- function untrack(fn) {
3103
- var previous_untracking = untracking;
3307
+ };
3308
+ function _hydrate_resolved_content() {
3104
3309
  try {
3105
- untracking = true;
3106
- return fn();
3107
- } finally {
3108
- untracking = previous_untracking;
3310
+ _classPrivateFieldSet2(_main_effect, this, branch(() => _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this))));
3311
+ } catch (error) {
3312
+ this.error(error);
3109
3313
  }
3110
3314
  }
3111
- //#endregion
3112
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/elements/events.js
3113
3315
  /**
3114
- * Used on elements, as a map of event type -> event handler,
3115
- * and on events themselves to track which element handled an event
3316
+ * @param {unknown} error The deserialized error from the server's hydration comment
3116
3317
  */
3117
- var event_symbol = Symbol("events");
3118
- /** @type {Set<string>} */
3119
- var all_registered_events = /* @__PURE__ */ new Set();
3120
- /** @type {Set<(events: Array<string>) => void>} */
3121
- var root_event_handles = /* @__PURE__ */ new Set();
3122
- var last_propagated_event = null;
3318
+ function _hydrate_failed_content(error) {
3319
+ const failed = _classPrivateFieldGet2(_props, this).failed;
3320
+ const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, error);
3321
+ queue_micro_task(invoke_onerror);
3322
+ if (!failed) return;
3323
+ _classPrivateFieldSet2(_failed_effect, this, branch(() => {
3324
+ failed(_classPrivateFieldGet2(_anchor, this), () => error, () => reset);
3325
+ }));
3326
+ }
3123
3327
  /**
3124
- * @this {EventTarget}
3125
- * @param {Event} event
3126
- * @returns {void}
3328
+ * Creates the `reset` function for a failed boundary, along with a function
3329
+ * that invokes `onerror` with it (if provided)
3330
+ * @param {unknown} error
3331
+ * @returns {{ reset: () => void, invoke_onerror: () => void }}
3127
3332
  */
3128
- function handle_event_propagation(event) {
3129
- var handler_element = this;
3130
- var owner_document = handler_element.ownerDocument;
3131
- var event_name = event.type;
3132
- var path = event.composedPath?.() || [];
3133
- var current_target = path[0] || event.target;
3134
- last_propagated_event = event;
3135
- var path_idx = 0;
3136
- var handled_at = last_propagated_event === event && event[event_symbol];
3137
- if (handled_at) {
3138
- var at_idx = path.indexOf(handled_at);
3139
- if (at_idx !== -1 && (handler_element === document || handler_element === window)) {
3140
- event[event_symbol] = handler_element;
3333
+ function _create_reset(error) {
3334
+ var did_reset = false;
3335
+ var calling_on_error = false;
3336
+ const reset = () => {
3337
+ if (did_reset) {
3338
+ svelte_boundary_reset_noop();
3141
3339
  return;
3142
3340
  }
3143
- var handler_idx = path.indexOf(handler_element);
3144
- if (handler_idx === -1) return;
3145
- if (at_idx <= handler_idx) path_idx = at_idx;
3146
- }
3147
- current_target = path[path_idx] || event.target;
3148
- if (current_target === handler_element) return;
3149
- define_property(event, "currentTarget", {
3150
- configurable: true,
3151
- get() {
3152
- return current_target || owner_document;
3341
+ did_reset = true;
3342
+ if (calling_on_error) svelte_boundary_reset_onerror();
3343
+ if (_classPrivateFieldGet2(_failed_effect, this) !== null) pause_effect(_classPrivateFieldGet2(_failed_effect, this), () => {
3344
+ _classPrivateFieldSet2(_failed_effect, this, null);
3345
+ });
3346
+ _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
3347
+ _assertClassBrand(_Boundary_brand, this, _render).call(this);
3348
+ });
3349
+ };
3350
+ const invoke_onerror = () => {
3351
+ try {
3352
+ calling_on_error = true;
3353
+ _classPrivateFieldGet2(_props, this).onerror?.(error, reset);
3354
+ calling_on_error = false;
3355
+ } catch (err) {
3356
+ invoke_error_boundary(err, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
3153
3357
  }
3154
- });
3155
- var previous_reaction = active_reaction;
3156
- var previous_effect = active_effect;
3157
- set_active_reaction(null);
3158
- set_active_effect(null);
3159
- try {
3160
- /**
3161
- * @type {unknown}
3162
- */
3163
- var throw_error;
3164
- /**
3165
- * @type {unknown[]}
3166
- */
3167
- var other_errors = [];
3168
- while (current_target !== null) {
3169
- /** @type {null | Element} */
3170
- var parent_element = current_target.assignedSlot || current_target.parentNode || current_target.host || null;
3358
+ };
3359
+ return {
3360
+ reset,
3361
+ invoke_onerror
3362
+ };
3363
+ }
3364
+ function _hydrate_pending_content() {
3365
+ const pending = _classPrivateFieldGet2(_props, this).pending;
3366
+ if (!pending) return;
3367
+ this.is_pending = true;
3368
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
3369
+ queue_micro_task(() => {
3370
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
3371
+ var anchor = create_text();
3372
+ var handled = false;
3373
+ fragment.append(anchor);
3374
+ _classPrivateFieldSet2(_main_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
3171
3375
  try {
3172
- var delegated = current_target[event_symbol]?.[event_name];
3173
- if (delegated != null && (!current_target.disabled || event.target === current_target)) delegated.call(current_target, event);
3376
+ return branch(() => _classPrivateFieldGet2(_children, this).call(this, anchor));
3174
3377
  } catch (error) {
3175
- if (throw_error) other_errors.push(error);
3176
- else throw_error = error;
3378
+ try {
3379
+ this.error(error);
3380
+ handled = true;
3381
+ } catch (error) {
3382
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
3383
+ }
3384
+ return null;
3177
3385
  }
3178
- if (event.cancelBubble || parent_element === handler_element || parent_element === null) break;
3179
- current_target = parent_element;
3386
+ }));
3387
+ if (_classPrivateFieldGet2(_main_effect, this) === null) {
3388
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
3389
+ if (handled) _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
3390
+ return;
3180
3391
  }
3181
- if (throw_error) {
3182
- for (let error of other_errors) queueMicrotask(() => {
3183
- throw error;
3392
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
3393
+ _classPrivateFieldGet2(_anchor, this).before(fragment);
3394
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
3395
+ pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
3396
+ _classPrivateFieldSet2(_pending_effect, this, null);
3184
3397
  });
3185
- throw throw_error;
3398
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
3186
3399
  }
3187
- } finally {
3188
- event[event_symbol] = handler_element;
3189
- delete event.currentTarget;
3190
- set_active_reaction(previous_reaction);
3191
- set_active_effect(previous_effect);
3192
- }
3400
+ });
3193
3401
  }
3194
- //#endregion
3195
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/reconciler.js
3196
- var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
3197
- /** @param {string} html */
3198
- createHTML: (html) => {
3199
- return html;
3200
- } });
3201
- /** @param {string} html */
3202
- function create_trusted_html(html) {
3203
- return policy?.createHTML(html) ?? html;
3402
+ function _render() {
3403
+ try {
3404
+ this.is_pending = this.has_pending_snippet();
3405
+ _classPrivateFieldSet2(_pending_count, this, 0);
3406
+ _classPrivateFieldSet2(_local_pending_count, this, 0);
3407
+ _classPrivateFieldSet2(_main_effect, this, branch(() => {
3408
+ _classPrivateFieldGet2(_children, this).call(this, _classPrivateFieldGet2(_anchor, this));
3409
+ }));
3410
+ if (_classPrivateFieldGet2(_pending_count, this) > 0) {
3411
+ var fragment = _classPrivateFieldSet2(_offscreen_fragment, this, document.createDocumentFragment());
3412
+ move_effect(_classPrivateFieldGet2(_main_effect, this), fragment);
3413
+ const pending = _classPrivateFieldGet2(_props, this).pending;
3414
+ _classPrivateFieldSet2(_pending_effect, this, branch(() => pending(_classPrivateFieldGet2(_anchor, this))));
3415
+ } else _assertClassBrand(_Boundary_brand, this, _resolve).call(this, current_batch);
3416
+ } catch (error) {
3417
+ this.error(error);
3418
+ }
3204
3419
  }
3205
3420
  /**
3206
- * @param {string} html
3421
+ * @param {Batch} batch
3207
3422
  */
3208
- function create_fragment_from_html(html) {
3209
- var elem = create_element("template");
3210
- elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
3211
- return elem.content;
3423
+ function _resolve(batch) {
3424
+ this.is_pending = false;
3425
+ batch.transfer_effects(_classPrivateFieldGet2(_dirty_effects, this), _classPrivateFieldGet2(_maybe_dirty_effects, this));
3212
3426
  }
3213
- //#endregion
3214
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/template.js
3215
- /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
3216
- /** @import { TemplateStructure } from './types' */
3217
3427
  /**
3218
- * @param {TemplateNode} start
3219
- * @param {TemplateNode | null} end
3428
+ * @template T
3429
+ * @param {() => T} fn
3220
3430
  */
3221
- function assign_nodes(start, end) {
3222
- var effect = active_effect;
3223
- if (effect.nodes === null) effect.nodes = {
3224
- start,
3225
- end,
3226
- a: null,
3227
- t: null
3228
- };
3431
+ function _run(fn) {
3432
+ var previous_effect = active_effect;
3433
+ var previous_reaction = active_reaction;
3434
+ var previous_ctx = component_context;
3435
+ set_active_effect(_classPrivateFieldGet2(_effect, this));
3436
+ set_active_reaction(_classPrivateFieldGet2(_effect, this));
3437
+ set_component_context(_classPrivateFieldGet2(_effect, this).ctx);
3438
+ try {
3439
+ Batch.ensure();
3440
+ return fn();
3441
+ } finally {
3442
+ set_active_effect(previous_effect);
3443
+ set_active_reaction(previous_reaction);
3444
+ set_component_context(previous_ctx);
3445
+ }
3229
3446
  }
3230
3447
  /**
3231
- * @param {string} content
3232
- * @param {number} flags
3233
- * @returns {() => Node | Node[]}
3448
+ * Updates the pending count associated with the currently visible pending snippet,
3449
+ * if any, such that we can replace the snippet with content once work is done
3450
+ * @param {1 | -1} d
3451
+ * @param {Batch} batch
3234
3452
  */
3235
- /* @__NO_SIDE_EFFECTS__ */
3236
- function from_html(content, flags) {
3237
- var is_fragment = (flags & 1) !== 0;
3238
- var use_import_node = (flags & 2) !== 0;
3239
- /** @type {Node} */
3240
- var node;
3241
- /**
3242
- * Whether or not the first item is a text/element node. If not, we need to
3243
- * create an additional comment node to act as `effect.nodes.start`
3244
- */
3245
- var has_start = !content.startsWith("<!>");
3246
- return () => {
3247
- if (hydrating) {
3248
- assign_nodes(hydrate_node, null);
3249
- return hydrate_node;
3453
+ function _update_pending_count(d, batch) {
3454
+ if (!this.has_pending_snippet()) {
3455
+ if (this.parent) {
3456
+ var _this$parent;
3457
+ _assertClassBrand(_Boundary_brand, _this$parent = this.parent, _update_pending_count).call(_this$parent, d, batch);
3250
3458
  }
3251
- if (node === void 0) {
3252
- node = create_fragment_from_html(has_start ? content : "<!>" + content);
3253
- if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
3459
+ return;
3460
+ }
3461
+ _classPrivateFieldSet2(_pending_count, this, _classPrivateFieldGet2(_pending_count, this) + d);
3462
+ if (_classPrivateFieldGet2(_pending_count, this) === 0) {
3463
+ _assertClassBrand(_Boundary_brand, this, _resolve).call(this, batch);
3464
+ if (_classPrivateFieldGet2(_pending_effect, this)) pause_effect(_classPrivateFieldGet2(_pending_effect, this), () => {
3465
+ _classPrivateFieldSet2(_pending_effect, this, null);
3466
+ });
3467
+ if (_classPrivateFieldGet2(_offscreen_fragment, this)) {
3468
+ _classPrivateFieldGet2(_anchor, this).before(_classPrivateFieldGet2(_offscreen_fragment, this));
3469
+ _classPrivateFieldSet2(_offscreen_fragment, this, null);
3254
3470
  }
3255
- var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
3256
- if (is_fragment) {
3257
- var start = /* @__PURE__ */ get_first_child(clone);
3258
- var end = clone.lastChild;
3259
- assign_nodes(start, end);
3260
- } else assign_nodes(clone, clone);
3261
- return clone;
3262
- };
3263
- }
3264
- /**
3265
- * Don't mark this as side-effect-free, hydration needs to walk all nodes
3266
- * @param {any} value
3267
- */
3268
- function text(value = "") {
3269
- if (!hydrating) {
3270
- var t = create_text(value + "");
3271
- assign_nodes(t, t);
3272
- return t;
3273
3471
  }
3274
- var node = hydrate_node;
3275
- if (node.nodeType !== 3) {
3276
- node.before(node = create_text());
3277
- set_hydrate_node(node);
3278
- } else merge_text_nodes(node);
3279
- assign_nodes(node, node);
3280
- return node;
3281
3472
  }
3282
3473
  /**
3283
- * @returns {TemplateNode | DocumentFragment}
3474
+ * @param {unknown} error
3284
3475
  */
3285
- function comment() {
3286
- if (hydrating) {
3287
- assign_nodes(hydrate_node, null);
3288
- return hydrate_node;
3476
+ function _handle_error(error) {
3477
+ if (_classPrivateFieldGet2(_main_effect, this)) {
3478
+ destroy_effect(_classPrivateFieldGet2(_main_effect, this));
3479
+ _classPrivateFieldSet2(_main_effect, this, null);
3480
+ }
3481
+ if (_classPrivateFieldGet2(_pending_effect, this)) {
3482
+ destroy_effect(_classPrivateFieldGet2(_pending_effect, this));
3483
+ _classPrivateFieldSet2(_pending_effect, this, null);
3484
+ }
3485
+ if (_classPrivateFieldGet2(_failed_effect, this)) {
3486
+ destroy_effect(_classPrivateFieldGet2(_failed_effect, this));
3487
+ _classPrivateFieldSet2(_failed_effect, this, null);
3289
3488
  }
3290
- var frag = document.createDocumentFragment();
3291
- var start = document.createComment("");
3292
- var anchor = create_text();
3293
- frag.append(start, anchor);
3294
- assign_nodes(start, anchor);
3295
- return frag;
3296
- }
3297
- /**
3298
- * Assign the created (or in hydration mode, traversed) dom elements to the current block
3299
- * and insert the elements into the dom (in client mode).
3300
- * @param {Text | Comment | Element} anchor
3301
- * @param {DocumentFragment | Element} dom
3302
- */
3303
- function append(anchor, dom) {
3304
3489
  if (hydrating) {
3305
- var effect = active_effect;
3306
- if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
3307
- hydrate_next();
3308
- return;
3490
+ set_hydrate_node(_classPrivateFieldGet2(_hydrate_open, this));
3491
+ next();
3492
+ set_hydrate_node(skip_nodes());
3309
3493
  }
3310
- if (anchor === null) return;
3311
- anchor.before(dom);
3312
- }
3313
- /**
3314
- * Subset of delegated events which should be passive by default.
3315
- * These two are already passive via browser defaults on window, document and body.
3316
- * But since
3317
- * - we're delegating them
3318
- * - they happen often
3319
- * - they apply to mobile which is generally less performant
3320
- * we're marking them as passive by default for other elements, too.
3321
- */
3322
- var PASSIVE_EVENTS = ["touchstart", "touchmove"];
3323
- /**
3324
- * Returns `true` if `name` is a passive event
3325
- * @param {string} name
3326
- */
3327
- function is_passive_event(name) {
3328
- return PASSIVE_EVENTS.includes(name);
3494
+ let failed = _classPrivateFieldGet2(_props, this).failed;
3495
+ /** @param {unknown} transformed_error */
3496
+ const handle_error_result = (transformed_error) => {
3497
+ const { reset, invoke_onerror } = _assertClassBrand(_Boundary_brand, this, _create_reset).call(this, transformed_error);
3498
+ invoke_onerror();
3499
+ if (failed) _classPrivateFieldSet2(_failed_effect, this, _assertClassBrand(_Boundary_brand, this, _run).call(this, () => {
3500
+ try {
3501
+ return branch(() => {
3502
+ var effect = active_effect;
3503
+ effect.b = this;
3504
+ effect.f |= 128;
3505
+ failed(_classPrivateFieldGet2(_anchor, this), () => transformed_error, () => reset);
3506
+ });
3507
+ } catch (error) {
3508
+ invoke_error_boundary(error, _classPrivateFieldGet2(_effect, this).parent);
3509
+ return null;
3510
+ }
3511
+ }));
3512
+ };
3513
+ queue_micro_task(() => {
3514
+ /** @type {unknown} */
3515
+ var result;
3516
+ try {
3517
+ result = this.transform_error(error);
3518
+ } catch (e) {
3519
+ invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent);
3520
+ return;
3521
+ }
3522
+ if (result !== null && typeof result === "object" && typeof result.then === "function")
3523
+ /** @type {any} */ result.then(
3524
+ handle_error_result,
3525
+ /** @param {unknown} e */
3526
+ (e) => invoke_error_boundary(e, _classPrivateFieldGet2(_effect, this) && _classPrivateFieldGet2(_effect, this).parent)
3527
+ );
3528
+ else handle_error_result(result);
3529
+ });
3329
3530
  }
3330
3531
  /**
3331
3532
  * @param {Element} text
@@ -3334,8 +3535,8 @@ function is_passive_event(name) {
3334
3535
  */
3335
3536
  function set_text(text, value) {
3336
3537
  var str = value == null ? "" : typeof value === "object" ? `${value}` : value;
3337
- if (str !== (text.__t ?? (text.__t = text.nodeValue))) {
3338
- text.__t = str;
3538
+ if (str !== (text[TEXT_CACHE] ?? (text[TEXT_CACHE] = text.nodeValue))) {
3539
+ /** @type {any} */ text[TEXT_CACHE] = str;
3339
3540
  text.nodeValue = `${str}`;
3340
3541
  }
3341
3542
  }
@@ -3429,7 +3630,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
3429
3630
  if (events)
3430
3631
  /** @type {any} */ props.$$events = events;
3431
3632
  if (hydrating) assign_nodes(anchor_node, null);
3432
- component = Component(anchor_node, props) || {};
3633
+ component = Component(anchor_node, props) || mark_as_component();
3433
3634
  if (hydrating) {
3434
3635
  /** @type {Effect & { nodes: EffectNodes }} */ active_effect.nodes.end = hydrate_node;
3435
3636
  if (hydrate_node === null || hydrate_node.nodeType !== 8 || hydrate_node.data !== "]") {
@@ -3515,7 +3716,7 @@ function unmount(component, options) {
3515
3716
  return Promise.resolve();
3516
3717
  }
3517
3718
  //#endregion
3518
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3719
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3519
3720
  /** @import { Effect, TemplateNode } from '#client' */
3520
3721
  var _batches = /* @__PURE__ */ new WeakMap();
3521
3722
  var _onscreen = /* @__PURE__ */ new WeakMap();
@@ -3557,6 +3758,7 @@ var BranchManager = class {
3557
3758
  } else {
3558
3759
  var offscreen = _classPrivateFieldGet2(_offscreen, this).get(key);
3559
3760
  if (offscreen) {
3761
+ resume_effect(offscreen.effect);
3560
3762
  _classPrivateFieldGet2(_onscreen, this).set(key, offscreen.effect);
3561
3763
  _classPrivateFieldGet2(_offscreen, this).delete(key);
3562
3764
  /** @type {TemplateNode} */ offscreen.fragment.lastChild.remove();
@@ -3637,7 +3839,7 @@ var BranchManager = class {
3637
3839
  }
3638
3840
  };
3639
3841
  //#endregion
3640
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/blocks/if.js
3842
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/if.js
3641
3843
  /** @import { TemplateNode } from '#client' */
3642
3844
  /**
3643
3845
  * @param {TemplateNode} node
@@ -3683,7 +3885,7 @@ function if_block(node, fn, elseif = false) {
3683
3885
  }, flags);
3684
3886
  }
3685
3887
  //#endregion
3686
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/blocks/each.js
3888
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/each.js
3687
3889
  /** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */
3688
3890
  /** @import { Batch } from '../../reactivity/batch.js'; */
3689
3891
  /**
@@ -3723,7 +3925,7 @@ function pause_effects(state, to_destroy, controlled_anchor) {
3723
3925
  }, false);
3724
3926
  }
3725
3927
  if (remaining === 0) {
3726
- var fast_path = transitions.length === 0 && controlled_anchor !== null;
3928
+ var fast_path = transitions.length === 0 && controlled_anchor !== null && state.pending.size === 0;
3727
3929
  if (fast_path) {
3728
3930
  var anchor = controlled_anchor;
3729
3931
  var parent_node = anchor.parentNode;
@@ -4155,13 +4357,14 @@ function html(node, get_value, is_controlled = false, svg = false, mathml = fals
4155
4357
  });
4156
4358
  }
4157
4359
  //#endregion
4158
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/css.js
4360
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/css.js
4159
4361
  /**
4160
4362
  * @param {Node} anchor
4161
4363
  * @param {{ hash: string, code: string }} css
4162
4364
  */
4163
4365
  function append_styles(anchor, css) {
4164
4366
  effect(() => {
4367
+ anchor = active_effect?.parent?.nodes?.start ?? anchor;
4165
4368
  var root = anchor.getRootNode();
4166
4369
  var target = root.host ? root : /** @type {Document} */ root.head ?? root.ownerDocument.head;
4167
4370
  if (!target.querySelector("#" + css.hash)) {
@@ -4173,7 +4376,7 @@ function append_styles(anchor, css) {
4173
4376
  });
4174
4377
  }
4175
4378
  //#endregion
4176
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/elements/attributes.js
4379
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/attributes.js
4177
4380
  /** @import { Blocker, Effect } from '#client' */
4178
4381
  var IS_CUSTOM_ELEMENT = Symbol("is custom element");
4179
4382
  var IS_HTML = Symbol("is html");
@@ -4196,7 +4399,7 @@ function set_attribute(element, attribute, value, skip_warning) {
4196
4399
  if (attributes[attribute] === (attributes[attribute] = value)) return;
4197
4400
  if (attribute === "loading") element[LOADING_ATTR_SYMBOL] = value;
4198
4401
  if (value == null) element.removeAttribute(attribute);
4199
- else if (typeof value !== "string" && get_setters(element).includes(attribute)) element[attribute] = value;
4402
+ else if (typeof value !== "string" && get_setters(element).has(attribute)) element[attribute] = value;
4200
4403
  else element.setAttribute(attribute, value);
4201
4404
  }
4202
4405
  /**
@@ -4204,31 +4407,31 @@ function set_attribute(element, attribute, value, skip_warning) {
4204
4407
  * @param {Element} element
4205
4408
  */
4206
4409
  function get_attributes(element) {
4207
- return element.__attributes ?? (element.__attributes = {
4410
+ return element[ATTRIBUTES_CACHE] ?? (element[ATTRIBUTES_CACHE] = {
4208
4411
  [IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"),
4209
4412
  [IS_HTML]: element.namespaceURI === "http://www.w3.org/1999/xhtml"
4210
4413
  });
4211
4414
  }
4212
- /** @type {Map<string, string[]>} */
4415
+ /** @type {Map<string, Set<string>>} */
4213
4416
  var setters_cache = /* @__PURE__ */ new Map();
4214
4417
  /** @param {Element} element */
4215
4418
  function get_setters(element) {
4216
4419
  var cache_key = element.getAttribute("is") || element.nodeName;
4217
4420
  var setters = setters_cache.get(cache_key);
4218
4421
  if (setters) return setters;
4219
- setters_cache.set(cache_key, setters = []);
4422
+ setters_cache.set(cache_key, setters = /* @__PURE__ */ new Set());
4220
4423
  var descriptors;
4221
4424
  var proto = element;
4222
4425
  var element_proto = Element.prototype;
4223
4426
  while (element_proto !== proto) {
4224
4427
  descriptors = get_descriptors(proto);
4225
- for (var key in descriptors) if (descriptors[key].set) setters.push(key);
4428
+ for (var key in descriptors) if (descriptors[key].set && key !== "innerHTML" && key !== "textContent" && key !== "innerText") setters.add(key);
4226
4429
  proto = get_prototype_of(proto);
4227
4430
  }
4228
4431
  return setters;
4229
4432
  }
4230
4433
  //#endregion
4231
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
4434
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
4232
4435
  var _ResizeObserverSingleton;
4233
4436
  var _listeners = /* @__PURE__ */ new WeakMap();
4234
4437
  var _observer = /* @__PURE__ */ new WeakMap();
@@ -4280,8 +4483,8 @@ function _getObserver() {
4280
4483
  }
4281
4484
  _defineProperty(ResizeObserverSingleton, "entries", /* @__PURE__ */ new WeakMap());
4282
4485
  //#endregion
4283
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/reactivity/props.js
4284
- /** @import { Effect, Source } from './types.js' */
4486
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/props.js
4487
+ /** @import { Derived, Effect, Source } from './types.js' */
4285
4488
  /**
4286
4489
  * This function is responsible for synchronizing a possibly bound prop with the inner component state.
4287
4490
  * It is used whenever the compiler sees that the component writes to the prop, or when it has a default prop_value.
@@ -4298,7 +4501,12 @@ function prop(props, key, flags, fallback) {
4298
4501
  var lazy = (flags & 16) !== 0;
4299
4502
  var fallback_value = fallback;
4300
4503
  var fallback_dirty = true;
4504
+ var fallback_signal = void 0;
4301
4505
  var get_fallback = () => {
4506
+ if (lazy && runes) {
4507
+ fallback_signal ?? (fallback_signal = /* @__PURE__ */ derived(fallback));
4508
+ return get(fallback_signal);
4509
+ }
4302
4510
  if (fallback_dirty) {
4303
4511
  fallback_dirty = false;
4304
4512
  fallback_value = lazy ? untrack(fallback) : fallback;
@@ -4368,7 +4576,7 @@ function prop(props, key, flags, fallback) {
4368
4576
  });
4369
4577
  }
4370
4578
  //#endregion
4371
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/legacy/legacy-client.js
4579
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/legacy/legacy-client.js
4372
4580
  /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
4373
4581
  /**
4374
4582
  * Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
@@ -4487,7 +4695,7 @@ var Svelte4Component = class {
4487
4695
  }
4488
4696
  };
4489
4697
  //#endregion
4490
- //#region ../../../node_modules/.bun/svelte@5.55.5/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
4698
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
4491
4699
  /**
4492
4700
  * @typedef {Object} CustomElementPropDefinition
4493
4701
  * @property {string} [attribute]
@@ -4773,18 +4981,18 @@ function create_custom_element(Component, props_definition, slots, exports, shad
4773
4981
  }
4774
4982
  //#endregion
4775
4983
  //#region src/print/Print.svelte
4776
- var root_1 = /* @__PURE__ */ from_html(`<div class="mb-4 prose prose-sm svelte-1fx5wwa"></div>`);
4777
- var root_2 = /* @__PURE__ */ from_html(`<div class="mb-2 prose prose-sm svelte-1fx5wwa"></div>`);
4778
- var root_4 = /* @__PURE__ */ from_html(`<img class="max-h-14 object-contain"/>`);
4984
+ var root = /* @__PURE__ */ from_html(`<div class="mb-4 prose prose-sm svelte-1fx5wwa"></div>`);
4985
+ var root_1 = /* @__PURE__ */ from_html(`<div class="mb-2 prose prose-sm svelte-1fx5wwa"></div>`);
4986
+ var root_2 = /* @__PURE__ */ from_html(`<img class="max-h-14 object-contain"/>`);
4779
4987
  var root_3 = /* @__PURE__ */ from_html(`<div class="mb-4 prose prose-sm svelte-1fx5wwa"><!> <span class="inline-block min-w-[6rem] border-b-2 border-gray-600 print:border-black px-1"><!></span> <!></div>`);
4780
- var root_8 = /* @__PURE__ */ from_html(`<div><strong>Audio:</strong> </div>`);
4781
- var root_9 = /* @__PURE__ */ from_html(`<div><strong>Transcript:</strong> </div>`);
4782
- var root_7 = /* @__PURE__ */ from_html(`<div class="text-sm mb-4"><!> <!></div>`);
4783
- var root_11 = /* @__PURE__ */ from_html(`<span class="font-medium"> </span> <!>`, 1);
4784
- var root_14 = /* @__PURE__ */ from_html(`<span class="font-medium">(key)</span>`);
4785
- var root_13 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
4988
+ var root_4 = /* @__PURE__ */ from_html(`<div><strong>Audio:</strong> </div>`);
4989
+ var root_5 = /* @__PURE__ */ from_html(`<div><strong>Transcript:</strong> </div>`);
4990
+ var root_6 = /* @__PURE__ */ from_html(`<div class="text-sm mb-4"><!> <!></div>`);
4991
+ var root_7 = /* @__PURE__ */ from_html(`<span class="font-medium"> </span> <!>`, 1);
4992
+ var root_8 = /* @__PURE__ */ from_html(`<span class="font-medium">(key)</span>`);
4993
+ var root_9 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
4786
4994
  var root_10 = /* @__PURE__ */ from_html(`<li><!></li>`);
4787
- var root = /* @__PURE__ */ from_html(`<div class="p-4 print:p-0"><!> <!> <!> <!> <ul class="text-sm list-disc pl-5"></ul></div>`);
4995
+ var root_11 = /* @__PURE__ */ from_html(`<div class="p-4 print:p-0"><!> <!> <!> <!> <ul class="text-sm list-disc pl-5"></ul></div>`);
4788
4996
  var $$css = {
4789
4997
  hash: "svelte-1fx5wwa",
4790
4998
  code: ".prose.svelte-1fx5wwa p {margin:0.5em 0;}.prose.svelte-1fx5wwa strong {font-weight:600;}"
@@ -4825,10 +5033,10 @@ function Print($$anchor, $$props) {
4825
5033
  flushSync();
4826
5034
  }
4827
5035
  };
4828
- var div = root();
5036
+ var div = root_11();
4829
5037
  var node = child(div);
4830
5038
  var consequent = ($$anchor) => {
4831
- var div_1 = root_1();
5039
+ var div_1 = root();
4832
5040
  html(div_1, () => get(prompt), true);
4833
5041
  reset(div_1);
4834
5042
  append($$anchor, div_1);
@@ -4838,7 +5046,7 @@ function Print($$anchor, $$props) {
4838
5046
  });
4839
5047
  var node_1 = sibling(node, 2);
4840
5048
  var consequent_1 = ($$anchor) => {
4841
- var div_2 = root_2();
5049
+ var div_2 = root_1();
4842
5050
  html(div_2, () => model().sentenceHtml, true);
4843
5051
  reset(div_2);
4844
5052
  append($$anchor, div_2);
@@ -4854,7 +5062,7 @@ function Print($$anchor, $$props) {
4854
5062
  var span = sibling(node_3, 2);
4855
5063
  var node_4 = child(span);
4856
5064
  var consequent_2 = ($$anchor) => {
4857
- var img = root_4();
5065
+ var img = root_2();
4858
5066
  template_effect(() => {
4859
5067
  set_attribute(img, "src", get(correct).imageUrl);
4860
5068
  set_attribute(img, "alt", get(correct).imageAlt || "");
@@ -4884,10 +5092,10 @@ function Print($$anchor, $$props) {
4884
5092
  });
4885
5093
  var node_7 = sibling(node_2, 2);
4886
5094
  var consequent_7 = ($$anchor) => {
4887
- var div_4 = root_7();
5095
+ var div_4 = root_6();
4888
5096
  var node_8 = child(div_4);
4889
5097
  var consequent_5 = ($$anchor) => {
4890
- var div_5 = root_8();
5098
+ var div_5 = root_4();
4891
5099
  var text_1 = sibling(child(div_5));
4892
5100
  reset(div_5);
4893
5101
  template_effect(() => set_text(text_1, ` ${model().audioUrl ?? ""}`));
@@ -4898,7 +5106,7 @@ function Print($$anchor, $$props) {
4898
5106
  });
4899
5107
  var node_9 = sibling(node_8, 2);
4900
5108
  var consequent_6 = ($$anchor) => {
4901
- var div_6 = root_9();
5109
+ var div_6 = root_5();
4902
5110
  var text_2 = sibling(child(div_6));
4903
5111
  reset(div_6);
4904
5112
  template_effect(() => set_text(text_2, ` ${model().audioTranscript ?? ""}`));
@@ -4918,10 +5126,9 @@ function Print($$anchor, $$props) {
4918
5126
  var li = root_10();
4919
5127
  var node_10 = child(li);
4920
5128
  var consequent_9 = ($$anchor) => {
4921
- var fragment_1 = root_11();
5129
+ var fragment_1 = root_7();
4922
5130
  var span_1 = first_child(fragment_1);
4923
- var text_3 = child(span_1, true);
4924
- reset(span_1);
5131
+ var text_3 = only_child(span_1, true);
4925
5132
  var node_11 = sibling(span_1, 2);
4926
5133
  var consequent_8 = ($$anchor) => {
4927
5134
  append($$anchor, text("(key)"));
@@ -4933,12 +5140,12 @@ function Print($$anchor, $$props) {
4933
5140
  append($$anchor, fragment_1);
4934
5141
  };
4935
5142
  var alternate_1 = ($$anchor) => {
4936
- var fragment_2 = root_13();
5143
+ var fragment_2 = root_9();
4937
5144
  var node_12 = first_child(fragment_2);
4938
5145
  html(node_12, () => get(c).labelHtml || "");
4939
5146
  var node_13 = sibling(node_12, 2);
4940
5147
  var consequent_10 = ($$anchor) => {
4941
- append($$anchor, root_14());
5148
+ append($$anchor, root_8());
4942
5149
  };
4943
5150
  if_block(node_13, ($$render) => {
4944
5151
  if (get(showAnswerKey) && get(c).id === model()?.correctChoiceId) $$render(consequent_10);