caveat-cli 0.20.2 → 0.21.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.
@@ -2,7 +2,6 @@
2
2
  import { createRequire as __caveat_createRequire } from 'node:module';
3
3
  const require = __caveat_createRequire(import.meta.url);
4
4
  import {
5
- __export,
6
5
  findCaveatHome,
7
6
  get,
8
7
  listJevObservations,
@@ -11,49 +10,195 @@ import {
11
10
  resolvePaths,
12
11
  search,
13
12
  stderrLogger
14
- } from "./chunk-JYXVT46B.js";
13
+ } from "./chunk-NH5X6DJE.js";
14
+ import {
15
+ __export
16
+ } from "./chunk-TWJDSUZ4.js";
15
17
 
16
- // ../../node_modules/.pnpm/@hono+node-server@2.0.10_hono@4.12.30/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
18
+ // ../../node_modules/.pnpm/@hono+node-server@2.1.5_hono@4.13.13/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
17
19
  var X_ALREADY_SENT = "x-hono-already-sent";
18
20
 
19
- // ../../node_modules/.pnpm/@hono+node-server@2.0.10_hono@4.12.30/node_modules/@hono/node-server/dist/index.mjs
20
- import { STATUS_CODES, createServer } from "node:http";
21
+ // ../../node_modules/.pnpm/@hono+node-server@2.1.5_hono@4.13.13/node_modules/@hono/node-server/dist/index.mjs
22
+ import { STATUS_CODES, ServerResponse, createServer } from "node:http";
21
23
  import { Http2ServerRequest, constants } from "node:http2";
22
24
  import { Readable } from "node:stream";
23
25
 
24
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/helper/websocket/index.js
26
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/helper/websocket/index.js
25
27
  var defineWebSocketHelper = (handler) => {
26
28
  return ((...args) => {
27
29
  if (typeof args[0] === "function") {
28
30
  const [createEvents, options] = args;
29
31
  return async function upgradeWebSocket2(c, next) {
30
- const events = await createEvents(c);
31
- const result = await handler(c, events, options);
32
- if (result) {
33
- return result;
34
- }
32
+ const result = await handler(c, await createEvents(c), options);
33
+ if (result) return result;
35
34
  await next();
36
35
  };
37
36
  } else {
38
37
  const [c, events, options] = args;
39
38
  return (async () => {
40
39
  const upgraded = await handler(c, events, options);
41
- if (!upgraded) {
42
- throw new Error("Failed to upgrade WebSocket");
43
- }
40
+ if (!upgraded) throw new Error("Failed to upgrade WebSocket");
44
41
  return upgraded;
45
42
  })();
46
43
  }
47
44
  });
48
45
  };
49
46
 
50
- // ../../node_modules/.pnpm/@hono+node-server@2.0.10_hono@4.12.30/node_modules/@hono/node-server/dist/index.mjs
47
+ // ../../node_modules/.pnpm/@hono+node-server@2.1.5_hono@4.13.13/node_modules/@hono/node-server/dist/index.mjs
51
48
  var RequestError = class extends Error {
52
49
  constructor(message, options) {
53
50
  super(message, options);
54
51
  this.name = "RequestError";
55
52
  }
56
53
  };
54
+ var nonJoinedHeaders = /* @__PURE__ */ new Set([
55
+ "age",
56
+ "authorization",
57
+ "content-length",
58
+ "content-type",
59
+ "etag",
60
+ "expires",
61
+ "from",
62
+ "host",
63
+ "if-modified-since",
64
+ "if-unmodified-since",
65
+ "last-modified",
66
+ "location",
67
+ "max-forwards",
68
+ "proxy-authorization",
69
+ "referer",
70
+ "retry-after",
71
+ "server",
72
+ "user-agent"
73
+ ]);
74
+ var validHeaderName = /^[!#$%&'*+\-.^_`|~\dA-Za-z]+$/;
75
+ var isHttpWhitespace = (code2) => code2 === 9 || code2 === 10 || code2 === 13 || code2 === 32;
76
+ var normalizeHeaderValue = (value) => {
77
+ if (!isHttpWhitespace(value.charCodeAt(0)) && !isHttpWhitespace(value.charCodeAt(value.length - 1))) return value;
78
+ let start = 0;
79
+ let end = value.length;
80
+ while (start < end && isHttpWhitespace(value.charCodeAt(start))) start++;
81
+ while (end > start && isHttpWhitespace(value.charCodeAt(end - 1))) end--;
82
+ return value.slice(start, end);
83
+ };
84
+ var forbiddenHeaderValue = /[\0\r\n]/;
85
+ var GlobalHeaders = globalThis.Headers;
86
+ var materializeHeaders = (rawHeaders, HeadersCtor = GlobalHeaders) => {
87
+ const headers = new HeadersCtor();
88
+ for (let i = 0; i < rawHeaders.length; i += 2) {
89
+ const name = rawHeaders[i];
90
+ if (!name.startsWith(":")) headers.append(name, rawHeaders[i + 1]);
91
+ }
92
+ return headers;
93
+ };
94
+ var RequestHeaders = class {
95
+ #incoming;
96
+ #rawHeaders;
97
+ #headers;
98
+ #invalidValue;
99
+ constructor(incoming) {
100
+ this.#incoming = incoming;
101
+ if (incoming instanceof Http2ServerRequest) this.#rawHeaders = incoming.rawHeaders.slice();
102
+ }
103
+ get #lazyRawHeaders() {
104
+ return this.#rawHeaders ??= this.#incoming.rawHeaders.slice();
105
+ }
106
+ get #native() {
107
+ if (!this.#headers) {
108
+ this.#headers = materializeHeaders(this.#lazyRawHeaders);
109
+ this.#rawHeaders = void 0;
110
+ }
111
+ return this.#headers;
112
+ }
113
+ #normalizedName(name) {
114
+ if (typeof name !== "string") return;
115
+ if (!validHeaderName.test(name)) throw new TypeError(`Invalid header name: ${name}`);
116
+ return name.toLowerCase();
117
+ }
118
+ #lookupHttp1(lowerName) {
119
+ const headers = this.#incoming instanceof Http2ServerRequest ? void 0 : this.#incoming.headers;
120
+ if (!headers || nonJoinedHeaders.has(lowerName) || lowerName === "set-cookie" || lowerName === "__proto__") return;
121
+ if (!Object.hasOwn(headers, lowerName)) return null;
122
+ const rawValue = headers[lowerName];
123
+ if (typeof rawValue === "string") {
124
+ const value = normalizeHeaderValue(rawValue);
125
+ return forbiddenHeaderValue.test(value) ? void 0 : value;
126
+ }
127
+ }
128
+ #lookup(rawHeaders, lowerName) {
129
+ const separator = lowerName === "cookie" ? "; " : ", ";
130
+ let value = null;
131
+ for (let i = 0; i < rawHeaders.length; i += 2) {
132
+ const rawName = rawHeaders[i];
133
+ if (rawName.length === lowerName.length && rawName.toLowerCase() === lowerName) {
134
+ const rawValue = normalizeHeaderValue(rawHeaders[i + 1]);
135
+ if (forbiddenHeaderValue.test(rawValue)) {
136
+ this.#invalidValue = true;
137
+ return;
138
+ }
139
+ value = value === null ? rawValue : value + separator + rawValue;
140
+ }
141
+ }
142
+ return value;
143
+ }
144
+ append(name, value) {
145
+ this.#native.append(name, value);
146
+ }
147
+ delete(name) {
148
+ this.#native.delete(name);
149
+ }
150
+ get(name) {
151
+ const lowerName = this.#normalizedName(name);
152
+ if (lowerName && !this.#headers && !this.#invalidValue) {
153
+ const http1Value = this.#lookupHttp1(lowerName);
154
+ if (http1Value !== void 0) return http1Value;
155
+ const value = this.#lookup(this.#lazyRawHeaders, lowerName);
156
+ if (value !== void 0) return value;
157
+ }
158
+ return this.#native.get(name);
159
+ }
160
+ has(name) {
161
+ const lowerName = this.#normalizedName(name);
162
+ if (lowerName && !this.#headers && !this.#invalidValue) {
163
+ const http1Value = this.#lookupHttp1(lowerName);
164
+ if (http1Value !== void 0) return http1Value !== null;
165
+ const value = this.#lookup(this.#lazyRawHeaders, lowerName);
166
+ if (value !== void 0) return value !== null;
167
+ }
168
+ return this.#native.has(name);
169
+ }
170
+ set(name, value) {
171
+ this.#native.set(name, value);
172
+ }
173
+ getSetCookie() {
174
+ return this.#native.getSetCookie();
175
+ }
176
+ keys() {
177
+ return this.#native.keys();
178
+ }
179
+ values() {
180
+ return this.#native.values();
181
+ }
182
+ entries() {
183
+ return this.#native.entries();
184
+ }
185
+ forEach(callback, thisArg) {
186
+ this.#native.forEach((value, key) => {
187
+ callback.call(thisArg, value, key, this);
188
+ });
189
+ }
190
+ [Symbol.iterator]() {
191
+ return this.entries();
192
+ }
193
+ };
194
+ Object.defineProperty(RequestHeaders.prototype, /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
195
+ return `Headers (lightweight) ${inspectFn(Object.fromEntries(this), {
196
+ ...options,
197
+ depth: depth == null ? null : depth - 1
198
+ })}`;
199
+ } });
200
+ Object.setPrototypeOf(RequestHeaders.prototype, GlobalHeaders.prototype);
201
+ var newHeadersFromIncoming = (incoming) => globalThis.Headers === GlobalHeaders ? new RequestHeaders(incoming) : materializeHeaders(incoming.rawHeaders, globalThis.Headers);
57
202
  var reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
