@agent-profile/web 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +110 -0
  2. package/build/client/_app/immutable/assets/0.BG6jUcBX.css +1 -0
  3. package/build/client/_app/immutable/assets/0.BG6jUcBX.css.br +0 -0
  4. package/build/client/_app/immutable/assets/0.BG6jUcBX.css.gz +0 -0
  5. package/build/client/_app/immutable/chunks/B-io8J2C.js +1 -0
  6. package/build/client/_app/immutable/chunks/B-io8J2C.js.br +2 -0
  7. package/build/client/_app/immutable/chunks/B-io8J2C.js.gz +0 -0
  8. package/build/client/_app/immutable/chunks/BFYQcBYR.js +1 -0
  9. package/build/client/_app/immutable/chunks/BFYQcBYR.js.br +0 -0
  10. package/build/client/_app/immutable/chunks/BFYQcBYR.js.gz +0 -0
  11. package/build/client/_app/immutable/chunks/D5BQ10GJ.js +3 -0
  12. package/build/client/_app/immutable/chunks/D5BQ10GJ.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/D5BQ10GJ.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/DAWBIq3g.js +2 -0
  15. package/build/client/_app/immutable/chunks/DAWBIq3g.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/DAWBIq3g.js.gz +0 -0
  17. package/build/client/_app/immutable/chunks/DCJP-V9E.js +3 -0
  18. package/build/client/_app/immutable/chunks/DCJP-V9E.js.br +0 -0
  19. package/build/client/_app/immutable/chunks/DCJP-V9E.js.gz +0 -0
  20. package/build/client/_app/immutable/chunks/I8rQr1kY.js +1 -0
  21. package/build/client/_app/immutable/chunks/I8rQr1kY.js.br +1 -0
  22. package/build/client/_app/immutable/chunks/I8rQr1kY.js.gz +0 -0
  23. package/build/client/_app/immutable/chunks/SOrpfga1.js +1 -0
  24. package/build/client/_app/immutable/chunks/SOrpfga1.js.br +0 -0
  25. package/build/client/_app/immutable/chunks/SOrpfga1.js.gz +0 -0
  26. package/build/client/_app/immutable/chunks/rbd2FHQ6.js +1 -0
  27. package/build/client/_app/immutable/chunks/rbd2FHQ6.js.br +2 -0
  28. package/build/client/_app/immutable/chunks/rbd2FHQ6.js.gz +0 -0
  29. package/build/client/_app/immutable/entry/app.wvdb3njx.js +2 -0
  30. package/build/client/_app/immutable/entry/app.wvdb3njx.js.br +0 -0
  31. package/build/client/_app/immutable/entry/app.wvdb3njx.js.gz +0 -0
  32. package/build/client/_app/immutable/entry/start.CYyClicm.js +1 -0
  33. package/build/client/_app/immutable/entry/start.CYyClicm.js.br +1 -0
  34. package/build/client/_app/immutable/entry/start.CYyClicm.js.gz +0 -0
  35. package/build/client/_app/immutable/nodes/0.DI161f18.js +1 -0
  36. package/build/client/_app/immutable/nodes/0.DI161f18.js.br +0 -0
  37. package/build/client/_app/immutable/nodes/0.DI161f18.js.gz +0 -0
  38. package/build/client/_app/immutable/nodes/1.CZb1wh8q.js +1 -0
  39. package/build/client/_app/immutable/nodes/1.CZb1wh8q.js.br +3 -0
  40. package/build/client/_app/immutable/nodes/1.CZb1wh8q.js.gz +0 -0
  41. package/build/client/_app/immutable/nodes/10.BOQgahuX.js +2 -0
  42. package/build/client/_app/immutable/nodes/10.BOQgahuX.js.br +0 -0
  43. package/build/client/_app/immutable/nodes/10.BOQgahuX.js.gz +0 -0
  44. package/build/client/_app/immutable/nodes/11.BjwWla8T.js +1 -0
  45. package/build/client/_app/immutable/nodes/11.BjwWla8T.js.br +0 -0
  46. package/build/client/_app/immutable/nodes/11.BjwWla8T.js.gz +0 -0
  47. package/build/client/_app/immutable/nodes/2.BmqkJNGt.js +9 -0
  48. package/build/client/_app/immutable/nodes/2.BmqkJNGt.js.br +0 -0
  49. package/build/client/_app/immutable/nodes/2.BmqkJNGt.js.gz +0 -0
  50. package/build/client/_app/immutable/nodes/3.NnDkXnSG.js +2 -0
  51. package/build/client/_app/immutable/nodes/3.NnDkXnSG.js.br +0 -0
  52. package/build/client/_app/immutable/nodes/3.NnDkXnSG.js.gz +0 -0
  53. package/build/client/_app/immutable/nodes/4.8sZ5zCiS.js +4 -0
  54. package/build/client/_app/immutable/nodes/4.8sZ5zCiS.js.br +0 -0
  55. package/build/client/_app/immutable/nodes/4.8sZ5zCiS.js.gz +0 -0
  56. package/build/client/_app/immutable/nodes/5.CSOalQ9R.js +2 -0
  57. package/build/client/_app/immutable/nodes/5.CSOalQ9R.js.br +0 -0
  58. package/build/client/_app/immutable/nodes/5.CSOalQ9R.js.gz +0 -0
  59. package/build/client/_app/immutable/nodes/6.BMBuGW7y.js +5 -0
  60. package/build/client/_app/immutable/nodes/6.BMBuGW7y.js.br +0 -0
  61. package/build/client/_app/immutable/nodes/6.BMBuGW7y.js.gz +0 -0
  62. package/build/client/_app/immutable/nodes/7.CG2RK2bH.js +4 -0
  63. package/build/client/_app/immutable/nodes/7.CG2RK2bH.js.br +0 -0
  64. package/build/client/_app/immutable/nodes/7.CG2RK2bH.js.gz +0 -0
  65. package/build/client/_app/immutable/nodes/8.Dzq0LDIw.js +1 -0
  66. package/build/client/_app/immutable/nodes/8.Dzq0LDIw.js.br +0 -0
  67. package/build/client/_app/immutable/nodes/8.Dzq0LDIw.js.gz +0 -0
  68. package/build/client/_app/immutable/nodes/9.CnkwRoxn.js +5 -0
  69. package/build/client/_app/immutable/nodes/9.CnkwRoxn.js.br +0 -0
  70. package/build/client/_app/immutable/nodes/9.CnkwRoxn.js.gz +0 -0
  71. package/build/client/_app/version.json +1 -0
  72. package/build/client/_app/version.json.br +0 -0
  73. package/build/client/_app/version.json.gz +0 -0
  74. package/build/env.js +94 -0
  75. package/build/handler.js +1494 -0
  76. package/build/index.js +345 -0
  77. package/build/server/chunks/0-u7mEipCH.js +110 -0
  78. package/build/server/chunks/0-u7mEipCH.js.map +1 -0
  79. package/build/server/chunks/1-BBGjCHyQ.js +9 -0
  80. package/build/server/chunks/1-BBGjCHyQ.js.map +1 -0
  81. package/build/server/chunks/10-B1aX7ZZ8.js +9 -0
  82. package/build/server/chunks/10-B1aX7ZZ8.js.map +1 -0
  83. package/build/server/chunks/11-4z6b2WB8.js +83 -0
  84. package/build/server/chunks/11-4z6b2WB8.js.map +1 -0
  85. package/build/server/chunks/2-CZ6isW8Z.js +9 -0
  86. package/build/server/chunks/2-CZ6isW8Z.js.map +1 -0
  87. package/build/server/chunks/3-CLWhM7Et.js +9 -0
  88. package/build/server/chunks/3-CLWhM7Et.js.map +1 -0
  89. package/build/server/chunks/4-BehBrXcu.js +146 -0
  90. package/build/server/chunks/4-BehBrXcu.js.map +1 -0
  91. package/build/server/chunks/5-C1YtO2Ru.js +9 -0
  92. package/build/server/chunks/5-C1YtO2Ru.js.map +1 -0
  93. package/build/server/chunks/6-DJ03bQJy.js +9 -0
  94. package/build/server/chunks/6-DJ03bQJy.js.map +1 -0
  95. package/build/server/chunks/7-CI__yhaj.js +73 -0
  96. package/build/server/chunks/7-CI__yhaj.js.map +1 -0
  97. package/build/server/chunks/8-BGx10Z6s.js +9 -0
  98. package/build/server/chunks/8-BGx10Z6s.js.map +1 -0
  99. package/build/server/chunks/9-LeS-ldcl.js +57 -0
  100. package/build/server/chunks/9-LeS-ldcl.js.map +1 -0
  101. package/build/server/chunks/Badge-BrV_lIru.js +24 -0
  102. package/build/server/chunks/Badge-BrV_lIru.js.map +1 -0
  103. package/build/server/chunks/SafetyBadge-BSDbVVMY.js +13 -0
  104. package/build/server/chunks/SafetyBadge-BSDbVVMY.js.map +1 -0
  105. package/build/server/chunks/_layout.svelte-Cg7oqdVB.js +214 -0
  106. package/build/server/chunks/_layout.svelte-Cg7oqdVB.js.map +1 -0
  107. package/build/server/chunks/_page.svelte-B0_5f_5-.js +86 -0
  108. package/build/server/chunks/_page.svelte-B0_5f_5-.js.map +1 -0
  109. package/build/server/chunks/_page.svelte-BS9xpx67.js +204 -0
  110. package/build/server/chunks/_page.svelte-BS9xpx67.js.map +1 -0
  111. package/build/server/chunks/_page.svelte-Bv-w7cKm.js +106 -0
  112. package/build/server/chunks/_page.svelte-Bv-w7cKm.js.map +1 -0
  113. package/build/server/chunks/_page.svelte-C8HqSRYY.js +55 -0
  114. package/build/server/chunks/_page.svelte-C8HqSRYY.js.map +1 -0
  115. package/build/server/chunks/_page.svelte-DRj4L7XZ.js +104 -0
  116. package/build/server/chunks/_page.svelte-DRj4L7XZ.js.map +1 -0
  117. package/build/server/chunks/_page.svelte-DXeUSVlF.js +14 -0
  118. package/build/server/chunks/_page.svelte-DXeUSVlF.js.map +1 -0
  119. package/build/server/chunks/_page.svelte-DbsvERRq.js +424 -0
  120. package/build/server/chunks/_page.svelte-DbsvERRq.js.map +1 -0
  121. package/build/server/chunks/_page.svelte-DuJcNgye.js +172 -0
  122. package/build/server/chunks/_page.svelte-DuJcNgye.js.map +1 -0
  123. package/build/server/chunks/_page.svelte-DyYKrY-D.js +92 -0
  124. package/build/server/chunks/_page.svelte-DyYKrY-D.js.map +1 -0
  125. package/build/server/chunks/_page.svelte-r2AHAn4f.js +134 -0
  126. package/build/server/chunks/_page.svelte-r2AHAn4f.js.map +1 -0
  127. package/build/server/chunks/client-DRY1rofW.js +23 -0
  128. package/build/server/chunks/client-DRY1rofW.js.map +1 -0
  129. package/build/server/chunks/dev-CrqJ3ZR3.js +4558 -0
  130. package/build/server/chunks/dev-CrqJ3ZR3.js.map +1 -0
  131. package/build/server/chunks/dist--t-UlYlZ.js +532 -0
  132. package/build/server/chunks/dist--t-UlYlZ.js.map +1 -0
  133. package/build/server/chunks/doctorSummary-CGjSiyKU.js +85 -0
  134. package/build/server/chunks/doctorSummary-CGjSiyKU.js.map +1 -0
  135. package/build/server/chunks/error.svelte-CvT76GCP.js +66 -0
  136. package/build/server/chunks/error.svelte-CvT76GCP.js.map +1 -0
  137. package/build/server/chunks/hooks.server-BGib69tn.js +38 -0
  138. package/build/server/chunks/hooks.server-BGib69tn.js.map +1 -0
  139. package/build/server/chunks/index-XyMIhwom.js +4727 -0
  140. package/build/server/chunks/index-XyMIhwom.js.map +1 -0
  141. package/build/server/chunks/internal-DDD35M_S.js +2068 -0
  142. package/build/server/chunks/internal-DDD35M_S.js.map +1 -0
  143. package/build/server/chunks/projectContext-C4-xYqFg.js +17311 -0
  144. package/build/server/chunks/projectContext-C4-xYqFg.js.map +1 -0
  145. package/build/server/index.js +5 -0
  146. package/build/server/index.js.map +1 -0
  147. package/build/server/manifest.js +118 -0
  148. package/build/server/manifest.js.map +1 -0
  149. package/build/shims.js +32 -0
  150. package/package.json +34 -0
