@aopslabs/aops-server 0.2.2 → 0.2.4

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 (49) hide show
  1. package/README.md +6 -5
  2. package/THIRD_PARTY_NOTICES +1112 -90
  3. package/THIRD_PARTY_NOTICES.inventory.json +228 -17
  4. package/build/client/_app/immutable/chunks/{BlANKL2r.js → Bjgoxj0p.js} +1 -1
  5. package/build/client/_app/immutable/entry/{app.a0iGCm6X.js → app.BYB9Sok4.js} +2 -2
  6. package/build/client/_app/immutable/entry/start.B9dFbET3.js +1 -0
  7. package/build/client/_app/immutable/nodes/{1.BtbjYUHR.js → 1.CVn3O1wW.js} +1 -1
  8. package/build/client/_app/version.json +1 -1
  9. package/build/handler.js +3 -3
  10. package/build/index.js +3 -3
  11. package/build/server/chunks/{1-UJuUicIe.js → 1-dRRhKt5b.js} +2 -2
  12. package/build/server/chunks/{_server.ts-BkxSxdd0.js → _server.ts-B-i329o7.js} +29 -68
  13. package/build/server/chunks/{_server.ts-Ua5Ieisy.js → _server.ts-BKHrYeaH.js} +13 -10
  14. package/build/server/chunks/{_server.ts-BX4X0tW0.js → _server.ts-BQ60-REv.js} +1 -1
  15. package/build/server/chunks/{_server.ts-DQzYSH_C.js → _server.ts-BZ4AVjKT.js} +12 -9
  16. package/build/server/chunks/{_server.ts-B9gjXi95.js → _server.ts-BpeZOHh9.js} +1 -1
  17. package/build/server/chunks/{_server.ts-CjzSQgpk.js → _server.ts-Bvm76oFb.js} +11 -8
  18. package/build/server/chunks/{_server.ts-DaIr3NkR.js → _server.ts-BzCsmQvL.js} +1 -1
  19. package/build/server/chunks/{_server.ts-Bz-Erv-1.js → _server.ts-CLPseTqB.js} +1 -1
  20. package/build/server/chunks/{_server.ts-XmKDT59M.js → _server.ts-CUfJtkgM.js} +13 -10
  21. package/build/server/chunks/{_server.ts-AwMeEYiZ.js → _server.ts-Cc0Bnt1g.js} +1 -1
  22. package/build/server/chunks/{_server.ts-u2UWBqNN.js → _server.ts-CsKHhoNV.js} +1 -1
  23. package/build/server/chunks/{_server.ts-N61POKjl.js → _server.ts-D9nuwLDu.js} +12 -9
  24. package/build/server/chunks/{_server.ts-DsTeOL2P.js → _server.ts-DL4m3Nag.js} +1 -1
  25. package/build/server/chunks/{_server.ts-DQWRrk5C.js → _server.ts-DUxJA8_s.js} +1 -1
  26. package/build/server/chunks/{_server.ts-CRKd0KAC.js → _server.ts-Df-V1NXF.js} +13 -10
  27. package/build/server/chunks/{_server.ts-6bdzoHJH.js → _server.ts-Dm0Cz5fI.js} +17 -6
  28. package/build/server/chunks/{_server.ts-o9pJceJP.js → _server.ts-Dpu5VI6c.js} +1 -1
  29. package/build/server/chunks/{_server.ts-De9ZrSV0.js → _server.ts-DxGF-jS0.js} +12 -9
  30. package/build/server/chunks/{agent-gateway-runtime-C7Kvvy0H.js → agent-gateway-runtime-DV-xLmJx.js} +39 -4
  31. package/build/server/chunks/commercial-admission-loader-ZGZHRPLe.js +480 -0
  32. package/build/server/chunks/{discovery-BvDEgiqC.js → discovery-DL0RzVks.js} +2 -2
  33. package/build/server/chunks/{error.svelte-B9R6O_Hn.js → error.svelte-c1sBbVzV.js} +1 -1
  34. package/build/server/chunks/{handler-DurXhqww.js → handler-MPrrqrDK.js} +262 -2
  35. package/build/server/chunks/{hooks.server-DYGrWbgh.js → hooks.server-Dpmff0ik.js} +1 -1
  36. package/build/server/chunks/{index.js-BQnOaW3H.js → index.js-CkBvZHgI.js} +1414 -2293
  37. package/build/server/chunks/{manifest.js-CCJDdahY.js → manifest.js-CVFLTOOv.js} +20 -20
  38. package/build/server/chunks/{registry-DO8ob5o1.js → registry-DIreA2IZ.js} +132 -268
  39. package/cockpit/.vite/manifest.json +122 -122
  40. package/cockpit/community.module-inventory.json +30 -30
  41. package/host.config.json +140 -0
  42. package/npm-shrinkwrap.json +6640 -0
  43. package/package.json +10 -4
  44. package/runtime/commercial-integrity-worker.mjs +8 -1
  45. package/runtime-closure.package.json +26 -6
  46. package/build/client/_app/immutable/entry/start.Df7u6fQ1.js +0 -1
  47. package/build/server/chunks/admission-snapshot-C2wGfTWE.js +0 -1034
  48. package/build/server/chunks/canonical-text-order-DbXJJnFD.js +0 -5
  49. package/build/server/chunks/commercial-admission-loader-V_vXHdVa.js +0 -2077
@@ -73,1886 +73,6 @@ class ActionFailure {
73
73
  }
74
74
  }
75
75
 
