@10p.io/github 20.67.0 → 20.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/github.bundle.js +1034 -745
  2. package/package.json +1 -1
package/github.bundle.js CHANGED
@@ -41,128 +41,83 @@ var __app = (() => {
41
41
  default: () => stdin_default
42
42
  });
43
43
 
44
- // node_modules/hono/dist/compose.js
45
- var compose = (middleware, onError, onNotFound) => {
46
- return (context, next) => {
47
- let index = -1;
48
- return dispatch(0);
49
- async function dispatch(i) {
50
- if (i <= index) {
51
- throw new Error("next() called multiple times");
52
- }
53
- index = i;
54
- let res;
55
- let isError = false;
56
- let handler;
57
- if (middleware[i]) {
58
- handler = middleware[i][0][0];
59
- context.req.routeIndex = i;
60
- } else {
61
- handler = i === middleware.length && next || void 0;
62
- }
63
- if (handler) {
64
- try {
65
- res = await handler(context, () => dispatch(i + 1));
66
- } catch (err) {
67
- if (err instanceof Error && onError) {
68
- context.error = err;
69
- res = await onError(err, context);
70
- isError = true;
71
- } else {
72
- throw err;
73
- }
74
- }
75
- } else {
76
- if (context.finalized === false && onNotFound) {
77
- res = await onNotFound(context);
78
- }
79
- }
80
- if (res && (context.finalized === false || isError)) {
81
- context.res = res;
82
- }
83
- return context;
84
- }
85
- };
86
- };
87
-
88
44
  // node_modules/hono/dist/request/constants.js
89
45
  var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
90
46
 
