@tonyclaw/agent-inspector 4.0.8 → 4.0.9

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 (119) hide show
  1. package/.output/backend/nitro.json +1 -1
  2. package/.output/cli.js +915 -25970
  3. package/.output/server/_chunks/ssr-renderer.mjs +1 -38
  4. package/.output/server/_libs/@opentelemetry/semantic-conventions+[...].mjs +1 -2658
  5. package/.output/server/_libs/agent-base.mjs +2 -234
  6. package/.output/server/_libs/ajv-formats.mjs +1 -330
  7. package/.output/server/_libs/ajv.mjs +8 -6080
  8. package/.output/server/_libs/anthropic-ai__sdk.mjs +19 -6021
  9. package/.output/server/_libs/atomically.mjs +1 -155
  10. package/.output/server/_libs/base64-js.mjs +1 -102
  11. package/.output/server/_libs/bignumber.js.mjs +1 -1353
  12. package/.output/server/_libs/buffer-equal-constant-time.mjs +1 -38
  13. package/.output/server/_libs/conf.mjs +1 -635
  14. package/.output/server/_libs/cookie-es.mjs +1 -44
  15. package/.output/server/_libs/core-util-is.mjs +1 -75
  16. package/.output/server/_libs/data-uri-to-buffer.mjs +1 -39
  17. package/.output/server/_libs/debounce-fn.mjs +1 -69
  18. package/.output/server/_libs/debug.mjs +5 -547
  19. package/.output/server/_libs/dot-prop.mjs +1 -265
  20. package/.output/server/_libs/ecdsa-sig-formatter.mjs +1 -162
  21. package/.output/server/_libs/env-paths.mjs +1 -57
  22. package/.output/server/_libs/extend.mjs +1 -94
  23. package/.output/server/_libs/fast-deep-equal.mjs +1 -38
  24. package/.output/server/_libs/fast-uri.mjs +1 -812
  25. package/.output/server/_libs/fetch-blob.mjs +1 -287
  26. package/.output/server/_libs/formdata-polyfill.mjs +9 -86
  27. package/.output/server/_libs/gaxios.mjs +5 -926
  28. package/.output/server/_libs/gcp-metadata.mjs +1 -322
  29. package/.output/server/_libs/google-auth-library.mjs +16 -6339
  30. package/.output/server/_libs/google-logging-utils.mjs +1 -385
  31. package/.output/server/_libs/google__genai.mjs +13 -18034
  32. package/.output/server/_libs/h3-v2.mjs +2 -287
  33. package/.output/server/_libs/h3.mjs +2 -408
  34. package/.output/server/_libs/has-flag.mjs +1 -16
  35. package/.output/server/_libs/https-proxy-agent.mjs +7 -280
  36. package/.output/server/_libs/immediate.mjs +1 -74
  37. package/.output/server/_libs/inherits.mjs +1 -50
  38. package/.output/server/_libs/isarray.mjs +1 -14
  39. package/.output/server/_libs/isbot.mjs +1 -20
  40. package/.output/server/_libs/json-bigint.mjs +8 -413
  41. package/.output/server/_libs/json-schema-traverse.mjs +1 -91
  42. package/.output/server/_libs/jszip.mjs +2 -3051
  43. package/.output/server/_libs/jwa.mjs +3 -233
  44. package/.output/server/_libs/jws.mjs +1 -298
  45. package/.output/server/_libs/lie.mjs +1 -273
  46. package/.output/server/_libs/mariozechner__pi-agent-core.mjs +1 -824
  47. package/.output/server/_libs/mariozechner__pi-ai.mjs +34 -22887
  48. package/.output/server/_libs/mimic-function.mjs +2 -47
  49. package/.output/server/_libs/mistralai__mistralai.mjs +7 -32045
  50. package/.output/server/_libs/modelcontextprotocol__core.mjs +1 -1121
  51. package/.output/server/_libs/modelcontextprotocol__server.mjs +13 -13205
  52. package/.output/server/_libs/ms.mjs +1 -120
  53. package/.output/server/_libs/node-domexception.mjs +1 -17
  54. package/.output/server/_libs/node-fetch.mjs +4 -1578
  55. package/.output/server/_libs/ohash.mjs +1 -1
  56. package/.output/server/_libs/openai.mjs +23 -6766
  57. package/.output/server/_libs/opentelemetry__api.mjs +1 -1678
  58. package/.output/server/_libs/p-retry.mjs +1 -87
  59. package/.output/server/_libs/pako.mjs +1 -4223
  60. package/.output/server/_libs/partial-json.mjs +2 -244
  61. package/.output/server/_libs/process-nextick-args.mjs +1 -48
  62. package/.output/server/_libs/react-dom.mjs +62 -10778
  63. package/.output/server/_libs/react.mjs +1 -519
  64. package/.output/server/_libs/readable-stream.mjs +1 -1518
  65. package/.output/server/_libs/retry.mjs +1 -236
  66. package/.output/server/_libs/rou3.mjs +1 -14
  67. package/.output/server/_libs/safe-buffer.mjs +1 -126
  68. package/.output/server/_libs/semver.mjs +1 -1938
  69. package/.output/server/_libs/seroval-plugins.mjs +1 -58
  70. package/.output/server/_libs/seroval.mjs +3 -1775
  71. package/.output/server/_libs/setimmediate.mjs +1 -152
  72. package/.output/server/_libs/srvx.mjs +4 -1390
  73. package/.output/server/_libs/stubborn-fs.mjs +1 -91
  74. package/.output/server/_libs/stubborn-utils.mjs +1 -66
  75. package/.output/server/_libs/supports-color.mjs +1 -108
  76. package/.output/server/_libs/tanstack__history.mjs +1 -230
  77. package/.output/server/_libs/tanstack__react-router.mjs +1 -848
  78. package/.output/server/_libs/tanstack__react-store.mjs +1 -1
  79. package/.output/server/_libs/tanstack__router-core.mjs +1 -4839
  80. package/.output/server/_libs/typebox.mjs +3 -6596
  81. package/.output/server/_libs/ufo.mjs +1 -54
  82. package/.output/server/_libs/uint8array-extras.mjs +1 -69
  83. package/.output/server/_libs/util-deprecate.mjs +1 -12
  84. package/.output/server/_libs/web-streams-polyfill.mjs +1 -4282
  85. package/.output/server/_libs/when-exit.mjs +1 -53
  86. package/.output/server/_libs/ws.mjs +7 -3715
  87. package/.output/server/_libs/zod-to-json-schema.mjs +5 -1207
  88. package/.output/server/_libs/zod.mjs +59 -9958
  89. package/.output/server/_ssr/empty-plugin-adapters-C3Q1xu4u.mjs +1 -0
  90. package/.output/server/_ssr/index.mjs +2 -1512
  91. package/.output/server/_ssr/publicBasePathContext--TAQS2_5.mjs +1 -0
  92. package/.output/server/_ssr/router-zSWaME0l.mjs +341 -0
  93. package/.output/server/_ssr/start-PDVGOqUN.mjs +1 -0
  94. package/.output/server/_tanstack-start-manifest_v-D7cKwKzM.mjs +1 -0
  95. package/.output/server/index.mjs +1 -320
  96. package/.output/ui/assets/{CompareDrawer-DafpfgaT.js → CompareDrawer-C6KvvPtJ.js} +1 -1
  97. package/.output/ui/assets/{InspectorPet-Brsmmfzx.js → InspectorPet-CSH6OAhB.js} +1 -1
  98. package/.output/ui/assets/{ProxyViewerContainer-D2pq1fUr.js → ProxyViewerContainer-vPd7g0Xn.js} +4 -4
  99. package/.output/ui/assets/{ReplayDialog-D4mXXgT9.js → ReplayDialog-DbXUcT39.js} +1 -1
  100. package/.output/ui/assets/{RequestAnatomy-Ccnsq12U.js → RequestAnatomy-BWOCIN7J.js} +1 -1
  101. package/.output/ui/assets/{ResponseView-CJv3vB5X.js → ResponseView-BqDbTzFs.js} +1 -1
  102. package/.output/ui/assets/{StreamingChunkSequence-CEkLnOF6.js → StreamingChunkSequence-UHl2g6w6.js} +1 -1
  103. package/.output/ui/assets/{_sessionId-DlG-yHoI.js → _sessionId-B2S61lDJ.js} +1 -1
  104. package/.output/ui/assets/{_sessionId-C7s68UH3.js → _sessionId-CS6hqj8-.js} +1 -1
  105. package/.output/ui/assets/{index-Cqh47jeU.js → index-C6V66rNI.js} +1 -1
  106. package/.output/ui/assets/{index-CFqnSirZ.js → index-DY5xBYHr.js} +1 -1
  107. package/.output/ui/assets/{index-B0NCZQ93.js → index-DgyIeqyV.js} +2 -2
  108. package/.output/ui/assets/{index-ChZZrVHa.js → index-HLs5jTyi.js} +1 -1
  109. package/.output/ui/assets/{json-viewer-DvpI0vbY.js → json-viewer-i5LcN8e7.js} +1 -1
  110. package/.output/ui/assets/{jszip.min-5AG8hW2c.js → jszip.min-yNpb9qnf.js} +1 -1
  111. package/.output/ui/index.html +1 -1
  112. package/.output/workers/logFinalizer.worker.js +41 -17739
  113. package/.output/workers/sessionWorkerEntry.js +41 -17735
  114. package/package.json +7 -7
  115. package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +0 -6
  116. package/.output/server/_ssr/publicBasePathContext-IH2ilOfu.mjs +0 -176
  117. package/.output/server/_ssr/router-BDyF-OMB.mjs +0 -27187
  118. package/.output/server/_ssr/start-COQu_AgD.mjs +0 -57
  119. package/.output/server/_tanstack-start-manifest_v-ClTaMkEj.mjs +0 -4
