token-usage-dashboard 1.0.13 → 1.0.14

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 (126) hide show
  1. package/build/adapter-node.js +11 -0
  2. package/build/client/_app/immutable/chunks/B0VWrXPj.js +1 -0
  3. package/build/client/_app/immutable/chunks/B0VWrXPj.js.br +0 -0
  4. package/build/client/_app/immutable/chunks/B0VWrXPj.js.gz +0 -0
  5. package/build/client/_app/immutable/chunks/BaNbYf_w.js +1 -0
  6. package/build/client/_app/immutable/chunks/BaNbYf_w.js.br +0 -0
  7. package/build/client/_app/immutable/chunks/BaNbYf_w.js.gz +0 -0
  8. package/build/client/_app/immutable/chunks/CbiRHTcG.js +1 -0
  9. package/build/client/_app/immutable/chunks/CbiRHTcG.js.br +0 -0
  10. package/build/client/_app/immutable/chunks/CbiRHTcG.js.gz +0 -0
  11. package/build/client/_app/immutable/chunks/DTingiCe.js +3 -0
  12. package/build/client/_app/immutable/chunks/DTingiCe.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/DTingiCe.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/ssd4Rw-g.js +3 -0
  15. package/build/client/_app/immutable/chunks/ssd4Rw-g.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/ssd4Rw-g.js.gz +0 -0
  17. package/build/client/_app/immutable/entry/app.CRLWmGVY.js +2 -0
  18. package/build/client/_app/immutable/entry/app.CRLWmGVY.js.br +0 -0
  19. package/build/client/_app/immutable/entry/app.CRLWmGVY.js.gz +0 -0
  20. package/build/client/_app/immutable/entry/payload.DSmR2FwN.js +1 -0
  21. package/build/client/_app/immutable/entry/payload.DSmR2FwN.js.br +0 -0
  22. package/build/client/_app/immutable/entry/payload.DSmR2FwN.js.gz +0 -0
  23. package/build/client/_app/immutable/entry/start.CzGx2BYz.js +2 -0
  24. package/build/client/_app/immutable/entry/start.CzGx2BYz.js.br +0 -0
  25. package/build/client/_app/immutable/entry/start.CzGx2BYz.js.gz +0 -0
  26. package/build/client/_app/immutable/nodes/0.BBGTwdwd.js +1 -0
  27. package/build/client/_app/immutable/nodes/0.BBGTwdwd.js.br +0 -0
  28. package/build/client/_app/immutable/nodes/0.BBGTwdwd.js.gz +0 -0
  29. package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js +1 -0
  30. package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js.br +2 -0
  31. package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js.gz +0 -0
  32. package/build/client/_app/immutable/nodes/2.CRMPKkcX.js +2 -0
  33. package/build/client/_app/immutable/nodes/2.CRMPKkcX.js.br +0 -0
  34. package/build/client/_app/immutable/nodes/2.CRMPKkcX.js.gz +0 -0
  35. package/build/client/_app/version.json +1 -1
  36. package/build/client/_app/version.json.br +0 -0
  37. package/build/client/_app/version.json.gz +0 -0
  38. package/build/handler.js +1 -22
  39. package/build/index.js +1 -145
  40. package/build/server/.vite/manifest.json +271 -0
  41. package/build/server/_app/immutable/assets/_layout.CZ6VMqH1.css +1 -0
  42. package/build/server/_app/immutable/assets/_page.CZocdpCk.css +1 -0
  43. package/build/server/adapter-env.js +2 -0
  44. package/build/server/adapter-index.js +74 -0
  45. package/build/server/adapter-node-env.js +63 -0
  46. package/build/server/adapter-node-handler.js +584 -0
  47. package/build/server/chunks/config.js +10 -0
  48. package/build/server/chunks/functions.js +30 -0
  49. package/build/server/chunks/index-server.js +2 -0
  50. package/build/server/chunks/instance.js +3546 -0
  51. package/build/server/chunks/internal.js +3323 -0
  52. package/build/server/chunks/navigation.js +16 -0
  53. package/build/server/chunks/{chunks/queries.js-BEdRnpMa.js → queries.js} +9 -9
  54. package/build/server/chunks/{chunks/range.js-CiCoLGqh.js → range.js} +3 -2
  55. package/build/server/chunks/{chunks/refresh.js-0W7-GwaH.js → refresh.js} +7 -7
  56. package/build/server/chunks/{chunks/request.js-BF7n7fZo.js → request.js} +5 -5
  57. package/build/server/chunks/server-errors.js +489 -0
  58. package/build/server/chunks/server.js +9 -0
  59. package/build/server/chunks/server2.js +1504 -0
  60. package/build/server/chunks/shared.js +84 -0
  61. package/build/server/chunks/uneval.js +537 -0
  62. package/build/server/entries/endpoints/api/refresh/_server.ts.js +12 -0
  63. package/build/server/entries/endpoints/api/settings/_server.ts.js +15 -0
  64. package/build/server/entries/endpoints/api/usage/_server.ts.js +8 -0
  65. package/build/server/entries/fallbacks/error.svelte.js +47 -0
  66. package/build/server/entries/hooks.server.js +10 -0
  67. package/build/server/{chunks/entries/pages/_layout.svelte.js-C9kkUOBf.js → entries/pages/_layout.svelte.js} +4 -2
  68. package/build/server/entries/pages/_page.server.ts.js +12 -0
  69. package/build/server/{chunks/entries/pages/_page.svelte.js-HFiLlojS.js → entries/pages/_page.svelte.js} +64 -27
  70. package/build/server/env.js +2 -0
  71. package/build/server/handler.js +2 -0
  72. package/build/server/index.js +67 -0
  73. package/build/server/manifest-full.js +58 -0
  74. package/build/server/manifest.js +58 -0
  75. package/build/server/nodes/0.js +8 -0
  76. package/build/server/nodes/1.js +8 -0
  77. package/build/server/nodes/2.js +10 -0
  78. package/build/server/remote-entry.js +1564 -0
  79. package/build/server/server.js +60 -0
  80. package/package.json +8 -8
  81. package/build/client/_app/immutable/chunks/CukLSH0w.js +0 -2
  82. package/build/client/_app/immutable/chunks/CukLSH0w.js.br +0 -0
  83. package/build/client/_app/immutable/chunks/CukLSH0w.js.gz +0 -0
  84. package/build/client/_app/immutable/chunks/Dsm7b1TR.js +0 -3
  85. package/build/client/_app/immutable/chunks/Dsm7b1TR.js.br +0 -0
  86. package/build/client/_app/immutable/chunks/Dsm7b1TR.js.gz +0 -0
  87. package/build/client/_app/immutable/chunks/xihTtKlq.js +0 -1
  88. package/build/client/_app/immutable/chunks/xihTtKlq.js.br +0 -1
  89. package/build/client/_app/immutable/chunks/xihTtKlq.js.gz +0 -0
  90. package/build/client/_app/immutable/entry/app.Hr-44d0W.js +0 -2
  91. package/build/client/_app/immutable/entry/app.Hr-44d0W.js.br +0 -0
  92. package/build/client/_app/immutable/entry/app.Hr-44d0W.js.gz +0 -0
  93. package/build/client/_app/immutable/entry/start.DGEKXdCU.js +0 -1
  94. package/build/client/_app/immutable/entry/start.DGEKXdCU.js.br +0 -0
  95. package/build/client/_app/immutable/entry/start.DGEKXdCU.js.gz +0 -0
  96. package/build/client/_app/immutable/nodes/0.PGglbI9f.js +0 -1
  97. package/build/client/_app/immutable/nodes/0.PGglbI9f.js.br +0 -0
  98. package/build/client/_app/immutable/nodes/0.PGglbI9f.js.gz +0 -0
  99. package/build/client/_app/immutable/nodes/1.MxgNrYxb.js +0 -1
  100. package/build/client/_app/immutable/nodes/1.MxgNrYxb.js.br +0 -0
  101. package/build/client/_app/immutable/nodes/1.MxgNrYxb.js.gz +0 -0
  102. package/build/client/_app/immutable/nodes/2.DOLqBxXu.js +0 -2
  103. package/build/client/_app/immutable/nodes/2.DOLqBxXu.js.br +0 -0
  104. package/build/client/_app/immutable/nodes/2.DOLqBxXu.js.gz +0 -0
  105. package/build/env.js +0 -70
  106. package/build/server/chunks/chunks/client.js-9ZtqvVP6.js +0 -28
  107. package/build/server/chunks/chunks/env.js-l0sNRNKZ.js +0 -2
  108. package/build/server/chunks/chunks/exports.js-Bbyr-JtB.js +0 -349
  109. package/build/server/chunks/chunks/internal.js-WGl35QnN.js +0 -1202
  110. package/build/server/chunks/chunks/internal2.js-BlXt2rfE.js +0 -22
  111. package/build/server/chunks/chunks/server.js-UOanU7fq.js +0 -5527
  112. package/build/server/chunks/chunks/shared.js-Dg3Ewm8t.js +0 -255
  113. package/build/server/chunks/chunks/utils.js-DUDFXVFd.js +0 -1049
  114. package/build/server/chunks/entries/endpoints/api/refresh/_server.ts.js-CcG44vTx.js +0 -21
  115. package/build/server/chunks/entries/endpoints/api/settings/_server.ts.js-B0LWCQis.js +0 -24
  116. package/build/server/chunks/entries/endpoints/api/usage/_server.ts.js-CJGTdjik.js +0 -17
  117. package/build/server/chunks/entries/fallbacks/error.svelte.js-D7UgI0q0.js +0 -68
  118. package/build/server/chunks/entries/hooks.server.js-_Fcw_IVA.js +0 -16
  119. package/build/server/chunks/entries/pages/_page.server.ts.js-BBibcAZP.js +0 -17
  120. package/build/server/chunks/handler-TvIKu86j.js +0 -1475
  121. package/build/server/chunks/index.js-C3LwYUKO.js +0 -3972
  122. package/build/server/chunks/manifest.js-CZoz0xLc.js +0 -63
  123. package/build/server/chunks/nodes/0.js-7EReDAeT.js +0 -9
  124. package/build/server/chunks/nodes/1.js-BcW8BjKg.js +0 -9
  125. package/build/server/chunks/nodes/2.js-fS9KDy-5.js +0 -20
  126. package/build/shims.js +0 -33