76
- var defaultParseOptions = {
77
- decodeValues: true,
78
- map: false,
79
- silent: false,
80
- split: "auto", // auto = split strings but not arrays
81
- };
82
-
83
- function isForbiddenKey(key) {
84
- return typeof key !== "string" || key in {};
85
- }
86
-
87
- function createNullObj() {
88
- return Object.create(null);
89
- }
90
-
91
- function isNonEmptyString(str) {
92
- return typeof str === "string" && !!str.trim();
93
- }
94
-
95
- function parseString(setCookieValue, options) {
96
- var parts = setCookieValue.split(";").filter(isNonEmptyString);
97
-
98
- var nameValuePairStr = parts.shift();
99
- if (!nameValuePairStr) {
100
- return null;
101
- }
102
- var parsed = parseNameValuePair(nameValuePairStr);
103
- var name = parsed.name;
104
- var value = parsed.value;
105
-
106
- options = options
107
- ? Object.assign({}, defaultParseOptions, options)
108
- : defaultParseOptions;
109
-
110
- if (isForbiddenKey(name)) {
111
- return null;
112
- }
113
-
114
- try {
115
- value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
116
- } catch (e) {
117
- console.error(
118
- "set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",
119
- e
120
- );
121
- }
122
-
123
- var cookie = createNullObj();
124
- cookie.name = name;
125
- cookie.value = value;
126
-
127
- parts.forEach(function (part) {
128
- var sides = part.split("=");
129
- var key = sides.shift().trim().toLowerCase();
130
- if (isForbiddenKey(key)) {
131
- return;
132
- }
133
- var value = sides.join("=").trim();
134
- if (key === "expires") {
135
- cookie.expires = new Date(value);
136
- } else if (key === "max-age") {
137
- var n = parseInt(value, 10);
138
- if (!Number.isNaN(n)) cookie.maxAge = n;
139
- } else if (key === "secure") {
140
- cookie.secure = true;
141
- } else if (key === "httponly") {
142
- cookie.httpOnly = true;
143
- } else if (key === "samesite") {
144
- cookie.sameSite = value;
145
- } else if (key === "partitioned") {
146
- cookie.partitioned = true;
147
- } else if (key) {
148
- cookie[key] = value;
149
- }
150
- });
151
-
152
- return cookie;
153
- }
154
-
155
- function parseNameValuePair(nameValuePairStr) {
156
- // Parses name-value-pair according to rfc6265bis draft
157
-
158
- var name = "";
159
- var value = "";
160
- var nameValueArr = nameValuePairStr.split("=");
161
- if (nameValueArr.length > 1) {
162
- name = nameValueArr.shift();
163
- value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
164
- } else {
165
- value = nameValuePairStr;
166
- }
167
-
168
- return { name: name, value: value };
169
- }
170
-
171
- function parseSetCookie(input, options) {
172
- options = options
173
- ? Object.assign({}, defaultParseOptions, options)
174
- : defaultParseOptions;
175
-
176
- if (!input) {
177
- if (!options.map) {
178
- return [];
179
- } else {
180
- return createNullObj();
181
- }
182
- }
183
-
184
- if (input.headers) {
185
- if (typeof input.headers.getSetCookie === "function") {
186
- // for fetch responses - they combine headers of the same type in the headers array,
187
- // but getSetCookie returns an uncombined array
188
- input = input.headers.getSetCookie();
189
- } else if (input.headers["set-cookie"]) {
190
- // fast-path for node.js (which automatically normalizes header names to lower-case)
191
- input = input.headers["set-cookie"];
192
- } else {
193
- // slow-path for other environments - see #25
194
- var sch =
195
- input.headers[
196
- Object.keys(input.headers).find(function (key) {
197
- return key.toLowerCase() === "set-cookie";
198
- })
199
- ];
200
- // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
201
- if (!sch && input.headers.cookie && !options.silent) {
202
- console.warn(
203
- "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
204
- );
205
- }
206
- input = sch;
207
- }
208
- }
209
-
210
- var split = options.split;
211
- var isArray = Array.isArray(input);
212
-
213
- if (split === "auto") {
214
- split = !isArray;
215
- }
216
-
217
- if (!isArray) {
218
- input = [input];
219
- }
220
-
221
- input = input.filter(isNonEmptyString);
222
-
223
- if (split) {
224
- input = input.map(splitCookiesString).flat();
225
- }
226
-
227
- if (!options.map) {
228
- return input
229
- .map(function (str) {
230
- return parseString(str, options);
231
- })
232
- .filter(Boolean);
233
- } else {
234
- var cookies = createNullObj();
235
- return input.reduce(function (cookies, str) {
236
- var cookie = parseString(str, options);
237
- if (cookie && !isForbiddenKey(cookie.name)) {
238
- cookies[cookie.name] = cookie;
239
- }
240
- return cookies;
241
- }, cookies);
242
- }
243
- }
244
-
245
- /*
246
- Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
247
- that are within a single set-cookie field-value, such as in the Expires portion.
248
-
249
- This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
250
- Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
251
- React Native's fetch does this for *every* header, including set-cookie.
252
-
253
- Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
254
- Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
255
- */
256
- function splitCookiesString(cookiesString) {
257
- if (Array.isArray(cookiesString)) {
258
- return cookiesString;
259
- }
260
- if (typeof cookiesString !== "string") {
261
- return [];
262
- }
263
-
264
- var cookiesStrings = [];
265
- var pos = 0;
266
- var start;
267
- var ch;
268
- var lastComma;
269
- var nextStart;
270
- var cookiesSeparatorFound;
271
-
272
- function skipWhitespace() {
273
- while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
274
- pos += 1;
275
- }
276
- return pos < cookiesString.length;
277
- }
278
-
279
- function notSpecialChar() {
280
- ch = cookiesString.charAt(pos);
281
-
282
- return ch !== "=" && ch !== ";" && ch !== ",";
283
- }
284
-
285
- while (pos < cookiesString.length) {
286
- start = pos;
287
- cookiesSeparatorFound = false;
288
-
289
- while (skipWhitespace()) {
290
- ch = cookiesString.charAt(pos);
291
- if (ch === ",") {
292
- // ',' is a cookie separator if we have later first '=', not ';' or ','
293
- lastComma = pos;
294
- pos += 1;
295
-
296
- skipWhitespace();
297
- nextStart = pos;
298
-
299
- while (pos < cookiesString.length && notSpecialChar()) {
300
- pos += 1;
301
- }
302
-
303
- // currently special character
304
- if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
305
- // we found cookies separator
306
- cookiesSeparatorFound = true;
307
- // pos is inside the next cookie, so back up and return it.
308
- pos = nextStart;
309
- cookiesStrings.push(cookiesString.substring(start, lastComma));
310
- start = pos;
311
- } else {
312
- // in param ',' or param separator ';',
313
- // we continue from that comma
314
- pos = lastComma + 1;
315
- }
316
- } else {
317
- pos += 1;
318
- }
319
- }
320
-
321
- if (!cookiesSeparatorFound || pos >= cookiesString.length) {
322
- cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
323
- }
324
- }
325
-
326
- return cookiesStrings;
327
- }
328
-
329
- // named export for CJS
330
- parseSetCookie.parseSetCookie = parseSetCookie;
331
- // for backwards compatibility
332
- parseSetCookie.parse = parseSetCookie;
333
- parseSetCookie.parseString = parseString;
334
- parseSetCookie.splitCookiesString = splitCookiesString;
335
-
336
- const UNDEFINED = -1;
337
- const HOLE = -2;
338
- const NAN = -3;
339
- const POSITIVE_INFINITY = -4;
340
- const NEGATIVE_INFINITY = -5;
341
- const NEGATIVE_ZERO = -6;
342
- const SPARSE = -7;
343
-
344
- // The largest valid value for a JavaScript array's `length` property,
345
- // and the largest valid array index (one less than the max length).
346
- const MAX_ARRAY_LEN = 2 ** 32 - 1;
347
- const MAX_ARRAY_INDEX = MAX_ARRAY_LEN - 1;
348
-
349
- /** @type {Record<string, string>} */
350
- const escaped = {
351
- '<': '\\u003C',
352
- '\\': '\\\\',
353
- '\b': '\\b',
354
- '\f': '\\f',
355
- '\n': '\\n',
356
- '\r': '\\r',
357
- '\t': '\\t',
358
- '\u2028': '\\u2028',
359
- '\u2029': '\\u2029'
360
- };
361
-
362
- class DevalueError extends Error {
363
- /**
364
- * @param {string} message
365
- * @param {string[]} keys
366
- * @param {any} [value] - The value that failed to be serialized
367
- * @param {any} [root] - The root value being serialized
368
- */
369
- constructor(message, keys, value, root) {
370
- super(message);
371
- this.name = 'DevalueError';
372
- this.path = keys.join('');
373
- this.value = value;
374
- this.root = root;
375
- }
376
- }
377
-
378
- /** @param {any} thing */
379
- function is_primitive(thing) {
380
- return thing === null || (typeof thing !== 'object' && typeof thing !== 'function');
381
- }
382
-
383
- const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype)
384
- .sort()
385
- .join('\0');
386
-
387
- /** @param {any} thing */
388
- function is_plain_object(thing) {
389
- const proto = Object.getPrototypeOf(thing);
390
-
391
- return (
392
- proto === Object.prototype ||
393
- proto === null ||
394
- Object.getPrototypeOf(proto) === null ||
395
- Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
396
- );
397
- }
398
-
399
- /** @param {any} thing */
400
- function get_type(thing) {
401
- return Object.prototype.toString.call(thing).slice(8, -1);
402
- }
403
-
404
- /** @param {string} char */
405
- function get_escaped_char(char) {
406
- switch (char) {
407
- case '"':
408
- return '\\"';
409
- case '<':
410
- return '\\u003C';
411
- case '\\':
412
- return '\\\\';
413
- case '\n':
414
- return '\\n';
415
- case '\r':
416
- return '\\r';
417
- case '\t':
418
- return '\\t';
419
- case '\b':
420
- return '\\b';
421
- case '\f':
422
- return '\\f';
423
- case '\u2028':
424
- return '\\u2028';
425
- case '\u2029':
426
- return '\\u2029';
427
- default:
428
- return char < ' ' ? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}` : '';
429
- }
430
- }
431
-
432
- /** @param {string} str */
433
- function stringify_string(str) {
434
- let result = '';
435
- let last_pos = 0;
436
- const len = str.length;
437
-
438
- for (let i = 0; i < len; i += 1) {
439
- const char = str[i];
440
- const replacement = get_escaped_char(char);
441
- if (replacement) {
442
- result += str.slice(last_pos, i) + replacement;
443
- last_pos = i + 1;
444
- }
445
- }
446
-
447
- return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
448
- }
449
-
450
- /** @param {Record<string | symbol, any>} object */
451
- function enumerable_symbols(object) {
452
- return Object.getOwnPropertySymbols(object).filter(
453
- (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
454
- );
455
- }
456
-
457
- const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
458
-
459
- /** @param {string} key */
460
- function stringify_key(key) {
461
- return is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';
462
- }
463
-
464
- /** @param {number} n */
465
- function is_valid_array_index(n) {
466
- if (!Number.isInteger(n)) return false;
467
- if (n < 0) return false;
468
- if (n > MAX_ARRAY_INDEX) return false;
469
- return true;
470
- }
471
-
472
- /** @param {number} n */
473
- function is_valid_array_len(n) {
474
- if (!Number.isInteger(n)) return false;
475
- if (n < 0) return false;
476
- if (n > MAX_ARRAY_LEN) return false;
477
- return true;
478
- }
479
-
480
- /** @param {string} s */
481
- function is_valid_array_index_string(s) {
482
- if (s.length === 0) return false;
483
- if (s.length > 1 && s.charCodeAt(0) === 48) return false; // leading zero
484
- for (let i = 0; i < s.length; i++) {
485
- const c = s.charCodeAt(i);
486
- if (c < 48 || c > 57) return false;
487
- }
488
- // by this point we know it's a string of digits, but it has to be within
489
- // the range of valid array indices
490
- return is_valid_array_index(+s);
491
- }
492
-
493
- /**
494
- * Returns the length of the leading run of valid array indices in `keys`.
495
- * @param {readonly string[]} keys
496
- */
497
- function array_index_cut(keys) {
498
- for (var i = keys.length - 1; i >= 0; i--) {
499
- if (is_valid_array_index_string(keys[i])) {
500
- break;
501
- }
502
- }
503
- return i + 1;
504
- }
505
-
506
- /**
507
- * Finds the populated indices of an array.
508
- * @param {unknown[]} array
509
- */
510
- function valid_array_indices(array) {
511
- const keys = Object.keys(array);
512
- keys.length = array_index_cut(keys);
513
- return keys;
514
- }
515
-
516
- const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
517
- const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
518
- const reserved =
519
- /^(?: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)$/;
520
-
521
- /**
522
- * Turn a value into the JavaScript that creates an equivalent value
523
- * @param {any} value
524
- * @param {(value: any, uneval: (value: any) => string) => string | void} [replacer]
525
- */
526
- function uneval(value, replacer) {
527
- const counts = new Map();
528
-
529
- /** @type {string[]} */
530
- const keys = [];
531
-
532
- const custom = new Map();
533
-
534
- /** @param {any} thing */
535
- function walk(thing) {
536
- if (!is_primitive(thing)) {
537
- if (counts.has(thing)) {
538
- counts.set(thing, counts.get(thing) + 1);
539
- return;
540
- }
541
-
542
- counts.set(thing, 1);
543
-
544
- if (replacer) {
545
- const str = replacer(thing, (value) => uneval(value, replacer));
546
-
547
- if (typeof str === 'string') {
548
- custom.set(thing, str);
549
- return;
550
- }
551
- }
552
-
553
- if (typeof thing === 'function') {
554
- throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
555
- }
556
-
557
- const type = get_type(thing);
558
-
559
- switch (type) {
560
- case 'Number':
561
- case 'BigInt':
562
- case 'String':
563
- case 'Boolean':
564
- case 'Date':
565
- case 'RegExp':
566
- case 'URL':
567
- case 'URLSearchParams':
568
- return;
569
-
570
- case 'Array':
571
- /** @type {any[]} */ (thing).forEach((value, i) => {
572
- keys.push(`[${i}]`);
573
- walk(value);
574
- keys.pop();
575
- });
576
- break;
577
-
578
- case 'Set':
579
- Array.from(thing).forEach(walk);
580
- break;
581
-
582
- case 'Map':
583
- for (const [key, value] of thing) {
584
- keys.push(`.get(${is_primitive(key) ? stringify_primitive$1(key) : '...'})`);
585
- walk(key);
586
- walk(value);
587
- keys.pop();
588
- }
589
- break;
590
-
591
- case 'Int8Array':
592
- case 'Uint8Array':
593
- case 'Uint8ClampedArray':
594
- case 'Int16Array':
595
- case 'Uint16Array':
596
- case 'Float16Array':
597
- case 'Int32Array':
598
- case 'Uint32Array':
599
- case 'Float32Array':
600
- case 'Float64Array':
601
- case 'BigInt64Array':
602
- case 'BigUint64Array':
603
- case 'DataView':
604
- walk(thing.buffer);
605
- return;
606
-
607
- case 'ArrayBuffer':
608
- return;
609
-
610
- case 'Temporal.Duration':
611
- case 'Temporal.Instant':
612
- case 'Temporal.PlainDate':
613
- case 'Temporal.PlainTime':
614
- case 'Temporal.PlainDateTime':
615
- case 'Temporal.PlainMonthDay':
616
- case 'Temporal.PlainYearMonth':
617
- case 'Temporal.ZonedDateTime':
618
- return;
619
-
620
- default:
621
- if (!is_plain_object(thing)) {
622
- throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
623
- }
624
-
625
- if (enumerable_symbols(thing).length > 0) {
626
- throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
627
- }
628
-
629
- for (const key of Object.keys(thing)) {
630
- if (key === '__proto__') {
631
- throw new DevalueError(
632
- `Cannot stringify objects with __proto__ keys`,
633
- keys,
634
- thing,
635
- value
636
- );
637
- }
638
-
639
- keys.push(stringify_key(key));
640
- walk(thing[key]);
641
- keys.pop();
642
- }
643
- }
644
- } else if (typeof thing === 'symbol') {
645
- throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
646
- }
647
- }
648
-
649
- walk(value);
650
-
651
- const names = new Map();
652
-
653
- Array.from(counts)
654
- .filter((entry) => entry[1] > 1)
655
- .sort((a, b) => b[1] - a[1])
656
- .forEach((entry, i) => {
657
- names.set(entry[0], get_name(i));
658
- });
659
-
660
- /**
661
- * @param {any} thing
662
- * @returns {string}
663
- */
664
- function stringify(thing) {
665
- if (names.has(thing)) {
666
- return names.get(thing);
667
- }
668
-
669
- if (is_primitive(thing)) {
670
- return stringify_primitive$1(thing);
671
- }
672
-
673
- if (custom.has(thing)) {
674
- return custom.get(thing);
675
- }
676
-
677
- const type = get_type(thing);
678
-
679
- switch (type) {
680
- case 'Number':
681
- case 'String':
682
- case 'Boolean':
683
- case 'BigInt':
684
- return `Object(${stringify(thing.valueOf())})`;
685
-
686
- case 'RegExp':
687
- const { source, flags } = thing;
688
- return flags
689
- ? `new RegExp(${stringify_string(source)},"${flags}")`
690
- : `new RegExp(${stringify_string(source)})`;
691
-
692
- case 'Date':
693
- return `new Date(${thing.getTime()})`;
694
-
695
- case 'URL':
696
- return `new URL(${stringify_string(thing.toString())})`;
697
-
698
- case 'URLSearchParams':
699
- return `new URLSearchParams(${stringify_string(thing.toString())})`;
700
-
701
- case 'Array': {
702
- // For dense arrays (no holes), we iterate normally.
703
- // When we encounter the first hole, we call Object.keys
704
- // to determine the sparseness, then decide between:
705
- // - Array literal with holes: [,"a",,] (default)
706
- // - Object.assign: Object.assign(Array(n),{...}) (for very sparse arrays)
707
- // Only the Object.assign path avoids iterating every slot, which
708
- // is what protects against the DoS of e.g. `arr[1000000] = 1`.
709
- let has_holes = false;
710
-
711
- let result = '[';
712
-
713
- for (let i = 0; i < thing.length; i += 1) {
714
- if (i > 0) result += ',';
715
-
716
- if (Object.hasOwn(thing, i)) {
717
- result += stringify(thing[i]);
718
- } else if (!has_holes) {
719
- // Decide between array literal and Object.assign.
720
- //
721
- // Array literal: holes are consecutive commas.
722
- // For example, [, "a", ,] is written as [,"a",,].
723
- // Each hole costs 1 char (a comma).
724
- //
725
- // Object.assign: populated indices are listed explicitly.
726
- // For example, [, "a", ,] would be written as
727
- // Object.assign(Array(3),{1:"a"}). This avoids paying
728
- // per-hole, but has a large fixed overhead for the
729
- // "Object.assign(Array(n),{...})" wrapper, and each
730
- // element costs extra chars for its index and colon.
731
- //
732
- // The serialized values are the same size either way, so
733
- // the choice comes down to the structural overhead:
734
- //
735
- // Array literal overhead:
736
- // 1 char per element or hole (comma separators)
737
- // + 2 chars for "[" and "]"
738
- // = L + 2
739
- //
740
- // Object.assign overhead:
741
- // "Object.assign(Array(" — 20 chars
742
- // + length — d chars
743
- // + "),{" — 3 chars
744
- // + for each populated element:
745
- // index + ":" + "," — (d + 2) chars
746
- // + "})" — 2 chars
747
- // = (25 + d) + P * (d + 2)
748
- //
749
- // where L is the array length, P is the number of
750
- // populated elements, and d is the number of digits
751
- // in L (an upper bound on the digits in any index).
752
- //
753
- // Object.assign is cheaper when:
754
- // (25 + d) + P * (d + 2) < L + 2
755
- const populated_keys = valid_array_indices(/** @type {any[]} */ (thing));
756
- const population = populated_keys.length;
757
- const d = String(thing.length).length;
758
-
759
- const hole_cost = thing.length + 2;
760
- const sparse_cost = 25 + d + population * (d + 2);
761
-
762
- if (hole_cost > sparse_cost) {
763
- const entries = populated_keys.map((k) => `${k}:${stringify(thing[k])}`).join(',');
764
- return `Object.assign(Array(${thing.length}),{${entries}})`;
765
- }
766
-
767
- has_holes = true;
768
- }
769
- // else: already decided on array literal, hole is just an empty slot
770
- // (the comma separator is all we need — no content for this position)
771
- }
772
-
773
- const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
774
- return result + tail + ']';
775
- }
776
-
777
- case 'Set':
778
- case 'Map':
779
- return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
780
-
781
- case 'Int8Array':
782
- case 'Uint8Array':
783
- case 'Uint8ClampedArray':
784
- case 'Int16Array':
785
- case 'Uint16Array':
786
- case 'Float16Array':
787
- case 'Int32Array':
788
- case 'Uint32Array':
789
- case 'Float32Array':
790
- case 'Float64Array':
791
- case 'BigInt64Array':
792
- case 'BigUint64Array': {
793
- let str = `new ${type}`;
794
-
795
- if (!names.has(thing.buffer)) {
796
- str += `([${stringify_typed_array_elements(new thing.constructor(thing.buffer))}])`;
797
- } else {
798
- str += `(${stringify(thing.buffer)})`;
799
- }
800
-
801
- // handle subarrays
802
- if (thing.byteLength !== thing.buffer.byteLength) {
803
- const start = thing.byteOffset / thing.BYTES_PER_ELEMENT;
804
- const end = start + thing.length;
805
- str += `.subarray(${start},${end})`;
806
- }
807
-
808
- return str;
809
- }
810
-
811
- case 'DataView': {
812
- let str = `new DataView`;
813
-
814
- if (!names.has(thing.buffer)) {
815
- str += `(new Uint8Array([${new Uint8Array(thing.buffer)}]).buffer`;
816
- } else {
817
- str += `(${stringify(thing.buffer)}`;
818
- }
819
-
820
- // handle subviews
821
- if (thing.byteLength !== thing.buffer.byteLength) {
822
- str += `,${thing.byteOffset},${thing.byteLength}`;
823
- }
824
-
825
- return str + ')';
826
- }
827
-
828
- case 'ArrayBuffer': {
829
- const ui8 = new Uint8Array(thing);
830
- return `new Uint8Array([${ui8.toString()}]).buffer`;
831
- }
832
-
833
- case 'Temporal.Duration':
834
- case 'Temporal.Instant':
835
- case 'Temporal.PlainDate':
836
- case 'Temporal.PlainTime':
837
- case 'Temporal.PlainDateTime':
838
- case 'Temporal.PlainMonthDay':
839
- case 'Temporal.PlainYearMonth':
840
- case 'Temporal.ZonedDateTime':
841
- return `${type}.from(${stringify_string(thing.toString())})`;
842
-
843
- default:
844
- const keys = Object.keys(thing);
845
- const obj = keys.map((key) => `${safe_key(key)}:${stringify(thing[key])}`).join(',');
846
- const proto = Object.getPrototypeOf(thing);
847
- if (proto === null) {
848
- return keys.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
849
- }
850
-
851
- return `{${obj}}`;
852
- }
853
- }
854
-
855
- const str = stringify(value);
856
-
857
- if (names.size) {
858
- /** @type {string[]} */
859
- const params = [];
860
-
861
- /** @type {string[]} */
862
- const statements = [];
863
-
864
- /** @type {string[]} */
865
- const values = [];
866
-
867
- // Reconstructions (e.g. `b = new Uint8Array(...)`) reassign a placeholder
868
- // parameter. They must run before the `statements` that reference them,
869
- // otherwise those statements capture the placeholder. They only depend on
870
- // IIFE arguments (never on each other), so emitting them first is safe.
871
- /** @type {string[]} */
872
- const reconstructions = [];
873
-
874
- names.forEach((name, thing) => {
875
- params.push(name);
876
-
877
- if (custom.has(thing)) {
878
- values.push(/** @type {string} */ (custom.get(thing)));
879
- return;
880
- }
881
-
882
- if (is_primitive(thing)) {
883
- values.push(stringify_primitive$1(thing));
884
- return;
885
- }
886
-
887
- const type = get_type(thing);
888
-
889
- switch (type) {
890
- case 'Number':
891
- case 'String':
892
- case 'Boolean':
893
- case 'BigInt':
894
- values.push(`Object(${stringify(thing.valueOf())})`);
895
- break;
896
-
897
- case 'RegExp':
898
- const { source, flags } = thing;
899
- const regexp = flags
900
- ? `new RegExp(${stringify_string(source)},"${flags}")`
901
- : `new RegExp(${stringify_string(source)})`;
902
- values.push(regexp);
903
- break;
904
-
905
- case 'Date':
906
- values.push(`new Date(${thing.getTime()})`);
907
- break;
908
-
909
- case 'URL':
910
- values.push(`new URL(${stringify_string(thing.toString())})`);
911
- break;
912
-
913
- case 'URLSearchParams':
914
- values.push(`new URLSearchParams(${stringify_string(thing.toString())})`);
915
- break;
916
-
917
- case 'Array':
918
- values.push(`Array(${thing.length})`);
919
- /** @type {any[]} */ (thing).forEach((v, i) => {
920
- statements.push(`${name}[${i}]=${stringify(v)}`);
921
- });
922
- break;
923
-
924
- case 'Set': {
925
- values.push(`new Set`);
926
- const adds = Array.from(thing).map((v) => `.add(${stringify(v)})`);
927
- // An empty Set is fully built by `new Set`; a chained statement would
928
- // otherwise be a dangling `name.`.
929
- if (adds.length > 0) statements.push(name + adds.join(''));
930
- break;
931
- }
932
-
933
- case 'Map': {
934
- values.push(`new Map`);
935
- const sets = Array.from(thing).map(
936
- ([k, v]) => `.set(${stringify(k)}, ${stringify(v)})`
937
- );
938
- if (sets.length > 0) statements.push(name + sets.join(''));
939
- break;
940
- }
941
-
942
- case 'Int8Array':
943
- case 'Uint8Array':
944
- case 'Uint8ClampedArray':
945
- case 'Int16Array':
946
- case 'Uint16Array':
947
- case 'Float16Array':
948
- case 'Int32Array':
949
- case 'Uint32Array':
950
- case 'Float32Array':
951
- case 'Float64Array':
952
- case 'BigInt64Array':
953
- case 'BigUint64Array': {
954
- let str = `new ${type}`;
955
-
956
- if (!names.has(thing.buffer)) {
957
- str += `([${stringify_typed_array_elements(new thing.constructor(thing.buffer))}])`;
958
- } else {
959
- str += `(${stringify(thing.buffer)})`;
960
- }
961
-
962
- // handle subarrays
963
- if (thing.byteLength !== thing.buffer.byteLength) {
964
- const start = thing.byteOffset / thing.BYTES_PER_ELEMENT;
965
- const end = start + thing.length;
966
- str += `.subarray(${start},${end})`;
967
- }
968
-
969
- values.push(`{}`);
970
- reconstructions.push(`${name}=${str}`);
971
- break;
972
- }
973
-
974
- case 'DataView': {
975
- let str = `new DataView`;
976
-
977
- if (!names.has(thing.buffer)) {
978
- str += `(new Uint8Array([${new Uint8Array(thing.buffer)}]).buffer`;
979
- } else {
980
- str += `(${stringify(thing.buffer)}`;
981
- }
982
-
983
- // handle subviews
984
- if (thing.byteLength !== thing.buffer.byteLength) {
985
- str += `,${thing.byteOffset},${thing.byteLength}`;
986
- }
987
-
988
- str += ')';
989
-
990
- values.push(`{}`);
991
- reconstructions.push(`${name}=${str}`);
992
- break;
993
- }
994
-
995
- case 'ArrayBuffer':
996
- values.push(`new Uint8Array([${new Uint8Array(thing)}]).buffer`);
997
- break;
998
-
999
- case 'Temporal.Duration':
1000
- case 'Temporal.Instant':
1001
- case 'Temporal.PlainDate':
1002
- case 'Temporal.PlainTime':
1003
- case 'Temporal.PlainDateTime':
1004
- case 'Temporal.PlainMonthDay':
1005
- case 'Temporal.PlainYearMonth':
1006
- case 'Temporal.ZonedDateTime':
1007
- values.push(`${type}.from(${stringify_string(thing.toString())})`);
1008
- break;
1009
-
1010
- default:
1011
- values.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}');
1012
- Object.keys(thing).forEach((key) => {
1013
- statements.push(`${name}${safe_prop(key)}=${stringify(thing[key])}`);
1014
- });
1015
- }
1016
- });
1017
-
1018
- statements.push(`return ${str}`);
1019
-
1020
- const body = [...reconstructions, ...statements].join(';');
1021
- return `(function(${params.join(',')}){${body}}(${values.join(',')}))`;
1022
- } else {
1023
- return str;
1024
- }
1025
- }
1026
-
1027
- /**
1028
- * Serialize the elements of a typed array as a comma-separated list.
1029
- * `BigInt64Array`/`BigUint64Array` elements are bigints and must be written
1030
- * with an `n` suffix, otherwise the emitted `new BigInt64Array([...])` throws.
1031
- * @param {import('./types.js').TypedArray} array
1032
- */
1033
- function stringify_typed_array_elements(array) {
1034
- if (array instanceof BigInt64Array || array instanceof BigUint64Array) {
1035
- return Array.from(array, (element) => `${element}n`).join(',');
1036
- }
1037
-
1038
- return array.toString();
1039
- }
1040
-
1041
- /** @param {number} num */
1042
- function get_name(num) {
1043
- let name = '';
1044
-
1045
- do {
1046
- name = chars[num % chars.length] + name;
1047
- num = ~~(num / chars.length) - 1;
1048
- } while (num >= 0);
1049
-
1050
- return reserved.test(name) ? `${name}0` : name;
1051
- }
1052
-
1053
- /** @param {string} c */
1054
- function escape_unsafe_char(c) {
1055
- return escaped[c] || c;
1056
- }
1057
-
1058
- /** @param {string} str */
1059
- function escape_unsafe_chars(str) {
1060
- return str.replace(unsafe_chars, escape_unsafe_char);
1061
- }
1062
-
1063
- /** @param {string} key */
1064
- function safe_key(key) {
1065
- return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
1066
- }
1067
-
1068
- /** @param {string} key */
1069
- function safe_prop(key) {
1070
- return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
1071
- ? `.${key}`
1072
- : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
1073
- }
1074
-
1075
- /** @param {any} thing */
1076
- function stringify_primitive$1(thing) {
1077
- const type = typeof thing;
1078
- if (type === 'string') return stringify_string(thing);
1079
- if (thing === void 0) return 'void 0';
1080
- if (thing === 0 && 1 / thing < 0) return '-0';
1081
- const str = String(thing);
1082
- if (type === 'number') return str.replace(/^(-)?0\./, '$1.');
1083
- if (type === 'bigint') return thing + 'n';
1084
- return str;
1085
- }
1086
-
1087
- /* Baseline 2025 runtimes */
1088
-
1089
- /** @type {(array_buffer: ArrayBuffer) => string} */
1090
- function encode_native(array_buffer) {
1091
- return new Uint8Array(array_buffer).toBase64();
1092
- }
1093
-
1094
- /** @type {(base64: string) => ArrayBuffer} */
1095
- function decode_native(base64) {
1096
- return Uint8Array.fromBase64(base64).buffer;
1097
- }
1098
-
1099
- /* Node-compatible runtimes */
1100
-
1101
- /** @type {(array_buffer: ArrayBuffer) => string} */
1102
- function encode_buffer(array_buffer) {
1103
- return Buffer.from(array_buffer).toString('base64');
1104
- }
1105
-
1106
- /** @type {(base64: string) => ArrayBuffer} */
1107
- function decode_buffer(base64) {
1108
- return Uint8Array.from(Buffer.from(base64, 'base64')).buffer;
1109
- }
1110
-
1111
- /* Legacy runtimes */
1112
-
1113
- /** @type {(array_buffer: ArrayBuffer) => string} */
1114
- function encode_legacy(array_buffer) {
1115
- const array = new Uint8Array(array_buffer);
1116
- let binary = '';
1117
-
1118
- // the maximum number of arguments to String.fromCharCode.apply
1119
- // should be around 0xFFFF in modern engines
1120
- const chunk_size = 0x8000;
1121
- for (let i = 0; i < array.length; i += chunk_size) {
1122
- const chunk = array.subarray(i, i + chunk_size);
1123
- binary += String.fromCharCode.apply(null, chunk);
1124
- }
1125
-
1126
- return btoa(binary);
1127
- }
1128
-
1129
- /** @type {(base64: string) => ArrayBuffer} */
1130
- function decode_legacy(base64) {
1131
- const binary_string = atob(base64);
1132
- const len = binary_string.length;
1133
- const array = new Uint8Array(len);
1134
-
1135
- for (let i = 0; i < len; i++) {
1136
- array[i] = binary_string.charCodeAt(i);
1137
- }
1138
-
1139
- return array.buffer;
1140
- }
1141
-
1142
- const native = typeof Uint8Array.fromBase64 === 'function';
1143
- const buffer = typeof process === 'object' && process.versions?.node !== undefined;
1144
-
1145
- const encode64 = native ? encode_native : buffer ? encode_buffer : encode_legacy;
1146
- const decode64 = native ? decode_native : buffer ? decode_buffer : decode_legacy;
1147
-
1148
- /**
1149
- * Merges caller-provided operation overrides over the defaults. Iterating the
1150
- * default keys (rather than the override's own keys) means nullish members
1151
- * fall back to the default, and inherited members — e.g. from a class
1152
- * instance — are picked up.
1153
- *
1154
- * @template {Record<string, any>} T
1155
- * @param {T} defaults
1156
- * @param {Partial<T> | undefined} overrides
1157
- * @returns {T}
1158
- */
1159
- function merge_operations(defaults, overrides) {
1160
- return defaults;
1161
- }
1162
-
1163
- /** @type {{ kind: 'not-plain' }} */
1164
- const NOT_PLAIN = Object.freeze({ kind: 'not-plain' });
1165
-
1166
- /** @type {{ kind: 'symbol-keys' }} */
1167
- const SYMBOL_KEYS = Object.freeze({ kind: 'symbol-keys' });
1168
-
1169
- /**
1170
- * The default implementations of every introspection/extraction operation
1171
- * `stringify` performs on the value being serialized. Each one uses native
1172
- * JavaScript semantics (property access, iteration, prototype methods, etc).
1173
- *
1174
- * Pass overrides via the `operations` option of `stringify`/`stringifyAsync`
1175
- * to customize how values are inspected — e.g. to serialize values without
1176
- * triggering getters, proxy traps, or patched prototype methods, or to
1177
- * serialize values that live in a different JavaScript runtime (a `node:vm`
1178
- * context, a WASM-hosted engine, a remote process) through handle objects.
1179
- *
1180
- * The object is frozen — it is shared by every `stringify` call that does
1181
- * not override a given operation.
1182
- *
1183
- */
1184
- /** @type {import('./types.js').DefaultStringifyOperations} */
1185
- const stringify_operations = {
1186
- identify: (value) => value,
1187
-
1188
- typeOf: (value) => (value === null ? 'null' : typeof value),
1189
-
1190
- toPrimitive: (value) => value,
1191
-
1192
- tagOf: (value) => get_type(value),
1193
-
1194
- isThenable: (value) => typeof value.then === 'function',
1195
-
1196
- toPromise: (thenable) => Promise.resolve(thenable),
1197
-
1198
- unbox: (boxed) => boxed.valueOf(),
1199
-
1200
- toISOString: (date) => (isNaN(date.getDate()) ? '' : date.toISOString()),
1201
-
1202
- toStringValue: (value) => value.toString(),
1203
-
1204
- regExpInfo: (regexp) => ({ source: regexp.source, flags: regexp.flags }),
1205
-
1206
- valuesOf: (set) => set,
1207
-
1208
- entriesOf: (map) => map,
1209
-
1210
- viewInfo: (view) => ({
1211
- buffer: view.buffer,
1212
- byteOffset: view.byteOffset,
1213
- byteLength: view.byteLength,
1214
- length: view.length,
1215
- bufferByteLength: view.buffer.byteLength
1216
- }),
1217
-
1218
- toArrayBuffer: (buffer) => buffer,
1219
-
1220
- lengthOf: (array) => array.length,
1221
-
1222
- hasOwn: (value, key) => Object.hasOwn(value, key),
1223
-
1224
- indicesOf: (array) => valid_array_indices(array),
1225
-
1226
- shapeOf: (value) => {
1227
- if (!is_plain_object(value)) return NOT_PLAIN;
1228
- if (enumerable_symbols(value).length > 0) return SYMBOL_KEYS;
1229
-
1230
- return {
1231
- kind: Object.getPrototypeOf(value) === null ? 'null-proto' : 'plain',
1232
- keys: Object.keys(value)
1233
- };
1234
- },
1235
-
1236
- get: (value, key) => value[key]
1237
- };
1238
-
1239
- const default_stringify_operations = Object.freeze(stringify_operations);
1240
-
1241
- /**
1242
- * The default implementations of every construction operation `parse` and
1243
- * `unflatten` perform while reviving a value. Each one uses native
1244
- * JavaScript semantics (built-in constructors, property assignment, etc).
1245
- *
1246
- * Pass overrides via the `operations` option of `parse`/`unflatten` to
1247
- * customize how values are built — e.g. to construct them from the
1248
- * intrinsics of a different realm (a `node:vm` context), or to build up
1249
- * values inside another JavaScript runtime (a WASM-hosted engine, a remote
1250
- * process) through handle objects.
1251
- *
1252
- * The object is frozen — it is shared by every `parse` call that does not
1253
- * override a given operation.
1254
- *
1255
- */
1256
- /** @type {import('./types.js').DefaultParseOperations} */
1257
- const parse_operations = {
1258
- fromPrimitive: (primitive) => primitive,
1259
-
1260
- fromISOString: (iso) => new Date(iso),
1261
-
1262
- fromStringValue: (tag, text) => {
1263
- if (tag === 'URL') return new URL(text);
1264
- if (tag === 'URLSearchParams') return new URLSearchParams(text);
1265
- // 'Temporal.Instant', 'Temporal.PlainDate', ...
1266
- // @ts-expect-error TS doesn't know about Temporal yet
1267
- return Temporal[tag.slice(9)].from(text);
1268
- },
1269
-
1270
- fromArrayBuffer: (buffer) => buffer,
1271
-
1272
- fromRegExpInfo: (source, flags) => new RegExp(source, flags),
1273
-
1274
- fromViewInfo: (tag, buffer, byteOffset, length) => {
1275
- const Constructor = /** @type {any} */ (globalThis)[tag];
1276
- return byteOffset !== undefined
1277
- ? new Constructor(buffer, byteOffset, length)
1278
- : new Constructor(buffer);
1279
- },
1280
-
1281
- box: (value) => Object(value),
1282
-
1283
- createArray: (length) => new Array(length),
1284
-
1285
- createSparseArray: (length) => {
1286
- /** @type {any[]} */
1287
- const array = [];
1288
-
1289
- // Setting `array.length = length` (or equivalently calling
1290
- // `new Array(length)`) on an untrusted length is a DoS vector: V8
1291
- // eagerly allocates a contiguous backing store for array lengths below
1292
- // ~10^8, so a small payload with a huge declared length can force
1293
- // arbitrary memory allocation. Touching the largest-possible index
1294
- // first forces V8 into dictionary-elements mode, where `length` is
1295
- // just a number and no contiguous allocation occurs.
1296
- array[MAX_ARRAY_INDEX] = undefined;
1297
- delete array[MAX_ARRAY_INDEX];
1298
- array.length = length;
1299
-
1300
- return array;
1301
- },
1302
-
1303
- createObject: () => ({}),
1304
-
1305
- createNullPrototypeObject: () => Object.create(null),
1306
-
1307
- createSet: () => new Set(),
1308
-
1309
- createMap: () => new Map(),
1310
-
1311
- set: (target, key, value) => {
1312
- target[key] = value;
1313
- },
1314
-
1315
- addValue: (set, value) => {
1316
- set.add(value);
1317
- },
1318
-
1319
- addEntry: (map, key, value) => {
1320
- map.set(key, value);
1321
- }
1322
- };
1323
-
1324
- const default_parse_operations = Object.freeze(parse_operations);
1325
-
1326
- /**
1327
- * Revive a value serialized with `devalue.stringify`
1328
- * @param {string} serialized
1329
- * @param {Record<string, (value: any) => any>} [revivers]
1330
- * @param {import('./types.js').ParseOptions} [options]
1331
- */
1332
- function parse(serialized, revivers, options) {
1333
- return unflatten(JSON.parse(serialized), revivers);
1334
- }
1335
-
1336
- /**
1337
- * Revive a value flattened with `devalue.stringify`
1338
- * @param {number | any[]} parsed
1339
- * @param {Record<string, (value: any) => any>} [revivers]
1340
- * @param {import('./types.js').ParseOptions} [options]
1341
- */
1342
- function unflatten(parsed, revivers, options) {
1343
- /** @type {import('./types.js').ParseOperations} */
1344
- const ops = merge_operations(default_parse_operations);
1345
-
1346
- if (typeof parsed === 'number') return hydrate(parsed, true);
1347
-
1348
- if (!Array.isArray(parsed) || parsed.length === 0) {
1349
- throw new Error('Invalid input');
1350
- }
1351
-
1352
- const values = /** @type {any[]} */ (parsed);
1353
-
1354
- const hydrated = Array(values.length);
1355
-
1356
- /**
1357
- * A set of values currently being hydrated with custom revivers,
1358
- * used to detect invalid cyclical dependencies
1359
- * @type {Set<number> | null}
1360
- */
1361
- let hydrating = null;
1362
-
1363
- /**
1364
- * @param {number} index
1365
- * @returns {any}
1366
- */
1367
- function hydrate(index, standalone = false) {
1368
- if (index === UNDEFINED) return ops.fromPrimitive(undefined);
1369
- if (index === NAN) return ops.fromPrimitive(NaN);
1370
- if (index === POSITIVE_INFINITY) return ops.fromPrimitive(Infinity);
1371
- if (index === NEGATIVE_INFINITY) return ops.fromPrimitive(-Infinity);
1372
- if (index === NEGATIVE_ZERO) return ops.fromPrimitive(-0);
1373
-
1374
- if (standalone || typeof index !== 'number') {
1375
- throw new Error(`Invalid input`);
1376
- }
1377
-
1378
- if (index in hydrated) return hydrated[index];
1379
-
1380
- const value = values[index];
1381
-
1382
- if (!value || typeof value !== 'object') {
1383
- hydrated[index] = ops.fromPrimitive(value);
1384
- } else if (Array.isArray(value)) {
1385
- if (typeof value[0] === 'string') {
1386
- const type = value[0];
1387
-
1388
- const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : undefined;
1389
-
1390
- if (reviver) {
1391
- let i = value[1];
1392
- if (typeof i !== 'number') {
1393
- // if it's not a number, it was serialized by a builtin reviver
1394
- // so we need to munge it into the format expected by a custom reviver
1395
- i = values.push(value[1]) - 1;
1396
- }
1397
-
1398
- // If the payload is already hydrated, its recursion has already
1399
- // terminated (e.g. a self-referential object cached itself before
1400
- // following its own back-reference), so revive it directly. Falling
1401
- // through to the `hydrating` guard here would wrongly reject a valid
1402
- // cycle. An actually infinite payload (e.g. `[["Custom", 0]]`) is never
1403
- // cached, so it still hits the guard below.
1404
- if (Object.hasOwn(hydrated, i)) {
1405
- return (hydrated[index] = reviver(hydrated[i]));
1406
- }
1407
-
1408
- hydrating ??= new Set();
1409
-
1410
- if (hydrating.has(i)) {
1411
- throw new Error('Invalid circular reference');
1412
- }
1413
-
1414
- hydrating.add(i);
1415
- hydrated[index] = reviver(hydrate(i));
1416
- hydrating.delete(i);
1417
-
1418
- return hydrated[index];
1419
- }
1420
-
1421
- switch (type) {
1422
- case 'Date':
1423
- hydrated[index] = ops.fromISOString(value[1]);
1424
- break;
1425
-
1426
- case 'Set':
1427
- const set = ops.createSet();
1428
- hydrated[index] = set;
1429
- for (let i = 1; i < value.length; i += 1) {
1430
- ops.addValue(set, hydrate(value[i]));
1431
- }
1432
- break;
1433
-
1434
- case 'Map':
1435
- const map = ops.createMap();
1436
- hydrated[index] = map;
1437
- for (let i = 1; i < value.length; i += 2) {
1438
- ops.addEntry(map, hydrate(value[i]), hydrate(value[i + 1]));
1439
- }
1440
- break;
1441
-
1442
- case 'RegExp':
1443
- hydrated[index] = ops.fromRegExpInfo(value[1], value[2]);
1444
- break;
1445
-
1446
- case 'Object': {
1447
- const wrapped_index = value[1];
1448
-
1449
- if (
1450
- typeof values[wrapped_index] === 'object' &&
1451
- values[wrapped_index][0] !== 'BigInt'
1452
- ) {
1453
- // avoid infinite recusion in case of malformed input
1454
- throw new Error('Invalid input');
1455
- }
1456
-
1457
- hydrated[index] = ops.box(hydrate(wrapped_index));
1458
- break;
1459
- }
1460
-
1461
- case 'BigInt':
1462
- hydrated[index] = ops.fromPrimitive(BigInt(value[1]));
1463
- break;
1464
-
1465
- case 'null':
1466
- const obj = ops.createNullPrototypeObject();
1467
- hydrated[index] = obj;
1468
- for (let i = 1; i < value.length; i += 2) {
1469
- if (value[i] === '__proto__') {
1470
- throw new Error('Cannot parse an object with a `__proto__` property');
1471
- }
1472
-
1473
- ops.set(obj, value[i], hydrate(value[i + 1]));
1474
- }
1475
- break;
1476
-
1477
- case 'Int8Array':
1478
- case 'Uint8Array':
1479
- case 'Uint8ClampedArray':
1480
- case 'Int16Array':
1481
- case 'Uint16Array':
1482
- case 'Float16Array':
1483
- case 'Int32Array':
1484
- case 'Uint32Array':
1485
- case 'Float32Array':
1486
- case 'Float64Array':
1487
- case 'BigInt64Array':
1488
- case 'BigUint64Array':
1489
- case 'DataView': {
1490
- if (values[value[1]][0] !== 'ArrayBuffer') {
1491
- // without this, if we receive malformed input we could
1492
- // end up trying to hydrate in a circle or allocate
1493
- // huge amounts of memory when we call `new TypedArrayConstructor(buffer)`
1494
- throw new Error('Invalid data');
1495
- }
1496
-
1497
- const buffer = hydrate(value[1]);
1498
-
1499
- hydrated[index] = ops.fromViewInfo(type, buffer, value[2], value[3]);
1500
-
1501
- break;
1502
- }
1503
-
1504
- case 'ArrayBuffer': {
1505
- const base64 = value[1];
1506
- if (typeof base64 !== 'string') {
1507
- throw new Error('Invalid ArrayBuffer encoding');
1508
- }
1509
- hydrated[index] = ops.fromArrayBuffer(decode64(base64));
1510
- break;
1511
- }
1512
-
1513
- case 'URL':
1514
- case 'URLSearchParams':
1515
- case 'Temporal.Duration':
1516
- case 'Temporal.Instant':
1517
- case 'Temporal.PlainDate':
1518
- case 'Temporal.PlainTime':
1519
- case 'Temporal.PlainDateTime':
1520
- case 'Temporal.PlainMonthDay':
1521
- case 'Temporal.PlainYearMonth':
1522
- case 'Temporal.ZonedDateTime': {
1523
- // the same tags `toStringValue` serializes on the stringify side
1524
- hydrated[index] = ops.fromStringValue(type, value[1]);
1525
- break;
1526
- }
1527
-
1528
- default:
1529
- throw new Error(`Unknown type ${type}`);
1530
- }
1531
- } else if (value[0] === SPARSE) {
1532
- // Sparse array encoding: [SPARSE, length, idx, val, idx, val, ...]
1533
- const len = value[1];
1534
-
1535
- if (!is_valid_array_len(len)) {
1536
- throw new Error('Invalid input');
1537
- }
1538
-
1539
- // `len` comes from the input rather than being bounded by it, so
1540
- // `createSparseArray` is responsible for not allocating storage
1541
- // proportional to it.
1542
- const array = ops.createSparseArray(len);
1543
- hydrated[index] = array;
1544
-
1545
- for (let i = 2; i < value.length; i += 2) {
1546
- const idx = value[i];
1547
-
1548
- if (!is_valid_array_index(idx) || idx >= len) {
1549
- throw new Error('Invalid input');
1550
- }
1551
-
1552
- ops.set(array, idx, hydrate(value[i + 1]));
1553
- }
1554
- } else {
1555
- const array = ops.createArray(value.length);
1556
- hydrated[index] = array;
1557
-
1558
- for (let i = 0; i < value.length; i += 1) {
1559
- const n = value[i];
1560
- if (n === HOLE) continue;
1561
-
1562
- ops.set(array, i, hydrate(n));
1563
- }
1564
- }
1565
- } else {
1566
- const object = ops.createObject();
1567
- hydrated[index] = object;
1568
-
1569
- for (const key of Object.keys(value)) {
1570
- if (key === '__proto__') {
1571
- throw new Error('Cannot parse an object with a `__proto__` property');
1572
- }
1573
-
1574
- ops.set(object, key, hydrate(value[key]));
1575
- }
1576
- }
1577
-
1578
- return hydrated[index];
1579
- }
1580
-
1581
- return hydrate(0);
1582
- }
1583
-
1584
- /**
1585
- * Turn a value into a JSON string that can be parsed with `devalue.parse`
1586
- * @param {any} value
1587
- * @param {Record<string, (value: any) => any>} [reducers]
1588
- * @param {import('./types.js').StringifyOptions} [options]
1589
- */
1590
- function stringify$1(value, reducers, options) {
1591
- const stringified = run(false, value, reducers);
1592
- return typeof stringified === 'string' ? stringified : `[${stringified.join(',')}]`;
1593
- }
1594
-
1595
- /**
1596
- * @param {boolean} async
1597
- * @param {any} value
1598
- * @param {Record<string, (value: any) => any>} [reducers]
1599
- * @param {import('./types.js').StringifyOptions} [options]
1600
- */
1601
- function run(async, value, reducers, options) {
1602
- const ops = merge_operations(default_stringify_operations);
1603
-
1604
- /** @type {any[]} */
1605
- const stringified = [];
1606
-
1607
- /** @type {Map<any, number>} */
1608
- const indexes = new Map();
1609
-
1610
- /** @type {Array<{ key: string, fn: (value: any) => any }>} */
1611
- const custom = [];
1612
- if (reducers) {
1613
- for (const key of Object.getOwnPropertyNames(reducers)) {
1614
- custom.push({ key, fn: reducers[key] });
1615
- }
1616
- }
1617
-
1618
- /** @type {string[]} */
1619
- const keys = [];
1620
-
1621
- let p = 0;
1622
-
1623
- /**
1624
- * @param {any} thing
1625
- * @param {number} [index]
1626
- */
1627
- function flatten(thing, index) {
1628
- const type = ops.typeOf(thing);
1629
-
1630
- if (type === 'undefined') return UNDEFINED;
1631
-
1632
- /** @type {number | undefined} */
1633
- let number;
1634
-
1635
- // `ops.toPrimitive` is the boundary between the value being serialized and
1636
- // plain host JavaScript: everything below operates on the extracted host
1637
- // primitive, so native comparisons and arithmetic are correct there.
1638
- if (type === 'number') {
1639
- number = /** @type {number} */ (ops.toPrimitive(thing));
1640
- if (Number.isNaN(number)) return NAN;
1641
- if (number === Infinity) return POSITIVE_INFINITY;
1642
- if (number === -Infinity) return NEGATIVE_INFINITY;
1643
- if (number === 0 && 1 / number < 0) return NEGATIVE_ZERO;
1644
- }
1645
-
1646
- const id = ops.identify(thing);
1647
-
1648
- if (indexes.has(id)) return /** @type {number} */ (indexes.get(id));
1649
-
1650
- index ??= p++;
1651
- indexes.set(id, index);
1652
-
1653
- for (const { key, fn } of custom) {
1654
- const value = fn(thing);
1655
- if (value) {
1656
- stringified[index] = `["${key}",${flatten(value)}]`;
1657
- return index;
1658
- }
1659
- }
1660
-
1661
- if (type === 'function') {
1662
- throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
1663
- } else if (type === 'symbol') {
1664
- throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
1665
- }
1666
-
1667
- /** @type {string | Promise<any>} */
1668
- let str = '';
1669
-
1670
- if (type !== 'object') {
1671
- str = stringify_primitive(type === 'number' ? number : ops.toPrimitive(thing));
1672
- } else if (ops.isThenable(thing)) {
1673
- {
1674
- throw new DevalueError(
1675
- `Cannot stringify a Promise or thenable — use stringifyAsync instead`,
1676
- keys,
1677
- thing,
1678
- value
1679
- );
1680
- }
1681
- } else {
1682
- const tag = ops.tagOf(thing);
1683
-
1684
- switch (tag) {
1685
- case 'Number':
1686
- case 'String':
1687
- case 'Boolean':
1688
- case 'BigInt':
1689
- str = `["Object",${flatten(ops.unbox(thing))}]`;
1690
- break;
1691
-
1692
- case 'Date':
1693
- str = `["Date","${ops.toISOString(thing)}"]`;
1694
- break;
1695
-
1696
- case 'URL':
1697
- str = `["URL",${stringify_string(ops.toStringValue(thing))}]`;
1698
- break;
1699
-
1700
- case 'URLSearchParams':
1701
- str = `["URLSearchParams",${stringify_string(ops.toStringValue(thing))}]`;
1702
- break;
1703
-
1704
- case 'RegExp':
1705
- const { source, flags } = ops.regExpInfo(thing);
1706
- str = flags
1707
- ? `["RegExp",${stringify_string(source)},"${flags}"]`
1708
- : `["RegExp",${stringify_string(source)}]`;
1709
- break;
1710
-
1711
- case 'Array': {
1712
- // For dense arrays (no holes), we iterate normally.
1713
- // When we encounter the first hole, we call Object.keys
1714
- // to determine the sparseness, then decide between:
1715
- // - HOLE encoding: [-2, val, -2, ...] (default)
1716
- // - Sparse encoding: [-7, length, idx, val, ...] (for very sparse arrays)
1717
- // Only the sparse path avoids iterating every slot, which
1718
- // is what protects against the DoS of e.g. `arr[1000000] = 1`.
1719
- let mostly_dense = false;
1720
-
1721
- const length = ops.lengthOf(thing);
1722
-
1723
- str = '[';
1724
-
1725
- for (let i = 0; i < length; i += 1) {
1726
- if (i > 0) str += ',';
1727
-
1728
- if (ops.hasOwn(thing, i)) {
1729
- keys.push(`[${i}]`);
1730
- str += flatten(ops.get(thing, i));
1731
- keys.pop();
1732
- } else if (mostly_dense) {
1733
- // Use dense encoding. The heuristic guarantees the
1734
- // array is only mildly sparse, so iterating over every
1735
- // slot is fine.
1736
- str += HOLE;
1737
- } else {
1738
- // Decide between HOLE encoding and sparse encoding.
1739
- //
1740
- // HOLE encoding: each hole is serialized as the HOLE
1741
- // sentinel (-2). For example, [, "a", ,] becomes
1742
- // [-2, 0, -2]. Each hole costs 3 chars ("-2" + comma).
1743
- //
1744
- // Sparse encoding: lists only populated indices.
1745
- // For example, [, "a", ,] becomes [-7, 3, 1, 0] — the
1746
- // -7 sentinel, the array length (3), then index-value
1747
- // pairs. This avoids paying per-hole, but each element
1748
- // costs extra chars to write its index.
1749
- //
1750
- // The values are the same size either way, so the
1751
- // choice comes down to structural overhead:
1752
- //
1753
- // HOLE overhead:
1754
- // 3 chars per hole ("-2" + comma)
1755
- // = (L - P) * 3
1756
- //
1757
- // Sparse overhead:
1758
- // "-7," — 3 chars (sparse sentinel + comma)
1759
- // + length + "," — (d + 1) chars (array length + comma)
1760
- // + per element: index + "," — (d + 1) chars
1761
- // = (4 + d) + P * (d + 1)
1762
- //
1763
- // where L is the array length, P is the number of
1764
- // populated elements, and d is the number of digits
1765
- // in L (an upper bound on the digits in any index).
1766
- //
1767
- // Sparse encoding is cheaper when:
1768
- // (4 + d) + P * (d + 1) < (L - P) * 3
1769
- const populated_keys = ops.indicesOf(thing);
1770
- const population = populated_keys.length;
1771
- const d = String(length).length;
1772
-
1773
- const hole_cost = (length - population) * 3;
1774
- const sparse_cost = 4 + d + population * (d + 1);
1775
-
1776
- if (hole_cost > sparse_cost) {
1777
- str = '[' + SPARSE + ',' + length;
1778
- for (let j = 0; j < populated_keys.length; j++) {
1779
- const key = populated_keys[j];
1780
- keys.push(`[${key}]`);
1781
- str += ',' + key + ',' + flatten(ops.get(thing, key));
1782
- keys.pop();
1783
- }
1784
- break;
1785
- } else {
1786
- mostly_dense = true;
1787
- str += HOLE;
1788
- }
1789
- }
1790
- }
1791
-
1792
- str += ']';
1793
-
1794
- break;
1795
- }
1796
-
1797
- case 'Set':
1798
- str = '["Set"';
1799
-
1800
- for (const value of ops.valuesOf(thing)) {
1801
- str += `,${flatten(value)}`;
1802
- }
1803
-
1804
- str += ']';
1805
- break;
1806
-
1807
- case 'Map':
1808
- str = '["Map"';
1809
-
1810
- for (const [key, value] of ops.entriesOf(thing)) {
1811
- const key_type = ops.typeOf(key);
1812
- const key_is_primitive =
1813
- key_type !== 'object' && key_type !== 'function' && key_type !== 'symbol';
1814
- keys.push(
1815
- `.get(${key_is_primitive ? stringify_primitive(ops.toPrimitive(key)) : '...'})`
1816
- );
1817
- str += `,${flatten(key)},${flatten(value)}`;
1818
- keys.pop();
1819
- }
1820
-
1821
- str += ']';
1822
- break;
1823
-
1824
- case 'Int8Array':
1825
- case 'Uint8Array':
1826
- case 'Uint8ClampedArray':
1827
- case 'Int16Array':
1828
- case 'Uint16Array':
1829
- case 'Float16Array':
1830
- case 'Int32Array':
1831
- case 'Uint32Array':
1832
- case 'Float32Array':
1833
- case 'Float64Array':
1834
- case 'BigInt64Array':
1835
- case 'BigUint64Array': {
1836
- const info = ops.viewInfo(thing);
1837
- str = '["' + tag + '",' + flatten(info.buffer);
1838
-
1839
- // handle subarrays
1840
- if (info.byteLength !== info.bufferByteLength) {
1841
- str += `,${info.byteOffset},${info.length}`;
1842
- }
1843
-
1844
- str += ']';
1845
- break;
1846
- }
1847
-
1848
- case 'DataView': {
1849
- const info = ops.viewInfo(thing);
1850
- str = '["' + tag + '",' + flatten(info.buffer);
1851
-
1852
- if (info.byteLength !== info.bufferByteLength) {
1853
- str += `,${info.byteOffset},${info.byteLength}`;
1854
- }
1855
-
1856
- str += ']';
1857
- break;
1858
- }
1859
-
1860
- case 'ArrayBuffer': {
1861
- const base64 = encode64(ops.toArrayBuffer(thing));
1862
-
1863
- str = `["ArrayBuffer","${base64}"]`;
1864
- break;
1865
- }
1866
-
1867
- case 'Temporal.Duration':
1868
- case 'Temporal.Instant':
1869
- case 'Temporal.PlainDate':
1870
- case 'Temporal.PlainTime':
1871
- case 'Temporal.PlainDateTime':
1872
- case 'Temporal.PlainMonthDay':
1873
- case 'Temporal.PlainYearMonth':
1874
- case 'Temporal.ZonedDateTime':
1875
- str = `["${tag}",${stringify_string(ops.toStringValue(thing))}]`;
1876
- break;
1877
-
1878
- default: {
1879
- const shape = ops.shapeOf(thing);
1880
-
1881
- if (shape.kind === 'not-plain') {
1882
- throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
1883
- }
1884
-
1885
- if (shape.kind === 'symbol-keys') {
1886
- throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
1887
- }
1888
-
1889
- if (shape.kind === 'null-proto') {
1890
- str = '["null"';
1891
- for (const key of shape.keys) {
1892
- if (key === '__proto__') {
1893
- throw new DevalueError(
1894
- `Cannot stringify objects with __proto__ keys`,
1895
- keys,
1896
- thing,
1897
- value
1898
- );
1899
- }
1900
-
1901
- keys.push(stringify_key(key));
1902
- str += `,${stringify_string(key)},${flatten(ops.get(thing, key))}`;
1903
- keys.pop();
1904
- }
1905
- str += ']';
1906
- } else {
1907
- str = '{';
1908
- let started = false;
1909
- for (const key of shape.keys) {
1910
- if (key === '__proto__') {
1911
- throw new DevalueError(
1912
- `Cannot stringify objects with __proto__ keys`,
1913
- keys,
1914
- thing,
1915
- value
1916
- );
1917
- }
1918
-
1919
- if (started) str += ',';
1920
- started = true;
1921
- keys.push(stringify_key(key));
1922
- str += `${stringify_string(key)}:${flatten(ops.get(thing, key))}`;
1923
- keys.pop();
1924
- }
1925
- str += '}';
1926
- }
1927
- }
1928
- }
1929
- }
1930
-
1931
- stringified[index] = str;
1932
- return index;
1933
- }
1934
-
1935
- const index = flatten(value);
1936
-
1937
- // special case — value is represented as a negative index
1938
- if (index < 0) return `${index}`;
1939
-
1940
- return stringified;
1941
- }
1942
-
1943
- /**
1944
- * @param {any} thing
1945
- * @returns {string}
1946
- */
1947
- function stringify_primitive(thing) {
1948
- const type = typeof thing;
1949
- if (type === 'string') return stringify_string(thing);
1950
- if (thing === void 0) return UNDEFINED.toString();
1951
- if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
1952
- if (type === 'bigint') return `["BigInt","${thing}"]`;
1953
- return String(thing);
1954
- }
1955
-
1956
76
  const text_encoder$2 = new TextEncoder();
1957
77
 
1958
78
  const text_encoder$1 = new TextEncoder();
@@ -1991,6 +111,505 @@ function base64_decode(encoded) {
1991
111
  return bytes;
1992
112
  }
1993
113
 
114
+ const UNDEFINED = -1;
115
+ const HOLE = -2;
116
+ const NAN = -3;
117
+ const POSITIVE_INFINITY = -4;
118
+ const NEGATIVE_INFINITY = -5;
119
+ const NEGATIVE_ZERO = -6;
120
+ const SPARSE = -7;
121
+ const MAX_ARRAY_LEN = 2 ** 32 - 1;
122
+ const MAX_ARRAY_INDEX = MAX_ARRAY_LEN - 1;
123
+ const escaped = {
124
+ "<": "\\u003C",
125
+ "\\": "\\\\",
126
+ "\b": "\\b",
127
+ "\f": "\\f",
128
+ "\n": "\\n",
129
+ "\r": "\\r",
130
+ " ": "\\t",
131
+ "\u2028": "\\u2028",
132
+ "\u2029": "\\u2029"
133
+ };
134
+ class DevalueError extends Error {
135
+ /**
136
+ * @param {string} message
137
+ * @param {string[]} keys
138
+ * @param {any} [value] - The value that failed to be serialized
139
+ * @param {any} [root] - The root value being serialized
140
+ */
141
+ constructor(message, keys, value, root) {
142
+ super(message);
143
+ this.name = "DevalueError";
144
+ this.path = keys.join("");
145
+ this.value = value;
146
+ this.root = root;
147
+ }
148
+ }
149
+ function is_primitive(thing) {
150
+ return thing === null || typeof thing !== "object" && typeof thing !== "function";
151
+ }
152
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
153
+ function is_plain_object(thing) {
154
+ const proto = Object.getPrototypeOf(thing);
155
+ return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
156
+ }
157
+ function get_type(thing) {
158
+ return Object.prototype.toString.call(thing).slice(8, -1);
159
+ }
160
+ function get_escaped_char(char) {
161
+ switch (char) {
162
+ case '"':
163
+ return '\\"';
164
+ case "<":
165
+ return "\\u003C";
166
+ case "\\":
167
+ return "\\\\";
168
+ case "\n":
169
+ return "\\n";
170
+ case "\r":
171
+ return "\\r";
172
+ case " ":
173
+ return "\\t";
174
+ case "\b":
175
+ return "\\b";
176
+ case "\f":
177
+ return "\\f";
178
+ case "\u2028":
179
+ return "\\u2028";
180
+ case "\u2029":
181
+ return "\\u2029";
182
+ default:
183
+ return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
184
+ }
185
+ }
186
+ function stringify_string(str) {
187
+ let result = "";
188
+ let last_pos = 0;
189
+ const len = str.length;
190
+ for (let i = 0; i < len; i += 1) {
191
+ const char = str[i];
192
+ const replacement = get_escaped_char(char);
193
+ if (replacement) {
194
+ result += str.slice(last_pos, i) + replacement;
195
+ last_pos = i + 1;
196
+ }
197
+ }
198
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
199
+ }
200
+ function enumerable_symbols(object) {
201
+ return Object.getOwnPropertySymbols(object).filter(
202
+ (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
203
+ );
204
+ }
205
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
206
+ function stringify_key(key) {
207
+ return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
208
+ }
209
+ function is_valid_array_index(n) {
210
+ if (!Number.isInteger(n)) return false;
211
+ if (n < 0) return false;
212
+ if (n > MAX_ARRAY_INDEX) return false;
213
+ return true;
214
+ }
215
+ function is_valid_array_len(n) {
216
+ if (!Number.isInteger(n)) return false;
217
+ if (n < 0) return false;
218
+ if (n > MAX_ARRAY_LEN) return false;
219
+ return true;
220
+ }
221
+ function is_valid_array_index_string(s) {
222
+ if (s.length === 0) return false;
223
+ if (s.length > 1 && s.charCodeAt(0) === 48) return false;
224
+ for (let i = 0; i < s.length; i++) {
225
+ const c = s.charCodeAt(i);
226
+ if (c < 48 || c > 57) return false;
227
+ }
228
+ return is_valid_array_index(+s);
229
+ }
230
+ function valid_array_indices(array) {
231
+ const keys = Object.keys(array);
232
+ for (var i = keys.length - 1; i >= 0; i--) {
233
+ if (is_valid_array_index_string(keys[i])) {
234
+ break;
235
+ }
236
+ }
237
+ keys.length = i + 1;
238
+ return keys;
239
+ }
240
+ const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
241
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
242
+ const reserved = /^(?: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)$/;
243
+ function uneval(value, replacer) {
244
+ const counts = /* @__PURE__ */ new Map();
245
+ const keys = [];
246
+ const custom = /* @__PURE__ */ new Map();
247
+ function walk(thing) {
248
+ if (!is_primitive(thing)) {
249
+ if (counts.has(thing)) {
250
+ counts.set(thing, counts.get(thing) + 1);
251
+ return;
252
+ }
253
+ counts.set(thing, 1);
254
+ if (replacer) {
255
+ const str2 = replacer(thing, (value2) => uneval(value2, replacer));
256
+ if (typeof str2 === "string") {
257
+ custom.set(thing, str2);
258
+ return;
259
+ }
260
+ }
261
+ if (typeof thing === "function") {
262
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
263
+ }
264
+ const type = get_type(thing);
265
+ switch (type) {
266
+ case "Number":
267
+ case "BigInt":
268
+ case "String":
269
+ case "Boolean":
270
+ case "Date":
271
+ case "RegExp":
272
+ case "URL":
273
+ case "URLSearchParams":
274
+ return;
275
+ case "Array":
276
+ thing.forEach((value2, i) => {
277
+ keys.push(`[${i}]`);
278
+ walk(value2);
279
+ keys.pop();
280
+ });
281
+ break;
282
+ case "Set":
283
+ Array.from(thing).forEach(walk);
284
+ break;
285
+ case "Map":
286
+ for (const [key, value2] of thing) {
287
+ keys.push(`.get(${is_primitive(key) ? stringify_primitive$1(key) : "..."})`);
288
+ walk(value2);
289
+ keys.pop();
290
+ }
291
+ break;
292
+ case "Int8Array":
293
+ case "Uint8Array":
294
+ case "Uint8ClampedArray":
295
+ case "Int16Array":
296
+ case "Uint16Array":
297
+ case "Float16Array":
298
+ case "Int32Array":
299
+ case "Uint32Array":
300
+ case "Float32Array":
301
+ case "Float64Array":
302
+ case "BigInt64Array":
303
+ case "BigUint64Array":
304
+ case "DataView":
305
+ walk(thing.buffer);
306
+ return;
307
+ case "ArrayBuffer":
308
+ return;
309
+ case "Temporal.Duration":
310
+ case "Temporal.Instant":
311
+ case "Temporal.PlainDate":
312
+ case "Temporal.PlainTime":
313
+ case "Temporal.PlainDateTime":
314
+ case "Temporal.PlainMonthDay":
315
+ case "Temporal.PlainYearMonth":
316
+ case "Temporal.ZonedDateTime":
317
+ return;
318
+ default:
319
+ if (!is_plain_object(thing)) {
320
+ throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
321
+ }
322
+ if (enumerable_symbols(thing).length > 0) {
323
+ throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
324
+ }
325
+ for (const key of Object.keys(thing)) {
326
+ if (key === "__proto__") {
327
+ throw new DevalueError(
328
+ `Cannot stringify objects with __proto__ keys`,
329
+ keys,
330
+ thing,
331
+ value
332
+ );
333
+ }
334
+ keys.push(stringify_key(key));
335
+ walk(thing[key]);
336
+ keys.pop();
337
+ }
338
+ }
339
+ } else if (typeof thing === "symbol") {
340
+ throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
341
+ }
342
+ }
343
+ walk(value);
344
+ const names = /* @__PURE__ */ new Map();
345
+ Array.from(counts).filter((entry) => entry[1] > 1).sort((a, b) => b[1] - a[1]).forEach((entry, i) => {
346
+ names.set(entry[0], get_name(i));
347
+ });
348
+ function stringify(thing) {
349
+ if (names.has(thing)) {
350
+ return names.get(thing);
351
+ }
352
+ if (is_primitive(thing)) {
353
+ return stringify_primitive$1(thing);
354
+ }
355
+ if (custom.has(thing)) {
356
+ return custom.get(thing);
357
+ }
358
+ const type = get_type(thing);
359
+ switch (type) {
360
+ case "Number":
361
+ case "String":
362
+ case "Boolean":
363
+ case "BigInt":
364
+ return `Object(${stringify(thing.valueOf())})`;
365
+ case "RegExp":
366
+ const { source, flags } = thing;
367
+ return flags ? `new RegExp(${stringify_string(source)},"${flags}")` : `new RegExp(${stringify_string(source)})`;
368
+ case "Date":
369
+ return `new Date(${thing.getTime()})`;
370
+ case "URL":
371
+ return `new URL(${stringify_string(thing.toString())})`;
372
+ case "URLSearchParams":
373
+ return `new URLSearchParams(${stringify_string(thing.toString())})`;
374
+ case "Array": {
375
+ let has_holes = false;
376
+ let result = "[";
377
+ for (let i = 0; i < thing.length; i += 1) {
378
+ if (i > 0) result += ",";
379
+ if (Object.hasOwn(thing, i)) {
380
+ result += stringify(thing[i]);
381
+ } else if (!has_holes) {
382
+ const populated_keys = valid_array_indices(
383
+ /** @type {any[]} */
384
+ thing
385
+ );
386
+ const population = populated_keys.length;
387
+ const d = String(thing.length).length;
388
+ const hole_cost = thing.length + 2;
389
+ const sparse_cost = 25 + d + population * (d + 2);
390
+ if (hole_cost > sparse_cost) {
391
+ const entries = populated_keys.map((k) => `${k}:${stringify(thing[k])}`).join(",");
392
+ return `Object.assign(Array(${thing.length}),{${entries}})`;
393
+ }
394
+ has_holes = true;
395
+ i -= 1;
396
+ }
397
+ }
398
+ const tail = thing.length === 0 || thing.length - 1 in thing ? "" : ",";
399
+ return result + tail + "]";
400
+ }
401
+ case "Set":
402
+ case "Map":
403
+ return `new ${type}([${Array.from(thing).map(stringify).join(",")}])`;
404
+ case "Int8Array":
405
+ case "Uint8Array":
406
+ case "Uint8ClampedArray":
407
+ case "Int16Array":
408
+ case "Uint16Array":
409
+ case "Float16Array":
410
+ case "Int32Array":
411
+ case "Uint32Array":
412
+ case "Float32Array":
413
+ case "Float64Array":
414
+ case "BigInt64Array":
415
+ case "BigUint64Array": {
416
+ let str2 = `new ${type}`;
417
+ if (!names.has(thing.buffer)) {
418
+ const array = new thing.constructor(thing.buffer);
419
+ str2 += `([${array}])`;
420
+ } else {
421
+ str2 += `(${stringify(thing.buffer)})`;
422
+ }
423
+ if (thing.byteLength !== thing.buffer.byteLength) {
424
+ const start = thing.byteOffset / thing.BYTES_PER_ELEMENT;
425
+ const end = start + thing.length;
426
+ str2 += `.subarray(${start},${end})`;
427
+ }
428
+ return str2;
429
+ }
430
+ case "DataView": {
431
+ let str2 = `new DataView`;
432
+ if (!names.has(thing.buffer)) {
433
+ str2 += `(new Uint8Array([${new Uint8Array(thing.buffer)}]).buffer`;
434
+ } else {
435
+ str2 += `(${stringify(thing.buffer)}`;
436
+ }
437
+ if (thing.byteLength !== thing.buffer.byteLength) {
438
+ str2 += `,${thing.startOffset},${thing.byteLength}`;
439
+ }
440
+ return str2 + ")";
441
+ }
442
+ case "ArrayBuffer": {
443
+ const ui8 = new Uint8Array(thing);
444
+ return `new Uint8Array([${ui8.toString()}]).buffer`;
445
+ }
446
+ case "Temporal.Duration":
447
+ case "Temporal.Instant":
448
+ case "Temporal.PlainDate":
449
+ case "Temporal.PlainTime":
450
+ case "Temporal.PlainDateTime":
451
+ case "Temporal.PlainMonthDay":
452
+ case "Temporal.PlainYearMonth":
453
+ case "Temporal.ZonedDateTime":
454
+ return `${type}.from(${stringify_string(thing.toString())})`;
455
+ default:
456
+ const keys2 = Object.keys(thing);
457
+ const obj = keys2.map((key) => `${safe_key(key)}:${stringify(thing[key])}`).join(",");
458
+ const proto = Object.getPrototypeOf(thing);
459
+ if (proto === null) {
460
+ return keys2.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
461
+ }
462
+ return `{${obj}}`;
463
+ }
464
+ }
465
+ const str = stringify(value);
466
+ if (names.size) {
467
+ const params = [];
468
+ const statements = [];
469
+ const values = [];
470
+ names.forEach((name, thing) => {
471
+ params.push(name);
472
+ if (custom.has(thing)) {
473
+ values.push(
474
+ /** @type {string} */
475
+ custom.get(thing)
476
+ );
477
+ return;
478
+ }
479
+ if (is_primitive(thing)) {
480
+ values.push(stringify_primitive$1(thing));
481
+ return;
482
+ }
483
+ const type = get_type(thing);
484
+ switch (type) {
485
+ case "Number":
486
+ case "String":
487
+ case "Boolean":
488
+ case "BigInt":
489
+ values.push(`Object(${stringify(thing.valueOf())})`);
490
+ break;
491
+ case "RegExp":
492
+ const { source, flags } = thing;
493
+ const regexp = flags ? `new RegExp(${stringify_string(source)},"${flags}")` : `new RegExp(${stringify_string(source)})`;
494
+ values.push(regexp);
495
+ break;
496
+ case "Date":
497
+ values.push(`new Date(${thing.getTime()})`);
498
+ break;
499
+ case "URL":
500
+ values.push(`new URL(${stringify_string(thing.toString())})`);
501
+ break;
502
+ case "URLSearchParams":
503
+ values.push(`new URLSearchParams(${stringify_string(thing.toString())})`);
504
+ break;
505
+ case "Array":
506
+ values.push(`Array(${thing.length})`);
507
+ thing.forEach((v, i) => {
508
+ statements.push(`${name}[${i}]=${stringify(v)}`);
509
+ });
510
+ break;
511
+ case "Set":
512
+ values.push(`new Set`);
513
+ statements.push(
514
+ `${name}.${Array.from(thing).map((v) => `add(${stringify(v)})`).join(".")}`
515
+ );
516
+ break;
517
+ case "Map":
518
+ values.push(`new Map`);
519
+ statements.push(
520
+ `${name}.${Array.from(thing).map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`).join(".")}`
521
+ );
522
+ break;
523
+ case "Int8Array":
524
+ case "Uint8Array":
525
+ case "Uint8ClampedArray":
526
+ case "Int16Array":
527
+ case "Uint16Array":
528
+ case "Float16Array":
529
+ case "Int32Array":
530
+ case "Uint32Array":
531
+ case "Float32Array":
532
+ case "Float64Array":
533
+ case "BigInt64Array":
534
+ case "BigUint64Array": {
535
+ let str2 = `new ${type}`;
536
+ if (!names.has(thing.buffer)) {
537
+ const array = new thing.constructor(thing.buffer);
538
+ str2 += `([${array}])`;
539
+ } else {
540
+ str2 += `(${stringify(thing.buffer)})`;
541
+ }
542
+ if (thing.byteLength !== thing.buffer.byteLength) {
543
+ const start = thing.byteOffset / thing.BYTES_PER_ELEMENT;
544
+ const end = start + thing.length;
545
+ str2 += `.subarray(${start},${end})`;
546
+ }
547
+ values.push(`{}`);
548
+ statements.push(`${name}=${str2}`);
549
+ break;
550
+ }
551
+ case "DataView": {
552
+ let str2 = `new DataView`;
553
+ if (!names.has(thing.buffer)) {
554
+ str2 += `(new Uint8Array([${new Uint8Array(thing.buffer)}]).buffer`;
555
+ } else {
556
+ str2 += `(${stringify(thing.buffer)}`;
557
+ }
558
+ if (thing.byteLength !== thing.buffer.byteLength) {
559
+ str2 += `,${thing.byteOffset},${thing.byteLength}`;
560
+ }
561
+ str2 += ")";
562
+ values.push(`{}`);
563
+ statements.push(`${name}=${str2}`);
564
+ break;
565
+ }
566
+ case "ArrayBuffer":
567
+ values.push(`new Uint8Array([${new Uint8Array(thing)}]).buffer`);
568
+ break;
569
+ default:
570
+ values.push(Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}");
571
+ Object.keys(thing).forEach((key) => {
572
+ statements.push(`${name}${safe_prop(key)}=${stringify(thing[key])}`);
573
+ });
574
+ }
575
+ });
576
+ statements.push(`return ${str}`);
577
+ return `(function(${params.join(",")}){${statements.join(";")}}(${values.join(",")}))`;
578
+ } else {
579
+ return str;
580
+ }
581
+ }
582
+ function get_name(num) {
583
+ let name = "";
584
+ do {
585
+ name = chars[num % chars.length] + name;
586
+ num = ~~(num / chars.length) - 1;
587
+ } while (num >= 0);
588
+ return reserved.test(name) ? `${name}0` : name;
589
+ }
590
+ function escape_unsafe_char(c) {
591
+ return escaped[c] || c;
592
+ }
593
+ function escape_unsafe_chars(str) {
594
+ return str.replace(unsafe_chars, escape_unsafe_char);
595
+ }
596
+ function safe_key(key) {
597
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
598
+ }
599
+ function safe_prop(key) {
600
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? `.${key}` : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
601
+ }
602
+ function stringify_primitive$1(thing) {
603
+ const type = typeof thing;
604
+ if (type === "string") return stringify_string(thing);
605
+ if (thing === void 0) return "void 0";
606
+ if (thing === 0 && 1 / thing < 0) return "-0";
607
+ const str = String(thing);
608
+ if (type === "number") return str.replace(/^(-)?0\./, "$1.");
609
+ if (type === "bigint") return thing + "n";
610
+ return str;
611
+ }
612
+
1994
613
  /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
1995
614
 
1996
615
 
@@ -2158,23 +777,466 @@ function with_request_store(store, fn) {
2158
777
  }
2159
778
  }
2160
779
  }
