@sentropic/h2a 0.85.16 → 0.85.18

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 (193) hide show
  1. package/.claude-plugin/plugin.json +29 -0
  2. package/.codex-plugin/plugin.json +35 -0
  3. package/.mcp.json +19 -0
  4. package/README.md +3 -0
  5. package/dist/bin-routing.d.ts +14 -3
  6. package/dist/bin-routing.d.ts.map +1 -1
  7. package/dist/bin-routing.js +31 -6
  8. package/dist/bin-routing.js.map +1 -1
  9. package/dist/bin.js +45 -14
  10. package/dist/bin.js.map +1 -1
  11. package/dist/cli-contract.d.ts.map +1 -1
  12. package/dist/cli-contract.js +41 -1
  13. package/dist/cli-contract.js.map +1 -1
  14. package/dist/cli.d.ts +4 -0
  15. package/dist/cli.d.ts.map +1 -1
  16. package/dist/cli.js +146 -18
  17. package/dist/cli.js.map +1 -1
  18. package/dist/index.d.ts +4 -3
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +3 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/mcp.d.ts +1 -1
  23. package/dist/mcp.d.ts.map +1 -1
  24. package/dist/mcp.js +1 -0
  25. package/dist/mcp.js.map +1 -1
  26. package/dist/runtime/focus/serve.d.ts +42 -0
  27. package/dist/runtime/focus/serve.d.ts.map +1 -0
  28. package/dist/runtime/focus/serve.js +366 -0
  29. package/dist/runtime/focus/serve.js.map +1 -0
  30. package/dist/runtime/loop/engine/adapters.d.ts +62 -6
  31. package/dist/runtime/loop/engine/adapters.d.ts.map +1 -1
  32. package/dist/runtime/loop/engine/adapters.js +272 -36
  33. package/dist/runtime/loop/engine/adapters.js.map +1 -1
  34. package/dist/runtime/loop/engine/decision.d.ts.map +1 -1
  35. package/dist/runtime/loop/engine/decision.js +20 -2
  36. package/dist/runtime/loop/engine/decision.js.map +1 -1
  37. package/dist/runtime/loop/engine/execute.d.ts +13 -4
  38. package/dist/runtime/loop/engine/execute.d.ts.map +1 -1
  39. package/dist/runtime/loop/engine/execute.js +17 -7
  40. package/dist/runtime/loop/engine/execute.js.map +1 -1
  41. package/dist/runtime/loop/index.d.ts +16 -0
  42. package/dist/runtime/loop/index.d.ts.map +1 -1
  43. package/dist/runtime/loop/index.js +146 -13
  44. package/dist/runtime/loop/index.js.map +1 -1
  45. package/dist/runtime/mcp/agent-launch.d.ts +33 -0
  46. package/dist/runtime/mcp/agent-launch.d.ts.map +1 -0
  47. package/dist/runtime/mcp/agent-launch.js +250 -0
  48. package/dist/runtime/mcp/agent-launch.js.map +1 -0
  49. package/dist/runtime/mcp/handlers.d.ts +8 -0
  50. package/dist/runtime/mcp/handlers.d.ts.map +1 -1
  51. package/dist/runtime/mcp/handlers.js +34 -4
  52. package/dist/runtime/mcp/handlers.js.map +1 -1
  53. package/dist/runtime/mcp/index.d.ts +2 -1
  54. package/dist/runtime/mcp/index.d.ts.map +1 -1
  55. package/dist/runtime/mcp/index.js +2 -1
  56. package/dist/runtime/mcp/index.js.map +1 -1
  57. package/dist/runtime/mcp/server.d.ts +5 -0
  58. package/dist/runtime/mcp/server.d.ts.map +1 -1
  59. package/dist/runtime/mcp/server.js +3 -0
  60. package/dist/runtime/mcp/server.js.map +1 -1
  61. package/dist/runtime/mcp/stdio.d.ts +17 -0
  62. package/dist/runtime/mcp/stdio.d.ts.map +1 -1
  63. package/dist/runtime/mcp/stdio.js +65 -13
  64. package/dist/runtime/mcp/stdio.js.map +1 -1
  65. package/dist/runtime/mcp/tools.d.ts.map +1 -1
  66. package/dist/runtime/mcp/tools.js +96 -5
  67. package/dist/runtime/mcp/tools.js.map +1 -1
  68. package/dist/runtime/path-safety.d.ts +3 -0
  69. package/dist/runtime/path-safety.d.ts.map +1 -0
  70. package/dist/runtime/path-safety.js +12 -0
  71. package/dist/runtime/path-safety.js.map +1 -0
  72. package/dist/runtime/reporting/config.d.ts +21 -0
  73. package/dist/runtime/reporting/config.d.ts.map +1 -0
  74. package/dist/runtime/reporting/config.js +76 -0
  75. package/dist/runtime/reporting/config.js.map +1 -0
  76. package/dist/runtime/reporting/context.d.ts +27 -0
  77. package/dist/runtime/reporting/context.d.ts.map +1 -0
  78. package/dist/runtime/reporting/context.js +265 -0
  79. package/dist/runtime/reporting/context.js.map +1 -0
  80. package/dist/runtime/reporting/index.d.ts +4 -0
  81. package/dist/runtime/reporting/index.d.ts.map +1 -0
  82. package/dist/runtime/reporting/index.js +4 -0
  83. package/dist/runtime/reporting/index.js.map +1 -0
  84. package/dist/runtime/reporting/report-ai.d.ts +49 -0
  85. package/dist/runtime/reporting/report-ai.d.ts.map +1 -0
  86. package/dist/runtime/reporting/report-ai.js +325 -0
  87. package/dist/runtime/reporting/report-ai.js.map +1 -0
  88. package/focus-app/client/_app/immutable/assets/0.BdzHFb9q.css +1 -0
  89. package/focus-app/client/_app/immutable/assets/0.BdzHFb9q.css.br +2 -0
  90. package/focus-app/client/_app/immutable/assets/0.BdzHFb9q.css.gz +0 -0
  91. package/focus-app/client/_app/immutable/assets/2.Ddxq02y4.css +1 -0
  92. package/focus-app/client/_app/immutable/assets/2.Ddxq02y4.css.br +0 -0
  93. package/focus-app/client/_app/immutable/assets/2.Ddxq02y4.css.gz +0 -0
  94. package/focus-app/client/_app/immutable/chunks/Bs3f1UbD.js +2 -0
  95. package/focus-app/client/_app/immutable/chunks/Bs3f1UbD.js.br +0 -0
  96. package/focus-app/client/_app/immutable/chunks/Bs3f1UbD.js.gz +0 -0
  97. package/focus-app/client/_app/immutable/chunks/Bv8OL8ib.js +1 -0
  98. package/focus-app/client/_app/immutable/chunks/Bv8OL8ib.js.br +0 -0
  99. package/focus-app/client/_app/immutable/chunks/Bv8OL8ib.js.gz +0 -0
  100. package/focus-app/client/_app/immutable/chunks/CVq_IFFr.js +2 -0
  101. package/focus-app/client/_app/immutable/chunks/CVq_IFFr.js.br +0 -0
  102. package/focus-app/client/_app/immutable/chunks/CVq_IFFr.js.gz +0 -0
  103. package/focus-app/client/_app/immutable/chunks/Cj6wo28J.js +1 -0
  104. package/focus-app/client/_app/immutable/chunks/Cj6wo28J.js.br +0 -0
  105. package/focus-app/client/_app/immutable/chunks/Cj6wo28J.js.gz +0 -0
  106. package/focus-app/client/_app/immutable/chunks/DEmooz0s.js +1 -0
  107. package/focus-app/client/_app/immutable/chunks/DEmooz0s.js.br +0 -0
  108. package/focus-app/client/_app/immutable/chunks/DEmooz0s.js.gz +0 -0
  109. package/focus-app/client/_app/immutable/chunks/DQIRXgdC.js +2 -0
  110. package/focus-app/client/_app/immutable/chunks/DQIRXgdC.js.br +0 -0
  111. package/focus-app/client/_app/immutable/chunks/DQIRXgdC.js.gz +0 -0
  112. package/focus-app/client/_app/immutable/chunks/ZxFklh9T.js +1 -0
  113. package/focus-app/client/_app/immutable/chunks/ZxFklh9T.js.br +0 -0
  114. package/focus-app/client/_app/immutable/chunks/ZxFklh9T.js.gz +0 -0
  115. package/focus-app/client/_app/immutable/chunks/_wRuVGPs.js +1 -0
  116. package/focus-app/client/_app/immutable/chunks/_wRuVGPs.js.br +0 -0
  117. package/focus-app/client/_app/immutable/chunks/_wRuVGPs.js.gz +0 -0
  118. package/focus-app/client/_app/immutable/chunks/wbPk3Yxo.js +81 -0
  119. package/focus-app/client/_app/immutable/chunks/wbPk3Yxo.js.br +0 -0
  120. package/focus-app/client/_app/immutable/chunks/wbPk3Yxo.js.gz +0 -0
  121. package/focus-app/client/_app/immutable/entry/app.6DKouWRt.js +2 -0
  122. package/focus-app/client/_app/immutable/entry/app.6DKouWRt.js.br +0 -0
  123. package/focus-app/client/_app/immutable/entry/app.6DKouWRt.js.gz +0 -0
  124. package/focus-app/client/_app/immutable/entry/start.DlLmkUb7.js +1 -0
  125. package/focus-app/client/_app/immutable/entry/start.DlLmkUb7.js.br +2 -0
  126. package/focus-app/client/_app/immutable/entry/start.DlLmkUb7.js.gz +0 -0
  127. package/focus-app/client/_app/immutable/nodes/0.CuSOF0Of.js +5 -0
  128. package/focus-app/client/_app/immutable/nodes/0.CuSOF0Of.js.br +0 -0
  129. package/focus-app/client/_app/immutable/nodes/0.CuSOF0Of.js.gz +0 -0
  130. package/focus-app/client/_app/immutable/nodes/1.D39jdnqm.js +1 -0
  131. package/focus-app/client/_app/immutable/nodes/1.D39jdnqm.js.br +0 -0
  132. package/focus-app/client/_app/immutable/nodes/1.D39jdnqm.js.gz +0 -0
  133. package/focus-app/client/_app/immutable/nodes/2.CnU8ifRl.js +1 -0
  134. package/focus-app/client/_app/immutable/nodes/2.CnU8ifRl.js.br +0 -0
  135. package/focus-app/client/_app/immutable/nodes/2.CnU8ifRl.js.gz +0 -0
  136. package/focus-app/client/_app/version.json +1 -0
  137. package/focus-app/client/_app/version.json.br +0 -0
  138. package/focus-app/client/_app/version.json.gz +0 -0
  139. package/focus-app/env.js +70 -0
  140. package/focus-app/env.js.map +1 -0
  141. package/focus-app/h2a-focus.json +114 -0
  142. package/focus-app/handler.js +24 -0
  143. package/focus-app/handler.js.map +1 -0
  144. package/focus-app/index.js +147 -0
  145. package/focus-app/index.js.map +1 -0
  146. package/focus-app/server/chunks/chunks/exports.js-DUTkELZq.js +217 -0
  147. package/focus-app/server/chunks/chunks/exports.js-DUTkELZq.js.map +1 -0
  148. package/focus-app/server/chunks/chunks/false.js-B2gHlHjM.js +4 -0
  149. package/focus-app/server/chunks/chunks/false.js-B2gHlHjM.js.map +1 -0
  150. package/focus-app/server/chunks/chunks/friendly.js-D4fjovnZ.js +246 -0
  151. package/focus-app/server/chunks/chunks/friendly.js-D4fjovnZ.js.map +1 -0
  152. package/focus-app/server/chunks/chunks/index.js-Di21TltP.js +1315 -0
  153. package/focus-app/server/chunks/chunks/index.js-Di21TltP.js.map +1 -0
  154. package/focus-app/server/chunks/chunks/internal.js-33vbd70h.js +126 -0
  155. package/focus-app/server/chunks/chunks/internal.js-33vbd70h.js.map +1 -0
  156. package/focus-app/server/chunks/chunks/root.js-DO1m-gJA.js +2967 -0
  157. package/focus-app/server/chunks/chunks/root.js-DO1m-gJA.js.map +1 -0
  158. package/focus-app/server/chunks/chunks/server.js-Bf8x1V_n.js +16 -0
  159. package/focus-app/server/chunks/chunks/server.js-Bf8x1V_n.js.map +1 -0
  160. package/focus-app/server/chunks/chunks/utils.js-C_3_iViC.js +2545 -0
  161. package/focus-app/server/chunks/chunks/utils.js-C_3_iViC.js.map +1 -0
  162. package/focus-app/server/chunks/chunks/utils2.js-BQzn9ikS.js +38 -0
  163. package/focus-app/server/chunks/chunks/utils2.js-BQzn9ikS.js.map +1 -0
  164. package/focus-app/server/chunks/entries/endpoints/api/actions/launch/_server.ts.js-DUQcf9xd.js +63 -0
  165. package/focus-app/server/chunks/entries/endpoints/api/actions/launch/_server.ts.js-DUQcf9xd.js.map +1 -0
  166. package/focus-app/server/chunks/entries/endpoints/api/decisions/inject/_server.ts.js-j0NNcOSZ.js +100 -0
  167. package/focus-app/server/chunks/entries/endpoints/api/decisions/inject/_server.ts.js-j0NNcOSZ.js.map +1 -0
  168. package/focus-app/server/chunks/entries/fallbacks/error.svelte.js-Dj3sETSX.js +50 -0
  169. package/focus-app/server/chunks/entries/fallbacks/error.svelte.js-Dj3sETSX.js.map +1 -0
  170. package/focus-app/server/chunks/entries/pages/_layout.svelte.js-BoLsbuC2.js +1420 -0
  171. package/focus-app/server/chunks/entries/pages/_layout.svelte.js-BoLsbuC2.js.map +1 -0
  172. package/focus-app/server/chunks/entries/pages/_page.server.ts.js-ChRBj_xK.js +246 -0
  173. package/focus-app/server/chunks/entries/pages/_page.server.ts.js-ChRBj_xK.js.map +1 -0
  174. package/focus-app/server/chunks/entries/pages/_page.svelte.js-QDldMYhk.js +2725 -0
  175. package/focus-app/server/chunks/entries/pages/_page.svelte.js-QDldMYhk.js.map +1 -0
  176. package/focus-app/server/chunks/handler-Cp_5hLyY.js +1474 -0
  177. package/focus-app/server/chunks/handler-Cp_5hLyY.js.map +1 -0
  178. package/focus-app/server/chunks/index.js-CBh7Wjqp.js +4242 -0
  179. package/focus-app/server/chunks/index.js-CBh7Wjqp.js.map +1 -0
  180. package/focus-app/server/chunks/manifest.js-Cm6cC7mC.js +56 -0
  181. package/focus-app/server/chunks/manifest.js-Cm6cC7mC.js.map +1 -0
  182. package/focus-app/server/chunks/nodes/0.js-4wlmdsk8.js +9 -0
  183. package/focus-app/server/chunks/nodes/0.js-4wlmdsk8.js.map +1 -0
  184. package/focus-app/server/chunks/nodes/1.js-B-LpY-lC.js +9 -0
  185. package/focus-app/server/chunks/nodes/1.js-B-LpY-lC.js.map +1 -0
  186. package/focus-app/server/chunks/nodes/2.js-F6jp5eD9.js +19 -0
  187. package/focus-app/server/chunks/nodes/2.js-F6jp5eD9.js.map +1 -0
  188. package/focus-app/shims.js +33 -0
  189. package/focus-app/shims.js.map +1 -0
  190. package/package.json +8 -4
  191. package/skills/h2a/SKILL.md +7 -5
  192. package/skills/harness/SKILL.md +17 -0
  193. package/skills/harness/using-harness/SKILL.md +26 -0