@@ -0,0 +1,3323 @@
1
+ import { a as SvelteKitError, i as Redirect, n as HandledHttpError, o as ValidationError, r as HttpError, t as ActionFailure } from "./shared.js";
2
+ import { W as request_store_after_await, X as url_search_unavailable_prerender, Z as capture_error, h as handle_error_hook_failed, i as action_response_not_serializable, n as action_default_with_named, r as action_name_reserved, s as action_throw_fail, t as action_data_not_serializable, v as load_not_plain_object, y as load_not_serializable } from "./server-errors.js";
3
+ import { a as is_buffer, c as is_valid_array_len, d as valid_array_indices, f as MAX_ARRAY_INDEX, i as get_type, l as stringify_key, n as DevalueError, o as is_plain_object$1, r as enumerable_symbols, s as is_valid_array_index, t as uneval$1, u as stringify_string } from "./uneval.js";
4
+ import { n as noop } from "./functions.js";
5
+ //#region node_modules/@sveltejs/kit/src/messages/internal/shared.js
6
+ /**
7
+ * Whether shared errors include their full text on the server even though `DEV` is false. This is
8
+ * enabled while the app is being built (analysed or prerendered)
9
+ */
10
+ var verbose = false;
11
+ function enable_verbose_errors() {
12
+ verbose = true;
13
+ }
14
+ /**
15
+ * Throws the full diagnostic. Generated helpers throw their URL-only production error inline, so
16
+ * bundlers can remove both this call and the message text from production browser builds
17
+ * @param {string} code
18
+ * @param {string} message
19
+ * @param {Function} caller The generated helper, which is omitted from the stack along with this function
20
+ * @returns {never}
21
+ */
22
+ function throw_error(code, message, caller) {
23
+ const error = /* @__PURE__ */ new Error(`${code}\n${message}\nhttps://svelte.dev/e/kit/${code}`);
24
+ error.name = "SvelteKit error";
25
+ Error.captureStackTrace?.(error, caller);
26
+ throw error;
27
+ }
28
+ var assets = "";
29
+ var app_dir = "_app";
30
+ /** @param {string} path */
31
+ function set_assets(path) {
32
+ assets = path;
33
+ }
34
+ //#endregion
35
+ //#region node_modules/@sveltejs/kit/src/runtime/server/dev.js
36
+ var symbol = Symbol.for("sveltekit.global_state");
37
+ globalThis[symbol] ??= {};
38
+ //#endregion
39
+ //#region node_modules/@sveltejs/kit/src/runtime/utils.js
40
+ var text_encoder$1 = new TextEncoder();
41
+ /**
42
+ * `ReadableStream.from`, for runtimes that don't support it (as of writing, every Bun release)
43
+ * @template T
44
+ * @param {AsyncIterable<T>} iterable
45
+ * @returns {ReadableStream<T>}
46
+ */
47
+ function stream_from_iterable(iterable) {
48
+ if (ReadableStream.from) return ReadableStream.from(iterable);
49
+ const iterator = iterable[Symbol.asyncIterator]();
50
+ return new ReadableStream({
51
+ async pull(controller) {
52
+ const { value, done } = await iterator.next();
53
+ if (done) controller.close();
54
+ else controller.enqueue(value);
55
+ },
56
+ async cancel(reason) {
57
+ await iterator.return?.(reason);
58
+ }
59
+ });
60
+ }
61
+ /**
62
+ * @param {string} head
63
+ * @param {AsyncIterable<string>} chunks
64
+ * @returns {ReadableStream<Uint8Array>} `head` followed by each non-empty chunk, encoded
65
+ */
66
+ function stream_text(head, chunks) {
67
+ return stream_from_iterable((async function* () {
68
+ yield text_encoder$1.encode(head);
69
+ for await (const chunk of chunks) if (chunk) yield text_encoder$1.encode(chunk);
70
+ })());
71
+ }
72
+ var text_decoder = new TextDecoder();
73
+ /**
74
+ * @param {Uint8Array} bytes
75
+ * @returns {string}
76
+ */
77
+ function base64_encode(bytes) {
78
+ if (globalThis.Buffer) return globalThis.Buffer.from(bytes).toString("base64");
79
+ let binary = "";
80
+ for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
81
+ return btoa(binary);
82
+ }
83
+ /**
84
+ * @param {string} encoded
85
+ * @returns {Uint8Array}
86
+ */
87
+ function base64_decode(encoded) {
88
+ if (globalThis.Buffer) {
89
+ const buffer = globalThis.Buffer.from(encoded, "base64");
90
+ return new Uint8Array(buffer);
91
+ }
92
+ const binary = atob(encoded);
93
+ const bytes = new Uint8Array(binary.length);
94
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
95
+ return bytes;
96
+ }
97
+ //#endregion
98
+ //#region node_modules/@sveltejs/kit/src/pathname.js
99
+ var DATA_SUFFIX = "/__data.json";
100
+ var HTML_DATA_SUFFIX = ".html__data.json";
101
+ /** @param {string} pathname */
102
+ function has_data_suffix(pathname) {
103
+ return pathname.endsWith(DATA_SUFFIX) || pathname.endsWith(HTML_DATA_SUFFIX);
104
+ }
105
+ /** @param {string} pathname */
106
+ function add_data_suffix(pathname) {
107
+ if (pathname.endsWith(".html")) return pathname.replace(/\.html$/, HTML_DATA_SUFFIX);
108
+ return pathname.replace(/\/$/, "") + DATA_SUFFIX;
109
+ }
110
+ /** @param {string} pathname */
111
+ function strip_data_suffix(pathname) {
112
+ if (pathname.endsWith(HTML_DATA_SUFFIX)) return pathname.slice(0, -16) + ".html";
113
+ return pathname.slice(0, -12);
114
+ }
115
+ var ROUTE_SUFFIX = "/__route.js";
116
+ var HTML_ROUTE_SUFFIX = ".html__route.js";
117
+ /**
118
+ * @param {string} pathname
119
+ * @returns {boolean}
120
+ */
121
+ function has_resolution_suffix(pathname) {
122
+ return pathname.endsWith(ROUTE_SUFFIX) || pathname.endsWith(HTML_ROUTE_SUFFIX);
123
+ }
124
+ /**
125
+ * Convert a regular URL to a route to send to SvelteKit's server-side route resolution endpoint
126
+ * @param {string} pathname
127
+ * @returns {string}
128
+ */
129
+ function add_resolution_suffix(pathname) {
130
+ if (pathname.endsWith(".html")) return pathname.replace(/\.html$/, HTML_ROUTE_SUFFIX);
131
+ return pathname.replace(/\/$/, "") + ROUTE_SUFFIX;
132
+ }
133
+ /**
134
+ * @param {string} pathname
135
+ * @returns {string}
136
+ */
137
+ function strip_resolution_suffix(pathname) {
138
+ if (pathname.endsWith(HTML_ROUTE_SUFFIX)) return pathname.slice(0, -15) + ".html";
139
+ return pathname.slice(0, -11);
140
+ }
141
+ //#endregion
142
+ //#region node_modules/@sveltejs/kit/src/constants.js
143
+ /**
144
+ * A fake asset path used in `vite dev` and `vite preview`, so that we can
145
+ * serve local assets while verifying that requests are correctly prefixed
146
+ */
147
+ var SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
148
+ var ENDPOINT_METHODS = [
149
+ "GET",
150
+ "POST",
151
+ "PUT",
152
+ "PATCH",
153
+ "DELETE",
154
+ "OPTIONS",
155
+ "HEAD",
156
+ "QUERY"
157
+ ];
158
+ var MUTATIVE_METHODS = [
159
+ "POST",
160
+ "PUT",
161
+ "PATCH",
162
+ "DELETE"
163
+ ];
164
+ /** methods whose responses depend on the request body, so they can never be prerendered */
165
+ var BODY_DEPENDENT_METHODS = [...MUTATIVE_METHODS, "QUERY"];
166
+ var PAGE_METHODS = [
167
+ "GET",
168
+ "POST",
169
+ "HEAD"
170
+ ];
171
+ import.meta.dirname;
172
+ var IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;
173
+ /**
174
+ * If an an adapter deploys a catch-all serverless function, the rerouted URL
175
+ * is stored in this header.
176
+ */
177
+ var REROUTED_URL_HEADER = "x-sveltekit-rerouted-url";
178
+ //#endregion
179
+ //#region node_modules/@sveltejs/kit/src/exports/internal/server/event.js
180
+ /** @import { RequestEvent } from '@sveltejs/kit' */
181
+ /** @import { RequestStore } from 'types' */
182
+ /** @import { AsyncLocalStorage } from 'node:async_hooks' */
183
+ /** @type {RequestStore | null} */
184
+ var sync_store = null;
185
+ /** @type {AsyncLocalStorage<RequestStore | null> | null} */
186
+ var als;
187
+ import("node:async_hooks").then((hooks) => als = new hooks.AsyncLocalStorage()).catch(() => {});
188
+ function get_request_store() {
189
+ const result = try_get_request_store();
190
+ if (!result) {
191
+ if (als) throw new Error("Could not get the request store. This is an internal error.");
192
+ request_store_after_await();
193
+ }
194
+ return result;
195
+ }
196
+ function try_get_request_store() {
197
+ return sync_store ?? als?.getStore() ?? null;
198
+ }
199
+ /**
200
+ * @template T
201
+ * @param {RequestStore | null} store
202
+ * @param {() => T} fn
203
+ */
204
+ function with_request_store(store, fn) {
205
+ try {
206
+ sync_store = store;
207
+ return als ? als.run(store, fn) : fn();
208
+ } finally {
209
+ if (!IN_WEBCONTAINER) sync_store = null;
210
+ }
211
+ }
212
+ //#endregion
213
+ //#region node_modules/@sveltejs/kit/src/telemetry.js
214
+ /** @import { Span, SpanContext } from '@opentelemetry/api' */
215
+ /**
216
+ * @type {Span}
217
+ */
218
+ var noop_span = {
219
+ spanContext() {
220
+ return noop_span_context;
221
+ },
222
+ setAttribute() {
223
+ return this;
224
+ },
225
+ setAttributes() {
226
+ return this;
227
+ },
228
+ addEvent() {
229
+ return this;
230
+ },
231
+ setStatus() {
232
+ return this;
233
+ },
234
+ updateName() {
235
+ return this;
236
+ },
237
+ end() {
238
+ return this;
239
+ },
240
+ isRecording() {
241
+ return false;
242
+ },
243
+ recordException() {
244
+ return this;
245
+ },
246
+ addLink() {
247
+ return this;
248
+ },
249
+ addLinks() {
250
+ return this;
251
+ }
252
+ };
253
+ /**
254
+ * @type {SpanContext}
255
+ */
256
+ var noop_span_context = {
257
+ traceId: "",
258
+ spanId: "",
259
+ traceFlags: 0
260
+ };
261
+ //#endregion
262
+ //#region node_modules/@sveltejs/kit/src/exports/internal/server/telemetry.js
263
+ /** @import { Tracer, SpanStatusCode, PropagationAPI, ContextAPI } from '@opentelemetry/api' */
264
+ /** @import { RecordSpan } from 'types' */
265
+ /** @type {Promise<{ tracer: Tracer, SpanStatusCode: typeof SpanStatusCode, propagation: PropagationAPI, context: ContextAPI }> | null} */
266
+ var otel = null;
267
+ /** @type {RecordSpan} */
268
+ async function record_span({ name, attributes, fn }) {
269
+ if (otel === null) return fn(noop_span);
270
+ const { SpanStatusCode, tracer } = await otel;
271
+ return tracer.startActiveSpan(name, { attributes }, async (span) => {
272
+ try {
273
+ return await fn(span);
274
+ } catch (error) {
275
+ if (error instanceof HttpError) {
276
+ span.setAttributes({
277
+ [`${name}.result.type`]: "known_error",
278
+ [`${name}.result.status`]: error.status,
279
+ [`${name}.result.message`]: error.body.message
280
+ });
281
+ if (error.status >= 500) {
282
+ span.recordException({
283
+ name: "HttpError",
284
+ message: error.body.message
285
+ });
286
+ span.setStatus({
287
+ code: SpanStatusCode.ERROR,
288
+ message: error.body.message
289
+ });
290
+ }
291
+ } else if (error instanceof Redirect) span.setAttributes({
292
+ [`${name}.result.type`]: "redirect",
293
+ [`${name}.result.status`]: error.status,
294
+ [`${name}.result.location`]: error.location
295
+ });
296
+ else if (error instanceof Error) {
297
+ span.setAttributes({ [`${name}.result.type`]: "unknown_error" });
298
+ span.recordException({
299
+ name: error.name,
300
+ message: error.message,
301
+ ...error.stack !== void 0 && { stack: error.stack }
302
+ });
303
+ span.setStatus({
304
+ code: SpanStatusCode.ERROR,
305
+ message: error.message
306
+ });
307
+ } else {
308
+ span.setAttributes({ [`${name}.result.type`]: "unknown_error" });
309
+ span.setStatus({ code: SpanStatusCode.ERROR });
310
+ }
311
+ throw error;
312
+ } finally {
313
+ span.end();
314
+ }
315
+ });
316
+ }
317
+ //#endregion
318
+ //#region node_modules/@sveltejs/kit/src/exports/internal/server/index.js
319
+ /**
320
+ * @template {{ tracing: { enabled: boolean, root: Span, current: Span } }} T
321
+ * @param {T} event_like
322
+ * @param {Span} current
323
+ * @returns {T}
324
+ */
325
+ function merge_tracing(event_like, current) {
326
+ return {
327
+ ...event_like,
328
+ tracing: {
329
+ ...event_like.tracing,
330
+ current
331
+ }
332
+ };
333
+ }
334
+ //#endregion
335
+ //#region node_modules/@sveltejs/kit/src/messages/shared-errors.js
336
+ /**
337
+ * Invalid array key `%key%`
338
+ * @param {{ "key": string }} _values
339
+ * @returns {never}
340
+ */
341
+ function form_field_array_conflict(_values) {
342
+ if (verbose) throw_error("form_field_array_conflict", `Invalid array key \`${_values.key}\``, form_field_array_conflict);
343
+ throw new Error("https://svelte.dev/e/kit/form_field_array_conflict");
344
+ }
345
+ /**
346
+ * Form cannot contain duplicated keys — `%name%` has %count% values
347
+ * @param {{ "name": string; "count": string }} _values
348
+ * @returns {never}
349
+ */
350
+ function form_field_duplicate(_values) {
351
+ if (verbose) throw_error("form_field_duplicate", `Form cannot contain duplicated keys — \`${_values.name}\` has ${_values.count} values`, form_field_duplicate);
352
+ throw new Error("https://svelte.dev/e/kit/form_field_duplicate");
353
+ }
354
+ /**
355
+ * Invalid key `%key%`: This key is not allowed to prevent prototype pollution.
356
+ * @param {{ "key": string }} _values
357
+ * @returns {never}
358
+ */
359
+ function form_field_forbidden_key(_values) {
360
+ if (verbose) throw_error("form_field_forbidden_key", `Invalid key \`${_values.key}\`: This key is not allowed to prevent prototype pollution.`, form_field_forbidden_key);
361
+ throw new Error("https://svelte.dev/e/kit/form_field_forbidden_key");
362
+ }
363
+ /**
364
+ * Invalid field name `%name%`: field names are written in JS object notation, so keys that would need quoting are not supported. See https://svelte.dev/docs/kit/remote-functions#form-Fields
365
+ * @param {{ "name": string }} _values
366
+ * @returns {never}
367
+ */
368
+ function form_field_invalid_name(_values) {
369
+ if (verbose) throw_error("form_field_invalid_name", `Invalid field name \`${_values.name}\`: field names are written in JS object notation, so keys that would need quoting are not supported. See https://svelte.dev/docs/kit/remote-functions#form-Fields`, form_field_invalid_name);
370
+ throw new Error("https://svelte.dev/e/kit/form_field_invalid_name");
371
+ }
372
+ /**
373
+ * Form contained a field that wasn't created with `form.fields.as(...)`: `%name%`
374
+ * @param {{ "name": string }} _values
375
+ * @returns {never}
376
+ */
377
+ function form_field_unbound(_values) {
378
+ if (verbose) throw_error("form_field_unbound", `Form contained a field that wasn't created with \`form.fields.as(...)\`: \`${_values.name}\``, form_field_unbound);
379
+ throw new Error("https://svelte.dev/e/kit/form_field_unbound");
380
+ }
381
+ /**
382
+ * HTTP error status codes must be between 400 and 599 — %status% is invalid
383
+ * @param {{ "status": string }} _values
384
+ * @returns {never}
385
+ */
386
+ function invalid_error_status(_values) {
387
+ if (verbose) throw_error("invalid_error_status", `HTTP error status codes must be between 400 and 599 — ${_values.status} is invalid`, invalid_error_status);
388
+ throw new Error("https://svelte.dev/e/kit/invalid_error_status");
389
+ }
390
+ /**
391
+ * Invalid export `%key%` (valid exports are %exports%, or anything with a `'_'` prefix)
392
+ * @param {{ "key": string; "exports": string; "file"?: string }} _values
393
+ * @returns {never}
394
+ */
395
+ function invalid_export(_values) {
396
+ if (verbose) throw_error("invalid_export", _values?.file !== void 0 ? `Invalid export \`${_values.key}\` in \`${_values.file}\` (valid exports are ${_values.exports}, or anything with a \`'_'\` prefix)` : `Invalid export \`${_values.key}\` (valid exports are ${_values.exports}, or anything with a \`'_'\` prefix)`, invalid_export);
397
+ throw new Error("https://svelte.dev/e/kit/invalid_export");
398
+ }
399
+ /**
400
+ * Invalid export `%key%` (`%key%` is a valid export in %locations%)
401
+ * @param {{ "key": string; "locations": string; "file"?: string }} _values
402
+ * @returns {never}
403
+ */
404
+ function invalid_export_location(_values) {
405
+ if (verbose) throw_error("invalid_export_location", _values?.file !== void 0 ? `Invalid export \`${_values.key}\` in \`${_values.file}\` (\`${_values.key}\` is a valid export in ${_values.locations})` : `Invalid export \`${_values.key}\` (\`${_values.key}\` is a valid export in ${_values.locations})`, invalid_export_location);
406
+ throw new Error("https://svelte.dev/e/kit/invalid_export_location");
407
+ }
408
+ /**
409
+ * a `load` function %location% returned %type%, but must return a plain object at the top level (i.e. `return {...}`)
410
+ * @param {{ "location": string; "type": string }} _values
411
+ * @returns {never}
412
+ */
413
+ function load_invalid_response(_values) {
414
+ if (verbose) throw_error("load_invalid_response", `a \`load\` function ${_values.location} returned ${_values.type}, but must return a plain object at the top level (i.e. \`return {...}\`)`, load_invalid_response);
415
+ throw new Error("https://svelte.dev/e/kit/load_invalid_response");
416
+ }
417
+ /**
418
+ * Async param matchers are not supported
419
+ * @param {void} _values
420
+ * @returns {never}
421
+ */
422
+ function param_matcher_async(_values) {
423
+ if (verbose) throw_error("param_matcher_async", `Async param matchers are not supported`, param_matcher_async);
424
+ throw new Error("https://svelte.dev/e/kit/param_matcher_async");
425
+ }
426
+ /**
427
+ * Param matcher must return a string, number, boolean, or bigint
428
+ * @param {void} _values
429
+ * @returns {never}
430
+ */
431
+ function param_matcher_result_invalid(_values) {
432
+ if (verbose) throw_error("param_matcher_result_invalid", `Param matcher must return a string, number, boolean, or bigint`, param_matcher_result_invalid);
433
+ throw new Error("https://svelte.dev/e/kit/param_matcher_result_invalid");
434
+ }
435
+ /**
436
+ * %type% are not valid remote function arguments
437
+ * @param {{ "type": string }} _values
438
+ * @returns {never}
439
+ */
440
+ function remote_argument_unsupported(_values) {
441
+ if (verbose) throw_error("remote_argument_unsupported", `${_values.type} are not valid remote function arguments`, remote_argument_unsupported);
442
+ throw new Error("https://svelte.dev/e/kit/remote_argument_unsupported");
443
+ }
444
+ /**
445
+ * Cannot access `event.url.hash`. Consider using `page.url.hash` inside a component instead
446
+ * @param {void} _values
447
+ * @returns {never}
448
+ */
449
+ function url_hash_unavailable(_values) {
450
+ if (verbose) throw_error("url_hash_unavailable", `Cannot access \`event.url.hash\`. Consider using \`page.url.hash\` inside a component instead`, url_hash_unavailable);
451
+ throw new Error("https://svelte.dev/e/kit/url_hash_unavailable");
452
+ }
453
+ //#endregion
454
+ //#region node_modules/@sveltejs/kit/src/utils/url.js
455
+ /**
456
+ * Matches a URI scheme. See https://www.rfc-editor.org/rfc/rfc3986#section-3.1
457
+ * @type {RegExp}
458
+ */
459
+ var SCHEME = /^[a-z][a-z\d+\-.]*:/i;
460
+ var internal = new URL("a://");
461
+ /**
462
+ * @param {string} base
463
+ * @param {string} path
464
+ */
465
+ function resolve(base, path) {
466
+ if (path[0] === "/" && path[1] === "/") return path;
467
+ let url = new URL(base, internal);
468
+ url = new URL(path, url);
469
+ return url.protocol === internal.protocol ? url.pathname + url.search + url.hash : url.href;
470
+ }
471
+ /**
472
+ * Relative reference from `from` to `to`, which must differ only by a trailing slash
473
+ * @param {string} from
474
+ * @param {string} to
475
+ * @returns {string}
476
+ */
477
+ function relative_pathname(from, to) {
478
+ const segment = to.replace(/\/$/, "").split("/").at(-1);
479
+ return from.endsWith("/") ? `../${segment}` : `./${segment}/`;
480
+ }
481
+ /**
482
+ * @param {string} path
483
+ * @param {import('types').TrailingSlash} trailing_slash
484
+ */
485
+ function normalize_path(path, trailing_slash) {
486
+ if (path === "/" || trailing_slash === "ignore") return path;
487
+ if (trailing_slash === "never") return path.endsWith("/") ? path.slice(0, -1) : path;
488
+ else if (trailing_slash === "always" && !path.endsWith("/")) return path + "/";
489
+ return path;
490
+ }
491
+ /**
492
+ * Decode pathname excluding %25 to prevent further double decoding of params
493
+ * @param {string} pathname
494
+ */
495
+ function decode_pathname(pathname) {
496
+ return pathname.split("%25").map(decodeURI).join("%25");
497
+ }
498
+ /**
499
+ * @param {URL} url
500
+ * @param {() => void} callback
501
+ * @param {(search_param: string) => void} search_params_callback
502
+ * @param {boolean} [allow_hash]
503
+ */
504
+ function make_trackable(url, callback, search_params_callback, allow_hash = false) {
505
+ const tracked = new URL(url);
506
+ Object.defineProperty(tracked, "searchParams", {
507
+ value: new Proxy(tracked.searchParams, { get(obj, key) {
508
+ if (key === "get" || key === "getAll" || key === "has") return (param, ...rest) => {
509
+ search_params_callback(param);
510
+ return obj[key](param, ...rest);
511
+ };
512
+ callback();
513
+ const value = Reflect.get(obj, key);
514
+ return typeof value === "function" ? value.bind(obj) : value;
515
+ } }),
516
+ enumerable: true,
517
+ configurable: true
518
+ });
519
+ /**
520
+ * URL properties that could change during the lifetime of the page,
521
+ * which excludes things like `origin`
522
+ * @type {(keyof URL)[]}
523
+ */
524
+ const tracked_url_properties = [
525
+ "href",
526
+ "pathname",
527
+ "search",
528
+ "toString",
529
+ "toJSON"
530
+ ];
531
+ if (allow_hash) tracked_url_properties.push("hash");
532
+ for (const property of tracked_url_properties) Object.defineProperty(tracked, property, {
533
+ get() {
534
+ callback();
535
+ return url[property];
536
+ },
537
+ enumerable: true,
538
+ configurable: true
539
+ });
540
+ tracked[Symbol.for("nodejs.util.inspect.custom")] = (_depth, opts, inspect) => {
541
+ return inspect(url, opts);
542
+ };
543
+ tracked.searchParams[Symbol.for("nodejs.util.inspect.custom")] = (_depth, opts, inspect) => {
544
+ return inspect(url.searchParams, opts);
545
+ };
546
+ if (!allow_hash) disable_hash(tracked);
547
+ return tracked;
548
+ }
549
+ /**
550
+ * Disallow access to `url.hash` on the server and in `load`
551
+ * @param {URL} url
552
+ */
553
+ function disable_hash(url) {
554
+ allow_nodejs_console_log(url);
555
+ Object.defineProperty(url, "hash", { get() {
556
+ return url_hash_unavailable();
557
+ } });
558
+ }
559
+ /**
560
+ * Disallow access to `url.search` and `url.searchParams` during prerendering
561
+ * @param {URL} url
562
+ */
563
+ function disable_search(url) {
564
+ allow_nodejs_console_log(url);
565
+ for (const property of ["search", "searchParams"]) Object.defineProperty(url, property, { get() {
566
+ return url_search_unavailable_prerender({ property });
567
+ } });
568
+ }
569
+ /**
570
+ * Allow URL to be console logged, bypassing disabled properties.
571
+ * @param {URL} url
572
+ */
573
+ function allow_nodejs_console_log(url) {
574
+ url[Symbol.for("nodejs.util.inspect.custom")] = (_depth, opts, inspect) => {
575
+ return inspect(new URL(url), opts);
576
+ };
577
+ }
578
+ //#endregion
579
+ //#region node_modules/@sveltejs/kit/src/messages/shared-warnings.js
580
+ /**
581
+ * `%route%`: Calling `depends('%dependency%')` will throw an error in Firefox because `%scheme%` is a special URI scheme
582
+ * @param {{ "route": string; "dependency": string; "scheme": string }} _values
583
+ */
584
+ function depends_special_scheme(_values) {
585
+ console.warn("https://svelte.dev/e/kit/depends_special_scheme");
586
+ }
587
+ //#endregion
588
+ //#region node_modules/@sveltejs/kit/src/exports/index.js
589
+ /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
590
+ var text_encoder = new TextEncoder();
591
+ /**
592
+ * Throws an error with a HTTP status code and an optional message.
593
+ * When called during request handling, this will cause SvelteKit to
594
+ * return an error response; the error will be passed to `handleError` as an _expected_ error.
595
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
596
+ * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
597
+ * @param {string} [message] The error message.
598
+ * @overload
599
+ * @param {{ status: number; message: string } extends App.Error ? number : never} status
600
+ * @param {{ status: number; message: string } extends App.Error ? string : never} [message]
601
+ * @return {never}
602
+ * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
603
+ * @throws {Error} If the provided status is invalid (not between 400 and 599).
604
+ */
605
+ /**
606
+ * Throws an error with a HTTP status code and an optional message.
607
+ * When called during request handling, this will cause SvelteKit to
608
+ * return an error response; the error will be passed to `handleError` as an _expected_ error.
609
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
610
+ * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
611
+ * @param {string} message The error message.
612
+ * @param {keyof Omit<App.Error, 'status' | 'message'> extends never ? never : Omit<App.Error, 'status' | 'message'>} properties Additional properties of the App.Error type.
613
+ * @overload
614
+ * @param {number} status
615
+ * @param {string} message
616
+ * @param {keyof Omit<App.Error, 'status' | 'message'> extends never ? never : Omit<App.Error, 'status' | 'message'>} properties
617
+ * @return {never}
618
+ * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
619
+ * @throws {Error} If the provided status is invalid (not between 400 and 599).
620
+ */
621
+ /**
622
+ * Throws an error with a HTTP status code and an optional message.
623
+ * When called during request handling, this will cause SvelteKit to
624
+ * return an error response; the error will be passed to `handleError` as an _expected_ error.
625
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
626
+ * @deprecated Passing an `App.Error` body as the second argument is deprecated — pass the `message` as the second argument, and any additional properties as the third
627
+ * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
628
+ * @param {Omit<App.Error, 'status'> & { status?: App.Error['status'] }} body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
629
+ * @overload
630
+ * @param {number} status
631
+ * @param {Omit<App.Error, 'status'> & { status?: App.Error['status'] }} properties
632
+ * @return {never}
633
+ * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
634
+ * @throws {Error} If the provided status is invalid (not between 400 and 599).
635
+ */
636
+ /**
637
+ * Throws an error with a HTTP status code and an optional message.
638
+ * When called during request handling, this will cause SvelteKit to
639
+ * return an error response; the error will be passed to `handleError` as an _expected_ error.
640
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
641
+ * @param {any} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
642
+ * @param {any} [message] A string, or (deprecated) a partial App.Error object
643
+ * @param {any} [properties] Additional properties of the App.Error type when passing a string message.
644
+ * @return {never}
645
+ * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
646
+ * @throws {Error} If the provided status is invalid (not between 400 and 599).
647
+ */
648
+ function error(status, message, properties) {
649
+ if (isNaN(status) || status < 400 || status > 599) invalid_error_status({ status: String(status) });
650
+ if (message !== void 0 && typeof message !== "string") ({message, ...properties} = message);
651
+ throw new HttpError({
652
+ ...properties,
653
+ status,
654
+ message: message ?? `Error: ${status}`
655
+ });
656
+ }
657
+ /**
658
+ * Checks whether this is a redirect thrown by {@link redirect}.
659
+ * @param {unknown} e The object to check.
660
+ * @return {e is import('./public.js').Redirect}
661
+ */
662
+ function isRedirect(e) {
663
+ return e instanceof Redirect;
664
+ }
665
+ /**
666
+ * Create a `Response` object from the supplied body.
667
+ * @param {string} body The value that will be used as-is.
668
+ * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically.
669
+ * @deprecated use `new Response`
670
+ */
671
+ function text(body, init) {
672
+ const headers = new Headers(init?.headers);
673
+ if (!headers.has("content-length")) {
674
+ const encoded = text_encoder.encode(body);
675
+ headers.set("content-length", encoded.byteLength.toString());
676
+ return new Response(encoded, {
677
+ ...init,
678
+ headers
679
+ });
680
+ }
681
+ return new Response(body, {
682
+ ...init,
683
+ headers
684
+ });
685
+ }
686
+ //#endregion
687
+ //#region node_modules/@sveltejs/kit/src/utils/routing.js
688
+ /** @import { ParamMatcher, ParamValue } from '@sveltejs/kit/params' */
689
+ var escape_sequence_pattern = /\[([ux])\+([^\]]+)\]/;
690
+ /**
691
+ * @param {ParamMatcher} matcher
692
+ * @param {string} value
693
+ * @returns {{ success: true, value: any } | { success: false }}
694
+ */
695
+ function run_matcher(matcher, value) {
696
+ const result = matcher["~standard"].validate(value);
697
+ if (result instanceof Promise) param_matcher_async();
698
+ if (result.issues) return { success: false };
699
+ const parsed = result.value;
700
+ if (typeof parsed !== "string" && typeof parsed !== "number" && typeof parsed !== "boolean" && typeof parsed !== "bigint") param_matcher_result_invalid();
701
+ return {
702
+ success: true,
703
+ value: parsed
704
+ };
705
+ }
706
+ /**
707
+ * @param {RegExpMatchArray} match
708
+ * @param {import('types').RouteParam[]} params
709
+ * @param {Record<string, ParamMatcher>} matchers
710
+ */
711
+ function exec(match, params, matchers) {
712
+ /** @type {Record<string, any>} */
713
+ const result = {};
714
+ const values = match.slice(1);
715
+ const values_needing_match = values.filter((value) => value !== void 0);
716
+ let buffered = 0;
717
+ for (let i = 0; i < params.length; i += 1) {
718
+ const param = params[i];
719
+ let value = values[i - buffered];
720
+ if (param.chained && param.rest && buffered) {
721
+ value = values.slice(i - buffered, i + 1).filter((s) => s).join("/");
722
+ buffered = 0;
723
+ }
724
+ if (value === void 0) {
725
+ if (param.rest) value = "";
726
+ else continue;
727
+ }
728
+ const decoded = decodeURIComponent(value);
729
+ if (param.matcher) {
730
+ const outcome = run_matcher(matchers[param.matcher], decoded);
731
+ if (!outcome.success) {
732
+ if (param.optional && param.chained) {
733
+ buffered++;
734
+ continue;
735
+ }
736
+ return;
737
+ }
738
+ result[param.name] = outcome.value;
739
+ } else result[param.name] = decoded;
740
+ const next_param = params[i + 1];
741
+ const next_value = values[i + 1];
742
+ if (next_param && !next_param.rest && next_param.optional && next_value && param.chained) buffered = 0;
743
+ if (!next_param && !next_value && Object.keys(result).length === values_needing_match.length) buffered = 0;
744
+ }
745
+ if (buffered) return;
746
+ return result;
747
+ }
748
+ new RegExp(`${escape_sequence_pattern.source}|${/\[(\[)?(\.\.\.)?([\w-]+?)(?:=([\w-]+))?\]\]?/g.source}`, "g");
749
+ /**
750
+ * Find the first route that matches the given path
751
+ * @template {{pattern: RegExp, params: import('types').RouteParam[]}} Route
752
+ * @param {string} path - The decoded pathname to match
753
+ * @param {Route[]} routes
754
+ * @param {Record<string, ParamMatcher>} matchers
755
+ * @returns {{ route: Route, params: Record<string, any> } | null}
756
+ */
757
+ function find_route(path, routes, matchers) {
758
+ for (const route of routes) {
759
+ const match = route.pattern.exec(path);
760
+ if (!match) continue;
761
+ const matched = exec(match, route.params, matchers);
762
+ if (matched) return {
763
+ route,
764
+ params: matched
765
+ };
766
+ }
767
+ return null;
768
+ }
769
+ //#endregion
770
+ //#region .svelte-kit/generated/build/shared/error-template.js
771
+ var error_template_default = ({ status, message }) => "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>" + message + "</title>\n\n <style>\n body {\n --bg: white;\n --fg: #222;\n --divider: #ccc;\n background: var(--bg);\n color: var(--fg);\n font-family:\n system-ui,\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n Oxygen,\n Ubuntu,\n Cantarell,\n 'Open Sans',\n 'Helvetica Neue',\n sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100vh;\n margin: 0;\n }\n\n .error {\n display: flex;\n align-items: center;\n max-width: 32rem;\n margin: 0 1rem;\n }\n\n .status {\n font-weight: 200;\n font-size: 3rem;\n line-height: 1;\n position: relative;\n top: -0.05rem;\n }\n\n .message {\n border-left: 1px solid var(--divider);\n padding: 0 0 0 1rem;\n margin: 0 0 0 1rem;\n min-height: 2.5rem;\n display: flex;\n align-items: center;\n }\n\n .message h1 {\n font-weight: 400;\n font-size: 1em;\n margin: 0;\n }\n\n @media (prefers-color-scheme: dark) {\n body {\n --bg: #222;\n --fg: #ddd;\n --divider: #666;\n }\n }\n </style>\n </head>\n <body>\n <div class=\"error\">\n <span class=\"status\">" + status + "</span>\n <div class=\"message\">\n <h1>" + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n";
772
+ //#endregion
773
+ //#region .svelte-kit/generated/build/server.js
774
+ var options = {
775
+ app_template_contains_nonce: false,
776
+ csp: {
777
+ "mode": "auto",
778
+ "directives": {
779
+ "upgrade-insecure-requests": false,
780
+ "block-all-mixed-content": false
781
+ },
782
+ "reportOnly": {
783
+ "upgrade-insecure-requests": false,
784
+ "block-all-mixed-content": false
785
+ }
786
+ },
787
+ csrf_trusted_origins: [],
788
+ service_worker_options: void 0,
789
+ templates: {
790
+ app: ({ head, body, assets, nonce, env }) => "<!doctype html>\n<html lang=\"en\" data-theme=\"%aiusage.theme%\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <meta name=\"color-scheme\" content=\"light dark\" />\n <meta\n name=\"description\"\n content=\"Every token your AI coding tools have spent, from the transcripts already on your machine.\"\n />\n <meta name=\"robots\" content=\"noindex\" />\n <link rel=\"icon\" href=\"" + assets + "/favicon.svg\" type=\"image/svg+xml\" />\n " + head + "\n </head>\n <body data-sveltekit-preload-data=\"hover\">\n <div style=\"display: contents\">" + body + "</div>\n </body>\n</html>\n",
791
+ error: error_template_default
792
+ }
793
+ };
794
+ async function get_hooks() {
795
+ let handle;
796
+ let handleFetch;
797
+ let handleError;
798
+ let init;
799
+ ({handle, handleFetch, handleError, init} = await import("../entries/hooks.server.js"));
800
+ let reroute;
801
+ let transport;
802
+ return {
803
+ handle,
804
+ handleFetch,
805
+ handleError,
806
+ init,
807
+ reroute,
808
+ transport
809
+ };
810
+ }
811
+ //#endregion
812
+ //#region node_modules/devalue/src/base64.js
813
+ /** @type {(array_buffer: ArrayBuffer) => string} */
814
+ function encode_native(array_buffer) {
815
+ return new Uint8Array(array_buffer).toBase64();
816
+ }
817
+ /** @type {(base64: string) => ArrayBuffer} */
818
+ function decode_native(base64) {
819
+ return Uint8Array.fromBase64(base64).buffer;
820
+ }
821
+ /** @type {(array_buffer: ArrayBuffer) => string} */
822
+ function encode_buffer(array_buffer) {
823
+ return Buffer.from(array_buffer).toString("base64");
824
+ }
825
+ /** @type {(base64: string) => ArrayBuffer} */
826
+ function decode_buffer(base64) {
827
+ return Uint8Array.from(Buffer.from(base64, "base64")).buffer;
828
+ }
829
+ /** @type {(array_buffer: ArrayBuffer) => string} */
830
+ function encode_legacy(array_buffer) {
831
+ const array = new Uint8Array(array_buffer);
832
+ let binary = "";
833
+ const chunk_size = 32768;
834
+ for (let i = 0; i < array.length; i += chunk_size) {
835
+ const chunk = array.subarray(i, i + chunk_size);
836
+ binary += String.fromCharCode.apply(null, chunk);
837
+ }
838
+ return btoa(binary);
839
+ }
840
+ /** @type {(base64: string) => ArrayBuffer} */
841
+ function decode_legacy(base64) {
842
+ const binary_string = atob(base64);
843
+ const len = binary_string.length;
844
+ const array = new Uint8Array(len);
845
+ for (let i = 0; i < len; i++) array[i] = binary_string.charCodeAt(i);
846
+ return array.buffer;
847
+ }
848
+ var native = typeof Uint8Array.fromBase64 === "function";
849
+ var buffer = typeof process === "object" && process.versions?.node !== void 0;
850
+ var encode64 = native ? encode_native : buffer ? encode_buffer : encode_legacy;
851
+ var decode64 = native ? decode_native : buffer ? decode_buffer : decode_legacy;
852
+ //#endregion
853
+ //#region node_modules/devalue/src/operations.js
854
+ /**
855
+ * Merges caller-provided operation overrides over the defaults. Iterating the
856
+ * default keys (rather than the override's own keys) means nullish members
857
+ * fall back to the default, and inherited members — e.g. from a class
858
+ * instance — are picked up.
859
+ *
860
+ * @template {Record<string, any>} T
861
+ * @param {T} defaults
862
+ * @param {Partial<T> | undefined} overrides
863
+ * @returns {T}
864
+ */
865
+ function merge_operations(defaults, overrides) {
866
+ if (!overrides) return defaults;
867
+ const merged = {};
868
+ for (const key of Object.keys(defaults)) merged[key] = overrides[key] ?? defaults[key];
869
+ return merged;
870
+ }
871
+ /** @type {{ kind: 'not-plain' }} */
872
+ var NOT_PLAIN = /* @__PURE__ */ Object.freeze({ kind: "not-plain" });
873
+ /** @type {{ kind: 'symbol-keys' }} */
874
+ var SYMBOL_KEYS = /* @__PURE__ */ Object.freeze({ kind: "symbol-keys" });
875
+ var default_stringify_operations = /* @__PURE__ */ Object.freeze({
876
+ identify: (value) => value,
877
+ typeOf: (value) => value === null ? "null" : typeof value,
878
+ toPrimitive: (value) => value,
879
+ tagOf: (value) => get_type(value),
880
+ isThenable: (value) => typeof value.then === "function",
881
+ toPromise: (thenable) => Promise.resolve(thenable),
882
+ unbox: (boxed) => boxed.valueOf(),
883
+ toISOString: (date) => isNaN(date.getDate()) ? "" : date.toISOString(),
884
+ toStringValue: (value) => value.toString(),
885
+ regExpInfo: (regexp) => ({
886
+ source: regexp.source,
887
+ flags: regexp.flags
888
+ }),
889
+ valuesOf: (set) => set,
890
+ entriesOf: (map) => map,
891
+ viewInfo: (view) => {
892
+ if (is_buffer(view)) view = new Uint8Array(view);
893
+ return {
894
+ buffer: view.buffer,
895
+ byteOffset: view.byteOffset,
896
+ byteLength: view.byteLength,
897
+ length: view.length,
898
+ bufferByteLength: view.buffer.byteLength
899
+ };
900
+ },
901
+ toArrayBuffer: (buffer) => buffer,
902
+ lengthOf: (array) => array.length,
903
+ hasOwn: (value, key) => Object.hasOwn(value, key),
904
+ indicesOf: (array) => valid_array_indices(array),
905
+ shapeOf: (value) => {
906
+ if (!is_plain_object$1(value)) return NOT_PLAIN;
907
+ if (enumerable_symbols(value).length > 0) return SYMBOL_KEYS;
908
+ return {
909
+ kind: Object.getPrototypeOf(value) === null ? "null-proto" : "plain",
910
+ keys: Object.keys(value)
911
+ };
912
+ },
913
+ get: (value, key) => value[key]
914
+ });
915
+ var array_buffer_byte_length = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
916
+ var shared_array_buffer_byte_length = typeof SharedArrayBuffer === "undefined" ? void 0 : Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
917
+ var default_parse_operations = /* @__PURE__ */ Object.freeze({
918
+ fromPrimitive: (primitive) => primitive,
919
+ fromISOString: (iso) => new Date(iso),
920
+ fromStringValue: (tag, text) => {
921
+ if (tag === "URL") return new URL(text);
922
+ if (tag === "URLSearchParams") return new URLSearchParams(text);
923
+ return Temporal[tag.slice(9)].from(text);
924
+ },
925
+ fromArrayBuffer: (buffer) => buffer,
926
+ fromRegExpInfo: (source, flags) => new RegExp(source, flags),
927
+ fromViewInfo: (tag, buffer, byteOffset, length) => {
928
+ try {
929
+ array_buffer_byte_length.call(buffer);
930
+ } catch (error) {
931
+ if (!shared_array_buffer_byte_length) throw error;
932
+ shared_array_buffer_byte_length.call(buffer);
933
+ }
934
+ const Constructor = globalThis[tag];
935
+ return byteOffset !== void 0 ? new Constructor(buffer, byteOffset, length) : new Constructor(buffer);
936
+ },
937
+ box: (value) => Object(value),
938
+ createArray: (length) => new Array(length),
939
+ createSparseArray: (length) => {
940
+ /** @type {any[]} */
941
+ const array = [];
942
+ array[MAX_ARRAY_INDEX] = void 0;
943
+ delete array[MAX_ARRAY_INDEX];
944
+ array.length = length;
945
+ return array;
946
+ },
947
+ createObject: () => ({}),
948
+ createNullPrototypeObject: () => Object.create(null),
949
+ createSet: () => /* @__PURE__ */ new Set(),
950
+ createMap: () => /* @__PURE__ */ new Map(),
951
+ set: (target, key, value) => {
952
+ target[key] = value;
953
+ },
954
+ addValue: (set, value) => {
955
+ set.add(value);
956
+ },
957
+ addEntry: (map, key, value) => {
958
+ map.set(key, value);
959
+ }
960
+ });
961
+ //#endregion
962
+ //#region node_modules/devalue/src/parse.js
963
+ /**
964
+ * Revive a value serialized with `devalue.stringify`
965
+ * @param {string} serialized
966
+ * @param {Record<string, (value: any) => any>} [revivers]
967
+ * @param {import('./types.js').ParseOptions} [options]
968
+ */
969
+ function parse$1(serialized, revivers, options) {
970
+ return unflatten(JSON.parse(serialized), revivers, options);
971
+ }
972
+ /**
973
+ * Revive a value flattened with `devalue.stringify`
974
+ * @param {number | any[]} parsed
975
+ * @param {Record<string, (value: any) => any>} [revivers]
976
+ * @param {import('./types.js').ParseOptions} [options]
977
+ */
978
+ function unflatten(parsed, revivers, options) {
979
+ /** @type {import('./types.js').ParseOperations} */
980
+ const ops = merge_operations(default_parse_operations, options?.operations);
981
+ if (typeof parsed === "number") return hydrate(parsed, true);
982
+ if (!Array.isArray(parsed) || parsed.length === 0) throw new Error("Invalid input");
983
+ const values = parsed;
984
+ const hydrated = Array(values.length);
985
+ /**
986
+ * A set of values currently being hydrated with custom revivers,
987
+ * used to detect invalid cyclical dependencies
988
+ * @type {Set<number> | null}
989
+ */
990
+ let hydrating = null;
991
+ /**
992
+ * @param {number} index
993
+ * @returns {any}
994
+ */
995
+ function hydrate(index, standalone = false) {
996
+ if (index === -1) return ops.fromPrimitive(void 0);
997
+ if (index === -3) return ops.fromPrimitive(NaN);
998
+ if (index === -4) return ops.fromPrimitive(Infinity);
999
+ if (index === -5) return ops.fromPrimitive(-Infinity);
1000
+ if (index === -6) return ops.fromPrimitive(-0);
1001
+ if (standalone || typeof index !== "number") throw new Error(`Invalid input`);
1002
+ if (index in hydrated) return hydrated[index];
1003
+ if (index >= values.length) throw new Error(`Invalid input`);
1004
+ const value = values[index];
1005
+ if (!value || typeof value !== "object") hydrated[index] = ops.fromPrimitive(value);
1006
+ else if (Array.isArray(value)) {
1007
+ if (typeof value[0] === "string") {
1008
+ const type = value[0];
1009
+ const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
1010
+ if (reviver) {
1011
+ let i = value[1];
1012
+ if (typeof i !== "number") i = values.push(value[1]) - 1;
1013
+ if (Object.hasOwn(hydrated, i)) return hydrated[index] = reviver(hydrated[i]);
1014
+ hydrating ??= /* @__PURE__ */ new Set();
1015
+ if (hydrating.has(i)) throw new Error("Invalid circular reference");
1016
+ hydrating.add(i);
1017
+ hydrated[index] = reviver(hydrate(i));
1018
+ hydrating.delete(i);
1019
+ return hydrated[index];
1020
+ }
1021
+ switch (type) {
1022
+ case "Date":
1023
+ hydrated[index] = ops.fromISOString(value[1]);
1024
+ break;
1025
+ case "Set":
1026
+ const set = ops.createSet();
1027
+ hydrated[index] = set;
1028
+ for (let i = 1; i < value.length; i += 1) ops.addValue(set, hydrate(value[i]));
1029
+ break;
1030
+ case "Map":
1031
+ const map = ops.createMap();
1032
+ hydrated[index] = map;
1033
+ for (let i = 1; i < value.length; i += 2) ops.addEntry(map, hydrate(value[i]), hydrate(value[i + 1]));
1034
+ break;
1035
+ case "RegExp":
1036
+ hydrated[index] = ops.fromRegExpInfo(value[1], value[2]);
1037
+ break;
1038
+ case "Object": {
1039
+ const wrapped_index = value[1];
1040
+ if (typeof values[wrapped_index] === "object" && values[wrapped_index][0] !== "BigInt") throw new Error("Invalid input");
1041
+ hydrated[index] = ops.box(hydrate(wrapped_index));
1042
+ break;
1043
+ }
1044
+ case "BigInt":
1045
+ hydrated[index] = ops.fromPrimitive(BigInt(value[1]));
1046
+ break;
1047
+ case "null":
1048
+ const obj = ops.createNullPrototypeObject();
1049
+ hydrated[index] = obj;
1050
+ for (let i = 1; i < value.length; i += 2) {
1051
+ const key = value[i];
1052
+ if (typeof key !== "string") throw new Error("Cannot parse an object with a non-string key");
1053
+ if (key === "__proto__") throw new Error("Cannot parse an object with a `__proto__` property");
1054
+ ops.set(obj, key, hydrate(value[i + 1]));
1055
+ }
1056
+ break;
1057
+ case "Int8Array":
1058
+ case "Uint8Array":
1059
+ case "Uint8ClampedArray":
1060
+ case "Int16Array":
1061
+ case "Uint16Array":
1062
+ case "Float16Array":
1063
+ case "Int32Array":
1064
+ case "Uint32Array":
1065
+ case "Float32Array":
1066
+ case "Float64Array":
1067
+ case "BigInt64Array":
1068
+ case "BigUint64Array":
1069
+ case "DataView": {
1070
+ if (values[value[1]][0] !== "ArrayBuffer") throw new Error("Invalid data");
1071
+ const buffer = hydrate(value[1]);
1072
+ hydrated[index] = ops.fromViewInfo(type, buffer, value[2], value[3]);
1073
+ break;
1074
+ }
1075
+ case "ArrayBuffer": {
1076
+ const base64 = value[1];
1077
+ if (typeof base64 !== "string") throw new Error("Invalid ArrayBuffer encoding");
1078
+ hydrated[index] = ops.fromArrayBuffer(decode64(base64));
1079
+ break;
1080
+ }
1081
+ case "URL":
1082
+ case "URLSearchParams":
1083
+ case "Temporal.Duration":
1084
+ case "Temporal.Instant":
1085
+ case "Temporal.PlainDate":
1086
+ case "Temporal.PlainTime":
1087
+ case "Temporal.PlainDateTime":
1088
+ case "Temporal.PlainMonthDay":
1089
+ case "Temporal.PlainYearMonth":
1090
+ case "Temporal.ZonedDateTime":
1091
+ hydrated[index] = ops.fromStringValue(type, value[1]);
1092
+ break;
1093
+ default: throw new Error(`Unknown type ${type}`);
1094
+ }
1095
+ } else if (value[0] === -7) {
1096
+ const len = value[1];
1097
+ if (!is_valid_array_len(len)) throw new Error("Invalid input");
1098
+ const array = ops.createSparseArray(len);
1099
+ hydrated[index] = array;
1100
+ for (let i = 2; i < value.length; i += 2) {
1101
+ const idx = value[i];
1102
+ if (!is_valid_array_index(idx) || idx >= len) throw new Error("Invalid input");
1103
+ ops.set(array, idx, hydrate(value[i + 1]));
1104
+ }
1105
+ } else {
1106
+ const array = ops.createArray(value.length);
1107
+ hydrated[index] = array;
1108
+ for (let i = 0; i < value.length; i += 1) {
1109
+ const n = value[i];
1110
+ if (n === -2) continue;
1111
+ ops.set(array, i, hydrate(n));
1112
+ }
1113
+ }
1114
+ } else {
1115
+ const object = ops.createObject();
1116
+ hydrated[index] = object;
1117
+ for (const key of Object.keys(value)) {
1118
+ if (key === "__proto__") throw new Error("Cannot parse an object with a `__proto__` property");
1119
+ ops.set(object, key, hydrate(value[key]));
1120
+ }
1121
+ }
1122
+ return hydrated[index];
1123
+ }
1124
+ return hydrate(0);
1125
+ }
1126
+ //#endregion
1127
+ //#region node_modules/devalue/src/stringify.js
1128
+ /**
1129
+ * Turn a value into a JSON string that can be parsed with `devalue.parse`
1130
+ * @param {any} value
1131
+ * @param {Record<string, (value: any) => any>} [reducers]
1132
+ * @param {import('./types.js').StringifyOptions} [options]
1133
+ */
1134
+ function stringify$1(value, reducers, options) {
1135
+ const stringified = run(false, value, reducers, options);
1136
+ return typeof stringified === "string" ? stringified : `[${stringified.join(",")}]`;
1137
+ }
1138
+ /**
1139
+ * @param {boolean} async
1140
+ * @param {any} value
1141
+ * @param {Record<string, (value: any) => any>} [reducers]
1142
+ * @param {import('./types.js').StringifyOptions} [options]
1143
+ */
1144
+ function run(async, value, reducers, options) {
1145
+ const ops = merge_operations(default_stringify_operations, options?.operations);
1146
+ /** @type {any[]} */
1147
+ const stringified = [];
1148
+ /** @type {Map<any, number>} */
1149
+ const indexes = /* @__PURE__ */ new Map();
1150
+ /** @type {Array<{ key: string, fn: (value: any) => any }>} */
1151
+ const custom = [];
1152
+ if (reducers) for (const key of Object.getOwnPropertyNames(reducers)) custom.push({
1153
+ key,
1154
+ fn: reducers[key]
1155
+ });
1156
+ /** @type {string[]} */
1157
+ const keys = [];
1158
+ let p = 0;
1159
+ /**
1160
+ * @param {any} thing
1161
+ * @param {number} [index]
1162
+ */
1163
+ function flatten(thing, index) {
1164
+ const type = ops.typeOf(thing);
1165
+ if (type === "undefined") return -1;
1166
+ /** @type {number | undefined} */
1167
+ let number;
1168
+ if (type === "number") {
1169
+ number = ops.toPrimitive(thing);
1170
+ if (Number.isNaN(number)) return -3;
1171
+ if (number === Infinity) return -4;
1172
+ if (number === -Infinity) return -5;
1173
+ if (number === 0 && 1 / number < 0) return -6;
1174
+ }
1175
+ const id = ops.identify(thing);
1176
+ if (indexes.has(id)) return indexes.get(id);
1177
+ index ??= p++;
1178
+ indexes.set(id, index);
1179
+ for (const { key, fn } of custom) {
1180
+ const value = fn(thing);
1181
+ if (value) {
1182
+ stringified[index] = `["${key}",${flatten(value)}]`;
1183
+ return index;
1184
+ }
1185
+ }
1186
+ if (type === "function") throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
1187
+ else if (type === "symbol") throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
1188
+ /** @type {string | Promise<any>} */
1189
+ let str = "";
1190
+ if (type !== "object") str = stringify_primitive(type === "number" ? number : ops.toPrimitive(thing));
1191
+ else if (ops.isThenable(thing)) {
1192
+ if (!async) throw new DevalueError(`Cannot stringify a Promise or thenable — use stringifyAsync instead`, keys, thing, value);
1193
+ str = ops.toPromise(thing).then((value) => {
1194
+ const i = flatten(value, index);
1195
+ if (i < 0) stringified[index] = i;
1196
+ });
1197
+ str.catch(() => {});
1198
+ } else {
1199
+ const tag = ops.tagOf(thing);
1200
+ switch (tag) {
1201
+ case "Number":
1202
+ case "String":
1203
+ case "Boolean":
1204
+ case "BigInt":
1205
+ str = `["Object",${flatten(ops.unbox(thing))}]`;
1206
+ break;
1207
+ case "Date":
1208
+ str = `["Date","${ops.toISOString(thing)}"]`;
1209
+ break;
1210
+ case "URL":
1211
+ str = `["URL",${stringify_string(ops.toStringValue(thing))}]`;
1212
+ break;
1213
+ case "URLSearchParams":
1214
+ str = `["URLSearchParams",${stringify_string(ops.toStringValue(thing))}]`;
1215
+ break;
1216
+ case "RegExp":
1217
+ const { source, flags } = ops.regExpInfo(thing);
1218
+ str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
1219
+ break;
1220
+ case "Array": {
1221
+ let mostly_dense = false;
1222
+ const length = ops.lengthOf(thing);
1223
+ str = "[";
1224
+ for (let i = 0; i < length; i += 1) {
1225
+ if (i > 0) str += ",";
1226
+ if (ops.hasOwn(thing, i)) {
1227
+ keys.push(`[${i}]`);
1228
+ str += flatten(ops.get(thing, i));
1229
+ keys.pop();
1230
+ } else if (mostly_dense) str += -2;
1231
+ else {
1232
+ const populated_keys = ops.indicesOf(thing);
1233
+ const population = populated_keys.length;
1234
+ const d = String(length).length;
1235
+ if ((length - population) * 3 > 4 + d + population * (d + 1)) {
1236
+ str = "[-7," + length;
1237
+ for (let j = 0; j < populated_keys.length; j++) {
1238
+ const key = populated_keys[j];
1239
+ keys.push(`[${key}]`);
1240
+ str += "," + key + "," + flatten(ops.get(thing, key));
1241
+ keys.pop();
1242
+ }
1243
+ break;
1244
+ } else {
1245
+ mostly_dense = true;
1246
+ str += -2;
1247
+ }
1248
+ }
1249
+ }
1250
+ str += "]";
1251
+ break;
1252
+ }
1253
+ case "Set":
1254
+ str = "[\"Set\"";
1255
+ for (const value of ops.valuesOf(thing)) str += `,${flatten(value)}`;
1256
+ str += "]";
1257
+ break;
1258
+ case "Map":
1259
+ str = "[\"Map\"";
1260
+ for (const [key, value] of ops.entriesOf(thing)) {
1261
+ const key_type = ops.typeOf(key);
1262
+ const key_is_primitive = key_type !== "object" && key_type !== "function" && key_type !== "symbol";
1263
+ keys.push(`.get(${key_is_primitive ? stringify_primitive(ops.toPrimitive(key)) : "..."})`);
1264
+ str += `,${flatten(key)},${flatten(value)}`;
1265
+ keys.pop();
1266
+ }
1267
+ str += "]";
1268
+ break;
1269
+ case "Int8Array":
1270
+ case "Uint8Array":
1271
+ case "Uint8ClampedArray":
1272
+ case "Int16Array":
1273
+ case "Uint16Array":
1274
+ case "Float16Array":
1275
+ case "Int32Array":
1276
+ case "Uint32Array":
1277
+ case "Float32Array":
1278
+ case "Float64Array":
1279
+ case "BigInt64Array":
1280
+ case "BigUint64Array": {
1281
+ const info = ops.viewInfo(thing);
1282
+ str = "[\"" + tag + "\"," + flatten(info.buffer);
1283
+ if (info.byteLength !== info.bufferByteLength) str += `,${info.byteOffset},${info.length}`;
1284
+ str += "]";
1285
+ break;
1286
+ }
1287
+ case "DataView": {
1288
+ const info = ops.viewInfo(thing);
1289
+ str = "[\"" + tag + "\"," + flatten(info.buffer);
1290
+ if (info.byteLength !== info.bufferByteLength) str += `,${info.byteOffset},${info.byteLength}`;
1291
+ str += "]";
1292
+ break;
1293
+ }
1294
+ case "ArrayBuffer":
1295
+ str = `["ArrayBuffer","${encode64(ops.toArrayBuffer(thing))}"]`;
1296
+ break;
1297
+ case "Temporal.Duration":
1298
+ case "Temporal.Instant":
1299
+ case "Temporal.PlainDate":
1300
+ case "Temporal.PlainTime":
1301
+ case "Temporal.PlainDateTime":
1302
+ case "Temporal.PlainMonthDay":
1303
+ case "Temporal.PlainYearMonth":
1304
+ case "Temporal.ZonedDateTime":
1305
+ str = `["${tag}",${stringify_string(ops.toStringValue(thing))}]`;
1306
+ break;
1307
+ default: {
1308
+ const shape = ops.shapeOf(thing);
1309
+ if (shape.kind === "not-plain") throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
1310
+ if (shape.kind === "symbol-keys") throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
1311
+ if (shape.kind === "null-proto") {
1312
+ str = "[\"null\"";
1313
+ for (const key of shape.keys) {
1314
+ if (key === "__proto__") throw new DevalueError(`Cannot stringify objects with __proto__ keys`, keys, thing, value);
1315
+ keys.push(stringify_key(key));
1316
+ str += `,${stringify_string(key)},${flatten(ops.get(thing, key))}`;
1317
+ keys.pop();
1318
+ }
1319
+ str += "]";
1320
+ } else {
1321
+ str = "{";
1322
+ let started = false;
1323
+ for (const key of shape.keys) {
1324
+ if (key === "__proto__") throw new DevalueError(`Cannot stringify objects with __proto__ keys`, keys, thing, value);
1325
+ if (started) str += ",";
1326
+ started = true;
1327
+ keys.push(stringify_key(key));
1328
+ str += `${stringify_string(key)}:${flatten(ops.get(thing, key))}`;
1329
+ keys.pop();
1330
+ }
1331
+ str += "}";
1332
+ }
1333
+ }
1334
+ }
1335
+ }
1336
+ stringified[index] = str;
1337
+ return index;
1338
+ }
1339
+ const index = flatten(value);
1340
+ if (index < 0) return `${index}`;
1341
+ return stringified;
1342
+ }
1343
+ /**
1344
+ * @param {any} thing
1345
+ * @returns {string}
1346
+ */
1347
+ function stringify_primitive(thing) {
1348
+ const type = typeof thing;
1349
+ if (type === "string") return stringify_string(thing);
1350
+ if (thing === void 0) return (-1).toString();
1351
+ if (thing === 0 && 1 / thing < 0) return (-6).toString();
1352
+ if (type === "bigint") return `["BigInt","${thing}"]`;
1353
+ return String(thing);
1354
+ }
1355
+ //#endregion
1356
+ //#region node_modules/@sveltejs/kit/src/runtime/form-utils.js
1357
+ /** @import { BinaryFormMeta, InternalRemoteFormIssue } from 'types' */
1358
+ /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
1359
+ /**
1360
+ * Sets a parsed form field value in a nested object, mutating the original object.
1361
+ * @param {Record<string, any>} object
1362
+ * @param {{ name: string; type: 'number' | 'boolean' | null }} field
1363
+ * @param {any} value
1364
+ */
1365
+ function set_nested_value(object, field, value) {
1366
+ deep_set(object, split_path(field.name), value);
1367
+ }
1368
+ /**
1369
+ * Separates a form field's path from the metadata encoded in its name.
1370
+ * @param {string} form_id
1371
+ * @param {string} key
1372
+ * @returns {{ name: string; type: 'number' | 'boolean' | null; is_array: boolean }}
1373
+ */
1374
+ function parse_form_key(form_id, key) {
1375
+ const suffix = "/" + form_id;
1376
+ let name = key;
1377
+ let image_coordinate = "";
1378
+ if (name.startsWith("i:") && (name.endsWith(suffix + ".x") || name.endsWith(suffix + ".y"))) {
1379
+ image_coordinate = name[name.length - 1];
1380
+ name = name.slice(0, -2);
1381
+ }
1382
+ if (!name.endsWith(suffix)) form_field_unbound({ name });
1383
+ name = name.slice(0, -suffix.length);
1384
+ /** @type {'number' | 'boolean' | null} */
1385
+ let type = null;
1386
+ if (name.startsWith("n:")) {
1387
+ name = name.slice(2);
1388
+ type = "number";
1389
+ } else if (name.startsWith("b:")) {
1390
+ name = name.slice(2);
1391
+ type = "boolean";
1392
+ } else if (name.startsWith("i:")) {
1393
+ name = name.slice(2);
1394
+ type = "number";
1395
+ }
1396
+ const is_array = name.endsWith("[]");
1397
+ if (is_array) name = name.slice(0, -2);
1398
+ if (image_coordinate) name += "." + image_coordinate;
1399
+ return {
1400
+ name,
1401
+ type,
1402
+ is_array
1403
+ };
1404
+ }
1405
+ /**
1406
+ * @param {'number' | 'boolean' | null} type
1407
+ * @param {any} value
1408
+ * @returns {any}
1409
+ */
1410
+ function coerce_form_value(type, value) {
1411
+ if (Array.isArray(value)) return value.map((value) => coerce_form_value(type, value));
1412
+ if (type === "number") return value === "" ? void 0 : parseFloat(value);
1413
+ if (type === "boolean") return value === "on";
1414
+ return value;
1415
+ }
1416
+ /** Pass this to set_nested_value to delete the last part of the given path */
1417
+ var DELETE_KEY = {};
1418
+ /**
1419
+ * Convert `FormData` into a POJO
1420
+ * @param {string} form_id
1421
+ * @param {FormData} data
1422
+ */
1423
+ function convert_formdata(form_id, data) {
1424
+ /** @type {Record<string, any>} */
1425
+ const result = {};
1426
+ for (const field_name of data.keys()) {
1427
+ /** @type {any[]} */
1428
+ const values = data.getAll(field_name);
1429
+ const field = parse_form_key(form_id, field_name);
1430
+ const entries = values.filter((entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0);
1431
+ if (entries.length === 0 && !field.is_array) continue;
1432
+ if (entries.length > 1 && !field.is_array) form_field_duplicate({
1433
+ name: field.name,
1434
+ count: String(entries.length)
1435
+ });
1436
+ set_nested_value(result, field, coerce_form_value(field.type, field.is_array ? entries : entries[0]));
1437
+ }
1438
+ return result;
1439
+ }
1440
+ var BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata";
1441
+ var BINARY_FORM_VERSION = 0;
1442
+ var HEADER_BYTES = 7;
1443
+ /**
1444
+ * @param {Request} request
1445
+ * @param {string} form_id
1446
+ * @returns {Promise<{ data: Record<string, any>; meta: BinaryFormMeta; form_data: FormData | null }>}
1447
+ */
1448
+ async function deserialize_binary_form(request, form_id) {
1449
+ if (request.headers.get("content-type") !== "application/x-sveltekit-formdata") {
1450
+ const form_data = await request.formData();
1451
+ return {
1452
+ data: convert_formdata(form_id, form_data),
1453
+ meta: {},
1454
+ form_data
1455
+ };
1456
+ }
1457
+ if (!request.body) throw deserialize_error("no body");
1458
+ const reader = request.body.getReader();
1459
+ /** @type {Array<Promise<Uint8Array<ArrayBuffer> | undefined>>} */
1460
+ const chunks = [];
1461
+ /**
1462
+ * @param {number} index
1463
+ * @returns {Promise<Uint8Array<ArrayBuffer> | undefined>}
1464
+ */
1465
+ function get_chunk(index) {
1466
+ if (index in chunks) return chunks[index];
1467
+ let i = chunks.length;
1468
+ while (i <= index) {
1469
+ const previous = chunks[i - 1] ?? Promise.resolve(void 0);
1470
+ chunks[i] = previous.then(() => reader.read()).then((chunk) => chunk.value);
1471
+ i++;
1472
+ }
1473
+ return chunks[index];
1474
+ }
1475
+ /**
1476
+ * @param {number} offset
1477
+ * @param {number} length
1478
+ * @returns {Promise<Uint8Array | null>}
1479
+ */
1480
+ async function get_buffer(offset, length) {
1481
+ /** @type {Uint8Array<ArrayBuffer>[]} */
1482
+ const parts = [];
1483
+ let total = 0;
1484
+ for await (const part of read_range(get_chunk, offset, length)) {
1485
+ parts.push(part);
1486
+ total += part.byteLength;
1487
+ }
1488
+ if (total < length || parts.length === 0) return null;
1489
+ if (parts.length === 1) return parts[0];
1490
+ const buffer = new Uint8Array(length);
1491
+ let cursor = 0;
1492
+ for (const part of parts) {
1493
+ buffer.set(part, cursor);
1494
+ cursor += part.byteLength;
1495
+ }
1496
+ return buffer;
1497
+ }
1498
+ const header = await get_buffer(0, HEADER_BYTES);
1499
+ if (!header) throw deserialize_error("too short");
1500
+ if (header[0] !== BINARY_FORM_VERSION) throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);
1501
+ const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);
1502
+ const data_length = header_view.getUint32(1, true);
1503
+ const file_offsets_length = header_view.getUint16(5, true);
1504
+ const data_buffer = await get_buffer(HEADER_BYTES, data_length);
1505
+ if (!data_buffer) throw deserialize_error("data too short");
1506
+ /** @type {Array<number | undefined>} */
1507
+ let file_offsets;
1508
+ /** @type {number} */
1509
+ let files_start_offset;
1510
+ if (file_offsets_length > 0) {
1511
+ const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
1512
+ if (!file_offsets_buffer) throw deserialize_error("file offset table too short");
1513
+ const parsed_offsets = JSON.parse(text_decoder.decode(file_offsets_buffer));
1514
+ if (!Array.isArray(parsed_offsets) || parsed_offsets.some((n) => typeof n !== "number" || !Number.isInteger(n) || n < 0)) throw deserialize_error("invalid file offset table");
1515
+ file_offsets = parsed_offsets;
1516
+ files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
1517
+ }
1518
+ /** @type {Array<{ offset: number, size: number }>} */
1519
+ const file_spans = [];
1520
+ const [data, meta] = parse$1(text_decoder.decode(data_buffer), { File: ([name, type, size, last_modified, index]) => {
1521
+ if (typeof name !== "string" || typeof type !== "string" || !Number.isSafeInteger(size) || size < 0 || !Number.isSafeInteger(last_modified) || !Number.isSafeInteger(index) || index < 0) throw deserialize_error("invalid file metadata");
1522
+ let offset = file_offsets[index];
1523
+ if (offset === void 0) throw deserialize_error("duplicate file offset table index");
1524
+ file_offsets[index] = void 0;
1525
+ offset += files_start_offset;
1526
+ file_spans.push({
1527
+ offset,
1528
+ size
1529
+ });
1530
+ return new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, offset), { getPrototypeOf() {
1531
+ return File.prototype;
1532
+ } });
1533
+ } });
1534
+ file_spans.sort((a, b) => a.offset - b.offset || a.size - b.size);
1535
+ for (let i = 1; i < file_spans.length; i++) {
1536
+ const previous = file_spans[i - 1];
1537
+ const current = file_spans[i];
1538
+ const previous_end = previous.offset + previous.size;
1539
+ if (previous_end < current.offset) throw deserialize_error("gaps in file data");
1540
+ if (previous_end > current.offset) throw deserialize_error("overlapping file data");
1541
+ }
1542
+ (async () => {
1543
+ let has_more = true;
1544
+ while (has_more) has_more = !!await get_chunk(chunks.length);
1545
+ })().catch(noop);
1546
+ return {
1547
+ data,
1548
+ meta,
1549
+ form_data: null
1550
+ };
1551
+ }
1552
+ /**
1553
+ * @param {string} message
1554
+ */
1555
+ function deserialize_error(message) {
1556
+ return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`);
1557
+ }
1558
+ /**
1559
+ * Yields the chunks that make up the byte range `[offset, offset + length)`,
1560
+ * trimmed to its boundaries. Ends early if the underlying data runs out.
1561
+ * @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
1562
+ * @param {number} offset
1563
+ * @param {number} length
1564
+ * @returns {AsyncGenerator<Uint8Array<ArrayBuffer>, void, void>}
1565
+ */
1566
+ async function* read_range(get_chunk, offset, length) {
1567
+ let chunk_start = 0;
1568
+ for (let index = 0;; index++) {
1569
+ const chunk = await get_chunk(index);
1570
+ if (!chunk) return;
1571
+ const chunk_end = chunk_start + chunk.byteLength;
1572
+ if (chunk_end > offset) {
1573
+ yield chunk.subarray(Math.max(0, offset - chunk_start), Math.min(chunk.byteLength, offset + length - chunk_start));
1574
+ if (offset + length <= chunk_end) return;
1575
+ }
1576
+ chunk_start = chunk_end;
1577
+ }
1578
+ }
1579
+ /** @implements {File} */
1580
+ var LazyFile = class LazyFile {
1581
+ /** @type {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} */
1582
+ #get_chunk;
1583
+ /** @type {number} */
1584
+ #offset;
1585
+ /**
1586
+ * @param {string} name
1587
+ * @param {string} type
1588
+ * @param {number} size
1589
+ * @param {number} last_modified
1590
+ * @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
1591
+ * @param {number} offset
1592
+ */
1593
+ constructor(name, type, size, last_modified, get_chunk, offset) {
1594
+ this.name = name;
1595
+ this.type = type;
1596
+ this.size = size;
1597
+ this.lastModified = last_modified;
1598
+ this.webkitRelativePath = "";
1599
+ this.#get_chunk = get_chunk;
1600
+ this.#offset = offset;
1601
+ this.arrayBuffer = this.arrayBuffer.bind(this);
1602
+ this.bytes = this.bytes.bind(this);
1603
+ this.slice = this.slice.bind(this);
1604
+ this.stream = this.stream.bind(this);
1605
+ this.text = this.text.bind(this);
1606
+ }
1607
+ /** @type {ArrayBuffer | undefined} */
1608
+ #buffer;
1609
+ async arrayBuffer() {
1610
+ this.#buffer ??= await new Response(this.stream()).arrayBuffer();
1611
+ return this.#buffer;
1612
+ }
1613
+ async bytes() {
1614
+ return new Uint8Array(await this.arrayBuffer());
1615
+ }
1616
+ /**
1617
+ * @param {number=} start
1618
+ * @param {number=} end
1619
+ * @param {string=} contentType
1620
+ */
1621
+ slice(start = 0, end = this.size, contentType = this.type) {
1622
+ if (start < 0) start = Math.max(this.size + start, 0);
1623
+ else start = Math.min(start, this.size);
1624
+ if (end < 0) end = Math.max(this.size + end, 0);
1625
+ else end = Math.min(end, this.size);
1626
+ const size = Math.max(end - start, 0);
1627
+ return new LazyFile(this.name, contentType, size, this.lastModified, this.#get_chunk, this.#offset + start);
1628
+ }
1629
+ stream() {
1630
+ const range = read_range(this.#get_chunk, this.#offset, this.size);
1631
+ const size = this.size;
1632
+ return stream_from_iterable((async function* () {
1633
+ let cursor = 0;
1634
+ for await (const chunk of range) {
1635
+ cursor += chunk.byteLength;
1636
+ yield chunk;
1637
+ }
1638
+ if (cursor < size) throw new Error("incomplete file data");
1639
+ })());
1640
+ }
1641
+ async text() {
1642
+ return text_decoder.decode(await this.arrayBuffer());
1643
+ }
1644
+ };
1645
+ var path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/;
1646
+ /**
1647
+ * @param {string} path
1648
+ */
1649
+ function split_path(path) {
1650
+ if (!path_regex.test(path)) form_field_invalid_name({ name: path });
1651
+ return path.split(/\.|\[|\]/).filter(Boolean);
1652
+ }
1653
+ /**
1654
+ * Check if a property key is dangerous and could lead to prototype pollution
1655
+ * @param {string} key
1656
+ */
1657
+ function check_prototype_pollution(key) {
1658
+ if (key === "__proto__" || key === "constructor" || key === "prototype") form_field_forbidden_key({ key });
1659
+ }
1660
+ /**
1661
+ * Sets a value in a nested object using an array of keys, mutating the original object.
1662
+ * @param {Record<string, any>} object
1663
+ * @param {string[]} keys
1664
+ * @param {any} value
1665
+ */
1666
+ function deep_set(object, keys, value) {
1667
+ let current = object;
1668
+ for (let i = 0; i < keys.length - 1; i += 1) {
1669
+ const key = keys[i];
1670
+ check_prototype_pollution(key);
1671
+ const is_array = /^\d+$/.test(keys[i + 1]);
1672
+ const inner = Object.hasOwn(current, key) ? current[key] : void 0;
1673
+ const exists = inner != null;
1674
+ if (exists && is_array !== Array.isArray(inner)) form_field_array_conflict({ key: keys[i + 1] });
1675
+ if (!exists) {
1676
+ if (value === DELETE_KEY) return;
1677
+ current[key] = is_array ? [] : {};
1678
+ }
1679
+ current = current[key];
1680
+ }
1681
+ const final_key = keys[keys.length - 1];
1682
+ check_prototype_pollution(final_key);
1683
+ if (value === DELETE_KEY) delete current[final_key];
1684
+ else current[final_key] = value;
1685
+ }
1686
+ /**
1687
+ * @param {StandardSchemaV1.Issue} issue
1688
+ * @param {boolean} server Whether this issue came from server validation
1689
+ */
1690
+ function normalize_issue(issue, server = false) {
1691
+ /** @type {InternalRemoteFormIssue} */
1692
+ const normalized = {
1693
+ name: "",
1694
+ path: [],
1695
+ message: issue.message,
1696
+ server
1697
+ };
1698
+ if (issue.path !== void 0) {
1699
+ let name = "";
1700
+ for (const segment of issue.path) {
1701
+ const key = typeof segment === "object" ? segment.key : segment;
1702
+ normalized.path.push(key);
1703
+ if (typeof key === "number") name += `[${key}]`;
1704
+ else if (typeof key === "string") name += name === "" ? key : "." + key;
1705
+ }
1706
+ normalized.name = name;
1707
+ }
1708
+ return normalized;
1709
+ }
1710
+ /**
1711
+ * @param {InternalRemoteFormIssue[]} issues
1712
+ */
1713
+ function flatten_issues(issues) {
1714
+ /** @type {Record<string, InternalRemoteFormIssue[]>} */
1715
+ const result = Object.create(null);
1716
+ for (const issue of issues) {
1717
+ (result.$ ??= []).push(issue);
1718
+ let name = "";
1719
+ if (issue.path !== void 0) for (const key of issue.path) {
1720
+ if (typeof key === "number") name += `[${key}]`;
1721
+ else if (typeof key === "string") name += name === "" ? key : "." + key;
1722
+ (result[name] ??= []).push(issue);
1723
+ }
1724
+ }
1725
+ return result;
1726
+ }
1727
+ /**
1728
+ * Gets a nested value from an object using a path array
1729
+ * @param {Record<string, any>} object
1730
+ * @param {(string | number)[]} path
1731
+ * @returns {any}
1732
+ */
1733
+ function deep_get(object, path) {
1734
+ let current = object;
1735
+ for (const key of path) {
1736
+ if (current === null || typeof current !== "object" || !Object.hasOwn(current, key)) return;
1737
+ current = current[key];
1738
+ }
1739
+ return current;
1740
+ }
1741
+ /** name prefixes that tell the server which type to coerce a submitted string to */
1742
+ var type_prefixes = {
1743
+ number: "n:",
1744
+ boolean: "b:"
1745
+ };
1746
+ /**
1747
+ * adds props; a function becomes a getter that is computed each time it is read
1748
+ * @param {Record<string, any>} base_props
1749
+ * @param {Record<string, unknown>} props
1750
+ */
1751
+ function add_props(base_props, props) {
1752
+ for (const prop in props) {
1753
+ const value = props[prop];
1754
+ if (typeof value === "function") Object.defineProperty(base_props, prop, {
1755
+ enumerable: true,
1756
+ get: value
1757
+ });
1758
+ else base_props[prop] = value;
1759
+ }
1760
+ return base_props;
1761
+ }
1762
+ /**
1763
+ * @param {string} type
1764
+ * @param {boolean} is_array
1765
+ * @param {unknown} input_value
1766
+ */
1767
+ function get_type_prefix(type, is_array, input_value) {
1768
+ if (type === "number" || type === "range") return "n:";
1769
+ if (type === "image") return "i:";
1770
+ if (type === "checkbox" && !is_array) return "b:";
1771
+ if (type === "hidden" || type === "submit") return type_prefixes[typeof input_value] ?? "";
1772
+ return "";
1773
+ }
1774
+ /**
1775
+ * A deep-clone implementation specifically for form data, where
1776
+ * we don't need to worry about cycles and whatnot
1777
+ * @param {any} value
1778
+ * @returns {any}
1779
+ */
1780
+ function deep_clone(value) {
1781
+ if (value !== null && typeof value === "object") {
1782
+ if (value instanceof Date) return new Date(value.getTime());
1783
+ if (value instanceof File) return value;
1784
+ if (Array.isArray(value)) return value.map(deep_clone);
1785
+ /** @type {Record<string, any>} */
1786
+ const clone = {};
1787
+ for (const key of Object.keys(value)) clone[key] = deep_clone(value[key]);
1788
+ return clone;
1789
+ }
1790
+ return value;
1791
+ }
1792
+ /** @type {ProxyHandler<object> | null} */
1793
+ var dev_traps = null;
1794
+ /** @param {InternalRemoteFormIssue} issue */
1795
+ var public_issue = (issue) => ({
1796
+ path: issue.path,
1797
+ message: issue.message
1798
+ });
1799
+ /** @typedef {{
1800
+ * form_id: string,
1801
+ * get: () => Record<string, any>,
1802
+ * set: (path: (string | number)[], value: any) => void,
1803
+ * get_issues: (path?: (string | number)[], all?: boolean) => Record<string, InternalRemoteFormIssue[]>,
1804
+ * get_touched: () => Record<string, boolean>,
1805
+ * get_dirty: () => Record<string, boolean>
1806
+ * }} FieldContext */
1807
+ /**
1808
+ * @param {FieldContext} context
1809
+ * @param {(string | number)[]} path
1810
+ * @param {string} prop
1811
+ * @returns {any} a method of the field at `path`, or undefined for a nested field
1812
+ */
1813
+ function create_field_method(context, path, prop) {
1814
+ switch (prop) {
1815
+ case "set": return (value) => {
1816
+ context.set(path, value);
1817
+ return value;
1818
+ };
1819
+ case "value": return () => deep_clone(deep_get(context.get(), path));
1820
+ case "issues":
1821
+ case "allIssues": {
1822
+ const key = build_path_string(path);
1823
+ const all = prop === "allIssues";
1824
+ return () => {
1825
+ const issues = context.get_issues(path, all)[key === "" ? "$" : key];
1826
+ if (all) return issues?.map(public_issue);
1827
+ const own = issues?.filter((issue) => issue.name === key).map(public_issue);
1828
+ return own?.length ? own : void 0;
1829
+ };
1830
+ }
1831
+ case "touched":
1832
+ case "dirty": {
1833
+ const key = build_path_string(path);
1834
+ return () => {
1835
+ const object = prop === "dirty" ? context.get_dirty() : context.get_touched();
1836
+ if (Object.hasOwn(object, key)) return true;
1837
+ for (const candidate in object) {
1838
+ if (!Object.hasOwn(object, candidate)) continue;
1839
+ if (key === "") return true;
1840
+ if (!candidate.startsWith(key)) continue;
1841
+ const next = candidate[key.length];
1842
+ if (next === "." || next === "[") return true;
1843
+ }
1844
+ return false;
1845
+ };
1846
+ }
1847
+ case "as": {
1848
+ const key = build_path_string(path);
1849
+ /**
1850
+ * the field's value, or `fallback` until the field has been edited
1851
+ * (without a fallback there is nothing to suppress, so `dirty` is not read)
1852
+ * @param {unknown} [fallback]
1853
+ */
1854
+ const read = (fallback) => deep_get(context.get(), path) ?? (fallback !== void 0 && Object.hasOwn(context.get_dirty(), key) ? void 0 : fallback);
1855
+ /**
1856
+ * @param {string} type
1857
+ * @param {unknown} [input_value]
1858
+ * @param {boolean} [checked]
1859
+ */
1860
+ return (type, input_value, checked) => {
1861
+ const is_array = type === "file multiple" || type === "select multiple" || type === "checkbox" && typeof input_value === "string";
1862
+ /** @type {Record<string, any>} */
1863
+ const base_props = {
1864
+ name: get_type_prefix(type, is_array, input_value) + key + (is_array ? "[]" : "") + "/" + context.form_id,
1865
+ get "aria-invalid"() {
1866
+ const issues = context.get_issues();
1867
+ return key in issues ? "true" : void 0;
1868
+ }
1869
+ };
1870
+ if (type !== "text" && type !== "select" && type !== "select multiple") base_props.type = type === "file multiple" ? "file" : type;
1871
+ if (type === "submit" || type === "hidden") return add_props(base_props, { value: typeof input_value === "boolean" ? input_value ? "on" : "off" : input_value });
1872
+ if (type === "select" || type === "select multiple") return add_props(base_props, {
1873
+ multiple: is_array,
1874
+ value: () => {
1875
+ const value = read(input_value);
1876
+ return Array.isArray(value) ? [...value] : value;
1877
+ }
1878
+ });
1879
+ if (type === "checkbox" || type === "radio") {
1880
+ if (type === "radio" || is_array) base_props.value = input_value ?? "on";
1881
+ else checked = input_value;
1882
+ return add_props(base_props, {
1883
+ defaultChecked: checked,
1884
+ checked: () => {
1885
+ const value = read();
1886
+ if (value == null) return read(checked);
1887
+ if (type === "radio") return value === input_value;
1888
+ if (is_array) return value.includes(input_value);
1889
+ return value;
1890
+ }
1891
+ });
1892
+ }
1893
+ if (type === "file" || type === "file multiple") return add_props(base_props, {
1894
+ multiple: is_array,
1895
+ files: () => {
1896
+ const value = read();
1897
+ const files = value instanceof File ? [value] : value;
1898
+ if (!Array.isArray(files) || !files.every((f) => f instanceof File)) return null;
1899
+ if (typeof DataTransfer === "undefined") return Object.assign({ length: files.length }, files);
1900
+ const transfer = new DataTransfer();
1901
+ for (const file of files) transfer.items.add(file);
1902
+ return transfer.files;
1903
+ }
1904
+ });
1905
+ if (type === "image") return base_props;
1906
+ return add_props(base_props, {
1907
+ defaultValue: input_value,
1908
+ value: () => String(read(input_value) ?? "")
1909
+ });
1910
+ };
1911
+ }
1912
+ }
1913
+ }
1914
+ /**
1915
+ * Creates a proxy-based field accessor for form data
1916
+ * @param {FieldContext} context
1917
+ * @param {any} target - Function or empty POJO
1918
+ * @param {(string | number)[]} path - Current access path
1919
+ * @returns {any} Proxy object with name(), value(), and issues() methods
1920
+ */
1921
+ function create_field_proxy(context, target = {}, path = []) {
1922
+ return new Proxy(target, {
1923
+ ...dev_traps,
1924
+ get(target, prop) {
1925
+ if (typeof prop === "symbol") return target[prop];
1926
+ const next = [...path, /^\d+$/.test(prop) ? parseInt(prop, 10) : prop];
1927
+ return create_field_proxy(context, create_field_method(context, path, prop), next);
1928
+ }
1929
+ });
1930
+ }
1931
+ /**
1932
+ * Builds a path string from an array of path segments
1933
+ * @param {(string | number)[]} path
1934
+ * @returns {string}
1935
+ */
1936
+ function build_path_string(path) {
1937
+ let result = "";
1938
+ for (const segment of path) if (typeof segment === "number") result += `[${segment}]`;
1939
+ else result += result === "" ? segment : "." + segment;
1940
+ return result;
1941
+ }
1942
+ //#endregion
1943
+ //#region node_modules/@sveltejs/kit/src/utils/http.js
1944
+ /**
1945
+ * Given an Accept header and a list of possible content types, pick
1946
+ * the most suitable one to respond with
1947
+ * @param {string} accept
1948
+ * @param {string[]} types
1949
+ */
1950
+ function negotiate(accept, types) {
1951
+ /** @type {Array<{ type: string, subtype: string, q: number, i: number }>} */
1952
+ const parts = [];
1953
+ accept.split(",").forEach((str, i) => {
1954
+ const match = /^[ \t]*([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
1955
+ if (match) {
1956
+ const [, type, subtype, q = "1"] = match;
1957
+ parts.push({
1958
+ type,
1959
+ subtype,
1960
+ q: +q,
1961
+ i
1962
+ });
1963
+ }
1964
+ });
1965
+ parts.sort((a, b) => {
1966
+ if (a.q !== b.q) return b.q - a.q;
1967
+ if (a.subtype === "*" !== (b.subtype === "*")) return a.subtype === "*" ? 1 : -1;
1968
+ if (a.type === "*" !== (b.type === "*")) return a.type === "*" ? 1 : -1;
1969
+ return a.i - b.i;
1970
+ });
1971
+ let accepted;
1972
+ let min_priority = Infinity;
1973
+ for (const mimetype of types) {
1974
+ const [type, subtype] = mimetype.split("/");
1975
+ const priority = parts.findIndex((part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*"));
1976
+ if (priority !== -1 && priority < min_priority) {
1977
+ accepted = mimetype;
1978
+ min_priority = priority;
1979
+ }
1980
+ }
1981
+ return accepted;
1982
+ }
1983
+ /**
1984
+ * Returns `true` if a `content-type` header value is one of the given types, ignoring
1985
+ * parameters such as `charset` and comparing case-insensitively
1986
+ * @param {string | null | undefined} header
1987
+ * @param {...string} types
1988
+ */
1989
+ function matches_content_type(header, ...types) {
1990
+ const type = header?.split(";", 1)[0].trim() ?? "";
1991
+ return types.includes(type.toLowerCase());
1992
+ }
1993
+ /**
1994
+ * @param {Request} request
1995
+ */
1996
+ function is_form_content_type(request) {
1997
+ return matches_content_type(request.headers.get("content-type"), "application/x-www-form-urlencoded", "multipart/form-data", "text/plain", BINARY_FORM_CONTENT_TYPE);
1998
+ }
1999
+ //#endregion
2000
+ //#region node_modules/@sveltejs/kit/src/runtime/app/internal/transport.js
2001
+ /** @import { Transport } from '@sveltejs/kit/hooks' */
2002
+ /** @type {(thing: any) => string} */
2003
+ var uneval = () => {
2004
+ throw new Error("");
2005
+ };
2006
+ /** @type {(data: any) => string} */
2007
+ var stringify = () => {
2008
+ throw new Error("");
2009
+ };
2010
+ /** @type {(data: string) => any} */
2011
+ var parse = () => {
2012
+ throw new Error("");
2013
+ };
2014
+ /** @type {Record<string, (data: any) => any>} */
2015
+ var encoders = {};
2016
+ /** @type {Record<string, (data: any) => any>} */
2017
+ var decoders = {};
2018
+ var has_custom_transporters = false;
2019
+ /**
2020
+ *
2021
+ * @param {Transport} transport
2022
+ */
2023
+ function init_transport(transport) {
2024
+ const transporters = Object.entries(transport);
2025
+ has_custom_transporters = transporters.length > 0;
2026
+ /** @param {unknown} thing */
2027
+ const replacer = (thing) => {
2028
+ for (const key of Object.keys(transport)) {
2029
+ const encoded = transport[key].encode(thing);
2030
+ if (encoded) return `app.decode('${key}', ${uneval$1(encoded, replacer)})`;
2031
+ }
2032
+ };
2033
+ encoders = Object.fromEntries(transporters.map(([k, v]) => [k, v.encode]));
2034
+ decoders = Object.fromEntries(transporters.map(([k, v]) => [k, v.decode]));
2035
+ uneval = (data) => uneval$1(data, replacer);
2036
+ stringify = (data) => stringify$1(data, encoders);
2037
+ parse = (data) => parse$1(data, decoders);
2038
+ }
2039
+ //#endregion
2040
+ //#region node_modules/@sveltejs/kit/src/runtime/shared.js
2041
+ /**
2042
+ * @param {string} route_id
2043
+ * @param {string} dep
2044
+ */
2045
+ function validate_depends(route_id, dep) {
2046
+ const match = /^(moz-icon|view-source|jar):/.exec(dep);
2047
+ if (match) depends_special_scheme({
2048
+ route: route_id,
2049
+ dependency: dep,
2050
+ scheme: match[1]
2051
+ });
2052
+ }
2053
+ /**
2054
+ * Same-origin urls are keyed by path, so prerendered pages can be served from any origin
2055
+ * @param {URL} url
2056
+ * @param {{ origin: string }} page
2057
+ */
2058
+ function fetch_cache_url(url, page) {
2059
+ return url.origin === page.origin ? url.href.slice(page.origin.length) : url.href;
2060
+ }
2061
+ var INVALIDATED_PARAM = "x-sveltekit-invalidated";
2062
+ var TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
2063
+ /**
2064
+ * @param {any} data
2065
+ * @param {string} [location_description]
2066
+ */
2067
+ function validate_load_response(data, location_description) {
2068
+ if (data != null && Object.getPrototypeOf(data) !== Object.prototype) load_invalid_response({
2069
+ location: String(location_description),
2070
+ type: typeof data !== "object" ? `a ${typeof data}` : data instanceof Response ? "a Response object" : Array.isArray(data) ? "an array" : "a non-plain object"
2071
+ });
2072
+ }
2073
+ var object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
2074
+ /**
2075
+ * @param {unknown} thing
2076
+ * @returns {thing is Record<PropertyKey, unknown>}
2077
+ */
2078
+ function is_plain_object(thing) {
2079
+ if (typeof thing !== "object" || thing === null) return false;
2080
+ const proto = Object.getPrototypeOf(thing);
2081
+ return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
2082
+ }
2083
+ /**
2084
+ * @param {Record<string, any>} value
2085
+ * @param {Map<object, any>} clones
2086
+ */
2087
+ function to_sorted(value, clones) {
2088
+ const clone = Object.getPrototypeOf(value) === null ? Object.create(null) : {};
2089
+ clones.set(value, clone);
2090
+ Object.defineProperty(clone, remote_arg_marker, { value: true });
2091
+ for (const key of Object.keys(value).sort()) {
2092
+ const property = value[key];
2093
+ Object.defineProperty(clone, key, {
2094
+ value: clones.get(property) ?? property,
2095
+ enumerable: true,
2096
+ configurable: true,
2097
+ writable: true
2098
+ });
2099
+ }
2100
+ return clone;
2101
+ }
2102
+ var remote_object = "__skrao";
2103
+ var remote_map = "__skram";
2104
+ var remote_set = "__skras";
2105
+ var remote_file = "__skraf";
2106
+ var remote_regex_guard = "__skrag";
2107
+ var remote_arg_marker = Symbol(remote_object);
2108
+ /**
2109
+ * @param {boolean} sort
2110
+ */
2111
+ function create_remote_arg_reducers(sort) {
2112
+ /** @type {Record<string, (value: unknown) => unknown>} */
2113
+ const remote_fns_reducers = {
2114
+ /** @param {unknown} value */
2115
+ [remote_regex_guard]: (value) => {
2116
+ if (value instanceof RegExp) remote_argument_unsupported({ type: "Regular expressions" });
2117
+ } };
2118
+ if (sort) {
2119
+ const clones = /* @__PURE__ */ new Map();
2120
+ /** @type {(value: unknown) => Array<[unknown, unknown]> | undefined} */
2121
+ remote_fns_reducers[remote_map] = (value) => {
2122
+ if (!(value instanceof Map)) return;
2123
+ /** @type {Array<[string, string]>} */
2124
+ const entries = [];
2125
+ for (const [key, val] of value) entries.push([stringify(key), stringify(val)]);
2126
+ return entries.sort(([a1, a2], [b1, b2]) => {
2127
+ if (a1 < b1) return -1;
2128
+ if (a1 > b1) return 1;
2129
+ if (a2 < b2) return -1;
2130
+ if (a2 > b2) return 1;
2131
+ return 0;
2132
+ });
2133
+ };
2134
+ /** @type {(value: unknown) => unknown[] | undefined} */
2135
+ remote_fns_reducers[remote_set] = (value) => {
2136
+ if (!(value instanceof Set)) return;
2137
+ /** @type {string[]} */
2138
+ const items = [];
2139
+ for (const item of value) items.push(stringify(item));
2140
+ items.sort();
2141
+ return items;
2142
+ };
2143
+ /** @type {(value: unknown) => Record<PropertyKey, unknown> | undefined} */
2144
+ remote_fns_reducers[remote_object] = (value) => {
2145
+ if (!is_plain_object(value)) return;
2146
+ if (Object.hasOwn(value, remote_arg_marker)) return;
2147
+ if (clones.has(value)) return clones.get(value);
2148
+ return to_sorted(value, clones);
2149
+ };
2150
+ }
2151
+ const all_reducers = {
2152
+ ...encoders,
2153
+ ...remote_fns_reducers
2154
+ };
2155
+ /** @type {(value: unknown) => string} */
2156
+ const stringify = (value) => stringify$1(value, all_reducers);
2157
+ return all_reducers;
2158
+ }
2159
+ function create_remote_arg_revivers() {
2160
+ const remote_fns_revivers = {
2161
+ /** @type {(value: unknown) => unknown} */
2162
+ [remote_object]: (value) => value,
2163
+ /** @type {(value: unknown) => Map<unknown, unknown>} */
2164
+ [remote_map]: (value) => {
2165
+ if (!Array.isArray(value)) throw new Error("Invalid data for Map reviver");
2166
+ const map = /* @__PURE__ */ new Map();
2167
+ for (const item of value) {
2168
+ if (!Array.isArray(item) || item.length !== 2 || typeof item[0] !== "string" || typeof item[1] !== "string") throw new Error("Invalid data for Map reviver");
2169
+ const [key, val] = item;
2170
+ map.set(parse(key), parse(val));
2171
+ }
2172
+ return map;
2173
+ },
2174
+ /** @type {(value: unknown) => Set<unknown>} */
2175
+ [remote_set]: (value) => {
2176
+ if (!Array.isArray(value)) throw new Error("Invalid data for Set reviver");
2177
+ const set = /* @__PURE__ */ new Set();
2178
+ for (const item of value) {
2179
+ if (typeof item !== "string") throw new Error("Invalid data for Set reviver");
2180
+ set.add(parse(item));
2181
+ }
2182
+ return set;
2183
+ },
2184
+ /** @type {(value: any) => File} */
2185
+ [remote_file]: (value) => {
2186
+ 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)) throw new Error("Invalid data for File reviver");
2187
+ const { data, name, ...meta } = value;
2188
+ return new File([data], name, meta);
2189
+ }
2190
+ };
2191
+ const all_revivers = {
2192
+ ...decoders,
2193
+ ...remote_fns_revivers
2194
+ };
2195
+ /** @type {(data: string) => unknown} */
2196
+ const parse = (data) => parse$1(data, all_revivers);
2197
+ return all_revivers;
2198
+ }
2199
+ /**
2200
+ * Stringifies the argument (if any) for a remote function in such a way that
2201
+ * it is both a valid URL and a valid file name (necessary for prerendering).
2202
+ * @param {any} value
2203
+ */
2204
+ function stringify_remote_arg(value) {
2205
+ if (value === void 0) return "";
2206
+ return url_friendly_base64_encode(stringify$1(value, create_remote_arg_reducers(true)));
2207
+ }
2208
+ /**
2209
+ * Base64-encodes `string` in such a way that the result is safe to use
2210
+ * as both a URI component and a filename
2211
+ * @param {string} string
2212
+ */
2213
+ function url_friendly_base64_encode(string) {
2214
+ return base64_encode(text_encoder$1.encode(string)).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
2215
+ }
2216
+ /**
2217
+ * Parses the argument (if any) for a remote function
2218
+ * @param {string} string
2219
+ */
2220
+ function parse_remote_arg(string) {
2221
+ if (!string) return void 0;
2222
+ return parse$1(text_decoder.decode(base64_decode(string.replaceAll("-", "+").replaceAll("_", "/"))), create_remote_arg_revivers());
2223
+ }
2224
+ /**
2225
+ * @param {string} id
2226
+ * @param {string} payload
2227
+ */
2228
+ function create_remote_key(id, payload) {
2229
+ return id + "/" + payload;
2230
+ }
2231
+ /**
2232
+ * @param {string} key
2233
+ * @returns {{ id: string; payload: string }}
2234
+ */
2235
+ function split_remote_key(key) {
2236
+ const i = key.lastIndexOf("/");
2237
+ if (i === -1) throw new Error(`Invalid remote key: ${key}`);
2238
+ return {
2239
+ id: key.slice(0, i),
2240
+ payload: key.slice(i + 1)
2241
+ };
2242
+ }
2243
+ //#endregion
2244
+ //#region node_modules/@sveltejs/kit/src/utils/error.js
2245
+ /**
2246
+ * @param {Error} error
2247
+ * @param {string} stack
2248
+ * @returns {string | undefined}
2249
+ */
2250
+ function set_error_stack(error, stack) {
2251
+ try {
2252
+ Reflect.set(error, "stack", stack);
2253
+ } catch {}
2254
+ return error.stack;
2255
+ }
2256
+ /**
2257
+ * @param {unknown} err
2258
+ * @return {Error}
2259
+ */
2260
+ function coalesce_to_error(err) {
2261
+ return err instanceof Error || err && err.name && err.message ? err : new Error(JSON.stringify(err));
2262
+ }
2263
+ /**
2264
+ * This is an identity function that exists to make TypeScript less
2265
+ * paranoid about people throwing things that aren't errors, which
2266
+ * frankly is not something we should care about
2267
+ * @param {unknown} error
2268
+ */
2269
+ function normalize_error(error) {
2270
+ return error;
2271
+ }
2272
+ /**
2273
+ * @param {unknown} error
2274
+ */
2275
+ function get_status(error) {
2276
+ return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
2277
+ }
2278
+ //#endregion
2279
+ //#region node_modules/@sveltejs/kit/src/messages/server-warnings.js
2280
+ /**
2281
+ * `cache-control` header contains empty directives. (While parsing `%value%`.)
2282
+ * @param {{ "value": string }} _values
2283
+ */
2284
+ function cache_control_empty_directive(_values) {
2285
+ console.warn("https://svelte.dev/e/kit/cache_control_empty_directive");
2286
+ }
2287
+ /**
2288
+ * Invalid `cache-control` directive `%directive%`. Did you mean one of: %directives%? (While parsing `%value%`.)
2289
+ * @param {{ "directive": string; "directives": string; "value": string }} _values
2290
+ */
2291
+ function cache_control_invalid_directive(_values) {
2292
+ console.warn("https://svelte.dev/e/kit/cache_control_invalid_directive");
2293
+ }
2294
+ /**
2295
+ * Invalid `content-type` value `%type%`. (While parsing `%value%`.)
2296
+ * @param {{ "type": string; "value": string }} _values
2297
+ */
2298
+ function content_type_invalid(_values) {
2299
+ console.warn("https://svelte.dev/e/kit/content_type_invalid");
2300
+ }
2301
+ /**
2302
+ * `%name%` cookie does not exist for `%pathname%`, but was previously set at %paths%. Did you mean to set its `path` to `'/'` instead?
2303
+ * @param {{ "name": string; "pathname": string; "paths": string }} _values
2304
+ */
2305
+ function cookie_path_mismatch(_values) {
2306
+ console.warn("https://svelte.dev/e/kit/cookie_path_mismatch");
2307
+ }
2308
+ /**
2309
+ * The form action returned a value, but it isn't available in `page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#Progressive-enhancement-use:enhance
2310
+ * @param {void} _values
2311
+ */
2312
+ function form_action_data_without_ssr(_values) {
2313
+ console.warn("https://svelte.dev/e/kit/form_action_data_without_ssr");
2314
+ }
2315
+ /**
2316
+ * The form action returned an error, but `+error.svelte` wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#Progressive-enhancement-use:enhance
2317
+ * @param {void} _values
2318
+ */
2319
+ function form_action_error_without_ssr(_values) {
2320
+ console.warn("https://svelte.dev/e/kit/form_action_error_without_ssr");
2321
+ }
2322
+ /**
2323
+ * To use an async `handleError` hook to handle errors that occur during rendering, you must enable `compilerOptions.experimental.async` in the SvelteKit plugin of your Vite config. The returned error has been replaced with a generic object
2324
+ * @param {void} _values
2325
+ */
2326
+ function handle_error_async_without_async_svelte(_values) {
2327
+ console.warn("https://svelte.dev/e/kit/handle_error_async_without_async_svelte");
2328
+ }
2329
+ /**
2330
+ * `%id%`: %usage% in a promise handler after `load(...)` has returned will not cause the function to re-run when %change%
2331
+ * @param {{ "id": string; "usage": string; "change": string }} _values
2332
+ */
2333
+ function load_tracking_after_return(_values) {
2334
+ console.warn("https://svelte.dev/e/kit/load_tracking_after_return");
2335
+ }
2336
+ /**
2337
+ * Avoid calling `fetch` eagerly during server-side rendering — put your `fetch` calls inside `onMount` or a `load` function instead
2338
+ * @param {void} _values
2339
+ */
2340
+ function ssr_fetch_eager(_values) {
2341
+ console.warn("https://svelte.dev/e/kit/ssr_fetch_eager");
2342
+ }
2343
+ /**
2344
+ * Returning promises from server `load` functions will only work if `csr === true`
2345
+ * @param {void} _values
2346
+ */
2347
+ function streaming_without_csr(_values) {
2348
+ console.warn("https://svelte.dev/e/kit/streaming_without_csr");
2349
+ }
2350
+ /**
2351
+ * Removing comments in `transformPageChunk` can break Svelte's hydration
2352
+ * @param {void} _values
2353
+ */
2354
+ function transform_page_chunk_comments(_values) {
2355
+ console.warn("https://svelte.dev/e/kit/transform_page_chunk_comments");
2356
+ }
2357
+ //#endregion
2358
+ //#region node_modules/@sveltejs/kit/src/runtime/server/errors.js
2359
+ /**
2360
+ * @param {import('@sveltejs/kit').RequestEvent} event
2361
+ * @param {import('types').RequestState} state
2362
+ * @param {any} error
2363
+ * @returns {App.Error | Promise<App.Error>}
2364
+ */
2365
+ function handle_error_and_jsonify(event, state, error) {
2366
+ if (error instanceof HandledHttpError) return error.body;
2367
+ /** @type {import('@sveltejs/kit/hooks').CaughtError} */
2368
+ let caught;
2369
+ if (error instanceof HttpError) caught = {
2370
+ kind: "app",
2371
+ error: error.body
2372
+ };
2373
+ else if (error instanceof SvelteKitError) caught = {
2374
+ kind: "framework",
2375
+ error: {
2376
+ status: error.status,
2377
+ message: error.text
2378
+ }
2379
+ };
2380
+ else if (error instanceof ValidationError) caught = {
2381
+ kind: "validation",
2382
+ error: {
2383
+ status: 400,
2384
+ message: "Bad Request"
2385
+ },
2386
+ issues: error.issues
2387
+ };
2388
+ else {
2389
+ caught = {
2390
+ kind: "unknown",
2391
+ error
2392
+ };
2393
+ let e = error;
2394
+ while (e instanceof Error) {
2395
+ fix_stack_trace(e);
2396
+ e = e.cause;
2397
+ }
2398
+ }
2399
+ const fallback = caught.kind === "unknown" ? {
2400
+ status: 500,
2401
+ message: "Internal Error"
2402
+ } : caught.error;
2403
+ /**
2404
+ * The hook returns only the properties it wants to override; anything it omits
2405
+ * (including by returning nothing at all) is inherited from the caught error.
2406
+ * @param {Awaited<ReturnType<import('@sveltejs/kit/hooks').HandleServerError>>} body
2407
+ * @returns {App.Error}
2408
+ */
2409
+ function merge(body) {
2410
+ return {
2411
+ ...fallback,
2412
+ ...body
2413
+ };
2414
+ }
2415
+ let result;
2416
+ try {
2417
+ const input = {
2418
+ ...caught,
2419
+ event
2420
+ };
2421
+ result = with_request_store({
2422
+ event,
2423
+ state
2424
+ }, () => hooks.handleError(input));
2425
+ } catch (hook_error) {
2426
+ log_handle_error_hook_failure(error, hook_error);
2427
+ return {
2428
+ status: fallback.status,
2429
+ message: "Internal Error"
2430
+ };
2431
+ }
2432
+ if (result instanceof Promise) {
2433
+ if (state.is_in_render) {
2434
+ handle_error_async_without_async_svelte();
2435
+ result.catch((hook_error) => log_handle_error_hook_failure(error, hook_error));
2436
+ return {
2437
+ status: fallback.status,
2438
+ message: "Internal Error"
2439
+ };
2440
+ }
2441
+ return result.then(merge, (hook_error) => {
2442
+ log_handle_error_hook_failure(error, hook_error);
2443
+ return {
2444
+ status: fallback.status,
2445
+ message: "Internal Error"
2446
+ };
2447
+ });
2448
+ }
2449
+ return merge(result);
2450
+ }
2451
+ /**
2452
+ * @param {unknown} error
2453
+ * @param {unknown} hook_error
2454
+ */
2455
+ function log_handle_error_hook_failure(error, hook_error) {
2456
+ const failure = capture_error(() => handle_error_hook_failed(void 0, { cause: coalesce_to_error(hook_error) }));
2457
+ failure.stack = `${failure.name}: ${failure.message}`;
2458
+ console.error(failure);
2459
+ if (error instanceof SvelteKitError) console.error(`Original error: ${error.status} ${error.text}: ${error.message}`);
2460
+ else console.error("Original error:", error);
2461
+ }
2462
+ //#endregion
2463
+ //#region node_modules/@sveltejs/kit/src/runtime/server/utils.js
2464
+ /**
2465
+ * @param {Partial<Record<import('types').HttpMethod, any>>} mod
2466
+ * @param {import('types').HttpMethod} method
2467
+ */
2468
+ function method_not_allowed(mod, method) {
2469
+ return text(`${method} method not allowed`, {
2470
+ status: 405,
2471
+ headers: { allow: allowed_methods(mod).join(", ") }
2472
+ });
2473
+ }
2474
+ /** @param {Partial<Record<import('types').HttpMethod, any>>} mod */
2475
+ function allowed_methods(mod) {
2476
+ const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
2477
+ if ("GET" in mod && !("HEAD" in mod)) allowed.push("HEAD");
2478
+ return allowed;
2479
+ }
2480
+ /**
2481
+ * @param {number} status
2482
+ * @param {string} location
2483
+ */
2484
+ function redirect_response(status, location) {
2485
+ return new Response(void 0, {
2486
+ status,
2487
+ headers: { location }
2488
+ });
2489
+ }
2490
+ /**
2491
+ * @param {Response} response
2492
+ */
2493
+ function with_version_header(response) {
2494
+ response.headers.set("x-sveltekit-version", "1791433154666");
2495
+ return response;
2496
+ }
2497
+ /**
2498
+ * Throws an error explaining why data returned from `load` couldn't be serialized by devalue,
2499
+ * whose error becomes the cause
2500
+ * @param {import('@sveltejs/kit').RequestEvent} event
2501
+ * @param {Error & { path: string }} error
2502
+ * @returns {never}
2503
+ */
2504
+ function throw_devalue_error(event, error) {
2505
+ const id = event.route.id;
2506
+ if (error.path) load_not_serializable({
2507
+ id,
2508
+ message: error.message,
2509
+ path: error.path
2510
+ }, { cause: error });
2511
+ if (error.path === "") load_not_plain_object({ id }, { cause: error });
2512
+ throw new Error(error.message, { cause: error });
2513
+ }
2514
+ /**
2515
+ * @param {import('types').ServerDataNode} node
2516
+ */
2517
+ function serialize_uses(node) {
2518
+ const uses = {};
2519
+ if (node.uses && node.uses.dependencies.size > 0) uses.dependencies = Array.from(node.uses.dependencies);
2520
+ if (node.uses && node.uses.search_params.size > 0) uses.search_params = Array.from(node.uses.search_params);
2521
+ if (node.uses && node.uses.params.size > 0) uses.params = Array.from(node.uses.params);
2522
+ if (node.uses?.parent) uses.parent = 1;
2523
+ if (node.uses?.route) uses.route = 1;
2524
+ if (node.uses?.url) uses.url = 1;
2525
+ return uses;
2526
+ }
2527
+ /**
2528
+ * Returns `true` if the given path was prerendered
2529
+ * @param {string} pathname Should include the base and be decoded
2530
+ */
2531
+ function has_prerendered_path(pathname) {
2532
+ return manifest.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest.prerendered_routes.has(pathname.slice(0, -1));
2533
+ }
2534
+ /**
2535
+ * Returns the filename without the extension. e.g., `+page.server`, `+page`, etc.
2536
+ * @param {string | undefined} node_id
2537
+ * @returns {string}
2538
+ */
2539
+ function get_node_type(node_id) {
2540
+ const filename = (node_id?.split("/"))?.at(-1);
2541
+ if (!filename) return "unknown";
2542
+ return filename.split(".").slice(0, -1).join(".");
2543
+ }
2544
+ /**
2545
+ * Counts HTML comments that are not SSI directives (which start with `<!--#`).
2546
+ * Used to detect when `transformPageChunk` removes comments that Svelte needs for hydration.
2547
+ * @param {string} str
2548
+ * @returns {number}
2549
+ */
2550
+ function count_non_ssi_comments(str) {
2551
+ return (str.match(/<!--(?!#)/g) ?? []).length;
2552
+ }
2553
+ //#endregion
2554
+ //#region node_modules/@sveltejs/kit/src/runtime/server/page/actions.js
2555
+ /** @import { RequestEvent, Actions } from '@sveltejs/kit' */
2556
+ /** @import { ActionResult } from '$app/forms' */
2557
+ /** @import { SSRNode, ServerNode, ServerActionResult } from 'types' */
2558
+ /** @param {RequestEvent} event */
2559
+ function is_action_json_request(event) {
2560
+ return negotiate(event.request.headers.get("accept") ?? "*/*", ["application/json", "text/html"]) === "application/json" && event.request.method === "POST";
2561
+ }
2562
+ /**
2563
+ * @param {RequestEvent} event
2564
+ * @param {import('types').RequestState} state
2565
+ * @param {SSRNode['server'] | undefined} server
2566
+ */
2567
+ async function handle_action_json_request(event, state, server) {
2568
+ return action_result_json(event, state, await handle_action_request(event, state, server));
2569
+ }
2570
+ /**
2571
+ * @param {RequestEvent} event
2572
+ * @param {import('types').RequestState} state
2573
+ * @param {ServerActionResult} result
2574
+ * @returns {Promise<Response>}
2575
+ */
2576
+ async function action_result_json(event, state, result) {
2577
+ if (result.type === "redirect") return action_json(result);
2578
+ if (result.type === "error") {
2579
+ const error = await handle_error_and_jsonify(event, state, result.error);
2580
+ return action_json({
2581
+ ...result,
2582
+ error
2583
+ }, { status: error.status });
2584
+ }
2585
+ if (result.type === "success" && !result.data) return action_json({
2586
+ ...result,
2587
+ status: 204,
2588
+ data: void 0
2589
+ });
2590
+ try {
2591
+ return action_json({
2592
+ ...result,
2593
+ data: try_serialize(result.data, stringify, event.route.id)
2594
+ }, { status: result.status });
2595
+ } catch (error) {
2596
+ return action_result_json(event, state, action_error_result(error, result.location));
2597
+ }
2598
+ }
2599
+ /**
2600
+ * @param {URL} url
2601
+ */
2602
+ function get_action_location(url) {
2603
+ const location = new URL(url);
2604
+ for (const key of location.searchParams.keys()) if (key.startsWith("/")) {
2605
+ location.searchParams.delete(key);
2606
+ break;
2607
+ }
2608
+ return (location.pathname.startsWith("//") ? "/." + location.pathname : location.pathname) + location.search;
2609
+ }
2610
+ /**
2611
+ * @param {RequestEvent} event
2612
+ * @param {string} location
2613
+ * @returns {Extract<ServerActionResult, { type: 'error' }>}
2614
+ */
2615
+ function method_not_allowed_result(event, location) {
2616
+ event.setHeaders({ allow: "GET" });
2617
+ return {
2618
+ type: "error",
2619
+ location,
2620
+ error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
2621
+ };
2622
+ }
2623
+ /**
2624
+ * @param {unknown} error
2625
+ * @param {string} location
2626
+ * @returns {Extract<ServerActionResult, { type: 'redirect' | 'error' }>}
2627
+ */
2628
+ function action_error_result(error, location) {
2629
+ const err = normalize_error(error);
2630
+ if (err instanceof Redirect) return {
2631
+ type: "redirect",
2632
+ status: err.status,
2633
+ location: err.location
2634
+ };
2635
+ return {
2636
+ type: "error",
2637
+ location,
2638
+ error: err
2639
+ };
2640
+ }
2641
+ /**
2642
+ * @param {Redirect} redirect
2643
+ */
2644
+ function action_json_redirect(redirect) {
2645
+ return action_json({
2646
+ type: "redirect",
2647
+ status: redirect.status,
2648
+ location: redirect.location
2649
+ });
2650
+ }
2651
+ /**
2652
+ * @param {ActionResult} data
2653
+ * @param {ResponseInit} [init]
2654
+ */
2655
+ function action_json(data, init) {
2656
+ return with_version_header(Response.json(data, init));
2657
+ }
2658
+ /**
2659
+ * @param {RequestEvent} event
2660
+ */
2661
+ function is_action_request(event) {
2662
+ return event.request.method === "POST";
2663
+ }
2664
+ /**
2665
+ * @param {RequestEvent} event
2666
+ * @param {import('types').RequestState} state
2667
+ * @param {SSRNode['server'] | undefined} server
2668
+ * @returns {Promise<ServerActionResult>}
2669
+ */
2670
+ async function handle_action_request(event, state, server) {
2671
+ const actions = server?.actions;
2672
+ const location = get_action_location(event.url);
2673
+ if (!actions) return method_not_allowed_result(event, location);
2674
+ check_named_default_separate(actions);
2675
+ try {
2676
+ const data = await call_action(event, state, actions);
2677
+ if (data instanceof ActionFailure) return {
2678
+ type: "failure",
2679
+ status: data.status,
2680
+ location,
2681
+ data: data.data
2682
+ };
2683
+ else return {
2684
+ type: "success",
2685
+ status: 200,
2686
+ location,
2687
+ data
2688
+ };
2689
+ } catch (error) {
2690
+ return action_error_result(error instanceof ActionFailure ? capture_error(() => action_throw_fail()) : error, location);
2691
+ }
2692
+ }
2693
+ /**
2694
+ * @param {Actions} actions
2695
+ */
2696
+ function check_named_default_separate(actions) {
2697
+ if (actions.default && Object.keys(actions).length > 1) action_default_with_named();
2698
+ }
2699
+ /**
2700
+ * @param {RequestEvent} event
2701
+ * @param {import('types').RequestState} state
2702
+ * @param {NonNullable<ServerNode['actions']>} actions
2703
+ * @throws {Redirect | HttpError | SvelteKitError | Error}
2704
+ */
2705
+ async function call_action(event, state, actions) {
2706
+ const url = new URL(event.request.url);
2707
+ let name = "default";
2708
+ for (const param of url.searchParams) if (param[0].startsWith("/")) {
2709
+ name = param[0].slice(1);
2710
+ if (name === "default") action_name_reserved();
2711
+ break;
2712
+ }
2713
+ if (!Object.hasOwn(actions, name)) throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
2714
+ const action = actions[name];
2715
+ if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `Form actions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
2716
+ return record_span({
2717
+ name: "sveltekit.form_action",
2718
+ attributes: {
2719
+ "sveltekit.form_action.name": name,
2720
+ "http.route": event.route.id || "unknown"
2721
+ },
2722
+ fn: async (current) => {
2723
+ const traced_event = merge_tracing(event, current);
2724
+ const result = await with_request_store({
2725
+ event: traced_event,
2726
+ state
2727
+ }, () => action(traced_event));
2728
+ if (result instanceof ActionFailure) current.setAttributes({
2729
+ "sveltekit.form_action.result.type": "failure",
2730
+ "sveltekit.form_action.result.status": result.status
2731
+ });
2732
+ return result;
2733
+ }
2734
+ });
2735
+ }
2736
+ /**
2737
+ * Try to `devalue.uneval` the data object, and if it fails, return a proper Error with context
2738
+ * @param {any} data
2739
+ * @param {string} route_id
2740
+ */
2741
+ function uneval_action_response(data, route_id) {
2742
+ return try_serialize(data, uneval, route_id);
2743
+ }
2744
+ /**
2745
+ * @param {any} data
2746
+ * @param {(data: any) => string} fn
2747
+ * @param {string} route_id
2748
+ */
2749
+ function try_serialize(data, fn, route_id) {
2750
+ try {
2751
+ return fn(data);
2752
+ } catch (error) {
2753
+ if (data instanceof Response) action_response_not_serializable({ id: route_id }, { cause: error });
2754
+ if ("path" in error) {
2755
+ const values = {
2756
+ id: route_id,
2757
+ message: error.message
2758
+ };
2759
+ action_data_not_serializable(error.path === "" ? values : {
2760
+ ...values,
2761
+ path: `data${error.path}`
2762
+ }, { cause: error });
2763
+ }
2764
+ throw error;
2765
+ }
2766
+ }
2767
+ //#endregion
2768
+ //#region node_modules/@sveltejs/kit/src/runtime/server/remote-functions.js
2769
+ /** @import { RequestEvent } from '@sveltejs/kit' */
2770
+ /** @import { RemoteForm } from '$app/server' */
2771
+ /** @import { RemoteFormInternals, RemoteFunctionData, RemoteFunctionResponse, RemoteInternals, RequestState, ServerActionResult } from 'types' */
2772
+ /**
2773
+ * How long (in milliseconds) to wait after the last message was sent before
2774
+ * sending a `: keep-alive` SSE comment, to prevent proxies/load balancers with
2775
+ * an idle timeout from closing an otherwise-quiet `query.live` connection.
2776
+ */
2777
+ var KEEP_ALIVE_INTERVAL = 3e4;
2778
+ /**
2779
+ * @param {RequestEvent} event
2780
+ * @param {RequestState} state
2781
+ * @param {import('types').RemoteQueryLiveInternals} internals
2782
+ * @param {any} arg
2783
+ */
2784
+ function create_live_query_response(event, state, internals, arg) {
2785
+ const cancellation = new AbortController();
2786
+ const live_event = {
2787
+ ...event,
2788
+ request: new Request(event.request, { signal: AbortSignal.any([event.request.signal, cancellation.signal]) })
2789
+ };
2790
+ const generator = internals.run(live_event, state, arg);
2791
+ let open = true;
2792
+ let pulling = false;
2793
+ /** @type {ReadableStreamDefaultController<Uint8Array>} */
2794
+ let stream_controller;
2795
+ /** @type {ReturnType<typeof setTimeout> | undefined} */
2796
+ let keep_alive;
2797
+ /** @type {string | undefined} */
2798
+ let result;
2799
+ function schedule_keep_alive() {
2800
+ clearTimeout(keep_alive);
2801
+ keep_alive = setTimeout(() => {
2802
+ if (!open) return;
2803
+ if ((stream_controller.desiredSize ?? 0) > 0) stream_controller.enqueue(text_encoder$1.encode(": keep-alive\n\n"));
2804
+ schedule_keep_alive();
2805
+ }, KEEP_ALIVE_INTERVAL);
2806
+ }
2807
+ /** @param {any} data */
2808
+ function send(data) {
2809
+ if (!open) return;
2810
+ stream_controller.enqueue(text_encoder$1.encode("data: " + JSON.stringify(data) + "\n\n"));
2811
+ schedule_keep_alive();
2812
+ }
2813
+ /** @param {boolean} cancelled */
2814
+ function teardown(cancelled) {
2815
+ if (!open) return;
2816
+ open = false;
2817
+ clearTimeout(keep_alive);
2818
+ cancellation.abort();
2819
+ if (!cancelled) stream_controller.close();
2820
+ generator.return(void 0).catch(() => {});
2821
+ }
2822
+ event.request.signal.addEventListener("abort", () => teardown(true), { once: true });
2823
+ return new Response(new ReadableStream({
2824
+ start(controller) {
2825
+ stream_controller = controller;
2826
+ schedule_keep_alive();
2827
+ },
2828
+ async pull() {
2829
+ if (!open || pulling) return;
2830
+ pulling = true;
2831
+ try {
2832
+ while (open) {
2833
+ const { value, done } = await generator.next();
2834
+ if (!open) return;
2835
+ if (done) {
2836
+ teardown(false);
2837
+ return;
2838
+ }
2839
+ if (result !== (result = stringify(value))) {
2840
+ send({
2841
+ type: "result",
2842
+ result
2843
+ });
2844
+ return;
2845
+ }
2846
+ }
2847
+ } catch (error) {
2848
+ if (!open) return;
2849
+ if (error instanceof Redirect) send({
2850
+ type: "redirect",
2851
+ location: error.location
2852
+ });
2853
+ else send({
2854
+ type: "error",
2855
+ error: await handle_error_and_jsonify(event, state, error)
2856
+ });
2857
+ teardown(false);
2858
+ } finally {
2859
+ pulling = false;
2860
+ }
2861
+ },
2862
+ cancel() {
2863
+ teardown(true);
2864
+ }
2865
+ }), { headers: {
2866
+ "cache-control": "private, no-store",
2867
+ "content-type": "text/event-stream"
2868
+ } });
2869
+ }
2870
+ /** @type {typeof handle_remote_call_internal} */
2871
+ async function handle_remote_call(event, state, id) {
2872
+ return record_span({
2873
+ name: "sveltekit.remote.call",
2874
+ attributes: { "sveltekit.remote.call.id": id },
2875
+ fn: async (current) => {
2876
+ const traced_event = merge_tracing(event, current);
2877
+ return with_version_header(await with_request_store({
2878
+ event: traced_event,
2879
+ state
2880
+ }, () => handle_remote_call_internal(traced_event, state, id)));
2881
+ }
2882
+ });
2883
+ }
2884
+ /**
2885
+ * @param {RequestEvent} event
2886
+ * @param {RequestState} state
2887
+ * @param {string} id
2888
+ */
2889
+ async function handle_remote_call_internal(event, state, id) {
2890
+ const [hash, name, additional_args] = id.split("/");
2891
+ const remotes = manifest.remotes;
2892
+ if (!Object.hasOwn(remotes, hash)) error(404);
2893
+ const module = await remotes[hash]();
2894
+ const fn = Object.hasOwn(module.default, name) ? module.default[name] : void 0;
2895
+ if (!fn) error(404);
2896
+ /** @type {RemoteInternals} */
2897
+ const internals = fn.__;
2898
+ event.tracing.current.setAttributes({
2899
+ "sveltekit.remote.call.type": internals.type,
2900
+ "sveltekit.remote.call.name": internals.name
2901
+ });
2902
+ /** @type {HeadersInit | undefined} */
2903
+ const headers = state.prerendering ? void 0 : { "cache-control": "private, no-store" };
2904
+ try {
2905
+ /** @type {RemoteFunctionData} */
2906
+ const data = {};
2907
+ switch (internals.type) {
2908
+ case "query_live":
2909
+ if (event.request.method !== "GET") throw new SvelteKitError(405, "Method Not Allowed", `\`query.live\` functions must be invoked via GET request, not ${event.request.method}`);
2910
+ return create_live_query_response(event, state, internals, parse_remote_arg(new URL(event.request.url).searchParams.get("payload")));
2911
+ case "query_batch": {
2912
+ if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`query.batch\` functions must be invoked via POST request, not ${event.request.method}`);
2913
+ /** @type {{ payloads: string[] }} */
2914
+ const { payloads } = await event.request.json();
2915
+ const args = await Promise.all(payloads.map((payload) => parse_remote_arg(payload)));
2916
+ data._ = await with_request_store({
2917
+ event,
2918
+ state
2919
+ }, () => internals.run(args));
2920
+ break;
2921
+ }
2922
+ case "form": {
2923
+ if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`form\` functions must be invoked via POST request, not ${event.request.method}`);
2924
+ if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `\`form\` functions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
2925
+ const { data: input, meta, form_data } = await deserialize_binary_form(event.request, internals.id);
2926
+ state.remote.requested = create_requested_map(meta.remote_refreshes);
2927
+ if (additional_args && !("id" in input)) input.id = JSON.parse(decodeURIComponent(additional_args));
2928
+ const fn = internals.fn;
2929
+ data._ = await with_request_store({
2930
+ event,
2931
+ state: {
2932
+ ...state,
2933
+ is_in_remote_form_or_command: true
2934
+ }
2935
+ }, () => fn(input, meta, form_data));
2936
+ if (data._.issues) return Response.json({
2937
+ type: "result",
2938
+ data: stringify(data)
2939
+ }, { headers });
2940
+ break;
2941
+ }
2942
+ case "command": {
2943
+ /** @type {{ payload: string, refreshes?: string[] }} */
2944
+ const { payload, refreshes } = await event.request.json();
2945
+ state.remote.requested = create_requested_map(refreshes);
2946
+ const arg = parse_remote_arg(payload);
2947
+ data._ = await with_request_store({
2948
+ event,
2949
+ state: {
2950
+ ...state,
2951
+ is_in_remote_form_or_command: true
2952
+ }
2953
+ }, () => fn(arg));
2954
+ break;
2955
+ }
2956
+ case "prerender":
2957
+ data._ = await with_request_store({
2958
+ event,
2959
+ state
2960
+ }, () => fn(parse_remote_arg(additional_args)));
2961
+ break;
2962
+ case "query": {
2963
+ const payload = new URL(event.request.url).searchParams.get("payload");
2964
+ data._ = await with_request_store({
2965
+ event,
2966
+ state
2967
+ }, () => fn(parse_remote_arg(payload)));
2968
+ break;
2969
+ }
2970
+ }
2971
+ await collect_remote_data(data, event, state);
2972
+ if (state.remote.ignored?.size) data.i = Array.from(state.remote.ignored);
2973
+ return Response.json({
2974
+ type: "result",
2975
+ data: stringify(data)
2976
+ }, { headers });
2977
+ } catch (error) {
2978
+ if (error instanceof Redirect) {
2979
+ const data = await collect_remote_data({ redirect: error.location }, event, state);
2980
+ return Response.json({
2981
+ type: "result",
2982
+ data: stringify(data)
2983
+ }, { headers });
2984
+ }
2985
+ const transformed = await handle_error_and_jsonify(event, state, error);
2986
+ return Response.json({
2987
+ type: "error",
2988
+ error: transformed
2989
+ }, {
2990
+ status: state.prerendering ? transformed.status : void 0,
2991
+ headers: { "cache-control": "private, no-store" }
2992
+ });
2993
+ }
2994
+ }
2995
+ /**
2996
+ * Collects all the query/prerender data that was retrieved
2997
+ * during the request and adds it to `data`
2998
+ * @param {RemoteFunctionData} data
2999
+ * @param {RequestEvent} event
3000
+ * @param {RequestState} state
3001
+ */
3002
+ async function collect_remote_data(data, event, state) {
3003
+ /**
3004
+ *
3005
+ * @param {unknown} error
3006
+ * @returns {Promise<App.Error>}
3007
+ */
3008
+ function convert_error(error) {
3009
+ return Promise.resolve(handle_error_and_jsonify(event, state, error));
3010
+ }
3011
+ /** @type {Promise<any>[]} */
3012
+ const promises = [];
3013
+ /** @type {Set<string>} */
3014
+ const processed = /* @__PURE__ */ new Set();
3015
+ if (state.remote.explicit) {
3016
+ const { explicit } = state.remote;
3017
+ /** @type {Promise<void>[]} */
3018
+ const inflight = [];
3019
+ const drain = () => {
3020
+ for (const [remote_key, { internals, fn }] of explicit) {
3021
+ explicit.delete(remote_key);
3022
+ if (processed.has(remote_key)) continue;
3023
+ processed.add(remote_key);
3024
+ data.r = true;
3025
+ const type = internals.type === "query_live" ? "l" : internals.type[0];
3026
+ inflight.push(fn().then((v) => {
3027
+ (data[type] ??= {})[remote_key] = { v };
3028
+ drain();
3029
+ }, async (e) => {
3030
+ if (!(e instanceof Redirect)) (data[type] ??= {})[remote_key] = { e: await convert_error(e) };
3031
+ drain();
3032
+ }));
3033
+ }
3034
+ };
3035
+ drain();
3036
+ for (const promise of inflight) await promise;
3037
+ }
3038
+ if (state.remote.implicit) for (const [internals, record] of state.remote.implicit) {
3039
+ if (!internals.id) continue;
3040
+ for (const key in record) {
3041
+ const remote_key = internals.type === "form" ? key : create_remote_key(internals.id, key);
3042
+ if (processed.has(remote_key)) continue;
3043
+ const type = internals.type === "query_live" ? "l" : internals.type[0];
3044
+ const promise = state.remote.data?.get(internals)?.[key] ?? record[key]();
3045
+ let resolved = true;
3046
+ await Promise.race([Promise.resolve(promise).then((v) => {
3047
+ if (resolved) ((data[type] ??= {})[remote_key] ??= {}).v = v;
3048
+ }, (e) => {
3049
+ if (e instanceof Redirect) return;
3050
+ if (resolved) promises.push(convert_error(e).then((e) => {
3051
+ ((data[type] ??= {})[remote_key] ??= {}).e = e;
3052
+ }));
3053
+ }), Promise.resolve().then(() => resolved = false)]);
3054
+ }
3055
+ }
3056
+ await Promise.all(promises);
3057
+ return data;
3058
+ }
3059
+ /**
3060
+ * @param {string[] | undefined} refreshes
3061
+ */
3062
+ function create_requested_map(refreshes) {
3063
+ /** @type {Map<string, Set<string>>} */
3064
+ const requested = /* @__PURE__ */ new Map();
3065
+ for (const key of refreshes ?? []) {
3066
+ const parts = split_remote_key(key);
3067
+ const existing = requested.get(parts.id);
3068
+ if (existing) existing.add(parts.payload);
3069
+ else requested.set(parts.id, /* @__PURE__ */ new Set([parts.payload]));
3070
+ }
3071
+ return requested;
3072
+ }
3073
+ /** @type {typeof handle_remote_form_post_internal} */
3074
+ async function handle_remote_form_post(event, state, id) {
3075
+ return record_span({
3076
+ name: "sveltekit.remote.form.post",
3077
+ attributes: { "sveltekit.remote.form.post.id": id },
3078
+ fn: (current) => {
3079
+ const traced_event = merge_tracing(event, current);
3080
+ return with_request_store({
3081
+ event: traced_event,
3082
+ state
3083
+ }, () => handle_remote_form_post_internal(traced_event, state, id));
3084
+ }
3085
+ });
3086
+ }
3087
+ /**
3088
+ * @param {RequestEvent} event
3089
+ * @param {RequestState} state
3090
+ * @param {string} id
3091
+ * @returns {Promise<ServerActionResult>}
3092
+ */
3093
+ async function handle_remote_form_post_internal(event, state, id) {
3094
+ const location = get_action_location(event.url);
3095
+ const [hash, name, ...rest] = id.split("/");
3096
+ const action_id = rest.join("/");
3097
+ const remotes = manifest.remotes;
3098
+ const module = Object.hasOwn(remotes, hash) ? await remotes[hash]() : void 0;
3099
+ let form = module && Object.hasOwn(module.default, name) ? module.default[name] : void 0;
3100
+ if (!form) return method_not_allowed_result(event, location);
3101
+ if (action_id) form = with_request_store({
3102
+ event,
3103
+ state
3104
+ }, () => form.for(JSON.parse(action_id)));
3105
+ try {
3106
+ const __ = form.__;
3107
+ const { data, meta, form_data } = await deserialize_binary_form(event.request, __.id);
3108
+ if (action_id && !("id" in data)) data.id = JSON.parse(decodeURIComponent(action_id));
3109
+ await with_request_store({
3110
+ event,
3111
+ state: {
3112
+ ...state,
3113
+ is_in_remote_form_or_command: true
3114
+ }
3115
+ }, () => __.fn(data, meta, form_data));
3116
+ return {
3117
+ type: "success",
3118
+ status: 200,
3119
+ location
3120
+ };
3121
+ } catch (e) {
3122
+ return action_error_result(e, location);
3123
+ }
3124
+ }
3125
+ /**
3126
+ * @param {URL} url
3127
+ */
3128
+ function has_remote_prefix(url) {
3129
+ return url.pathname.startsWith(`/${app_dir}/remote/`);
3130
+ }
3131
+ /**
3132
+ * @param {URL} url
3133
+ */
3134
+ function strip_remote_prefix(url) {
3135
+ return url.pathname.replace(`/${app_dir}/remote/`, "");
3136
+ }
3137
+ /**
3138
+ * @param {URL} url
3139
+ */
3140
+ function get_remote_id(url) {
3141
+ return has_remote_prefix(url) && strip_remote_prefix(url);
3142
+ }
3143
+ /**
3144
+ * @param {URL} url
3145
+ */
3146
+ function get_remote_action(url) {
3147
+ return url.searchParams.get("/remote");
3148
+ }
3149
+ //#endregion
3150
+ //#region node_modules/@sveltejs/kit/src/runtime/server/sourcemaps.js
3151
+ var fs = globalThis.process?.getBuiltinModule?.("node:fs");
3152
+ var url = globalThis.process?.getBuiltinModule?.("node:url");
3153
+ var path = globalThis.process?.getBuiltinModule?.("node:path");
3154
+ var module = globalThis.process?.getBuiltinModule?.("node:module");
3155
+ var cwd = globalThis.process?.cwd?.();
3156
+ /** @type {(file: string) => string} */
3157
+ var relative = cwd ? (file) => path.relative(cwd, file) : (file) => file;
3158
+ /**
3159
+ * Applies sourcemaps, makes paths relative to the cwd, and truncates
3160
+ * non-user code from the bottom of the stack
3161
+ * @param {Error} error
3162
+ * @returns void
3163
+ */
3164
+ var fix_stack_trace = (error) => {
3165
+ if (!error.stack || !fs) return;
3166
+ let end = 0;
3167
+ set_error_stack(error, error.stack.split("\n").map((line, i) => {
3168
+ const match = line.match(/^ {4}at.+(file:\/\/\/.*):(\d+):(\d+)(\)?)$/);
3169
+ if (!match) {
3170
+ if (!line.includes("node:internal/")) end = i + 1;
3171
+ return line;
3172
+ }
3173
+ const file = url.fileURLToPath(match[1]);
3174
+ const traced = trace(file, Number(match[2]) - 1, Number(match[3]) - 1);
3175
+ if (!/[\\/]node_modules[\\/]/.test(traced?.file ?? file)) end = i + 1;
3176
+ if (traced?.line) {
3177
+ const location = `${match[1]}:${match[2]}:${match[3]}`;
3178
+ const original = `${relative(traced.file)}:${traced.line}:${traced.column}`;
3179
+ return line.replace(location, original);
3180
+ }
3181
+ if (traced) return `${line.replace(match[1], relative(file))} [${traced.file}]`;
3182
+ return line;
3183
+ }).slice(0, end).join("\n"));
3184
+ };
3185
+ /**
3186
+ * Override the implementation of fix_stack_trace (for using during dev)
3187
+ * @param {(error: Error) => void} fn
3188
+ */
3189
+ function set_fix_stack_trace(fn) {
3190
+ fix_stack_trace = fn;
3191
+ }
3192
+ /** @type {Map<string, { map: import('node:module').SourceMap; directory: string } | null>} */
3193
+ var source_maps = /* @__PURE__ */ new Map();
3194
+ /** @type {Map<string, Array<string | undefined>>} */
3195
+ var source_regions = /* @__PURE__ */ new Map();
3196
+ /** @param {string} file */
3197
+ function get_source_map(file) {
3198
+ if (source_maps.has(file)) return source_maps.get(file);
3199
+ try {
3200
+ let source;
3201
+ let directory = path.dirname(file);
3202
+ const code = fs.readFileSync(file, "utf8");
3203
+ const url = Array.from(code.matchAll(/\/\/[#@]\s*sourceMappingURL=(\S+)/g)).at(-1)?.[1];
3204
+ if (url?.startsWith("data:")) {
3205
+ const comma = url.indexOf(",");
3206
+ const metadata = url.slice(5, comma);
3207
+ const data = url.slice(comma + 1);
3208
+ source = metadata.endsWith(";base64") ? Buffer.from(data, "base64").toString() : decodeURIComponent(data);
3209
+ } else {
3210
+ const map_file = url ? path.resolve(path.dirname(file), decodeURIComponent(url)) : `${file}.map`;
3211
+ if (fs.existsSync(map_file)) {
3212
+ directory = path.dirname(map_file);
3213
+ source = fs.readFileSync(map_file, "utf8");
3214
+ }
3215
+ }
3216
+ if (source) {
3217
+ const source_map = {
3218
+ map: new module.SourceMap(JSON.parse(source)),
3219
+ directory
3220
+ };
3221
+ source_maps.set(file, source_map);
3222
+ return source_map;
3223
+ }
3224
+ } catch {}
3225
+ source_maps.set(file, null);
3226
+ return null;
3227
+ }
3228
+ /**
3229
+ *
3230
+ * @param {string} file
3231
+ * @param {number} line
3232
+ * @param {number} column
3233
+ * @returns {null | { file: string, line?: number, column?: number }}
3234
+ */
3235
+ function trace(file, line, column) {
3236
+ const source_map = get_source_map(file);
3237
+ if (!source_map) return null;
3238
+ const entry = source_map.map.findEntry(line, column);
3239
+ if (entry && "originalSource" in entry && entry.originalSource && typeof entry.originalLine === "number" && typeof entry.originalColumn === "number") {
3240
+ const traced = {
3241
+ file: entry.originalSource.startsWith("file:") ? url.fileURLToPath(entry.originalSource) : path.resolve(source_map.directory, entry.originalSource),
3242
+ line: entry.originalLine + 1,
3243
+ column: entry.originalColumn + 1
3244
+ };
3245
+ return trace(traced.file, traced.line - 1, traced.column - 1) ?? traced;
3246
+ }
3247
+ let regions = source_regions.get(file);
3248
+ if (!regions) {
3249
+ /** @type {string | undefined} */
3250
+ let source;
3251
+ regions = fs.readFileSync(file, "utf8").split("\n").map((line) => {
3252
+ const start = line.match(/^\/\/#region (.+)$/);
3253
+ if (start) source = start[1];
3254
+ if (line === "//#endregion") source = void 0;
3255
+ return source;
3256
+ });
3257
+ source_regions.set(file, regions);
3258
+ }
3259
+ const source = regions[line];
3260
+ if (source) return { file: source };
3261
+ return null;
3262
+ }
3263
+ //#endregion
3264
+ //#region node_modules/@sveltejs/kit/src/runtime/server/internal.js
3265
+ var styleText = globalThis.process?.getBuiltinModule?.("node:util")?.styleText ?? ((_format, text) => text);
3266
+ var read_implementation = false;
3267
+ var manifest = false;
3268
+ var hooks = false;
3269
+ /**
3270
+ * The public `read` may return a promise, the runtime expects a stream
3271
+ * @param {NonNullable<import('@sveltejs/kit').ServerInitOptions['read']>} read
3272
+ */
3273
+ function set_read_implementation(read) {
3274
+ read_implementation = (file) => {
3275
+ const result = read(file);
3276
+ if (result instanceof ReadableStream) return result;
3277
+ return stream_from_iterable((async function* () {
3278
+ const stream = await result;
3279
+ if (stream) yield* stream;
3280
+ })());
3281
+ };
3282
+ }
3283
+ /**
3284
+ *
3285
+ * @param {SSRManifest} value
3286
+ */
3287
+ function set_manifest(value) {
3288
+ manifest = value;
3289
+ }
3290
+ /**
3291
+ * @param {ServerHooks} value
3292
+ */
3293
+ function set_hooks(value) {
3294
+ hooks = value;
3295
+ }
3296
+ /**
3297
+ * @param {number} status
3298
+ * @param {Request} request
3299
+ * @returns {string}
3300
+ */
3301
+ function format_response(status, request) {
3302
+ const url = new URL(request.url);
3303
+ const requested = url.href.replace(url.origin, "");
3304
+ let log = `${styleText(status < 400 ? ["cyan"] : ["bold", "red"], `${status}`)} ${request.method} `;
3305
+ if (has_data_suffix(url.pathname)) {
3306
+ const pathname = strip_data_suffix(url.pathname) || "/";
3307
+ log += pathname + styleText("dim", requested.slice(pathname.length));
3308
+ } else if (has_resolution_suffix(url.pathname)) {
3309
+ const pathname = strip_resolution_suffix(url.pathname) || "/";
3310
+ log += pathname + styleText("dim", requested.slice(pathname.length));
3311
+ } else if (has_remote_prefix(url)) {
3312
+ const id = strip_remote_prefix(url);
3313
+ const [file_hash, name, arg_hash] = id.split("/");
3314
+ log += styleText("dim", `${url.pathname.slice(0, -id.length)}${file_hash}/`) + name;
3315
+ if (arg_hash) log += styleText("dim", `/${arg_hash}`);
3316
+ if (url.search) log += styleText("dim", url.search);
3317
+ } else log += requested;
3318
+ return log;
3319
+ }
3320
+ //#endregion
3321
+ export { parse as $, cache_control_empty_directive as A, try_get_request_store as At, get_status as B, add_resolution_suffix as Bt, has_prerendered_path as C, resolve as Ct, throw_devalue_error as D, otel as Dt, serialize_uses as E, merge_tracing as Et, form_action_error_without_ssr as F, MUTATIVE_METHODS as Ft, fetch_cache_url as G, base64_encode as Gt, INVALIDATED_PARAM as H, has_resolution_suffix as Ht, load_tracking_after_return as I, PAGE_METHODS as It, validate_depends as J, app_dir as Jt, parse_remote_arg as K, stream_text as Kt, ssr_fetch_eager as L, REROUTED_URL_HEADER as Lt, content_type_invalid as M, BODY_DEPENDENT_METHODS as Mt, cookie_path_mismatch as N, ENDPOINT_METHODS as Nt, with_version_header as O, record_span as Ot, form_action_data_without_ssr as P, IN_WEBCONTAINER as Pt, init_transport as Q, streaming_without_csr as R, SVELTE_KIT_ASSETS as Rt, get_node_type as S, relative_pathname as St, redirect_response as T, invalid_export_location as Tt, TRAILING_SLASH_PARAM as U, strip_data_suffix as Ut, normalize_error as V, has_data_suffix as Vt, create_remote_key as W, strip_resolution_suffix as Wt, encoders as X, set_assets as Xt, validate_load_response as Y, assets as Yt, has_custom_transporters as Z, enable_verbose_errors as Zt, handle_action_request as _, SCHEME as _t, set_hooks as a, deep_set as at, uneval_action_response as b, make_trackable as bt, fix_stack_trace as c, parse_form_key as ct, get_remote_action as d, get_hooks as dt, stringify as et, get_remote_id as f, options as ft, handle_action_json_request as g, text as gt, action_json_redirect as h, isRedirect as ht, read_implementation as i, create_field_proxy as it, cache_control_invalid_directive as j, with_request_store as jt, handle_error_and_jsonify as k, get_request_store as kt, set_fix_stack_trace as l, split_path as lt, handle_remote_form_post as m, error as mt, hooks as n, is_form_content_type as nt, set_manifest as o, flatten_issues as ot, handle_remote_call as p, find_route as pt, stringify_remote_arg as q, text_encoder$1 as qt, manifest as r, negotiate as rt, set_read_implementation as s, normalize_issue as st, format_response as t, uneval as tt, collect_remote_data as u, stringify$1 as ut, is_action_json_request as v, decode_pathname as vt, method_not_allowed as w, invalid_export as wt, count_non_ssi_comments as x, normalize_path as xt, is_action_request as y, disable_search as yt, transform_page_chunk_comments as z, add_data_suffix as zt };
3322
+
3323
+ //# sourceMappingURL=internal.js.map