2161
-
2162
- /**
2163
- * @template {{ tracing: { enabled: boolean, root: import('@opentelemetry/api').Span, current: import('@opentelemetry/api').Span } }} T
2164
- * @param {T} event_like
2165
- * @param {import('@opentelemetry/api').Span} current
2166
- * @returns {T}
2167
- */
2168
- function merge_tracing(event_like, current) {
2169
- return {
2170
- ...event_like,
2171
- tracing: {
2172
- ...event_like.tracing,
2173
- current
2174
- }
2175
- };
780
+
781
+ /**
782
+ * @template {{ tracing: { enabled: boolean, root: import('@opentelemetry/api').Span, current: import('@opentelemetry/api').Span } }} T
783
+ * @param {T} event_like
784
+ * @param {import('@opentelemetry/api').Span} current
785
+ * @returns {T}
786
+ */
787
+ function merge_tracing(event_like, current) {
788
+ return {
789
+ ...event_like,
790
+ tracing: {
791
+ ...event_like.tracing,
792
+ current
793
+ }
794
+ };
795
+ }
796
+
797
+ function encode_native(array_buffer) {
798
+ return new Uint8Array(array_buffer).toBase64();
799
+ }
800
+ function decode_native(base64) {
801
+ return Uint8Array.fromBase64(base64).buffer;
802
+ }
803
+ function encode_buffer(array_buffer) {
804
+ return Buffer.from(array_buffer).toString("base64");
805
+ }
806
+ function decode_buffer(base64) {
807
+ return Uint8Array.from(Buffer.from(base64, "base64")).buffer;
808
+ }
809
+ function encode_legacy(array_buffer) {
810
+ const array = new Uint8Array(array_buffer);
811
+ let binary = "";
812
+ const chunk_size = 32768;
813
+ for (let i = 0; i < array.length; i += chunk_size) {
814
+ const chunk = array.subarray(i, i + chunk_size);
815
+ binary += String.fromCharCode.apply(null, chunk);
816
+ }
817
+ return btoa(binary);
818
+ }
819
+ function decode_legacy(base64) {
820
+ const binary_string = atob(base64);
821
+ const len = binary_string.length;
822
+ const array = new Uint8Array(len);
823
+ for (let i = 0; i < len; i++) {
824
+ array[i] = binary_string.charCodeAt(i);
825
+ }
826
+ return array.buffer;
827
+ }
828
+ const native = typeof Uint8Array.fromBase64 === "function";
829
+ const buffer = typeof process === "object" && process.versions?.node !== void 0;
830
+ const encode64 = native ? encode_native : buffer ? encode_buffer : encode_legacy;
831
+ const decode64 = native ? decode_native : buffer ? decode_buffer : decode_legacy;
832
+ function parse(serialized, revivers) {
833
+ return unflatten(JSON.parse(serialized), revivers);
834
+ }
835
+ function unflatten(parsed, revivers) {
836
+ if (typeof parsed === "number") return hydrate(parsed, true);
837
+ if (!Array.isArray(parsed) || parsed.length === 0) {
838
+ throw new Error("Invalid input");
839
+ }
840
+ const values = (
841
+ /** @type {any[]} */
842
+ parsed
843
+ );
844
+ const hydrated = Array(values.length);
845
+ let hydrating = null;
846
+ function hydrate(index, standalone = false) {
847
+ if (index === UNDEFINED) return void 0;
848
+ if (index === NAN) return NaN;
849
+ if (index === POSITIVE_INFINITY) return Infinity;
850
+ if (index === NEGATIVE_INFINITY) return -Infinity;
851
+ if (index === NEGATIVE_ZERO) return -0;
852
+ if (standalone || typeof index !== "number") {
853
+ throw new Error(`Invalid input`);
854
+ }
855
+ if (index in hydrated) return hydrated[index];
856
+ const value = values[index];
857
+ if (!value || typeof value !== "object") {
858
+ hydrated[index] = value;
859
+ } else if (Array.isArray(value)) {
860
+ if (typeof value[0] === "string") {
861
+ const type = value[0];
862
+ const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
863
+ if (reviver) {
864
+ let i = value[1];
865
+ if (typeof i !== "number") {
866
+ i = values.push(value[1]) - 1;
867
+ }
868
+ hydrating ??= /* @__PURE__ */ new Set();
869
+ if (hydrating.has(i)) {
870
+ throw new Error("Invalid circular reference");
871
+ }
872
+ hydrating.add(i);
873
+ hydrated[index] = reviver(hydrate(i));
874
+ hydrating.delete(i);
875
+ return hydrated[index];
876
+ }
877
+ switch (type) {
878
+ case "Date":
879
+ hydrated[index] = new Date(value[1]);
880
+ break;
881
+ case "Set":
882
+ const set = /* @__PURE__ */ new Set();
883
+ hydrated[index] = set;
884
+ for (let i = 1; i < value.length; i += 1) {
885
+ set.add(hydrate(value[i]));
886
+ }
887
+ break;
888
+ case "Map":
889
+ const map = /* @__PURE__ */ new Map();
890
+ hydrated[index] = map;
891
+ for (let i = 1; i < value.length; i += 2) {
892
+ map.set(hydrate(value[i]), hydrate(value[i + 1]));
893
+ }
894
+ break;
895
+ case "RegExp":
896
+ hydrated[index] = new RegExp(value[1], value[2]);
897
+ break;
898
+ case "Object": {
899
+ const wrapped_index = value[1];
900
+ if (typeof values[wrapped_index] === "object" && values[wrapped_index][0] !== "BigInt") {
901
+ throw new Error("Invalid input");
902
+ }
903
+ hydrated[index] = Object(hydrate(wrapped_index));
904
+ break;
905
+ }
906
+ case "BigInt":
907
+ hydrated[index] = BigInt(value[1]);
908
+ break;
909
+ case "null":
910
+ const obj = /* @__PURE__ */ Object.create(null);
911
+ hydrated[index] = obj;
912
+ for (let i = 1; i < value.length; i += 2) {
913
+ if (value[i] === "__proto__") {
914
+ throw new Error("Cannot parse an object with a `__proto__` property");
915
+ }
916
+ obj[value[i]] = hydrate(value[i + 1]);
917
+ }
918
+ break;
919
+ case "Int8Array":
920
+ case "Uint8Array":
921
+ case "Uint8ClampedArray":
922
+ case "Int16Array":
923
+ case "Uint16Array":
924
+ case "Float16Array":
925
+ case "Int32Array":
926
+ case "Uint32Array":
927
+ case "Float32Array":
928
+ case "Float64Array":
929
+ case "BigInt64Array":
930
+ case "BigUint64Array":
931
+ case "DataView": {
932
+ if (values[value[1]][0] !== "ArrayBuffer") {
933
+ throw new Error("Invalid data");
934
+ }
935
+ const TypedArrayConstructor = globalThis[type];
936
+ const buffer2 = hydrate(value[1]);
937
+ hydrated[index] = value[2] !== void 0 ? new TypedArrayConstructor(buffer2, value[2], value[3]) : new TypedArrayConstructor(buffer2);
938
+ break;
939
+ }
940
+ case "ArrayBuffer": {
941
+ const base64 = value[1];
942
+ if (typeof base64 !== "string") {
943
+ throw new Error("Invalid ArrayBuffer encoding");
944
+ }
945
+ const arraybuffer = decode64(base64);
946
+ hydrated[index] = arraybuffer;
947
+ break;
948
+ }
949
+ case "Temporal.Duration":
950
+ case "Temporal.Instant":
951
+ case "Temporal.PlainDate":
952
+ case "Temporal.PlainTime":
953
+ case "Temporal.PlainDateTime":
954
+ case "Temporal.PlainMonthDay":
955
+ case "Temporal.PlainYearMonth":
956
+ case "Temporal.ZonedDateTime": {
957
+ const temporalName = type.slice(9);
958
+ hydrated[index] = Temporal[temporalName].from(value[1]);
959
+ break;
960
+ }
961
+ case "URL": {
962
+ const url = new URL(value[1]);
963
+ hydrated[index] = url;
964
+ break;
965
+ }
966
+ case "URLSearchParams": {
967
+ const url = new URLSearchParams(value[1]);
968
+ hydrated[index] = url;
969
+ break;
970
+ }
971
+ default:
972
+ throw new Error(`Unknown type ${type}`);
973
+ }
974
+ } else if (value[0] === SPARSE) {
975
+ const len = value[1];
976
+ if (!is_valid_array_len(len)) {
977
+ throw new Error("Invalid input");
978
+ }
979
+ const array = [];
980
+ hydrated[index] = array;
981
+ array[MAX_ARRAY_INDEX] = void 0;
982
+ delete array[MAX_ARRAY_INDEX];
983
+ for (let i = 2; i < value.length; i += 2) {
984
+ const idx = value[i];
985
+ if (!is_valid_array_index(idx) || idx >= len) {
986
+ throw new Error("Invalid input");
987
+ }
988
+ array[idx] = hydrate(value[i + 1]);
989
+ }
990
+ array.length = len;
991
+ } else {
992
+ const array = new Array(value.length);
993
+ hydrated[index] = array;
994
+ for (let i = 0; i < value.length; i += 1) {
995
+ const n = value[i];
996
+ if (n === HOLE) continue;
997
+ array[i] = hydrate(n);
998
+ }
999
+ }
1000
+ } else {
1001
+ const object = {};
1002
+ hydrated[index] = object;
1003
+ for (const key of Object.keys(value)) {
1004
+ if (key === "__proto__") {
1005
+ throw new Error("Cannot parse an object with a `__proto__` property");
1006
+ }
1007
+ const n = value[key];
1008
+ object[key] = hydrate(n);
1009
+ }
1010
+ }
1011
+ return hydrated[index];
1012
+ }
1013
+ return hydrate(0);
1014
+ }
1015
+ function stringify$1(value, reducers) {
1016
+ const stringified = run(false, value, reducers);
1017
+ return typeof stringified === "string" ? stringified : `[${stringified.join(",")}]`;
1018
+ }
1019
+ function run(async, value, reducers) {
1020
+ const stringified = [];
1021
+ const indexes = /* @__PURE__ */ new Map();
1022
+ const custom = [];
1023
+ if (reducers) {
1024
+ for (const key of Object.getOwnPropertyNames(reducers)) {
1025
+ custom.push({ key, fn: reducers[key] });
1026
+ }
1027
+ }
1028
+ const keys = [];
1029
+ let p = 0;
1030
+ function flatten(thing, index2) {
1031
+ if (thing === void 0) return UNDEFINED;
1032
+ if (Number.isNaN(thing)) return NAN;
1033
+ if (thing === Infinity) return POSITIVE_INFINITY;
1034
+ if (thing === -Infinity) return NEGATIVE_INFINITY;
1035
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
1036
+ if (indexes.has(thing)) return (
1037
+ /** @type {number} */
1038
+ indexes.get(thing)
1039
+ );
1040
+ index2 ??= p++;
1041
+ indexes.set(thing, index2);
1042
+ for (const { key, fn } of custom) {
1043
+ const value2 = fn(thing);
1044
+ if (value2) {
1045
+ stringified[index2] = `["${key}",${flatten(value2)}]`;
1046
+ return index2;
1047
+ }
1048
+ }
1049
+ if (typeof thing === "function") {
1050
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
1051
+ } else if (typeof thing === "symbol") {
1052
+ throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
1053
+ }
1054
+ let str = "";
1055
+ if (is_primitive(thing)) {
1056
+ str = stringify_primitive(thing);
1057
+ } else if (typeof thing.then === "function") {
1058
+ {
1059
+ throw new DevalueError(
1060
+ `Cannot stringify a Promise or thenable — use stringifyAsync instead`,
1061
+ keys,
1062
+ thing,
1063
+ value
1064
+ );
1065
+ }
1066
+ } else {
1067
+ const type = get_type(thing);
1068
+ switch (type) {
1069
+ case "Number":
1070
+ case "String":
1071
+ case "Boolean":
1072
+ case "BigInt":
1073
+ str = `["Object",${flatten(thing.valueOf())}]`;
1074
+ break;
1075
+ case "Date":
1076
+ const valid = !isNaN(thing.getDate());
1077
+ str = `["Date","${valid ? thing.toISOString() : ""}"]`;
1078
+ break;
1079
+ case "URL":
1080
+ str = `["URL",${stringify_string(thing.toString())}]`;
1081
+ break;
1082
+ case "URLSearchParams":
1083
+ str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
1084
+ break;
1085
+ case "RegExp":
1086
+ const { source, flags } = thing;
1087
+ str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
1088
+ break;
1089
+ case "Array": {
1090
+ let mostly_dense = false;
1091
+ str = "[";
1092
+ for (let i = 0; i < thing.length; i += 1) {
1093
+ if (i > 0) str += ",";
1094
+ if (Object.hasOwn(thing, i)) {
1095
+ keys.push(`[${i}]`);
1096
+ str += flatten(thing[i]);
1097
+ keys.pop();
1098
+ } else if (mostly_dense) {
1099
+ str += HOLE;
1100
+ } else {
1101
+ const populated_keys = valid_array_indices(
1102
+ /** @type {any[]} */
1103
+ thing
1104
+ );
1105
+ const population = populated_keys.length;
1106
+ const d = String(thing.length).length;
1107
+ const hole_cost = (thing.length - population) * 3;
1108
+ const sparse_cost = 4 + d + population * (d + 1);
1109
+ if (hole_cost > sparse_cost) {
1110
+ str = "[" + SPARSE + "," + thing.length;
1111
+ for (let j = 0; j < populated_keys.length; j++) {
1112
+ const key = populated_keys[j];
1113
+ keys.push(`[${key}]`);
1114
+ str += "," + key + "," + flatten(thing[key]);
1115
+ keys.pop();
1116
+ }
1117
+ break;
1118
+ } else {
1119
+ mostly_dense = true;
1120
+ str += HOLE;
1121
+ }
1122
+ }
1123
+ }
1124
+ str += "]";
1125
+ break;
1126
+ }
1127
+ case "Set":
1128
+ str = '["Set"';
1129
+ for (const value2 of thing) {
1130
+ str += `,${flatten(value2)}`;
1131
+ }
1132
+ str += "]";
1133
+ break;
1134
+ case "Map":
1135
+ str = '["Map"';
1136
+ for (const [key, value2] of thing) {
1137
+ keys.push(`.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`);
1138
+ str += `,${flatten(key)},${flatten(value2)}`;
1139
+ keys.pop();
1140
+ }
1141
+ str += "]";
1142
+ break;
1143
+ case "Int8Array":
1144
+ case "Uint8Array":
1145
+ case "Uint8ClampedArray":
1146
+ case "Int16Array":
1147
+ case "Uint16Array":
1148
+ case "Float16Array":
1149
+ case "Int32Array":
1150
+ case "Uint32Array":
1151
+ case "Float32Array":
1152
+ case "Float64Array":
1153
+ case "BigInt64Array":
1154
+ case "BigUint64Array":
1155
+ case "DataView": {
1156
+ const typedArray = thing;
1157
+ str = '["' + type + '",' + flatten(typedArray.buffer);
1158
+ if (typedArray.byteLength !== typedArray.buffer.byteLength) {
1159
+ str += `,${typedArray.byteOffset},${typedArray.length}`;
1160
+ }
1161
+ str += "]";
1162
+ break;
1163
+ }
1164
+ case "ArrayBuffer": {
1165
+ const arraybuffer = thing;
1166
+ const base64 = encode64(arraybuffer);
1167
+ str = `["ArrayBuffer","${base64}"]`;
1168
+ break;
1169
+ }
1170
+ case "Temporal.Duration":
1171
+ case "Temporal.Instant":
1172
+ case "Temporal.PlainDate":
1173
+ case "Temporal.PlainTime":
1174
+ case "Temporal.PlainDateTime":
1175
+ case "Temporal.PlainMonthDay":
1176
+ case "Temporal.PlainYearMonth":
1177
+ case "Temporal.ZonedDateTime":
1178
+ str = `["${type}",${stringify_string(thing.toString())}]`;
1179
+ break;
1180
+ default:
1181
+ if (!is_plain_object(thing)) {
1182
+ throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
1183
+ }
1184
+ if (enumerable_symbols(thing).length > 0) {
1185
+ throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
1186
+ }
1187
+ if (Object.getPrototypeOf(thing) === null) {
1188
+ str = '["null"';
1189
+ for (const key of Object.keys(thing)) {
1190
+ if (key === "__proto__") {
1191
+ throw new DevalueError(
1192
+ `Cannot stringify objects with __proto__ keys`,
1193
+ keys,
1194
+ thing,
1195
+ value
1196
+ );
1197
+ }
1198
+ keys.push(stringify_key(key));
1199
+ str += `,${stringify_string(key)},${flatten(thing[key])}`;
1200
+ keys.pop();
1201
+ }
1202
+ str += "]";
1203
+ } else {
1204
+ str = "{";
1205
+ let started = false;
1206
+ for (const key of Object.keys(thing)) {
1207
+ if (key === "__proto__") {
1208
+ throw new DevalueError(
1209
+ `Cannot stringify objects with __proto__ keys`,
1210
+ keys,
1211
+ thing,
1212
+ value
1213
+ );
1214
+ }
1215
+ if (started) str += ",";
1216
+ started = true;
1217
+ keys.push(stringify_key(key));
1218
+ str += `${stringify_string(key)}:${flatten(thing[key])}`;
1219
+ keys.pop();
1220
+ }
1221
+ str += "}";
1222
+ }
1223
+ }
1224
+ }
1225
+ stringified[index2] = str;
1226
+ return index2;
1227
+ }
1228
+ const index = flatten(value);
1229
+ if (index < 0) return `${index}`;
1230
+ return stringified;
1231
+ }
1232
+ function stringify_primitive(thing) {
1233
+ const type = typeof thing;
1234
+ if (type === "string") return stringify_string(thing);
1235
+ if (thing === void 0) return UNDEFINED.toString();
1236
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
1237
+ if (type === "bigint") return `["BigInt","${thing}"]`;
1238
+ return String(thing);
2176
1239
  }
2177
-
2178
1240
  const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
2179
1241
  const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
2180
1242
  const PAGE_METHODS = ["GET", "POST", "HEAD"];
@@ -2279,13 +1341,13 @@ async function deserialize_binary_form(request) {
2279
1341
  chunks2.push(chunk);
2280
1342
  cursor += chunk.byteLength;
2281
1343
  }
2282
- const buffer = new Uint8Array(length);
1344
+ const buffer2 = new Uint8Array(length);
2283
1345
  cursor = 0;
2284
1346
  for (const chunk of chunks2) {
2285
- buffer.set(chunk, cursor);
1347
+ buffer2.set(chunk, cursor);
2286
1348
  cursor += chunk.byteLength;
2287
1349
  }
2288
- return buffer;
1350
+ return buffer2;
2289
1351
  }