@@ -0,0 +1,4558 @@
1
+ /** @type {Record<string, string>} */
2
+ const escaped = {
3
+ '<': '\\u003C',
4
+ '\\': '\\\\',
5
+ '\b': '\\b',
6
+ '\f': '\\f',
7
+ '\n': '\\n',
8
+ '\r': '\\r',
9
+ '\t': '\\t',
10
+ '\u2028': '\\u2028',
11
+ '\u2029': '\\u2029'
12
+ };
13
+
14
+ class DevalueError extends Error {
15
+ /**
16
+ * @param {string} message
17
+ * @param {string[]} keys
18
+ * @param {any} [value] - The value that failed to be serialized
19
+ * @param {any} [root] - The root value being serialized
20
+ */
21
+ constructor(message, keys, value, root) {
22
+ super(message);
23
+ this.name = 'DevalueError';
24
+ this.path = keys.join('');
25
+ this.value = value;
26
+ this.root = root;
27
+ }
28
+ }
29
+
30
+ /** @param {any} thing */
31
+ function is_primitive(thing) {
32
+ return thing === null || (typeof thing !== 'object' && typeof thing !== 'function');
33
+ }
34
+
35
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype)
36
+ .sort()
37
+ .join('\0');
38
+
39
+ /** @param {any} thing */
40
+ function is_plain_object(thing) {
41
+ const proto = Object.getPrototypeOf(thing);
42
+
43
+ return (
44
+ proto === Object.prototype ||
45
+ proto === null ||
46
+ Object.getPrototypeOf(proto) === null ||
47
+ Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
48
+ );
49
+ }
50
+
51
+ /** @param {any} thing */
52
+ function get_type(thing) {
53
+ return Object.prototype.toString.call(thing).slice(8, -1);
54
+ }
55
+
56
+ /** @param {string} char */
57
+ function get_escaped_char(char) {
58
+ switch (char) {
59
+ case '"':
60
+ return '\\"';
61
+ case '<':
62
+ return '\\u003C';
63
+ case '\\':
64
+ return '\\\\';
65
+ case '\n':
66
+ return '\\n';
67
+ case '\r':
68
+ return '\\r';
69
+ case '\t':
70
+ return '\\t';
71
+ case '\b':
72
+ return '\\b';
73
+ case '\f':
74
+ return '\\f';
75
+ case '\u2028':
76
+ return '\\u2028';
77
+ case '\u2029':
78
+ return '\\u2029';
79
+ default:
80
+ return char < ' ' ? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}` : '';
81
+ }
82
+ }
83
+
84
+ /** @param {string} str */
85
+ function stringify_string(str) {
86
+ let result = '';
87
+ let last_pos = 0;
88
+ const len = str.length;
89
+
90
+ for (let i = 0; i < len; i += 1) {
91
+ const char = str[i];
92
+ const replacement = get_escaped_char(char);
93
+ if (replacement) {
94
+ result += str.slice(last_pos, i) + replacement;
95
+ last_pos = i + 1;
96
+ }
97
+ }
98
+
99
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
100
+ }
101
+
102
+ /** @param {Record<string | symbol, any>} object */
103
+ function enumerable_symbols(object) {
104
+ return Object.getOwnPropertySymbols(object).filter(
105
+ (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
106
+ );
107
+ }
108
+
109
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
110
+
111
+ /** @param {string} key */
112
+ function stringify_key(key) {
113
+ return is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';
114
+ }
115
+
116
+ /** @param {string} s */
117
+ function is_valid_array_index(s) {
118
+ if (s.length === 0) return false;
119
+ if (s.length > 1 && s.charCodeAt(0) === 48) return false; // leading zero
120
+ for (let i = 0; i < s.length; i++) {
121
+ const c = s.charCodeAt(i);
122
+ if (c < 48 || c > 57) return false;
123
+ }
124
+ // by this point we know it's a string of digits, but it has to be within the range of valid array indices
125
+ const n = +s;
126
+ if (n >= 2 ** 32 - 1) return false;
127
+ if (n < 0) return false;
128
+ return true;
129
+ }
130
+
131
+ /**
132
+ * Finds the populated indices of an array.
133
+ * @param {unknown[]} array
134
+ */
135
+ function valid_array_indices(array) {
136
+ const keys = Object.keys(array);
137
+ for (var i = keys.length - 1; i >= 0; i--) {
138
+ if (is_valid_array_index(keys[i])) {
139
+ break;
140
+ }
141
+ }
142
+ keys.length = i + 1;
143
+ return keys;
144
+ }
145
+
146
+ const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
147
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
148
+ const reserved =
149
+ /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
150
+
151
+ /**
152
+ * Turn a value into the JavaScript that creates an equivalent value
153
+ * @param {any} value
154
+ * @param {(value: any, uneval: (value: any) => string) => string | void} [replacer]
155
+ */
156
+ function uneval(value, replacer) {
157
+ const counts = new Map();
158
+
159
+ /** @type {string[]} */
160
+ const keys = [];
161
+
162
+ const custom = new Map();
163
+
164
+ /** @param {any} thing */
165
+ function walk(thing) {
166
+ if (!is_primitive(thing)) {
167
+ if (counts.has(thing)) {
168
+ counts.set(thing, counts.get(thing) + 1);
169
+ return;
170
+ }
171
+
172
+ counts.set(thing, 1);
173
+
174
+ if (replacer) {
175
+ const str = replacer(thing, (value) => uneval(value, replacer));
176
+
177
+ if (typeof str === 'string') {
178
+ custom.set(thing, str);
179
+ return;
180
+ }
181
+ }
182
+
183
+ if (typeof thing === 'function') {
184
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
185
+ }
186
+
187
+ const type = get_type(thing);
188
+
189
+ switch (type) {
190
+ case 'Number':
191
+ case 'BigInt':
192
+ case 'String':
193
+ case 'Boolean':
194
+ case 'Date':
195
+ case 'RegExp':
196
+ case 'URL':
197
+ case 'URLSearchParams':
198
+ return;
199
+
200
+ case 'Array':
201
+ /** @type {any[]} */ (thing).forEach((value, i) => {
202
+ keys.push(`[${i}]`);
203
+ walk(value);
204
+ keys.pop();
205
+ });
206
+ break;
207
+
208
+ case 'Set':
209
+ Array.from(thing).forEach(walk);
210
+ break;
211
+
212
+ case 'Map':
213
+ for (const [key, value] of thing) {
214
+ keys.push(`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`);
215
+ walk(value);
216
+ keys.pop();
217
+ }
218
+ break;
219
+
220
+ case 'Int8Array':
221
+ case 'Uint8Array':
222
+ case 'Uint8ClampedArray':
223
+ case 'Int16Array':
224
+ case 'Uint16Array':
225
+ case 'Float16Array':
226
+ case 'Int32Array':
227
+ case 'Uint32Array':
228
+ case 'Float32Array':
229
+ case 'Float64Array':
230
+ case 'BigInt64Array':
231
+ case 'BigUint64Array':
232
+ case 'DataView':
233
+ walk(thing.buffer);
234
+ return;
235
+
236
+ case 'ArrayBuffer':
237
+ return;
238
+
239
+ case 'Temporal.Duration':
240
+ case 'Temporal.Instant':
241
+ case 'Temporal.PlainDate':
242
+ case 'Temporal.PlainTime':
243
+ case 'Temporal.PlainDateTime':
244
+ case 'Temporal.PlainMonthDay':
245
+ case 'Temporal.PlainYearMonth':
246
+ case 'Temporal.ZonedDateTime':
247
+ return;
248
+
249
+ default:
250
+ if (!is_plain_object(thing)) {
251
+ throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
252
+ }
253
+
254
+ if (enumerable_symbols(thing).length > 0) {
255
+ throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
256
+ }
257
+
258
+ for (const key of Object.keys(thing)) {
259
+ if (key === '__proto__') {
260
+ throw new DevalueError(
261
+ `Cannot stringify objects with __proto__ keys`,
262
+ keys,
263
+ thing,
264
+ value
265
+ );
266
+ }
267
+
268
+ keys.push(stringify_key(key));
269
+ walk(thing[key]);
270
+ keys.pop();
271
+ }
272
+ }
273
+ } else if (typeof thing === 'symbol') {
274
+ throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
275
+ }
276
+ }
277
+
278
+ walk(value);
279
+
280
+ const names = new Map();
281
+
282
+ Array.from(counts)
283
+ .filter((entry) => entry[1] > 1)
284
+ .sort((a, b) => b[1] - a[1])
285
+ .forEach((entry, i) => {
286
+ names.set(entry[0], get_name(i));
287
+ });
288
+
289
+ /**
290
+ * @param {any} thing
291
+ * @returns {string}
292
+ */
293
+ function stringify(thing) {
294
+ if (names.has(thing)) {
295
+ return names.get(thing);
296
+ }
297
+
298
+ if (is_primitive(thing)) {
299
+ return stringify_primitive(thing);
300
+ }
301
+
302
+ if (custom.has(thing)) {
303
+ return custom.get(thing);
304
+ }
305
+
306
+ const type = get_type(thing);
307
+
308
+ switch (type) {
309
+ case 'Number':
310
+ case 'String':
311
+ case 'Boolean':
312
+ case 'BigInt':
313
+ return `Object(${stringify(thing.valueOf())})`;
314
+
315
+ case 'RegExp':
316
+ const { source, flags } = thing;
317
+ return flags
318
+ ? `new RegExp(${stringify_string(source)},"${flags}")`
319
+ : `new RegExp(${stringify_string(source)})`;
320
+
321
+ case 'Date':
322
+ return `new Date(${thing.getTime()})`;
323
+
324
+ case 'URL':
325
+ return `new URL(${stringify_string(thing.toString())})`;
326
+
327
+ case 'URLSearchParams':
328
+ return `new URLSearchParams(${stringify_string(thing.toString())})`;
329
+
330
+ case 'Array': {
331
+ // For dense arrays (no holes), we iterate normally.
332
+ // When we encounter the first hole, we call Object.keys
333
+ // to determine the sparseness, then decide between:
334
+ // - Array literal with holes: [,"a",,] (default)
335
+ // - Object.assign: Object.assign(Array(n),{...}) (for very sparse arrays)
336
+ // Only the Object.assign path avoids iterating every slot, which
337
+ // is what protects against the DoS of e.g. `arr[1000000] = 1`.
338
+ let has_holes = false;
339
+
340
+ let result = '[';
341
+
342
+ for (let i = 0; i < thing.length; i += 1) {
343
+ if (i > 0) result += ',';
344
+
345
+ if (Object.hasOwn(thing, i)) {
346
+ result += stringify(thing[i]);
347
+ } else if (!has_holes) {
348
+ // Decide between array literal and Object.assign.
349
+ //
350
+ // Array literal: holes are consecutive commas.
351
+ // For example, [, "a", ,] is written as [,"a",,].
352
+ // Each hole costs 1 char (a comma).
353
+ //
354
+ // Object.assign: populated indices are listed explicitly.
355
+ // For example, [, "a", ,] would be written as
356
+ // Object.assign(Array(3),{1:"a"}). This avoids paying
357
+ // per-hole, but has a large fixed overhead for the
358
+ // "Object.assign(Array(n),{...})" wrapper, and each
359
+ // element costs extra chars for its index and colon.
360
+ //
361
+ // The serialized values are the same size either way, so
362
+ // the choice comes down to the structural overhead:
363
+ //
364
+ // Array literal overhead:
365
+ // 1 char per element or hole (comma separators)
366
+ // + 2 chars for "[" and "]"
367
+ // = L + 2
368
+ //
369
+ // Object.assign overhead:
370
+ // "Object.assign(Array(" — 20 chars
371
+ // + length — d chars
372
+ // + "),{" — 3 chars
373
+ // + for each populated element:
374
+ // index + ":" + "," — (d + 2) chars
375
+ // + "})" — 2 chars
376
+ // = (25 + d) + P * (d + 2)
377
+ //
378
+ // where L is the array length, P is the number of
379
+ // populated elements, and d is the number of digits
380
+ // in L (an upper bound on the digits in any index).
381
+ //
382
+ // Object.assign is cheaper when:
383
+ // (25 + d) + P * (d + 2) < L + 2
384
+ const populated_keys = valid_array_indices(/** @type {any[]} */ (thing));
385
+ const population = populated_keys.length;
386
+ const d = String(thing.length).length;
387
+
388
+ const hole_cost = thing.length + 2;
389
+ const sparse_cost = 25 + d + population * (d + 2);
390
+
391
+ if (hole_cost > sparse_cost) {
392
+ const entries = populated_keys.map((k) => `${k}:${stringify(thing[k])}`).join(',');
393
+ return `Object.assign(Array(${thing.length}),{${entries}})`;
394
+ }
395
+
396
+ // Re-process this index as a hole in the array literal
397
+ has_holes = true;
398
+ i -= 1;
399
+ }
400
+ // else: already decided on array literal, hole is just an empty slot
401
+ // (the comma separator is all we need — no content for this position)
402
+ }
403
+
404
+ const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
405
+ return result + tail + ']';
406
+ }
407
+
408
+ case 'Set':
409
+ case 'Map':
410
+ return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
411
+
412
+ case 'Int8Array':
413
+ case 'Uint8Array':
414
+ case 'Uint8ClampedArray':
415
+ case 'Int16Array':
416
+ case 'Uint16Array':
417
+ case 'Float16Array':
418
+ case 'Int32Array':
419
+ case 'Uint32Array':
420
+ case 'Float32Array':
421
+ case 'Float64Array':
422
+ case 'BigInt64Array':
423
+ case 'BigUint64Array': {
424
+ let str = `new ${type}`;
425
+
426
+ if (!names.has(thing.buffer)) {
427
+ const array = new thing.constructor(thing.buffer);
428
+ str += `([${array}])`;
429
+ } else {
430
+ str += `(${stringify(thing.buffer)})`;
431
+ }
432
+
433
+ // handle subarrays
434
+ if (thing.byteLength !== thing.buffer.byteLength) {
435
+ const start = thing.byteOffset / thing.BYTES_PER_ELEMENT;
436
+ const end = start + thing.length;
437
+ str += `.subarray(${start},${end})`;
438
+ }
439
+
440
+ return str;
441
+ }
442
+
443
+ case 'DataView': {
444
+ let str = `new DataView`;
445
+
446
+ if (!names.has(thing.buffer)) {
447
+ str += `(new Uint8Array([${new Uint8Array(thing.buffer)}]).buffer`;
448
+ } else {
449
+ str += `(${stringify(thing.buffer)}`;
450
+ }
451
+
452
+ // handle subviews
453
+ if (thing.byteLength !== thing.buffer.byteLength) {
454
+ str += `,${thing.startOffset},${thing.byteLength}`;
455
+ }
456
+
457
+ return str + ')';
458
+ }
459
+
460
+ case 'ArrayBuffer': {
461
+ const ui8 = new Uint8Array(thing);
462
+ return `new Uint8Array([${ui8.toString()}]).buffer`;
463
+ }
464
+
465
+ case 'Temporal.Duration':
466
+ case 'Temporal.Instant':
467
+ case 'Temporal.PlainDate':
468
+ case 'Temporal.PlainTime':
469
+ case 'Temporal.PlainDateTime':
470
+ case 'Temporal.PlainMonthDay':
471
+ case 'Temporal.PlainYearMonth':
472
+ case 'Temporal.ZonedDateTime':
473
+ return `${type}.from(${stringify_string(thing.toString())})`;
474
+
475
+ default:
476
+ const keys = Object.keys(thing);
477
+ const obj = keys.map((key) => `${safe_key(key)}:${stringify(thing[key])}`).join(',');
478
+ const proto = Object.getPrototypeOf(thing);
479
+ if (proto === null) {
480
+ return keys.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
481
+ }
482
+
483
+ return `{${obj}}`;
484
+ }
485
+ }
486
+
487
+ const str = stringify(value);
488
+
489
+ if (names.size) {
490
+ /** @type {string[]} */
491
+ const params = [];
492
+
493
+ /** @type {string[]} */
494
+ const statements = [];
495
+
496
+ /** @type {string[]} */
497
+ const values = [];
498
+
499
+ names.forEach((name, thing) => {
500
+ params.push(name);
501
+
502
+ if (custom.has(thing)) {
503
+ values.push(/** @type {string} */ (custom.get(thing)));
504
+ return;
505
+ }
506
+
507
+ if (is_primitive(thing)) {
508
+ values.push(stringify_primitive(thing));
509
+ return;
510
+ }
511
+
512
+ const type = get_type(thing);
513
+
514
+ switch (type) {
515
+ case 'Number':
516
+ case 'String':
517
+ case 'Boolean':
518
+ case 'BigInt':
519
+ values.push(`Object(${stringify(thing.valueOf())})`);
520
+ break;
521
+
522
+ case 'RegExp':
523
+ const { source, flags } = thing;
524
+ const regexp = flags
525
+ ? `new RegExp(${stringify_string(source)},"${flags}")`
526
+ : `new RegExp(${stringify_string(source)})`;
527
+ values.push(regexp);
528
+ break;
529
+
530
+ case 'Date':
531
+ values.push(`new Date(${thing.getTime()})`);
532
+ break;
533
+
534
+ case 'URL':
535
+ values.push(`new URL(${stringify_string(thing.toString())})`);
536
+ break;
537
+
538
+ case 'URLSearchParams':
539
+ values.push(`new URLSearchParams(${stringify_string(thing.toString())})`);
540
+ break;
541
+
542
+ case 'Array':
543
+ values.push(`Array(${thing.length})`);
544
+ /** @type {any[]} */ (thing).forEach((v, i) => {
545
+ statements.push(`${name}[${i}]=${stringify(v)}`);
546
+ });
547
+ break;
548
+
549
+ case 'Set':
550
+ values.push(`new Set`);
551
+ statements.push(
552
+ `${name}.${Array.from(thing)
553
+ .map((v) => `add(${stringify(v)})`)
554
+ .join('.')}`
555
+ );
556
+ break;
557
+
558
+ case 'Map':
559
+ values.push(`new Map`);
560
+ statements.push(
561
+ `${name}.${Array.from(thing)
562
+ .map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`)
563
+ .join('.')}`
564
+ );
565
+ break;
566
+
567
+ case 'Int8Array':
568
+ case 'Uint8Array':
569
+ case 'Uint8ClampedArray':
570
+ case 'Int16Array':
571
+ case 'Uint16Array':
572
+ case 'Float16Array':
573
+ case 'Int32Array':
574
+ case 'Uint32Array':
575
+ case 'Float32Array':
576
+ case 'Float64Array':
577
+ case 'BigInt64Array':
578
+ case 'BigUint64Array': {
579
+ let str = `new ${type}`;
580
+
581
+ if (!names.has(thing.buffer)) {
582
+ const array = new thing.constructor(thing.buffer);
583
+ str += `([${array}])`;
584
+ } else {
585
+ str += `(${stringify(thing.buffer)})`;
586
+ }
587
+
588
+ // handle subarrays
589
+ if (thing.byteLength !== thing.buffer.byteLength) {
590
+ const start = thing.byteOffset / thing.BYTES_PER_ELEMENT;
591
+ const end = start + thing.length;
592
+ str += `.subarray(${start},${end})`;
593
+ }
594
+
595
+ values.push(`{}`);
596
+ statements.push(`${name}=${str}`);
597
+ break;
598
+ }
599
+
600
+ case 'DataView': {
601
+ let str = `new DataView`;
602
+
603
+ if (!names.has(thing.buffer)) {
604
+ str += `(new Uint8Array([${new Uint8Array(thing.buffer)}]).buffer`;
605
+ } else {
606
+ str += `(${stringify(thing.buffer)}`;
607
+ }
608
+
609
+ // handle subviews
610
+ if (thing.byteLength !== thing.buffer.byteLength) {
611
+ str += `,${thing.byteOffset},${thing.byteLength}`;
612
+ }
613
+
614
+ str += ')';
615
+
616
+ values.push(`{}`);
617
+ statements.push(`${name}=${str}`);
618
+ break;
619
+ }
620
+
621
+ case 'ArrayBuffer':
622
+ values.push(`new Uint8Array([${new Uint8Array(thing)}]).buffer`);
623
+ break;
624
+
625
+ default:
626
+ values.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}');
627
+ Object.keys(thing).forEach((key) => {
628
+ statements.push(`${name}${safe_prop(key)}=${stringify(thing[key])}`);
629
+ });
630
+ }
631
+ });
632
+
633
+ statements.push(`return ${str}`);
634
+
635
+ return `(function(${params.join(',')}){${statements.join(';')}}(${values.join(',')}))`;
636
+ } else {
637
+ return str;
638
+ }
639
+ }
640
+
641
+ /** @param {number} num */
642
+ function get_name(num) {
643
+ let name = '';
644
+
645
+ do {
646
+ name = chars[num % chars.length] + name;
647
+ num = ~~(num / chars.length) - 1;
648
+ } while (num >= 0);
649
+
650
+ return reserved.test(name) ? `${name}0` : name;
651
+ }
652
+
653
+ /** @param {string} c */
654
+ function escape_unsafe_char(c) {
655
+ return escaped[c] || c;
656
+ }
657
+
658
+ /** @param {string} str */
659
+ function escape_unsafe_chars(str) {
660
+ return str.replace(unsafe_chars, escape_unsafe_char);
661
+ }
662
+
663
+ /** @param {string} key */
664
+ function safe_key(key) {
665
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
666
+ }
667
+
668
+ /** @param {string} key */
669
+ function safe_prop(key) {
670
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
671
+ ? `.${key}`
672
+ : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
673
+ }
674
+
675
+ /** @param {any} thing */
676
+ function stringify_primitive(thing) {
677
+ const type = typeof thing;
678
+ if (type === 'string') return stringify_string(thing);
679
+ if (thing === void 0) return 'void 0';
680
+ if (thing === 0 && 1 / thing < 0) return '-0';
681
+ const str = String(thing);
682
+ if (type === 'number') return str.replace(/^(-)?0\./, '$1.');
683
+ if (type === 'bigint') return thing + 'n';
684
+ return str;
685
+ }
686
+
687
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
688
+
689
+ //#region ../../node_modules/svelte/src/internal/shared/errors.js
690
+ /**
691
+ * Cannot use `%name%(...)` unless the `experimental.async` compiler option is `true`
692
+ * @param {string} name
693
+ * @returns {never}
694
+ */
695
+ function experimental_async_required(name) {
696
+ throw new Error(`https://svelte.dev/e/experimental_async_required`);
697
+ }
698
+ /**
699
+ * `%name%(...)` can only be used during component initialisation
700
+ * @param {string} name
701
+ * @returns {never}
702
+ */
703
+ function lifecycle_outside_component(name) {
704
+ throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
705
+ }
706
+ /**
707
+ * Context was not set in a parent component
708
+ * @returns {never}
709
+ */
710
+ function missing_context() {
711
+ throw new Error(`https://svelte.dev/e/missing_context`);
712
+ }
713
+ /**
714
+ * Encountered asynchronous work while rendering synchronously.
715
+ * @returns {never}
716
+ */
717
+ function await_invalid() {
718
+ const error = /* @__PURE__ */ new Error(`await_invalid\nEncountered asynchronous work while rendering synchronously.\nhttps://svelte.dev/e/await_invalid`);
719
+ error.name = "Svelte error";
720
+ throw error;
721
+ }
722
+ /**
723
+ * Failed to serialize `hydratable` data for key `%key%`.
724
+ *
725
+ * `hydratable` can serialize anything [`uneval` from `devalue`](https://npmjs.com/package/uneval) can, plus Promises.
726
+ *
727
+ * Cause:
728
+ * %stack%
729
+ * @param {string} key
730
+ * @param {string} stack
731
+ * @returns {never}
732
+ */
733
+ function hydratable_serialization_failed(key, stack) {
734
+ const error = /* @__PURE__ */ new Error(`hydratable_serialization_failed\nFailed to serialize \`hydratable\` data for key \`${key}\`.
735
+
736
+ \`hydratable\` can serialize anything [\`uneval\` from \`devalue\`](https://npmjs.com/package/uneval) can, plus Promises.
737
+
738
+ Cause:
739
+ ${stack}\nhttps://svelte.dev/e/hydratable_serialization_failed`);
740
+ error.name = "Svelte error";
741
+ throw error;
742
+ }
743
+ /**
744
+ * `csp.nonce` was set while `csp.hash` was `true`. These options cannot be used simultaneously.
745
+ * @returns {never}
746
+ */
747
+ function invalid_csp() {
748
+ const error = /* @__PURE__ */ new Error(`invalid_csp\n\`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.\nhttps://svelte.dev/e/invalid_csp`);
749
+ error.name = "Svelte error";
750
+ throw error;
751
+ }
752
+ /**
753
+ * The `idPrefix` option cannot include `--`.
754
+ * @returns {never}
755
+ */
756
+ function invalid_id_prefix() {
757
+ const error = /* @__PURE__ */ new Error(`invalid_id_prefix\nThe \`idPrefix\` option cannot include \`--\`.\nhttps://svelte.dev/e/invalid_id_prefix`);
758
+ error.name = "Svelte error";
759
+ throw error;
760
+ }
761
+ /**
762
+ * `%name%(...)` is not available on the server
763
+ * @param {string} name
764
+ * @returns {never}
765
+ */
766
+ function lifecycle_function_unavailable(name) {
767
+ const error = /* @__PURE__ */ new Error(`lifecycle_function_unavailable\n\`${name}(...)\` is not available on the server\nhttps://svelte.dev/e/lifecycle_function_unavailable`);
768
+ error.name = "Svelte error";
769
+ throw error;
770
+ }
771
+ /**
772
+ * Could not resolve `render` context.
773
+ * @returns {never}
774
+ */
775
+ function server_context_required() {
776
+ const error = /* @__PURE__ */ new Error(`server_context_required\nCould not resolve \`render\` context.\nhttps://svelte.dev/e/server_context_required`);
777
+ error.name = "Svelte error";
778
+ throw error;
779
+ }
780
+ //#endregion
781
+ //#region ../../node_modules/svelte/src/internal/server/context.js
782
+ /** @import { SSRContext } from '#server' */
783
+ /** @type {SSRContext | null} */
784
+ var ssr_context = null;
785
+ /** @param {SSRContext | null} v */
786
+ function set_ssr_context(v) {
787
+ ssr_context = v;
788
+ }
789
+ /**
790
+ * @template T
791
+ * @returns {[() => T, (context: T) => T]}
792
+ * @since 5.40.0
793
+ */
794
+ function createContext() {
795
+ const key = {};
796
+ return [() => {
797
+ if (!hasContext(key)) missing_context();
798
+ return getContext(key);
799
+ }, (context) => setContext(key, context)];
800
+ }
801
+ /**
802
+ * @template T
803
+ * @param {any} key
804
+ * @returns {T}
805
+ */
806
+ function getContext(key) {
807
+ return get_or_init_context_map().get(key);
808
+ }
809
+ /**
810
+ * @template T
811
+ * @param {any} key
812
+ * @param {T} context
813
+ * @returns {T}
814
+ */
815
+ function setContext(key, context) {
816
+ get_or_init_context_map().set(key, context);
817
+ return context;
818
+ }
819
+ /**
820
+ * @param {any} key
821
+ * @returns {boolean}
822
+ */
823
+ function hasContext(key) {
824
+ return get_or_init_context_map().has(key);
825
+ }
826
+ /** @returns {Map<any, any>} */
827
+ function getAllContexts() {
828
+ return get_or_init_context_map();
829
+ }
830
+ /**
831
+ * @param {string} name
832
+ * @returns {Map<unknown, unknown>}
833
+ */
834
+ function get_or_init_context_map(name) {
835
+ if (ssr_context === null) lifecycle_outside_component();
836
+ return ssr_context.c ??= new Map(get_parent_context(ssr_context) || void 0);
837
+ }
838
+ /**
839
+ * @param {Function} [fn]
840
+ */
841
+ function push$1(fn) {
842
+ ssr_context = {
843
+ p: ssr_context,
844
+ c: null,
845
+ r: null
846
+ };
847
+ }
848
+ function pop$1() {
849
+ ssr_context = ssr_context.p;
850
+ }
851
+ /**
852
+ * @param {SSRContext} ssr_context
853
+ * @returns {Map<unknown, unknown> | null}
854
+ */
855
+ function get_parent_context(ssr_context) {
856
+ let parent = ssr_context.p;
857
+ while (parent !== null) {
858
+ const context_map = parent.c;
859
+ if (context_map !== null) return context_map;
860
+ parent = parent.p;
861
+ }
862
+ return null;
863
+ }
864
+ //#endregion
865
+ //#region ../../node_modules/svelte/src/internal/shared/utils.js
866
+ var is_array = Array.isArray;
867
+ var index_of = Array.prototype.indexOf;
868
+ var includes = Array.prototype.includes;
869
+ var array_from = Array.from;
870
+ var define_property = Object.defineProperty;
871
+ var get_descriptor = Object.getOwnPropertyDescriptor;
872
+ var object_prototype = Object.prototype;
873
+ var array_prototype = Array.prototype;
874
+ var get_prototype_of = Object.getPrototypeOf;
875
+ var is_extensible = Object.isExtensible;
876
+ var has_own_property = Object.prototype.hasOwnProperty;
877
+ var noop = () => {};
878
+ /** @param {Function} fn */
879
+ function run(fn) {
880
+ return fn();
881
+ }
882
+ /** @param {Array<() => void>} arr */
883
+ function run_all(arr) {
884
+ for (var i = 0; i < arr.length; i++) arr[i]();
885
+ }
886
+ /**
887
+ * TODO replace with Promise.withResolvers once supported widely enough
888
+ * @template [T=void]
889
+ */
890
+ function deferred() {
891
+ /** @type {(value: T) => void} */
892
+ var resolve;
893
+ /** @type {(reason: any) => void} */
894
+ var reject;
895
+ return {
896
+ promise: new Promise((res, rej) => {
897
+ resolve = res;
898
+ reject = rej;
899
+ }),
900
+ resolve,
901
+ reject
902
+ };
903
+ }
904
+ var CLEAN = 1024;
905
+ var DIRTY = 2048;
906
+ var MAYBE_DIRTY = 4096;
907
+ var INERT = 8192;
908
+ var DESTROYED = 16384;
909
+ /** Set once a reaction has run for the first time */
910
+ var REACTION_RAN = 32768;
911
+ /** Effect is in the process of getting destroyed. Can be observed in child teardown functions */
912
+ var DESTROYING = 1 << 25;
913
+ /**
914
+ * 'Transparent' effects do not create a transition boundary.
915
+ * This is on a block effect 99% of the time but may also be on a branch effect if its parent block effect was pruned
916
+ */
917
+ var EFFECT_TRANSPARENT = 65536;
918
+ var EFFECT_PRESERVED = 1 << 19;
919
+ var USER_EFFECT = 1 << 20;
920
+ /**
921
+ * Tells that we marked this derived and its reactions as visited during the "mark as (maybe) dirty"-phase.
922
+ * Will be lifted during execution of the derived and during checking its dirty state (both are necessary
923
+ * because a derived might be checked but not executed). This is a pure performance optimization flag and
924
+ * should not be used for any other purpose!
925
+ */
926
+ var WAS_MARKED = 65536;
927
+ var REACTION_IS_UPDATING = 1 << 21;
928
+ var ERROR_VALUE = 1 << 23;
929
+ var STATE_SYMBOL = Symbol("$state");
930
+ var LEGACY_PROPS = Symbol("legacy props");
931
+ /** allow users to ignore aborted signal errors if `reason.name === 'StaleReactionError` */
932
+ var STALE_REACTION = new class StaleReactionError extends Error {
933
+ name = "StaleReactionError";
934
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
935
+ }();
936
+ //#endregion
937
+ //#region ../../node_modules/svelte/src/internal/server/abort-signal.js
938
+ /** @type {AbortController | null} */
939
+ var controller = null;
940
+ function abort() {
941
+ controller?.abort(STALE_REACTION);
942
+ controller = null;
943
+ }
944
+ function getAbortSignal() {
945
+ return (controller ??= new AbortController()).signal;
946
+ }
947
+ /** @returns {RenderContext} */
948
+ function get_render_context() {
949
+ const store = als?.getStore();
950
+ server_context_required();
951
+ return store;
952
+ }
953
+ /** @type {AsyncLocalStorage<RenderContext | null> | null} */
954
+ var als = null;
955
+ //#endregion
956
+ //#region ../../node_modules/svelte/src/constants.js
957
+ var HYDRATION_ERROR = {};
958
+ var UNINITIALIZED = Symbol();
959
+ /**
960
+ * A `hydratable` value with key `%key%` was created, but at least part of it was not used during the render.
961
+ *
962
+ * The `hydratable` was initialized in:
963
+ * %stack%
964
+ * @param {string} key
965
+ * @param {string} stack
966
+ */
967
+ function unresolved_hydratable(key, stack) {
968
+ console.warn(`https://svelte.dev/e/unresolved_hydratable`);
969
+ }
970
+ //#endregion
971
+ //#region ../../node_modules/svelte/src/internal/server/hydration.js
972
+ var BLOCK_OPEN = `<!--[-->`;
973
+ var BLOCK_CLOSE = `<!--]-->`;
974
+ var EMPTY_COMMENT = `<!---->`;
975
+ //#endregion
976
+ //#region ../../node_modules/svelte/src/escaping.js
977
+ var ATTR_REGEX = /[&"<]/g;
978
+ var CONTENT_REGEX = /[&<]/g;
979
+ /**
980
+ * @template V
981
+ * @param {V} value
982
+ * @param {boolean} [is_attr]
983
+ */
984
+ function escape_html(value, is_attr) {
985
+ const str = String(value ?? "");
986
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
987
+ pattern.lastIndex = 0;
988
+ let escaped = "";
989
+ let last = 0;
990
+ while (pattern.test(str)) {
991
+ const i = pattern.lastIndex - 1;
992
+ const ch = str[i];
993
+ escaped += str.substring(last, i) + (ch === "&" ? "&amp;" : ch === "\"" ? "&quot;" : "&lt;");
994
+ last = i + 1;
995
+ }
996
+ return escaped + str.substring(last);
997
+ }
998
+ //#endregion
999
+ //#region ../../node_modules/svelte/src/internal/shared/attributes.js
1000
+ /**
1001
+ * `<div translate={false}>` should be rendered as `<div translate="no">` and _not_
1002
+ * `<div translate="false">`, which is equivalent to `<div translate="yes">`. There
1003
+ * may be other odd cases that need to be added to this list in future
1004
+ * @type {Record<string, Map<any, string>>}
1005
+ */
1006
+ var replacements = { translate: new Map([[true, "yes"], [false, "no"]]) };
1007
+ /**
1008
+ * @template V
1009
+ * @param {string} name
1010
+ * @param {V} value
1011
+ * @param {boolean} [is_boolean]
1012
+ * @returns {string}
1013
+ */
1014
+ function attr(name, value, is_boolean = false) {
1015
+ if (name === "hidden" && value !== "until-found") is_boolean = true;
1016
+ if (value == null || !value && is_boolean) return "";
1017
+ const normalized = has_own_property.call(replacements, name) && replacements[name].get(value) || value;
1018
+ return ` ${name}${is_boolean ? `=""` : `="${escape_html(normalized, true)}"`}`;
1019
+ }
1020
+ /**
1021
+ * Small wrapper around clsx to preserve Svelte's (weird) handling of falsy values.
1022
+ * TODO Svelte 6 revisit this, and likely turn all falsy values into the empty string (what clsx also does)
1023
+ * @param {any} value
1024
+ */
1025
+ function clsx$1(value) {
1026
+ if (typeof value === "object") return clsx(value);
1027
+ else return value ?? "";
1028
+ }
1029
+ var whitespace = [..." \n\r\f\xA0\v"];
1030
+ /**
1031
+ * @param {any} value
1032
+ * @param {string | null} [hash]
1033
+ * @param {Record<string, boolean>} [directives]
1034
+ * @returns {string | null}
1035
+ */
1036
+ function to_class(value, hash, directives) {
1037
+ var classname = value == null ? "" : "" + value;
1038
+ if (hash) classname = classname ? classname + " " + hash : hash;
1039
+ if (directives) {
1040
+ for (var key of Object.keys(directives)) if (directives[key]) classname = classname ? classname + " " + key : key;
1041
+ else if (classname.length) {
1042
+ var len = key.length;
1043
+ var a = 0;
1044
+ while ((a = classname.indexOf(key, a)) >= 0) {
1045
+ var b = a + len;
1046
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
1047
+ else a = b;
1048
+ }
1049
+ }
1050
+ }
1051
+ return classname === "" ? null : classname;
1052
+ }
1053
+ /**
1054
+ *
1055
+ * @param {Record<string,any>} styles
1056
+ * @param {boolean} important
1057
+ */
1058
+ function append_styles(styles, important = false) {
1059
+ var separator = important ? " !important;" : ";";
1060
+ var css = "";
1061
+ for (var key of Object.keys(styles)) {
1062
+ var value = styles[key];
1063
+ if (value != null && value !== "") css += " " + key + ": " + value + separator;
1064
+ }
1065
+ return css;
1066
+ }
1067
+ /**
1068
+ * @param {string} name
1069
+ * @returns {string}
1070
+ */
1071
+ function to_css_name(name) {
1072
+ if (name[0] !== "-" || name[1] !== "-") return name.toLowerCase();
1073
+ return name;
1074
+ }
1075
+ /**
1076
+ * @param {any} value
1077
+ * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [styles]
1078
+ * @returns {string | null}
1079
+ */
1080
+ function to_style(value, styles) {
1081
+ if (styles) {
1082
+ var new_style = "";
1083
+ /** @type {Record<string,any> | undefined} */
1084
+ var normal_styles;
1085
+ /** @type {Record<string,any> | undefined} */
1086
+ var important_styles;
1087
+ if (Array.isArray(styles)) {
1088
+ normal_styles = styles[0];
1089
+ important_styles = styles[1];
1090
+ } else normal_styles = styles;
1091
+ if (value) {
1092
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
1093
+ /** @type {boolean | '"' | "'"} */
1094
+ var in_str = false;
1095
+ var in_apo = 0;
1096
+ var in_comment = false;
1097
+ var reserved_names = [];
1098
+ if (normal_styles) reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
1099
+ if (important_styles) reserved_names.push(...Object.keys(important_styles).map(to_css_name));
1100
+ var start_index = 0;
1101
+ var name_index = -1;
1102
+ const len = value.length;
1103
+ for (var i = 0; i < len; i++) {
1104
+ var c = value[i];
1105
+ if (in_comment) {
1106
+ if (c === "/" && value[i - 1] === "*") in_comment = false;
1107
+ } else if (in_str) {
1108
+ if (in_str === c) in_str = false;
1109
+ } else if (c === "/" && value[i + 1] === "*") in_comment = true;
1110
+ else if (c === "\"" || c === "'") in_str = c;
1111
+ else if (c === "(") in_apo++;
1112
+ else if (c === ")") in_apo--;
1113
+ if (!in_comment && in_str === false && in_apo === 0) {
1114
+ if (c === ":" && name_index === -1) name_index = i;
1115
+ else if (c === ";" || i === len - 1) {
1116
+ if (name_index !== -1) {
1117
+ var name = to_css_name(value.substring(start_index, name_index).trim());
1118
+ if (!reserved_names.includes(name)) {
1119
+ if (c !== ";") i++;
1120
+ var property = value.substring(start_index, i).trim();
1121
+ new_style += " " + property + ";";
1122
+ }
1123
+ }
1124
+ start_index = i + 1;
1125
+ name_index = -1;
1126
+ }
1127
+ }
1128
+ }
1129
+ }
1130
+ if (normal_styles) new_style += append_styles(normal_styles);
1131
+ if (important_styles) new_style += append_styles(important_styles, true);
1132
+ new_style = new_style.trim();
1133
+ return new_style === "" ? null : new_style;
1134
+ }
1135
+ return value == null ? null : String(value);
1136
+ }
1137
+ /**
1138
+ * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
1139
+ * @returns {never}
1140
+ */
1141
+ function effect_update_depth_exceeded() {
1142
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
1143
+ }
1144
+ /**
1145
+ * Failed to hydrate the application
1146
+ * @returns {never}
1147
+ */
1148
+ function hydration_failed() {
1149
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
1150
+ }
1151
+ /**
1152
+ * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
1153
+ * @returns {never}
1154
+ */
1155
+ function state_descriptors_fixed() {
1156
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
1157
+ }
1158
+ /**
1159
+ * Cannot set prototype of `$state` object
1160
+ * @returns {never}
1161
+ */
1162
+ function state_prototype_fixed() {
1163
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
1164
+ }
1165
+ /**
1166
+ * Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
1167
+ * @returns {never}
1168
+ */
1169
+ function state_unsafe_mutation() {
1170
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
1171
+ }
1172
+ /**
1173
+ * A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
1174
+ * @returns {never}
1175
+ */
1176
+ function svelte_boundary_reset_onerror() {
1177
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
1178
+ }
1179
+ /**
1180
+ * Reading a derived belonging to a now-destroyed effect may result in stale values
1181
+ */
1182
+ function derived_inert() {
1183
+ console.warn(`https://svelte.dev/e/derived_inert`);
1184
+ }
1185
+ /**
1186
+ * Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near %location%
1187
+ * @param {string | undefined | null} [location]
1188
+ */
1189
+ function hydration_mismatch(location) {
1190
+ console.warn(`https://svelte.dev/e/hydration_mismatch`);
1191
+ }
1192
+ /**
1193
+ * A `<svelte:boundary>` `reset` function only resets the boundary the first time it is called
1194
+ */
1195
+ function svelte_boundary_reset_noop() {
1196
+ console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
1197
+ }
1198
+ //#endregion
1199
+ //#region ../../node_modules/svelte/src/internal/client/dom/hydration.js
1200
+ /** @import { TemplateNode } from '#client' */
1201
+ /**
1202
+ * Use this variable to guard everything related to hydration code so it can be treeshaken out
1203
+ * if the user doesn't use the `hydrate` method and these code paths are therefore not needed.
1204
+ */
1205
+ var hydrating = false;
1206
+ /** @param {boolean} value */
1207
+ function set_hydrating(value) {
1208
+ hydrating = value;
1209
+ }
1210
+ /**
1211
+ * The node that is currently being hydrated. This starts out as the first node inside the opening
1212
+ * <!--[--> comment, and updates each time a component calls `$.child(...)` or `$.sibling(...)`.
1213
+ * When entering a block (e.g. `{#if ...}`), `hydrate_node` is the block opening comment; by the
1214
+ * time we leave the block it is the closing comment, which serves as the block's anchor.
1215
+ * @type {TemplateNode}
1216
+ */
1217
+ var hydrate_node;
1218
+ /** @param {TemplateNode | null} node */
1219
+ function set_hydrate_node(node) {
1220
+ if (node === null) {
1221
+ hydration_mismatch();
1222
+ throw HYDRATION_ERROR;
1223
+ }
1224
+ return hydrate_node = node;
1225
+ }
1226
+ function hydrate_next() {
1227
+ return set_hydrate_node(/* @__PURE__ */ get_next_sibling(hydrate_node));
1228
+ }
1229
+ function next(count = 1) {
1230
+ if (hydrating) {
1231
+ var i = count;
1232
+ var node = hydrate_node;
1233
+ while (i--) node = /* @__PURE__ */ get_next_sibling(node);
1234
+ hydrate_node = node;
1235
+ }
1236
+ }
1237
+ /**
1238
+ * Skips or removes (depending on {@link remove}) all nodes starting at `hydrate_node` up until the next hydration end comment
1239
+ * @param {boolean} remove
1240
+ */
1241
+ function skip_nodes(remove = true) {
1242
+ var depth = 0;
1243
+ var node = hydrate_node;
1244
+ while (true) {
1245
+ if (node.nodeType === 8) {
1246
+ var data = node.data;
1247
+ if (data === "]") {
1248
+ if (depth === 0) return node;
1249
+ depth -= 1;
1250
+ } else if (data === "[" || data === "[!" || data[0] === "[" && !isNaN(Number(data.slice(1)))) depth += 1;
1251
+ }
1252
+ var next = /* @__PURE__ */ get_next_sibling(node);
1253
+ if (remove) node.remove();
1254
+ node = next;
1255
+ }
1256
+ }
1257
+ //#endregion
1258
+ //#region ../../node_modules/svelte/src/internal/client/reactivity/equality.js
1259
+ /** @import { Equals } from '#client' */
1260
+ /** @type {Equals} */
1261
+ function equals(value) {
1262
+ return value === this.v;
1263
+ }
1264
+ /**
1265
+ * @param {unknown} a
1266
+ * @param {unknown} b
1267
+ * @returns {boolean}
1268
+ */
1269
+ function safe_not_equal(a, b) {
1270
+ return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
1271
+ }
1272
+ /** @type {Equals} */
1273
+ function safe_equals(value) {
1274
+ return !safe_not_equal(value, this.v);
1275
+ }
1276
+ //#endregion
1277
+ //#region ../../node_modules/svelte/src/internal/client/context.js
1278
+ /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
1279
+ /** @type {ComponentContext | null} */
1280
+ var component_context = null;
1281
+ /** @param {ComponentContext | null} context */
1282
+ function set_component_context(context) {
1283
+ component_context = context;
1284
+ }
1285
+ /**
1286
+ * @param {Record<string, unknown>} props
1287
+ * @param {any} runes
1288
+ * @param {Function} [fn]
1289
+ * @returns {void}
1290
+ */
1291
+ function push(props, runes = false, fn) {
1292
+ component_context = {
1293
+ p: component_context,
1294
+ i: false,
1295
+ c: null,
1296
+ e: null,
1297
+ s: props,
1298
+ x: null,
1299
+ r: active_effect,
1300
+ l: null
1301
+ };
1302
+ }
1303
+ /**
1304
+ * @template {Record<string, any>} T
1305
+ * @param {T} [component]
1306
+ * @returns {T}
1307
+ */
1308
+ function pop(component) {
1309
+ var context = component_context;
1310
+ var effects = context.e;
1311
+ if (effects !== null) {
1312
+ context.e = null;
1313
+ for (var fn of effects) create_user_effect(fn);
1314
+ }
1315
+ context.i = true;
1316
+ component_context = context.p;
1317
+ return {};
1318
+ }
1319
+ /** @returns {boolean} */
1320
+ function is_runes() {
1321
+ return true;
1322
+ }
1323
+ //#endregion
1324
+ //#region ../../node_modules/svelte/src/internal/client/dom/task.js
1325
+ /** @type {Array<() => void>} */
1326
+ var micro_tasks = [];
1327
+ function run_micro_tasks() {
1328
+ var tasks = micro_tasks;
1329
+ micro_tasks = [];
1330
+ run_all(tasks);
1331
+ }
1332
+ /**
1333
+ * @param {() => void} fn
1334
+ */
1335
+ function queue_micro_task(fn) {
1336
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
1337
+ var tasks = micro_tasks;
1338
+ queueMicrotask(() => {
1339
+ if (tasks === micro_tasks) run_micro_tasks();
1340
+ });
1341
+ }
1342
+ micro_tasks.push(fn);
1343
+ }
1344
+ /**
1345
+ * Synchronously run any queued tasks.
1346
+ */
1347
+ function flush_tasks() {
1348
+ while (micro_tasks.length > 0) run_micro_tasks();
1349
+ }
1350
+ /**
1351
+ * @param {unknown} error
1352
+ */
1353
+ function handle_error(error) {
1354
+ var effect = active_effect;
1355
+ if (effect === null) {
1356
+ /** @type {Derived} */ active_reaction.f |= ERROR_VALUE;
1357
+ return error;
1358
+ }
1359
+ if ((effect.f & 32768) === 0 && (effect.f & 4) === 0) throw error;
1360
+ invoke_error_boundary(error, effect);
1361
+ }
1362
+ /**
1363
+ * @param {unknown} error
1364
+ * @param {Effect | null} effect
1365
+ */
1366
+ function invoke_error_boundary(error, effect) {
1367
+ while (effect !== null) {
1368
+ if ((effect.f & 128) !== 0) {
1369
+ if ((effect.f & 32768) === 0) throw error;
1370
+ try {
1371
+ /** @type {Boundary} */ effect.b.error(error);
1372
+ return;
1373
+ } catch (e) {
1374
+ error = e;
1375
+ }
1376
+ }
1377
+ effect = effect.parent;
1378
+ }
1379
+ throw error;
1380
+ }
1381
+ //#endregion
1382
+ //#region ../../node_modules/svelte/src/internal/client/reactivity/status.js
1383
+ /** @import { Derived, Signal } from '#client' */
1384
+ var STATUS_MASK = -7169;
1385
+ /**
1386
+ * @param {Signal} signal
1387
+ * @param {number} status
1388
+ */
1389
+ function set_signal_status(signal, status) {
1390
+ signal.f = signal.f & STATUS_MASK | status;
1391
+ }
1392
+ /**
1393
+ * Set a derived's status to CLEAN or MAYBE_DIRTY based on its connection state.
1394
+ * @param {Derived} derived
1395
+ */
1396
+ function update_derived_status(derived) {
1397
+ if ((derived.f & 512) !== 0 || derived.deps === null) set_signal_status(derived, CLEAN);
1398
+ else set_signal_status(derived, MAYBE_DIRTY);
1399
+ }
1400
+ //#endregion
1401
+ //#region ../../node_modules/svelte/src/internal/client/reactivity/utils.js
1402
+ /** @import { Derived, Effect, Value } from '#client' */
1403
+ /**
1404
+ * @param {Value[] | null} deps
1405
+ */
1406
+ function clear_marked(deps) {
1407
+ if (deps === null) return;
1408
+ for (const dep of deps) {
1409
+ if ((dep.f & 2) === 0 || (dep.f & 65536) === 0) continue;
1410
+ dep.f ^= WAS_MARKED;
1411
+ clear_marked(
1412
+ /** @type {Derived} */
1413
+ dep.deps
1414
+ );
1415
+ }
1416
+ }
1417
+ /**
1418
+ * @param {Effect} effect
1419
+ * @param {Set<Effect>} dirty_effects
1420
+ * @param {Set<Effect>} maybe_dirty_effects
1421
+ */
1422
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
1423
+ if ((effect.f & 2048) !== 0) dirty_effects.add(effect);
1424
+ else if ((effect.f & 4096) !== 0) maybe_dirty_effects.add(effect);
1425
+ clear_marked(effect.deps);
1426
+ set_signal_status(effect, CLEAN);
1427
+ }
1428
+ //#endregion
1429
+ //#region ../../node_modules/svelte/src/store/shared/index.js
1430
+ /** @import { Readable, StartStopNotifier, Subscriber, Unsubscriber, Updater, Writable } from '../public.js' */
1431
+ /** @import { Stores, StoresValues, SubscribeInvalidateTuple } from '../private.js' */
1432
+ /**
1433
+ * @type {Array<SubscribeInvalidateTuple<any> | any>}
1434
+ */
1435
+ var subscriber_queue = [];
1436
+ /**
1437
+ * Creates a `Readable` store that allows reading by subscription.
1438
+ *
1439
+ * @template T
1440
+ * @param {T} [value] initial value
1441
+ * @param {StartStopNotifier<T>} [start]
1442
+ * @returns {Readable<T>}
1443
+ */
1444
+ function readable(value, start) {
1445
+ return { subscribe: writable(value, start).subscribe };
1446
+ }
1447
+ /**
1448
+ * Create a `Writable` store that allows both updating and reading by subscription.
1449
+ *
1450
+ * @template T
1451
+ * @param {T} [value] initial value
1452
+ * @param {StartStopNotifier<T>} [start]
1453
+ * @returns {Writable<T>}
1454
+ */
1455
+ function writable(value, start = noop) {
1456
+ /** @type {Unsubscriber | null} */
1457
+ let stop = null;
1458
+ /** @type {Set<SubscribeInvalidateTuple<T>>} */
1459
+ const subscribers = /* @__PURE__ */ new Set();
1460
+ /**
1461
+ * @param {T} new_value
1462
+ * @returns {void}
1463
+ */
1464
+ function set(new_value) {
1465
+ if (safe_not_equal(value, new_value)) {
1466
+ value = new_value;
1467
+ if (stop) {
1468
+ const run_queue = !subscriber_queue.length;
1469
+ for (const subscriber of subscribers) {
1470
+ subscriber[1]();
1471
+ subscriber_queue.push(subscriber, value);
1472
+ }
1473
+ if (run_queue) {
1474
+ for (let i = 0; i < subscriber_queue.length; i += 2) subscriber_queue[i][0](subscriber_queue[i + 1]);
1475
+ subscriber_queue.length = 0;
1476
+ }
1477
+ }
1478
+ }
1479
+ }
1480
+ /**
1481
+ * @param {Updater<T>} fn
1482
+ * @returns {void}
1483
+ */
1484
+ function update(fn) {
1485
+ set(fn(value));
1486
+ }
1487
+ /**
1488
+ * @param {Subscriber<T>} run
1489
+ * @param {() => void} [invalidate]
1490
+ * @returns {Unsubscriber}
1491
+ */
1492
+ function subscribe(run, invalidate = noop) {
1493
+ /** @type {SubscribeInvalidateTuple<T>} */
1494
+ const subscriber = [run, invalidate];
1495
+ subscribers.add(subscriber);
1496
+ if (subscribers.size === 1) stop = start(set, update) || noop;
1497
+ run(value);
1498
+ return () => {
1499
+ subscribers.delete(subscriber);
1500
+ if (subscribers.size === 0 && stop) {
1501
+ stop();
1502
+ stop = null;
1503
+ }
1504
+ };
1505
+ }
1506
+ return {
1507
+ set,
1508
+ update,
1509
+ subscribe
1510
+ };
1511
+ }
1512
+ //#endregion
1513
+ //#region ../../node_modules/svelte/src/internal/client/reactivity/batch.js
1514
+ /** @import { Fork } from 'svelte' */
1515
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
1516
+ /** @type {Set<Batch>} */
1517
+ var batches = /* @__PURE__ */ new Set();
1518
+ /** @type {Batch | null} */
1519
+ var current_batch = null;
1520
+ /**
1521
+ * When time travelling (i.e. working in one batch, while other batches
1522
+ * still have ongoing work), we ignore the real values of affected
1523
+ * signals in favour of their values within the batch
1524
+ * @type {Map<Value, any> | null}
1525
+ */
1526
+ var batch_values = null;
1527
+ /** @type {Effect | null} */
1528
+ var last_scheduled_effect = null;
1529
+ var is_flushing_sync = false;
1530
+ var is_processing = false;
1531
+ /**
1532
+ * During traversal, this is an array. Newly created effects are (if not immediately
1533
+ * executed) pushed to this array, rather than going through the scheduling
1534
+ * rigamarole that would cause another turn of the flush loop.
1535
+ * @type {Effect[] | null}
1536
+ */
1537
+ var collected_effects = null;
1538
+ /**
1539
+ * An array of effects that are marked during traversal as a result of a `set`
1540
+ * (not `internal_set`) call. These will be added to the next batch and
1541
+ * trigger another `batch.process()`
1542
+ * @type {Effect[] | null}
1543
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1544
+ */
1545
+ var legacy_updates = null;
1546
+ var flush_count = 0;
1547
+ var uid = 1;
1548
+ var Batch = class Batch {
1549
+ id = uid++;
1550
+ /**
1551
+ * The current values of any signals that are updated in this batch.
1552
+ * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
1553
+ * They keys of this map are identical to `this.#previous`
1554
+ * @type {Map<Value, [any, boolean]>}
1555
+ */
1556
+ current = /* @__PURE__ */ new Map();
1557
+ /**
1558
+ * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
1559
+ * They keys of this map are identical to `this.#current`
1560
+ * @type {Map<Value, any>}
1561
+ */
1562
+ previous = /* @__PURE__ */ new Map();
1563
+ /**
1564
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
1565
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
1566
+ * @type {Set<(batch: Batch) => void>}
1567
+ */
1568
+ #commit_callbacks = /* @__PURE__ */ new Set();
1569
+ /**
1570
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
1571
+ * @type {Set<(batch: Batch) => void>}
1572
+ */
1573
+ #discard_callbacks = /* @__PURE__ */ new Set();
1574
+ /**
1575
+ * Callbacks that should run only when a fork is committed.
1576
+ * @type {Set<(batch: Batch) => void>}
1577
+ */
1578
+ #fork_commit_callbacks = /* @__PURE__ */ new Set();
1579
+ /**
1580
+ * Async effects that are currently in flight
1581
+ * @type {Map<Effect, number>}
1582
+ */
1583
+ #pending = /* @__PURE__ */ new Map();
1584
+ /**
1585
+ * Async effects that are currently in flight, _not_ inside a pending boundary
1586
+ * @type {Map<Effect, number>}
1587
+ */
1588
+ #blocking_pending = /* @__PURE__ */ new Map();
1589
+ /**
1590
+ * A deferred that resolves when the batch is committed, used with `settled()`
1591
+ * TODO replace with Promise.withResolvers once supported widely enough
1592
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
1593
+ */
1594
+ #deferred = null;
1595
+ /**
1596
+ * The root effects that need to be flushed
1597
+ * @type {Effect[]}
1598
+ */
1599
+ #roots = [];
1600
+ /**
1601
+ * Effects created while this batch was active.
1602
+ * @type {Effect[]}
1603
+ */
1604
+ #new_effects = [];
1605
+ /**
1606
+ * Deferred effects (which run after async work has completed) that are DIRTY
1607
+ * @type {Set<Effect>}
1608
+ */
1609
+ #dirty_effects = /* @__PURE__ */ new Set();
1610
+ /**
1611
+ * Deferred effects that are MAYBE_DIRTY
1612
+ * @type {Set<Effect>}
1613
+ */
1614
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
1615
+ /**
1616
+ * A map of branches that still exist, but will be destroyed when this batch
1617
+ * is committed — we skip over these during `process`.
1618
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
1619
+ * so they can be rescheduled if the branch survives.
1620
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
1621
+ */
1622
+ #skipped_branches = /* @__PURE__ */ new Map();
1623
+ /**
1624
+ * Inverse of #skipped_branches which we need to tell prior batches to unskip them when committing
1625
+ * @type {Set<Effect>}
1626
+ */
1627
+ #unskipped_branches = /* @__PURE__ */ new Set();
1628
+ is_fork = false;
1629
+ #decrement_queued = false;
1630
+ /** @type {Set<Batch>} */
1631
+ #blockers = /* @__PURE__ */ new Set();
1632
+ #is_deferred() {
1633
+ return this.is_fork || this.#blocking_pending.size > 0;
1634
+ }
1635
+ #is_blocked() {
1636
+ for (const batch of this.#blockers) for (const effect of batch.#blocking_pending.keys()) {
1637
+ var skipped = false;
1638
+ var e = effect;
1639
+ while (e.parent !== null) {
1640
+ if (this.#skipped_branches.has(e)) {
1641
+ skipped = true;
1642
+ break;
1643
+ }
1644
+ e = e.parent;
1645
+ }
1646
+ if (!skipped) return true;
1647
+ }
1648
+ return false;
1649
+ }
1650
+ /**
1651
+ * Add an effect to the #skipped_branches map and reset its children
1652
+ * @param {Effect} effect
1653
+ */
1654
+ skip_effect(effect) {
1655
+ if (!this.#skipped_branches.has(effect)) this.#skipped_branches.set(effect, {
1656
+ d: [],
1657
+ m: []
1658
+ });
1659
+ this.#unskipped_branches.delete(effect);
1660
+ }
1661
+ /**
1662
+ * Remove an effect from the #skipped_branches map and reschedule
1663
+ * any tracked dirty/maybe_dirty child effects
1664
+ * @param {Effect} effect
1665
+ * @param {(e: Effect) => void} callback
1666
+ */
1667
+ unskip_effect(effect, callback = (e) => this.schedule(e)) {
1668
+ var tracked = this.#skipped_branches.get(effect);
1669
+ if (tracked) {
1670
+ this.#skipped_branches.delete(effect);
1671
+ for (var e of tracked.d) {
1672
+ set_signal_status(e, DIRTY);
1673
+ callback(e);
1674
+ }
1675
+ for (e of tracked.m) {
1676
+ set_signal_status(e, MAYBE_DIRTY);
1677
+ callback(e);
1678
+ }
1679
+ }
1680
+ this.#unskipped_branches.add(effect);
1681
+ }
1682
+ #process() {
1683
+ if (flush_count++ > 1e3) {
1684
+ batches.delete(this);
1685
+ infinite_loop_guard();
1686
+ }
1687
+ if (!this.#is_deferred()) {
1688
+ for (const e of this.#dirty_effects) {
1689
+ this.#maybe_dirty_effects.delete(e);
1690
+ set_signal_status(e, DIRTY);
1691
+ this.schedule(e);
1692
+ }
1693
+ for (const e of this.#maybe_dirty_effects) {
1694
+ set_signal_status(e, MAYBE_DIRTY);
1695
+ this.schedule(e);
1696
+ }
1697
+ }
1698
+ const roots = this.#roots;
1699
+ this.#roots = [];
1700
+ this.apply();
1701
+ /** @type {Effect[]} */
1702
+ var effects = collected_effects = [];
1703
+ /** @type {Effect[]} */
1704
+ var render_effects = [];
1705
+ /**
1706
+ * @type {Effect[]}
1707
+ * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1708
+ */
1709
+ var updates = legacy_updates = [];
1710
+ for (const root of roots) try {
1711
+ this.#traverse(root, effects, render_effects);
1712
+ } catch (e) {
1713
+ reset_all(root);
1714
+ throw e;
1715
+ }
1716
+ current_batch = null;
1717
+ if (updates.length > 0) {
1718
+ var batch = Batch.ensure();
1719
+ for (const e of updates) batch.schedule(e);
1720
+ }
1721
+ collected_effects = null;
1722
+ legacy_updates = null;
1723
+ if (this.#is_deferred() || this.#is_blocked()) {
1724
+ this.#defer_effects(render_effects);
1725
+ this.#defer_effects(effects);
1726
+ for (const [e, t] of this.#skipped_branches) reset_branch(e, t);
1727
+ } else {
1728
+ if (this.#pending.size === 0) batches.delete(this);
1729
+ this.#dirty_effects.clear();
1730
+ this.#maybe_dirty_effects.clear();
1731
+ for (const fn of this.#commit_callbacks) fn(this);
1732
+ this.#commit_callbacks.clear();
1733
+ flush_queued_effects(render_effects);
1734
+ flush_queued_effects(effects);
1735
+ this.#deferred?.resolve();
1736
+ }
1737
+ var next_batch = current_batch;
1738
+ if (this.#roots.length > 0) {
1739
+ const batch = next_batch ??= this;
1740
+ batch.#roots.push(...this.#roots.filter((r) => !batch.#roots.includes(r)));
1741
+ }
1742
+ if (next_batch !== null) {
1743
+ batches.add(next_batch);
1744
+ next_batch.#process();
1745
+ }
1746
+ }
1747
+ /**
1748
+ * Traverse the effect tree, executing effects or stashing
1749
+ * them for later execution as appropriate
1750
+ * @param {Effect} root
1751
+ * @param {Effect[]} effects
1752
+ * @param {Effect[]} render_effects
1753
+ */
1754
+ #traverse(root, effects, render_effects) {
1755
+ root.f ^= CLEAN;
1756
+ var effect = root.first;
1757
+ while (effect !== null) {
1758
+ var flags = effect.f;
1759
+ var is_branch = (flags & 96) !== 0;
1760
+ if (!(is_branch && (flags & 1024) !== 0 || (flags & 8192) !== 0 || this.#skipped_branches.has(effect)) && effect.fn !== null) {
1761
+ if (is_branch) effect.f ^= CLEAN;
1762
+ else if ((flags & 4) !== 0) effects.push(effect);
1763
+ else if (is_dirty(effect)) {
1764
+ if ((flags & 16) !== 0) this.#maybe_dirty_effects.add(effect);
1765
+ update_effect(effect);
1766
+ }
1767
+ var child = effect.first;
1768
+ if (child !== null) {
1769
+ effect = child;
1770
+ continue;
1771
+ }
1772
+ }
1773
+ while (effect !== null) {
1774
+ var next = effect.next;
1775
+ if (next !== null) {
1776
+ effect = next;
1777
+ break;
1778
+ }
1779
+ effect = effect.parent;
1780
+ }
1781
+ }
1782
+ }
1783
+ /**
1784
+ * @param {Effect[]} effects
1785
+ */
1786
+ #defer_effects(effects) {
1787
+ for (var i = 0; i < effects.length; i += 1) defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
1788
+ }
1789
+ /**
1790
+ * Associate a change to a given source with the current
1791
+ * batch, noting its previous and current values
1792
+ * @param {Value} source
1793
+ * @param {any} value
1794
+ * @param {boolean} [is_derived]
1795
+ */
1796
+ capture(source, value, is_derived = false) {
1797
+ if (source.v !== UNINITIALIZED && !this.previous.has(source)) this.previous.set(source, source.v);
1798
+ if ((source.f & 8388608) === 0) {
1799
+ this.current.set(source, [value, is_derived]);
1800
+ batch_values?.set(source, value);
1801
+ }
1802
+ if (!this.is_fork) source.v = value;
1803
+ }
1804
+ activate() {
1805
+ current_batch = this;
1806
+ }
1807
+ deactivate() {
1808
+ current_batch = null;
1809
+ batch_values = null;
1810
+ }
1811
+ flush() {
1812
+ try {
1813
+ is_processing = true;
1814
+ current_batch = this;
1815
+ this.#process();
1816
+ } finally {
1817
+ flush_count = 0;
1818
+ last_scheduled_effect = null;
1819
+ collected_effects = null;
1820
+ legacy_updates = null;
1821
+ is_processing = false;
1822
+ current_batch = null;
1823
+ batch_values = null;
1824
+ old_values.clear();
1825
+ }
1826
+ }
1827
+ discard() {
1828
+ for (const fn of this.#discard_callbacks) fn(this);
1829
+ this.#discard_callbacks.clear();
1830
+ this.#fork_commit_callbacks.clear();
1831
+ batches.delete(this);
1832
+ }
1833
+ /**
1834
+ * @param {Effect} effect
1835
+ */
1836
+ register_created_effect(effect) {
1837
+ this.#new_effects.push(effect);
1838
+ }
1839
+ #commit() {
1840
+ for (const batch of batches) {
1841
+ var is_earlier = batch.id < this.id;
1842
+ /** @type {Source[]} */
1843
+ var sources = [];
1844
+ for (const [source, [value, is_derived]] of this.current) {
1845
+ if (batch.current.has(source)) {
1846
+ var batch_value = batch.current.get(source)[0];
1847
+ if (is_earlier && value !== batch_value) batch.current.set(source, [value, is_derived]);
1848
+ else continue;
1849
+ }
1850
+ sources.push(source);
1851
+ }
1852
+ var others = [...batch.current.keys()].filter((s) => !this.current.has(s));
1853
+ if (others.length === 0) {
1854
+ if (is_earlier) batch.discard();
1855
+ } else if (sources.length > 0) {
1856
+ if (is_earlier) for (const unskipped of this.#unskipped_branches) batch.unskip_effect(unskipped, (e) => {
1857
+ if ((e.f & 4194320) !== 0) batch.schedule(e);
1858
+ else batch.#defer_effects([e]);
1859
+ });
1860
+ batch.activate();
1861
+ /** @type {Set<Value>} */
1862
+ var marked = /* @__PURE__ */ new Set();
1863
+ /** @type {Map<Reaction, boolean>} */
1864
+ var checked = /* @__PURE__ */ new Map();
1865
+ for (var source of sources) mark_effects(source, others, marked, checked);
1866
+ checked = /* @__PURE__ */ new Map();
1867
+ var current_unequal = [...batch.current.keys()].filter((c) => this.current.has(c) ? this.current.get(c)[0] !== c : true);
1868
+ for (const effect of this.#new_effects) if ((effect.f & 155648) === 0 && depends_on(effect, current_unequal, checked)) if ((effect.f & 4194320) !== 0) {
1869
+ set_signal_status(effect, DIRTY);
1870
+ batch.schedule(effect);
1871
+ } else batch.#dirty_effects.add(effect);
1872
+ if (batch.#roots.length > 0) {
1873
+ batch.apply();
1874
+ for (var root of batch.#roots) batch.#traverse(root, [], []);
1875
+ batch.#roots = [];
1876
+ }
1877
+ batch.deactivate();
1878
+ }
1879
+ }
1880
+ for (const batch of batches) if (batch.#blockers.has(this)) {
1881
+ batch.#blockers.delete(this);
1882
+ if (batch.#blockers.size === 0 && !batch.#is_deferred()) {
1883
+ batch.activate();
1884
+ batch.#process();
1885
+ }
1886
+ }
1887
+ }
1888
+ /**
1889
+ * @param {boolean} blocking
1890
+ * @param {Effect} effect
1891
+ */
1892
+ increment(blocking, effect) {
1893
+ let pending_count = this.#pending.get(effect) ?? 0;
1894
+ this.#pending.set(effect, pending_count + 1);
1895
+ if (blocking) {
1896
+ let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
1897
+ this.#blocking_pending.set(effect, blocking_pending_count + 1);
1898
+ }
1899
+ }
1900
+ /**
1901
+ * @param {boolean} blocking
1902
+ * @param {Effect} effect
1903
+ * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
1904
+ */
1905
+ decrement(blocking, effect, skip) {
1906
+ let pending_count = this.#pending.get(effect) ?? 0;
1907
+ if (pending_count === 1) this.#pending.delete(effect);
1908
+ else this.#pending.set(effect, pending_count - 1);
1909
+ if (blocking) {
1910
+ let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
1911
+ if (blocking_pending_count === 1) this.#blocking_pending.delete(effect);
1912
+ else this.#blocking_pending.set(effect, blocking_pending_count - 1);
1913
+ }
1914
+ if (this.#decrement_queued || skip) return;
1915
+ this.#decrement_queued = true;
1916
+ queue_micro_task(() => {
1917
+ this.#decrement_queued = false;
1918
+ this.flush();
1919
+ });
1920
+ }
1921
+ /**
1922
+ * @param {Set<Effect>} dirty_effects
1923
+ * @param {Set<Effect>} maybe_dirty_effects
1924
+ */
1925
+ transfer_effects(dirty_effects, maybe_dirty_effects) {
1926
+ for (const e of dirty_effects) this.#dirty_effects.add(e);
1927
+ for (const e of maybe_dirty_effects) this.#maybe_dirty_effects.add(e);
1928
+ dirty_effects.clear();
1929
+ maybe_dirty_effects.clear();
1930
+ }
1931
+ /** @param {(batch: Batch) => void} fn */
1932
+ oncommit(fn) {
1933
+ this.#commit_callbacks.add(fn);
1934
+ }
1935
+ /** @param {(batch: Batch) => void} fn */
1936
+ ondiscard(fn) {
1937
+ this.#discard_callbacks.add(fn);
1938
+ }
1939
+ /** @param {(batch: Batch) => void} fn */
1940
+ on_fork_commit(fn) {
1941
+ this.#fork_commit_callbacks.add(fn);
1942
+ }
1943
+ run_fork_commit_callbacks() {
1944
+ for (const fn of this.#fork_commit_callbacks) fn(this);
1945
+ this.#fork_commit_callbacks.clear();
1946
+ }
1947
+ settled() {
1948
+ return (this.#deferred ??= deferred()).promise;
1949
+ }
1950
+ static ensure() {
1951
+ if (current_batch === null) {
1952
+ const batch = current_batch = new Batch();
1953
+ if (!is_processing) {
1954
+ batches.add(current_batch);
1955
+ if (!is_flushing_sync) queue_micro_task(() => {
1956
+ if (current_batch !== batch) return;
1957
+ batch.flush();
1958
+ });
1959
+ }
1960
+ }
1961
+ return current_batch;
1962
+ }
1963
+ apply() {
1964
+ {
1965
+ batch_values = null;
1966
+ return;
1967
+ }
1968
+ }
1969
+ /**
1970
+ *
1971
+ * @param {Effect} effect
1972
+ */
1973
+ schedule(effect) {
1974
+ last_scheduled_effect = effect;
1975
+ if (effect.b?.is_pending && (effect.f & 16777228) !== 0 && (effect.f & 32768) === 0) {
1976
+ effect.b.defer_effect(effect);
1977
+ return;
1978
+ }
1979
+ var e = effect;
1980
+ while (e.parent !== null) {
1981
+ e = e.parent;
1982
+ var flags = e.f;
1983
+ if (collected_effects !== null && e === active_effect) {
1984
+ if ((active_reaction === null || (active_reaction.f & 2) === 0) && true) return;
1985
+ }
1986
+ if ((flags & 96) !== 0) {
1987
+ if ((flags & 1024) === 0) return;
1988
+ e.f ^= CLEAN;
1989
+ }
1990
+ }
1991
+ this.#roots.push(e);
1992
+ }
1993
+ };
1994
+ /**
1995
+ * Synchronously flush any pending updates.
1996
+ * Returns void if no callback is provided, otherwise returns the result of calling the callback.
1997
+ * @template [T=void]
1998
+ * @param {(() => T) | undefined} [fn]
1999
+ * @returns {T}
2000
+ */
2001
+ function flushSync(fn) {
2002
+ var was_flushing_sync = is_flushing_sync;
2003
+ is_flushing_sync = true;
2004
+ try {
2005
+ var result;
2006
+ if (fn) ;
2007
+ while (true) {
2008
+ flush_tasks();
2009
+ if (current_batch === null) return result;
2010
+ current_batch.flush();
2011
+ }
2012
+ } finally {
2013
+ is_flushing_sync = was_flushing_sync;
2014
+ }
2015
+ }
2016
+ function infinite_loop_guard() {
2017
+ try {
2018
+ effect_update_depth_exceeded();
2019
+ } catch (error) {
2020
+ invoke_error_boundary(error, last_scheduled_effect);
2021
+ }
2022
+ }
2023
+ /** @type {Set<Effect> | null} */
2024
+ var eager_block_effects = null;
2025
+ /**
2026
+ * @param {Array<Effect>} effects
2027
+ * @returns {void}
2028
+ */
2029
+ function flush_queued_effects(effects) {
2030
+ var length = effects.length;
2031
+ if (length === 0) return;
2032
+ var i = 0;
2033
+ while (i < length) {
2034
+ var effect = effects[i++];
2035
+ if ((effect.f & 24576) === 0 && is_dirty(effect)) {
2036
+ eager_block_effects = /* @__PURE__ */ new Set();
2037
+ update_effect(effect);
2038
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) unlink_effect(effect);
2039
+ if (eager_block_effects?.size > 0) {
2040
+ old_values.clear();
2041
+ for (const e of eager_block_effects) {
2042
+ if ((e.f & 24576) !== 0) continue;
2043
+ /** @type {Effect[]} */
2044
+ const ordered_effects = [e];
2045
+ let ancestor = e.parent;
2046
+ while (ancestor !== null) {
2047
+ if (eager_block_effects.has(ancestor)) {
2048
+ eager_block_effects.delete(ancestor);
2049
+ ordered_effects.push(ancestor);
2050
+ }
2051
+ ancestor = ancestor.parent;
2052
+ }
2053
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
2054
+ const e = ordered_effects[j];
2055
+ if ((e.f & 24576) !== 0) continue;
2056
+ update_effect(e);
2057
+ }
2058
+ }
2059
+ eager_block_effects.clear();
2060
+ }
2061
+ }
2062
+ }
2063
+ eager_block_effects = null;
2064
+ }
2065
+ /**
2066
+ * This is similar to `mark_reactions`, but it only marks async/block effects
2067
+ * depending on `value` and at least one of the other `sources`, so that
2068
+ * these effects can re-run after another batch has been committed
2069
+ * @param {Value} value
2070
+ * @param {Source[]} sources
2071
+ * @param {Set<Value>} marked
2072
+ * @param {Map<Reaction, boolean>} checked
2073
+ */
2074
+ function mark_effects(value, sources, marked, checked) {
2075
+ if (marked.has(value)) return;
2076
+ marked.add(value);
2077
+ if (value.reactions !== null) for (const reaction of value.reactions) {
2078
+ const flags = reaction.f;
2079
+ if ((flags & 2) !== 0) mark_effects(reaction, sources, marked, checked);
2080
+ else if ((flags & 4194320) !== 0 && (flags & 2048) === 0 && depends_on(reaction, sources, checked)) {
2081
+ set_signal_status(reaction, DIRTY);
2082
+ schedule_effect(reaction);
2083
+ }
2084
+ }
2085
+ }
2086
+ /**
2087
+ * @param {Reaction} reaction
2088
+ * @param {Source[]} sources
2089
+ * @param {Map<Reaction, boolean>} checked
2090
+ */
2091
+ function depends_on(reaction, sources, checked) {
2092
+ const depends = checked.get(reaction);
2093
+ if (depends !== void 0) return depends;
2094
+ if (reaction.deps !== null) for (const dep of reaction.deps) {
2095
+ if (includes.call(sources, dep)) return true;
2096
+ if ((dep.f & 2) !== 0 && depends_on(dep, sources, checked)) {
2097
+ checked.set(dep, true);
2098
+ return true;
2099
+ }
2100
+ }
2101
+ checked.set(reaction, false);
2102
+ return false;
2103
+ }
2104
+ /**
2105
+ * @param {Effect} effect
2106
+ * @returns {void}
2107
+ */
2108
+ function schedule_effect(effect) {
2109
+ /** @type {Batch} */ current_batch.schedule(effect);
2110
+ }
2111
+ /**
2112
+ * Mark all the effects inside a skipped branch CLEAN, so that
2113
+ * they can be correctly rescheduled later. Tracks dirty and maybe_dirty
2114
+ * effects so they can be rescheduled if the branch survives.
2115
+ * @param {Effect} effect
2116
+ * @param {{ d: Effect[], m: Effect[] }} tracked
2117
+ */
2118
+ function reset_branch(effect, tracked) {
2119
+ if ((effect.f & 32) !== 0 && (effect.f & 1024) !== 0) return;
2120
+ if ((effect.f & 2048) !== 0) tracked.d.push(effect);
2121
+ else if ((effect.f & 4096) !== 0) tracked.m.push(effect);
2122
+ set_signal_status(effect, CLEAN);
2123
+ var e = effect.first;
2124
+ while (e !== null) {
2125
+ reset_branch(e, tracked);
2126
+ e = e.next;
2127
+ }
2128
+ }
2129
+ /**
2130
+ * Mark an entire effect tree clean following an error
2131
+ * @param {Effect} effect
2132
+ */
2133
+ function reset_all(effect) {
2134
+ set_signal_status(effect, CLEAN);
2135
+ var e = effect.first;
2136
+ while (e !== null) {
2137
+ reset_all(e);
2138
+ e = e.next;
2139
+ }
2140
+ }
2141
+ //#endregion
2142
+ //#region ../../node_modules/svelte/src/reactivity/create-subscriber.js
2143
+ /**
2144
+ * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
2145
+ * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
2146
+ *
2147
+ * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),
2148
+ * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.
2149
+ *
2150
+ * If `start` returns a cleanup function, it will be called when the effect is destroyed.
2151
+ *
2152
+ * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects
2153
+ * are active, and the returned teardown function will only be called when all effects are destroyed.
2154
+ *
2155
+ * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):
2156
+ *
2157
+ * ```js
2158
+ * import { createSubscriber } from 'svelte/reactivity';
2159
+ * import { on } from 'svelte/events';
2160
+ *
2161
+ * export class MediaQuery {
2162
+ * #query;
2163
+ * #subscribe;
2164
+ *
2165
+ * constructor(query) {
2166
+ * this.#query = window.matchMedia(`(${query})`);
2167
+ *
2168
+ * this.#subscribe = createSubscriber((update) => {
2169
+ * // when the `change` event occurs, re-run any effects that read `this.current`
2170
+ * const off = on(this.#query, 'change', update);
2171
+ *
2172
+ * // stop listening when all the effects are destroyed
2173
+ * return () => off();
2174
+ * });
2175
+ * }
2176
+ *
2177
+ * get current() {
2178
+ * // This makes the getter reactive, if read in an effect
2179
+ * this.#subscribe();
2180
+ *
2181
+ * // Return the current state of the query, whether or not we're in an effect
2182
+ * return this.#query.matches;
2183
+ * }
2184
+ * }
2185
+ * ```
2186
+ * @param {(update: () => void) => (() => void) | void} start
2187
+ * @since 5.7.0
2188
+ */
2189
+ function createSubscriber(start) {
2190
+ let subscribers = 0;
2191
+ let version = source(0);
2192
+ /** @type {(() => void) | void} */
2193
+ let stop;
2194
+ return () => {
2195
+ if (effect_tracking()) {
2196
+ get(version);
2197
+ render_effect(() => {
2198
+ if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
2199
+ subscribers += 1;
2200
+ return () => {
2201
+ queue_micro_task(() => {
2202
+ subscribers -= 1;
2203
+ if (subscribers === 0) {
2204
+ stop?.();
2205
+ stop = void 0;
2206
+ increment(version);
2207
+ }
2208
+ });
2209
+ };
2210
+ });
2211
+ }
2212
+ };
2213
+ }
2214
+ //#endregion
2215
+ //#region ../../node_modules/svelte/src/internal/client/dom/blocks/boundary.js
2216
+ /** @import { Effect, Source, TemplateNode, } from '#client' */
2217
+ /**
2218
+ * @typedef {{
2219
+ * onerror?: (error: unknown, reset: () => void) => void;
2220
+ * failed?: (anchor: Node, error: () => unknown, reset: () => () => void) => void;
2221
+ * pending?: (anchor: Node) => void;
2222
+ * }} BoundaryProps
2223
+ */
2224
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
2225
+ /**
2226
+ * @param {TemplateNode} node
2227
+ * @param {BoundaryProps} props
2228
+ * @param {((anchor: Node) => void)} children
2229
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
2230
+ * @returns {void}
2231
+ */
2232
+ function boundary(node, props, children, transform_error) {
2233
+ new Boundary(node, props, children, transform_error);
2234
+ }
2235
+ var Boundary = class {
2236
+ /** @type {Boundary | null} */
2237
+ parent;
2238
+ is_pending = false;
2239
+ /**
2240
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
2241
+ * Inherited from parent boundary, or defaults to identity.
2242
+ * @type {(error: unknown) => unknown}
2243
+ */
2244
+ transform_error;
2245
+ /** @type {TemplateNode} */
2246
+ #anchor;
2247
+ /** @type {TemplateNode | null} */
2248
+ #hydrate_open = hydrating ? hydrate_node : null;
2249
+ /** @type {BoundaryProps} */
2250
+ #props;
2251
+ /** @type {((anchor: Node) => void)} */
2252
+ #children;
2253
+ /** @type {Effect} */
2254
+ #effect;
2255
+ /** @type {Effect | null} */
2256
+ #main_effect = null;
2257
+ /** @type {Effect | null} */
2258
+ #pending_effect = null;
2259
+ /** @type {Effect | null} */
2260
+ #failed_effect = null;
2261
+ /** @type {DocumentFragment | null} */
2262
+ #offscreen_fragment = null;
2263
+ #local_pending_count = 0;
2264
+ #pending_count = 0;
2265
+ #pending_count_update_queued = false;
2266
+ /** @type {Set<Effect>} */
2267
+ #dirty_effects = /* @__PURE__ */ new Set();
2268
+ /** @type {Set<Effect>} */
2269
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
2270
+ /**
2271
+ * A source containing the number of pending async deriveds/expressions.
2272
+ * Only created if `$effect.pending()` is used inside the boundary,
2273
+ * otherwise updating the source results in needless `Batch.ensure()`
2274
+ * calls followed by no-op flushes
2275
+ * @type {Source<number> | null}
2276
+ */
2277
+ #effect_pending = null;
2278
+ #effect_pending_subscriber = createSubscriber(() => {
2279
+ this.#effect_pending = source(this.#local_pending_count);
2280
+ return () => {
2281
+ this.#effect_pending = null;
2282
+ };
2283
+ });
2284
+ /**
2285
+ * @param {TemplateNode} node
2286
+ * @param {BoundaryProps} props
2287
+ * @param {((anchor: Node) => void)} children
2288
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
2289
+ */
2290
+ constructor(node, props, children, transform_error) {
2291
+ this.#anchor = node;
2292
+ this.#props = props;
2293
+ this.#children = (anchor) => {
2294
+ var effect = active_effect;
2295
+ effect.b = this;
2296
+ effect.f |= 128;
2297
+ children(anchor);
2298
+ };
2299
+ this.parent = active_effect.b;
2300
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
2301
+ this.#effect = block(() => {
2302
+ if (hydrating) {
2303
+ const comment = this.#hydrate_open;
2304
+ hydrate_next();
2305
+ const server_rendered_pending = comment.data === "[!";
2306
+ if (comment.data.startsWith("[?")) {
2307
+ const serialized_error = JSON.parse(comment.data.slice(2));
2308
+ this.#hydrate_failed_content(serialized_error);
2309
+ } else if (server_rendered_pending) this.#hydrate_pending_content();
2310
+ else this.#hydrate_resolved_content();
2311
+ } else this.#render();
2312
+ }, flags);
2313
+ if (hydrating) this.#anchor = hydrate_node;
2314
+ }
2315
+ #hydrate_resolved_content() {
2316
+ try {
2317
+ this.#main_effect = branch(() => this.#children(this.#anchor));
2318
+ } catch (error) {
2319
+ this.error(error);
2320
+ }
2321
+ }
2322
+ /**
2323
+ * @param {unknown} error The deserialized error from the server's hydration comment
2324
+ */
2325
+ #hydrate_failed_content(error) {
2326
+ const failed = this.#props.failed;
2327
+ if (!failed) return;
2328
+ this.#failed_effect = branch(() => {
2329
+ failed(this.#anchor, () => error, () => () => {});
2330
+ });
2331
+ }
2332
+ #hydrate_pending_content() {
2333
+ const pending = this.#props.pending;
2334
+ if (!pending) return;
2335
+ this.is_pending = true;
2336
+ this.#pending_effect = branch(() => pending(this.#anchor));
2337
+ queue_micro_task(() => {
2338
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
2339
+ var anchor = create_text();
2340
+ fragment.append(anchor);
2341
+ this.#main_effect = this.#run(() => {
2342
+ return branch(() => this.#children(anchor));
2343
+ });
2344
+ if (this.#pending_count === 0) {
2345
+ this.#anchor.before(fragment);
2346
+ this.#offscreen_fragment = null;
2347
+ pause_effect(this.#pending_effect, () => {
2348
+ this.#pending_effect = null;
2349
+ });
2350
+ this.#resolve(current_batch);
2351
+ }
2352
+ });
2353
+ }
2354
+ #render() {
2355
+ try {
2356
+ this.is_pending = this.has_pending_snippet();
2357
+ this.#pending_count = 0;
2358
+ this.#local_pending_count = 0;
2359
+ this.#main_effect = branch(() => {
2360
+ this.#children(this.#anchor);
2361
+ });
2362
+ if (this.#pending_count > 0) {
2363
+ var fragment = this.#offscreen_fragment = document.createDocumentFragment();
2364
+ move_effect(this.#main_effect, fragment);
2365
+ const pending = this.#props.pending;
2366
+ this.#pending_effect = branch(() => pending(this.#anchor));
2367
+ } else this.#resolve(current_batch);
2368
+ } catch (error) {
2369
+ this.error(error);
2370
+ }
2371
+ }
2372
+ /**
2373
+ * @param {Batch} batch
2374
+ */
2375
+ #resolve(batch) {
2376
+ this.is_pending = false;
2377
+ batch.transfer_effects(this.#dirty_effects, this.#maybe_dirty_effects);
2378
+ }
2379
+ /**
2380
+ * Defer an effect inside a pending boundary until the boundary resolves
2381
+ * @param {Effect} effect
2382
+ */
2383
+ defer_effect(effect) {
2384
+ defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects);
2385
+ }
2386
+ /**
2387
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
2388
+ * @returns {boolean}
2389
+ */
2390
+ is_rendered() {
2391
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
2392
+ }
2393
+ has_pending_snippet() {
2394
+ return !!this.#props.pending;
2395
+ }
2396
+ /**
2397
+ * @template T
2398
+ * @param {() => T} fn
2399
+ */
2400
+ #run(fn) {
2401
+ var previous_effect = active_effect;
2402
+ var previous_reaction = active_reaction;
2403
+ var previous_ctx = component_context;
2404
+ set_active_effect(this.#effect);
2405
+ set_active_reaction(this.#effect);
2406
+ set_component_context(this.#effect.ctx);
2407
+ try {
2408
+ Batch.ensure();
2409
+ return fn();
2410
+ } catch (e) {
2411
+ handle_error(e);
2412
+ return null;
2413
+ } finally {
2414
+ set_active_effect(previous_effect);
2415
+ set_active_reaction(previous_reaction);
2416
+ set_component_context(previous_ctx);
2417
+ }
2418
+ }
2419
+ /**
2420
+ * Updates the pending count associated with the currently visible pending snippet,
2421
+ * if any, such that we can replace the snippet with content once work is done
2422
+ * @param {1 | -1} d
2423
+ * @param {Batch} batch
2424
+ */
2425
+ #update_pending_count(d, batch) {
2426
+ if (!this.has_pending_snippet()) {
2427
+ if (this.parent) this.parent.#update_pending_count(d, batch);
2428
+ return;
2429
+ }
2430
+ this.#pending_count += d;
2431
+ if (this.#pending_count === 0) {
2432
+ this.#resolve(batch);
2433
+ if (this.#pending_effect) pause_effect(this.#pending_effect, () => {
2434
+ this.#pending_effect = null;
2435
+ });
2436
+ if (this.#offscreen_fragment) {
2437
+ this.#anchor.before(this.#offscreen_fragment);
2438
+ this.#offscreen_fragment = null;
2439
+ }
2440
+ }
2441
+ }
2442
+ /**
2443
+ * Update the source that powers `$effect.pending()` inside this boundary,
2444
+ * and controls when the current `pending` snippet (if any) is removed.
2445
+ * Do not call from inside the class
2446
+ * @param {1 | -1} d
2447
+ * @param {Batch} batch
2448
+ */
2449
+ update_pending_count(d, batch) {
2450
+ this.#update_pending_count(d, batch);
2451
+ this.#local_pending_count += d;
2452
+ if (!this.#effect_pending || this.#pending_count_update_queued) return;
2453
+ this.#pending_count_update_queued = true;
2454
+ queue_micro_task(() => {
2455
+ this.#pending_count_update_queued = false;
2456
+ if (this.#effect_pending) internal_set(this.#effect_pending, this.#local_pending_count);
2457
+ });
2458
+ }
2459
+ get_effect_pending() {
2460
+ this.#effect_pending_subscriber();
2461
+ return get(this.#effect_pending);
2462
+ }
2463
+ /** @param {unknown} error */
2464
+ error(error) {
2465
+ if (!this.#props.onerror && !this.#props.failed) throw error;
2466
+ if (current_batch?.is_fork) {
2467
+ if (this.#main_effect) current_batch.skip_effect(this.#main_effect);
2468
+ if (this.#pending_effect) current_batch.skip_effect(this.#pending_effect);
2469
+ if (this.#failed_effect) current_batch.skip_effect(this.#failed_effect);
2470
+ current_batch.on_fork_commit(() => {
2471
+ this.#handle_error(error);
2472
+ });
2473
+ } else this.#handle_error(error);
2474
+ }
2475
+ /**
2476
+ * @param {unknown} error
2477
+ */
2478
+ #handle_error(error) {
2479
+ if (this.#main_effect) {
2480
+ destroy_effect(this.#main_effect);
2481
+ this.#main_effect = null;
2482
+ }
2483
+ if (this.#pending_effect) {
2484
+ destroy_effect(this.#pending_effect);
2485
+ this.#pending_effect = null;
2486
+ }
2487
+ if (this.#failed_effect) {
2488
+ destroy_effect(this.#failed_effect);
2489
+ this.#failed_effect = null;
2490
+ }
2491
+ if (hydrating) {
2492
+ set_hydrate_node(this.#hydrate_open);
2493
+ next();
2494
+ set_hydrate_node(skip_nodes());
2495
+ }
2496
+ var onerror = this.#props.onerror;
2497
+ let failed = this.#props.failed;
2498
+ var did_reset = false;
2499
+ var calling_on_error = false;
2500
+ const reset = () => {
2501
+ if (did_reset) {
2502
+ svelte_boundary_reset_noop();
2503
+ return;
2504
+ }
2505
+ did_reset = true;
2506
+ if (calling_on_error) svelte_boundary_reset_onerror();
2507
+ if (this.#failed_effect !== null) pause_effect(this.#failed_effect, () => {
2508
+ this.#failed_effect = null;
2509
+ });
2510
+ this.#run(() => {
2511
+ this.#render();
2512
+ });
2513
+ };
2514
+ /** @param {unknown} transformed_error */
2515
+ const handle_error_result = (transformed_error) => {
2516
+ try {
2517
+ calling_on_error = true;
2518
+ onerror?.(transformed_error, reset);
2519
+ calling_on_error = false;
2520
+ } catch (error) {
2521
+ invoke_error_boundary(error, this.#effect && this.#effect.parent);
2522
+ }
2523
+ if (failed) this.#failed_effect = this.#run(() => {
2524
+ try {
2525
+ return branch(() => {
2526
+ var effect = active_effect;
2527
+ effect.b = this;
2528
+ effect.f |= 128;
2529
+ failed(this.#anchor, () => transformed_error, () => reset);
2530
+ });
2531
+ } catch (error) {
2532
+ invoke_error_boundary(error, this.#effect.parent);
2533
+ return null;
2534
+ }
2535
+ });
2536
+ };
2537
+ queue_micro_task(() => {
2538
+ /** @type {unknown} */
2539
+ var result;
2540
+ try {
2541
+ result = this.transform_error(error);
2542
+ } catch (e) {
2543
+ invoke_error_boundary(e, this.#effect && this.#effect.parent);
2544
+ return;
2545
+ }
2546
+ if (result !== null && typeof result === "object" && typeof result.then === "function")
2547
+ /** @type {any} */ result.then(
2548
+ handle_error_result,
2549
+ /** @param {unknown} e */
2550
+ (e) => invoke_error_boundary(e, this.#effect && this.#effect.parent)
2551
+ );
2552
+ else handle_error_result(result);
2553
+ });
2554
+ }
2555
+ };
2556
+ /**
2557
+ * @param {Derived} derived
2558
+ * @returns {void}
2559
+ */
2560
+ function destroy_derived_effects(derived) {
2561
+ var effects = derived.effects;
2562
+ if (effects !== null) {
2563
+ derived.effects = null;
2564
+ for (var i = 0; i < effects.length; i += 1) destroy_effect(effects[i]);
2565
+ }
2566
+ }
2567
+ /**
2568
+ * @template T
2569
+ * @param {Derived} derived
2570
+ * @returns {T}
2571
+ */
2572
+ function execute_derived(derived) {
2573
+ var value;
2574
+ var prev_active_effect = active_effect;
2575
+ var parent = derived.parent;
2576
+ if (!is_destroying_effect && parent !== null && (parent.f & 24576) !== 0) {
2577
+ derived_inert();
2578
+ return derived.v;
2579
+ }
2580
+ set_active_effect(parent);
2581
+ try {
2582
+ derived.f &= ~WAS_MARKED;
2583
+ destroy_derived_effects(derived);
2584
+ value = update_reaction(derived);
2585
+ } finally {
2586
+ set_active_effect(prev_active_effect);
2587
+ }
2588
+ return value;
2589
+ }
2590
+ /**
2591
+ * @param {Derived} derived
2592
+ * @returns {void}
2593
+ */
2594
+ function update_derived(derived) {
2595
+ var value = execute_derived(derived);
2596
+ if (!derived.equals(value)) {
2597
+ derived.wv = increment_write_version();
2598
+ if (!current_batch?.is_fork || derived.deps === null) {
2599
+ if (current_batch !== null) current_batch.capture(derived, value, true);
2600
+ else derived.v = value;
2601
+ if (derived.deps === null) {
2602
+ set_signal_status(derived, CLEAN);
2603
+ return;
2604
+ }
2605
+ }
2606
+ }
2607
+ if (is_destroying_effect) return;
2608
+ if (batch_values !== null) {
2609
+ if (effect_tracking() || current_batch?.is_fork) batch_values.set(derived, value);
2610
+ } else update_derived_status(derived);
2611
+ }
2612
+ /**
2613
+ * @param {Derived} derived
2614
+ */
2615
+ function freeze_derived_effects(derived) {
2616
+ if (derived.effects === null) return;
2617
+ for (const e of derived.effects) if (e.teardown || e.ac) {
2618
+ e.teardown?.();
2619
+ e.ac?.abort(STALE_REACTION);
2620
+ e.teardown = noop;
2621
+ e.ac = null;
2622
+ remove_reactions(e, 0);
2623
+ destroy_effect_children(e);
2624
+ }
2625
+ }
2626
+ /**
2627
+ * @param {Derived} derived
2628
+ */
2629
+ function unfreeze_derived_effects(derived) {
2630
+ if (derived.effects === null) return;
2631
+ for (const e of derived.effects) if (e.teardown) update_effect(e);
2632
+ }
2633
+ //#endregion
2634
+ //#region ../../node_modules/svelte/src/internal/client/reactivity/sources.js
2635
+ /** @import { Derived, Effect, Source, Value } from '#client' */
2636
+ /** @type {Set<any>} */
2637
+ var eager_effects = /* @__PURE__ */ new Set();
2638
+ /** @type {Map<Source, any>} */
2639
+ var old_values = /* @__PURE__ */ new Map();
2640
+ var eager_effects_deferred = false;
2641
+ /**
2642
+ * @template V
2643
+ * @param {V} v
2644
+ * @param {Error | null} [stack]
2645
+ * @returns {Source<V>}
2646
+ */
2647
+ function source(v, stack) {
2648
+ return {
2649
+ f: 0,
2650
+ v,
2651
+ reactions: null,
2652
+ equals,
2653
+ rv: 0,
2654
+ wv: 0
2655
+ };
2656
+ }
2657
+ /**
2658
+ * @template V
2659
+ * @param {V} v
2660
+ * @param {Error | null} [stack]
2661
+ */
2662
+ /* @__NO_SIDE_EFFECTS__ */
2663
+ function state(v, stack) {
2664
+ const s = source(v);
2665
+ push_reaction_value(s);
2666
+ return s;
2667
+ }
2668
+ /**
2669
+ * @template V
2670
+ * @param {V} initial_value
2671
+ * @param {boolean} [immutable]
2672
+ * @returns {Source<V>}
2673
+ */
2674
+ /* @__NO_SIDE_EFFECTS__ */
2675
+ function mutable_source(initial_value, immutable = false, trackable = true) {
2676
+ const s = source(initial_value);
2677
+ if (!immutable) s.equals = safe_equals;
2678
+ return s;
2679
+ }
2680
+ /**
2681
+ * @template V
2682
+ * @param {Source<V>} source
2683
+ * @param {V} value
2684
+ * @param {boolean} [should_proxy]
2685
+ * @returns {V}
2686
+ */
2687
+ function set(source, value, should_proxy = false) {
2688
+ if (active_reaction !== null && (!untracking || (active_reaction.f & 131072) !== 0) && is_runes() && (active_reaction.f & 4325394) !== 0 && (current_sources === null || !includes.call(current_sources, source))) state_unsafe_mutation();
2689
+ return internal_set(source, should_proxy ? proxy(value) : value, legacy_updates);
2690
+ }
2691
+ /**
2692
+ * @template V
2693
+ * @param {Source<V>} source
2694
+ * @param {V} value
2695
+ * @param {Effect[] | null} [updated_during_traversal]
2696
+ * @returns {V}
2697
+ */
2698
+ function internal_set(source, value, updated_during_traversal = null) {
2699
+ if (!source.equals(value)) {
2700
+ old_values.set(source, is_destroying_effect ? value : source.v);
2701
+ var batch = Batch.ensure();
2702
+ batch.capture(source, value);
2703
+ if ((source.f & 2) !== 0) {
2704
+ const derived = source;
2705
+ if ((source.f & 2048) !== 0) execute_derived(derived);
2706
+ if (batch_values === null) update_derived_status(derived);
2707
+ }
2708
+ source.wv = increment_write_version();
2709
+ mark_reactions(source, DIRTY, updated_during_traversal);
2710
+ if (active_effect !== null && (active_effect.f & 1024) !== 0 && (active_effect.f & 96) === 0) if (untracked_writes === null) set_untracked_writes([source]);
2711
+ else untracked_writes.push(source);
2712
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) flush_eager_effects();
2713
+ }
2714
+ return value;
2715
+ }
2716
+ function flush_eager_effects() {
2717
+ eager_effects_deferred = false;
2718
+ for (const effect of eager_effects) {
2719
+ if ((effect.f & 1024) !== 0) set_signal_status(effect, MAYBE_DIRTY);
2720
+ if (is_dirty(effect)) update_effect(effect);
2721
+ }
2722
+ eager_effects.clear();
2723
+ }
2724
+ /**
2725
+ * Silently (without using `get`) increment a source
2726
+ * @param {Source<number>} source
2727
+ */
2728
+ function increment(source) {
2729
+ set(source, source.v + 1);
2730
+ }
2731
+ /**
2732
+ * @param {Value} signal
2733
+ * @param {number} status should be DIRTY or MAYBE_DIRTY
2734
+ * @param {Effect[] | null} updated_during_traversal
2735
+ * @returns {void}
2736
+ */
2737
+ function mark_reactions(signal, status, updated_during_traversal) {
2738
+ var reactions = signal.reactions;
2739
+ if (reactions === null) return;
2740
+ var length = reactions.length;
2741
+ for (var i = 0; i < length; i++) {
2742
+ var reaction = reactions[i];
2743
+ var flags = reaction.f;
2744
+ var not_dirty = (flags & DIRTY) === 0;
2745
+ if (not_dirty) set_signal_status(reaction, status);
2746
+ if ((flags & 2) !== 0) {
2747
+ var derived = reaction;
2748
+ batch_values?.delete(derived);
2749
+ if ((flags & 65536) === 0) {
2750
+ if (flags & 512 && (active_effect === null || (active_effect.f & 2097152) === 0)) reaction.f |= WAS_MARKED;
2751
+ mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
2752
+ }
2753
+ } else if (not_dirty) {
2754
+ var effect = reaction;
2755
+ if ((flags & 16) !== 0 && eager_block_effects !== null) eager_block_effects.add(effect);
2756
+ if (updated_during_traversal !== null) updated_during_traversal.push(effect);
2757
+ else schedule_effect(effect);
2758
+ }
2759
+ }
2760
+ }
2761
+ /**
2762
+ * @template T
2763
+ * @param {T} value
2764
+ * @returns {T}
2765
+ */
2766
+ function proxy(value) {
2767
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) return value;
2768
+ const prototype = get_prototype_of(value);
2769
+ if (prototype !== object_prototype && prototype !== array_prototype) return value;
2770
+ /** @type {Map<any, Source<any>>} */
2771
+ var sources = /* @__PURE__ */ new Map();
2772
+ var is_proxied_array = is_array(value);
2773
+ var version = /* @__PURE__ */ state(0);
2774
+ var parent_version = update_version;
2775
+ /**
2776
+ * Executes the proxy in the context of the reaction it was originally created in, if any
2777
+ * @template T
2778
+ * @param {() => T} fn
2779
+ */
2780
+ var with_parent = (fn) => {
2781
+ if (update_version === parent_version) return fn();
2782
+ var reaction = active_reaction;
2783
+ var version = update_version;
2784
+ set_active_reaction(null);
2785
+ set_update_version(parent_version);
2786
+ var result = fn();
2787
+ set_active_reaction(reaction);
2788
+ set_update_version(version);
2789
+ return result;
2790
+ };
2791
+ if (is_proxied_array) sources.set("length", /* @__PURE__ */ state(
2792
+ /** @type {any[]} */
2793
+ value.length));
2794
+ return new Proxy(value, {
2795
+ defineProperty(_, prop, descriptor) {
2796
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) state_descriptors_fixed();
2797
+ var s = sources.get(prop);
2798
+ if (s === void 0) with_parent(() => {
2799
+ var s = /* @__PURE__ */ state(descriptor.value);
2800
+ sources.set(prop, s);
2801
+ return s;
2802
+ });
2803
+ else set(s, descriptor.value, true);
2804
+ return true;
2805
+ },
2806
+ deleteProperty(target, prop) {
2807
+ var s = sources.get(prop);
2808
+ if (s === void 0) {
2809
+ if (prop in target) {
2810
+ const s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
2811
+ sources.set(prop, s);
2812
+ increment(version);
2813
+ }
2814
+ } else {
2815
+ set(s, UNINITIALIZED);
2816
+ increment(version);
2817
+ }
2818
+ return true;
2819
+ },
2820
+ get(target, prop, receiver) {
2821
+ if (prop === STATE_SYMBOL) return value;
2822
+ var s = sources.get(prop);
2823
+ var exists = prop in target;
2824
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
2825
+ s = with_parent(() => {
2826
+ return /* @__PURE__ */ state(proxy(exists ? target[prop] : UNINITIALIZED));
2827
+ });
2828
+ sources.set(prop, s);
2829
+ }
2830
+ if (s !== void 0) {
2831
+ var v = get(s);
2832
+ return v === UNINITIALIZED ? void 0 : v;
2833
+ }
2834
+ return Reflect.get(target, prop, receiver);
2835
+ },
2836
+ getOwnPropertyDescriptor(target, prop) {
2837
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
2838
+ if (descriptor && "value" in descriptor) {
2839
+ var s = sources.get(prop);
2840
+ if (s) descriptor.value = get(s);
2841
+ } else if (descriptor === void 0) {
2842
+ var source = sources.get(prop);
2843
+ var value = source?.v;
2844
+ if (source !== void 0 && value !== UNINITIALIZED) return {
2845
+ enumerable: true,
2846
+ configurable: true,
2847
+ value,
2848
+ writable: true
2849
+ };
2850
+ }
2851
+ return descriptor;
2852
+ },
2853
+ has(target, prop) {
2854
+ if (prop === STATE_SYMBOL) return true;
2855
+ var s = sources.get(prop);
2856
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
2857
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
2858
+ if (s === void 0) {
2859
+ s = with_parent(() => {
2860
+ return /* @__PURE__ */ state(has ? proxy(target[prop]) : UNINITIALIZED);
2861
+ });
2862
+ sources.set(prop, s);
2863
+ }
2864
+ if (get(s) === UNINITIALIZED) return false;
2865
+ }
2866
+ return has;
2867
+ },
2868
+ set(target, prop, value, receiver) {
2869
+ var s = sources.get(prop);
2870
+ var has = prop in target;
2871
+ if (is_proxied_array && prop === "length") for (var i = value; i < s.v; i += 1) {
2872
+ var other_s = sources.get(i + "");
2873
+ if (other_s !== void 0) set(other_s, UNINITIALIZED);
2874
+ else if (i in target) {
2875
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
2876
+ sources.set(i + "", other_s);
2877
+ }
2878
+ }
2879
+ if (s === void 0) {
2880
+ if (!has || get_descriptor(target, prop)?.writable) {
2881
+ s = with_parent(() => /* @__PURE__ */ state(void 0));
2882
+ set(s, proxy(value));
2883
+ sources.set(prop, s);
2884
+ }
2885
+ } else {
2886
+ has = s.v !== UNINITIALIZED;
2887
+ var p = with_parent(() => proxy(value));
2888
+ set(s, p);
2889
+ }
2890
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
2891
+ if (descriptor?.set) descriptor.set.call(receiver, value);
2892
+ if (!has) {
2893
+ if (is_proxied_array && typeof prop === "string") {
2894
+ var ls = sources.get("length");
2895
+ var n = Number(prop);
2896
+ if (Number.isInteger(n) && n >= ls.v) set(ls, n + 1);
2897
+ }
2898
+ increment(version);
2899
+ }
2900
+ return true;
2901
+ },
2902
+ ownKeys(target) {
2903
+ get(version);
2904
+ var own_keys = Reflect.ownKeys(target).filter((key) => {
2905
+ var source = sources.get(key);
2906
+ return source === void 0 || source.v !== UNINITIALIZED;
2907
+ });
2908
+ for (var [key, source] of sources) if (source.v !== UNINITIALIZED && !(key in target)) own_keys.push(key);
2909
+ return own_keys;
2910
+ },
2911
+ setPrototypeOf() {
2912
+ state_prototype_fixed();
2913
+ }
2914
+ });
2915
+ }
2916
+ //#endregion
2917
+ //#region ../../node_modules/svelte/src/internal/client/dom/operations.js
2918
+ /** @type {Window} */
2919
+ var $window;
2920
+ /** @type {() => Node | null} */
2921
+ var first_child_getter;
2922
+ /** @type {() => Node | null} */
2923
+ var next_sibling_getter;
2924
+ /**
2925
+ * Initialize these lazily to avoid issues when using the runtime in a server context
2926
+ * where these globals are not available while avoiding a separate server entry point
2927
+ */
2928
+ function init_operations() {
2929
+ if ($window !== void 0) return;
2930
+ $window = window;
2931
+ var element_prototype = Element.prototype;
2932
+ var node_prototype = Node.prototype;
2933
+ var text_prototype = Text.prototype;
2934
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
2935
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
2936
+ if (is_extensible(element_prototype)) {
2937
+ element_prototype.__click = void 0;
2938
+ element_prototype.__className = void 0;
2939
+ element_prototype.__attributes = null;
2940
+ element_prototype.__style = void 0;
2941
+ element_prototype.__e = void 0;
2942
+ }
2943
+ if (is_extensible(text_prototype)) text_prototype.__t = void 0;
2944
+ }
2945
+ /**
2946
+ * @param {string} value
2947
+ * @returns {Text}
2948
+ */
2949
+ function create_text(value = "") {
2950
+ return document.createTextNode(value);
2951
+ }
2952
+ /**
2953
+ * @template {Node} N
2954
+ * @param {N} node
2955
+ */
2956
+ /* @__NO_SIDE_EFFECTS__ */
2957
+ function get_first_child(node) {
2958
+ return first_child_getter.call(node);
2959
+ }
2960
+ /**
2961
+ * @template {Node} N
2962
+ * @param {N} node
2963
+ */
2964
+ /* @__NO_SIDE_EFFECTS__ */
2965
+ function get_next_sibling(node) {
2966
+ return next_sibling_getter.call(node);
2967
+ }
2968
+ /**
2969
+ * @template {Node} N
2970
+ * @param {N} node
2971
+ * @returns {void}
2972
+ */
2973
+ function clear_text_content(node) {
2974
+ node.textContent = "";
2975
+ }
2976
+ //#endregion
2977
+ //#region ../../node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
2978
+ /**
2979
+ * @template T
2980
+ * @param {() => T} fn
2981
+ */
2982
+ function without_reactive_context(fn) {
2983
+ var previous_reaction = active_reaction;
2984
+ var previous_effect = active_effect;
2985
+ set_active_reaction(null);
2986
+ set_active_effect(null);
2987
+ try {
2988
+ return fn();
2989
+ } finally {
2990
+ set_active_reaction(previous_reaction);
2991
+ set_active_effect(previous_effect);
2992
+ }
2993
+ }
2994
+ //#endregion
2995
+ //#region ../../node_modules/svelte/src/internal/client/reactivity/effects.js
2996
+ /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
2997
+ /**
2998
+ * @param {Effect} effect
2999
+ * @param {Effect} parent_effect
3000
+ */
3001
+ function push_effect(effect, parent_effect) {
3002
+ var parent_last = parent_effect.last;
3003
+ if (parent_last === null) parent_effect.last = parent_effect.first = effect;
3004
+ else {
3005
+ parent_last.next = effect;
3006
+ effect.prev = parent_last;
3007
+ parent_effect.last = effect;
3008
+ }
3009
+ }
3010
+ /**
3011
+ * @param {number} type
3012
+ * @param {null | (() => void | (() => void))} fn
3013
+ * @returns {Effect}
3014
+ */
3015
+ function create_effect(type, fn) {
3016
+ var parent = active_effect;
3017
+ if (parent !== null && (parent.f & 8192) !== 0) type |= INERT;
3018
+ /** @type {Effect} */
3019
+ var effect = {
3020
+ ctx: component_context,
3021
+ deps: null,
3022
+ nodes: null,
3023
+ f: type | DIRTY | 512,
3024
+ first: null,
3025
+ fn,
3026
+ last: null,
3027
+ next: null,
3028
+ parent,
3029
+ b: parent && parent.b,
3030
+ prev: null,
3031
+ teardown: null,
3032
+ wv: 0,
3033
+ ac: null
3034
+ };
3035
+ current_batch?.register_created_effect(effect);
3036
+ /** @type {Effect | null} */
3037
+ var e = effect;
3038
+ if ((type & 4) !== 0) if (collected_effects !== null) collected_effects.push(effect);
3039
+ else Batch.ensure().schedule(effect);
3040
+ else if (fn !== null) {
3041
+ try {
3042
+ update_effect(effect);
3043
+ } catch (e) {
3044
+ destroy_effect(effect);
3045
+ throw e;
3046
+ }
3047
+ if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && (e.f & 524288) === 0) {
3048
+ e = e.first;
3049
+ if ((type & 16) !== 0 && (type & 65536) !== 0 && e !== null) e.f |= EFFECT_TRANSPARENT;
3050
+ }
3051
+ }
3052
+ if (e !== null) {
3053
+ e.parent = parent;
3054
+ if (parent !== null) push_effect(e, parent);
3055
+ if (active_reaction !== null && (active_reaction.f & 2) !== 0 && (type & 64) === 0) {
3056
+ var derived = active_reaction;
3057
+ (derived.effects ??= []).push(e);
3058
+ }
3059
+ }
3060
+ return effect;
3061
+ }
3062
+ /**
3063
+ * Internal representation of `$effect.tracking()`
3064
+ * @returns {boolean}
3065
+ */
3066
+ function effect_tracking() {
3067
+ return active_reaction !== null && !untracking;
3068
+ }
3069
+ /**
3070
+ * @param {() => void | (() => void)} fn
3071
+ */
3072
+ function create_user_effect(fn) {
3073
+ return create_effect(4 | USER_EFFECT, fn);
3074
+ }
3075
+ /**
3076
+ * An effect root whose children can transition out
3077
+ * @param {() => void} fn
3078
+ * @returns {(options?: { outro?: boolean }) => Promise<void>}
3079
+ */
3080
+ function component_root(fn) {
3081
+ Batch.ensure();
3082
+ const effect = create_effect(64 | EFFECT_PRESERVED, fn);
3083
+ return (options = {}) => {
3084
+ return new Promise((fulfil) => {
3085
+ if (options.outro) pause_effect(effect, () => {
3086
+ destroy_effect(effect);
3087
+ fulfil(void 0);
3088
+ });
3089
+ else {
3090
+ destroy_effect(effect);
3091
+ fulfil(void 0);
3092
+ }
3093
+ });
3094
+ };
3095
+ }
3096
+ /**
3097
+ * @param {() => void | (() => void)} fn
3098
+ * @returns {Effect}
3099
+ */
3100
+ function render_effect(fn, flags = 0) {
3101
+ return create_effect(8 | flags, fn);
3102
+ }
3103
+ /**
3104
+ * @param {(() => void)} fn
3105
+ * @param {number} flags
3106
+ */
3107
+ function block(fn, flags = 0) {
3108
+ return create_effect(16 | flags, fn);
3109
+ }
3110
+ /**
3111
+ * @param {(() => void)} fn
3112
+ */
3113
+ function branch(fn) {
3114
+ return create_effect(32 | EFFECT_PRESERVED, fn);
3115
+ }
3116
+ /**
3117
+ * @param {Effect} effect
3118
+ */
3119
+ function execute_effect_teardown(effect) {
3120
+ var teardown = effect.teardown;
3121
+ if (teardown !== null) {
3122
+ const previously_destroying_effect = is_destroying_effect;
3123
+ const previous_reaction = active_reaction;
3124
+ set_is_destroying_effect(true);
3125
+ set_active_reaction(null);
3126
+ try {
3127
+ teardown.call(null);
3128
+ } finally {
3129
+ set_is_destroying_effect(previously_destroying_effect);
3130
+ set_active_reaction(previous_reaction);
3131
+ }
3132
+ }
3133
+ }
3134
+ /**
3135
+ * @param {Effect} signal
3136
+ * @param {boolean} remove_dom
3137
+ * @returns {void}
3138
+ */
3139
+ function destroy_effect_children(signal, remove_dom = false) {
3140
+ var effect = signal.first;
3141
+ signal.first = signal.last = null;
3142
+ while (effect !== null) {
3143
+ const controller = effect.ac;
3144
+ if (controller !== null) without_reactive_context(() => {
3145
+ controller.abort(STALE_REACTION);
3146
+ });
3147
+ var next = effect.next;
3148
+ if ((effect.f & 64) !== 0) effect.parent = null;
3149
+ else destroy_effect(effect, remove_dom);
3150
+ effect = next;
3151
+ }
3152
+ }
3153
+ /**
3154
+ * @param {Effect} signal
3155
+ * @returns {void}
3156
+ */
3157
+ function destroy_block_effect_children(signal) {
3158
+ var effect = signal.first;
3159
+ while (effect !== null) {
3160
+ var next = effect.next;
3161
+ if ((effect.f & 32) === 0) destroy_effect(effect);
3162
+ effect = next;
3163
+ }
3164
+ }
3165
+ /**
3166
+ * @param {Effect} effect
3167
+ * @param {boolean} [remove_dom]
3168
+ * @returns {void}
3169
+ */
3170
+ function destroy_effect(effect, remove_dom = true) {
3171
+ var removed = false;
3172
+ if ((remove_dom || (effect.f & 262144) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
3173
+ remove_effect_dom(effect.nodes.start, effect.nodes.end);
3174
+ removed = true;
3175
+ }
3176
+ set_signal_status(effect, DESTROYING);
3177
+ destroy_effect_children(effect, remove_dom && !removed);
3178
+ remove_reactions(effect, 0);
3179
+ var transitions = effect.nodes && effect.nodes.t;
3180
+ if (transitions !== null) for (const transition of transitions) transition.stop();
3181
+ execute_effect_teardown(effect);
3182
+ effect.f ^= DESTROYING;
3183
+ effect.f |= DESTROYED;
3184
+ var parent = effect.parent;
3185
+ if (parent !== null && parent.first !== null) unlink_effect(effect);
3186
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = effect.b = null;
3187
+ }
3188
+ /**
3189
+ *
3190
+ * @param {TemplateNode | null} node
3191
+ * @param {TemplateNode} end
3192
+ */
3193
+ function remove_effect_dom(node, end) {
3194
+ while (node !== null) {
3195
+ /** @type {TemplateNode | null} */
3196
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
3197
+ node.remove();
3198
+ node = next;
3199
+ }
3200
+ }
3201
+ /**
3202
+ * Detach an effect from the effect tree, freeing up memory and
3203
+ * reducing the amount of work that happens on subsequent traversals
3204
+ * @param {Effect} effect
3205
+ */
3206
+ function unlink_effect(effect) {
3207
+ var parent = effect.parent;
3208
+ var prev = effect.prev;
3209
+ var next = effect.next;
3210
+ if (prev !== null) prev.next = next;
3211
+ if (next !== null) next.prev = prev;
3212
+ if (parent !== null) {
3213
+ if (parent.first === effect) parent.first = next;
3214
+ if (parent.last === effect) parent.last = prev;
3215
+ }
3216
+ }
3217
+ /**
3218
+ * When a block effect is removed, we don't immediately destroy it or yank it
3219
+ * out of the DOM, because it might have transitions. Instead, we 'pause' it.
3220
+ * It stays around (in memory, and in the DOM) until outro transitions have
3221
+ * completed, and if the state change is reversed then we _resume_ it.
3222
+ * A paused effect does not update, and the DOM subtree becomes inert.
3223
+ * @param {Effect} effect
3224
+ * @param {() => void} [callback]
3225
+ * @param {boolean} [destroy]
3226
+ */
3227
+ function pause_effect(effect, callback, destroy = true) {
3228
+ /** @type {TransitionManager[]} */
3229
+ var transitions = [];
3230
+ pause_children(effect, transitions, true);
3231
+ var fn = () => {
3232
+ if (destroy) destroy_effect(effect);
3233
+ if (callback) callback();
3234
+ };
3235
+ var remaining = transitions.length;
3236
+ if (remaining > 0) {
3237
+ var check = () => --remaining || fn();
3238
+ for (var transition of transitions) transition.out(check);
3239
+ } else fn();
3240
+ }
3241
+ /**
3242
+ * @param {Effect} effect
3243
+ * @param {TransitionManager[]} transitions
3244
+ * @param {boolean} local
3245
+ */
3246
+ function pause_children(effect, transitions, local) {
3247
+ if ((effect.f & 8192) !== 0) return;
3248
+ effect.f ^= INERT;
3249
+ var t = effect.nodes && effect.nodes.t;
3250
+ if (t !== null) {
3251
+ for (const transition of t) if (transition.is_global || local) transitions.push(transition);
3252
+ }
3253
+ var child = effect.first;
3254
+ while (child !== null) {
3255
+ var sibling = child.next;
3256
+ if ((child.f & 64) === 0) {
3257
+ var transparent = (child.f & 65536) !== 0 || (child.f & 32) !== 0 && (effect.f & 16) !== 0;
3258
+ pause_children(child, transitions, transparent ? local : false);
3259
+ }
3260
+ child = sibling;
3261
+ }
3262
+ }
3263
+ /**
3264
+ * @param {Effect} effect
3265
+ * @param {DocumentFragment} fragment
3266
+ */
3267
+ function move_effect(effect, fragment) {
3268
+ if (!effect.nodes) return;
3269
+ /** @type {TemplateNode | null} */
3270
+ var node = effect.nodes.start;
3271
+ var end = effect.nodes.end;
3272
+ while (node !== null) {
3273
+ /** @type {TemplateNode | null} */
3274
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
3275
+ fragment.append(node);
3276
+ node = next;
3277
+ }
3278
+ }
3279
+ //#endregion
3280
+ //#region ../../node_modules/svelte/src/internal/client/runtime.js
3281
+ /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
3282
+ var is_updating_effect = false;
3283
+ var is_destroying_effect = false;
3284
+ /** @param {boolean} value */
3285
+ function set_is_destroying_effect(value) {
3286
+ is_destroying_effect = value;
3287
+ }
3288
+ /** @type {null | Reaction} */
3289
+ var active_reaction = null;
3290
+ var untracking = false;
3291
+ /** @param {null | Reaction} reaction */
3292
+ function set_active_reaction(reaction) {
3293
+ active_reaction = reaction;
3294
+ }
3295
+ /** @type {null | Effect} */
3296
+ var active_effect = null;
3297
+ /** @param {null | Effect} effect */
3298
+ function set_active_effect(effect) {
3299
+ active_effect = effect;
3300
+ }
3301
+ /**
3302
+ * When sources are created within a reaction, reading and writing
3303
+ * them within that reaction should not cause a re-run
3304
+ * @type {null | Source[]}
3305
+ */
3306
+ var current_sources = null;
3307
+ /** @param {Value} value */
3308
+ function push_reaction_value(value) {
3309
+ if (active_reaction !== null && (true)) if (current_sources === null) current_sources = [value];
3310
+ else current_sources.push(value);
3311
+ }
3312
+ /**
3313
+ * The dependencies of the reaction that is currently being executed. In many cases,
3314
+ * the dependencies are unchanged between runs, and so this will be `null` unless
3315
+ * and until a new dependency is accessed — we track this via `skipped_deps`
3316
+ * @type {null | Value[]}
3317
+ */
3318
+ var new_deps = null;
3319
+ var skipped_deps = 0;
3320
+ /**
3321
+ * Tracks writes that the effect it's executed in doesn't listen to yet,
3322
+ * so that the dependency can be added to the effect later on if it then reads it
3323
+ * @type {null | Source[]}
3324
+ */
3325
+ var untracked_writes = null;
3326
+ /** @param {null | Source[]} value */
3327
+ function set_untracked_writes(value) {
3328
+ untracked_writes = value;
3329
+ }
3330
+ /**
3331
+ * @type {number} Used by sources and deriveds for handling updates.
3332
+ * Version starts from 1 so that unowned deriveds differentiate between a created effect and a run one for tracing
3333
+ **/
3334
+ var write_version = 1;
3335
+ /** @type {number} Used to version each read of a source of derived to avoid duplicating depedencies inside a reaction */
3336
+ var read_version = 0;
3337
+ var update_version = read_version;
3338
+ /** @param {number} value */
3339
+ function set_update_version(value) {
3340
+ update_version = value;
3341
+ }
3342
+ function increment_write_version() {
3343
+ return ++write_version;
3344
+ }
3345
+ /**
3346
+ * Determines whether a derived or effect is dirty.
3347
+ * If it is MAYBE_DIRTY, will set the status to CLEAN
3348
+ * @param {Reaction} reaction
3349
+ * @returns {boolean}
3350
+ */
3351
+ function is_dirty(reaction) {
3352
+ var flags = reaction.f;
3353
+ if ((flags & 2048) !== 0) return true;
3354
+ if (flags & 2) reaction.f &= ~WAS_MARKED;
3355
+ if ((flags & 4096) !== 0) {
3356
+ var dependencies = reaction.deps;
3357
+ var length = dependencies.length;
3358
+ for (var i = 0; i < length; i++) {
3359
+ var dependency = dependencies[i];
3360
+ if (is_dirty(dependency)) update_derived(dependency);
3361
+ if (dependency.wv > reaction.wv) return true;
3362
+ }
3363
+ if ((flags & 512) !== 0 && batch_values === null) set_signal_status(reaction, CLEAN);
3364
+ }
3365
+ return false;
3366
+ }
3367
+ /**
3368
+ * @param {Value} signal
3369
+ * @param {Effect} effect
3370
+ * @param {boolean} [root]
3371
+ */
3372
+ function schedule_possible_effect_self_invalidation(signal, effect, root = true) {
3373
+ var reactions = signal.reactions;
3374
+ if (reactions === null) return;
3375
+ if (current_sources !== null && includes.call(current_sources, signal)) return;
3376
+ for (var i = 0; i < reactions.length; i++) {
3377
+ var reaction = reactions[i];
3378
+ if ((reaction.f & 2) !== 0) schedule_possible_effect_self_invalidation(reaction, effect, false);
3379
+ else if (effect === reaction) {
3380
+ if (root) set_signal_status(reaction, DIRTY);
3381
+ else if ((reaction.f & 1024) !== 0) set_signal_status(reaction, MAYBE_DIRTY);
3382
+ schedule_effect(reaction);
3383
+ }
3384
+ }
3385
+ }
3386
+ /** @param {Reaction} reaction */
3387
+ function update_reaction(reaction) {
3388
+ var previous_deps = new_deps;
3389
+ var previous_skipped_deps = skipped_deps;
3390
+ var previous_untracked_writes = untracked_writes;
3391
+ var previous_reaction = active_reaction;
3392
+ var previous_sources = current_sources;
3393
+ var previous_component_context = component_context;
3394
+ var previous_untracking = untracking;
3395
+ var previous_update_version = update_version;
3396
+ var flags = reaction.f;
3397
+ new_deps = null;
3398
+ skipped_deps = 0;
3399
+ untracked_writes = null;
3400
+ active_reaction = (flags & 96) === 0 ? reaction : null;
3401
+ current_sources = null;
3402
+ set_component_context(reaction.ctx);
3403
+ untracking = false;
3404
+ update_version = ++read_version;
3405
+ if (reaction.ac !== null) {
3406
+ without_reactive_context(() => {
3407
+ /** @type {AbortController} */ reaction.ac.abort(STALE_REACTION);
3408
+ });
3409
+ reaction.ac = null;
3410
+ }
3411
+ try {
3412
+ reaction.f |= REACTION_IS_UPDATING;
3413
+ var fn = reaction.fn;
3414
+ var result = fn();
3415
+ reaction.f |= REACTION_RAN;
3416
+ var deps = reaction.deps;
3417
+ var is_fork = current_batch?.is_fork;
3418
+ if (new_deps !== null) {
3419
+ var i;
3420
+ if (!is_fork) remove_reactions(reaction, skipped_deps);
3421
+ if (deps !== null && skipped_deps > 0) {
3422
+ deps.length = skipped_deps + new_deps.length;
3423
+ for (i = 0; i < new_deps.length; i++) deps[skipped_deps + i] = new_deps[i];
3424
+ } else reaction.deps = deps = new_deps;
3425
+ if (effect_tracking() && (reaction.f & 512) !== 0) for (i = skipped_deps; i < deps.length; i++) (deps[i].reactions ??= []).push(reaction);
3426
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
3427
+ remove_reactions(reaction, skipped_deps);
3428
+ deps.length = skipped_deps;
3429
+ }
3430
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & 6146) === 0) for (i = 0; i < untracked_writes.length; i++) schedule_possible_effect_self_invalidation(untracked_writes[i], reaction);
3431
+ if (previous_reaction !== null && previous_reaction !== reaction) {
3432
+ read_version++;
3433
+ if (previous_reaction.deps !== null) for (let i = 0; i < previous_skipped_deps; i += 1) previous_reaction.deps[i].rv = read_version;
3434
+ if (previous_deps !== null) for (const dep of previous_deps) dep.rv = read_version;
3435
+ if (untracked_writes !== null) if (previous_untracked_writes === null) previous_untracked_writes = untracked_writes;
3436
+ else previous_untracked_writes.push(...untracked_writes);
3437
+ }
3438
+ if ((reaction.f & 8388608) !== 0) reaction.f ^= ERROR_VALUE;
3439
+ return result;
3440
+ } catch (error) {
3441
+ return handle_error(error);
3442
+ } finally {
3443
+ reaction.f ^= REACTION_IS_UPDATING;
3444
+ new_deps = previous_deps;
3445
+ skipped_deps = previous_skipped_deps;
3446
+ untracked_writes = previous_untracked_writes;
3447
+ active_reaction = previous_reaction;
3448
+ current_sources = previous_sources;
3449
+ set_component_context(previous_component_context);
3450
+ untracking = previous_untracking;
3451
+ update_version = previous_update_version;
3452
+ }
3453
+ }
3454
+ /**
3455
+ * @template V
3456
+ * @param {Reaction} signal
3457
+ * @param {Value<V>} dependency
3458
+ * @returns {void}
3459
+ */
3460
+ function remove_reaction(signal, dependency) {
3461
+ let reactions = dependency.reactions;
3462
+ if (reactions !== null) {
3463
+ var index = index_of.call(reactions, signal);
3464
+ if (index !== -1) {
3465
+ var new_length = reactions.length - 1;
3466
+ if (new_length === 0) reactions = dependency.reactions = null;
3467
+ else {
3468
+ reactions[index] = reactions[new_length];
3469
+ reactions.pop();
3470
+ }
3471
+ }
3472
+ }
3473
+ if (reactions === null && (dependency.f & 2) !== 0 && (new_deps === null || !includes.call(new_deps, dependency))) {
3474
+ var derived = dependency;
3475
+ if ((derived.f & 512) !== 0) {
3476
+ derived.f ^= 512;
3477
+ derived.f &= ~WAS_MARKED;
3478
+ }
3479
+ if (derived.v !== UNINITIALIZED) update_derived_status(derived);
3480
+ freeze_derived_effects(derived);
3481
+ remove_reactions(derived, 0);
3482
+ }
3483
+ }
3484
+ /**
3485
+ * @param {Reaction} signal
3486
+ * @param {number} start_index
3487
+ * @returns {void}
3488
+ */
3489
+ function remove_reactions(signal, start_index) {
3490
+ var dependencies = signal.deps;
3491
+ if (dependencies === null) return;
3492
+ for (var i = start_index; i < dependencies.length; i++) remove_reaction(signal, dependencies[i]);
3493
+ }
3494
+ /**
3495
+ * @param {Effect} effect
3496
+ * @returns {void}
3497
+ */
3498
+ function update_effect(effect) {
3499
+ var flags = effect.f;
3500
+ if ((flags & 16384) !== 0) return;
3501
+ set_signal_status(effect, CLEAN);
3502
+ var previous_effect = active_effect;
3503
+ var was_updating_effect = is_updating_effect;
3504
+ active_effect = effect;
3505
+ is_updating_effect = true;
3506
+ try {
3507
+ if ((flags & 16777232) !== 0) destroy_block_effect_children(effect);
3508
+ else destroy_effect_children(effect);
3509
+ execute_effect_teardown(effect);
3510
+ var teardown = update_reaction(effect);
3511
+ effect.teardown = typeof teardown === "function" ? teardown : null;
3512
+ effect.wv = write_version;
3513
+ } finally {
3514
+ is_updating_effect = was_updating_effect;
3515
+ active_effect = previous_effect;
3516
+ }
3517
+ }
3518
+ /**
3519
+ * @template V
3520
+ * @param {Value<V>} signal
3521
+ * @returns {V}
3522
+ */
3523
+ function get(signal) {
3524
+ var is_derived = (signal.f & 2) !== 0;
3525
+ if (active_reaction !== null && !untracking) {
3526
+ if (!(active_effect !== null && (active_effect.f & 16384) !== 0) && (current_sources === null || !includes.call(current_sources, signal))) {
3527
+ var deps = active_reaction.deps;
3528
+ if ((active_reaction.f & 2097152) !== 0) {
3529
+ if (signal.rv < read_version) {
3530
+ signal.rv = read_version;
3531
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) skipped_deps++;
3532
+ else if (new_deps === null) new_deps = [signal];
3533
+ else new_deps.push(signal);
3534
+ }
3535
+ } else {
3536
+ (active_reaction.deps ??= []).push(signal);
3537
+ var reactions = signal.reactions;
3538
+ if (reactions === null) signal.reactions = [active_reaction];
3539
+ else if (!includes.call(reactions, active_reaction)) reactions.push(active_reaction);
3540
+ }
3541
+ }
3542
+ }
3543
+ if (is_destroying_effect && old_values.has(signal)) return old_values.get(signal);
3544
+ if (is_derived) {
3545
+ var derived = signal;
3546
+ if (is_destroying_effect) {
3547
+ var value = derived.v;
3548
+ if ((derived.f & 1024) === 0 && derived.reactions !== null || depends_on_old_values(derived)) value = execute_derived(derived);
3549
+ old_values.set(derived, value);
3550
+ return value;
3551
+ }
3552
+ var should_connect = (derived.f & 512) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & 512) !== 0);
3553
+ var is_new = (derived.f & REACTION_RAN) === 0;
3554
+ if (is_dirty(derived)) {
3555
+ if (should_connect) derived.f |= 512;
3556
+ update_derived(derived);
3557
+ }
3558
+ if (should_connect && !is_new) {
3559
+ unfreeze_derived_effects(derived);
3560
+ reconnect(derived);
3561
+ }
3562
+ }
3563
+ if (batch_values?.has(signal)) return batch_values.get(signal);
3564
+ if ((signal.f & 8388608) !== 0) throw signal.v;
3565
+ return signal.v;
3566
+ }
3567
+ /**
3568
+ * (Re)connect a disconnected derived, so that it is notified
3569
+ * of changes in `mark_reactions`
3570
+ * @param {Derived} derived
3571
+ */
3572
+ function reconnect(derived) {
3573
+ derived.f |= 512;
3574
+ if (derived.deps === null) return;
3575
+ for (const dep of derived.deps) {
3576
+ (dep.reactions ??= []).push(derived);
3577
+ if ((dep.f & 2) !== 0 && (dep.f & 512) === 0) {
3578
+ unfreeze_derived_effects(dep);
3579
+ reconnect(dep);
3580
+ }
3581
+ }
3582
+ }
3583
+ /** @param {Derived} derived */
3584
+ function depends_on_old_values(derived) {
3585
+ if (derived.v === UNINITIALIZED) return true;
3586
+ if (derived.deps === null) return false;
3587
+ for (const dep of derived.deps) {
3588
+ if (old_values.has(dep)) return true;
3589
+ if ((dep.f & 2) !== 0 && depends_on_old_values(dep)) return true;
3590
+ }
3591
+ return false;
3592
+ }
3593
+ /**
3594
+ * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect),
3595
+ * any state read inside `fn` will not be treated as a dependency.
3596
+ *
3597
+ * ```ts
3598
+ * $effect(() => {
3599
+ * // this will run when `data` changes, but not when `time` changes
3600
+ * save(data, {
3601
+ * timestamp: untrack(() => time)
3602
+ * });
3603
+ * });
3604
+ * ```
3605
+ * @template T
3606
+ * @param {() => T} fn
3607
+ * @returns {T}
3608
+ */
3609
+ function untrack(fn) {
3610
+ var previous_untracking = untracking;
3611
+ try {
3612
+ untracking = true;
3613
+ return fn();
3614
+ } finally {
3615
+ untracking = previous_untracking;
3616
+ }
3617
+ }
3618
+ //#endregion
3619
+ //#region ../../node_modules/svelte/src/store/utils.js
3620
+ /** @import { Readable } from './public' */
3621
+ /**
3622
+ * @template T
3623
+ * @param {Readable<T> | null | undefined} store
3624
+ * @param {(value: T) => void} run
3625
+ * @param {(value: T) => void} [invalidate]
3626
+ * @returns {() => void}
3627
+ */
3628
+ function subscribe_to_store(store, run, invalidate) {
3629
+ if (store == null) {
3630
+ run(void 0);
3631
+ return noop;
3632
+ }
3633
+ const unsub = untrack(() => store.subscribe(run, invalidate));
3634
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
3635
+ }
3636
+ /**
3637
+ * Attributes that are boolean, i.e. they are present or not present.
3638
+ */
3639
+ var DOM_BOOLEAN_ATTRIBUTES = [
3640
+ "allowfullscreen",
3641
+ "async",
3642
+ "autofocus",
3643
+ "autoplay",
3644
+ "checked",
3645
+ "controls",
3646
+ "default",
3647
+ "disabled",
3648
+ "formnovalidate",
3649
+ "indeterminate",
3650
+ "inert",
3651
+ "ismap",
3652
+ "loop",
3653
+ "multiple",
3654
+ "muted",
3655
+ "nomodule",
3656
+ "novalidate",
3657
+ "open",
3658
+ "playsinline",
3659
+ "readonly",
3660
+ "required",
3661
+ "reversed",
3662
+ "seamless",
3663
+ "selected",
3664
+ "webkitdirectory",
3665
+ "defer",
3666
+ "disablepictureinpicture",
3667
+ "disableremoteplayback"
3668
+ ];
3669
+ /**
3670
+ * Returns `true` if `name` is a boolean attribute
3671
+ * @param {string} name
3672
+ */
3673
+ function is_boolean_attribute(name) {
3674
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
3675
+ }
3676
+ /**
3677
+ * Subset of delegated events which should be passive by default.
3678
+ * These two are already passive via browser defaults on window, document and body.
3679
+ * But since
3680
+ * - we're delegating them
3681
+ * - they happen often
3682
+ * - they apply to mobile which is generally less performant
3683
+ * we're marking them as passive by default for other elements, too.
3684
+ */
3685
+ var PASSIVE_EVENTS = ["touchstart", "touchmove"];
3686
+ /**
3687
+ * Returns `true` if `name` is a passive event
3688
+ * @param {string} name
3689
+ */
3690
+ function is_passive_event(name) {
3691
+ return PASSIVE_EVENTS.includes(name);
3692
+ }
3693
+ //#endregion
3694
+ //#region ../../node_modules/svelte/src/internal/server/blocks/html.js
3695
+ /**
3696
+ * @param {string} value
3697
+ */
3698
+ function html(value) {
3699
+ return "<!---->" + String(value ?? "") + "<!---->";
3700
+ }
3701
+ //#endregion
3702
+ //#region ../../node_modules/svelte/src/internal/server/index.js
3703
+ var INVALID_ATTR_NAME_CHAR_REGEX = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
3704
+ /**
3705
+ * Only available on the server and when compiling with the `server` option.
3706
+ * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
3707
+ * @template {Record<string, any>} Props
3708
+ * @param {Component<Props> | ComponentType<SvelteComponent<Props>>} component
3709
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} [options]
3710
+ * @returns {RenderOutput}
3711
+ */
3712
+ function render(component, options = {}) {
3713
+ if (options.csp?.hash && options.csp.nonce) invalid_csp();
3714
+ return Renderer.render(component, options);
3715
+ }
3716
+ /**
3717
+ * @param {string} hash
3718
+ * @param {Renderer} renderer
3719
+ * @param {(renderer: Renderer) => Promise<void> | void} fn
3720
+ * @returns {void}
3721
+ */
3722
+ function head(hash, renderer, fn) {
3723
+ renderer.head((renderer) => {
3724
+ renderer.push(`<!--${hash}-->`);
3725
+ renderer.child(fn);
3726
+ renderer.push(EMPTY_COMMENT);
3727
+ });
3728
+ }
3729
+ /**
3730
+ * @param {Record<string, unknown>} attrs
3731
+ * @param {string} [css_hash]
3732
+ * @param {Record<string, boolean>} [classes]
3733
+ * @param {Record<string, string>} [styles]
3734
+ * @param {number} [flags]
3735
+ * @returns {string}
3736
+ */
3737
+ function attributes(attrs, css_hash, classes, styles, flags = 0) {
3738
+ if (styles) attrs.style = to_style(attrs.style, styles);
3739
+ if (attrs.class) attrs.class = clsx$1(attrs.class);
3740
+ if (css_hash || classes) attrs.class = to_class(attrs.class, css_hash, classes);
3741
+ let attr_str = "";
3742
+ let name;
3743
+ const is_html = (flags & 1) === 0;
3744
+ const lowercase = (flags & 2) === 0;
3745
+ const is_input = (flags & 4) !== 0;
3746
+ for (name of Object.keys(attrs)) {
3747
+ if (typeof attrs[name] === "function") continue;
3748
+ if (name[0] === "$" && name[1] === "$") continue;
3749
+ if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
3750
+ var value = attrs[name];
3751
+ var lower = name.toLowerCase();
3752
+ if (lowercase) name = lower;
3753
+ if (lower.length > 2 && lower.startsWith("on")) continue;
3754
+ if (is_input) {
3755
+ if (name === "defaultvalue" || name === "defaultchecked") {
3756
+ name = name === "defaultvalue" ? "value" : "checked";
3757
+ if (attrs[name]) continue;
3758
+ }
3759
+ }
3760
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
3761
+ }
3762
+ return attr_str;
3763
+ }
3764
+ /**
3765
+ * @param {unknown} value
3766
+ * @returns {string}
3767
+ */
3768
+ function stringify(value) {
3769
+ return typeof value === "string" ? value : value == null ? "" : value + "";
3770
+ }
3771
+ /**
3772
+ * @param {any} value
3773
+ * @param {string | undefined} [hash]
3774
+ * @param {Record<string, boolean>} [directives]
3775
+ */
3776
+ function attr_class(value, hash, directives) {
3777
+ var result = to_class(value, hash, directives);
3778
+ return result ? ` class="${escape_html(result, true)}"` : "";
3779
+ }
3780
+ /**
3781
+ * @param {any} value
3782
+ * @param {Record<string,any>|[Record<string,any>,Record<string,any>]} [directives]
3783
+ */
3784
+ function attr_style(value, directives) {
3785
+ var result = to_style(value, directives);
3786
+ return result ? ` style="${escape_html(result, true)}"` : "";
3787
+ }
3788
+ /**
3789
+ * @template V
3790
+ * @param {Record<string, [any, any, any]>} store_values
3791
+ * @param {string} store_name
3792
+ * @param {Store<V> | null | undefined} store
3793
+ * @returns {V}
3794
+ */
3795
+ function store_get(store_values, store_name, store) {
3796
+ if (store_name in store_values && store_values[store_name][0] === store) return store_values[store_name][2];
3797
+ store_values[store_name]?.[1]();
3798
+ store_values[store_name] = [
3799
+ store,
3800
+ null,
3801
+ void 0
3802
+ ];
3803
+ const unsub = subscribe_to_store(
3804
+ store,
3805
+ /** @param {any} v */
3806
+ (v) => store_values[store_name][2] = v
3807
+ );
3808
+ store_values[store_name][1] = unsub;
3809
+ return store_values[store_name][2];
3810
+ }
3811
+ /** @param {Record<string, [any, any, any]>} store_values */
3812
+ function unsubscribe_stores(store_values) {
3813
+ for (const store_name of Object.keys(store_values)) store_values[store_name][1]();
3814
+ }
3815
+ /**
3816
+ * Legacy mode: If the prop has a fallback and is bound in the
3817
+ * parent component, propagate the fallback value upwards.
3818
+ * @param {Record<string, unknown>} props_parent
3819
+ * @param {Record<string, unknown>} props_now
3820
+ */
3821
+ function bind_props(props_parent, props_now) {
3822
+ for (const key of Object.keys(props_now)) {
3823
+ const initial_value = props_parent[key];
3824
+ const value = props_now[key];
3825
+ if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) props_parent[key] = value;
3826
+ }
3827
+ }
3828
+ /** @param {any} array_like_or_iterator */
3829
+ function ensure_array_like(array_like_or_iterator) {
3830
+ if (array_like_or_iterator) return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
3831
+ return [];
3832
+ }
3833
+ /**
3834
+ * @template V
3835
+ * @param {() => V} get_value
3836
+ */
3837
+ function once(get_value) {
3838
+ let value = UNINITIALIZED;
3839
+ return () => {
3840
+ if (value === UNINITIALIZED) value = get_value();
3841
+ return value;
3842
+ };
3843
+ }
3844
+ /**
3845
+ * @template T
3846
+ * @param {()=>T} fn
3847
+ * @returns {(new_value?: T) => (T | void)}
3848
+ */
3849
+ function derived(fn) {
3850
+ const get_value = ssr_context === null ? fn : once(fn);
3851
+ /** @type {T | undefined} */
3852
+ let updated_value;
3853
+ return function(new_value) {
3854
+ if (arguments.length === 0) return updated_value ?? get_value();
3855
+ updated_value = new_value;
3856
+ return updated_value;
3857
+ };
3858
+ }
3859
+ //#endregion
3860
+ //#region ../../node_modules/svelte/src/internal/server/crypto.js
3861
+ var text_encoder;
3862
+ var crypto;
3863
+ /** @param {string} module_name */
3864
+ var obfuscated_import = (module_name) => import(
3865
+ /* @vite-ignore */
3866
+ module_name
3867
+ );
3868
+ /** @param {string} data */
3869
+ async function sha256(data) {
3870
+ text_encoder ??= new TextEncoder();
3871
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (await obfuscated_import("node:crypto")).webcrypto;
3872
+ return base64_encode(await crypto.subtle.digest("SHA-256", text_encoder.encode(data)));
3873
+ }
3874
+ /**
3875
+ * @param {Uint8Array} bytes
3876
+ * @returns {string}
3877
+ */
3878
+ function base64_encode(bytes) {
3879
+ if (globalThis.Buffer) return globalThis.Buffer.from(bytes).toString("base64");
3880
+ let binary = "";
3881
+ for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
3882
+ return btoa(binary);
3883
+ }
3884
+ //#endregion
3885
+ //#region ../../node_modules/svelte/src/internal/server/renderer.js
3886
+ /** @import { Component } from 'svelte' */
3887
+ /** @import { Csp, HydratableContext, RenderOutput, SSRContext, SyncRenderOutput, Sha256Source } from './types.js' */
3888
+ /** @import { MaybePromise } from '#shared' */
3889
+ /** @typedef {'head' | 'body'} RendererType */
3890
+ /** @typedef {{ [key in RendererType]: string }} AccumulatedContent */
3891
+ /**
3892
+ * @typedef {string | Renderer} RendererItem
3893
+ */
3894
+ /**
3895
+ * Renderers are basically a tree of `string | Renderer`s, where each `Renderer` in the tree represents
3896
+ * work that may or may not have completed. A renderer can be {@link collect}ed to aggregate the
3897
+ * content from itself and all of its children, but this will throw if any of the children are
3898
+ * performing asynchronous work. To asynchronously collect a renderer, just `await` it.
3899
+ *
3900
+ * The `string` values within a renderer are always associated with the {@link type} of that renderer. To switch types,
3901
+ * call {@link child} with a different `type` argument.
3902
+ */
3903
+ var Renderer = class Renderer {
3904
+ /**
3905
+ * The contents of the renderer.
3906
+ * @type {RendererItem[]}
3907
+ */
3908
+ #out = [];
3909
+ /**
3910
+ * Any `onDestroy` callbacks registered during execution of this renderer.
3911
+ * @type {(() => void)[] | undefined}
3912
+ */
3913
+ #on_destroy = void 0;
3914
+ /**
3915
+ * Whether this renderer is a component body.
3916
+ * @type {boolean}
3917
+ */
3918
+ #is_component_body = false;
3919
+ /**
3920
+ * If set, this renderer is an error boundary. When async collection
3921
+ * of the children fails, the failed snippet is rendered instead.
3922
+ * @type {{
3923
+ * failed: (renderer: Renderer, error: unknown, reset: () => void) => void;
3924
+ * transformError: (error: unknown) => unknown;
3925
+ * context: SSRContext | null;
3926
+ * } | null}
3927
+ */
3928
+ #boundary = null;
3929
+ /**
3930
+ * The type of string content that this renderer is accumulating.
3931
+ * @type {RendererType}
3932
+ */
3933
+ type;
3934
+ /** @type {Renderer | undefined} */
3935
+ #parent;
3936
+ /**
3937
+ * Asynchronous work associated with this renderer
3938
+ * @type {Promise<void> | undefined}
3939
+ */
3940
+ promise = void 0;
3941
+ /**
3942
+ * State which is associated with the content tree as a whole.
3943
+ * It will be re-exposed, uncopied, on all children.
3944
+ * @type {SSRState}
3945
+ * @readonly
3946
+ */
3947
+ global;
3948
+ /**
3949
+ * State that is local to the branch it is declared in.
3950
+ * It will be shallow-copied to all children.
3951
+ *
3952
+ * @type {{ select_value: string | undefined }}
3953
+ */
3954
+ local;
3955
+ /**
3956
+ * @param {SSRState} global
3957
+ * @param {Renderer | undefined} [parent]
3958
+ */
3959
+ constructor(global, parent) {
3960
+ this.#parent = parent;
3961
+ this.global = global;
3962
+ this.local = parent ? { ...parent.local } : { select_value: void 0 };
3963
+ this.type = parent ? parent.type : "body";
3964
+ }
3965
+ /**
3966
+ * @param {(renderer: Renderer) => void} fn
3967
+ */
3968
+ head(fn) {
3969
+ const head = new Renderer(this.global, this);
3970
+ head.type = "head";
3971
+ this.#out.push(head);
3972
+ head.child(fn);
3973
+ }
3974
+ /**
3975
+ * @param {Array<Promise<void>>} blockers
3976
+ * @param {(renderer: Renderer) => void} fn
3977
+ */
3978
+ async_block(blockers, fn) {
3979
+ this.#out.push(BLOCK_OPEN);
3980
+ this.async(blockers, fn);
3981
+ this.#out.push(BLOCK_CLOSE);
3982
+ }
3983
+ /**
3984
+ * @param {Array<Promise<void>>} blockers
3985
+ * @param {(renderer: Renderer) => void} fn
3986
+ */
3987
+ async(blockers, fn) {
3988
+ let callback = fn;
3989
+ if (blockers.length > 0) {
3990
+ const context = ssr_context;
3991
+ callback = (renderer) => {
3992
+ return Promise.all(blockers).then(() => {
3993
+ const previous_context = ssr_context;
3994
+ try {
3995
+ set_ssr_context(context);
3996
+ return fn(renderer);
3997
+ } finally {
3998
+ set_ssr_context(previous_context);
3999
+ }
4000
+ });
4001
+ };
4002
+ }
4003
+ this.child(callback);
4004
+ }
4005
+ /**
4006
+ * @param {Array<() => void>} thunks
4007
+ */
4008
+ run(thunks) {
4009
+ const context = ssr_context;
4010
+ let promise = Promise.resolve(thunks[0]());
4011
+ const promises = [promise];
4012
+ for (const fn of thunks.slice(1)) {
4013
+ promise = promise.then(() => {
4014
+ const previous_context = ssr_context;
4015
+ set_ssr_context(context);
4016
+ try {
4017
+ return fn();
4018
+ } finally {
4019
+ set_ssr_context(previous_context);
4020
+ }
4021
+ });
4022
+ promises.push(promise);
4023
+ }
4024
+ promise.catch(noop);
4025
+ this.promise = promise;
4026
+ return promises;
4027
+ }
4028
+ /**
4029
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
4030
+ */
4031
+ child_block(fn) {
4032
+ this.#out.push(BLOCK_OPEN);
4033
+ this.child(fn);
4034
+ this.#out.push(BLOCK_CLOSE);
4035
+ }
4036
+ /**
4037
+ * Create a child renderer. The child renderer inherits the state from the parent,
4038
+ * but has its own content.
4039
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
4040
+ */
4041
+ child(fn) {
4042
+ const child = new Renderer(this.global, this);
4043
+ this.#out.push(child);
4044
+ const parent = ssr_context;
4045
+ set_ssr_context({
4046
+ ...ssr_context,
4047
+ p: parent,
4048
+ c: null,
4049
+ r: child
4050
+ });
4051
+ const result = fn(child);
4052
+ set_ssr_context(parent);
4053
+ if (result instanceof Promise) {
4054
+ result.catch(noop);
4055
+ result.finally(() => set_ssr_context(null)).catch(noop);
4056
+ if (child.global.mode === "sync") await_invalid();
4057
+ child.promise = result;
4058
+ }
4059
+ return child;
4060
+ }
4061
+ /**
4062
+ * Render children inside an error boundary. If the children throw and the API-level
4063
+ * `transformError` transform handles the error (doesn't re-throw), the `failed` snippet is
4064
+ * rendered instead. Otherwise the error propagates.
4065
+ *
4066
+ * @param {{ failed?: (renderer: Renderer, error: unknown, reset: () => void) => void }} props
4067
+ * @param {(renderer: Renderer) => MaybePromise<void>} children_fn
4068
+ */
4069
+ boundary(props, children_fn) {
4070
+ const child = new Renderer(this.global, this);
4071
+ this.#out.push(child);
4072
+ const parent_context = ssr_context;
4073
+ if (props.failed) child.#boundary = {
4074
+ failed: props.failed,
4075
+ transformError: this.global.transformError,
4076
+ context: parent_context
4077
+ };
4078
+ set_ssr_context({
4079
+ ...ssr_context,
4080
+ p: parent_context,
4081
+ c: null,
4082
+ r: child
4083
+ });
4084
+ try {
4085
+ const result = children_fn(child);
4086
+ set_ssr_context(parent_context);
4087
+ if (result instanceof Promise) {
4088
+ if (child.global.mode === "sync") await_invalid();
4089
+ result.catch(noop);
4090
+ child.promise = result;
4091
+ }
4092
+ } catch (error) {
4093
+ set_ssr_context(parent_context);
4094
+ const failed_snippet = props.failed;
4095
+ if (!failed_snippet) throw error;
4096
+ const result = this.global.transformError(error);
4097
+ child.#out.length = 0;
4098
+ child.#boundary = null;
4099
+ if (result instanceof Promise) {
4100
+ if (this.global.mode === "sync") await_invalid();
4101
+ child.promise = result.then((transformed) => {
4102
+ set_ssr_context(parent_context);
4103
+ child.#out.push(Renderer.#serialize_failed_boundary(transformed));
4104
+ failed_snippet(child, transformed, noop);
4105
+ child.#out.push(BLOCK_CLOSE);
4106
+ });
4107
+ child.promise.catch(noop);
4108
+ } else {
4109
+ child.#out.push(Renderer.#serialize_failed_boundary(result));
4110
+ failed_snippet(child, result, noop);
4111
+ child.#out.push(BLOCK_CLOSE);
4112
+ }
4113
+ }
4114
+ }
4115
+ /**
4116
+ * Create a component renderer. The component renderer inherits the state from the parent,
4117
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
4118
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
4119
+ * @param {Function} [component_fn]
4120
+ * @returns {void}
4121
+ */
4122
+ component(fn, component_fn) {
4123
+ push$1();
4124
+ const child = this.child(fn);
4125
+ child.#is_component_body = true;
4126
+ pop$1();
4127
+ }
4128
+ /**
4129
+ * @param {Record<string, any>} attrs
4130
+ * @param {(renderer: Renderer) => void} fn
4131
+ * @param {string | undefined} [css_hash]
4132
+ * @param {Record<string, boolean> | undefined} [classes]
4133
+ * @param {Record<string, string> | undefined} [styles]
4134
+ * @param {number | undefined} [flags]
4135
+ * @param {boolean | undefined} [is_rich]
4136
+ * @returns {void}
4137
+ */
4138
+ select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
4139
+ const { value, ...select_attrs } = attrs;
4140
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
4141
+ this.child((renderer) => {
4142
+ renderer.local.select_value = value;
4143
+ fn(renderer);
4144
+ });
4145
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
4146
+ }
4147
+ /**
4148
+ * @param {Record<string, any>} attrs
4149
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
4150
+ * @param {string | undefined} [css_hash]
4151
+ * @param {Record<string, boolean> | undefined} [classes]
4152
+ * @param {Record<string, string> | undefined} [styles]
4153
+ * @param {number | undefined} [flags]
4154
+ * @param {boolean | undefined} [is_rich]
4155
+ */
4156
+ option(attrs, body, css_hash, classes, styles, flags, is_rich) {
4157
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
4158
+ /**
4159
+ * @param {Renderer} renderer
4160
+ * @param {any} value
4161
+ * @param {{ head?: string, body: any }} content
4162
+ */
4163
+ const close = (renderer, value, { head, body }) => {
4164
+ if (has_own_property.call(attrs, "value")) value = attrs.value;
4165
+ if (value === this.local.select_value) renderer.#out.push(" selected=\"\"");
4166
+ renderer.#out.push(`>${body}${is_rich ? "<!>" : ""}</option>`);
4167
+ if (head) renderer.head((child) => child.push(head));
4168
+ };
4169
+ if (typeof body === "function") this.child((renderer) => {
4170
+ const r = new Renderer(this.global, this);
4171
+ body(r);
4172
+ if (this.global.mode === "async") return r.#collect_content_async().then((content) => {
4173
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
4174
+ });
4175
+ else {
4176
+ const content = r.#collect_content();
4177
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
4178
+ }
4179
+ });
4180
+ else close(this, body, { body: escape_html(body) });
4181
+ }
4182
+ /**
4183
+ * @param {(renderer: Renderer) => void} fn
4184
+ */
4185
+ title(fn) {
4186
+ const path = this.get_path();
4187
+ /** @param {string} head */
4188
+ const close = (head) => {
4189
+ this.global.set_title(head, path);
4190
+ };
4191
+ this.child((renderer) => {
4192
+ const r = new Renderer(renderer.global, renderer);
4193
+ fn(r);
4194
+ if (renderer.global.mode === "async") return r.#collect_content_async().then((content) => {
4195
+ close(content.head);
4196
+ });
4197
+ else close(r.#collect_content().head);
4198
+ });
4199
+ }
4200
+ /**
4201
+ * @param {string | (() => Promise<string>)} content
4202
+ */
4203
+ push(content) {
4204
+ if (typeof content === "function") this.child(async (renderer) => renderer.push(await content()));
4205
+ else this.#out.push(content);
4206
+ }
4207
+ /**
4208
+ * @param {() => void} fn
4209
+ */
4210
+ on_destroy(fn) {
4211
+ (this.#on_destroy ??= []).push(fn);
4212
+ }
4213
+ /**
4214
+ * @returns {number[]}
4215
+ */
4216
+ get_path() {
4217
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
4218
+ }
4219
+ /**
4220
+ * @deprecated this is needed for legacy component bindings
4221
+ */
4222
+ copy() {
4223
+ const copy = new Renderer(this.global, this.#parent);
4224
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
4225
+ copy.promise = this.promise;
4226
+ return copy;
4227
+ }
4228
+ /**
4229
+ * @param {Renderer} other
4230
+ * @deprecated this is needed for legacy component bindings
4231
+ */
4232
+ subsume(other) {
4233
+ if (this.global.mode !== other.global.mode) throw new Error("invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!");
4234
+ this.local = other.local;
4235
+ this.#out = other.#out.map((item, i) => {
4236
+ const current = this.#out[i];
4237
+ if (current instanceof Renderer && item instanceof Renderer) {
4238
+ current.subsume(item);
4239
+ return current;
4240
+ }
4241
+ return item;
4242
+ });
4243
+ this.promise = other.promise;
4244
+ this.type = other.type;
4245
+ }
4246
+ get length() {
4247
+ return this.#out.length;
4248
+ }
4249
+ /**
4250
+ * Creates the hydration comment that marks the start of a failed boundary.
4251
+ * The error is JSON-serialized and embedded inside an HTML comment for the client
4252
+ * to parse during hydration. The JSON is escaped to prevent `-->` or `<!--` sequences
4253
+ * from breaking out of the comment (XSS). Uses unicode escapes which `JSON.parse()`
4254
+ * handles transparently.
4255
+ * @param {unknown} error
4256
+ * @returns {string}
4257
+ */
4258
+ static #serialize_failed_boundary(error) {
4259
+ return `<!--[?${JSON.stringify(error).replace(/>/g, "\\u003e").replace(/</g, "\\u003c")}-->`;
4260
+ }
4261
+ /**
4262
+ * Only available on the server and when compiling with the `server` option.
4263
+ * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
4264
+ * @template {Record<string, any>} Props
4265
+ * @param {Component<Props>} component
4266
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
4267
+ * @returns {RenderOutput}
4268
+ */
4269
+ static render(component, options = {}) {
4270
+ /** @type {AccumulatedContent | undefined} */
4271
+ let sync;
4272
+ const result = {};
4273
+ Object.defineProperties(result, {
4274
+ html: { get: () => {
4275
+ return (sync ??= Renderer.#render(component, options)).body;
4276
+ } },
4277
+ head: { get: () => {
4278
+ return (sync ??= Renderer.#render(component, options)).head;
4279
+ } },
4280
+ body: { get: () => {
4281
+ return (sync ??= Renderer.#render(component, options)).body;
4282
+ } },
4283
+ hashes: { value: { script: "" } },
4284
+ then: { value: (onfulfilled, onrejected) => {
4285
+ {
4286
+ const result = sync ??= Renderer.#render(component, options);
4287
+ const user_result = onfulfilled({
4288
+ head: result.head,
4289
+ body: result.body,
4290
+ html: result.body,
4291
+ hashes: { script: [] }
4292
+ });
4293
+ return Promise.resolve(user_result);
4294
+ }
4295
+ } }
4296
+ });
4297
+ return result;
4298
+ }
4299
+ /**
4300
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
4301
+ * after awaiting `collect_async`.
4302
+ *
4303
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
4304
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
4305
+ * @returns {Iterable<() => void>}
4306
+ */
4307
+ *#collect_on_destroy() {
4308
+ for (const component of this.#traverse_components()) yield* component.#collect_ondestroy();
4309
+ }
4310
+ /**
4311
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
4312
+ * @returns {Iterable<Renderer>}
4313
+ */
4314
+ *#traverse_components() {
4315
+ for (const child of this.#out) if (typeof child !== "string") yield* child.#traverse_components();
4316
+ if (this.#is_component_body) yield this;
4317
+ }
4318
+ /**
4319
+ * @returns {Iterable<() => void>}
4320
+ */
4321
+ *#collect_ondestroy() {
4322
+ if (this.#on_destroy) for (const fn of this.#on_destroy) yield fn;
4323
+ for (const child of this.#out) if (child instanceof Renderer && !child.#is_component_body) yield* child.#collect_ondestroy();
4324
+ }
4325
+ /**
4326
+ * Render a component. Throws if any of the children are performing asynchronous work.
4327
+ *
4328
+ * @template {Record<string, any>} Props
4329
+ * @param {Component<Props>} component
4330
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
4331
+ * @returns {AccumulatedContent}
4332
+ */
4333
+ static #render(component, options) {
4334
+ var previous_context = ssr_context;
4335
+ try {
4336
+ const renderer = Renderer.#open_render("sync", component, options);
4337
+ const content = renderer.#collect_content();
4338
+ return Renderer.#close_render(content, renderer);
4339
+ } finally {
4340
+ abort();
4341
+ set_ssr_context(previous_context);
4342
+ }
4343
+ }
4344
+ /**
4345
+ * Render a component.
4346
+ *
4347
+ * @template {Record<string, any>} Props
4348
+ * @param {Component<Props>} component
4349
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
4350
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
4351
+ */
4352
+ static async #render_async(component, options) {
4353
+ const previous_context = ssr_context;
4354
+ try {
4355
+ const renderer = Renderer.#open_render("async", component, options);
4356
+ const content = await renderer.#collect_content_async();
4357
+ const hydratables = await renderer.#collect_hydratables();
4358
+ if (hydratables !== null) content.head = hydratables + content.head;
4359
+ return Renderer.#close_render(content, renderer);
4360
+ } finally {
4361
+ set_ssr_context(previous_context);
4362
+ abort();
4363
+ }
4364
+ }
4365
+ /**
4366
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
4367
+ * @param {AccumulatedContent} content
4368
+ * @returns {AccumulatedContent}
4369
+ */
4370
+ #collect_content(content = {
4371
+ head: "",
4372
+ body: ""
4373
+ }) {
4374
+ for (const item of this.#out) if (typeof item === "string") content[this.type] += item;
4375
+ else if (item instanceof Renderer) item.#collect_content(content);
4376
+ return content;
4377
+ }
4378
+ /**
4379
+ * Collect all of the code from the `out` array and return it as a string.
4380
+ * @param {AccumulatedContent} content
4381
+ * @returns {Promise<AccumulatedContent>}
4382
+ */
4383
+ async #collect_content_async(content = {
4384
+ head: "",
4385
+ body: ""
4386
+ }) {
4387
+ await this.promise;
4388
+ for (const item of this.#out) if (typeof item === "string") content[this.type] += item;
4389
+ else if (item instanceof Renderer) if (item.#boundary) {
4390
+ /** @type {AccumulatedContent} */
4391
+ const boundary_content = {
4392
+ head: "",
4393
+ body: ""
4394
+ };
4395
+ try {
4396
+ await item.#collect_content_async(boundary_content);
4397
+ content.head += boundary_content.head;
4398
+ content.body += boundary_content.body;
4399
+ } catch (error) {
4400
+ const { context, failed, transformError } = item.#boundary;
4401
+ set_ssr_context(context);
4402
+ let transformed = await transformError(error);
4403
+ const failed_renderer = new Renderer(item.global, item);
4404
+ failed_renderer.type = item.type;
4405
+ failed_renderer.#out.push(Renderer.#serialize_failed_boundary(transformed));
4406
+ failed(failed_renderer, transformed, noop);
4407
+ failed_renderer.#out.push(BLOCK_CLOSE);
4408
+ await failed_renderer.#collect_content_async(content);
4409
+ }
4410
+ } else await item.#collect_content_async(content);
4411
+ return content;
4412
+ }
4413
+ async #collect_hydratables() {
4414
+ const ctx = get_render_context().hydratable;
4415
+ for (const [_, key] of ctx.unresolved_promises) unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
4416
+ for (const comparison of ctx.comparisons) await comparison;
4417
+ return await this.#hydratable_block(ctx);
4418
+ }
4419
+ /**
4420
+ * @template {Record<string, any>} Props
4421
+ * @param {'sync' | 'async'} mode
4422
+ * @param {import('svelte').Component<Props>} component
4423
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
4424
+ * @returns {Renderer}
4425
+ */
4426
+ static #open_render(mode, component, options) {
4427
+ if (options.idPrefix?.includes("--")) invalid_id_prefix();
4428
+ var previous_context = ssr_context;
4429
+ try {
4430
+ const renderer = new Renderer(new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp, options.transformError));
4431
+ set_ssr_context({
4432
+ p: null,
4433
+ c: options.context ?? null,
4434
+ r: renderer
4435
+ });
4436
+ renderer.push(BLOCK_OPEN);
4437
+ component(renderer, options.props ?? {});
4438
+ renderer.push(BLOCK_CLOSE);
4439
+ return renderer;
4440
+ } finally {
4441
+ set_ssr_context(previous_context);
4442
+ }
4443
+ }
4444
+ /**
4445
+ * @param {AccumulatedContent} content
4446
+ * @param {Renderer} renderer
4447
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
4448
+ */
4449
+ static #close_render(content, renderer) {
4450
+ for (const cleanup of renderer.#collect_on_destroy()) cleanup();
4451
+ let head = content.head + renderer.global.get_title();
4452
+ let body = content.body;
4453
+ for (const { hash, code } of renderer.global.css) head += `<style id="${hash}">${code}</style>`;
4454
+ return {
4455
+ head,
4456
+ body,
4457
+ hashes: { script: renderer.global.csp.script_hashes }
4458
+ };
4459
+ }
4460
+ /**
4461
+ * @param {HydratableContext} ctx
4462
+ */
4463
+ async #hydratable_block(ctx) {
4464
+ if (ctx.lookup.size === 0) return null;
4465
+ let entries = [];
4466
+ let has_promises = false;
4467
+ for (const [k, v] of ctx.lookup) {
4468
+ if (v.promises) {
4469
+ has_promises = true;
4470
+ for (const p of v.promises) await p;
4471
+ }
4472
+ entries.push(`[${uneval(k)},${v.serialized}]`);
4473
+ }
4474
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
4475
+ if (has_promises) prelude = `const r = (v) => Promise.resolve(v);
4476
+ ${prelude}`;
4477
+ const body = `
4478
+ {
4479
+ ${prelude}
4480
+
4481
+ for (const [k, v] of [
4482
+ ${entries.join(",\n ")}
4483
+ ]) {
4484
+ h.set(k, v);
4485
+ }
4486
+ }
4487
+ `;
4488
+ let csp_attr = "";
4489
+ if (this.global.csp.nonce) csp_attr = ` nonce="${this.global.csp.nonce}"`;
4490
+ else if (this.global.csp.hash) {
4491
+ const hash = await sha256(body);
4492
+ this.global.csp.script_hashes.push(`sha256-${hash}`);
4493
+ }
4494
+ return `\n\t\t<script${csp_attr}>${body}<\/script>`;
4495
+ }
4496
+ };
4497
+ var SSRState = class {
4498
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
4499
+ csp;
4500
+ /** @readonly @type {'sync' | 'async'} */
4501
+ mode;
4502
+ /** @readonly @type {() => string} */
4503
+ uid;
4504
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
4505
+ css = /* @__PURE__ */ new Set();
4506
+ /**
4507
+ * `transformError` passed to `render`. Called when an error boundary catches an error.
4508
+ * Throws by default if unset in `render`.
4509
+ * @type {(error: unknown) => unknown}
4510
+ */
4511
+ transformError;
4512
+ /** @type {{ path: number[], value: string }} */
4513
+ #title = {
4514
+ path: [],
4515
+ value: ""
4516
+ };
4517
+ /**
4518
+ * @param {'sync' | 'async'} mode
4519
+ * @param {string} id_prefix
4520
+ * @param {Csp} csp
4521
+ * @param {((error: unknown) => unknown) | undefined} [transformError]
4522
+ */
4523
+ constructor(mode, id_prefix = "", csp = { hash: false }, transformError) {
4524
+ this.mode = mode;
4525
+ this.csp = {
4526
+ ...csp,
4527
+ script_hashes: []
4528
+ };
4529
+ this.transformError = transformError ?? ((error) => {
4530
+ throw error;
4531
+ });
4532
+ let uid = 1;
4533
+ this.uid = () => `${id_prefix}s${uid++}`;
4534
+ }
4535
+ get_title() {
4536
+ return this.#title.value;
4537
+ }
4538
+ /**
4539
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
4540
+ * from earlier than or equal to the current value.
4541
+ * @param {string} value
4542
+ * @param {number[]} path
4543
+ */
4544
+ set_title(value, path) {
4545
+ const current = this.#title.path;
4546
+ let i = 0;
4547
+ let l = Math.min(path.length, current.length);
4548
+ while (i < l && path[i] === current[i]) i += 1;
4549
+ if (path[i] === void 0) return;
4550
+ if (current[i] === void 0 || path[i] > current[i]) {
4551
+ this.#title.path = path;
4552
+ this.#title.value = value;
4553
+ }
4554
+ }
4555
+ };
4556
+
4557
+ export { create_text as $, hasContext as A, getAllContexts as B, getAbortSignal as C, DevalueError as D, createContext as E, ssr_context as F, lifecycle_function_unavailable as G, experimental_async_required as H, get_render_context as I, hydratable_serialization_failed as J, render as K, set as L, LEGACY_PROPS as M, get as N, flushSync as O, define_property as P, mutable_source as Q, init_operations as R, get_first_child as S, get_next_sibling as T, HYDRATION_ERROR as U, set_hydrating as V, set_hydrate_node as W, hydration_failed as X, clear_text_content as Y, component_root as Z, hydrate_node as _, attr_class as a, boundary as a0, array_from as a1, is_passive_event as a2, set_active_reaction as a3, set_active_effect as a4, active_reaction as a5, active_effect as a6, hydrating as a7, push as a8, component_context as a9, hydration_mismatch as aa, pop as ab, bind_props as ac, attr as b, clsx$1 as c, escape_html as d, ensure_array_like as e, derived as f, unsubscribe_stores as g, html as h, getContext as i, head as j, attr_style as k, stringify as l, is_primitive as m, noop as n, get_type as o, is_plain_object as p, enumerable_symbols as q, readable as r, store_get as s, stringify_key as t, uneval as u, stringify_string as v, writable as w, valid_array_indices as x, run as y, setContext as z };
4558
+ //# sourceMappingURL=dev-CrqJ3ZR3.js.map