58
203
  var reDotSegment = /\/\.\.?(?:[/?#]|$)/;
59
204
  var reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
@@ -86,15 +231,6 @@ var Request$1 = class extends GlobalRequest {
86
231
  super(input, options);
87
232
  }
88
233
  };
89
- var newHeadersFromIncoming = (incoming) => {
90
- const headerRecord = [];
91
- const rawHeaders = incoming.rawHeaders;
92
- for (let i = 0, len = rawHeaders.length; i < len; i += 2) {
93
- const key = rawHeaders[i];
94
- if (key.charCodeAt(0) !== 58) headerRecord.push([key, rawHeaders[i + 1]]);
95
- }
96
- return new Headers(headerRecord);
97
- };
98
234
  var wrapBodyStream = /* @__PURE__ */ Symbol("wrapBodyStream");
99
235
  var byteExactEncodings = /* @__PURE__ */ new Set([
100
236
  "latin1",
@@ -229,8 +365,10 @@ var normalizeIncomingMethod = (method) => {
229
365
  case "GET":
230
366
  case "HEAD":
231
367
  case "OPTIONS":
368
+ case "PATCH":
232
369
  case "POST":
233
370
  case "PUT":
371
+ case "QUERY":
234
372
  return method;
235
373
  }
236
374
  const upper = method.toUpperCase();
@@ -528,16 +666,15 @@ var Response$1 = class Response$12 {
528
666
  constructor(body, init) {
529
667
  let headers;
530
668
  this.#body = body;
531
- if (init instanceof Response$12) {
669
+ if (init instanceof GlobalResponse) {
532
670
  const cachedGlobalResponse = init[responseCache];
533
671
  if (cachedGlobalResponse) {
534
672
  this.#init = cachedGlobalResponse;
535
673
  this[getResponseCache]();
536
674
  return;
537
- } else {
538
- this.#init = init.#init;
539
- headers = new Headers(init.headers);
540
675
  }
676
+ this.#init = init instanceof Response$12 ? init.#init : init;
677
+ headers = new Headers(init.headers);
541
678
  } else this.#init = init;
542
679
  if (body == null || typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) this[cacheKey] = [
543
680
  init?.status || 200,
@@ -715,7 +852,10 @@ var drainIncoming = (incoming) => {
715
852
  const forceClose = () => {
716
853
  cleanup();
717
854
  const socket = incoming.socket;
718
- if (socket && !socket.destroyed) socket.destroySoon();
855
+ if (socket && !socket.destroyed) {
856
+ if (typeof socket.destroySoon === "function") socket.destroySoon();
857
+ else if (typeof socket.destroy === "function") socket.destroy();
858
+ }
719
859
  };
720
860
  const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
721
861
  timer.unref?.();
@@ -732,7 +872,7 @@ var makeCloseHandler = (req, incoming, outgoing, needsBodyCleanup) => () => {
732
872
  if (incoming.errored) {
733
873
  recordBodyBufferedBeforeDisconnect(incoming);
734
874
  req[abortRequest](incoming.errored.toString());
735
- } else if (!outgoing.writableFinished) {
875
+ } else if (!outgoing.writableFinished || incoming instanceof Http2ServerRequest && incoming.aborted) {
736
876
  recordBodyBufferedBeforeDisconnect(incoming);
737
877
  req[abortRequest]("Client connection prematurely closed.");
738
878
  }
@@ -754,7 +894,10 @@ var handleResponseError = (e, outgoing) => {
754
894
  if (err.code === "ERR_STREAM_PREMATURE_CLOSE") console.info("The user aborted a request.");
755
895
  else {
756
896
  console.error(e);
757
- if (!outgoing.headersSent) outgoing.writeHead(500, { "Content-Type": "text/plain" });
897
+ if (!outgoing.headersSent) {
898
+ if (outgoing instanceof ServerResponse) outgoing._contentLength = null;
899
+ outgoing.writeHead(500, { "Content-Type": "text/plain" });
900
+ }
758
901
  outgoing.end(`Error: ${err.message}`);
759
902
  outgoing.destroy(err);
760
903
  }
@@ -762,6 +905,21 @@ var handleResponseError = (e, outgoing) => {
762
905
  var flushHeaders = (outgoing) => {
763
906
  if ("flushHeaders" in outgoing && outgoing.writable) outgoing.flushHeaders();
764
907
  };
908
+ var trySetContentLength = (outgoing, status, length) => {
909
+ const http1 = outgoing;
910
+ if (http1._contentLength === null && http1._hasBody && http1.useChunkedEncodingByDefault && !http1._removedContLen && status >= 200 && status !== 204 && status !== 304 && !outgoing.hasHeader("content-length") && !outgoing.hasHeader("transfer-encoding") && !outgoing.hasHeader("trailer")) {
911
+ http1._contentLength = length;
912
+ return true;
913
+ }
914
+ return false;
915
+ };
916
+ var writeDefaultHeaders = (outgoing, status, length) => {
917
+ if (trySetContentLength(outgoing, status, length)) outgoing.writeHead(status, { "Content-Type": defaultContentType });
918
+ else outgoing.writeHead(status, {
919
+ "Content-Type": defaultContentType,
920
+ "Content-Length": length
921
+ });
922
+ };
765
923
  var responseViaCache = async (res, outgoing) => {
766
924
  let [status, body, header] = res[cacheKey];
767
925
  if (!header) {
@@ -769,22 +927,13 @@ var responseViaCache = async (res, outgoing) => {
769
927
  outgoing.writeHead(status);
770
928
  outgoing.end();
771
929
  } else if (typeof body === "string") {
772
- outgoing.writeHead(status, {
773
- "Content-Type": defaultContentType,
774
- "Content-Length": Buffer.byteLength(body)
775
- });
930
+ writeDefaultHeaders(outgoing, status, Buffer.byteLength(body));
776
931
  outgoing.end(body);
777
932
  } else if (body instanceof Uint8Array) {
778
- outgoing.writeHead(status, {
779
- "Content-Type": defaultContentType,
780
- "Content-Length": body.byteLength
781
- });
933
+ writeDefaultHeaders(outgoing, status, body.byteLength);
782
934
  outgoing.end(body);
783
935
  } else if (body instanceof Blob) {
784
- outgoing.writeHead(status, {
785
- "Content-Type": defaultContentType,
786
- "Content-Length": body.size
787
- });
936
+ writeDefaultHeaders(outgoing, status, body.size);
788
937
  outgoing.end(new Uint8Array(await body.arrayBuffer()));
789
938
  } else {
790
939
  outgoing.writeHead(status, { "Content-Type": defaultContentType });
@@ -795,6 +944,8 @@ var responseViaCache = async (res, outgoing) => {
795
944
  return;
796
945
  }
797
946
  let hasContentLength = false;
947
+ let plainHeaders = false;
948
+ let canAutoLength = true;
798
949
  if (header instanceof Headers) {
799
950
  hasContentLength = header.has("content-length");
800
951
  header = buildOutgoingHttpHeaders(header, body === null ? void 0 : defaultContentType);
@@ -802,14 +953,25 @@ var responseViaCache = async (res, outgoing) => {
802
953
  const headerObj = new Headers(header);
803
954
  hasContentLength = headerObj.has("content-length");
804
955
  header = buildOutgoingHttpHeaders(headerObj, body === null ? void 0 : defaultContentType);
805
- } else for (const key in header) if (key.length === 14 && key.toLowerCase() === "content-length") {
806
- hasContentLength = true;
807
- break;
956
+ } else {
957
+ plainHeaders = true;
958
+ for (const key in header) {
959
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
960
+ hasContentLength = true;
961
+ break;
962
+ }
963
+ if (key.length === 17 && key.toLowerCase() === "transfer-encoding" || key.length === 7 && key.toLowerCase() === "trailer") canAutoLength = false;
964
+ }
808
965
  }
809
966
  if (!hasContentLength) {
810
- if (typeof body === "string") header["Content-Length"] = Buffer.byteLength(body);
811
- else if (body instanceof Uint8Array) header["Content-Length"] = body.byteLength;
812
- else if (body instanceof Blob) header["Content-Length"] = body.size;
967
+ let length;
968
+ if (typeof body === "string") length = Buffer.byteLength(body);
969
+ else if (body instanceof Uint8Array) length = body.byteLength;
970
+ else if (body instanceof Blob) length = body.size;
971
+ if (length !== void 0 && (!plainHeaders || !canAutoLength || !trySetContentLength(outgoing, status, length))) {
972
+ if (plainHeaders) header = { ...header };
973
+ header["Content-Length"] = length;
974
+ }
813
975
  }
814
976
  outgoing.writeHead(status, header);
815
977
  if (body == null) outgoing.end();
@@ -1200,150 +1362,82 @@ function buildWebContext(overrides = {}) {
1200
1362
  return { caveatHome, userHome, userConfigPath, config: config2, paths, logger, db };
1201
1363
  }
1202
1364
 
1203
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/compose.js
1204
- var compose = (middleware, onError, onNotFound) => {
1205
- return (context, next) => {
1206
- let index = -1;
1207
- return dispatch(0);
1208
- async function dispatch(i) {
1209
- if (i <= index) {
1210
- throw new Error("next() called multiple times");
1211
- }
1212
- index = i;
1213
- let res;
1214
- let isError = false;
1215
- let handler;
1216
- if (middleware[i]) {
1217
- handler = middleware[i][0][0];
1218
- context.req.routeIndex = i;
1219
- } else {
1220
- handler = i === middleware.length && next || void 0;
1221
- }
1222
- if (handler) {
1223
- try {
1224
- res = await handler(context, () => dispatch(i + 1));
1225
- } catch (err) {
1226
- if (err instanceof Error && onError) {
1227
- context.error = err;
1228
- res = await onError(err, context);
1229
- isError = true;
1230
- } else {
1231
- throw err;
1232
- }
1233
- }
1234
- } else {
1235
- if (context.finalized === false && onNotFound) {
1236
- res = await onNotFound(context);
1237
- }
1238
- }
1239
- if (res && (context.finalized === false || isError)) {
1240
- context.res = res;
1241
- }
1242
- return context;
1243
- }
1244
- };
1245
- };
1246
-
1247
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/request/constants.js
1365
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/request/constants.js
1248
1366
  var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
1249
1367
 
1250
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/utils/buffer.js
1368
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/utils/buffer.js
1251
1369
  var bufferToFormData = (arrayBuffer, contentType2) => {
1252
- const response = new Response(arrayBuffer, {
1253
- headers: {
1254
- // Normalize the media type (case-insensitive) while keeping parameters like the boundary
1255
- "Content-Type": contentType2.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase())
1256
- }
1257
- });
1258
- return response.formData();
1370
+ return new Response(arrayBuffer, { headers: { "Content-Type": contentType2.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) } }).formData();
1259
1371
  };
1260
1372
 
1261
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/utils/body.js
1373
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/utils/body.js
1374
+ var MAX_NESTED_OBJECTS = 1e4;
1262
1375
  var isRawRequest = (request) => "headers" in request;
1263
1376
  var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
1264
1377
  const { all = false, dot = false } = options;
1265
- const headers = isRawRequest(request) ? request.headers : request.raw.headers;
1266
- const contentType2 = headers.get("Content-Type");
1267
- const mediaType = contentType2?.split(";")[0].trim().toLowerCase();
1268
- if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") {
1269
- return parseFormData(request, { all, dot });
1270
- }
1378
+ const mediaType = (isRawRequest(request) ? request.headers : request.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
1379
+ if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return parseFormData(request, {
1380
+ all,
1381
+ dot
1382
+ });
1271
1383
  return {};
1272
1384
  };
1273
1385
  async function parseFormData(request, options) {
1386
+ if (!isRawRequest(request) && request.bodyCache.formData) return convertFormDataToBodyData(await request.bodyCache.formData, options);
1274
1387
  const headers = isRawRequest(request) ? request.headers : request.raw.headers;
1275
1388
  const arrayBuffer = await request.arrayBuffer();
1276
1389
  const formDataPromise = bufferToFormData(arrayBuffer, headers.get("Content-Type") || "");
1277
- if (!isRawRequest(request)) {
1278
- request.bodyCache.formData = formDataPromise;
1279
- }
1390
+ if (!isRawRequest(request)) request.bodyCache.formData = formDataPromise;
1280
1391
  const formData = await formDataPromise;
1281
- if (formData) {
1282
- return convertFormDataToBodyData(formData, options);
1283
- }
1392
+ if (formData) return convertFormDataToBodyData(formData, options);
1284
1393
  return {};
1285
1394
  }
1286
1395
  function convertFormDataToBodyData(formData, options) {
1287
1396
  const form = /* @__PURE__ */ Object.create(null);
1397
+ const nestingState = { count: 0 };
1288
1398
  formData.forEach((value, key) => {
1289
- const shouldParseAllValues = options.all || key.endsWith("[]");
1290
- if (!shouldParseAllValues) {
1291
- form[key] = value;
1292
- } else {
1293
- handleParsingAllValues(form, key, value);
1399
+ if (!(options.all || key.endsWith("[]"))) form[key] = value;
1400
+ else handleParsingAllValues(form, key, value);
1401
+ });
1402
+ if (options.dot) Object.entries(form).forEach(([key, value]) => {
1403
+ if (key.includes(".")) {
1404
+ handleParsingNestedValues(form, key, value, nestingState);
1405
+ delete form[key];
1294
1406
  }
1295
1407
  });
1296
- if (options.dot) {
1297
- Object.entries(form).forEach(([key, value]) => {
1298
- const shouldParseDotValues = key.includes(".");
1299
- if (shouldParseDotValues) {
1300
- handleParsingNestedValues(form, key, value);
1301
- delete form[key];
1302
- }
1303
- });
1304
- }
1305
1408
  return form;
1306
1409
  }
1307
1410
  var handleParsingAllValues = (form, key, value) => {
1308
1411
  if (form[key] !== void 0) {
1309
- if (Array.isArray(form[key])) {
1310
- ;
1311
- form[key].push(value);
1312
- } else {
1313
- form[key] = [form[key], value];
1314
- }
1315
- } else {
1316
- if (!key.endsWith("[]")) {
1317
- form[key] = value;
1318
- } else {
1319
- form[key] = [value];
1320
- }
1321
- }
1412
+ if (Array.isArray(form[key])) form[key].push(value);
1413
+ else form[key] = [form[key], value];
1414
+ } else if (!key.endsWith("[]")) form[key] = value;
1415
+ else form[key] = [value];
1322
1416
  };
1323
- var handleParsingNestedValues = (form, key, value) => {
1324
- if (/(?:^|\.)__proto__\./.test(key)) {
1325
- return;
1326
- }
1417
+ var handleParsingNestedValues = (form, key, value, state) => {
1418
+ if (/(?:^|\.)__proto__\./.test(key)) return;
1327
1419
  let nestedForm = form;
1328
- const keys = key.split(".");
1420
+ const keys = key.split(".", 34);
1421
+ if (keys.length > 33) throwNestingLimitExceeded();
1329
1422
  keys.forEach((key2, index) => {
1330
- if (index === keys.length - 1) {
1331
- nestedForm[key2] = value;
1332
- } else {
1423
+ if (index === keys.length - 1) nestedForm[key2] = value;
1424
+ else {
1333
1425
  if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
1426
+ if (state.count++ >= MAX_NESTED_OBJECTS) throwNestingLimitExceeded();
1334
1427
  nestedForm[key2] = /* @__PURE__ */ Object.create(null);
1335
1428
  }
1336
1429
  nestedForm = nestedForm[key2];
1337
1430
  }
1338
1431
  });
1339
1432
  };
1433
+ var throwNestingLimitExceeded = () => {
1434
+ throw new Error("Nesting limit exceeded");
1435
+ };
1340
1436
 
1341
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/utils/url.js
1437
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/utils/url.js
1342
1438
  var splitPath = (path) => {
1343
1439
  const paths = path.split("/");
1344
- if (paths[0] === "") {
1345
- paths.shift();
1346
- }
1440
+ if (paths[0] === "") paths.shift();
1347
1441
  return paths;
1348
1442
  };
1349
1443
  var splitRoutingPath = (routePath) => {
@@ -1358,34 +1452,42 @@ var extractGroupsFromPath = (path) => {
1358
1452
  groups.push([mark, match3]);
1359
1453
  return mark;
1360
1454
  });
1361
- return { groups, path };
1455
+ return {
1456
+ groups,
1457
+ path
1458
+ };
1362
1459
  };
1363
1460
  var replaceGroupMarks = (paths, groups) => {
1364
1461
  for (let i = groups.length - 1; i >= 0; i--) {
1365
1462
  const [mark] = groups[i];
1366
- for (let j = paths.length - 1; j >= 0; j--) {
1367
- if (paths[j].includes(mark)) {
1368
- paths[j] = paths[j].replace(mark, groups[i][1]);
1369
- break;
1370
- }
1463
+ for (let j = paths.length - 1; j >= 0; j--) if (paths[j].includes(mark)) {
1464
+ paths[j] = paths[j].replace(mark, groups[i][1]);
1465
+ break;
1371
1466
  }
1372
1467
  }
1373
1468
  return paths;
1374
1469
  };
1375
1470
  var patternCache = {};
1376
1471
  var getPattern = (label, next) => {
1377
- if (label === "*") {
1378
- return "*";
1379
- }
1472
+ if (label === "*") return "*";
1380
1473
  const match3 = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
1381
1474
  if (match3) {
1382
1475
  const cacheKey2 = `${label}#${next}`;
1383
1476
  if (!patternCache[cacheKey2]) {
1384
- if (match3[2]) {
1385
- patternCache[cacheKey2] = next && next[0] !== ":" && next[0] !== "*" ? [cacheKey2, match3[1], new RegExp(`^${match3[2]}(?=/${next})`)] : [label, match3[1], new RegExp(`^${match3[2]}$`)];
1386
- } else {
1387
- patternCache[cacheKey2] = [label, match3[1], true];
1388
- }
1477
+ if (match3[2]) patternCache[cacheKey2] = next && next[0] !== ":" && next[0] !== "*" ? [
1478
+ cacheKey2,
1479
+ match3[1],
1480
+ new RegExp(`^${match3[2]}(?=/${next})`)
1481
+ ] : [
1482
+ label,
1483
+ match3[1],
1484
+ new RegExp(`^${match3[2]}$`)
1485
+ ];
1486
+ else patternCache[cacheKey2] = [
1487
+ label,
1488
+ match3[1],
1489
+ true
1490
+ ];
1389
1491
  }
1390
1492
  return patternCache[cacheKey2];
1391
1493
  }
@@ -1417,9 +1519,7 @@ var getPath = (request) => {
1417
1519
  const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
1418
1520
  const path = url.slice(start, end);
1419
1521
  return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
1420
- } else if (charCode === 63 || charCode === 35) {
1421
- break;
1422
- }
1522
+ } else if (charCode === 63 || charCode === 35) break;
1423
1523
  }
1424
1524
  return url.slice(start, i);
1425
1525
  };
@@ -1428,111 +1528,74 @@ var getPathNoStrict = (request) => {
1428
1528
  return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
1429
1529
  };
1430
1530
  var mergePath = (base2, sub, ...rest) => {
1431
- if (rest.length) {
1432
- sub = mergePath(sub, ...rest);
1433
- }
1531
+ if (rest.length) sub = mergePath(sub, ...rest);
1434
1532
  return `${base2?.[0] === "/" ? "" : "/"}${base2}${sub === "/" ? "" : `${base2?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
1435
1533
  };
1436
1534
  var checkOptionalParameter = (path) => {
1437
- if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
1438
- return null;
1439
- }
1535
+ if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) return null;
1440
1536
  const segments = path.split("/");
1441
1537
  const results = [];
1442
1538
  let basePath = "";
1443
1539
  segments.forEach((segment) => {
1444
- if (segment !== "" && !/\:/.test(segment)) {
1445
- basePath += "/" + segment;
1446
- } else if (/\:/.test(segment)) {
1447
- if (/\?/.test(segment)) {
1448
- if (results.length === 0 && basePath === "") {
1449
- results.push("/");
1450
- } else {
1451
- results.push(basePath);
1452
- }
1453
- const optionalSegment = segment.replace("?", "");
1540
+ if (segment !== "" && !/\:/.test(segment)) basePath += "/" + segment;
1541
+ else if (/\:/.test(segment)) {
1542
+ if (segment.charCodeAt(segment.length - 1) === 63) {
1543
+ if (results.length === 0 && basePath === "") results.push("/");
1544
+ else results.push(basePath);
1545
+ const optionalSegment = segment.slice(0, -1);
1454
1546
  basePath += "/" + optionalSegment;
1455
1547
  results.push(basePath);
1456
- } else {
1457
- basePath += "/" + segment;
1458
- }
1548
+ } else basePath += "/" + segment;
1459
1549
  }
1460
1550
  });
1461
1551
  return results.filter((v, i, a) => a.indexOf(v) === i);
1462
1552
  };
1553
+ var tryDecodeURIComponent = (str) => str.indexOf("%") !== -1 ? tryDecode(str, decodeURIComponent_) : str;
1463
1554
  var _decodeURI = (value) => {
1464
- if (!/[%+]/.test(value)) {
1465
- return value;
1466
- }
1467
- if (value.indexOf("+") !== -1) {
1468
- value = value.replace(/\+/g, " ");
1469
- }
1470
- return value.indexOf("%") !== -1 ? tryDecode(value, decodeURIComponent_) : value;
1555
+ if (value.indexOf("+") !== -1) value = value.replace(/\+/g, " ");
1556
+ return tryDecodeURIComponent(value);
1471
1557
  };
1472
1558
  var _getQueryParam = (url, key, multiple) => {
1559
+ const hashIndex = url.indexOf("#", 8);
1560
+ if (hashIndex !== -1) url = url.slice(0, hashIndex);
1473
1561
  let encoded;
1474
- if (!multiple && key && !/[%+]/.test(key)) {
1562
+ if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
1475
1563
  let keyIndex2 = url.indexOf("?", 8);
1476
- if (keyIndex2 === -1) {
1477
- return void 0;
1478
- }
1479
- if (!url.startsWith(key, keyIndex2 + 1)) {
1480
- keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
1481
- }
1564
+ if (keyIndex2 === -1) return;
1565
+ if (!url.startsWith(key, keyIndex2 + 1)) keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
1482
1566
  while (keyIndex2 !== -1) {
1483
1567
  const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
1484
1568
  if (trailingKeyCode === 61) {
1485
1569
  const valueIndex = keyIndex2 + key.length + 2;
1486
1570
  const endIndex = url.indexOf("&", valueIndex);
1487
1571
  return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
1488
- } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) {
1489
- return "";
1490
- }
1572
+ } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) return "";
1491
1573
  keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
1492
1574
  }
1493
1575
  encoded = /[%+]/.test(url);
1494
- if (!encoded) {
1495
- return void 0;
1496
- }
1576
+ if (!encoded) return;
1497
1577
  }
1498
- const results = {};
1578
+ const results = /* @__PURE__ */ Object.create(null);
1499
1579
  encoded ??= /[%+]/.test(url);
1500
1580
  let keyIndex = url.indexOf("?", 8);
1501
1581
  while (keyIndex !== -1) {
1502
1582
  const nextKeyIndex = url.indexOf("&", keyIndex + 1);
1503
1583
  let valueIndex = url.indexOf("=", keyIndex);
1504
- if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) {
1505
- valueIndex = -1;
1506
- }
1507
- let name = url.slice(
1508
- keyIndex + 1,
1509
- valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex
1510
- );
1511
- if (encoded) {
1512
- name = _decodeURI(name);
1513
- }
1584
+ if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) valueIndex = -1;
1585
+ let name = url.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex);
1586
+ if (encoded) name = _decodeURI(name);
1514
1587
  keyIndex = nextKeyIndex;
1515
- if (name === "") {
1516
- continue;
1517
- }
1588
+ if (name === "") continue;
1518
1589
  let value;
1519
- if (valueIndex === -1) {
1520
- value = "";
1521
- } else {
1590
+ if (valueIndex === -1) value = "";
1591
+ else {
1522
1592
  value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);
1523
- if (encoded) {
1524
- value = _decodeURI(value);
1525
- }
1593
+ if (encoded) value = _decodeURI(value);
1526
1594
  }
1527
1595
  if (multiple) {
1528
- if (!(results[name] && Array.isArray(results[name]))) {
1529
- results[name] = [];
1530
- }
1531
- ;
1596
+ if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
1532
1597
  results[name].push(value);
1533
- } else {
1534
- results[name] ??= value;
1535
- }
1598
+ } else results[name] ??= value;
1536
1599
  }
1537
1600
  return key ? results[key] : results;
1538
1601
  };
@@ -1542,64 +1605,59 @@ var getQueryParams = (url, key) => {
1542
1605
  };
1543
1606
  var decodeURIComponent_ = decodeURIComponent;
1544
1607
 
1545
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/request.js
1546
- var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
1608
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/request.js
1547
1609
  var HonoRequest = class {
1548
1610
  /**
1549
- * `.raw` can get the raw Request object.
1550
- *
1551
- * @see {@link https://hono.dev/docs/api/request#raw}
1552
- *
1553
- * @example
1554
- * ```ts
1555
- * // For Cloudflare Workers
1556
- * app.post('/', async (c) => {
1557
- * const metadata = c.req.raw.cf?.hostMetadata?
1558
- * ...
1559
- * })
1560
- * ```
1561
- */
1611
+ * `.raw` can get the raw Request object.
1612
+ *
1613
+ * @see {@link https://hono.dev/docs/api/request#raw}
1614
+ *
1615
+ * @example
1616
+ * ```ts
1617
+ * // For Cloudflare Workers
1618
+ * app.post('/', async (c) => {
1619
+ * const metadata = c.req.raw.cf?.hostMetadata?
1620
+ * ...
1621
+ * })
1622
+ * ```
1623
+ */
1562
1624
  raw;
1563
1625
  #validatedData;
1564
- // Short name of validatedData
1565
1626
  #matchResult;
1566
1627
  routeIndex = 0;
1567
1628
  /**
1568
- * `.path` can get the pathname of the request.
1569
- *
1570
- * @see {@link https://hono.dev/docs/api/request#path}
1571
- *
1572
- * @example
1573
- * ```ts
1574
- * app.get('/about/me', (c) => {
1575
- * const pathname = c.req.path // `/about/me`
1576
- * })
1577
- * ```
1578
- */
1629
+ * `.path` can get the pathname of the request.
1630
+ *
1631
+ * @see {@link https://hono.dev/docs/api/request#path}
1632
+ *
1633
+ * @example
1634
+ * ```ts
1635
+ * app.get('/about/me', (c) => {
1636
+ * const pathname = c.req.path // `/about/me`
1637
+ * })
1638
+ * ```
1639
+ */
1579
1640
  path;
1580
1641
  bodyCache = {};
1581
1642
  constructor(request, path = "/", matchResult = [[]]) {
1582
1643
  this.raw = request;
1583
1644
  this.path = path;
1584
1645
  this.#matchResult = matchResult;
1585
- this.#validatedData = {};
1586
1646
  }
1587
1647
  param(key) {
1588
1648
  return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams();
1589
1649
  }
1590
1650
  #getDecodedParam(key) {
1591
- const paramKey = this.#matchResult[0][this.routeIndex][1][key];
1651
+ const paramKey = this.#matchResult[0][this.routeIndex]?.[1][key];
1592
1652
  const param = this.#getParamValue(paramKey);
1593
- return param && /\%/.test(param) ? tryDecodeURIComponent(param) : param;
1653
+ return param && tryDecodeURIComponent(param);
1594
1654
  }
1595
1655
  #getAllDecodedParams() {
1596
1656
  const decoded = {};
1597
- const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
1657
+ const keys = Object.keys(this.#matchResult[0][this.routeIndex]?.[1] ?? {});
1598
1658
  for (const key of keys) {
1599
1659
  const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
1600
- if (value !== void 0) {
1601
- decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value;
1602
- }
1660
+ if (value !== void 0) decoded[key] = tryDecodeURIComponent(value);
1603
1661
  }
1604
1662
  return decoded;
1605
1663
  }
@@ -1613,10 +1671,8 @@ var HonoRequest = class {
1613
1671
  return getQueryParams(this.url, key);
1614
1672
  }
1615
1673
  header(name) {
1616
- if (name) {
1617
- return this.raw.headers.get(name) ?? void 0;
1618
- }
1619
- const headerData = {};
1674
+ if (name) return this.raw.headers.get(name) ?? void 0;
1675
+ const headerData = /* @__PURE__ */ Object.create(null);
1620
1676
  this.raw.headers.forEach((value, key) => {
1621
1677
  headerData[key] = value;
1622
1678
  });
@@ -1628,146 +1684,140 @@ var HonoRequest = class {
1628
1684
  #cachedBody = (key) => {
1629
1685
  const { bodyCache, raw: raw2 } = this;
1630
1686
  const cachedBody = bodyCache[key];
1631
- if (cachedBody) {
1632
- return cachedBody;
1633
- }
1634
- const anyCachedKey = Object.keys(bodyCache)[0];
1635
- if (anyCachedKey) {
1636
- return bodyCache[anyCachedKey].then((body) => {
1637
- if (anyCachedKey === "json") {
1638
- body = JSON.stringify(body);
1639
- }
1640
- return new Response(body)[key]();
1641
- });
1642
- }
1687
+ if (cachedBody) return cachedBody;
1688
+ for (const anyCachedKey in bodyCache) return bodyCache[anyCachedKey].then((body) => {
1689
+ if (anyCachedKey === "json") body = JSON.stringify(body);
1690
+ const contentType2 = anyCachedKey === "formData" ? void 0 : raw2.headers.get("content-type");
1691
+ return new Response(body, { headers: contentType2 ? { "Content-Type": contentType2 } : void 0 })[key]();
1692
+ });
1643
1693
  return bodyCache[key] = raw2[key]();
1644
1694
  };
1645
1695
  /**
1646
- * `.json()` can parse Request body of type `application/json`
1647
- *
1648
- * @see {@link https://hono.dev/docs/api/request#json}
1649
- *
1650
- * @example
1651
- * ```ts
1652
- * app.post('/entry', async (c) => {
1653
- * const body = await c.req.json()
1654
- * })
1655
- * ```
1656
- */
1696
+ * `.json()` can parse Request body of type `application/json`
1697
+ *
1698
+ * @see {@link https://hono.dev/docs/api/request#json}
1699
+ *
1700
+ * @example
1701
+ * ```ts
1702
+ * app.post('/entry', async (c) => {
1703
+ * const body = await c.req.json()
1704
+ * })
1705
+ * ```
1706
+ */
1657
1707
  json() {
1658
1708
  return this.#cachedBody("text").then((text2) => JSON.parse(text2));
1659
1709
  }
1660
1710
  /**
1661
- * `.text()` can parse Request body of type `text/plain`
1662
- *
1663
- * @see {@link https://hono.dev/docs/api/request#text}
1664
- *
1665
- * @example
1666
- * ```ts
1667
- * app.post('/entry', async (c) => {
1668
- * const body = await c.req.text()
1669
- * })
1670
- * ```
1671
- */
1711
+ * `.text()` can parse Request body of type `text/plain`
1712
+ *
1713
+ * @see {@link https://hono.dev/docs/api/request#text}
1714
+ *
1715
+ * @example
1716
+ * ```ts
1717
+ * app.post('/entry', async (c) => {
1718
+ * const body = await c.req.text()
1719
+ * })
1720
+ * ```
1721
+ */
1672
1722
  text() {
1673
1723
  return this.#cachedBody("text");
1674
1724
  }
1675
1725
  /**
1676
- * `.arrayBuffer()` parse Request body as an `ArrayBuffer`
1677
- *
1678
- * @see {@link https://hono.dev/docs/api/request#arraybuffer}
1679
- *
1680
- * @example
1681
- * ```ts
1682
- * app.post('/entry', async (c) => {
1683
- * const body = await c.req.arrayBuffer()
1684
- * })
1685
- * ```
1686
- */
1726
+ * `.arrayBuffer()` parse Request body as an `ArrayBuffer`
1727
+ *
1728
+ * @see {@link https://hono.dev/docs/api/request#arraybuffer}
1729
+ *
1730
+ * @example
1731
+ * ```ts
1732
+ * app.post('/entry', async (c) => {
1733
+ * const body = await c.req.arrayBuffer()
1734
+ * })
1735
+ * ```
1736
+ */
1687
1737
  arrayBuffer() {
1688
1738
  return this.#cachedBody("arrayBuffer");
1689
1739
  }
1690
1740
  /**
1691
- * `.bytes()` parses the request body as a `Uint8Array`.
1692
- *
1693
- * @see {@link https://hono.dev/docs/api/request#bytes}
1694
- *
1695
- * @example
1696
- * ```ts
1697
- * app.post('/entry', async (c) => {
1698
- * const body = await c.req.bytes()
1699
- * })
1700
- * ```
1701
- */
1741
+ * `.bytes()` parses the request body as a `Uint8Array`.
1742
+ *
1743
+ * @see {@link https://hono.dev/docs/api/request#bytes}
1744
+ *
1745
+ * @example
1746
+ * ```ts
1747
+ * app.post('/entry', async (c) => {
1748
+ * const body = await c.req.bytes()
1749
+ * })
1750
+ * ```
1751
+ */
1702
1752
  bytes() {
1703
1753
  return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
1704
1754
  }
1705
1755
  /**
1706
- * Parses the request body as a `Blob`.
1707
- * @example
1708
- * ```ts
1709
- * app.post('/entry', async (c) => {
1710
- * const body = await c.req.blob();
1711
- * });
1712
- * ```
1713
- * @see https://hono.dev/docs/api/request#blob
1714
- */
1756
+ * Parses the request body as a `Blob`.
1757
+ * @example
1758
+ * ```ts
1759
+ * app.post('/entry', async (c) => {
1760
+ * const body = await c.req.blob();
1761
+ * });
1762
+ * ```
1763
+ * @see https://hono.dev/docs/api/request#blob
1764
+ */
1715
1765
  blob() {
1716
1766
  return this.#cachedBody("blob");
1717
1767
  }
1718
1768
  /**
1719
- * Parses the request body as `FormData`.
1720
- * @example
1721
- * ```ts
1722
- * app.post('/entry', async (c) => {
1723
- * const body = await c.req.formData();
1724
- * });
1725
- * ```
1726
- * @see https://hono.dev/docs/api/request#formdata
1727
- */
1769
+ * Parses the request body as `FormData`.
1770
+ * @example
1771
+ * ```ts
1772
+ * app.post('/entry', async (c) => {
1773
+ * const body = await c.req.formData();
1774
+ * });
1775
+ * ```
1776
+ * @see https://hono.dev/docs/api/request#formdata
1777
+ */
1728
1778
  formData() {
1729
1779
  return this.#cachedBody("formData");
1730
1780
  }
1731
1781
  /**
1732
- * Adds validated data to the request.
1733
- *
1734
- * @param target - The target of the validation.
1735
- * @param data - The validated data to add.
1736
- */
1782
+ * Adds validated data to the request.
1783
+ *
1784
+ * @param target - The target of the validation.
1785
+ * @param data - The validated data to add.
1786
+ */
1737
1787
  addValidatedData(target, data) {
1738
- this.#validatedData[target] = data;
1788
+ (this.#validatedData ??= {})[target] = data;
1739
1789
  }
1740
1790
  valid(target) {
1741
- return this.#validatedData[target];
1791
+ return this.#validatedData?.[target];
1742
1792
  }
1743
1793
  /**
1744
- * `.url()` can get the request url strings.
1745
- *
1746
- * @see {@link https://hono.dev/docs/api/request#url}
1747
- *
1748
- * @example
1749
- * ```ts
1750
- * app.get('/about/me', (c) => {
1751
- * const url = c.req.url // `http://localhost:8787/about/me`
1752
- * ...
1753
- * })
1754
- * ```
1755
- */
1794
+ * `.url` can get the request url strings.
1795
+ *
1796
+ * @see {@link https://hono.dev/docs/api/request#url}
1797
+ *
1798
+ * @example
1799
+ * ```ts
1800
+ * app.get('/about/me', (c) => {
1801
+ * const url = c.req.url // `http://localhost:8787/about/me`
1802
+ * ...
1803
+ * })
1804
+ * ```
1805
+ */
1756
1806
  get url() {
1757
1807
  return this.raw.url;
1758
1808
  }
1759
1809
  /**
1760
- * `.method()` can get the method name of the request.
1761
- *
1762
- * @see {@link https://hono.dev/docs/api/request#method}
1763
- *
1764
- * @example
1765
- * ```ts
1766
- * app.get('/about/me', (c) => {
1767
- * const method = c.req.method // `GET`
1768
- * })
1769
- * ```
1770
- */
1810
+ * `.method` can get the method name of the request.
1811
+ *
1812
+ * @see {@link https://hono.dev/docs/api/request#method}
1813
+ *
1814
+ * @example
1815
+ * ```ts
1816
+ * app.get('/about/me', (c) => {
1817
+ * const method = c.req.method // `GET`
1818
+ * })
1819
+ * ```
1820
+ */
1771
1821
  get method() {
1772
1822
  return this.raw.method;
1773
1823
  }
@@ -1775,57 +1825,57 @@ var HonoRequest = class {
1775
1825
  return this.#matchResult;
1776
1826
  }
1777
1827
  /**
1778
- * `.matchedRoutes()` can return a matched route in the handler
1779
- *
1780
- * @deprecated
1781
- *
1782
- * Use matchedRoutes helper defined in "hono/route" instead.
1783
- *
1784
- * @see {@link https://hono.dev/docs/api/request#matchedroutes}
1785
- *
1786
- * @example
1787
- * ```ts
1788
- * app.use('*', async function logger(c, next) {
1789
- * await next()
1790
- * c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
1791
- * const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
1792
- * console.log(
1793
- * method,
1794
- * ' ',
1795
- * path,
1796
- * ' '.repeat(Math.max(10 - path.length, 0)),
1797
- * name,
1798
- * i === c.req.routeIndex ? '<- respond from here' : ''
1799
- * )
1800
- * })
1801
- * })
1802
- * ```
1803
- */
1828
+ * `.matchedRoutes` can return a matched route in the handler
1829
+ *
1830
+ * @deprecated
1831
+ *
1832
+ * Use matchedRoutes helper defined in "hono/route" instead.
1833
+ *
1834
+ * @see {@link https://hono.dev/docs/api/request#matchedroutes}
1835
+ *
1836
+ * @example
1837
+ * ```ts
1838
+ * app.use('*', async function logger(c, next) {
1839
+ * await next()
1840
+ * c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
1841
+ * const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
1842
+ * console.log(
1843
+ * method,
1844
+ * ' ',
1845
+ * path,
1846
+ * ' '.repeat(Math.max(10 - path.length, 0)),
1847
+ * name,
1848
+ * i === c.req.routeIndex ? '<- respond from here' : ''
1849
+ * )
1850
+ * })
1851
+ * })
1852
+ * ```
1853
+ */
1804
1854
  get matchedRoutes() {
1805
1855
  return this.#matchResult[0].map(([[, route]]) => route);
1806
1856
  }
1807
1857
  /**
1808
- * `routePath()` can retrieve the path registered within the handler
1809
- *
1810
- * @deprecated
1811
- *
1812
- * Use routePath helper defined in "hono/route" instead.
1813
- *
1814
- * @see {@link https://hono.dev/docs/api/request#routepath}
1815
- *
1816
- * @example
1817
- * ```ts
1818
- * app.get('/posts/:id', (c) => {
1819
- * return c.json({ path: c.req.routePath })
1820
- * })
1821
- * ```
1822
- */
1858
+ * `.routePath` can retrieve the path registered within the handler
1859
+ *
1860
+ * @deprecated
1861
+ *
1862
+ * Use routePath helper defined in "hono/route" instead.
1863
+ *
1864
+ * @see {@link https://hono.dev/docs/api/request#routepath}
1865
+ *
1866
+ * @example
1867
+ * ```ts
1868
+ * app.get('/posts/:id', (c) => {
1869
+ * return c.json({ path: c.req.routePath })
1870
+ * })
1871
+ * ```
1872
+ */
1823
1873
  get routePath() {
1824
1874
  return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;
1825
1875
  }
1826
1876
  };
1827
1877
 
1828
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/utils/html.js
1878
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/utils/html.js
1829
1879
  var HtmlEscapedCallbackPhase = {
1830
1880
  Stringify: 1,
1831
1881
  BeforeStream: 2,
@@ -1839,35 +1889,23 @@ var raw = (value, callbacks) => {
1839
1889
  };
1840
1890
  var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
1841
1891
  if (typeof str === "object" && !(str instanceof String)) {
1842
- if (!(str instanceof Promise)) {
1843
- str = str.toString();
1844
- }
1845
- if (str instanceof Promise) {
1846
- str = await str;
1847
- }
1892
+ if (!(str instanceof Promise)) str = str.toString();
1893
+ if (str instanceof Promise) str = await str;
1848
1894
  }
1849
1895
  const callbacks = str.callbacks;
1850
- if (!callbacks?.length) {
1851
- return Promise.resolve(str);
1852
- }
1853
- if (buffer) {
1854
- buffer[0] += str;
1855
- } else {
1856
- buffer = [str];
1857
- }
1858
- const resStr = Promise.all(callbacks.map((c) => c({ phase, buffer, context }))).then(
1859
- (res) => Promise.all(
1860
- res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))
1861
- ).then(() => buffer[0])
1862
- );
1863
- if (preserveCallbacks) {
1864
- return raw(await resStr, callbacks);
1865
- } else {
1866
- return resStr;
1867
- }
1896
+ if (!callbacks?.length) return Promise.resolve(str);
1897
+ if (buffer) buffer[0] += str;
1898
+ else buffer = [str];
1899
+ const resStr = Promise.all(callbacks.map((c) => c({
1900
+ phase,
1901
+ buffer,
1902
+ context
1903
+ }))).then((res) => Promise.all(res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))).then(() => buffer[0]));
1904
+ if (preserveCallbacks) return raw(await resStr, callbacks);
1905
+ else return resStr;
1868
1906
  };
1869
1907
 
1870
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/context.js
1908
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/context.js
1871
1909
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
1872
1910
  var setDefaultContentType = (contentType2, headers) => {
1873
1911
  return {
@@ -1880,36 +1918,36 @@ var Context = class {
1880
1918
  #rawRequest;
1881
1919
  #req;
1882
1920
  /**
1883
- * `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
1884
- *
1885
- * @see {@link https://hono.dev/docs/api/context#env}
1886
- *
1887
- * @example
1888
- * ```ts
1889
- * // Environment object for Cloudflare Workers
1890
- * app.get('*', async c => {
1891
- * const counter = c.env.COUNTER
1892
- * })
1893
- * ```
1894
- */
1921
+ * `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
1922
+ *
1923
+ * @see {@link https://hono.dev/docs/api/context#env}
1924
+ *
1925
+ * @example
1926
+ * ```ts
1927
+ * // Environment object for Cloudflare Workers
1928
+ * app.get('*', async c => {
1929
+ * const counter = c.env.COUNTER
1930
+ * })
1931
+ * ```
1932
+ */
1895
1933
  env = {};
1896
1934
  #var;
1897
1935
  finalized = false;
1898
1936
  /**
1899
- * `.error` can get the error object from the middleware if the Handler throws an error.
1900
- *
1901
- * @see {@link https://hono.dev/docs/api/context#error}
1902
- *
1903
- * @example
1904
- * ```ts
1905
- * app.use('*', async (c, next) => {
1906
- * await next()
1907
- * if (c.error) {
1908
- * // do something...
1909
- * }
1910
- * })
1911
- * ```
1912
- */
1937
+ * `.error` can get the error object from the middleware if the Handler throws an error.
1938
+ *
1939
+ * @see {@link https://hono.dev/docs/api/context#error}
1940
+ *
1941
+ * @example
1942
+ * ```ts
1943
+ * app.use('*', async (c, next) => {
1944
+ * await next()
1945
+ * if (c.error) {
1946
+ * // do something...
1947
+ * }
1948
+ * })
1949
+ * ```
1950
+ */
1913
1951
  error;
1914
1952
  #status;
1915
1953
  #executionCtx;
@@ -1921,11 +1959,11 @@ var Context = class {
1921
1959
  #matchResult;
1922
1960
  #path;
1923
1961
  /**
1924
- * Creates an instance of the Context class.
1925
- *
1926
- * @param req - The Request object.
1927
- * @param options - Optional configuration options for the context.
1928
- */
1962
+ * Creates an instance of the Context class.
1963
+ *
1964
+ * @param req - The Request object.
1965
+ * @param options - Optional configuration options for the context.
1966
+ */
1929
1967
  constructor(req, options) {
1930
1968
  this.#rawRequest = req;
1931
1969
  if (options) {
@@ -1937,355 +1975,363 @@ var Context = class {
1937
1975
  }
1938
1976
  }
1939
1977
  /**
1940
- * `.req` is the instance of {@link HonoRequest}.
1941
- */
1978
+ * `.req` is the instance of {@link HonoRequest}.
1979
+ */
1942
1980
  get req() {
1943
1981
  this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
1944
1982
  return this.#req;
1945
1983
  }
1946
1984
  /**
1947
- * @see {@link https://hono.dev/docs/api/context#event}
1948
- * The FetchEvent associated with the current request.
1949
- *
1950
- * @throws Will throw an error if the context does not have a FetchEvent.
1951
- */
1985
+ * @see {@link https://hono.dev/docs/api/context#event}
1986
+ * The FetchEvent associated with the current request.
1987
+ *
1988
+ * @throws Will throw an error if the context does not have a FetchEvent.
1989
+ */
1952
1990
  get event() {
1953
- if (this.#executionCtx && "respondWith" in this.#executionCtx) {
1954
- return this.#executionCtx;
1955
- } else {
1956
- throw Error("This context has no FetchEvent");
1957
- }
1991
+ if (this.#executionCtx && "respondWith" in this.#executionCtx) return this.#executionCtx;
1992
+ else throw Error("This context has no FetchEvent");
1958
1993
  }
1959
1994
  /**
1960
- * @see {@link https://hono.dev/docs/api/context#executionctx}
1961
- * The ExecutionContext associated with the current request.
1962
- *
1963
- * @throws Will throw an error if the context does not have an ExecutionContext.
1964
- */
1995
+ * @see {@link https://hono.dev/docs/api/context#executionctx}
1996
+ * The ExecutionContext associated with the current request.
1997
+ *
1998
+ * @throws Will throw an error if the context does not have an ExecutionContext.
1999
+ */
1965
2000
  get executionCtx() {
1966
- if (this.#executionCtx) {
1967
- return this.#executionCtx;
1968
- } else {
1969
- throw Error("This context has no ExecutionContext");
1970
- }
2001
+ if (this.#executionCtx) return this.#executionCtx;
2002
+ else throw Error("This context has no ExecutionContext");
1971
2003
  }
1972
2004
  /**
1973
- * @see {@link https://hono.dev/docs/api/context#res}
1974
- * The Response object for the current request.
1975
- */
2005
+ * @see {@link https://hono.dev/docs/api/context#res}
2006
+ * The Response object for the current request.
2007
+ */
1976
2008
  get res() {
1977
- return this.#res ||= createResponseInstance(null, {
1978
- headers: this.#preparedHeaders ??= new Headers()
1979
- });
2009
+ return this.#res ||= createResponseInstance(null, { headers: this.#preparedHeaders ??= new Headers() });
1980
2010
  }
1981
2011
  /**
1982
- * Sets the Response object for the current request.
1983
- *
1984
- * @param _res - The Response object to set.
1985
- */
2012
+ * Sets the Response object for the current request.
2013
+ *
2014
+ * @param _res - The Response object to set.
2015
+ */
1986
2016
  set res(_res) {
1987
2017
  if (this.#res && _res) {
1988
2018
  _res = createResponseInstance(_res.body, _res);
1989
2019
  for (const [k, v] of this.#res.headers.entries()) {
1990
- if (k === "content-type") {
1991
- continue;
1992
- }
2020
+ if (k === "content-type") continue;
1993
2021
  if (k === "set-cookie") {
1994
2022
  const cookies = this.#res.headers.getSetCookie();
1995
2023
  _res.headers.delete("set-cookie");
1996
- for (const cookie of cookies) {
1997
- _res.headers.append("set-cookie", cookie);
1998
- }
1999
- } else {
2000
- _res.headers.set(k, v);
2001
- }
2024
+ for (const cookie of cookies) _res.headers.append("set-cookie", cookie);
2025
+ } else _res.headers.set(k, v);
2002
2026
  }
2003
2027
  }
2004
2028
  this.#res = _res;
2005
2029
  this.finalized = true;
2006
2030
  }
2007
2031
  /**
2008
- * `.render()` can create a response within a layout.
2009
- *
2010
- * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
2011
- *
2012
- * @example
2013
- * ```ts
2014
- * app.get('/', (c) => {
2015
- * return c.render('Hello!')
2016
- * })
2017
- * ```
2018
- */
2032
+ * `.render()` can create a response within a layout.
2033
+ *
2034
+ * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
2035
+ *
2036
+ * @example
2037
+ * ```ts
2038
+ * app.get('/', (c) => {
2039
+ * return c.render('Hello!')
2040
+ * })
2041
+ * ```
2042
+ */
2019
2043
  render = (...args) => {
2020
2044
  this.#renderer ??= (content) => this.html(content);
2021
2045
  return this.#renderer(...args);
2022
2046
  };
2023
2047
  /**
2024
- * Sets the layout for the response.
2025
- *
2026
- * @param layout - The layout to set.
2027
- * @returns The layout function.
2028
- */
2048
+ * Sets the layout for the response.
2049
+ *
2050
+ * @param layout - The layout to set.
2051
+ * @returns The layout function.
2052
+ */
2029
2053
  setLayout = (layout2) => this.#layout = layout2;
2030
2054
  /**
2031
- * Gets the current layout for the response.
2032
- *
2033
- * @returns The current layout function.
2034
- */
2055
+ * Gets the current layout for the response.
2056
+ *
2057
+ * @returns The current layout function.
2058
+ */
2035
2059
  getLayout = () => this.#layout;
2036
2060
  /**
2037
- * `.setRenderer()` can set the layout in the custom middleware.
2038
- *
2039
- * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
2040
- *
2041
- * @example
2042
- * ```tsx
2043
- * app.use('*', async (c, next) => {
2044
- * c.setRenderer((content) => {
2045
- * return c.html(
2046
- * <html>
2047
- * <body>
2048
- * <p>{content}</p>
2049
- * </body>
2050
- * </html>
2051
- * )
2052
- * })
2053
- * await next()
2054
- * })
2055
- * ```
2056
- */
2061
+ * `.setRenderer()` can set the layout in the custom middleware.
2062
+ *
2063
+ * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
2064
+ *
2065
+ * @example
2066
+ * ```tsx
2067
+ * app.use('*', async (c, next) => {
2068
+ * c.setRenderer((content) => {
2069
+ * return c.html(
2070
+ * <html>
2071
+ * <body>
2072
+ * <p>{content}</p>
2073
+ * </body>
2074
+ * </html>
2075
+ * )
2076
+ * })
2077
+ * await next()
2078
+ * })
2079
+ * ```
2080
+ */
2057
2081
  setRenderer = (renderer) => {
2058
2082
  this.#renderer = renderer;
2059
2083
  };
2060
2084
  /**
2061
- * `.header()` can set headers.
2062
- *
2063
- * @see {@link https://hono.dev/docs/api/context#header}
2064
- *
2065
- * @example
2066
- * ```ts
2067
- * app.get('/welcome', (c) => {
2068
- * // Set headers
2069
- * c.header('X-Message', 'Hello!')
2070
- * c.header('Content-Type', 'text/plain')
2071
- *
2072
- * return c.body('Thank you for coming')
2073
- * })
2074
- * ```
2075
- */
2085
+ * `.header()` can set headers.
2086
+ *
2087
+ * @see {@link https://hono.dev/docs/api/context#header}
2088
+ *
2089
+ * @example
2090
+ * ```ts
2091
+ * app.get('/welcome', (c) => {
2092
+ * // Set headers
2093
+ * c.header('X-Message', 'Hello!')
2094
+ * c.header('Content-Type', 'text/plain')
2095
+ *
2096
+ * // Append multiple headers using the append option (e.g. Vary)
2097
+ * c.header('Vary', 'Accept-Encoding', { append: true })
2098
+ * c.header('Vary', 'User-Agent', { append: true })
2099
+ *
2100
+ * return c.body('Thank you for coming')
2101
+ * })
2102
+ * ```
2103
+ */
2076
2104
  header = (name, value, options) => {
2077
- if (this.finalized) {
2078
- this.#res = createResponseInstance(this.#res.body, this.#res);
2079
- }
2105
+ if (this.finalized) this.#res = createResponseInstance(this.#res.body, this.#res);
2080
2106
  const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
2081
- if (value === void 0) {
2082
- headers.delete(name);
2083
- } else if (options?.append) {
2084
- headers.append(name, value);
2085
- } else {
2086
- headers.set(name, value);
2087
- }
2107
+ if (value === void 0) headers.delete(name);
2108
+ else if (options?.append) headers.append(name, value);
2109
+ else headers.set(name, value);
2088
2110
  };
2089
2111
  status = (status) => {
2090
2112
  this.#status = status;
2091
2113
  };
2092
2114
  /**
2093
- * `.set()` can set the value specified by the key.
2094
- *
2095
- * @see {@link https://hono.dev/docs/api/context#set-get}
2096
- *
2097
- * @example
2098
- * ```ts
2099
- * app.use('*', async (c, next) => {
2100
- * c.set('message', 'Hono is hot!!')
2101
- * await next()
2102
- * })
2103
- * ```
2104
- */
2115
+ * `.set()` can set the value specified by the key.
2116
+ *
2117
+ * @see {@link https://hono.dev/docs/api/context#set-get}
2118
+ *
2119
+ * @example
2120
+ * ```ts
2121
+ * app.use('*', async (c, next) => {
2122
+ * c.set('message', 'Hono is hot!!')
2123
+ * await next()
2124
+ * })
2125
+ * ```
2126
+ */
2105
2127
  set = (key, value) => {
2106
2128
  this.#var ??= /* @__PURE__ */ new Map();
2107
2129
  this.#var.set(key, value);
2108
2130
  };
2109
2131
  /**
2110
- * `.get()` can use the value specified by the key.
2111
- *
2112
- * @see {@link https://hono.dev/docs/api/context#set-get}
2113
- *
2114
- * @example
2115
- * ```ts
2116
- * app.get('/', (c) => {
2117
- * const message = c.get('message')
2118
- * return c.text(`The message is "${message}"`)
2119
- * })
2120
- * ```
2121
- */
2132
+ * `.get()` can use the value specified by the key.
2133
+ *
2134
+ * @see {@link https://hono.dev/docs/api/context#set-get}
2135
+ *
2136
+ * @example
2137
+ * ```ts
2138
+ * app.get('/', (c) => {
2139
+ * const message = c.get('message')
2140
+ * return c.text(`The message is "${message}"`)
2141
+ * })
2142
+ * ```
2143
+ */
2122
2144
  get = (key) => {
2123
2145
  return this.#var ? this.#var.get(key) : void 0;
2124
2146
  };
2125
2147
  /**
2126
- * `.var` can access the value of a variable.
2127
- *
2128
- * @see {@link https://hono.dev/docs/api/context#var}
2129
- *
2130
- * @example
2131
- * ```ts
2132
- * const result = c.var.client.oneMethod()
2133
- * ```
2134
- */
2135
- // c.var.propName is a read-only
2148
+ * `.var` can access the value of a variable.
2149
+ *
2150
+ * @see {@link https://hono.dev/docs/api/context#var}
2151
+ *
2152
+ * @example
2153
+ * ```ts
2154
+ * const result = c.var.client.oneMethod()
2155
+ * ```
2156
+ */
2136
2157
  get var() {
2137
- if (!this.#var) {
2138
- return {};
2139
- }
2158
+ if (!this.#var) return {};
2140
2159
  return Object.fromEntries(this.#var);
2141
2160
  }
2142
2161
  #newResponse(data, arg, headers) {
2143
- const responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders ?? new Headers();
2144
- if (typeof arg === "object" && "headers" in arg) {
2145
- const argHeaders = arg.headers instanceof Headers ? arg.headers : new Headers(arg.headers);
2146
- for (const [key, value] of argHeaders) {
2147
- if (key.toLowerCase() === "set-cookie") {
2148
- responseHeaders.append(key, value);
2149
- } else {
2150
- responseHeaders.set(key, value);
2151
- }
2152
- }
2162
+ let responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders;
2163
+ if (typeof arg === "object" && arg.headers) {
2164
+ responseHeaders ??= new Headers();
2165
+ for (const [key, value] of new Headers(arg.headers)) if (key === "set-cookie") responseHeaders.append(key, value);
2166
+ else responseHeaders.set(key, value);
2153
2167
  }
2154
2168
  if (headers) {
2155
- for (const [k, v] of Object.entries(headers)) {
2156
- if (typeof v === "string") {
2157
- responseHeaders.set(k, v);
2158
- } else {
2169
+ if (!responseHeaders) {
2170
+ let count = 0;
2171
+ for (const k in headers) if (++count > 1 || typeof headers[k] !== "string") {
2172
+ responseHeaders = new Headers();
2173
+ break;
2174
+ }
2175
+ }
2176
+ if (responseHeaders) for (const k in headers) {
2177
+ const v = headers[k];
2178
+ if (typeof v === "string") responseHeaders.set(k, v);
2179
+ else {
2159
2180
  responseHeaders.delete(k);
2160
- for (const v2 of v) {
2161
- responseHeaders.append(k, v2);
2162
- }
2181
+ for (const v2 of v) responseHeaders.append(k, v2);
2163
2182
  }
2164
2183
  }
2165
2184
  }
2166
2185
  const status = typeof arg === "number" ? arg : arg?.status ?? this.#status;
2167
- return createResponseInstance(data, { status, headers: responseHeaders });
2186
+ return createResponseInstance(data, {
2187
+ status,
2188
+ headers: responseHeaders ?? headers
2189
+ });
2168
2190
  }
2169
2191
  newResponse = (...args) => this.#newResponse(...args);
2170
2192
  /**
2171
- * `.body()` can return the HTTP response.
2172
- * You can set headers with `.header()` and set HTTP status code with `.status`.
2173
- * This can also be set in `.text()`, `.json()` and so on.
2174
- *
2175
- * @see {@link https://hono.dev/docs/api/context#body}
2176
- *
2177
- * @example
2178
- * ```ts
2179
- * app.get('/welcome', (c) => {
2180
- * // Set headers
2181
- * c.header('X-Message', 'Hello!')
2182
- * c.header('Content-Type', 'text/plain')
2183
- * // Set HTTP status code
2184
- * c.status(201)
2185
- *
2186
- * // Return the response body
2187
- * return c.body('Thank you for coming')
2188
- * })
2189
- * ```
2190
- */
2193
+ * `.body()` can return the HTTP response.
2194
+ * You can set headers with `.header()` and set HTTP status code with `.status`.
2195
+ * This can also be set in `.text()`, `.json()` and so on.
2196
+ *
2197
+ * @see {@link https://hono.dev/docs/api/context#body}
2198
+ *
2199
+ * @example
2200
+ * ```ts
2201
+ * app.get('/welcome', (c) => {
2202
+ * // Set headers
2203
+ * c.header('X-Message', 'Hello!')
2204
+ * c.header('Content-Type', 'text/plain')
2205
+ * // Set HTTP status code
2206
+ * c.status(201)
2207
+ *
2208
+ * // Return the response body
2209
+ * return c.body('Thank you for coming')
2210
+ * })
2211
+ * ```
2212
+ */
2191
2213
  body = (data, arg, headers) => this.#newResponse(data, arg, headers);
2192
2214
  /**
2193
- * `.text()` can render text as `Content-Type:text/plain`.
2194
- *
2195
- * @see {@link https://hono.dev/docs/api/context#text}
2196
- *
2197
- * @example
2198
- * ```ts
2199
- * app.get('/say', (c) => {
2200
- * return c.text('Hello!')
2201
- * })
2202
- * ```
2203
- */
2215
+ * `.text()` can render text as `Content-Type:text/plain`.
2216
+ *
2217
+ * @see {@link https://hono.dev/docs/api/context#text}
2218
+ *
2219
+ * @example
2220
+ * ```ts
2221
+ * app.get('/say', (c) => {
2222
+ * return c.text('Hello!')
2223
+ * })
2224
+ * ```
2225
+ */
2204
2226
  text = (text2, arg, headers) => {
2205
- return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text2) : this.#newResponse(
2206
- text2,
2207
- arg,
2208
- setDefaultContentType(TEXT_PLAIN, headers)
2209
- );
2227
+ return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text2) : this.#newResponse(text2, arg, setDefaultContentType(TEXT_PLAIN, headers));
2210
2228
  };
2211
2229
  /**
2212
- * `.json()` can render JSON as `Content-Type:application/json`.
2213
- *
2214
- * @see {@link https://hono.dev/docs/api/context#json}
2215
- *
2216
- * @example
2217
- * ```ts
2218
- * app.get('/api', (c) => {
2219
- * return c.json({ message: 'Hello!' })
2220
- * })
2221
- * ```
2222
- */
2230
+ * `.json()` can render JSON as `Content-Type:application/json`.
2231
+ *
2232
+ * @see {@link https://hono.dev/docs/api/context#json}
2233
+ *
2234
+ * @example
2235
+ * ```ts
2236
+ * app.get('/api', (c) => {
2237
+ * return c.json({ message: 'Hello!' })
2238
+ * })
2239
+ * ```
2240
+ */
2223
2241
  json = (object, arg, headers) => {
2224
- return this.#newResponse(
2225
- JSON.stringify(object),
2226
- arg,
2227
- setDefaultContentType("application/json", headers)
2228
- );
2242
+ return this.#newResponse(JSON.stringify(object), arg, setDefaultContentType("application/json", headers));
2229
2243
  };
2230
2244
  html = (html, arg, headers) => {
2231
2245
  const res = (html2) => this.#newResponse(html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
2232
2246
  return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
2233
2247
  };
2234
2248
  /**
2235
- * `.redirect()` can Redirect, default status code is 302.
2236
- *
2237
- * @see {@link https://hono.dev/docs/api/context#redirect}
2238
- *
2239
- * @example
2240
- * ```ts
2241
- * app.get('/redirect', (c) => {
2242
- * return c.redirect('/')
2243
- * })
2244
- * app.get('/redirect-permanently', (c) => {
2245
- * return c.redirect('/', 301)
2246
- * })
2247
- * ```
2248
- */
2249
+ * `.redirect()` can Redirect, default status code is 302.
2250
+ *
2251
+ * @see {@link https://hono.dev/docs/api/context#redirect}
2252
+ *
2253
+ * @example
2254
+ * ```ts
2255
+ * app.get('/redirect', (c) => {
2256
+ * return c.redirect('/')
2257
+ * })
2258
+ * app.get('/redirect-permanently', (c) => {
2259
+ * return c.redirect('/', 301)
2260
+ * })
2261
+ * ```
2262
+ */
2249
2263
  redirect = (location, status) => {
2250
2264
  const locationString = String(location);
2251
- this.header(
2252
- "Location",
2253
- // Multibyes should be encoded
2254
- // eslint-disable-next-line no-control-regex
2255
- !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
2256
- );
2265
+ this.header("Location", !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString));
2257
2266
  return this.newResponse(null, status ?? 302);
2258
2267
  };
2259
2268
  /**
2260
- * `.notFound()` can return the Not Found Response.
2261
- *
2262
- * @see {@link https://hono.dev/docs/api/context#notfound}
2263
- *
2264
- * @example
2265
- * ```ts
2266
- * app.get('/notfound', (c) => {
2267
- * return c.notFound()
2268
- * })
2269
- * ```
2270
- */
2269
+ * `.notFound()` can return the Not Found Response.
2270
+ *
2271
+ * @see {@link https://hono.dev/docs/api/context#notfound}
2272
+ *
2273
+ * @example
2274
+ * ```ts
2275
+ * app.get('/notfound', (c) => {
2276
+ * return c.notFound()
2277
+ * })
2278
+ * ```
2279
+ */
2271
2280
  notFound = () => {
2272
2281
  this.#notFoundHandler ??= () => createResponseInstance();
2273
2282
  return this.#notFoundHandler(this);
2274
2283
  };
2275
2284
  };
2276
2285
 
2277
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/router.js
2278
- var METHOD_NAME_ALL = "ALL";
2279
- var METHOD_NAME_ALL_LOWERCASE = "all";
2280
- var METHODS = ["get", "post", "put", "delete", "options", "patch"];
2286
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/compose.js
2287
+ var compose = (middleware, onError, onNotFound) => {
2288
+ return (context, next) => {
2289
+ let index = -1;
2290
+ return dispatch(0);
2291
+ async function dispatch(i) {
2292
+ if (i <= index) throw new Error("next() called multiple times");
2293
+ index = i;
2294
+ let res;
2295
+ let isError = false;
2296
+ let handler;
2297
+ if (middleware[i]) {
2298
+ handler = middleware[i][0][0];
2299
+ context.req.routeIndex = i;
2300
+ } else handler = i === middleware.length && next || void 0;
2301
+ if (handler) try {
2302
+ res = await handler(context, () => dispatch(i + 1));
2303
+ } catch (err) {
2304
+ if (err instanceof Error && onError) {
2305
+ context.error = err;
2306
+ res = await onError(err, context);
2307
+ isError = true;
2308
+ } else throw err;
2309
+ }
2310
+ else if (context.finalized === false && onNotFound) res = await onNotFound(context);
2311
+ if (res && (context.finalized === false || isError)) context.res = res;
2312
+ return context;
2313
+ }
2314
+ };
2315
+ };
2316
+
2317
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router.js
2318
+ var METHODS = [
2319
+ "get",
2320
+ "post",
2321
+ "put",
2322
+ "delete",
2323
+ "options",
2324
+ "patch",
2325
+ "query"
2326
+ ];
2281
2327
  var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
2282
2328
  var UnsupportedPathError = class extends Error {
2283
2329
  };
2284
2330
 
2285
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/utils/constants.js
2331
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/utils/constants.js
2286
2332
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
2287
2333
 
2288
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/hono-base.js
2334
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/hono-base.js
2289
2335
  var notFoundHandler = (c) => {
2290
2336
  return c.text("404 Not Found", 404);
2291
2337
  };
@@ -2297,37 +2343,30 @@ var errorHandler = (err, c) => {
2297
2343
  console.error(err);
2298
2344
  return c.text("Internal Server Error", 500);
2299
2345
  };
2300
- var Hono = class _Hono {
2346
+ var Hono = class Hono2 {
2301
2347
  get;
2302
2348
  post;
2303
2349
  put;
2304
2350
  delete;
2305
2351
  options;
2306
2352
  patch;
2353
+ query;
2307
2354
  all;
2308
2355
  on;
2309
2356
  use;
2310
- /*
2311
- This class is like an abstract class and does not have a router.
2312
- To use it, inherit the class and implement router in the constructor.
2313
- */
2314
2357
  router;
2315
2358
  getPath;
2316
- // Cannot use `#` because it requires visibility at JavaScript runtime.
2317
2359
  _basePath = "/";
2318
2360
  #path = "/";
2319
2361
  routes = [];
2320
2362
  constructor(options = {}) {
2321
- const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
2322
- allMethods.forEach((method) => {
2363
+ [...METHODS, "all"].forEach((method) => {
2323
2364
  this[method] = (args1, ...args) => {
2324
- if (typeof args1 === "string") {
2325
- this.#path = args1;
2326
- } else {
2327
- this.#addRoute(method, this.#path, args1);
2328
- }
2365
+ const methodName = method.toUpperCase();
2366
+ if (typeof args1 === "string") this.#path = args1;
2367
+ else this.#addRoute(methodName, this.#path, args1);
2329
2368
  args.forEach((handler) => {
2330
- this.#addRoute(method, this.#path, handler);
2369
+ this.#addRoute(methodName, this.#path, handler);
2331
2370
  });
2332
2371
  return this;
2333
2372
  };
@@ -2336,22 +2375,20 @@ var Hono = class _Hono {
2336
2375
  for (const p of [path].flat()) {
2337
2376
  this.#path = p;
2338
2377
  for (const m of [method].flat()) {
2339
- handlers.map((handler) => {
2340
- this.#addRoute(m.toUpperCase(), this.#path, handler);
2341
- });
2378
+ const methodName = m.toUpperCase();
2379
+ for (const handler of handlers) this.#addRoute(methodName, this.#path, handler);
2342
2380
  }
2343
2381
  }
2344
2382
  return this;
2345
2383
  };
2346
2384
  this.use = (arg1, ...handlers) => {
2347
- if (typeof arg1 === "string") {
2348
- this.#path = arg1;
2349
- } else {
2385
+ if (typeof arg1 === "string") this.#path = arg1;
2386
+ else {
2350
2387
  this.#path = "*";
2351
2388
  handlers.unshift(arg1);
2352
2389
  }
2353
2390
  handlers.forEach((handler) => {
2354
- this.#addRoute(METHOD_NAME_ALL, this.#path, handler);
2391
+ this.#addRoute("ALL", this.#path, handler);
2355
2392
  });
2356
2393
  return this;
2357
2394
  };
@@ -2360,7 +2397,7 @@ var Hono = class _Hono {
2360
2397
  this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict;
2361
2398
  }
2362
2399
  #clone() {
2363
- const clone = new _Hono({
2400
+ const clone = new Hono2({
2364
2401
  router: this.router,
2365
2402
  getPath: this.getPath
2366
2403
  });
@@ -2370,33 +2407,31 @@ var Hono = class _Hono {
2370
2407
  return clone;
2371
2408
  }
2372
2409
  #notFoundHandler = notFoundHandler;
2373
- // Cannot use `#` because it requires visibility at JavaScript runtime.
2374
2410
  errorHandler = errorHandler;
2375
2411
  /**
2376
- * `.route()` allows grouping other Hono instance in routes.
2377
- *
2378
- * @see {@link https://hono.dev/docs/api/routing#grouping}
2379
- *
2380
- * @param {string} path - base Path
2381
- * @param {Hono} app - other Hono instance
2382
- * @returns {Hono} routed Hono instance
2383
- *
2384
- * @example
2385
- * ```ts
2386
- * const app = new Hono()
2387
- * const app2 = new Hono()
2388
- *
2389
- * app2.get("/user", (c) => c.text("user"))
2390
- * app.route("/api", app2) // GET /api/user
2391
- * ```
2392
- */
2412
+ * `.route()` allows grouping other Hono instance in routes.
2413
+ *
2414
+ * @see {@link https://hono.dev/docs/api/routing#grouping}
2415
+ *
2416
+ * @param {string} path - base Path
2417
+ * @param {Hono} app - other Hono instance
2418
+ * @returns {Hono} routed Hono instance
2419
+ *
2420
+ * @example
2421
+ * ```ts
2422
+ * const app = new Hono()
2423
+ * const app2 = new Hono()
2424
+ *
2425
+ * app2.get("/user", (c) => c.text("user"))
2426
+ * app.route("/api", app2) // GET /api/user
2427
+ * ```
2428
+ */
2393
2429
  route(path, app) {
2394
2430
  const subApp = this.basePath(path);
2395
2431
  app.routes.map((r) => {
2396
2432
  let handler;
2397
- if (app.errorHandler === errorHandler) {
2398
- handler = r.handler;
2399
- } else {
2433
+ if (app.errorHandler === errorHandler) handler = r.handler;
2434
+ else {
2400
2435
  handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
2401
2436
  handler[COMPOSED_HANDLER] = r.handler;
2402
2437
  }
@@ -2405,107 +2440,105 @@ var Hono = class _Hono {
2405
2440
  return this;
2406
2441
  }
2407
2442
  /**
2408
- * `.basePath()` allows base paths to be specified.
2409
- *
2410
- * @see {@link https://hono.dev/docs/api/routing#base-path}
2411
- *
2412
- * @param {string} path - base Path
2413
- * @returns {Hono} changed Hono instance
2414
- *
2415
- * @example
2416
- * ```ts
2417
- * const api = new Hono().basePath('/api')
2418
- * ```
2419
- */
2443
+ * `.basePath()` allows base paths to be specified.
2444
+ *
2445
+ * @see {@link https://hono.dev/docs/api/routing#base-path}
2446
+ *
2447
+ * @param {string} path - base Path
2448
+ * @returns {Hono} changed Hono instance
2449
+ *
2450
+ * @example
2451
+ * ```ts
2452
+ * const api = new Hono().basePath('/api')
2453
+ * ```
2454
+ */
2420
2455
  basePath(path) {
2421
2456
  const subApp = this.#clone();
2422
2457
  subApp._basePath = mergePath(this._basePath, path);
2423
2458
  return subApp;
2424
2459
  }
2425
2460
  /**
2426
- * `.onError()` handles an error and returns a customized Response.
2427
- *
2428
- * @see {@link https://hono.dev/docs/api/hono#error-handling}
2429
- *
2430
- * @param {ErrorHandler} handler - request Handler for error
2431
- * @returns {Hono} changed Hono instance
2432
- *
2433
- * @example
2434
- * ```ts
2435
- * app.onError((err, c) => {
2436
- * console.error(`${err}`)
2437
- * return c.text('Custom Error Message', 500)
2438
- * })
2439
- * ```
2440
- */
2461
+ * `.onError()` handles an error and returns a customized Response.
2462
+ *
2463
+ * @see {@link https://hono.dev/docs/api/hono#error-handling}
2464
+ *
2465
+ * @param {ErrorHandler} handler - request Handler for error
2466
+ * @returns {Hono} changed Hono instance
2467
+ *
2468
+ * @example
2469
+ * ```ts
2470
+ * app.onError((err, c) => {
2471
+ * console.error(`${err}`)
2472
+ * return c.text('Custom Error Message', 500)
2473
+ * })
2474
+ * ```
2475
+ */
2441
2476
  onError = (handler) => {
2442
2477
  this.errorHandler = handler;
2443
- return this;
2444
- };
2445
- /**
2446
- * `.notFound()` allows you to customize a Not Found Response.
2447
- *
2448
- * @see {@link https://hono.dev/docs/api/hono#not-found}
2449
- *
2450
- * @param {NotFoundHandler} handler - request handler for not-found
2451
- * @returns {Hono} changed Hono instance
2452
- *
2453
- * @example
2454
- * ```ts
2455
- * app.notFound((c) => {
2456
- * return c.text('Custom 404 Message', 404)
2457
- * })
2458
- * ```
2459
- */
2478
+ return this;
2479
+ };
2480
+ /**
2481
+ * `.notFound()` allows you to customize a Not Found Response.
2482
+ *
2483
+ * @see {@link https://hono.dev/docs/api/hono#not-found}
2484
+ *
2485
+ * @param {NotFoundHandler} handler - request handler for not-found
2486
+ * @returns {Hono} changed Hono instance
2487
+ *
2488
+ * @example
2489
+ * ```ts
2490
+ * app.notFound((c) => {
2491
+ * return c.text('Custom 404 Message', 404)
2492
+ * })
2493
+ * ```
2494
+ */
2460
2495
  notFound = (handler) => {
2461
2496
  this.#notFoundHandler = handler;
2462
2497
  return this;
2463
2498
  };
2464
2499
  /**
2465
- * `.mount()` allows you to mount applications built with other frameworks into your Hono application.
2466
- *
2467
- * @see {@link https://hono.dev/docs/api/hono#mount}
2468
- *
2469
- * @param {string} path - base Path
2470
- * @param {Function} applicationHandler - other Request Handler
2471
- * @param {MountOptions} [options] - options of `.mount()`
2472
- * @returns {Hono} mounted Hono instance
2473
- *
2474
- * @example
2475
- * ```ts
2476
- * import { Router as IttyRouter } from 'itty-router'
2477
- * import { Hono } from 'hono'
2478
- * // Create itty-router application
2479
- * const ittyRouter = IttyRouter()
2480
- * // GET /itty-router/hello
2481
- * ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
2482
- *
2483
- * const app = new Hono()
2484
- * app.mount('/itty-router', ittyRouter.handle)
2485
- * ```
2486
- *
2487
- * @example
2488
- * ```ts
2489
- * const app = new Hono()
2490
- * // Send the request to another application without modification.
2491
- * app.mount('/app', anotherApp, {
2492
- * replaceRequest: (req) => req,
2493
- * })
2494
- * ```
2495
- */
2500
+ * `.mount()` allows you to mount applications built with other frameworks into your Hono application.
2501
+ *
2502
+ * @deprecated Use `mount()` from `hono/mount` instead. `.mount()` will be removed in v5.
2503
+ *
2504
+ * @see {@link https://hono.dev/docs/api/hono#mount}
2505
+ *
2506
+ * @param {string} path - base Path
2507
+ * @param {Function} applicationHandler - other Request Handler
2508
+ * @param {MountOptions} [options] - options of `.mount()`
2509
+ * @returns {Hono} mounted Hono instance
2510
+ *
2511
+ * @example
2512
+ * ```ts
2513
+ * import { Router as IttyRouter } from 'itty-router'
2514
+ * import { Hono } from 'hono'
2515
+ * // Create itty-router application
2516
+ * const ittyRouter = IttyRouter()
2517
+ * // GET /itty-router/hello
2518
+ * ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
2519
+ *
2520
+ * const app = new Hono()
2521
+ * app.mount('/itty-router', ittyRouter.handle)
2522
+ * ```
2523
+ *
2524
+ * @example
2525
+ * ```ts
2526
+ * const app = new Hono()
2527
+ * // Send the request to another application without modification.
2528
+ * app.mount('/app', anotherApp, {
2529
+ * replaceRequest: (req) => req,
2530
+ * })
2531
+ * ```
2532
+ */
2496
2533
  mount(path, applicationHandler, options) {
2497
2534
  let replaceRequest;
2498
2535
  let optionHandler;
2499
2536
  if (options) {
2500
- if (typeof options === "function") {
2501
- optionHandler = options;
2502
- } else {
2537
+ if (typeof options === "function") optionHandler = options;
2538
+ else {
2503
2539
  optionHandler = options.optionHandler;
2504
- if (options.replaceRequest === false) {
2505
- replaceRequest = (request) => request;
2506
- } else {
2507
- replaceRequest = options.replaceRequest;
2508
- }
2540
+ if (options.replaceRequest === false) replaceRequest = (request) => request;
2541
+ else replaceRequest = options.replaceRequest;
2509
2542
  }
2510
2543
  }
2511
2544
  const getOptions = optionHandler ? (c) => {
@@ -2530,16 +2563,13 @@ var Hono = class _Hono {
2530
2563
  })();
2531
2564
  const handler = async (c, next) => {
2532
2565
  const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
2533
- if (res) {
2534
- return res;
2535
- }
2566
+ if (res) return res;
2536
2567
  await next();
2537
2568
  };
2538
- this.#addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
2569
+ this.#addRoute("ALL", mergePath(path, "*"), handler);
2539
2570
  return this;
2540
2571
  }
2541
2572
  #addRoute(method, path, handler, baseRoutePath) {
2542
- method = method.toUpperCase();
2543
2573
  path = mergePath(this._basePath, path);
2544
2574
  const r = {
2545
2575
  basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
@@ -2551,15 +2581,11 @@ var Hono = class _Hono {
2551
2581
  this.routes.push(r);
2552
2582
  }
2553
2583
  #handleError(err, c) {
2554
- if (err instanceof Error) {
2555
- return this.errorHandler(err, c);
2556
- }
2584
+ if (err instanceof Error) return this.errorHandler(err, c);
2557
2585
  throw err;
2558
2586
  }
2559
2587
  #dispatch(request, executionCtx, env, method) {
2560
- if (method === "HEAD") {
2561
- return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
2562
- }
2588
+ if (method === "HEAD") return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
2563
2589
  const path = this.getPath(request, { env });
2564
2590
  const matchResult = this.router.match(method, path);
2565
2591
  const c = new Context(request, {
@@ -2578,19 +2604,13 @@ var Hono = class _Hono {
2578
2604
  } catch (err) {
2579
2605
  return this.#handleError(err, c);
2580
2606
  }
2581
- return res instanceof Promise ? res.then(
2582
- (resolved) => resolved || (c.finalized ? c.res : this.#notFoundHandler(c))
2583
- ).catch((err) => this.#handleError(err, c)) : res ?? this.#notFoundHandler(c);
2607
+ return res instanceof Promise ? res.then((resolved) => resolved || (c.finalized ? c.res : this.#notFoundHandler(c))).catch((err) => this.#handleError(err, c)) : res ?? this.#notFoundHandler(c);
2584
2608
  }
2585
2609
  const composed = compose(matchResult[0], this.errorHandler, this.#notFoundHandler);
2586
2610
  return (async () => {
2587
2611
  try {
2588
2612
  const context = await composed(c);
2589
- if (!context.finalized) {
2590
- throw new Error(
2591
- "Context is not finalized. Did you forget to return a Response object or `await next()`?"
2592
- );
2593
- }
2613
+ if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
2594
2614
  return context.res;
2595
2615
  } catch (err) {
2596
2616
  return this.#handleError(err, c);
@@ -2598,62 +2618,53 @@ var Hono = class _Hono {
2598
2618
  })();
2599
2619
  }
2600
2620
  /**
2601
- * `.fetch()` will be entry point of your app.
2602
- *
2603
- * @see {@link https://hono.dev/docs/api/hono#fetch}
2604
- *
2605
- * @param {Request} request - request Object of request
2606
- * @param {Env} Env - env Object
2607
- * @param {ExecutionContext} - context of execution
2608
- * @returns {Response | Promise<Response>} response of request
2609
- *
2610
- */
2621
+ * `.fetch()` will be entry point of your app.
2622
+ *
2623
+ * @see {@link https://hono.dev/docs/api/hono#fetch}
2624
+ *
2625
+ * @param {Request} request - request Object of request
2626
+ * @param {Env} env - env Object
2627
+ * @param {ExecutionContext} executionCtx - context of execution
2628
+ * @returns {Response | Promise<Response>} response of request
2629
+ *
2630
+ */
2611
2631
  fetch = (request, ...rest) => {
2612
2632
  return this.#dispatch(request, rest[1], rest[0], request.method);
2613
2633
  };
2614
2634
  /**
2615
- * `.request()` is a useful method for testing.
2616
- * You can pass a URL or pathname to send a GET request.
2617
- * app will return a Response object.
2618
- * ```ts
2619
- * test('GET /hello is ok', async () => {
2620
- * const res = await app.request('/hello')
2621
- * expect(res.status).toBe(200)
2622
- * })
2623
- * ```
2624
- * @see https://hono.dev/docs/api/hono#request
2625
- */
2635
+ * `.request()` is a useful method for testing.
2636
+ * You can pass a URL or pathname to send a GET request.
2637
+ * app will return a Response object.
2638
+ * ```ts
2639
+ * test('GET /hello is ok', async () => {
2640
+ * const res = await app.request('/hello')
2641
+ * expect(res.status).toBe(200)
2642
+ * })
2643
+ * ```
2644
+ * @see https://hono.dev/docs/api/hono#request
2645
+ */
2626
2646
  request = (input, requestInit, Env, executionCtx) => {
2627
- if (input instanceof Request) {
2628
- return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
2629
- }
2647
+ if (input instanceof Request) return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
2630
2648
  input = input.toString();
2631
- return this.fetch(
2632
- new Request(
2633
- /^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`,
2634
- requestInit
2635
- ),
2636
- Env,
2637
- executionCtx
2638
- );
2649
+ return this.fetch(new Request(/^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`, requestInit), Env, executionCtx);
2639
2650
  };
2640
2651
  /**
2641
- * `.fire()` automatically adds a global fetch event listener.
2642
- * This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
2643
- * @deprecated
2644
- * Use `fire` from `hono/service-worker` instead.
2645
- * ```ts
2646
- * import { Hono } from 'hono'
2647
- * import { fire } from 'hono/service-worker'
2648
- *
2649
- * const app = new Hono()
2650
- * // ...
2651
- * fire(app)
2652
- * ```
2653
- * @see https://hono.dev/docs/api/hono#fire
2654
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
2655
- * @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
2656
- */
2652
+ * `.fire()` automatically adds a global fetch event listener.
2653
+ * This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
2654
+ * @deprecated
2655
+ * Use `fire` from `hono/service-worker` instead.
2656
+ * ```ts
2657
+ * import { Hono } from 'hono'
2658
+ * import { fire } from 'hono/service-worker'
2659
+ *
2660
+ * const app = new Hono()
2661
+ * // ...
2662
+ * fire(app)
2663
+ * ```
2664
+ * @see https://hono.dev/docs/api/hono#fire
2665
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
2666
+ * @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
2667
+ */
2657
2668
  fire = () => {
2658
2669
  addEventListener("fetch", (event) => {
2659
2670
  event.respondWith(this.#dispatch(event.request, event, void 0, event.request.method));
@@ -2661,173 +2672,150 @@ var Hono = class _Hono {
2661
2672
  };
2662
2673
  };
2663
2674
 
2664
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/router/reg-exp-router/matcher.js
2675
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router/utils.js
2676
+ var createNullObject = () => /* @__PURE__ */ Object.create(null);
2677
+
2678
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router/reg-exp-router/matcher.js
2665
2679
  var emptyParam = [];
2666
2680
  function match(method, path) {
2667
2681
  const matchers = this.buildAllMatchers();
2668
- const match22 = ((method2, path2) => {
2669
- const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
2682
+ const match3 = ((method2, path2) => {
2683
+ const matcher = matchers[method2] || matchers["ALL"];
2670
2684
  const staticMatch = matcher[2][path2];
2671
- if (staticMatch) {
2672
- return staticMatch;
2673
- }
2674
- const match3 = path2.match(matcher[0]);
2675
- if (!match3) {
2676
- return [[], emptyParam];
2677
- }
2678
- const index = match3.indexOf("", 1);
2679
- return [matcher[1][index], match3];
2685
+ if (staticMatch) return staticMatch;
2686
+ const match4 = path2.match(matcher[0]);
2687
+ if (!match4) return [[], emptyParam];
2688
+ const index = match4.indexOf("", 1);
2689
+ return [matcher[1][index], match4];
2680
2690
  });
2681
- this.match = match22;
2682
- return match22(method, path);
2691
+ this.match = match3;
2692
+ return match3(method, path);
2683
2693
  }
2684
2694
 
2685
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/router/reg-exp-router/node.js
2695
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router/reg-exp-router/node.js
2686
2696
  var LABEL_REG_EXP_STR = "[^/]+";
2687
- var ONLY_WILDCARD_REG_EXP_STR = ".*";
2688
2697
  var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
2689
2698
  var PATH_ERROR = /* @__PURE__ */ Symbol();
2690
- var regExpMetaChars = new Set(".\\+*[^]$()");
2699
+ var regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
2691
2700
  function compareKey(a, b) {
2692
- if (a.length === 1) {
2693
- return b.length === 1 ? a < b ? -1 : 1 : -1;
2694
- }
2695
- if (b.length === 1) {
2696
- return 1;
2697
- }
2698
- if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {
2699
- return 1;
2700
- } else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {
2701
- return -1;
2702
- }
2703
- if (a === LABEL_REG_EXP_STR) {
2704
- return 1;
2705
- } else if (b === LABEL_REG_EXP_STR) {
2706
- return -1;
2707
- }
2701
+ if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
2702
+ if (b.length === 1) return 1;
2703
+ if (a === ".*" || a === "(?:|/.*)") return b === "(?:|/.*)" ? -1 : 1;
2704
+ else if (b === ".*" || b === "(?:|/.*)") return -1;
2705
+ if (a === "[^/]+") return 1;
2706
+ else if (b === "[^/]+") return -1;
2708
2707
  return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
2709
2708
  }
2710
- var Node = class _Node {
2709
+ var Node = class Node2 {
2711
2710
  #index;
2712
2711
  #varIndex;
2713
- #children = /* @__PURE__ */ Object.create(null);
2714
- insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
2715
- if (tokens.length === 0) {
2716
- if (this.#index !== void 0) {
2717
- throw PATH_ERROR;
2718
- }
2719
- if (pathErrorCheckOnly) {
2720
- return;
2721
- }
2722
- this.#index = index;
2723
- return;
2724
- }
2725
- const [token, ...restTokens] = tokens;
2726
- const pattern = token === "*" ? restTokens.length === 0 ? ["", "", ONLY_WILDCARD_REG_EXP_STR] : ["", "", LABEL_REG_EXP_STR] : token === "/*" ? ["", "", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
2727
- let node;
2728
- if (pattern) {
2729
- const name = pattern[1];
2730
- let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
2731
- if (name && pattern[2]) {
2732
- if (regexpStr === ".*") {
2733
- throw PATH_ERROR;
2734
- }
2735
- regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
2736
- if (/\((?!\?:)/.test(regexpStr)) {
2737
- throw PATH_ERROR;
2738
- }
2739
- }
2740
- node = this.#children[regexpStr];
2741
- if (!node) {
2742
- if (Object.keys(this.#children).some(
2743
- (k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
2744
- )) {
2745
- throw PATH_ERROR;
2712
+ #children = createNullObject();
2713
+ insert(tokens, index, paramMap, context, isStatic) {
2714
+ let node = this;
2715
+ for (let i = 0, len = tokens.length; i < len; i++) {
2716
+ const token = tokens[i];
2717
+ const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? [
2718
+ "",
2719
+ "",
2720
+ ".*"
2721
+ ] : [
2722
+ "",
2723
+ "",
2724
+ LABEL_REG_EXP_STR
2725
+ ] : null : token === "/*" ? [
2726
+ "",
2727
+ "",
2728
+ TAIL_WILDCARD_REG_EXP_STR
2729
+ ] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
2730
+ let nextNode;
2731
+ if (pattern) {
2732
+ const name = pattern[1];
2733
+ let regexpStr = pattern[2] || "[^/]+";
2734
+ if (name && pattern[2]) {
2735
+ if (regexpStr === ".*") throw PATH_ERROR;
2736
+ regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
2737
+ if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
2738
+ if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
2746
2739
  }
2747
- if (pathErrorCheckOnly) {
2748
- return;
2740
+ nextNode = node.#children[regexpStr];
2741
+ if (!nextNode) {
2742
+ if (regexpStr !== ".*" && regexpStr !== "(?:|/.*)") {
2743
+ for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
2744
+ }
2745
+ nextNode = node.#children[regexpStr] = new Node2();
2749
2746
  }
2750
- node = this.#children[regexpStr] = new _Node();
2751
2747
  if (name !== "") {
2752
- node.#varIndex = context.varIndex++;
2753
- }
2754
- }
2755
- if (!pathErrorCheckOnly && name !== "") {
2756
- paramMap.push([name, node.#varIndex]);
2757
- }
2758
- } else {
2759
- node = this.#children[token];
2760
- if (!node) {
2761
- if (Object.keys(this.#children).some(
2762
- (k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
2763
- )) {
2764
- throw PATH_ERROR;
2748
+ nextNode.#varIndex ??= context.varIndex++;
2749
+ paramMap.push([name, nextNode.#varIndex]);
2765
2750
  }
2766
- if (pathErrorCheckOnly) {
2767
- return;
2751
+ } else {
2752
+ nextNode = node.#children[token];
2753
+ if (!nextNode) {
2754
+ for (const k in node.#children) if (k.length > 1 && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
2755
+ nextNode = node.#children[token] = new Node2();
2768
2756
  }
2769
- node = this.#children[token] = new _Node();
2770
2757
  }
2758
+ node = nextNode;
2771
2759
  }
2772
- node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
2760
+ if (node.#index !== void 0) throw PATH_ERROR;
2761
+ node.#index = isStatic ? -1 : index;
2773
2762
  }
2774
2763
  buildRegExpStr() {
2775
- const childKeys = Object.keys(this.#children).sort(compareKey);
2776
- const strList = childKeys.map((k) => {
2764
+ const strList = Object.keys(this.#children).sort(compareKey).map((k) => {
2777
2765
  const c = this.#children[k];
2778
- return (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
2779
- });
2780
- if (typeof this.#index === "number") {
2781
- strList.unshift(`#${this.#index}`);
2782
- }
2783
- if (strList.length === 0) {
2784
- return "";
2785
- }
2786
- if (strList.length === 1) {
2787
- return strList[0];
2788
- }
2766
+ const childStr = c.buildRegExpStr();
2767
+ return childStr === "" ? "" : (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + childStr;
2768
+ }).filter(Boolean);
2769
+ if (typeof this.#index === "number" && this.#index !== -1) strList.unshift(`#${this.#index}`);
2770
+ if (strList.length === 0) return "";
2771
+ if (strList.length === 1) return strList[0];
2789
2772
  return "(?:" + strList.join("|") + ")";
2790
2773
  }
2791
2774
  };
2792
2775
 
2793
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/router/reg-exp-router/trie.js
2776
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router/reg-exp-router/trie.js
2794
2777
  var Trie = class {
2795
2778
  #context = { varIndex: 0 };
2796
2779
  #root = new Node();
2797
- insert(path, index, pathErrorCheckOnly) {
2780
+ #index = 0;
2781
+ paths = createNullObject();
2782
+ insert(path, isStatic) {
2783
+ if (isStatic) {
2784
+ this.#root.insert(path.split(""), 0, [], this.#context, true);
2785
+ return;
2786
+ }
2798
2787
  const paramAssoc = [];
2799
2788
  const groups = [];
2789
+ let markedPath = path;
2800
2790
  for (let i = 0; ; ) {
2801
2791
  let replaced = false;
2802
- path = path.replace(/\{[^}]+\}/g, (m) => {
2792
+ markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
2803
2793
  const mark = `@\\${i}`;
2804
2794
  groups[i] = [mark, m];
2805
2795
  i++;
2806
2796
  replaced = true;
2807
2797
  return mark;
2808
2798
  });
2809
- if (!replaced) {
2810
- break;
2811
- }
2799
+ if (!replaced) break;
2812
2800
  }
2813
- const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
2801
+ const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
2814
2802
  for (let i = groups.length - 1; i >= 0; i--) {
2815
2803
  const [mark] = groups[i];
2816
- for (let j = tokens.length - 1; j >= 0; j--) {
2817
- if (tokens[j].indexOf(mark) !== -1) {
2818
- tokens[j] = tokens[j].replace(mark, groups[i][1]);
2819
- break;
2820
- }
2804
+ for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
2805
+ tokens[j] = tokens[j].replace(mark, groups[i][1]);
2806
+ break;
2821
2807
  }
2822
2808
  }
2823
- this.#root.insert(tokens, index, paramAssoc, this.#context, pathErrorCheckOnly);
2824
- return paramAssoc;
2809
+ this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
2810
+ this.paths[path] = [this.#index++, paramAssoc];
2825
2811
  }
2826
2812
  buildRegExp() {
2827
2813
  let regexp = this.#root.buildRegExpStr();
2828
- if (regexp === "") {
2829
- return [/^$/, [], []];
2830
- }
2814
+ if (regexp === "") return [
2815
+ /^$/,
2816
+ [],
2817
+ []
2818
+ ];
2831
2819
  let captureIndex = 0;
2832
2820
  const indexReplacementMap = [];
2833
2821
  const paramReplacementMap = [];
@@ -2842,190 +2830,109 @@ var Trie = class {
2842
2830
  }
2843
2831
  return "";
2844
2832
  });
2845
- return [new RegExp(`^${regexp}`), indexReplacementMap, paramReplacementMap];
2833
+ return [
2834
+ new RegExp(`^${regexp}`),
2835
+ indexReplacementMap,
2836
+ paramReplacementMap
2837
+ ];
2846
2838
  }
2847
2839
  };
2848
2840
 
2849
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/router/reg-exp-router/router.js
2850
- var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
2851
- var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
2841
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router/reg-exp-router/router.js
2842
+ var wildcardRegExpCache = createNullObject();
2852
2843
  function buildWildcardRegExp(path) {
2853
- return wildcardRegExpCache[path] ??= new RegExp(
2854
- path === "*" ? "" : `^${path.replace(
2855
- /\/\*$|([.\\+*[^\]$()])/g,
2856
- (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
2857
- )}$`
2858
- );
2859
- }
2860
- function clearWildcardRegExpCache() {
2861
- wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
2862
- }
2863
- function buildMatcherFromPreprocessedRoutes(routes) {
2864
- const trie = new Trie();
2865
- const handlerData = [];
2866
- if (routes.length === 0) {
2867
- return nullMatcher;
2868
- }
2869
- const routesWithStaticPathFlag = routes.map(
2870
- (route) => [!/\*|\/:/.test(route[0]), ...route]
2871
- ).sort(
2872
- ([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length
2873
- );
2874
- const staticMap = /* @__PURE__ */ Object.create(null);
2875
- for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
2876
- const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
2877
- if (pathErrorCheckOnly) {
2878
- staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
2879
- } else {
2880
- j++;
2881
- }
2882
- let paramAssoc;
2883
- try {
2884
- paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
2885
- } catch (e) {
2886
- throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
2887
- }
2888
- if (pathErrorCheckOnly) {
2889
- continue;
2890
- }
2891
- handlerData[j] = handlers.map(([h, paramCount]) => {
2892
- const paramIndexMap = /* @__PURE__ */ Object.create(null);
2893
- paramCount -= 1;
2894
- for (; paramCount >= 0; paramCount--) {
2895
- const [key, value] = paramAssoc[paramCount];
2896
- paramIndexMap[key] = value;
2897
- }
2898
- return [h, paramIndexMap];
2899
- });
2900
- }
2901
- const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
2902
- for (let i = 0, len = handlerData.length; i < len; i++) {
2903
- for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
2904
- const map2 = handlerData[i][j]?.[1];
2905
- if (!map2) {
2906
- continue;
2907
- }
2908
- const keys = Object.keys(map2);
2909
- for (let k = 0, len3 = keys.length; k < len3; k++) {
2910
- map2[keys[k]] = paramReplacementMap[map2[keys[k]]];
2911
- }
2912
- }
2913
- }
2914
- const handlerMap = [];
2915
- for (const i in indexReplacementMap) {
2916
- handlerMap[i] = handlerData[indexReplacementMap[i]];
2917
- }
2918
- return [regexp, handlerMap, staticMap];
2844
+ return wildcardRegExpCache[path] ??= new RegExp(`^${path.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (match3, metaChar) => metaChar ? `\\${metaChar}` : match3 === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match3 === "*" ? ".*" : `/:${LABEL_REG_EXP_STR}`)}$`);
2919
2845
  }
2920
2846
  function findMiddleware(middleware, path) {
2921
- if (!middleware) {
2922
- return void 0;
2923
- }
2924
- for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
2925
- if (buildWildcardRegExp(k).test(path)) {
2926
- return [...middleware[k]];
2927
- }
2928
- }
2929
- return void 0;
2847
+ for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path)) return [...middleware[k]];
2930
2848
  }
2931
2849
  var RegExpRouter = class {
2932
2850
  name = "RegExpRouter";
2933
2851
  #middleware;
2934
2852
  #routes;
2853
+ #tries;
2935
2854
  constructor() {
2936
- this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
2937
- this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
2855
+ this.#middleware = { ["ALL"]: createNullObject() };
2856
+ this.#routes = { ["ALL"]: createNullObject() };
2857
+ this.#tries = { ["ALL"]: new Trie() };
2858
+ }
2859
+ #insertPath(method, path) {
2860
+ try {
2861
+ this.#tries[method].insert(path, !/\*|\/:/.test(path));
2862
+ } catch (e) {
2863
+ throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
2864
+ }
2938
2865
  }
2939
2866
  add(method, path, handler) {
2940
2867
  const middleware = this.#middleware;
2941
2868
  const routes = this.#routes;
2942
- if (!middleware || !routes) {
2943
- throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
2944
- }
2869
+ if (!middleware) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
2945
2870
  if (!middleware[method]) {
2946
- ;
2947
- [middleware, routes].forEach((handlerMap) => {
2948
- handlerMap[method] = /* @__PURE__ */ Object.create(null);
2949
- Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {
2950
- handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
2951
- });
2952
- });
2953
- }
2954
- if (path === "/*") {
2955
- path = "*";
2871
+ this.#tries[method] = new Trie();
2872
+ for (const handlerMap of [middleware, routes]) {
2873
+ handlerMap[method] = createNullObject();
2874
+ for (const p in handlerMap["ALL"]) {
2875
+ handlerMap[method][p] = [...handlerMap["ALL"][p]];
2876
+ this.#insertPath(method, p);
2877
+ }
2878
+ }
2956
2879
  }
2957
- const paramCount = (path.match(/\/:/g) || []).length;
2880
+ if (path === "/*") path = "*";
2881
+ const methods = method === "ALL" ? Object.keys(middleware) : [method];
2958
2882
  if (/\*$/.test(path)) {
2959
2883
  const re = buildWildcardRegExp(path);
2960
- if (method === METHOD_NAME_ALL) {
2961
- Object.keys(middleware).forEach((m) => {
2962
- middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
2963
- });
2964
- } else {
2965
- middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
2884
+ for (const m of methods) if (!middleware[m][path]) {
2885
+ this.#insertPath(m, path);
2886
+ middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
2966
2887
  }
2967
- Object.keys(middleware).forEach((m) => {
2968
- if (method === METHOD_NAME_ALL || method === m) {
2969
- Object.keys(middleware[m]).forEach((p) => {
2970
- re.test(p) && middleware[m][p].push([handler, paramCount]);
2971
- });
2972
- }
2973
- });
2974
- Object.keys(routes).forEach((m) => {
2975
- if (method === METHOD_NAME_ALL || method === m) {
2976
- Object.keys(routes[m]).forEach(
2977
- (p) => re.test(p) && routes[m][p].push([handler, paramCount])
2978
- );
2979
- }
2980
- });
2888
+ 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]);
2981
2889
  return;
2982
2890
  }
2983
2891
  const paths = checkOptionalParameter(path) || [path];
2984
- for (let i = 0, len = paths.length; i < len; i++) {
2985
- const path2 = paths[i];
2986
- Object.keys(routes).forEach((m) => {
2987
- if (method === METHOD_NAME_ALL || method === m) {
2988
- routes[m][path2] ||= [
2989
- ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
2990
- ];
2991
- routes[m][path2].push([handler, paramCount - len + i + 1]);
2992
- }
2993
- });
2892
+ for (const path2 of paths) for (const m of methods) {
2893
+ if (!routes[m][path2]) {
2894
+ this.#insertPath(m, path2);
2895
+ routes[m][path2] = findMiddleware(middleware[m], path2) || findMiddleware(middleware["ALL"], path2) || [];
2896
+ }
2897
+ routes[m][path2].push([handler, path2]);
2994
2898
  }
2995
2899
  }
2996
2900
  match = match;
2997
2901
  buildAllMatchers() {
2998
- const matchers = /* @__PURE__ */ Object.create(null);
2999
- Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach((method) => {
3000
- matchers[method] ||= this.#buildMatcher(method);
3001
- });
3002
- this.#middleware = this.#routes = void 0;
3003
- clearWildcardRegExpCache();
2902
+ const matchers = createNullObject();
2903
+ for (const method of Object.keys(this.#routes)) matchers[method] = this.#buildMatcher(method);
2904
+ this.#middleware = this.#routes = this.#tries = void 0;
2905
+ wildcardRegExpCache = createNullObject();
3004
2906
  return matchers;
3005
2907
  }
3006
2908
  #buildMatcher(method) {
3007
- const routes = [];
3008
- let hasOwnRoute = method === METHOD_NAME_ALL;
3009
- [this.#middleware, this.#routes].forEach((r) => {
3010
- const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : [];
3011
- if (ownRoute.length !== 0) {
3012
- hasOwnRoute ||= true;
3013
- routes.push(...ownRoute);
3014
- } else if (method !== METHOD_NAME_ALL) {
3015
- routes.push(
3016
- ...Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]])
3017
- );
2909
+ const middleware = this.#middleware[method];
2910
+ const routes = this.#routes[method];
2911
+ const trie = this.#tries[method];
2912
+ const staticMap = createNullObject();
2913
+ const handlerData = [];
2914
+ const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
2915
+ for (const r of [middleware, routes]) for (const path in r) {
2916
+ const handlers = r[path];
2917
+ const pathData = trie.paths[path];
2918
+ if (!pathData) {
2919
+ staticMap[path] = [handlers.map(([h]) => [h, createNullObject()]), emptyParam];
2920
+ continue;
3018
2921
  }
3019
- });
3020
- if (!hasOwnRoute) {
3021
- return null;
3022
- } else {
3023
- return buildMatcherFromPreprocessedRoutes(routes);
2922
+ handlerData[pathData[0]] = handlers.map(([h, handlerPath]) => [h, trie.paths[handlerPath][1].reduceRight((map2, [key], i) => {
2923
+ map2[key] = paramReplacementMap[pathData[1][i][1]];
2924
+ return map2;
2925
+ }, createNullObject())]);
3024
2926
  }
2927
+ return [
2928
+ regexp,
2929
+ indexReplacementMap.map((i) => handlerData[i]),
2930
+ staticMap
2931
+ ];
3025
2932
  }
3026
2933
  };
3027
2934
 
3028
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/router/smart-router/router.js
2935
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router/smart-router/router.js
3029
2936
  var SmartRouter = class {
3030
2937
  name = "SmartRouter";
3031
2938
  #routers = [];
@@ -3034,15 +2941,15 @@ var SmartRouter = class {
3034
2941
  this.#routers = init.routers;
3035
2942
  }
3036
2943
  add(method, path, handler) {
3037
- if (!this.#routes) {
3038
- throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
3039
- }
3040
- this.#routes.push([method, path, handler]);
2944
+ if (!this.#routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
2945
+ this.#routes.push([
2946
+ method,
2947
+ path,
2948
+ handler
2949
+ ]);
3041
2950
  }
3042
2951
  match(method, path) {
3043
- if (!this.#routes) {
3044
- throw new Error("Fatal error");
3045
- }
2952
+ if (!this.#routes) throw new Error("Fatal error");
3046
2953
  const routers = this.#routers;
3047
2954
  const routes = this.#routes;
3048
2955
  const len = routers.length;
@@ -3051,14 +2958,10 @@ var SmartRouter = class {
3051
2958
  for (; i < len; i++) {
3052
2959
  const router = routers[i];
3053
2960
  try {
3054
- for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
3055
- router.add(...routes[i2]);
3056
- }
2961
+ for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) router.add(...routes[i2]);
3057
2962
  res = router.match(method, path);
3058
2963
  } catch (e) {
3059
- if (e instanceof UnsupportedPathError) {
3060
- continue;
3061
- }
2964
+ if (e instanceof UnsupportedPathError) continue;
3062
2965
  throw e;
3063
2966
  }
3064
2967
  this.match = router.match.bind(router);
@@ -3066,92 +2969,59 @@ var SmartRouter = class {
3066
2969
  this.#routes = void 0;
3067
2970
  break;
3068
2971
  }
3069
- if (i === len) {
3070
- throw new Error("Fatal error");
3071
- }
2972
+ if (i === len) throw new Error("Fatal error");
3072
2973
  this.name = `SmartRouter + ${this.activeRouter.name}`;
3073
2974
  return res;
3074
2975
  }
3075
2976
  get activeRouter() {
3076
- if (this.#routes || this.#routers.length !== 1) {
3077
- throw new Error("No active router has been determined yet.");
3078
- }
2977
+ if (this.#routes || this.#routers.length !== 1) throw new Error("No active router has been determined yet.");
3079
2978
  return this.#routers[0];
3080
2979
  }
3081
2980
  };
3082
2981
 
3083
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/router/trie-router/node.js
3084
- var emptyParams = /* @__PURE__ */ Object.create(null);
3085
- var hasChildren = (children) => {
3086
- for (const _ in children) {
3087
- return true;
3088
- }
3089
- return false;
3090
- };
3091
- var Node2 = class _Node2 {
3092
- #methods;
3093
- #children;
3094
- #patterns;
3095
- #order = 0;
2982
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router/trie-router/node.js
2983
+ var emptyParams = createNullObject();
2984
+ var order = 0;
2985
+ var Node3 = class Node4 {
2986
+ #methods = [];
2987
+ #children = createNullObject();
2988
+ #patterns = [];
2989
+ #pattern;
3096
2990
  #params = emptyParams;
3097
- constructor(method, handler, children) {
3098
- this.#children = children || /* @__PURE__ */ Object.create(null);
3099
- this.#methods = [];
3100
- if (method && handler) {
3101
- const m = /* @__PURE__ */ Object.create(null);
3102
- m[method] = { handler, possibleKeys: [], score: 0 };
3103
- this.#methods = [m];
3104
- }
3105
- this.#patterns = [];
3106
- }
3107
2991
  insert(method, path, handler) {
3108
- this.#order = ++this.#order;
3109
2992
  let curNode = this;
3110
2993
  const parts = splitRoutingPath(path);
3111
- const possibleKeys = [];
3112
- for (let i = 0, len = parts.length; i < len; i++) {
3113
- const p = parts[i];
3114
- const nextP = parts[i + 1];
3115
- const pattern = getPattern(p, nextP);
3116
- const key = Array.isArray(pattern) ? pattern[0] : p;
3117
- if (key in curNode.#children) {
3118
- curNode = curNode.#children[key];
3119
- if (pattern) {
3120
- possibleKeys.push(pattern[1]);
3121
- }
3122
- continue;
3123
- }
3124
- curNode.#children[key] = new _Node2();
3125
- if (pattern) {
3126
- curNode.#patterns.push(pattern);
3127
- possibleKeys.push(pattern[1]);
3128
- }
3129
- curNode = curNode.#children[key];
3130
- }
3131
- curNode.#methods.push({
3132
- [method]: {
3133
- handler,
3134
- possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
3135
- score: this.#order
3136
- }
3137
- });
3138
- return curNode;
2994
+ const possibleKeys = /* @__PURE__ */ new Set();
2995
+ let i = 0;
2996
+ for (const p of parts) {
2997
+ const nextP = parts[++i];
2998
+ const pattern = getPattern(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
2999
+ const isParam = Array.isArray(pattern);
3000
+ const key = isParam ? pattern[0] : pattern || p;
3001
+ const child = curNode.#children[key] ||= new Node4();
3002
+ if (pattern && !child.#pattern) {
3003
+ child.#pattern = pattern;
3004
+ curNode.#patterns.push(child);
3005
+ }
3006
+ curNode = child;
3007
+ if (isParam) possibleKeys.add(pattern[1]);
3008
+ }
3009
+ curNode.#methods.push({ [method]: {
3010
+ handler,
3011
+ possibleKeys: [...possibleKeys],
3012
+ score: ++order
3013
+ } });
3139
3014
  }
3140
3015
  #pushHandlerSets(handlerSets, node, method, nodeParams, params) {
3141
3016
  for (let i = 0, len = node.#methods.length; i < len; i++) {
3142
3017
  const m = node.#methods[i];
3143
- const handlerSet = m[method] || m[METHOD_NAME_ALL];
3144
- const processedSet = {};
3145
- if (handlerSet !== void 0) {
3146
- handlerSet.params = /* @__PURE__ */ Object.create(null);
3018
+ const handlerSet = m[method] || m["ALL"];
3019
+ if (handlerSet) {
3020
+ handlerSet.params = createNullObject();
3147
3021
  handlerSets.push(handlerSet);
3148
- if (nodeParams !== emptyParams || params && params !== emptyParams) {
3149
- for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
3150
- const key = handlerSet.possibleKeys[i2];
3151
- const processed = processedSet[handlerSet.score];
3152
- handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
3153
- processedSet[handlerSet.score] = true;
3154
- }
3022
+ for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
3023
+ const key = handlerSet.possibleKeys[i2];
3024
+ handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
3155
3025
  }
3156
3026
  }
3157
3027
  }
@@ -3159,8 +3029,7 @@ var Node2 = class _Node2 {
3159
3029
  search(method, path) {
3160
3030
  const handlerSets = [];
3161
3031
  this.#params = emptyParams;
3162
- const curNode = this;
3163
- let curNodes = [curNode];
3032
+ let curNodes = [this];
3164
3033
  const parts = splitPath(path);
3165
3034
  const curNodesQueue = [];
3166
3035
  const len = parts.length;
@@ -3175,59 +3044,45 @@ var Node2 = class _Node2 {
3175
3044
  if (nextNode) {
3176
3045
  nextNode.#params = node.#params;
3177
3046
  if (isLast) {
3178
- if (nextNode.#children["*"]) {
3179
- this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node.#params);
3180
- }
3047
+ if (nextNode.#children["*"]) this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node.#params);
3181
3048
  this.#pushHandlerSets(handlerSets, nextNode, method, node.#params);
3182
- } else {
3183
- tempNodes.push(nextNode);
3184
- }
3049
+ } else tempNodes.push(nextNode);
3185
3050
  }
3186
- for (let k = 0, len3 = node.#patterns.length; k < len3; k++) {
3187
- const pattern = node.#patterns[k];
3051
+ for (const child of node.#patterns) {
3052
+ const pattern = child.#pattern;
3188
3053
  const params = node.#params === emptyParams ? {} : { ...node.#params };
3189
- if (pattern === "*") {
3190
- const astNode = node.#children["*"];
3191
- if (astNode) {
3192
- this.#pushHandlerSets(handlerSets, astNode, method, node.#params);
3193
- astNode.#params = params;
3194
- tempNodes.push(astNode);
3054
+ if (typeof pattern === "string") {
3055
+ if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
3056
+ this.#pushHandlerSets(handlerSets, child, method, node.#params);
3057
+ if (pattern === "*") {
3058
+ child.#params = params;
3059
+ tempNodes.push(child);
3060
+ }
3195
3061
  }
3196
3062
  continue;
3197
3063
  }
3198
- const [key, name, matcher] = pattern;
3199
- if (!part && !(matcher instanceof RegExp)) {
3200
- continue;
3201
- }
3202
- const child = node.#children[key];
3203
- if (matcher instanceof RegExp) {
3204
- if (partOffsets === null) {
3205
- partOffsets = new Array(len);
3064
+ const [, name, matcher] = pattern;
3065
+ if (!part && matcher === true) continue;
3066
+ if (matcher !== true) {
3067
+ if (!partOffsets) {
3068
+ partOffsets = [];
3206
3069
  let offset = path[0] === "/" ? 1 : 0;
3207
3070
  for (let p = 0; p < len; p++) {
3208
3071
  partOffsets[p] = offset;
3209
3072
  offset += parts[p].length + 1;
3210
3073
  }
3211
3074
  }
3212
- const restPathString = path.substring(partOffsets[i]);
3075
+ const restPathString = path.slice(partOffsets[i]);
3213
3076
  const m = matcher.exec(restPathString);
3214
3077
  if (m) {
3215
3078
  params[name] = m[0];
3216
3079
  this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
3217
- if (m[0].length === restPathString.length && child.#children["*"]) {
3218
- this.#pushHandlerSets(
3219
- handlerSets,
3220
- child.#children["*"],
3221
- method,
3222
- node.#params,
3223
- params
3224
- );
3225
- }
3226
- if (hasChildren(child.#children)) {
3080
+ if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
3081
+ for (const _ in child.#children) {
3227
3082
  child.#params = params;
3228
- const componentCount = m[0].match(/\//)?.length ?? 0;
3229
- const targetCurNodes = curNodesQueue[componentCount] ||= [];
3230
- targetCurNodes.push(child);
3083
+ const componentCount = m[0].match(/\//g)?.length ?? 0;
3084
+ (curNodesQueue[componentCount] ||= []).push(child);
3085
+ break;
3231
3086
  }
3232
3087
  continue;
3233
3088
  }
@@ -3236,15 +3091,7 @@ var Node2 = class _Node2 {
3236
3091
  params[name] = part;
3237
3092
  if (isLast) {
3238
3093
  this.#pushHandlerSets(handlerSets, child, method, params, node.#params);
3239
- if (child.#children["*"]) {
3240
- this.#pushHandlerSets(
3241
- handlerSets,
3242
- child.#children["*"],
3243
- method,
3244
- params,
3245
- node.#params
3246
- );
3247
- }
3094
+ if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node.#params);
3248
3095
  } else {
3249
3096
  child.#params = params;
3250
3097
  tempNodes.push(child);
@@ -3255,49 +3102,35 @@ var Node2 = class _Node2 {
3255
3102
  const shifted = curNodesQueue.shift();
3256
3103
  curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
3257
3104
  }
3258
- if (handlerSets.length > 1) {
3259
- handlerSets.sort((a, b) => {
3260
- return a.score - b.score;
3261
- });
3262
- }
3105
+ if (handlerSets[1]) handlerSets.sort((a, b) => {
3106
+ return a.score - b.score;
3107
+ });
3263
3108
  return [handlerSets.map(({ handler, params }) => [handler, params])];
3264
3109
  }
3265
3110
  };
3266
3111
 
3267
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/router/trie-router/router.js
3112
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/router/trie-router/router.js
3268
3113
  var TrieRouter = class {
3269
3114
  name = "TrieRouter";
3270
- #node;
3271
- constructor() {
3272
- this.#node = new Node2();
3273
- }
3115
+ #node = new Node3();
3274
3116
  add(method, path, handler) {
3275
- const results = checkOptionalParameter(path);
3276
- if (results) {
3277
- for (let i = 0, len = results.length; i < len; i++) {
3278
- this.#node.insert(method, results[i], handler);
3279
- }
3280
- return;
3281
- }
3282
- this.#node.insert(method, path, handler);
3117
+ for (const result of checkOptionalParameter(path) || [path]) this.#node.insert(method, result, handler);
3283
3118
  }
3284
3119
  match(method, path) {
3285
3120
  return this.#node.search(method, path);
3286
3121
  }
3287
3122
  };
3288
3123
 
3289
- // ../../node_modules/.pnpm/hono@4.12.30/node_modules/hono/dist/hono.js
3290
- var Hono2 = class extends Hono {
3124
+ // ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/hono.js
3125
+ var Hono3 = class extends Hono {
3291
3126
  /**
3292
- * Creates an instance of the Hono class.
3293
- *
3294
- * @param options - Optional configuration options for the Hono instance.
3295
- */
3127
+ * Creates an instance of the Hono class.
3128
+ *
3129
+ * @param options - Optional configuration options for the Hono instance.
3130
+ */
3296
3131
  constructor(options = {}) {
3297
3132
  super(options);
3298
- this.router = options.router ?? new SmartRouter({
3299
- routers: [new RegExpRouter(), new TrieRouter()]
3300
- });
3133
+ this.router = options.router ?? new SmartRouter({ routers: [new RegExpRouter(), new TrieRouter()] });
3301
3134
  }
3302
3135
  };
3303
3136
 
@@ -3438,7 +3271,7 @@ ${body}
3438
3271
 
3439
3272
  // ../web/dist/routes/index.js
3440
3273
  function createIndexRoute(ctx) {
3441
- const app = new Hono2();
3274
+ const app = new Hono3();
3442
3275
  app.get("/", (c) => {
3443
3276
  const q = c.req.query("q")?.trim() ?? "";
3444
3277
  const sourceParam = c.req.query("source");
@@ -3498,7 +3331,7 @@ ${results.length > 0 ? `<ul class="entries">${rows}</ul>` : (() => {
3498
3331
  return app;
3499
3332
  }
3500
3333
 
3501
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/common/utils.mjs
3334
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/common/utils.mjs
3502
3335
  var utils_exports = {};
3503
3336
  __export(utils_exports, {
3504
3337
  arrayReplaceAt: () => arrayReplaceAt,
@@ -3521,7 +3354,7 @@ __export(utils_exports, {
3521
3354
  unescapeMd: () => unescapeMd
3522
3355
  });
3523
3356
 
3524
- // ../../node_modules/.pnpm/mdurl@2.0.0/node_modules/mdurl/index.mjs
3357
+ // ../../node_modules/.pnpm/mdurl@2.1.0/node_modules/mdurl/index.mjs
3525
3358
  var mdurl_exports = {};
3526
3359
  __export(mdurl_exports, {
3527
3360
  decode: () => decode_default,
@@ -3530,7 +3363,7 @@ __export(mdurl_exports, {
3530
3363
  parse: () => parse_default
3531
3364
  });
3532
3365
 
3533
- // ../../node_modules/.pnpm/mdurl@2.0.0/node_modules/mdurl/lib/decode.mjs
3366
+ // ../../node_modules/.pnpm/mdurl@2.1.0/node_modules/mdurl/lib/decode.mjs
3534
3367
  var decodeCache = {};
3535
3368
  function getDecodeCache(exclude) {
3536
3369
  let cache = decodeCache[exclude];
@@ -3613,7 +3446,7 @@ decode.defaultChars = ";/?:@&=+$,#";
3613
3446
  decode.componentChars = "";
3614
3447
  var decode_default = decode;
3615
3448
 
3616
- // ../../node_modules/.pnpm/mdurl@2.0.0/node_modules/mdurl/lib/encode.mjs
3449
+ // ../../node_modules/.pnpm/mdurl@2.1.0/node_modules/mdurl/lib/encode.mjs
3617
3450
  var encodeCache = {};
3618
3451
  function getEncodeCache(exclude) {
3619
3452
  let cache = encodeCache[exclude];
@@ -3677,7 +3510,7 @@ encode.defaultChars = ";/?:@&=+$,-_.!~*'()#";
3677
3510
  encode.componentChars = "-_.!~*'()";
3678
3511
  var encode_default = encode;
3679
3512
 
3680
- // ../../node_modules/.pnpm/mdurl@2.0.0/node_modules/mdurl/lib/format.mjs
3513
+ // ../../node_modules/.pnpm/mdurl@2.1.0/node_modules/mdurl/lib/format.mjs
3681
3514
  function format(url) {
3682
3515
  let result = "";
3683
3516
  result += url.protocol || "";
@@ -3695,7 +3528,7 @@ function format(url) {
3695
3528
  return result;
3696
3529
  }
3697
3530
 
3698
- // ../../node_modules/.pnpm/mdurl@2.0.0/node_modules/mdurl/lib/parse.mjs
3531
+ // ../../node_modules/.pnpm/mdurl@2.1.0/node_modules/mdurl/lib/parse.mjs
3699
3532
  function Url() {
3700
3533
  this.protocol = null;
3701
3534
  this.slashes = null;
@@ -4409,7 +4242,7 @@ var EncodingMode;
4409
4242
  EncodingMode2[EncodingMode2["Text"] = 4] = "Text";
4410
4243
  })(EncodingMode || (EncodingMode = {}));
4411
4244
 
4412
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/common/utils.mjs
4245
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/common/utils.mjs
4413
4246
  function _class(obj) {
4414
4247
  return Object.prototype.toString.call(obj);
4415
4248
  }
@@ -4635,7 +4468,7 @@ function asciiTrim(str) {
4635
4468
  }
4636
4469
  var lib = { mdurl: mdurl_exports, ucmicro: uc_exports };
4637
4470
 
4638
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/helpers/index.mjs
4471
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/helpers/index.mjs
4639
4472
  var helpers_exports = {};
4640
4473
  __export(helpers_exports, {
4641
4474
  parseLinkDestination: () => parseLinkDestination,
@@ -4643,7 +4476,7 @@ __export(helpers_exports, {
4643
4476
  parseLinkTitle: () => parseLinkTitle
4644
4477
  });
4645
4478
 
4646
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/helpers/parse_link_label.mjs
4479
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/helpers/parse_link_label.mjs
4647
4480
  function parseLinkLabel(state, start, disableNested) {
4648
4481
  let level, found, marker, prevPos;
4649
4482
  const max = state.posMax;
@@ -4678,7 +4511,7 @@ function parseLinkLabel(state, start, disableNested) {
4678
4511
  return labelEnd;
4679
4512
  }
4680
4513
 
4681
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs
4514
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs
4682
4515
  function parseLinkDestination(str, start, max) {
4683
4516
  let code2;
4684
4517
  let pos = start;
@@ -4722,7 +4555,8 @@ function parseLinkDestination(str, start, max) {
4722
4555
  }
4723
4556
  if (code2 === 92 && pos + 1 < max) {
4724
4557
  if (str.charCodeAt(pos + 1) === 32) {
4725
- break;
4558
+ pos++;
4559
+ continue;
4726
4560
  }
4727
4561
  pos += 2;
4728
4562
  continue;
@@ -4753,7 +4587,7 @@ function parseLinkDestination(str, start, max) {
4753
4587
  return result;
4754
4588
  }
4755
4589
 
4756
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/helpers/parse_link_title.mjs
4590
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/helpers/parse_link_title.mjs
4757
4591
  function parseLinkTitle(str, start, max, prev_state) {
4758
4592
  let code2;
4759
4593
  let pos = start;
@@ -4806,7 +4640,7 @@ function parseLinkTitle(str, start, max, prev_state) {
4806
4640
  return state;
4807
4641
  }
4808
4642
 
4809
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/renderer.mjs
4643
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/renderer.mjs
4810
4644
  var default_rules = {};
4811
4645
  default_rules.code_inline = function(tokens, idx, options, env, slf) {
4812
4646
  const token = tokens[idx];
@@ -4971,7 +4805,7 @@ Renderer.prototype.render = function(tokens, options, env) {
4971
4805
  };
4972
4806
  var renderer_default = Renderer;
4973
4807
 
4974
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/ruler.mjs
4808
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/ruler.mjs
4975
4809
  function Ruler() {
4976
4810
  this.__rules__ = [];
4977
4811
  this.__cache__ = null;
@@ -5114,7 +4948,7 @@ Ruler.prototype.getRules = function(chainName) {
5114
4948
  };
5115
4949
  var ruler_default = Ruler;
5116
4950
 
5117
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/token.mjs
4951
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/token.mjs
5118
4952
  function Token(type, tag, nesting) {
5119
4953
  this.type = type;
5120
4954
  this.tag = tag;
@@ -5176,7 +5010,7 @@ Token.prototype.attrJoin = function attrJoin(name, value) {
5176
5010
  };
5177
5011
  var token_default = Token;
5178
5012
 
5179
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/state_core.mjs
5013
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/state_core.mjs
5180
5014
  function StateCore(src, md2, env) {
5181
5015
  this.src = src;
5182
5016
  this.env = env;
@@ -5187,7 +5021,7 @@ function StateCore(src, md2, env) {
5187
5021
  StateCore.prototype.Token = token_default;
5188
5022
  var state_core_default = StateCore;
5189
5023
 
5190
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/normalize.mjs
5024
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/normalize.mjs
5191
5025
  var NEWLINES_RE = /\r\n?|\n/g;
5192
5026
  var NULL_RE = /\0/g;
5193
5027
  function normalize(state) {
@@ -5197,7 +5031,7 @@ function normalize(state) {
5197
5031
  state.src = str;
5198
5032
  }
5199
5033
 
5200
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/block.mjs
5034
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/block.mjs
5201
5035
  function block(state) {
5202
5036
  let token;
5203
5037
  if (state.inlineMode) {
@@ -5211,7 +5045,7 @@ function block(state) {
5211
5045
  }
5212
5046
  }
5213
5047
 
5214
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/inline.mjs
5048
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/inline.mjs
5215
5049
  function inline(state) {
5216
5050
  const tokens = state.tokens;
5217
5051
  for (let i = 0, l = tokens.length; i < l; i++) {
@@ -5222,7 +5056,7 @@ function inline(state) {
5222
5056
  }
5223
5057
  }
5224
5058
 
5225
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/linkify.mjs
5059
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/linkify.mjs
5226
5060
  function isLinkOpen(str) {
5227
5061
  return /^<a[>\s]/i.test(str);
5228
5062
  }
@@ -5238,7 +5072,8 @@ function linkify(state) {
5238
5072
  if (blockTokens[j].type !== "inline" || !state.md.linkify.pretest(blockTokens[j].content)) {
5239
5073
  continue;
5240
5074
  }
5241
- let tokens = blockTokens[j].children;
5075
+ const tokens = blockTokens[j].children;
5076
+ const replacements = [];
5242
5077
  let htmlLinkLevel = 0;
5243
5078
  for (let i = tokens.length - 1; i >= 0; i--) {
5244
5079
  const currentToken = tokens[i];
@@ -5313,13 +5148,35 @@ function linkify(state) {
5313
5148
  token.level = level;
5314
5149
  nodes.push(token);
5315
5150
  }
5316
- blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
5151
+ replacements.push({ index: i, nodes });
5152
+ }
5153
+ }
5154
+ if (replacements.length > 0) {
5155
+ let newTokensLength = tokens.length;
5156
+ for (const replacement of replacements) {
5157
+ newTokensLength += replacement.nodes.length - 1;
5158
+ }
5159
+ const newTokens = new Array(newTokensLength);
5160
+ let replacementIndex = 0;
5161
+ let newTokenIndex = 0;
5162
+ replacements.reverse();
5163
+ for (let i = 0; i < tokens.length; i++) {
5164
+ const replacement = replacements[replacementIndex];
5165
+ if (replacement?.index === i) {
5166
+ for (const node of replacement.nodes) {
5167
+ newTokens[newTokenIndex++] = node;
5168
+ }
5169
+ replacementIndex++;
5170
+ } else {
5171
+ newTokens[newTokenIndex++] = tokens[i];
5172
+ }
5317
5173
  }
5174
+ blockTokens[j].children = newTokens;
5318
5175
  }
5319
5176
  }
5320
5177
  }
5321
5178
 
5322
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/replacements.mjs
5179
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/replacements.mjs
5323
5180
  var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
5324
5181
  var SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i;
5325
5182
  var SCOPED_ABBR_RE = /\((c|tm|r)\)/ig;
@@ -5381,10 +5238,21 @@ function replace(state) {
5381
5238
  }
5382
5239
  }
5383
5240
 
5384
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/smartquotes.mjs
5241
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/smartquotes.mjs
5385
5242
  var QUOTE_TEST_RE = /['"]/;
5386
5243
  var QUOTE_RE = /['"]/g;
5387
5244
  var APOSTROPHE = "\u2019";
5245
+ var MAX_OPENERS = 1e3;
5246
+ function truncateStack(stack, heads, length) {
5247
+ while (stack.length > length) {
5248
+ const item = stack.pop();
5249
+ if (item.isSingleQuote) {
5250
+ heads.single = item.prevSameQuoteIdx;
5251
+ } else {
5252
+ heads.double = item.prevSameQuoteIdx;
5253
+ }
5254
+ }
5255
+ }
5388
5256
  function addReplacement(replacements, tokenIdx, pos, ch) {
5389
5257
  if (!replacements[tokenIdx]) {
5390
5258
  replacements[tokenIdx] = [];
@@ -5405,6 +5273,7 @@ function applyReplacements(str, replacements) {
5405
5273
  function process_inlines(tokens, state) {
5406
5274
  let j;
5407
5275
  const stack = [];
5276
+ const heads = { single: -1, double: -1 };
5408
5277
  const replacements = {};
5409
5278
  for (let i = 0; i < tokens.length; i++) {
5410
5279
  const token = tokens[i];
@@ -5414,7 +5283,7 @@ function process_inlines(tokens, state) {
5414
5283
  break;
5415
5284
  }
5416
5285
  }
5417
- stack.length = j + 1;
5286
+ truncateStack(stack, heads, j + 1);
5418
5287
  if (token.type !== "text") {
5419
5288
  continue;
5420
5289
  }
@@ -5488,36 +5357,41 @@ function process_inlines(tokens, state) {
5488
5357
  continue;
5489
5358
  }
5490
5359
  if (canClose) {
5491
- for (j = stack.length - 1; j >= 0; j--) {
5492
- let item = stack[j];
5493
- if (stack[j].level < thisLevel) {
5494
- break;
5495
- }
5496
- if (item.single === isSingle && stack[j].level === thisLevel) {
5497
- item = stack[j];
5498
- let openQuote;
5499
- let closeQuote;
5500
- if (isSingle) {
5501
- openQuote = state.md.options.quotes[2];
5502
- closeQuote = state.md.options.quotes[3];
5503
- } else {
5504
- openQuote = state.md.options.quotes[0];
5505
- closeQuote = state.md.options.quotes[1];
5506
- }
5507
- addReplacement(replacements, i, t.index, closeQuote);
5508
- addReplacement(replacements, item.token, item.pos, openQuote);
5509
- stack.length = j;
5510
- continue OUTER;
5360
+ j = isSingle ? heads.single : heads.double;
5361
+ if (j >= 0 && stack[j].level === thisLevel) {
5362
+ const item = stack[j];
5363
+ let openQuote;
5364
+ let closeQuote;
5365
+ if (isSingle) {
5366
+ openQuote = state.md.options.quotes[2];
5367
+ closeQuote = state.md.options.quotes[3];
5368
+ } else {
5369
+ openQuote = state.md.options.quotes[0];
5370
+ closeQuote = state.md.options.quotes[1];
5511
5371
  }
5372
+ addReplacement(replacements, i, t.index, closeQuote);
5373
+ addReplacement(replacements, item.tokenIdx, item.contentPos, openQuote);
5374
+ truncateStack(stack, heads, j);
5375
+ continue OUTER;
5512
5376
  }
5513
5377
  }
5514
5378
  if (canOpen) {
5379
+ if (stack.length >= MAX_OPENERS) {
5380
+ return;
5381
+ }
5515
5382
  stack.push({
5516
- token: i,
5517
- pos: t.index,
5518
- single: isSingle,
5519
- level: thisLevel
5383
+ tokenIdx: i,
5384
+ contentPos: t.index,
5385
+ isSingleQuote: isSingle,
5386
+ level: thisLevel,
5387
+ // stack index of the previous opener of the same quote type, -1 if none
5388
+ prevSameQuoteIdx: isSingle ? heads.single : heads.double
5520
5389
  });
5390
+ if (isSingle) {
5391
+ heads.single = stack.length - 1;
5392
+ } else {
5393
+ heads.double = stack.length - 1;
5394
+ }
5521
5395
  } else if (canClose && isSingle) {
5522
5396
  addReplacement(replacements, i, t.index, APOSTROPHE);
5523
5397
  }
@@ -5539,7 +5413,7 @@ function smartquotes(state) {
5539
5413
  }
5540
5414
  }
5541
5415
 
5542
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/text_join.mjs
5416
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/text_join.mjs
5543
5417
  function text_join(state) {
5544
5418
  let curr, last;
5545
5419
  const blockTokens = state.tokens;
@@ -5569,7 +5443,7 @@ function text_join(state) {
5569
5443
  }
5570
5444
  }
5571
5445
 
5572
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/parser_core.mjs
5446
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/parser_core.mjs
5573
5447
  var _rules = [
5574
5448
  ["normalize", normalize],
5575
5449
  ["block", block],
@@ -5596,7 +5470,7 @@ Core.prototype.process = function(state) {
5596
5470
  Core.prototype.State = state_core_default;
5597
5471
  var parser_core_default = Core;
5598
5472
 
5599
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/state_block.mjs
5473
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/state_block.mjs
5600
5474
  function StateBlock(src, md2, env, tokens) {
5601
5475
  this.src = src;
5602
5476
  this.md = md2;
@@ -5753,7 +5627,7 @@ StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF
5753
5627
  StateBlock.prototype.Token = token_default;
5754
5628
  var state_block_default = StateBlock;
5755
5629
 
5756
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/table.mjs
5630
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/table.mjs
5757
5631
  var MAX_AUTOCOMPLETED_CELLS = 65536;
5758
5632
  function getLine(state, line) {
5759
5633
  const pos = state.bMarks[line] + state.tShift[line];
@@ -5943,7 +5817,7 @@ function table(state, startLine, endLine, silent) {
5943
5817
  return true;
5944
5818
  }
5945
5819
 
5946
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/code.mjs
5820
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/code.mjs
5947
5821
  function code(state, startLine, endLine) {
5948
5822
  if (state.sCount[startLine] - state.blkIndent < 4) {
5949
5823
  return false;
@@ -5969,7 +5843,7 @@ function code(state, startLine, endLine) {
5969
5843
  return true;
5970
5844
  }
5971
5845
 
5972
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/fence.mjs
5846
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/fence.mjs
5973
5847
  function fence(state, startLine, endLine, silent) {
5974
5848
  let pos = state.bMarks[startLine] + state.tShift[startLine];
5975
5849
  let max = state.eMarks[startLine];
@@ -6038,7 +5912,7 @@ function fence(state, startLine, endLine, silent) {
6038
5912
  return true;
6039
5913
  }
6040
5914
 
6041
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/blockquote.mjs
5915
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/blockquote.mjs
6042
5916
  function blockquote(state, startLine, endLine, silent) {
6043
5917
  let pos = state.bMarks[startLine] + state.tShift[startLine];
6044
5918
  let max = state.eMarks[startLine];
@@ -6163,7 +6037,7 @@ function blockquote(state, startLine, endLine, silent) {
6163
6037
  return true;
6164
6038
  }
6165
6039
 
6166
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/hr.mjs
6040
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/hr.mjs
6167
6041
  function hr(state, startLine, endLine, silent) {
6168
6042
  const max = state.eMarks[startLine];
6169
6043
  if (state.sCount[startLine] - state.blkIndent >= 4) {
@@ -6197,7 +6071,7 @@ function hr(state, startLine, endLine, silent) {
6197
6071
  return true;
6198
6072
  }
6199
6073
 
6200
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/list.mjs
6074
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/list.mjs
6201
6075
  function skipBulletListMarker(state, startLine) {
6202
6076
  const max = state.eMarks[startLine];
6203
6077
  let pos = state.bMarks[startLine] + state.tShift[startLine];
@@ -6421,96 +6295,121 @@ function list(state, startLine, endLine, silent) {
6421
6295
  return true;
6422
6296
  }
6423
6297
 
6424
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/reference.mjs
6298
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/reference.mjs
6299
+ var MAX_LABEL_LENGTH = 999;
6300
+ function countCodePoints(str) {
6301
+ let length = str.length;
6302
+ for (let i = 0; i < str.length - 1; i++) {
6303
+ const high = str.charCodeAt(i);
6304
+ if (high < 55296 || high > 56319) {
6305
+ continue;
6306
+ }
6307
+ const low = str.charCodeAt(i + 1);
6308
+ if (low >= 56320 && low <= 57343) {
6309
+ length--;
6310
+ i++;
6311
+ }
6312
+ }
6313
+ return length;
6314
+ }
6315
+ function lineEnd(state, line) {
6316
+ return Math.min(state.eMarks[line] + 1, state.src.length);
6317
+ }
6318
+ function getNextLinePos(state, nextLine) {
6319
+ const endLine = state.lineMax;
6320
+ if (nextLine >= endLine || state.isEmpty(nextLine)) {
6321
+ return -1;
6322
+ }
6323
+ let isContinuation = false;
6324
+ if (state.sCount[nextLine] - state.blkIndent > 3) {
6325
+ isContinuation = true;
6326
+ }
6327
+ if (state.sCount[nextLine] < 0) {
6328
+ isContinuation = true;
6329
+ }
6330
+ if (!isContinuation) {
6331
+ const terminatorRules = state.md.block.ruler.getRules("reference");
6332
+ const oldParentType = state.parentType;
6333
+ state.parentType = "reference";
6334
+ let terminate = false;
6335
+ for (let i = 0, l = terminatorRules.length; i < l; i++) {
6336
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
6337
+ terminate = true;
6338
+ break;
6339
+ }
6340
+ }
6341
+ state.parentType = oldParentType;
6342
+ if (terminate) {
6343
+ return -1;
6344
+ }
6345
+ }
6346
+ return state.bMarks[nextLine] + state.tShift[nextLine];
6347
+ }
6425
6348
  function reference(state, startLine, _endLine, silent) {
6349
+ const src = state.src;
6426
6350
  let pos = state.bMarks[startLine] + state.tShift[startLine];
6427
- let max = state.eMarks[startLine];
6428
6351
  let nextLine = startLine + 1;
6429
6352
  if (state.sCount[startLine] - state.blkIndent >= 4) {
6430
6353
  return false;
6431
6354
  }
6432
- if (state.src.charCodeAt(pos) !== 91) {
6355
+ if (src.charCodeAt(pos) !== 91) {
6433
6356
  return false;
6434
6357
  }
6435
- function getNextLine(nextLine2) {
6436
- const endLine = state.lineMax;
6437
- if (nextLine2 >= endLine || state.isEmpty(nextLine2)) {
6438
- return null;
6439
- }
6440
- let isContinuation = false;
6441
- if (state.sCount[nextLine2] - state.blkIndent > 3) {
6442
- isContinuation = true;
6443
- }
6444
- if (state.sCount[nextLine2] < 0) {
6445
- isContinuation = true;
6446
- }
6447
- if (!isContinuation) {
6448
- const terminatorRules = state.md.block.ruler.getRules("reference");
6449
- const oldParentType = state.parentType;
6450
- state.parentType = "reference";
6451
- let terminate = false;
6452
- for (let i = 0, l = terminatorRules.length; i < l; i++) {
6453
- if (terminatorRules[i](state, nextLine2, endLine, true)) {
6454
- terminate = true;
6455
- break;
6456
- }
6457
- }
6458
- state.parentType = oldParentType;
6459
- if (terminate) {
6460
- return null;
6461
- }
6462
- }
6463
- const pos2 = state.bMarks[nextLine2] + state.tShift[nextLine2];
6464
- const max2 = state.eMarks[nextLine2];
6465
- return state.src.slice(pos2, max2 + 1);
6466
- }
6467
- let str = state.src.slice(pos, max + 1);
6468
- max = str.length;
6358
+ let max = lineEnd(state, startLine);
6359
+ let rawLabel = "";
6469
6360
  let labelEnd = -1;
6470
- for (pos = 1; pos < max; pos++) {
6471
- const ch = str.charCodeAt(pos);
6361
+ let segmentStart = ++pos;
6362
+ while (pos < max) {
6363
+ if (rawLabel.length + pos - segmentStart > MAX_LABEL_LENGTH * 2) {
6364
+ return false;
6365
+ }
6366
+ let ch = src.charCodeAt(pos);
6472
6367
  if (ch === 91) {
6473
6368
  return false;
6474
- } else if (ch === 93) {
6369
+ }
6370
+ if (ch === 93) {
6475
6371
  labelEnd = pos;
6476
6372
  break;
6477
- } else if (ch === 10) {
6478
- const lineContent = getNextLine(nextLine);
6479
- if (lineContent !== null) {
6480
- str += lineContent;
6481
- max = str.length;
6482
- nextLine++;
6483
- }
6484
- } else if (ch === 92) {
6485
- pos++;
6486
- if (pos < max && str.charCodeAt(pos) === 10) {
6487
- const lineContent = getNextLine(nextLine);
6488
- if (lineContent !== null) {
6489
- str += lineContent;
6490
- max = str.length;
6491
- nextLine++;
6492
- }
6373
+ }
6374
+ if (ch === 92) {
6375
+ ch = src.charCodeAt(++pos);
6376
+ }
6377
+ if (ch === 10 && pos < max) {
6378
+ const nextPos = getNextLinePos(state, nextLine);
6379
+ if (nextPos < 0) {
6380
+ return false;
6493
6381
  }
6382
+ rawLabel += src.slice(segmentStart, max);
6383
+ pos = segmentStart = nextPos;
6384
+ max = lineEnd(state, nextLine++);
6385
+ continue;
6494
6386
  }
6387
+ pos++;
6388
+ }
6389
+ if (labelEnd < 0 || src.charCodeAt(labelEnd + 1) !== 58) {
6390
+ return false;
6495
6391
  }
6496
- if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 58) {
6392
+ rawLabel += src.slice(segmentStart, labelEnd);
6393
+ if (rawLabel.length > MAX_LABEL_LENGTH && countCodePoints(rawLabel) > MAX_LABEL_LENGTH) {
6497
6394
  return false;
6498
6395
  }
6499
- for (pos = labelEnd + 2; pos < max; pos++) {
6500
- const ch = str.charCodeAt(pos);
6396
+ pos = labelEnd + 2;
6397
+ while (pos < max) {
6398
+ const ch = src.charCodeAt(pos);
6501
6399
  if (ch === 10) {
6502
- const lineContent = getNextLine(nextLine);
6503
- if (lineContent !== null) {
6504
- str += lineContent;
6505
- max = str.length;
6506
- nextLine++;
6400
+ const nextPos = getNextLinePos(state, nextLine);
6401
+ if (nextPos < 0) {
6402
+ break;
6507
6403
  }
6404
+ pos = nextPos;
6405
+ max = lineEnd(state, nextLine++);
6508
6406
  } else if (isSpace(ch)) {
6407
+ pos++;
6509
6408
  } else {
6510
6409
  break;
6511
6410
  }
6512
6411
  }
6513
- const destRes = state.md.helpers.parseLinkDestination(str, pos, max);
6412
+ const destRes = state.md.helpers.parseLinkDestination(src, pos, max);
6514
6413
  if (!destRes.ok) {
6515
6414
  return false;
6516
6415
  }
@@ -6520,55 +6419,57 @@ function reference(state, startLine, _endLine, silent) {
6520
6419
  }
6521
6420
  pos = destRes.pos;
6522
6421
  const destEndPos = pos;
6422
+ const destEndMax = max;
6523
6423
  const destEndLineNo = nextLine;
6524
- const start = pos;
6525
- for (; pos < max; pos++) {
6526
- const ch = str.charCodeAt(pos);
6424
+ while (pos < max) {
6425
+ const ch = src.charCodeAt(pos);
6527
6426
  if (ch === 10) {
6528
- const lineContent = getNextLine(nextLine);
6529
- if (lineContent !== null) {
6530
- str += lineContent;
6531
- max = str.length;
6532
- nextLine++;
6427
+ const nextPos = getNextLinePos(state, nextLine);
6428
+ if (nextPos < 0) {
6429
+ break;
6533
6430
  }
6431
+ pos = nextPos;
6432
+ max = lineEnd(state, nextLine++);
6534
6433
  } else if (isSpace(ch)) {
6434
+ pos++;
6535
6435
  } else {
6536
6436
  break;
6537
6437
  }
6538
6438
  }
6539
- let titleRes = state.md.helpers.parseLinkTitle(str, pos, max);
6439
+ const titleStart = pos;
6440
+ let titleRes = state.md.helpers.parseLinkTitle(src, pos, max);
6540
6441
  while (titleRes.can_continue) {
6541
- const lineContent = getNextLine(nextLine);
6542
- if (lineContent === null) break;
6543
- str += lineContent;
6544
- pos = max;
6545
- max = str.length;
6546
- nextLine++;
6547
- titleRes = state.md.helpers.parseLinkTitle(str, pos, max, titleRes);
6442
+ const nextPos = getNextLinePos(state, nextLine);
6443
+ if (nextPos < 0) break;
6444
+ pos = nextPos;
6445
+ max = lineEnd(state, nextLine++);
6446
+ titleRes = state.md.helpers.parseLinkTitle(src, pos, max, titleRes);
6548
6447
  }
6549
6448
  let title;
6550
- if (pos < max && start !== pos && titleRes.ok) {
6449
+ if (titleStart !== destEndPos && titleRes.ok) {
6551
6450
  title = titleRes.str;
6552
6451
  pos = titleRes.pos;
6553
6452
  } else {
6554
6453
  title = "";
6555
6454
  pos = destEndPos;
6455
+ max = destEndMax;
6556
6456
  nextLine = destEndLineNo;
6557
6457
  }
6558
6458
  while (pos < max) {
6559
- const ch = str.charCodeAt(pos);
6459
+ const ch = src.charCodeAt(pos);
6560
6460
  if (!isSpace(ch)) {
6561
6461
  break;
6562
6462
  }
6563
6463
  pos++;
6564
6464
  }
6565
- if (pos < max && str.charCodeAt(pos) !== 10) {
6465
+ if (pos < max && src.charCodeAt(pos) !== 10) {
6566
6466
  if (title) {
6567
6467
  title = "";
6568
6468
  pos = destEndPos;
6469
+ max = destEndMax;
6569
6470
  nextLine = destEndLineNo;
6570
6471
  while (pos < max) {
6571
- const ch = str.charCodeAt(pos);
6472
+ const ch = src.charCodeAt(pos);
6572
6473
  if (!isSpace(ch)) {
6573
6474
  break;
6574
6475
  }
@@ -6576,10 +6477,10 @@ function reference(state, startLine, _endLine, silent) {
6576
6477
  }
6577
6478
  }
6578
6479
  }
6579
- if (pos < max && str.charCodeAt(pos) !== 10) {
6480
+ if (pos < max && src.charCodeAt(pos) !== 10) {
6580
6481
  return false;
6581
6482
  }
6582
- const label = normalizeReference(str.slice(1, labelEnd));
6483
+ const label = normalizeReference(rawLabel);
6583
6484
  if (!label) {
6584
6485
  return false;
6585
6486
  }
@@ -6596,7 +6497,7 @@ function reference(state, startLine, _endLine, silent) {
6596
6497
  return true;
6597
6498
  }
6598
6499
 
6599
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/common/html_blocks.mjs
6500
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/common/html_blocks.mjs
6600
6501
  var html_blocks_default = [
6601
6502
  "address",
6602
6503
  "article",
@@ -6662,7 +6563,7 @@ var html_blocks_default = [
6662
6563
  "ul"
6663
6564
  ];
6664
6565
 
6665
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/common/html_re.mjs
6566
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/common/html_re.mjs
6666
6567
  var attr_name = "[a-zA-Z_:][a-zA-Z0-9:._-]*";
6667
6568
  var unquoted = "[^\"'=<>`\\x00-\\x20]+";
6668
6569
  var single_quoted = "'[^']*'";
@@ -6678,12 +6579,12 @@ var cdata = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";
6678
6579
  var HTML_TAG_RE = new RegExp("^(?:" + open_tag + "|" + close_tag + "|" + comment + "|" + processing + "|" + declaration + "|" + cdata + ")");
6679
6580
  var HTML_OPEN_CLOSE_TAG_RE = new RegExp("^(?:" + open_tag + "|" + close_tag + ")");
6680
6581
 
6681
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/html_block.mjs
6582
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/html_block.mjs
6682
6583
  var HTML_SEQUENCES = [
6683
6584
  [/^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true],
6684
6585
  [/^<!--/, /-->/, true],
6685
6586
  [/^<\?/, /\?>/, true],
6686
- [/^<![A-Z]/, />/, true],
6587
+ [/^<![A-Za-z]/, />/, true],
6687
6588
  [/^<!\[CDATA\[/, /\]\]>/, true],
6688
6589
  [new RegExp("^</?(" + html_blocks_default.join("|") + ")(?=(\\s|/?>|$))", "i"), /^$/, true],
6689
6590
  [new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + "\\s*$"), /^$/, false]
@@ -6740,7 +6641,7 @@ function html_block(state, startLine, endLine, silent) {
6740
6641
  return true;
6741
6642
  }
6742
6643
 
6743
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/heading.mjs
6644
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/heading.mjs
6744
6645
  function heading(state, startLine, endLine, silent) {
6745
6646
  let pos = state.bMarks[startLine] + state.tShift[startLine];
6746
6647
  let max = state.eMarks[startLine];
@@ -6781,7 +6682,7 @@ function heading(state, startLine, endLine, silent) {
6781
6682
  return true;
6782
6683
  }
6783
6684
 
6784
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/lheading.mjs
6685
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/lheading.mjs
6785
6686
  function lheading(state, startLine, endLine) {
6786
6687
  const terminatorRules = state.md.block.ruler.getRules("paragraph");
6787
6688
  if (state.sCount[startLine] - state.blkIndent >= 4) {
@@ -6844,7 +6745,7 @@ function lheading(state, startLine, endLine) {
6844
6745
  return true;
6845
6746
  }
6846
6747
 
6847
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/paragraph.mjs
6748
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/paragraph.mjs
6848
6749
  function paragraph(state, startLine, endLine) {
6849
6750
  const terminatorRules = state.md.block.ruler.getRules("paragraph");
6850
6751
  const oldParentType = state.parentType;
@@ -6881,7 +6782,7 @@ function paragraph(state, startLine, endLine) {
6881
6782
  return true;
6882
6783
  }
6883
6784
 
6884
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/parser_block.mjs
6785
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/parser_block.mjs
6885
6786
  var _rules2 = [
6886
6787
  // First 2 params - rule name & source. Secondary array - list of rules,
6887
6788
  // which can be terminated by this one.
@@ -6955,7 +6856,7 @@ ParserBlock.prototype.parse = function(src, md2, env, outTokens) {
6955
6856
  ParserBlock.prototype.State = state_block_default;
6956
6857
  var parser_block_default = ParserBlock;
6957
6858
 
6958
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/state_inline.mjs
6859
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/state_inline.mjs
6959
6860
  function StateInline(src, md2, env, outTokens) {
6960
6861
  this.src = src;
6961
6862
  this.env = env;
@@ -6972,6 +6873,7 @@ function StateInline(src, md2, env, outTokens) {
6972
6873
  this._prev_delimiters = [];
6973
6874
  this.backticks = {};
6974
6875
  this.backticksScanned = false;
6876
+ this.skipHtmlSpecial = false;
6975
6877
  this.linkLevel = 0;
6976
6878
  }
6977
6879
  StateInline.prototype.pushPending = function() {
@@ -7049,7 +6951,7 @@ StateInline.prototype.scanDelims = function(start, canSplitWord) {
7049
6951
  StateInline.prototype.Token = token_default;
7050
6952
  var state_inline_default = StateInline;
7051
6953
 
7052
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/text.mjs
6954
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/text.mjs
7053
6955
  function isTerminatorChar(ch) {
7054
6956
  switch (ch) {
7055
6957
  case 10:
@@ -7095,8 +6997,13 @@ function text(state, silent) {
7095
6997
  return true;
7096
6998
  }
7097
6999
 
7098
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/linkify.mjs
7099
- var SCHEME_RE = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;
7000
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/linkify.mjs
7001
+ function isAsciiAlpha(code2) {
7002
+ return code2 >= 65 && code2 <= 90 || code2 >= 97 && code2 <= 122;
7003
+ }
7004
+ function isSchemeChar(code2) {
7005
+ return code2 >= 65 && code2 <= 90 || code2 >= 97 && code2 <= 122 || code2 >= 48 && code2 <= 57 || code2 === 43 || code2 === 45 || code2 === 46;
7006
+ }
7100
7007
  function linkify2(state, silent) {
7101
7008
  if (!state.md.options.linkify) return false;
7102
7009
  if (state.linkLevel > 0) return false;
@@ -7106,13 +7013,17 @@ function linkify2(state, silent) {
7106
7013
  if (state.src.charCodeAt(pos) !== 58) return false;
7107
7014
  if (state.src.charCodeAt(pos + 1) !== 47) return false;
7108
7015
  if (state.src.charCodeAt(pos + 2) !== 47) return false;
7109
- const match3 = state.pending.match(SCHEME_RE);
7110
- if (!match3) return false;
7111
- const proto = match3[1];
7112
- const link2 = state.md.linkify.matchAtStart(state.src.slice(pos - proto.length));
7016
+ const protoMin = pos - Math.min(10, state.pending.length, pos);
7017
+ let protoStart = pos;
7018
+ while (protoStart > protoMin && isSchemeChar(state.src.charCodeAt(protoStart - 1))) {
7019
+ protoStart--;
7020
+ }
7021
+ if (protoStart === pos || !isAsciiAlpha(state.src.charCodeAt(protoStart))) return false;
7022
+ const protoLength = pos - protoStart;
7023
+ const link2 = state.md.linkify.matchAtStart(state.src.slice(protoStart));
7113
7024
  if (!link2) return false;
7114
7025
  let url = link2.url;
7115
- if (url.length <= proto.length) return false;
7026
+ if (url.length <= protoLength) return false;
7116
7027
  let urlEnd = url.length;
7117
7028
  while (urlEnd > 0 && url.charCodeAt(urlEnd - 1) === 42) {
7118
7029
  urlEnd--;
@@ -7123,7 +7034,7 @@ function linkify2(state, silent) {
7123
7034
  const fullUrl = state.md.normalizeLink(url);
7124
7035
  if (!state.md.validateLink(fullUrl)) return false;
7125
7036
  if (!silent) {
7126
- state.pending = state.pending.slice(0, -proto.length);
7037
+ state.pending = state.pending.slice(0, -protoLength);
7127
7038
  const token_o = state.push("link_open", "a", 1);
7128
7039
  token_o.attrs = [["href", fullUrl]];
7129
7040
  token_o.markup = "linkify";
@@ -7134,11 +7045,11 @@ function linkify2(state, silent) {
7134
7045
  token_c.markup = "linkify";
7135
7046
  token_c.info = "auto";
7136
7047
  }
7137
- state.pos += url.length - proto.length;
7048
+ state.pos += url.length - protoLength;
7138
7049
  return true;
7139
7050
  }
7140
7051
 
7141
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/newline.mjs
7052
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/newline.mjs
7142
7053
  function newline(state, silent) {
7143
7054
  let pos = state.pos;
7144
7055
  if (state.src.charCodeAt(pos) !== 10) {
@@ -7169,7 +7080,7 @@ function newline(state, silent) {
7169
7080
  return true;
7170
7081
  }
7171
7082
 
7172
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/escape.mjs
7083
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/escape.mjs
7173
7084
  var ESCAPED = [];
7174
7085
  for (let i = 0; i < 256; i++) {
7175
7086
  ESCAPED.push(0);
@@ -7230,7 +7141,7 @@ function escape2(state, silent) {
7230
7141
  return true;
7231
7142
  }
7232
7143
 
7233
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/backticks.mjs
7144
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/backticks.mjs
7234
7145
  function backtick(state, silent) {
7235
7146
  let pos = state.pos;
7236
7147
  const ch = state.src.charCodeAt(pos);
@@ -7275,7 +7186,7 @@ function backtick(state, silent) {
7275
7186
  return true;
7276
7187
  }
7277
7188
 
7278
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs
7189
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs
7279
7190
  function strikethrough_tokenize(state, silent) {
7280
7191
  const start = state.pos;
7281
7192
  const marker = state.src.charCodeAt(start);
@@ -7371,7 +7282,7 @@ var strikethrough_default = {
7371
7282
  postProcess: strikethrough_postProcess
7372
7283
  };
7373
7284
 
7374
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/emphasis.mjs
7285
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/emphasis.mjs
7375
7286
  function emphasis_tokenize(state, silent) {
7376
7287
  const start = state.pos;
7377
7288
  const marker = state.src.charCodeAt(start);
@@ -7458,7 +7369,7 @@ var emphasis_default = {
7458
7369
  postProcess: emphasis_post_process
7459
7370
  };
7460
7371
 
7461
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/link.mjs
7372
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/link.mjs
7462
7373
  function link(state, silent) {
7463
7374
  let code2, label, res, ref;
7464
7375
  let href = "";
@@ -7566,7 +7477,7 @@ function link(state, silent) {
7566
7477
  return true;
7567
7478
  }
7568
7479
 
7569
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/image.mjs
7480
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/image.mjs
7570
7481
  function image(state, silent) {
7571
7482
  let code2, content, label, pos, ref, res, title, start;
7572
7483
  let href = "";
@@ -7679,7 +7590,7 @@ function image(state, silent) {
7679
7590
  return true;
7680
7591
  }
7681
7592
 
7682
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/autolink.mjs
7593
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/autolink.mjs
7683
7594
  var EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/;
7684
7595
  var AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;
7685
7596
  function autolink(state, silent) {
@@ -7737,7 +7648,7 @@ function autolink(state, silent) {
7737
7648
  return false;
7738
7649
  }
7739
7650
 
7740
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/html_inline.mjs
7651
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/html_inline.mjs
7741
7652
  function isLinkOpen2(str) {
7742
7653
  return /^<a[>\s]/i.test(str);
7743
7654
  }
@@ -7748,6 +7659,41 @@ function isLetter(ch) {
7748
7659
  const lc = ch | 32;
7749
7660
  return lc >= 97 && lc <= 122;
7750
7661
  }
7662
+ function scanSpecial(state, pos) {
7663
+ const src = state.src;
7664
+ let start;
7665
+ let terminator;
7666
+ if (src.startsWith("<!--", pos)) {
7667
+ if (src.startsWith(">", pos + 4)) {
7668
+ return pos + 5;
7669
+ }
7670
+ if (src.startsWith("->", pos + 4)) {
7671
+ return pos + 6;
7672
+ }
7673
+ start = pos + 4;
7674
+ terminator = "-->";
7675
+ } else if (src.startsWith("<![CDATA[", pos)) {
7676
+ start = pos + 9;
7677
+ terminator = "]]>";
7678
+ } else if (src.charCodeAt(pos + 1) === 63) {
7679
+ start = pos + 2;
7680
+ terminator = "?>";
7681
+ } else if (isLetter(src.charCodeAt(pos + 2))) {
7682
+ start = pos + 3;
7683
+ terminator = ">";
7684
+ } else {
7685
+ return -1;
7686
+ }
7687
+ if (state.skipHtmlSpecial) {
7688
+ return -1;
7689
+ }
7690
+ const end = src.indexOf(terminator, start);
7691
+ if (end < 0) {
7692
+ state.skipHtmlSpecial = true;
7693
+ return -1;
7694
+ }
7695
+ return end + terminator.length;
7696
+ }
7751
7697
  function html_inline(state, silent) {
7752
7698
  if (!state.md.options.html) {
7753
7699
  return false;
@@ -7757,25 +7703,30 @@ function html_inline(state, silent) {
7757
7703
  if (state.src.charCodeAt(pos) !== 60 || pos + 2 >= max) {
7758
7704
  return false;
7759
7705
  }
7706
+ let end;
7760
7707
  const ch = state.src.charCodeAt(pos + 1);
7761
- if (ch !== 33 && ch !== 63 && ch !== 47 && !isLetter(ch)) {
7708
+ if (ch === 33 || ch === 63) {
7709
+ end = scanSpecial(state, pos);
7710
+ } else if (ch === 47 || isLetter(ch)) {
7711
+ const match3 = state.src.slice(pos).match(HTML_OPEN_CLOSE_TAG_RE);
7712
+ end = match3 ? pos + match3[0].length : -1;
7713
+ } else {
7762
7714
  return false;
7763
7715
  }
7764
- const match3 = state.src.slice(pos).match(HTML_TAG_RE);
7765
- if (!match3) {
7716
+ if (end < 0) {
7766
7717
  return false;
7767
7718
  }
7768
7719
  if (!silent) {
7769
7720
  const token = state.push("html_inline", "", 0);
7770
- token.content = match3[0];
7721
+ token.content = state.src.slice(pos, end);
7771
7722
  if (isLinkOpen2(token.content)) state.linkLevel++;
7772
7723
  if (isLinkClose2(token.content)) state.linkLevel--;
7773
7724
  }
7774
- state.pos += match3[0].length;
7725
+ state.pos = end;
7775
7726
  return true;
7776
7727
  }
7777
7728
 
7778
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/entity.mjs
7729
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/entity.mjs
7779
7730
  var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;
7780
7731
  var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
7781
7732
  function entity(state, silent) {
@@ -7816,7 +7767,7 @@ function entity(state, silent) {
7816
7767
  return false;
7817
7768
  }
7818
7769
 
7819
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs
7770
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs
7820
7771
  function processDelimiters(delimiters) {
7821
7772
  const openersBottom = {};
7822
7773
  const max = delimiters.length;
@@ -7880,7 +7831,7 @@ function link_pairs(state) {
7880
7831
  }
7881
7832
  }
7882
7833
 
7883
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs
7834
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs
7884
7835
  function fragments_join(state) {
7885
7836
  let curr, last;
7886
7837
  let level = 0;
@@ -7904,7 +7855,7 @@ function fragments_join(state) {
7904
7855
  }
7905
7856
  }
7906
7857
 
7907
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/parser_inline.mjs
7858
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/parser_inline.mjs
7908
7859
  var _rules3 = [
7909
7860
  ["text", text],
7910
7861
  ["linkify", linkify2],
@@ -8674,7 +8625,7 @@ var punycode = {
8674
8625
  };
8675
8626
  var punycode_es6_default = punycode;
8676
8627
 
8677
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/presets/default.mjs
8628
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/presets/default.mjs
8678
8629
  var default_default = {
8679
8630
  options: {
8680
8631
  // Enable HTML tags in source
@@ -8713,7 +8664,7 @@ var default_default = {
8713
8664
  }
8714
8665
  };
8715
8666
 
8716
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/presets/zero.mjs
8667
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/presets/zero.mjs
8717
8668
  var zero_default = {
8718
8669
  options: {
8719
8670
  // Enable HTML tags in source
@@ -8771,7 +8722,7 @@ var zero_default = {
8771
8722
  }
8772
8723
  };
8773
8724
 
8774
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/presets/commonmark.mjs
8725
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/presets/commonmark.mjs
8775
8726
  var commonmark_default = {
8776
8727
  options: {
8777
8728
  // Enable HTML tags in source
@@ -8848,7 +8799,7 @@ var commonmark_default = {
8848
8799
  }
8849
8800
  };
8850
8801
 
8851
- // ../../node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/index.mjs
8802
+ // ../../node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/index.mjs
8852
8803
  var config = {
8853
8804
  default: default_default,
8854
8805
  zero: zero_default,
@@ -9047,7 +8998,7 @@ function renderMarkdown(source) {
9047
8998
 
9048
8999
  // ../web/dist/routes/detail.js
9049
9000
  function createDetailRoute(ctx) {
9050
- const app = new Hono2();
9001
+ const app = new Hono3();
9051
9002
  app.get("/g/:id", (c) => {
9052
9003
  const id = c.req.param("id");
9053
9004
  const sourceParam = c.req.query("source") ?? "own";
@@ -9117,7 +9068,7 @@ function listCommunity(communityDir, db) {
9117
9068
  return handles;
9118
9069
  }
9119
9070
  function createCommunityRoute(ctx) {
9120
- const app = new Hono2();
9071
+ const app = new Hono3();
9121
9072
  app.get("/community", (c) => {
9122
9073
  const handles = listCommunity(ctx.paths.communityDir, ctx.db);
9123
9074
  const list2 = handles.map((h) => {
@@ -9150,7 +9101,7 @@ function percent(numerator, denominator) {
9150
9101
  return denominator === 0 ? "\u2014" : `${Math.round(numerator / denominator * 100)}%`;
9151
9102
  }
9152
9103
  function createJevRoute(ctx) {
9153
- const app = new Hono2();
9104
+ const app = new Hono3();
9154
9105
  app.get("/jev", (c) => {
9155
9106
  const cases = listJevObservations(ctx.caveatHome);
9156
9107
  const advice = cases.filter((item) => item.delivery === "delivered" && item.selectedRef !== null);
@@ -9188,7 +9139,7 @@ function createJevRoute(ctx) {
9188
9139
 
9189
9140
  // ../web/dist/app.js
9190
9141
  function createApp(ctx) {
9191
- const app = new Hono2();
9142
+ const app = new Hono3();
9192
9143
  app.route("/", createIndexRoute(ctx));
9193
9144
  app.route("/", createDetailRoute(ctx));
9194
9145
  app.route("/", createCommunityRoute(ctx));
@@ -9226,4 +9177,4 @@ if (import.meta.url === `file://${process.argv[1]?.replace(/\\/g, "/")}`) {
9226
9177
  export {
9227
9178
  startServer
9228
9179
  };
9229
- //# sourceMappingURL=server-XI7ZOMPY.js.map
9180
+ //# sourceMappingURL=server-UQ5OZ2IQ.js.map