2290
1352
  const header = await get_buffer(0, HEADER_BYTES);
2291
1353
  if (!header) throw deserialize_error("too short");
@@ -2532,86 +1594,276 @@ function create_remote_arg_revivers(transport) {
2532
1594
  if (!Array.isArray(item) || item.length !== 2 || typeof item[0] !== "string" || typeof item[1] !== "string") {
2533
1595
  throw new Error("Invalid data for Map reviver");
2534
1596
  }
2535
- const [key, val] = item;
2536
- map.set(parse$1(key), parse$1(val));
2537
- }
2538
- return map;
2539
- },
2540
- /** @type {(value: unknown) => Set<unknown>} */
2541
- [remote_set]: (value) => {
2542
- if (!Array.isArray(value)) {
2543
- throw new Error("Invalid data for Set reviver");
2544
- }
2545
- const set = /* @__PURE__ */ new Set();
2546
- for (const item of value) {
2547
- if (typeof item !== "string") {
2548
- throw new Error("Invalid data for Set reviver");
1597
+ const [key, val] = item;
1598
+ map.set(parse$1(key), parse$1(val));
1599
+ }
1600
+ return map;
1601
+ },
1602
+ /** @type {(value: unknown) => Set<unknown>} */
1603
+ [remote_set]: (value) => {
1604
+ if (!Array.isArray(value)) {
1605
+ throw new Error("Invalid data for Set reviver");
1606
+ }
1607
+ const set = /* @__PURE__ */ new Set();
1608
+ for (const item of value) {
1609
+ if (typeof item !== "string") {
1610
+ throw new Error("Invalid data for Set reviver");
1611
+ }
1612
+ set.add(parse$1(item));
1613
+ }
1614
+ return set;
1615
+ },
1616
+ /** @type {(value: any) => File} */
1617
+ [remote_file]: (value) => {
1618
+ if (!value || typeof value !== "object" || typeof value.name !== "string" || typeof value.type !== "string" || typeof value.size !== "number" || typeof value.lastModified !== "number" || !(value.data instanceof ArrayBuffer)) {
1619
+ throw new Error("Invalid data for File reviver");
1620
+ }
1621
+ const { data, name, ...meta } = value;
1622
+ return new File([data], name, meta);
1623
+ }
1624
+ };
1625
+ const user_revivers = Object.fromEntries(
1626
+ Object.entries(transport).map(([k, v]) => [k, v.decode])
1627
+ );
1628
+ const all_revivers = { ...user_revivers, ...remote_fns_revivers };
1629
+ const parse$1 = (data) => parse(data, all_revivers);
1630
+ return all_revivers;
1631
+ }
1632
+ function parse_remote_arg(string, transport) {
1633
+ if (!string) return void 0;
1634
+ const json_string = new TextDecoder().decode(
1635
+ // no need to add back `=` characters, atob can handle it
1636
+ base64_decode(string.replaceAll("-", "+").replaceAll("_", "/"))
1637
+ );
1638
+ return parse(json_string, create_remote_arg_revivers(transport));
1639
+ }
1640
+ function create_remote_key(id, payload) {
1641
+ return id + "/" + payload;
1642
+ }
1643
+ function split_remote_key(key) {
1644
+ const i = key.lastIndexOf("/");
1645
+ if (i === -1) {
1646
+ throw new Error(`Invalid remote key: ${key}`);
1647
+ }
1648
+ return {
1649
+ id: key.slice(0, i),
1650
+ payload: key.slice(i + 1)
1651
+ };
1652
+ }
1653
+ function coalesce_to_error(err) {
1654
+ return err instanceof Error || err && /** @type {any} */
1655
+ err.name && /** @type {any} */
1656
+ err.message ? (
1657
+ /** @type {Error} */
1658
+ err
1659
+ ) : new Error(JSON.stringify(err));
1660
+ }
1661
+ function normalize_error(error) {
1662
+ return (
1663
+ /** @type {import('../exports/internal/index.js').Redirect | HttpError | SvelteKitError | Error} */
1664
+ error
1665
+ );
1666
+ }
1667
+ function get_status(error) {
1668
+ return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
1669
+ }
1670
+ function get_message(error) {
1671
+ return error instanceof SvelteKitError ? error.text : "Internal Error";
1672
+ }
1673
+ var defaultParseOptions = {
1674
+ decodeValues: true,
1675
+ map: false,
1676
+ silent: false,
1677
+ split: "auto"
1678
+ // auto = split strings but not arrays
1679
+ };
1680
+ function isForbiddenKey(key) {
1681
+ return typeof key !== "string" || key in {};
1682
+ }
1683
+ function createNullObj() {
1684
+ return /* @__PURE__ */ Object.create(null);
1685
+ }
1686
+ function isNonEmptyString(str) {
1687
+ return typeof str === "string" && !!str.trim();
1688
+ }
1689
+ function parseString(setCookieValue, options) {
1690
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
1691
+ var nameValuePairStr = parts.shift();
1692
+ if (!nameValuePairStr) {
1693
+ return null;
1694
+ }
1695
+ var parsed = parseNameValuePair(nameValuePairStr);
1696
+ var name = parsed.name;
1697
+ var value = parsed.value;
1698
+ options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
1699
+ if (isForbiddenKey(name)) {
1700
+ return null;
1701
+ }
1702
+ try {
1703
+ value = options.decodeValues ? decodeURIComponent(value) : value;
1704
+ } catch (e) {
1705
+ console.error(
1706
+ "set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",
1707
+ e
1708
+ );
1709
+ }
1710
+ var cookie = createNullObj();
1711
+ cookie.name = name;
1712
+ cookie.value = value;
1713
+ parts.forEach(function(part) {
1714
+ var sides = part.split("=");
1715
+ var key = sides.shift().trim().toLowerCase();
1716
+ if (isForbiddenKey(key)) {
1717
+ return;
1718
+ }
1719
+ var value2 = sides.join("=").trim();
1720
+ if (key === "expires") {
1721
+ cookie.expires = new Date(value2);
1722
+ } else if (key === "max-age") {
1723
+ var n = parseInt(value2, 10);
1724
+ if (!Number.isNaN(n)) cookie.maxAge = n;
1725
+ } else if (key === "secure") {
1726
+ cookie.secure = true;
1727
+ } else if (key === "httponly") {
1728
+ cookie.httpOnly = true;
1729
+ } else if (key === "samesite") {
1730
+ cookie.sameSite = value2;
1731
+ } else if (key === "partitioned") {
1732
+ cookie.partitioned = true;
1733
+ } else if (key) {
1734
+ cookie[key] = value2;
1735
+ }
1736
+ });
1737
+ return cookie;
1738
+ }
1739
+ function parseNameValuePair(nameValuePairStr) {
1740
+ var name = "";
1741
+ var value = "";
1742
+ var nameValueArr = nameValuePairStr.split("=");
1743
+ if (nameValueArr.length > 1) {
1744
+ name = nameValueArr.shift();
1745
+ value = nameValueArr.join("=");
1746
+ } else {
1747
+ value = nameValuePairStr;
1748
+ }
1749
+ return { name, value };
1750
+ }
1751
+ function parseSetCookie(input, options) {
1752
+ options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
1753
+ if (!input) {
1754
+ if (!options.map) {
1755
+ return [];
1756
+ } else {
1757
+ return createNullObj();
1758
+ }
1759
+ }
1760
+ if (input.headers) {
1761
+ if (typeof input.headers.getSetCookie === "function") {
1762
+ input = input.headers.getSetCookie();
1763
+ } else if (input.headers["set-cookie"]) {
1764
+ input = input.headers["set-cookie"];
1765
+ } else {
1766
+ var sch = input.headers[Object.keys(input.headers).find(function(key) {
1767
+ return key.toLowerCase() === "set-cookie";
1768
+ })];
1769
+ if (!sch && input.headers.cookie && !options.silent) {
1770
+ console.warn(
1771
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
1772
+ );
1773
+ }
1774
+ input = sch;
1775
+ }
1776
+ }
1777
+ var split = options.split;
1778
+ var isArray = Array.isArray(input);
1779
+ if (split === "auto") {
1780
+ split = !isArray;
1781
+ }
1782
+ if (!isArray) {
1783
+ input = [input];
1784
+ }
1785
+ input = input.filter(isNonEmptyString);
1786
+ if (split) {
1787
+ input = input.map(splitCookiesString).flat();
1788
+ }
1789
+ if (!options.map) {
1790
+ return input.map(function(str) {
1791
+ return parseString(str, options);
1792
+ }).filter(Boolean);
1793
+ } else {
1794
+ var cookies = createNullObj();
1795
+ return input.reduce(function(cookies2, str) {
1796
+ var cookie = parseString(str, options);
1797
+ if (cookie && !isForbiddenKey(cookie.name)) {
1798
+ cookies2[cookie.name] = cookie;
1799
+ }
1800
+ return cookies2;
1801
+ }, cookies);
1802
+ }
1803
+ }
1804
+ function splitCookiesString(cookiesString) {
1805
+ if (Array.isArray(cookiesString)) {
1806
+ return cookiesString;
1807
+ }
1808
+ if (typeof cookiesString !== "string") {
1809
+ return [];
1810
+ }
1811
+ var cookiesStrings = [];
1812
+ var pos = 0;
1813
+ var start;
1814
+ var ch;
1815
+ var lastComma;
1816
+ var nextStart;
1817
+ var cookiesSeparatorFound;
1818
+ function skipWhitespace() {
1819
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
1820
+ pos += 1;
1821
+ }
1822
+ return pos < cookiesString.length;
1823
+ }
1824
+ function notSpecialChar() {
1825
+ ch = cookiesString.charAt(pos);
1826
+ return ch !== "=" && ch !== ";" && ch !== ",";
1827
+ }
1828
+ while (pos < cookiesString.length) {
1829
+ start = pos;
1830
+ cookiesSeparatorFound = false;
1831
+ while (skipWhitespace()) {
1832
+ ch = cookiesString.charAt(pos);
1833
+ if (ch === ",") {
1834
+ lastComma = pos;
1835
+ pos += 1;
1836
+ skipWhitespace();
1837
+ nextStart = pos;
1838
+ while (pos < cookiesString.length && notSpecialChar()) {
1839
+ pos += 1;
1840
+ }
1841
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
1842
+ cookiesSeparatorFound = true;
1843
+ pos = nextStart;
1844
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
1845
+ start = pos;
1846
+ } else {
1847
+ pos = lastComma + 1;
2549
1848
  }
2550
- set.add(parse$1(item));
2551
- }
2552
- return set;
2553
- },
2554
- /** @type {(value: any) => File} */
2555
- [remote_file]: (value) => {
2556
- if (!value || typeof value !== "object" || typeof value.name !== "string" || typeof value.type !== "string" || typeof value.size !== "number" || typeof value.lastModified !== "number" || !(value.data instanceof ArrayBuffer)) {
2557
- throw new Error("Invalid data for File reviver");
1849
+ } else {
1850
+ pos += 1;
2558
1851
  }
2559
- const { data, name, ...meta } = value;
2560
- return new File([data], name, meta);
2561
1852
  }
