agenter 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/assets/auth-service/native/resvg_bridge/target/release/libprofile_resvg_bridge.dylib +0 -0
  2. package/assets/auth-service/webauthn-ui/authenticate.css +95 -0
  3. package/assets/auth-service/webauthn-ui/authenticate.js +4062 -0
  4. package/assets/auth-service/webauthn-ui/register.css +95 -0
  5. package/assets/auth-service/webauthn-ui/register.js +4106 -0
  6. package/assets/i18n-en/prompts/AGENTER.mdx +29 -0
  7. package/assets/i18n-en/prompts/AGENTER_SYSTEM.mdx +62 -0
  8. package/assets/i18n-en/prompts/RESPONSE_CONTRACT.mdx +25 -0
  9. package/assets/i18n-en/prompts/SYSTEM_TEMPLATE.mdx +13 -0
  10. package/assets/i18n-en/prompts.json +18 -0
  11. package/assets/i18n-en/runtime.json +18 -0
  12. package/assets/i18n-zh-Hans/prompts/AGENTER.mdx +29 -0
  13. package/assets/i18n-zh-Hans/prompts/AGENTER_SYSTEM.mdx +62 -0
  14. package/assets/i18n-zh-Hans/prompts/RESPONSE_CONTRACT.mdx +25 -0
  15. package/assets/i18n-zh-Hans/prompts/SYSTEM_TEMPLATE.mdx +13 -0
  16. package/assets/i18n-zh-Hans/prompts.json +18 -0
  17. package/assets/i18n-zh-Hans/runtime.json +18 -0
  18. package/bin/agenter.js +6 -0
  19. package/dist/agenter.js +349624 -0
  20. package/dist/highlights-eq9cgrbb.scm +604 -0
  21. package/dist/highlights-ghv9g403.scm +205 -0
  22. package/dist/highlights-hk7bwhj4.scm +284 -0
  23. package/dist/highlights-r812a2qc.scm +150 -0
  24. package/dist/highlights-x6tmsnaa.scm +115 -0
  25. package/dist/injections-73j83es3.scm +27 -0
  26. package/dist/resvgjs.darwin-arm64-h8sackw6.node +0 -0
  27. package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  28. package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
  29. package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  30. package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  31. package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
  32. package/package.json +26 -9
  33. package/README.md +0 -1