@@ -0,0 +1,2967 @@
1
+ import { r as render, L as LEGACY_PROPS, d as define_property, C as CONNECTED, R as REACTION_RAN, E as ERROR_VALUE, a as COMMENT_NODE, H as HYDRATION_START, b as HYDRATION_ERROR, S as STATE_SYMBOL, o as object_prototype, c as array_prototype, U as UNINITIALIZED, g as get_descriptor, D as DERIVED, e as DIRTY, M as MAYBE_DIRTY, i as is_extensible, f as CLASS_CACHE, A as ATTRIBUTES_CACHE, h as STYLE_CACHE, T as TEXT_CACHE, j as get_prototype_of, k as is_array, l as CLEAN, I as INERT, m as EFFECT, B as BLOCK_EFFECT, n as ASYNC, p as DESTROYED, q as EAGER_EFFECT, s as deferred, t as RENDER_EFFECT, u as MANAGED_EFFECT, v as ROOT_EFFECT, w as BRANCH_EFFECT, W as WAS_MARKED, x as REACTION_IS_UPDATING, y as run_all, z as includes, F as EFFECT_PRESERVED, G as EFFECT_TRANSPARENT, J as HEAD_EFFECT, K as DESTROYING, N as BOUNDARY_EFFECT, O as index_of, P as STALE_REACTION, Q as noop, V as array_from, X as is_passive_event, Y as setContext, Z as derived, _ as HYDRATION_END, $ as HYDRATION_START_ELSE, a0 as HYDRATION_START_FAILED, a1 as USER_EFFECT } from './index.js-Di21TltP.js';
2
+ import { D as DEV } from './false.js-B2gHlHjM.js';
3
+
4
+ function equals(value) {
5
+ return value === this.v;
6
+ }
7
+ function safe_not_equal(a, b) {
8
+ return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
9
+ }
10
+ function safe_equals(value) {
11
+ return !safe_not_equal(value, this.v);
12
+ }
13
+ function effect_update_depth_exceeded() {
14
+ {
15
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
16
+ }
17
+ }
18
+ function hydration_failed() {
19
+ {
20
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
21
+ }
22
+ }
23
+ function state_descriptors_fixed() {
24
+ {
25
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
26
+ }
27
+ }
28
+ function state_prototype_fixed() {
29
+ {
30
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
31
+ }
32
+ }
33
+ function state_unsafe_mutation() {
34
+ {
35
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
36
+ }
37
+ }
38
+ function svelte_boundary_reset_onerror() {
39
+ {
40
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
41
+ }
42
+ }
43
+ let tracing_mode_flag = false;
44
+ let component_context = null;
45
+ function set_component_context(context) {
46
+ component_context = context;
47
+ }
48
+ function push(props, runes = false, fn) {
49
+ component_context = {
50
+ p: component_context,
51
+ i: false,
52
+ c: null,
53
+ e: null,
54
+ s: props,
55
+ x: null,
56
+ r: (
57
+ /** @type {Effect} */
58
+ active_effect
59
+ ),
60
+ l: null
61
+ };
62
+ }
63
+ function pop(component) {
64
+ var context = (
65
+ /** @type {ComponentContext} */
66
+ component_context
67
+ );
68
+ var effects = context.e;
69
+ if (effects !== null) {
70
+ context.e = null;
71
+ for (var fn of effects) {
72
+ create_user_effect(fn);
73
+ }
74
+ }
75
+ context.i = true;
76
+ component_context = context.p;
77
+ return (
78
+ /** @type {T} */
79
+ {}
80
+ );
81
+ }
82
+ function is_runes() {
83
+ return true;
84
+ }
85
+ let micro_tasks = [];
86
+ function run_micro_tasks() {
87
+ var tasks = micro_tasks;
88
+ micro_tasks = [];
89
+ run_all(tasks);
90
+ }
91
+ function queue_micro_task(fn) {
92
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
93
+ var tasks = micro_tasks;
94
+ queueMicrotask(() => {
95
+ if (tasks === micro_tasks) run_micro_tasks();
96
+ });
97
+ }
98
+ micro_tasks.push(fn);
99
+ }
100
+ function flush_tasks() {
101
+ while (micro_tasks.length > 0) {
102
+ run_micro_tasks();
103
+ }
104
+ }
105
+ function derived_inert() {
106
+ {
107
+ console.warn(`https://svelte.dev/e/derived_inert`);
108
+ }
109
+ }
110
+ function hydration_mismatch(location) {
111
+ {
112
+ console.warn(`https://svelte.dev/e/hydration_mismatch`);
113
+ }
114
+ }
115
+ function svelte_boundary_reset_noop() {
116
+ {
117
+ console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
118
+ }
119
+ }
120
+ let hydrating = false;
121
+ function set_hydrating(value) {
122
+ hydrating = value;
123
+ }
124
+ let hydrate_node;
125
+ function set_hydrate_node(node) {
126
+ if (node === null) {
127
+ hydration_mismatch();
128
+ throw HYDRATION_ERROR;
129
+ }
130
+ return hydrate_node = node;
131
+ }
132
+ function hydrate_next() {
133
+ return set_hydrate_node(/* @__PURE__ */ get_next_sibling(hydrate_node));
134
+ }
135
+ function next(count = 1) {
136
+ if (hydrating) {
137
+ var i = count;
138
+ var node = hydrate_node;
139
+ while (i--) {
140
+ node = /** @type {TemplateNode} */
141
+ /* @__PURE__ */ get_next_sibling(node);
142
+ }
143
+ hydrate_node = node;
144
+ }
145
+ }
146
+ function skip_nodes(remove = true) {
147
+ var depth = 0;
148
+ var node = hydrate_node;
149
+ while (true) {
150
+ if (node.nodeType === COMMENT_NODE) {
151
+ var data = (
152
+ /** @type {Comment} */
153
+ node.data
154
+ );
155
+ if (data === HYDRATION_END) {
156
+ if (depth === 0) return node;
157
+ depth -= 1;
158
+ } else if (data === HYDRATION_START || data === HYDRATION_START_ELSE || // "[1", "[2", etc. for if blocks
159
+ data[0] === "[" && !isNaN(Number(data.slice(1)))) {
160
+ depth += 1;
161
+ }
162
+ }
163
+ var next2 = (
164
+ /** @type {TemplateNode} */
165
+ /* @__PURE__ */ get_next_sibling(node)
166
+ );
167
+ if (remove) node.remove();
168
+ node = next2;
169
+ }
170
+ }
171
+ function proxy(value) {
172
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) {
173
+ return value;
174
+ }
175
+ const prototype = get_prototype_of(value);
176
+ if (prototype !== object_prototype && prototype !== array_prototype) {
177
+ return value;
178
+ }
179
+ var sources = /* @__PURE__ */ new Map();
180
+ var is_proxied_array = is_array(value);
181
+ var version = /* @__PURE__ */ state(0);
182
+ var parent_version = update_version;
183
+ var with_parent = (fn) => {
184
+ if (update_version === parent_version) {
185
+ return fn();
186
+ }
187
+ var reaction = active_reaction;
188
+ var version2 = update_version;
189
+ set_active_reaction(null);
190
+ set_update_version(parent_version);
191
+ var result = fn();
192
+ set_active_reaction(reaction);
193
+ set_update_version(version2);
194
+ return result;
195
+ };
196
+ if (is_proxied_array) {
197
+ sources.set("length", /* @__PURE__ */ state(
198
+ /** @type {any[]} */
199
+ value.length
200
+ ));
201
+ }
202
+ return new Proxy(
203
+ /** @type {any} */
204
+ value,
205
+ {
206
+ defineProperty(_, prop, descriptor) {
207
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) {
208
+ state_descriptors_fixed();
209
+ }
210
+ var s = sources.get(prop);
211
+ if (s === void 0) {
212
+ with_parent(() => {
213
+ var s2 = /* @__PURE__ */ state(descriptor.value);
214
+ sources.set(prop, s2);
215
+ return s2;
216
+ });
217
+ } else {
218
+ set(s, descriptor.value, true);
219
+ }
220
+ return true;
221
+ },
222
+ deleteProperty(target, prop) {
223
+ var s = sources.get(prop);
224
+ if (s === void 0) {
225
+ if (prop in target) {
226
+ const s2 = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
227
+ sources.set(prop, s2);
228
+ increment(version);
229
+ }
230
+ } else {
231
+ set(s, UNINITIALIZED);
232
+ increment(version);
233
+ }
234
+ return true;
235
+ },
236
+ get(target, prop, receiver) {
237
+ if (prop === STATE_SYMBOL) {
238
+ return value;
239
+ }
240
+ var s = sources.get(prop);
241
+ var exists = prop in target;
242
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
243
+ s = with_parent(() => {
244
+ var p = proxy(exists ? target[prop] : UNINITIALIZED);
245
+ var s2 = /* @__PURE__ */ state(p);
246
+ return s2;
247
+ });
248
+ sources.set(prop, s);
249
+ }
250
+ if (s !== void 0) {
251
+ var v = get(s);
252
+ return v === UNINITIALIZED ? void 0 : v;
253
+ }
254
+ return Reflect.get(target, prop, receiver);
255
+ },
256
+ getOwnPropertyDescriptor(target, prop) {
257
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
258
+ if (descriptor && "value" in descriptor) {
259
+ var s = sources.get(prop);
260
+ if (s) descriptor.value = get(s);
261
+ } else if (descriptor === void 0) {
262
+ var source2 = sources.get(prop);
263
+ var value2 = source2?.v;
264
+ if (source2 !== void 0 && value2 !== UNINITIALIZED) {
265
+ return {
266
+ enumerable: true,
267
+ configurable: true,
268
+ value: value2,
269
+ writable: true
270
+ };
271
+ }
272
+ }
273
+ return descriptor;
274
+ },
275
+ has(target, prop) {
276
+ if (prop === STATE_SYMBOL) {
277
+ return true;
278
+ }
279
+ var s = sources.get(prop);
280
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
281
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
282
+ if (s === void 0) {
283
+ s = with_parent(() => {
284
+ var p = has ? proxy(target[prop]) : UNINITIALIZED;
285
+ var s2 = /* @__PURE__ */ state(p);
286
+ return s2;
287
+ });
288
+ sources.set(prop, s);
289
+ }
290
+ var value2 = get(s);
291
+ if (value2 === UNINITIALIZED) {
292
+ return false;
293
+ }
294
+ }
295
+ return has;
296
+ },
297
+ set(target, prop, value2, receiver) {
298
+ var s = sources.get(prop);
299
+ var has = prop in target;
300
+ if (is_proxied_array && prop === "length") {
301
+ for (var i = value2; i < /** @type {Source<number>} */
302
+ s.v; i += 1) {
303
+ var other_s = sources.get(i + "");
304
+ if (other_s !== void 0) {
305
+ set(other_s, UNINITIALIZED);
306
+ } else if (i in target) {
307
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
308
+ sources.set(i + "", other_s);
309
+ }
310
+ }
311
+ }
312
+ if (s === void 0) {
313
+ if (!has || get_descriptor(target, prop)?.writable) {
314
+ s = with_parent(() => /* @__PURE__ */ state(void 0));
315
+ set(s, proxy(value2));
316
+ sources.set(prop, s);
317
+ }
318
+ } else {
319
+ has = s.v !== UNINITIALIZED;
320
+ var p = with_parent(() => proxy(value2));
321
+ set(s, p);
322
+ }
323
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
324
+ if (descriptor?.set) {
325
+ descriptor.set.call(receiver, value2);
326
+ }
327
+ if (!has) {
328
+ if (is_proxied_array && typeof prop === "string") {
329
+ var ls = (
330
+ /** @type {Source<number>} */
331
+ sources.get("length")
332
+ );
333
+ var n = Number(prop);
334
+ if (Number.isInteger(n) && n >= ls.v) {
335
+ set(ls, n + 1);
336
+ }
337
+ }
338
+ increment(version);
339
+ }
340
+ return true;
341
+ },
342
+ ownKeys(target) {
343
+ get(version);
344
+ var own_keys = Reflect.ownKeys(target).filter((key2) => {
345
+ var source3 = sources.get(key2);
346
+ return source3 === void 0 || source3.v !== UNINITIALIZED;
347
+ });
348
+ for (var [key, source2] of sources) {
349
+ if (source2.v !== UNINITIALIZED && !(key in target)) {
350
+ own_keys.push(key);
351
+ }
352
+ }
353
+ return own_keys;
354
+ },
355
+ setPrototypeOf() {
356
+ state_prototype_fixed();
357
+ }
358
+ }
359
+ );
360
+ }
361
+ var $window;
362
+ var first_child_getter;
363
+ var next_sibling_getter;
364
+ function init_operations() {
365
+ if ($window !== void 0) {
366
+ return;
367
+ }
368
+ $window = window;
369
+ var element_prototype = Element.prototype;
370
+ var node_prototype = Node.prototype;
371
+ var text_prototype = Text.prototype;
372
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
373
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
374
+ if (is_extensible(element_prototype)) {
375
+ element_prototype[CLASS_CACHE] = void 0;
376
+ element_prototype[ATTRIBUTES_CACHE] = null;
377
+ element_prototype[STYLE_CACHE] = void 0;
378
+ element_prototype.__e = void 0;
379
+ }
380
+ if (is_extensible(text_prototype)) {
381
+ text_prototype[TEXT_CACHE] = void 0;
382
+ }
383
+ }
384
+ function create_text(value = "") {
385
+ return document.createTextNode(value);
386
+ }
387
+ // @__NO_SIDE_EFFECTS__
388
+ function get_first_child(node) {
389
+ return (
390
+ /** @type {TemplateNode | null} */
391
+ first_child_getter.call(node)
392
+ );
393
+ }
394
+ // @__NO_SIDE_EFFECTS__
395
+ function get_next_sibling(node) {
396
+ return (
397
+ /** @type {TemplateNode | null} */
398
+ next_sibling_getter.call(node)
399
+ );
400
+ }
401
+ function clear_text_content(node) {
402
+ node.textContent = "";
403
+ }
404
+ function handle_error(error) {
405
+ var effect = active_effect;
406
+ if (effect === null) {
407
+ active_reaction.f |= ERROR_VALUE;
408
+ return error;
409
+ }
410
+ if ((effect.f & REACTION_RAN) === 0 && (effect.f & EFFECT) === 0) {
411
+ throw error;
412
+ }
413
+ invoke_error_boundary(error, effect);
414
+ }
415
+ function invoke_error_boundary(error, effect) {
416
+ if (effect !== null && (effect.f & DESTROYED) !== 0) {
417
+ return;
418
+ }
419
+ while (effect !== null) {
420
+ if ((effect.f & BOUNDARY_EFFECT) !== 0) {
421
+ if ((effect.f & REACTION_RAN) === 0) {
422
+ throw error;
423
+ }
424
+ try {
425
+ effect.b.error(error);
426
+ return;
427
+ } catch (e) {
428
+ error = e;
429
+ }
430
+ }
431
+ effect = effect.parent;
432
+ }
433
+ throw error;
434
+ }
435
+ const STATUS_MASK = -7169;
436
+ function set_signal_status(signal, status) {
437
+ signal.f = signal.f & STATUS_MASK | status;
438
+ }
439
+ function update_derived_status(derived2) {
440
+ if ((derived2.f & CONNECTED) !== 0 || derived2.deps === null) {
441
+ set_signal_status(derived2, CLEAN);
442
+ } else {
443
+ set_signal_status(derived2, MAYBE_DIRTY);
444
+ }
445
+ }
446
+ function clear_marked(deps) {
447
+ if (deps === null) return;
448
+ for (const dep of deps) {
449
+ if ((dep.f & DERIVED) === 0 || (dep.f & WAS_MARKED) === 0) {
450
+ continue;
451
+ }
452
+ dep.f ^= WAS_MARKED;
453
+ clear_marked(
454
+ /** @type {Derived} */
455
+ dep.deps
456
+ );
457
+ }
458
+ }
459
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
460
+ if ((effect.f & DIRTY) !== 0) {
461
+ dirty_effects.add(effect);
462
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
463
+ maybe_dirty_effects.add(effect);
464
+ }
465
+ clear_marked(effect.deps);
466
+ set_signal_status(effect, CLEAN);
467
+ }
468
+ function createSubscriber(start) {
469
+ let subscribers = 0;
470
+ let version = source(0);
471
+ let stop;
472
+ return () => {
473
+ if (effect_tracking()) {
474
+ get(version);
475
+ render_effect(() => {
476
+ if (subscribers === 0) {
477
+ stop = untrack(() => start(() => increment(version)));
478
+ }
479
+ subscribers += 1;
480
+ return () => {
481
+ queue_micro_task(() => {
482
+ subscribers -= 1;
483
+ if (subscribers === 0) {
484
+ stop?.();
485
+ stop = void 0;
486
+ increment(version);
487
+ }
488
+ });
489
+ };
490
+ });
491
+ }
492
+ };
493
+ }
494
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
495
+ function boundary(node, props, children, transform_error) {
496
+ new Boundary(node, props, children, transform_error);
497
+ }
498
+ class Boundary {
499
+ /** @type {Boundary | null} */
500
+ parent;
501
+ is_pending = false;
502
+ /**
503
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
504
+ * Inherited from parent boundary, or defaults to identity.
505
+ * @type {(error: unknown) => unknown}
506
+ */
507
+ transform_error;
508
+ /** @type {TemplateNode} */
509
+ #anchor;
510
+ /** @type {TemplateNode | null} */
511
+ #hydrate_open = hydrating ? hydrate_node : null;
512
+ /** @type {BoundaryProps} */
513
+ #props;
514
+ /** @type {((anchor: Node) => void)} */
515
+ #children;
516
+ /** @type {Effect} */
517
+ #effect;
518
+ /** @type {Effect | null} */
519
+ #main_effect = null;
520
+ /** @type {Effect | null} */
521
+ #pending_effect = null;
522
+ /** @type {Effect | null} */
523
+ #failed_effect = null;
524
+ /** @type {DocumentFragment | null} */
525
+ #offscreen_fragment = null;
526
+ #local_pending_count = 0;
527
+ #pending_count = 0;
528
+ #pending_count_update_queued = false;
529
+ /** @type {Set<Effect>} */
530
+ #dirty_effects = /* @__PURE__ */ new Set();
531
+ /** @type {Set<Effect>} */
532
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
533
+ /**
534
+ * A source containing the number of pending async deriveds/expressions.
535
+ * Only created if `$effect.pending()` is used inside the boundary,
536
+ * otherwise updating the source results in needless `Batch.ensure()`
537
+ * calls followed by no-op flushes
538
+ * @type {Source<number> | null}
539
+ */
540
+ #effect_pending = null;
541
+ #effect_pending_subscriber = createSubscriber(() => {
542
+ this.#effect_pending = source(this.#local_pending_count);
543
+ return () => {
544
+ this.#effect_pending = null;
545
+ };
546
+ });
547
+ /**
548
+ * @param {TemplateNode} node
549
+ * @param {BoundaryProps} props
550
+ * @param {((anchor: Node) => void)} children
551
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
552
+ */
553
+ constructor(node, props, children, transform_error) {
554
+ this.#anchor = node;
555
+ this.#props = props;
556
+ this.#children = (anchor) => {
557
+ var effect = (
558
+ /** @type {Effect} */
559
+ active_effect
560
+ );
561
+ effect.b = this;
562
+ effect.f |= BOUNDARY_EFFECT;
563
+ children(anchor);
564
+ };
565
+ this.parent = /** @type {Effect} */
566
+ active_effect.b;
567
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
568
+ this.#effect = block(() => {
569
+ if (hydrating) {
570
+ const comment = (
571
+ /** @type {Comment} */
572
+ this.#hydrate_open
573
+ );
574
+ hydrate_next();
575
+ const server_rendered_pending = comment.data === HYDRATION_START_ELSE;
576
+ const server_rendered_failed = comment.data.startsWith(HYDRATION_START_FAILED);
577
+ if (server_rendered_failed) {
578
+ const serialized_error = JSON.parse(comment.data.slice(HYDRATION_START_FAILED.length));
579
+ this.#hydrate_failed_content(serialized_error);
580
+ } else if (server_rendered_pending) {
581
+ this.#hydrate_pending_content();
582
+ } else {
583
+ this.#hydrate_resolved_content();
584
+ }
585
+ } else {
586
+ this.#render();
587
+ }
588
+ }, flags);
589
+ if (hydrating) {
590
+ this.#anchor = hydrate_node;
591
+ }
592
+ }
593
+ #hydrate_resolved_content() {
594
+ try {
595
+ this.#main_effect = branch(() => this.#children(this.#anchor));
596
+ } catch (error) {
597
+ this.error(error);
598
+ }
599
+ }
600
+ /**
601
+ * @param {unknown} error The deserialized error from the server's hydration comment
602
+ */
603
+ #hydrate_failed_content(error) {
604
+ const failed = this.#props.failed;
605
+ if (!failed) return;
606
+ this.#failed_effect = branch(() => {
607
+ failed(
608
+ this.#anchor,
609
+ () => error,
610
+ () => () => {
611
+ }
612
+ );
613
+ });
614
+ }
615
+ #hydrate_pending_content() {
616
+ const pending = this.#props.pending;
617
+ if (!pending) return;
618
+ this.is_pending = true;
619
+ this.#pending_effect = branch(() => pending(this.#anchor));
620
+ queue_micro_task(() => {
621
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
622
+ var anchor = create_text();
623
+ fragment.append(anchor);
624
+ this.#main_effect = this.#run(() => {
625
+ return branch(() => this.#children(anchor));
626
+ });
627
+ if (this.#pending_count === 0) {
628
+ this.#anchor.before(fragment);
629
+ this.#offscreen_fragment = null;
630
+ pause_effect(
631
+ /** @type {Effect} */
632
+ this.#pending_effect,
633
+ () => {
634
+ this.#pending_effect = null;
635
+ }
636
+ );
637
+ this.#resolve(
638
+ /** @type {Batch} */
639
+ current_batch
640
+ );
641
+ }
642
+ });
643
+ }
644
+ #render() {
645
+ try {
646
+ this.is_pending = this.has_pending_snippet();
647
+ this.#pending_count = 0;
648
+ this.#local_pending_count = 0;
649
+ this.#main_effect = branch(() => {
650
+ this.#children(this.#anchor);
651
+ });
652
+ if (this.#pending_count > 0) {
653
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
654
+ move_effect(this.#main_effect, fragment);
655
+ const pending = (
656
+ /** @type {(anchor: Node) => void} */
657
+ this.#props.pending
658
+ );
659
+ this.#pending_effect = branch(() => pending(this.#anchor));
660
+ } else {
661
+ this.#resolve(
662
+ /** @type {Batch} */
663
+ current_batch
664
+ );
665
+ }
666
+ } catch (error) {
667
+ this.error(error);
668
+ }
669
+ }
670
+ /**
671
+ * @param {Batch} batch
672
+ */
673
+ #resolve(batch) {
674
+ this.is_pending = false;
675
+ batch.transfer_effects(this.#dirty_effects, this.#maybe_dirty_effects);
676
+ }
677
+ /**
678
+ * Defer an effect inside a pending boundary until the boundary resolves
679
+ * @param {Effect} effect
680
+ */
681
+ defer_effect(effect) {
682
+ defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects);
683
+ }
684
+ /**
685
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
686
+ * @returns {boolean}
687
+ */
688
+ is_rendered() {
689
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
690
+ }
691
+ has_pending_snippet() {
692
+ return !!this.#props.pending;
693
+ }
694
+ /**
695
+ * @template T
696
+ * @param {() => T} fn
697
+ */
698
+ #run(fn) {
699
+ var previous_effect = active_effect;
700
+ var previous_reaction = active_reaction;
701
+ var previous_ctx = component_context;
702
+ set_active_effect(this.#effect);
703
+ set_active_reaction(this.#effect);
704
+ set_component_context(this.#effect.ctx);
705
+ try {
706
+ Batch.ensure();
707
+ return fn();
708
+ } catch (e) {
709
+ handle_error(e);
710
+ return null;
711
+ } finally {
712
+ set_active_effect(previous_effect);
713
+ set_active_reaction(previous_reaction);
714
+ set_component_context(previous_ctx);
715
+ }
716
+ }
717
+ /**
718
+ * Updates the pending count associated with the currently visible pending snippet,
719
+ * if any, such that we can replace the snippet with content once work is done
720
+ * @param {1 | -1} d
721
+ * @param {Batch} batch
722
+ */
723
+ #update_pending_count(d, batch) {
724
+ if (!this.has_pending_snippet()) {
725
+ if (this.parent) {
726
+ this.parent.#update_pending_count(d, batch);
727
+ }
728
+ return;
729
+ }
730
+ this.#pending_count += d;
731
+ if (this.#pending_count === 0) {
732
+ this.#resolve(batch);
733
+ if (this.#pending_effect) {
734
+ pause_effect(this.#pending_effect, () => {
735
+ this.#pending_effect = null;
736
+ });
737
+ }
738
+ if (this.#offscreen_fragment) {
739
+ this.#anchor.before(this.#offscreen_fragment);
740
+ this.#offscreen_fragment = null;
741
+ }
742
+ }
743
+ }
744
+ /**
745
+ * Update the source that powers `$effect.pending()` inside this boundary,
746
+ * and controls when the current `pending` snippet (if any) is removed.
747
+ * Do not call from inside the class
748
+ * @param {1 | -1} d
749
+ * @param {Batch} batch
750
+ */
751
+ update_pending_count(d, batch) {
752
+ this.#update_pending_count(d, batch);
753
+ this.#local_pending_count += d;
754
+ if (!this.#effect_pending || this.#pending_count_update_queued) return;
755
+ this.#pending_count_update_queued = true;
756
+ queue_micro_task(() => {
757
+ this.#pending_count_update_queued = false;
758
+ if (this.#effect_pending) {
759
+ internal_set(this.#effect_pending, this.#local_pending_count);
760
+ }
761
+ });
762
+ }
763
+ get_effect_pending() {
764
+ this.#effect_pending_subscriber();
765
+ return get(
766
+ /** @type {Source<number>} */
767
+ this.#effect_pending
768
+ );
769
+ }
770
+ /** @param {unknown} error */
771
+ error(error) {
772
+ if (!this.#props.onerror && !this.#props.failed) {
773
+ throw error;
774
+ }
775
+ if (current_batch?.is_fork) {
776
+ if (this.#main_effect) current_batch.skip_effect(this.#main_effect);
777
+ if (this.#pending_effect) current_batch.skip_effect(this.#pending_effect);
778
+ if (this.#failed_effect) current_batch.skip_effect(this.#failed_effect);
779
+ current_batch.oncommit(() => {
780
+ this.#handle_error(error);
781
+ });
782
+ } else {
783
+ this.#handle_error(error);
784
+ }
785
+ }
786
+ /**
787
+ * @param {unknown} error
788
+ */
789
+ #handle_error(error) {
790
+ if (this.#main_effect) {
791
+ destroy_effect(this.#main_effect);
792
+ this.#main_effect = null;
793
+ }
794
+ if (this.#pending_effect) {
795
+ destroy_effect(this.#pending_effect);
796
+ this.#pending_effect = null;
797
+ }
798
+ if (this.#failed_effect) {
799
+ destroy_effect(this.#failed_effect);
800
+ this.#failed_effect = null;
801
+ }
802
+ if (hydrating) {
803
+ set_hydrate_node(
804
+ /** @type {TemplateNode} */
805
+ this.#hydrate_open
806
+ );
807
+ next();
808
+ set_hydrate_node(skip_nodes());
809
+ }
810
+ var onerror = this.#props.onerror;
811
+ let failed = this.#props.failed;
812
+ var did_reset = false;
813
+ var calling_on_error = false;
814
+ const reset = () => {
815
+ if (did_reset) {
816
+ svelte_boundary_reset_noop();
817
+ return;
818
+ }
819
+ did_reset = true;
820
+ if (calling_on_error) {
821
+ svelte_boundary_reset_onerror();
822
+ }
823
+ if (this.#failed_effect !== null) {
824
+ pause_effect(this.#failed_effect, () => {
825
+ this.#failed_effect = null;
826
+ });
827
+ }
828
+ this.#run(() => {
829
+ this.#render();
830
+ });
831
+ };
832
+ const handle_error_result = (transformed_error) => {
833
+ try {
834
+ calling_on_error = true;
835
+ onerror?.(transformed_error, reset);
836
+ calling_on_error = false;
837
+ } catch (error2) {
838
+ invoke_error_boundary(error2, this.#effect && this.#effect.parent);
839
+ }
840
+ if (failed) {
841
+ this.#failed_effect = this.#run(() => {
842
+ try {
843
+ return branch(() => {
844
+ var effect = (
845
+ /** @type {Effect} */
846
+ active_effect
847
+ );
848
+ effect.b = this;
849
+ effect.f |= BOUNDARY_EFFECT;
850
+ failed(
851
+ this.#anchor,
852
+ () => transformed_error,
853
+ () => reset
854
+ );
855
+ });
856
+ } catch (error2) {
857
+ invoke_error_boundary(
858
+ error2,
859
+ /** @type {Effect} */
860
+ this.#effect.parent
861
+ );
862
+ return null;
863
+ }
864
+ });
865
+ }
866
+ };
867
+ queue_micro_task(() => {
868
+ var result;
869
+ try {
870
+ result = this.transform_error(error);
871
+ } catch (e) {
872
+ invoke_error_boundary(e, this.#effect && this.#effect.parent);
873
+ return;
874
+ }
875
+ if (result !== null && typeof result === "object" && typeof /** @type {any} */
876
+ result.then === "function") {
877
+ result.then(
878
+ handle_error_result,
879
+ /** @param {unknown} e */
880
+ (e) => invoke_error_boundary(e, this.#effect && this.#effect.parent)
881
+ );
882
+ } else {
883
+ handle_error_result(result);
884
+ }
885
+ });
886
+ }
887
+ }
888
+ const OBSOLETE = /* @__PURE__ */ Symbol("obsolete");
889
+ function destroy_derived_effects(derived2) {
890
+ var effects = derived2.effects;
891
+ if (effects !== null) {
892
+ derived2.effects = null;
893
+ for (var i = 0; i < effects.length; i += 1) {
894
+ destroy_effect(
895
+ /** @type {Effect} */
896
+ effects[i]
897
+ );
898
+ }
899
+ }
900
+ }
901
+ function execute_derived(derived2) {
902
+ var value;
903
+ var prev_active_effect = active_effect;
904
+ var parent = derived2.parent;
905
+ if (!is_destroying_effect && parent !== null && derived2.v !== UNINITIALIZED && // if it was never evaluated before, it's guaranteed to fail downstream, so we try to execute instead
906
+ (parent.f & (DESTROYED | INERT)) !== 0) {
907
+ derived_inert();
908
+ return derived2.v;
909
+ }
910
+ set_active_effect(parent);
911
+ {
912
+ try {
913
+ derived2.f &= ~WAS_MARKED;
914
+ destroy_derived_effects(derived2);
915
+ value = update_reaction(derived2);
916
+ } finally {
917
+ set_active_effect(prev_active_effect);
918
+ }
919
+ }
920
+ return value;
921
+ }
922
+ function update_derived(derived2) {
923
+ var value = execute_derived(derived2);
924
+ if (!derived2.equals(value)) {
925
+ derived2.wv = increment_write_version();
926
+ if (!current_batch?.is_fork || derived2.deps === null) {
927
+ if (current_batch !== null) {
928
+ current_batch.capture(derived2, value, true);
929
+ previous_batch?.capture(derived2, value, true);
930
+ } else {
931
+ derived2.v = value;
932
+ }
933
+ if (derived2.deps === null) {
934
+ set_signal_status(derived2, CLEAN);
935
+ return;
936
+ }
937
+ }
938
+ }
939
+ if (is_destroying_effect) {
940
+ return;
941
+ }
942
+ if (batch_values !== null) {
943
+ if (effect_tracking() || current_batch?.is_fork) {
944
+ batch_values.set(derived2, value);
945
+ }
946
+ } else {
947
+ update_derived_status(derived2);
948
+ }
949
+ }
950
+ function freeze_derived_effects(derived2) {
951
+ if (derived2.effects === null) return;
952
+ for (const e of derived2.effects) {
953
+ if (e.teardown || e.ac) {
954
+ e.teardown?.();
955
+ e.ac?.abort(STALE_REACTION);
956
+ if (e.fn !== null) e.teardown = noop;
957
+ e.ac = null;
958
+ remove_reactions(e, 0);
959
+ destroy_effect_children(e);
960
+ }
961
+ }
962
+ }
963
+ function unfreeze_derived_effects(derived2) {
964
+ if (derived2.effects === null) return;
965
+ for (const e of derived2.effects) {
966
+ if (e.teardown && e.fn !== null) {
967
+ update_effect(e);
968
+ }
969
+ }
970
+ }
971
+ let first_batch = null;
972
+ let last_batch = null;
973
+ let current_batch = null;
974
+ let previous_batch = null;
975
+ let batch_values = null;
976
+ let last_scheduled_effect = null;
977
+ let is_flushing_sync = false;
978
+ let is_processing = false;
979
+ let collected_effects = null;
980
+ let legacy_updates = null;
981
+ var flush_count = 0;
982
+ let uid = 1;
983
+ class Batch {
984
+ id = uid++;
985
+ /** True as soon as `#process` was called */
986
+ #started = false;
987
+ linked = true;
988
+ /** @type {Batch | null} */
989
+ #prev = null;
990
+ /** @type {Batch | null} */
991
+ #next = null;
992
+ /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
993
+ async_deriveds = /* @__PURE__ */ new Map();
994
+ /**
995
+ * The current values of any signals that are updated in this batch.
996
+ * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
997
+ * They keys of this map are identical to `this.#previous`
998
+ * @type {Map<Value, [any, boolean]>}
999
+ */
1000
+ current = /* @__PURE__ */ new Map();
1001
+ /**
1002
+ * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
1003
+ * They keys of this map are identical to `this.#current`
1004
+ * @type {Map<Value, any>}
1005
+ */
1006
+ previous = /* @__PURE__ */ new Map();
1007
+ /**
1008
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
1009
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
1010
+ * @type {Set<(batch: Batch) => void>}
1011
+ */
1012
+ #commit_callbacks = /* @__PURE__ */ new Set();
1013
+ /**
1014
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
1015
+ * @type {Set<(batch: Batch) => void>}
1016
+ */
1017
+ #discard_callbacks = /* @__PURE__ */ new Set();
1018
+ /**
1019
+ * The number of async effects that are currently in flight
1020
+ */
1021
+ #pending = 0;
1022
+ /**
1023
+ * Async effects that are currently in flight, _not_ inside a pending boundary
1024
+ * @type {Map<Effect, number>}
1025
+ */
1026
+ #blocking_pending = /* @__PURE__ */ new Map();
1027
+ /**
1028
+ * A deferred that resolves when the batch is committed, used with `settled()`
1029
+ * TODO replace with Promise.withResolvers once supported widely enough
1030
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
1031
+ */
1032
+ #deferred = null;
1033
+ /**
1034
+ * The root effects that need to be flushed
1035
+ * @type {Effect[]}
1036
+ */
1037
+ #roots = [];
1038
+ /**
1039
+ * Effects created while this batch was active.
1040
+ * @type {Effect[]}
1041
+ */
1042
+ #new_effects = [];
1043
+ /**
1044
+ * Deferred effects (which run after async work has completed) that are DIRTY
1045
+ * @type {Set<Effect>}
1046
+ */
1047
+ #dirty_effects = /* @__PURE__ */ new Set();
1048
+ /**
1049
+ * Deferred effects that are MAYBE_DIRTY
1050
+ * @type {Set<Effect>}
1051
+ */
1052
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
1053
+ /**
1054
+ * A map of branches that still exist, but will be destroyed when this batch
1055
+ * is committed — we skip over these during `process`.
1056
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
1057
+ * so they can be rescheduled if the branch survives.
1058
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
1059
+ */
1060
+ #skipped_branches = /* @__PURE__ */ new Map();
1061
+ /**
1062
+ * Inverse of #skipped_branches which we need to tell prior batches to unskip them when committing
1063
+ * @type {Set<Effect>}
1064
+ */
1065
+ #unskipped_branches = /* @__PURE__ */ new Set();
1066
+ is_fork = false;
1067
+ #decrement_queued = false;
1068
+ constructor() {
1069
+ if (last_batch === null) {
1070
+ first_batch = last_batch = this;
1071
+ } else {
1072
+ last_batch.#next = this;
1073
+ this.#prev = last_batch;
1074
+ }
1075
+ last_batch = this;
1076
+ }
1077
+ #is_deferred() {
1078
+ if (this.is_fork) return true;
1079
+ for (const effect of this.#blocking_pending.keys()) {
1080
+ var e = effect;
1081
+ var skipped = false;
1082
+ while (e.parent !== null) {
1083
+ if (this.#skipped_branches.has(e)) {
1084
+ skipped = true;
1085
+ break;
1086
+ }
1087
+ e = e.parent;
1088
+ }
1089
+ if (!skipped) {
1090
+ return true;
1091
+ }
1092
+ }
1093
+ return false;
1094
+ }
1095
+ /**
1096
+ * Add an effect to the #skipped_branches map and reset its children
1097
+ * @param {Effect} effect
1098
+ */
1099
+ skip_effect(effect) {
1100
+ if (!this.#skipped_branches.has(effect)) {
1101
+ this.#skipped_branches.set(effect, { d: [], m: [] });
1102
+ }
1103
+ this.#unskipped_branches.delete(effect);
1104
+ }
1105
+ /**
1106
+ * Remove an effect from the #skipped_branches map and reschedule
1107
+ * any tracked dirty/maybe_dirty child effects
1108
+ * @param {Effect} effect
1109
+ * @param {(e: Effect) => void} callback
1110
+ */
1111
+ unskip_effect(effect, callback = (e) => this.schedule(e)) {
1112
+ var tracked = this.#skipped_branches.get(effect);
1113
+ if (tracked) {
1114
+ this.#skipped_branches.delete(effect);
1115
+ for (var e of tracked.d) {
1116
+ set_signal_status(e, DIRTY);
1117
+ callback(e);
1118
+ }
1119
+ for (e of tracked.m) {
1120
+ set_signal_status(e, MAYBE_DIRTY);
1121
+ callback(e);
1122
+ }
1123
+ }
1124
+ this.#unskipped_branches.add(effect);
1125
+ }
1126
+ #process() {
1127
+ this.#started = true;
1128
+ if (flush_count++ > 1e3) {
1129
+ this.#unlink();
1130
+ infinite_loop_guard();
1131
+ }
1132
+ for (const e of this.#dirty_effects) {
1133
+ this.#maybe_dirty_effects.delete(e);
1134
+ set_signal_status(e, DIRTY);
1135
+ this.schedule(e);
1136
+ }
1137
+ for (const e of this.#maybe_dirty_effects) {
1138
+ set_signal_status(e, MAYBE_DIRTY);
1139
+ this.schedule(e);
1140
+ }
1141
+ const roots = this.#roots;
1142
+ this.#roots = [];
1143
+ this.apply();
1144
+ var effects = collected_effects = [];
1145
+ var render_effects = [];
1146
+ var updates = legacy_updates = [];
1147
+ for (const root2 of roots) {
1148
+ try {
1149
+ this.#traverse(root2, effects, render_effects);
1150
+ } catch (e) {
1151
+ reset_all(root2);
1152
+ if (!this.#is_deferred()) this.discard();
1153
+ throw e;
1154
+ }
1155
+ }
1156
+ current_batch = null;
1157
+ if (updates.length > 0) {
1158
+ var batch = Batch.ensure();
1159
+ for (const e of updates) {
1160
+ batch.schedule(e);
1161
+ }
1162
+ }
1163
+ collected_effects = null;
1164
+ legacy_updates = null;
1165
+ if (this.#is_deferred()) {
1166
+ this.#defer_effects(render_effects);
1167
+ this.#defer_effects(effects);
1168
+ for (const [e, t] of this.#skipped_branches) {
1169
+ reset_branch(e, t);
1170
+ }
1171
+ if (updates.length > 0) {
1172
+ /** @type {unknown} */
1173
+ current_batch.#process();
1174
+ }
1175
+ return;
1176
+ }
1177
+ const earlier_batch = this.#find_earlier_batch();
1178
+ if (earlier_batch) {
1179
+ this.#defer_effects(render_effects);
1180
+ this.#defer_effects(effects);
1181
+ earlier_batch.#merge(this);
1182
+ return;
1183
+ }
1184
+ this.#dirty_effects.clear();
1185
+ this.#maybe_dirty_effects.clear();
1186
+ for (const fn of this.#commit_callbacks) fn(this);
1187
+ this.#commit_callbacks.clear();
1188
+ previous_batch = this;
1189
+ flush_queued_effects(render_effects);
1190
+ flush_queued_effects(effects);
1191
+ previous_batch = null;
1192
+ this.#deferred?.resolve();
1193
+ var next_batch = (
1194
+ /** @type {Batch | null} */
1195
+ /** @type {unknown} */
1196
+ current_batch
1197
+ );
1198
+ if (this.#pending === 0 && (this.#roots.length === 0 || next_batch !== null)) {
1199
+ this.#unlink();
1200
+ }
1201
+ if (this.#roots.length > 0) {
1202
+ if (next_batch !== null) {
1203
+ const batch2 = next_batch;
1204
+ batch2.#roots.push(...this.#roots.filter((r) => !batch2.#roots.includes(r)));
1205
+ } else {
1206
+ next_batch = this;
1207
+ }
1208
+ }
1209
+ if (next_batch !== null) {
1210
+ next_batch.#process();
1211
+ }
1212
+ }
1213
+ /**
1214
+ * Traverse the effect tree, executing effects or stashing
1215
+ * them for later execution as appropriate
1216
+ * @param {Effect} root
1217
+ * @param {Effect[]} effects
1218
+ * @param {Effect[]} render_effects
1219
+ */
1220
+ #traverse(root2, effects, render_effects) {
1221
+ root2.f ^= CLEAN;
1222
+ var effect = root2.first;
1223
+ while (effect !== null) {
1224
+ var flags2 = effect.f;
1225
+ var is_branch = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
1226
+ var is_skippable_branch = is_branch && (flags2 & CLEAN) !== 0;
1227
+ var skip = is_skippable_branch || (flags2 & INERT) !== 0 || this.#skipped_branches.has(effect);
1228
+ if (!skip && effect.fn !== null) {
1229
+ if (is_branch) {
1230
+ effect.f ^= CLEAN;
1231
+ } else if ((flags2 & EFFECT) !== 0) {
1232
+ effects.push(effect);
1233
+ } else if (is_dirty(effect)) {
1234
+ if ((flags2 & BLOCK_EFFECT) !== 0) this.#maybe_dirty_effects.add(effect);
1235
+ update_effect(effect);
1236
+ }
1237
+ var child = effect.first;
1238
+ if (child !== null) {
1239
+ effect = child;
1240
+ continue;
1241
+ }
1242
+ }
1243
+ while (effect !== null) {
1244
+ var next2 = effect.next;
1245
+ if (next2 !== null) {
1246
+ effect = next2;
1247
+ break;
1248
+ }
1249
+ effect = effect.parent;
1250
+ }
1251
+ }
1252
+ }
1253
+ #find_earlier_batch() {
1254
+ var batch = this.#prev;
1255
+ while (batch !== null) {
1256
+ if (!batch.is_fork) {
1257
+ for (const [value, [, is_derived]] of this.current) {
1258
+ if (batch.current.has(value) && !is_derived) {
1259
+ return batch;
1260
+ }
1261
+ }
1262
+ }
1263
+ batch = batch.#prev;
1264
+ }
1265
+ return null;
1266
+ }
1267
+ /**
1268
+ * @param {Batch} batch
1269
+ */
1270
+ #merge(batch) {
1271
+ for (const [source2, value] of batch.current) {
1272
+ if (!this.previous.has(source2) && batch.previous.has(source2)) {
1273
+ this.previous.set(source2, batch.previous.get(source2));
1274
+ }
1275
+ this.current.set(source2, value);
1276
+ }
1277
+ for (const [effect, deferred2] of batch.async_deriveds) {
1278
+ const d = this.async_deriveds.get(effect);
1279
+ if (d) deferred2.promise.then(d.resolve).catch(d.reject);
1280
+ }
1281
+ batch.async_deriveds.clear();
1282
+ this.transfer_effects(batch.#dirty_effects, batch.#maybe_dirty_effects);
1283
+ const mark = (value) => {
1284
+ var reactions = value.reactions;
1285
+ if (reactions === null) return;
1286
+ for (const reaction of reactions) {
1287
+ var flags2 = reaction.f;
1288
+ if ((flags2 & DERIVED) !== 0) {
1289
+ mark(
1290
+ /** @type {Derived} */
1291
+ reaction
1292
+ );
1293
+ } else {
1294
+ var effect = (
1295
+ /** @type {Effect} */
1296
+ reaction
1297
+ );
1298
+ if (flags2 & (ASYNC | BLOCK_EFFECT) && !this.async_deriveds.has(effect)) {
1299
+ this.#maybe_dirty_effects.delete(effect);
1300
+ set_signal_status(effect, DIRTY);
1301
+ this.schedule(effect);
1302
+ }
1303
+ }
1304
+ }
1305
+ };
1306
+ for (const source2 of this.current.keys()) {
1307
+ mark(source2);
1308
+ }
1309
+ this.oncommit(() => batch.discard());
1310
+ batch.#unlink();
1311
+ current_batch = this;
1312
+ this.#process();
1313
+ }
1314
+ /**
1315
+ * @param {Effect[]} effects
1316
+ */
1317
+ #defer_effects(effects) {
1318
+ for (var i = 0; i < effects.length; i += 1) {
1319
+ defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
1320
+ }
1321
+ }
1322
+ /**
1323
+ * Associate a change to a given source with the current
1324
+ * batch, noting its previous and current values
1325
+ * @param {Value} source
1326
+ * @param {any} value
1327
+ * @param {boolean} [is_derived]
1328
+ */
1329
+ capture(source2, value, is_derived = false) {
1330
+ if (source2.v !== UNINITIALIZED && !this.previous.has(source2)) {
1331
+ this.previous.set(source2, source2.v);
1332
+ }
1333
+ if ((source2.f & ERROR_VALUE) === 0) {
1334
+ this.current.set(source2, [value, is_derived]);
1335
+ batch_values?.set(source2, value);
1336
+ }
1337
+ if (!this.is_fork) {
1338
+ source2.v = value;
1339
+ }
1340
+ }
1341
+ activate() {
1342
+ current_batch = this;
1343
+ }
1344
+ deactivate() {
1345
+ current_batch = null;
1346
+ batch_values = null;
1347
+ }
1348
+ flush() {
1349
+ try {
1350
+ if (DEV) ;
1351
+ is_processing = true;
1352
+ current_batch = this;
1353
+ this.#process();
1354
+ } finally {
1355
+ flush_count = 0;
1356
+ last_scheduled_effect = null;
1357
+ collected_effects = null;
1358
+ legacy_updates = null;
1359
+ is_processing = false;
1360
+ current_batch = null;
1361
+ batch_values = null;
1362
+ old_values.clear();
1363
+ }
1364
+ }
1365
+ discard() {
1366
+ for (const fn of this.#discard_callbacks) fn(this);
1367
+ this.#discard_callbacks.clear();
1368
+ for (const deferred2 of this.async_deriveds.values()) {
1369
+ deferred2.reject(OBSOLETE);
1370
+ }
1371
+ this.#unlink();
1372
+ this.#deferred?.resolve();
1373
+ }
1374
+ /**
1375
+ * @param {Effect} effect
1376
+ */
1377
+ register_created_effect(effect) {
1378
+ this.#new_effects.push(effect);
1379
+ }
1380
+ #commit() {
1381
+ for (let batch = first_batch; batch !== null; batch = batch.#next) {
1382
+ var is_earlier = batch.id < this.id;
1383
+ var sources = [];
1384
+ for (const [source3, [value, is_derived]] of this.current) {
1385
+ if (batch.current.has(source3)) {
1386
+ var batch_value = (
1387
+ /** @type {[any, boolean]} */
1388
+ batch.current.get(source3)[0]
1389
+ );
1390
+ if (is_earlier && value !== batch_value) {
1391
+ batch.current.set(source3, [value, is_derived]);
1392
+ } else {
1393
+ continue;
1394
+ }
1395
+ }
1396
+ sources.push(source3);
1397
+ }
1398
+ if (is_earlier) {
1399
+ for (const [effect, deferred2] of this.async_deriveds) {
1400
+ const d = batch.async_deriveds.get(effect);
1401
+ if (d) deferred2.promise.then(d.resolve).catch(d.reject);
1402
+ }
1403
+ }
1404
+ var current = [...batch.current.keys()].filter(
1405
+ (source3) => !/** @type {[any, boolean]} */
1406
+ batch.current.get(source3)[1]
1407
+ );
1408
+ if (!batch.#started || current.length === 0) continue;
1409
+ var others = current.filter((source3) => !this.current.has(source3));
1410
+ if (others.length === 0) {
1411
+ if (is_earlier) {
1412
+ batch.discard();
1413
+ }
1414
+ } else if (sources.length > 0) {
1415
+ if (is_earlier) {
1416
+ for (const unskipped of this.#unskipped_branches) {
1417
+ batch.unskip_effect(unskipped, (e) => {
1418
+ if ((e.f & (BLOCK_EFFECT | ASYNC)) !== 0) {
1419
+ batch.schedule(e);
1420
+ } else {
1421
+ batch.#defer_effects([e]);
1422
+ }
1423
+ });
1424
+ }
1425
+ }
1426
+ batch.activate();
1427
+ var marked = /* @__PURE__ */ new Set();
1428
+ var checked = /* @__PURE__ */ new Map();
1429
+ for (var source2 of sources) {
1430
+ mark_effects(source2, others, marked, checked);
1431
+ }
1432
+ checked = /* @__PURE__ */ new Map();
1433
+ var current_unequal = [...batch.current].filter(([c, v1]) => {
1434
+ const v2 = this.current.get(c);
1435
+ if (!v2) return true;
1436
+ return v2[0] !== v1[0] || v2[1] !== v1[1];
1437
+ }).map(([c]) => c);
1438
+ if (current_unequal.length > 0) {
1439
+ for (const effect of this.#new_effects) {
1440
+ if ((effect.f & (DESTROYED | INERT | EAGER_EFFECT)) === 0 && depends_on(effect, current_unequal, checked)) {
1441
+ if ((effect.f & (ASYNC | BLOCK_EFFECT)) !== 0) {
1442
+ set_signal_status(effect, DIRTY);
1443
+ batch.schedule(effect);
1444
+ } else {
1445
+ batch.#dirty_effects.add(effect);
1446
+ }
1447
+ }
1448
+ }
1449
+ }
1450
+ if (batch.#roots.length > 0 && !batch.#decrement_queued) {
1451
+ batch.apply();
1452
+ for (var root2 of batch.#roots) {
1453
+ batch.#traverse(root2, [], []);
1454
+ }
1455
+ batch.#roots = [];
1456
+ }
1457
+ batch.deactivate();
1458
+ }
1459
+ }
1460
+ }
1461
+ /**
1462
+ * @param {boolean} blocking
1463
+ * @param {Effect} effect
1464
+ */
1465
+ increment(blocking, effect) {
1466
+ this.#pending += 1;
1467
+ if (blocking) {
1468
+ let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
1469
+ this.#blocking_pending.set(effect, blocking_pending_count + 1);
1470
+ }
1471
+ }
1472
+ /**
1473
+ * @param {boolean} blocking
1474
+ * @param {Effect} effect
1475
+ */
1476
+ decrement(blocking, effect) {
1477
+ this.#pending -= 1;
1478
+ if (blocking) {
1479
+ let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
1480
+ if (blocking_pending_count === 1) {
1481
+ this.#blocking_pending.delete(effect);
1482
+ } else {
1483
+ this.#blocking_pending.set(effect, blocking_pending_count - 1);
1484
+ }
1485
+ }
1486
+ if (this.#decrement_queued) return;
1487
+ this.#decrement_queued = true;
1488
+ queue_micro_task(() => {
1489
+ this.#decrement_queued = false;
1490
+ if (this.linked) {
1491
+ this.flush();
1492
+ }
1493
+ });
1494
+ }
1495
+ /**
1496
+ * @param {Set<Effect>} dirty_effects
1497
+ * @param {Set<Effect>} maybe_dirty_effects
1498
+ */
1499
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
1500
+ for (const e of dirty_effects) {
1501
+ this.#dirty_effects.add(e);
1502
+ }
1503
+ for (const e of maybe_dirty_effects) {
1504
+ this.#maybe_dirty_effects.add(e);
1505
+ }
1506
+ dirty_effects.clear();
1507
+ maybe_dirty_effects.clear();
1508
+ }
1509
+ /** @param {(batch: Batch) => void} fn */
1510
+ oncommit(fn) {
1511
+ this.#commit_callbacks.add(fn);
1512
+ }
1513
+ /** @param {(batch: Batch) => void} fn */
1514
+ ondiscard(fn) {
1515
+ this.#discard_callbacks.add(fn);
1516
+ }
1517
+ settled() {
1518
+ return (this.#deferred ??= deferred()).promise;
1519
+ }
1520
+ static ensure() {
1521
+ if (current_batch === null) {
1522
+ const batch = current_batch = new Batch();
1523
+ if (!is_processing && !is_flushing_sync) {
1524
+ queue_micro_task(() => {
1525
+ if (!batch.#started) {
1526
+ batch.flush();
1527
+ }
1528
+ });
1529
+ }
1530
+ }
1531
+ return current_batch;
1532
+ }
1533
+ apply() {
1534
+ {
1535
+ batch_values = null;
1536
+ return;
1537
+ }
1538
+ }
1539
+ /**
1540
+ *
1541
+ * @param {Effect} effect
1542
+ */
1543
+ schedule(effect) {
1544
+ last_scheduled_effect = effect;
1545
+ if (effect.b?.is_pending && (effect.f & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0 && (effect.f & REACTION_RAN) === 0) {
1546
+ effect.b.defer_effect(effect);
1547
+ return;
1548
+ }
1549
+ var e = effect;
1550
+ while (e.parent !== null) {
1551
+ e = e.parent;
1552
+ var flags2 = e.f;
1553
+ if (collected_effects !== null && e === active_effect) {
1554
+ if ((active_reaction === null || (active_reaction.f & DERIVED) === 0) && true) {
1555
+ return;
1556
+ }
1557
+ }
1558
+ if ((flags2 & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
1559
+ if ((flags2 & CLEAN) === 0) {
1560
+ return;
1561
+ }
1562
+ e.f ^= CLEAN;
1563
+ }
1564
+ }
1565
+ this.#roots.push(e);
1566
+ }
1567
+ #unlink() {
1568
+ if (!this.linked) return;
1569
+ var prev = this.#prev;
1570
+ var next2 = this.#next;
1571
+ if (prev === null) {
1572
+ first_batch = next2;
1573
+ } else {
1574
+ prev.#next = next2;
1575
+ }
1576
+ if (next2 === null) {
1577
+ last_batch = prev;
1578
+ } else {
1579
+ next2.#prev = prev;
1580
+ }
1581
+ this.linked = false;
1582
+ }
1583
+ }
1584
+ function flushSync(fn) {
1585
+ var was_flushing_sync = is_flushing_sync;
1586
+ is_flushing_sync = true;
1587
+ try {
1588
+ var result;
1589
+ if (fn) ;
1590
+ while (true) {
1591
+ flush_tasks();
1592
+ if (current_batch === null) {
1593
+ return (
1594
+ /** @type {T} */
1595
+ result
1596
+ );
1597
+ }
1598
+ current_batch.flush();
1599
+ }
1600
+ } finally {
1601
+ is_flushing_sync = was_flushing_sync;
1602
+ }
1603
+ }
1604
+ function infinite_loop_guard() {
1605
+ try {
1606
+ effect_update_depth_exceeded();
1607
+ } catch (error) {
1608
+ invoke_error_boundary(error, last_scheduled_effect);
1609
+ }
1610
+ }
1611
+ let eager_block_effects = null;
1612
+ function flush_queued_effects(effects) {
1613
+ var length = effects.length;
1614
+ if (length === 0) return;
1615
+ var i = 0;
1616
+ while (i < length) {
1617
+ var effect = effects[i++];
1618
+ if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
1619
+ eager_block_effects = /* @__PURE__ */ new Set();
1620
+ update_effect(effect);
1621
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) {
1622
+ unlink_effect(effect);
1623
+ }
1624
+ if (eager_block_effects?.size > 0) {
1625
+ old_values.clear();
1626
+ for (const e of eager_block_effects) {
1627
+ if ((e.f & (DESTROYED | INERT)) !== 0) continue;
1628
+ const ordered_effects = [e];
1629
+ let ancestor = e.parent;
1630
+ while (ancestor !== null) {
1631
+ if (eager_block_effects.has(ancestor)) {
1632
+ eager_block_effects.delete(ancestor);
1633
+ ordered_effects.push(ancestor);
1634
+ }
1635
+ ancestor = ancestor.parent;
1636
+ }
1637
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
1638
+ const e2 = ordered_effects[j];
1639
+ if ((e2.f & (DESTROYED | INERT)) !== 0) continue;
1640
+ update_effect(e2);
1641
+ }
1642
+ }
1643
+ eager_block_effects.clear();
1644
+ }
1645
+ }
1646
+ }
1647
+ eager_block_effects = null;
1648
+ }
1649
+ function mark_effects(value, sources, marked, checked) {
1650
+ if (marked.has(value)) return;
1651
+ marked.add(value);
1652
+ if (value.reactions !== null) {
1653
+ for (const reaction of value.reactions) {
1654
+ const flags2 = reaction.f;
1655
+ if ((flags2 & DERIVED) !== 0) {
1656
+ mark_effects(
1657
+ /** @type {Derived} */
1658
+ reaction,
1659
+ sources,
1660
+ marked,
1661
+ checked
1662
+ );
1663
+ } else if ((flags2 & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags2 & DIRTY) === 0 && depends_on(reaction, sources, checked)) {
1664
+ set_signal_status(reaction, DIRTY);
1665
+ schedule_effect(
1666
+ /** @type {Effect} */
1667
+ reaction
1668
+ );
1669
+ }
1670
+ }
1671
+ }
1672
+ }
1673
+ function depends_on(reaction, sources, checked) {
1674
+ const depends = checked.get(reaction);
1675
+ if (depends !== void 0) return depends;
1676
+ if (reaction.deps !== null) {
1677
+ for (const dep of reaction.deps) {
1678
+ if (includes.call(sources, dep)) {
1679
+ return true;
1680
+ }
1681
+ if ((dep.f & DERIVED) !== 0 && depends_on(
1682
+ /** @type {Derived} */
1683
+ dep,
1684
+ sources,
1685
+ checked
1686
+ )) {
1687
+ checked.set(
1688
+ /** @type {Derived} */
1689
+ dep,
1690
+ true
1691
+ );
1692
+ return true;
1693
+ }
1694
+ }
1695
+ }
1696
+ checked.set(reaction, false);
1697
+ return false;
1698
+ }
1699
+ function schedule_effect(effect) {
1700
+ current_batch.schedule(effect);
1701
+ }
1702
+ function reset_branch(effect, tracked) {
1703
+ if ((effect.f & BRANCH_EFFECT) !== 0 && (effect.f & CLEAN) !== 0) {
1704
+ return;
1705
+ }
1706
+ if ((effect.f & DIRTY) !== 0) {
1707
+ tracked.d.push(effect);
1708
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
1709
+ tracked.m.push(effect);
1710
+ }
1711
+ set_signal_status(effect, CLEAN);
1712
+ var e = effect.first;
1713
+ while (e !== null) {
1714
+ reset_branch(e, tracked);
1715
+ e = e.next;
1716
+ }
1717
+ }
1718
+ function reset_all(effect) {
1719
+ set_signal_status(effect, CLEAN);
1720
+ var e = effect.first;
1721
+ while (e !== null) {
1722
+ reset_all(e);
1723
+ e = e.next;
1724
+ }
1725
+ }
1726
+ let eager_effects = /* @__PURE__ */ new Set();
1727
+ const old_values = /* @__PURE__ */ new Map();
1728
+ let eager_effects_deferred = false;
1729
+ function source(v, stack) {
1730
+ var signal = {
1731
+ f: 0,
1732
+ // TODO ideally we could skip this altogether, but it causes type errors
1733
+ v,
1734
+ reactions: null,
1735
+ equals,
1736
+ rv: 0,
1737
+ wv: 0
1738
+ };
1739
+ return signal;
1740
+ }
1741
+ // @__NO_SIDE_EFFECTS__
1742
+ function state(v, stack) {
1743
+ const s = source(v);
1744
+ push_reaction_value(s);
1745
+ return s;
1746
+ }
1747
+ // @__NO_SIDE_EFFECTS__
1748
+ function mutable_source(initial_value, immutable = false, trackable = true) {
1749
+ const s = source(initial_value);
1750
+ if (!immutable) {
1751
+ s.equals = safe_equals;
1752
+ }
1753
+ return s;
1754
+ }
1755
+ function set(source2, value, should_proxy = false) {
1756
+ if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1757
+ // to ensure we error if state is set inside an inspect effect
1758
+ (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && (current_sources === null || !current_sources.has(source2))) {
1759
+ state_unsafe_mutation();
1760
+ }
1761
+ let new_value = should_proxy ? proxy(value) : value;
1762
+ return internal_set(source2, new_value, legacy_updates);
1763
+ }
1764
+ function internal_set(source2, value, updated_during_traversal = null) {
1765
+ if (!source2.equals(value)) {
1766
+ old_values.set(source2, is_destroying_effect ? value : source2.v);
1767
+ var batch = Batch.ensure();
1768
+ batch.capture(source2, value);
1769
+ if ((source2.f & DERIVED) !== 0) {
1770
+ const derived2 = (
1771
+ /** @type {Derived} */
1772
+ source2
1773
+ );
1774
+ if ((source2.f & DIRTY) !== 0) {
1775
+ execute_derived(derived2);
1776
+ }
1777
+ if (batch_values === null) {
1778
+ update_derived_status(derived2);
1779
+ }
1780
+ }
1781
+ source2.wv = increment_write_version();
1782
+ mark_reactions(source2, DIRTY, updated_during_traversal);
1783
+ if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
1784
+ if (untracked_writes === null) {
1785
+ set_untracked_writes([source2]);
1786
+ } else {
1787
+ untracked_writes.push(source2);
1788
+ }
1789
+ }
1790
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) {
1791
+ flush_eager_effects();
1792
+ }
1793
+ }
1794
+ return value;
1795
+ }
1796
+ function flush_eager_effects() {
1797
+ eager_effects_deferred = false;
1798
+ for (const effect of eager_effects) {
1799
+ if ((effect.f & CLEAN) !== 0) {
1800
+ set_signal_status(effect, MAYBE_DIRTY);
1801
+ }
1802
+ let dirty;
1803
+ try {
1804
+ dirty = is_dirty(effect);
1805
+ } catch {
1806
+ dirty = true;
1807
+ }
1808
+ if (dirty) {
1809
+ update_effect(effect);
1810
+ }
1811
+ }
1812
+ eager_effects.clear();
1813
+ }
1814
+ function increment(source2) {
1815
+ set(source2, source2.v + 1);
1816
+ }
1817
+ function mark_reactions(signal, status, updated_during_traversal) {
1818
+ var reactions = signal.reactions;
1819
+ if (reactions === null) return;
1820
+ var length = reactions.length;
1821
+ for (var i = 0; i < length; i++) {
1822
+ var reaction = reactions[i];
1823
+ var flags2 = reaction.f;
1824
+ var not_dirty = (flags2 & DIRTY) === 0;
1825
+ if (not_dirty) {
1826
+ set_signal_status(reaction, status);
1827
+ }
1828
+ if ((flags2 & EAGER_EFFECT) !== 0) {
1829
+ eager_effects.add(
1830
+ /** @type {Effect} */
1831
+ reaction
1832
+ );
1833
+ } else if ((flags2 & DERIVED) !== 0) {
1834
+ var derived2 = (
1835
+ /** @type {Derived} */
1836
+ reaction
1837
+ );
1838
+ batch_values?.delete(derived2);
1839
+ if ((flags2 & WAS_MARKED) === 0) {
1840
+ if (flags2 & CONNECTED && (active_effect === null || (active_effect.f & REACTION_IS_UPDATING) === 0)) {
1841
+ reaction.f |= WAS_MARKED;
1842
+ }
1843
+ mark_reactions(derived2, MAYBE_DIRTY, updated_during_traversal);
1844
+ }
1845
+ } else if (not_dirty) {
1846
+ var effect = (
1847
+ /** @type {Effect} */
1848
+ reaction
1849
+ );
1850
+ if ((flags2 & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
1851
+ eager_block_effects.add(effect);
1852
+ }
1853
+ if (updated_during_traversal !== null) {
1854
+ updated_during_traversal.push(effect);
1855
+ } else {
1856
+ schedule_effect(effect);
1857
+ }
1858
+ }
1859
+ }
1860
+ }
1861
+ function without_reactive_context(fn) {
1862
+ var previous_reaction = active_reaction;
1863
+ var previous_effect = active_effect;
1864
+ set_active_reaction(null);
1865
+ set_active_effect(null);
1866
+ try {
1867
+ return fn();
1868
+ } finally {
1869
+ set_active_reaction(previous_reaction);
1870
+ set_active_effect(previous_effect);
1871
+ }
1872
+ }
1873
+ let is_updating_effect = false;
1874
+ let is_destroying_effect = false;
1875
+ function set_is_destroying_effect(value) {
1876
+ is_destroying_effect = value;
1877
+ }
1878
+ let active_reaction = null;
1879
+ let untracking = false;
1880
+ function set_active_reaction(reaction) {
1881
+ active_reaction = reaction;
1882
+ }
1883
+ let active_effect = null;
1884
+ function set_active_effect(effect) {
1885
+ active_effect = effect;
1886
+ }
1887
+ let current_sources = null;
1888
+ function push_reaction_value(value) {
1889
+ if (active_reaction !== null && true) {
1890
+ (current_sources ??= /* @__PURE__ */ new Set()).add(value);
1891
+ }
1892
+ }
1893
+ let new_deps = null;
1894
+ let skipped_deps = 0;
1895
+ let untracked_writes = null;
1896
+ function set_untracked_writes(value) {
1897
+ untracked_writes = value;
1898
+ }
1899
+ let write_version = 1;
1900
+ let read_version = 0;
1901
+ let update_version = read_version;
1902
+ function set_update_version(value) {
1903
+ update_version = value;
1904
+ }
1905
+ function increment_write_version() {
1906
+ return ++write_version;
1907
+ }
1908
+ function is_dirty(reaction) {
1909
+ var flags2 = reaction.f;
1910
+ if ((flags2 & DIRTY) !== 0) {
1911
+ return true;
1912
+ }
1913
+ if (flags2 & DERIVED) {
1914
+ reaction.f &= ~WAS_MARKED;
1915
+ }
1916
+ if ((flags2 & MAYBE_DIRTY) !== 0) {
1917
+ var dependencies = (
1918
+ /** @type {Value[]} */
1919
+ reaction.deps
1920
+ );
1921
+ var length = dependencies.length;
1922
+ for (var i = 0; i < length; i++) {
1923
+ var dependency = dependencies[i];
1924
+ if (is_dirty(
1925
+ /** @type {Derived} */
1926
+ dependency
1927
+ )) {
1928
+ update_derived(
1929
+ /** @type {Derived} */
1930
+ dependency
1931
+ );
1932
+ }
1933
+ if (dependency.wv > reaction.wv) {
1934
+ return true;
1935
+ }
1936
+ }
1937
+ if ((flags2 & CONNECTED) !== 0 && // During time traveling we don't want to reset the status so that
1938
+ // traversal of the graph in the other batches still happens
1939
+ batch_values === null) {
1940
+ set_signal_status(reaction, CLEAN);
1941
+ }
1942
+ }
1943
+ return false;
1944
+ }
1945
+ function schedule_possible_effect_self_invalidation(signal, effect, root2 = true) {
1946
+ var reactions = signal.reactions;
1947
+ if (reactions === null) return;
1948
+ if (current_sources !== null && current_sources.has(signal)) {
1949
+ return;
1950
+ }
1951
+ for (var i = 0; i < reactions.length; i++) {
1952
+ var reaction = reactions[i];
1953
+ if ((reaction.f & DERIVED) !== 0) {
1954
+ schedule_possible_effect_self_invalidation(
1955
+ /** @type {Derived} */
1956
+ reaction,
1957
+ effect,
1958
+ false
1959
+ );
1960
+ } else if (effect === reaction) {
1961
+ if (root2) {
1962
+ set_signal_status(reaction, DIRTY);
1963
+ } else if ((reaction.f & CLEAN) !== 0) {
1964
+ set_signal_status(reaction, MAYBE_DIRTY);
1965
+ }
1966
+ schedule_effect(
1967
+ /** @type {Effect} */
1968
+ reaction
1969
+ );
1970
+ }
1971
+ }
1972
+ }
1973
+ function update_reaction(reaction) {
1974
+ var previous_deps = new_deps;
1975
+ var previous_skipped_deps = skipped_deps;
1976
+ var previous_untracked_writes = untracked_writes;
1977
+ var previous_reaction = active_reaction;
1978
+ var previous_sources = current_sources;
1979
+ var previous_component_context = component_context;
1980
+ var previous_untracking = untracking;
1981
+ var previous_update_version = update_version;
1982
+ var flags2 = reaction.f;
1983
+ new_deps = /** @type {null | Value[]} */
1984
+ null;
1985
+ skipped_deps = 0;
1986
+ untracked_writes = null;
1987
+ active_reaction = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
1988
+ current_sources = null;
1989
+ set_component_context(reaction.ctx);
1990
+ untracking = false;
1991
+ update_version = ++read_version;
1992
+ if (reaction.ac !== null) {
1993
+ without_reactive_context(() => {
1994
+ reaction.ac.abort(STALE_REACTION);
1995
+ });
1996
+ reaction.ac = null;
1997
+ }
1998
+ try {
1999
+ reaction.f |= REACTION_IS_UPDATING;
2000
+ var fn = (
2001
+ /** @type {Function} */
2002
+ reaction.fn
2003
+ );
2004
+ var result = fn();
2005
+ reaction.f |= REACTION_RAN;
2006
+ var deps = reaction.deps;
2007
+ var is_fork = current_batch?.is_fork;
2008
+ if (new_deps !== null) {
2009
+ var i;
2010
+ if (!is_fork) {
2011
+ remove_reactions(reaction, skipped_deps);
2012
+ }
2013
+ if (deps !== null && skipped_deps > 0) {
2014
+ deps.length = skipped_deps + new_deps.length;
2015
+ for (i = 0; i < new_deps.length; i++) {
2016
+ deps[skipped_deps + i] = new_deps[i];
2017
+ }
2018
+ } else {
2019
+ reaction.deps = deps = new_deps;
2020
+ }
2021
+ if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {
2022
+ for (i = skipped_deps; i < deps.length; i++) {
2023
+ (deps[i].reactions ??= []).push(reaction);
2024
+ }
2025
+ }
2026
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2027
+ remove_reactions(reaction, skipped_deps);
2028
+ deps.length = skipped_deps;
2029
+ }
2030
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (DERIVED | MAYBE_DIRTY | DIRTY)) === 0) {
2031
+ for (i = 0; i < /** @type {Source[]} */
2032
+ untracked_writes.length; i++) {
2033
+ schedule_possible_effect_self_invalidation(
2034
+ untracked_writes[i],
2035
+ /** @type {Effect} */
2036
+ reaction
2037
+ );
2038
+ }
2039
+ }
2040
+ if (previous_reaction !== null && previous_reaction !== reaction) {
2041
+ read_version++;
2042
+ if (previous_reaction.deps !== null) {
2043
+ for (let i2 = 0; i2 < previous_skipped_deps; i2 += 1) {
2044
+ previous_reaction.deps[i2].rv = read_version;
2045
+ }
2046
+ }
2047
+ if (previous_deps !== null) {
2048
+ for (const dep of previous_deps) {
2049
+ dep.rv = read_version;
2050
+ }
2051
+ }
2052
+ if (untracked_writes !== null) {
2053
+ if (previous_untracked_writes === null) {
2054
+ previous_untracked_writes = untracked_writes;
2055
+ } else {
2056
+ previous_untracked_writes.push(.../** @type {Source[]} */
2057
+ untracked_writes);
2058
+ }
2059
+ }
2060
+ }
2061
+ if ((reaction.f & ERROR_VALUE) !== 0) {
2062
+ reaction.f ^= ERROR_VALUE;
2063
+ }
2064
+ return result;
2065
+ } catch (error) {
2066
+ return handle_error(error);
2067
+ } finally {
2068
+ reaction.f ^= REACTION_IS_UPDATING;
2069
+ new_deps = previous_deps;
2070
+ skipped_deps = previous_skipped_deps;
2071
+ untracked_writes = previous_untracked_writes;
2072
+ active_reaction = previous_reaction;
2073
+ current_sources = previous_sources;
2074
+ set_component_context(previous_component_context);
2075
+ untracking = previous_untracking;
2076
+ update_version = previous_update_version;
2077
+ }
2078
+ }
2079
+ function remove_reaction(signal, dependency) {
2080
+ let reactions = dependency.reactions;
2081
+ if (reactions !== null) {
2082
+ var index = index_of.call(reactions, signal);
2083
+ if (index !== -1) {
2084
+ var new_length = reactions.length - 1;
2085
+ if (new_length === 0) {
2086
+ reactions = dependency.reactions = null;
2087
+ } else {
2088
+ reactions[index] = reactions[new_length];
2089
+ reactions.pop();
2090
+ }
2091
+ }
2092
+ }
2093
+ if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
2094
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
2095
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
2096
+ (new_deps === null || !includes.call(new_deps, dependency))) {
2097
+ var derived2 = (
2098
+ /** @type {Derived} */
2099
+ dependency
2100
+ );
2101
+ if ((derived2.f & CONNECTED) !== 0) {
2102
+ derived2.f ^= CONNECTED;
2103
+ derived2.f &= ~WAS_MARKED;
2104
+ }
2105
+ if (derived2.v !== UNINITIALIZED) {
2106
+ update_derived_status(derived2);
2107
+ }
2108
+ freeze_derived_effects(derived2);
2109
+ remove_reactions(derived2, 0);
2110
+ }
2111
+ }
2112
+ function remove_reactions(signal, start_index) {
2113
+ var dependencies = signal.deps;
2114
+ if (dependencies === null) return;
2115
+ for (var i = start_index; i < dependencies.length; i++) {
2116
+ remove_reaction(signal, dependencies[i]);
2117
+ }
2118
+ }
2119
+ function update_effect(effect) {
2120
+ var flags2 = effect.f;
2121
+ if ((flags2 & DESTROYED) !== 0) {
2122
+ return;
2123
+ }
2124
+ set_signal_status(effect, CLEAN);
2125
+ var previous_effect = active_effect;
2126
+ var was_updating_effect = is_updating_effect;
2127
+ active_effect = effect;
2128
+ is_updating_effect = true;
2129
+ try {
2130
+ if ((flags2 & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) {
2131
+ destroy_block_effect_children(effect);
2132
+ } else {
2133
+ destroy_effect_children(effect);
2134
+ }
2135
+ execute_effect_teardown(effect);
2136
+ var teardown = update_reaction(effect);
2137
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2138
+ effect.wv = write_version;
2139
+ var dep;
2140
+ if (DEV && tracing_mode_flag && (effect.f & DIRTY) !== 0 && effect.deps !== null) ;
2141
+ } finally {
2142
+ is_updating_effect = was_updating_effect;
2143
+ active_effect = previous_effect;
2144
+ }
2145
+ }
2146
+ function get(signal) {
2147
+ var flags2 = signal.f;
2148
+ var is_derived = (flags2 & DERIVED) !== 0;
2149
+ if (active_reaction !== null && !untracking) {
2150
+ var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
2151
+ if (!destroyed && (current_sources === null || !current_sources.has(signal))) {
2152
+ var deps = active_reaction.deps;
2153
+ if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
2154
+ if (signal.rv < read_version) {
2155
+ signal.rv = read_version;
2156
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
2157
+ skipped_deps++;
2158
+ } else if (new_deps === null) {
2159
+ new_deps = [signal];
2160
+ } else {
2161
+ new_deps.push(signal);
2162
+ }
2163
+ }
2164
+ } else {
2165
+ active_reaction.deps ??= [];
2166
+ if (!includes.call(active_reaction.deps, signal)) {
2167
+ active_reaction.deps.push(signal);
2168
+ }
2169
+ var reactions = signal.reactions;
2170
+ if (reactions === null) {
2171
+ signal.reactions = [active_reaction];
2172
+ } else if (!includes.call(reactions, active_reaction)) {
2173
+ reactions.push(active_reaction);
2174
+ }
2175
+ }
2176
+ }
2177
+ }
2178
+ if (is_destroying_effect && old_values.has(signal)) {
2179
+ return old_values.get(signal);
2180
+ }
2181
+ if (is_derived) {
2182
+ var derived2 = (
2183
+ /** @type {Derived} */
2184
+ signal
2185
+ );
2186
+ if (is_destroying_effect) {
2187
+ var value = derived2.v;
2188
+ if ((derived2.f & CLEAN) === 0 && derived2.reactions !== null || depends_on_old_values(derived2)) {
2189
+ value = execute_derived(derived2);
2190
+ }
2191
+ old_values.set(derived2, value);
2192
+ return value;
2193
+ }
2194
+ var should_connect = (derived2.f & CONNECTED) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & CONNECTED) !== 0);
2195
+ var is_new = (derived2.f & REACTION_RAN) === 0;
2196
+ if (is_dirty(derived2)) {
2197
+ if (should_connect) {
2198
+ derived2.f |= CONNECTED;
2199
+ }
2200
+ update_derived(derived2);
2201
+ }
2202
+ if (should_connect && !is_new) {
2203
+ unfreeze_derived_effects(derived2);
2204
+ reconnect(derived2);
2205
+ }
2206
+ }
2207
+ if (batch_values?.has(signal)) {
2208
+ return batch_values.get(signal);
2209
+ }
2210
+ if ((signal.f & ERROR_VALUE) !== 0) {
2211
+ throw signal.v;
2212
+ }
2213
+ return signal.v;
2214
+ }
2215
+ function reconnect(derived2) {
2216
+ derived2.f |= CONNECTED;
2217
+ if (derived2.deps === null) return;
2218
+ for (const dep of derived2.deps) {
2219
+ (dep.reactions ??= []).push(derived2);
2220
+ if ((dep.f & DERIVED) !== 0 && (dep.f & CONNECTED) === 0) {
2221
+ unfreeze_derived_effects(
2222
+ /** @type {Derived} */
2223
+ dep
2224
+ );
2225
+ reconnect(
2226
+ /** @type {Derived} */
2227
+ dep
2228
+ );
2229
+ }
2230
+ }
2231
+ }
2232
+ function depends_on_old_values(derived2) {
2233
+ if (derived2.v === UNINITIALIZED) return true;
2234
+ if (derived2.deps === null) return false;
2235
+ for (const dep of derived2.deps) {
2236
+ if (old_values.has(dep)) {
2237
+ return true;
2238
+ }
2239
+ if ((dep.f & DERIVED) !== 0 && depends_on_old_values(
2240
+ /** @type {Derived} */
2241
+ dep
2242
+ )) {
2243
+ return true;
2244
+ }
2245
+ }
2246
+ return false;
2247
+ }
2248
+ function untrack(fn) {
2249
+ var previous_untracking = untracking;
2250
+ try {
2251
+ untracking = true;
2252
+ return fn();
2253
+ } finally {
2254
+ untracking = previous_untracking;
2255
+ }
2256
+ }
2257
+ function push_effect(effect, parent_effect) {
2258
+ var parent_last = parent_effect.last;
2259
+ if (parent_last === null) {
2260
+ parent_effect.last = parent_effect.first = effect;
2261
+ } else {
2262
+ parent_last.next = effect;
2263
+ effect.prev = parent_last;
2264
+ parent_effect.last = effect;
2265
+ }
2266
+ }
2267
+ function create_effect(type, fn) {
2268
+ var parent = active_effect;
2269
+ if (parent !== null && (parent.f & INERT) !== 0) {
2270
+ type |= INERT;
2271
+ }
2272
+ var effect = {
2273
+ ctx: component_context,
2274
+ deps: null,
2275
+ nodes: null,
2276
+ f: type | DIRTY | CONNECTED,
2277
+ first: null,
2278
+ fn,
2279
+ last: null,
2280
+ next: null,
2281
+ parent,
2282
+ b: parent && parent.b,
2283
+ prev: null,
2284
+ teardown: null,
2285
+ wv: 0,
2286
+ ac: null
2287
+ };
2288
+ current_batch?.register_created_effect(effect);
2289
+ var e = effect;
2290
+ if ((type & EFFECT) !== 0) {
2291
+ if (collected_effects !== null) {
2292
+ collected_effects.push(effect);
2293
+ } else {
2294
+ Batch.ensure().schedule(effect);
2295
+ }
2296
+ } else if (fn !== null) {
2297
+ try {
2298
+ update_effect(effect);
2299
+ } catch (e2) {
2300
+ destroy_effect(effect);
2301
+ throw e2;
2302
+ }
2303
+ if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && // either `null`, or a singular child
2304
+ (e.f & EFFECT_PRESERVED) === 0) {
2305
+ e = e.first;
2306
+ if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
2307
+ e.f |= EFFECT_TRANSPARENT;
2308
+ }
2309
+ }
2310
+ }
2311
+ if (e !== null) {
2312
+ e.parent = parent;
2313
+ if (parent !== null) {
2314
+ push_effect(e, parent);
2315
+ }
2316
+ if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
2317
+ var derived2 = (
2318
+ /** @type {Derived} */
2319
+ active_reaction
2320
+ );
2321
+ (derived2.effects ??= []).push(e);
2322
+ }
2323
+ }
2324
+ return effect;
2325
+ }
2326
+ function effect_tracking() {
2327
+ return active_reaction !== null && !untracking;
2328
+ }
2329
+ function create_user_effect(fn) {
2330
+ return create_effect(EFFECT | USER_EFFECT, fn);
2331
+ }
2332
+ function component_root(fn) {
2333
+ Batch.ensure();
2334
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn);
2335
+ return (options = {}) => {
2336
+ return new Promise((fulfil) => {
2337
+ if (options.outro) {
2338
+ pause_effect(effect, () => {
2339
+ destroy_effect(effect);
2340
+ fulfil(void 0);
2341
+ });
2342
+ } else {
2343
+ destroy_effect(effect);
2344
+ fulfil(void 0);
2345
+ }
2346
+ });
2347
+ };
2348
+ }
2349
+ function render_effect(fn, flags2 = 0) {
2350
+ return create_effect(RENDER_EFFECT | flags2, fn);
2351
+ }
2352
+ function block(fn, flags2 = 0) {
2353
+ var effect = create_effect(BLOCK_EFFECT | flags2, fn);
2354
+ return effect;
2355
+ }
2356
+ function branch(fn) {
2357
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn);
2358
+ }
2359
+ function execute_effect_teardown(effect) {
2360
+ var teardown = effect.teardown;
2361
+ if (teardown !== null) {
2362
+ const previously_destroying_effect = is_destroying_effect;
2363
+ const previous_reaction = active_reaction;
2364
+ set_is_destroying_effect(true);
2365
+ set_active_reaction(null);
2366
+ try {
2367
+ teardown.call(null);
2368
+ } finally {
2369
+ set_is_destroying_effect(previously_destroying_effect);
2370
+ set_active_reaction(previous_reaction);
2371
+ }
2372
+ }
2373
+ }
2374
+ function destroy_effect_children(signal, remove_dom = false) {
2375
+ var effect = signal.first;
2376
+ signal.first = signal.last = null;
2377
+ while (effect !== null) {
2378
+ const controller = effect.ac;
2379
+ if (controller !== null) {
2380
+ without_reactive_context(() => {
2381
+ controller.abort(STALE_REACTION);
2382
+ });
2383
+ }
2384
+ var next2 = effect.next;
2385
+ if ((effect.f & ROOT_EFFECT) !== 0) {
2386
+ effect.parent = null;
2387
+ } else {
2388
+ destroy_effect(effect, remove_dom);
2389
+ }
2390
+ effect = next2;
2391
+ }
2392
+ }
2393
+ function destroy_block_effect_children(signal) {
2394
+ var effect = signal.first;
2395
+ while (effect !== null) {
2396
+ var next2 = effect.next;
2397
+ if ((effect.f & BRANCH_EFFECT) === 0) {
2398
+ destroy_effect(effect);
2399
+ }
2400
+ effect = next2;
2401
+ }
2402
+ }
2403
+ function destroy_effect(effect, remove_dom = true) {
2404
+ var removed = false;
2405
+ if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
2406
+ remove_effect_dom(
2407
+ effect.nodes.start,
2408
+ /** @type {TemplateNode} */
2409
+ effect.nodes.end
2410
+ );
2411
+ removed = true;
2412
+ }
2413
+ effect.f |= DESTROYING;
2414
+ destroy_effect_children(effect, remove_dom && !removed);
2415
+ remove_reactions(effect, 0);
2416
+ var transitions = effect.nodes && effect.nodes.t;
2417
+ if (transitions !== null) {
2418
+ for (const transition of transitions) {
2419
+ transition.stop();
2420
+ }
2421
+ }
2422
+ execute_effect_teardown(effect);
2423
+ effect.f ^= DESTROYING;
2424
+ effect.f |= DESTROYED;
2425
+ var parent = effect.parent;
2426
+ if (parent !== null && parent.first !== null) {
2427
+ unlink_effect(effect);
2428
+ }
2429
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = effect.b = null;
2430
+ }
2431
+ function remove_effect_dom(node, end) {
2432
+ while (node !== null) {
2433
+ var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2434
+ node.remove();
2435
+ node = next2;
2436
+ }
2437
+ }
2438
+ function unlink_effect(effect) {
2439
+ var parent = effect.parent;
2440
+ var prev = effect.prev;
2441
+ var next2 = effect.next;
2442
+ if (prev !== null) prev.next = next2;
2443
+ if (next2 !== null) next2.prev = prev;
2444
+ if (parent !== null) {
2445
+ if (parent.first === effect) parent.first = next2;
2446
+ if (parent.last === effect) parent.last = prev;
2447
+ }
2448
+ }
2449
+ function pause_effect(effect, callback, destroy = true) {
2450
+ var transitions = [];
2451
+ pause_children(effect, transitions, true);
2452
+ var fn = () => {
2453
+ if (destroy) destroy_effect(effect);
2454
+ if (callback) callback();
2455
+ };
2456
+ var remaining = transitions.length;
2457
+ if (remaining > 0) {
2458
+ var check = () => --remaining || fn();
2459
+ for (var transition of transitions) {
2460
+ transition.out(check);
2461
+ }
2462
+ } else {
2463
+ fn();
2464
+ }
2465
+ }
2466
+ function pause_children(effect, transitions, local) {
2467
+ if ((effect.f & INERT) !== 0) return;
2468
+ effect.f ^= INERT;
2469
+ var t = effect.nodes && effect.nodes.t;
2470
+ if (t !== null) {
2471
+ for (const transition of t) {
2472
+ if (transition.is_global || local) {
2473
+ transitions.push(transition);
2474
+ }
2475
+ }
2476
+ }
2477
+ var child = effect.first;
2478
+ while (child !== null) {
2479
+ var sibling = child.next;
2480
+ if ((child.f & ROOT_EFFECT) === 0) {
2481
+ var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || // If this is a branch effect without a block effect parent,
2482
+ // it means the parent block effect was pruned. In that case,
2483
+ // transparency information was transferred to the branch effect.
2484
+ (child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0;
2485
+ pause_children(child, transitions, transparent ? local : false);
2486
+ }
2487
+ child = sibling;
2488
+ }
2489
+ }
2490
+ function move_effect(effect, fragment) {
2491
+ if (!effect.nodes) return;
2492
+ var node = effect.nodes.start;
2493
+ var end = effect.nodes.end;
2494
+ while (node !== null) {
2495
+ var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
2496
+ fragment.append(node);
2497
+ node = next2;
2498
+ }
2499
+ }
2500
+ const event_symbol = /* @__PURE__ */ Symbol("events");
2501
+ const all_registered_events = /* @__PURE__ */ new Set();
2502
+ const root_event_handles = /* @__PURE__ */ new Set();
2503
+ let last_propagated_event = null;
2504
+ function handle_event_propagation(event) {
2505
+ var handler_element = this;
2506
+ var owner_document = (
2507
+ /** @type {Node} */
2508
+ handler_element.ownerDocument
2509
+ );
2510
+ var event_name = event.type;
2511
+ var path = event.composedPath?.() || [];
2512
+ var current_target = (
2513
+ /** @type {null | Element} */
2514
+ path[0] || event.target
2515
+ );
2516
+ last_propagated_event = event;
2517
+ var path_idx = 0;
2518
+ var handled_at = last_propagated_event === event && event[event_symbol];
2519
+ if (handled_at) {
2520
+ var at_idx = path.indexOf(handled_at);
2521
+ if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
2522
+ window)) {
2523
+ event[event_symbol] = handler_element;
2524
+ return;
2525
+ }
2526
+ var handler_idx = path.indexOf(handler_element);
2527
+ if (handler_idx === -1) {
2528
+ return;
2529
+ }
2530
+ if (at_idx <= handler_idx) {
2531
+ path_idx = at_idx;
2532
+ }
2533
+ }
2534
+ current_target = /** @type {Element} */
2535
+ path[path_idx] || event.target;
2536
+ if (current_target === handler_element) return;
2537
+ define_property(event, "currentTarget", {
2538
+ configurable: true,
2539
+ get() {
2540
+ return current_target || owner_document;
2541
+ }
2542
+ });
2543
+ var previous_reaction = active_reaction;
2544
+ var previous_effect = active_effect;
2545
+ set_active_reaction(null);
2546
+ set_active_effect(null);
2547
+ try {
2548
+ var throw_error;
2549
+ var other_errors = [];
2550
+ while (current_target !== null) {
2551
+ if (current_target === handler_element) break;
2552
+ try {
2553
+ var delegated = current_target[event_symbol]?.[event_name];
2554
+ if (delegated != null && (!/** @type {any} */
2555
+ current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
2556
+ // -> the target could not have been disabled because it emits the event in the first place
2557
+ event.target === current_target)) {
2558
+ delegated.call(current_target, event);
2559
+ }
2560
+ } catch (error) {
2561
+ if (throw_error) {
2562
+ other_errors.push(error);
2563
+ } else {
2564
+ throw_error = error;
2565
+ }
2566
+ }
2567
+ if (event.cancelBubble) break;
2568
+ path_idx++;
2569
+ current_target = path_idx < path.length ? (
2570
+ /** @type {Element} */
2571
+ path[path_idx]
2572
+ ) : null;
2573
+ }
2574
+ if (throw_error) {
2575
+ for (let error of other_errors) {
2576
+ queueMicrotask(() => {
2577
+ throw error;
2578
+ });
2579
+ }
2580
+ throw throw_error;
2581
+ }
2582
+ } finally {
2583
+ event[event_symbol] = handler_element;
2584
+ delete event.currentTarget;
2585
+ set_active_reaction(previous_reaction);
2586
+ set_active_effect(previous_effect);
2587
+ }
2588
+ }
2589
+ function assign_nodes(start, end) {
2590
+ var effect = (
2591
+ /** @type {Effect} */
2592
+ active_effect
2593
+ );
2594
+ if (effect.nodes === null) {
2595
+ effect.nodes = { start, end, a: null, t: null };
2596
+ }
2597
+ }
2598
+ function mount(component, options) {
2599
+ return _mount(component, options);
2600
+ }
2601
+ function hydrate(component, options) {
2602
+ init_operations();
2603
+ options.intro = options.intro ?? false;
2604
+ const target = options.target;
2605
+ const was_hydrating = hydrating;
2606
+ const previous_hydrate_node = hydrate_node;
2607
+ try {
2608
+ var anchor = /* @__PURE__ */ get_first_child(target);
2609
+ while (anchor && (anchor.nodeType !== COMMENT_NODE || /** @type {Comment} */
2610
+ anchor.data !== HYDRATION_START)) {
2611
+ anchor = /* @__PURE__ */ get_next_sibling(anchor);
2612
+ }
2613
+ if (!anchor) {
2614
+ throw HYDRATION_ERROR;
2615
+ }
2616
+ set_hydrating(true);
2617
+ set_hydrate_node(
2618
+ /** @type {Comment} */
2619
+ anchor
2620
+ );
2621
+ const instance = _mount(component, { ...options, anchor });
2622
+ set_hydrating(false);
2623
+ return (
2624
+ /** @type {Exports} */
2625
+ instance
2626
+ );
2627
+ } catch (error) {
2628
+ if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) {
2629
+ throw error;
2630
+ }
2631
+ if (error !== HYDRATION_ERROR) {
2632
+ console.warn("Failed to hydrate: ", error);
2633
+ }
2634
+ if (options.recover === false) {
2635
+ hydration_failed();
2636
+ }
2637
+ init_operations();
2638
+ clear_text_content(target);
2639
+ set_hydrating(false);
2640
+ return mount(component, options);
2641
+ } finally {
2642
+ set_hydrating(was_hydrating);
2643
+ set_hydrate_node(previous_hydrate_node);
2644
+ }
2645
+ }
2646
+ const listeners = /* @__PURE__ */ new Map();
2647
+ function _mount(Component, { target, anchor, props = {}, events, context, intro = true, transformError }) {
2648
+ init_operations();
2649
+ var component = void 0;
2650
+ var unmount2 = component_root(() => {
2651
+ var anchor_node = anchor ?? target.appendChild(create_text());
2652
+ boundary(
2653
+ /** @type {TemplateNode} */
2654
+ anchor_node,
2655
+ {
2656
+ pending: () => {
2657
+ }
2658
+ },
2659
+ (anchor_node2) => {
2660
+ push({});
2661
+ var ctx = (
2662
+ /** @type {ComponentContext} */
2663
+ component_context
2664
+ );
2665
+ if (context) ctx.c = context;
2666
+ if (events) {
2667
+ props.$$events = events;
2668
+ }
2669
+ if (hydrating) {
2670
+ assign_nodes(
2671
+ /** @type {TemplateNode} */
2672
+ anchor_node2,
2673
+ null
2674
+ );
2675
+ }
2676
+ component = Component(anchor_node2, props) || {};
2677
+ if (hydrating) {
2678
+ active_effect.nodes.end = hydrate_node;
2679
+ if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
2680
+ hydrate_node.data !== HYDRATION_END) {
2681
+ hydration_mismatch();
2682
+ throw HYDRATION_ERROR;
2683
+ }
2684
+ }
2685
+ pop();
2686
+ },
2687
+ transformError
2688
+ );
2689
+ var registered_events = /* @__PURE__ */ new Set();
2690
+ var event_handle = (events2) => {
2691
+ for (var i = 0; i < events2.length; i++) {
2692
+ var event_name = events2[i];
2693
+ if (registered_events.has(event_name)) continue;
2694
+ registered_events.add(event_name);
2695
+ var passive = is_passive_event(event_name);
2696
+ for (const node of [target, document]) {
2697
+ var counts = listeners.get(node);
2698
+ if (counts === void 0) {
2699
+ counts = /* @__PURE__ */ new Map();
2700
+ listeners.set(node, counts);
2701
+ }
2702
+ var count = counts.get(event_name);
2703
+ if (count === void 0) {
2704
+ node.addEventListener(event_name, handle_event_propagation, { passive });
2705
+ counts.set(event_name, 1);
2706
+ } else {
2707
+ counts.set(event_name, count + 1);
2708
+ }
2709
+ }
2710
+ }
2711
+ };
2712
+ event_handle(array_from(all_registered_events));
2713
+ root_event_handles.add(event_handle);
2714
+ return () => {
2715
+ for (var event_name of registered_events) {
2716
+ for (const node of [target, document]) {
2717
+ var counts = (
2718
+ /** @type {Map<string, number>} */
2719
+ listeners.get(node)
2720
+ );
2721
+ var count = (
2722
+ /** @type {number} */
2723
+ counts.get(event_name)
2724
+ );
2725
+ if (--count == 0) {
2726
+ node.removeEventListener(event_name, handle_event_propagation);
2727
+ counts.delete(event_name);
2728
+ if (counts.size === 0) {
2729
+ listeners.delete(node);
2730
+ }
2731
+ } else {
2732
+ counts.set(event_name, count);
2733
+ }
2734
+ }
2735
+ }
2736
+ root_event_handles.delete(event_handle);
2737
+ if (anchor_node !== anchor) {
2738
+ anchor_node.parentNode?.removeChild(anchor_node);
2739
+ }
2740
+ };
2741
+ });
2742
+ mounted_components.set(component, unmount2);
2743
+ return component;
2744
+ }
2745
+ let mounted_components = /* @__PURE__ */ new WeakMap();
2746
+ function unmount(component, options) {
2747
+ const fn = mounted_components.get(component);
2748
+ if (fn) {
2749
+ mounted_components.delete(component);
2750
+ return fn(options);
2751
+ }
2752
+ return Promise.resolve();
2753
+ }
2754
+ function asClassComponent$1(component) {
2755
+ return class extends Svelte4Component {
2756
+ /** @param {any} options */
2757
+ constructor(options) {
2758
+ super({
2759
+ component,
2760
+ ...options
2761
+ });
2762
+ }
2763
+ };
2764
+ }
2765
+ class Svelte4Component {
2766
+ /** @type {any} */
2767
+ #events;
2768
+ /** @type {Record<string, any>} */
2769
+ #instance;
2770
+ /**
2771
+ * @param {ComponentConstructorOptions & {
2772
+ * component: any;
2773
+ * }} options
2774
+ */
2775
+ constructor(options) {
2776
+ var sources = /* @__PURE__ */ new Map();
2777
+ var add_source = (key, value) => {
2778
+ var s = /* @__PURE__ */ mutable_source(value, false, false);
2779
+ sources.set(key, s);
2780
+ return s;
2781
+ };
2782
+ const props = new Proxy(
2783
+ { ...options.props || {}, $$events: {} },
2784
+ {
2785
+ get(target, prop) {
2786
+ return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
2787
+ },
2788
+ has(target, prop) {
2789
+ if (prop === LEGACY_PROPS) return true;
2790
+ get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
2791
+ return Reflect.has(target, prop);
2792
+ },
2793
+ set(target, prop, value) {
2794
+ set(sources.get(prop) ?? add_source(prop, value), value);
2795
+ return Reflect.set(target, prop, value);
2796
+ }
2797
+ }
2798
+ );
2799
+ this.#instance = (options.hydrate ? hydrate : mount)(options.component, {
2800
+ target: options.target,
2801
+ anchor: options.anchor,
2802
+ props,
2803
+ context: options.context,
2804
+ intro: options.intro ?? false,
2805
+ recover: options.recover,
2806
+ transformError: options.transformError
2807
+ });
2808
+ if (!options?.props?.$$host || options.sync === false) {
2809
+ flushSync();
2810
+ }
2811
+ this.#events = props.$$events;
2812
+ for (const key of Object.keys(this.#instance)) {
2813
+ if (key === "$set" || key === "$destroy" || key === "$on") continue;
2814
+ define_property(this, key, {
2815
+ get() {
2816
+ return this.#instance[key];
2817
+ },
2818
+ /** @param {any} value */
2819
+ set(value) {
2820
+ this.#instance[key] = value;
2821
+ },
2822
+ enumerable: true
2823
+ });
2824
+ }
2825
+ this.#instance.$set = /** @param {Record<string, any>} next */
2826
+ (next2) => {
2827
+ Object.assign(props, next2);
2828
+ };
2829
+ this.#instance.$destroy = () => {
2830
+ unmount(this.#instance);
2831
+ };
2832
+ }
2833
+ /** @param {Record<string, any>} props */
2834
+ $set(props) {
2835
+ this.#instance.$set(props);
2836
+ }
2837
+ /**
2838
+ * @param {string} event
2839
+ * @param {(...args: any[]) => any} callback
2840
+ * @returns {any}
2841
+ */
2842
+ $on(event, callback) {
2843
+ this.#events[event] = this.#events[event] || [];
2844
+ const cb = (...args) => callback.call(this, ...args);
2845
+ this.#events[event].push(cb);
2846
+ return () => {
2847
+ this.#events[event] = this.#events[event].filter(
2848
+ /** @param {any} fn */
2849
+ (fn) => fn !== cb
2850
+ );
2851
+ };
2852
+ }
2853
+ $destroy() {
2854
+ this.#instance.$destroy();
2855
+ }
2856
+ }
2857
+ function asClassComponent(component) {
2858
+ const component_constructor = asClassComponent$1(component);
2859
+ const _render = (props, { context, csp, transformError } = {}) => {
2860
+ const result = render(component, { props, context, csp, transformError });
2861
+ const munged = Object.defineProperties(
2862
+ /** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */
2863
+ {},
2864
+ {
2865
+ css: {
2866
+ value: { code: "", map: null }
2867
+ },
2868
+ head: {
2869
+ get: () => result.head
2870
+ },
2871
+ html: {
2872
+ get: () => result.body
2873
+ },
2874
+ then: {
2875
+ /**
2876
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
2877
+ *
2878
+ * @template TResult1
2879
+ * @template [TResult2=never]
2880
+ * @param { (value: LegacyRenderResult) => TResult1 } onfulfilled
2881
+ * @param { (reason: unknown) => TResult2 } onrejected
2882
+ */
2883
+ value: (onfulfilled, onrejected) => {
2884
+ {
2885
+ const user_result = onfulfilled({
2886
+ css: munged.css,
2887
+ head: munged.head,
2888
+ html: munged.html
2889
+ });
2890
+ return Promise.resolve(user_result);
2891
+ }
2892
+ }
2893
+ }
2894
+ }
2895
+ );
2896
+ return munged;
2897
+ };
2898
+ component_constructor.render = _render;
2899
+ return component_constructor;
2900
+ }
2901
+ function Root($$renderer, $$props) {
2902
+ $$renderer.component(($$renderer2) => {
2903
+ let {
2904
+ stores,
2905
+ page,
2906
+ constructors,
2907
+ components = [],
2908
+ form,
2909
+ data_0 = null,
2910
+ data_1 = null
2911
+ } = $$props;
2912
+ {
2913
+ setContext("__svelte__", stores);
2914
+ }
2915
+ {
2916
+ stores.page.set(page);
2917
+ }
2918
+ const Pyramid_1 = derived(() => constructors[1]);
2919
+ if (constructors[1]) {
2920
+ $$renderer2.push("<!--[0-->");
2921
+ const Pyramid_0 = constructors[0];
2922
+ if (Pyramid_0) {
2923
+ $$renderer2.push("<!--[-->");
2924
+ Pyramid_0($$renderer2, {
2925
+ data: data_0,
2926
+ form,
2927
+ params: page.params,
2928
+ children: ($$renderer3) => {
2929
+ if (Pyramid_1()) {
2930
+ $$renderer3.push("<!--[-->");
2931
+ Pyramid_1()($$renderer3, { data: data_1, form, params: page.params });
2932
+ $$renderer3.push("<!--]-->");
2933
+ } else {
2934
+ $$renderer3.push("<!--[!-->");
2935
+ $$renderer3.push("<!--]-->");
2936
+ }
2937
+ },
2938
+ $$slots: { default: true }
2939
+ });
2940
+ $$renderer2.push("<!--]-->");
2941
+ } else {
2942
+ $$renderer2.push("<!--[!-->");
2943
+ $$renderer2.push("<!--]-->");
2944
+ }
2945
+ } else {
2946
+ $$renderer2.push("<!--[-1-->");
2947
+ const Pyramid_0 = constructors[0];
2948
+ if (Pyramid_0) {
2949
+ $$renderer2.push("<!--[-->");
2950
+ Pyramid_0($$renderer2, { data: data_0, form, params: page.params });
2951
+ $$renderer2.push("<!--]-->");
2952
+ } else {
2953
+ $$renderer2.push("<!--[!-->");
2954
+ $$renderer2.push("<!--]-->");
2955
+ }
2956
+ }
2957
+ $$renderer2.push(`<!--]--> `);
2958
+ {
2959
+ $$renderer2.push("<!--[-1-->");
2960
+ }
2961
+ $$renderer2.push(`<!--]-->`);
2962
+ });
2963
+ }
2964
+ const root = asClassComponent(Root);
2965
+
2966
+ export { root as r, safe_not_equal as s };
2967
+ //# sourceMappingURL=root.js-DO1m-gJA.js.map