2562
- };
2563
- const user_revivers = Object.fromEntries(
2564
- Object.entries(transport).map(([k, v]) => [k, v.decode])
2565
- );
2566
- const all_revivers = { ...user_revivers, ...remote_fns_revivers };
2567
- const parse$1 = (data) => parse(data, all_revivers);
2568
- return all_revivers;
2569
- }
2570
- function parse_remote_arg(string, transport) {
2571
- if (!string) return void 0;
2572
- const json_string = new TextDecoder().decode(
2573
- // no need to add back `=` characters, atob can handle it
2574
- base64_decode(string.replaceAll("-", "+").replaceAll("_", "/"))
2575
- );
2576
- return parse(json_string, create_remote_arg_revivers(transport));
2577
- }
2578
- function create_remote_key(id, payload) {
2579
- return id + "/" + payload;
2580
- }
2581
- function split_remote_key(key) {
2582
- const i = key.lastIndexOf("/");
2583
- if (i === -1) {
2584
- throw new Error(`Invalid remote key: ${key}`);
1853
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
1854
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
1855
+ }
2585
1856
  }
2586
- return {
2587
- id: key.slice(0, i),
2588
- payload: key.slice(i + 1)
2589
- };
2590
- }
2591
- function coalesce_to_error(err) {
2592
- return err instanceof Error || err && /** @type {any} */
2593
- err.name && /** @type {any} */
2594
- err.message ? (
2595
- /** @type {Error} */
2596
- err
2597
- ) : new Error(JSON.stringify(err));
2598
- }
2599
- function normalize_error(error) {
2600
- return (
2601
- /** @type {import('../exports/internal/index.js').Redirect | HttpError | SvelteKitError | Error} */
2602
- error
2603
- );
2604
- }
2605
- function get_status(error) {
2606
- return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
2607
- }
2608
- function get_message(error) {
2609
- return error instanceof SvelteKitError ? error.text : "Internal Error";
1857
+ return cookiesStrings;
2610
1858
  }