47
+ // node_modules/hono/dist/utils/buffer.js
48
+ var bufferToFormData = (arrayBuffer, contentType) => {
49
+ return new Response(arrayBuffer, { headers: { "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) } }).formData();
50
+ };
51
+
91
52
  // node_modules/hono/dist/utils/body.js
53
+ var MAX_NESTED_OBJECTS = 1e4;
54
+ var isRawRequest = (request) => "headers" in request;
92
55
  var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
56
+ var _a14;
93
57
  const { all = false, dot = false } = options;
94
- const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
95
- const contentType = headers.get("Content-Type");
96
- if ((contentType == null ? void 0 : contentType.startsWith("multipart/form-data")) || (contentType == null ? void 0 : contentType.startsWith("application/x-www-form-urlencoded"))) {
97
- return parseFormData(request, { all, dot });
98
- }
58
+ const mediaType = (_a14 = (isRawRequest(request) ? request.headers : request.raw.headers).get("Content-Type")) == null ? void 0 : _a14.split(";")[0].trim().toLowerCase();
59
+ if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return parseFormData(request, {
60
+ all,
61
+ dot
62
+ });
99
63
  return {};
100
64
  };
101
65
  async function parseFormData(request, options) {
102
- const formData = await request.formData();
103
- if (formData) {
104
- return convertFormDataToBodyData(formData, options);
105
- }
66
+ if (!isRawRequest(request) && request.bodyCache.formData) return convertFormDataToBodyData(await request.bodyCache.formData, options);
67
+ const headers = isRawRequest(request) ? request.headers : request.raw.headers;
68
+ const arrayBuffer = await request.arrayBuffer();
69
+ const formDataPromise = bufferToFormData(arrayBuffer, headers.get("Content-Type") || "");
70
+ if (!isRawRequest(request)) request.bodyCache.formData = formDataPromise;
71
+ const formData = await formDataPromise;
72
+ if (formData) return convertFormDataToBodyData(formData, options);
106
73
  return {};
107
74
  }
108
75
  function convertFormDataToBodyData(formData, options) {
109
76
  const form = /* @__PURE__ */ Object.create(null);
77
+ const nestingState = { count: 0 };
110
78
  formData.forEach((value, key) => {
111
- const shouldParseAllValues = options.all || key.endsWith("[]");
112
- if (!shouldParseAllValues) {
113
- form[key] = value;
114
- } else {
115
- handleParsingAllValues(form, key, value);
79
+ if (!(options.all || key.endsWith("[]"))) form[key] = value;
80
+ else handleParsingAllValues(form, key, value);
81
+ });
82
+ if (options.dot) Object.entries(form).forEach(([key, value]) => {
83
+ if (key.includes(".")) {
84
+ handleParsingNestedValues(form, key, value, nestingState);
85
+ delete form[key];
116
86
  }
117
87
  });
118
- if (options.dot) {
119
- Object.entries(form).forEach(([key, value]) => {
120
- const shouldParseDotValues = key.includes(".");
121
- if (shouldParseDotValues) {
122
- handleParsingNestedValues(form, key, value);
123
- delete form[key];
124
- }
125
- });
126
- }
127
88
  return form;
128
89
  }
129
90
  var handleParsingAllValues = (form, key, value) => {
130
91
  if (form[key] !== void 0) {
131
- if (Array.isArray(form[key])) {
132
- ;
133
- form[key].push(value);
134
- } else {
135
- form[key] = [form[key], value];
136
- }
137
- } else {
138
- if (!key.endsWith("[]")) {
139
- form[key] = value;
140
- } else {
141
- form[key] = [value];
142
- }
143
- }
92
+ if (Array.isArray(form[key])) form[key].push(value);
93
+ else form[key] = [form[key], value];
94
+ } else if (!key.endsWith("[]")) form[key] = value;
95
+ else form[key] = [value];
144
96
  };
145
- var handleParsingNestedValues = (form, key, value) => {
97
+ var handleParsingNestedValues = (form, key, value, state) => {
98
+ if (/(?:^|\.)__proto__\./.test(key)) return;
146
99
  let nestedForm = form;
147
- const keys = key.split(".");
100
+ const keys = key.split(".", 34);
101
+ if (keys.length > 33) throwNestingLimitExceeded();
148
102
  keys.forEach((key2, index) => {
149
- if (index === keys.length - 1) {
150
- nestedForm[key2] = value;
151
- } else {
103
+ if (index === keys.length - 1) nestedForm[key2] = value;
104
+ else {
152
105
  if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
106
+ if (state.count++ >= MAX_NESTED_OBJECTS) throwNestingLimitExceeded();
153
107
  nestedForm[key2] = /* @__PURE__ */ Object.create(null);
154
108
  }
155
109
  nestedForm = nestedForm[key2];
156
110
  }
157
111
  });
158
112
  };
113
+ var throwNestingLimitExceeded = () => {
114
+ throw new Error("Nesting limit exceeded");
115
+ };
159
116
 
160
117
  // node_modules/hono/dist/utils/url.js
161
118
  var splitPath = (path) => {
162
119
  const paths = path.split("/");
163
- if (paths[0] === "") {
164
- paths.shift();
165
- }
120
+ if (paths[0] === "") paths.shift();
166
121
  return paths;
167
122
  };
168
123
  var splitRoutingPath = (routePath) => {
@@ -177,34 +132,42 @@ var __app = (() => {
177
132
  groups.push([mark, match2]);
178
133
  return mark;
179
134
  });
180
- return { groups, path };
135
+ return {
136
+ groups,
137
+ path
138
+ };
181
139
  };
182
140
  var replaceGroupMarks = (paths, groups) => {
183
141
  for (let i = groups.length - 1; i >= 0; i--) {
184
142
  const [mark] = groups[i];
185
- for (let j = paths.length - 1; j >= 0; j--) {
186
- if (paths[j].includes(mark)) {
187
- paths[j] = paths[j].replace(mark, groups[i][1]);
188
- break;
189
- }
143
+ for (let j = paths.length - 1; j >= 0; j--) if (paths[j].includes(mark)) {
144
+ paths[j] = paths[j].replace(mark, groups[i][1]);
145
+ break;
190
146
  }
191
147
  }
192
148
  return paths;
193
149
  };
194
150
  var patternCache = {};
195
151
  var getPattern = (label, next) => {
196
- if (label === "*") {
197
- return "*";
198
- }
152
+ if (label === "*") return "*";
199
153
  const match2 = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
200
154
  if (match2) {
201
155
  const cacheKey = `${label}#${next}`;
202
156
  if (!patternCache[cacheKey]) {
203
- if (match2[2]) {
204
- patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [cacheKey, match2[1], new RegExp(`^${match2[2]}(?=/${next})`)] : [label, match2[1], new RegExp(`^${match2[2]}$`)];
205
- } else {
206
- patternCache[cacheKey] = [label, match2[1], true];
207
- }
157
+ if (match2[2]) patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [
158
+ cacheKey,
159
+ match2[1],
160
+ new RegExp(`^${match2[2]}(?=/${next})`)
161
+ ] : [
162
+ label,
163
+ match2[1],
164
+ new RegExp(`^${match2[2]}$`)
165
+ ];
166
+ else patternCache[cacheKey] = [
167
+ label,
168
+ match2[1],
169
+ true
170
+ ];
208
171
  }
209
172
  return patternCache[cacheKey];
210
173
  }
@@ -232,11 +195,11 @@ var __app = (() => {
232
195
  const charCode = url2.charCodeAt(i);
233
196
  if (charCode === 37) {
234
197
  const queryIndex = url2.indexOf("?", i);
235
- const path = url2.slice(start, queryIndex === -1 ? void 0 : queryIndex);
198
+ const hashIndex = url2.indexOf("#", i);
199
+ const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
200
+ const path = url2.slice(start, end);
236
201
  return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
237
- } else if (charCode === 63) {
238
- break;
239
- }
202
+ } else if (charCode === 63 || charCode === 35) break;
240
203
  }
241
204
  return url2.slice(start, i);
242
205
  };
@@ -245,109 +208,75 @@ var __app = (() => {
245
208
  return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
246
209
  };
247
210
  var mergePath = (base, sub, ...rest) => {
248
- if (rest.length) {
249
- sub = mergePath(sub, ...rest);
250
- }
211
+ if (rest.length) sub = mergePath(sub, ...rest);
251
212
  return `${(base == null ? void 0 : base[0]) === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${(base == null ? void 0 : base.at(-1)) === "/" ? "" : "/"}${(sub == null ? void 0 : sub[0]) === "/" ? sub.slice(1) : sub}`}`;
252
213
  };
253
214
  var checkOptionalParameter = (path) => {
254
- if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
255
- return null;
256
- }
215
+ if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) return null;
257
216
  const segments = path.split("/");
258
217
  const results = [];
259
218
  let basePath = "";
260
219
  segments.forEach((segment) => {
261
- if (segment !== "" && !/\:/.test(segment)) {
262
- basePath += "/" + segment;
263
- } else if (/\:/.test(segment)) {
264
- if (/\?/.test(segment)) {
265
- if (results.length === 0 && basePath === "") {
266
- results.push("/");
267
- } else {
268
- results.push(basePath);
269
- }
270
- const optionalSegment = segment.replace("?", "");
220
+ if (segment !== "" && !/\:/.test(segment)) basePath += "/" + segment;
221
+ else if (/\:/.test(segment)) {
222
+ if (segment.charCodeAt(segment.length - 1) === 63) {
223
+ if (results.length === 0 && basePath === "") results.push("/");
224
+ else results.push(basePath);
225
+ const optionalSegment = segment.slice(0, -1);
271
226
  basePath += "/" + optionalSegment;
272
227
  results.push(basePath);
273
- } else {
274
- basePath += "/" + segment;
275
- }
228
+ } else basePath += "/" + segment;
276
229
  }
277
230
  });
278
231
  return results.filter((v, i, a) => a.indexOf(v) === i);
279
232
  };
233
+ var tryDecodeURIComponent = (str) => str.indexOf("%") !== -1 ? tryDecode(str, decodeURIComponent_) : str;
280
234
  var _decodeURI = (value) => {
281
- if (!/[%+]/.test(value)) {
282
- return value;
283
- }
284
- if (value.indexOf("+") !== -1) {
285
- value = value.replace(/\+/g, " ");
286
- }
287
- return value.indexOf("%") !== -1 ? tryDecode(value, decodeURIComponent_) : value;
235
+ if (value.indexOf("+") !== -1) value = value.replace(/\+/g, " ");
236
+ return tryDecodeURIComponent(value);
288
237
  };
289
238
  var _getQueryParam = (url2, key, multiple) => {
290
239
  var _a14;
240
+ const hashIndex = url2.indexOf("#", 8);
241
+ if (hashIndex !== -1) url2 = url2.slice(0, hashIndex);
291
242
  let encoded;
292
- if (!multiple && key && !/[%+]/.test(key)) {
293
- let keyIndex2 = url2.indexOf(`?${key}`, 8);
294
- if (keyIndex2 === -1) {
295
- keyIndex2 = url2.indexOf(`&${key}`, 8);
296
- }
243
+ if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
244
+ let keyIndex2 = url2.indexOf("?", 8);
245
+ if (keyIndex2 === -1) return;
246
+ if (!url2.startsWith(key, keyIndex2 + 1)) keyIndex2 = url2.indexOf(`&${key}`, keyIndex2 + 1);
297
247
  while (keyIndex2 !== -1) {
298
248
  const trailingKeyCode = url2.charCodeAt(keyIndex2 + key.length + 1);
299
249
  if (trailingKeyCode === 61) {
300
250
  const valueIndex = keyIndex2 + key.length + 2;
301
251
  const endIndex = url2.indexOf("&", valueIndex);
302
252
  return _decodeURI(url2.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
303
- } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) {
304
- return "";
305
- }
253
+ } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) return "";
306
254
  keyIndex2 = url2.indexOf(`&${key}`, keyIndex2 + 1);
307
255
  }
308
256
  encoded = /[%+]/.test(url2);
309
- if (!encoded) {
310
- return void 0;
311
- }
257
+ if (!encoded) return;
312
258
  }
313
- const results = {};
259
+ const results = /* @__PURE__ */ Object.create(null);
314
260
  encoded != null ? encoded : encoded = /[%+]/.test(url2);
315
261
  let keyIndex = url2.indexOf("?", 8);
316
262
  while (keyIndex !== -1) {
317
263
  const nextKeyIndex = url2.indexOf("&", keyIndex + 1);
318
264
  let valueIndex = url2.indexOf("=", keyIndex);
319
- if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) {
320
- valueIndex = -1;
321
- }
322
- let name = url2.slice(
323
- keyIndex + 1,
324
- valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex
325
- );
326
- if (encoded) {
327
- name = _decodeURI(name);
328
- }
265
+ if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) valueIndex = -1;
266
+ let name = url2.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex);
267
+ if (encoded) name = _decodeURI(name);
329
268
  keyIndex = nextKeyIndex;
330
- if (name === "") {
331
- continue;
332
- }
269
+ if (name === "") continue;
333
270
  let value;
334
- if (valueIndex === -1) {
335
- value = "";
336
- } else {
271
+ if (valueIndex === -1) value = "";
272
+ else {
337
273
  value = url2.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);
338
- if (encoded) {
339
- value = _decodeURI(value);
340
- }
274
+ if (encoded) value = _decodeURI(value);
341
275
  }
342
276
  if (multiple) {
343
- if (!(results[name] && Array.isArray(results[name]))) {
344
- results[name] = [];
345
- }
346
- ;
277
+ if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
347
278
  results[name].push(value);
348
- } else {
349
- (_a14 = results[name]) != null ? _a14 : results[name] = value;
350
- }
279
+ } else (_a14 = results[name]) != null ? _a14 : results[name] = value;
351
280
  }
352
281
  return key ? results[key] : results;
353
282
  };
@@ -358,38 +287,56 @@ var __app = (() => {
358
287
  var decodeURIComponent_ = decodeURIComponent;
359
288
 
360
289
  // node_modules/hono/dist/request.js
361
- var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
362
290
  var _validatedData, _matchResult, _HonoRequest_instances, getDecodedParam_fn, getAllDecodedParams_fn, getParamValue_fn, _cachedBody, _a;
363
291
  var HonoRequest = (_a = class {
364
292
  constructor(request, path = "/", matchResult = [[]]) {
365
293
  __privateAdd(this, _HonoRequest_instances);
294
+ /**
295
+ * `.raw` can get the raw Request object.
296
+ *
297
+ * @see {@link https://hono.dev/docs/api/request#raw}
298
+ *
299
+ * @example
300
+ * ```ts
301
+ * // For Cloudflare Workers
302
+ * app.post('/', async (c) => {
303
+ * const metadata = c.req.raw.cf?.hostMetadata?
304
+ * ...
305
+ * })
306
+ * ```
307
+ */
366
308
  __publicField(this, "raw");
367
309
  __privateAdd(this, _validatedData);
368
310
  __privateAdd(this, _matchResult);
369
311
  __publicField(this, "routeIndex", 0);
312
+ /**
313
+ * `.path` can get the pathname of the request.
314
+ *
315
+ * @see {@link https://hono.dev/docs/api/request#path}
316
+ *
317
+ * @example
318
+ * ```ts
319
+ * app.get('/about/me', (c) => {
320
+ * const pathname = c.req.path // `/about/me`
321
+ * })
322
+ * ```
323
+ */
370
324
  __publicField(this, "path");
371
325
  __publicField(this, "bodyCache", {});
372
326
  __privateAdd(this, _cachedBody, (key) => {
373
327
  const { bodyCache, raw: raw2 } = this;
374
328
  const cachedBody = bodyCache[key];
375
- if (cachedBody) {
376
- return cachedBody;
377
- }
378
- const anyCachedKey = Object.keys(bodyCache)[0];
379
- if (anyCachedKey) {
380
- return bodyCache[anyCachedKey].then((body) => {
381
- if (anyCachedKey === "json") {
382
- body = JSON.stringify(body);
383
- }
384
- return new Response(body)[key]();
385
- });
386
- }
329
+ if (cachedBody) return cachedBody;
330
+ for (const anyCachedKey in bodyCache) return bodyCache[anyCachedKey].then((body) => {
331
+ if (anyCachedKey === "json") body = JSON.stringify(body);
332
+ const contentType = anyCachedKey === "formData" ? void 0 : raw2.headers.get("content-type");
333
+ return new Response(body, { headers: contentType ? { "Content-Type": contentType } : void 0 })[key]();
334
+ });
387
335
  return bodyCache[key] = raw2[key]();
388
336
  });
389
337
  this.raw = request;
390
338
  this.path = path;
391
339
  __privateSet(this, _matchResult, matchResult);
392
- __privateSet(this, _validatedData, {});
393
340
  }
394
341
  param(key) {
395
342
  return key ? __privateMethod(this, _HonoRequest_instances, getDecodedParam_fn).call(this, key) : __privateMethod(this, _HonoRequest_instances, getAllDecodedParams_fn).call(this);
@@ -402,67 +349,211 @@ var __app = (() => {
402
349
  }
403
350
  header(name) {
404
351
  var _a14;
405
- if (name) {
406
- return (_a14 = this.raw.headers.get(name)) != null ? _a14 : void 0;
407
- }
408
- const headerData = {};
352
+ if (name) return (_a14 = this.raw.headers.get(name)) != null ? _a14 : void 0;
353
+ const headerData = /* @__PURE__ */ Object.create(null);
409
354
  this.raw.headers.forEach((value, key) => {
410
355
  headerData[key] = value;
411
356
  });
412
357
  return headerData;
413
358
  }
414
359
  async parseBody(options) {
415
- var _a14, _b;
416
- return (_b = (_a14 = this.bodyCache).parsedBody) != null ? _b : _a14.parsedBody = await parseBody(this, options);
360
+ return parseBody(this, options);
417
361
  }
362
+ /**
363
+ * `.json()` can parse Request body of type `application/json`
364
+ *
365
+ * @see {@link https://hono.dev/docs/api/request#json}
366
+ *
367
+ * @example
368
+ * ```ts
369
+ * app.post('/entry', async (c) => {
370
+ * const body = await c.req.json()
371
+ * })
372
+ * ```
373
+ */
418
374
  json() {
419
375
  return __privateGet(this, _cachedBody).call(this, "text").then((text) => JSON.parse(text));
420
376
  }
377
+ /**
378
+ * `.text()` can parse Request body of type `text/plain`
379
+ *
380
+ * @see {@link https://hono.dev/docs/api/request#text}
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * app.post('/entry', async (c) => {
385
+ * const body = await c.req.text()
386
+ * })
387
+ * ```
388
+ */
421
389
  text() {
422
390
  return __privateGet(this, _cachedBody).call(this, "text");
423
391
  }
392
+ /**
393
+ * `.arrayBuffer()` parse Request body as an `ArrayBuffer`
394
+ *
395
+ * @see {@link https://hono.dev/docs/api/request#arraybuffer}
396
+ *
397
+ * @example
398
+ * ```ts
399
+ * app.post('/entry', async (c) => {
400
+ * const body = await c.req.arrayBuffer()
401
+ * })
402
+ * ```
403
+ */
424
404
  arrayBuffer() {
425
405
  return __privateGet(this, _cachedBody).call(this, "arrayBuffer");
426
406
  }
407
+ /**
408
+ * `.bytes()` parses the request body as a `Uint8Array`.
409
+ *
410
+ * @see {@link https://hono.dev/docs/api/request#bytes}
411
+ *
412
+ * @example
413
+ * ```ts
414
+ * app.post('/entry', async (c) => {
415
+ * const body = await c.req.bytes()
416
+ * })
417
+ * ```
418
+ */
419
+ bytes() {
420
+ return __privateGet(this, _cachedBody).call(this, "arrayBuffer").then((buffer) => new Uint8Array(buffer));
421
+ }
422
+ /**
423
+ * Parses the request body as a `Blob`.
424
+ * @example
425
+ * ```ts
426
+ * app.post('/entry', async (c) => {
427
+ * const body = await c.req.blob();
428
+ * });
429
+ * ```
430
+ * @see https://hono.dev/docs/api/request#blob
431
+ */
427
432
  blob() {
428
433
  return __privateGet(this, _cachedBody).call(this, "blob");
429
434
  }
435
+ /**
436
+ * Parses the request body as `FormData`.
437
+ * @example
438
+ * ```ts
439
+ * app.post('/entry', async (c) => {
440
+ * const body = await c.req.formData();
441
+ * });
442
+ * ```
443
+ * @see https://hono.dev/docs/api/request#formdata
444
+ */
430
445
  formData() {
431
446
  return __privateGet(this, _cachedBody).call(this, "formData");
432
447
  }
448
+ /**
449
+ * Adds validated data to the request.
450
+ *
451
+ * @param target - The target of the validation.
452
+ * @param data - The validated data to add.
453
+ */
433
454
  addValidatedData(target, data) {
434
- __privateGet(this, _validatedData)[target] = data;
455
+ var _a14;
456
+ ((_a14 = __privateGet(this, _validatedData)) != null ? _a14 : __privateSet(this, _validatedData, {}))[target] = data;
435
457
  }
436
458
  valid(target) {
437
- return __privateGet(this, _validatedData)[target];
459
+ var _a14;
460
+ return (_a14 = __privateGet(this, _validatedData)) == null ? void 0 : _a14[target];
438
461
  }
462
+ /**
463
+ * `.url` can get the request url strings.
464
+ *
465
+ * @see {@link https://hono.dev/docs/api/request#url}
466
+ *
467
+ * @example
468
+ * ```ts
469
+ * app.get('/about/me', (c) => {
470
+ * const url = c.req.url // `http://localhost:8787/about/me`
471
+ * ...
472
+ * })
473
+ * ```
474
+ */
439
475
  get url() {
440
476
  return this.raw.url;
441
477
  }
478
+ /**
479
+ * `.method` can get the method name of the request.
480
+ *
481
+ * @see {@link https://hono.dev/docs/api/request#method}
482
+ *
483
+ * @example
484
+ * ```ts
485
+ * app.get('/about/me', (c) => {
486
+ * const method = c.req.method // `GET`
487
+ * })
488
+ * ```
489
+ */
442
490
  get method() {
443
491
  return this.raw.method;
444
492
  }
445
493
  get [GET_MATCH_RESULT]() {
446
494
  return __privateGet(this, _matchResult);
447
495
  }
496
+ /**
497
+ * `.matchedRoutes` can return a matched route in the handler
498
+ *
499
+ * @deprecated
500
+ *
501
+ * Use matchedRoutes helper defined in "hono/route" instead.
502
+ *
503
+ * @see {@link https://hono.dev/docs/api/request#matchedroutes}
504
+ *
505
+ * @example
506
+ * ```ts
507
+ * app.use('*', async function logger(c, next) {
508
+ * await next()
509
+ * c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
510
+ * const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
511
+ * console.log(
512
+ * method,
513
+ * ' ',
514
+ * path,
515
+ * ' '.repeat(Math.max(10 - path.length, 0)),
516
+ * name,
517
+ * i === c.req.routeIndex ? '<- respond from here' : ''
518
+ * )
519
+ * })
520
+ * })
521
+ * ```
522
+ */
448
523
  get matchedRoutes() {
449
524
  return __privateGet(this, _matchResult)[0].map(([[, route]]) => route);
450
525
  }
526
+ /**
527
+ * `.routePath` can retrieve the path registered within the handler
528
+ *
529
+ * @deprecated
530
+ *
531
+ * Use routePath helper defined in "hono/route" instead.
532
+ *
533
+ * @see {@link https://hono.dev/docs/api/request#routepath}
534
+ *
535
+ * @example
536
+ * ```ts
537
+ * app.get('/posts/:id', (c) => {
538
+ * return c.json({ path: c.req.routePath })
539
+ * })
540
+ * ```
541
+ */
451
542
  get routePath() {
452
543
  return __privateGet(this, _matchResult)[0].map(([[, route]]) => route)[this.routeIndex].path;
453
544
  }
454
545
  }, _validatedData = new WeakMap(), _matchResult = new WeakMap(), _HonoRequest_instances = new WeakSet(), getDecodedParam_fn = function(key) {
455
- const paramKey = __privateGet(this, _matchResult)[0][this.routeIndex][1][key];
546
+ var _a14;
547
+ const paramKey = (_a14 = __privateGet(this, _matchResult)[0][this.routeIndex]) == null ? void 0 : _a14[1][key];
456
548
  const param = __privateMethod(this, _HonoRequest_instances, getParamValue_fn).call(this, paramKey);
457
- return param && /\%/.test(param) ? tryDecodeURIComponent(param) : param;
549
+ return param && tryDecodeURIComponent(param);
458
550
  }, getAllDecodedParams_fn = function() {
551
+ var _a14, _b;
459
552
  const decoded = {};
460
- const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]);
553
+ const keys = Object.keys((_b = (_a14 = __privateGet(this, _matchResult)[0][this.routeIndex]) == null ? void 0 : _a14[1]) != null ? _b : {});
461
554
  for (const key of keys) {
462
555
  const value = __privateMethod(this, _HonoRequest_instances, getParamValue_fn).call(this, __privateGet(this, _matchResult)[0][this.routeIndex][1][key]);
463
- if (value !== void 0) {
464
- decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value;
465
- }
556
+ if (value !== void 0) decoded[key] = tryDecodeURIComponent(value);
466
557
  }
467
558
  return decoded;
468
559
  }, getParamValue_fn = function(paramKey) {
@@ -483,32 +574,20 @@ var __app = (() => {
483
574
  };
484
575
  var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
485
576
  if (typeof str === "object" && !(str instanceof String)) {
486
- if (!(str instanceof Promise)) {
487
- str = str.toString();
488
- }
489
- if (str instanceof Promise) {
490
- str = await str;
491
- }
577
+ if (!(str instanceof Promise)) str = str.toString();
578
+ if (str instanceof Promise) str = await str;
492
579
  }
493
580
  const callbacks = str.callbacks;
494
- if (!(callbacks == null ? void 0 : callbacks.length)) {
495
- return Promise.resolve(str);
496
- }
497
- if (buffer) {
498
- buffer[0] += str;
499
- } else {
500
- buffer = [str];
501
- }
502
- const resStr = Promise.all(callbacks.map((c) => c({ phase, buffer, context }))).then(
503
- (res) => Promise.all(
504
- res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))
505
- ).then(() => buffer[0])
506
- );
507
- if (preserveCallbacks) {
508
- return raw(await resStr, callbacks);
509
- } else {
510
- return resStr;
511
- }
581
+ if (!(callbacks == null ? void 0 : callbacks.length)) return Promise.resolve(str);
582
+ if (buffer) buffer[0] += str;
583
+ else buffer = [str];
584
+ const resStr = Promise.all(callbacks.map((c) => c({
585
+ phase,
586
+ buffer,
587
+ context
588
+ }))).then((res) => Promise.all(res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))).then(() => buffer[0]));
589
+ if (preserveCallbacks) return raw(await resStr, callbacks);
590
+ else return resStr;
512
591
  };