@@ -1,1390 +1,4 @@
1
- import http from "node:http";
2
- import { Readable, PassThrough } from "node:stream";
3
- import { pipeline } from "node:stream/promises";
4
- import nodeHTTPS from "node:https";
5
- import nodeHTTP2 from "node:http2";
6
- function lazyInherit$2(target, source, sourceKey) {
7
- for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) {
8
- if (key === "constructor") continue;
9
- const targetDesc = Object.getOwnPropertyDescriptor(target, key);
10
- const desc = Object.getOwnPropertyDescriptor(source, key);
11
- let modified = false;
12
- if (desc.get) {
13
- modified = true;
14
- desc.get = targetDesc?.get || function() {
15
- return this[sourceKey][key];
16
- };
17
- }
18
- if (desc.set) {
19
- modified = true;
20
- desc.set = targetDesc?.set || function(value) {
21
- this[sourceKey][key] = value;
22
- };
23
- }
24
- if (!targetDesc?.value && typeof desc.value === "function") {
25
- modified = true;
26
- desc.value = function(...args) {
27
- return this[sourceKey][key](...args);
28
- };
29
- }
30
- if (modified) Object.defineProperty(target, key, desc);
31
- }
32
- }
33
- const _needsNormRE$2 = /(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^#"<>{}`\x80-\uffff]/i;
34
- const _searchNeedsNormRE = /[#"'<>]/;
35
- const FastURL$2 = /* @__PURE__ */ (() => {
36
- const NativeURL = globalThis.URL;
37
- const FastURL2 = class URL {
38
- #url;
39
- #href;
40
- #protocol;
41
- #host;
42
- #pathname;
43
- #search;
44
- #searchParams;
45
- #pos;
46
- constructor(url) {
47
- if (typeof url === "string") {
48
- const isOriginForm = url[0] === "/";
49
- if (isOriginForm && !_searchNeedsNormRE.test(url)) this.#href = url;
50
- else this.#url = new NativeURL(isOriginForm ? `http://localhost${url}` : url);
51
- } else if (_needsNormRE$2.test(url.pathname) || url.search && _searchNeedsNormRE.test(url.search)) this.#url = new NativeURL(`${url.protocol || "http:"}//${url.host || "localhost"}${url.pathname}${url.search || ""}`);
52
- else {
53
- this.#protocol = url.protocol;
54
- this.#host = url.host;
55
- this.#pathname = url.pathname;
56
- this.#search = url.search;
57
- }
58
- }
59
- static [Symbol.hasInstance](val) {
60
- return val instanceof NativeURL;
61
- }
62
- get _url() {
63
- if (this.#url) return this.#url;
64
- this.#url = new NativeURL(this.href);
65
- this.#href = void 0;
66
- this.#protocol = void 0;
67
- this.#host = void 0;
68
- this.#pathname = void 0;
69
- this.#search = void 0;
70
- this.#searchParams = void 0;
71
- this.#pos = void 0;
72
- return this.#url;
73
- }
74
- get href() {
75
- if (this.#url) return this.#url.href;
76
- if (!this.#href) this.#href = `${this.#protocol || "http:"}//${this.#host || "localhost"}${this.#pathname || "/"}${this.#search || ""}`;
77
- return this.#href;
78
- }
79
- #getPos() {
80
- if (!this.#pos) {
81
- const url = this.href;
82
- const protoIndex = url.indexOf("://");
83
- const pathnameIndex = protoIndex === -1 ? -1 : url.indexOf("/", protoIndex + 4);
84
- const qIndex = pathnameIndex === -1 ? -1 : url.indexOf("?", pathnameIndex);
85
- this.#pos = [
86
- protoIndex,
87
- pathnameIndex,
88
- qIndex
89
- ];
90
- }
91
- return this.#pos;
92
- }
93
- get pathname() {
94
- if (this.#url) return this.#url.pathname;
95
- if (this.#pathname === void 0) {
96
- const [, pathnameIndex, queryIndex] = this.#getPos();
97
- if (pathnameIndex === -1) return this._url.pathname;
98
- this.#pathname = this.href.slice(pathnameIndex, queryIndex === -1 ? void 0 : queryIndex);
99
- }
100
- return this.#pathname;
101
- }
102
- get search() {
103
- if (this.#url) return this.#url.search;
104
- if (this.#search === void 0) {
105
- const [, pathnameIndex, queryIndex] = this.#getPos();
106
- if (pathnameIndex === -1) return this._url.search;
107
- const url = this.href;
108
- this.#search = queryIndex === -1 || queryIndex === url.length - 1 ? "" : url.slice(queryIndex);
109
- }
110
- return this.#search;
111
- }
112
- get searchParams() {
113
- if (this.#url) return this.#url.searchParams;
114
- if (!this.#searchParams) this.#searchParams = new URLSearchParams(this.search);
115
- return this.#searchParams;
116
- }
117
- get protocol() {
118
- if (this.#url) return this.#url.protocol;
119
- if (this.#protocol === void 0) {
120
- const [protocolIndex] = this.#getPos();
121
- if (protocolIndex === -1) return this._url.protocol;
122
- const url = this.href;
123
- this.#protocol = url.slice(0, protocolIndex + 1);
124
- }
125
- return this.#protocol;
126
- }
127
- toString() {
128
- return this.href;
129
- }
130
- toJSON() {
131
- return this.href;
132
- }
133
- };
134
- lazyInherit$2(FastURL2.prototype, NativeURL.prototype, "_url");
135
- Object.setPrototypeOf(FastURL2.prototype, NativeURL.prototype);
136
- Object.setPrototypeOf(FastURL2, NativeURL);
137
- return FastURL2;
138
- })();
139
- function resolvePortAndHost(opts) {
140
- const _port = opts.port ?? globalThis.process?.env.PORT ?? 3e3;
141
- const port = typeof _port === "number" ? _port : Number.parseInt(_port, 10);
142
- if (port < 0 || port > 65535) throw new RangeError(`Port must be between 0 and 65535 (got "${port}").`);
143
- return {
144
- port,
145
- hostname: opts.hostname ?? globalThis.process?.env.HOST
146
- };
147
- }
148
- function fmtURL(host, port, secure) {
149
- if (!host || !port) return;
150
- if (host.includes(":")) host = `[${host}]`;
151
- return `http${secure ? "s" : ""}://${host}:${port}/`;
152
- }
153
- function printListening(opts, url) {
154
- if (!url || (opts.silent ?? globalThis.process?.env?.TEST)) return;
155
- let additionalInfo = "";
156
- try {
157
- const _url = new URL(url);
158
- if (_url.hostname === "[::]" || _url.hostname === "0.0.0.0") {
159
- _url.hostname = "localhost";
160
- url = _url.href;
161
- additionalInfo = " (all interfaces)";
162
- }
163
- } catch {
164
- }
165
- let listeningOn = `➜ Listening on:`;
166
- if (globalThis.process.stdout?.isTTY) {
167
- listeningOn = `\x1B[32m${listeningOn}\x1B[0m`;
168
- url = `\x1B[36m${url}\x1B[0m`;
169
- additionalInfo = `\x1B[2m${additionalInfo}\x1B[0m`;
170
- }
171
- console.log(`${listeningOn} ${url}${additionalInfo}`);
172
- }
173
- function resolveTLSOptions(opts) {
174
- if (!opts.tls || opts.protocol === "http") return;
175
- const cert = resolveCertOrKey(opts.tls.cert);
176
- const key = resolveCertOrKey(opts.tls.key);
177
- if (!cert && !key) {
178
- if (opts.protocol === "https") throw new TypeError("TLS `cert` and `key` must be provided for `https` protocol.");
179
- return;
180
- }
181
- if (!cert || !key) throw new TypeError("TLS `cert` and `key` must be provided together.");
182
- return {
183
- cert,
184
- key,
185
- passphrase: opts.tls.passphrase
186
- };
187
- }
188
- function resolveCertOrKey(value) {
189
- if (!value) return;
190
- if (typeof value !== "string") throw new TypeError("TLS certificate and key must be strings in PEM format or file paths.");
191
- if (value.startsWith("-----BEGIN ")) return value;
192
- const { readFileSync } = process.getBuiltinModule("node:fs");
193
- return readFileSync(value, "utf8");
194
- }
195
- function createWaitUntil() {
196
- const promises = /* @__PURE__ */ new Set();
197
- return {
198
- waitUntil: (promise) => {
199
- if (typeof promise?.then !== "function") return;
200
- promises.add(Promise.resolve(promise).catch(console.error).finally(() => {
201
- promises.delete(promise);
202
- }));
203
- },
204
- wait: () => {
205
- return Promise.all(promises);
206
- }
207
- };
208
- }
209
- const noColor = /* @__PURE__ */ (() => {
210
- const env = globalThis.process?.env ?? {};
211
- return env.NO_COLOR === "1" || env.TERM === "dumb";
212
- })();
213
- const _c = (c, r = 39) => (t) => noColor ? t : `\x1B[${c}m${t}\x1B[${r}m`;
214
- const bold = /* @__PURE__ */ _c(1, 22);
215
- const red = /* @__PURE__ */ _c(31);
216
- const green = /* @__PURE__ */ _c(32);
217
- const gray = /* @__PURE__ */ _c(90);
218
- function wrapFetch(server) {
219
- const fetchHandler = server.options.fetch;
220
- const middleware = server.options.middleware || [];
221
- return middleware.length === 0 ? fetchHandler : (request) => callMiddleware(request, fetchHandler, middleware, 0);
222
- }
223
- function callMiddleware(request, fetchHandler, middleware, index) {
224
- if (index === middleware.length) return fetchHandler(request);
225
- return middleware[index](request, () => callMiddleware(request, fetchHandler, middleware, index + 1));
226
- }
227
- const errorPlugin = (server) => {
228
- const errorHandler = server.options.error;
229
- if (!errorHandler) return;
230
- server.options.middleware.unshift((_req, next) => {
231
- try {
232
- const res = next();
233
- return res instanceof Promise ? res.catch((error) => errorHandler(error)) : res;
234
- } catch (error) {
235
- return errorHandler(error);
236
- }
237
- });
238
- };
239
- const gracefulShutdownPlugin = (server) => {
240
- const config = server.options?.gracefulShutdown;
241
- if (!globalThis.process?.on || config === false || config === void 0 && (process.env.CI || process.env.TEST)) return;
242
- const gracefulTimeout = config === true || !config?.gracefulTimeout ? Number.parseInt(process.env.SERVER_SHUTDOWN_TIMEOUT || "") || 5 : config.gracefulTimeout;
243
- let isClosing = false;
244
- let isClosed = false;
245
- const w = server.options.silent ? () => {
246
- } : process.stderr.write.bind(process.stderr);
247
- const forceClose = async () => {
248
- if (isClosed) return;
249
- w(red("\x1B[2K\rForcibly closing connections...\n"));
250
- isClosed = true;
251
- await server.close(true);
252
- };
253
- const shutdown = async () => {
254
- if (isClosing || isClosed) return;
255
- setTimeout(() => {
256
- globalThis.process.once("SIGINT", forceClose);
257
- }, 100);
258
- isClosing = true;
259
- const closePromise = server.close();
260
- for (let remaining = gracefulTimeout; remaining > 0; remaining--) {
261
- w(gray(`\rStopping server gracefully (${remaining}s)... Press ${bold("Ctrl+C")} again to force close.`));
262
- if (await Promise.race([closePromise.then(() => true), new Promise((r) => setTimeout(() => r(false), 1e3))])) {
263
- w("\x1B[2K\r" + green("Server closed successfully.\n"));
264
- isClosed = true;
265
- return;
266
- }
267
- }
268
- w("\x1B[2K\rGraceful shutdown timed out.\n");
269
- await forceClose();
270
- };
271
- for (const sig of ["SIGINT", "SIGTERM"]) globalThis.process.on(sig, shutdown);
272
- };
273
- function createBodyTooLargeError(maxRequestBodySize) {
274
- return Object.assign(/* @__PURE__ */ new Error(`Request body exceeds the maximum allowed size of ${maxRequestBodySize} bytes.`), {
275
- code: "ERR_BODY_TOO_LARGE",
276
- statusCode: 413,
277
- status: 413
278
- });
279
- }
280
- function limitBodyStream(stream, maxRequestBodySize) {
281
- const reader = stream.getReader();
282
- let size = 0;
283
- return new ReadableStream({
284
- async pull(controller) {
285
- const { done, value } = await reader.read();
286
- if (done) {
287
- controller.close();
288
- return;
289
- }
290
- size += value.byteLength;
291
- if (size > maxRequestBodySize) {
292
- const error = createBodyTooLargeError(maxRequestBodySize);
293
- reader.cancel(error).catch(() => {
294
- });
295
- controller.error(error);
296
- return;
297
- }
298
- controller.enqueue(value);
299
- },
300
- cancel(reason) {
301
- return reader.cancel(reason);
302
- }
303
- });
304
- }
305
- function sendNodeResponseDetached(nodeRes, webRes) {
306
- try {
307
- return _sendNodeResponse(nodeRes, webRes, true);
308
- } catch (error) {
309
- handleSendError(nodeRes);
310
- }
311
- }
312
- function handleSendError(nodeRes, _error) {
313
- if (nodeRes.headersSent) nodeRes.destroy();
314
- else {
315
- nodeRes.statusCode = 500;
316
- nodeRes.end();
317
- }
318
- }
319
- function _sendNodeResponse(nodeRes, webRes, detached) {
320
- if (!webRes) {
321
- nodeRes.statusCode = 500;
322
- return endNodeResponse(nodeRes, detached);
323
- }
324
- if (webRes._toNodeResponse) {
325
- const res = webRes._toNodeResponse();
326
- if (res.body) {
327
- if (res.body instanceof ReadableStream) {
328
- writeHead(nodeRes, res.status, res.statusText, res.headers);
329
- return streamBody(res.body, nodeRes);
330
- } else if (typeof res.body?.pipe === "function") return pipeBody(res.body, nodeRes, res.status, res.statusText, res.headers);
331
- writeHead(nodeRes, res.status, res.statusText, res.headers);
332
- nodeRes.write(res.body);
333
- } else writeHead(nodeRes, res.status, res.statusText, res.headers);
334
- return endNodeResponse(nodeRes, detached);
335
- }
336
- const rawHeaders = [];
337
- for (const [key, value] of webRes.headers) rawHeaders.push(key, value);
338
- writeHead(nodeRes, webRes.status, webRes.statusText, rawHeaders);
339
- return webRes.body ? streamBody(webRes.body, nodeRes) : endNodeResponse(nodeRes, detached);
340
- }
341
- function writeHead(nodeRes, status, statusText, rawHeaders) {
342
- if (!nodeRes.headersSent) if (nodeRes.req?.httpVersion === "2.0") nodeRes.writeHead(status, rawHeaders);
343
- else nodeRes.writeHead(status, statusText, rawHeaders);
344
- }
345
- function endNodeResponse(nodeRes, detached) {
346
- if (detached) {
347
- nodeRes.end();
348
- return;
349
- }
350
- return new Promise((resolve) => nodeRes.end(resolve));
351
- }
352
- function pipeBody(stream, nodeRes, status, statusText, headers) {
353
- if (nodeRes.destroyed) {
354
- stream.destroy?.();
355
- return;
356
- }
357
- if (typeof stream.on !== "function" || typeof stream.destroy !== "function") {
358
- writeHead(nodeRes, status, statusText, headers);
359
- stream.pipe(nodeRes);
360
- return new Promise((resolve) => nodeRes.on("close", resolve));
361
- }
362
- if (stream.destroyed) {
363
- writeHead(nodeRes, 500, "Internal Server Error", []);
364
- return endNodeResponse(nodeRes);
365
- }
366
- return new Promise((resolve) => {
367
- function onEarlyError() {
368
- stream.off("readable", onReadable);
369
- stream.destroy();
370
- writeHead(nodeRes, 500, "Internal Server Error", []);
371
- endNodeResponse(nodeRes).then(resolve);
372
- }
373
- function onReadable() {
374
- stream.off("error", onEarlyError);
375
- if (nodeRes.destroyed) {
376
- stream.destroy();
377
- return resolve();
378
- }
379
- writeHead(nodeRes, status, statusText, headers);
380
- pipeline(stream, nodeRes).catch(() => {
381
- }).then(() => resolve());
382
- }
383
- stream.once("error", onEarlyError);
384
- stream.once("readable", onReadable);
385
- });
386
- }
387
- function streamBody(stream, nodeRes) {
388
- if (nodeRes.destroyed) {
389
- stream.cancel();
390
- return;
391
- }
392
- const reader = stream.getReader();
393
- function streamCancel(error) {
394
- reader.cancel(error).catch(() => {
395
- });
396
- if (error) nodeRes.destroy(error);
397
- }
398
- function streamHandle({ done, value }) {
399
- try {
400
- if (done) nodeRes.end();
401
- else if (nodeRes.write(value)) reader.read().then(streamHandle, streamCancel);
402
- else nodeRes.once("drain", () => reader.read().then(streamHandle, streamCancel));
403
- } catch (error) {
404
- streamCancel(error instanceof Error ? error : void 0);
405
- }
406
- }
407
- nodeRes.on("close", streamCancel);
408
- nodeRes.on("error", streamCancel);
409
- reader.read().then(streamHandle, streamCancel);
410
- return reader.closed.catch(streamCancel).finally(() => {
411
- nodeRes.off("close", streamCancel);
412
- nodeRes.off("error", streamCancel);
413
- });
414
- }
415
- const HOST_RE = /^(\[(?:[A-Fa-f0-9:.]+)\]|(?:[A-Za-z0-9_-]+\.)*[A-Za-z0-9_-]+|(?:\d{1,3}\.){3}\d{1,3})(:\d{1,5})?$/;
416
- var NodeRequestURL = class extends FastURL$2 {
417
- constructor({ req }) {
418
- const path = req.url || "/";
419
- let host = req.headers.host || req.headers[":authority"];
420
- if (host && !HOST_RE.test(host)) host = "_invalid_";
421
- else if (!host) if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`;
422
- else host = "localhost";
423
- const protocol = req.socket?.encrypted || req.headers["x-forwarded-proto"] === "https" || req.headers[":scheme"] === "https" ? "https:" : "http:";
424
- if (path[0] === "/") {
425
- const qIndex = path.indexOf("?");
426
- super({
427
- protocol,
428
- host,
429
- pathname: qIndex === -1 ? path : path.slice(0, qIndex) || "/",
430
- search: qIndex === -1 ? "" : path.slice(qIndex) || ""
431
- });
432
- } else if (path === "*") super({
433
- protocol,
434
- host,
435
- pathname: "/*",
436
- search: ""
437
- });
438
- else super(path);
439
- }
440
- };
441
- const _nonJoinedHeaders = /* @__PURE__ */ new Set([
442
- "age",
443
- "authorization",
444
- "content-length",
445
- "content-type",
446
- "etag",
447
- "expires",
448
- "from",
449
- "host",
450
- "if-modified-since",
451
- "if-unmodified-since",
452
- "last-modified",
453
- "location",
454
- "max-forwards",
455
- "proxy-authorization",
456
- "referer",
457
- "retry-after",
458
- "server",
459
- "user-agent"
460
- ]);
461
- const _validHeaderNameRE = /^[!#$%&'*+\-.^_`|~\dA-Za-z]+$/;
462
- function _isRepeated(rawHeaders, lowerName) {
463
- let seen = false;
464
- for (let i = 0; i < rawHeaders.length; i += 2) {
465
- const key = rawHeaders[i];
466
- if (key.length === lowerName.length && key.toLowerCase() === lowerName) {
467
- if (seen) return true;
468
- seen = true;
469
- }
470
- }
471
- return false;
472
- }
473
- const NodeRequestHeaders = /* @__PURE__ */ (() => {
474
- const NativeHeaders = globalThis.Headers;
475
- class Headers2 {
476
- #req;
477
- #headers;
478
- constructor(req) {
479
- this.#req = req;
480
- }
481
- static [Symbol.hasInstance](val) {
482
- return val instanceof NativeHeaders;
483
- }
484
- get _headers() {
485
- if (!this.#headers) {
486
- const headers = new NativeHeaders();
487
- const rawHeaders = this.#req.rawHeaders;
488
- const len = rawHeaders.length;
489
- for (let i = 0; i < len; i += 2) {
490
- const key = rawHeaders[i];
491
- if (key.charCodeAt(0) === 58) continue;
492
- const value = rawHeaders[i + 1];
493
- headers.append(key, value);
494
- }
495
- this.#headers = headers;
496
- }
497
- return this.#headers;
498
- }
499
- get(name) {
500
- if (this.#headers) return this.#headers.get(name);
501
- const lower = name.toLowerCase();
502
- if (lower.charCodeAt(0) === 58) return this._headers.get(name);
503
- const value = this.#req.headers[lower];
504
- if (typeof value === "string") return _nonJoinedHeaders.has(lower) && _isRepeated(this.#req.rawHeaders, lower) ? this._headers.get(name) : value;
505
- if (Array.isArray(value)) return value.join(", ");
506
- return lower !== "__proto__" && _validHeaderNameRE.test(name) ? null : this._headers.get(name);
507
- }
508
- has(name) {
509
- if (this.#headers) return this.#headers.has(name);
510
- const lower = name.toLowerCase();
511
- if (lower.charCodeAt(0) === 58) return this._headers.has(name);
512
- if (Object.hasOwn(this.#req.headers, lower)) return true;
513
- return lower !== "__proto__" && _validHeaderNameRE.test(name) ? false : this._headers.has(name);
514
- }
515
- getSetCookie() {
516
- if (this.#headers) return this.#headers.getSetCookie();
517
- const value = this.#req.headers["set-cookie"];
518
- return Array.isArray(value) ? value.slice() : value ? [value] : [];
519
- }
520
- entries() {
521
- return this._headers.entries();
522
- }
523
- [Symbol.iterator]() {
524
- return this.entries();
525
- }
526
- }
527
- lazyInherit$2(Headers2.prototype, NativeHeaders.prototype, "_headers");
528
- Object.setPrototypeOf(Headers2, NativeHeaders);
529
- Object.setPrototypeOf(Headers2.prototype, NativeHeaders.prototype);
530
- return Headers2;
531
- })();
532
- const kNativeRequest = /* @__PURE__ */ Symbol.for("srvx.nativeRequest");
533
- const NodeRequest = /* @__PURE__ */ (() => {
534
- const NativeRequest = getNativeRequest();
535
- class Request {
536
- runtime;
537
- waitUntil;
538
- #req;
539
- #url;
540
- #bodyStream;
541
- #request;
542
- #headers;
543
- #abortController;
544
- #maxRequestBodySize;
545
- constructor(ctx) {
546
- this.#req = ctx.req;
547
- this.#maxRequestBodySize = ctx.maxRequestBodySize;
548
- this.runtime = {
549
- name: "node",
550
- node: ctx
551
- };
552
- }
553
- static [Symbol.hasInstance](val) {
554
- return val instanceof NativeRequest;
555
- }
556
- get ip() {
557
- return this.#req.socket?.remoteAddress;
558
- }
559
- get method() {
560
- if (this.#request) return this.#request.method;
561
- return this.#req.method || "GET";
562
- }
563
- get _url() {
564
- return this.#url ||= new NodeRequestURL({ req: this.#req });
565
- }
566
- set _url(url) {
567
- this.#url = url;
568
- }
569
- get url() {
570
- if (this.#request) return this.#request.url;
571
- return this._url.href;
572
- }
573
- get headers() {
574
- if (this.#request) return this.#request.headers;
575
- return this.#headers ||= new NodeRequestHeaders(this.#req);
576
- }
577
- get _abortController() {
578
- if (!this.#abortController) {
579
- this.#abortController = new AbortController();
580
- const { req, res } = this.runtime.node;
581
- const abortController = this.#abortController;
582
- const abort = (err) => abortController.abort?.(err);
583
- if (res) res.once("close", () => {
584
- const reqError = req.errored;
585
- if (reqError) abort(reqError);
586
- else if (!res.writableEnded) abort();
587
- });
588
- else req.once("close", () => {
589
- if (!req.complete) abort();
590
- });
591
- }
592
- return this.#abortController;
593
- }
594
- get signal() {
595
- return this.#request ? this.#request.signal : this._abortController.signal;
596
- }
597
- get body() {
598
- if (this.#request) return this.#request.body;
599
- if (this.#bodyStream === void 0) {
600
- const method = this.method;
601
- let stream = !(method === "GET" || method === "HEAD") ? Readable.toWeb(this.#req) : null;
602
- if (stream && this.#maxRequestBodySize !== void 0) stream = limitBodyStream(stream, this.#maxRequestBodySize);
603
- this.#bodyStream = stream;
604
- }
605
- return this.#bodyStream;
606
- }
607
- #readBuffered() {
608
- return readBody(this.#req, this.#maxRequestBodySize);
609
- }
610
- text() {
611
- if (this.#request) return this.#request.text();
612
- if (this.#bodyStream !== void 0) return this.#bodyStream ? new Response(this.#bodyStream).text() : Promise.resolve("");
613
- return this.#readBuffered().then((buf) => buf.toString());
614
- }
615
- json() {
616
- if (this.#request) return this.#request.json();
617
- if (this.#bodyStream !== void 0) return this.text().then((text) => JSON.parse(text));
618
- return this.#readBuffered().then((buf) => JSON.parse(buf.toString()));
619
- }
620
- get _request() {
621
- if (!this.#request) {
622
- const body = this.body;
623
- this.#request = new NativeRequest(this.url, {
624
- method: this.method,
625
- headers: this.headers,
626
- signal: this._abortController.signal,
627
- body,
628
- duplex: body ? "half" : void 0
629
- });
630
- this.#headers = void 0;
631
- this.#bodyStream = void 0;
632
- }
633
- return this.#request;
634
- }
635
- }
636
- lazyInherit$2(Request.prototype, NativeRequest.prototype, "_request");
637
- Object.setPrototypeOf(Request.prototype, NativeRequest.prototype);
638
- return Request;
639
- })();
640
- function readBody(req, maxRequestBodySize) {
641
- if ("rawBody" in req && Buffer.isBuffer(req.rawBody)) {
642
- if (maxRequestBodySize !== void 0 && req.rawBody.length > maxRequestBodySize) return Promise.reject(createBodyTooLargeError(maxRequestBodySize));
643
- return Promise.resolve(req.rawBody);
644
- }
645
- return new Promise((resolve, reject) => {
646
- const chunks = [];
647
- let size = 0;
648
- const cleanup = () => {
649
- req.off("data", onData);
650
- req.off("end", onEnd);
651
- req.off("error", onError);
652
- };
653
- const onData = (chunk) => {
654
- if (maxRequestBodySize !== void 0) {
655
- size += chunk.length;
656
- if (size > maxRequestBodySize) {
657
- cleanup();
658
- req.pause?.();
659
- reject(createBodyTooLargeError(maxRequestBodySize));
660
- return;
661
- }
662
- }
663
- chunks.push(chunk);
664
- };
665
- const onError = (err) => {
666
- cleanup();
667
- reject(err);
668
- };
669
- const onEnd = () => {
670
- cleanup();
671
- resolve(chunks.length === 1 ? chunks[0] : Buffer.concat(chunks));
672
- };
673
- req.on("data", onData).once("end", onEnd).once("error", onError);
674
- });
675
- }
676
- function getNativeRequest() {
677
- let R = globalThis[kNativeRequest] || globalThis.Request;
678
- while (R?._srvx) R = Object.getPrototypeOf(R);
679
- return globalThis[kNativeRequest] ??= R;
680
- }
681
- const NodeResponse$2 = /* @__PURE__ */ (() => {
682
- const NativeResponse = globalThis.Response;
683
- const STATUS_CODES = globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES || {};
684
- class NodeResponse2 {
685
- #body;
686
- #init;
687
- #headers;
688
- #response;
689
- constructor(body, init) {
690
- this.#body = body;
691
- this.#init = init;
692
- }
693
- static [Symbol.hasInstance](val) {
694
- return val instanceof NativeResponse;
695
- }
696
- get status() {
697
- return this.#response?.status || this.#init?.status || 200;
698
- }
699
- get statusText() {
700
- return this.#response?.statusText || this.#init?.statusText || STATUS_CODES[this.status] || "";
701
- }
702
- get headers() {
703
- if (this.#response) return this.#response.headers;
704
- if (this.#headers) return this.#headers;
705
- const initHeaders = this.#init?.headers;
706
- return this.#headers = initHeaders instanceof Headers ? initHeaders : new Headers(initHeaders);
707
- }
708
- get ok() {
709
- if (this.#response) return this.#response.ok;
710
- const status = this.status;
711
- return status >= 200 && status < 300;
712
- }
713
- get _response() {
714
- if (this.#response) return this.#response;
715
- let body = this.#body;
716
- if (body && typeof body.pipe === "function" && !(body instanceof Readable)) {
717
- const stream = new PassThrough();
718
- body.pipe(stream);
719
- const abort = body.abort;
720
- if (abort) stream.once("close", () => abort());
721
- body = stream;
722
- }
723
- this.#response = new NativeResponse(body, this.#headers ? {
724
- ...this.#init,
725
- headers: this.#headers
726
- } : this.#init);
727
- this.#init = void 0;
728
- this.#headers = void 0;
729
- this.#body = void 0;
730
- return this.#response;
731
- }
732
- _toNodeResponse() {
733
- const status = this.status;
734
- const statusText = this.statusText;
735
- let body;
736
- let contentType;
737
- let contentLength;
738
- if (this.#response) body = this.#response.body;
739
- else if (this.#body) if (this.#body instanceof ReadableStream) body = this.#body;
740
- else if (typeof this.#body === "string") {
741
- body = this.#body;
742
- contentType = "text/plain; charset=UTF-8";
743
- contentLength = Buffer.byteLength(this.#body);
744
- } else if (this.#body instanceof ArrayBuffer) {
745
- body = Buffer.from(this.#body);
746
- contentLength = this.#body.byteLength;
747
- } else if (this.#body instanceof Uint8Array) {
748
- body = this.#body;
749
- contentLength = this.#body.byteLength;
750
- } else if (this.#body instanceof DataView) {
751
- body = Buffer.from(this.#body.buffer);
752
- contentLength = this.#body.byteLength;
753
- } else if (this.#body instanceof Blob) {
754
- body = this.#body.stream();
755
- contentType = this.#body.type;
756
- contentLength = this.#body.size;
757
- } else if (typeof this.#body.pipe === "function") body = this.#body;
758
- else body = this._response.body;
759
- const headers = [];
760
- const initHeaders = this.#init?.headers;
761
- const headerEntries = this.#response?.headers || this.#headers || (initHeaders ? Array.isArray(initHeaders) ? initHeaders : initHeaders?.entries ? initHeaders.entries() : Object.entries(initHeaders) : void 0);
762
- let hasContentTypeHeader;
763
- let hasContentLength;
764
- if (headerEntries) for (const [key, value] of headerEntries) {
765
- const lowerKey = typeof key === "string" ? key.toLowerCase() : String(key);
766
- if (Array.isArray(value)) for (const v of value) headers.push(lowerKey, v);
767
- else headers.push(lowerKey, value);
768
- if (lowerKey === "content-type") hasContentTypeHeader = true;
769
- else if (lowerKey === "content-length") hasContentLength = true;
770
- }
771
- if (contentType && !hasContentTypeHeader) headers.push("content-type", contentType);
772
- if (contentLength && !hasContentLength) headers.push("content-length", String(contentLength));
773
- this.#init = void 0;
774
- this.#headers = void 0;
775
- this.#response = void 0;
776
- this.#body = void 0;
777
- return {
778
- status,
779
- statusText,
780
- headers,
781
- body
782
- };
783
- }
784
- }
785
- lazyInherit$2(NodeResponse2.prototype, NativeResponse.prototype, "_response");
786
- Object.setPrototypeOf(NodeResponse2, NativeResponse);
787
- Object.setPrototypeOf(NodeResponse2.prototype, NativeResponse.prototype);
788
- return NodeResponse2;
789
- })();
790
- function serve(options) {
791
- return new NodeServer(options);
792
- }
793
- var NodeServer = class {
794
- runtime = "node";
795
- options;
796
- node;
797
- serveOptions;
798
- fetch;
799
- waitUntil;
800
- #isSecure;
801
- #listeningPromise;
802
- #listenError;
803
- #wait;
804
- constructor(options) {
805
- this.options = {
806
- ...options,
807
- middleware: [...options.middleware || []]
808
- };
809
- for (const plugin of options.plugins || []) plugin(this);
810
- errorPlugin(this);
811
- const fetchHandler = this.fetch = wrapFetch(this);
812
- const handler = (nodeReq, nodeRes) => {
813
- const reqUrl = nodeReq.url;
814
- if (reqUrl && reqUrl[0] !== "/" && reqUrl !== "*" && !URL.canParse(reqUrl)) {
815
- nodeRes.statusCode = 400;
816
- nodeRes.end();
817
- return;
818
- }
819
- const request = new NodeRequest({
820
- req: nodeReq,
821
- res: nodeRes,
822
- maxRequestBodySize: this.options.maxRequestBodySize
823
- });
824
- request.waitUntil = this.#wait?.waitUntil;
825
- const res = fetchHandler(request);
826
- return res instanceof Promise ? res.then((resolvedRes) => sendNodeResponseDetached(nodeRes, resolvedRes)) : sendNodeResponseDetached(nodeRes, res);
827
- };
828
- this.node = {
829
- handler,
830
- server: void 0
831
- };
832
- const loader = globalThis.__srvxLoader__;
833
- if (loader) {
834
- loader({ server: this });
835
- return;
836
- }
837
- gracefulShutdownPlugin(this);
838
- this.#wait = createWaitUntil();
839
- this.waitUntil = this.#wait.waitUntil;
840
- const tls = resolveTLSOptions(this.options);
841
- const { port, hostname: host } = resolvePortAndHost(this.options);
842
- this.serveOptions = {
843
- port,
844
- host,
845
- exclusive: !this.options.reusePort,
846
- ...tls ? {
847
- cert: tls.cert,
848
- key: tls.key,
849
- passphrase: tls.passphrase
850
- } : {},
851
- ...this.options.node
852
- };
853
- let server;
854
- this.#isSecure = !!this.serveOptions.cert && this.options.protocol !== "http";
855
- if (this.options.node?.http2 ?? this.#isSecure) if (this.#isSecure) server = nodeHTTP2.createSecureServer({
856
- allowHTTP1: true,
857
- ...this.serveOptions
858
- }, handler);
859
- else throw new Error("node.http2 option requires tls certificate!");
860
- else if (this.#isSecure) server = nodeHTTPS.createServer(this.serveOptions, handler);
861
- else server = http.createServer(this.serveOptions, handler);
862
- this.node.server = server;
863
- if (!options.manual) this.serve().catch(() => {
864
- });
865
- }
866
- serve() {
867
- if (this.#listeningPromise) return this.#listeningPromise.then(() => this);
868
- const server = this.node?.server;
869
- if (!server) return Promise.reject(/* @__PURE__ */ new Error("Server not initialized"));
870
- this.#listenError = void 0;
871
- this.#listeningPromise = new Promise((resolve, reject) => {
872
- const onError = (error) => {
873
- server.off("listening", onListening);
874
- this.#listenError = error;
875
- this.#listeningPromise = void 0;
876
- reject(error);
877
- };
878
- const onListening = () => {
879
- server.off("error", onError);
880
- printListening(this.options, this.url);
881
- resolve();
882
- };
883
- server.once("error", onError);
884
- server.once("listening", onListening);
885
- server.listen(this.serveOptions);
886
- });
887
- return this.#listeningPromise.then(() => this);
888
- }
889
- get url() {
890
- const addr = this.node?.server?.address();
891
- if (!addr) return;
892
- return typeof addr === "string" ? addr : fmtURL(addr.address, addr.port, this.#isSecure);
893
- }
894
- ready() {
895
- if (this.#listenError) return Promise.reject(this.#listenError);
896
- return Promise.resolve(this.#listeningPromise).then(() => this);
897
- }
898
- async close(closeAll) {
899
- await Promise.all([this.#wait?.wait(), new Promise((resolve, reject) => {
900
- const server = this.node?.server;
901
- if (server && closeAll && "closeAllConnections" in server) server.closeAllConnections();
902
- if (!server || !server.listening) return resolve();
903
- server.close((error) => error ? reject(error) : resolve());
904
- })]);
905
- }
906
- };
907
- function lazyInherit$1(target, source, sourceKey) {
908
- for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) {
909
- if (key === "constructor") continue;
910
- const targetDesc = Object.getOwnPropertyDescriptor(target, key);
911
- const desc = Object.getOwnPropertyDescriptor(source, key);
912
- let modified = false;
913
- if (desc.get) {
914
- modified = true;
915
- desc.get = targetDesc?.get || function() {
916
- return this[sourceKey][key];
917
- };
918
- }
919
- if (desc.set) {
920
- modified = true;
921
- desc.set = targetDesc?.set || function(value) {
922
- this[sourceKey][key] = value;
923
- };
924
- }
925
- if (!targetDesc?.value && typeof desc.value === "function") {
926
- modified = true;
927
- desc.value = function(...args) {
928
- return this[sourceKey][key](...args);
929
- };
930
- }
931
- if (modified) Object.defineProperty(target, key, desc);
932
- }
933
- }
934
- const _needsNormRE$1 = /(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^\x80-\uffff]/i;
935
- const FastURL$1 = /* @__PURE__ */ (() => {
936
- const NativeURL = globalThis.URL;
937
- const FastURL2 = class URL {
938
- #url;
939
- #href;
940
- #protocol;
941
- #host;
942
- #pathname;
943
- #search;
944
- #searchParams;
945
- #pos;
946
- constructor(url) {
947
- if (typeof url === "string") if (url[0] === "/") this.#href = url;
948
- else this.#url = new NativeURL(url);
949
- else if (_needsNormRE$1.test(url.pathname)) this.#url = new NativeURL(`${url.protocol || "http:"}//${url.host || "localhost"}${url.pathname}${url.search || ""}`);
950
- else {
951
- this.#protocol = url.protocol;
952
- this.#host = url.host;
953
- this.#pathname = url.pathname;
954
- this.#search = url.search;
955
- }
956
- }
957
- static [Symbol.hasInstance](val) {
958
- return val instanceof NativeURL;
959
- }
960
- get _url() {
961
- if (this.#url) return this.#url;
962
- this.#url = new NativeURL(this.href);
963
- this.#href = void 0;
964
- this.#protocol = void 0;
965
- this.#host = void 0;
966
- this.#pathname = void 0;
967
- this.#search = void 0;
968
- this.#searchParams = void 0;
969
- this.#pos = void 0;
970
- return this.#url;
971
- }
972
- get href() {
973
- if (this.#url) return this.#url.href;
974
- if (!this.#href) this.#href = `${this.#protocol || "http:"}//${this.#host || "localhost"}${this.#pathname || "/"}${this.#search || ""}`;
975
- return this.#href;
976
- }
977
- #getPos() {
978
- if (!this.#pos) {
979
- const url = this.href;
980
- const protoIndex = url.indexOf("://");
981
- const pathnameIndex = protoIndex === -1 ? -1 : url.indexOf("/", protoIndex + 4);
982
- const qIndex = pathnameIndex === -1 ? -1 : url.indexOf("?", pathnameIndex);
983
- this.#pos = [
984
- protoIndex,
985
- pathnameIndex,
986
- qIndex
987
- ];
988
- }
989
- return this.#pos;
990
- }
991
- get pathname() {
992
- if (this.#url) return this.#url.pathname;
993
- if (this.#pathname === void 0) {
994
- const [, pathnameIndex, queryIndex] = this.#getPos();
995
- if (pathnameIndex === -1) return this._url.pathname;
996
- this.#pathname = this.href.slice(pathnameIndex, queryIndex === -1 ? void 0 : queryIndex);
997
- }
998
- return this.#pathname;
999
- }
1000
- get search() {
1001
- if (this.#url) return this.#url.search;
1002
- if (this.#search === void 0) {
1003
- const [, pathnameIndex, queryIndex] = this.#getPos();
1004
- if (pathnameIndex === -1) return this._url.search;
1005
- const url = this.href;
1006
- this.#search = queryIndex === -1 || queryIndex === url.length - 1 ? "" : url.slice(queryIndex);
1007
- }
1008
- return this.#search;
1009
- }
1010
- get searchParams() {
1011
- if (this.#url) return this.#url.searchParams;
1012
- if (!this.#searchParams) this.#searchParams = new URLSearchParams(this.search);
1013
- return this.#searchParams;
1014
- }
1015
- get protocol() {
1016
- if (this.#url) return this.#url.protocol;
1017
- if (this.#protocol === void 0) {
1018
- const [protocolIndex] = this.#getPos();
1019
- if (protocolIndex === -1) return this._url.protocol;
1020
- const url = this.href;
1021
- this.#protocol = url.slice(0, protocolIndex + 1);
1022
- }
1023
- return this.#protocol;
1024
- }
1025
- toString() {
1026
- return this.href;
1027
- }
1028
- toJSON() {
1029
- return this.href;
1030
- }
1031
- };
1032
- lazyInherit$1(FastURL2.prototype, NativeURL.prototype, "_url");
1033
- Object.setPrototypeOf(FastURL2.prototype, NativeURL.prototype);
1034
- Object.setPrototypeOf(FastURL2, NativeURL);
1035
- return FastURL2;
1036
- })();
1037
- const NodeResponse$1 = /* @__PURE__ */ (() => {
1038
- const NativeResponse = globalThis.Response;
1039
- const STATUS_CODES = globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES || {};
1040
- class NodeResponse2 {
1041
- #body;
1042
- #init;
1043
- #headers;
1044
- #response;
1045
- constructor(body, init) {
1046
- this.#body = body;
1047
- this.#init = init;
1048
- }
1049
- static [Symbol.hasInstance](val) {
1050
- return val instanceof NativeResponse;
1051
- }
1052
- get status() {
1053
- return this.#response?.status || this.#init?.status || 200;
1054
- }
1055
- get statusText() {
1056
- return this.#response?.statusText || this.#init?.statusText || STATUS_CODES[this.status] || "";
1057
- }
1058
- get headers() {
1059
- if (this.#response) return this.#response.headers;
1060
- if (this.#headers) return this.#headers;
1061
- const initHeaders = this.#init?.headers;
1062
- return this.#headers = initHeaders instanceof Headers ? initHeaders : new Headers(initHeaders);
1063
- }
1064
- get ok() {
1065
- if (this.#response) return this.#response.ok;
1066
- const status = this.status;
1067
- return status >= 200 && status < 300;
1068
- }
1069
- get _response() {
1070
- if (this.#response) return this.#response;
1071
- let body = this.#body;
1072
- if (body && typeof body.pipe === "function" && !(body instanceof Readable)) {
1073
- const stream = new PassThrough();
1074
- body.pipe(stream);
1075
- const abort = body.abort;
1076
- if (abort) stream.once("close", () => abort());
1077
- body = stream;
1078
- }
1079
- this.#response = new NativeResponse(body, this.#headers ? {
1080
- ...this.#init,
1081
- headers: this.#headers
1082
- } : this.#init);
1083
- this.#init = void 0;
1084
- this.#headers = void 0;
1085
- this.#body = void 0;
1086
- return this.#response;
1087
- }
1088
- _toNodeResponse() {
1089
- const status = this.status;
1090
- const statusText = this.statusText;
1091
- let body;
1092
- let contentType;
1093
- let contentLength;
1094
- if (this.#response) body = this.#response.body;
1095
- else if (this.#body) if (this.#body instanceof ReadableStream) body = this.#body;
1096
- else if (typeof this.#body === "string") {
1097
- body = this.#body;
1098
- contentType = "text/plain; charset=UTF-8";
1099
- contentLength = Buffer.byteLength(this.#body);
1100
- } else if (this.#body instanceof ArrayBuffer) {
1101
- body = Buffer.from(this.#body);
1102
- contentLength = this.#body.byteLength;
1103
- } else if (this.#body instanceof Uint8Array) {
1104
- body = this.#body;
1105
- contentLength = this.#body.byteLength;
1106
- } else if (this.#body instanceof DataView) {
1107
- body = Buffer.from(this.#body.buffer);
1108
- contentLength = this.#body.byteLength;
1109
- } else if (this.#body instanceof Blob) {
1110
- body = this.#body.stream();
1111
- contentType = this.#body.type;
1112
- contentLength = this.#body.size;
1113
- } else if (typeof this.#body.pipe === "function") body = this.#body;
1114
- else body = this._response.body;
1115
- const headers = [];
1116
- const initHeaders = this.#init?.headers;
1117
- const headerEntries = this.#response?.headers || this.#headers || (initHeaders ? Array.isArray(initHeaders) ? initHeaders : initHeaders?.entries ? initHeaders.entries() : Object.entries(initHeaders).map(([k, v]) => [k.toLowerCase(), v]) : void 0);
1118
- let hasContentTypeHeader;
1119
- let hasContentLength;
1120
- if (headerEntries) for (const [key, value] of headerEntries) {
1121
- if (Array.isArray(value)) for (const v of value) headers.push([key, v]);
1122
- else headers.push([key, value]);
1123
- if (key === "content-type") hasContentTypeHeader = true;
1124
- else if (key === "content-length") hasContentLength = true;
1125
- }
1126
- if (contentType && !hasContentTypeHeader) headers.push(["content-type", contentType]);
1127
- if (contentLength && !hasContentLength) headers.push(["content-length", String(contentLength)]);
1128
- this.#init = void 0;
1129
- this.#headers = void 0;
1130
- this.#response = void 0;
1131
- this.#body = void 0;
1132
- return {
1133
- status,
1134
- statusText,
1135
- headers,
1136
- body
1137
- };
1138
- }
1139
- }
1140
- lazyInherit$1(NodeResponse2.prototype, NativeResponse.prototype, "_response");
1141
- Object.setPrototypeOf(NodeResponse2, NativeResponse);
1142
- Object.setPrototypeOf(NodeResponse2.prototype, NativeResponse.prototype);
1143
- return NodeResponse2;
1144
- })();
1145
- function lazyInherit(target, source, sourceKey) {
1146
- for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) {
1147
- if (key === "constructor") continue;
1148
- const targetDesc = Object.getOwnPropertyDescriptor(target, key);
1149
- const desc = Object.getOwnPropertyDescriptor(source, key);
1150
- let modified = false;
1151
- if (desc.get) {
1152
- modified = true;
1153
- desc.get = targetDesc?.get || function() {
1154
- return this[sourceKey][key];
1155
- };
1156
- }
1157
- if (desc.set) {
1158
- modified = true;
1159
- desc.set = targetDesc?.set || function(value) {
1160
- this[sourceKey][key] = value;
1161
- };
1162
- }
1163
- if (!targetDesc?.value && typeof desc.value === "function") {
1164
- modified = true;
1165
- desc.value = function(...args) {
1166
- return this[sourceKey][key](...args);
1167
- };
1168
- }
1169
- if (modified) Object.defineProperty(target, key, desc);
1170
- }
1171
- }
1172
- const _needsNormRE = /(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^\x80-\uffff]/i;
1173
- const FastURL = /* @__PURE__ */ (() => {
1174
- const NativeURL = globalThis.URL;
1175
- const FastURL2 = class URL {
1176
- #url;
1177
- #href;
1178
- #protocol;
1179
- #host;
1180
- #pathname;
1181
- #search;
1182
- #searchParams;
1183
- #pos;
1184
- constructor(url) {
1185
- if (typeof url === "string") if (url[0] === "/") this.#href = url;
1186
- else this.#url = new NativeURL(url);
1187
- else if (_needsNormRE.test(url.pathname)) this.#url = new NativeURL(`${url.protocol || "http:"}//${url.host || "localhost"}${url.pathname}${url.search || ""}`);
1188
- else {
1189
- this.#protocol = url.protocol;
1190
- this.#host = url.host;
1191
- this.#pathname = url.pathname;
1192
- this.#search = url.search;
1193
- }
1194
- }
1195
- static [Symbol.hasInstance](val) {
1196
- return val instanceof NativeURL;
1197
- }
1198
- get _url() {
1199
- if (this.#url) return this.#url;
1200
- this.#url = new NativeURL(this.href);
1201
- this.#href = void 0;
1202
- this.#protocol = void 0;
1203
- this.#host = void 0;
1204
- this.#pathname = void 0;
1205
- this.#search = void 0;
1206
- this.#searchParams = void 0;
1207
- this.#pos = void 0;
1208
- return this.#url;
1209
- }
1210
- get href() {
1211
- if (this.#url) return this.#url.href;
1212
- if (!this.#href) this.#href = `${this.#protocol || "http:"}//${this.#host || "localhost"}${this.#pathname || "/"}${this.#search || ""}`;
1213
- return this.#href;
1214
- }
1215
- #getPos() {
1216
- if (!this.#pos) {
1217
- const url = this.href;
1218
- const protoIndex = url.indexOf("://");
1219
- const pathnameIndex = protoIndex === -1 ? -1 : url.indexOf("/", protoIndex + 4);
1220
- const qIndex = pathnameIndex === -1 ? -1 : url.indexOf("?", pathnameIndex);
1221
- this.#pos = [
1222
- protoIndex,
1223
- pathnameIndex,
1224
- qIndex
1225
- ];
1226
- }
1227
- return this.#pos;
1228
- }
1229
- get pathname() {
1230
- if (this.#url) return this.#url.pathname;
1231
- if (this.#pathname === void 0) {
1232
- const [, pathnameIndex, queryIndex] = this.#getPos();
1233
- if (pathnameIndex === -1) return this._url.pathname;
1234
- this.#pathname = this.href.slice(pathnameIndex, queryIndex === -1 ? void 0 : queryIndex);
1235
- }
1236
- return this.#pathname;
1237
- }
1238
- get search() {
1239
- if (this.#url) return this.#url.search;
1240
- if (this.#search === void 0) {
1241
- const [, pathnameIndex, queryIndex] = this.#getPos();
1242
- if (pathnameIndex === -1) return this._url.search;
1243
- const url = this.href;
1244
- this.#search = queryIndex === -1 || queryIndex === url.length - 1 ? "" : url.slice(queryIndex);
1245
- }
1246
- return this.#search;
1247
- }
1248
- get searchParams() {
1249
- if (this.#url) return this.#url.searchParams;
1250
- if (!this.#searchParams) this.#searchParams = new URLSearchParams(this.search);
1251
- return this.#searchParams;
1252
- }
1253
- get protocol() {
1254
- if (this.#url) return this.#url.protocol;
1255
- if (this.#protocol === void 0) {
1256
- const [protocolIndex] = this.#getPos();
1257
- if (protocolIndex === -1) return this._url.protocol;
1258
- const url = this.href;
1259
- this.#protocol = url.slice(0, protocolIndex + 1);
1260
- }
1261
- return this.#protocol;
1262
- }
1263
- toString() {
1264
- return this.href;
1265
- }
1266
- toJSON() {
1267
- return this.href;
1268
- }
1269
- };
1270
- lazyInherit(FastURL2.prototype, NativeURL.prototype, "_url");
1271
- Object.setPrototypeOf(FastURL2.prototype, NativeURL.prototype);
1272
- Object.setPrototypeOf(FastURL2, NativeURL);
1273
- return FastURL2;
1274
- })();
1275
- const NodeResponse = /* @__PURE__ */ (() => {
1276
- const NativeResponse = globalThis.Response;
1277
- const STATUS_CODES = globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES || {};
1278
- class NodeResponse2 {
1279
- #body;
1280
- #init;
1281
- #headers;
1282
- #response;
1283
- constructor(body, init) {
1284
- this.#body = body;
1285
- this.#init = init;
1286
- }
1287
- static [Symbol.hasInstance](val) {
1288
- return val instanceof NativeResponse;
1289
- }
1290
- get status() {
1291
- return this.#response?.status || this.#init?.status || 200;
1292
- }
1293
- get statusText() {
1294
- return this.#response?.statusText || this.#init?.statusText || STATUS_CODES[this.status] || "";
1295
- }
1296
- get headers() {
1297
- if (this.#response) return this.#response.headers;
1298
- if (this.#headers) return this.#headers;
1299
- const initHeaders = this.#init?.headers;
1300
- return this.#headers = initHeaders instanceof Headers ? initHeaders : new Headers(initHeaders);
1301
- }
1302
- get ok() {
1303
- if (this.#response) return this.#response.ok;
1304
- const status = this.status;
1305
- return status >= 200 && status < 300;
1306
- }
1307
- get _response() {
1308
- if (this.#response) return this.#response;
1309
- let body = this.#body;
1310
- if (body && typeof body.pipe === "function" && !(body instanceof Readable)) {
1311
- const stream = new PassThrough();
1312
- body.pipe(stream);
1313
- const abort = body.abort;
1314
- if (abort) stream.once("close", () => abort());
1315
- body = stream;
1316
- }
1317
- this.#response = new NativeResponse(body, this.#headers ? {
1318
- ...this.#init,
1319
- headers: this.#headers
1320
- } : this.#init);
1321
- this.#init = void 0;
1322
- this.#headers = void 0;
1323
- this.#body = void 0;
1324
- return this.#response;
1325
- }
1326
- _toNodeResponse() {
1327
- const status = this.status;
1328
- const statusText = this.statusText;
1329
- let body;
1330
- let contentType;
1331
- let contentLength;
1332
- if (this.#response) body = this.#response.body;
1333
- else if (this.#body) if (this.#body instanceof ReadableStream) body = this.#body;
1334
- else if (typeof this.#body === "string") {
1335
- body = this.#body;
1336
- contentType = "text/plain; charset=UTF-8";
1337
- contentLength = Buffer.byteLength(this.#body);
1338
- } else if (this.#body instanceof ArrayBuffer) {
1339
- body = Buffer.from(this.#body);
1340
- contentLength = this.#body.byteLength;
1341
- } else if (this.#body instanceof Uint8Array) {
1342
- body = this.#body;
1343
- contentLength = this.#body.byteLength;
1344
- } else if (this.#body instanceof DataView) {
1345
- body = Buffer.from(this.#body.buffer);
1346
- contentLength = this.#body.byteLength;
1347
- } else if (this.#body instanceof Blob) {
1348
- body = this.#body.stream();
1349
- contentType = this.#body.type;
1350
- contentLength = this.#body.size;
1351
- } else if (typeof this.#body.pipe === "function") body = this.#body;
1352
- else body = this._response.body;
1353
- const headers = [];
1354
- const initHeaders = this.#init?.headers;
1355
- const headerEntries = this.#response?.headers || this.#headers || (initHeaders ? Array.isArray(initHeaders) ? initHeaders : initHeaders?.entries ? initHeaders.entries() : Object.entries(initHeaders).map(([k, v]) => [k.toLowerCase(), v]) : void 0);
1356
- let hasContentTypeHeader;
1357
- let hasContentLength;
1358
- if (headerEntries) for (const [key, value] of headerEntries) {
1359
- if (Array.isArray(value)) for (const v of value) headers.push([key, v]);
1360
- else headers.push([key, value]);
1361
- if (key === "content-type") hasContentTypeHeader = true;
1362
- else if (key === "content-length") hasContentLength = true;
1363
- }
1364
- if (contentType && !hasContentTypeHeader) headers.push(["content-type", contentType]);
1365
- if (contentLength && !hasContentLength) headers.push(["content-length", String(contentLength)]);
1366
- this.#init = void 0;
1367
- this.#headers = void 0;
1368
- this.#response = void 0;
1369
- this.#body = void 0;
1370
- return {
1371
- status,
1372
- statusText,
1373
- headers,
1374
- body
1375
- };
1376
- }
1377
- }
1378
- lazyInherit(NodeResponse2.prototype, NativeResponse.prototype, "_response");
1379
- Object.setPrototypeOf(NodeResponse2, NativeResponse);
1380
- Object.setPrototypeOf(NodeResponse2.prototype, NativeResponse.prototype);
1381
- return NodeResponse2;
1382
- })();
1383
- export {
1384
- FastURL$1 as F,
1385
- NodeResponse$1 as N,
1386
- FastURL as a,
1387
- NodeResponse as b,
1388
- NodeResponse$2 as c,
1389
- serve as s
1390
- };
1
+ import A from"node:http";import{Readable as v,PassThrough as _}from"node:stream";import{pipeline as B}from"node:stream/promises";import j from"node:https";import H from"node:http2";function w(s,r,o){for(const t of[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)]){if(t==="constructor")continue;const e=Object.getOwnPropertyDescriptor(s,t),i=Object.getOwnPropertyDescriptor(r,t);let n=!1;i.get&&(n=!0,i.get=e?.get||function(){return this[o][t]}),i.set&&(n=!0,i.set=e?.set||function(h){this[o][t]=h}),!e?.value&&typeof i.value=="function"&&(n=!0,i.value=function(...h){return this[o][t](...h)}),n&&Object.defineProperty(s,t,i)}}const k=/(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^#"<>{}`\x80-\uffff]/i,S=/[#"'<>]/,R=(()=>{const s=globalThis.URL,r=class{#t;#s;#r;#e;#o;#i;#n;#h;constructor(t){if(typeof t=="string"){const e=t[0]==="/";e&&!S.test(t)?this.#s=t:this.#t=new s(e?`http://localhost${t}`:t)}else k.test(t.pathname)||t.search&&S.test(t.search)?this.#t=new s(`${t.protocol||"http:"}//${t.host||"localhost"}${t.pathname}${t.search||""}`):(this.#r=t.protocol,this.#e=t.host,this.#o=t.pathname,this.#i=t.search)}static[Symbol.hasInstance](t){return t instanceof s}get _url(){return this.#t?this.#t:(this.#t=new s(this.href),this.#s=void 0,this.#r=void 0,this.#e=void 0,this.#o=void 0,this.#i=void 0,this.#n=void 0,this.#h=void 0,this.#t)}get href(){return this.#t?this.#t.href:(this.#s||(this.#s=`${this.#r||"http:"}//${this.#e||"localhost"}${this.#o||"/"}${this.#i||""}`),this.#s)}#a(){if(!this.#h){const t=this.href,e=t.indexOf("://"),i=e===-1?-1:t.indexOf("/",e+4),n=i===-1?-1:t.indexOf("?",i);this.#h=[e,i,n]}return this.#h}get pathname(){if(this.#t)return this.#t.pathname;if(this.#o===void 0){const[,t,e]=this.#a();if(t===-1)return this._url.pathname;this.#o=this.href.slice(t,e===-1?void 0:e)}return this.#o}get search(){if(this.#t)return this.#t.search;if(this.#i===void 0){const[,t,e]=this.#a();if(t===-1)return this._url.search;const i=this.href;this.#i=e===-1||e===i.length-1?"":i.slice(e)}return this.#i}get searchParams(){return this.#t?this.#t.searchParams:(this.#n||(this.#n=new URLSearchParams(this.search)),this.#n)}get protocol(){if(this.#t)return this.#t.protocol;if(this.#r===void 0){const[t]=this.#a();if(t===-1)return this._url.protocol;const e=this.href;this.#r=e.slice(0,t+1)}return this.#r}toString(){return this.href}toJSON(){return this.href}};return w(r.prototype,s.prototype,"_url"),Object.setPrototypeOf(r.prototype,s.prototype),Object.setPrototypeOf(r,s),r})();function D(s){const r=s.port??globalThis.process?.env.PORT??3e3,o=typeof r=="number"?r:Number.parseInt(r,10);if(o<0||o>65535)throw new RangeError(`Port must be between 0 and 65535 (got "${o}").`);return{port:o,hostname:s.hostname??globalThis.process?.env.HOST}}function F(s,r,o){if(!(!s||!r))return s.includes(":")&&(s=`[${s}]`),`http${o?"s":""}://${s}:${r}/`}function q(s,r){if(!r||(s.silent??globalThis.process?.env?.TEST))return;let o="";try{const e=new URL(r);(e.hostname==="[::]"||e.hostname==="0.0.0.0")&&(e.hostname="localhost",r=e.href,o=" (all interfaces)")}catch{}let t="➜ Listening on:";globalThis.process.stdout?.isTTY&&(t=`\x1B[32m${t}\x1B[0m`,r=`\x1B[36m${r}\x1B[0m`,o=`\x1B[2m${o}\x1B[0m`),console.log(`${t} ${r}${o}`)}function z(s){if(!s.tls||s.protocol==="http")return;const r=P(s.tls.cert),o=P(s.tls.key);if(!r&&!o){if(s.protocol==="https")throw new TypeError("TLS `cert` and `key` must be provided for `https` protocol.");return}if(!r||!o)throw new TypeError("TLS `cert` and `key` must be provided together.");return{cert:r,key:o,passphrase:s.tls.passphrase}}function P(s){if(!s)return;if(typeof s!="string")throw new TypeError("TLS certificate and key must be strings in PEM format or file paths.");if(s.startsWith("-----BEGIN "))return s;const{readFileSync:r}=process.getBuiltinModule("node:fs");return r(s,"utf8")}function M(){const s=new Set;return{waitUntil:r=>{typeof r?.then=="function"&&s.add(Promise.resolve(r).catch(console.error).finally(()=>{s.delete(r)}))},wait:()=>Promise.all(s)}}const G=(()=>{const s=globalThis.process?.env??{};return s.NO_COLOR==="1"||s.TERM==="dumb"})(),O=(s,r=39)=>o=>G?o:`\x1B[${s}m${o}\x1B[${r}m`,J=O(1,22),V=O(31),W=O(32),Z=O(90);function Y(s){const r=s.options.fetch,o=s.options.middleware||[];return o.length===0?r:t=>E(t,r,o,0)}function E(s,r,o,t){return t===o.length?r(s):o[t](s,()=>E(s,r,o,t+1))}const Q=s=>{const r=s.options.error;r&&s.options.middleware.unshift((o,t)=>{try{const e=t();return e instanceof Promise?e.catch(i=>r(i)):e}catch(e){return r(e)}})},X=s=>{const r=s.options?.gracefulShutdown;if(!globalThis.process?.on||r===!1||r===void 0&&(process.env.CI||process.env.TEST))return;const o=r===!0||!r?.gracefulTimeout?Number.parseInt(process.env.SERVER_SHUTDOWN_TIMEOUT||"")||5:r.gracefulTimeout;let t=!1,e=!1;const i=s.options.silent?()=>{}:process.stderr.write.bind(process.stderr),n=async()=>{e||(i(V(`\x1B[2K\rForcibly closing connections...
2
+ `)),e=!0,await s.close(!0))},h=async()=>{if(t||e)return;setTimeout(()=>{globalThis.process.once("SIGINT",n)},100),t=!0;const a=s.close();for(let f=o;f>0;f--)if(i(Z(`\rStopping server gracefully (${f}s)... Press ${J("Ctrl+C")} again to force close.`)),await Promise.race([a.then(()=>!0),new Promise(c=>setTimeout(()=>c(!1),1e3))])){i("\x1B[2K\r"+W(`Server closed successfully.
3
+ `)),e=!0;return}i(`\x1B[2K\rGraceful shutdown timed out.
4
+ `),await n()};for(const a of["SIGINT","SIGTERM"])globalThis.process.on(a,h)};function T(s){return Object.assign(new Error(`Request body exceeds the maximum allowed size of ${s} bytes.`),{code:"ERR_BODY_TOO_LARGE",statusCode:413,status:413})}function K(s,r){const o=s.getReader();let t=0;return new ReadableStream({async pull(e){const{done:i,value:n}=await o.read();if(i){e.close();return}if(t+=n.byteLength,t>r){const h=T(r);o.cancel(h).catch(()=>{}),e.error(h);return}e.enqueue(n)},cancel(e){return o.cancel(e)}})}function x(s,r){try{return et(s,r,!0)}catch{tt(s)}}function tt(s,r){s.headersSent?s.destroy():(s.statusCode=500,s.end())}function et(s,r,o){if(!r)return s.statusCode=500,b(s,o);if(r._toNodeResponse){const e=r._toNodeResponse();if(e.body){if(e.body instanceof ReadableStream)return m(s,e.status,e.statusText,e.headers),L(e.body,s);if(typeof e.body?.pipe=="function")return st(e.body,s,e.status,e.statusText,e.headers);m(s,e.status,e.statusText,e.headers),s.write(e.body)}else m(s,e.status,e.statusText,e.headers);return b(s,o)}const t=[];for(const[e,i]of r.headers)t.push(e,i);return m(s,r.status,r.statusText,t),r.body?L(r.body,s):b(s,o)}function m(s,r,o,t){s.headersSent||(s.req?.httpVersion==="2.0"?s.writeHead(r,t):s.writeHead(r,o,t))}function b(s,r){if(r){s.end();return}return new Promise(o=>s.end(o))}function st(s,r,o,t,e){if(r.destroyed){s.destroy?.();return}return typeof s.on!="function"||typeof s.destroy!="function"?(m(r,o,t,e),s.pipe(r),new Promise(i=>r.on("close",i))):s.destroyed?(m(r,500,"Internal Server Error",[]),b(r)):new Promise(i=>{function n(){s.off("readable",h),s.destroy(),m(r,500,"Internal Server Error",[]),b(r).then(i)}function h(){if(s.off("error",n),r.destroyed)return s.destroy(),i();m(r,o,t,e),B(s,r).catch(()=>{}).then(()=>i())}s.once("error",n),s.once("readable",h)})}function L(s,r){if(r.destroyed){s.cancel();return}const o=s.getReader();function t(i){o.cancel(i).catch(()=>{}),i&&r.destroy(i)}function e({done:i,value:n}){try{i?r.end():r.write(n)?o.read().then(e,t):r.once("drain",()=>o.read().then(e,t))}catch(h){t(h instanceof Error?h:void 0)}}return r.on("close",t),r.on("error",t),o.read().then(e,t),o.closed.catch(t).finally(()=>{r.off("close",t),r.off("error",t)})}const rt=/^(\[(?:[A-Fa-f0-9:.]+)\]|(?:[A-Za-z0-9_-]+\.)*[A-Za-z0-9_-]+|(?:\d{1,3}\.){3}\d{1,3})(:\d{1,5})?$/;var it=class extends R{constructor({req:s}){const r=s.url||"/";let o=s.headers.host||s.headers[":authority"];o&&!rt.test(o)?o="_invalid_":o||(s.socket?o=`${s.socket.localFamily==="IPv6"?"["+s.socket.localAddress+"]":s.socket.localAddress}:${s.socket?.localPort||"80"}`:o="localhost");const t=s.socket?.encrypted||s.headers["x-forwarded-proto"]==="https"||s.headers[":scheme"]==="https"?"https:":"http:";if(r[0]==="/"){const e=r.indexOf("?");super({protocol:t,host:o,pathname:e===-1?r:r.slice(0,e)||"/",search:e===-1?"":r.slice(e)||""})}else r==="*"?super({protocol:t,host:o,pathname:"/*",search:""}):super(r)}};const ot=new Set(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","server","user-agent"]),$=/^[!#$%&'*+\-.^_`|~\dA-Za-z]+$/;function nt(s,r){let o=!1;for(let t=0;t<s.length;t+=2){const e=s[t];if(e.length===r.length&&e.toLowerCase()===r){if(o)return!0;o=!0}}return!1}const ht=(()=>{const s=globalThis.Headers;class r{#t;#s;constructor(t){this.#t=t}static[Symbol.hasInstance](t){return t instanceof s}get _headers(){if(!this.#s){const t=new s,e=this.#t.rawHeaders,i=e.length;for(let n=0;n<i;n+=2){const h=e[n];if(h.charCodeAt(0)===58)continue;const a=e[n+1];t.append(h,a)}this.#s=t}return this.#s}get(t){if(this.#s)return this.#s.get(t);const e=t.toLowerCase();if(e.charCodeAt(0)===58)return this._headers.get(t);const i=this.#t.headers[e];return typeof i=="string"?ot.has(e)&&nt(this.#t.rawHeaders,e)?this._headers.get(t):i:Array.isArray(i)?i.join(", "):e!=="__proto__"&&$.test(t)?null:this._headers.get(t)}has(t){if(this.#s)return this.#s.has(t);const e=t.toLowerCase();return e.charCodeAt(0)===58?this._headers.has(t):Object.hasOwn(this.#t.headers,e)?!0:e!=="__proto__"&&$.test(t)?!1:this._headers.has(t)}getSetCookie(){if(this.#s)return this.#s.getSetCookie();const t=this.#t.headers["set-cookie"];return Array.isArray(t)?t.slice():t?[t]:[]}entries(){return this._headers.entries()}[Symbol.iterator](){return this.entries()}}return w(r.prototype,s.prototype,"_headers"),Object.setPrototypeOf(r,s),Object.setPrototypeOf(r.prototype,s.prototype),r})(),I=Symbol.for("srvx.nativeRequest"),at=(()=>{const s=ft();class r{runtime;waitUntil;#t;#s;#r;#e;#o;#i;#n;constructor(t){this.#t=t.req,this.#n=t.maxRequestBodySize,this.runtime={name:"node",node:t}}static[Symbol.hasInstance](t){return t instanceof s}get ip(){return this.#t.socket?.remoteAddress}get method(){return this.#e?this.#e.method:this.#t.method||"GET"}get _url(){return this.#s||=new it({req:this.#t})}set _url(t){this.#s=t}get url(){return this.#e?this.#e.url:this._url.href}get headers(){return this.#e?this.#e.headers:this.#o||=new ht(this.#t)}get _abortController(){if(!this.#i){this.#i=new AbortController;const{req:t,res:e}=this.runtime.node,i=this.#i,n=h=>i.abort?.(h);e?e.once("close",()=>{const h=t.errored;h?n(h):e.writableEnded||n()}):t.once("close",()=>{t.complete||n()})}return this.#i}get signal(){return this.#e?this.#e.signal:this._abortController.signal}get body(){if(this.#e)return this.#e.body;if(this.#r===void 0){const t=this.method;let e=t==="GET"||t==="HEAD"?null:v.toWeb(this.#t);e&&this.#n!==void 0&&(e=K(e,this.#n)),this.#r=e}return this.#r}#h(){return ct(this.#t,this.#n)}text(){return this.#e?this.#e.text():this.#r!==void 0?this.#r?new Response(this.#r).text():Promise.resolve(""):this.#h().then(t=>t.toString())}json(){return this.#e?this.#e.json():this.#r!==void 0?this.text().then(t=>JSON.parse(t)):this.#h().then(t=>JSON.parse(t.toString()))}get _request(){if(!this.#e){const t=this.body;this.#e=new s(this.url,{method:this.method,headers:this.headers,signal:this._abortController.signal,body:t,duplex:t?"half":void 0}),this.#o=void 0,this.#r=void 0}return this.#e}}return w(r.prototype,s.prototype,"_request"),Object.setPrototypeOf(r.prototype,s.prototype),r})();function ct(s,r){return"rawBody"in s&&Buffer.isBuffer(s.rawBody)?r!==void 0&&s.rawBody.length>r?Promise.reject(T(r)):Promise.resolve(s.rawBody):new Promise((o,t)=>{const e=[];let i=0;const n=()=>{s.off("data",h),s.off("end",f),s.off("error",a)},h=c=>{if(r!==void 0&&(i+=c.length,i>r)){n(),s.pause?.(),t(T(r));return}e.push(c)},a=c=>{n(),t(c)},f=()=>{n(),o(e.length===1?e[0]:Buffer.concat(e))};s.on("data",h).once("end",f).once("error",a)})}function ft(){let s=globalThis[I]||globalThis.Request;for(;s?._srvx;)s=Object.getPrototypeOf(s);return globalThis[I]??=s}const wt=(()=>{const s=globalThis.Response,r=globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES||{};class o{#t;#s;#r;#e;constructor(e,i){this.#t=e,this.#s=i}static[Symbol.hasInstance](e){return e instanceof s}get status(){return this.#e?.status||this.#s?.status||200}get statusText(){return this.#e?.statusText||this.#s?.statusText||r[this.status]||""}get headers(){if(this.#e)return this.#e.headers;if(this.#r)return this.#r;const e=this.#s?.headers;return this.#r=e instanceof Headers?e:new Headers(e)}get ok(){if(this.#e)return this.#e.ok;const e=this.status;return e>=200&&e<300}get _response(){if(this.#e)return this.#e;let e=this.#t;if(e&&typeof e.pipe=="function"&&!(e instanceof v)){const i=new _;e.pipe(i);const n=e.abort;n&&i.once("close",()=>n()),e=i}return this.#e=new s(e,this.#r?{...this.#s,headers:this.#r}:this.#s),this.#s=void 0,this.#r=void 0,this.#t=void 0,this.#e}_toNodeResponse(){const e=this.status,i=this.statusText;let n,h,a;this.#e?n=this.#e.body:this.#t&&(this.#t instanceof ReadableStream?n=this.#t:typeof this.#t=="string"?(n=this.#t,h="text/plain; charset=UTF-8",a=Buffer.byteLength(this.#t)):this.#t instanceof ArrayBuffer?(n=Buffer.from(this.#t),a=this.#t.byteLength):this.#t instanceof Uint8Array?(n=this.#t,a=this.#t.byteLength):this.#t instanceof DataView?(n=Buffer.from(this.#t.buffer),a=this.#t.byteLength):this.#t instanceof Blob?(n=this.#t.stream(),h=this.#t.type,a=this.#t.size):typeof this.#t.pipe=="function"?n=this.#t:n=this._response.body);const f=[],c=this.#s?.headers,d=this.#e?.headers||this.#r||(c?Array.isArray(c)?c:c?.entries?c.entries():Object.entries(c):void 0);let p,y;if(d)for(const[u,l]of d){const g=typeof u=="string"?u.toLowerCase():String(u);if(Array.isArray(l))for(const U of l)f.push(g,U);else f.push(g,l);g==="content-type"?p=!0:g==="content-length"&&(y=!0)}return h&&!p&&f.push("content-type",h),a&&!y&&f.push("content-length",String(a)),this.#s=void 0,this.#r=void 0,this.#e=void 0,this.#t=void 0,{status:e,statusText:i,headers:f,body:n}}}return w(o.prototype,s.prototype,"_response"),Object.setPrototypeOf(o,s),Object.setPrototypeOf(o.prototype,s.prototype),o})();function Ot(s){return new ut(s)}var ut=class{runtime="node";options;node;serveOptions;fetch;waitUntil;#t;#s;#r;#e;constructor(s){this.options={...s,middleware:[...s.middleware||[]]};for(const a of s.plugins||[])a(this);Q(this);const r=this.fetch=Y(this),o=(a,f)=>{const c=a.url;if(c&&c[0]!=="/"&&c!=="*"&&!URL.canParse(c)){f.statusCode=400,f.end();return}const d=new at({req:a,res:f,maxRequestBodySize:this.options.maxRequestBodySize});d.waitUntil=this.#e?.waitUntil;const p=r(d);return p instanceof Promise?p.then(y=>x(f,y)):x(f,p)};this.node={handler:o,server:void 0};const t=globalThis.__srvxLoader__;if(t){t({server:this});return}X(this),this.#e=M(),this.waitUntil=this.#e.waitUntil;const e=z(this.options),{port:i,hostname:n}=D(this.options);this.serveOptions={port:i,host:n,exclusive:!this.options.reusePort,...e?{cert:e.cert,key:e.key,passphrase:e.passphrase}:{},...this.options.node};let h;if(this.#t=!!this.serveOptions.cert&&this.options.protocol!=="http",this.options.node?.http2??this.#t)if(this.#t)h=H.createSecureServer({allowHTTP1:!0,...this.serveOptions},o);else throw new Error("node.http2 option requires tls certificate!");else this.#t?h=j.createServer(this.serveOptions,o):h=A.createServer(this.serveOptions,o);this.node.server=h,s.manual||this.serve().catch(()=>{})}serve(){if(this.#s)return this.#s.then(()=>this);const s=this.node?.server;return s?(this.#r=void 0,this.#s=new Promise((r,o)=>{const t=i=>{s.off("listening",e),this.#r=i,this.#s=void 0,o(i)},e=()=>{s.off("error",t),q(this.options,this.url),r()};s.once("error",t),s.once("listening",e),s.listen(this.serveOptions)}),this.#s.then(()=>this)):Promise.reject(new Error("Server not initialized"))}get url(){const s=this.node?.server?.address();if(s)return typeof s=="string"?s:F(s.address,s.port,this.#t)}ready(){return this.#r?Promise.reject(this.#r):Promise.resolve(this.#s).then(()=>this)}async close(s){await Promise.all([this.#e?.wait(),new Promise((r,o)=>{const t=this.node?.server;if(t&&s&&"closeAllConnections"in t&&t.closeAllConnections(),!t||!t.listening)return r();t.close(e=>e?o(e):r())})])}};function N(s,r,o){for(const t of[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)]){if(t==="constructor")continue;const e=Object.getOwnPropertyDescriptor(s,t),i=Object.getOwnPropertyDescriptor(r,t);let n=!1;i.get&&(n=!0,i.get=e?.get||function(){return this[o][t]}),i.set&&(n=!0,i.set=e?.set||function(h){this[o][t]=h}),!e?.value&&typeof i.value=="function"&&(n=!0,i.value=function(...h){return this[o][t](...h)}),n&&Object.defineProperty(s,t,i)}}const lt=/(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^\x80-\uffff]/i,Tt=(()=>{const s=globalThis.URL,r=class{#t;#s;#r;#e;#o;#i;#n;#h;constructor(t){typeof t=="string"?t[0]==="/"?this.#s=t:this.#t=new s(t):lt.test(t.pathname)?this.#t=new s(`${t.protocol||"http:"}//${t.host||"localhost"}${t.pathname}${t.search||""}`):(this.#r=t.protocol,this.#e=t.host,this.#o=t.pathname,this.#i=t.search)}static[Symbol.hasInstance](t){return t instanceof s}get _url(){return this.#t?this.#t:(this.#t=new s(this.href),this.#s=void 0,this.#r=void 0,this.#e=void 0,this.#o=void 0,this.#i=void 0,this.#n=void 0,this.#h=void 0,this.#t)}get href(){return this.#t?this.#t.href:(this.#s||(this.#s=`${this.#r||"http:"}//${this.#e||"localhost"}${this.#o||"/"}${this.#i||""}`),this.#s)}#a(){if(!this.#h){const t=this.href,e=t.indexOf("://"),i=e===-1?-1:t.indexOf("/",e+4),n=i===-1?-1:t.indexOf("?",i);this.#h=[e,i,n]}return this.#h}get pathname(){if(this.#t)return this.#t.pathname;if(this.#o===void 0){const[,t,e]=this.#a();if(t===-1)return this._url.pathname;this.#o=this.href.slice(t,e===-1?void 0:e)}return this.#o}get search(){if(this.#t)return this.#t.search;if(this.#i===void 0){const[,t,e]=this.#a();if(t===-1)return this._url.search;const i=this.href;this.#i=e===-1||e===i.length-1?"":i.slice(e)}return this.#i}get searchParams(){return this.#t?this.#t.searchParams:(this.#n||(this.#n=new URLSearchParams(this.search)),this.#n)}get protocol(){if(this.#t)return this.#t.protocol;if(this.#r===void 0){const[t]=this.#a();if(t===-1)return this._url.protocol;const e=this.href;this.#r=e.slice(0,t+1)}return this.#r}toString(){return this.href}toJSON(){return this.href}};return N(r.prototype,s.prototype,"_url"),Object.setPrototypeOf(r.prototype,s.prototype),Object.setPrototypeOf(r,s),r})(),St=(()=>{const s=globalThis.Response,r=globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES||{};class o{#t;#s;#r;#e;constructor(e,i){this.#t=e,this.#s=i}static[Symbol.hasInstance](e){return e instanceof s}get status(){return this.#e?.status||this.#s?.status||200}get statusText(){return this.#e?.statusText||this.#s?.statusText||r[this.status]||""}get headers(){if(this.#e)return this.#e.headers;if(this.#r)return this.#r;const e=this.#s?.headers;return this.#r=e instanceof Headers?e:new Headers(e)}get ok(){if(this.#e)return this.#e.ok;const e=this.status;return e>=200&&e<300}get _response(){if(this.#e)return this.#e;let e=this.#t;if(e&&typeof e.pipe=="function"&&!(e instanceof v)){const i=new _;e.pipe(i);const n=e.abort;n&&i.once("close",()=>n()),e=i}return this.#e=new s(e,this.#r?{...this.#s,headers:this.#r}:this.#s),this.#s=void 0,this.#r=void 0,this.#t=void 0,this.#e}_toNodeResponse(){const e=this.status,i=this.statusText;let n,h,a;this.#e?n=this.#e.body:this.#t&&(this.#t instanceof ReadableStream?n=this.#t:typeof this.#t=="string"?(n=this.#t,h="text/plain; charset=UTF-8",a=Buffer.byteLength(this.#t)):this.#t instanceof ArrayBuffer?(n=Buffer.from(this.#t),a=this.#t.byteLength):this.#t instanceof Uint8Array?(n=this.#t,a=this.#t.byteLength):this.#t instanceof DataView?(n=Buffer.from(this.#t.buffer),a=this.#t.byteLength):this.#t instanceof Blob?(n=this.#t.stream(),h=this.#t.type,a=this.#t.size):typeof this.#t.pipe=="function"?n=this.#t:n=this._response.body);const f=[],c=this.#s?.headers,d=this.#e?.headers||this.#r||(c?Array.isArray(c)?c:c?.entries?c.entries():Object.entries(c).map(([u,l])=>[u.toLowerCase(),l]):void 0);let p,y;if(d)for(const[u,l]of d){if(Array.isArray(l))for(const g of l)f.push([u,g]);else f.push([u,l]);u==="content-type"?p=!0:u==="content-length"&&(y=!0)}return h&&!p&&f.push(["content-type",h]),a&&!y&&f.push(["content-length",String(a)]),this.#s=void 0,this.#r=void 0,this.#e=void 0,this.#t=void 0,{status:e,statusText:i,headers:f,body:n}}}return N(o.prototype,s.prototype,"_response"),Object.setPrototypeOf(o,s),Object.setPrototypeOf(o.prototype,s.prototype),o})();function C(s,r,o){for(const t of[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)]){if(t==="constructor")continue;const e=Object.getOwnPropertyDescriptor(s,t),i=Object.getOwnPropertyDescriptor(r,t);let n=!1;i.get&&(n=!0,i.get=e?.get||function(){return this[o][t]}),i.set&&(n=!0,i.set=e?.set||function(h){this[o][t]=h}),!e?.value&&typeof i.value=="function"&&(n=!0,i.value=function(...h){return this[o][t](...h)}),n&&Object.defineProperty(s,t,i)}}const pt=/(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^\x80-\uffff]/i,Pt=(()=>{const s=globalThis.URL,r=class{#t;#s;#r;#e;#o;#i;#n;#h;constructor(t){typeof t=="string"?t[0]==="/"?this.#s=t:this.#t=new s(t):pt.test(t.pathname)?this.#t=new s(`${t.protocol||"http:"}//${t.host||"localhost"}${t.pathname}${t.search||""}`):(this.#r=t.protocol,this.#e=t.host,this.#o=t.pathname,this.#i=t.search)}static[Symbol.hasInstance](t){return t instanceof s}get _url(){return this.#t?this.#t:(this.#t=new s(this.href),this.#s=void 0,this.#r=void 0,this.#e=void 0,this.#o=void 0,this.#i=void 0,this.#n=void 0,this.#h=void 0,this.#t)}get href(){return this.#t?this.#t.href:(this.#s||(this.#s=`${this.#r||"http:"}//${this.#e||"localhost"}${this.#o||"/"}${this.#i||""}`),this.#s)}#a(){if(!this.#h){const t=this.href,e=t.indexOf("://"),i=e===-1?-1:t.indexOf("/",e+4),n=i===-1?-1:t.indexOf("?",i);this.#h=[e,i,n]}return this.#h}get pathname(){if(this.#t)return this.#t.pathname;if(this.#o===void 0){const[,t,e]=this.#a();if(t===-1)return this._url.pathname;this.#o=this.href.slice(t,e===-1?void 0:e)}return this.#o}get search(){if(this.#t)return this.#t.search;if(this.#i===void 0){const[,t,e]=this.#a();if(t===-1)return this._url.search;const i=this.href;this.#i=e===-1||e===i.length-1?"":i.slice(e)}return this.#i}get searchParams(){return this.#t?this.#t.searchParams:(this.#n||(this.#n=new URLSearchParams(this.search)),this.#n)}get protocol(){if(this.#t)return this.#t.protocol;if(this.#r===void 0){const[t]=this.#a();if(t===-1)return this._url.protocol;const e=this.href;this.#r=e.slice(0,t+1)}return this.#r}toString(){return this.href}toJSON(){return this.href}};return C(r.prototype,s.prototype,"_url"),Object.setPrototypeOf(r.prototype,s.prototype),Object.setPrototypeOf(r,s),r})(),Lt=(()=>{const s=globalThis.Response,r=globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES||{};class o{#t;#s;#r;#e;constructor(e,i){this.#t=e,this.#s=i}static[Symbol.hasInstance](e){return e instanceof s}get status(){return this.#e?.status||this.#s?.status||200}get statusText(){return this.#e?.statusText||this.#s?.statusText||r[this.status]||""}get headers(){if(this.#e)return this.#e.headers;if(this.#r)return this.#r;const e=this.#s?.headers;return this.#r=e instanceof Headers?e:new Headers(e)}get ok(){if(this.#e)return this.#e.ok;const e=this.status;return e>=200&&e<300}get _response(){if(this.#e)return this.#e;let e=this.#t;if(e&&typeof e.pipe=="function"&&!(e instanceof v)){const i=new _;e.pipe(i);const n=e.abort;n&&i.once("close",()=>n()),e=i}return this.#e=new s(e,this.#r?{...this.#s,headers:this.#r}:this.#s),this.#s=void 0,this.#r=void 0,this.#t=void 0,this.#e}_toNodeResponse(){const e=this.status,i=this.statusText;let n,h,a;this.#e?n=this.#e.body:this.#t&&(this.#t instanceof ReadableStream?n=this.#t:typeof this.#t=="string"?(n=this.#t,h="text/plain; charset=UTF-8",a=Buffer.byteLength(this.#t)):this.#t instanceof ArrayBuffer?(n=Buffer.from(this.#t),a=this.#t.byteLength):this.#t instanceof Uint8Array?(n=this.#t,a=this.#t.byteLength):this.#t instanceof DataView?(n=Buffer.from(this.#t.buffer),a=this.#t.byteLength):this.#t instanceof Blob?(n=this.#t.stream(),h=this.#t.type,a=this.#t.size):typeof this.#t.pipe=="function"?n=this.#t:n=this._response.body);const f=[],c=this.#s?.headers,d=this.#e?.headers||this.#r||(c?Array.isArray(c)?c:c?.entries?c.entries():Object.entries(c).map(([u,l])=>[u.toLowerCase(),l]):void 0);let p,y;if(d)for(const[u,l]of d){if(Array.isArray(l))for(const g of l)f.push([u,g]);else f.push([u,l]);u==="content-type"?p=!0:u==="content-length"&&(y=!0)}return h&&!p&&f.push(["content-type",h]),a&&!y&&f.push(["content-length",String(a)]),this.#s=void 0,this.#r=void 0,this.#e=void 0,this.#t=void 0,{status:e,statusText:i,headers:f,body:n}}}return C(o.prototype,s.prototype,"_response"),Object.setPrototypeOf(o,s),Object.setPrototypeOf(o.prototype,s.prototype),o})();export{Tt as F,St as N,Pt as a,Lt as b,wt as c,Ot as s};