1859
+ parseSetCookie.parseSetCookie = parseSetCookie;
1860
+ parseSetCookie.parse = parseSetCookie;
1861
+ parseSetCookie.parseString = parseString;
1862
+ parseSetCookie.splitCookiesString = splitCookiesString;
2611
1863
  function negotiate(accept, types) {
2612
1864
  const parts = [];
2613
1865
  accept.split(",").forEach((str, i) => {
2614
- const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
1866
+ const match = /^[ \t]*([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
2615
1867
  if (match) {
2616
1868
  const [, type, subtype, q = "1"] = match;
2617
1869
  parts.push({ type, subtype, q: +q, i });
@@ -2812,8 +2064,6 @@ function create_replacer(transport) {
2812
2064
  return replacer;
2813
2065
  }
2814
2066
 
2815
- 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}
2816
-
2817
2067
  const DERIVED = 1 << 1;
2818
2068
  const EFFECT = 1 << 2;
2819
2069
  const RENDER_EFFECT = 1 << 3;
@@ -4108,7 +3358,7 @@ class Batch {
4108
3358
  if (this.#roots.length > 0) {
4109
3359
  if (next_batch !== null) {
4110
3360
  const batch2 = next_batch;
4111
- batch2.#roots.push(...this.#roots.filter((r) => !batch2.#roots.includes(r)));
3361
+ batch2.#roots.push(...this.#roots.filter((r2) => !batch2.#roots.includes(r2)));
4112
3362
  } else {
4113
3363
  next_batch = this;
4114
3364
  }
@@ -5812,6 +5062,19 @@ function escape_html(value, is_attr) {
5812
5062
  }
5813
5063
  return escaped + str.substring(last);
5814
5064
  }
5065
+ function r(e) {
5066
+ var t, f, n = "";
5067
+ if ("string" == typeof e || "number" == typeof e) n += e;
5068
+ else if ("object" == typeof e) if (Array.isArray(e)) {
5069
+ var o = e.length;
5070
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
5071
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
5072
+ return n;
5073
+ }
5074
+ function clsx$1() {
5075
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
5076
+ return n;
5077
+ }
5815
5078
  const replacements$1 = {
5816
5079
  translate: /* @__PURE__ */ new Map([
5817
5080
  [true, "yes"],
@@ -6345,14 +5608,14 @@ class Renderer {
6345
5608
  };
6346
5609
  if (typeof body === "function") {
6347
5610
  this.child((renderer) => {
6348
- const r = new Renderer(this.global, this);
6349
- body(r);
5611
+ const r2 = new Renderer(this.global, this);
5612
+ body(r2);
6350
5613
  if (this.global.mode === "async") {
6351
- return r.#collect_content_async().then((content) => {
5614
+ return r2.#collect_content_async().then((content) => {
6352
5615
  close(renderer, content.body.replaceAll("<!---->", ""), content);
6353
5616
  });
6354
5617
  } else {
6355
- const content = r.#collect_content();
5618
+ const content = r2.#collect_content();
6356
5619
  close(renderer, content.body.replaceAll("<!---->", ""), content);
6357
5620
  }
6358
5621
  });
@@ -6369,14 +5632,14 @@ class Renderer {
6369
5632
  this.global.set_title(head, path);
6370
5633
  };
6371
5634
  this.child((renderer) => {
6372
- const r = new Renderer(renderer.global, renderer);
6373
- fn(r);
5635
+ const r2 = new Renderer(renderer.global, renderer);
5636
+ fn(r2);
6374
5637
  if (renderer.global.mode === "async") {
6375
- return r.#collect_content_async().then((content) => {
5638
+ return r2.#collect_content_async().then((content) => {
6376
5639
  close(content.head);
6377
5640
  });
6378
5641
  } else {
6379
- const content = r.#collect_content();
5642
+ const content = r2.#collect_content();
6380
5643
  close(content.head);
6381
5644
  }
6382
5645
  });
@@ -7211,304 +6474,16 @@ const validate_page_exports = validator(valid_page_exports);
7211
6474
  const validate_layout_server_exports = validator(valid_layout_server_exports);
7212
6475
  const validate_page_server_exports = validator(valid_page_server_exports);
7213
6476
 
7214
- let private_env = {};
6477
+ let read_implementation = null;
6478
+ function set_read_implementation(fn) {
6479
+ read_implementation = fn;
6480
+ }
7215
6481
  let public_env = {};
7216
6482
  function set_private_env(environment) {
7217
- private_env = environment;
7218
6483
  }
7219
6484
  function set_public_env(environment) {
7220
6485
  public_env = environment;
7221
6486
  }
7222
-
7223
- var cookie = {};
7224
-
7225
- /*!
7226
- * cookie
7227
- * Copyright(c) 2012-2014 Roman Shtylman
7228
- * Copyright(c) 2015 Douglas Christopher Wilson
7229
- * MIT Licensed
7230
- */
7231
-
7232
- var hasRequiredCookie;
7233
-
7234
- function requireCookie () {
7235
- if (hasRequiredCookie) return cookie;
7236
- hasRequiredCookie = 1;
7237
-
7238
- /**
7239
- * Module exports.
7240
- * @public
7241
- */
7242
-
7243
- cookie.parse = parse;
7244
- cookie.serialize = serialize;
7245
-
7246
- /**
7247
- * Module variables.
7248
- * @private
7249
- */
7250
-
7251
- var __toString = Object.prototype.toString;
7252
-
7253
- /**
7254
- * RegExp to match field-content in RFC 7230 sec 3.2
7255
- *
7256
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
7257
- * field-vchar = VCHAR / obs-text
7258
- * obs-text = %x80-FF
7259
- */
7260
-
7261
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
7262
-
7263
- /**
7264
- * Parse a cookie header.
7265
- *
7266
- * Parse the given cookie header string into an object
7267
- * The object has the various cookies as keys(names) => values
7268
- *
7269
- * @param {string} str
7270
- * @param {object} [options]
7271
- * @return {object}
7272
- * @public
7273
- */
7274
-
7275
- function parse(str, options) {
7276
- if (typeof str !== 'string') {
7277
- throw new TypeError('argument str must be a string');
7278
- }
7279
-
7280
- var obj = {};
7281
- var opt = options || {};
7282
- var dec = opt.decode || decode;
7283
-
7284
- var index = 0;
7285
- while (index < str.length) {
7286
- var eqIdx = str.indexOf('=', index);
7287
-
7288
- // no more cookie pairs
7289
- if (eqIdx === -1) {
7290
- break
7291
- }
7292
-
7293
- var endIdx = str.indexOf(';', index);
7294
-
7295
- if (endIdx === -1) {
7296
- endIdx = str.length;
7297
- } else if (endIdx < eqIdx) {
7298
- // backtrack on prior semicolon
7299
- index = str.lastIndexOf(';', eqIdx - 1) + 1;
7300
- continue
7301
- }
7302
-
7303
- var key = str.slice(index, eqIdx).trim();
7304
-
7305
- // only assign once
7306
- if (undefined === obj[key]) {
7307
- var val = str.slice(eqIdx + 1, endIdx).trim();
7308
-
7309
- // quoted values
7310
- if (val.charCodeAt(0) === 0x22) {
7311
- val = val.slice(1, -1);
7312
- }
7313
-
7314
- obj[key] = tryDecode(val, dec);
7315
- }
7316
-
7317
- index = endIdx + 1;
7318
- }
7319
-
7320
- return obj;
7321
- }
7322
-
7323
- /**
7324
- * Serialize data into a cookie header.
7325
- *
7326
- * Serialize the a name value pair into a cookie string suitable for
7327
- * http headers. An optional options object specified cookie parameters.
7328
- *
7329
- * serialize('foo', 'bar', { httpOnly: true })
7330
- * => "foo=bar; httpOnly"
7331
- *
7332
- * @param {string} name
7333
- * @param {string} val
7334
- * @param {object} [options]
7335
- * @return {string}
7336
- * @public
7337
- */
7338
-
7339
- function serialize(name, val, options) {
7340
- var opt = options || {};
7341
- var enc = opt.encode || encode;
7342
-
7343
- if (typeof enc !== 'function') {
7344
- throw new TypeError('option encode is invalid');
7345
- }
7346
-
7347
- if (!fieldContentRegExp.test(name)) {
7348
- throw new TypeError('argument name is invalid');
7349
- }
7350
-
7351
- var value = enc(val);
7352
-
7353
- if (value && !fieldContentRegExp.test(value)) {
7354
- throw new TypeError('argument val is invalid');
7355
- }
7356
-
7357
- var str = name + '=' + value;
7358
-
7359
- if (null != opt.maxAge) {
7360
- var maxAge = opt.maxAge - 0;
7361
-
7362
- if (isNaN(maxAge) || !isFinite(maxAge)) {
7363
- throw new TypeError('option maxAge is invalid')
7364
- }
7365
-
7366
- str += '; Max-Age=' + Math.floor(maxAge);
7367
- }
7368
-
7369
- if (opt.domain) {
7370
- if (!fieldContentRegExp.test(opt.domain)) {
7371
- throw new TypeError('option domain is invalid');
7372
- }
7373
-
7374
- str += '; Domain=' + opt.domain;
7375
- }
7376
-
7377
- if (opt.path) {
7378
- if (!fieldContentRegExp.test(opt.path)) {
7379
- throw new TypeError('option path is invalid');
7380
- }
7381
-
7382
- str += '; Path=' + opt.path;
7383
- }
7384
-
7385
- if (opt.expires) {
7386
- var expires = opt.expires;
7387
-
7388
- if (!isDate(expires) || isNaN(expires.valueOf())) {
7389
- throw new TypeError('option expires is invalid');
7390
- }
7391
-
7392
- str += '; Expires=' + expires.toUTCString();
7393
- }
7394
-
7395
- if (opt.httpOnly) {
7396
- str += '; HttpOnly';
7397
- }
7398
-
7399
- if (opt.secure) {
7400
- str += '; Secure';
7401
- }
7402
-
7403
- if (opt.partitioned) {
7404
- str += '; Partitioned';
7405
- }
7406
-
7407
- if (opt.priority) {
7408
- var priority = typeof opt.priority === 'string'
7409
- ? opt.priority.toLowerCase()
7410
- : opt.priority;
7411
-
7412
- switch (priority) {
7413
- case 'low':
7414
- str += '; Priority=Low';
7415
- break
7416
- case 'medium':
7417
- str += '; Priority=Medium';
7418
- break
7419
- case 'high':
7420
- str += '; Priority=High';
7421
- break
7422
- default:
7423
- throw new TypeError('option priority is invalid')
7424
- }
7425
- }
7426
-
7427
- if (opt.sameSite) {
7428
- var sameSite = typeof opt.sameSite === 'string'
7429
- ? opt.sameSite.toLowerCase() : opt.sameSite;
7430
-
7431
- switch (sameSite) {
7432
- case true:
7433
- str += '; SameSite=Strict';
7434
- break;
7435
- case 'lax':
7436
- str += '; SameSite=Lax';
7437
- break;
7438
- case 'strict':
7439
- str += '; SameSite=Strict';
7440
- break;
7441
- case 'none':
7442
- str += '; SameSite=None';
7443
- break;
7444
- default:
7445
- throw new TypeError('option sameSite is invalid');
7446
- }
7447
- }
7448
-
7449
- return str;
7450
- }
7451
-
7452
- /**
7453
- * URL-decode string value. Optimized to skip native call when no %.
7454
- *
7455
- * @param {string} str
7456
- * @returns {string}
7457
- */
7458
-
7459
- function decode (str) {
7460
- return str.indexOf('%') !== -1
7461
- ? decodeURIComponent(str)
7462
- : str
7463
- }
7464
-
7465
- /**
7466
- * URL-encode value.
7467
- *
7468
- * @param {string} val
7469
- * @returns {string}
7470
- */
7471
-
7472
- function encode (val) {
7473
- return encodeURIComponent(val)
7474
- }
7475
-
7476
- /**
7477
- * Determine if value is a Date.
7478
- *
7479
- * @param {*} val
7480
- * @private
7481
- */
7482
-
7483
- function isDate (val) {
7484
- return __toString.call(val) === '[object Date]' ||
7485
- val instanceof Date
7486
- }
7487
-
7488
- /**
7489
- * Try decoding a string using a decoding function.
7490
- *
7491
- * @param {string} str
7492
- * @param {function} decode
7493
- * @private
7494
- */
7495
-
7496
- function tryDecode(str, decode) {
7497
- try {
7498
- return decode(str);
7499
- } catch (e) {
7500
- return str;
7501
- }
7502
- }
7503
- return cookie;
7504
- }
7505
-
7506
- var cookieExports = requireCookie();
7507
-
7508
- let read_implementation = null;
7509
- function set_read_implementation(fn) {
7510
- read_implementation = fn;
7511
- }
7512
6487
  const error = ({ status, message }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <title>' + message + `</title>
7513
6488
 
7514
6489
  <style>
@@ -7600,7 +6575,7 @@ const options = {
7600
6575
  app: ({ head, body, assets, nonce, env }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" href="' + assets + '/favicon.png" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n ' + head + '\n </head>\n <body data-sveltekit-preload-data="hover">\n <div style="display: contents">' + body + "</div>\n </body>\n</html>\n",
7601
6576
  error
7602
6577
  },
7603
- version_hash: "iei8u2"
6578
+ version_hash: "oa7is1"
7604
6579
  };
7605
6580
  async function get_hooks() {
7606
6581
  let handle;
@@ -7608,7 +6583,7 @@ async function get_hooks() {
7608
6583
  let handleError;
7609
6584
  let handleValidationError;
7610
6585
  let init;
7611
- ({ handle, handleFetch, handleError, handleValidationError, init } = await import('./hooks.server-DYGrWbgh.js'));
6586
+ ({ handle, handleFetch, handleError, handleValidationError, init } = await import('./hooks.server-Dpmff0ik.js'));
7612
6587
  let reroute;
7613
6588
  let transport;
7614
6589
  return {
@@ -10591,6 +9566,152 @@ function redirect_json_response(redirect) {
10591
9566
  }
10592
9567
  );
10593
9568
  }
9569
+ var cookie = {};
9570
+ var hasRequiredCookie;
9571
+ function requireCookie() {
9572
+ if (hasRequiredCookie) return cookie;
9573
+ hasRequiredCookie = 1;
9574
+ cookie.parse = parse;
9575
+ cookie.serialize = serialize;
9576
+ var __toString = Object.prototype.toString;
9577
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
9578
+ function parse(str, options2) {
9579
+ if (typeof str !== "string") {
9580
+ throw new TypeError("argument str must be a string");
9581
+ }
9582
+ var obj = {};
9583
+ var opt = options2 || {};
9584
+ var dec = opt.decode || decode;
9585
+ var index = 0;
9586
+ while (index < str.length) {
9587
+ var eqIdx = str.indexOf("=", index);
9588
+ if (eqIdx === -1) {
9589
+ break;
9590
+ }
9591
+ var endIdx = str.indexOf(";", index);
9592
+ if (endIdx === -1) {
9593
+ endIdx = str.length;
9594
+ } else if (endIdx < eqIdx) {
9595
+ index = str.lastIndexOf(";", eqIdx - 1) + 1;
9596
+ continue;
9597
+ }
9598
+ var key2 = str.slice(index, eqIdx).trim();
9599
+ if (void 0 === obj[key2]) {
9600
+ var val = str.slice(eqIdx + 1, endIdx).trim();
9601
+ if (val.charCodeAt(0) === 34) {
9602
+ val = val.slice(1, -1);
9603
+ }
9604
+ obj[key2] = tryDecode(val, dec);
9605
+ }
9606
+ index = endIdx + 1;
9607
+ }
9608
+ return obj;
9609
+ }
9610
+ function serialize(name, val, options2) {
9611
+ var opt = options2 || {};
9612
+ var enc = opt.encode || encode2;
9613
+ if (typeof enc !== "function") {
9614
+ throw new TypeError("option encode is invalid");
9615
+ }
9616
+ if (!fieldContentRegExp.test(name)) {
9617
+ throw new TypeError("argument name is invalid");
9618
+ }
9619
+ var value = enc(val);
9620
+ if (value && !fieldContentRegExp.test(value)) {
9621
+ throw new TypeError("argument val is invalid");
9622
+ }
9623
+ var str = name + "=" + value;
9624
+ if (null != opt.maxAge) {
9625
+ var maxAge = opt.maxAge - 0;
9626
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
9627
+ throw new TypeError("option maxAge is invalid");
9628
+ }
9629
+ str += "; Max-Age=" + Math.floor(maxAge);
9630
+ }
9631
+ if (opt.domain) {
9632
+ if (!fieldContentRegExp.test(opt.domain)) {
9633
+ throw new TypeError("option domain is invalid");
9634
+ }
9635
+ str += "; Domain=" + opt.domain;
9636
+ }
9637
+ if (opt.path) {
9638
+ if (!fieldContentRegExp.test(opt.path)) {
9639
+ throw new TypeError("option path is invalid");
9640
+ }
9641
+ str += "; Path=" + opt.path;
9642
+ }
9643
+ if (opt.expires) {
9644
+ var expires = opt.expires;
9645
+ if (!isDate(expires) || isNaN(expires.valueOf())) {
9646
+ throw new TypeError("option expires is invalid");
9647
+ }
9648
+ str += "; Expires=" + expires.toUTCString();
9649
+ }
9650
+ if (opt.httpOnly) {
9651
+ str += "; HttpOnly";
9652
+ }
9653
+ if (opt.secure) {
9654
+ str += "; Secure";
9655
+ }
9656
+ if (opt.partitioned) {
9657
+ str += "; Partitioned";
9658
+ }
9659
+ if (opt.priority) {
9660
+ var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
9661
+ switch (priority) {
9662
+ case "low":
9663
+ str += "; Priority=Low";
9664
+ break;
9665
+ case "medium":
9666
+ str += "; Priority=Medium";
9667
+ break;
9668
+ case "high":
9669
+ str += "; Priority=High";
9670
+ break;
9671
+ default:
9672
+ throw new TypeError("option priority is invalid");
9673
+ }
9674
+ }
9675
+ if (opt.sameSite) {
9676
+ var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
9677
+ switch (sameSite) {
9678
+ case true:
9679
+ str += "; SameSite=Strict";
9680
+ break;
9681
+ case "lax":
9682
+ str += "; SameSite=Lax";
9683
+ break;
9684
+ case "strict":
9685
+ str += "; SameSite=Strict";
9686
+ break;
9687
+ case "none":
9688
+ str += "; SameSite=None";
9689
+ break;
9690
+ default:
9691
+ throw new TypeError("option sameSite is invalid");
9692
+ }
9693
+ }
9694
+ return str;
9695
+ }
9696
+ function decode(str) {
9697
+ return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
9698
+ }
9699
+ function encode2(val) {
9700
+ return encodeURIComponent(val);
9701
+ }
9702
+ function isDate(val) {
9703
+ return __toString.call(val) === "[object Date]" || val instanceof Date;
9704
+ }
9705
+ function tryDecode(str, decode2) {
9706
+ try {
9707
+ return decode2(str);
9708
+ } catch (e) {
9709
+ return str;
9710
+ }
9711
+ }
9712
+ return cookie;
9713
+ }
9714
+ var cookieExports = requireCookie();
10594
9715
  const INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
10595
9716
  function validate_options(options2) {
10596
9717
  if (options2?.path === void 0) {
@@ -10627,8 +9748,8 @@ function get_cookies(request, url) {
10627
9748
  return best_match.options.maxAge === 0 ? void 0 : best_match.value;
10628
9749
  }
10629
9750
  const req_cookies = cookieExports.parse(header, { decode: opts?.decode });
10630
- const cookie = req_cookies[name];
10631
- return cookie;
9751
+ const cookie2 = req_cookies[name];
9752
+ return cookie2;
10632
9753
  },
10633
9754
  /**
10634
9755
  * @param {import('cookie').CookieParseOptions} [opts]
@@ -10696,11 +9817,11 @@ function get_cookies(request, url) {
10696
9817
  // cookies sent by the user agent have lowest precedence
10697
9818
  ...initial_cookies
10698
9819
  };
10699
- for (const cookie of new_cookies.values()) {
10700
- if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
10701
- if (!path_matches(destination.pathname, cookie.options.path)) continue;
10702
- const encoder = cookie.options.encode || encodeURIComponent;
10703
- combined_cookies[cookie.name] = encoder(cookie.value);
9820
+ for (const cookie2 of new_cookies.values()) {
9821
+ if (!domain_matches(destination.hostname, cookie2.options.domain)) continue;
9822
+ if (!path_matches(destination.pathname, cookie2.options.path)) continue;
9823
+ const encoder = cookie2.options.encode || encodeURIComponent;
9824
+ combined_cookies[cookie2.name] = encoder(cookie2.value);
10704
9825
  }
10705
9826
  if (header2) {
10706
9827
  const parsed = cookieExports.parse(header2, { decode: (value) => value });
@@ -10721,8 +9842,8 @@ function get_cookies(request, url) {
10721
9842
  path = resolve(normalized_url, path);
10722
9843
  }
10723
9844
  const cookie_key = generate_cookie_key(options2.domain, path, name);
10724
- const cookie = { name, value, options: { ...options2, path } };
10725
- new_cookies.set(cookie_key, cookie);
9845
+ const cookie2 = { name, value, options: { ...options2, path } };
9846
+ new_cookies.set(cookie_key, cookie2);
10726
9847
  }
10727
9848
  function set_trailing_slash(trailing_slash) {
10728
9849
  normalized_url = normalize_path(url.pathname, trailing_slash);
@@ -10776,8 +9897,8 @@ function create_fetch({ event, options: options2, manifest, state, get_cookie_he
10776
9897
  const decoded = decodeURIComponent(url.pathname);
10777
9898
  if (url.origin !== event.url.origin || base && decoded !== base && !decoded.startsWith(`${base}/`)) {
10778
9899
  if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== "omit") {
10779
- const cookie = get_cookie_header(url, request.headers.get("cookie"));
10780
- if (cookie) request.headers.set("cookie", cookie);
9900
+ const cookie2 = get_cookie_header(url, request.headers.get("cookie"));
9901
+ if (cookie2) request.headers.set("cookie", cookie2);
10781
9902
  }
10782
9903
  return fetch(request);
10783
9904
  }
@@ -10809,9 +9930,9 @@ function create_fetch({ event, options: options2, manifest, state, get_cookie_he
10809
9930
  return await fetch(request);
10810
9931
  }
10811
9932
  if (credentials !== "omit") {
10812
- const cookie = get_cookie_header(url, request.headers.get("cookie"));
10813
- if (cookie) {
10814
- request.headers.set("cookie", cookie);
9933
+ const cookie2 = get_cookie_header(url, request.headers.get("cookie"));
9934
+ if (cookie2) {
9935
+ request.headers.set("cookie", cookie2);
10815
9936
  }
10816
9937
  const authorization = event.request.headers.get("authorization");
10817
9938
  if (authorization && !request.headers.has("authorization")) {
@@ -11249,8 +10370,8 @@ async function internal_respond(request, options2, manifest, state) {
11249
10370
  const value = response.headers.get(key2);
11250
10371
  if (value) headers22.set(key2, value);
11251
10372
  }
11252
- for (const cookie of get_set_cookies(response.headers)) {
11253
- headers22.append("set-cookie", cookie);
10373
+ for (const cookie2 of get_set_cookies(response.headers)) {
10374
+ headers22.append("set-cookie", cookie2);
11254
10375
  }
11255
10376
  return new Response(void 0, {
11256
10377
  status: 304,
@@ -11570,4 +10691,4 @@ class Server {
11570
10691
  }
11571
10692
  }
11572
10693
 
11573
- export { SvelteKitError as S, Server as a, escape_html as e, getContext as g, json as j, noop as n, private_env as p, splitCookiesString as s, writable as w };
10694
+ export { SvelteKitError as S, Server as a, escape_html as e, getContext as g, json as j, noop as n, writable as w };