agent-replay 0.1.0

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 (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/bin/agent-replay.js +20 -0
  4. package/build/client/_app/immutable/assets/0.D9-tUsfl.css +1 -0
  5. package/build/client/_app/immutable/assets/0.D9-tUsfl.css.br +0 -0
  6. package/build/client/_app/immutable/assets/0.D9-tUsfl.css.gz +0 -0
  7. package/build/client/_app/immutable/assets/2.Ch4de4ty.css +1 -0
  8. package/build/client/_app/immutable/assets/2.Ch4de4ty.css.br +0 -0
  9. package/build/client/_app/immutable/assets/2.Ch4de4ty.css.gz +0 -0
  10. package/build/client/_app/immutable/assets/3.BP1aEJ1A.css +1 -0
  11. package/build/client/_app/immutable/assets/3.BP1aEJ1A.css.br +0 -0
  12. package/build/client/_app/immutable/assets/3.BP1aEJ1A.css.gz +0 -0
  13. package/build/client/_app/immutable/chunks/8LyLqy0e.js +1 -0
  14. package/build/client/_app/immutable/chunks/8LyLqy0e.js.br +3 -0
  15. package/build/client/_app/immutable/chunks/8LyLqy0e.js.gz +0 -0
  16. package/build/client/_app/immutable/chunks/BmaMsIzI.js +3 -0
  17. package/build/client/_app/immutable/chunks/BmaMsIzI.js.br +0 -0
  18. package/build/client/_app/immutable/chunks/BmaMsIzI.js.gz +0 -0
  19. package/build/client/_app/immutable/chunks/BoUXsunA.js +1 -0
  20. package/build/client/_app/immutable/chunks/BoUXsunA.js.br +0 -0
  21. package/build/client/_app/immutable/chunks/BoUXsunA.js.gz +0 -0
  22. package/build/client/_app/immutable/chunks/CCa20sJM.js +1 -0
  23. package/build/client/_app/immutable/chunks/CCa20sJM.js.br +0 -0
  24. package/build/client/_app/immutable/chunks/CCa20sJM.js.gz +0 -0
  25. package/build/client/_app/immutable/chunks/CP-o74wi.js +2 -0
  26. package/build/client/_app/immutable/chunks/CP-o74wi.js.br +0 -0
  27. package/build/client/_app/immutable/chunks/CP-o74wi.js.gz +0 -0
  28. package/build/client/_app/immutable/chunks/CZWwZlGk.js +1 -0
  29. package/build/client/_app/immutable/chunks/CZWwZlGk.js.br +0 -0
  30. package/build/client/_app/immutable/chunks/CZWwZlGk.js.gz +0 -0
  31. package/build/client/_app/immutable/chunks/D6SnDtAs.js +1 -0
  32. package/build/client/_app/immutable/chunks/D6SnDtAs.js.br +0 -0
  33. package/build/client/_app/immutable/chunks/D6SnDtAs.js.gz +0 -0
  34. package/build/client/_app/immutable/chunks/DApgqo7x.js +1 -0
  35. package/build/client/_app/immutable/chunks/DApgqo7x.js.br +0 -0
  36. package/build/client/_app/immutable/chunks/DApgqo7x.js.gz +0 -0
  37. package/build/client/_app/immutable/chunks/DCcb0kkP.js +1 -0
  38. package/build/client/_app/immutable/chunks/DCcb0kkP.js.br +0 -0
  39. package/build/client/_app/immutable/chunks/DCcb0kkP.js.gz +0 -0
  40. package/build/client/_app/immutable/entry/app.CelDjTDX.js +2 -0
  41. package/build/client/_app/immutable/entry/app.CelDjTDX.js.br +0 -0
  42. package/build/client/_app/immutable/entry/app.CelDjTDX.js.gz +0 -0
  43. package/build/client/_app/immutable/entry/start.Bo8U6P_2.js +1 -0
  44. package/build/client/_app/immutable/entry/start.Bo8U6P_2.js.br +2 -0
  45. package/build/client/_app/immutable/entry/start.Bo8U6P_2.js.gz +0 -0
  46. package/build/client/_app/immutable/nodes/0.DdgnJbSm.js +1 -0
  47. package/build/client/_app/immutable/nodes/0.DdgnJbSm.js.br +0 -0
  48. package/build/client/_app/immutable/nodes/0.DdgnJbSm.js.gz +0 -0
  49. package/build/client/_app/immutable/nodes/1.DUCL1Cc_.js +1 -0
  50. package/build/client/_app/immutable/nodes/1.DUCL1Cc_.js.br +0 -0
  51. package/build/client/_app/immutable/nodes/1.DUCL1Cc_.js.gz +0 -0
  52. package/build/client/_app/immutable/nodes/2.FNRc_Nvw.js +1 -0
  53. package/build/client/_app/immutable/nodes/2.FNRc_Nvw.js.br +0 -0
  54. package/build/client/_app/immutable/nodes/2.FNRc_Nvw.js.gz +0 -0
  55. package/build/client/_app/immutable/nodes/3.CaEmUkA2.js +29 -0
  56. package/build/client/_app/immutable/nodes/3.CaEmUkA2.js.br +0 -0
  57. package/build/client/_app/immutable/nodes/3.CaEmUkA2.js.gz +0 -0
  58. package/build/client/_app/version.json +1 -0
  59. package/build/client/_app/version.json.br +0 -0
  60. package/build/client/_app/version.json.gz +0 -0
  61. package/build/client/favicon.svg +13 -0
  62. package/build/client/favicon.svg.br +0 -0
  63. package/build/client/favicon.svg.gz +0 -0
  64. package/build/client/robots.txt +3 -0
  65. package/build/client/screenshot.png +0 -0
  66. package/build/env.js +94 -0
  67. package/build/handler.js +1494 -0
  68. package/build/index.js +345 -0
  69. package/build/server/chunks/0-CkGitm9W.js +9 -0
  70. package/build/server/chunks/0-CkGitm9W.js.map +1 -0
  71. package/build/server/chunks/1-BU8Hl3FY.js +9 -0
  72. package/build/server/chunks/1-BU8Hl3FY.js.map +1 -0
  73. package/build/server/chunks/2-DenZJmTh.js +27 -0
  74. package/build/server/chunks/2-DenZJmTh.js.map +1 -0
  75. package/build/server/chunks/3-Df2VKXDy.js +73 -0
  76. package/build/server/chunks/3-Df2VKXDy.js.map +1 -0
  77. package/build/server/chunks/_layout.svelte-BK7oCPlN.js +26 -0
  78. package/build/server/chunks/_layout.svelte-BK7oCPlN.js.map +1 -0
  79. package/build/server/chunks/_page.svelte-BMqbzglq.js +178 -0
  80. package/build/server/chunks/_page.svelte-BMqbzglq.js.map +1 -0
  81. package/build/server/chunks/_page.svelte-C2kNC2pi.js +504 -0
  82. package/build/server/chunks/_page.svelte-C2kNC2pi.js.map +1 -0
  83. package/build/server/chunks/context-JUYyv6NC.js +74 -0
  84. package/build/server/chunks/context-JUYyv6NC.js.map +1 -0
  85. package/build/server/chunks/error.svelte-Epasb48G.js +46 -0
  86. package/build/server/chunks/error.svelte-Epasb48G.js.map +1 -0
  87. package/build/server/chunks/escaping-CqgfEcN3.js +19 -0
  88. package/build/server/chunks/escaping-CqgfEcN3.js.map +1 -0
  89. package/build/server/chunks/exports-CURVw3-F.js +303 -0
  90. package/build/server/chunks/exports-CURVw3-F.js.map +1 -0
  91. package/build/server/chunks/format-dOzJq-yD.js +59 -0
  92. package/build/server/chunks/format-dOzJq-yD.js.map +1 -0
  93. package/build/server/chunks/index-C0L7m6Jv.js +1497 -0
  94. package/build/server/chunks/index-C0L7m6Jv.js.map +1 -0
  95. package/build/server/chunks/index-CoD1IJuy.js +190 -0
  96. package/build/server/chunks/index-CoD1IJuy.js.map +1 -0
  97. package/build/server/chunks/index2-f44F-4KW.js +614 -0
  98. package/build/server/chunks/index2-f44F-4KW.js.map +1 -0
  99. package/build/server/chunks/shared-server-DaWdgxVh.js +11 -0
  100. package/build/server/chunks/shared-server-DaWdgxVh.js.map +1 -0
  101. package/build/server/index.js +8152 -0
  102. package/build/server/index.js.map +1 -0
  103. package/build/server/manifest.js +54 -0
  104. package/build/server/manifest.js.map +1 -0
  105. package/build/shims.js +32 -0
  106. package/package.json +71 -0
  107. package/static/favicon.svg +13 -0
  108. package/static/robots.txt +3 -0
  109. package/static/screenshot.png +0 -0
@@ -0,0 +1,1497 @@
1
+ import { e as escape_html } from './escaping-CqgfEcN3.js';
2
+ import { n as noop, l as set_ssr_context, m as ssr_context, p as push, q as pop } from './context-JUYyv6NC.js';
3
+
4
+ /** @type {Record<string, string>} */
5
+ const escaped = {
6
+ '<': '\\u003C',
7
+ '\\': '\\\\',
8
+ '\b': '\\b',
9
+ '\f': '\\f',
10
+ '\n': '\\n',
11
+ '\r': '\\r',
12
+ '\t': '\\t',
13
+ '\u2028': '\\u2028',
14
+ '\u2029': '\\u2029'
15
+ };
16
+
17
+ class DevalueError extends Error {
18
+ /**
19
+ * @param {string} message
20
+ * @param {string[]} keys
21
+ * @param {any} [value] - The value that failed to be serialized
22
+ * @param {any} [root] - The root value being serialized
23
+ */
24
+ constructor(message, keys, value, root) {
25
+ super(message);
26
+ this.name = 'DevalueError';
27
+ this.path = keys.join('');
28
+ this.value = value;
29
+ this.root = root;
30
+ }
31
+ }
32
+
33
+ /** @param {any} thing */
34
+ function is_primitive(thing) {
35
+ return Object(thing) !== thing;
36
+ }
37
+
38
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
39
+ Object.prototype
40
+ )
41
+ .sort()
42
+ .join('\0');
43
+
44
+ /** @param {any} thing */
45
+ function is_plain_object(thing) {
46
+ const proto = Object.getPrototypeOf(thing);
47
+
48
+ return (
49
+ proto === Object.prototype ||
50
+ proto === null ||
51
+ Object.getPrototypeOf(proto) === null ||
52
+ Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
53
+ );
54
+ }
55
+
56
+ /** @param {any} thing */
57
+ function get_type(thing) {
58
+ return Object.prototype.toString.call(thing).slice(8, -1);
59
+ }
60
+
61
+ /** @param {string} char */
62
+ function get_escaped_char(char) {
63
+ switch (char) {
64
+ case '"':
65
+ return '\\"';
66
+ case '<':
67
+ return '\\u003C';
68
+ case '\\':
69
+ return '\\\\';
70
+ case '\n':
71
+ return '\\n';
72
+ case '\r':
73
+ return '\\r';
74
+ case '\t':
75
+ return '\\t';
76
+ case '\b':
77
+ return '\\b';
78
+ case '\f':
79
+ return '\\f';
80
+ case '\u2028':
81
+ return '\\u2028';
82
+ case '\u2029':
83
+ return '\\u2029';
84
+ default:
85
+ return char < ' '
86
+ ? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`
87
+ : '';
88
+ }
89
+ }
90
+
91
+ /** @param {string} str */
92
+ function stringify_string(str) {
93
+ let result = '';
94
+ let last_pos = 0;
95
+ const len = str.length;
96
+
97
+ for (let i = 0; i < len; i += 1) {
98
+ const char = str[i];
99
+ const replacement = get_escaped_char(char);
100
+ if (replacement) {
101
+ result += str.slice(last_pos, i) + replacement;
102
+ last_pos = i + 1;
103
+ }
104
+ }
105
+
106
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
107
+ }
108
+
109
+ /** @param {Record<string | symbol, any>} object */
110
+ function enumerable_symbols(object) {
111
+ return Object.getOwnPropertySymbols(object).filter(
112
+ (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
113
+ );
114
+ }
115
+
116
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
117
+
118
+ /** @param {string} key */
119
+ function stringify_key(key) {
120
+ return is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';
121
+ }
122
+
123
+ const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
124
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
125
+ const reserved =
126
+ /^(?: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)$/;
127
+
128
+ /**
129
+ * Turn a value into the JavaScript that creates an equivalent value
130
+ * @param {any} value
131
+ * @param {(value: any, uneval: (value: any) => string) => string | void} [replacer]
132
+ */
133
+ function uneval(value, replacer) {
134
+ const counts = new Map();
135
+
136
+ /** @type {string[]} */
137
+ const keys = [];
138
+
139
+ const custom = new Map();
140
+
141
+ /** @param {any} thing */
142
+ function walk(thing) {
143
+ if (!is_primitive(thing)) {
144
+ if (counts.has(thing)) {
145
+ counts.set(thing, counts.get(thing) + 1);
146
+ return;
147
+ }
148
+
149
+ counts.set(thing, 1);
150
+
151
+ if (replacer) {
152
+ const str = replacer(thing, (value) => uneval(value, replacer));
153
+
154
+ if (typeof str === 'string') {
155
+ custom.set(thing, str);
156
+ return;
157
+ }
158
+ }
159
+
160
+ if (typeof thing === 'function') {
161
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
162
+ }
163
+
164
+ const type = get_type(thing);
165
+
166
+ switch (type) {
167
+ case 'Number':
168
+ case 'BigInt':
169
+ case 'String':
170
+ case 'Boolean':
171
+ case 'Date':
172
+ case 'RegExp':
173
+ case 'URL':
174
+ case 'URLSearchParams':
175
+ return;
176
+
177
+ case 'Array':
178
+ /** @type {any[]} */ (thing).forEach((value, i) => {
179
+ keys.push(`[${i}]`);
180
+ walk(value);
181
+ keys.pop();
182
+ });
183
+ break;
184
+
185
+ case 'Set':
186
+ Array.from(thing).forEach(walk);
187
+ break;
188
+
189
+ case 'Map':
190
+ for (const [key, value] of thing) {
191
+ keys.push(
192
+ `.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`
193
+ );
194
+ walk(value);
195
+ keys.pop();
196
+ }
197
+ break;
198
+
199
+ case 'Int8Array':
200
+ case 'Uint8Array':
201
+ case 'Uint8ClampedArray':
202
+ case 'Int16Array':
203
+ case 'Uint16Array':
204
+ case 'Int32Array':
205
+ case 'Uint32Array':
206
+ case 'Float32Array':
207
+ case 'Float64Array':
208
+ case 'BigInt64Array':
209
+ case 'BigUint64Array':
210
+ walk(thing.buffer);
211
+ return;
212
+
213
+ case 'ArrayBuffer':
214
+ return;
215
+
216
+ case 'Temporal.Duration':
217
+ case 'Temporal.Instant':
218
+ case 'Temporal.PlainDate':
219
+ case 'Temporal.PlainTime':
220
+ case 'Temporal.PlainDateTime':
221
+ case 'Temporal.PlainMonthDay':
222
+ case 'Temporal.PlainYearMonth':
223
+ case 'Temporal.ZonedDateTime':
224
+ return;
225
+
226
+ default:
227
+ if (!is_plain_object(thing)) {
228
+ throw new DevalueError(
229
+ `Cannot stringify arbitrary non-POJOs`,
230
+ keys,
231
+ thing,
232
+ value
233
+ );
234
+ }
235
+
236
+ if (enumerable_symbols(thing).length > 0) {
237
+ throw new DevalueError(
238
+ `Cannot stringify POJOs with symbolic keys`,
239
+ keys,
240
+ thing,
241
+ value
242
+ );
243
+ }
244
+
245
+ for (const key in thing) {
246
+ keys.push(stringify_key(key));
247
+ walk(thing[key]);
248
+ keys.pop();
249
+ }
250
+ }
251
+ }
252
+ }
253
+
254
+ walk(value);
255
+
256
+ const names = new Map();
257
+
258
+ Array.from(counts)
259
+ .filter((entry) => entry[1] > 1)
260
+ .sort((a, b) => b[1] - a[1])
261
+ .forEach((entry, i) => {
262
+ names.set(entry[0], get_name(i));
263
+ });
264
+
265
+ /**
266
+ * @param {any} thing
267
+ * @returns {string}
268
+ */
269
+ function stringify(thing) {
270
+ if (names.has(thing)) {
271
+ return names.get(thing);
272
+ }
273
+
274
+ if (is_primitive(thing)) {
275
+ return stringify_primitive(thing);
276
+ }
277
+
278
+ if (custom.has(thing)) {
279
+ return custom.get(thing);
280
+ }
281
+
282
+ const type = get_type(thing);
283
+
284
+ switch (type) {
285
+ case 'Number':
286
+ case 'String':
287
+ case 'Boolean':
288
+ return `Object(${stringify(thing.valueOf())})`;
289
+
290
+ case 'RegExp':
291
+ return `new RegExp(${stringify_string(thing.source)}, "${
292
+ thing.flags
293
+ }")`;
294
+
295
+ case 'Date':
296
+ return `new Date(${thing.getTime()})`;
297
+
298
+ case 'URL':
299
+ return `new URL(${stringify_string(thing.toString())})`;
300
+
301
+ case 'URLSearchParams':
302
+ return `new URLSearchParams(${stringify_string(thing.toString())})`;
303
+
304
+ case 'Array':
305
+ const members = /** @type {any[]} */ (thing).map((v, i) =>
306
+ i in thing ? stringify(v) : ''
307
+ );
308
+ const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
309
+ return `[${members.join(',')}${tail}]`;
310
+
311
+ case 'Set':
312
+ case 'Map':
313
+ return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
314
+
315
+ case 'Int8Array':
316
+ case 'Uint8Array':
317
+ case 'Uint8ClampedArray':
318
+ case 'Int16Array':
319
+ case 'Uint16Array':
320
+ case 'Int32Array':
321
+ case 'Uint32Array':
322
+ case 'Float32Array':
323
+ case 'Float64Array':
324
+ case 'BigInt64Array':
325
+ case 'BigUint64Array': {
326
+ let str = `new ${type}`;
327
+
328
+ if (counts.get(thing.buffer) === 1) {
329
+ const array = new thing.constructor(thing.buffer);
330
+ str += `([${array}])`;
331
+ } else {
332
+ str += `([${stringify(thing.buffer)}])`;
333
+ }
334
+
335
+ const a = thing.byteOffset;
336
+ const b = a + thing.byteLength;
337
+
338
+ // handle subarrays
339
+ if (a > 0 || b !== thing.buffer.byteLength) {
340
+ const m = +/(\d+)/.exec(type)[1] / 8;
341
+ str += `.subarray(${a / m},${b / m})`;
342
+ }
343
+
344
+ return str;
345
+ }
346
+
347
+ case 'ArrayBuffer': {
348
+ const ui8 = new Uint8Array(thing);
349
+ return `new Uint8Array([${ui8.toString()}]).buffer`;
350
+ }
351
+
352
+ case 'Temporal.Duration':
353
+ case 'Temporal.Instant':
354
+ case 'Temporal.PlainDate':
355
+ case 'Temporal.PlainTime':
356
+ case 'Temporal.PlainDateTime':
357
+ case 'Temporal.PlainMonthDay':
358
+ case 'Temporal.PlainYearMonth':
359
+ case 'Temporal.ZonedDateTime':
360
+ return `${type}.from(${stringify_string(thing.toString())})`;
361
+
362
+ default:
363
+ const keys = Object.keys(thing);
364
+ const obj = keys
365
+ .map((key) => `${safe_key(key)}:${stringify(thing[key])}`)
366
+ .join(',');
367
+ const proto = Object.getPrototypeOf(thing);
368
+ if (proto === null) {
369
+ return keys.length > 0
370
+ ? `{${obj},__proto__:null}`
371
+ : `{__proto__:null}`;
372
+ }
373
+
374
+ return `{${obj}}`;
375
+ }
376
+ }
377
+
378
+ const str = stringify(value);
379
+
380
+ if (names.size) {
381
+ /** @type {string[]} */
382
+ const params = [];
383
+
384
+ /** @type {string[]} */
385
+ const statements = [];
386
+
387
+ /** @type {string[]} */
388
+ const values = [];
389
+
390
+ names.forEach((name, thing) => {
391
+ params.push(name);
392
+
393
+ if (custom.has(thing)) {
394
+ values.push(/** @type {string} */ (custom.get(thing)));
395
+ return;
396
+ }
397
+
398
+ if (is_primitive(thing)) {
399
+ values.push(stringify_primitive(thing));
400
+ return;
401
+ }
402
+
403
+ const type = get_type(thing);
404
+
405
+ switch (type) {
406
+ case 'Number':
407
+ case 'String':
408
+ case 'Boolean':
409
+ values.push(`Object(${stringify(thing.valueOf())})`);
410
+ break;
411
+
412
+ case 'RegExp':
413
+ values.push(thing.toString());
414
+ break;
415
+
416
+ case 'Date':
417
+ values.push(`new Date(${thing.getTime()})`);
418
+ break;
419
+
420
+ case 'Array':
421
+ values.push(`Array(${thing.length})`);
422
+ /** @type {any[]} */ (thing).forEach((v, i) => {
423
+ statements.push(`${name}[${i}]=${stringify(v)}`);
424
+ });
425
+ break;
426
+
427
+ case 'Set':
428
+ values.push(`new Set`);
429
+ statements.push(
430
+ `${name}.${Array.from(thing)
431
+ .map((v) => `add(${stringify(v)})`)
432
+ .join('.')}`
433
+ );
434
+ break;
435
+
436
+ case 'Map':
437
+ values.push(`new Map`);
438
+ statements.push(
439
+ `${name}.${Array.from(thing)
440
+ .map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`)
441
+ .join('.')}`
442
+ );
443
+ break;
444
+
445
+ case 'ArrayBuffer':
446
+ values.push(
447
+ `new Uint8Array([${new Uint8Array(thing).join(',')}]).buffer`
448
+ );
449
+ break;
450
+
451
+ default:
452
+ values.push(
453
+ Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'
454
+ );
455
+ Object.keys(thing).forEach((key) => {
456
+ statements.push(
457
+ `${name}${safe_prop(key)}=${stringify(thing[key])}`
458
+ );
459
+ });
460
+ }
461
+ });
462
+
463
+ statements.push(`return ${str}`);
464
+
465
+ return `(function(${params.join(',')}){${statements.join(
466
+ ';'
467
+ )}}(${values.join(',')}))`;
468
+ } else {
469
+ return str;
470
+ }
471
+ }
472
+
473
+ /** @param {number} num */
474
+ function get_name(num) {
475
+ let name = '';
476
+
477
+ do {
478
+ name = chars[num % chars.length] + name;
479
+ num = ~~(num / chars.length) - 1;
480
+ } while (num >= 0);
481
+
482
+ return reserved.test(name) ? `${name}0` : name;
483
+ }
484
+
485
+ /** @param {string} c */
486
+ function escape_unsafe_char(c) {
487
+ return escaped[c] || c;
488
+ }
489
+
490
+ /** @param {string} str */
491
+ function escape_unsafe_chars(str) {
492
+ return str.replace(unsafe_chars, escape_unsafe_char);
493
+ }
494
+
495
+ /** @param {string} key */
496
+ function safe_key(key) {
497
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
498
+ ? key
499
+ : escape_unsafe_chars(JSON.stringify(key));
500
+ }
501
+
502
+ /** @param {string} key */
503
+ function safe_prop(key) {
504
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
505
+ ? `.${key}`
506
+ : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
507
+ }
508
+
509
+ /** @param {any} thing */
510
+ function stringify_primitive(thing) {
511
+ if (typeof thing === 'string') return stringify_string(thing);
512
+ if (thing === void 0) return 'void 0';
513
+ if (thing === 0 && 1 / thing < 0) return '-0';
514
+ const str = String(thing);
515
+ if (typeof thing === 'number') return str.replace(/^(-)?0\./, '$1.');
516
+ if (typeof thing === 'bigint') return thing + 'n';
517
+ return str;
518
+ }
519
+
520
+ 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$1(){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}
521
+
522
+ const DERIVED = 1 << 1;
523
+ const EFFECT = 1 << 2;
524
+ const RENDER_EFFECT = 1 << 3;
525
+ const MANAGED_EFFECT = 1 << 24;
526
+ const BLOCK_EFFECT = 1 << 4;
527
+ const BRANCH_EFFECT = 1 << 5;
528
+ const ROOT_EFFECT = 1 << 6;
529
+ const BOUNDARY_EFFECT = 1 << 7;
530
+ const CONNECTED = 1 << 9;
531
+ const CLEAN = 1 << 10;
532
+ const DIRTY = 1 << 11;
533
+ const MAYBE_DIRTY = 1 << 12;
534
+ const INERT = 1 << 13;
535
+ const DESTROYED = 1 << 14;
536
+ const REACTION_RAN = 1 << 15;
537
+ const EFFECT_TRANSPARENT = 1 << 16;
538
+ const EAGER_EFFECT = 1 << 17;
539
+ const HEAD_EFFECT = 1 << 18;
540
+ const EFFECT_PRESERVED = 1 << 19;
541
+ const USER_EFFECT = 1 << 20;
542
+ const WAS_MARKED = 1 << 16;
543
+ const REACTION_IS_UPDATING = 1 << 21;
544
+ const ASYNC = 1 << 22;
545
+ const ERROR_VALUE = 1 << 23;
546
+ const STATE_SYMBOL = /* @__PURE__ */ Symbol("$state");
547
+ const LEGACY_PROPS = /* @__PURE__ */ Symbol("legacy props");
548
+ const STALE_REACTION = new class StaleReactionError extends Error {
549
+ name = "StaleReactionError";
550
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
551
+ }();
552
+ const COMMENT_NODE = 8;
553
+ const HYDRATION_START = "[";
554
+ const HYDRATION_START_ELSE = "[!";
555
+ const HYDRATION_END = "]";
556
+ const HYDRATION_ERROR = {};
557
+ const ELEMENT_IS_NAMESPACED = 1;
558
+ const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 1 << 1;
559
+ const ELEMENT_IS_INPUT = 1 << 2;
560
+ const UNINITIALIZED = /* @__PURE__ */ Symbol();
561
+ const DOM_BOOLEAN_ATTRIBUTES = [
562
+ "allowfullscreen",
563
+ "async",
564
+ "autofocus",
565
+ "autoplay",
566
+ "checked",
567
+ "controls",
568
+ "default",
569
+ "disabled",
570
+ "formnovalidate",
571
+ "indeterminate",
572
+ "inert",
573
+ "ismap",
574
+ "loop",
575
+ "multiple",
576
+ "muted",
577
+ "nomodule",
578
+ "novalidate",
579
+ "open",
580
+ "playsinline",
581
+ "readonly",
582
+ "required",
583
+ "reversed",
584
+ "seamless",
585
+ "selected",
586
+ "webkitdirectory",
587
+ "defer",
588
+ "disablepictureinpicture",
589
+ "disableremoteplayback"
590
+ ];
591
+ function is_boolean_attribute(name) {
592
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
593
+ }
594
+ const PASSIVE_EVENTS = ["touchstart", "touchmove"];
595
+ function is_passive_event(name) {
596
+ return PASSIVE_EVENTS.includes(name);
597
+ }
598
+ const replacements = {
599
+ translate: /* @__PURE__ */ new Map([
600
+ [true, "yes"],
601
+ [false, "no"]
602
+ ])
603
+ };
604
+ function attr(name, value, is_boolean = false) {
605
+ if (name === "hidden" && value !== "until-found") {
606
+ is_boolean = true;
607
+ }
608
+ if (value == null || !value && is_boolean) return "";
609
+ const normalized = name in replacements && replacements[name].get(value) || value;
610
+ const assignment = is_boolean ? `=""` : `="${escape_html(normalized, true)}"`;
611
+ return ` ${name}${assignment}`;
612
+ }
613
+ function clsx(value) {
614
+ if (typeof value === "object") {
615
+ return clsx$1(value);
616
+ } else {
617
+ return value ?? "";
618
+ }
619
+ }
620
+ const whitespace = [..." \n\r\f \v\uFEFF"];
621
+ function to_class(value, hash, directives) {
622
+ var classname = value == null ? "" : "" + value;
623
+ if (hash) {
624
+ classname = classname ? classname + " " + hash : hash;
625
+ }
626
+ if (directives) {
627
+ for (var key in directives) {
628
+ if (directives[key]) {
629
+ classname = classname ? classname + " " + key : key;
630
+ } else if (classname.length) {
631
+ var len = key.length;
632
+ var a = 0;
633
+ while ((a = classname.indexOf(key, a)) >= 0) {
634
+ var b = a + len;
635
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
636
+ classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
637
+ } else {
638
+ a = b;
639
+ }
640
+ }
641
+ }
642
+ }
643
+ }
644
+ return classname === "" ? null : classname;
645
+ }
646
+ function append_styles(styles, important = false) {
647
+ var separator = important ? " !important;" : ";";
648
+ var css = "";
649
+ for (var key in styles) {
650
+ var value = styles[key];
651
+ if (value != null && value !== "") {
652
+ css += " " + key + ": " + value + separator;
653
+ }
654
+ }
655
+ return css;
656
+ }
657
+ function to_css_name(name) {
658
+ if (name[0] !== "-" || name[1] !== "-") {
659
+ return name.toLowerCase();
660
+ }
661
+ return name;
662
+ }
663
+ function to_style(value, styles) {
664
+ if (styles) {
665
+ var new_style = "";
666
+ var normal_styles;
667
+ var important_styles;
668
+ if (Array.isArray(styles)) {
669
+ normal_styles = styles[0];
670
+ important_styles = styles[1];
671
+ } else {
672
+ normal_styles = styles;
673
+ }
674
+ if (value) {
675
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
676
+ var in_str = false;
677
+ var in_apo = 0;
678
+ var in_comment = false;
679
+ var reserved_names = [];
680
+ if (normal_styles) {
681
+ reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
682
+ }
683
+ if (important_styles) {
684
+ reserved_names.push(...Object.keys(important_styles).map(to_css_name));
685
+ }
686
+ var start_index = 0;
687
+ var name_index = -1;
688
+ const len = value.length;
689
+ for (var i = 0; i < len; i++) {
690
+ var c = value[i];
691
+ if (in_comment) {
692
+ if (c === "/" && value[i - 1] === "*") {
693
+ in_comment = false;
694
+ }
695
+ } else if (in_str) {
696
+ if (in_str === c) {
697
+ in_str = false;
698
+ }
699
+ } else if (c === "/" && value[i + 1] === "*") {
700
+ in_comment = true;
701
+ } else if (c === '"' || c === "'") {
702
+ in_str = c;
703
+ } else if (c === "(") {
704
+ in_apo++;
705
+ } else if (c === ")") {
706
+ in_apo--;
707
+ }
708
+ if (!in_comment && in_str === false && in_apo === 0) {
709
+ if (c === ":" && name_index === -1) {
710
+ name_index = i;
711
+ } else if (c === ";" || i === len - 1) {
712
+ if (name_index !== -1) {
713
+ var name = to_css_name(value.substring(start_index, name_index).trim());
714
+ if (!reserved_names.includes(name)) {
715
+ if (c !== ";") {
716
+ i++;
717
+ }
718
+ var property = value.substring(start_index, i).trim();
719
+ new_style += " " + property + ";";
720
+ }
721
+ }
722
+ start_index = i + 1;
723
+ name_index = -1;
724
+ }
725
+ }
726
+ }
727
+ }
728
+ if (normal_styles) {
729
+ new_style += append_styles(normal_styles);
730
+ }
731
+ if (important_styles) {
732
+ new_style += append_styles(important_styles, true);
733
+ }
734
+ new_style = new_style.trim();
735
+ return new_style === "" ? null : new_style;
736
+ }
737
+ return value == null ? null : String(value);
738
+ }
739
+ const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
740
+ const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
741
+ const EMPTY_COMMENT = `<!---->`;
742
+ let controller = null;
743
+ function abort() {
744
+ controller?.abort(STALE_REACTION);
745
+ controller = null;
746
+ }
747
+ function await_invalid() {
748
+ const error = new Error(`await_invalid
749
+ Encountered asynchronous work while rendering synchronously.
750
+ https://svelte.dev/e/await_invalid`);
751
+ error.name = "Svelte error";
752
+ throw error;
753
+ }
754
+ function invalid_csp() {
755
+ const error = new Error(`invalid_csp
756
+ \`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
757
+ https://svelte.dev/e/invalid_csp`);
758
+ error.name = "Svelte error";
759
+ throw error;
760
+ }
761
+ function server_context_required() {
762
+ const error = new Error(`server_context_required
763
+ Could not resolve \`render\` context.
764
+ https://svelte.dev/e/server_context_required`);
765
+ error.name = "Svelte error";
766
+ throw error;
767
+ }
768
+ function unresolved_hydratable(key, stack) {
769
+ {
770
+ console.warn(`https://svelte.dev/e/unresolved_hydratable`);
771
+ }
772
+ }
773
+ function get_render_context() {
774
+ const store = als?.getStore();
775
+ {
776
+ server_context_required();
777
+ }
778
+ return store;
779
+ }
780
+ let als = null;
781
+ let text_encoder;
782
+ let crypto;
783
+ async function sha256(data) {
784
+ text_encoder ??= new TextEncoder();
785
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (
786
+ // @ts-ignore - we don't install node types in the prod build
787
+ // don't use 'node:crypto' because static analysers will think we rely on node when we don't
788
+ (await import(
789
+ /* @vite-ignore */
790
+ 'node:crypto'
791
+ )).webcrypto
792
+ );
793
+ const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data));
794
+ return base64_encode(hash_buffer);
795
+ }
796
+ function base64_encode(bytes) {
797
+ if (globalThis.Buffer) {
798
+ return globalThis.Buffer.from(bytes).toString("base64");
799
+ }
800
+ let binary = "";
801
+ for (let i = 0; i < bytes.length; i++) {
802
+ binary += String.fromCharCode(bytes[i]);
803
+ }
804
+ return btoa(binary);
805
+ }
806
+ class Renderer {
807
+ /**
808
+ * The contents of the renderer.
809
+ * @type {RendererItem[]}
810
+ */
811
+ #out = [];
812
+ /**
813
+ * Any `onDestroy` callbacks registered during execution of this renderer.
814
+ * @type {(() => void)[] | undefined}
815
+ */
816
+ #on_destroy = void 0;
817
+ /**
818
+ * Whether this renderer is a component body.
819
+ * @type {boolean}
820
+ */
821
+ #is_component_body = false;
822
+ /**
823
+ * The type of string content that this renderer is accumulating.
824
+ * @type {RendererType}
825
+ */
826
+ type;
827
+ /** @type {Renderer | undefined} */
828
+ #parent;
829
+ /**
830
+ * Asynchronous work associated with this renderer
831
+ * @type {Promise<void> | undefined}
832
+ */
833
+ promise = void 0;
834
+ /**
835
+ * State which is associated with the content tree as a whole.
836
+ * It will be re-exposed, uncopied, on all children.
837
+ * @type {SSRState}
838
+ * @readonly
839
+ */
840
+ global;
841
+ /**
842
+ * State that is local to the branch it is declared in.
843
+ * It will be shallow-copied to all children.
844
+ *
845
+ * @type {{ select_value: string | undefined }}
846
+ */
847
+ local;
848
+ /**
849
+ * @param {SSRState} global
850
+ * @param {Renderer | undefined} [parent]
851
+ */
852
+ constructor(global, parent) {
853
+ this.#parent = parent;
854
+ this.global = global;
855
+ this.local = parent ? { ...parent.local } : { select_value: void 0 };
856
+ this.type = parent ? parent.type : "body";
857
+ }
858
+ /**
859
+ * @param {(renderer: Renderer) => void} fn
860
+ */
861
+ head(fn) {
862
+ const head2 = new Renderer(this.global, this);
863
+ head2.type = "head";
864
+ this.#out.push(head2);
865
+ head2.child(fn);
866
+ }
867
+ /**
868
+ * @param {Array<Promise<void>>} blockers
869
+ * @param {(renderer: Renderer) => void} fn
870
+ */
871
+ async_block(blockers, fn) {
872
+ this.#out.push(BLOCK_OPEN);
873
+ this.async(blockers, fn);
874
+ this.#out.push(BLOCK_CLOSE);
875
+ }
876
+ /**
877
+ * @param {Array<Promise<void>>} blockers
878
+ * @param {(renderer: Renderer) => void} fn
879
+ */
880
+ async(blockers, fn) {
881
+ let callback = fn;
882
+ if (blockers.length > 0) {
883
+ const context = ssr_context;
884
+ callback = (renderer) => {
885
+ return Promise.all(blockers).then(() => {
886
+ const previous_context = ssr_context;
887
+ try {
888
+ set_ssr_context(context);
889
+ return fn(renderer);
890
+ } finally {
891
+ set_ssr_context(previous_context);
892
+ }
893
+ });
894
+ };
895
+ }
896
+ this.child(callback);
897
+ }
898
+ /**
899
+ * @param {Array<() => void>} thunks
900
+ */
901
+ run(thunks) {
902
+ const context = ssr_context;
903
+ let promise = Promise.resolve(thunks[0]());
904
+ const promises = [promise];
905
+ for (const fn of thunks.slice(1)) {
906
+ promise = promise.then(() => {
907
+ const previous_context = ssr_context;
908
+ set_ssr_context(context);
909
+ try {
910
+ return fn();
911
+ } finally {
912
+ set_ssr_context(previous_context);
913
+ }
914
+ });
915
+ promises.push(promise);
916
+ }
917
+ promise.catch(noop);
918
+ this.promise = promise;
919
+ return promises;
920
+ }
921
+ /**
922
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
923
+ */
924
+ child_block(fn) {
925
+ this.#out.push(BLOCK_OPEN);
926
+ this.child(fn);
927
+ this.#out.push(BLOCK_CLOSE);
928
+ }
929
+ /**
930
+ * Create a child renderer. The child renderer inherits the state from the parent,
931
+ * but has its own content.
932
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
933
+ */
934
+ child(fn) {
935
+ const child = new Renderer(this.global, this);
936
+ this.#out.push(child);
937
+ const parent = ssr_context;
938
+ set_ssr_context({
939
+ ...ssr_context,
940
+ p: parent,
941
+ c: null,
942
+ r: child
943
+ });
944
+ const result = fn(child);
945
+ set_ssr_context(parent);
946
+ if (result instanceof Promise) {
947
+ if (child.global.mode === "sync") {
948
+ await_invalid();
949
+ }
950
+ result.catch(() => {
951
+ });
952
+ child.promise = result;
953
+ }
954
+ return child;
955
+ }
956
+ /**
957
+ * Create a component renderer. The component renderer inherits the state from the parent,
958
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
959
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
960
+ * @param {Function} [component_fn]
961
+ * @returns {void}
962
+ */
963
+ component(fn, component_fn) {
964
+ push();
965
+ const child = this.child(fn);
966
+ child.#is_component_body = true;
967
+ pop();
968
+ }
969
+ /**
970
+ * @param {Record<string, any>} attrs
971
+ * @param {(renderer: Renderer) => void} fn
972
+ * @param {string | undefined} [css_hash]
973
+ * @param {Record<string, boolean> | undefined} [classes]
974
+ * @param {Record<string, string> | undefined} [styles]
975
+ * @param {number | undefined} [flags]
976
+ * @param {boolean | undefined} [is_rich]
977
+ * @returns {void}
978
+ */
979
+ select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
980
+ const { value, ...select_attrs } = attrs;
981
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
982
+ this.child((renderer) => {
983
+ renderer.local.select_value = value;
984
+ fn(renderer);
985
+ });
986
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
987
+ }
988
+ /**
989
+ * @param {Record<string, any>} attrs
990
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
991
+ * @param {string | undefined} [css_hash]
992
+ * @param {Record<string, boolean> | undefined} [classes]
993
+ * @param {Record<string, string> | undefined} [styles]
994
+ * @param {number | undefined} [flags]
995
+ * @param {boolean | undefined} [is_rich]
996
+ */
997
+ option(attrs, body, css_hash, classes, styles, flags, is_rich) {
998
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
999
+ const close = (renderer, value, { head: head2, body: body2 }) => {
1000
+ if ("value" in attrs) {
1001
+ value = attrs.value;
1002
+ }
1003
+ if (value === this.local.select_value) {
1004
+ renderer.#out.push(' selected=""');
1005
+ }
1006
+ renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
1007
+ if (head2) {
1008
+ renderer.head((child) => child.push(head2));
1009
+ }
1010
+ };
1011
+ if (typeof body === "function") {
1012
+ this.child((renderer) => {
1013
+ const r = new Renderer(this.global, this);
1014
+ body(r);
1015
+ if (this.global.mode === "async") {
1016
+ return r.#collect_content_async().then((content) => {
1017
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
1018
+ });
1019
+ } else {
1020
+ const content = r.#collect_content();
1021
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
1022
+ }
1023
+ });
1024
+ } else {
1025
+ close(this, body, { body });
1026
+ }
1027
+ }
1028
+ /**
1029
+ * @param {(renderer: Renderer) => void} fn
1030
+ */
1031
+ title(fn) {
1032
+ const path = this.get_path();
1033
+ const close = (head2) => {
1034
+ this.global.set_title(head2, path);
1035
+ };
1036
+ this.child((renderer) => {
1037
+ const r = new Renderer(renderer.global, renderer);
1038
+ fn(r);
1039
+ if (renderer.global.mode === "async") {
1040
+ return r.#collect_content_async().then((content) => {
1041
+ close(content.head);
1042
+ });
1043
+ } else {
1044
+ const content = r.#collect_content();
1045
+ close(content.head);
1046
+ }
1047
+ });
1048
+ }
1049
+ /**
1050
+ * @param {string | (() => Promise<string>)} content
1051
+ */
1052
+ push(content) {
1053
+ if (typeof content === "function") {
1054
+ this.child(async (renderer) => renderer.push(await content()));
1055
+ } else {
1056
+ this.#out.push(content);
1057
+ }
1058
+ }
1059
+ /**
1060
+ * @param {() => void} fn
1061
+ */
1062
+ on_destroy(fn) {
1063
+ (this.#on_destroy ??= []).push(fn);
1064
+ }
1065
+ /**
1066
+ * @returns {number[]}
1067
+ */
1068
+ get_path() {
1069
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
1070
+ }
1071
+ /**
1072
+ * @deprecated this is needed for legacy component bindings
1073
+ */
1074
+ copy() {
1075
+ const copy = new Renderer(this.global, this.#parent);
1076
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
1077
+ copy.promise = this.promise;
1078
+ return copy;
1079
+ }
1080
+ /**
1081
+ * @param {Renderer} other
1082
+ * @deprecated this is needed for legacy component bindings
1083
+ */
1084
+ subsume(other) {
1085
+ if (this.global.mode !== other.global.mode) {
1086
+ throw new Error(
1087
+ "invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!"
1088
+ );
1089
+ }
1090
+ this.local = other.local;
1091
+ this.#out = other.#out.map((item) => {
1092
+ if (item instanceof Renderer) {
1093
+ item.subsume(item);
1094
+ }
1095
+ return item;
1096
+ });
1097
+ this.promise = other.promise;
1098
+ this.type = other.type;
1099
+ }
1100
+ get length() {
1101
+ return this.#out.length;
1102
+ }
1103
+ /**
1104
+ * Only available on the server and when compiling with the `server` option.
1105
+ * 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.
1106
+ * @template {Record<string, any>} Props
1107
+ * @param {Component<Props>} component
1108
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
1109
+ * @returns {RenderOutput}
1110
+ */
1111
+ static render(component, options = {}) {
1112
+ let sync;
1113
+ const result = (
1114
+ /** @type {RenderOutput} */
1115
+ {}
1116
+ );
1117
+ Object.defineProperties(result, {
1118
+ html: {
1119
+ get: () => {
1120
+ return (sync ??= Renderer.#render(component, options)).body;
1121
+ }
1122
+ },
1123
+ head: {
1124
+ get: () => {
1125
+ return (sync ??= Renderer.#render(component, options)).head;
1126
+ }
1127
+ },
1128
+ body: {
1129
+ get: () => {
1130
+ return (sync ??= Renderer.#render(component, options)).body;
1131
+ }
1132
+ },
1133
+ hashes: {
1134
+ value: {
1135
+ script: ""
1136
+ }
1137
+ },
1138
+ then: {
1139
+ value: (
1140
+ /**
1141
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
1142
+ *
1143
+ * @template TResult1
1144
+ * @template [TResult2=never]
1145
+ * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
1146
+ * @param { (reason: unknown) => TResult2 } onrejected
1147
+ */
1148
+ (onfulfilled, onrejected) => {
1149
+ {
1150
+ const result2 = sync ??= Renderer.#render(component, options);
1151
+ const user_result = onfulfilled({
1152
+ head: result2.head,
1153
+ body: result2.body,
1154
+ html: result2.body,
1155
+ hashes: { script: [] }
1156
+ });
1157
+ return Promise.resolve(user_result);
1158
+ }
1159
+ }
1160
+ )
1161
+ }
1162
+ });
1163
+ return result;
1164
+ }
1165
+ /**
1166
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
1167
+ * after awaiting `collect_async`.
1168
+ *
1169
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
1170
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
1171
+ * @returns {Iterable<() => void>}
1172
+ */
1173
+ *#collect_on_destroy() {
1174
+ for (const component of this.#traverse_components()) {
1175
+ yield* component.#collect_ondestroy();
1176
+ }
1177
+ }
1178
+ /**
1179
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
1180
+ * @returns {Iterable<Renderer>}
1181
+ */
1182
+ *#traverse_components() {
1183
+ for (const child of this.#out) {
1184
+ if (typeof child !== "string") {
1185
+ yield* child.#traverse_components();
1186
+ }
1187
+ }
1188
+ if (this.#is_component_body) {
1189
+ yield this;
1190
+ }
1191
+ }
1192
+ /**
1193
+ * @returns {Iterable<() => void>}
1194
+ */
1195
+ *#collect_ondestroy() {
1196
+ if (this.#on_destroy) {
1197
+ for (const fn of this.#on_destroy) {
1198
+ yield fn;
1199
+ }
1200
+ }
1201
+ for (const child of this.#out) {
1202
+ if (child instanceof Renderer && !child.#is_component_body) {
1203
+ yield* child.#collect_ondestroy();
1204
+ }
1205
+ }
1206
+ }
1207
+ /**
1208
+ * Render a component. Throws if any of the children are performing asynchronous work.
1209
+ *
1210
+ * @template {Record<string, any>} Props
1211
+ * @param {Component<Props>} component
1212
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
1213
+ * @returns {AccumulatedContent}
1214
+ */
1215
+ static #render(component, options) {
1216
+ var previous_context = ssr_context;
1217
+ try {
1218
+ const renderer = Renderer.#open_render("sync", component, options);
1219
+ const content = renderer.#collect_content();
1220
+ return Renderer.#close_render(content, renderer);
1221
+ } finally {
1222
+ abort();
1223
+ set_ssr_context(previous_context);
1224
+ }
1225
+ }
1226
+ /**
1227
+ * Render a component.
1228
+ *
1229
+ * @template {Record<string, any>} Props
1230
+ * @param {Component<Props>} component
1231
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
1232
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
1233
+ */
1234
+ static async #render_async(component, options) {
1235
+ const previous_context = ssr_context;
1236
+ try {
1237
+ const renderer = Renderer.#open_render("async", component, options);
1238
+ const content = await renderer.#collect_content_async();
1239
+ const hydratables = await renderer.#collect_hydratables();
1240
+ if (hydratables !== null) {
1241
+ content.head = hydratables + content.head;
1242
+ }
1243
+ return Renderer.#close_render(content, renderer);
1244
+ } finally {
1245
+ set_ssr_context(previous_context);
1246
+ abort();
1247
+ }
1248
+ }
1249
+ /**
1250
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
1251
+ * @param {AccumulatedContent} content
1252
+ * @returns {AccumulatedContent}
1253
+ */
1254
+ #collect_content(content = { head: "", body: "" }) {
1255
+ for (const item of this.#out) {
1256
+ if (typeof item === "string") {
1257
+ content[this.type] += item;
1258
+ } else if (item instanceof Renderer) {
1259
+ item.#collect_content(content);
1260
+ }
1261
+ }
1262
+ return content;
1263
+ }
1264
+ /**
1265
+ * Collect all of the code from the `out` array and return it as a string.
1266
+ * @param {AccumulatedContent} content
1267
+ * @returns {Promise<AccumulatedContent>}
1268
+ */
1269
+ async #collect_content_async(content = { head: "", body: "" }) {
1270
+ await this.promise;
1271
+ for (const item of this.#out) {
1272
+ if (typeof item === "string") {
1273
+ content[this.type] += item;
1274
+ } else if (item instanceof Renderer) {
1275
+ await item.#collect_content_async(content);
1276
+ }
1277
+ }
1278
+ return content;
1279
+ }
1280
+ async #collect_hydratables() {
1281
+ const ctx = get_render_context().hydratable;
1282
+ for (const [_, key] of ctx.unresolved_promises) {
1283
+ unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
1284
+ }
1285
+ for (const comparison of ctx.comparisons) {
1286
+ await comparison;
1287
+ }
1288
+ return await this.#hydratable_block(ctx);
1289
+ }
1290
+ /**
1291
+ * @template {Record<string, any>} Props
1292
+ * @param {'sync' | 'async'} mode
1293
+ * @param {import('svelte').Component<Props>} component
1294
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
1295
+ * @returns {Renderer}
1296
+ */
1297
+ static #open_render(mode, component, options) {
1298
+ const renderer = new Renderer(
1299
+ new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp)
1300
+ );
1301
+ renderer.push(BLOCK_OPEN);
1302
+ push();
1303
+ if (options.context) ssr_context.c = options.context;
1304
+ ssr_context.r = renderer;
1305
+ component(renderer, options.props ?? {});
1306
+ pop();
1307
+ renderer.push(BLOCK_CLOSE);
1308
+ return renderer;
1309
+ }
1310
+ /**
1311
+ * @param {AccumulatedContent} content
1312
+ * @param {Renderer} renderer
1313
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
1314
+ */
1315
+ static #close_render(content, renderer) {
1316
+ for (const cleanup of renderer.#collect_on_destroy()) {
1317
+ cleanup();
1318
+ }
1319
+ let head2 = content.head + renderer.global.get_title();
1320
+ let body = content.body;
1321
+ for (const { hash, code } of renderer.global.css) {
1322
+ head2 += `<style id="${hash}">${code}</style>`;
1323
+ }
1324
+ return {
1325
+ head: head2,
1326
+ body,
1327
+ hashes: {
1328
+ script: renderer.global.csp.script_hashes
1329
+ }
1330
+ };
1331
+ }
1332
+ /**
1333
+ * @param {HydratableContext} ctx
1334
+ */
1335
+ async #hydratable_block(ctx) {
1336
+ if (ctx.lookup.size === 0) {
1337
+ return null;
1338
+ }
1339
+ let entries = [];
1340
+ let has_promises = false;
1341
+ for (const [k, v] of ctx.lookup) {
1342
+ if (v.promises) {
1343
+ has_promises = true;
1344
+ for (const p of v.promises) await p;
1345
+ }
1346
+ entries.push(`[${uneval(k)},${v.serialized}]`);
1347
+ }
1348
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
1349
+ if (has_promises) {
1350
+ prelude = `const r = (v) => Promise.resolve(v);
1351
+ ${prelude}`;
1352
+ }
1353
+ const body = `
1354
+ {
1355
+ ${prelude}
1356
+
1357
+ for (const [k, v] of [
1358
+ ${entries.join(",\n ")}
1359
+ ]) {
1360
+ h.set(k, v);
1361
+ }
1362
+ }
1363
+ `;
1364
+ let csp_attr = "";
1365
+ if (this.global.csp.nonce) {
1366
+ csp_attr = ` nonce="${this.global.csp.nonce}"`;
1367
+ } else if (this.global.csp.hash) {
1368
+ const hash = await sha256(body);
1369
+ this.global.csp.script_hashes.push(`sha256-${hash}`);
1370
+ }
1371
+ return `
1372
+ <script${csp_attr}>${body}<\/script>`;
1373
+ }
1374
+ }
1375
+ class SSRState {
1376
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
1377
+ csp;
1378
+ /** @readonly @type {'sync' | 'async'} */
1379
+ mode;
1380
+ /** @readonly @type {() => string} */
1381
+ uid;
1382
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
1383
+ css = /* @__PURE__ */ new Set();
1384
+ /** @type {{ path: number[], value: string }} */
1385
+ #title = { path: [], value: "" };
1386
+ /**
1387
+ * @param {'sync' | 'async'} mode
1388
+ * @param {string} id_prefix
1389
+ * @param {Csp} csp
1390
+ */
1391
+ constructor(mode, id_prefix = "", csp = { hash: false }) {
1392
+ this.mode = mode;
1393
+ this.csp = { ...csp, script_hashes: [] };
1394
+ let uid = 1;
1395
+ this.uid = () => `${id_prefix}s${uid++}`;
1396
+ }
1397
+ get_title() {
1398
+ return this.#title.value;
1399
+ }
1400
+ /**
1401
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
1402
+ * from earlier than or equal to the current value.
1403
+ * @param {string} value
1404
+ * @param {number[]} path
1405
+ */
1406
+ set_title(value, path) {
1407
+ const current = this.#title.path;
1408
+ let i = 0;
1409
+ let l = Math.min(path.length, current.length);
1410
+ while (i < l && path[i] === current[i]) i += 1;
1411
+ if (path[i] === void 0) return;
1412
+ if (current[i] === void 0 || path[i] > current[i]) {
1413
+ this.#title.path = path;
1414
+ this.#title.value = value;
1415
+ }
1416
+ }
1417
+ }
1418
+ const 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;
1419
+ function render(component, options = {}) {
1420
+ if (options.csp?.hash && options.csp.nonce) {
1421
+ invalid_csp();
1422
+ }
1423
+ return Renderer.render(
1424
+ /** @type {Component<Props>} */
1425
+ component,
1426
+ options
1427
+ );
1428
+ }
1429
+ function head(hash, renderer, fn) {
1430
+ renderer.head((renderer2) => {
1431
+ renderer2.push(`<!--${hash}-->`);
1432
+ renderer2.child(fn);
1433
+ renderer2.push(EMPTY_COMMENT);
1434
+ });
1435
+ }
1436
+ function attributes(attrs, css_hash, classes, styles, flags = 0) {
1437
+ if (styles) {
1438
+ attrs.style = to_style(attrs.style, styles);
1439
+ }
1440
+ if (attrs.class) {
1441
+ attrs.class = clsx(attrs.class);
1442
+ }
1443
+ if (css_hash || classes) {
1444
+ attrs.class = to_class(attrs.class, css_hash, classes);
1445
+ }
1446
+ let attr_str = "";
1447
+ let name;
1448
+ const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;
1449
+ const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
1450
+ const is_input = (flags & ELEMENT_IS_INPUT) !== 0;
1451
+ for (name in attrs) {
1452
+ if (typeof attrs[name] === "function") continue;
1453
+ if (name[0] === "$" && name[1] === "$") continue;
1454
+ if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
1455
+ var value = attrs[name];
1456
+ if (lowercase) {
1457
+ name = name.toLowerCase();
1458
+ }
1459
+ if (is_input) {
1460
+ if (name === "defaultvalue" || name === "defaultchecked") {
1461
+ name = name === "defaultvalue" ? "value" : "checked";
1462
+ if (attrs[name]) continue;
1463
+ }
1464
+ }
1465
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
1466
+ }
1467
+ return attr_str;
1468
+ }
1469
+ function stringify(value) {
1470
+ return typeof value === "string" ? value : value == null ? "" : value + "";
1471
+ }
1472
+ function attr_class(value, hash, directives) {
1473
+ var result = to_class(value, hash, directives);
1474
+ return result ? ` class="${escape_html(result, true)}"` : "";
1475
+ }
1476
+ function attr_style(value, directives) {
1477
+ var result = to_style(value, directives);
1478
+ return result ? ` style="${escape_html(result, true)}"` : "";
1479
+ }
1480
+ function bind_props(props_parent, props_now) {
1481
+ for (const key in props_now) {
1482
+ const initial_value = props_parent[key];
1483
+ const value = props_now[key];
1484
+ if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) {
1485
+ props_parent[key] = value;
1486
+ }
1487
+ }
1488
+ }
1489
+ function ensure_array_like(array_like_or_iterator) {
1490
+ if (array_like_or_iterator) {
1491
+ return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
1492
+ }
1493
+ return [];
1494
+ }
1495
+
1496
+ export { ASYNC as A, BLOCK_EFFECT as B, CONNECTED as C, DevalueError as D, ERROR_VALUE as E, HYDRATION_END as F, HYDRATION_START_ELSE as G, HYDRATION_START as H, INERT as I, USER_EFFECT as J, uneval as K, LEGACY_PROPS as L, MAYBE_DIRTY as M, head as N, attr as O, ensure_array_like as P, attr_class as Q, REACTION_RAN as R, STATE_SYMBOL as S, stringify as T, UNINITIALIZED as U, attr_style as V, WAS_MARKED as W, bind_props as X, is_plain_object as a, stringify_string as b, COMMENT_NODE as c, HYDRATION_ERROR as d, enumerable_symbols as e, DERIVED as f, get_type as g, DIRTY as h, is_primitive as i, CLEAN as j, EFFECT as k, DESTROYED as l, MANAGED_EFFECT as m, BRANCH_EFFECT as n, ROOT_EFFECT as o, RENDER_EFFECT as p, HEAD_EFFECT as q, render as r, stringify_key as s, REACTION_IS_UPDATING as t, EFFECT_PRESERVED as u, EFFECT_TRANSPARENT as v, BOUNDARY_EFFECT as w, STALE_REACTION as x, EAGER_EFFECT as y, is_passive_event as z };
1497
+ //# sourceMappingURL=index-C0L7m6Jv.js.map