@@ -0,0 +1,4062 @@
1
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/shared/utils.js
2
+ var is_array = Array.isArray;
3
+ var index_of = Array.prototype.indexOf;
4
+ var includes = Array.prototype.includes;
5
+ var array_from = Array.from;
6
+ var define_property = Object.defineProperty;
7
+ var get_descriptor = Object.getOwnPropertyDescriptor;
8
+ var get_descriptors = Object.getOwnPropertyDescriptors;
9
+ var object_prototype = Object.prototype;
10
+ var array_prototype = Array.prototype;
11
+ var get_prototype_of = Object.getPrototypeOf;
12
+ var is_extensible = Object.isExtensible;
13
+ var noop = () => {};
14
+ /** @param {Array<() => void>} arr */
15
+ function run_all(arr) {
16
+ for (var i = 0; i < arr.length; i++) arr[i]();
17
+ }
18
+ /**
19
+ * TODO replace with Promise.withResolvers once supported widely enough
20
+ * @template [T=void]
21
+ */
22
+ function deferred() {
23
+ /** @type {(value: T) => void} */
24
+ var resolve;
25
+ /** @type {(reason: any) => void} */
26
+ var reject;
27
+ return {
28
+ promise: new Promise((res, rej) => {
29
+ resolve = res;
30
+ reject = rej;
31
+ }),
32
+ resolve,
33
+ reject
34
+ };
35
+ }
36
+ var CLEAN = 1024;
37
+ var DIRTY = 2048;
38
+ var MAYBE_DIRTY = 4096;
39
+ var INERT = 8192;
40
+ var DESTROYED = 16384;
41
+ /** Set once a reaction has run for the first time */
42
+ var REACTION_RAN = 32768;
43
+ /** Effect is in the process of getting destroyed. Can be observed in child teardown functions */
44
+ var DESTROYING = 1 << 25;
45
+ /**
46
+ * 'Transparent' effects do not create a transition boundary.
47
+ * This is on a block effect 99% of the time but may also be on a branch effect if its parent block effect was pruned
48
+ */
49
+ var EFFECT_TRANSPARENT = 65536;
50
+ var HEAD_EFFECT = 1 << 18;
51
+ var EFFECT_PRESERVED = 1 << 19;
52
+ var USER_EFFECT = 1 << 20;
53
+ /**
54
+ * Tells that we marked this derived and its reactions as visited during the "mark as (maybe) dirty"-phase.
55
+ * Will be lifted during execution of the derived and during checking its dirty state (both are necessary
56
+ * because a derived might be checked but not executed).
57
+ */
58
+ var WAS_MARKED = 65536;
59
+ var REACTION_IS_UPDATING = 1 << 21;
60
+ var ASYNC = 1 << 22;
61
+ var ERROR_VALUE = 1 << 23;
62
+ var STATE_SYMBOL = Symbol("$state");
63
+ var LOADING_ATTR_SYMBOL = Symbol("");
64
+ /** allow users to ignore aborted signal errors if `reason.name === 'StaleReactionError` */
65
+ var STALE_REACTION = new class StaleReactionError extends Error {
66
+ name = "StaleReactionError";
67
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
68
+ }();
69
+ var IS_XHTML = !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml");
70
+ //#endregion
71
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/errors.js
72
+ /**
73
+ * Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
74
+ * @returns {never}
75
+ */
76
+ function async_derived_orphan() {
77
+ throw new Error(`https://svelte.dev/e/async_derived_orphan`);
78
+ }
79
+ /**
80
+ * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
81
+ * @returns {never}
82
+ */
83
+ function effect_update_depth_exceeded() {
84
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
85
+ }
86
+ /**
87
+ * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
88
+ * @returns {never}
89
+ */
90
+ function state_descriptors_fixed() {
91
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
92
+ }
93
+ /**
94
+ * Cannot set prototype of `$state` object
95
+ * @returns {never}
96
+ */
97
+ function state_prototype_fixed() {
98
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
99
+ }
100
+ /**
101
+ * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
102
+ * @returns {never}
103
+ */
104
+ function state_unsafe_mutation() {
105
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
106
+ }
107
+ /**
108
+ * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
109
+ * @returns {never}
110
+ */
111
+ function svelte_boundary_reset_onerror() {
112
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
113
+ }
114
+ //#endregion
115
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/constants.js
116
+ var HYDRATION_ERROR = {};
117
+ var UNINITIALIZED = Symbol();
118
+ var NAMESPACE_HTML = "http://www.w3.org/1999/xhtml";
119
+ /**
120
+ * Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near %location%
121
+ * @param {string | undefined | null} [location]
122
+ */
123
+ function hydration_mismatch(location) {
124
+ console.warn(`https://svelte.dev/e/hydration_mismatch`);
125
+ }
126
+ /**
127
+ * A `<svelte:boundary>` `reset` function only resets the boundary the first time it is called
128
+ */
129
+ function svelte_boundary_reset_noop() {
130
+ console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
131
+ }
132
+ //#endregion
133
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/hydration.js
134
+ /** @import { TemplateNode } from '#client' */
135
+ /**
136
+ * Use this variable to guard everything related to hydration code so it can be treeshaken out
137
+ * if the user doesn't use the `hydrate` method and these code paths are therefore not needed.
138
+ */
139
+ var hydrating = false;
140
+ /** @param {boolean} value */
141
+ function set_hydrating(value) {
142
+ hydrating = value;
143
+ }
144
+ /**
145
+ * The node that is currently being hydrated. This starts out as the first node inside the opening
146
+ * <!--[--> comment, and updates each time a component calls `$.child(...)` or `$.sibling(...)`.
147
+ * When entering a block (e.g. `{#if ...}`), `hydrate_node` is the block opening comment; by the
148
+ * time we leave the block it is the closing comment, which serves as the block's anchor.
149
+ * @type {TemplateNode}
150
+ */
151
+ var hydrate_node;
152
+ /** @param {TemplateNode | null} node */
153
+ function set_hydrate_node(node) {
154
+ if (node === null) {
155
+ hydration_mismatch();
156
+ throw HYDRATION_ERROR;
157
+ }
158
+ return hydrate_node = node;
159
+ }
160
+ function hydrate_next() {
161
+ return set_hydrate_node(/* @__PURE__ */ get_next_sibling(hydrate_node));
162
+ }
163
+ /** @param {TemplateNode} node */
164
+ function reset(node) {
165
+ if (!hydrating) return;
166
+ if (/* @__PURE__ */ get_next_sibling(hydrate_node) !== null) {
167
+ hydration_mismatch();
168
+ throw HYDRATION_ERROR;
169
+ }
170
+ hydrate_node = node;
171
+ }
172
+ function next(count = 1) {
173
+ if (hydrating) {
174
+ var i = count;
175
+ var node = hydrate_node;
176
+ while (i--) node = /* @__PURE__ */ get_next_sibling(node);
177
+ hydrate_node = node;
178
+ }
179
+ }
180
+ /**
181
+ * Skips or removes (depending on {@link remove}) all nodes starting at `hydrate_node` up until the next hydration end comment
182
+ * @param {boolean} remove
183
+ */
184
+ function skip_nodes(remove = true) {
185
+ var depth = 0;
186
+ var node = hydrate_node;
187
+ while (true) {
188
+ if (node.nodeType === 8) {
189
+ var data = node.data;
190
+ if (data === "]") {
191
+ if (depth === 0) return node;
192
+ depth -= 1;
193
+ } else if (data === "[" || data === "[!" || data[0] === "[" && !isNaN(Number(data.slice(1)))) depth += 1;
194
+ }
195
+ var next = /* @__PURE__ */ get_next_sibling(node);
196
+ if (remove) node.remove();
197
+ node = next;
198
+ }
199
+ }
200
+ /**
201
+ *
202
+ * @param {TemplateNode} node
203
+ */
204
+ function read_hydration_instruction(node) {
205
+ if (!node || node.nodeType !== 8) {
206
+ hydration_mismatch();
207
+ throw HYDRATION_ERROR;
208
+ }
209
+ return node.data;
210
+ }
211
+ //#endregion
212
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/reactivity/equality.js
213
+ /** @import { Equals } from '#client' */
214
+ /** @type {Equals} */
215
+ function equals(value) {
216
+ return value === this.v;
217
+ }
218
+ /**
219
+ * @param {unknown} a
220
+ * @param {unknown} b
221
+ * @returns {boolean}
222
+ */
223
+ function safe_not_equal(a, b) {
224
+ return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
225
+ }
226
+ /** @type {Equals} */
227
+ function safe_equals(value) {
228
+ return !safe_not_equal(value, this.v);
229
+ }
230
+ //#endregion
231
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/flags/index.js
232
+ /** True if experimental.async=true */
233
+ var async_mode_flag = false;
234
+ /** True if we're not certain that we only have Svelte 5 code in the compilation */
235
+ var legacy_mode_flag = false;
236
+ //#endregion
237
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/context.js
238
+ /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
239
+ /** @type {ComponentContext | null} */
240
+ var component_context = null;
241
+ /** @param {ComponentContext | null} context */
242
+ function set_component_context(context) {
243
+ component_context = context;
244
+ }
245
+ /**
246
+ * @param {Record<string, unknown>} props
247
+ * @param {any} runes
248
+ * @param {Function} [fn]
249
+ * @returns {void}
250
+ */
251
+ function push(props, runes = false, fn) {
252
+ component_context = {
253
+ p: component_context,
254
+ i: false,
255
+ c: null,
256
+ e: null,
257
+ s: props,
258
+ x: null,
259
+ r: active_effect,
260
+ l: legacy_mode_flag && !runes ? {
261
+ s: null,
262
+ u: null,
263
+ $: []
264
+ } : null
265
+ };
266
+ }
267
+ /**
268
+ * @template {Record<string, any>} T
269
+ * @param {T} [component]
270
+ * @returns {T}
271
+ */
272
+ function pop(component) {
273
+ var context = component_context;
274
+ var effects = context.e;
275
+ if (effects !== null) {
276
+ context.e = null;
277
+ for (var fn of effects) create_user_effect(fn);
278
+ }
279
+ if (component !== void 0) context.x = component;
280
+ context.i = true;
281
+ component_context = context.p;
282
+ return component ?? {};
283
+ }
284
+ /** @returns {boolean} */
285
+ function is_runes() {
286
+ return !legacy_mode_flag || component_context !== null && component_context.l === null;
287
+ }
288
+ //#endregion
289
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/task.js
290
+ /** @type {Array<() => void>} */
291
+ var micro_tasks = [];
292
+ function run_micro_tasks() {
293
+ var tasks = micro_tasks;
294
+ micro_tasks = [];
295
+ run_all(tasks);
296
+ }
297
+ /**
298
+ * @param {() => void} fn
299
+ */
300
+ function queue_micro_task(fn) {
301
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
302
+ var tasks = micro_tasks;
303
+ queueMicrotask(() => {
304
+ if (tasks === micro_tasks) run_micro_tasks();
305
+ });
306
+ }
307
+ micro_tasks.push(fn);
308
+ }
309
+ /**
310
+ * Synchronously run any queued tasks.
311
+ */
312
+ function flush_tasks() {
313
+ while (micro_tasks.length > 0) run_micro_tasks();
314
+ }
315
+ /**
316
+ * @param {unknown} error
317
+ */
318
+ function handle_error(error) {
319
+ var effect = active_effect;
320
+ if (effect === null) {
321
+ /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
322
+ return error;
323
+ }
324
+ if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
325
+ invoke_error_boundary(error, effect);
326
+ }
327
+ /**
328
+ * @param {unknown} error
329
+ * @param {Effect | null} effect
330
+ */
331
+ function invoke_error_boundary(error, effect) {
332
+ while (effect !== null) {
333
+ if ((effect.f & 128) !== 0) {
334
+ if ((effect.f & 32768) === 0) throw error;
335
+ try {
336
+ /** @type {Boundary} */ effect.b.error(error);
337
+ return;
338
+ } catch (e) {
339
+ error = e;
340
+ }
341
+ }
342
+ effect = effect.parent;
343
+ }
344
+ throw error;
345
+ }
346
+ //#endregion
347
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/reactivity/status.js
348
+ /** @import { Derived, Signal } from '#client' */
349
+ var STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
350
+ /**
351
+ * @param {Signal} signal
352
+ * @param {number} status
353
+ */
354
+ function set_signal_status(signal, status) {
355
+ signal.f = signal.f & STATUS_MASK | status;
356
+ }
357
+ /**
358
+ * Set a derived's status to CLEAN or MAYBE_DIRTY based on its connection state.
359
+ * @param {Derived} derived
360
+ */
361
+ function update_derived_status(derived) {
362
+ if ((derived.f & 512) !== 0 || derived.deps === null) set_signal_status(derived, CLEAN);
363
+ else set_signal_status(derived, MAYBE_DIRTY);
364
+ }
365
+ //#endregion
366
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/reactivity/utils.js
367
+ /** @import { Derived, Effect, Value } from '#client' */
368
+ /**
369
+ * @param {Value[] | null} deps
370
+ */
371
+ function clear_marked(deps) {
372
+ if (deps === null) return;
373
+ for (const dep of deps) {
374
+ if ((dep.f & 2) === 0 || (dep.f & 65536) === 0) continue;
375
+ dep.f ^= WAS_MARKED;
376
+ clear_marked(
377
+ /** @type {Derived} */
378
+ dep.deps
379
+ );
380
+ }
381
+ }
382
+ /**
383
+ * @param {Effect} effect
384
+ * @param {Set<Effect>} dirty_effects
385
+ * @param {Set<Effect>} maybe_dirty_effects
386
+ */
387
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
388
+ if ((effect.f & 2048) !== 0) dirty_effects.add(effect);
389
+ else if ((effect.f & 4096) !== 0) maybe_dirty_effects.add(effect);
390
+ clear_marked(effect.deps);
391
+ set_signal_status(effect, CLEAN);
392
+ }
393
+ //#endregion
394
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/reactivity/store.js
395
+ /**
396
+ * We set this to `true` when updating a store so that we correctly
397
+ * schedule effects if the update takes place inside a `$:` effect
398
+ */
399
+ var legacy_is_updating_store = false;
400
+ //#endregion
401
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/reactivity/batch.js
402
+ /** @import { Fork } from 'svelte' */
403
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
404
+ /** @type {Set<Batch>} */
405
+ var batches = /* @__PURE__ */ new Set();
406
+ /** @type {Batch | null} */
407
+ var current_batch = null;
408
+ /**
409
+ * This is needed to avoid overwriting inputs
410
+ * @type {Batch | null}
411
+ */
412
+ var previous_batch = null;
413
+ /**
414
+ * When time travelling (i.e. working in one batch, while other batches
415
+ * still have ongoing work), we ignore the real values of affected
416
+ * signals in favour of their values within the batch
417
+ * @type {Map<Value, any> | null}
418
+ */
419
+ var batch_values = null;
420
+ /** @type {Effect | null} */
421
+ var last_scheduled_effect = null;
422
+ var is_flushing_sync = false;
423
+ var is_processing = false;
424
+ /**
425
+ * During traversal, this is an array. Newly created effects are (if not immediately
426
+ * executed) pushed to this array, rather than going through the scheduling
427
+ * rigamarole that would cause another turn of the flush loop.
428
+ * @type {Effect[] | null}
429
+ */
430
+ var collected_effects = null;
431
+ /**
432
+ * An array of effects that are marked during traversal as a result of a `set`
433
+ * (not `internal_set`) call. These will be added to the next batch and
434
+ * trigger another `batch.process()`
435
+ * @type {Effect[] | null}
436
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
437
+ */
438
+ var legacy_updates = null;
439
+ var flush_count = 0;
440
+ var uid = 1;
441
+ var Batch = class Batch {
442
+ id = uid++;
443
+ /**
444
+ * The current values of any signals that are updated in this batch.
445
+ * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
446
+ * They keys of this map are identical to `this.#previous`
447
+ * @type {Map<Value, [any, boolean]>}
448
+ */
449
+ current = /* @__PURE__ */ new Map();
450
+ /**
451
+ * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
452
+ * They keys of this map are identical to `this.#current`
453
+ * @type {Map<Value, any>}
454
+ */
455
+ previous = /* @__PURE__ */ new Map();
456
+ /**
457
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
458
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
459
+ * @type {Set<(batch: Batch) => void>}
460
+ */
461
+ #commit_callbacks = /* @__PURE__ */ new Set();
462
+ /**
463
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
464
+ * @type {Set<(batch: Batch) => void>}
465
+ */
466
+ #discard_callbacks = /* @__PURE__ */ new Set();
467
+ /**
468
+ * Async effects that are currently in flight
469
+ * @type {Map<Effect, number>}
470
+ */
471
+ #pending = /* @__PURE__ */ new Map();
472
+ /**
473
+ * Async effects that are currently in flight, _not_ inside a pending boundary
474
+ * @type {Map<Effect, number>}
475
+ */
476
+ #blocking_pending = /* @__PURE__ */ new Map();
477
+ /**
478
+ * A deferred that resolves when the batch is committed, used with `settled()`
479
+ * TODO replace with Promise.withResolvers once supported widely enough
480
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
481
+ */
482
+ #deferred = null;
483
+ /**
484
+ * The root effects that need to be flushed
485
+ * @type {Effect[]}
486
+ */
487
+ #roots = [];
488
+ /**
489
+ * Effects created while this batch was active.
490
+ * @type {Effect[]}
491
+ */
492
+ #new_effects = [];
493
+ /**
494
+ * Deferred effects (which run after async work has completed) that are DIRTY
495
+ * @type {Set<Effect>}
496
+ */
497
+ #dirty_effects = /* @__PURE__ */ new Set();
498
+ /**
499
+ * Deferred effects that are MAYBE_DIRTY
500
+ * @type {Set<Effect>}
501
+ */
502
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
503
+ /**
504
+ * A map of branches that still exist, but will be destroyed when this batch
505
+ * is committed — we skip over these during `process`.
506
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
507
+ * so they can be rescheduled if the branch survives.
508
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
509
+ */
510
+ #skipped_branches = /* @__PURE__ */ new Map();
511
+ /**
512
+ * Inverse of #skipped_branches which we need to tell prior batches to unskip them when committing
513
+ * @type {Set<Effect>}
514
+ */
515
+ #unskipped_branches = /* @__PURE__ */ new Set();
516
+ is_fork = false;
517
+ #decrement_queued = false;
518
+ /** @type {Set<Batch>} */
519
+ #blockers = /* @__PURE__ */ new Set();
520
+ #is_deferred() {
521
+ return this.is_fork || this.#blocking_pending.size > 0;
522
+ }
523
+ #is_blocked() {
524
+ for (const batch of this.#blockers) for (const effect of batch.#blocking_pending.keys()) {
525
+ var skipped = false;
526
+ var e = effect;
527
+ while (e.parent !== null) {
528
+ if (this.#skipped_branches.has(e)) {
529
+ skipped = true;
530
+ break;
531
+ }
532
+ e = e.parent;
533
+ }
534
+ if (!skipped) return true;
535
+ }
536
+ return false;
537
+ }
538
+ /**
539
+ * Add an effect to the #skipped_branches map and reset its children
540
+ * @param {Effect} effect
541
+ */
542
+ skip_effect(effect) {
543
+ if (!this.#skipped_branches.has(effect)) this.#skipped_branches.set(effect, {
544
+ d: [],
545
+ m: []
546
+ });
547
+ this.#unskipped_branches.delete(effect);
548
+ }
549
+ /**
550
+ * Remove an effect from the #skipped_branches map and reschedule
551
+ * any tracked dirty/maybe_dirty child effects
552
+ * @param {Effect} effect
553
+ * @param {(e: Effect) => void} callback
554
+ */
555
+ unskip_effect(effect, callback = (e) => this.schedule(e)) {
556
+ var tracked = this.#skipped_branches.get(effect);
557
+ if (tracked) {
558
+ this.#skipped_branches.delete(effect);
559
+ for (var e of tracked.d) {
560
+ set_signal_status(e, DIRTY);
561
+ callback(e);
562
+ }
563
+ for (e of tracked.m) {
564
+ set_signal_status(e, MAYBE_DIRTY);
565
+ callback(e);
566
+ }
567
+ }
568
+ this.#unskipped_branches.add(effect);
569
+ }
570
+ #process() {
571
+ if (flush_count++ > 1e3) {
572
+ batches.delete(this);
573
+ infinite_loop_guard();
574
+ }
575
+ if (!this.#is_deferred()) {
576
+ for (const e of this.#dirty_effects) {
577
+ this.#maybe_dirty_effects.delete(e);
578
+ set_signal_status(e, DIRTY);
579
+ this.schedule(e);
580
+ }
581
+ for (const e of this.#maybe_dirty_effects) {
582
+ set_signal_status(e, MAYBE_DIRTY);
583
+ this.schedule(e);
584
+ }
585
+ }
586
+ const roots = this.#roots;
587
+ this.#roots = [];
588
+ this.apply();
589
+ /** @type {Effect[]} */
590
+ var effects = collected_effects = [];
591
+ /** @type {Effect[]} */
592
+ var render_effects = [];
593
+ /**
594
+ * @type {Effect[]}
595
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
596
+ */
597
+ var updates = legacy_updates = [];
598
+ for (const root of roots) try {
599
+ this.#traverse(root, effects, render_effects);
600
+ } catch (e) {
601
+ reset_all(root);
602
+ throw e;
603
+ }
604
+ current_batch = null;
605
+ if (updates.length > 0) {
606
+ var batch = Batch.ensure();
607
+ for (const e of updates) batch.schedule(e);
608
+ }
609
+ collected_effects = null;
610
+ legacy_updates = null;
611
+ if (this.#is_deferred() || this.#is_blocked()) {
612
+ this.#defer_effects(render_effects);
613
+ this.#defer_effects(effects);
614
+ for (const [e, t] of this.#skipped_branches) reset_branch(e, t);
615
+ } else {
616
+ if (this.#pending.size === 0) batches.delete(this);
617
+ this.#dirty_effects.clear();
618
+ this.#maybe_dirty_effects.clear();
619
+ for (const fn of this.#commit_callbacks) fn(this);
620
+ this.#commit_callbacks.clear();
621
+ previous_batch = this;
622
+ flush_queued_effects(render_effects);
623
+ flush_queued_effects(effects);
624
+ previous_batch = null;
625
+ this.#deferred?.resolve();
626
+ }
627
+ var next_batch = current_batch;
628
+ if (this.#roots.length > 0) {
629
+ const batch = next_batch ??= this;
630
+ batch.#roots.push(...this.#roots.filter((r) => !batch.#roots.includes(r)));
631
+ }
632
+ if (next_batch !== null) {
633
+ batches.add(next_batch);
634
+ next_batch.#process();
635
+ }
636
+ if (async_mode_flag && !batches.has(this)) this.#commit();
637
+ }
638
+ /**
639
+ * Traverse the effect tree, executing effects or stashing
640
+ * them for later execution as appropriate
641
+ * @param {Effect} root
642
+ * @param {Effect[]} effects
643
+ * @param {Effect[]} render_effects
644
+ */
645
+ #traverse(root, effects, render_effects) {
646
+ root.f ^= CLEAN;
647
+ var effect = root.first;
648
+ while (effect !== null) {
649
+ var flags = effect.f;
650
+ var is_branch = (flags & 96) !== 0;
651
+ if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || this.#skipped_branches.has(effect)) && effect.fn !== null) {
652
+ if (is_branch) effect.f ^= CLEAN;
653
+ else if ((flags & 4) !== 0) effects.push(effect);
654
+ else if (async_mode_flag && (flags & 16777224) !== 0) render_effects.push(effect);
655
+ else if (is_dirty(effect)) {
656
+ if ((flags & 16) !== 0) this.#maybe_dirty_effects.add(effect);
657
+ update_effect(effect);
658
+ }
659
+ var child = effect.first;
660
+ if (child !== null) {
661
+ effect = child;
662
+ continue;
663
+ }
664
+ }
665
+ while (effect !== null) {
666
+ var next = effect.next;
667
+ if (next !== null) {
668
+ effect = next;
669
+ break;
670
+ }
671
+ effect = effect.parent;
672
+ }
673
+ }
674
+ }
675
+ /**
676
+ * @param {Effect[]} effects
677
+ */
678
+ #defer_effects(effects) {
679
+ for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
680
+ }
681
+ /**
682
+ * Associate a change to a given source with the current
683
+ * batch, noting its previous and current values
684
+ * @param {Value} source
685
+ * @param {any} value
686
+ * @param {boolean} [is_derived]
687
+ */
688
+ capture(source, value, is_derived = false) {
689
+ if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
690
+ if ((source.f & 8388608) === 0) {
691
+ this.current.set(source, [value, is_derived]);
692
+ batch_values?.set(source, value);
693
+ }
694
+ if (!this.is_fork) source.v = value;
695
+ }
696
+ activate() {
697
+ current_batch = this;
698
+ }
699
+ deactivate() {
700
+ current_batch = null;
701
+ batch_values = null;
702
+ }
703
+ flush() {
704
+ try {
705
+ is_processing = true;
706
+ current_batch = this;
707
+ this.#process();
708
+ } finally {
709
+ flush_count = 0;
710
+ last_scheduled_effect = null;
711
+ collected_effects = null;
712
+ legacy_updates = null;
713
+ is_processing = false;
714
+ current_batch = null;
715
+ batch_values = null;
716
+ old_values.clear();
717
+ }
718
+ }
719
+ discard() {
720
+ for (const fn of this.#discard_callbacks) fn(this);
721
+ this.#discard_callbacks.clear();
722
+ batches.delete(this);
723
+ }
724
+ /**
725
+ * @param {Effect} effect
726
+ */
727
+ register_created_effect(effect) {
728
+ this.#new_effects.push(effect);
729
+ }
730
+ #commit() {
731
+ for (const batch of batches) {
732
+ var is_earlier = batch.id < this.id;
733
+ /** @type {Source[]} */
734
+ var sources = [];
735
+ for (const [source, [value, is_derived]] of this.current) {
736
+ if (batch.current.has(source)) {
737
+ var batch_value = batch.current.get(source)[0];
738
+ if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
739
+ else continue;
740
+ }
741
+ sources.push(source);
742
+ }
743
+ var others = [...batch.current.keys()].filter((s) => !this.current.has(s));
744
+ if (others.length === 0) {
745
+ if (is_earlier) batch.discard();
746
+ } else if (sources.length > 0) {
747
+ if (is_earlier) for (const unskipped of this.#unskipped_branches) batch.unskip_effect(unskipped, (e) => {
748
+ if ((e.f & 4194320) !== 0) batch.schedule(e);
749
+ else batch.#defer_effects([e]);
750
+ });
751
+ batch.activate();
752
+ /** @type {Set<Value>} */
753
+ var marked = /* @__PURE__ */ new Set();
754
+ /** @type {Map<Reaction, boolean>} */
755
+ var checked = /* @__PURE__ */ new Map();
756
+ for (var source of sources) mark_effects(source, others, marked, checked);
757
+ checked = /* @__PURE__ */ new Map();
758
+ var current_unequal = [...batch.current.keys()].filter((c) => this.current.has(c) ? this.current.get(c)[0] !== c : true);
759
+ for (const effect of this.#new_effects) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
760
+ set_signal_status(effect, DIRTY);
761
+ batch.schedule(effect);
762
+ } else batch.#dirty_effects.add(effect);
763
+ if (batch.#roots.length > 0) {
764
+ batch.apply();
765
+ for (var root of batch.#roots) batch.#traverse(root, [], []);
766
+ batch.#roots = [];
767
+ }
768
+ batch.deactivate();
769
+ }
770
+ }
771
+ for (const batch of batches) if (batch.#blockers.has(this)) {
772
+ batch.#blockers.delete(this);
773
+ if (batch.#blockers.size === 0 && !batch.#is_deferred()) {
774
+ batch.activate();
775
+ batch.#process();
776
+ }
777
+ }
778
+ }
779
+ /**
780
+ * @param {boolean} blocking
781
+ * @param {Effect} effect
782
+ */
783
+ increment(blocking, effect) {
784
+ let pending_count = this.#pending.get(effect) ?? 0;
785
+ this.#pending.set(effect, pending_count + 1);
786
+ if (blocking) {
787
+ let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
788
+ this.#blocking_pending.set(effect, blocking_pending_count + 1);
789
+ }
790
+ }
791
+ /**
792
+ * @param {boolean} blocking
793
+ * @param {Effect} effect
794
+ * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
795
+ */
796
+ decrement(blocking, effect, skip) {
797
+ let pending_count = this.#pending.get(effect) ?? 0;
798
+ if (pending_count === 1) this.#pending.delete(effect);
799
+ else this.#pending.set(effect, pending_count - 1);
800
+ if (blocking) {
801
+ let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
802
+ if (blocking_pending_count === 1) this.#blocking_pending.delete(effect);
803
+ else this.#blocking_pending.set(effect, blocking_pending_count - 1);
804
+ }
805
+ if (this.#decrement_queued || skip) return;
806
+ this.#decrement_queued = true;
807
+ queue_micro_task(() => {
808
+ this.#decrement_queued = false;
809
+ this.flush();
810
+ });
811
+ }
812
+ /**
813
+ * @param {Set<Effect>} dirty_effects
814
+ * @param {Set<Effect>} maybe_dirty_effects
815
+ */
816
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
817
+ for (const e of dirty_effects) this.#dirty_effects.add(e);
818
+ for (const e of maybe_dirty_effects) this.#maybe_dirty_effects.add(e);
819
+ dirty_effects.clear();
820
+ maybe_dirty_effects.clear();
821
+ }
822
+ /** @param {(batch: Batch) => void} fn */
823
+ oncommit(fn) {
824
+ this.#commit_callbacks.add(fn);
825
+ }
826
+ /** @param {(batch: Batch) => void} fn */
827
+ ondiscard(fn) {
828
+ this.#discard_callbacks.add(fn);
829
+ }
830
+ settled() {
831
+ return (this.#deferred ??= deferred()).promise;
832
+ }
833
+ static ensure() {
834
+ if (current_batch === null) {
835
+ const batch = current_batch = new Batch();
836
+ if (!is_processing) {
837
+ batches.add(current_batch);
838
+ if (!is_flushing_sync) queue_micro_task(() => {
839
+ if (current_batch !== batch) return;
840
+ batch.flush();
841
+ });
842
+ }
843
+ }
844
+ return current_batch;
845
+ }
846
+ apply() {
847
+ if (!async_mode_flag || !this.is_fork && batches.size === 1) {
848
+ batch_values = null;
849
+ return;
850
+ }
851
+ batch_values = /* @__PURE__ */ new Map();
852
+ for (const [source, [value]] of this.current) batch_values.set(source, value);
853
+ for (const batch of batches) {
854
+ if (batch === this || batch.is_fork) continue;
855
+ var intersects = false;
856
+ var differs = false;
857
+ if (batch.id < this.id) for (const [source, [, is_derived]] of batch.current) {
858
+ if (is_derived) continue;
859
+ intersects ||= this.current.has(source);
860
+ differs ||= !this.current.has(source);
861
+ }
862
+ if (intersects && differs) this.#blockers.add(batch);
863
+ else for (const [source, previous] of batch.previous) if (!batch_values.has(source)) batch_values.set(source, previous);
864
+ }
865
+ }
866
+ /**
867
+ *
868
+ * @param {Effect} effect
869
+ */
870
+ schedule(effect) {
871
+ last_scheduled_effect = effect;
872
+ if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
873
+ effect.b.defer_effect(effect);
874
+ return;
875
+ }
876
+ var e = effect;
877
+ while (e.parent !== null) {
878
+ e = e.parent;
879
+ var flags = e.f;
880
+ if (collected_effects !== null && e === active_effect) {
881
+ if (async_mode_flag) return;
882
+ if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
883
+ }
884
+ if ((flags & 96) !== 0) {
885
+ if ((flags & 1024) === 0) return;
886
+ e.f ^= CLEAN;
887
+ }
888
+ }
889
+ this.#roots.push(e);
890
+ }
891
+ };
892
+ /**
893
+ * Synchronously flush any pending updates.
894
+ * Returns void if no callback is provided, otherwise returns the result of calling the callback.
895
+ * @template [T=void]
896
+ * @param {(() => T) | undefined} [fn]
897
+ * @returns {T}
898
+ */
899
+ function flushSync(fn) {
900
+ var was_flushing_sync = is_flushing_sync;
901
+ is_flushing_sync = true;
902
+ try {
903
+ var result;
904
+ if (fn) {
905
+ if (current_batch !== null && !current_batch.is_fork) current_batch.flush();
906
+ result = fn();
907
+ }
908
+ while (true) {
909
+ flush_tasks();
910
+ if (current_batch === null) return result;
911
+ current_batch.flush();
912
+ }
913
+ } finally {
914
+ is_flushing_sync = was_flushing_sync;
915
+ }
916
+ }
917
+ function infinite_loop_guard() {
918
+ try {
919
+ effect_update_depth_exceeded();
920
+ } catch (error) {
921
+ invoke_error_boundary(error, last_scheduled_effect);
922
+ }
923
+ }
924
+ /** @type {Set<Effect> | null} */
925
+ var eager_block_effects = null;
926
+ /**
927
+ * @param {Array<Effect>} effects
928
+ * @returns {void}
929
+ */
930
+ function flush_queued_effects(effects) {
931
+ var length = effects.length;
932
+ if (length === 0) return;
933
+ var i = 0;
934
+ while (i < length) {
935
+ var effect = effects[i++];
936
+ if ((effect.f & 24576) === 0 && is_dirty(effect)) {
937
+ eager_block_effects = /* @__PURE__ */ new Set();
938
+ update_effect(effect);
939
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
940
+ if (eager_block_effects?.size > 0) {
941
+ old_values.clear();
942
+ for (const e of eager_block_effects) {
943
+ if ((e.f & 24576) !== 0) continue;
944
+ /** @type {Effect[]} */
945
+ const ordered_effects = [e];
946
+ let ancestor = e.parent;
947
+ while (ancestor !== null) {
948
+ if (eager_block_effects.has(ancestor)) {
949
+ eager_block_effects.delete(ancestor);
950
+ ordered_effects.push(ancestor);
951
+ }
952
+ ancestor = ancestor.parent;
953
+ }
954
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
955
+ const e = ordered_effects[j];
956
+ if ((e.f & 24576) !== 0) continue;
957
+ update_effect(e);
958
+ }
959
+ }
960
+ eager_block_effects.clear();
961
+ }
962
+ }
963
+ }
964
+ eager_block_effects = null;
965
+ }
966
+ /**
967
+ * This is similar to `mark_reactions`, but it only marks async/block effects
968
+ * depending on `value` and at least one of the other `sources`, so that
969
+ * these effects can re-run after another batch has been committed
970
+ * @param {Value} value
971
+ * @param {Source[]} sources
972
+ * @param {Set<Value>} marked
973
+ * @param {Map<Reaction, boolean>} checked
974
+ */
975
+ function mark_effects(value, sources, marked, checked) {
976
+ if (marked.has(value)) return;
977
+ marked.add(value);
978
+ if (value.reactions !== null) for (const reaction of value.reactions) {
979
+ const flags = reaction.f;
980
+ if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
981
+ else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
982
+ set_signal_status(reaction, DIRTY);
983
+ schedule_effect(reaction);
984
+ }
985
+ }
986
+ }
987
+ /**
988
+ * @param {Reaction} reaction
989
+ * @param {Source[]} sources
990
+ * @param {Map<Reaction, boolean>} checked
991
+ */
992
+ function depends_on(reaction, sources, checked) {
993
+ const depends = checked.get(reaction);
994
+ if (depends !== void 0) return depends;
995
+ if (reaction.deps !== null) for (const dep of reaction.deps) {
996
+ if (includes.call(sources, dep)) return true;
997
+ if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
998
+ checked.set(dep, true);
999
+ return true;
1000
+ }
1001
+ }
1002
+ checked.set(reaction, false);
1003
+ return false;
1004
+ }
1005
+ /**
1006
+ * @param {Effect} effect
1007
+ * @returns {void}
1008
+ */
1009
+ function schedule_effect(effect) {
1010
+ /** @type {Batch} */ current_batch.schedule(effect);
1011
+ }
1012
+ /**
1013
+ * Mark all the effects inside a skipped branch CLEAN, so that
1014
+ * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
1015
+ * effects so they can be rescheduled if the branch survives.
1016
+ * @param {Effect} effect
1017
+ * @param {{ d: Effect[], m: Effect[] }} tracked
1018
+ */
1019
+ function reset_branch(effect, tracked) {
1020
+ if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
1021
+ if ((effect.f & 2048) !== 0) tracked.d.push(effect);
1022
+ else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
1023
+ set_signal_status(effect, CLEAN);
1024
+ var e = effect.first;
1025
+ while (e !== null) {
1026
+ reset_branch(e, tracked);
1027
+ e = e.next;
1028
+ }
1029
+ }
1030
+ /**
1031
+ * Mark an entire effect tree clean following an error
1032
+ * @param {Effect} effect
1033
+ */
1034
+ function reset_all(effect) {
1035
+ set_signal_status(effect, CLEAN);
1036
+ var e = effect.first;
1037
+ while (e !== null) {
1038
+ reset_all(e);
1039
+ e = e.next;
1040
+ }
1041
+ }
1042
+ //#endregion
1043
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/reactivity/create-subscriber.js
1044
+ /**
1045
+ * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
1046
+ * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
1047
+ *
1048
+ * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
1049
+ * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
1050
+ *
1051
+ * If `start` returns a cleanup function, it will be called when the effect is destroyed.
1052
+ *
1053
+ * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
1054
+ * are active, and the returned teardown function will only be called when all effects are destroyed.
1055
+ *
1056
+ * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
1057
+ *
1058
+ * ```js
1059
+ * import { createSubscriber } from 'svelte/reactivity';
1060
+ * import { on } from 'svelte/events';
1061
+ *
1062
+ * export class MediaQuery {
1063
+ * #query;
1064
+ * #subscribe;
1065
+ *
1066
+ * constructor(query) {
1067
+ * this.#query = window.matchMedia(`(${query})`);
1068
+ *
1069
+ * this.#subscribe = createSubscriber((update) => {
1070
+ * // when the `change` event occurs, re-run any effects that read `this.current`
1071
+ * const off = on(this.#query, 'change', update);
1072
+ *
1073
+ * // stop listening when all the effects are destroyed
1074
+ * return () => off();
1075
+ * });
1076
+ * }
1077
+ *
1078
+ * get current() {
1079
+ * // This makes the getter reactive, if read in an effect
1080
+ * this.#subscribe();
1081
+ *
1082
+ * // Return the current state of the query, whether or not we're in an effect
1083
+ * return this.#query.matches;
1084
+ * }
1085
+ * }
1086
+ * ```
1087
+ * @param {(update: () => void) => (() => void) | void} start
1088
+ * @since 5.7.0
1089
+ */
1090
+ function createSubscriber(start) {
1091
+ let subscribers = 0;
1092
+ let version = source(0);
1093
+ /** @type {(() => void) | void} */
1094
+ let stop;
1095
+ return () => {
1096
+ if (effect_tracking()) {
1097
+ get(version);
1098
+ render_effect(() => {
1099
+ if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
1100
+ subscribers += 1;
1101
+ return () => {
1102
+ queue_micro_task(() => {
1103
+ subscribers -= 1;
1104
+ if (subscribers === 0) {
1105
+ stop?.();
1106
+ stop = void 0;
1107
+ increment(version);
1108
+ }
1109
+ });
1110
+ };
1111
+ });
1112
+ }
1113
+ };
1114
+ }
1115
+ //#endregion
1116
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
1117
+ /** @import { Effect, Source, TemplateNode, } from '#client' */
1118
+ /**
1119
+ * @typedef {{
1120
+ * onerror?: (error: unknown, reset: () => void) => void;
1121
+ * failed?: (anchor: Node, error: () => unknown, reset: () => () => void) => void;
1122
+ * pending?: (anchor: Node) => void;
1123
+ * }} BoundaryProps
1124
+ */
1125
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
1126
+ /**
1127
+ * @param {TemplateNode} node
1128
+ * @param {BoundaryProps} props
1129
+ * @param {((anchor: Node) => void)} children
1130
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
1131
+ * @returns {void}
1132
+ */
1133
+ function boundary(node, props, children, transform_error) {
1134
+ new Boundary(node, props, children, transform_error);
1135
+ }
1136
+ var Boundary = class {
1137
+ /** @type {Boundary | null} */
1138
+ parent;
1139
+ is_pending = false;
1140
+ /**
1141
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
1142
+ * Inherited from parent boundary, or defaults to identity.
1143
+ * @type {(error: unknown) => unknown}
1144
+ */
1145
+ transform_error;
1146
+ /** @type {TemplateNode} */
1147
+ #anchor;
1148
+ /** @type {TemplateNode | null} */
1149
+ #hydrate_open = hydrating ? hydrate_node : null;
1150
+ /** @type {BoundaryProps} */
1151
+ #props;
1152
+ /** @type {((anchor: Node) => void)} */
1153
+ #children;
1154
+ /** @type {Effect} */
1155
+ #effect;
1156
+ /** @type {Effect | null} */
1157
+ #main_effect = null;
1158
+ /** @type {Effect | null} */
1159
+ #pending_effect = null;
1160
+ /** @type {Effect | null} */
1161
+ #failed_effect = null;
1162
+ /** @type {DocumentFragment | null} */
1163
+ #offscreen_fragment = null;
1164
+ #local_pending_count = 0;
1165
+ #pending_count = 0;
1166
+ #pending_count_update_queued = false;
1167
+ /** @type {Set<Effect>} */
1168
+ #dirty_effects = /* @__PURE__ */ new Set();
1169
+ /** @type {Set<Effect>} */
1170
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
1171
+ /**
1172
+ * A source containing the number of pending async deriveds/expressions.
1173
+ * Only created if `$effect.pending()` is used inside the boundary,
1174
+ * otherwise updating the source results in needless `Batch.ensure()`
1175
+ * calls followed by no-op flushes
1176
+ * @type {Source<number> | null}
1177
+ */
1178
+ #effect_pending = null;
1179
+ #effect_pending_subscriber = createSubscriber(() => {
1180
+ this.#effect_pending = source(this.#local_pending_count);
1181
+ return () => {
1182
+ this.#effect_pending = null;
1183
+ };
1184
+ });
1185
+ /**
1186
+ * @param {TemplateNode} node
1187
+ * @param {BoundaryProps} props
1188
+ * @param {((anchor: Node) => void)} children
1189
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
1190
+ */
1191
+ constructor(node, props, children, transform_error) {
1192
+ this.#anchor = node;
1193
+ this.#props = props;
1194
+ this.#children = (anchor) => {
1195
+ var effect = active_effect;
1196
+ effect.b = this;
1197
+ effect.f |= 128;
1198
+ children(anchor);
1199
+ };
1200
+ this.parent = active_effect.b;
1201
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
1202
+ this.#effect = block(() => {
1203
+ if (hydrating) {
1204
+ const comment = this.#hydrate_open;
1205
+ hydrate_next();
1206
+ const server_rendered_pending = comment.data === "[!";
1207
+ if (comment.data.startsWith("[?")) {
1208
+ const serialized_error = JSON.parse(comment.data.slice(2));
1209
+ this.#hydrate_failed_content(serialized_error);
1210
+ } else if (server_rendered_pending) this.#hydrate_pending_content();
1211
+ else this.#hydrate_resolved_content();
1212
+ } else this.#render();
1213
+ }, flags);
1214
+ if (hydrating) this.#anchor = hydrate_node;
1215
+ }
1216
+ #hydrate_resolved_content() {
1217
+ try {
1218
+ this.#main_effect = branch(() => this.#children(this.#anchor));
1219
+ } catch (error) {
1220
+ this.error(error);
1221
+ }
1222
+ }
1223
+ /**
1224
+ * @param {unknown} error The deserialized error from the server's hydration comment
1225
+ */
1226
+ #hydrate_failed_content(error) {
1227
+ const failed = this.#props.failed;
1228
+ if (!failed) return;
1229
+ this.#failed_effect = branch(() => {
1230
+ failed(this.#anchor, () => error, () => () => {});
1231
+ });
1232
+ }
1233
+ #hydrate_pending_content() {
1234
+ const pending = this.#props.pending;
1235
+ if (!pending) return;
1236
+ this.is_pending = true;
1237
+ this.#pending_effect = branch(() => pending(this.#anchor));
1238
+ queue_micro_task(() => {
1239
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
1240
+ var anchor = create_text();
1241
+ fragment.append(anchor);
1242
+ this.#main_effect = this.#run(() => {
1243
+ return branch(() => this.#children(anchor));
1244
+ });
1245
+ if (this.#pending_count === 0) {
1246
+ this.#anchor.before(fragment);
1247
+ this.#offscreen_fragment = null;
1248
+ pause_effect(this.#pending_effect, () => {
1249
+ this.#pending_effect = null;
1250
+ });
1251
+ this.#resolve(current_batch);
1252
+ }
1253
+ });
1254
+ }
1255
+ #render() {
1256
+ try {
1257
+ this.is_pending = this.has_pending_snippet();
1258
+ this.#pending_count = 0;
1259
+ this.#local_pending_count = 0;
1260
+ this.#main_effect = branch(() => {
1261
+ this.#children(this.#anchor);
1262
+ });
1263
+ if (this.#pending_count > 0) {
1264
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
1265
+ move_effect(this.#main_effect, fragment);
1266
+ const pending = this.#props.pending;
1267
+ this.#pending_effect = branch(() => pending(this.#anchor));
1268
+ } else this.#resolve(current_batch);
1269
+ } catch (error) {
1270
+ this.error(error);
1271
+ }
1272
+ }
1273
+ /**
1274
+ * @param {Batch} batch
1275
+ */
1276
+ #resolve(batch) {
1277
+ this.is_pending = false;
1278
+ batch.transfer_effects(this.#dirty_effects, this.#maybe_dirty_effects);
1279
+ }
1280
+ /**
1281
+ * Defer an effect inside a pending boundary until the boundary resolves
1282
+ * @param {Effect} effect
1283
+ */
1284
+ defer_effect(effect) {
1285
+ defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects);
1286
+ }
1287
+ /**
1288
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1289
+ * @returns {boolean}
1290
+ */
1291
+ is_rendered() {
1292
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
1293
+ }
1294
+ has_pending_snippet() {
1295
+ return !!this.#props.pending;
1296
+ }
1297
+ /**
1298
+ * @template T
1299
+ * @param {() => T} fn
1300
+ */
1301
+ #run(fn) {
1302
+ var previous_effect = active_effect;
1303
+ var previous_reaction = active_reaction;
1304
+ var previous_ctx = component_context;
1305
+ set_active_effect(this.#effect);
1306
+ set_active_reaction(this.#effect);
1307
+ set_component_context(this.#effect.ctx);
1308
+ try {
1309
+ Batch.ensure();
1310
+ return fn();
1311
+ } catch (e) {
1312
+ handle_error(e);
1313
+ return null;
1314
+ } finally {
1315
+ set_active_effect(previous_effect);
1316
+ set_active_reaction(previous_reaction);
1317
+ set_component_context(previous_ctx);
1318
+ }
1319
+ }
1320
+ /**
1321
+ * Updates the pending count associated with the currently visible pending snippet,
1322
+ * if any, such that we can replace the snippet with content once work is done
1323
+ * @param {1 | -1} d
1324
+ * @param {Batch} batch
1325
+ */
1326
+ #update_pending_count(d, batch) {
1327
+ if (!this.has_pending_snippet()) {
1328
+ if (this.parent) this.parent.#update_pending_count(d, batch);
1329
+ return;
1330
+ }
1331
+ this.#pending_count += d;
1332
+ if (this.#pending_count === 0) {
1333
+ this.#resolve(batch);
1334
+ if (this.#pending_effect) pause_effect(this.#pending_effect, () => {
1335
+ this.#pending_effect = null;
1336
+ });
1337
+ if (this.#offscreen_fragment) {
1338
+ this.#anchor.before(this.#offscreen_fragment);
1339
+ this.#offscreen_fragment = null;
1340
+ }
1341
+ }
1342
+ }
1343
+ /**
1344
+ * Update the source that powers `$effect.pending()` inside this boundary,
1345
+ * and controls when the current `pending` snippet (if any) is removed.
1346
+ * Do not call from inside the class
1347
+ * @param {1 | -1} d
1348
+ * @param {Batch} batch
1349
+ */
1350
+ update_pending_count(d, batch) {
1351
+ this.#update_pending_count(d, batch);
1352
+ this.#local_pending_count += d;
1353
+ if (!this.#effect_pending || this.#pending_count_update_queued) return;
1354
+ this.#pending_count_update_queued = true;
1355
+ queue_micro_task(() => {
1356
+ this.#pending_count_update_queued = false;
1357
+ if (this.#effect_pending) internal_set(this.#effect_pending, this.#local_pending_count);
1358
+ });
1359
+ }
1360
+ get_effect_pending() {
1361
+ this.#effect_pending_subscriber();
1362
+ return get(this.#effect_pending);
1363
+ }
1364
+ /** @param {unknown} error */
1365
+ error(error) {
1366
+ var onerror = this.#props.onerror;
1367
+ let failed = this.#props.failed;
1368
+ if (!onerror && !failed) throw error;
1369
+ if (this.#main_effect) {
1370
+ destroy_effect(this.#main_effect);
1371
+ this.#main_effect = null;
1372
+ }
1373
+ if (this.#pending_effect) {
1374
+ destroy_effect(this.#pending_effect);
1375
+ this.#pending_effect = null;
1376
+ }
1377
+ if (this.#failed_effect) {
1378
+ destroy_effect(this.#failed_effect);
1379
+ this.#failed_effect = null;
1380
+ }
1381
+ if (hydrating) {
1382
+ set_hydrate_node(this.#hydrate_open);
1383
+ next();
1384
+ set_hydrate_node(skip_nodes());
1385
+ }
1386
+ var did_reset = false;
1387
+ var calling_on_error = false;
1388
+ const reset = () => {
1389
+ if (did_reset) {
1390
+ svelte_boundary_reset_noop();
1391
+ return;
1392
+ }
1393
+ did_reset = true;
1394
+ if (calling_on_error) svelte_boundary_reset_onerror();
1395
+ if (this.#failed_effect !== null) pause_effect(this.#failed_effect, () => {
1396
+ this.#failed_effect = null;
1397
+ });
1398
+ this.#run(() => {
1399
+ this.#render();
1400
+ });
1401
+ };
1402
+ /** @param {unknown} transformed_error */
1403
+ const handle_error_result = (transformed_error) => {
1404
+ try {
1405
+ calling_on_error = true;
1406
+ onerror?.(transformed_error, reset);
1407
+ calling_on_error = false;
1408
+ } catch (error) {
1409
+ invoke_error_boundary(error, this.#effect && this.#effect.parent);
1410
+ }
1411
+ if (failed) this.#failed_effect = this.#run(() => {
1412
+ try {
1413
+ return branch(() => {
1414
+ var effect = active_effect;
1415
+ effect.b = this;
1416
+ effect.f |= 128;
1417
+ failed(this.#anchor, () => transformed_error, () => reset);
1418
+ });
1419
+ } catch (error) {
1420
+ invoke_error_boundary(error, this.#effect.parent);
1421
+ return null;
1422
+ }
1423
+ });
1424
+ };
1425
+ queue_micro_task(() => {
1426
+ /** @type {unknown} */
1427
+ var result;
1428
+ try {
1429
+ result = this.transform_error(error);
1430
+ } catch (e) {
1431
+ invoke_error_boundary(e, this.#effect && this.#effect.parent);
1432
+ return;
1433
+ }
1434
+ if (result !== null && typeof result === "object" && typeof result.then === "function")
1435
+ /** @type {any} */ result.then(
1436
+ handle_error_result,
1437
+ /** @param {unknown} e */
1438
+ (e) => invoke_error_boundary(e, this.#effect && this.#effect.parent)
1439
+ );
1440
+ else handle_error_result(result);
1441
+ });
1442
+ }
1443
+ };
1444
+ //#endregion
1445
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/reactivity/async.js
1446
+ /** @import { Blocker, Effect, Value } from '#client' */
1447
+ /**
1448
+ * @param {Blocker[]} blockers
1449
+ * @param {Array<() => any>} sync
1450
+ * @param {Array<() => Promise<any>>} async
1451
+ * @param {(values: Value[]) => any} fn
1452
+ */
1453
+ function flatten(blockers, sync, async, fn) {
1454
+ const d = is_runes() ? derived : derived_safe_equal;
1455
+ var pending = blockers.filter((b) => !b.settled);
1456
+ if (async.length === 0 && pending.length === 0) {
1457
+ fn(sync.map(d));
1458
+ return;
1459
+ }
1460
+ var parent = active_effect;
1461
+ var restore = capture();
1462
+ var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b) => b.promise)) : null;
1463
+ /** @param {Value[]} values */
1464
+ function finish(values) {
1465
+ restore();
1466
+ try {
1467
+ fn(values);
1468
+ } catch (error) {
1469
+ if ((parent.f & 16384) === 0) invoke_error_boundary(error, parent);
1470
+ }
1471
+ unset_context();
1472
+ }
1473
+ if (async.length === 0) {
1474
+ /** @type {Promise<any>} */ blocker_promise.then(() => finish(sync.map(d)));
1475
+ return;
1476
+ }
1477
+ var decrement_pending = increment_pending();
1478
+ function run() {
1479
+ 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());
1480
+ }
1481
+ if (blocker_promise) blocker_promise.then(() => {
1482
+ restore();
1483
+ run();
1484
+ unset_context();
1485
+ });
1486
+ else run();
1487
+ }
1488
+ /**
1489
+ * Captures the current effect context so that we can restore it after
1490
+ * some asynchronous work has happened (so that e.g. `await a + b`
1491
+ * causes `b` to be registered as a dependency).
1492
+ */
1493
+ function capture() {
1494
+ var previous_effect = active_effect;
1495
+ var previous_reaction = active_reaction;
1496
+ var previous_component_context = component_context;
1497
+ var previous_batch = current_batch;
1498
+ return function restore(activate_batch = true) {
1499
+ set_active_effect(previous_effect);
1500
+ set_active_reaction(previous_reaction);
1501
+ set_component_context(previous_component_context);
1502
+ if (activate_batch && (previous_effect.f & 16384) === 0) {
1503
+ previous_batch?.activate();
1504
+ previous_batch?.apply();
1505
+ }
1506
+ };
1507
+ }
1508
+ function unset_context(deactivate_batch = true) {
1509
+ set_active_effect(null);
1510
+ set_active_reaction(null);
1511
+ set_component_context(null);
1512
+ if (deactivate_batch) current_batch?.deactivate();
1513
+ }
1514
+ /**
1515
+ * @returns {(skip?: boolean) => void}
1516
+ */
1517
+ function increment_pending() {
1518
+ var effect = active_effect;
1519
+ var boundary = effect.b;
1520
+ var batch = current_batch;
1521
+ var blocking = boundary.is_rendered();
1522
+ boundary.update_pending_count(1, batch);
1523
+ batch.increment(blocking, effect);
1524
+ return (skip = false) => {
1525
+ boundary.update_pending_count(-1, batch);
1526
+ batch.decrement(blocking, effect, skip);
1527
+ };
1528
+ }
1529
+ /**
1530
+ * @template V
1531
+ * @param {() => V} fn
1532
+ * @returns {Derived<V>}
1533
+ */
1534
+ /* @__NO_SIDE_EFFECTS__ */
1535
+ function derived(fn) {
1536
+ var flags = 2 | DIRTY;
1537
+ var parent_derived = active_reaction !== null && (active_reaction.f & 2) !== 0 ? active_reaction : null;
1538
+ if (active_effect !== null) active_effect.f |= EFFECT_PRESERVED;
1539
+ return {
1540
+ ctx: component_context,
1541
+ deps: null,
1542
+ effects: null,
1543
+ equals,
1544
+ f: flags,
1545
+ fn,
1546
+ reactions: null,
1547
+ rv: 0,
1548
+ v: UNINITIALIZED,
1549
+ wv: 0,
1550
+ parent: parent_derived ?? active_effect,
1551
+ ac: null
1552
+ };
1553
+ }
1554
+ /**
1555
+ * @template V
1556
+ * @param {() => V | Promise<V>} fn
1557
+ * @param {string} [label]
1558
+ * @param {string} [location] If provided, print a warning if the value is not read immediately after update
1559
+ * @returns {Promise<Source<V>>}
1560
+ */
1561
+ /* @__NO_SIDE_EFFECTS__ */
1562
+ function async_derived(fn, label, location) {
1563
+ let parent = active_effect;
1564
+ if (parent === null) async_derived_orphan();
1565
+ var promise = void 0;
1566
+ var signal = source(UNINITIALIZED);
1567
+ var should_suspend = !active_reaction;
1568
+ /** @type {Map<Batch, ReturnType<typeof deferred<V>>>} */
1569
+ var deferreds = /* @__PURE__ */ new Map();
1570
+ async_effect(() => {
1571
+ var effect = active_effect;
1572
+ /** @type {ReturnType<typeof deferred<V>>} */
1573
+ var d = deferred();
1574
+ promise = d.promise;
1575
+ try {
1576
+ Promise.resolve(fn()).then(d.resolve, d.reject).finally(unset_context);
1577
+ } catch (error) {
1578
+ d.reject(error);
1579
+ unset_context();
1580
+ }
1581
+ var batch = current_batch;
1582
+ if (should_suspend) {
1583
+ if ((effect.f & 32768) !== 0) var decrement_pending = increment_pending();
1584
+ if (parent.b.is_rendered()) {
1585
+ deferreds.get(batch)?.reject(STALE_REACTION);
1586
+ deferreds.delete(batch);
1587
+ } else {
1588
+ for (const d of deferreds.values()) d.reject(STALE_REACTION);
1589
+ deferreds.clear();
1590
+ }
1591
+ deferreds.set(batch, d);
1592
+ }
1593
+ /**
1594
+ * @param {any} value
1595
+ * @param {unknown} error
1596
+ */
1597
+ const handler = (value, error = void 0) => {
1598
+ if (decrement_pending) decrement_pending(error === STALE_REACTION);
1599
+ if (error === STALE_REACTION || (effect.f & 16384) !== 0) return;
1600
+ batch.activate();
1601
+ if (error) {
1602
+ signal.f |= ERROR_VALUE;
1603
+ internal_set(signal, error);
1604
+ } else {
1605
+ if ((signal.f & 8388608) !== 0) signal.f ^= ERROR_VALUE;
1606
+ internal_set(signal, value);
1607
+ for (const [b, d] of deferreds) {
1608
+ deferreds.delete(b);
1609
+ if (b === batch) break;
1610
+ d.reject(STALE_REACTION);
1611
+ }
1612
+ }
1613
+ batch.deactivate();
1614
+ };
1615
+ d.promise.then(handler, (e) => handler(null, e || "unknown"));
1616
+ });
1617
+ teardown(() => {
1618
+ for (const d of deferreds.values()) d.reject(STALE_REACTION);
1619
+ });
1620
+ return new Promise((fulfil) => {
1621
+ /** @param {Promise<V>} p */
1622
+ function next(p) {
1623
+ function go() {
1624
+ if (p === promise) fulfil(signal);
1625
+ else next(promise);
1626
+ }
1627
+ p.then(go, go);
1628
+ }
1629
+ next(promise);
1630
+ });
1631
+ }
1632
+ /**
1633
+ * @template V
1634
+ * @param {() => V} fn
1635
+ * @returns {Derived<V>}
1636
+ */
1637
+ /* @__NO_SIDE_EFFECTS__ */
1638
+ function derived_safe_equal(fn) {
1639
+ const signal = /* @__PURE__ */ derived(fn);
1640
+ signal.equals = safe_equals;
1641
+ return signal;
1642
+ }
1643
+ /**
1644
+ * @param {Derived} derived
1645
+ * @returns {void}
1646
+ */
1647
+ function destroy_derived_effects(derived) {
1648
+ var effects = derived.effects;
1649
+ if (effects !== null) {
1650
+ derived.effects = null;
1651
+ for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
1652
+ }
1653
+ }
1654
+ /**
1655
+ * @param {Derived} derived
1656
+ * @returns {Effect | null}
1657
+ */
1658
+ function get_derived_parent_effect(derived) {
1659
+ var parent = derived.parent;
1660
+ while (parent !== null) {
1661
+ if ((parent.f & 2) === 0) return (parent.f & 16384) === 0 ? parent : null;
1662
+ parent = parent.parent;
1663
+ }
1664
+ return null;
1665
+ }
1666
+ /**
1667
+ * @template T
1668
+ * @param {Derived} derived
1669
+ * @returns {T}
1670
+ */
1671
+ function execute_derived(derived) {
1672
+ var value;
1673
+ var prev_active_effect = active_effect;
1674
+ set_active_effect(get_derived_parent_effect(derived));
1675
+ try {
1676
+ derived.f &= ~WAS_MARKED;
1677
+ destroy_derived_effects(derived);
1678
+ value = update_reaction(derived);
1679
+ } finally {
1680
+ set_active_effect(prev_active_effect);
1681
+ }
1682
+ return value;
1683
+ }
1684
+ /**
1685
+ * @param {Derived} derived
1686
+ * @returns {void}
1687
+ */
1688
+ function update_derived(derived) {
1689
+ var value = execute_derived(derived);
1690
+ if (!derived.equals(value)) {
1691
+ derived.wv = increment_write_version();
1692
+ if (!current_batch?.is_fork || derived.deps === null) {
1693
+ if (current_batch !== null) current_batch.capture(derived, value, true);
1694
+ else derived.v = value;
1695
+ if (derived.deps === null) {
1696
+ set_signal_status(derived, CLEAN);
1697
+ return;
1698
+ }
1699
+ }
1700
+ }
1701
+ if (is_destroying_effect) return;
1702
+ if (batch_values !== null) {
1703
+ if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
1704
+ } else update_derived_status(derived);
1705
+ }
1706
+ /**
1707
+ * @param {Derived} derived
1708
+ */
1709
+ function freeze_derived_effects(derived) {
1710
+ if (derived.effects === null) return;
1711
+ for (const e of derived.effects) if (e.teardown || e.ac) {
1712
+ e.teardown?.();
1713
+ e.ac?.abort(STALE_REACTION);
1714
+ e.teardown = noop;
1715
+ e.ac = null;
1716
+ remove_reactions(e, 0);
1717
+ destroy_effect_children(e);
1718
+ }
1719
+ }
1720
+ /**
1721
+ * @param {Derived} derived
1722
+ */
1723
+ function unfreeze_derived_effects(derived) {
1724
+ if (derived.effects === null) return;
1725
+ for (const e of derived.effects) if (e.teardown) update_effect(e);
1726
+ }
1727
+ //#endregion
1728
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/reactivity/sources.js
1729
+ /** @import { Derived, Effect, Source, Value } from '#client' */
1730
+ /** @type {Set<any>} */
1731
+ var eager_effects = /* @__PURE__ */ new Set();
1732
+ /** @type {Map<Source, any>} */
1733
+ var old_values = /* @__PURE__ */ new Map();
1734
+ var eager_effects_deferred = false;
1735
+ /**
1736
+ * @template V
1737
+ * @param {V} v
1738
+ * @param {Error | null} [stack]
1739
+ * @returns {Source<V>}
1740
+ */
1741
+ function source(v, stack) {
1742
+ return {
1743
+ f: 0,
1744
+ v,
1745
+ reactions: null,
1746
+ equals,
1747
+ rv: 0,
1748
+ wv: 0
1749
+ };
1750
+ }
1751
+ /**
1752
+ * @template V
1753
+ * @param {V} v
1754
+ * @param {Error | null} [stack]
1755
+ */
1756
+ /* @__NO_SIDE_EFFECTS__ */
1757
+ function state(v, stack) {
1758
+ const s = source(v, stack);
1759
+ push_reaction_value(s);
1760
+ return s;
1761
+ }
1762
+ /**
1763
+ * @template V
1764
+ * @param {Source<V>} source
1765
+ * @param {V} value
1766
+ * @param {boolean} [should_proxy]
1767
+ * @returns {V}
1768
+ */
1769
+ function set(source, value, should_proxy = false) {
1770
+ 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();
1771
+ return internal_set(source, should_proxy ? proxy(value) : value, legacy_updates);
1772
+ }
1773
+ /**
1774
+ * @template V
1775
+ * @param {Source<V>} source
1776
+ * @param {V} value
1777
+ * @param {Effect[] | null} [updated_during_traversal]
1778
+ * @returns {V}
1779
+ */
1780
+ function internal_set(source, value, updated_during_traversal = null) {
1781
+ if (!source.equals(value)) {
1782
+ old_values.set(source, is_destroying_effect ? value : source.v);
1783
+ var batch = Batch.ensure();
1784
+ batch.capture(source, value);
1785
+ if ((source.f & 2) !== 0) {
1786
+ const derived = source;
1787
+ if ((source.f & 2048) !== 0) execute_derived(derived);
1788
+ if (batch_values === null) update_derived_status(derived);
1789
+ }
1790
+ source.wv = increment_write_version();
1791
+ mark_reactions(source, DIRTY, updated_during_traversal);
1792
+ if (is_runes() && active_effect !== null && (active_effect.f & 1024) !== 0 && (active_effect.f & 96) === 0) if (untracked_writes === null) set_untracked_writes([source]);
1793
+ else untracked_writes.push(source);
1794
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) flush_eager_effects();
1795
+ }
1796
+ return value;
1797
+ }
1798
+ function flush_eager_effects() {
1799
+ eager_effects_deferred = false;
1800
+ for (const effect of eager_effects) {
1801
+ if ((effect.f & 1024) !== 0) set_signal_status(effect, MAYBE_DIRTY);
1802
+ if (is_dirty(effect)) update_effect(effect);
1803
+ }
1804
+ eager_effects.clear();
1805
+ }
1806
+ /**
1807
+ * Silently (without using `get`) increment a source
1808
+ * @param {Source<number>} source
1809
+ */
1810
+ function increment(source) {
1811
+ set(source, source.v + 1);
1812
+ }
1813
+ /**
1814
+ * @param {Value} signal
1815
+ * @param {number} status should be DIRTY or MAYBE_DIRTY
1816
+ * @param {Effect[] | null} updated_during_traversal
1817
+ * @returns {void}
1818
+ */
1819
+ function mark_reactions(signal, status, updated_during_traversal) {
1820
+ var reactions = signal.reactions;
1821
+ if (reactions === null) return;
1822
+ var runes = is_runes();
1823
+ var length = reactions.length;
1824
+ for (var i = 0; i < length; i++) {
1825
+ var reaction = reactions[i];
1826
+ var flags = reaction.f;
1827
+ if (!runes && reaction === active_effect) continue;
1828
+ var not_dirty = (flags & DIRTY) === 0;
1829
+ if (not_dirty) set_signal_status(reaction, status);
1830
+ if ((flags & 2) !== 0) {
1831
+ var derived = reaction;
1832
+ batch_values?.delete(derived);
1833
+ if ((flags & 65536) === 0) {
1834
+ if (flags & 512) reaction.f |= WAS_MARKED;
1835
+ mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
1836
+ }
1837
+ } else if (not_dirty) {
1838
+ var effect = reaction;
1839
+ if ((flags & 16) !== 0 && eager_block_effects !== null) eager_block_effects.add(effect);
1840
+ if (updated_during_traversal !== null) updated_during_traversal.push(effect);
1841
+ else schedule_effect(effect);
1842
+ }
1843
+ }
1844
+ }
1845
+ /**
1846
+ * @template T
1847
+ * @param {T} value
1848
+ * @returns {T}
1849
+ */
1850
+ function proxy(value) {
1851
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) return value;
1852
+ const prototype = get_prototype_of(value);
1853
+ if (prototype !== object_prototype && prototype !== array_prototype) return value;
1854
+ /** @type {Map<any, Source<any>>} */
1855
+ var sources = /* @__PURE__ */ new Map();
1856
+ var is_proxied_array = is_array(value);
1857
+ var version = /* @__PURE__ */ state(0);
1858
+ var stack = null;
1859
+ var parent_version = update_version;
1860
+ /**
1861
+ * Executes the proxy in the context of the reaction it was originally created in, if any
1862
+ * @template T
1863
+ * @param {() => T} fn
1864
+ */
1865
+ var with_parent = (fn) => {
1866
+ if (update_version === parent_version) return fn();
1867
+ var reaction = active_reaction;
1868
+ var version = update_version;
1869
+ set_active_reaction(null);
1870
+ set_update_version(parent_version);
1871
+ var result = fn();
1872
+ set_active_reaction(reaction);
1873
+ set_update_version(version);
1874
+ return result;
1875
+ };
1876
+ if (is_proxied_array) sources.set("length", /* @__PURE__ */ state(
1877
+ /** @type {any[]} */
1878
+ value.length,
1879
+ stack
1880
+ ));
1881
+ return new Proxy(value, {
1882
+ defineProperty(_, prop, descriptor) {
1883
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) state_descriptors_fixed();
1884
+ var s = sources.get(prop);
1885
+ if (s === void 0) with_parent(() => {
1886
+ var s = /* @__PURE__ */ state(descriptor.value, stack);
1887
+ sources.set(prop, s);
1888
+ return s;
1889
+ });
1890
+ else set(s, descriptor.value, true);
1891
+ return true;
1892
+ },
1893
+ deleteProperty(target, prop) {
1894
+ var s = sources.get(prop);
1895
+ if (s === void 0) {
1896
+ if (prop in target) {
1897
+ const s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED, stack));
1898
+ sources.set(prop, s);
1899
+ increment(version);
1900
+ }
1901
+ } else {
1902
+ set(s, UNINITIALIZED);
1903
+ increment(version);
1904
+ }
1905
+ return true;
1906
+ },
1907
+ get(target, prop, receiver) {
1908
+ if (prop === STATE_SYMBOL) return value;
1909
+ var s = sources.get(prop);
1910
+ var exists = prop in target;
1911
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1912
+ s = with_parent(() => {
1913
+ return /* @__PURE__ */ state(proxy(exists ? target[prop] : UNINITIALIZED), stack);
1914
+ });
1915
+ sources.set(prop, s);
1916
+ }
1917
+ if (s !== void 0) {
1918
+ var v = get(s);
1919
+ return v === UNINITIALIZED ? void 0 : v;
1920
+ }
1921
+ return Reflect.get(target, prop, receiver);
1922
+ },
1923
+ getOwnPropertyDescriptor(target, prop) {
1924
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1925
+ if (descriptor && "value" in descriptor) {
1926
+ var s = sources.get(prop);
1927
+ if (s) descriptor.value = get(s);
1928
+ } else if (descriptor === void 0) {
1929
+ var source = sources.get(prop);
1930
+ var value = source?.v;
1931
+ if (source !== void 0 && value !== UNINITIALIZED) return {
1932
+ enumerable: true,
1933
+ configurable: true,
1934
+ value,
1935
+ writable: true
1936
+ };
1937
+ }
1938
+ return descriptor;
1939
+ },
1940
+ has(target, prop) {
1941
+ if (prop === STATE_SYMBOL) return true;
1942
+ var s = sources.get(prop);
1943
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
1944
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
1945
+ if (s === void 0) {
1946
+ s = with_parent(() => {
1947
+ return /* @__PURE__ */ state(has ? proxy(target[prop]) : UNINITIALIZED, stack);
1948
+ });
1949
+ sources.set(prop, s);
1950
+ }
1951
+ if (get(s) === UNINITIALIZED) return false;
1952
+ }
1953
+ return has;
1954
+ },
1955
+ set(target, prop, value, receiver) {
1956
+ var s = sources.get(prop);
1957
+ var has = prop in target;
1958
+ if (is_proxied_array && prop === "length") for (var i = value; i < s.v; i += 1) {
1959
+ var other_s = sources.get(i + "");
1960
+ if (other_s !== void 0) set(other_s, UNINITIALIZED);
1961
+ else if (i in target) {
1962
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED, stack));
1963
+ sources.set(i + "", other_s);
1964
+ }
1965
+ }
1966
+ if (s === void 0) {
1967
+ if (!has || get_descriptor(target, prop)?.writable) {
1968
+ s = with_parent(() => /* @__PURE__ */ state(void 0, stack));
1969
+ set(s, proxy(value));
1970
+ sources.set(prop, s);
1971
+ }
1972
+ } else {
1973
+ has = s.v !== UNINITIALIZED;
1974
+ var p = with_parent(() => proxy(value));
1975
+ set(s, p);
1976
+ }
1977
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1978
+ if (descriptor?.set) descriptor.set.call(receiver, value);
1979
+ if (!has) {
1980
+ if (is_proxied_array && typeof prop === "string") {
1981
+ var ls = sources.get("length");
1982
+ var n = Number(prop);
1983
+ if (Number.isInteger(n) && n >= ls.v) set(ls, n + 1);
1984
+ }
1985
+ increment(version);
1986
+ }
1987
+ return true;
1988
+ },
1989
+ ownKeys(target) {
1990
+ get(version);
1991
+ var own_keys = Reflect.ownKeys(target).filter((key) => {
1992
+ var source = sources.get(key);
1993
+ return source === void 0 || source.v !== UNINITIALIZED;
1994
+ });
1995
+ for (var [key, source] of sources) if (source.v !== UNINITIALIZED && !(key in target)) own_keys.push(key);
1996
+ return own_keys;
1997
+ },
1998
+ setPrototypeOf() {
1999
+ state_prototype_fixed();
2000
+ }
2001
+ });
2002
+ }
2003
+ //#endregion
2004
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/operations.js
2005
+ /** @import { Effect, TemplateNode } from '#client' */
2006
+ /** @type {Window} */
2007
+ var $window;
2008
+ /** @type {Document} */
2009
+ var $document;
2010
+ /** @type {boolean} */
2011
+ var is_firefox;
2012
+ /** @type {() => Node | null} */
2013
+ var first_child_getter;
2014
+ /** @type {() => Node | null} */
2015
+ var next_sibling_getter;
2016
+ /**
2017
+ * Initialize these lazily to avoid issues when using the runtime in a server context
2018
+ * where these globals are not available while avoiding a separate server entry point
2019
+ */
2020
+ function init_operations() {
2021
+ if ($window !== void 0) return;
2022
+ $window = window;
2023
+ $document = document;
2024
+ is_firefox = /Firefox/.test(navigator.userAgent);
2025
+ var element_prototype = Element.prototype;
2026
+ var node_prototype = Node.prototype;
2027
+ var text_prototype = Text.prototype;
2028
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
2029
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
2030
+ if (is_extensible(element_prototype)) {
2031
+ element_prototype.__click = void 0;
2032
+ element_prototype.__className = void 0;
2033
+ element_prototype.__attributes = null;
2034
+ element_prototype.__style = void 0;
2035
+ element_prototype.__e = void 0;
2036
+ }
2037
+ if (is_extensible(text_prototype)) text_prototype.__t = void 0;
2038
+ }
2039
+ /**
2040
+ * @param {string} value
2041
+ * @returns {Text}
2042
+ */
2043
+ function create_text(value = "") {
2044
+ return document.createTextNode(value);
2045
+ }
2046
+ /**
2047
+ * @template {Node} N
2048
+ * @param {N} node
2049
+ */
2050
+ /* @__NO_SIDE_EFFECTS__ */
2051
+ function get_first_child(node) {
2052
+ return first_child_getter.call(node);
2053
+ }
2054
+ /**
2055
+ * @template {Node} N
2056
+ * @param {N} node
2057
+ */
2058
+ /* @__NO_SIDE_EFFECTS__ */
2059
+ function get_next_sibling(node) {
2060
+ return next_sibling_getter.call(node);
2061
+ }
2062
+ /**
2063
+ * Don't mark this as side-effect-free, hydration needs to walk all nodes
2064
+ * @template {Node} N
2065
+ * @param {N} node
2066
+ * @param {boolean} is_text
2067
+ * @returns {TemplateNode | null}
2068
+ */
2069
+ function child(node, is_text) {
2070
+ if (!hydrating) return /* @__PURE__ */ get_first_child(node);
2071
+ var child = /* @__PURE__ */ get_first_child(hydrate_node);
2072
+ if (child === null) child = hydrate_node.appendChild(create_text());
2073
+ else if (is_text && child.nodeType !== 3) {
2074
+ var text = create_text();
2075
+ child?.before(text);
2076
+ set_hydrate_node(text);
2077
+ return text;
2078
+ }
2079
+ if (is_text) merge_text_nodes(child);
2080
+ set_hydrate_node(child);
2081
+ return child;
2082
+ }
2083
+ /**
2084
+ * Don't mark this as side-effect-free, hydration needs to walk all nodes
2085
+ * @param {TemplateNode} node
2086
+ * @param {boolean} [is_text]
2087
+ * @returns {TemplateNode | null}
2088
+ */
2089
+ function first_child(node, is_text = false) {
2090
+ if (!hydrating) {
2091
+ var first = /* @__PURE__ */ get_first_child(node);
2092
+ if (first instanceof Comment && first.data === "") return /* @__PURE__ */ get_next_sibling(first);
2093
+ return first;
2094
+ }
2095
+ if (is_text) {
2096
+ if (hydrate_node?.nodeType !== 3) {
2097
+ var text = create_text();
2098
+ hydrate_node?.before(text);
2099
+ set_hydrate_node(text);
2100
+ return text;
2101
+ }
2102
+ merge_text_nodes(hydrate_node);
2103
+ }
2104
+ return hydrate_node;
2105
+ }
2106
+ /**
2107
+ * Don't mark this as side-effect-free, hydration needs to walk all nodes
2108
+ * @param {TemplateNode} node
2109
+ * @param {number} count
2110
+ * @param {boolean} is_text
2111
+ * @returns {TemplateNode | null}
2112
+ */
2113
+ function sibling(node, count = 1, is_text = false) {
2114
+ let next_sibling = hydrating ? hydrate_node : node;
2115
+ var last_sibling;
2116
+ while (count--) {
2117
+ last_sibling = next_sibling;
2118
+ next_sibling = /* @__PURE__ */ get_next_sibling(next_sibling);
2119
+ }
2120
+ if (!hydrating) return next_sibling;
2121
+ if (is_text) {
2122
+ if (next_sibling?.nodeType !== 3) {
2123
+ var text = create_text();
2124
+ if (next_sibling === null) last_sibling?.after(text);
2125
+ else next_sibling.before(text);
2126
+ set_hydrate_node(text);
2127
+ return text;
2128
+ }
2129
+ merge_text_nodes(next_sibling);
2130
+ }
2131
+ set_hydrate_node(next_sibling);
2132
+ return next_sibling;
2133
+ }
2134
+ /**
2135
+ * @template {Node} N
2136
+ * @param {N} node
2137
+ * @returns {void}
2138
+ */
2139
+ function clear_text_content(node) {
2140
+ node.textContent = "";
2141
+ }
2142
+ /**
2143
+ * Returns `true` if we're updating the current block, for example `condition` in
2144
+ * an `{#if condition}` block just changed. In this case, the branch should be
2145
+ * appended (or removed) at the same time as other updates within the
2146
+ * current `<svelte:boundary>`
2147
+ */
2148
+ function should_defer_append() {
2149
+ if (!async_mode_flag) return false;
2150
+ if (eager_block_effects !== null) return false;
2151
+ return (active_effect.f & REACTION_RAN) !== 0;
2152
+ }
2153
+ /**
2154
+ * @template {keyof HTMLElementTagNameMap | string} T
2155
+ * @param {T} tag
2156
+ * @param {string} [namespace]
2157
+ * @param {string} [is]
2158
+ * @returns {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element}
2159
+ */
2160
+ function create_element(tag, namespace, is) {
2161
+ let options = is ? { is } : void 0;
2162
+ return document.createElementNS(namespace ?? "http://www.w3.org/1999/xhtml", tag, options);
2163
+ }
2164
+ /**
2165
+ * Browsers split text nodes larger than 65536 bytes when parsing.
2166
+ * For hydration to succeed, we need to stitch them back together
2167
+ * @param {Text} text
2168
+ */
2169
+ function merge_text_nodes(text) {
2170
+ if (text.nodeValue.length < 65536) return;
2171
+ let next = text.nextSibling;
2172
+ while (next !== null && next.nodeType === 3) {
2173
+ next.remove();
2174
+ /** @type {string} */ text.nodeValue += next.nodeValue;
2175
+ next = text.nextSibling;
2176
+ }
2177
+ }
2178
+ //#endregion
2179
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/elements/misc.js
2180
+ /**
2181
+ * The child of a textarea actually corresponds to the defaultValue property, so we need
2182
+ * to remove it upon hydration to avoid a bug when someone resets the form value.
2183
+ * @param {HTMLTextAreaElement} dom
2184
+ * @returns {void}
2185
+ */
2186
+ function remove_textarea_child(dom) {
2187
+ if (hydrating && /* @__PURE__ */ get_first_child(dom) !== null) clear_text_content(dom);
2188
+ }
2189
+ var listening_to_form_reset = false;
2190
+ function add_form_reset_listener() {
2191
+ if (!listening_to_form_reset) {
2192
+ listening_to_form_reset = true;
2193
+ document.addEventListener("reset", (evt) => {
2194
+ Promise.resolve().then(() => {
2195
+ if (!evt.defaultPrevented) for (const e of evt.target.elements) e.__on_r?.();
2196
+ });
2197
+ }, { capture: true });
2198
+ }
2199
+ }
2200
+ //#endregion
2201
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
2202
+ /**
2203
+ * @template T
2204
+ * @param {() => T} fn
2205
+ */
2206
+ function without_reactive_context(fn) {
2207
+ var previous_reaction = active_reaction;
2208
+ var previous_effect = active_effect;
2209
+ set_active_reaction(null);
2210
+ set_active_effect(null);
2211
+ try {
2212
+ return fn();
2213
+ } finally {
2214
+ set_active_reaction(previous_reaction);
2215
+ set_active_effect(previous_effect);
2216
+ }
2217
+ }
2218
+ /**
2219
+ * Listen to the given event, and then instantiate a global form reset listener if not already done,
2220
+ * to notify all bindings when the form is reset
2221
+ * @param {HTMLElement} element
2222
+ * @param {string} event
2223
+ * @param {(is_reset?: true) => void} handler
2224
+ * @param {(is_reset?: true) => void} [on_reset]
2225
+ */
2226
+ function listen_to_event_and_reset_event(element, event, handler, on_reset = handler) {
2227
+ element.addEventListener(event, () => without_reactive_context(handler));
2228
+ const prev = element.__on_r;
2229
+ if (prev) element.__on_r = () => {
2230
+ prev();
2231
+ on_reset(true);
2232
+ };
2233
+ else element.__on_r = () => on_reset(true);
2234
+ add_form_reset_listener();
2235
+ }
2236
+ //#endregion
2237
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/reactivity/effects.js
2238
+ /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
2239
+ /**
2240
+ * @param {Effect} effect
2241
+ * @param {Effect} parent_effect
2242
+ */
2243
+ function push_effect(effect, parent_effect) {
2244
+ var parent_last = parent_effect.last;
2245
+ if (parent_last === null) parent_effect.last = parent_effect.first = effect;
2246
+ else {
2247
+ parent_last.next = effect;
2248
+ effect.prev = parent_last;
2249
+ parent_effect.last = effect;
2250
+ }
2251
+ }
2252
+ /**
2253
+ * @param {number} type
2254
+ * @param {null | (() => void | (() => void))} fn
2255
+ * @returns {Effect}
2256
+ */
2257
+ function create_effect(type, fn) {
2258
+ var parent = active_effect;
2259
+ if (parent !== null && (parent.f & 8192) !== 0) type |= INERT;
2260
+ /** @type {Effect} */
2261
+ var effect = {
2262
+ ctx: component_context,
2263
+ deps: null,
2264
+ nodes: null,
2265
+ f: type | DIRTY | 512,
2266
+ first: null,
2267
+ fn,
2268
+ last: null,
2269
+ next: null,
2270
+ parent,
2271
+ b: parent && parent.b,
2272
+ prev: null,
2273
+ teardown: null,
2274
+ wv: 0,
2275
+ ac: null
2276
+ };
2277
+ current_batch?.register_created_effect(effect);
2278
+ /** @type {Effect | null} */
2279
+ var e = effect;
2280
+ if ((type & 4) !== 0) if (collected_effects !== null) collected_effects.push(effect);
2281
+ else Batch.ensure().schedule(effect);
2282
+ else if (fn !== null) {
2283
+ try {
2284
+ update_effect(effect);
2285
+ } catch (e) {
2286
+ destroy_effect(effect);
2287
+ throw e;
2288
+ }
2289
+ if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && (e.f & 524288) === 0) {
2290
+ e = e.first;
2291
+ if ((type & 16) !== 0 && (type & 65536) !== 0 && e !== null) e.f |= EFFECT_TRANSPARENT;
2292
+ }
2293
+ }
2294
+ if (e !== null) {
2295
+ e.parent = parent;
2296
+ if (parent !== null) push_effect(e, parent);
2297
+ if (active_reaction !== null && (active_reaction.f & 2) !== 0 && (type & 64) === 0) {
2298
+ var derived = active_reaction;
2299
+ (derived.effects ??= []).push(e);
2300
+ }
2301
+ }
2302
+ return effect;
2303
+ }
2304
+ /**
2305
+ * Internal representation of `$effect.tracking()`
2306
+ * @returns {boolean}
2307
+ */
2308
+ function effect_tracking() {
2309
+ return active_reaction !== null && !untracking;
2310
+ }
2311
+ /**
2312
+ * @param {() => void} fn
2313
+ */
2314
+ function teardown(fn) {
2315
+ const effect = create_effect(8, null);
2316
+ set_signal_status(effect, CLEAN);
2317
+ effect.teardown = fn;
2318
+ return effect;
2319
+ }
2320
+ /**
2321
+ * @param {() => void | (() => void)} fn
2322
+ */
2323
+ function create_user_effect(fn) {
2324
+ return create_effect(4 | USER_EFFECT, fn);
2325
+ }
2326
+ /**
2327
+ * An effect root whose children can transition out
2328
+ * @param {() => void} fn
2329
+ * @returns {(options?: { outro?: boolean }) => Promise<void>}
2330
+ */
2331
+ function component_root(fn) {
2332
+ Batch.ensure();
2333
+ const effect = create_effect(64 | EFFECT_PRESERVED, fn);
2334
+ return (options = {}) => {
2335
+ return new Promise((fulfil) => {
2336
+ if (options.outro) pause_effect(effect, () => {
2337
+ destroy_effect(effect);
2338
+ fulfil(void 0);
2339
+ });
2340
+ else {
2341
+ destroy_effect(effect);
2342
+ fulfil(void 0);
2343
+ }
2344
+ });
2345
+ };
2346
+ }
2347
+ /**
2348
+ * @param {() => void | (() => void)} fn
2349
+ * @returns {Effect}
2350
+ */
2351
+ function effect(fn) {
2352
+ return create_effect(4, fn);
2353
+ }
2354
+ /**
2355
+ * @param {() => void | (() => void)} fn
2356
+ * @returns {Effect}
2357
+ */
2358
+ function async_effect(fn) {
2359
+ return create_effect(ASYNC | EFFECT_PRESERVED, fn);
2360
+ }
2361
+ /**
2362
+ * @param {() => void | (() => void)} fn
2363
+ * @returns {Effect}
2364
+ */
2365
+ function render_effect(fn, flags = 0) {
2366
+ return create_effect(8 | flags, fn);
2367
+ }
2368
+ /**
2369
+ * @param {(...expressions: any) => void | (() => void)} fn
2370
+ * @param {Array<() => any>} sync
2371
+ * @param {Array<() => Promise<any>>} async
2372
+ * @param {Blocker[]} blockers
2373
+ */
2374
+ function template_effect(fn, sync = [], async = [], blockers = []) {
2375
+ flatten(blockers, sync, async, (values) => {
2376
+ create_effect(8, () => fn(...values.map(get)));
2377
+ });
2378
+ }
2379
+ /**
2380
+ * @param {(() => void)} fn
2381
+ * @param {number} flags
2382
+ */
2383
+ function block(fn, flags = 0) {
2384
+ return create_effect(16 | flags, fn);
2385
+ }
2386
+ /**
2387
+ * @param {(() => void)} fn
2388
+ */
2389
+ function branch(fn) {
2390
+ return create_effect(32 | EFFECT_PRESERVED, fn);
2391
+ }
2392
+ /**
2393
+ * @param {Effect} effect
2394
+ */
2395
+ function execute_effect_teardown(effect) {
2396
+ var teardown = effect.teardown;
2397
+ if (teardown !== null) {
2398
+ const previously_destroying_effect = is_destroying_effect;
2399
+ const previous_reaction = active_reaction;
2400
+ set_is_destroying_effect(true);
2401
+ set_active_reaction(null);
2402
+ try {
2403
+ teardown.call(null);
2404
+ } finally {
2405
+ set_is_destroying_effect(previously_destroying_effect);
2406
+ set_active_reaction(previous_reaction);
2407
+ }
2408
+ }
2409
+ }
2410
+ /**
2411
+ * @param {Effect} signal
2412
+ * @param {boolean} remove_dom
2413
+ * @returns {void}
2414
+ */
2415
+ function destroy_effect_children(signal, remove_dom = false) {
2416
+ var effect = signal.first;
2417
+ signal.first = signal.last = null;
2418
+ while (effect !== null) {
2419
+ const controller = effect.ac;
2420
+ if (controller !== null) without_reactive_context(() => {
2421
+ controller.abort(STALE_REACTION);
2422
+ });
2423
+ var next = effect.next;
2424
+ if ((effect.f & 64) !== 0) effect.parent = null;
2425
+ else destroy_effect(effect, remove_dom);
2426
+ effect = next;
2427
+ }
2428
+ }
2429
+ /**
2430
+ * @param {Effect} signal
2431
+ * @returns {void}
2432
+ */
2433
+ function destroy_block_effect_children(signal) {
2434
+ var effect = signal.first;
2435
+ while (effect !== null) {
2436
+ var next = effect.next;
2437
+ if ((effect.f & 32) === 0) destroy_effect(effect);
2438
+ effect = next;
2439
+ }
2440
+ }
2441
+ /**
2442
+ * @param {Effect} effect
2443
+ * @param {boolean} [remove_dom]
2444
+ * @returns {void}
2445
+ */
2446
+ function destroy_effect(effect, remove_dom = true) {
2447
+ var removed = false;
2448
+ if ((remove_dom || (effect.f & 262144) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
2449
+ remove_effect_dom(effect.nodes.start, effect.nodes.end);
2450
+ removed = true;
2451
+ }
2452
+ set_signal_status(effect, DESTROYING);
2453
+ destroy_effect_children(effect, remove_dom && !removed);
2454
+ remove_reactions(effect, 0);
2455
+ var transitions = effect.nodes && effect.nodes.t;
2456
+ if (transitions !== null) for (const transition of transitions) transition.stop();
2457
+ execute_effect_teardown(effect);
2458
+ effect.f ^= DESTROYING;
2459
+ effect.f |= DESTROYED;
2460
+ var parent = effect.parent;
2461
+ if (parent !== null && parent.first !== null) unlink_effect(effect);
2462
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = effect.b = null;
2463
+ }
2464
+ /**
2465
+ *
2466
+ * @param {TemplateNode | null} node
2467
+ * @param {TemplateNode} end
2468
+ */
2469
+ function remove_effect_dom(node, end) {
2470
+ while (node !== null) {
2471
+ /** @type {TemplateNode | null} */
2472
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2473
+ node.remove();
2474
+ node = next;
2475
+ }
2476
+ }
2477
+ /**
2478
+ * Detach an effect from the effect tree, freeing up memory and
2479
+ * reducing the amount of work that happens on subsequent traversals
2480
+ * @param {Effect} effect
2481
+ */
2482
+ function unlink_effect(effect) {
2483
+ var parent = effect.parent;
2484
+ var prev = effect.prev;
2485
+ var next = effect.next;
2486
+ if (prev !== null) prev.next = next;
2487
+ if (next !== null) next.prev = prev;
2488
+ if (parent !== null) {
2489
+ if (parent.first === effect) parent.first = next;
2490
+ if (parent.last === effect) parent.last = prev;
2491
+ }
2492
+ }
2493
+ /**
2494
+ * When a block effect is removed, we don't immediately destroy it or yank it
2495
+ * out of the DOM, because it might have transitions. Instead, we 'pause' it.
2496
+ * It stays around (in memory, and in the DOM) until outro transitions have
2497
+ * completed, and if the state change is reversed then we _resume_ it.
2498
+ * A paused effect does not update, and the DOM subtree becomes inert.
2499
+ * @param {Effect} effect
2500
+ * @param {() => void} [callback]
2501
+ * @param {boolean} [destroy]
2502
+ */
2503
+ function pause_effect(effect, callback, destroy = true) {
2504
+ /** @type {TransitionManager[]} */
2505
+ var transitions = [];
2506
+ pause_children(effect, transitions, true);
2507
+ var fn = () => {
2508
+ if (destroy) destroy_effect(effect);
2509
+ if (callback) callback();
2510
+ };
2511
+ var remaining = transitions.length;
2512
+ if (remaining > 0) {
2513
+ var check = () => --remaining || fn();
2514
+ for (var transition of transitions) transition.out(check);
2515
+ } else fn();
2516
+ }
2517
+ /**
2518
+ * @param {Effect} effect
2519
+ * @param {TransitionManager[]} transitions
2520
+ * @param {boolean} local
2521
+ */
2522
+ function pause_children(effect, transitions, local) {
2523
+ if ((effect.f & 8192) !== 0) return;
2524
+ effect.f ^= INERT;
2525
+ var t = effect.nodes && effect.nodes.t;
2526
+ if (t !== null) {
2527
+ for (const transition of t) if (transition.is_global || local) transitions.push(transition);
2528
+ }
2529
+ var child = effect.first;
2530
+ while (child !== null) {
2531
+ var sibling = child.next;
2532
+ var transparent = (child.f & 65536) !== 0 || (child.f & 32) !== 0 && (effect.f & 16) !== 0;
2533
+ pause_children(child, transitions, transparent ? local : false);
2534
+ child = sibling;
2535
+ }
2536
+ }
2537
+ /**
2538
+ * The opposite of `pause_effect`. We call this if (for example)
2539
+ * `x` becomes falsy then truthy: `{#if x}...{/if}`
2540
+ * @param {Effect} effect
2541
+ */
2542
+ function resume_effect(effect) {
2543
+ resume_children(effect, true);
2544
+ }
2545
+ /**
2546
+ * @param {Effect} effect
2547
+ * @param {boolean} local
2548
+ */
2549
+ function resume_children(effect, local) {
2550
+ if ((effect.f & 8192) === 0) return;
2551
+ effect.f ^= INERT;
2552
+ if ((effect.f & 1024) === 0) {
2553
+ set_signal_status(effect, DIRTY);
2554
+ Batch.ensure().schedule(effect);
2555
+ }
2556
+ var child = effect.first;
2557
+ while (child !== null) {
2558
+ var sibling = child.next;
2559
+ var transparent = (child.f & 65536) !== 0 || (child.f & 32) !== 0;
2560
+ resume_children(child, transparent ? local : false);
2561
+ child = sibling;
2562
+ }
2563
+ var t = effect.nodes && effect.nodes.t;
2564
+ if (t !== null) {
2565
+ for (const transition of t) if (transition.is_global || local) transition.in();
2566
+ }
2567
+ }
2568
+ /**
2569
+ * @param {Effect} effect
2570
+ * @param {DocumentFragment} fragment
2571
+ */
2572
+ function move_effect(effect, fragment) {
2573
+ if (!effect.nodes) return;
2574
+ /** @type {TemplateNode | null} */
2575
+ var node = effect.nodes.start;
2576
+ var end = effect.nodes.end;
2577
+ while (node !== null) {
2578
+ /** @type {TemplateNode | null} */
2579
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2580
+ fragment.append(node);
2581
+ node = next;
2582
+ }
2583
+ }
2584
+ //#endregion
2585
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/legacy.js
2586
+ /**
2587
+ * @type {Set<Value> | null}
2588
+ * @deprecated
2589
+ */
2590
+ var captured_signals = null;
2591
+ //#endregion
2592
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/runtime.js
2593
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
2594
+ var is_updating_effect = false;
2595
+ var is_destroying_effect = false;
2596
+ /** @param {boolean} value */
2597
+ function set_is_destroying_effect(value) {
2598
+ is_destroying_effect = value;
2599
+ }
2600
+ /** @type {null | Reaction} */
2601
+ var active_reaction = null;
2602
+ var untracking = false;
2603
+ /** @param {null | Reaction} reaction */
2604
+ function set_active_reaction(reaction) {
2605
+ active_reaction = reaction;
2606
+ }
2607
+ /** @type {null | Effect} */
2608
+ var active_effect = null;
2609
+ /** @param {null | Effect} effect */
2610
+ function set_active_effect(effect) {
2611
+ active_effect = effect;
2612
+ }
2613
+ /**
2614
+ * When sources are created within a reaction, reading and writing
2615
+ * them within that reaction should not cause a re-run
2616
+ * @type {null | Source[]}
2617
+ */
2618
+ var current_sources = null;
2619
+ /** @param {Value} value */
2620
+ function push_reaction_value(value) {
2621
+ if (active_reaction !== null && (!async_mode_flag || (active_reaction.f & 2) !== 0)) if (current_sources === null) current_sources = [value];
2622
+ else current_sources.push(value);
2623
+ }
2624
+ /**
2625
+ * The dependencies of the reaction that is currently being executed. In many cases,
2626
+ * the dependencies are unchanged between runs, and so this will be `null` unless
2627
+ * and until a new dependency is accessed — we track this via `skipped_deps`
2628
+ * @type {null | Value[]}
2629
+ */
2630
+ var new_deps = null;
2631
+ var skipped_deps = 0;
2632
+ /**
2633
+ * Tracks writes that the effect it's executed in doesn't listen to yet,
2634
+ * so that the dependency can be added to the effect later on if it then reads it
2635
+ * @type {null | Source[]}
2636
+ */
2637
+ var untracked_writes = null;
2638
+ /** @param {null | Source[]} value */
2639
+ function set_untracked_writes(value) {
2640
+ untracked_writes = value;
2641
+ }
2642
+ /**
2643
+ * @type {number} Used by sources and deriveds for handling updates.
2644
+ * Version starts from 1 so that unowned deriveds differentiate between a created effect and a run one for tracing
2645
+ **/
2646
+ var write_version = 1;
2647
+ /** @type {number} Used to version each read of a source of derived to avoid duplicating depedencies inside a reaction */
2648
+ var read_version = 0;
2649
+ var update_version = read_version;
2650
+ /** @param {number} value */
2651
+ function set_update_version(value) {
2652
+ update_version = value;
2653
+ }
2654
+ function increment_write_version() {
2655
+ return ++write_version;
2656
+ }
2657
+ /**
2658
+ * Determines whether a derived or effect is dirty.
2659
+ * If it is MAYBE_DIRTY, will set the status to CLEAN
2660
+ * @param {Reaction} reaction
2661
+ * @returns {boolean}
2662
+ */
2663
+ function is_dirty(reaction) {
2664
+ var flags = reaction.f;
2665
+ if ((flags & 2048) !== 0) return true;
2666
+ if (flags & 2) reaction.f &= ~WAS_MARKED;
2667
+ if ((flags & 4096) !== 0) {
2668
+ var dependencies = reaction.deps;
2669
+ var length = dependencies.length;
2670
+ for (var i = 0; i < length; i++) {
2671
+ var dependency = dependencies[i];
2672
+ if (is_dirty(dependency)) update_derived(dependency);
2673
+ if (dependency.wv > reaction.wv) return true;
2674
+ }
2675
+ if ((flags & 512) !== 0 && batch_values === null) set_signal_status(reaction, CLEAN);
2676
+ }
2677
+ return false;
2678
+ }
2679
+ /**
2680
+ * @param {Value} signal
2681
+ * @param {Effect} effect
2682
+ * @param {boolean} [root]
2683
+ */
2684
+ function schedule_possible_effect_self_invalidation(signal, effect, root = true) {
2685
+ var reactions = signal.reactions;
2686
+ if (reactions === null) return;
2687
+ if (!async_mode_flag && current_sources !== null && includes.call(current_sources, signal)) return;
2688
+ for (var i = 0; i < reactions.length; i++) {
2689
+ var reaction = reactions[i];
2690
+ if ((reaction.f & 2) !== 0) schedule_possible_effect_self_invalidation(reaction, effect, false);
2691
+ else if (effect === reaction) {
2692
+ if (root) set_signal_status(reaction, DIRTY);
2693
+ else if ((reaction.f & 1024) !== 0) set_signal_status(reaction, MAYBE_DIRTY);
2694
+ schedule_effect(reaction);
2695
+ }
2696
+ }
2697
+ }
2698
+ /** @param {Reaction} reaction */
2699
+ function update_reaction(reaction) {
2700
+ var previous_deps = new_deps;
2701
+ var previous_skipped_deps = skipped_deps;
2702
+ var previous_untracked_writes = untracked_writes;
2703
+ var previous_reaction = active_reaction;
2704
+ var previous_sources = current_sources;
2705
+ var previous_component_context = component_context;
2706
+ var previous_untracking = untracking;
2707
+ var previous_update_version = update_version;
2708
+ var flags = reaction.f;
2709
+ new_deps = null;
2710
+ skipped_deps = 0;
2711
+ untracked_writes = null;
2712
+ active_reaction = (flags & 96) === 0 ? reaction : null;
2713
+ current_sources = null;
2714
+ set_component_context(reaction.ctx);
2715
+ untracking = false;
2716
+ update_version = ++read_version;
2717
+ if (reaction.ac !== null) {
2718
+ without_reactive_context(() => {
2719
+ /** @type {AbortController} */ reaction.ac.abort(STALE_REACTION);
2720
+ });
2721
+ reaction.ac = null;
2722
+ }
2723
+ try {
2724
+ reaction.f |= REACTION_IS_UPDATING;
2725
+ var fn = reaction.fn;
2726
+ var result = fn();
2727
+ reaction.f |= REACTION_RAN;
2728
+ var deps = reaction.deps;
2729
+ var is_fork = current_batch?.is_fork;
2730
+ if (new_deps !== null) {
2731
+ var i;
2732
+ if (!is_fork) remove_reactions(reaction, skipped_deps);
2733
+ if (deps !== null && skipped_deps > 0) {
2734
+ deps.length = skipped_deps + new_deps.length;
2735
+ for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
2736
+ } else reaction.deps = deps = new_deps;
2737
+ if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) (deps[i].reactions ??= []).push(reaction);
2738
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2739
+ remove_reactions(reaction, skipped_deps);
2740
+ deps.length = skipped_deps;
2741
+ }
2742
+ 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);
2743
+ if (previous_reaction !== null && previous_reaction !== reaction) {
2744
+ read_version++;
2745
+ if (previous_reaction.deps !== null) for (let i = 0; i < previous_skipped_deps; i += 1) previous_reaction.deps[i].rv = read_version;
2746
+ if (previous_deps !== null) for (const dep of previous_deps) dep.rv = read_version;
2747
+ if (untracked_writes !== null) if (previous_untracked_writes === null) previous_untracked_writes = untracked_writes;
2748
+ else previous_untracked_writes.push(...untracked_writes);
2749
+ }
2750
+ if ((reaction.f & 8388608) !== 0) reaction.f ^= ERROR_VALUE;
2751
+ return result;
2752
+ } catch (error) {
2753
+ return handle_error(error);
2754
+ } finally {
2755
+ reaction.f ^= REACTION_IS_UPDATING;
2756
+ new_deps = previous_deps;
2757
+ skipped_deps = previous_skipped_deps;
2758
+ untracked_writes = previous_untracked_writes;
2759
+ active_reaction = previous_reaction;
2760
+ current_sources = previous_sources;
2761
+ set_component_context(previous_component_context);
2762
+ untracking = previous_untracking;
2763
+ update_version = previous_update_version;
2764
+ }
2765
+ }
2766
+ /**
2767
+ * @template V
2768
+ * @param {Reaction} signal
2769
+ * @param {Value<V>} dependency
2770
+ * @returns {void}
2771
+ */
2772
+ function remove_reaction(signal, dependency) {
2773
+ let reactions = dependency.reactions;
2774
+ if (reactions !== null) {
2775
+ var index = index_of.call(reactions, signal);
2776
+ if (index !== -1) {
2777
+ var new_length = reactions.length - 1;
2778
+ if (new_length === 0) reactions = dependency.reactions = null;
2779
+ else {
2780
+ reactions[index] = reactions[new_length];
2781
+ reactions.pop();
2782
+ }
2783
+ }
2784
+ }
2785
+ if (reactions === null && (dependency.f & 2) !== 0 && (new_deps === null || !includes.call(new_deps, dependency))) {
2786
+ var derived = dependency;
2787
+ if ((derived.f & 512) !== 0) {
2788
+ derived.f ^= 512;
2789
+ derived.f &= ~WAS_MARKED;
2790
+ }
2791
+ if (derived.v !== UNINITIALIZED) update_derived_status(derived);
2792
+ freeze_derived_effects(derived);
2793
+ remove_reactions(derived, 0);
2794
+ }
2795
+ }
2796
+ /**
2797
+ * @param {Reaction} signal
2798
+ * @param {number} start_index
2799
+ * @returns {void}
2800
+ */
2801
+ function remove_reactions(signal, start_index) {
2802
+ var dependencies = signal.deps;
2803
+ if (dependencies === null) return;
2804
+ for (var i = start_index; i < dependencies.length; i++) remove_reaction(signal, dependencies[i]);
2805
+ }
2806
+ /**
2807
+ * @param {Effect} effect
2808
+ * @returns {void}
2809
+ */
2810
+ function update_effect(effect) {
2811
+ var flags = effect.f;
2812
+ if ((flags & 16384) !== 0) return;
2813
+ set_signal_status(effect, CLEAN);
2814
+ var previous_effect = active_effect;
2815
+ var was_updating_effect = is_updating_effect;
2816
+ active_effect = effect;
2817
+ is_updating_effect = true;
2818
+ try {
2819
+ if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
2820
+ else destroy_effect_children(effect);
2821
+ execute_effect_teardown(effect);
2822
+ var teardown = update_reaction(effect);
2823
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2824
+ effect.wv = write_version;
2825
+ } finally {
2826
+ is_updating_effect = was_updating_effect;
2827
+ active_effect = previous_effect;
2828
+ }
2829
+ }
2830
+ /**
2831
+ * Returns a promise that resolves once any pending state changes have been applied.
2832
+ * @returns {Promise<void>}
2833
+ */
2834
+ async function tick() {
2835
+ if (async_mode_flag) return new Promise((f) => {
2836
+ requestAnimationFrame(() => f());
2837
+ setTimeout(() => f());
2838
+ });
2839
+ await Promise.resolve();
2840
+ flushSync();
2841
+ }
2842
+ /**
2843
+ * @template V
2844
+ * @param {Value<V>} signal
2845
+ * @returns {V}
2846
+ */
2847
+ function get(signal) {
2848
+ var is_derived = (signal.f & 2) !== 0;
2849
+ captured_signals?.add(signal);
2850
+ if (active_reaction !== null && !untracking) {
2851
+ if (!(active_effect !== null && (active_effect.f & 16384) !== 0) && (current_sources === null || !includes.call(current_sources, signal))) {
2852
+ var deps = active_reaction.deps;
2853
+ if ((active_reaction.f & 2097152) !== 0) {
2854
+ if (signal.rv < read_version) {
2855
+ signal.rv = read_version;
2856
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) skipped_deps++;
2857
+ else if (new_deps === null) new_deps = [signal];
2858
+ else new_deps.push(signal);
2859
+ }
2860
+ } else {
2861
+ (active_reaction.deps ??= []).push(signal);
2862
+ var reactions = signal.reactions;
2863
+ if (reactions === null) signal.reactions = [active_reaction];
2864
+ else if (!includes.call(reactions, active_reaction)) reactions.push(active_reaction);
2865
+ }
2866
+ }
2867
+ }
2868
+ if (is_destroying_effect && old_values.has(signal)) return old_values.get(signal);
2869
+ if (is_derived) {
2870
+ var derived = signal;
2871
+ if (is_destroying_effect) {
2872
+ var value = derived.v;
2873
+ if ((derived.f & 1024) === 0 && derived.reactions !== null || depends_on_old_values(derived)) value = execute_derived(derived);
2874
+ old_values.set(derived, value);
2875
+ return value;
2876
+ }
2877
+ var should_connect = (derived.f & 512) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & 512) !== 0);
2878
+ var is_new = (derived.f & REACTION_RAN) === 0;
2879
+ if (is_dirty(derived)) {
2880
+ if (should_connect) derived.f |= 512;
2881
+ update_derived(derived);
2882
+ }
2883
+ if (should_connect && !is_new) {
2884
+ unfreeze_derived_effects(derived);
2885
+ reconnect(derived);
2886
+ }
2887
+ }
2888
+ if (batch_values?.has(signal)) return batch_values.get(signal);
2889
+ if ((signal.f & 8388608) !== 0) throw signal.v;
2890
+ return signal.v;
2891
+ }
2892
+ /**
2893
+ * (Re)connect a disconnected derived, so that it is notified
2894
+ * of changes in `mark_reactions`
2895
+ * @param {Derived} derived
2896
+ */
2897
+ function reconnect(derived) {
2898
+ derived.f |= 512;
2899
+ if (derived.deps === null) return;
2900
+ for (const dep of derived.deps) {
2901
+ (dep.reactions ??= []).push(derived);
2902
+ if ((dep.f & 2) !== 0 && (dep.f & 512) === 0) {
2903
+ unfreeze_derived_effects(dep);
2904
+ reconnect(dep);
2905
+ }
2906
+ }
2907
+ }
2908
+ /** @param {Derived} derived */
2909
+ function depends_on_old_values(derived) {
2910
+ if (derived.v === UNINITIALIZED) return true;
2911
+ if (derived.deps === null) return false;
2912
+ for (const dep of derived.deps) {
2913
+ if (old_values.has(dep)) return true;
2914
+ if ((dep.f & 2) !== 0 && depends_on_old_values(dep)) return true;
2915
+ }
2916
+ return false;
2917
+ }
2918
+ /**
2919
+ * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect),
2920
+ * any state read inside `fn` will not be treated as a dependency.
2921
+ *
2922
+ * ```ts
2923
+ * $effect(() => {
2924
+ * // this will run when `data` changes, but not when `time` changes
2925
+ * save(data, {
2926
+ * timestamp: untrack(() => time)
2927
+ * });
2928
+ * });
2929
+ * ```
2930
+ * @template T
2931
+ * @param {() => T} fn
2932
+ * @returns {T}
2933
+ */
2934
+ function untrack(fn) {
2935
+ var previous_untracking = untracking;
2936
+ try {
2937
+ untracking = true;
2938
+ return fn();
2939
+ } finally {
2940
+ untracking = previous_untracking;
2941
+ }
2942
+ }
2943
+ /**
2944
+ * Subset of delegated events which should be passive by default.
2945
+ * These two are already passive via browser defaults on window, document and body.
2946
+ * But since
2947
+ * - we're delegating them
2948
+ * - they happen often
2949
+ * - they apply to mobile which is generally less performant
2950
+ * we're marking them as passive by default for other elements, too.
2951
+ */
2952
+ var PASSIVE_EVENTS = ["touchstart", "touchmove"];
2953
+ /**
2954
+ * Returns `true` if `name` is a passive event
2955
+ * @param {string} name
2956
+ */
2957
+ function is_passive_event(name) {
2958
+ return PASSIVE_EVENTS.includes(name);
2959
+ }
2960
+ //#endregion
2961
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/elements/events.js
2962
+ /**
2963
+ * Used on elements, as a map of event type -> event handler,
2964
+ * and on events themselves to track which element handled an event
2965
+ */
2966
+ var event_symbol = Symbol("events");
2967
+ /** @type {Set<string>} */
2968
+ var all_registered_events = /* @__PURE__ */ new Set();
2969
+ /** @type {Set<(events: Array<string>) => void>} */
2970
+ var root_event_handles = /* @__PURE__ */ new Set();
2971
+ /**
2972
+ * @param {string} event_name
2973
+ * @param {Element} element
2974
+ * @param {EventListener} [handler]
2975
+ * @returns {void}
2976
+ */
2977
+ function delegated(event_name, element, handler) {
2978
+ (element[event_symbol] ??= {})[event_name] = handler;
2979
+ }
2980
+ /**
2981
+ * @param {Array<string>} events
2982
+ * @returns {void}
2983
+ */
2984
+ function delegate(events) {
2985
+ for (var i = 0; i < events.length; i++) all_registered_events.add(events[i]);
2986
+ for (var fn of root_event_handles) fn(events);
2987
+ }
2988
+ var last_propagated_event = null;
2989
+ /**
2990
+ * @this {EventTarget}
2991
+ * @param {Event} event
2992
+ * @returns {void}
2993
+ */
2994
+ function handle_event_propagation(event) {
2995
+ var handler_element = this;
2996
+ var owner_document = handler_element.ownerDocument;
2997
+ var event_name = event.type;
2998
+ var path = event.composedPath?.() || [];
2999
+ var current_target = path[0] || event.target;
3000
+ last_propagated_event = event;
3001
+ var path_idx = 0;
3002
+ var handled_at = last_propagated_event === event && event[event_symbol];
3003
+ if (handled_at) {
3004
+ var at_idx = path.indexOf(handled_at);
3005
+ if (at_idx !== -1 && (handler_element === document || handler_element === window)) {
3006
+ event[event_symbol] = handler_element;
3007
+ return;
3008
+ }
3009
+ var handler_idx = path.indexOf(handler_element);
3010
+ if (handler_idx === -1) return;
3011
+ if (at_idx <= handler_idx) path_idx = at_idx;
3012
+ }
3013
+ current_target = path[path_idx] || event.target;
3014
+ if (current_target === handler_element) return;
3015
+ define_property(event, "currentTarget", {
3016
+ configurable: true,
3017
+ get() {
3018
+ return current_target || owner_document;
3019
+ }
3020
+ });
3021
+ var previous_reaction = active_reaction;
3022
+ var previous_effect = active_effect;
3023
+ set_active_reaction(null);
3024
+ set_active_effect(null);
3025
+ try {
3026
+ /**
3027
+ * @type {unknown}
3028
+ */
3029
+ var throw_error;
3030
+ /**
3031
+ * @type {unknown[]}
3032
+ */
3033
+ var other_errors = [];
3034
+ while (current_target !== null) {
3035
+ /** @type {null | Element} */
3036
+ var parent_element = current_target.assignedSlot || current_target.parentNode || current_target.host || null;
3037
+ try {
3038
+ var delegated = current_target[event_symbol]?.[event_name];
3039
+ if (delegated != null && (!current_target.disabled || event.target === current_target)) delegated.call(current_target, event);
3040
+ } catch (error) {
3041
+ if (throw_error) other_errors.push(error);
3042
+ else throw_error = error;
3043
+ }
3044
+ if (event.cancelBubble || parent_element === handler_element || parent_element === null) break;
3045
+ current_target = parent_element;
3046
+ }
3047
+ if (throw_error) {
3048
+ for (let error of other_errors) queueMicrotask(() => {
3049
+ throw error;
3050
+ });
3051
+ throw throw_error;
3052
+ }
3053
+ } finally {
3054
+ event[event_symbol] = handler_element;
3055
+ delete event.currentTarget;
3056
+ set_active_reaction(previous_reaction);
3057
+ set_active_effect(previous_effect);
3058
+ }
3059
+ }
3060
+ //#endregion
3061
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/reconciler.js
3062
+ var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", { createHTML: (html) => {
3063
+ return html;
3064
+ } });
3065
+ /** @param {string} html */
3066
+ function create_trusted_html(html) {
3067
+ return policy?.createHTML(html) ?? html;
3068
+ }
3069
+ /**
3070
+ * @param {string} html
3071
+ */
3072
+ function create_fragment_from_html(html) {
3073
+ var elem = create_element("template");
3074
+ elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
3075
+ return elem.content;
3076
+ }
3077
+ //#endregion
3078
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/template.js
3079
+ /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
3080
+ /** @import { TemplateStructure } from './types' */
3081
+ /**
3082
+ * @param {TemplateNode} start
3083
+ * @param {TemplateNode | null} end
3084
+ */
3085
+ function assign_nodes(start, end) {
3086
+ var effect = active_effect;
3087
+ if (effect.nodes === null) effect.nodes = {
3088
+ start,
3089
+ end,
3090
+ a: null,
3091
+ t: null
3092
+ };
3093
+ }
3094
+ /**
3095
+ * @param {string} content
3096
+ * @param {number} flags
3097
+ * @returns {() => Node | Node[]}
3098
+ */
3099
+ /* @__NO_SIDE_EFFECTS__ */
3100
+ function from_html(content, flags) {
3101
+ var is_fragment = (flags & 1) !== 0;
3102
+ var use_import_node = (flags & 2) !== 0;
3103
+ /** @type {Node} */
3104
+ var node;
3105
+ /**
3106
+ * Whether or not the first item is a text/element node. If not, we need to
3107
+ * create an additional comment node to act as `effect.nodes.start`
3108
+ */
3109
+ var has_start = !content.startsWith("<!>");
3110
+ return () => {
3111
+ if (hydrating) {
3112
+ assign_nodes(hydrate_node, null);
3113
+ return hydrate_node;
3114
+ }
3115
+ if (node === void 0) {
3116
+ node = create_fragment_from_html(has_start ? content : "<!>" + content);
3117
+ if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
3118
+ }
3119
+ var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
3120
+ if (is_fragment) {
3121
+ var start = /* @__PURE__ */ get_first_child(clone);
3122
+ var end = clone.lastChild;
3123
+ assign_nodes(start, end);
3124
+ } else assign_nodes(clone, clone);
3125
+ return clone;
3126
+ };
3127
+ }
3128
+ /**
3129
+ * Assign the created (or in hydration mode, traversed) dom elements to the current block
3130
+ * and insert the elements into the dom (in client mode).
3131
+ * @param {Text | Comment | Element} anchor
3132
+ * @param {DocumentFragment | Element} dom
3133
+ */
3134
+ function append(anchor, dom) {
3135
+ if (hydrating) {
3136
+ var effect = active_effect;
3137
+ if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
3138
+ hydrate_next();
3139
+ return;
3140
+ }
3141
+ if (anchor === null) return;
3142
+ anchor.before(dom);
3143
+ }
3144
+ /**
3145
+ * @param {Element} text
3146
+ * @param {string} value
3147
+ * @returns {void}
3148
+ */
3149
+ function set_text(text, value) {
3150
+ var str = value == null ? "" : typeof value === "object" ? `${value}` : value;
3151
+ if (str !== (text.__t ??= text.nodeValue)) {
3152
+ text.__t = str;
3153
+ text.nodeValue = `${str}`;
3154
+ }
3155
+ }
3156
+ /**
3157
+ * Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component.
3158
+ * Transitions will play during the initial render unless the `intro` option is set to `false`.
3159
+ *
3160
+ * @template {Record<string, any>} Props
3161
+ * @template {Record<string, any>} Exports
3162
+ * @param {ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>} component
3163
+ * @param {MountOptions<Props>} options
3164
+ * @returns {Exports}
3165
+ */
3166
+ function mount(component, options) {
3167
+ return _mount(component, options);
3168
+ }
3169
+ /** @type {Map<EventTarget, Map<string, number>>} */
3170
+ var listeners = /* @__PURE__ */ new Map();
3171
+ /**
3172
+ * @template {Record<string, any>} Exports
3173
+ * @param {ComponentType<SvelteComponent<any>> | Component<any>} Component
3174
+ * @param {MountOptions} options
3175
+ * @returns {Exports}
3176
+ */
3177
+ function _mount(Component, { target, anchor, props = {}, events, context, intro = true, transformError }) {
3178
+ init_operations();
3179
+ /** @type {Exports} */
3180
+ var component = void 0;
3181
+ var unmount = component_root(() => {
3182
+ var anchor_node = anchor ?? target.appendChild(create_text());
3183
+ boundary(anchor_node, { pending: () => {} }, (anchor_node) => {
3184
+ push({});
3185
+ var ctx = component_context;
3186
+ if (context) ctx.c = context;
3187
+ if (events)
3188
+ /** @type {any} */ props.$$events = events;
3189
+ if (hydrating) assign_nodes(anchor_node, null);
3190
+ component = Component(anchor_node, props) || {};
3191
+ if (hydrating) {
3192
+ /** @type {Effect & { nodes: EffectNodes }} */ active_effect.nodes.end = hydrate_node;
3193
+ if (hydrate_node === null || hydrate_node.nodeType !== 8 || hydrate_node.data !== "]") {
3194
+ hydration_mismatch();
3195
+ throw HYDRATION_ERROR;
3196
+ }
3197
+ }
3198
+ pop();
3199
+ }, transformError);
3200
+ /** @type {Set<string>} */
3201
+ var registered_events = /* @__PURE__ */ new Set();
3202
+ /** @param {Array<string>} events */
3203
+ var event_handle = (events) => {
3204
+ for (var i = 0; i < events.length; i++) {
3205
+ var event_name = events[i];
3206
+ if (registered_events.has(event_name)) continue;
3207
+ registered_events.add(event_name);
3208
+ var passive = is_passive_event(event_name);
3209
+ for (const node of [target, document]) {
3210
+ var counts = listeners.get(node);
3211
+ if (counts === void 0) {
3212
+ counts = /* @__PURE__ */ new Map();
3213
+ listeners.set(node, counts);
3214
+ }
3215
+ var count = counts.get(event_name);
3216
+ if (count === void 0) {
3217
+ node.addEventListener(event_name, handle_event_propagation, { passive });
3218
+ counts.set(event_name, 1);
3219
+ } else counts.set(event_name, count + 1);
3220
+ }
3221
+ }
3222
+ };
3223
+ event_handle(array_from(all_registered_events));
3224
+ root_event_handles.add(event_handle);
3225
+ return () => {
3226
+ for (var event_name of registered_events) for (const node of [target, document]) {
3227
+ var counts = listeners.get(node);
3228
+ var count = counts.get(event_name);
3229
+ if (--count == 0) {
3230
+ node.removeEventListener(event_name, handle_event_propagation);
3231
+ counts.delete(event_name);
3232
+ if (counts.size === 0) listeners.delete(node);
3233
+ } else counts.set(event_name, count);
3234
+ }
3235
+ root_event_handles.delete(event_handle);
3236
+ if (anchor_node !== anchor) anchor_node.parentNode?.removeChild(anchor_node);
3237
+ };
3238
+ });
3239
+ mounted_components.set(component, unmount);
3240
+ return component;
3241
+ }
3242
+ /**
3243
+ * References of the components that were mounted or hydrated.
3244
+ * Uses a `WeakMap` to avoid memory leaks.
3245
+ */
3246
+ var mounted_components = /* @__PURE__ */ new WeakMap();
3247
+ //#endregion
3248
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3249
+ /** @import { Effect, TemplateNode } from '#client' */
3250
+ /**
3251
+ * @typedef {{ effect: Effect, fragment: DocumentFragment }} Branch
3252
+ */
3253
+ /**
3254
+ * @template Key
3255
+ */
3256
+ var BranchManager = class {
3257
+ /** @type {TemplateNode} */
3258
+ anchor;
3259
+ /** @type {Map<Batch, Key>} */
3260
+ #batches = /* @__PURE__ */ new Map();
3261
+ /**
3262
+ * Map of keys to effects that are currently rendered in the DOM.
3263
+ * These effects are visible and actively part of the document tree.
3264
+ * Example:
3265
+ * ```
3266
+ * {#if condition}
3267
+ * foo
3268
+ * {:else}
3269
+ * bar
3270
+ * {/if}
3271
+ * ```
3272
+ * Can result in the entries `true->Effect` and `false->Effect`
3273
+ * @type {Map<Key, Effect>}
3274
+ */
3275
+ #onscreen = /* @__PURE__ */ new Map();
3276
+ /**
3277
+ * Similar to #onscreen with respect to the keys, but contains branches that are not yet
3278
+ * in the DOM, because their insertion is deferred.
3279
+ * @type {Map<Key, Branch>}
3280
+ */
3281
+ #offscreen = /* @__PURE__ */ new Map();
3282
+ /**
3283
+ * Keys of effects that are currently outroing
3284
+ * @type {Set<Key>}
3285
+ */
3286
+ #outroing = /* @__PURE__ */ new Set();
3287
+ /**
3288
+ * Whether to pause (i.e. outro) on change, or destroy immediately.
3289
+ * This is necessary for `<svelte:element>`
3290
+ */
3291
+ #transition = true;
3292
+ /**
3293
+ * @param {TemplateNode} anchor
3294
+ * @param {boolean} transition
3295
+ */
3296
+ constructor(anchor, transition = true) {
3297
+ this.anchor = anchor;
3298
+ this.#transition = transition;
3299
+ }
3300
+ /**
3301
+ * @param {Batch} batch
3302
+ */
3303
+ #commit = (batch) => {
3304
+ if (!this.#batches.has(batch)) return;
3305
+ var key = this.#batches.get(batch);
3306
+ var onscreen = this.#onscreen.get(key);
3307
+ if (onscreen) {
3308
+ resume_effect(onscreen);
3309
+ this.#outroing.delete(key);
3310
+ } else {
3311
+ var offscreen = this.#offscreen.get(key);
3312
+ if (offscreen) {
3313
+ this.#onscreen.set(key, offscreen.effect);
3314
+ this.#offscreen.delete(key);
3315
+ /** @type {TemplateNode} */ offscreen.fragment.lastChild.remove();
3316
+ this.anchor.before(offscreen.fragment);
3317
+ onscreen = offscreen.effect;
3318
+ }
3319
+ }
3320
+ for (const [b, k] of this.#batches) {
3321
+ this.#batches.delete(b);
3322
+ if (b === batch) break;
3323
+ const offscreen = this.#offscreen.get(k);
3324
+ if (offscreen) {
3325
+ destroy_effect(offscreen.effect);
3326
+ this.#offscreen.delete(k);
3327
+ }
3328
+ }
3329
+ for (const [k, effect] of this.#onscreen) {
3330
+ if (k === key || this.#outroing.has(k)) continue;
3331
+ const on_destroy = () => {
3332
+ if (Array.from(this.#batches.values()).includes(k)) {
3333
+ var fragment = document.createDocumentFragment();
3334
+ move_effect(effect, fragment);
3335
+ fragment.append(create_text());
3336
+ this.#offscreen.set(k, {
3337
+ effect,
3338
+ fragment
3339
+ });
3340
+ } else destroy_effect(effect);
3341
+ this.#outroing.delete(k);
3342
+ this.#onscreen.delete(k);
3343
+ };
3344
+ if (this.#transition || !onscreen) {
3345
+ this.#outroing.add(k);
3346
+ pause_effect(effect, on_destroy, false);
3347
+ } else on_destroy();
3348
+ }
3349
+ };
3350
+ /**
3351
+ * @param {Batch} batch
3352
+ */
3353
+ #discard = (batch) => {
3354
+ this.#batches.delete(batch);
3355
+ const keys = Array.from(this.#batches.values());
3356
+ for (const [k, branch] of this.#offscreen) if (!keys.includes(k)) {
3357
+ destroy_effect(branch.effect);
3358
+ this.#offscreen.delete(k);
3359
+ }
3360
+ };
3361
+ /**
3362
+ *
3363
+ * @param {any} key
3364
+ * @param {null | ((target: TemplateNode) => void)} fn
3365
+ */
3366
+ ensure(key, fn) {
3367
+ var batch = current_batch;
3368
+ var defer = should_defer_append();
3369
+ if (fn && !this.#onscreen.has(key) && !this.#offscreen.has(key)) if (defer) {
3370
+ var fragment = document.createDocumentFragment();
3371
+ var target = create_text();
3372
+ fragment.append(target);
3373
+ this.#offscreen.set(key, {
3374
+ effect: branch(() => fn(target)),
3375
+ fragment
3376
+ });
3377
+ } else this.#onscreen.set(key, branch(() => fn(this.anchor)));
3378
+ this.#batches.set(batch, key);
3379
+ if (defer) {
3380
+ for (const [k, effect] of this.#onscreen) if (k === key) batch.unskip_effect(effect);
3381
+ else batch.skip_effect(effect);
3382
+ for (const [k, branch] of this.#offscreen) if (k === key) batch.unskip_effect(branch.effect);
3383
+ else batch.skip_effect(branch.effect);
3384
+ batch.oncommit(this.#commit);
3385
+ batch.ondiscard(this.#discard);
3386
+ } else {
3387
+ if (hydrating) this.anchor = hydrate_node;
3388
+ this.#commit(batch);
3389
+ }
3390
+ }
3391
+ };
3392
+ //#endregion
3393
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/blocks/if.js
3394
+ /** @import { TemplateNode } from '#client' */
3395
+ /**
3396
+ * @param {TemplateNode} node
3397
+ * @param {(branch: (fn: (anchor: Node) => void, key?: number | false) => void) => void} fn
3398
+ * @param {boolean} [elseif] True if this is an `{:else if ...}` block rather than an `{#if ...}`, as that affects which transitions are considered 'local'
3399
+ * @returns {void}
3400
+ */
3401
+ function if_block(node, fn, elseif = false) {
3402
+ /** @type {TemplateNode | undefined} */
3403
+ var marker;
3404
+ if (hydrating) {
3405
+ marker = hydrate_node;
3406
+ hydrate_next();
3407
+ }
3408
+ var branches = new BranchManager(node);
3409
+ var flags = elseif ? EFFECT_TRANSPARENT : 0;
3410
+ /**
3411
+ * @param {number | false} key
3412
+ * @param {null | ((anchor: Node) => void)} fn
3413
+ */
3414
+ function update_branch(key, fn) {
3415
+ if (hydrating) {
3416
+ var data = read_hydration_instruction(marker);
3417
+ if (key !== parseInt(data.substring(1))) {
3418
+ var anchor = skip_nodes();
3419
+ set_hydrate_node(anchor);
3420
+ branches.anchor = anchor;
3421
+ set_hydrating(false);
3422
+ branches.ensure(key, fn);
3423
+ set_hydrating(true);
3424
+ return;
3425
+ }
3426
+ }
3427
+ branches.ensure(key, fn);
3428
+ }
3429
+ block(() => {
3430
+ var has_branch = false;
3431
+ fn((fn, key = 0) => {
3432
+ has_branch = true;
3433
+ update_branch(key, fn);
3434
+ });
3435
+ if (!has_branch) update_branch(-1, null);
3436
+ }, flags);
3437
+ }
3438
+ //#endregion
3439
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/blocks/svelte-head.js
3440
+ /** @import { TemplateNode } from '#client' */
3441
+ /**
3442
+ * @param {string} hash
3443
+ * @param {(anchor: Node) => void} render_fn
3444
+ * @returns {void}
3445
+ */
3446
+ function head(hash, render_fn) {
3447
+ let previous_hydrate_node = null;
3448
+ let was_hydrating = hydrating;
3449
+ /** @type {Comment | Text} */
3450
+ var anchor;
3451
+ if (hydrating) {
3452
+ previous_hydrate_node = hydrate_node;
3453
+ var head_anchor = /* @__PURE__ */ get_first_child(document.head);
3454
+ while (head_anchor !== null && (head_anchor.nodeType !== 8 || head_anchor.data !== hash)) head_anchor = /* @__PURE__ */ get_next_sibling(head_anchor);
3455
+ if (head_anchor === null) set_hydrating(false);
3456
+ else {
3457
+ var start = /* @__PURE__ */ get_next_sibling(head_anchor);
3458
+ head_anchor.remove();
3459
+ set_hydrate_node(start);
3460
+ }
3461
+ }
3462
+ if (!hydrating) anchor = document.head.appendChild(create_text());
3463
+ try {
3464
+ block(() => render_fn(anchor), HEAD_EFFECT | EFFECT_PRESERVED);
3465
+ } finally {
3466
+ if (was_hydrating) {
3467
+ set_hydrating(true);
3468
+ set_hydrate_node(previous_hydrate_node);
3469
+ }
3470
+ }
3471
+ }
3472
+ //#endregion
3473
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/elements/attributes.js
3474
+ /** @import { Blocker, Effect } from '#client' */
3475
+ var IS_CUSTOM_ELEMENT = Symbol("is custom element");
3476
+ var IS_HTML = Symbol("is html");
3477
+ var LINK_TAG = IS_XHTML ? "link" : "LINK";
3478
+ var PROGRESS_TAG = IS_XHTML ? "progress" : "PROGRESS";
3479
+ /**
3480
+ * The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
3481
+ * to remove it upon hydration to avoid a bug when someone resets the form value.
3482
+ * @param {HTMLInputElement} input
3483
+ * @returns {void}
3484
+ */
3485
+ function remove_input_defaults(input) {
3486
+ if (!hydrating) return;
3487
+ var already_removed = false;
3488
+ var remove_defaults = () => {
3489
+ if (already_removed) return;
3490
+ already_removed = true;
3491
+ if (input.hasAttribute("value")) {
3492
+ var value = input.value;
3493
+ set_attribute(input, "value", null);
3494
+ input.value = value;
3495
+ }
3496
+ if (input.hasAttribute("checked")) {
3497
+ var checked = input.checked;
3498
+ set_attribute(input, "checked", null);
3499
+ input.checked = checked;
3500
+ }
3501
+ };
3502
+ input.__on_r = remove_defaults;
3503
+ queue_micro_task(remove_defaults);
3504
+ add_form_reset_listener();
3505
+ }
3506
+ /**
3507
+ * @param {Element} element
3508
+ * @param {any} value
3509
+ */
3510
+ function set_value(element, value) {
3511
+ var attributes = get_attributes(element);
3512
+ if (attributes.value === (attributes.value = value ?? void 0) || element.value === value && (value !== 0 || element.nodeName !== PROGRESS_TAG)) return;
3513
+ element.value = value ?? "";
3514
+ }
3515
+ /**
3516
+ * @param {Element} element
3517
+ * @param {string} attribute
3518
+ * @param {string | null} value
3519
+ * @param {boolean} [skip_warning]
3520
+ */
3521
+ function set_attribute(element, attribute, value, skip_warning) {
3522
+ var attributes = get_attributes(element);
3523
+ if (hydrating) {
3524
+ attributes[attribute] = element.getAttribute(attribute);
3525
+ if (attribute === "src" || attribute === "srcset" || attribute === "href" && element.nodeName === LINK_TAG) {
3526
+ if (!skip_warning) check_src_in_dev_hydration(element, attribute, value ?? "");
3527
+ return;
3528
+ }
3529
+ }
3530
+ if (attributes[attribute] === (attributes[attribute] = value)) return;
3531
+ if (attribute === "loading") element[LOADING_ATTR_SYMBOL] = value;
3532
+ if (value == null) element.removeAttribute(attribute);
3533
+ else if (typeof value !== "string" && get_setters(element).includes(attribute)) element[attribute] = value;
3534
+ else element.setAttribute(attribute, value);
3535
+ }
3536
+ /**
3537
+ *
3538
+ * @param {Element} element
3539
+ */
3540
+ function get_attributes(element) {
3541
+ return element.__attributes ??= {
3542
+ [IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"),
3543
+ [IS_HTML]: element.namespaceURI === NAMESPACE_HTML
3544
+ };
3545
+ }
3546
+ /** @type {Map<string, string[]>} */
3547
+ var setters_cache = /* @__PURE__ */ new Map();
3548
+ /** @param {Element} element */
3549
+ function get_setters(element) {
3550
+ var cache_key = element.getAttribute("is") || element.nodeName;
3551
+ var setters = setters_cache.get(cache_key);
3552
+ if (setters) return setters;
3553
+ setters_cache.set(cache_key, setters = []);
3554
+ var descriptors;
3555
+ var proto = element;
3556
+ var element_proto = Element.prototype;
3557
+ while (element_proto !== proto) {
3558
+ descriptors = get_descriptors(proto);
3559
+ for (var key in descriptors) if (descriptors[key].set) setters.push(key);
3560
+ proto = get_prototype_of(proto);
3561
+ }
3562
+ return setters;
3563
+ }
3564
+ /**
3565
+ * @param {any} element
3566
+ * @param {string} attribute
3567
+ * @param {string} value
3568
+ */
3569
+ function check_src_in_dev_hydration(element, attribute, value) {}
3570
+ //#endregion
3571
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/client/dom/elements/bindings/input.js
3572
+ /** @import { Batch } from '../../../reactivity/batch.js' */
3573
+ /**
3574
+ * @param {HTMLInputElement} input
3575
+ * @param {() => unknown} get
3576
+ * @param {(value: unknown) => void} set
3577
+ * @returns {void}
3578
+ */
3579
+ function bind_value(input, get, set = get) {
3580
+ var batches = /* @__PURE__ */ new WeakSet();
3581
+ listen_to_event_and_reset_event(input, "input", async (is_reset) => {
3582
+ /** @type {any} */
3583
+ var value = is_reset ? input.defaultValue : input.value;
3584
+ value = is_numberlike_input(input) ? to_number(value) : value;
3585
+ set(value);
3586
+ if (current_batch !== null) batches.add(current_batch);
3587
+ await tick();
3588
+ if (value !== (value = get())) {
3589
+ var start = input.selectionStart;
3590
+ var end = input.selectionEnd;
3591
+ var length = input.value.length;
3592
+ input.value = value ?? "";
3593
+ if (end !== null) {
3594
+ var new_length = input.value.length;
3595
+ if (start === end && end === length && new_length > length) {
3596
+ input.selectionStart = new_length;
3597
+ input.selectionEnd = new_length;
3598
+ } else {
3599
+ input.selectionStart = start;
3600
+ input.selectionEnd = Math.min(end, new_length);
3601
+ }
3602
+ }
3603
+ }
3604
+ });
3605
+ if (hydrating && input.defaultValue !== input.value || untrack(get) == null && input.value) {
3606
+ set(is_numberlike_input(input) ? to_number(input.value) : input.value);
3607
+ if (current_batch !== null) batches.add(current_batch);
3608
+ }
3609
+ render_effect(() => {
3610
+ var value = get();
3611
+ if (input === document.activeElement) {
3612
+ var batch = async_mode_flag ? previous_batch : current_batch;
3613
+ if (batches.has(batch)) return;
3614
+ }
3615
+ if (is_numberlike_input(input) && value === to_number(input.value)) return;
3616
+ if (input.type === "date" && !value && !input.value) return;
3617
+ if (value !== input.value) input.value = value ?? "";
3618
+ });
3619
+ }
3620
+ /**
3621
+ * @param {HTMLInputElement} input
3622
+ */
3623
+ function is_numberlike_input(input) {
3624
+ var type = input.type;
3625
+ return type === "number" || type === "range";
3626
+ }
3627
+ /**
3628
+ * @param {string} value
3629
+ */
3630
+ function to_number(value) {
3631
+ return value === "" ? null : +value;
3632
+ }
3633
+ if (typeof HTMLElement === "function");
3634
+ //#endregion
3635
+ //#region ../../node_modules/.bun/svelte@5.55.2/node_modules/svelte/src/internal/disclose-version.js
3636
+ if (typeof window !== "undefined") ((window.__svelte ??= {}).v ??= /* @__PURE__ */ new Set()).add("5");
3637
+ //#endregion
3638
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js
3639
+ /**
3640
+ * Convert the given array buffer into a Base64URL-encoded string. Ideal for converting various
3641
+ * credential response ArrayBuffers to string for sending back to the server as JSON.
3642
+ *
3643
+ * Helper method to compliment `base64URLStringToBuffer`
3644
+ */
3645
+ function bufferToBase64URLString(buffer) {
3646
+ const bytes = new Uint8Array(buffer);
3647
+ let str = "";
3648
+ for (const charCode of bytes) str += String.fromCharCode(charCode);
3649
+ return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
3650
+ }
3651
+ //#endregion
3652
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/base64URLStringToBuffer.js
3653
+ /**
3654
+ * Convert from a Base64URL-encoded string to an Array Buffer. Best used when converting a
3655
+ * credential ID from a JSON string to an ArrayBuffer, like in allowCredentials or
3656
+ * excludeCredentials
3657
+ *
3658
+ * Helper method to compliment `bufferToBase64URLString`
3659
+ */
3660
+ function base64URLStringToBuffer(base64URLString) {
3661
+ const base64 = base64URLString.replace(/-/g, "+").replace(/_/g, "/");
3662
+ /**
3663
+ * Pad with '=' until it's a multiple of four
3664
+ * (4 - (85 % 4 = 1) = 3) % 4 = 3 padding
3665
+ * (4 - (86 % 4 = 2) = 2) % 4 = 2 padding
3666
+ * (4 - (87 % 4 = 3) = 1) % 4 = 1 padding
3667
+ * (4 - (88 % 4 = 0) = 4) % 4 = 0 padding
3668
+ */
3669
+ const padLength = (4 - base64.length % 4) % 4;
3670
+ const padded = base64.padEnd(base64.length + padLength, "=");
3671
+ const binary = atob(padded);
3672
+ const buffer = new ArrayBuffer(binary.length);
3673
+ const bytes = new Uint8Array(buffer);
3674
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
3675
+ return buffer;
3676
+ }
3677
+ //#endregion
3678
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js
3679
+ /**
3680
+ * Determine if the browser is capable of Webauthn
3681
+ */
3682
+ function browserSupportsWebAuthn() {
3683
+ return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== void 0 && typeof globalThis.PublicKeyCredential === "function");
3684
+ }
3685
+ /**
3686
+ * Make it possible to stub the return value during testing
3687
+ * @ignore Don't include this in docs output
3688
+ */
3689
+ var _browserSupportsWebAuthnInternals = { stubThis: (value) => value };
3690
+ //#endregion
3691
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/toPublicKeyCredentialDescriptor.js
3692
+ function toPublicKeyCredentialDescriptor(descriptor) {
3693
+ const { id } = descriptor;
3694
+ return {
3695
+ ...descriptor,
3696
+ id: base64URLStringToBuffer(id),
3697
+ transports: descriptor.transports
3698
+ };
3699
+ }
3700
+ //#endregion
3701
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/isValidDomain.js
3702
+ /**
3703
+ * A simple test to determine if a hostname is a properly-formatted domain name
3704
+ *
3705
+ * A "valid domain" is defined here: https://url.spec.whatwg.org/#valid-domain
3706
+ *
3707
+ * Regex was originally sourced from here, then remixed to add punycode support:
3708
+ * https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html
3709
+ */
3710
+ function isValidDomain(hostname) {
3711
+ return hostname === "localhost" || /^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(hostname);
3712
+ }
3713
+ //#endregion
3714
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnError.js
3715
+ /**
3716
+ * A custom Error used to return a more nuanced error detailing _why_ one of the eight documented
3717
+ * errors in the spec was raised after calling `navigator.credentials.create()` or
3718
+ * `navigator.credentials.get()`:
3719
+ *
3720
+ * - `AbortError`
3721
+ * - `ConstraintError`
3722
+ * - `InvalidStateError`
3723
+ * - `NotAllowedError`
3724
+ * - `NotSupportedError`
3725
+ * - `SecurityError`
3726
+ * - `TypeError`
3727
+ * - `UnknownError`
3728
+ *
3729
+ * Error messages were determined through investigation of the spec to determine under which
3730
+ * scenarios a given error would be raised.
3731
+ */
3732
+ var WebAuthnError = class extends Error {
3733
+ constructor({ message, code, cause, name }) {
3734
+ super(message, { cause });
3735
+ Object.defineProperty(this, "code", {
3736
+ enumerable: true,
3737
+ configurable: true,
3738
+ writable: true,
3739
+ value: void 0
3740
+ });
3741
+ this.name = name ?? cause.name;
3742
+ this.code = code;
3743
+ }
3744
+ };
3745
+ //#endregion
3746
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnAbortService.js
3747
+ var BaseWebAuthnAbortService = class {
3748
+ constructor() {
3749
+ Object.defineProperty(this, "controller", {
3750
+ enumerable: true,
3751
+ configurable: true,
3752
+ writable: true,
3753
+ value: void 0
3754
+ });
3755
+ }
3756
+ createNewAbortSignal() {
3757
+ if (this.controller) {
3758
+ const abortError = /* @__PURE__ */ new Error("Cancelling existing WebAuthn API call for new one");
3759
+ abortError.name = "AbortError";
3760
+ this.controller.abort(abortError);
3761
+ }
3762
+ const newController = new AbortController();
3763
+ this.controller = newController;
3764
+ return newController.signal;
3765
+ }
3766
+ cancelCeremony() {
3767
+ if (this.controller) {
3768
+ const abortError = /* @__PURE__ */ new Error("Manually cancelling existing WebAuthn API call");
3769
+ abortError.name = "AbortError";
3770
+ this.controller.abort(abortError);
3771
+ this.controller = void 0;
3772
+ }
3773
+ }
3774
+ };
3775
+ /**
3776
+ * A service singleton to help ensure that only a single WebAuthn ceremony is active at a time.
3777
+ *
3778
+ * Users of **@simplewebauthn/browser** shouldn't typically need to use this, but it can help e.g.
3779
+ * developers building projects that use client-side routing to better control the behavior of
3780
+ * their UX in response to router navigation events.
3781
+ */
3782
+ var WebAuthnAbortService = new BaseWebAuthnAbortService();
3783
+ //#endregion
3784
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/toAuthenticatorAttachment.js
3785
+ var attachments = ["cross-platform", "platform"];
3786
+ /**
3787
+ * If possible coerce a `string` value into a known `AuthenticatorAttachment`
3788
+ */
3789
+ function toAuthenticatorAttachment(attachment) {
3790
+ if (!attachment) return;
3791
+ if (attachments.indexOf(attachment) < 0) return;
3792
+ return attachment;
3793
+ }
3794
+ //#endregion
3795
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthnAutofill.js
3796
+ /**
3797
+ * Determine if the browser supports conditional UI, so that WebAuthn credentials can
3798
+ * be shown to the user in the browser's typical password autofill popup.
3799
+ */
3800
+ function browserSupportsWebAuthnAutofill() {
3801
+ if (!browserSupportsWebAuthn()) return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
3802
+ /**
3803
+ * I don't like the `as unknown` here but there's a `declare var PublicKeyCredential` in
3804
+ * TS' DOM lib that's making it difficult for me to just go `as PublicKeyCredentialFuture` as I
3805
+ * want. I think I'm fine with this for now since it's _supposed_ to be temporary, until TS types
3806
+ * have a chance to catch up.
3807
+ */
3808
+ const globalPublicKeyCredential = globalThis.PublicKeyCredential;
3809
+ if (globalPublicKeyCredential?.isConditionalMediationAvailable === void 0) return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
3810
+ return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());
3811
+ }
3812
+ var _browserSupportsWebAuthnAutofillInternals = { stubThis: (value) => value };
3813
+ //#endregion
3814
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyAuthenticationError.js
3815
+ /**
3816
+ * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.get()`
3817
+ */
3818
+ function identifyAuthenticationError({ error, options }) {
3819
+ const { publicKey } = options;
3820
+ if (!publicKey) throw Error("options was missing required publicKey property");
3821
+ if (error.name === "AbortError") {
3822
+ if (options.signal instanceof AbortSignal) return new WebAuthnError({
3823
+ message: "Authentication ceremony was sent an abort signal",
3824
+ code: "ERROR_CEREMONY_ABORTED",
3825
+ cause: error
3826
+ });
3827
+ } else if (error.name === "NotAllowedError")
3828
+ /**
3829
+ * Pass the error directly through. Platforms are overloading this error beyond what the spec
3830
+ * defines and we don't want to overwrite potentially useful error messages.
3831
+ */
3832
+ return new WebAuthnError({
3833
+ message: error.message,
3834
+ code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
3835
+ cause: error
3836
+ });
3837
+ else if (error.name === "SecurityError") {
3838
+ const effectiveDomain = globalThis.location.hostname;
3839
+ if (!isValidDomain(effectiveDomain)) return new WebAuthnError({
3840
+ message: `${globalThis.location.hostname} is an invalid domain`,
3841
+ code: "ERROR_INVALID_DOMAIN",
3842
+ cause: error
3843
+ });
3844
+ else if (publicKey.rpId !== effectiveDomain) return new WebAuthnError({
3845
+ message: `The RP ID "${publicKey.rpId}" is invalid for this domain`,
3846
+ code: "ERROR_INVALID_RP_ID",
3847
+ cause: error
3848
+ });
3849
+ } else if (error.name === "UnknownError") return new WebAuthnError({
3850
+ message: "The authenticator was unable to process the specified options, or could not create a new assertion signature",
3851
+ code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
3852
+ cause: error
3853
+ });
3854
+ return error;
3855
+ }
3856
+ //#endregion
3857
+ //#region ../../node_modules/.bun/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/methods/startAuthentication.js
3858
+ /**
3859
+ * Begin authenticator "login" via WebAuthn assertion
3860
+ *
3861
+ * @param optionsJSON Output from **@simplewebauthn/server**'s `generateAuthenticationOptions()`
3862
+ * @param useBrowserAutofill (Optional) Initialize conditional UI to enable logging in via browser autofill prompts. Defaults to `false`.
3863
+ * @param verifyBrowserAutofillInput (Optional) Ensure a suitable `<input>` element is present when `useBrowserAutofill` is `true`. Defaults to `true`.
3864
+ */
3865
+ async function startAuthentication(options) {
3866
+ if (!options.optionsJSON && options.challenge) {
3867
+ console.warn("startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.");
3868
+ options = { optionsJSON: options };
3869
+ }
3870
+ const { optionsJSON, useBrowserAutofill = false, verifyBrowserAutofillInput = true } = options;
3871
+ if (!browserSupportsWebAuthn()) throw new Error("WebAuthn is not supported in this browser");
3872
+ let allowCredentials;
3873
+ if (optionsJSON.allowCredentials?.length !== 0) allowCredentials = optionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);
3874
+ const publicKey = {
3875
+ ...optionsJSON,
3876
+ challenge: base64URLStringToBuffer(optionsJSON.challenge),
3877
+ allowCredentials
3878
+ };
3879
+ const getOptions = {};
3880
+ /**
3881
+ * Set up the page to prompt the user to select a credential for authentication via the browser's
3882
+ * input autofill mechanism.
3883
+ */
3884
+ if (useBrowserAutofill) {
3885
+ if (!await browserSupportsWebAuthnAutofill()) throw Error("Browser does not support WebAuthn autofill");
3886
+ if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1 && verifyBrowserAutofillInput) throw Error("No <input> with \"webauthn\" as the only or last value in its `autocomplete` attribute was detected");
3887
+ getOptions.mediation = "conditional";
3888
+ publicKey.allowCredentials = [];
3889
+ }
3890
+ getOptions.publicKey = publicKey;
3891
+ getOptions.signal = WebAuthnAbortService.createNewAbortSignal();
3892
+ let credential;
3893
+ try {
3894
+ credential = await navigator.credentials.get(getOptions);
3895
+ } catch (err) {
3896
+ throw identifyAuthenticationError({
3897
+ error: err,
3898
+ options: getOptions
3899
+ });
3900
+ }
3901
+ if (!credential) throw new Error("Authentication was not completed");
3902
+ const { id, rawId, response, type } = credential;
3903
+ let userHandle = void 0;
3904
+ if (response.userHandle) userHandle = bufferToBase64URLString(response.userHandle);
3905
+ return {
3906
+ id,
3907
+ rawId: bufferToBase64URLString(rawId),
3908
+ response: {
3909
+ authenticatorData: bufferToBase64URLString(response.authenticatorData),
3910
+ clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
3911
+ signature: bufferToBase64URLString(response.signature),
3912
+ userHandle
3913
+ },
3914
+ type,
3915
+ clientExtensionResults: credential.getClientExtensionResults(),
3916
+ authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment)
3917
+ };
3918
+ }
3919
+ //#endregion
3920
+ //#region src/webauthn-ui-src/shared.ts
3921
+ var AUTH_MESSAGE_SOURCE = "agenter-auth-service";
3922
+ var resolveOpenerOrigin = () => {
3923
+ const openerOrigin = new URLSearchParams(window.location.search).get("openerOrigin")?.trim();
3924
+ if (openerOrigin) return openerOrigin;
3925
+ if (document.referrer) try {
3926
+ return new URL(document.referrer).origin;
3927
+ } catch {
3928
+ return null;
3929
+ }
3930
+ return null;
3931
+ };
3932
+ var publishAuthSuccess = (payload) => {
3933
+ const openerOrigin = resolveOpenerOrigin();
3934
+ if (window.opener && openerOrigin) window.opener.postMessage({
3935
+ source: AUTH_MESSAGE_SOURCE,
3936
+ kind: "auth-success",
3937
+ token: payload.token,
3938
+ profileId: payload.profile.profileId
3939
+ }, openerOrigin);
3940
+ };
3941
+ var readSearchParam = (key) => {
3942
+ const value = new URLSearchParams(window.location.search).get(key)?.trim();
3943
+ return value && value.length > 0 ? value : "";
3944
+ };
3945
+ var jsonFetch = async (input, init) => {
3946
+ const response = await fetch(input, init);
3947
+ if (!response.ok) throw new Error(await response.text());
3948
+ return await response.json();
3949
+ };
3950
+ //#endregion
3951
+ //#region src/webauthn-ui-src/authenticate-page.svelte
3952
+ var root_2 = /* @__PURE__ */ from_html(`<p class="error svelte-wq363v"> </p>`);
3953
+ var root_3 = /* @__PURE__ */ from_html(`<p class="svelte-wq363v"><strong>Profile:</strong> </p> <textarea readonly="" rows="6" class="svelte-wq363v"></textarea>`, 1);
3954
+ var root = /* @__PURE__ */ from_html(`<main class="shell svelte-wq363v"><section class="card svelte-wq363v"><header class="header svelte-wq363v"><p class="eyebrow svelte-wq363v">Profile Service</p> <h1 class="svelte-wq363v">Authenticate with passkey</h1> <p class="copy svelte-wq363v">Sign into a durable profile by presenting a previously registered WebAuthn credential.</p></header> <label class="field svelte-wq363v"><span>Profile reference</span> <input placeholder="profile id or bound identifier" spellcheck="false" class="svelte-wq363v"/></label> <button class="primary svelte-wq363v"> </button> <div class="status svelte-wq363v"><p class="svelte-wq363v"><strong>Status:</strong> </p> <!> <!></div></section></main>`);
3955
+ function Authenticate_page($$anchor, $$props) {
3956
+ push($$props, true);
3957
+ let reference = /* @__PURE__ */ state(proxy(readSearchParam("reference")));
3958
+ let status = /* @__PURE__ */ state("Ready");
3959
+ let error = /* @__PURE__ */ state("");
3960
+ let token = /* @__PURE__ */ state("");
3961
+ let profileId = /* @__PURE__ */ state("");
3962
+ let busy = /* @__PURE__ */ state(false);
3963
+ const runAuthentication = async () => {
3964
+ if (!get(reference)) {
3965
+ set(error, "Reference is required");
3966
+ return;
3967
+ }
3968
+ set(busy, true);
3969
+ set(error, "");
3970
+ set(status, "Requesting authentication options…");
3971
+ try {
3972
+ const optionsPayload = await jsonFetch("/auth/webauthn/authenticate/options", {
3973
+ method: "POST",
3974
+ headers: { "content-type": "application/json" },
3975
+ body: JSON.stringify({ reference: get(reference) })
3976
+ });
3977
+ set(status, "Waiting for passkey…");
3978
+ const response = await startAuthentication({ optionsJSON: optionsPayload.options });
3979
+ set(status, "Verifying passkey…");
3980
+ const verified = await jsonFetch("/auth/webauthn/authenticate/verify", {
3981
+ method: "POST",
3982
+ headers: { "content-type": "application/json" },
3983
+ body: JSON.stringify({
3984
+ ticketId: optionsPayload.ticketId,
3985
+ response
3986
+ })
3987
+ });
3988
+ set(token, verified.token, true);
3989
+ set(profileId, verified.profile.profileId ?? "", true);
3990
+ publishAuthSuccess(verified);
3991
+ set(status, "Authentication completed");
3992
+ } catch (caught) {
3993
+ set(error, caught instanceof Error ? caught.message : String(caught), true);
3994
+ set(status, "Authentication failed");
3995
+ } finally {
3996
+ set(busy, false);
3997
+ }
3998
+ };
3999
+ var main = root();
4000
+ head("wq363v", ($$anchor) => {
4001
+ effect(() => {
4002
+ $document.title = "Authenticate passkey";
4003
+ });
4004
+ });
4005
+ var section = child(main);
4006
+ var label = sibling(child(section), 2);
4007
+ var input = sibling(child(label), 2);
4008
+ remove_input_defaults(input);
4009
+ reset(label);
4010
+ var button = sibling(label, 2);
4011
+ var text = child(button, true);
4012
+ reset(button);
4013
+ var div = sibling(button, 2);
4014
+ var p = child(div);
4015
+ var text_1 = sibling(child(p));
4016
+ reset(p);
4017
+ var node = sibling(p, 2);
4018
+ var consequent = ($$anchor) => {
4019
+ var p_1 = root_2();
4020
+ var text_2 = child(p_1, true);
4021
+ reset(p_1);
4022
+ template_effect(() => set_text(text_2, get(error)));
4023
+ append($$anchor, p_1);
4024
+ };
4025
+ if_block(node, ($$render) => {
4026
+ if (get(error)) $$render(consequent);
4027
+ });
4028
+ var node_1 = sibling(node, 2);
4029
+ var consequent_1 = ($$anchor) => {
4030
+ var fragment = root_3();
4031
+ var p_2 = first_child(fragment);
4032
+ var text_3 = sibling(child(p_2));
4033
+ reset(p_2);
4034
+ var textarea = sibling(p_2, 2);
4035
+ remove_textarea_child(textarea);
4036
+ template_effect(() => {
4037
+ set_text(text_3, ` ${(get(profileId) || "unknown") ?? ""}`);
4038
+ set_value(textarea, get(token));
4039
+ });
4040
+ append($$anchor, fragment);
4041
+ };
4042
+ if_block(node_1, ($$render) => {
4043
+ if (get(token)) $$render(consequent_1);
4044
+ });
4045
+ reset(div);
4046
+ reset(section);
4047
+ reset(main);
4048
+ template_effect(() => {
4049
+ button.disabled = get(busy);
4050
+ set_text(text, get(busy) ? "Working…" : "Authenticate");
4051
+ set_text(text_1, ` ${get(status) ?? ""}`);
4052
+ });
4053
+ bind_value(input, () => get(reference), ($$value) => set(reference, $$value));
4054
+ delegated("click", button, runAuthentication);
4055
+ append($$anchor, main);
4056
+ pop();
4057
+ }
4058
+ delegate(["click"]);
4059
+ //#endregion
4060
+ //#region src/webauthn-ui-src/entry-authenticate.ts
4061
+ mount(Authenticate_page, { target: document.getElementById("app") });
4062
+ //#endregion