513
592
 
514
593
  // node_modules/hono/dist/context.js
@@ -519,15 +598,50 @@ var __app = (() => {
519
598
  ...headers
520
599
  };
521
600
  };
601
+ var createResponseInstance = (body, init) => new Response(body, init);
522
602
  var _rawRequest, _req, _var, _status, _executionCtx, _res, _layout, _renderer, _notFoundHandler, _preparedHeaders, _matchResult2, _path, _Context_instances, newResponse_fn, _a2;
523
603
  var Context = (_a2 = class {
604
+ /**
605
+ * Creates an instance of the Context class.
606
+ *
607
+ * @param req - The Request object.
608
+ * @param options - Optional configuration options for the context.
609
+ */
524
610
  constructor(req, options) {
525
611
  __privateAdd(this, _Context_instances);
526
612
  __privateAdd(this, _rawRequest);
527
613
  __privateAdd(this, _req);
614
+ /**
615
+ * `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
616
+ *
617
+ * @see {@link https://hono.dev/docs/api/context#env}
618
+ *
619
+ * @example
620
+ * ```ts
621
+ * // Environment object for Cloudflare Workers
622
+ * app.get('*', async c => {
623
+ * const counter = c.env.COUNTER
624
+ * })
625
+ * ```
626
+ */
528
627
  __publicField(this, "env", {});
529
628
  __privateAdd(this, _var);
530
629
  __publicField(this, "finalized", false);
630
+ /**
631
+ * `.error` can get the error object from the middleware if the Handler throws an error.
632
+ *
633
+ * @see {@link https://hono.dev/docs/api/context#error}
634
+ *
635
+ * @example
636
+ * ```ts
637
+ * app.use('*', async (c, next) => {
638
+ * await next()
639
+ * if (c.error) {
640
+ * // do something...
641
+ * }
642
+ * })
643
+ * ```
644
+ */
531
645
  __publicField(this, "error");
532
646
  __privateAdd(this, _status);
533
647
  __privateAdd(this, _executionCtx);
@@ -538,46 +652,175 @@ var __app = (() => {
538
652
  __privateAdd(this, _preparedHeaders);
539
653
  __privateAdd(this, _matchResult2);
540
654
  __privateAdd(this, _path);
655
+ /**
656
+ * `.render()` can create a response within a layout.
657
+ *
658
+ * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
659
+ *
660
+ * @example
661
+ * ```ts
662
+ * app.get('/', (c) => {
663
+ * return c.render('Hello!')
664
+ * })
665
+ * ```
666
+ */
541
667
  __publicField(this, "render", (...args) => {
542
668
  var _a14;
543
669
  (_a14 = __privateGet(this, _renderer)) != null ? _a14 : __privateSet(this, _renderer, (content) => this.html(content));
544
670
  return __privateGet(this, _renderer).call(this, ...args);
545
671
  });
672
+ /**
673
+ * Sets the layout for the response.
674
+ *
675
+ * @param layout - The layout to set.
676
+ * @returns The layout function.
677
+ */
546
678
  __publicField(this, "setLayout", (layout) => __privateSet(this, _layout, layout));
679
+ /**
680
+ * Gets the current layout for the response.
681
+ *
682
+ * @returns The current layout function.
683
+ */
547
684
  __publicField(this, "getLayout", () => __privateGet(this, _layout));
685
+ /**
686
+ * `.setRenderer()` can set the layout in the custom middleware.
687
+ *
688
+ * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
689
+ *
690
+ * @example
691
+ * ```tsx
692
+ * app.use('*', async (c, next) => {
693
+ * c.setRenderer((content) => {
694
+ * return c.html(
695
+ * <html>
696
+ * <body>
697
+ * <p>{content}</p>
698
+ * </body>
699
+ * </html>
700
+ * )
701
+ * })
702
+ * await next()
703
+ * })
704
+ * ```
705
+ */
548
706
  __publicField(this, "setRenderer", (renderer) => {
549
707
  __privateSet(this, _renderer, renderer);
550
708
  });
709
+ /**
710
+ * `.header()` can set headers.
711
+ *
712
+ * @see {@link https://hono.dev/docs/api/context#header}
713
+ *
714
+ * @example
715
+ * ```ts
716
+ * app.get('/welcome', (c) => {
717
+ * // Set headers
718
+ * c.header('X-Message', 'Hello!')
719
+ * c.header('Content-Type', 'text/plain')
720
+ *
721
+ * // Append multiple headers using the append option (e.g. Vary)
722
+ * c.header('Vary', 'Accept-Encoding', { append: true })
723
+ * c.header('Vary', 'User-Agent', { append: true })
724
+ *
725
+ * return c.body('Thank you for coming')
726
+ * })
727
+ * ```
728
+ */
551
729
  __publicField(this, "header", (name, value, options) => {
552
730
  var _a14;
553
- if (this.finalized) {
554
- __privateSet(this, _res, new Response(__privateGet(this, _res).body, __privateGet(this, _res)));
555
- }
731
+ if (this.finalized) __privateSet(this, _res, createResponseInstance(__privateGet(this, _res).body, __privateGet(this, _res)));
556
732
  const headers = __privateGet(this, _res) ? __privateGet(this, _res).headers : (_a14 = __privateGet(this, _preparedHeaders)) != null ? _a14 : __privateSet(this, _preparedHeaders, new Headers());
557
- if (value === void 0) {
558
- headers.delete(name);
559
- } else if (options == null ? void 0 : options.append) {
560
- headers.append(name, value);
561
- } else {
562
- headers.set(name, value);
563
- }
733
+ if (value === void 0) headers.delete(name);
734
+ else if (options == null ? void 0 : options.append) headers.append(name, value);
735
+ else headers.set(name, value);
564
736
  });
565
737
  __publicField(this, "status", (status) => {
566
738
  __privateSet(this, _status, status);
567
739
  });
740
+ /**
741
+ * `.set()` can set the value specified by the key.
742
+ *
743
+ * @see {@link https://hono.dev/docs/api/context#set-get}
744
+ *
745
+ * @example
746
+ * ```ts
747
+ * app.use('*', async (c, next) => {
748
+ * c.set('message', 'Hono is hot!!')
749
+ * await next()
750
+ * })
751
+ * ```
752
+ */
568
753
  __publicField(this, "set", (key, value) => {
569
754
  var _a14;
570
755
  (_a14 = __privateGet(this, _var)) != null ? _a14 : __privateSet(this, _var, /* @__PURE__ */ new Map());
571
756
  __privateGet(this, _var).set(key, value);
572
757
  });
758
+ /**
759
+ * `.get()` can use the value specified by the key.
760
+ *
761
+ * @see {@link https://hono.dev/docs/api/context#set-get}
762
+ *
763
+ * @example
764
+ * ```ts
765
+ * app.get('/', (c) => {
766
+ * const message = c.get('message')
767
+ * return c.text(`The message is "${message}"`)
768
+ * })
769
+ * ```
770
+ */
573
771
  __publicField(this, "get", (key) => {
574
772
  return __privateGet(this, _var) ? __privateGet(this, _var).get(key) : void 0;
575
773
  });
576
774
  __publicField(this, "newResponse", (...args) => __privateMethod(this, _Context_instances, newResponse_fn).call(this, ...args));
775
+ /**
776
+ * `.body()` can return the HTTP response.
777
+ * You can set headers with `.header()` and set HTTP status code with `.status`.
778
+ * This can also be set in `.text()`, `.json()` and so on.
779
+ *
780
+ * @see {@link https://hono.dev/docs/api/context#body}
781
+ *
782
+ * @example
783
+ * ```ts
784
+ * app.get('/welcome', (c) => {
785
+ * // Set headers
786
+ * c.header('X-Message', 'Hello!')
787
+ * c.header('Content-Type', 'text/plain')
788
+ * // Set HTTP status code
789
+ * c.status(201)
790
+ *
791
+ * // Return the response body
792
+ * return c.body('Thank you for coming')
793
+ * })
794
+ * ```
795
+ */
577
796
  __publicField(this, "body", (data, arg, headers) => __privateMethod(this, _Context_instances, newResponse_fn).call(this, data, arg, headers));
797
+ /**
798
+ * `.text()` can render text as `Content-Type:text/plain`.
799
+ *
800
+ * @see {@link https://hono.dev/docs/api/context#text}
801
+ *
802
+ * @example
803
+ * ```ts
804
+ * app.get('/say', (c) => {
805
+ * return c.text('Hello!')
806
+ * })
807
+ * ```
808
+ */
578
809
  __publicField(this, "text", (text, arg, headers) => {
579
810
  return !__privateGet(this, _preparedHeaders) && !__privateGet(this, _status) && !arg && !headers && !this.finalized ? new Response(text) : __privateMethod(this, _Context_instances, newResponse_fn).call(this, text, arg, setDefaultContentType(TEXT_PLAIN, headers));
580
811
  });
812
+ /**
813
+ * `.json()` can render JSON as `Content-Type:application/json`.
814
+ *
815
+ * @see {@link https://hono.dev/docs/api/context#json}
816
+ *
817
+ * @example
818
+ * ```ts
819
+ * app.get('/api', (c) => {
820
+ * return c.json({ message: 'Hello!' })
821
+ * })
822
+ * ```
823
+ */
581
824
  __publicField(this, "json", (object2, arg, headers) => {
582
825
  return __privateMethod(this, _Context_instances, newResponse_fn).call(this, JSON.stringify(object2), arg, setDefaultContentType("application/json", headers));
583
826
  });
@@ -585,17 +828,41 @@ var __app = (() => {
585
828
  const res = (html2) => __privateMethod(this, _Context_instances, newResponse_fn).call(this, html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
586
829
  return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
587
830
  });
831
+ /**
832
+ * `.redirect()` can Redirect, default status code is 302.
833
+ *
834
+ * @see {@link https://hono.dev/docs/api/context#redirect}
835
+ *
836
+ * @example
837
+ * ```ts
838
+ * app.get('/redirect', (c) => {
839
+ * return c.redirect('/')
840
+ * })
841
+ * app.get('/redirect-permanently', (c) => {
842
+ * return c.redirect('/', 301)
843
+ * })
844
+ * ```
845
+ */
588
846
  __publicField(this, "redirect", (location, status) => {
589
847
  const locationString = String(location);
590
- this.header(
591
- "Location",
592
- !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
593
- );
848
+ this.header("Location", !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString));
594
849
  return this.newResponse(null, status != null ? status : 302);
595
850
  });
851
+ /**
852
+ * `.notFound()` can return the Not Found Response.
853
+ *
854
+ * @see {@link https://hono.dev/docs/api/context#notfound}
855
+ *
856
+ * @example
857
+ * ```ts
858
+ * app.get('/notfound', (c) => {
859
+ * return c.notFound()
860
+ * })
861
+ * ```
862
+ */
596
863
  __publicField(this, "notFound", () => {
597
864
  var _a14;
598
- (_a14 = __privateGet(this, _notFoundHandler)) != null ? _a14 : __privateSet(this, _notFoundHandler, () => new Response());
865
+ (_a14 = __privateGet(this, _notFoundHandler)) != null ? _a14 : __privateSet(this, _notFoundHandler, () => createResponseInstance());
599
866
  return __privateGet(this, _notFoundHandler).call(this, this);
600
867
  });
601
868
  __privateSet(this, _rawRequest, req);
@@ -607,91 +874,149 @@ var __app = (() => {
607
874
  __privateSet(this, _matchResult2, options.matchResult);
608
875
  }
609
876
  }
877
+ /**
878
+ * `.req` is the instance of {@link HonoRequest}.
879
+ */
610
880
  get req() {
611
881
  var _a14;
612
882
  (_a14 = __privateGet(this, _req)) != null ? _a14 : __privateSet(this, _req, new HonoRequest(__privateGet(this, _rawRequest), __privateGet(this, _path), __privateGet(this, _matchResult2)));
613
883
  return __privateGet(this, _req);
614
884
  }
885
+ /**
886
+ * @see {@link https://hono.dev/docs/api/context#event}
887
+ * The FetchEvent associated with the current request.
888
+ *
889
+ * @throws Will throw an error if the context does not have a FetchEvent.
890
+ */
615
891
  get event() {
616
- if (__privateGet(this, _executionCtx) && "respondWith" in __privateGet(this, _executionCtx)) {
617
- return __privateGet(this, _executionCtx);
618
- } else {
619
- throw Error("This context has no FetchEvent");
620
- }
892
+ if (__privateGet(this, _executionCtx) && "respondWith" in __privateGet(this, _executionCtx)) return __privateGet(this, _executionCtx);
893
+ else throw Error("This context has no FetchEvent");
621
894
  }
895
+ /**
896
+ * @see {@link https://hono.dev/docs/api/context#executionctx}
897
+ * The ExecutionContext associated with the current request.
898
+ *
899
+ * @throws Will throw an error if the context does not have an ExecutionContext.
900
+ */
622
901
  get executionCtx() {
623
- if (__privateGet(this, _executionCtx)) {
624
- return __privateGet(this, _executionCtx);
625
- } else {
626
- throw Error("This context has no ExecutionContext");
627
- }
902
+ if (__privateGet(this, _executionCtx)) return __privateGet(this, _executionCtx);
903
+ else throw Error("This context has no ExecutionContext");
628
904
  }
905
+ /**
906
+ * @see {@link https://hono.dev/docs/api/context#res}
907
+ * The Response object for the current request.
908
+ */
629
909
  get res() {
630
910
  var _a14;
631
- return __privateGet(this, _res) || __privateSet(this, _res, new Response(null, {
632
- headers: (_a14 = __privateGet(this, _preparedHeaders)) != null ? _a14 : __privateSet(this, _preparedHeaders, new Headers())
633
- }));
911
+ return __privateGet(this, _res) || __privateSet(this, _res, createResponseInstance(null, { headers: (_a14 = __privateGet(this, _preparedHeaders)) != null ? _a14 : __privateSet(this, _preparedHeaders, new Headers()) }));
634
912
  }
913
+ /**
914
+ * Sets the Response object for the current request.
915
+ *
916
+ * @param _res - The Response object to set.
917
+ */
635
918
  set res(_res2) {
636
919
  if (__privateGet(this, _res) && _res2) {
637
- _res2 = new Response(_res2.body, _res2);
920
+ _res2 = createResponseInstance(_res2.body, _res2);
638
921
  for (const [k, v] of __privateGet(this, _res).headers.entries()) {
639
- if (k === "content-type") {
640
- continue;
641
- }
922
+ if (k === "content-type") continue;
642
923
  if (k === "set-cookie") {
643
924
  const cookies = __privateGet(this, _res).headers.getSetCookie();
644
925
  _res2.headers.delete("set-cookie");
645
- for (const cookie of cookies) {
646
- _res2.headers.append("set-cookie", cookie);
647
- }
648
- } else {
649
- _res2.headers.set(k, v);
650
- }
926
+ for (const cookie of cookies) _res2.headers.append("set-cookie", cookie);
927
+ } else _res2.headers.set(k, v);
651
928
  }
652
929
  }
653
930
  __privateSet(this, _res, _res2);
654
931
  this.finalized = true;
655
932
  }
933
+ /**
934
+ * `.var` can access the value of a variable.
935
+ *
936
+ * @see {@link https://hono.dev/docs/api/context#var}
937
+ *
938
+ * @example
939
+ * ```ts
940
+ * const result = c.var.client.oneMethod()
941
+ * ```
942
+ */
656
943
  get var() {
657
- if (!__privateGet(this, _var)) {
658
- return {};
659
- }
944
+ if (!__privateGet(this, _var)) return {};
660
945
  return Object.fromEntries(__privateGet(this, _var));
661
946
  }
662
947
  }, _rawRequest = new WeakMap(), _req = new WeakMap(), _var = new WeakMap(), _status = new WeakMap(), _executionCtx = new WeakMap(), _res = new WeakMap(), _layout = new WeakMap(), _renderer = new WeakMap(), _notFoundHandler = new WeakMap(), _preparedHeaders = new WeakMap(), _matchResult2 = new WeakMap(), _path = new WeakMap(), _Context_instances = new WeakSet(), newResponse_fn = function(data, arg, headers) {
663
- var _a14, _b;
664
- const responseHeaders = __privateGet(this, _res) ? new Headers(__privateGet(this, _res).headers) : (_a14 = __privateGet(this, _preparedHeaders)) != null ? _a14 : new Headers();
665
- if (typeof arg === "object" && "headers" in arg) {
666
- const argHeaders = arg.headers instanceof Headers ? arg.headers : new Headers(arg.headers);
667
- for (const [key, value] of argHeaders) {
668
- if (key.toLowerCase() === "set-cookie") {
669
- responseHeaders.append(key, value);
670
- } else {
671
- responseHeaders.set(key, value);
672
- }
673
- }
948
+ var _a14;
949
+ let responseHeaders = __privateGet(this, _res) ? new Headers(__privateGet(this, _res).headers) : __privateGet(this, _preparedHeaders);
950
+ if (typeof arg === "object" && arg.headers) {
951
+ responseHeaders != null ? responseHeaders : responseHeaders = new Headers();
952
+ for (const [key, value] of new Headers(arg.headers)) if (key === "set-cookie") responseHeaders.append(key, value);
953
+ else responseHeaders.set(key, value);
674
954
  }
675
955
  if (headers) {
676
- for (const [k, v] of Object.entries(headers)) {
677
- if (typeof v === "string") {
678
- responseHeaders.set(k, v);
679
- } else {
956
+ if (!responseHeaders) {
957
+ let count = 0;
958
+ for (const k in headers) if (++count > 1 || typeof headers[k] !== "string") {
959
+ responseHeaders = new Headers();
960
+ break;
961
+ }
962
+ }
963
+ if (responseHeaders) for (const k in headers) {
964
+ const v = headers[k];
965
+ if (typeof v === "string") responseHeaders.set(k, v);
966
+ else {
680
967
  responseHeaders.delete(k);
681
- for (const v2 of v) {
682
- responseHeaders.append(k, v2);
683
- }
968
+ for (const v2 of v) responseHeaders.append(k, v2);
684
969
  }
685
970
  }
686
971
  }
687
- const status = typeof arg === "number" ? arg : (_b = arg == null ? void 0 : arg.status) != null ? _b : __privateGet(this, _status);
688
- return new Response(data, { status, headers: responseHeaders });
972
+ const status = typeof arg === "number" ? arg : (_a14 = arg == null ? void 0 : arg.status) != null ? _a14 : __privateGet(this, _status);
973
+ return createResponseInstance(data, {
974
+ status,
975
+ headers: responseHeaders != null ? responseHeaders : headers
976
+ });
689
977
  }, _a2);
690
978
 
979
+ // node_modules/hono/dist/compose.js
980
+ var compose = (middleware, onError, onNotFound) => {
981
+ return (context, next) => {
982
+ let index = -1;
983
+ return dispatch(0);
984
+ async function dispatch(i) {
985
+ if (i <= index) throw new Error("next() called multiple times");
986
+ index = i;
987
+ let res;
988
+ let isError = false;
989
+ let handler;
990
+ if (middleware[i]) {
991
+ handler = middleware[i][0][0];
992
+ context.req.routeIndex = i;
993
+ } else handler = i === middleware.length && next || void 0;
994
+ if (handler) try {
995
+ res = await handler(context, () => dispatch(i + 1));
996
+ } catch (err) {
997
+ if (err instanceof Error && onError) {
998
+ context.error = err;
999
+ res = await onError(err, context);
1000
+ isError = true;
1001
+ } else throw err;
1002
+ }
1003
+ else if (context.finalized === false && onNotFound) res = await onNotFound(context);
1004
+ if (res && (context.finalized === false || isError)) context.res = res;
1005
+ return context;
1006
+ }
1007
+ };
1008
+ };
1009
+
691
1010
  // node_modules/hono/dist/router.js
692
- var METHOD_NAME_ALL = "ALL";
693
- var METHOD_NAME_ALL_LOWERCASE = "all";
694
- var METHODS = ["get", "post", "put", "delete", "options", "patch"];
1011
+ var METHODS = [
1012
+ "get",
1013
+ "post",
1014
+ "put",
1015
+ "delete",
1016
+ "options",
1017
+ "patch",
1018
+ "query"
1019
+ ];
695
1020
  var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
696
1021
  var UnsupportedPathError = class extends Error {
697
1022
  };
@@ -721,6 +1046,7 @@ var __app = (() => {
721
1046
  __publicField(this, "delete");
722
1047
  __publicField(this, "options");
723
1048
  __publicField(this, "patch");
1049
+ __publicField(this, "query");
724
1050
  __publicField(this, "all");
725
1051
  __publicField(this, "on");
726
1052
  __publicField(this, "use");
@@ -731,47 +1057,106 @@ var __app = (() => {
731
1057
  __publicField(this, "routes", []);
732
1058
  __privateAdd(this, _notFoundHandler2, notFoundHandler);
733
1059
  __publicField(this, "errorHandler", errorHandler);
1060
+ /**
1061
+ * `.onError()` handles an error and returns a customized Response.
1062
+ *
1063
+ * @see {@link https://hono.dev/docs/api/hono#error-handling}
1064
+ *
1065
+ * @param {ErrorHandler} handler - request Handler for error
1066
+ * @returns {Hono} changed Hono instance
1067
+ *
1068
+ * @example
1069
+ * ```ts
1070
+ * app.onError((err, c) => {
1071
+ * console.error(`${err}`)
1072
+ * return c.text('Custom Error Message', 500)
1073
+ * })
1074
+ * ```
1075
+ */
734
1076
  __publicField(this, "onError", (handler) => {
735
1077
  this.errorHandler = handler;
736
1078
  return this;
737
1079
  });
1080
+ /**
1081
+ * `.notFound()` allows you to customize a Not Found Response.
1082
+ *
1083
+ * @see {@link https://hono.dev/docs/api/hono#not-found}
1084
+ *
1085
+ * @param {NotFoundHandler} handler - request handler for not-found
1086
+ * @returns {Hono} changed Hono instance
1087
+ *
1088
+ * @example
1089
+ * ```ts
1090
+ * app.notFound((c) => {
1091
+ * return c.text('Custom 404 Message', 404)
1092
+ * })
1093
+ * ```
1094
+ */
738
1095
  __publicField(this, "notFound", (handler) => {
739
1096
  __privateSet(this, _notFoundHandler2, handler);
740
1097
  return this;
741
1098
  });
1099
+ /**
1100
+ * `.fetch()` will be entry point of your app.
1101
+ *
1102
+ * @see {@link https://hono.dev/docs/api/hono#fetch}
1103
+ *
1104
+ * @param {Request} request - request Object of request
1105
+ * @param {Env} env - env Object
1106
+ * @param {ExecutionContext} executionCtx - context of execution
1107
+ * @returns {Response | Promise<Response>} response of request
1108
+ *
1109
+ */
742
1110
  __publicField(this, "fetch", (request, ...rest) => {
743
1111
  return __privateMethod(this, _Hono_instances, dispatch_fn).call(this, request, rest[1], rest[0], request.method);
744
1112
  });
1113
+ /**
1114
+ * `.request()` is a useful method for testing.
1115
+ * You can pass a URL or pathname to send a GET request.
1116
+ * app will return a Response object.
1117
+ * ```ts
1118
+ * test('GET /hello is ok', async () => {
1119
+ * const res = await app.request('/hello')
1120
+ * expect(res.status).toBe(200)
1121
+ * })
1122
+ * ```
1123
+ * @see https://hono.dev/docs/api/hono#request
1124
+ */
745
1125
  __publicField(this, "request", (input, requestInit, Env, executionCtx) => {
746
- if (input instanceof Request) {
747
- return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
748
- }
1126
+ if (input instanceof Request) return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
749
1127
  input = input.toString();
750
- return this.fetch(
751
- new Request(
752
- /^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`,
753
- requestInit
754
- ),
755
- Env,
756
- executionCtx
757
- );
1128
+ return this.fetch(new Request(/^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`, requestInit), Env, executionCtx);
758
1129
  });
1130
+ /**
1131
+ * `.fire()` automatically adds a global fetch event listener.
1132
+ * This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
1133
+ * @deprecated
1134
+ * Use `fire` from `hono/service-worker` instead.
1135
+ * ```ts
1136
+ * import { Hono } from 'hono'
1137
+ * import { fire } from 'hono/service-worker'
1138
+ *
1139
+ * const app = new Hono()
1140
+ * // ...
1141
+ * fire(app)
1142
+ * ```
1143
+ * @see https://hono.dev/docs/api/hono#fire
1144
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
1145
+ * @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
1146
+ */
759
1147
  __publicField(this, "fire", () => {
760
1148
  addEventListener("fetch", (event) => {
761
1149
  event.respondWith(__privateMethod(this, _Hono_instances, dispatch_fn).call(this, event.request, event, void 0, event.request.method));
762
1150
  });
763
1151
  });
764
1152
  var _a14;
765
- const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
766
- allMethods.forEach((method) => {
1153
+ [...METHODS, "all"].forEach((method) => {
767
1154
  this[method] = (args1, ...args) => {
768
- if (typeof args1 === "string") {
769
- __privateSet(this, _path2, args1);
770
- } else {
771
- __privateMethod(this, _Hono_instances, addRoute_fn).call(this, method, __privateGet(this, _path2), args1);
772
- }
1155
+ const methodName = method.toUpperCase();
1156
+ if (typeof args1 === "string") __privateSet(this, _path2, args1);
1157
+ else __privateMethod(this, _Hono_instances, addRoute_fn).call(this, methodName, __privateGet(this, _path2), args1);
773
1158
  args.forEach((handler) => {
774
- __privateMethod(this, _Hono_instances, addRoute_fn).call(this, method, __privateGet(this, _path2), handler);
1159
+ __privateMethod(this, _Hono_instances, addRoute_fn).call(this, methodName, __privateGet(this, _path2), handler);
775
1160
  });
776
1161
  return this;
777
1162
  };
@@ -780,22 +1165,20 @@ var __app = (() => {
780
1165
  for (const p of [path].flat()) {
781
1166
  __privateSet(this, _path2, p);
782
1167
  for (const m of [method].flat()) {
783
- handlers.map((handler) => {
784
- __privateMethod(this, _Hono_instances, addRoute_fn).call(this, m.toUpperCase(), __privateGet(this, _path2), handler);
785
- });
1168
+ const methodName = m.toUpperCase();
1169
+ for (const handler of handlers) __privateMethod(this, _Hono_instances, addRoute_fn).call(this, methodName, __privateGet(this, _path2), handler);
786
1170
  }
787
1171
  }
788
1172
  return this;
789
1173
  };
790
1174
  this.use = (arg1, ...handlers) => {
791
- if (typeof arg1 === "string") {
792
- __privateSet(this, _path2, arg1);
793
- } else {
1175
+ if (typeof arg1 === "string") __privateSet(this, _path2, arg1);
1176
+ else {
794
1177
  __privateSet(this, _path2, "*");
795
1178
  handlers.unshift(arg1);
796
1179
  }
797
1180
  handlers.forEach((handler) => {
798
- __privateMethod(this, _Hono_instances, addRoute_fn).call(this, METHOD_NAME_ALL, __privateGet(this, _path2), handler);
1181
+ __privateMethod(this, _Hono_instances, addRoute_fn).call(this, "ALL", __privateGet(this, _path2), handler);
799
1182
  });
800
1183
  return this;
801
1184
  };
@@ -803,39 +1186,99 @@ var __app = (() => {
803
1186
  Object.assign(this, optionsWithoutStrict);
804
1187
  this.getPath = (strict != null ? strict : true) ? (_a14 = options.getPath) != null ? _a14 : getPath : getPathNoStrict;
805
1188
  }
1189
+ /**
1190
+ * `.route()` allows grouping other Hono instance in routes.
1191
+ *
1192
+ * @see {@link https://hono.dev/docs/api/routing#grouping}
1193
+ *
1194
+ * @param {string} path - base Path
1195
+ * @param {Hono} app - other Hono instance
1196
+ * @returns {Hono} routed Hono instance
1197
+ *
1198
+ * @example
1199
+ * ```ts
1200
+ * const app = new Hono()
1201
+ * const app2 = new Hono()
1202
+ *
1203
+ * app2.get("/user", (c) => c.text("user"))
1204
+ * app.route("/api", app2) // GET /api/user
1205
+ * ```
1206
+ */
806
1207
  route(path, app) {
807
1208
  const subApp = this.basePath(path);
808
1209
  app.routes.map((r) => {
809
1210
  var _a14;
810
1211
  let handler;
811
- if (app.errorHandler === errorHandler) {
812
- handler = r.handler;
813
- } else {
1212
+ if (app.errorHandler === errorHandler) handler = r.handler;
1213
+ else {
814
1214
  handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
815
1215
  handler[COMPOSED_HANDLER] = r.handler;
816
1216
  }
817
- __privateMethod(_a14 = subApp, _Hono_instances, addRoute_fn).call(_a14, r.method, r.path, handler);
1217
+ __privateMethod(_a14 = subApp, _Hono_instances, addRoute_fn).call(_a14, r.method, r.path, handler, r.basePath);
818
1218
  });
819
1219
  return this;
820
1220
  }
1221
+ /**
1222
+ * `.basePath()` allows base paths to be specified.
1223
+ *
1224
+ * @see {@link https://hono.dev/docs/api/routing#base-path}
1225
+ *
1226
+ * @param {string} path - base Path
1227
+ * @returns {Hono} changed Hono instance
1228
+ *
1229
+ * @example
1230
+ * ```ts
1231
+ * const api = new Hono().basePath('/api')
1232
+ * ```
1233
+ */
821
1234
  basePath(path) {
822
1235
  const subApp = __privateMethod(this, _Hono_instances, clone_fn).call(this);
823
1236
  subApp._basePath = mergePath(this._basePath, path);
824
1237
  return subApp;
825
1238
  }
1239
+ /**
1240
+ * `.mount()` allows you to mount applications built with other frameworks into your Hono application.
1241
+ *
1242
+ * @deprecated Use `mount()` from `hono/mount` instead. `.mount()` will be removed in v5.
1243
+ *
1244
+ * @see {@link https://hono.dev/docs/api/hono#mount}
1245
+ *
1246
+ * @param {string} path - base Path
1247
+ * @param {Function} applicationHandler - other Request Handler
1248
+ * @param {MountOptions} [options] - options of `.mount()`
1249
+ * @returns {Hono} mounted Hono instance
1250
+ *
1251
+ * @example
1252
+ * ```ts
1253
+ * import { Router as IttyRouter } from 'itty-router'
1254
+ * import { Hono } from 'hono'
1255
+ * // Create itty-router application
1256
+ * const ittyRouter = IttyRouter()
1257
+ * // GET /itty-router/hello
1258
+ * ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
1259
+ *
1260
+ * const app = new Hono()
1261
+ * app.mount('/itty-router', ittyRouter.handle)
1262
+ * ```
1263
+ *
1264
+ * @example
1265
+ * ```ts
1266
+ * const app = new Hono()
1267
+ * // Send the request to another application without modification.
1268
+ * app.mount('/app', anotherApp, {
1269
+ * replaceRequest: (req) => req,
1270
+ * })
1271
+ * ```
1272
+ */
826
1273
  mount(path, applicationHandler, options) {
827
1274
  let replaceRequest;
828
1275
  let optionHandler;
829
1276
  if (options) {
830
- if (typeof options === "function") {
831
- optionHandler = options;
832
- } else {
1277
+ if (typeof options === "function") optionHandler = options;
1278
+ else {
833
1279
  optionHandler = options.optionHandler;
834
- if (options.replaceRequest === false) {
835
- replaceRequest = (request) => request;
836
- } else {
837
- replaceRequest = options.replaceRequest;
838
- }
1280
+ if (options.replaceRequest === false) replaceRequest = (request) => request;
1281
+ else replaceRequest = options.replaceRequest;
839
1282
  }
840
1283
  }
841
1284
  const getOptions = optionHandler ? (c) => {
@@ -854,22 +1297,20 @@ var __app = (() => {
854
1297
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
855
1298
  return (request) => {
856
1299
  const url2 = new URL(request.url);
857
- url2.pathname = url2.pathname.slice(pathPrefixLength) || "/";
1300
+ url2.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
858
1301
  return new Request(url2, request);
859
1302
  };
860
1303
  })());
861
1304
  const handler = async (c, next) => {
862
1305
  const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
863
- if (res) {
864
- return res;
865
- }
1306
+ if (res) return res;
866
1307
  await next();
867
1308
  };
868
- __privateMethod(this, _Hono_instances, addRoute_fn).call(this, METHOD_NAME_ALL, mergePath(path, "*"), handler);
1309
+ __privateMethod(this, _Hono_instances, addRoute_fn).call(this, "ALL", mergePath(path, "*"), handler);
869
1310
  return this;
870
1311
  }
871
1312
  }, _path2 = new WeakMap(), _Hono_instances = new WeakSet(), clone_fn = function() {
872
- const clone2 = new Hono({
1313
+ const clone2 = new _a3({
873
1314
  router: this.router,
874
1315
  getPath: this.getPath
875
1316
  });
@@ -877,21 +1318,21 @@ var __app = (() => {
877
1318
  __privateSet(clone2, _notFoundHandler2, __privateGet(this, _notFoundHandler2));
878
1319
  clone2.routes = this.routes;
879
1320
  return clone2;
880
- }, _notFoundHandler2 = new WeakMap(), addRoute_fn = function(method, path, handler) {
881
- method = method.toUpperCase();
1321
+ }, _notFoundHandler2 = new WeakMap(), addRoute_fn = function(method, path, handler, baseRoutePath) {
882
1322
  path = mergePath(this._basePath, path);
883
- const r = { basePath: this._basePath, path, method, handler };
1323
+ const r = {
1324
+ basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
1325
+ path,
1326
+ method,
1327
+ handler
1328
+ };
884
1329
  this.router.add(method, path, [handler, r]);
885
1330
  this.routes.push(r);
886
1331
  }, handleError_fn = function(err, c) {
887
- if (err instanceof Error) {
888
- return this.errorHandler(err, c);
889
- }
1332
+ if (err instanceof Error) return this.errorHandler(err, c);
890
1333
  throw err;
891
1334
  }, dispatch_fn = function(request, executionCtx, env, method) {
892
- if (method === "HEAD") {
893
- return (async () => new Response(null, await __privateMethod(this, _Hono_instances, dispatch_fn).call(this, request, executionCtx, env, "GET")))();
894
- }
1335
+ if (method === "HEAD") return (async () => new Response(null, await __privateMethod(this, _Hono_instances, dispatch_fn).call(this, request, executionCtx, env, "GET")))();
895
1336
  const path = this.getPath(request, { env });
896
1337
  const matchResult = this.router.match(method, path);
897
1338
  const c = new Context(request, {
@@ -910,19 +1351,13 @@ var __app = (() => {
910
1351
  } catch (err) {
911
1352
  return __privateMethod(this, _Hono_instances, handleError_fn).call(this, err, c);
912
1353
  }
913
- return res instanceof Promise ? res.then(
914
- (resolved) => resolved || (c.finalized ? c.res : __privateGet(this, _notFoundHandler2).call(this, c))
915
- ).catch((err) => __privateMethod(this, _Hono_instances, handleError_fn).call(this, err, c)) : res != null ? res : __privateGet(this, _notFoundHandler2).call(this, c);
1354
+ return res instanceof Promise ? res.then((resolved) => resolved || (c.finalized ? c.res : __privateGet(this, _notFoundHandler2).call(this, c))).catch((err) => __privateMethod(this, _Hono_instances, handleError_fn).call(this, err, c)) : res != null ? res : __privateGet(this, _notFoundHandler2).call(this, c);
916
1355
  }
917
1356
  const composed = compose(matchResult[0], this.errorHandler, __privateGet(this, _notFoundHandler2));
918
1357
  return (async () => {
919
1358
  try {
920
1359
  const context = await composed(c);
921
- if (!context.finalized) {
922
- throw new Error(
923
- "Context is not finalized. Did you forget to return a Response object or `await next()`?"
924
- );
925
- }
1360
+ if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
926
1361
  return context.res;
927
1362
  } catch (err) {
928
1363
  return __privateMethod(this, _Hono_instances, handleError_fn).call(this, err, c);
@@ -930,50 +1365,38 @@ var __app = (() => {
930
1365
  })();
931
1366
  }, _a3);
932
1367
 
1368
+ // node_modules/hono/dist/router/utils.js
1369
+ var createNullObject = () => /* @__PURE__ */ Object.create(null);
1370
+
933
1371
  // node_modules/hono/dist/router/reg-exp-router/matcher.js
934
1372
  var emptyParam = [];
935
1373
  function match(method, path) {
936
1374
  const matchers = this.buildAllMatchers();
937
- const match2 = (method2, path2) => {
938
- const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
1375
+ const match2 = ((method2, path2) => {
1376
+ const matcher = matchers[method2] || matchers["ALL"];
939
1377
  const staticMatch = matcher[2][path2];
940
- if (staticMatch) {
941
- return staticMatch;
942
- }
1378
+ if (staticMatch) return staticMatch;
943
1379
  const match3 = path2.match(matcher[0]);
944
- if (!match3) {
945
- return [[], emptyParam];
946
- }
1380
+ if (!match3) return [[], emptyParam];
947
1381
  const index = match3.indexOf("", 1);
948
1382
  return [matcher[1][index], match3];
949
- };
1383
+ });
950
1384
  this.match = match2;
951
1385
  return match2(method, path);
952
1386
  }
953
1387
 
954
1388
  // node_modules/hono/dist/router/reg-exp-router/node.js
955
1389
  var LABEL_REG_EXP_STR = "[^/]+";
956
- var ONLY_WILDCARD_REG_EXP_STR = ".*";
957
1390
  var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
958
1391
  var PATH_ERROR = /* @__PURE__ */ Symbol();
959
- var regExpMetaChars = new Set(".\\+*[^]$()");
1392
+ var regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
960
1393
  function compareKey(a, b) {
961
- if (a.length === 1) {
962
- return b.length === 1 ? a < b ? -1 : 1 : -1;
963
- }
964
- if (b.length === 1) {
965
- return 1;
966
- }
967
- if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {
968
- return 1;
969
- } else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {
970
- return -1;
971
- }
972
- if (a === LABEL_REG_EXP_STR) {
973
- return 1;
974
- } else if (b === LABEL_REG_EXP_STR) {
975
- return -1;
976
- }
1394
+ if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
1395
+ if (b.length === 1) return 1;
1396
+ if (a === ".*" || a === "(?:|/.*)") return b === "(?:|/.*)" ? -1 : 1;
1397
+ else if (b === ".*" || b === "(?:|/.*)") return -1;
1398
+ if (a === "[^/]+") return 1;
1399
+ else if (b === "[^/]+") return -1;
977
1400
  return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
978
1401
  }
979
1402
  var _index, _varIndex, _children, _a4;
@@ -981,128 +1404,118 @@ var __app = (() => {
981
1404
  constructor() {
982
1405
  __privateAdd(this, _index);
983
1406
  __privateAdd(this, _varIndex);
984
- __privateAdd(this, _children, /* @__PURE__ */ Object.create(null));
1407
+ __privateAdd(this, _children, createNullObject());
985
1408
  }
986
- insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
987
- if (tokens.length === 0) {
988
- if (__privateGet(this, _index) !== void 0) {
989
- throw PATH_ERROR;
990
- }
991
- if (pathErrorCheckOnly) {
992
- return;
993
- }
994
- __privateSet(this, _index, index);
995
- return;
996
- }
997
- const [token, ...restTokens] = tokens;
998
- const pattern = token === "*" ? restTokens.length === 0 ? ["", "", ONLY_WILDCARD_REG_EXP_STR] : ["", "", LABEL_REG_EXP_STR] : token === "/*" ? ["", "", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
999
- let node;
1000
- if (pattern) {
1001
- const name = pattern[1];
1002
- let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
1003
- if (name && pattern[2]) {
1004
- if (regexpStr === ".*") {
1005
- throw PATH_ERROR;
1006
- }
1007
- regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
1008
- if (/\((?!\?:)/.test(regexpStr)) {
1009
- throw PATH_ERROR;
1010
- }
1011
- }
1012
- node = __privateGet(this, _children)[regexpStr];
1013
- if (!node) {
1014
- if (Object.keys(__privateGet(this, _children)).some(
1015
- (k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
1016
- )) {
1017
- throw PATH_ERROR;
1409
+ insert(tokens, index, paramMap, context, isStatic) {
1410
+ var _a14;
1411
+ let node = this;
1412
+ for (let i = 0, len = tokens.length; i < len; i++) {
1413
+ const token = tokens[i];
1414
+ const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? [
1415
+ "",
1416
+ "",
1417
+ ".*"
1418
+ ] : [
1419
+ "",
1420
+ "",
1421
+ LABEL_REG_EXP_STR
1422
+ ] : null : token === "/*" ? [
1423
+ "",
1424
+ "",
1425
+ TAIL_WILDCARD_REG_EXP_STR
1426
+ ] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
1427
+ let nextNode;
1428
+ if (pattern) {
1429
+ const name = pattern[1];
1430
+ let regexpStr = pattern[2] || "[^/]+";
1431
+ if (name && pattern[2]) {
1432
+ if (regexpStr === ".*") throw PATH_ERROR;
1433
+ regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
1434
+ if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
1435
+ if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
1018
1436
  }
1019
- if (pathErrorCheckOnly) {
1020
- return;
1437
+ nextNode = __privateGet(node, _children)[regexpStr];
1438
+ if (!nextNode) {
1439
+ if (regexpStr !== ".*" && regexpStr !== "(?:|/.*)") {
1440
+ for (const k in __privateGet(node, _children)) if ((regexpStr.length > 1 || k.length > 1) && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
1441
+ }
1442
+ nextNode = __privateGet(node, _children)[regexpStr] = new _a4();
1021
1443
  }
1022
- node = __privateGet(this, _children)[regexpStr] = new Node();
1023
1444
  if (name !== "") {
1024
- __privateSet(node, _varIndex, context.varIndex++);
1445
+ (_a14 = __privateGet(nextNode, _varIndex)) != null ? _a14 : __privateSet(nextNode, _varIndex, context.varIndex++);
1446
+ paramMap.push([name, __privateGet(nextNode, _varIndex)]);
1025
1447
  }
1026
- }
1027
- if (!pathErrorCheckOnly && name !== "") {
1028
- paramMap.push([name, __privateGet(node, _varIndex)]);
1029
- }
1030
- } else {
1031
- node = __privateGet(this, _children)[token];
1032
- if (!node) {
1033
- if (Object.keys(__privateGet(this, _children)).some(
1034
- (k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
1035
- )) {
1036
- throw PATH_ERROR;
1037
- }
1038
- if (pathErrorCheckOnly) {
1039
- return;
1448
+ } else {
1449
+ nextNode = __privateGet(node, _children)[token];
1450
+ if (!nextNode) {
1451
+ for (const k in __privateGet(node, _children)) if (k.length > 1 && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
1452
+ nextNode = __privateGet(node, _children)[token] = new _a4();
1040
1453
  }
1041
- node = __privateGet(this, _children)[token] = new Node();
1042
1454
  }
1455
+ node = nextNode;
1043
1456
  }
1044
- node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
1457
+ if (__privateGet(node, _index) !== void 0) throw PATH_ERROR;
1458
+ __privateSet(node, _index, isStatic ? -1 : index);
1045
1459
  }
1046
1460
  buildRegExpStr() {
1047
- const childKeys = Object.keys(__privateGet(this, _children)).sort(compareKey);
1048
- const strList = childKeys.map((k) => {
1461
+ const strList = Object.keys(__privateGet(this, _children)).sort(compareKey).map((k) => {
1049
1462
  const c = __privateGet(this, _children)[k];
1050
- return (typeof __privateGet(c, _varIndex) === "number" ? `(${k})@${__privateGet(c, _varIndex)}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
1051
- });
1052
- if (typeof __privateGet(this, _index) === "number") {
1053
- strList.unshift(`#${__privateGet(this, _index)}`);
1054
- }
1055
- if (strList.length === 0) {
1056
- return "";
1057
- }
1058
- if (strList.length === 1) {
1059
- return strList[0];
1060
- }
1463
+ const childStr = c.buildRegExpStr();
1464
+ return childStr === "" ? "" : (typeof __privateGet(c, _varIndex) === "number" ? `(${k})@${__privateGet(c, _varIndex)}` : regExpMetaChars.has(k) ? `\\${k}` : k) + childStr;
1465
+ }).filter(Boolean);
1466
+ if (typeof __privateGet(this, _index) === "number" && __privateGet(this, _index) !== -1) strList.unshift(`#${__privateGet(this, _index)}`);
1467
+ if (strList.length === 0) return "";
1468
+ if (strList.length === 1) return strList[0];
1061
1469
  return "(?:" + strList.join("|") + ")";
1062
1470
  }
1063
1471
  }, _index = new WeakMap(), _varIndex = new WeakMap(), _children = new WeakMap(), _a4);
1064
1472
 
1065
1473
  // node_modules/hono/dist/router/reg-exp-router/trie.js
1066
- var _context, _root, _a5;
1474
+ var _context, _root, _index2, _a5;
1067
1475
  var Trie = (_a5 = class {
1068
1476
  constructor() {
1069
1477
  __privateAdd(this, _context, { varIndex: 0 });
1070
1478
  __privateAdd(this, _root, new Node());
1479
+ __privateAdd(this, _index2, 0);
1480
+ __publicField(this, "paths", createNullObject());
1071
1481
  }
1072
- insert(path, index, pathErrorCheckOnly) {
1482
+ insert(path, isStatic) {
1483
+ if (isStatic) {
1484
+ __privateGet(this, _root).insert(path.split(""), 0, [], __privateGet(this, _context), true);
1485
+ return;
1486
+ }
1073
1487
  const paramAssoc = [];
1074
1488
  const groups = [];
1489
+ let markedPath = path;
1075
1490
  for (let i = 0; ; ) {
1076
1491
  let replaced = false;
1077
- path = path.replace(/\{[^}]+\}/g, (m) => {
1492
+ markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
1078
1493
  const mark = `@\\${i}`;
1079
1494
  groups[i] = [mark, m];
1080
1495
  i++;
1081
1496
  replaced = true;
1082
1497
  return mark;
1083
1498
  });
1084
- if (!replaced) {
1085
- break;
1086
- }
1499
+ if (!replaced) break;
1087
1500
  }
1088
- const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1501
+ const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1089
1502
  for (let i = groups.length - 1; i >= 0; i--) {
1090
1503
  const [mark] = groups[i];
1091
- for (let j = tokens.length - 1; j >= 0; j--) {
1092
- if (tokens[j].indexOf(mark) !== -1) {
1093
- tokens[j] = tokens[j].replace(mark, groups[i][1]);
1094
- break;
1095
- }
1504
+ for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
1505
+ tokens[j] = tokens[j].replace(mark, groups[i][1]);
1506
+ break;
1096
1507
  }
1097
1508
  }
1098
- __privateGet(this, _root).insert(tokens, index, paramAssoc, __privateGet(this, _context), pathErrorCheckOnly);
1099
- return paramAssoc;
1509
+ __privateGet(this, _root).insert(tokens, __privateGet(this, _index2), paramAssoc, __privateGet(this, _context), false);
1510
+ this.paths[path] = [__privateWrapper(this, _index2)._++, paramAssoc];
1100
1511
  }
1101
1512
  buildRegExp() {
1102
1513
  let regexp = __privateGet(this, _root).buildRegExpStr();
1103
- if (regexp === "") {
1104
- return [/^$/, [], []];
1105
- }
1514
+ if (regexp === "") return [
1515
+ /^$/,
1516
+ [],
1517
+ []
1518
+ ];
1106
1519
  let captureIndex = 0;
1107
1520
  const indexReplacementMap = [];
1108
1521
  const paramReplacementMap = [];
@@ -1117,193 +1530,107 @@ var __app = (() => {
1117
1530
  }
1118
1531
  return "";
1119
1532
  });
1120
- return [new RegExp(`^${regexp}`), indexReplacementMap, paramReplacementMap];
1533
+ return [
1534
+ new RegExp(`^${regexp}`),
1535
+ indexReplacementMap,
1536
+ paramReplacementMap
1537
+ ];
1121
1538
  }
1122
- }, _context = new WeakMap(), _root = new WeakMap(), _a5);
1539
+ }, _context = new WeakMap(), _root = new WeakMap(), _index2 = new WeakMap(), _a5);
1123
1540
 
1124
1541
  // node_modules/hono/dist/router/reg-exp-router/router.js
1125
- var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
1126
- var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1542
+ var wildcardRegExpCache = createNullObject();
1127
1543
  function buildWildcardRegExp(path) {
1128
1544
  var _a14;
1129
- return (_a14 = wildcardRegExpCache[path]) != null ? _a14 : wildcardRegExpCache[path] = new RegExp(
1130
- path === "*" ? "" : `^${path.replace(
1131
- /\/\*$|([.\\+*[^\]$()])/g,
1132
- (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
1133
- )}$`
1134
- );
1135
- }
1136
- function clearWildcardRegExpCache() {
1137
- wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1138
- }
1139
- function buildMatcherFromPreprocessedRoutes(routes) {
1140
- var _a14;
1141
- const trie = new Trie();
1142
- const handlerData = [];
1143
- if (routes.length === 0) {
1144
- return nullMatcher;
1145
- }
1146
- const routesWithStaticPathFlag = routes.map(
1147
- (route) => [!/\*|\/:/.test(route[0]), ...route]
1148
- ).sort(
1149
- ([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length
1150
- );
1151
- const staticMap = /* @__PURE__ */ Object.create(null);
1152
- for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
1153
- const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
1154
- if (pathErrorCheckOnly) {
1155
- staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
1156
- } else {
1157
- j++;
1158
- }
1159
- let paramAssoc;
1160
- try {
1161
- paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
1162
- } catch (e) {
1163
- throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
1164
- }
1165
- if (pathErrorCheckOnly) {
1166
- continue;
1167
- }
1168
- handlerData[j] = handlers.map(([h, paramCount]) => {
1169
- const paramIndexMap = /* @__PURE__ */ Object.create(null);
1170
- paramCount -= 1;
1171
- for (; paramCount >= 0; paramCount--) {
1172
- const [key, value] = paramAssoc[paramCount];
1173
- paramIndexMap[key] = value;
1174
- }
1175
- return [h, paramIndexMap];
1176
- });
1177
- }
1178
- const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
1179
- for (let i = 0, len = handlerData.length; i < len; i++) {
1180
- for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
1181
- const map2 = (_a14 = handlerData[i][j]) == null ? void 0 : _a14[1];
1182
- if (!map2) {
1183
- continue;
1184
- }
1185
- const keys = Object.keys(map2);
1186
- for (let k = 0, len3 = keys.length; k < len3; k++) {
1187
- map2[keys[k]] = paramReplacementMap[map2[keys[k]]];
1188
- }
1189
- }
1190
- }
1191
- const handlerMap = [];
1192
- for (const i in indexReplacementMap) {
1193
- handlerMap[i] = handlerData[indexReplacementMap[i]];
1194
- }
1195
- return [regexp, handlerMap, staticMap];
1545
+ return (_a14 = wildcardRegExpCache[path]) != null ? _a14 : wildcardRegExpCache[path] = new RegExp(`^${path.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (match2, metaChar) => metaChar ? `\\${metaChar}` : match2 === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match2 === "*" ? ".*" : `/:${LABEL_REG_EXP_STR}`)}$`);
1196
1546
  }
1197
1547
  function findMiddleware(middleware, path) {
1198
- if (!middleware) {
1199
- return void 0;
1200
- }
1201
- for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
1202
- if (buildWildcardRegExp(k).test(path)) {
1203
- return [...middleware[k]];
1204
- }
1205
- }
1206
- return void 0;
1548
+ for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path)) return [...middleware[k]];
1207
1549
  }
1208
- var _middleware, _routes, _RegExpRouter_instances, buildMatcher_fn, _a6;
1550
+ var _middleware, _routes, _tries, _RegExpRouter_instances, insertPath_fn, buildMatcher_fn, _a6;
1209
1551
  var RegExpRouter = (_a6 = class {
1210
1552
  constructor() {
1211
1553
  __privateAdd(this, _RegExpRouter_instances);
1212
1554
  __publicField(this, "name", "RegExpRouter");
1213
1555
  __privateAdd(this, _middleware);
1214
1556
  __privateAdd(this, _routes);
1557
+ __privateAdd(this, _tries);
1215
1558
  __publicField(this, "match", match);
1216
- __privateSet(this, _middleware, { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) });
1217
- __privateSet(this, _routes, { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) });
1559
+ __privateSet(this, _middleware, { ["ALL"]: createNullObject() });
1560
+ __privateSet(this, _routes, { ["ALL"]: createNullObject() });
1561
+ __privateSet(this, _tries, { ["ALL"]: new Trie() });
1218
1562
  }
1219
1563
  add(method, path, handler) {
1220
- var _a14;
1221
1564
  const middleware = __privateGet(this, _middleware);
1222
1565
  const routes = __privateGet(this, _routes);
1223
- if (!middleware || !routes) {
1224
- throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1225
- }
1566
+ if (!middleware) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1226
1567
  if (!middleware[method]) {
1227
- ;
1228
- [middleware, routes].forEach((handlerMap) => {
1229
- handlerMap[method] = /* @__PURE__ */ Object.create(null);
1230
- Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {
1231
- handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
1232
- });
1233
- });
1234
- }
1235
- if (path === "/*") {
1236
- path = "*";
1568
+ __privateGet(this, _tries)[method] = new Trie();
1569
+ for (const handlerMap of [middleware, routes]) {
1570
+ handlerMap[method] = createNullObject();
1571
+ for (const p in handlerMap["ALL"]) {
1572
+ handlerMap[method][p] = [...handlerMap["ALL"][p]];
1573
+ __privateMethod(this, _RegExpRouter_instances, insertPath_fn).call(this, method, p);
1574
+ }
1575
+ }
1237
1576
  }
1238
- const paramCount = (path.match(/\/:/g) || []).length;
1577
+ if (path === "/*") path = "*";
1578
+ const methods = method === "ALL" ? Object.keys(middleware) : [method];
1239
1579
  if (/\*$/.test(path)) {
1240
1580
  const re = buildWildcardRegExp(path);
1241
- if (method === METHOD_NAME_ALL) {
1242
- Object.keys(middleware).forEach((m) => {
1243
- var _a15;
1244
- (_a15 = middleware[m])[path] || (_a15[path] = findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || []);
1245
- });
1246
- } else {
1247
- (_a14 = middleware[method])[path] || (_a14[path] = findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || []);
1581
+ for (const m of methods) if (!middleware[m][path]) {
1582
+ __privateMethod(this, _RegExpRouter_instances, insertPath_fn).call(this, m, path);
1583
+ middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
1248
1584
  }
1249
- Object.keys(middleware).forEach((m) => {
1250
- if (method === METHOD_NAME_ALL || method === m) {
1251
- Object.keys(middleware[m]).forEach((p) => {
1252
- re.test(p) && middleware[m][p].push([handler, paramCount]);
1253
- });
1254
- }
1255
- });
1256
- Object.keys(routes).forEach((m) => {
1257
- if (method === METHOD_NAME_ALL || method === m) {
1258
- Object.keys(routes[m]).forEach(
1259
- (p) => re.test(p) && routes[m][p].push([handler, paramCount])
1260
- );
1261
- }
1262
- });
1585
+ for (const handlerMap of [middleware, routes]) for (const m of methods) for (const p in handlerMap[m]) re.test(p) && handlerMap[m][p].push([handler, path]);
1263
1586
  return;
1264
1587
  }
1265
1588
  const paths = checkOptionalParameter(path) || [path];
1266
- for (let i = 0, len = paths.length; i < len; i++) {
1267
- const path2 = paths[i];
1268
- Object.keys(routes).forEach((m) => {
1269
- var _a15;
1270
- if (method === METHOD_NAME_ALL || method === m) {
1271
- (_a15 = routes[m])[path2] || (_a15[path2] = [
1272
- ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
1273
- ]);
1274
- routes[m][path2].push([handler, paramCount - len + i + 1]);
1275
- }
1276
- });
1589
+ for (const path2 of paths) for (const m of methods) {
1590
+ if (!routes[m][path2]) {
1591
+ __privateMethod(this, _RegExpRouter_instances, insertPath_fn).call(this, m, path2);
1592
+ routes[m][path2] = findMiddleware(middleware[m], path2) || findMiddleware(middleware["ALL"], path2) || [];
1593
+ }
1594
+ routes[m][path2].push([handler, path2]);
1277
1595
  }
1278
1596
  }
1279
1597
  buildAllMatchers() {
1280
- const matchers = /* @__PURE__ */ Object.create(null);
1281
- Object.keys(__privateGet(this, _routes)).concat(Object.keys(__privateGet(this, _middleware))).forEach((method) => {
1282
- matchers[method] || (matchers[method] = __privateMethod(this, _RegExpRouter_instances, buildMatcher_fn).call(this, method));
1283
- });
1284
- __privateSet(this, _middleware, __privateSet(this, _routes, void 0));
1285
- clearWildcardRegExpCache();
1598
+ const matchers = createNullObject();
1599
+ for (const method of Object.keys(__privateGet(this, _routes))) matchers[method] = __privateMethod(this, _RegExpRouter_instances, buildMatcher_fn).call(this, method);
1600
+ __privateSet(this, _middleware, __privateSet(this, _routes, __privateSet(this, _tries, void 0)));
1601
+ wildcardRegExpCache = createNullObject();
1286
1602
  return matchers;
1287
1603
  }
1288
- }, _middleware = new WeakMap(), _routes = new WeakMap(), _RegExpRouter_instances = new WeakSet(), buildMatcher_fn = function(method) {
1289
- const routes = [];
1290
- let hasOwnRoute = method === METHOD_NAME_ALL;
1291
- [__privateGet(this, _middleware), __privateGet(this, _routes)].forEach((r) => {
1292
- const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : [];
1293
- if (ownRoute.length !== 0) {
1294
- hasOwnRoute || (hasOwnRoute = true);
1295
- routes.push(...ownRoute);
1296
- } else if (method !== METHOD_NAME_ALL) {
1297
- routes.push(
1298
- ...Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]])
1299
- );
1604
+ }, _middleware = new WeakMap(), _routes = new WeakMap(), _tries = new WeakMap(), _RegExpRouter_instances = new WeakSet(), insertPath_fn = function(method, path) {
1605
+ try {
1606
+ __privateGet(this, _tries)[method].insert(path, !/\*|\/:/.test(path));
1607
+ } catch (e) {
1608
+ throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
1609
+ }
1610
+ }, buildMatcher_fn = function(method) {
1611
+ const middleware = __privateGet(this, _middleware)[method];
1612
+ const routes = __privateGet(this, _routes)[method];
1613
+ const trie = __privateGet(this, _tries)[method];
1614
+ const staticMap = createNullObject();
1615
+ const handlerData = [];
1616
+ const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
1617
+ for (const r of [middleware, routes]) for (const path in r) {
1618
+ const handlers = r[path];
1619
+ const pathData = trie.paths[path];
1620
+ if (!pathData) {
1621
+ staticMap[path] = [handlers.map(([h]) => [h, createNullObject()]), emptyParam];
1622
+ continue;
1300
1623
  }
1301
- });
1302
- if (!hasOwnRoute) {
1303
- return null;
1304
- } else {
1305
- return buildMatcherFromPreprocessedRoutes(routes);
1624
+ handlerData[pathData[0]] = handlers.map(([h, handlerPath]) => [h, trie.paths[handlerPath][1].reduceRight((map2, [key], i) => {
1625
+ map2[key] = paramReplacementMap[pathData[1][i][1]];
1626
+ return map2;
1627
+ }, createNullObject())]);
1306
1628
  }
1629
+ return [
1630
+ regexp,
1631
+ indexReplacementMap.map((i) => handlerData[i]),
1632
+ staticMap
1633
+ ];
1307
1634
  }, _a6);
1308
1635
 
1309
1636
  // node_modules/hono/dist/router/smart-router/router.js
@@ -1316,15 +1643,15 @@ var __app = (() => {
1316
1643
  __privateSet(this, _routers, init.routers);
1317
1644
  }
1318
1645
  add(method, path, handler) {
1319
- if (!__privateGet(this, _routes2)) {
1320
- throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1321
- }
1322
- __privateGet(this, _routes2).push([method, path, handler]);
1646
+ if (!__privateGet(this, _routes2)) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1647
+ __privateGet(this, _routes2).push([
1648
+ method,
1649
+ path,
1650
+ handler
1651
+ ]);
1323
1652
  }
1324
1653
  match(method, path) {
1325
- if (!__privateGet(this, _routes2)) {
1326
- throw new Error("Fatal error");
1327
- }
1654
+ if (!__privateGet(this, _routes2)) throw new Error("Fatal error");
1328
1655
  const routers = __privateGet(this, _routers);
1329
1656
  const routes = __privateGet(this, _routes2);
1330
1657
  const len = routers.length;
@@ -1333,14 +1660,10 @@ var __app = (() => {
1333
1660
  for (; i < len; i++) {
1334
1661
  const router = routers[i];
1335
1662
  try {
1336
- for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
1337
- router.add(...routes[i2]);
1338
- }
1663
+ for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) router.add(...routes[i2]);
1339
1664
  res = router.match(method, path);
1340
1665
  } catch (e) {
1341
- if (e instanceof UnsupportedPathError) {
1342
- continue;
1343
- }
1666
+ if (e instanceof UnsupportedPathError) continue;
1344
1667
  throw e;
1345
1668
  }
1346
1669
  this.match = router.match.bind(router);
@@ -1348,82 +1671,64 @@ var __app = (() => {
1348
1671
  __privateSet(this, _routes2, void 0);
1349
1672
  break;
1350
1673
  }
1351
- if (i === len) {
1352
- throw new Error("Fatal error");
1353
- }
1674
+ if (i === len) throw new Error("Fatal error");
1354
1675
  this.name = `SmartRouter + ${this.activeRouter.name}`;
1355
1676
  return res;
1356
1677
  }
1357
1678
  get activeRouter() {
1358
- if (__privateGet(this, _routes2) || __privateGet(this, _routers).length !== 1) {
1359
- throw new Error("No active router has been determined yet.");
1360
- }
1679
+ if (__privateGet(this, _routes2) || __privateGet(this, _routers).length !== 1) throw new Error("No active router has been determined yet.");
1361
1680
  return __privateGet(this, _routers)[0];
1362
1681
  }
1363
1682
  }, _routers = new WeakMap(), _routes2 = new WeakMap(), _a7);
1364
1683
 
1365
1684
  // node_modules/hono/dist/router/trie-router/node.js
1366
- var emptyParams = /* @__PURE__ */ Object.create(null);
1367
- var _methods, _children2, _patterns, _order, _params, _Node_instances, getHandlerSets_fn, _a8;
1685
+ var emptyParams = createNullObject();
1686
+ var order = 0;
1687
+ var _methods, _children2, _patterns, _pattern, _params, _Node_instances, pushHandlerSets_fn, _a8;
1368
1688
  var Node2 = (_a8 = class {
1369
- constructor(method, handler, children) {
1689
+ constructor() {
1370
1690
  __privateAdd(this, _Node_instances);
1371
- __privateAdd(this, _methods);
1372
- __privateAdd(this, _children2);
1373
- __privateAdd(this, _patterns);
1374
- __privateAdd(this, _order, 0);
1691
+ __privateAdd(this, _methods, []);
1692
+ __privateAdd(this, _children2, createNullObject());
1693
+ __privateAdd(this, _patterns, []);
1694
+ __privateAdd(this, _pattern);
1375
1695
  __privateAdd(this, _params, emptyParams);
1376
- __privateSet(this, _children2, children || /* @__PURE__ */ Object.create(null));
1377
- __privateSet(this, _methods, []);
1378
- if (method && handler) {
1379
- const m = /* @__PURE__ */ Object.create(null);
1380
- m[method] = { handler, possibleKeys: [], score: 0 };
1381
- __privateSet(this, _methods, [m]);
1382
- }
1383
- __privateSet(this, _patterns, []);
1384
1696
  }
1385
1697
  insert(method, path, handler) {
1386
- __privateSet(this, _order, ++__privateWrapper(this, _order)._);
1698
+ var _a14;
1387
1699
  let curNode = this;
1388
1700
  const parts = splitRoutingPath(path);
1389
- const possibleKeys = [];
1390
- for (let i = 0, len = parts.length; i < len; i++) {
1391
- const p = parts[i];
1392
- const nextP = parts[i + 1];
1393
- const pattern = getPattern(p, nextP);
1394
- const key = Array.isArray(pattern) ? pattern[0] : p;
1395
- if (key in __privateGet(curNode, _children2)) {
1396
- curNode = __privateGet(curNode, _children2)[key];
1397
- if (pattern) {
1398
- possibleKeys.push(pattern[1]);
1399
- }
1400
- continue;
1401
- }
1402
- __privateGet(curNode, _children2)[key] = new Node2();
1403
- if (pattern) {
1404
- __privateGet(curNode, _patterns).push(pattern);
1405
- possibleKeys.push(pattern[1]);
1406
- }
1407
- curNode = __privateGet(curNode, _children2)[key];
1408
- }
1409
- __privateGet(curNode, _methods).push({
1410
- [method]: {
1411
- handler,
1412
- possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
1413
- score: __privateGet(this, _order)
1414
- }
1415
- });
1416
- return curNode;
1701
+ const possibleKeys = /* @__PURE__ */ new Set();
1702
+ let i = 0;
1703
+ for (const p of parts) {
1704
+ const nextP = parts[++i];
1705
+ const pattern = getPattern(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
1706
+ const isParam = Array.isArray(pattern);
1707
+ const key = isParam ? pattern[0] : pattern || p;
1708
+ const child = (_a14 = __privateGet(curNode, _children2))[key] || (_a14[key] = new _a8());
1709
+ if (pattern && !__privateGet(child, _pattern)) {
1710
+ __privateSet(child, _pattern, pattern);
1711
+ __privateGet(curNode, _patterns).push(child);
1712
+ }
1713
+ curNode = child;
1714
+ if (isParam) possibleKeys.add(pattern[1]);
1715
+ }
1716
+ __privateGet(curNode, _methods).push({ [method]: {
1717
+ handler,
1718
+ possibleKeys: [...possibleKeys],
1719
+ score: ++order
1720
+ } });
1417
1721
  }
1418
1722
  search(method, path) {
1419
- var _a14, _b, _c;
1723
+ var _a14, _b;
1420
1724
  const handlerSets = [];
1421
1725
  __privateSet(this, _params, emptyParams);
1422
- const curNode = this;
1423
- let curNodes = [curNode];
1726
+ let curNodes = [this];
1424
1727
  const parts = splitPath(path);
1425
1728
  const curNodesQueue = [];
1426
- for (let i = 0, len = parts.length; i < len; i++) {
1729
+ const len = parts.length;
1730
+ let partOffsets = null;
1731
+ for (let i = 0; i < len; i++) {
1427
1732
  const part = parts[i];
1428
1733
  const isLast = i === len - 1;
1429
1734
  const tempNodes = [];
@@ -1433,44 +1738,45 @@ var __app = (() => {
1433
1738
  if (nextNode) {
1434
1739
  __privateSet(nextNode, _params, __privateGet(node, _params));
1435
1740
  if (isLast) {
1436
- if (__privateGet(nextNode, _children2)["*"]) {
1437
- handlerSets.push(
1438
- ...__privateMethod(this, _Node_instances, getHandlerSets_fn).call(this, __privateGet(nextNode, _children2)["*"], method, __privateGet(node, _params))
1439
- );
1440
- }
1441
- handlerSets.push(...__privateMethod(this, _Node_instances, getHandlerSets_fn).call(this, nextNode, method, __privateGet(node, _params)));
1442
- } else {
1443
- tempNodes.push(nextNode);
1444
- }
1741
+ if (__privateGet(nextNode, _children2)["*"]) __privateMethod(this, _Node_instances, pushHandlerSets_fn).call(this, handlerSets, __privateGet(nextNode, _children2)["*"], method, __privateGet(node, _params));
1742
+ __privateMethod(this, _Node_instances, pushHandlerSets_fn).call(this, handlerSets, nextNode, method, __privateGet(node, _params));
1743
+ } else tempNodes.push(nextNode);
1445
1744
  }
1446
- for (let k = 0, len3 = __privateGet(node, _patterns).length; k < len3; k++) {
1447
- const pattern = __privateGet(node, _patterns)[k];
1745
+ for (const child of __privateGet(node, _patterns)) {
1746
+ const pattern = __privateGet(child, _pattern);
1448
1747
  const params = __privateGet(node, _params) === emptyParams ? {} : { ...__privateGet(node, _params) };
1449
- if (pattern === "*") {
1450
- const astNode = __privateGet(node, _children2)["*"];
1451
- if (astNode) {
1452
- handlerSets.push(...__privateMethod(this, _Node_instances, getHandlerSets_fn).call(this, astNode, method, __privateGet(node, _params)));
1453
- __privateSet(astNode, _params, params);
1454
- tempNodes.push(astNode);
1748
+ if (typeof pattern === "string") {
1749
+ if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
1750
+ __privateMethod(this, _Node_instances, pushHandlerSets_fn).call(this, handlerSets, child, method, __privateGet(node, _params));
1751
+ if (pattern === "*") {
1752
+ __privateSet(child, _params, params);
1753
+ tempNodes.push(child);
1754
+ }
1455
1755
  }
1456
1756
  continue;
1457
1757
  }
1458
- const [key, name, matcher] = pattern;
1459
- if (!part && !(matcher instanceof RegExp)) {
1460
- continue;
1461
- }
1462
- const child = __privateGet(node, _children2)[key];
1463
- const restPathString = parts.slice(i).join("/");
1464
- if (matcher instanceof RegExp) {
1758
+ const [, name, matcher] = pattern;
1759
+ if (!part && matcher === true) continue;
1760
+ if (matcher !== true) {
1761
+ if (!partOffsets) {
1762
+ partOffsets = [];
1763
+ let offset = path[0] === "/" ? 1 : 0;
1764
+ for (let p = 0; p < len; p++) {
1765
+ partOffsets[p] = offset;
1766
+ offset += parts[p].length + 1;
1767
+ }
1768
+ }
1769
+ const restPathString = path.slice(partOffsets[i]);
1465
1770
  const m = matcher.exec(restPathString);
1466
1771
  if (m) {
1467
1772
  params[name] = m[0];
1468
- handlerSets.push(...__privateMethod(this, _Node_instances, getHandlerSets_fn).call(this, child, method, __privateGet(node, _params), params));
1469
- if (Object.keys(__privateGet(child, _children2)).length) {
1773
+ __privateMethod(this, _Node_instances, pushHandlerSets_fn).call(this, handlerSets, child, method, __privateGet(node, _params), params);
1774
+ if (m[0].length === restPathString.length && __privateGet(child, _children2)["*"]) __privateMethod(this, _Node_instances, pushHandlerSets_fn).call(this, handlerSets, __privateGet(child, _children2)["*"], method, __privateGet(node, _params), params);
1775
+ for (const _ in __privateGet(child, _children2)) {
1470
1776
  __privateSet(child, _params, params);
1471
- const componentCount = (_b = (_a14 = m[0].match(/\//)) == null ? void 0 : _a14.length) != null ? _b : 0;
1472
- const targetCurNodes = curNodesQueue[componentCount] || (curNodesQueue[componentCount] = []);
1473
- targetCurNodes.push(child);
1777
+ const componentCount = (_b = (_a14 = m[0].match(/\//g)) == null ? void 0 : _a14.length) != null ? _b : 0;
1778
+ (curNodesQueue[componentCount] || (curNodesQueue[componentCount] = [])).push(child);
1779
+ break;
1474
1780
  }
1475
1781
  continue;
1476
1782
  }
@@ -1478,12 +1784,8 @@ var __app = (() => {
1478
1784
  if (matcher === true || matcher.test(part)) {
1479
1785
  params[name] = part;
1480
1786
  if (isLast) {
1481
- handlerSets.push(...__privateMethod(this, _Node_instances, getHandlerSets_fn).call(this, child, method, params, __privateGet(node, _params)));
1482
- if (__privateGet(child, _children2)["*"]) {
1483
- handlerSets.push(
1484
- ...__privateMethod(this, _Node_instances, getHandlerSets_fn).call(this, __privateGet(child, _children2)["*"], method, params, __privateGet(node, _params))
1485
- );
1486
- }
1787
+ __privateMethod(this, _Node_instances, pushHandlerSets_fn).call(this, handlerSets, child, method, params, __privateGet(node, _params));
1788
+ if (__privateGet(child, _children2)["*"]) __privateMethod(this, _Node_instances, pushHandlerSets_fn).call(this, handlerSets, __privateGet(child, _children2)["*"], method, params, __privateGet(node, _params));
1487
1789
  } else {
1488
1790
  __privateSet(child, _params, params);
1489
1791
  tempNodes.push(child);
@@ -1491,36 +1793,28 @@ var __app = (() => {
1491
1793
  }
1492
1794
  }
1493
1795
  }
1494
- curNodes = tempNodes.concat((_c = curNodesQueue.shift()) != null ? _c : []);
1495
- }
1496
- if (handlerSets.length > 1) {
1497
- handlerSets.sort((a, b) => {
1498
- return a.score - b.score;
1499
- });
1796
+ const shifted = curNodesQueue.shift();
1797
+ curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
1500
1798
  }
1799
+ if (handlerSets[1]) handlerSets.sort((a, b) => {
1800
+ return a.score - b.score;
1801
+ });
1501
1802
  return [handlerSets.map(({ handler, params }) => [handler, params])];
1502
1803
  }
1503
- }, _methods = new WeakMap(), _children2 = new WeakMap(), _patterns = new WeakMap(), _order = new WeakMap(), _params = new WeakMap(), _Node_instances = new WeakSet(), getHandlerSets_fn = function(node, method, nodeParams, params) {
1804
+ }, _methods = new WeakMap(), _children2 = new WeakMap(), _patterns = new WeakMap(), _pattern = new WeakMap(), _params = new WeakMap(), _Node_instances = new WeakSet(), pushHandlerSets_fn = function(handlerSets, node, method, nodeParams, params) {
1504
1805
  var _a14;
1505
- const handlerSets = [];
1506
1806
  for (let i = 0, len = __privateGet(node, _methods).length; i < len; i++) {
1507
1807
  const m = __privateGet(node, _methods)[i];
1508
- const handlerSet = m[method] || m[METHOD_NAME_ALL];
1509
- const processedSet = {};
1510
- if (handlerSet !== void 0) {
1511
- handlerSet.params = /* @__PURE__ */ Object.create(null);
1808
+ const handlerSet = m[method] || m["ALL"];
1809
+ if (handlerSet) {
1810
+ handlerSet.params = createNullObject();
1512
1811
  handlerSets.push(handlerSet);
1513
- if (nodeParams !== emptyParams || params && params !== emptyParams) {
1514
- for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
1515
- const key = handlerSet.possibleKeys[i2];
1516
- const processed = processedSet[handlerSet.score];
1517
- handlerSet.params[key] = (params == null ? void 0 : params[key]) && !processed ? params[key] : (_a14 = nodeParams[key]) != null ? _a14 : params == null ? void 0 : params[key];
1518
- processedSet[handlerSet.score] = true;
1519
- }
1812
+ for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
1813
+ const key = handlerSet.possibleKeys[i2];
1814
+ handlerSet.params[key] = (params == null ? void 0 : params[key]) && !i2 ? params[key] : (_a14 = nodeParams[key]) != null ? _a14 : params == null ? void 0 : params[key];
1520
1815
  }
1521
1816
  }
1522
1817
  }
1523
- return handlerSets;
1524
1818
  }, _a8);
1525
1819
 
1526
1820
  // node_modules/hono/dist/router/trie-router/router.js
@@ -1528,18 +1822,10 @@ var __app = (() => {
1528
1822
  var TrieRouter = (_a9 = class {
1529
1823
  constructor() {
1530
1824
  __publicField(this, "name", "TrieRouter");
1531
- __privateAdd(this, _node);
1532
- __privateSet(this, _node, new Node2());
1825
+ __privateAdd(this, _node, new Node2());
1533
1826
  }
1534
1827
  add(method, path, handler) {
1535
- const results = checkOptionalParameter(path);
1536
- if (results) {
1537
- for (let i = 0, len = results.length; i < len; i++) {
1538
- __privateGet(this, _node).insert(method, results[i], handler);
1539
- }
1540
- return;
1541
- }
1542
- __privateGet(this, _node).insert(method, path, handler);
1828
+ for (const result of checkOptionalParameter(path) || [path]) __privateGet(this, _node).insert(method, result, handler);
1543
1829
  }
1544
1830
  match(method, path) {
1545
1831
  return __privateGet(this, _node).search(method, path);
@@ -1548,12 +1834,15 @@ var __app = (() => {
1548
1834
 
1549
1835
  // node_modules/hono/dist/hono.js
1550
1836
  var Hono2 = class extends Hono {
1837
+ /**
1838
+ * Creates an instance of the Hono class.
1839
+ *
1840
+ * @param options - Optional configuration options for the Hono instance.
1841
+ */
1551
1842
  constructor(options = {}) {
1552
1843
  var _a14;
1553
1844
  super(options);
1554
- this.router = (_a14 = options.router) != null ? _a14 : new SmartRouter({
1555
- routers: [new RegExpRouter(), new TrieRouter()]
1556
- });
1845
+ this.router = (_a14 = options.router) != null ? _a14 : new SmartRouter({ routers: [new RegExpRouter(), new TrieRouter()] });
1557
1846
  }
1558
1847
  };
1559
1848