frameboard 0.28.0 → 0.29.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.
package/dist/cli.js CHANGED
@@ -23,14 +23,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
23
23
  var __getProtoOf = Object.getPrototypeOf;
24
24
  var __hasOwnProp = Object.prototype.hasOwnProperty;
25
25
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
26
- var __exportAll = (all, no_symbols) => {
27
- let target = {};
26
+ var __exportAll = (all, flags) => {
27
+ let target = Object.setPrototypeOf({}, null);
28
28
  for (var name in all) __defProp(target, name, {
29
29
  get: all[name],
30
30
  enumerable: true
31
31
  });
32
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
33
- return target;
32
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
33
+ return flags & 2 ? target : Object.preventExtensions(target);
34
34
  };
35
35
  var __copyProps = (to, from, except, desc) => {
36
36
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -267,8 +267,8 @@ var Help = class {
267
267
  const removeShort = helpOption.short && cmd._findOption(helpOption.short);
268
268
  const removeLong = helpOption.long && cmd._findOption(helpOption.long);
269
269
  if (!removeShort && !removeLong) visibleOptions.push(helpOption);
270
- else if (helpOption.long && !removeLong) visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
271
- else if (helpOption.short && !removeShort) visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
270
+ else if (helpOption.long && !removeLong) visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description).helpGroup(helpOption.helpGroupHeading));
271
+ else if (helpOption.short && !removeShort) visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description).helpGroup(helpOption.helpGroupHeading));
272
272
  }
273
273
  if (this.sortOptions) visibleOptions.sort(this.compareOptions);
274
274
  return visibleOptions;
@@ -686,7 +686,7 @@ var Option = class {
686
686
  this.description = description || "";
687
687
  this.required = flags.includes("<");
688
688
  this.optional = flags.includes("[");
689
- this.variadic = /\w\.\.\.[>\]]$/.test(flags);
689
+ this.variadic = /\p{ID_Continue}\.\.\.[>\]]$/u.test(flags);
690
690
  this.mandatory = false;
691
691
  const optionFlags = splitOptionFlags(flags);
692
692
  this.short = optionFlags.shortFlag;
@@ -1771,7 +1771,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1771
1771
  getOptionValueSourceWithGlobals(key) {
1772
1772
  let source;
1773
1773
  this._getCommandAndAncestors().forEach((cmd) => {
1774
- if (cmd.getOptionValueSource(key) !== void 0) source = cmd.getOptionValueSource(key);
1774
+ if (Object.hasOwn(cmd._optionValueSources, key)) source = cmd.getOptionValueSource(key);
1775
1775
  });
1776
1776
  return source;
1777
1777
  }
@@ -2280,7 +2280,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2280
2280
  return arg.length > 1 && arg[0] === "-";
2281
2281
  }
2282
2282
  const negativeNumberArg = (arg) => {
2283
- if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg)) return false;
2283
+ if (!/^-(\d+|\d*\.\d+)([eE][+-]?\d+)?$/.test(arg)) return false;
2284
2284
  return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
2285
2285
  };
2286
2286
  let activeVariadicOption = null;
@@ -2680,7 +2680,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2680
2680
  * (This does not override a group set directly on the subcommand using .helpGroup().)
2681
2681
  *
2682
2682
  * @example
2683
- * program.commandsGroup('Development Commands:);
2683
+ * program.commandsGroup('Development Commands:');
2684
2684
  * program.command('watch')...
2685
2685
  * program.command('lint')...
2686
2686
  * ...
@@ -2849,7 +2849,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2849
2849
  * Pass in false to disable the built-in help option.
2850
2850
  *
2851
2851
  * @example
2852
- * program.helpOption('-?, --help' 'show help'); // customise
2852
+ * program.helpOption('-?, --help', 'show help'); // customise
2853
2853
  * program.helpOption(false); // disable
2854
2854
  *
2855
2855
  * @param {(string | boolean)} flags
@@ -2971,12 +2971,12 @@ function incrementNodeInspectorPort(args) {
2971
2971
  let debugHost = "127.0.0.1";
2972
2972
  let debugPort = "9229";
2973
2973
  let match;
2974
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) debugOption = match[1];
2975
- else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
2974
+ if ((match = arg.match(/^(--inspect(-brk|-wait)?)$/)) !== null) debugOption = match[1];
2975
+ else if ((match = arg.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+)$/)) !== null) {
2976
2976
  debugOption = match[1];
2977
2977
  if (/^\d+$/.test(match[3])) debugPort = match[3];
2978
2978
  else debugHost = match[3];
2979
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
2979
+ } else if ((match = arg.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+):(\d+)$/)) !== null) {
2980
2980
  debugOption = match[1];
2981
2981
  debugHost = match[3];
2982
2982
  debugPort = match[4];
@@ -9517,9 +9517,9 @@ async function isDirectory(path) {
9517
9517
  }
9518
9518
  }
9519
9519
  // package.json
9520
- var version$1 = "0.28.0";
9521
- var dependencies = { "playwright-core": "1.64.1" };
9522
- var peerDependencies = { "oxfmt": "0.75.0" };
9520
+ var version$1 = "0.29.0";
9521
+ var dependencies = { "playwright-core": "1.65.0" };
9522
+ var peerDependencies = { "oxfmt": "0.77.0" };
9523
9523
  // src/shared/version.ts
9524
9524
  const version = version$1;
9525
9525
  // src/cli/client-dir.ts
@@ -10470,16 +10470,27 @@ const newHeadersFromIncoming = (incoming) => globalThis.Headers === GlobalHeader
10470
10470
  const reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
10471
10471
  const reDotSegment = /\/\.\.?(?:[/?#]|$)/;
10472
10472
  const reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
10473
+ const validateRequestTarget = (target) => {
10474
+ const backslash = target.indexOf("\\");
10475
+ if (backslash !== -1) {
10476
+ const query = target.indexOf("?");
10477
+ if (query === -1 || backslash < query) throw new RequestError("Backslash in request path");
10478
+ }
10479
+ };
10473
10480
  const buildUrl = (scheme, host, incomingUrl) => {
10474
10481
  const url = `${scheme}://${host}${incomingUrl}`;
10475
10482
  if (!reValidHost.test(host)) {
10483
+ validateRequestTarget(incomingUrl);
10476
10484
  const urlObj = new URL(url);
10477
10485
  if (urlObj.hostname.length !== host.length && urlObj.hostname !== (host.includes(":") ? host.replace(/:\d+$/, "") : host).toLowerCase()) throw new RequestError("Invalid host header");
10478
10486
  return urlObj.href;
10479
10487
  } else if (incomingUrl.length === 0) return url + "/";
10480
10488
  else {
10481
10489
  if (incomingUrl.charCodeAt(0) !== 47) throw new RequestError("Invalid URL");
10482
- if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) return new URL(url).href;
10490
+ if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) {
10491
+ validateRequestTarget(incomingUrl);
10492
+ return new URL(url).href;
10493
+ }
10483
10494
  return url;
10484
10495
  }
10485
10496
  };
@@ -10888,6 +10899,7 @@ const newRequest = (incoming, defaultHostname) => {
10888
10899
  if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
10889
10900
  if (incoming instanceof Http2ServerRequest) throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
10890
10901
  try {
10902
+ validateRequestTarget(incomingUrl);
10891
10903
  req[urlKey] = new URL(incomingUrl).href;
10892
10904
  } catch (e) {
10893
10905
  throw new RequestError("Invalid absolute URL", { cause: e });
@@ -11384,6 +11396,7 @@ const appendResponseHeaders = (headers, responseHeaders) => {
11384
11396
  });
11385
11397
  };
11386
11398
  const rejectUpgradeRequest = (socket, status, responseHeaders) => {
11399
+ if (socket.destroyed) return;
11387
11400
  const responseLines = ["Connection: close", "Content-Length: 0"];
11388
11401
  appendResponseHeaders(responseLines, responseHeaders);
11389
11402
  socket.end(`HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ""}\r\n${responseLines.join("\r\n")}\r\n\r
@@ -11391,7 +11404,12 @@ const rejectUpgradeRequest = (socket, status, responseHeaders) => {
11391
11404
  };
11392
11405
  const createUpgradeRequest = (request) => {
11393
11406
  const protocol = request.socket.encrypted ? "https" : "http";
11394
- const url = new URL(request.url ?? "/", `${protocol}://${request.headers.host ?? "localhost"}`);
11407
+ const incomingUrl = request.url ?? "/";
11408
+ let url;
11409
+ if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
11410
+ validateRequestTarget(incomingUrl);
11411
+ url = new URL(incomingUrl).href;
11412
+ } else url = buildUrl(protocol, request.headers.host ?? "localhost", incomingUrl);
11395
11413
  const headers = new Headers();
11396
11414
  for (const key in request.headers) {
11397
11415
  const value = request.headers[key];
@@ -11428,6 +11446,10 @@ const setupWebSocket = (options) => {
11428
11446
  };
11429
11447
  server.on("upgrade", async (request, socket, head) => {
11430
11448
  if (request.headers.upgrade?.toLowerCase() !== "websocket") return;
11449
+ const ignoreSocketError = () => {};
11450
+ const reclaimWaiterOnClose = () => rejectWaiter(request);
11451
+ socket.on("error", ignoreSocketError);
11452
+ socket.once("close", reclaimWaiterOnClose);
11431
11453
  const env = {
11432
11454
  incoming: request,
11433
11455
  outgoing: void 0,
@@ -11442,8 +11464,12 @@ const setupWebSocket = (options) => {
11442
11464
  status = response.status;
11443
11465
  responseHeaders = response.headers;
11444
11466
  }
11445
- } catch {
11446
- if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, 500);
11467
+ } catch (error) {
11468
+ if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, error instanceof RequestError ? 400 : 500);
11469
+ return;
11470
+ }
11471
+ if (socket.destroyed) {
11472
+ rejectWaiter(request);
11447
11473
  return;
11448
11474
  }
11449
11475
  const waiter = waiterMap.get(request);
@@ -11455,12 +11481,11 @@ const setupWebSocket = (options) => {
11455
11481
  const addResponseHeaders = (headers) => {
11456
11482
  appendResponseHeaders(headers, responseHeaders);
11457
11483
  };
11458
- const reclaimWaiterOnClose = () => rejectWaiter(request);
11459
- socket.once("close", reclaimWaiterOnClose);
11460
11484
  wss.on("headers", addResponseHeaders);
11461
11485
  try {
11462
11486
  wss.handleUpgrade(request, socket, head, (ws) => {
11463
11487
  socket.off("close", reclaimWaiterOnClose);
11488
+ socket.off("error", ignoreSocketError);
11464
11489
  wss.emit("connection", ws, request);
11465
11490
  });
11466
11491
  } finally {
@@ -11751,6 +11776,15 @@ const getPathNoStrict = (request) => {
11751
11776
  const result = getPath(request);
11752
11777
  return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
11753
11778
  };
11779
+ const stripPathPrefix = (rawPath, decodedPath, prefixLength) => {
11780
+ if (rawPath.at(-1) === "/" && decodedPath.at(-1) !== "/") rawPath = rawPath.slice(0, -1);
11781
+ let index = 0;
11782
+ for (let i = decodedPath.indexOf("/"); i !== -1 && i < prefixLength; i = decodedPath.indexOf("/", i + 1)) {
11783
+ index = rawPath.indexOf("/", index + 1);
11784
+ if (index === -1) return "/";
11785
+ }
11786
+ return rawPath.slice(index) || "/";
11787
+ };
11754
11788
  /**
11755
11789
  * Merge paths.
11756
11790
  * @param {string[]} ...paths - The paths to merge.
@@ -11793,7 +11827,7 @@ const _getQueryParam = (url, key, multiple) => {
11793
11827
  const hashIndex = url.indexOf("#", 8);
11794
11828
  if (hashIndex !== -1) url = url.slice(0, hashIndex);
11795
11829
  let encoded;
11796
- if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
11830
+ if (!multiple && key && !/[%+&=]/.test(key)) {
11797
11831
  const queryIndex = url.indexOf("?", 8);
11798
11832
  let keyIndex = queryIndex;
11799
11833
  if (keyIndex === -1) return;
@@ -12342,7 +12376,7 @@ var Context = class {
12342
12376
  * ```
12343
12377
  */
12344
12378
  header = (name, value, options) => {
12345
- if (this.finalized) this.#res = createResponseInstance(this.#res.body, this.#res);
12379
+ if (this.finalized && !this.#res.bodyUsed) this.#res = createResponseInstance(this.#res.body, this.#res);
12346
12380
  const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
12347
12381
  if (value === void 0) headers.delete(name);
12348
12382
  else if (options?.append) headers.append(name, value);
@@ -12596,6 +12630,36 @@ var UnsupportedPathError = class extends Error {};
12596
12630
  * Constant used to mark a composed handler.
12597
12631
  */
12598
12632
  const COMPOSED_HANDLER = "__COMPOSED_HANDLER";
12633
+ // node_modules/hono/dist/utils/mount.js
12634
+ const getPathPrefixLength = (c, pathPrefix, routePath) => {
12635
+ if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
12636
+ const path = c.req.path;
12637
+ const matchResult = c.req[GET_MATCH_RESULT];
12638
+ const paramNames = /* @__PURE__ */ new Set();
12639
+ let length = 0;
12640
+ for (const part of splitRoutingPath(pathPrefix)) {
12641
+ const pattern = getPattern(part);
12642
+ if (pattern && pattern !== "*") {
12643
+ const name = pattern[1];
12644
+ if (paramNames.has(name)) throw new Error(`mount(): Duplicate path parameter "${name}" in "${routePath}".`);
12645
+ paramNames.add(name);
12646
+ }
12647
+ if (pattern && pattern !== "*" && pattern[2] !== true) {
12648
+ const value = matchResult.length === 2 ? matchResult[1][matchResult[0][c.req.routeIndex][1][pattern[1]]] : matchResult[0][c.req.routeIndex][1][pattern[1]];
12649
+ length += value.length + 1;
12650
+ } else if (pattern || part.endsWith("*")) {
12651
+ const end = path.indexOf("/", length + 1);
12652
+ length = end === -1 ? path.length : end;
12653
+ } else length += part.length + 1;
12654
+ }
12655
+ return length;
12656
+ };
12657
+ const createMountedRequest = (c, pathPrefix, routePath) => {
12658
+ if (/[^/]\*$/.test(routePath)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath}".`);
12659
+ const url = new URL(c.req.raw.url);
12660
+ url.pathname = stripPathPrefix(url.pathname, c.req.path, getPathPrefixLength(c, pathPrefix, routePath));
12661
+ return new Request(url, c.req.raw);
12662
+ };
12599
12663
  // node_modules/hono/dist/hono-base.js
12600
12664
  /**
12601
12665
  * @module
@@ -12820,17 +12884,10 @@ var Hono$1 = class Hono {
12820
12884
  } catch {}
12821
12885
  return [c.env, executionContext];
12822
12886
  };
12823
- replaceRequest ||= (() => {
12824
- const mergedPath = mergePath(this._basePath, path);
12825
- const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
12826
- return (request) => {
12827
- const url = new URL(request.url);
12828
- url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
12829
- return new Request(url, request);
12830
- };
12831
- })();
12887
+ const mergedPath = mergePath(this._basePath, path);
12888
+ const defaultReplaceRequest = (c) => createMountedRequest(c, mergedPath.replace(/\/$/, ""), mergePath(mergedPath, "*"));
12832
12889
  const handler = async (c, next) => {
12833
- const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
12890
+ const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
12834
12891
  if (res) return res;
12835
12892
  await next();
12836
12893
  };
@@ -12959,7 +13016,8 @@ function match(method, path) {
12959
13016
  }
12960
13017
  // node_modules/hono/dist/router/reg-exp-router/node.js
12961
13018
  const LABEL_REG_EXP_STR = "[^/]+";
12962
- const TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
13019
+ const ONLY_WILDCARD_REG_EXP_STR = "[^]*";
13020
+ const TAIL_WILDCARD_REG_EXP_STR = "(?:|/[^]*)";
12963
13021
  const PATH_ERROR = Symbol();
12964
13022
  const regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
12965
13023
  /**
@@ -12972,8 +13030,8 @@ const regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
12972
13030
  function compareKey(a, b) {
12973
13031
  if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
12974
13032
  if (b.length === 1) return 1;
12975
- if (a === ".*" || a === "(?:|/.*)") return b === "(?:|/.*)" ? -1 : 1;
12976
- else if (b === ".*" || b === "(?:|/.*)") return -1;
13033
+ if (a === "[^]*" || a === "(?:|/[^]*)") return b === "[^]*" ? -1 : 1;
13034
+ else if (b === "[^]*" || b === "(?:|/[^]*)") return -1;
12977
13035
  if (a === "[^/]+") return 1;
12978
13036
  else if (b === "[^/]+") return -1;
12979
13037
  return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
@@ -12982,14 +13040,14 @@ var Node$4 = class Node {
12982
13040
  #index;
12983
13041
  #varIndex;
12984
13042
  #children = createNullObject();
12985
- insert(tokens, index, paramMap, context, isStatic) {
13043
+ insert(tokens, index, paramMap, context, keys) {
12986
13044
  let node = this;
12987
13045
  for (let i = 0, len = tokens.length; i < len; i++) {
12988
13046
  const token = tokens[i];
12989
13047
  const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? [
12990
13048
  "",
12991
13049
  "",
12992
- ".*"
13050
+ ONLY_WILDCARD_REG_EXP_STR
12993
13051
  ] : [
12994
13052
  "",
12995
13053
  "",
@@ -13004,15 +13062,16 @@ var Node$4 = class Node {
13004
13062
  const name = pattern[1];
13005
13063
  let regexpStr = pattern[2] || "[^/]+";
13006
13064
  if (name && pattern[2]) {
13007
- if (regexpStr === ".*") throw PATH_ERROR;
13065
+ if (new RegExp(regexpStr).test("")) throw PATH_ERROR;
13008
13066
  regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
13009
13067
  if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
13010
13068
  if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
13011
13069
  }
13070
+ keys.push(regexpStr);
13012
13071
  nextNode = node.#children[regexpStr];
13013
13072
  if (!nextNode) {
13014
- if (regexpStr !== ".*" && regexpStr !== "(?:|/.*)") {
13015
- for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
13073
+ if (regexpStr !== "[^]*" && regexpStr !== "(?:|/[^]*)") {
13074
+ for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
13016
13075
  }
13017
13076
  nextNode = node.#children[regexpStr] = new Node();
13018
13077
  }
@@ -13021,16 +13080,17 @@ var Node$4 = class Node {
13021
13080
  paramMap.push([name, nextNode.#varIndex]);
13022
13081
  }
13023
13082
  } else {
13083
+ keys.push(token);
13024
13084
  nextNode = node.#children[token];
13025
13085
  if (!nextNode) {
13026
- for (const k in node.#children) if (k.length > 1 && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
13086
+ for (const k in node.#children) if (k.length > 1 && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
13027
13087
  nextNode = node.#children[token] = new Node();
13028
13088
  }
13029
13089
  }
13030
13090
  node = nextNode;
13031
13091
  }
13032
13092
  if (node.#index !== void 0) throw PATH_ERROR;
13033
- node.#index = isStatic ? -1 : index;
13093
+ node.#index = index;
13034
13094
  }
13035
13095
  buildRegExpStr() {
13036
13096
  const strList = Object.keys(this.#children).sort(compareKey).map((k) => {
@@ -13051,8 +13111,14 @@ var Trie = class {
13051
13111
  #index = 0;
13052
13112
  paths = createNullObject();
13053
13113
  insert(path, isStatic) {
13114
+ const keys = [];
13054
13115
  if (isStatic) {
13055
- this.#root.insert(path.split(""), 0, [], this.#context, true);
13116
+ this.#root.insert(path.split(""), -1, [], this.#context, keys);
13117
+ this.paths[path] = [
13118
+ -1,
13119
+ [],
13120
+ keys
13121
+ ];
13056
13122
  return;
13057
13123
  }
13058
13124
  const paramAssoc = [];
@@ -13060,7 +13126,7 @@ var Trie = class {
13060
13126
  let markedPath = path;
13061
13127
  for (let i = 0;;) {
13062
13128
  let replaced = false;
13063
- markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
13129
+ markedPath = markedPath.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g, (m) => {
13064
13130
  const mark = `@\\${i}`;
13065
13131
  groups[i] = [mark, m];
13066
13132
  i++;
@@ -13074,7 +13140,7 @@ var Trie = class {
13074
13140
  * - /* wildcard
13075
13141
  * - character
13076
13142
  */
13077
- const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
13143
+ const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./gs) || [];
13078
13144
  for (let i = groups.length - 1; i >= 0; i--) {
13079
13145
  const [mark] = groups[i];
13080
13146
  for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
@@ -13082,8 +13148,12 @@ var Trie = class {
13082
13148
  break;
13083
13149
  }
13084
13150
  }
13085
- this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
13086
- this.paths[path] = [this.#index++, paramAssoc];
13151
+ this.#root.insert(tokens, this.#index, paramAssoc, this.#context, keys);
13152
+ this.paths[path] = [
13153
+ this.#index++,
13154
+ paramAssoc,
13155
+ keys
13156
+ ];
13087
13157
  }
13088
13158
  buildRegExp() {
13089
13159
  let regexp = this.#root.buildRegExpStr();
@@ -13114,21 +13184,21 @@ var Trie = class {
13114
13184
  }
13115
13185
  };
13116
13186
  // node_modules/hono/dist/router/reg-exp-router/router.js
13117
- let wildcardRegExpCache = createNullObject();
13118
- function buildWildcardRegExp(path) {
13119
- return wildcardRegExpCache[path] ??= new RegExp(`^${path.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (match, metaChar) => metaChar ? `\\${metaChar}` : match === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match === "*" ? ".*" : `/:${LABEL_REG_EXP_STR}`)}$`);
13187
+ function endsWithWildcard(keys) {
13188
+ const tail = keys[keys.length - 1];
13189
+ return tail === "[^]*" || tail === "(?:|/[^]*)";
13120
13190
  }
13121
- function findMiddleware(middleware, path) {
13122
- for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path)) return [...middleware[k]];
13191
+ function covers(wildcard, target) {
13192
+ const last = wildcard.length - 1;
13193
+ for (let i = 0; i < last; i++) if (wildcard[i] !== target[i]) return false;
13194
+ return wildcard[last] === "[^]*" || target.length === last || target[last] === "/";
13123
13195
  }
13124
13196
  var RegExpRouter = class {
13125
13197
  name = "RegExpRouter";
13126
- #middleware;
13127
- #routes;
13198
+ #handlers;
13128
13199
  #tries;
13129
13200
  constructor() {
13130
- this.#middleware = { ["ALL"]: createNullObject() };
13131
- this.#routes = { ["ALL"]: createNullObject() };
13201
+ this.#handlers = { ["ALL"]: [] };
13132
13202
  this.#tries = { ["ALL"]: new Trie() };
13133
13203
  }
13134
13204
  #insertPath(method, path) {
@@ -13139,65 +13209,53 @@ var RegExpRouter = class {
13139
13209
  }
13140
13210
  }
13141
13211
  add(method, path, handler) {
13142
- const middleware = this.#middleware;
13143
- const routes = this.#routes;
13144
- if (!middleware) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
13145
- if (!middleware[method]) {
13146
- this.#tries[method] = new Trie();
13147
- for (const handlerMap of [middleware, routes]) {
13148
- handlerMap[method] = createNullObject();
13149
- for (const p in handlerMap["ALL"]) {
13150
- handlerMap[method][p] = [...handlerMap["ALL"][p]];
13151
- this.#insertPath(method, p);
13152
- }
13153
- }
13212
+ const handlers = this.#handlers;
13213
+ if (!handlers) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
13214
+ const tries = this.#tries;
13215
+ if (!handlers[method]) {
13216
+ tries[method] = new Trie();
13217
+ handlers[method] = [...handlers["ALL"]];
13218
+ for (const p in tries["ALL"].paths) this.#insertPath(method, p);
13154
13219
  }
13155
13220
  if (path === "/*") path = "*";
13156
- const methods = method === "ALL" ? Object.keys(middleware) : [method];
13157
- if (/\*$/.test(path)) {
13158
- const re = buildWildcardRegExp(path);
13159
- for (const m of methods) if (!middleware[m][path]) {
13160
- this.#insertPath(m, path);
13161
- middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
13162
- }
13163
- 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]);
13164
- return;
13165
- }
13221
+ const methods = method === "ALL" ? Object.keys(handlers) : [method];
13166
13222
  const paths = checkOptionalParameter(path) || [path];
13167
13223
  for (const path of paths) for (const m of methods) {
13168
- if (!routes[m][path]) {
13169
- this.#insertPath(m, path);
13170
- routes[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
13171
- }
13172
- routes[m][path].push([handler, path]);
13224
+ if (!tries[m].paths[path]) this.#insertPath(m, path);
13225
+ handlers[m].push([handler, path]);
13173
13226
  }
13174
13227
  }
13175
13228
  match = match;
13176
13229
  buildAllMatchers() {
13177
13230
  const matchers = createNullObject();
13178
- for (const method of Object.keys(this.#routes)) matchers[method] = this.#buildMatcher(method);
13179
- this.#middleware = this.#routes = this.#tries = void 0;
13180
- wildcardRegExpCache = createNullObject();
13231
+ for (const method of Object.keys(this.#handlers)) matchers[method] = this.#buildMatcher(method);
13232
+ this.#handlers = this.#tries = void 0;
13181
13233
  return matchers;
13182
13234
  }
13183
13235
  #buildMatcher(method) {
13184
- const middleware = this.#middleware[method];
13185
- const routes = this.#routes[method];
13236
+ const handlers = this.#handlers[method];
13186
13237
  const trie = this.#tries[method];
13187
13238
  const staticMap = createNullObject();
13188
13239
  const handlerData = [];
13189
13240
  const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
13190
- for (const r of [middleware, routes]) for (const path in r) {
13191
- const handlers = r[path];
13192
- const pathData = trie.paths[path];
13193
- if (!pathData) {
13194
- staticMap[path] = [handlers.map(([h]) => [h, createNullObject()]), emptyParam];
13195
- continue;
13196
- }
13197
- handlerData[pathData[0]] = handlers.map(([h, handlerPath]) => [h, trie.paths[handlerPath][1].reduceRight((map, [key], i) => {
13198
- map[key] = paramReplacementMap[pathData[1][i][1]];
13241
+ const own = createNullObject();
13242
+ const entries = handlers.map(([h, p], i) => {
13243
+ (own[p] ??= []).push(i);
13244
+ return [h, trie.paths[p][1].reduceRight((map, [key, varIndex]) => {
13245
+ map[key] = paramReplacementMap[varIndex];
13199
13246
  return map;
13200
- }, createNullObject())]);
13247
+ }, createNullObject())];
13248
+ });
13249
+ const wildcards = Object.keys(own).filter((p) => endsWithWildcard(trie.paths[p][2]));
13250
+ for (const path in trie.paths) {
13251
+ const [index, , keys] = trie.paths[path];
13252
+ const indexes = [...own[path]];
13253
+ for (const p of wildcards) if (p !== path && covers(trie.paths[p][2], keys)) indexes.push(...own[p]);
13254
+ const data = indexes.sort((a, b) => a - b).map((i) => entries[i]);
13255
+ if (index === -1) {
13256
+ const last = Math.max(-1, ...data.flatMap(([, map]) => Object.values(map)));
13257
+ staticMap[path] = [data, last === -1 ? emptyParam : path.match(regexp).slice(0, last + 1)];
13258
+ } else handlerData[index] = data;
13201
13259
  }
13202
13260
  return [
13203
13261
  regexp,
@@ -13687,8 +13745,8 @@ const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
13687
13745
  const _serialize = (name, value, opt = {}) => {
13688
13746
  if (!validCookieNameRegEx.test(name)) throw new Error("Invalid cookie name");
13689
13747
  let cookie = `${name}=${value}`;
13690
- if (name.startsWith("__Secure-") && !opt.secure) throw new Error("__Secure- Cookie must have Secure attributes");
13691
- if (name.startsWith("__Host-")) {
13748
+ if (/^__secure-/i.test(name) && !opt.secure) throw new Error("__Secure- Cookie must have Secure attributes");
13749
+ if (/^__host-/i.test(name)) {
13692
13750
  if (!opt.secure) throw new Error("__Host- Cookie must have Secure attributes");
13693
13751
  if (opt.path !== "/") throw new Error("__Host- Cookie must have Path attributes with \"/\"");
13694
13752
  if (opt.domain) throw new Error("__Host- Cookie must not have Domain attributes");
@@ -14099,8 +14157,13 @@ var Preprocessor = class {
14099
14157
  get col() {
14100
14158
  return this.pos - this.lineStartPos + Number(this.lastGapPos !== this.pos);
14101
14159
  }
14160
+ /** The index in `html` at which the current code point starts (the high surrogate of a pair). */
14161
+ get codePointStart() {
14162
+ return this.pos - Number(this.lastGapPos === this.pos);
14163
+ }
14164
+ /** The offset of the current code point, before the second unit of a surrogate pair. */
14102
14165
  get offset() {
14103
- return this.droppedBufferSize + this.pos;
14166
+ return this.droppedBufferSize + this.codePointStart;
14104
14167
  }
14105
14168
  getError(code, cpOffset) {
14106
14169
  const { line, col, offset } = this;
@@ -14129,7 +14192,7 @@ var Preprocessor = class {
14129
14192
  _processSurrogate(cp) {
14130
14193
  if (this.pos !== this.html.length - 1) {
14131
14194
  const nextCp = this.html.charCodeAt(this.pos + 1);
14132
- if (isSurrogatePair(nextCp)) {
14195
+ if (!isSurrogatePair(cp) && isSurrogatePair(nextCp)) {
14133
14196
  this.pos++;
14134
14197
  this._addGap();
14135
14198
  return getSurrogatePairCodePoint(cp, nextCp);
@@ -14144,14 +14207,20 @@ var Preprocessor = class {
14144
14207
  willDropParsedChunk() {
14145
14208
  return this.pos > this.bufferWaterline;
14146
14209
  }
14147
- dropParsedChunk() {
14210
+ /**
14211
+ * Drop the parsed input, except for the current code point and the `keep` code units before it. The gap history is
14212
+ * reset, so the kept units must contain no preprocessing gap.
14213
+ */
14214
+ dropParsedChunk(keep = 0) {
14148
14215
  if (this.willDropParsedChunk()) {
14149
- this.html = this.html.substring(this.pos);
14150
- this.lineStartPos -= this.pos;
14151
- this.droppedBufferSize += this.pos;
14152
- this.pos = 0;
14216
+ const droppedSize = this.offset - this.droppedBufferSize - keep;
14217
+ this.html = this.html.substring(droppedSize);
14218
+ this.lineStartPos -= droppedSize;
14219
+ this.droppedBufferSize += droppedSize;
14220
+ this.pos -= droppedSize;
14153
14221
  this.lastGapPos = -2;
14154
14222
  this.gapStack.length = 0;
14223
+ if (this.pos > keep) this._addGap();
14155
14224
  }
14156
14225
  }
14157
14226
  write(chunk, isLastChunk) {
@@ -14245,7 +14314,7 @@ function getTokenAttr(token, attrName) {
14245
14314
  }
14246
14315
  // node_modules/entities/dist/decode-codepoint.js
14247
14316
  /**
14248
- * C1 Unicode control character reference replacements (code points 128–159).
14317
+ * C1 Unicode control character reference replacements (code points 128-159).
14249
14318
  * Index i gives the replacement for code point 128+i; 0 means "no replacement".
14250
14319
  */
14251
14320
  const c1 = [
@@ -14292,7 +14361,7 @@ function isInvalidCodePoint(codePoint) {
14292
14361
  /**
14293
14362
  * Replace the given code point with U+FFFD if it is NUL (0), a surrogate, or
14294
14363
  * outside the valid Unicode range. Code points in the C1 controls range
14295
- * (128–159) are remapped to their Windows-1252 equivalents, following the
14364
+ * (128-159) are remapped to their Windows-1252 equivalents, following the
14296
14365
  * HTML spec. All other code points are returned unchanged.
14297
14366
  * @param codePoint Unicode code point to convert.
14298
14367
  */
@@ -14301,250 +14370,137 @@ function replaceCodePoint(codePoint) {
14301
14370
  if (codePoint >= 128 && codePoint <= 159) return c1[codePoint - 128] || codePoint;
14302
14371
  return codePoint;
14303
14372
  }
14373
+ // node_modules/entities/dist/generated/decode-data-html.js
14304
14374
  /**
14305
- * XML numeric character references are the referenced Unicode code point.
14306
- * Invalid values still become U+FFFD; the HTML Windows-1252 C1 remap is not
14307
- * applied.
14308
- * @see https://www.w3.org/TR/xml/#NT-CharRef
14309
- * @param codePoint Unicode code point to convert.
14310
- */
14311
- function replaceCodePointXML(codePoint) {
14312
- return isInvalidCodePoint(codePoint) ? 65533 : codePoint;
14313
- }
14314
- // node_modules/entities/dist/internal/decode-shared.js
14315
- const BASE91_INVERSE = /* #__PURE__ */ (() => {
14316
- const table = /* @__PURE__ */ new Uint8Array(127);
14317
- let code = 0;
14318
- for (let char = 33; char <= 126; char++) if (char !== 34 && char !== 36 && char !== 92) table[char] = code++;
14319
- return table;
14375
+ * Serialized decode data; the format is documented in
14376
+ * `src/internal/decode-data-format.ts`. `[0]` is one-byte data (all char
14377
+ * codes <= 0xFF: header, front-coded name suffixes, per-name metadata,
14378
+ * cuckoo choice bits); `[1]` holds the replacement values.
14379
+ */
14380
+ const htmlDecodeData = ["Q=¨`p0AEligMPacutebrevecircyfrgravelphamacrndogonpfpplyFunctionringscrsigntildeumlBackslashrvwedcyecausernoullistafropfrevescrumpeqCHcyOPYacutepitalDifferentialDyleyscaronedilirconintdotedillanterDotfrhiircleDotMinusPlusTimeslockwiseContourIntegralseCurlyDoubleQuoteQuoteolonengruentinttourIntegralpfroductunterClockwiseContourIntegralrossscrupCapDDotrahdJcyScyZcyaggerrrshvcaronyeltafriacriticalAcuteDotubleAcuteGraveTildemondfferentialDopftDotEqualubleContourIntegralDotwnArrowLeftArrowRightArrowTeeongLeftArrowRightArrowRightArrowRightArrowTeeUpArrowDownArrowVerticalBarwnArrowBarUpArrowBreveLeftRightVectorTeeVectorVectorBarRightTeeVectorVectorBarTeeArrowarrowscrtrokENGTHacutecaronircydotfrgravelementmacrptySmallSquareVerySmallSquareogonpfpsilonqualTildeilibriumscrimtaumlxistsponentialEFcyfrilledSmallSquareVerySmallSquareopfrAlluriertrfscrGJcyTammadbrevecedilircydotfrgopfreaterEqualLessFullEqualGreaterLessSlantEqualTildescrtHARDcyacektcircfrilbertSpaceopfrizontalLinescrtrokumpDownHumpEqualIEcyJligOcyacutecircydotfrgravemacrginaryIpliesntegralrsectionvisibleCommaTimesogonpftascrtildeukcymlJcircyfropfscrercyukcyKHcyJcyappacedilyfropfscrLJcyTacutembdangplacetrfrrcaronedilyeftAngleBracketrrowBarRightArrowCeilingDoubleBracketwnTeeVectorVectorBarFloorRightArrowVectorTeeArrowVectorriangleBarEqualUpDownVectorTeeVectorVectorBarVectorBararrowrightarrowssEqualGreaterFullEqualGreaterLessSlantEqualTildefrleftarrowmidotongLeftArrowRightArrowRightArrowleftarrowrightarrowrightarrowpfwerLeftArrowRightArrowscrhtroktMapcyediumSpacellintrffrinusPlusopfscruNJcyacutecaronedilyegativeMediumSpaceThickSpacenSpaceVeryThinSpacestedGreaterGreaterLessLesswLinefroBreaknBreakingSpacepftCongruentupCapDoubleVerticalBarElementqualTildexistsGreaterEqualFullEqualGreaterLessSlantEqualTildeHumpDownHumpEqualLeftTriangleBarEqualssEqualGreaterLessSlantEqualTildeNestedGreaterGreaterLessLessPrecedesEqualSlantEqualReverseElementightTriangleBarEqualSquareSubsetEqualpersetEqualubsetEqualcceedsEqualSlantEqualTildepersetEqualTildeEqualFullEqualTildeVerticalBarscrtildeuOEligacutecircydblacfrgravemacregaicronopfpenCurlyDoubleQuoteQuoterscrlashtildemesumlverBarraceketParenthesisPartialDcyfrhiilusMinusoincareplanepfrecedesEqualSlantEqualTildeimeoductportionalscriQUOTfropfscrRBarrEGacutengrrtlcaronedilyeverseElementquilibriumUpEquilibriumfrhoightAngleBracketrrowBarLeftArrowCeilingDoubleBracketwnTeeVectorVectorBarFloorTeeArrowVectorriangleBarEqualUpDownVectorTeeVectorVectorBarVectorBararrowopfundImpliesrightarrowscrhuleDelayedSHCHcycyOFTcyacutecaronedilircyfrhortDownArrowLeftArrowRightArrowUpArrowigmamallCircleopfqrtuareIntersectionSubsetEqualpersetEqualUnionscrtarubsetEqualcceedsEqualSlantEqualTildehThatmpersetEqualsetTHORNRADESHcycyabucaronedilyfrhereforetaickSpacenSpaceildeEqualFullEqualTildeopfripleDotscrtrokUacuterrocirbrcyevecircydblacfrgravemacrnderBarraceketParenthesisionPlusogonpfpArrowBarDownArrowDownArrowEquilibriumTeeArrowarrowdownarrowperLeftArrowRightArrowsilonringscrtildeumlVDashbarcydashleerbarticalBarLineSeparatorTildeyThinSpacefropfscrvdashWcircedgefropfscrXfriopfscrYAcyIcyUcyacutecircyfropfscrumlZHcyacutecaronydoteroWidthSpacetafropfscraacutebrevecEdircuteyeligfrgravelefsymphphamacrlgpndanddslopevgelemsdaabcdefghrtvbdsphtzarrogonpfpEacireidosproxeqringscrtympeqtildeumlwconintintbNotackcongepsilonprimesimeqrveewedgebrktbrkcongydquoecausemptyvpsirnoutahweenfrigcapircupodotplustimessqcuptartriangledownupuplusveewedgekarowlacklozengesquaretriangledownleftrightnkk12434ocknequivotopfttomwtiexDLRlrHDUduULRlrVHLRhlrboxdLRlrhDUduminusplustimesuLRlrvHLRhlrprimerevevbarscremiimeolbhsubulletmpEeqcacutepandbrcupcapupdotsretoncapsronedilircupssmdotedilmptyvnterdotfrhcyeckmarkiirEceqlearrowleftrightdRSastcircdashefnintmidscirlubsuitoloneqmmatpfnlementxesngdotintpfrodysrrarrossscrubepetdotudarrlreprsclarrppbrcapcapupdotorsrarrmlyeqprecsuccveewedgerenvearrowleftrightveewedwconintintylctydArrHaraggerlethrrshvbkarowlaccaronydaggerrrotseqegltamptyvfishtrharlriamondsuitsegammasinvideontimesonxjcylcornropollarpfteqdotminusplussquareublebarwedgewnarrowdownarrowsharpoonleftrightrbkarowcornropscryoltroktdotrifuarrharwanglezcyigrarreDDototacutestercaronircolonydotefDotrgravesdotlinterslsdotmacrptysetvsp134ngspogonpfparsllussilonvqcircolonsimlantgtrlessualsestivDDvparslrDotarrscrdotimtahumlroxclistpectationonentialefallingdotseqcyemalefiligligligriligjliglatligtnsnofopfrallkvpartintrac123456823534584556878slownscrgElacutemmadpbrevecircydotelqqslantsccdotollesfrggimeljcylEajnEapproxeqqsimopfravescrimeltccirdotlParquestrapproxrrdoteqlessqlesslesssimvertneqqnEhArrairsplfmiltrdcyrcirwbarcirceartsuitlliprconfrksearowwarowoarrmthtokleftarrowrightarrowpfrbarscrlashtrokybullpheniacutecircyecyxclffrgraveiiintntnfinotajligmacrgelinepartthofpedncarefintieodottcalegersrcallarhkprodocygonpftaprodquestscrinEdotsvvtildeukcymljcircyfrmathopfscrercyukcykappavcedilyfrgreenhcyjcyopfscrlAarrrrtailBarrEgHaracuteemptyvgranmbdangdlepquorrbfsfshklpplsimtltailesbarrbrkracekkeslducaronedililubydcaquorrdharusharsheftarrowtailharpoondownupleftarrowsrightarrowsharpoonssquigarrowthreetimesgqqslantsccdotorgessapproxdoteqgtrqgtrgtrsimfishtloorrgEhardulblkjcylarrcornerhardtrimidotoustachenEapproxeqqsimoangrrbrkngleftarrowrightarrowmapstorightarrowoparrowleftrightparflustimeswastbarzengefparltrarrcornerhardmtrisaquocrhimegqbuortroktccirdothreeimeslarrquestrPariefurdsharuharvertneqqnEmDDotacrletesepstodownleftuprkercommaydasheasuredanglefrhoicrodastcirdotnusbdulcpdrnplusodelspfpscrtposultimapmapnGgtvLeftarrowrightarrowltvRightarrowVDashdashablacutengpEidosproxturalsbspumpecapronedilongdotupydasheArrarhkrowdotquivsearimxistsfrgEeqqslantssimtrhArrarrparisdvjcylArrEarrdreftarrowrightarrowqqslantsssimtriemidopftinEdotvabcnivabcparallelsltolintrcueeceqrArrarrcwightarrowtriesccueerhortmidparallelimeqmidparqsubepeubEeseteqqcceqpEeseteqqtglildelgrianglelefteqrightequmerospvDashHarrapdashgetinfinlArretrierArrtriesimwArrarhkrownearoSacutestcircydashblacivotsoldeligfcirrgonravethbarmintlarrcirrossinetmacregaicrondnusopfparerplusrarrderoffmigoforslopevscrlasholtildemesasumlvbarparallelsimltcyercntiodmilptenkfrhivmmatoneitchforkvlanckhkvusacirbcirdouemnsimtwomointintpfundrEapcueecapproxcurlyeqeqnapproxeqqsimsimimesnEapsimodfalarlinesurfptosimurelscriuncspqfrintopfprimescruaternionsintesteqotrAarrrrtailBarrHaraceutedicemptyvngdelequorrapbfscfshklpplsimtlwtailionalsbarrbrkracekkeslducaronedililubydcaldharquorshealinepartsctgfishtloorrhardulovightarrowtailharpoondownupleftarrowsharpoonsrightarrowssquigarrowthreetimesngsingdotseqlarrharmmoustachenmidoangrrbrkparflustimespargtpolintrarrsaquocrhqbuorthreeimesriefltriuluharxsacutebquocEaproncueedilircnEapsimpolintsimydotbeeArrarhkrowctmiswartminusnxtfrownharpchcyyortmidparallelyigmafvmdoteqgElEneplusrarrlarrmallsetminusshpeparslidletesoftcylbarpfpadesuitrqcapsupssubeseteqpesetequareffrarrscretmnmiletarftarfraightepsilonphinsubEdotedotmultnEeplusrarrseteqqneqqimubpccapproxcurlyeqeqnapproxeqqsimsimmngp123EdotsubedothsolublarrmultnEeplusseteqqneqqimubpwArrarhkrownwarzligtargetubrkcaronedilydotelrecfrhere4foretasymvickapproxsimnspkapsimornildemesbardntoeapbotcirforksaprimeradeiangledownlefteqqrighteqdoteminusplussbtimepeziumscryhcytrokwixtoheadleftarrowrightarrowuArrHaracuterrbrcyevecircydarrblacharfishtrgraveharlrblklcornerroptrimacrlogonpfparrowdownarrowharpoonleftrightlussihlonuparrowsrcornerropingtriscrtdotilderifuarrmlwanglevArrBarvDashangrtrepsilonkappanothingphiiroptorhosigmaubsetneqqpsetneqqthetariangleleftrightcydasheebareqlliprbartfrltrinsubpopfproprtriscrubnEepnEezigzagwcircedbargeqierpfropfpreathscrxcapircupdtrifrhArrarrilArrarrmapnisodotpflustimerArrarrscrqcupuplustriveewedgeyacuteycircyenfricyopfscrucymlzacutecaronydoteetrftafrhcyigrarropfscrwjnjC(D%D($(D'%$$ED($'$'$%$'%E$/D'$F%'D(D&#,%%&&$%$)%+%%$E$F$'$&$(#'D&$(%$&4%($(E'%&%($&$)%*$%$%$+)()')($:&5-($'($%*&&&/%%&)%@$'$F$%&&#%%)$&$&$&$(%%%&$(%$$%&%$E$2.&0,.(.(&'%.$F%$&&&(%6)&+*),---&*/1---)-.&)*+,).%*,&,*'('2+,+)1&'1,)2&'&*('($F%'#&D%D($(E&%$$&$ED($)$'%1(2$'%E$)$'((&+$&%%$%D&$(%-#&$E$3)2$F%'%+$&#'D$$'($$($(%&%$$&$E$$$F$./'*,***'*-*($F$$#)$'%$$'$%$.$&%/$&%'$.'(#'$'$&D(D'%$$&$%D($$%&&*%($%&('+%/,($'%E%%$&$($'E%#(%$$E$F$F%'$'#'$&$'$(%$$E$F$F#'D$$(%'%%%+%%$(%'%$$2(',&,-'*'0).+)1&'('-,)'&*(*)(*/&/('/),))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&'&&)%+$)&,$'%'%($%%')'*'%'*(&(&'&%$%%%$F$F$F$&$&&'&&$'&&'(%&'&'&%'$&'&&)%+$)&,$'%'%($$'%''$(%%'D'#)%$$&$(%'%$$&$($E$(('&%(&($%,(&&&%&&&E&$'E&($)%($%%$&%$&&&&&D'&%%$($'%)+'+'/%+$+(0%&&&$&(&'&%&'%)$F&$%&%'$'%1*-#'$&D(%%$'&&D'%$$'%'%&$(%DD($''$%&$()%&&%&$'E$$'%E$)%,%.,(%&%%'$'&%+$()%&&%&%&$F$'%'%%'$$'E%$)#'$&'$$'$(%+&(&*&&'$'(&$'%&('K/D(J/D&('..($%$'$%&&&%%'%'&$$E$'$G'D$F$'$'$F%G(D&F(D$)#($(&%($%'$E$F$$$$%'$F#'%&%%$'$E$'%&$$$'%&$&$&$'%E&&%'$'%&$F%'$(%&$&$(C)&$$'%$D%$E$&$F$F$&E%#)$(%$$&$(%%$E$&$)$F$F$%%%0@0000H8H40H000047P00P@001000@0B0HP@:H9T8P000LB8d@800@I0<110000QQ8400P10030005940@410020000Q02000@0200000@P0101@8000440400000000808000000000@00000000P`0000000040400@0004<000000000008000030000000000P020T400020@0@00000000000000000000000000P0000000400400000400220080000100000000000000000P000000000000P000000@00402000000000@00000000000000000000040000000000000", "Æ&ÁĂÂА𝔄ÀΑĀ⩓Ą𝔸⁡Å𝒜≔ÃÄ∖⫧⌆Б∵ℬΒ𝔅𝔹˘ℬ≎Ч©Ć⋒ⅅℭČÇĈ∰Ċ¸·ℭΧ⊙⊖⊕⊗∲”’∷⩴≡∯∮ℂ∐∳⨯𝒞⋓≍ⅅ⤑ЂЅЏ‡↡⫤ĎД∇Δ𝔇´˙˝`˜⋄ⅆ𝔻¨⃜≐∯¨⇓⇐⇔⫤⟸⟺⟹⇒⊨⇑⇕∥↓⤓⇵̑⥐⥞↽⥖⥟⇁⥗⊤↧⇓𝒟ĐŊÐÉĚÊЭĖ𝔈È∈Ē◻▫Ę𝔼Ε⩵≂⇌ℰ⩳ΗË∃ⅇФ𝔉◼▪𝔽∀ℱℱЃ>ΓϜĞĢĜГĠ𝔊⋙𝔾≥⋛≧⪢≷⩾≳𝒢≫Ъˇ^Ĥℌℋℍ─ℋĦ≎≏ЕIJЁÍÎИİℑÌℑĪⅈ⇒∬∫⋂⁣⁢Į𝕀ΙℐĨІÏĴЙ𝔍𝕁𝒥ЈЄХЌΚĶК𝔎𝕂𝒦Љ<ĹΛ⟪ℒ↞ĽĻЛ⟨←⇤⇆⌈⟦⥡⇃⥙⌊↔⥎⊣↤⥚⊲⧏⊴⥑⥠↿⥘↼⥒⇐⇔⋚≦≶⪡⩽≲𝔏⋘⇚Ŀ⟵⟷⟶⟸⟺⟹𝕃↙↘ℒ↰Ł≪⤅М ℳ𝔐∓𝕄ℳΜЊŃŇŅН​​​​≫≪\n𝔑⁠\xA0ℕ⫬≢≭∦∉≠≂̸∄≯≱≧̸≫̸≹⩾̸≵≎̸≏̸⋪⧏̸⋬≮≰≸≪̸⩽̸≴⪢̸⪡̸⊀⪯̸⋠∌⋫⧐̸⋭⊏̸⋢⊐̸⋣⊂⃒⊈⊁⪰̸⋡≿̸⊃⃒⊉≁≄≇≉∤𝒩ÑΝŒÓÔОŐ𝔒ÒŌΩΟ𝕆“‘⩔𝒪ØÕ⨷Ö‾⏞⎴⏜∂П𝔓ΦΠ±ℌℙ⪻≺⪯≼≾″∏∷∝𝒫Ψ\"𝔔ℚ𝒬⤐®Ŕ⟫↠⤖ŘŖРℜ∋⇋⥯ℜΡ⟩→⇥⇄⌉⟧⥝⇂⥕⌋⊢↦⥛⊳⧐⊵⥏⥜↾⥔⇀⥓⇒ℝ⥰⇛ℛ↱⧴ЩШЬŚ⪼ŠŞŜС𝔖↓←→↑Σ∘𝕊√□⊓⊏⊑⊐⊒⊔𝒮⋆⋐⋐⊆≻⪰≽≿∋∑⋑⊃⊇⋑Þ™ЋЦ ΤŤŢТ𝔗∴Θ   ∼≃≅≈𝕋⃛𝒯ŦÚ↟⥉ЎŬÛУŰ𝔘ÙŪ_⏟⎵⏝⋃⊎Ų𝕌↑⤒⇅↕⥮⊥↥⇑⇕↖↗ϒΥŮ𝒰ŨÜ⊫⫫В⊩⫦⋁‖‖∣|❘≀ 𝔙𝕍𝒱⊪Ŵ⋀𝔚𝕎𝒲𝔛Ξ𝕏𝒳ЯЇЮÝŶЫ𝔜𝕐𝒴ŸЖŹŽЗŻ​Ζℨℤ𝒵áă∾∾̳∿â´аæ⁡𝔞àℵℵαā⨿&∧⩕⩜⩘⩚∠⦤∠∡⦨⦩⦪⦫⦬⦭⦮⦯∟⊾⦝∢Å⍼ą𝕒≈⩰⩯≊≋'≈≊å𝒶*≈≍ãä∳⨑⫭≌϶‵∽⋍⊽⌅⌅⎵⎶≌б„∵∵⦰϶ℬβℶ≬𝔟⋂◯⋃⨀⨁⨂⨆★▽△⨄⋁⋀⤍⧫▪▴▾◂▸␣▒░▓█=⃥≡⃥⌐𝕓⊥⊥⋈╗╔╖╓═╦╩╤╧╝╚╜╙║╬╣╠╫╢╟⧉╕╒┐┌─╥╨┬┴⊟⊞⊠╛╘┘└│╪╡╞┼┤├‵˘¦𝒷⁏∽⋍\\⧅⟈••≎⪮≏≏ć∩⩄⩉⩋⩇⩀∩︀⁁ˇ⩍čçĉ⩌⩐ċ¸⦲¢·𝔠ч✓✓χ○⧃ˆ≗↺↻®Ⓢ⊛⊚⊝≗⨐⫯⧂♣♣:≔≔,@∁∘∁ℂ≅⩭∮𝕔∐©℗↵✗𝒸⫏⫑⫐⫒⋯⤸⤵⋞⋟↶⤽∪⩈⩆⩊⊍⩅∪︀↷⤼⋞⋟⋎⋏¤↶↷⋎⋏∲∱⌭⇓⥥†ℸ↓‐⊣⤏˝ďдⅆ‡⇊⩷°δ⦱⥿𝔡⇃⇂⋄⋄♦♦¨ϝ⋲÷÷⋇⋇ђ⌞⌍$𝕕˙≐≑∸∔⊡⌆↓⇊⇃⇂⤐⌟⌌𝒹ѕ⧶đ⋱▿▾⇵⥯⦦џ⟿⩷≑é⩮ě≖ê≕эėⅇ≒𝔢⪚è⪖⪘⪙⏧ℓ⪕⪗ē∅∅∅   ŋ ę𝕖⋕⧣⩱εεϵ≖≕≂⪖⪕=≟≡⩸⧥≓⥱ℯ≐≂ηðë€!∃ℰⅇ≒ф♀ffiffffl𝔣fifj♭fl▱ƒ𝕗∀⋔⫙⨍½⅓¼⅕⅙⅛⅔⅖¾⅗⅜⅘⅚⅝⅞⁄⌢𝒻≧⪌ǵγϝ⪆ğĝгġ≥⋛≥≧⩾⩾⪩⪀⪂⪄⋛︀⪔𝔤≫⋙ℷѓ≷⪒⪥⪤≩⪊⪊⪈⪈≩⋧𝕘`ℊ≳⪎⪐>⪧⩺⋗⦕⩼⪆⥸⋗⋛⪌≷≳≩︀≩︀⇔ ½ℋъ↔⥈↭ℏĥ♥♥…⊹𝔥⤥⤦⇿∻↩↪𝕙―𝒽ℏħ⁃‐í⁣îие¡⇔𝔦ìⅈ⨌∭⧜℩ijīℑℐℑı⊷Ƶ∈℅∞⧝ı∫⊺ℤ⊺⨗⨼ёį𝕚ι⨼¿𝒾∈⋹⋵⋴⋳∈⁢ĩіïĵй𝔧ȷ𝕛𝒿јєκϰķк𝔨ĸхќ𝕜𝓀⇚⇐⤛⤎≦⪋⥢ĺ⦴ℒλ⟨⦑⟨⪅«←⇤⤟⤝↩↫⤹⥳↢⪫⤙⪭⪭︀⤌❲{[⦋⦏⦍ľļ⌈{л⤶“„⥧⥋↲≤←↢↽↼⇇↔⇆⇋↭⋋⋚≤≦⩽⩽⪨⩿⪁⪃⋚︀⪓⪅⋖⋚⪋≶≲⥼⌊𝔩≶⪑↽↼⥪▄љ≪⇇⌞⥫◺ŀ⎰⎰≨⪉⪉⪇⪇≨⋦⟬⇽⟦⟵⟷⟼⟶↫↬⦅𝕝⨭⨴∗_◊◊⧫(⦓⇆⌟⇋⥭‎⊿‹𝓁↰≲⪍⪏[‘‚ł<⪦⩹⋖⋋⋉⥶⩻⦖◃⊴◂⥊⥦≨︀≨︀∺¯♂✠✠↦↦↧↤↥▮⨩м—∡𝔪℧µ∣*⫰·−⊟∸⨪⫛…∓⊧𝕞∓𝓂∾μ⊸⊸⋙̸≫⃒≫̸⇍⇎⋘̸≪⃒≪̸⇏⊯⊮∇ń∠⃒≉⩰̸≋̸ʼn≉♮♮ℕ\xA0≎̸≏̸⩃ňņ≇⩭̸⩂н–≠⇗⤤↗↗≐̸≢⤨≂̸∄∄𝔫≧̸≱≱≧̸⩾̸⩾̸≵≯≯⇎↮⫲∋⋼⋺∋њ⇍≦̸↚‥≰↚↮≰≦̸⩽̸⩽̸≮≴≮⋪⋬∤𝕟¬∉⋹̸⋵̸∉⋷⋶∌∌⋾⋽∦∦⫽⃥∂̸⨔⊀⋠⪯̸⊀⪯̸⇏↛⤳̸↝̸↛⋫⋭⊁⋡⪰̸𝓃∤∦≁≄≄∤∦⋢⋣⊄⫅̸⊈⊂⃒⊈⫅̸⊁⪰̸⊅⫆̸⊉⊃⃒⊉⫆̸≹ñ≸⋪⋬⋫⋭ν#№ ⊭⤄≍⃒⊬≥⃒>⃒⧞⤂≤⃒<⃒⊴⃒⤃⊵⃒∼⃒⇖⤣↖↖⤧Ⓢó⊛⊚ôо⊝ő⨸⊙⦼œ⦿𝔬˛ò⧁⦵Ω∮↺⦾⦻‾⧀ōωο⦶⊖𝕠⦷⦹⊕∨↻⩝ℴℴªº⊶⩖⩗⩛ℴø⊘õ⊗⨶ö⌽∥¶∥⫳⫽∂п%.‰⊥‱𝔭φϕℳ☎π⋔ϖℏℎℏ+⨣⊞⨢∔⨥⩲±⨦⨧±⨕𝕡£≺⪳⪷≼⪯≺⪷≼⪯⪹⪵⋨≾′ℙ⪵⪹⋨∏⌮⌒⌓∝∝≾⊰𝓅ψ 𝔮⨌𝕢⁗𝓆ℍ⨖?≟\"⇛⇒⤜⤏⥤∽̱ŕ√⦳⟩⦒⦥⟩»→⥵⇥⤠⤳⤞↪↬⥅⥴↣↝⤚∶ℚ⤍❳}]⦌⦎⦐řŗ⌉}р⤷⥩””↳ℜℛℜℝ▭®⥽⌋𝔯⇁⇀⥬ρϱ→↣⇁⇀⇄⇌⇉↝⋌˚≓⇄⇌‏⎱⎱⫮⟭⇾⟧⦆𝕣⨮⨵)⦔⨒⇉›𝓇↱]’’⋌⋊▹⊵▸⧎⥨℞ś‚≻⪴⪸š≽⪰şŝ⪶⪺⋩⨓≿с⋅⊡⩦⇘⤥↘↘§;⤩∖∖✶𝔰⌢♯щш∣∥­σςς∼⩪≃≃⪞⪠⪝⪟≆⨤⥲←∖⨳⧤∣⌣⪪⪬⪬︀ь/⧄⌿𝕤♠♠∥⊓⊓︀⊔⊔︀⊏⊑⊏⊑⊐⊒⊐⊒□□▪▪→𝓈∖⌣⋆☆★ϵϕ¯⊂⫅⪽⊆⫃⫁⫋⊊⪿⥹⊂⊆⫅⊊⫋⫇⫕⫓≻⪸≽⪰⪺⪶⋩≿∑♪⊃¹²³⫆⪾⫘⊇⫄⟉⫗⥻⫂⫌⊋⫀⊃⊇⫆⊋⫌⫈⫔⫖⇙⤦↙↙⤪ß⌖τ⎴ťţт⃛⌕𝔱∴∴θϑϑ≈∼ ≈∼þ˜×⊠⨱⨰∭⤨⊤⌶⫱𝕥⫚⤩‴™▵▿◃⊴≜▹⊵◬≜⨺⨹⧍⨻⏢𝓉цћŧ≬↞↠⇑⥣ú↑ўŭûу⇅ű⥮⥾𝔲ù↿↾▀⌜⌜⌏◸ū¨ų𝕦↑↕↿↾⊎υϒυ⇈⌝⌝⌎ů◹𝓊⋰ũ▵▴⇈ü⦧⇕⫨⫩⊨⦜ϵϰ∅ϕϖ∝↕ϱς⊊︀⫋︀⊋︀⫌︀ϑ⊲⊳в⊢∨⊻≚⋮||𝔳⊲⊂⃒⊃⃒𝕧∝⊳𝓋⫋︀⊊︀⫌︀⊋︀⦚ŵ⩟∧≙℘𝔴𝕨℘≀≀𝓌⋂◯⋃▽𝔵⟺⟷ξ⟸⟵⟼⋻⨀𝕩⨁⨂⟹⟶𝓍⨆⨄△⋁⋀ýяŷы¥𝔶ї𝕪𝓎юÿźžзżℨζ𝔷ж⇝𝕫𝓏‍‌"];
14381
+ /** Multiplier deriving the first candidate bucket from a key. */
14382
+ const BUCKET_HASH_1 = 2654435761;
14383
+ /** Multiplier deriving the second candidate bucket from a key. */
14384
+ const BUCKET_HASH_2 = 2246822507;
14385
+ /** Size of the (c0,c1) class table (10-bit index). */
14386
+ const PAIR_TABLE_SIZE = 1024;
14387
+ /**
14388
+ * Map an alphanumeric char code to 6 bits (1..62); 0 = not alphanumeric.
14389
+ * Used for the key's last-character field.
14390
+ */
14391
+ const CHAR_REMAP = (() => {
14392
+ const remap = /* @__PURE__ */ new Uint8Array(128);
14393
+ for (let code = 48; code <= 57; code++) remap[code] = code - 47;
14394
+ for (let code = 65; code <= 90; code++) remap[code] = code - 54;
14395
+ for (let code = 97; code <= 122; code++) remap[code] = code - 60;
14396
+ return remap;
14320
14397
  })();
14321
14398
  /**
14322
- * Decode a dictionary-encoded trie string back into its Uint16Array.
14323
- *
14324
- * Stream layout (consumed in this order):
14325
- * 1. dict1 atoms — `dict1AtomCount` uint16 values, delta+RLE encoded.
14326
- * 2. dict2 atoms — `atomCount - dict1AtomCount` values, delta+RLE.
14327
- * 3. dict2 ngrams — `ngramCount - (dictSize - dict1AtomCount)` entries,
14328
- * each a pair of slot codes that resolve to earlier slots.
14329
- * 4. dict1 ngrams — `dictSize - dict1AtomCount` entries, same shape.
14330
- * 5. data — slot codes, each expanding to one or more uint16 values.
14331
- *
14332
- * Codes use a 91-char base (printable ASCII minus `"`, `$`, `\`):
14333
- * - char1 < dictSize → 1-char code, slot = char1
14334
- * - char1 ≥ dictSize → 2-char code, slot = dictSize + (char1 - dictSize)*91 + char2
14399
+ * The exact 32-bit key for a name occurring at `nameStart` with `length`
14400
+ * chars. Covers the first two and last two characters plus the length;
14401
+ * middle characters are verified separately against the names blob.
14335
14402
  *
14336
- * Slot index → token kind:
14337
- * [0, A) dict1 atoms (1-char codes)
14338
- * [A, dictSize) dict1 ngrams (1-char codes)
14339
- * [dictSize, dictSize+D) dict2 atoms (2-char codes)
14340
- * [dictSize+D, end) dict2 ngrams (2-char codes)
14341
- *
14342
- * Both atom dicts decode before any ngram, and dict2 ngrams decode before
14343
- * dict1 ngrams. So every ngram entry references slots whose contents are
14344
- * already filled — no forward references to handle.
14345
- *
14346
- * This runs on library import. Flat typed arrays store each slot as either
14347
- * a plain value (`single`, covering every atom) or a range in a shared
14348
- * `pool` (ngrams).
14349
- * @param input Packed trie string.
14350
- * @param resultLength Expected number of uint16 values in the output.
14351
- * @param atomCount Total number of distinct uint16 values in the trie.
14352
- * @param dict1AtomCount Atoms in the 1-char range (`A` above).
14353
- * @param ngramCount Total number of ngram entries (dict1 + dict2).
14354
- * @param dictSize Number of 1-char code slots; the rest of `BASE - dictSize`
14355
- * first-byte values are 2-char codes.
14356
- */
14357
- function decodeTrieDict(input, resultLength, atomCount, dict1AtomCount, ngramCount, dictSize) {
14358
- const base = 91;
14359
- const inputLength = input.length;
14360
- const twoCharBias = dictSize * 90;
14361
- let pos = 0;
14362
- /** Read one slot code at `pos` and return its slot index, advancing pos. */
14363
- const readSlotCode = () => {
14364
- const c1 = BASE91_INVERSE[input.charCodeAt(pos++)];
14365
- return c1 < dictSize ? c1 : c1 * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
14366
- };
14367
- const dict2AtomCount = atomCount - dict1AtomCount;
14368
- const slotCount = atomCount + ngramCount;
14369
- const single = new Int32Array(slotCount);
14370
- single.fill(-1, dict1AtomCount, dictSize);
14371
- single.fill(-1, dictSize + dict2AtomCount, slotCount);
14372
- const start = new Int32Array(slotCount);
14373
- const length = new Int32Array(slotCount);
14374
- /**
14375
- * Decode `count` ascending uint16 values from a delta+RLE stream into
14376
- * `single[off..off+count)`.
14377
- *
14378
- * code < 89 → delta = code
14379
- * code == 89 → run-length: next char encodes runLength-2; emit `runLength` consecutive +1 values
14380
- * code == 90, next < 90 → escape: delta = 89 + next * BASE + after-next
14381
- * code == 90, next == 90 → double-escape: extra char for very large deltas
14382
- * @param count
14383
- * @param off
14384
- */
14385
- function decodeDelta(count, off) {
14386
- let previous = 0;
14387
- let slot = off;
14388
- const end = off + count;
14389
- while (slot < end) {
14390
- const code = BASE91_INVERSE[input.charCodeAt(pos++)];
14391
- if (code < 89) {
14392
- previous += code;
14393
- single[slot++] = previous;
14394
- } else if (code === 89) {
14395
- let runLength = BASE91_INVERSE[input.charCodeAt(pos++)] + 2;
14396
- while (runLength--) single[slot++] = ++previous;
14397
- } else {
14398
- const next = BASE91_INVERSE[input.charCodeAt(pos++)];
14399
- previous += 89 + (next < 90 ? next * base + BASE91_INVERSE[input.charCodeAt(pos++)] : BASE91_INVERSE[input.charCodeAt(pos++)] * 8281 + BASE91_INVERSE[input.charCodeAt(pos++)] * base + BASE91_INVERSE[input.charCodeAt(pos++)]);
14400
- single[slot++] = previous;
14401
- }
14402
- }
14403
- }
14404
- decodeDelta(dict1AtomCount, 0);
14405
- decodeDelta(dict2AtomCount, dictSize);
14406
- const references = new Int32Array(ngramCount * 2);
14407
- let poolSize = 0;
14408
- let ngramIndex = 0;
14409
- /**
14410
- * Read `count` ngram entries (each = 2 slot-code references) for the slots
14411
- * starting at `startSlot`, recording references and assigning pool ranges.
14412
- * @param count
14413
- * @param startSlot
14414
- */
14415
- function readNgramReferences(count, startSlot) {
14416
- for (let index = 0; index < count; index++) {
14417
- const slot = startSlot + index;
14418
- const a = readSlotCode();
14419
- const b = readSlotCode();
14420
- references[ngramIndex * 2] = a;
14421
- references[ngramIndex * 2 + 1] = b;
14422
- ngramIndex += 1;
14423
- start[slot] = poolSize;
14424
- const entryLength = (single[a] < 0 ? length[a] : 1) + (single[b] < 0 ? length[b] : 1);
14425
- length[slot] = entryLength;
14426
- poolSize += entryLength;
14427
- }
14428
- }
14429
- readNgramReferences(ngramCount - dictSize + dict1AtomCount, dictSize + dict2AtomCount);
14430
- readNgramReferences(dictSize - dict1AtomCount, dict1AtomCount);
14431
- const pool = new Uint16Array(poolSize);
14432
- let write = 0;
14433
- for (let index = 0; index < ngramIndex; index++) for (let half = 0; half < 2; half++) {
14434
- const source = references[index * 2 + half];
14435
- const value = single[source];
14436
- if (value < 0) {
14437
- let read = start[source];
14438
- const readEnd = read + length[source];
14439
- while (read < readEnd) pool[write++] = pool[read++];
14440
- } else pool[write++] = value;
14441
- }
14442
- const out = new Uint16Array(resultLength);
14443
- let outIndex = 0;
14444
- while (pos < inputLength) {
14445
- let slot = BASE91_INVERSE[input.charCodeAt(pos++)];
14446
- if (slot >= dictSize) slot = slot * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
14447
- const value = single[slot];
14448
- if (value < 0) {
14449
- let read = start[slot];
14450
- const readEnd = read + length[slot];
14451
- while (read < readEnd) out[outIndex++] = pool[read++];
14452
- } else out[outIndex++] = value;
14403
+ * The hot decoder inlines this computation; tests assert both stay in sync
14404
+ * by looking every entity up through the public API.
14405
+ * @param text Text containing the name.
14406
+ * @param nameStart Index of the name's first character.
14407
+ * @param length Length of the name.
14408
+ */
14409
+ function exactKey(text, nameStart, length) {
14410
+ return text.charCodeAt(nameStart) << 25 | text.charCodeAt(nameStart + 1) << 18 | text.charCodeAt(nameStart + length - 2) << 11 | CHAR_REMAP[text.charCodeAt(nameStart + length - 1)] << 5 | length;
14411
+ }
14412
+ /**
14413
+ * The 10-bit (c0,c1) class index used by the probe front end. The function
14414
+ * was chosen by exhaustive search over load-free mixers for minimal
14415
+ * candidate-set collisions on the real entity set.
14416
+ * @param c0 First char code of the candidate name.
14417
+ * @param c1 Second char code.
14418
+ */
14419
+ function pairIndex(c0, c1) {
14420
+ return (c0 * 3 << 3 ^ c1) & 1023;
14421
+ }
14422
+ /**
14423
+ * First candidate bucket for a key in a table of `buckets` buckets.
14424
+ * @param key Exact key.
14425
+ * @param buckets Bucket count.
14426
+ */
14427
+ function bucketOne(key, buckets) {
14428
+ return (Math.imul(key, BUCKET_HASH_1) >>> 16) * buckets >>> 16;
14429
+ }
14430
+ /**
14431
+ * Second candidate bucket for a key.
14432
+ * @param key Exact key.
14433
+ * @param buckets Bucket count.
14434
+ */
14435
+ function bucketTwo(key, buckets) {
14436
+ return (Math.imul(key, BUCKET_HASH_2) >>> 16) * buckets >>> 16;
14437
+ }
14438
+ /**
14439
+ * Build the lookup structures from a serialized dataset.
14440
+ * @param packed Serialized decode data, see `decode-data-format.ts`.
14441
+ */
14442
+ function initDecodeData(packed) {
14443
+ const [data, values] = packed;
14444
+ const nameCount = data.charCodeAt(0) - 48 << 6 | data.charCodeAt(1) - 48;
14445
+ const suffixesLength = data.charCodeAt(2) - 48 << 6 | data.charCodeAt(3) - 48;
14446
+ const buckets = data.charCodeAt(4) - 48 << 6 | data.charCodeAt(5) - 48;
14447
+ const metaStart = 6 + suffixesLength;
14448
+ const choicesStart = metaStart + 2 * nameCount;
14449
+ const slotCount = 2 * buckets;
14450
+ const keys = new Int32Array(slotCount);
14451
+ const slotMidOff = new Uint16Array(slotCount);
14452
+ const slotValue = new Uint16Array(slotCount);
14453
+ const lengthBits = new Uint32Array(PAIR_TABLE_SIZE);
14454
+ const middleOffsets = /* @__PURE__ */ new Map();
14455
+ const middles = [];
14456
+ let name = "";
14457
+ let suffixOffset = 6;
14458
+ let valueOffset = 0;
14459
+ for (let index = 0; index < nameCount; index++) {
14460
+ const meta0 = data.charCodeAt(metaStart + 2 * index) - 35;
14461
+ const meta1 = data.charCodeAt(metaStart + 2 * index + 1) - 35;
14462
+ const prefixLength = meta0 & 31;
14463
+ const length = prefixLength + (meta1 & 31);
14464
+ const valueLength = (meta1 >> 5) + 1;
14465
+ name = name.slice(0, prefixLength) + data.slice(suffixOffset, suffixOffset + length - prefixLength);
14466
+ suffixOffset += length - prefixLength;
14467
+ const key = exactKey(name, 0, length);
14468
+ let slot = 2 * ((data.charCodeAt(choicesStart + Math.floor(index / 6)) - 48 & 1 << index % 6) === 0 ? bucketOne : bucketTwo)(key, buckets);
14469
+ if (keys[slot] !== 0) slot += 1;
14470
+ keys[slot] = key;
14471
+ if (length > 4) {
14472
+ const middle = name.slice(2, length - 2);
14473
+ const existing = middleOffsets.get(middle);
14474
+ if (existing === void 0) {
14475
+ middleOffsets.set(middle, middles.length);
14476
+ slotMidOff[slot] = middles.length;
14477
+ for (let middleIndex = 0; middleIndex < middle.length; middleIndex += 2) middles.push(middle.charCodeAt(middleIndex) | middle.charCodeAt(middleIndex + 1) << 16);
14478
+ } else slotMidOff[slot] = existing;
14479
+ }
14480
+ const pair = pairIndex(name.charCodeAt(0), name.charCodeAt(1));
14481
+ lengthBits[pair] |= length <= 16 ? 1 << length - 2 : 32768;
14482
+ if ((meta0 & 32) !== 0) lengthBits[pair] |= 1 << length - 2 + 16;
14483
+ slotValue[slot] = valueOffset << 2 | valueLength - 1 | (meta0 & 32) >> 4;
14484
+ valueOffset += valueLength;
14453
14485
  }
14454
- return out;
14486
+ return {
14487
+ keys,
14488
+ buckets,
14489
+ slotMidOff,
14490
+ slotValue,
14491
+ values,
14492
+ lengthBits,
14493
+ middles: new Uint32Array(middles)
14494
+ };
14455
14495
  }
14456
- // node_modules/entities/dist/generated/decode-data-html.js
14457
- /** Packed HTML decode trie data. */
14458
- const htmlDecodeTree = /* #__PURE__ */ decodeTrieDict("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(##%#'##+%'*.:1}#%#6-+(%'%%#%%%}#L'2351&('%}&/N'(0(/*-%(%%}#'+&T%7.2}#&%&#%#36/5##%&%%#&#%%#))2%%##%&&'0~!#*+&'%1~!%).'3q?&%'1~!.##%6(~!+%%%(Gw'rT~!E#<nA%#jZ~!H%(~!42##~!*31&~!G%U~#)5~#`3~!J~!Z~%]~%Y~%C~!q~!u~#kz~%#~!6'~!D~!U~!?~#T~!c%~!G#'~%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Q[y?3Dt%3[xn~<5rLOu!5p@Ku+D#'!t7~GrP~?rNKvlaya7'!h+v-5qMg=t|cd,U#5AAaa5Abb{S@52B5@a[@52B5Gx[iXueu;d<#`a(!/549C;ag>23ExY5@Dah89b^~689Jv)!~2b[~1Lv'w(%*!a#bX|aPrmawRe]keu7uhv-q6rxu,q`xTo]/a5aU!bNaDXbi!b-!ao!b<bwA!#5@B932:aV2G|:d-)Y#hJrL>RhG<7@C5<H|_=Cau:5aj5@B932:bJ|ng>vIbs)#?C2F|9jPv0w.vISh-MKvUaz(.!9ABbb|[5;5<H|Eg>unwfh;9:4E|YjQsBt|vjx'hYq3!(?C2F|J:2<BaY?C2F|GOu!5x,g|p{ah!-(?C2F|c9:4E|OjXuvvNr}:Rh&i[w*t|cd+U#jJvsu)vsSn~Mkfrmu9p}u7vwv]So!McW#Xa!ax5@A5aY:5;5<H|>kJv~vYrquJu3x4ib#T)2@SmZM?C2F|Bj:rmu9@xPhI(a*a#U#`a3-5Abb|L~@:RhK9:4E|0@52B5G|#C::aY?C2F|-:2<BaY?C2F|.5Jvk!a)javYrquJu3x4ia#T)2@SmYM?C2F|HAxPhH(!a#U#`a*-5Abb|4~@:RhJ9:4E|R@52B5G|F:2<BaY?C2F|Sc^#Xa2j=Qq5CJvB!-g<v{z;hhM?C2F|Zi[vrv{z;hiM?C2F|XKsA>!a)-g<v{z;h[eb?C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P", 13494, 2713, 49, 25, 61);
14459
- // node_modules/entities/dist/generated/decode-data-xml.js
14460
- /** Packed XML decode trie data. */
14461
- const xmlDecodeTree = /* #__PURE__ */ new Uint16Array([
14462
- 512,
14463
- 26465,
14464
- 29036,
14465
- 7,
14466
- 0,
14467
- 2,
14468
- 4,
14469
- 116,
14470
- 24638,
14471
- 116,
14472
- 24636,
14473
- 8693,
14474
- 29807,
14475
- 24610,
14476
- 621,
14477
- 1,
14478
- 0,
14479
- 0,
14480
- 3,
14481
- 112,
14482
- 24614,
14483
- 111,
14484
- 115,
14485
- 24615
14486
- ]);
14487
- // node_modules/entities/dist/internal/bin-trie-flags.js
14488
- /**
14489
- * Bit flags & masks for the binary trie encoding used for entity decoding.
14490
- *
14491
- * The trie is a flat `Uint16Array`. Every node starts with one header word:
14492
- *
14493
- * 15..14 VALUE_LENGTH Number of words the value occupies, +1.
14494
- * 0 = no value; 1 = value inline in bits 12..0;
14495
- * 2/3 = value in the 1/2 words after the header.
14496
- * 13 FLAG13 If VALUE_LENGTH > 0: semicolon required ("strict"
14497
- * entity; `;` is never stored as a branch).
14498
- * If VALUE_LENGTH == 0: this node is a compact run.
14499
- * 12..7 BRANCH_LENGTH Number of branches (or run length for runs).
14500
- * 6..0 JUMP_TABLE Jump-table offset / single-branch char / first
14501
- * run char (see below).
14502
- *
14503
- * Branch data follows the header and any value words. Its shape is selected
14504
- * by (JUMP_TABLE, BRANCH_LENGTH) in the header:
14505
- *
14506
- * Single branch JUMP_TABLE = the only child's char, BRANCH_LENGTH = 0.
14507
- * No branch words; the child node follows immediately.
14508
- * Jump table JUMP_TABLE = first covered char (> 0), BRANCH_LENGTH =
14509
- * table length. One word per covered char: 0 = no branch,
14510
- * otherwise the child's offset from the END of the table,
14511
- * +1 (so 0 stays the no-branch sentinel).
14512
- * Dictionary JUMP_TABLE = 0, BRANCH_LENGTH = number of branches.
14513
- * ceil(n/2) words of sorted keys packed two per word
14514
- * (low byte first), then n pointer words storing the
14515
- * child's offset from the END of the branch data.
14516
- * Compact run VALUE_LENGTH = 0, FLAG13 set. BRANCH_LENGTH = run
14517
- * length (3..63), JUMP_TABLE = first char; remaining run
14518
- * chars packed two per word after the header. The target
14519
- * node follows the packed words immediately.
14520
- *
14521
- * Pointers are end-relative (rather than relative to the pointer's own
14522
- * position) because that makes the common "child encoded right after the
14523
- * branch data" case a small constant, which compresses far better. Offsets
14524
- * to already-encoded (shared) nodes wrap via uint16 modulo arithmetic; the
14525
- * decoder masks navigation results with `& 0xff_ff` to match.
14526
- */
14527
- var BinTrieFlags;
14528
- (function(BinTrieFlags) {
14529
- BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
14530
- BinTrieFlags[BinTrieFlags["FLAG13"] = 8192] = "FLAG13";
14531
- BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
14532
- BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
14533
- /** Bits 12..0: the inline value of a VALUE_LENGTH = 1 header word. */
14534
- BinTrieFlags[BinTrieFlags["VALUE_MASK"] = 8191] = "VALUE_MASK";
14535
- })(BinTrieFlags || (BinTrieFlags = {}));
14536
14496
  // node_modules/entities/dist/decode.js
14537
- var CharCodes;
14538
- (function(CharCodes) {
14539
- CharCodes[CharCodes["AMP"] = 38] = "AMP";
14540
- CharCodes[CharCodes["NUM"] = 35] = "NUM";
14541
- CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
14542
- CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
14543
- CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
14544
- CharCodes[CharCodes["NINE"] = 57] = "NINE";
14545
- CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
14546
- CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
14547
- })(CharCodes || (CharCodes = {}));
14497
+ const CHAR_NUM = 35;
14498
+ const CHAR_SEMI = 59;
14499
+ const CHAR_EQUALS = 61;
14500
+ const CHAR_ZERO = 48;
14501
+ const CHAR_LOWER_A = 97;
14502
+ const CHAR_LOWER_X = 120;
14503
+ const CHAR_UPPER_A = 65;
14548
14504
  /** Bit that needs to be set to convert an upper case ASCII character to lower case */
14549
14505
  const TO_LOWER_BIT = 32;
14550
14506
  /**
@@ -14553,13 +14509,10 @@ const TO_LOWER_BIT = 32;
14553
14509
  * @param code Code point to check.
14554
14510
  */
14555
14511
  function isNumber(code) {
14556
- return code - CharCodes.ZERO >>> 0 <= 9;
14557
- }
14558
- function isHexadecimalCharacter(code) {
14559
- return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 5;
14512
+ return code - CHAR_ZERO >>> 0 <= 9;
14560
14513
  }
14561
- function isAlpha(code) {
14562
- return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 25;
14514
+ function isAlphaNumeric(code) {
14515
+ return isNumber(code) || (code | TO_LOWER_BIT) - CHAR_LOWER_A >>> 0 <= 25;
14563
14516
  }
14564
14517
  /**
14565
14518
  * Checks if the given character is a valid end character for an entity in an attribute.
@@ -14569,16 +14522,8 @@ function isAlpha(code) {
14569
14522
  * @param code Code point to check.
14570
14523
  */
14571
14524
  function isEntityInAttributeInvalidEnd(code) {
14572
- return code === CharCodes.EQUALS || isAlpha(code) || isNumber(code);
14525
+ return code === CHAR_EQUALS || isAlphaNumeric(code);
14573
14526
  }
14574
- var EntityDecoderState;
14575
- (function(EntityDecoderState) {
14576
- EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
14577
- EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
14578
- EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
14579
- EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
14580
- EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
14581
- })(EntityDecoderState || (EntityDecoderState = {}));
14582
14527
  /**
14583
14528
  * Decoding mode for named entities.
14584
14529
  */
@@ -14591,81 +14536,146 @@ var DecodingMode;
14591
14536
  /** Entities in attributes have limitations on ending characters. */
14592
14537
  DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
14593
14538
  })(DecodingMode || (DecodingMode = {}));
14539
+ /** Decode data for HTML entities. */
14540
+ const htmlDecode = /* #__PURE__ */ initDecodeData(htmlDecodeData);
14541
+ const htmlKeys = /* #__PURE__ */ (() => htmlDecode.keys)();
14542
+ const htmlBuckets = /* #__PURE__ */ (() => htmlDecode.buckets)();
14543
+ const htmlSlotMidOff = /* #__PURE__ */ (() => htmlDecode.slotMidOff)();
14544
+ const htmlLengthBits = /* #__PURE__ */ (() => htmlDecode.lengthBits)();
14545
+ const htmlMiddles = /* #__PURE__ */ (() => htmlDecode.middles)();
14546
+ /** Hoisted for the specialized HTML cores; see `emitHtmlValue`. */
14547
+ const htmlSlotValue = /* #__PURE__ */ (() => htmlDecode.slotValue)();
14548
+ const htmlValues = /* #__PURE__ */ (() => htmlDecode.values)();
14549
+ /**
14550
+ * Find the slot matching `text[start..start+length)`, or -1. A match proves
14551
+ * every character of the span (exact key + middle comparison).
14552
+ * @param text Input text.
14553
+ * @param start Start of the span in `text`.
14554
+ * @param length Length of the span.
14555
+ */
14556
+ function findSlotHtml(text, start, length) {
14557
+ const c0 = text.charCodeAt(start);
14558
+ const c1 = text.charCodeAt(start + 1);
14559
+ const c2 = text.charCodeAt(start + length - 2);
14560
+ const c3 = text.charCodeAt(start + length - 1);
14561
+ if ((c0 | c1 | c2 | c3) > 127) return -1;
14562
+ const key = c0 << 25 | c1 << 18 | c2 << 11 | CHAR_REMAP[c3] << 5 | length;
14563
+ let slot = 2 * ((Math.imul(key, BUCKET_HASH_1) >>> 16) * htmlBuckets >>> 16);
14564
+ for (let attempt = 0;; attempt++) {
14565
+ if (htmlKeys[slot] === key && (length <= 4 || isMidMatchHtml(slot, text, start, length))) return slot;
14566
+ if (htmlKeys[slot + 1] === key && (length <= 4 || isMidMatchHtml(slot + 1, text, start, length))) return slot + 1;
14567
+ if (attempt === 1) return -1;
14568
+ slot = 2 * ((Math.imul(key, BUCKET_HASH_2) >>> 16) * htmlBuckets >>> 16);
14569
+ }
14570
+ }
14571
+ /**
14572
+ * Compare the middle characters (positions 2..length-3) of the candidate at
14573
+ * `slot` against the input. The key already proves the outer characters and
14574
+ * the length. Names of length at most four are accepted by the caller.
14575
+ * @param slot Slot of the candidate.
14576
+ * @param text Input text.
14577
+ * @param start Start of the span in `text`.
14578
+ * @param length Length of the span.
14579
+ */
14580
+ function isMidMatchHtml(slot, text, start, length) {
14581
+ let wordIndex = htmlSlotMidOff[slot];
14582
+ let index = start + 2;
14583
+ const end = start + length - 2;
14584
+ while (index + 1 < end) {
14585
+ if ((text.charCodeAt(index) | text.charCodeAt(index + 1) << 16) !== htmlMiddles[wordIndex++]) return false;
14586
+ index += 2;
14587
+ }
14588
+ return index === end || text.charCodeAt(index) === (htmlMiddles[wordIndex] & 65535);
14589
+ }
14590
+ /** ASCII digit values; 0xff marks characters outside the hexadecimal range. */
14591
+ const numericDigits = /* #__PURE__ */ (() => {
14592
+ const digits = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
14593
+ for (let digit = 0; digit < 10; digit++) digits[CHAR_ZERO + digit] = digit;
14594
+ for (let digit = 0; digit < 6; digit++) {
14595
+ digits[CHAR_UPPER_A + digit] = digit + 10;
14596
+ digits[CHAR_LOWER_A + digit] = digit + 10;
14597
+ }
14598
+ return digits;
14599
+ })();
14600
+ /**
14601
+ * Find the longest legacy (semicolon-less) match for the name starting at
14602
+ * `start`, using the per-class legacy length bits. Returns
14603
+ * `slot << 3 | matchLength`, or -1 if there is no match. Only called after
14604
+ * the exact probes failed (the miss path).
14605
+ * @param input Input text.
14606
+ * @param start Start of the name.
14607
+ * @param maxLength Number of available run characters.
14608
+ */
14609
+ function findLegacySlot(input, start, maxLength) {
14610
+ let legacy = htmlLengthBits[pairIndex(input.charCodeAt(start), input.charCodeAt(start + 1))] >>> 16 & 31;
14611
+ while (legacy !== 0) {
14612
+ const top = 31 - Math.clz32(legacy);
14613
+ legacy ^= 1 << top;
14614
+ if (top + 2 > maxLength) continue;
14615
+ const slot = findSlotHtml(input, start, top + 2);
14616
+ if (slot >= 0 && (htmlSlotValue[slot] & 2) !== 0) return slot << 3 | top + 2;
14617
+ }
14618
+ return -1;
14619
+ }
14594
14620
  /**
14595
- * Token decoder with support of writing partial entities.
14621
+ * Match a class containing long names without probing all its shorter lengths.
14622
+ * The 32-character window bounds the scan even for invalid or unterminated runs.
14623
+ * Returns `(slot << 6) | consumed`, excluding the `&`, or -1 on a miss.
14624
+ * @param input Input containing the candidate name.
14625
+ * @param start Start of the name.
14626
+ * @param mode Decoding mode, including the rules for legacy matches.
14596
14627
  */
14597
- var EntityDecoder = class {
14598
- decodeTree;
14628
+ function findLongClassMatch(input, start, mode) {
14629
+ const length = input.slice(start, start + 32).indexOf(";");
14630
+ if (length - 2 >>> 0 <= 29) {
14631
+ const slot = findSlotHtml(input, start, length);
14632
+ if (slot >= 0) return slot << 6 | length + 1;
14633
+ }
14634
+ if (mode !== DecodingMode.Strict) {
14635
+ const packed = findLegacySlot(input, start, Math.min(31, input.length - start));
14636
+ if (packed >= 0) {
14637
+ const length = packed & 7;
14638
+ if (mode !== DecodingMode.Attribute || start + length >= input.length || !isEntityInAttributeInvalidEnd(input.charCodeAt(start + length))) return packed >> 3 << 6 | length;
14639
+ }
14640
+ }
14641
+ return -1;
14642
+ }
14643
+ const STATE_ENTITY_START = 0;
14644
+ const STATE_NUMERIC_START = 1;
14645
+ const STATE_NUMERIC_DECIMAL = 2;
14646
+ const STATE_NUMERIC_HEX = 3;
14647
+ const STATE_NAMED_ENTITY = 4;
14648
+ /**
14649
+ * Token decoder with support of writing partial entities; the shared base
14650
+ * of `HtmlEntityDecoder` and `XmlEntityDecoder`. Numeric entities are
14651
+ * identical in both document types and are handled here; named entities are
14652
+ * left to the subclasses.
14653
+ *
14654
+ * The decoder is driven by a tokenizer: after a `&`, write the following
14655
+ * input (possibly in chunks). `write` returns the number of characters
14656
+ * consumed once the entity is decided, or -1 while more input is needed.
14657
+ * Rejection may surface later than strictly possible (the decoder buffers
14658
+ * until a terminator or the name-length limit), but emitted code points,
14659
+ * consumed counts, and final return values are exact.
14660
+ */
14661
+ var EntityDecoderBase = class {
14599
14662
  emitCodePoint;
14600
14663
  errors;
14601
14664
  /** The current state of the decoder. */
14602
- state = EntityDecoderState.EntityStart;
14665
+ state = STATE_ENTITY_START;
14603
14666
  /** Characters that were consumed while parsing an entity. */
14604
14667
  consumed = 1;
14605
- /**
14606
- * The result of the entity.
14607
- *
14608
- * For named entities: the trie index of the best legacy match so far
14609
- * (0 = none). For numeric entities: the accumulated code point.
14610
- */
14668
+ /** Accumulated numeric code point, or a packed partial XML name. */
14611
14669
  result = 0;
14612
- /** The current index in the decode tree. */
14613
- treeIndex = 0;
14614
- /**
14615
- * Characters consumed since the last recorded legacy match, plus one.
14616
- * Invariant at the top of the `stateNamedEntity` loop: `excess` equals
14617
- * the number of unrecorded consumed characters + 1.
14618
- */
14619
- excess = 1;
14620
14670
  /** The mode in which the decoder is operating. */
14621
14671
  decodeMode = DecodingMode.Strict;
14622
- /** The number of characters that have been consumed in the current run. */
14623
- runConsumed = 0;
14624
- constructor(decodeTree, emitCodePoint, errors) {
14625
- this.decodeTree = decodeTree;
14672
+ /** Replacement rules for numeric character references. */
14673
+ replaceNumericCodePoint = replaceCodePoint;
14674
+ constructor(emitCodePoint, errors) {
14626
14675
  this.emitCodePoint = emitCodePoint;
14627
14676
  this.errors = errors;
14628
14677
  }
14629
14678
  /**
14630
- * Resets the instance to make it reusable.
14631
- * @param decodeMode Entity decoding mode to use.
14632
- */
14633
- startEntity(decodeMode) {
14634
- this.decodeMode = decodeMode;
14635
- this.state = EntityDecoderState.EntityStart;
14636
- this.result = 0;
14637
- this.treeIndex = 0;
14638
- this.excess = 1;
14639
- this.consumed = 1;
14640
- this.runConsumed = 0;
14641
- }
14642
- /**
14643
- * Write an entity to the decoder. This can be called multiple times with partial entities.
14644
- * If the entity is incomplete, the decoder will return -1.
14645
- *
14646
- * Mirrors the non-streaming `decodeWithTrie`, but with the ability to stop decoding if the
14647
- * entity is incomplete, and resume when the next string is written.
14648
- * @param input The string containing the entity (or a continuation of the entity).
14649
- * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
14650
- * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
14651
- */
14652
- write(input, offset) {
14653
- switch (this.state) {
14654
- case EntityDecoderState.EntityStart:
14655
- if (input.charCodeAt(offset) === CharCodes.NUM) {
14656
- this.state = EntityDecoderState.NumericStart;
14657
- this.consumed += 1;
14658
- return this.stateNumericStart(input, offset + 1);
14659
- }
14660
- this.state = EntityDecoderState.NamedEntity;
14661
- return this.stateNamedEntity(input, offset);
14662
- case EntityDecoderState.NumericStart: return this.stateNumericStart(input, offset);
14663
- case EntityDecoderState.NumericDecimal: return this.stateNumericDecimal(input, offset);
14664
- case EntityDecoderState.NumericHex: return this.stateNumericHex(input, offset);
14665
- default: return this.stateNamedEntity(input, offset);
14666
- }
14667
- }
14668
- /**
14669
14679
  * Switches between the numeric decimal and hexadecimal states.
14670
14680
  *
14671
14681
  * Equivalent to the `Numeric character reference state` in the HTML spec.
@@ -14675,40 +14685,37 @@ var EntityDecoder = class {
14675
14685
  */
14676
14686
  stateNumericStart(input, offset) {
14677
14687
  if (offset >= input.length) return -1;
14678
- if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
14679
- this.state = EntityDecoderState.NumericHex;
14688
+ if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CHAR_LOWER_X) {
14689
+ this.state = STATE_NUMERIC_HEX;
14680
14690
  this.consumed += 1;
14681
14691
  return this.stateNumericHex(input, offset + 1);
14682
14692
  }
14683
- this.state = EntityDecoderState.NumericDecimal;
14693
+ this.state = STATE_NUMERIC_DECIMAL;
14684
14694
  return this.stateNumericDecimal(input, offset);
14685
14695
  }
14686
14696
  /**
14687
14697
  * Parses a hexadecimal numeric entity.
14688
14698
  *
14689
- * Equivalent to the `Hexademical character reference state` in the HTML
14690
- * spec. Digit parsing matches the hex loop in `parseNumericEntity`.
14691
- * The accumulated value is preserved for numeric validation callbacks.
14699
+ * Equivalent to the `Hexadecimal character reference state` in the HTML spec.
14692
14700
  * @param input The string containing the entity (or a continuation of the entity).
14693
14701
  * @param offset The current offset.
14694
14702
  * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
14695
14703
  */
14696
14704
  stateNumericHex(input, offset) {
14697
14705
  const inputLength = input.length;
14698
- let { result } = this;
14699
- let { consumed } = this;
14700
- while (offset < inputLength) {
14701
- const char = input.charCodeAt(offset);
14702
- if (isNumber(char) || isHexadecimalCharacter(char)) {
14703
- const digit = char <= CharCodes.NINE ? char - CharCodes.ZERO : (char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10;
14704
- result = result * 16 + digit;
14705
- consumed += 1;
14706
- offset += 1;
14707
- } else {
14706
+ let { result, consumed } = this;
14707
+ let index = offset;
14708
+ while (index < inputLength) {
14709
+ const char = input.charCodeAt(index);
14710
+ const digit = numericDigits[char];
14711
+ if (digit <= 15) result = result * 16 + digit;
14712
+ else {
14708
14713
  this.result = result;
14709
14714
  this.consumed = consumed;
14710
14715
  return this.emitNumericEntity(char, 3);
14711
14716
  }
14717
+ consumed += 1;
14718
+ index += 1;
14712
14719
  }
14713
14720
  this.result = result;
14714
14721
  this.consumed = consumed;
@@ -14717,27 +14724,25 @@ var EntityDecoder = class {
14717
14724
  /**
14718
14725
  * Parses a decimal numeric entity.
14719
14726
  *
14720
- * Equivalent to the `Decimal character reference state` in the HTML
14721
- * spec. Digit parsing matches the decimal loop in `parseNumericEntity`.
14722
- * The accumulated value is preserved for numeric validation callbacks.
14727
+ * Equivalent to the `Decimal character reference state` in the HTML spec.
14723
14728
  * @param input The string containing the entity (or a continuation of the entity).
14724
14729
  * @param offset The current offset.
14725
14730
  * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
14726
14731
  */
14727
14732
  stateNumericDecimal(input, offset) {
14728
14733
  const inputLength = input.length;
14729
- let { result } = this;
14730
- let { consumed } = this;
14731
- while (offset < inputLength) {
14732
- const digit = input.charCodeAt(offset) - CharCodes.ZERO;
14734
+ let { result, consumed } = this;
14735
+ let index = offset;
14736
+ while (index < inputLength) {
14737
+ const digit = input.charCodeAt(index) - CHAR_ZERO;
14733
14738
  if (digit >>> 0 > 9) {
14734
14739
  this.result = result;
14735
14740
  this.consumed = consumed;
14736
- return this.emitNumericEntity(digit + CharCodes.ZERO, 2);
14741
+ return this.emitNumericEntity(digit + CHAR_ZERO, 2);
14737
14742
  }
14738
14743
  result = result * 10 + digit;
14739
14744
  consumed += 1;
14740
- offset += 1;
14745
+ index += 1;
14741
14746
  }
14742
14747
  this.result = result;
14743
14748
  this.consumed = consumed;
@@ -14746,7 +14751,7 @@ var EntityDecoder = class {
14746
14751
  /**
14747
14752
  * Validate and emit a numeric entity.
14748
14753
  *
14749
- * Implements the logic from the `Hexademical character reference start
14754
+ * Implements the logic from the `Hexadecimal character reference start
14750
14755
  * state` and `Numeric character reference end state` in the HTML spec.
14751
14756
  * @param lastCp The last code point of the entity. Used to see if the
14752
14757
  * entity was terminated with a semicolon.
@@ -14760,154 +14765,47 @@ var EntityDecoder = class {
14760
14765
  this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
14761
14766
  return 0;
14762
14767
  }
14763
- if (lastCp === CharCodes.SEMI) this.consumed += 1;
14768
+ if (lastCp === CHAR_SEMI) this.consumed += 1;
14764
14769
  else if (this.decodeMode === DecodingMode.Strict) return 0;
14765
- this.emitCodePoint((this.decodeTree === xmlDecodeTree ? replaceCodePointXML : replaceCodePoint)(this.result), this.consumed);
14770
+ this.emitCodePoint(this.replaceNumericCodePoint(this.result), this.consumed);
14766
14771
  if (this.errors) {
14767
- if (lastCp !== CharCodes.SEMI) this.errors.missingSemicolonAfterCharacterReference();
14772
+ if (lastCp !== CHAR_SEMI) this.errors.missingSemicolonAfterCharacterReference();
14768
14773
  this.errors.validateNumericCharacterReference(this.result);
14769
14774
  }
14770
14775
  return this.consumed;
14771
14776
  }
14772
14777
  /**
14773
- * Flush locally-tracked walk state back to the fields, then emit the
14774
- * recorded legacy match or reject (cold path — at most once per
14775
- * entity). Called after failed navigation (leaf node, branch miss, or
14776
- * compact-run mismatch). In attribute mode, reject if no legacy was
14777
- * recorded at the current node, if we descended past it, or if the
14778
- * pending input character is an invalid attribute terminator.
14779
- * @param consumed Locally-tracked consumed count.
14780
- * @param excess Locally-tracked excess count.
14781
- * @param char Pending input character (may be the mismatching char).
14782
- * @param valueLength Value length at the current trie node.
14778
+ * Resets the instance to make it reusable.
14779
+ * @param decodeMode Entity decoding mode to use.
14783
14780
  */
14784
- flushAndEmitLegacyOrReject(consumed, excess, char, valueLength) {
14785
- this.consumed = consumed;
14786
- this.excess = excess;
14787
- return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || excess > 1 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
14781
+ startEntity(decodeMode) {
14782
+ this.decodeMode = decodeMode;
14783
+ this.state = STATE_ENTITY_START;
14784
+ this.result = 0;
14785
+ this.consumed = 1;
14788
14786
  }
14789
14787
  /**
14790
- * Parses a named entity.
14791
- *
14792
- * Equivalent to the `Named character reference state` in the HTML spec.
14788
+ * Write an entity to the decoder. This can be called multiple times with partial entities.
14789
+ * If the entity is incomplete, the decoder will return -1.
14793
14790
  * @param input The string containing the entity (or a continuation of the entity).
14794
- * @param offset The current offset.
14791
+ * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
14795
14792
  * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
14796
14793
  */
14797
- stateNamedEntity(input, offset) {
14798
- const { decodeTree } = this;
14799
- const inputLength = input.length;
14800
- const isStrict = this.decodeMode === DecodingMode.Strict;
14801
- let { treeIndex } = this;
14802
- let { excess } = this;
14803
- let { consumed } = this;
14804
- let current = decodeTree[treeIndex];
14805
- while (offset < inputLength) {
14806
- while ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === 0 && (current & BinTrieFlags.JUMP_TABLE) !== 0) {
14807
- const char = input.charCodeAt(offset);
14808
- const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
14809
- const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
14810
- if (branchCount === 0) {
14811
- if (char !== jumpOffset) return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
14812
- treeIndex += 1;
14813
- } else {
14814
- const slot = char - jumpOffset;
14815
- if (slot >>> 0 >= branchCount) return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
14816
- const stored = decodeTree[treeIndex + 1 + slot];
14817
- if (stored === 0) return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
14818
- treeIndex = treeIndex + branchCount + stored & 65535;
14819
- }
14820
- current = decodeTree[treeIndex];
14821
- offset += 1;
14822
- excess += 1;
14823
- if (offset >= inputLength) break;
14824
- }
14825
- if (offset >= inputLength) break;
14826
- if ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === BinTrieFlags.FLAG13) {
14827
- const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
14828
- let { runConsumed } = this;
14829
- if (runConsumed === 0) {
14830
- const char = input.charCodeAt(offset);
14831
- if (char !== (current & BinTrieFlags.JUMP_TABLE)) return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
14832
- offset += 1;
14833
- excess += 1;
14834
- runConsumed = 1;
14835
- }
14836
- while (runConsumed < runLength) {
14837
- if (offset >= inputLength) {
14838
- this.treeIndex = treeIndex;
14839
- this.excess = excess;
14840
- this.consumed = consumed;
14841
- this.runConsumed = runConsumed;
14842
- return -1;
14843
- }
14844
- const charIndexInPacked = runConsumed - 1;
14845
- const expectedChar = decodeTree[treeIndex + 1 + (charIndexInPacked >> 1)] >> ((charIndexInPacked & 1) << 3) & 255;
14846
- const char = input.charCodeAt(offset);
14847
- if (char !== expectedChar) {
14848
- this.runConsumed = 0;
14849
- return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
14850
- }
14851
- offset += 1;
14852
- excess += 1;
14853
- runConsumed += 1;
14854
- }
14855
- this.runConsumed = 0;
14856
- treeIndex += 1 + (runLength >> 1);
14857
- current = decodeTree[treeIndex];
14858
- continue;
14859
- }
14860
- const valueLength = current >>> 14;
14861
- const char = input.charCodeAt(offset);
14862
- if (valueLength !== 0) {
14863
- if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
14864
- this.result = treeIndex;
14865
- consumed += excess - 1;
14866
- excess = 1;
14794
+ write(input, offset) {
14795
+ switch (this.state) {
14796
+ case STATE_ENTITY_START:
14797
+ if (input.charCodeAt(offset) === CHAR_NUM) {
14798
+ this.state = STATE_NUMERIC_START;
14799
+ this.consumed += 1;
14800
+ return this.stateNumericStart(input, offset + 1);
14867
14801
  }
14868
- if (char === CharCodes.SEMI) return this.emitNamedEntityData(treeIndex, valueLength, consumed + excess);
14869
- if (valueLength === 1) return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);
14870
- }
14871
- const next = determineBranch(decodeTree, current, treeIndex + (valueLength || 1), char);
14872
- if (next < 0) return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);
14873
- treeIndex = next;
14874
- current = decodeTree[treeIndex];
14875
- offset += 1;
14876
- excess += 1;
14877
- }
14878
- if (!isStrict && current >>> 14 !== 0 && (current & BinTrieFlags.FLAG13) === 0) {
14879
- this.result = treeIndex;
14880
- consumed += excess - 1;
14881
- excess = 1;
14882
- }
14883
- this.treeIndex = treeIndex;
14884
- this.excess = excess;
14885
- this.consumed = consumed;
14886
- return -1;
14887
- }
14888
- /**
14889
- * Emit a named entity that was not terminated with a semicolon.
14890
- * @returns The number of characters consumed.
14891
- */
14892
- emitNotTerminatedNamedEntity() {
14893
- const { result, decodeTree } = this;
14894
- const valueLength = decodeTree[result] >>> 14;
14895
- this.emitNamedEntityData(result, valueLength, this.consumed);
14896
- this.errors?.missingSemicolonAfterCharacterReference();
14897
- return this.consumed;
14898
- }
14899
- /**
14900
- * Emit a named entity.
14901
- * @param result The index of the entity in the decode tree.
14902
- * @param valueLength Encoded value length (header plus any value words).
14903
- * @param consumed The number of characters consumed.
14904
- * @returns The number of characters consumed.
14905
- */
14906
- emitNamedEntityData(result, valueLength, consumed) {
14907
- const { decodeTree } = this;
14908
- this.emitCodePoint(valueLength === 1 ? decodeTree[result] & BinTrieFlags.VALUE_MASK : decodeTree[result + 1], consumed);
14909
- if (valueLength === 3) this.emitCodePoint(decodeTree[result + 2], consumed);
14910
- return consumed;
14802
+ this.state = STATE_NAMED_ENTITY;
14803
+ return this.stateNamedEntity(input, offset);
14804
+ case STATE_NUMERIC_START: return this.stateNumericStart(input, offset);
14805
+ case STATE_NUMERIC_DECIMAL: return this.stateNumericDecimal(input, offset);
14806
+ case STATE_NUMERIC_HEX: return this.stateNumericHex(input, offset);
14807
+ default: return this.stateNamedEntity(input, offset);
14808
+ }
14911
14809
  }
14912
14810
  /**
14913
14811
  * Signal to the parser that the end of the input was reached.
@@ -14917,10 +14815,10 @@ var EntityDecoder = class {
14917
14815
  */
14918
14816
  end() {
14919
14817
  switch (this.state) {
14920
- case EntityDecoderState.NamedEntity: return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
14921
- case EntityDecoderState.NumericDecimal: return this.emitNumericEntity(0, 2);
14922
- case EntityDecoderState.NumericHex: return this.emitNumericEntity(0, 3);
14923
- case EntityDecoderState.NumericStart:
14818
+ case STATE_NAMED_ENTITY: return this.endNamedEntity();
14819
+ case STATE_NUMERIC_DECIMAL: return this.emitNumericEntity(0, 2);
14820
+ case STATE_NUMERIC_HEX: return this.emitNumericEntity(0, 3);
14821
+ case STATE_NUMERIC_START:
14924
14822
  this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
14925
14823
  return 0;
14926
14824
  default: return 0;
@@ -14928,34 +14826,168 @@ var EntityDecoder = class {
14928
14826
  }
14929
14827
  };
14930
14828
  /**
14931
- * Determines the branch of the current node that is taken given the current
14932
- * character. This function is used to traverse the trie.
14829
+ * Streaming decoder for HTML entities.
14933
14830
  *
14934
- * See `BinTrieFlags` for the branch-data layouts handled here.
14935
- * @param decodeTree The trie.
14936
- * @param current The current node's header word.
14937
- * @param nodeIndex Index of the node's first branch-data word (the header
14938
- * plus any value words have been skipped by the caller).
14939
- * @param char The current character.
14940
- * @returns The index of the next node, or -1 if no branch is taken.
14941
- */
14942
- function determineBranch(decodeTree, current, nodeIndex, char) {
14943
- const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
14944
- const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
14945
- if (jumpOffset) {
14946
- if (branchCount === 0) return char === jumpOffset ? nodeIndex : -1;
14947
- const slot = char - jumpOffset;
14948
- if (slot >>> 0 >= branchCount) return -1;
14949
- const stored = decodeTree[nodeIndex + slot];
14950
- return stored === 0 ? -1 : nodeIndex + branchCount + stored - 1 & 65535;
14951
- }
14952
- if (branchCount === 0) return -1;
14953
- const packedKeySlots = branchCount + 1 >> 1;
14954
- const branchEnd = nodeIndex + packedKeySlots + branchCount;
14955
- for (let index = 0; index < branchCount; index++) {
14956
- const key = decodeTree[nodeIndex + (index >> 1)] >> ((index & 1) << 3) & 255;
14957
- if (key === char) return branchEnd + decodeTree[nodeIndex + packedKeySlots + index] & 65535;
14958
- if (key > char) return -1;
14831
+ * When the entity fits inside the current chunk (the common case), the
14832
+ * lookup runs directly on the chunk via the same length-probe scheme as the
14833
+ * synchronous decoder; chunk-boundary runs use a reusable character buffer.
14834
+ */
14835
+ var HtmlEntityDecoder = class extends EntityDecoderBase {
14836
+ /** Total name characters seen for the current named entity. */
14837
+ runLength = 0;
14838
+ /** Reused for ASCII alphanumerics; the 32nd character rules out an exact match. */
14839
+ nameBuffer = /* @__PURE__ */ new Uint8Array(32);
14840
+ /**
14841
+ * Emit the replacement for a matched slot. Values are at most two
14842
+ * UTF-16 code units; like previous versions, each unit is emitted as
14843
+ * its own callback (surrogate halves included).
14844
+ * @param slot The matched slot.
14845
+ */
14846
+ emitSlot(slot) {
14847
+ const packed = htmlSlotValue[slot];
14848
+ const off = packed >> 2;
14849
+ this.emitCodePoint(htmlValues.charCodeAt(off), this.consumed);
14850
+ if ((packed & 1) !== 0) this.emitCodePoint(htmlValues.charCodeAt(off + 1), this.consumed);
14851
+ }
14852
+ startEntity(decodeMode) {
14853
+ super.startEntity(decodeMode);
14854
+ this.runLength = 0;
14855
+ }
14856
+ stateNamedEntity(input, offset) {
14857
+ const inputLength = input.length;
14858
+ if (this.runLength === 0 && offset + 17 <= inputLength) {
14859
+ const pair = pairIndex(input.charCodeAt(offset), input.charCodeAt(offset + 1));
14860
+ const bits = htmlLengthBits[pair];
14861
+ if ((bits & 32768) !== 0 && offset + 32 <= inputLength) {
14862
+ const packed = findLongClassMatch(input, offset, this.decodeMode);
14863
+ if (packed >= 0) {
14864
+ const length = packed & 63;
14865
+ this.consumed = length + 1;
14866
+ this.emitSlot(packed >> 6);
14867
+ if (input.charCodeAt(offset + length - 1) !== CHAR_SEMI) this.errors?.missingSemicolonAfterCharacterReference();
14868
+ return this.consumed;
14869
+ }
14870
+ return 0;
14871
+ }
14872
+ let probed = bits & 32767;
14873
+ while (probed !== 0) {
14874
+ const low = probed & -probed;
14875
+ probed ^= low;
14876
+ const length = 33 - Math.clz32(low);
14877
+ if (input.charCodeAt(offset + length) === CHAR_SEMI) {
14878
+ const slot = findSlotHtml(input, offset, length);
14879
+ if (slot >= 0) {
14880
+ this.consumed = length + 2;
14881
+ this.emitSlot(slot);
14882
+ return this.consumed;
14883
+ }
14884
+ }
14885
+ }
14886
+ if ((bits & 32768) === 0) {
14887
+ if (this.decodeMode !== DecodingMode.Strict) {
14888
+ const packed = findLegacySlot(input, offset, 31);
14889
+ if (packed >= 0) {
14890
+ const matchLength = packed & 7;
14891
+ const next = input.charCodeAt(offset + matchLength);
14892
+ if (this.decodeMode === DecodingMode.Attribute && isEntityInAttributeInvalidEnd(next)) return 0;
14893
+ this.consumed = matchLength + 1;
14894
+ this.emitSlot(packed >> 3);
14895
+ this.errors?.missingSemicolonAfterCharacterReference();
14896
+ return this.consumed;
14897
+ }
14898
+ }
14899
+ return 0;
14900
+ }
14901
+ }
14902
+ let index = offset;
14903
+ let { runLength } = this;
14904
+ let terminator = -1;
14905
+ const scanEnd = Math.min(inputLength, offset + 32 - runLength);
14906
+ while (index < scanEnd) {
14907
+ const char = input.charCodeAt(index);
14908
+ if (!isAlphaNumeric(char)) {
14909
+ terminator = char;
14910
+ break;
14911
+ }
14912
+ this.nameBuffer[runLength++] = char;
14913
+ index++;
14914
+ }
14915
+ if (terminator < 0 && runLength < 32) {
14916
+ this.runLength = runLength;
14917
+ return -1;
14918
+ }
14919
+ if (terminator === CHAR_SEMI && runLength - 2 >>> 0 <= 29) {
14920
+ const slot = findBufferedHtmlSlot(this.nameBuffer, runLength);
14921
+ if (slot >= 0) {
14922
+ this.consumed = runLength + 2;
14923
+ this.emitSlot(slot);
14924
+ return this.consumed;
14925
+ }
14926
+ }
14927
+ if (this.decodeMode !== DecodingMode.Strict && runLength >= 2) {
14928
+ const packed = findBufferedLegacySlot(this.nameBuffer, runLength);
14929
+ if (packed >= 0) {
14930
+ const length = packed & 7;
14931
+ const next = length < runLength ? this.nameBuffer[length] : terminator;
14932
+ if (this.decodeMode === DecodingMode.Attribute && isEntityInAttributeInvalidEnd(next)) return 0;
14933
+ this.consumed = length + 1;
14934
+ this.emitSlot(packed >> 3);
14935
+ this.errors?.missingSemicolonAfterCharacterReference();
14936
+ return this.consumed;
14937
+ }
14938
+ }
14939
+ return 0;
14940
+ }
14941
+ endNamedEntity() {
14942
+ if (this.decodeMode === DecodingMode.Strict || this.runLength < 2) return 0;
14943
+ const packed = findBufferedLegacySlot(this.nameBuffer, this.runLength);
14944
+ if (packed < 0) return 0;
14945
+ if (this.decodeMode === DecodingMode.Attribute && (packed & 7) < this.runLength) return 0;
14946
+ this.consumed = (packed & 7) + 1;
14947
+ this.emitSlot(packed >> 3);
14948
+ this.errors?.missingSemicolonAfterCharacterReference();
14949
+ return this.consumed;
14950
+ }
14951
+ };
14952
+ /**
14953
+ * Find a buffered name. Its characters were already checked as ASCII
14954
+ * alphanumerics while scanning, so no outer-character range check is needed.
14955
+ * @param buffer Reusable character buffer.
14956
+ * @param length Number of characters to match.
14957
+ */
14958
+ function findBufferedHtmlSlot(buffer, length) {
14959
+ const key = buffer[0] << 25 | buffer[1] << 18 | buffer[length - 2] << 11 | CHAR_REMAP[buffer[length - 1]] << 5 | length;
14960
+ let slot = 2 * ((Math.imul(key, BUCKET_HASH_1) >>> 16) * htmlBuckets >>> 16);
14961
+ for (let attempt = 0;; attempt++) {
14962
+ if (htmlKeys[slot] === key && (length <= 4 || isBufferedMiddle(slot, buffer, length))) return slot;
14963
+ if (htmlKeys[slot + 1] === key && (length <= 4 || isBufferedMiddle(slot + 1, buffer, length))) return slot + 1;
14964
+ if (attempt === 1) return -1;
14965
+ slot = 2 * ((Math.imul(key, BUCKET_HASH_2) >>> 16) * htmlBuckets >>> 16);
14966
+ }
14967
+ }
14968
+ function isBufferedMiddle(slot, buffer, length) {
14969
+ let wordIndex = htmlSlotMidOff[slot];
14970
+ let index = 2;
14971
+ const end = length - 2;
14972
+ while (index + 1 < end) {
14973
+ if ((buffer[index] | buffer[index + 1] << 16) !== htmlMiddles[wordIndex++]) return false;
14974
+ index += 2;
14975
+ }
14976
+ return index === end || buffer[index] === (htmlMiddles[wordIndex] & 65535);
14977
+ }
14978
+ /**
14979
+ * Find the longest legacy name in the buffer, packed as `(slot << 3) | length`.
14980
+ * @param buffer Reusable character buffer.
14981
+ * @param length Number of buffered characters.
14982
+ */
14983
+ function findBufferedLegacySlot(buffer, length) {
14984
+ let legacy = htmlLengthBits[pairIndex(buffer[0], buffer[1])] >>> 16 & 31;
14985
+ while (legacy !== 0) {
14986
+ const top = 31 - Math.clz32(legacy);
14987
+ legacy ^= 1 << top;
14988
+ if (top + 2 > length) continue;
14989
+ const slot = findBufferedHtmlSlot(buffer, top + 2);
14990
+ if (slot >= 0 && (htmlSlotValue[slot] & 2) !== 0) return slot << 3 | top + 2;
14959
14991
  }
14960
14992
  return -1;
14961
14993
  }
@@ -15481,7 +15513,7 @@ const SPECIAL_ELEMENTS = {
15481
15513
  [NS.XML]: /* @__PURE__ */ new Set(),
15482
15514
  [NS.XMLNS]: /* @__PURE__ */ new Set()
15483
15515
  };
15484
- const NUMBERED_HEADERS = /* @__PURE__ */ new Set([
15516
+ const NUMBERED_HEADERS$1 = /* @__PURE__ */ new Set([
15485
15517
  $$1.H1,
15486
15518
  $$1.H2,
15487
15519
  $$1.H3,
@@ -15502,6 +15534,7 @@ function hasUnescapedText(tn, scriptingEnabled) {
15502
15534
  return UNESCAPED_TEXT.has(tn) || scriptingEnabled && tn === TAG_NAMES.NOSCRIPT;
15503
15535
  }
15504
15536
  // node_modules/parse5/dist/tokenizer/index.js
15537
+ const ATTR_NAME_SET_THRESHOLD = 64;
15505
15538
  var State;
15506
15539
  (function(State) {
15507
15540
  State[State["DATA"] = 0] = "DATA";
@@ -15605,7 +15638,7 @@ function toAsciiLower(cp) {
15605
15638
  return cp + 32;
15606
15639
  }
15607
15640
  function isWhitespace$1(cp) {
15608
- return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED;
15641
+ return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED || cp === CODE_POINTS.CARRIAGE_RETURN;
15609
15642
  }
15610
15643
  function isScriptDataDoubleEscapeSequenceEnd(cp) {
15611
15644
  return isWhitespace$1(cp) || cp === CODE_POINTS.SOLIDUS || cp === CODE_POINTS.GREATER_THAN_SIGN;
@@ -15644,11 +15677,21 @@ var Tokenizer = class {
15644
15677
  name: "",
15645
15678
  value: ""
15646
15679
  };
15680
+ this.currentAttrLocation = null;
15681
+ this.currentAttrNames = null;
15682
+ /**
15683
+ * `[start, end)` of `preprocessor.html` still to be appended to the attribute value, comment data or character
15684
+ * token being built (`_flushRun`): input that is used as is is appended as one slice, not a code point at a time.
15685
+ */
15686
+ this.runStart = 0;
15687
+ this.runEnd = 0;
15647
15688
  this.preprocessor = new Preprocessor(handler);
15648
15689
  this.currentLocation = this.getCurrentLocation(-1);
15649
- this.entityDecoder = new EntityDecoder(htmlDecodeTree, (cp, consumed) => {
15690
+ this.entityDecoder = new HtmlEntityDecoder((cp, consumed) => {
15650
15691
  this.preprocessor.pos = this.entityStartPos + consumed - 1;
15651
- this._flushCodePointConsumedAsCharacterReference(cp);
15692
+ if (!this._isCharacterReferenceInAttribute()) this._ensureCharacterToken(isWhitespace$1(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER);
15693
+ this._extendRunWith(String.fromCodePoint(cp), 0);
15694
+ this.entityStartPos = this.preprocessor.pos - consumed + 1;
15652
15695
  }, handler.onParseError ? {
15653
15696
  missingSemicolonAfterCharacterReference: () => {
15654
15697
  this._err(ERR.missingSemicolonAfterCharacterReference, 1);
@@ -15687,6 +15730,76 @@ var Tokenizer = class {
15687
15730
  }
15688
15731
  this.inLoop = false;
15689
15732
  }
15733
+ /** Emit buffered character tokens without completing the current token or emitting EOF. */
15734
+ flushCharacters() {
15735
+ var _a;
15736
+ if (this.inLoop) throw new Error("Cannot flush characters from a tokenizer callback");
15737
+ const location = (_a = this.currentCharacterToken) === null || _a === void 0 ? void 0 : _a.location;
15738
+ let nextLocation = null;
15739
+ if (location) {
15740
+ nextLocation = this.getCharacterTokenEndLocation(location);
15741
+ this.currentLocation = nextLocation;
15742
+ }
15743
+ this.inLoop = true;
15744
+ try {
15745
+ this._emitCurrentCharacterToken(nextLocation);
15746
+ } finally {
15747
+ this.inLoop = false;
15748
+ }
15749
+ this._runParsingLoop();
15750
+ }
15751
+ getCharacterTokenEndLocation(location) {
15752
+ const endOffset = this.getCharacterTokenEndOffset();
15753
+ const html = this.preprocessor.html.slice(location.startOffset - this.preprocessor.droppedBufferSize, endOffset - this.preprocessor.droppedBufferSize);
15754
+ let line = location.startLine;
15755
+ let lastLineBreak = -1;
15756
+ for (let i = html.indexOf("\n"); i !== -1; i = html.indexOf("\n", i + 1)) {
15757
+ line++;
15758
+ lastLineBreak = i;
15759
+ }
15760
+ for (let i = html.indexOf("\r"); i !== -1; i = html.indexOf("\r", i + 1)) if (html.charCodeAt(i + 1) !== CODE_POINTS.LINE_FEED) {
15761
+ line++;
15762
+ lastLineBreak = Math.max(lastLineBreak, i);
15763
+ }
15764
+ return {
15765
+ startLine: line,
15766
+ startCol: lastLineBreak === -1 ? location.startCol + html.length : html.length - lastLineBreak,
15767
+ startOffset: endOffset,
15768
+ endLine: -1,
15769
+ endCol: -1,
15770
+ endOffset: -1
15771
+ };
15772
+ }
15773
+ getCharacterTokenEndOffset() {
15774
+ var _a;
15775
+ const end = this.preprocessor.droppedBufferSize + this.preprocessor.pos + 1;
15776
+ const tokenLocation = (_a = this.currentToken) === null || _a === void 0 ? void 0 : _a.location;
15777
+ switch (this.state) {
15778
+ case State.TAG_OPEN:
15779
+ case State.RCDATA_LESS_THAN_SIGN:
15780
+ case State.RAWTEXT_LESS_THAN_SIGN:
15781
+ case State.SCRIPT_DATA_LESS_THAN_SIGN:
15782
+ case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:
15783
+ case State.CDATA_SECTION_BRACKET: return end - 1;
15784
+ case State.END_TAG_OPEN:
15785
+ case State.MARKUP_DECLARATION_OPEN:
15786
+ case State.RCDATA_END_TAG_OPEN:
15787
+ case State.RCDATA_END_TAG_NAME:
15788
+ case State.RAWTEXT_END_TAG_OPEN:
15789
+ case State.RAWTEXT_END_TAG_NAME:
15790
+ case State.SCRIPT_DATA_END_TAG_OPEN:
15791
+ case State.SCRIPT_DATA_END_TAG_NAME:
15792
+ case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:
15793
+ case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME:
15794
+ case State.CDATA_SECTION_END: return end - 2;
15795
+ case State.CHARACTER_REFERENCE: return this._isCharacterReferenceInAttribute() && tokenLocation ? tokenLocation.startOffset : this.preprocessor.droppedBufferSize + this.entityStartPos;
15796
+ case State.DOCTYPE:
15797
+ case State.BEFORE_DOCTYPE_NAME: return this.currentLocation.startOffset;
15798
+ default:
15799
+ if (tokenLocation && (this.state === State.TAG_NAME || this.state >= State.BEFORE_ATTRIBUTE_NAME && this.state <= State.BOGUS_COMMENT || this.state >= State.COMMENT_START && this.state <= State.BOGUS_DOCTYPE)) return tokenLocation.startOffset;
15800
+ return end;
15801
+ }
15802
+ }
15690
15803
  pause() {
15691
15804
  this.paused = true;
15692
15805
  }
@@ -15708,6 +15821,18 @@ var Tokenizer = class {
15708
15821
  this.preprocessor.insertHtmlAtCurrentPos(chunk);
15709
15822
  this._runParsingLoop();
15710
15823
  }
15824
+ /** @internal Flush completed streaming text without splitting an unfinished token. */
15825
+ flushCurrentCharacterToken() {
15826
+ if (this.paused || this.active || !this.currentCharacterToken || this.currentToken || this.state === State.DOCTYPE || this.state === State.BEFORE_DOCTYPE_NAME || !this.preprocessor.willDropParsedChunk()) return;
15827
+ const pending = this.preprocessor.droppedBufferSize + this.preprocessor.pos + 1 - this.getCharacterTokenEndOffset();
15828
+ this.preprocessor.advance();
15829
+ this.currentLocation = this.getCurrentLocation(pending);
15830
+ this.preprocessor.retreat(1);
15831
+ this._emitCurrentCharacterToken(this.currentLocation);
15832
+ this._createCharacterToken(TokenType.CHARACTER);
15833
+ this.preprocessor.dropParsedChunk(Math.max(pending - 1, 0));
15834
+ this.entityStartPos = this.preprocessor.pos + 1 - pending;
15835
+ }
15711
15836
  _ensureHibernation() {
15712
15837
  if (this.preprocessor.endOfChunkHit) {
15713
15838
  this.preprocessor.retreat(this.consumedAfterSnapshot);
@@ -15733,6 +15858,7 @@ var Tokenizer = class {
15733
15858
  return false;
15734
15859
  }
15735
15860
  _createStartTagToken() {
15861
+ this._flushRun("");
15736
15862
  this.currentToken = {
15737
15863
  type: TokenType.START_TAG,
15738
15864
  tagName: "",
@@ -15744,6 +15870,7 @@ var Tokenizer = class {
15744
15870
  };
15745
15871
  }
15746
15872
  _createEndTagToken() {
15873
+ this._flushRun("");
15747
15874
  this.currentToken = {
15748
15875
  type: TokenType.END_TAG,
15749
15876
  tagName: "",
@@ -15755,6 +15882,7 @@ var Tokenizer = class {
15755
15882
  };
15756
15883
  }
15757
15884
  _createCommentToken(offset) {
15885
+ this._flushRun("");
15758
15886
  this.currentToken = {
15759
15887
  type: TokenType.COMMENT,
15760
15888
  data: "",
@@ -15762,6 +15890,7 @@ var Tokenizer = class {
15762
15890
  };
15763
15891
  }
15764
15892
  _createDoctypeToken(initialName) {
15893
+ this._flushRun("");
15765
15894
  this.currentToken = {
15766
15895
  type: TokenType.DOCTYPE,
15767
15896
  name: initialName,
@@ -15771,39 +15900,104 @@ var Tokenizer = class {
15771
15900
  location: this.currentLocation
15772
15901
  };
15773
15902
  }
15774
- _createCharacterToken(type, chars) {
15903
+ _createCharacterToken(type) {
15904
+ if (this.currentLocation) {
15905
+ const start = this.currentLocation.startOffset - this.preprocessor.droppedBufferSize;
15906
+ if (this.preprocessor.html[start] === "\n" && this.preprocessor.html[start - 1] === "\r") this.currentLocation.startOffset++;
15907
+ }
15775
15908
  this.currentCharacterToken = {
15776
15909
  type,
15777
- chars,
15910
+ chars: "",
15778
15911
  location: this.currentLocation
15779
15912
  };
15780
15913
  }
15781
15914
  _createAttr(attrNameFirstCh) {
15915
+ this._flushRun("");
15782
15916
  this.currentAttr = {
15783
15917
  name: attrNameFirstCh,
15784
15918
  value: ""
15785
15919
  };
15786
- this.currentLocation = this.getCurrentLocation(0);
15920
+ this.currentAttrLocation = this.getCurrentLocation(0);
15787
15921
  }
15788
15922
  _leaveAttrName() {
15789
15923
  var _a;
15790
15924
  var _b;
15791
15925
  const token = this.currentToken;
15792
- if (getTokenAttr(token, this.currentAttr.name) === null) {
15926
+ const { name } = this.currentAttr;
15927
+ const names = this.currentAttrNames;
15928
+ let duplicate;
15929
+ if (names === null) {
15930
+ duplicate = getTokenAttr(token, name) !== null;
15931
+ if (!duplicate && token.attrs.length === ATTR_NAME_SET_THRESHOLD) this.currentAttrNames = new Set(token.attrs.map((attr) => attr.name)).add(name);
15932
+ } else {
15933
+ duplicate = names.has(name);
15934
+ if (!duplicate) names.add(name);
15935
+ }
15936
+ if (duplicate) this._err(ERR.duplicateAttribute);
15937
+ else {
15793
15938
  token.attrs.push(this.currentAttr);
15794
- if (token.location && this.currentLocation) {
15939
+ if (token.location && this.currentAttrLocation) {
15795
15940
  const attrLocations = (_a = (_b = token.location).attrs) !== null && _a !== void 0 ? _a : _b.attrs = Object.create(null);
15796
- attrLocations[this.currentAttr.name] = this.currentLocation;
15941
+ attrLocations[this.currentAttr.name] = this.currentAttrLocation;
15797
15942
  this._leaveAttrValue();
15798
15943
  }
15799
- } else this._err(ERR.duplicateAttribute);
15944
+ }
15800
15945
  }
15801
15946
  _leaveAttrValue() {
15802
- if (this.currentLocation) {
15803
- this.currentLocation.endLine = this.preprocessor.line;
15804
- this.currentLocation.endCol = this.preprocessor.col;
15805
- this.currentLocation.endOffset = this.preprocessor.offset;
15947
+ if (this.currentAttrLocation) {
15948
+ this.currentAttrLocation.endLine = this.preprocessor.line;
15949
+ this.currentAttrLocation.endCol = this.preprocessor.col;
15950
+ this.currentAttrLocation.endOffset = this.preprocessor.offset;
15951
+ }
15952
+ }
15953
+ /**
15954
+ * Append the pending run and `text` to the attribute value, comment data or character token being built.
15955
+ * The run is a string of its own: V8 copies a slice of fewer than 13 characters but lets a longer one share
15956
+ * the input's buffer, which would keep that buffer alive for as long as any attribute value or text cut from
15957
+ * it is; a concatenation is flattened into a buffer of its own when it is sliced.
15958
+ */
15959
+ _flushRun(text) {
15960
+ if (this.runEnd === this.runStart && text.length === 0) return;
15961
+ const slice = this.preprocessor.html.slice(this.runStart, this.runEnd);
15962
+ const run = (slice.length < 13 ? slice : ` ${slice}`.slice(1)) + text;
15963
+ const token = this.currentToken;
15964
+ this.runStart = this.runEnd;
15965
+ if (token === null) this.currentCharacterToken.chars += run;
15966
+ else if (token.type === TokenType.COMMENT) token.data += run;
15967
+ else this.currentAttr.value += run;
15968
+ }
15969
+ /** Extend the pending run by the current input code point, read as `cp`, or flush it and start a new one. */
15970
+ _extendRun(cp) {
15971
+ const { preprocessor } = this;
15972
+ if (cp === CODE_POINTS.LINE_FEED && preprocessor.html.charCodeAt(preprocessor.pos) !== CODE_POINTS.LINE_FEED) {
15973
+ this._flushRun("\n");
15974
+ this.runStart = preprocessor.pos + 1;
15975
+ } else {
15976
+ const start = preprocessor.pos - Number(cp > 65535);
15977
+ if (start !== this.runEnd) {
15978
+ this._flushRun("");
15979
+ this.runStart = start;
15980
+ }
15806
15981
  }
15982
+ this.runEnd = preprocessor.pos + 1;
15983
+ }
15984
+ /**
15985
+ * Extend the pending run by `text`, the input that ends `cpOffset` code points after the current one, or flush
15986
+ * the run and append `text` where the input differs (a NUL replacement, a decoded reference, a dropped chunk).
15987
+ */
15988
+ _extendRunWith(text, cpOffset) {
15989
+ const { preprocessor } = this;
15990
+ const start = preprocessor.codePointStart + 1 + cpOffset - text.length;
15991
+ if (start >= 0 && preprocessor.html.startsWith(text, start)) {
15992
+ if (start !== this.runEnd) {
15993
+ this._flushRun("");
15994
+ this.runStart = start;
15995
+ }
15996
+ } else {
15997
+ this._flushRun(text);
15998
+ this.runStart = start + text.length;
15999
+ }
16000
+ this.runEnd = start + text.length;
15807
16001
  }
15808
16002
  prepareToken(ct) {
15809
16003
  this._emitCurrentCharacterToken(ct.location);
@@ -15817,6 +16011,7 @@ var Tokenizer = class {
15817
16011
  }
15818
16012
  emitCurrentTagToken() {
15819
16013
  const ct = this.currentToken;
16014
+ this.currentAttrNames = null;
15820
16015
  this.prepareToken(ct);
15821
16016
  ct.tagID = getTagID(ct.tagName);
15822
16017
  if (ct.type === TokenType.START_TAG) {
@@ -15840,6 +16035,7 @@ var Tokenizer = class {
15840
16035
  this.preprocessor.dropParsedChunk();
15841
16036
  }
15842
16037
  _emitCurrentCharacterToken(nextLocation) {
16038
+ this._flushRun("");
15843
16039
  if (this.currentCharacterToken) {
15844
16040
  if (nextLocation && this.currentCharacterToken.location) {
15845
16041
  this.currentCharacterToken.location.endLine = nextLocation.startLine;
@@ -15859,38 +16055,44 @@ var Tokenizer = class {
15859
16055
  }
15860
16056
  }
15861
16057
  _emitEOFToken() {
16058
+ var _a, _b;
15862
16059
  const location = this.getCurrentLocation(0);
15863
16060
  if (location) {
15864
16061
  location.endLine = location.startLine;
15865
16062
  location.endCol = location.startCol;
15866
16063
  location.endOffset = location.startOffset;
15867
16064
  }
15868
- this._emitCurrentCharacterToken(location);
16065
+ this._emitCurrentCharacterToken((_b = (_a = this.currentToken) === null || _a === void 0 ? void 0 : _a.location) !== null && _b !== void 0 ? _b : location);
15869
16066
  this.handler.onEof({
15870
16067
  type: TokenType.EOF,
15871
16068
  location
15872
16069
  });
15873
16070
  this.active = false;
15874
16071
  }
15875
- _appendCharToCurrentCharacterToken(type, ch) {
16072
+ /** Make the current character token one of `type`, emitting the current one if it has another type. */
16073
+ _ensureCharacterToken(type) {
15876
16074
  if (this.currentCharacterToken) {
15877
- if (this.currentCharacterToken.type === type) {
15878
- this.currentCharacterToken.chars += ch;
15879
- return;
15880
- } else {
15881
- this.currentLocation = this.getCurrentLocation(0);
15882
- this._emitCurrentCharacterToken(this.currentLocation);
15883
- this.preprocessor.dropParsedChunk();
15884
- }
16075
+ if (this.currentCharacterToken.type === type) return;
16076
+ this.currentLocation = this.getCurrentLocation(0);
16077
+ this._emitCurrentCharacterToken(this.currentLocation);
16078
+ this.preprocessor.dropParsedChunk();
15885
16079
  }
15886
- this._createCharacterToken(type, ch);
16080
+ this._createCharacterToken(type);
15887
16081
  }
16082
+ /** Emit the current input code point, read as `cp`. */
15888
16083
  _emitCodePoint(cp) {
15889
16084
  const type = isWhitespace$1(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER;
15890
- this._appendCharToCurrentCharacterToken(type, cp < 65536 ? String.fromCharCode(cp) : String.fromCodePoint(cp));
15891
- }
15892
- _emitChars(ch) {
15893
- this._appendCharToCurrentCharacterToken(TokenType.CHARACTER, ch);
16085
+ const token = this.currentCharacterToken;
16086
+ if (token === null || token.type !== type) this._ensureCharacterToken(type);
16087
+ this._extendRun(cp);
16088
+ }
16089
+ _emitChars(ch, cpOffset = 0) {
16090
+ if (this.options.sourceCodeLocationInfo && cpOffset !== 0 && this.currentCharacterToken && this.currentCharacterToken.type !== TokenType.CHARACTER) {
16091
+ this.currentLocation = this.getCurrentLocation(ch.length - 1 - cpOffset);
16092
+ this._emitCurrentCharacterToken(this.currentLocation);
16093
+ this._createCharacterToken(TokenType.CHARACTER);
16094
+ } else this._ensureCharacterToken(TokenType.CHARACTER);
16095
+ this._extendRunWith(ch, cpOffset);
15894
16096
  }
15895
16097
  _startCharacterReference() {
15896
16098
  this.returnState = this.state;
@@ -15902,7 +16104,7 @@ var Tokenizer = class {
15902
16104
  return this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED;
15903
16105
  }
15904
16106
  _flushCodePointConsumedAsCharacterReference(cp) {
15905
- if (this._isCharacterReferenceInAttribute()) this.currentAttr.value += String.fromCodePoint(cp);
16107
+ if (this._isCharacterReferenceInAttribute()) this._extendRun(cp);
15906
16108
  else this._emitCodePoint(cp);
15907
16109
  }
15908
16110
  _callState(cp) {
@@ -16227,12 +16429,12 @@ var Tokenizer = class {
16227
16429
  break;
16228
16430
  case CODE_POINTS.EOF:
16229
16431
  this._err(ERR.eofBeforeTagName);
16230
- this._emitChars("<");
16432
+ this._emitChars("<", -1);
16231
16433
  this._emitEOFToken();
16232
16434
  break;
16233
16435
  default:
16234
16436
  this._err(ERR.invalidFirstCharacterOfTagName);
16235
- this._emitChars("<");
16437
+ this._emitChars("<", -1);
16236
16438
  this.state = State.DATA;
16237
16439
  this._stateData(cp);
16238
16440
  }
@@ -16249,7 +16451,7 @@ var Tokenizer = class {
16249
16451
  break;
16250
16452
  case CODE_POINTS.EOF:
16251
16453
  this._err(ERR.eofBeforeTagName);
16252
- this._emitChars("</");
16454
+ this._emitChars("</", -1);
16253
16455
  this._emitEOFToken();
16254
16456
  break;
16255
16457
  default:
@@ -16289,7 +16491,7 @@ var Tokenizer = class {
16289
16491
  _stateRcdataLessThanSign(cp) {
16290
16492
  if (cp === CODE_POINTS.SOLIDUS) this.state = State.RCDATA_END_TAG_OPEN;
16291
16493
  else {
16292
- this._emitChars("<");
16494
+ this._emitChars("<", -1);
16293
16495
  this.state = State.RCDATA;
16294
16496
  this._stateRcdata(cp);
16295
16497
  }
@@ -16299,7 +16501,7 @@ var Tokenizer = class {
16299
16501
  this.state = State.RCDATA_END_TAG_NAME;
16300
16502
  this._stateRcdataEndTagName(cp);
16301
16503
  } else {
16302
- this._emitChars("</");
16504
+ this._emitChars("</", -1);
16303
16505
  this.state = State.RCDATA;
16304
16506
  this._stateRcdata(cp);
16305
16507
  }
@@ -16326,12 +16528,14 @@ var Tokenizer = class {
16326
16528
  this.emitCurrentTagToken();
16327
16529
  this.state = State.DATA;
16328
16530
  return false;
16329
- default: return !this._ensureHibernation();
16531
+ default:
16532
+ this.currentToken = null;
16533
+ return !this._ensureHibernation();
16330
16534
  }
16331
16535
  }
16332
16536
  _stateRcdataEndTagName(cp) {
16333
16537
  if (this.handleSpecialEndTag(cp)) {
16334
- this._emitChars("</");
16538
+ this._emitChars("</", -1);
16335
16539
  this.state = State.RCDATA;
16336
16540
  this._stateRcdata(cp);
16337
16541
  }
@@ -16339,7 +16543,7 @@ var Tokenizer = class {
16339
16543
  _stateRawtextLessThanSign(cp) {
16340
16544
  if (cp === CODE_POINTS.SOLIDUS) this.state = State.RAWTEXT_END_TAG_OPEN;
16341
16545
  else {
16342
- this._emitChars("<");
16546
+ this._emitChars("<", -1);
16343
16547
  this.state = State.RAWTEXT;
16344
16548
  this._stateRawtext(cp);
16345
16549
  }
@@ -16349,14 +16553,14 @@ var Tokenizer = class {
16349
16553
  this.state = State.RAWTEXT_END_TAG_NAME;
16350
16554
  this._stateRawtextEndTagName(cp);
16351
16555
  } else {
16352
- this._emitChars("</");
16556
+ this._emitChars("</", -1);
16353
16557
  this.state = State.RAWTEXT;
16354
16558
  this._stateRawtext(cp);
16355
16559
  }
16356
16560
  }
16357
16561
  _stateRawtextEndTagName(cp) {
16358
16562
  if (this.handleSpecialEndTag(cp)) {
16359
- this._emitChars("</");
16563
+ this._emitChars("</", -1);
16360
16564
  this.state = State.RAWTEXT;
16361
16565
  this._stateRawtext(cp);
16362
16566
  }
@@ -16371,7 +16575,7 @@ var Tokenizer = class {
16371
16575
  this._emitChars("<!");
16372
16576
  break;
16373
16577
  default:
16374
- this._emitChars("<");
16578
+ this._emitChars("<", -1);
16375
16579
  this.state = State.SCRIPT_DATA;
16376
16580
  this._stateScriptData(cp);
16377
16581
  }
@@ -16381,14 +16585,14 @@ var Tokenizer = class {
16381
16585
  this.state = State.SCRIPT_DATA_END_TAG_NAME;
16382
16586
  this._stateScriptDataEndTagName(cp);
16383
16587
  } else {
16384
- this._emitChars("</");
16588
+ this._emitChars("</", -1);
16385
16589
  this.state = State.SCRIPT_DATA;
16386
16590
  this._stateScriptData(cp);
16387
16591
  }
16388
16592
  }
16389
16593
  _stateScriptDataEndTagName(cp) {
16390
16594
  if (this.handleSpecialEndTag(cp)) {
16391
- this._emitChars("</");
16595
+ this._emitChars("</", -1);
16392
16596
  this.state = State.SCRIPT_DATA;
16393
16597
  this._stateScriptData(cp);
16394
16598
  }
@@ -16483,11 +16687,11 @@ var Tokenizer = class {
16483
16687
  _stateScriptDataEscapedLessThanSign(cp) {
16484
16688
  if (cp === CODE_POINTS.SOLIDUS) this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;
16485
16689
  else if (isAsciiLetter(cp)) {
16486
- this._emitChars("<");
16690
+ this._emitChars("<", -1);
16487
16691
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;
16488
16692
  this._stateScriptDataDoubleEscapeStart(cp);
16489
16693
  } else {
16490
- this._emitChars("<");
16694
+ this._emitChars("<", -1);
16491
16695
  this.state = State.SCRIPT_DATA_ESCAPED;
16492
16696
  this._stateScriptDataEscaped(cp);
16493
16697
  }
@@ -16497,14 +16701,14 @@ var Tokenizer = class {
16497
16701
  this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;
16498
16702
  this._stateScriptDataEscapedEndTagName(cp);
16499
16703
  } else {
16500
- this._emitChars("</");
16704
+ this._emitChars("</", -1);
16501
16705
  this.state = State.SCRIPT_DATA_ESCAPED;
16502
16706
  this._stateScriptDataEscaped(cp);
16503
16707
  }
16504
16708
  }
16505
16709
  _stateScriptDataEscapedEndTagName(cp) {
16506
16710
  if (this.handleSpecialEndTag(cp)) {
16507
- this._emitChars("</");
16711
+ this._emitChars("</", -1);
16508
16712
  this.state = State.SCRIPT_DATA_ESCAPED;
16509
16713
  this._stateScriptDataEscaped(cp);
16510
16714
  }
@@ -16721,13 +16925,13 @@ var Tokenizer = class {
16721
16925
  break;
16722
16926
  case CODE_POINTS.NULL:
16723
16927
  this._err(ERR.unexpectedNullCharacter);
16724
- this.currentAttr.value += "�";
16928
+ this._extendRunWith("�", 0);
16725
16929
  break;
16726
16930
  case CODE_POINTS.EOF:
16727
16931
  this._err(ERR.eofInTag);
16728
16932
  this._emitEOFToken();
16729
16933
  break;
16730
- default: this.currentAttr.value += String.fromCodePoint(cp);
16934
+ default: this._extendRun(cp);
16731
16935
  }
16732
16936
  }
16733
16937
  _stateAttributeValueSingleQuoted(cp) {
@@ -16740,13 +16944,13 @@ var Tokenizer = class {
16740
16944
  break;
16741
16945
  case CODE_POINTS.NULL:
16742
16946
  this._err(ERR.unexpectedNullCharacter);
16743
- this.currentAttr.value += "�";
16947
+ this._extendRunWith("�", 0);
16744
16948
  break;
16745
16949
  case CODE_POINTS.EOF:
16746
16950
  this._err(ERR.eofInTag);
16747
16951
  this._emitEOFToken();
16748
16952
  break;
16749
- default: this.currentAttr.value += String.fromCodePoint(cp);
16953
+ default: this._extendRun(cp);
16750
16954
  }
16751
16955
  }
16752
16956
  _stateAttributeValueUnquoted(cp) {
@@ -16768,7 +16972,7 @@ var Tokenizer = class {
16768
16972
  break;
16769
16973
  case CODE_POINTS.NULL:
16770
16974
  this._err(ERR.unexpectedNullCharacter);
16771
- this.currentAttr.value += "�";
16975
+ this._extendRunWith("�", 0);
16772
16976
  break;
16773
16977
  case CODE_POINTS.QUOTATION_MARK:
16774
16978
  case CODE_POINTS.APOSTROPHE:
@@ -16776,13 +16980,13 @@ var Tokenizer = class {
16776
16980
  case CODE_POINTS.EQUALS_SIGN:
16777
16981
  case CODE_POINTS.GRAVE_ACCENT:
16778
16982
  this._err(ERR.unexpectedCharacterInUnquotedAttributeValue);
16779
- this.currentAttr.value += String.fromCodePoint(cp);
16983
+ this._extendRun(cp);
16780
16984
  break;
16781
16985
  case CODE_POINTS.EOF:
16782
16986
  this._err(ERR.eofInTag);
16783
16987
  this._emitEOFToken();
16784
16988
  break;
16785
- default: this.currentAttr.value += String.fromCodePoint(cp);
16989
+ default: this._extendRun(cp);
16786
16990
  }
16787
16991
  }
16788
16992
  _stateAfterAttributeValueQuoted(cp) {
@@ -16809,6 +17013,7 @@ var Tokenizer = class {
16809
17013
  break;
16810
17014
  default:
16811
17015
  this._err(ERR.missingWhitespaceBetweenAttributes);
17016
+ this._leaveAttrValue();
16812
17017
  this.state = State.BEFORE_ATTRIBUTE_NAME;
16813
17018
  this._stateBeforeAttributeName(cp);
16814
17019
  }
@@ -16845,9 +17050,9 @@ var Tokenizer = class {
16845
17050
  break;
16846
17051
  case CODE_POINTS.NULL:
16847
17052
  this._err(ERR.unexpectedNullCharacter);
16848
- token.data += "�";
17053
+ this._extendRunWith("�", 0);
16849
17054
  break;
16850
- default: token.data += String.fromCodePoint(cp);
17055
+ default: this._extendRun(cp);
16851
17056
  }
16852
17057
  }
16853
17058
  _stateMarkupDeclarationOpen(cp) {
@@ -16906,7 +17111,7 @@ var Tokenizer = class {
16906
17111
  this._emitEOFToken();
16907
17112
  break;
16908
17113
  default:
16909
- token.data += "-";
17114
+ this._extendRunWith("-", -1);
16910
17115
  this.state = State.COMMENT;
16911
17116
  this._stateComment(cp);
16912
17117
  }
@@ -16918,30 +17123,29 @@ var Tokenizer = class {
16918
17123
  this.state = State.COMMENT_END_DASH;
16919
17124
  break;
16920
17125
  case CODE_POINTS.LESS_THAN_SIGN:
16921
- token.data += "<";
17126
+ this._extendRunWith("<", 0);
16922
17127
  this.state = State.COMMENT_LESS_THAN_SIGN;
16923
17128
  break;
16924
17129
  case CODE_POINTS.NULL:
16925
17130
  this._err(ERR.unexpectedNullCharacter);
16926
- token.data += "�";
17131
+ this._extendRunWith("�", 0);
16927
17132
  break;
16928
17133
  case CODE_POINTS.EOF:
16929
17134
  this._err(ERR.eofInComment);
16930
17135
  this.emitCurrentComment(token);
16931
17136
  this._emitEOFToken();
16932
17137
  break;
16933
- default: token.data += String.fromCodePoint(cp);
17138
+ default: this._extendRun(cp);
16934
17139
  }
16935
17140
  }
16936
17141
  _stateCommentLessThanSign(cp) {
16937
- const token = this.currentToken;
16938
17142
  switch (cp) {
16939
17143
  case CODE_POINTS.EXCLAMATION_MARK:
16940
- token.data += "!";
17144
+ this._extendRunWith("!", 0);
16941
17145
  this.state = State.COMMENT_LESS_THAN_SIGN_BANG;
16942
17146
  break;
16943
17147
  case CODE_POINTS.LESS_THAN_SIGN:
16944
- token.data += "<";
17148
+ this._extendRunWith("<", 0);
16945
17149
  break;
16946
17150
  default:
16947
17151
  this.state = State.COMMENT;
@@ -16979,7 +17183,7 @@ var Tokenizer = class {
16979
17183
  this._emitEOFToken();
16980
17184
  break;
16981
17185
  default:
16982
- token.data += "-";
17186
+ this._extendRunWith("-", -1);
16983
17187
  this.state = State.COMMENT;
16984
17188
  this._stateComment(cp);
16985
17189
  }
@@ -16995,7 +17199,7 @@ var Tokenizer = class {
16995
17199
  this.state = State.COMMENT_END_BANG;
16996
17200
  break;
16997
17201
  case CODE_POINTS.HYPHEN_MINUS:
16998
- token.data += "-";
17202
+ this._extendRunWith("-", -2);
16999
17203
  break;
17000
17204
  case CODE_POINTS.EOF:
17001
17205
  this._err(ERR.eofInComment);
@@ -17003,7 +17207,7 @@ var Tokenizer = class {
17003
17207
  this._emitEOFToken();
17004
17208
  break;
17005
17209
  default:
17006
- token.data += "--";
17210
+ this._extendRunWith("--", -1);
17007
17211
  this.state = State.COMMENT;
17008
17212
  this._stateComment(cp);
17009
17213
  }
@@ -17012,7 +17216,7 @@ var Tokenizer = class {
17012
17216
  const token = this.currentToken;
17013
17217
  switch (cp) {
17014
17218
  case CODE_POINTS.HYPHEN_MINUS:
17015
- token.data += "--!";
17219
+ this._extendRunWith("--!", -1);
17016
17220
  this.state = State.COMMENT_END_DASH;
17017
17221
  break;
17018
17222
  case CODE_POINTS.GREATER_THAN_SIGN:
@@ -17026,7 +17230,7 @@ var Tokenizer = class {
17026
17230
  this._emitEOFToken();
17027
17231
  break;
17028
17232
  default:
17029
- token.data += "--!";
17233
+ this._extendRunWith("--!", -1);
17030
17234
  this.state = State.COMMENT;
17031
17235
  this._stateComment(cp);
17032
17236
  }
@@ -17513,7 +17717,7 @@ var Tokenizer = class {
17513
17717
  _stateCdataSectionBracket(cp) {
17514
17718
  if (cp === CODE_POINTS.RIGHT_SQUARE_BRACKET) this.state = State.CDATA_SECTION_END;
17515
17719
  else {
17516
- this._emitChars("]");
17720
+ this._emitChars("]", -1);
17517
17721
  this.state = State.CDATA_SECTION;
17518
17722
  this._stateCdataSection(cp);
17519
17723
  }
@@ -17524,10 +17728,10 @@ var Tokenizer = class {
17524
17728
  this.state = State.DATA;
17525
17729
  break;
17526
17730
  case CODE_POINTS.RIGHT_SQUARE_BRACKET:
17527
- this._emitChars("]");
17731
+ this._emitChars("]", -2);
17528
17732
  break;
17529
17733
  default:
17530
- this._emitChars("]]");
17734
+ this._emitChars("]]", -1);
17531
17735
  this.state = State.CDATA_SECTION;
17532
17736
  this._stateCdataSection(cp);
17533
17737
  }
@@ -17583,54 +17787,112 @@ const IMPLICIT_END_TAG_REQUIRED_THOROUGHLY = /* @__PURE__ */ new Set([
17583
17787
  TAG_ID.THEAD,
17584
17788
  TAG_ID.TR
17585
17789
  ]);
17586
- const SCOPING_ELEMENTS_HTML = /* @__PURE__ */ new Set([
17587
- TAG_ID.APPLET,
17588
- TAG_ID.CAPTION,
17589
- TAG_ID.HTML,
17590
- TAG_ID.MARQUEE,
17591
- TAG_ID.OBJECT,
17592
- TAG_ID.TABLE,
17593
- TAG_ID.TD,
17594
- TAG_ID.TEMPLATE,
17595
- TAG_ID.TH
17596
- ]);
17597
- const SCOPING_ELEMENTS_HTML_LIST = /* @__PURE__ */ new Set([
17598
- ...SCOPING_ELEMENTS_HTML,
17599
- TAG_ID.OL,
17600
- TAG_ID.UL
17601
- ]);
17602
- const SCOPING_ELEMENTS_HTML_BUTTON = /* @__PURE__ */ new Set([...SCOPING_ELEMENTS_HTML, TAG_ID.BUTTON]);
17603
- const SCOPING_ELEMENTS_MATHML = /* @__PURE__ */ new Set([
17604
- TAG_ID.ANNOTATION_XML,
17605
- TAG_ID.MI,
17606
- TAG_ID.MN,
17607
- TAG_ID.MO,
17608
- TAG_ID.MS,
17609
- TAG_ID.MTEXT
17610
- ]);
17611
- const SCOPING_ELEMENTS_SVG = /* @__PURE__ */ new Set([
17612
- TAG_ID.DESC,
17613
- TAG_ID.FOREIGN_OBJECT,
17614
- TAG_ID.TITLE
17615
- ]);
17616
- const TABLE_ROW_CONTEXT = /* @__PURE__ */ new Set([
17790
+ /** A stack this deep starts to index its elements; a shallower one is cheaper to scan than to index. */
17791
+ const INDEX_DEPTH = 64;
17792
+ const SVG_KEYS = 256;
17793
+ const MATHML_KEYS = 512;
17794
+ const NAME_KEYS = 768;
17795
+ const NUMBERED_HEADERS = [
17796
+ TAG_ID.H1,
17797
+ TAG_ID.H2,
17798
+ TAG_ID.H3,
17799
+ TAG_ID.H4,
17800
+ TAG_ID.H5,
17801
+ TAG_ID.H6
17802
+ ];
17803
+ const TABLE_BODIES = [
17804
+ TAG_ID.TBODY,
17805
+ TAG_ID.TFOOT,
17806
+ TAG_ID.THEAD
17807
+ ];
17808
+ const TABLE_ROW_CONTEXT = [
17617
17809
  TAG_ID.TR,
17618
17810
  TAG_ID.TEMPLATE,
17619
17811
  TAG_ID.HTML
17620
- ]);
17621
- const TABLE_BODY_CONTEXT = /* @__PURE__ */ new Set([
17622
- TAG_ID.TBODY,
17623
- TAG_ID.TFOOT,
17624
- TAG_ID.THEAD,
17812
+ ];
17813
+ const TABLE_BODY_CONTEXT = [
17814
+ ...TABLE_BODIES,
17625
17815
  TAG_ID.TEMPLATE,
17626
17816
  TAG_ID.HTML
17627
- ]);
17628
- const TABLE_CONTEXT = /* @__PURE__ */ new Set([
17817
+ ];
17818
+ const TABLE_CONTEXT = [
17629
17819
  TAG_ID.TABLE,
17630
17820
  TAG_ID.TEMPLATE,
17631
17821
  TAG_ID.HTML
17632
- ]);
17633
- const TABLE_CELLS = /* @__PURE__ */ new Set([TAG_ID.TD, TAG_ID.TH]);
17822
+ ];
17823
+ const TABLE_CELLS = [TAG_ID.TD, TAG_ID.TH];
17824
+ const SPECIAL = 1;
17825
+ const LIST_ITEM_BOUNDARY = 2;
17826
+ const SCOPE = 4;
17827
+ const LIST_ITEM_SCOPE = 8;
17828
+ const BUTTON_SCOPE = 16;
17829
+ const TABLE_SCOPE = 32;
17830
+ const KEY_CLASSES = new Uint8Array(NAME_KEYS);
17831
+ for (const [ns, offset] of [
17832
+ [NS.HTML, 0],
17833
+ [NS.SVG, SVG_KEYS],
17834
+ [NS.MATHML, MATHML_KEYS]
17835
+ ]) for (const tn of SPECIAL_ELEMENTS[ns]) KEY_CLASSES[offset + tn] = ns === NS.HTML && (tn === TAG_ID.ADDRESS || tn === TAG_ID.DIV || tn === TAG_ID.P) ? SPECIAL : 3;
17836
+ for (const key of [
17837
+ TAG_ID.APPLET,
17838
+ TAG_ID.CAPTION,
17839
+ TAG_ID.HTML,
17840
+ TAG_ID.MARQUEE,
17841
+ TAG_ID.OBJECT,
17842
+ TAG_ID.TABLE,
17843
+ TAG_ID.TD,
17844
+ TAG_ID.TEMPLATE,
17845
+ TAG_ID.TH,
17846
+ SVG_KEYS + TAG_ID.DESC,
17847
+ SVG_KEYS + TAG_ID.FOREIGN_OBJECT,
17848
+ SVG_KEYS + TAG_ID.TITLE,
17849
+ MATHML_KEYS + TAG_ID.ANNOTATION_XML,
17850
+ MATHML_KEYS + TAG_ID.MI,
17851
+ MATHML_KEYS + TAG_ID.MN,
17852
+ MATHML_KEYS + TAG_ID.MO,
17853
+ MATHML_KEYS + TAG_ID.MS,
17854
+ MATHML_KEYS + TAG_ID.MTEXT
17855
+ ]) KEY_CLASSES[key] |= 28;
17856
+ KEY_CLASSES[TAG_ID.OL] |= LIST_ITEM_SCOPE;
17857
+ KEY_CLASSES[TAG_ID.UL] |= LIST_ITEM_SCOPE;
17858
+ KEY_CLASSES[TAG_ID.BUTTON] |= BUTTON_SCOPE;
17859
+ KEY_CLASSES[TAG_ID.TABLE] |= TABLE_SCOPE;
17860
+ KEY_CLASSES[TAG_ID.HTML] |= TABLE_SCOPE;
17861
+ const FORMATTING_TAGS = new Uint8Array(NAME_KEYS);
17862
+ for (const tn of [
17863
+ TAG_ID.A,
17864
+ TAG_ID.B,
17865
+ TAG_ID.BIG,
17866
+ TAG_ID.CODE,
17867
+ TAG_ID.EM,
17868
+ TAG_ID.FONT,
17869
+ TAG_ID.I,
17870
+ TAG_ID.NOBR,
17871
+ TAG_ID.S,
17872
+ TAG_ID.SMALL,
17873
+ TAG_ID.STRIKE,
17874
+ TAG_ID.STRONG,
17875
+ TAG_ID.TT,
17876
+ TAG_ID.U
17877
+ ]) FORMATTING_TAGS[tn] = 1;
17878
+ /** The key of an element with a tag ID in HTML, SVG or MathML, or -1 for an element keyed by its name. */
17879
+ function tagKey(ns, tagID) {
17880
+ if (tagID === TAG_ID.UNKNOWN) return -1;
17881
+ switch (ns) {
17882
+ case NS.HTML: return tagID;
17883
+ case NS.SVG: return SVG_KEYS + tagID;
17884
+ case NS.MATHML: return MATHML_KEYS + tagID;
17885
+ default: return -1;
17886
+ }
17887
+ }
17888
+ /**
17889
+ * The stack of open elements. Each element has a slot in `items` and `tagIDs`. Once the stack is `INDEX_DEPTH` deep, it
17890
+ * indexes its elements so that the searches the parser repeats per token take constant time: it chains the elements
17891
+ * with each key, so that the topmost one is found without a scan, and counts per slot the special elements and scope
17892
+ * boundaries at or below it, which tell whether one lies between two slots. Removing an element from the middle then
17893
+ * leaves its slot free instead of moving the elements above it; `slotBelow` and `slotAbove` step over free slots, and
17894
+ * `depth` counts the open elements.
17895
+ */
17634
17896
  var OpenElementStack = class {
17635
17897
  get currentTmplContentOrNode() {
17636
17898
  return this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : this.current;
@@ -17640,14 +17902,49 @@ var OpenElementStack = class {
17640
17902
  this.handler = handler;
17641
17903
  this.items = [];
17642
17904
  this.tagIDs = [];
17905
+ /** The slot of the current element. */
17643
17906
  this.stackTop = -1;
17907
+ /** The number of open elements. */
17908
+ this.depth = 0;
17644
17909
  this.tmplCount = 0;
17645
17910
  this.currentTagId = TAG_ID.UNKNOWN;
17911
+ this.indexed = false;
17912
+ /** The slot of the open element below, and above, each open element's slot; -1 for none. */
17913
+ this.below = [];
17914
+ this.above = [];
17915
+ this.keys = [];
17916
+ /** The slot of the next lower, and higher, open element with the same key; -1 for none. */
17917
+ this.keyPrev = [];
17918
+ this.keyNext = [];
17919
+ /** The slot of the topmost open element with each key, -1 for none. */
17920
+ this.keyTops = /* @__PURE__ */ new Int32Array(0);
17921
+ /** Per slot, the open special elements, list item boundaries and scope boundaries at or below it. */
17922
+ this.specials = [];
17923
+ this.listItemBoundaries = [];
17924
+ this.scopeBoundaries = [];
17925
+ /** Per slot, the slot of the topmost open HTML element at or below it, or -1. */
17926
+ this.htmlSlots = [];
17927
+ this.formattingSlots = /* @__PURE__ */ new Map();
17646
17928
  this.current = document;
17647
17929
  }
17930
+ /** The slot of an open element, or -1. */
17648
17931
  _indexOf(element) {
17932
+ if (this.indexed) {
17933
+ const idx = this.formattingSlots.get(element);
17934
+ if (idx !== void 0) return idx;
17935
+ if (FORMATTING_TAGS[getTagID(this.treeAdapter.getTagName(element))]) return -1;
17936
+ }
17649
17937
  return this.items.lastIndexOf(element, this.stackTop);
17650
17938
  }
17939
+ /** The slot of the open element below the one at `idx`, or -1. */
17940
+ slotBelow(idx) {
17941
+ return this.indexed ? this.below[idx] : idx - 1;
17942
+ }
17943
+ /** The slot of the open element above the one at `idx`, or -1. */
17944
+ slotAbove(idx) {
17945
+ if (this.indexed) return this.above[idx];
17946
+ return idx === this.stackTop ? -1 : idx + 1;
17947
+ }
17651
17948
  _isInTemplate() {
17652
17949
  return this.currentTagId === TAG_ID.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
17653
17950
  }
@@ -17655,48 +17952,243 @@ var OpenElementStack = class {
17655
17952
  this.current = this.items[this.stackTop];
17656
17953
  this.currentTagId = this.tagIDs[this.stackTop];
17657
17954
  }
17955
+ _nameKey(ns, tagName, create) {
17956
+ var _a, _b;
17957
+ const name = `${ns} ${tagName}`;
17958
+ let key = (_a = this.nameKeys) === null || _a === void 0 ? void 0 : _a.get(name);
17959
+ if (key === void 0 && create) {
17960
+ (_b = this.nameKeys) !== null && _b !== void 0 || (this.nameKeys = /* @__PURE__ */ new Map());
17961
+ key = NAME_KEYS + this.nameKeys.size;
17962
+ this.nameKeys.set(name, key);
17963
+ if (key === this.keyTops.length) {
17964
+ const keyTops = new Int32Array(2 * key).fill(-1);
17965
+ keyTops.set(this.keyTops);
17966
+ this.keyTops = keyTops;
17967
+ }
17968
+ }
17969
+ return key !== null && key !== void 0 ? key : -1;
17970
+ }
17971
+ /** Indexes the open elements once the stack is `INDEX_DEPTH` deep. */
17972
+ _indexAll() {
17973
+ this.indexed = true;
17974
+ this.keyTops = new Int32Array(NAME_KEYS).fill(-1);
17975
+ for (let i = 0; i <= this.stackTop; i++) this._index(i, i - 1);
17976
+ }
17977
+ /** Indexes the element at `slot`, above the open element at `belowIdx`. */
17978
+ _index(slot, belowIdx) {
17979
+ const element = this.items[slot];
17980
+ const tagID = this.tagIDs[slot];
17981
+ const ns = this.treeAdapter.getNamespaceURI(element);
17982
+ let key = tagKey(ns, tagID);
17983
+ if (key === -1) key = this._nameKey(ns, this.treeAdapter.getTagName(element), true);
17984
+ const keyPrev = this.keyTops[key];
17985
+ this.keys[slot] = key;
17986
+ this.keyPrev[slot] = keyPrev;
17987
+ this.keyNext[slot] = -1;
17988
+ if (keyPrev !== -1) this.keyNext[keyPrev] = slot;
17989
+ this.keyTops[key] = slot;
17990
+ this.above[slot] = -1;
17991
+ this._link(slot, belowIdx, ns === NS.HTML);
17992
+ if (FORMATTING_TAGS[tagID]) this.formattingSlots.set(element, slot);
17993
+ }
17994
+ /** Puts the indexed element at `slot` above the one at `belowIdx`, and counts the elements of each class. */
17995
+ _link(slot, belowIdx, isHtml) {
17996
+ const key = this.keys[slot];
17997
+ const classes = key < NAME_KEYS ? KEY_CLASSES[key] : 0;
17998
+ this.below[slot] = belowIdx;
17999
+ if (belowIdx === -1) {
18000
+ this.specials[slot] = classes & SPECIAL;
18001
+ this.listItemBoundaries[slot] = (classes & LIST_ITEM_BOUNDARY) >> 1;
18002
+ this.scopeBoundaries[slot] = (classes & SCOPE) >> 2;
18003
+ this.htmlSlots[slot] = isHtml ? slot : -1;
18004
+ } else {
18005
+ this.above[belowIdx] = slot;
18006
+ this.specials[slot] = this.specials[belowIdx] + (classes & SPECIAL);
18007
+ this.listItemBoundaries[slot] = this.listItemBoundaries[belowIdx] + ((classes & LIST_ITEM_BOUNDARY) >> 1);
18008
+ this.scopeBoundaries[slot] = this.scopeBoundaries[belowIdx] + ((classes & SCOPE) >> 2);
18009
+ this.htmlSlots[slot] = isHtml ? slot : this.htmlSlots[belowIdx];
18010
+ }
18011
+ }
18012
+ /** Takes the element at `slot` out of the index, except for the links between slots. */
18013
+ _unindex(slot) {
18014
+ const key = this.keys[slot];
18015
+ const keyPrev = this.keyPrev[slot];
18016
+ const keyNext = this.keyNext[slot];
18017
+ if (keyPrev !== -1) this.keyNext[keyPrev] = keyNext;
18018
+ if (keyNext === -1) this.keyTops[key] = keyPrev;
18019
+ else this.keyPrev[keyNext] = keyPrev;
18020
+ if (FORMATTING_TAGS[this.tagIDs[slot]]) this.formattingSlots.delete(this.items[slot]);
18021
+ }
18022
+ /** Moves the indexed element at `from` down to the free slot `to`, keeping its key chain in order. */
18023
+ _move(from, to) {
18024
+ const element = this.items[from];
18025
+ const key = this.keys[from];
18026
+ const keyPrev = this.keyPrev[from];
18027
+ const keyNext = this.keyNext[from];
18028
+ this.items[to] = element;
18029
+ this.tagIDs[to] = this.tagIDs[from];
18030
+ this.keys[to] = key;
18031
+ this.keyPrev[to] = keyPrev;
18032
+ this.keyNext[to] = keyNext;
18033
+ if (keyPrev !== -1) this.keyNext[keyPrev] = to;
18034
+ if (keyNext === -1) this.keyTops[key] = to;
18035
+ else this.keyPrev[keyNext] = to;
18036
+ if (FORMATTING_TAGS[this.tagIDs[to]]) this.formattingSlots.set(element, to);
18037
+ }
18038
+ /** The slot of the topmost open HTML element with this tag, or -1. */
18039
+ indexOfTopmost(tagID) {
18040
+ if (this.indexed) return this.keyTops[tagID];
18041
+ for (let i = this.stackTop; i >= 0; i--) if (this.tagIDs[i] === tagID && this.treeAdapter.getNamespaceURI(this.items[i]) === NS.HTML) return i;
18042
+ return -1;
18043
+ }
18044
+ /** The slot of the topmost open HTML element with any of these tags, or -1. */
18045
+ indexOfTopmostOf(tagIDs) {
18046
+ if (this.indexed) {
18047
+ let top = -1;
18048
+ for (const tagID of tagIDs) if (this.keyTops[tagID] > top) top = this.keyTops[tagID];
18049
+ return top;
18050
+ }
18051
+ for (let i = this.stackTop; i >= 0; i--) if (tagIDs.includes(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === NS.HTML) return i;
18052
+ return -1;
18053
+ }
18054
+ /** The slot of the topmost open element in this namespace with this tag name, or -1. */
18055
+ indexOfTopmostByName(ns, tagName) {
18056
+ if (this.indexed) {
18057
+ let key = tagKey(ns, getTagID(tagName));
18058
+ if (key === -1) key = this._nameKey(ns, tagName, false);
18059
+ return key === -1 ? -1 : this.keyTops[key];
18060
+ }
18061
+ for (let i = this.stackTop; i >= 0; i--) {
18062
+ const element = this.items[i];
18063
+ if (this.treeAdapter.getTagName(element) === tagName && this.treeAdapter.getNamespaceURI(element) === ns) return i;
18064
+ }
18065
+ return -1;
18066
+ }
18067
+ /** The slot of the topmost open HTML element, or -1. */
18068
+ indexOfTopmostHtmlElement() {
18069
+ if (this.indexed) return this.stackTop === -1 ? -1 : this.htmlSlots[this.stackTop];
18070
+ let i = this.stackTop;
18071
+ while (i >= 0 && this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) i--;
18072
+ return i;
18073
+ }
18074
+ /** Whether an element of the classes is open above the slot `idx`, on a stack that is not indexed. */
18075
+ _hasAbove(idx, classes) {
18076
+ for (let i = this.stackTop; i > idx; i--) {
18077
+ const key = tagKey(this.treeAdapter.getNamespaceURI(this.items[i]), this.tagIDs[i]);
18078
+ if (key !== -1 && KEY_CLASSES[key] & classes) return true;
18079
+ }
18080
+ return false;
18081
+ }
18082
+ /** Whether a special element is open above the slot `idx`. */
18083
+ hasSpecialElementAbove(idx) {
18084
+ return this.indexed ? this.specials[this.stackTop] !== this.specials[idx] : this._hasAbove(idx, SPECIAL);
18085
+ }
18086
+ /** Whether a special element other than HTML `address`, `div` and `p` is open above the slot `idx`. */
18087
+ hasListItemBoundaryAbove(idx) {
18088
+ return this.indexed ? this.listItemBoundaries[this.stackTop] !== this.listItemBoundaries[idx] : this._hasAbove(idx, LIST_ITEM_BOUNDARY);
18089
+ }
17658
18090
  push(element, tagID) {
18091
+ const belowIdx = this.stackTop;
17659
18092
  this.stackTop++;
18093
+ this.depth++;
17660
18094
  this.items[this.stackTop] = element;
17661
18095
  this.current = element;
17662
18096
  this.tagIDs[this.stackTop] = tagID;
17663
18097
  this.currentTagId = tagID;
18098
+ if (this.indexed) this._index(this.stackTop, belowIdx);
18099
+ else if (this.depth === INDEX_DEPTH) this._indexAll();
17664
18100
  if (this._isInTemplate()) this.tmplCount++;
17665
18101
  this.handler.onItemPush(element, tagID, true);
17666
18102
  }
17667
- pop() {
17668
- const popped = this.current;
18103
+ /** Pops the current element without calling the handler. */
18104
+ _popCurrent() {
17669
18105
  if (this.tmplCount > 0 && this._isInTemplate()) this.tmplCount--;
17670
- this.stackTop--;
18106
+ if (this.indexed) {
18107
+ this._unindex(this.stackTop);
18108
+ this.stackTop = this.below[this.stackTop];
18109
+ if (this.stackTop !== -1) this.above[this.stackTop] = -1;
18110
+ } else this.stackTop--;
18111
+ this.depth--;
17671
18112
  this._updateCurrentElement();
18113
+ }
18114
+ pop() {
18115
+ const popped = this.current;
18116
+ this._popCurrent();
17672
18117
  this.handler.onItemPop(popped, true);
17673
18118
  }
17674
18119
  replace(oldElement, newElement) {
17675
18120
  const idx = this._indexOf(oldElement);
17676
18121
  this.items[idx] = newElement;
18122
+ if (this.indexed && FORMATTING_TAGS[this.tagIDs[idx]]) {
18123
+ this.formattingSlots.delete(oldElement);
18124
+ this.formattingSlots.set(newElement, idx);
18125
+ }
17677
18126
  if (idx === this.stackTop) this.current = newElement;
17678
18127
  }
17679
- insertAfter(referenceElement, newElement, newElementID) {
17680
- const insertionIdx = this._indexOf(referenceElement) + 1;
17681
- this.items.splice(insertionIdx, 0, newElement);
17682
- this.tagIDs.splice(insertionIdx, 0, newElementID);
17683
- this.stackTop++;
17684
- if (insertionIdx === this.stackTop) this._updateCurrentElement();
17685
- if (this.current && this.currentTagId !== void 0) this.handler.onItemPush(this.current, this.currentTagId, insertionIdx === this.stackTop);
18128
+ /**
18129
+ * The adoption agency's last stack step: removes the formatting element at `formattingIdx` and opens `element`
18130
+ * directly above the furthest block at `furthestBlockIdx`. On an indexed stack, only formatting elements the agency
18131
+ * kept are still open between them; the furthest block, with those directly below it, moves down by one slot, and
18132
+ * `element` takes the furthest block's slot. No open element above the furthest block moves, and as all these
18133
+ * elements are HTML elements and only the furthest block is special, the counts above it stay the same.
18134
+ */
18135
+ replaceFormattingElement(formattingIdx, furthestBlockIdx, element, tagID) {
18136
+ const formattingElement = this.items[formattingIdx];
18137
+ if (!this.indexed) {
18138
+ this.items.splice(formattingIdx, 1);
18139
+ this.tagIDs.splice(formattingIdx, 1);
18140
+ this.handler.onItemPop(formattingElement, false);
18141
+ this.items.splice(furthestBlockIdx, 0, element);
18142
+ this.tagIDs.splice(furthestBlockIdx, 0, tagID);
18143
+ if (furthestBlockIdx === this.stackTop) this._updateCurrentElement();
18144
+ if (this.current && this.currentTagId !== void 0) this.handler.onItemPush(this.current, this.currentTagId, furthestBlockIdx === this.stackTop);
18145
+ return;
18146
+ }
18147
+ const key = this.keys[formattingIdx];
18148
+ const belowIdx = this.below[formattingIdx];
18149
+ const aboveIdx = this.above[furthestBlockIdx];
18150
+ const kept = [];
18151
+ for (let i = this.above[formattingIdx]; i !== furthestBlockIdx; i = this.above[i]) kept.push(i);
18152
+ const keyNext = this.keyNext[formattingIdx];
18153
+ this._unindex(formattingIdx);
18154
+ this.items[formattingIdx] = void 0;
18155
+ this.handler.onItemPop(formattingElement, false);
18156
+ let free = furthestBlockIdx - 1;
18157
+ while (kept.length > 0 && kept[kept.length - 1] === free) {
18158
+ kept.pop();
18159
+ free--;
18160
+ }
18161
+ for (let i = free + 1; i <= furthestBlockIdx; i++) this._move(i, i - 1);
18162
+ const keyPrev = keyNext === -1 ? this.keyTops[key] : this.keyPrev[keyNext];
18163
+ this.items[furthestBlockIdx] = element;
18164
+ this.tagIDs[furthestBlockIdx] = tagID;
18165
+ this.keys[furthestBlockIdx] = key;
18166
+ this.keyPrev[furthestBlockIdx] = keyPrev;
18167
+ this.keyNext[furthestBlockIdx] = keyNext;
18168
+ if (keyPrev !== -1) this.keyNext[keyPrev] = furthestBlockIdx;
18169
+ if (keyNext === -1) this.keyTops[key] = furthestBlockIdx;
18170
+ else this.keyPrev[keyNext] = furthestBlockIdx;
18171
+ if (FORMATTING_TAGS[tagID]) this.formattingSlots.set(element, furthestBlockIdx);
18172
+ let prev = belowIdx;
18173
+ for (const i of kept) {
18174
+ this._link(i, prev, true);
18175
+ prev = i;
18176
+ }
18177
+ for (let i = free; i < furthestBlockIdx; i++) {
18178
+ this._link(i, prev, true);
18179
+ prev = i;
18180
+ }
18181
+ this._link(furthestBlockIdx, prev, true);
18182
+ if (aboveIdx === -1) this._updateCurrentElement();
18183
+ if (this.current && this.currentTagId !== void 0) this.handler.onItemPush(this.current, this.currentTagId, aboveIdx === -1);
17686
18184
  }
17687
18185
  popUntilTagNamePopped(tagName) {
17688
- let targetIdx = this.stackTop + 1;
17689
- do
17690
- targetIdx = this.tagIDs.lastIndexOf(tagName, targetIdx - 1);
17691
- while (targetIdx > 0 && this.treeAdapter.getNamespaceURI(this.items[targetIdx]) !== NS.HTML);
17692
- this.shortenToLength(Math.max(targetIdx, 0));
18186
+ this.shortenToLength(Math.max(this.indexOfTopmost(tagName), 0));
17693
18187
  }
17694
18188
  shortenToLength(idx) {
17695
18189
  while (this.stackTop >= idx) {
17696
18190
  const popped = this.current;
17697
- if (this.tmplCount > 0 && this._isInTemplate()) this.tmplCount -= 1;
17698
- this.stackTop--;
17699
- this._updateCurrentElement();
18191
+ this._popCurrent();
17700
18192
  this.handler.onItemPop(popped, this.stackTop < idx);
17701
18193
  }
17702
18194
  }
@@ -17704,49 +18196,59 @@ var OpenElementStack = class {
17704
18196
  const idx = this._indexOf(element);
17705
18197
  this.shortenToLength(Math.max(idx, 0));
17706
18198
  }
17707
- popUntilPopped(tagNames, targetNS) {
17708
- const idx = this._indexOfTagNames(tagNames, targetNS);
17709
- this.shortenToLength(Math.max(idx, 0));
17710
- }
17711
18199
  popUntilNumberedHeaderPopped() {
17712
- this.popUntilPopped(NUMBERED_HEADERS, NS.HTML);
18200
+ this.shortenToLength(Math.max(this.indexOfTopmostOf(NUMBERED_HEADERS), 0));
17713
18201
  }
17714
18202
  popUntilTableCellPopped() {
17715
- this.popUntilPopped(TABLE_CELLS, NS.HTML);
18203
+ this.shortenToLength(Math.max(this.indexOfTopmostOf(TABLE_CELLS), 0));
17716
18204
  }
17717
18205
  popAllUpToHtmlElement() {
17718
18206
  this.tmplCount = 0;
17719
18207
  this.shortenToLength(1);
17720
18208
  }
17721
- _indexOfTagNames(tagNames, namespace) {
17722
- for (let i = this.stackTop; i >= 0; i--) if (tagNames.has(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === namespace) return i;
17723
- return -1;
17724
- }
17725
- clearBackTo(tagNames, targetNS) {
17726
- const idx = this._indexOfTagNames(tagNames, targetNS);
17727
- this.shortenToLength(idx + 1);
17728
- }
17729
18209
  clearBackToTableContext() {
17730
- this.clearBackTo(TABLE_CONTEXT, NS.HTML);
18210
+ this.shortenToLength(this.indexOfTopmostOf(TABLE_CONTEXT) + 1);
17731
18211
  }
17732
18212
  clearBackToTableBodyContext() {
17733
- this.clearBackTo(TABLE_BODY_CONTEXT, NS.HTML);
18213
+ this.shortenToLength(this.indexOfTopmostOf(TABLE_BODY_CONTEXT) + 1);
17734
18214
  }
17735
18215
  clearBackToTableRowContext() {
17736
- this.clearBackTo(TABLE_ROW_CONTEXT, NS.HTML);
18216
+ this.shortenToLength(this.indexOfTopmostOf(TABLE_ROW_CONTEXT) + 1);
17737
18217
  }
17738
18218
  remove(element) {
17739
18219
  const idx = this._indexOf(element);
17740
- if (idx >= 0) {
17741
- if (idx === this.stackTop) this.pop();
17742
- else {
17743
- this.items.splice(idx, 1);
17744
- this.tagIDs.splice(idx, 1);
17745
- this.stackTop--;
17746
- this._updateCurrentElement();
17747
- this.handler.onItemPop(element, false);
17748
- }
18220
+ if (idx !== -1) this.removeAt(idx);
18221
+ }
18222
+ /** Removes the open element at the slot `idx`; on an indexed stack, the elements above it keep their slots. */
18223
+ removeAt(idx) {
18224
+ if (idx === this.stackTop) {
18225
+ this.pop();
18226
+ return;
18227
+ }
18228
+ const element = this.items[idx];
18229
+ this.depth--;
18230
+ if (this.indexed) {
18231
+ const classes = this.keys[idx] < NAME_KEYS ? KEY_CLASSES[this.keys[idx]] : 0;
18232
+ const belowIdx = this.below[idx];
18233
+ const aboveIdx = this.above[idx];
18234
+ this._unindex(idx);
18235
+ this.items[idx] = void 0;
18236
+ this.below[aboveIdx] = belowIdx;
18237
+ if (belowIdx !== -1) this.above[belowIdx] = aboveIdx;
18238
+ if (classes !== 0) for (let i = aboveIdx; i !== -1; i = this.above[i]) {
18239
+ this.specials[i] -= classes & SPECIAL;
18240
+ this.listItemBoundaries[i] -= (classes & LIST_ITEM_BOUNDARY) >> 1;
18241
+ this.scopeBoundaries[i] -= (classes & SCOPE) >> 2;
18242
+ }
18243
+ const html = belowIdx === -1 ? -1 : this.htmlSlots[belowIdx];
18244
+ for (let i = aboveIdx; i !== -1 && this.htmlSlots[i] === idx; i = this.above[i]) this.htmlSlots[i] = html;
18245
+ } else {
18246
+ this.items.splice(idx, 1);
18247
+ this.tagIDs.splice(idx, 1);
18248
+ this.stackTop--;
18249
+ this._updateCurrentElement();
17749
18250
  }
18251
+ this.handler.onItemPop(element, false);
17750
18252
  }
17751
18253
  tryPeekProperlyNestedBodyElement() {
17752
18254
  return this.stackTop >= 1 && this.tagIDs[1] === TAG_ID.BODY ? this.items[1] : null;
@@ -17755,79 +18257,67 @@ var OpenElementStack = class {
17755
18257
  return this._indexOf(element) > -1;
17756
18258
  }
17757
18259
  getCommonAncestor(element) {
17758
- const elementIdx = this._indexOf(element) - 1;
17759
- return elementIdx >= 0 ? this.items[elementIdx] : null;
18260
+ const idx = this._indexOf(element);
18261
+ const belowIdx = idx === -1 ? -1 : this.slotBelow(idx);
18262
+ return belowIdx === -1 ? null : this.items[belowIdx];
17760
18263
  }
17761
18264
  isRootHtmlElementCurrent() {
17762
18265
  return this.stackTop === 0 && this.tagIDs[0] === TAG_ID.HTML;
17763
18266
  }
17764
- hasInDynamicScope(tagName, htmlScope) {
18267
+ /**
18268
+ * On an indexed stack: whether no element of the `scope` class is open above the slot `target`. A target that is not
18269
+ * open is in scope only on a stack without such an element, as a scan from the top would end there.
18270
+ */
18271
+ _isInScope(target, scope) {
18272
+ let boundary = -1;
18273
+ switch (scope) {
18274
+ case LIST_ITEM_SCOPE:
18275
+ boundary = Math.max(this.keyTops[TAG_ID.OL], this.keyTops[TAG_ID.UL]);
18276
+ break;
18277
+ case BUTTON_SCOPE:
18278
+ boundary = this.keyTops[TAG_ID.BUTTON];
18279
+ break;
18280
+ case TABLE_SCOPE:
18281
+ boundary = Math.max(this.keyTops[TAG_ID.TABLE], this.keyTops[TAG_ID.HTML]);
18282
+ return target === -1 ? boundary === -1 : target >= boundary;
18283
+ }
18284
+ return target === -1 ? boundary === -1 && (this.stackTop === -1 || this.scopeBoundaries[this.stackTop] === 0) : target >= boundary && this.scopeBoundaries[this.stackTop] === this.scopeBoundaries[target];
18285
+ }
18286
+ /**
18287
+ * On a stack that is not indexed: whether an HTML element with the tag, or one of the tags, and if passed the element
18288
+ * itself, is open above every element of the `scope` class; true if neither is open.
18289
+ */
18290
+ _scanScope(tagID, tagIDs, scope, element) {
17765
18291
  for (let i = this.stackTop; i >= 0; i--) {
17766
- const tn = this.tagIDs[i];
17767
- switch (this.treeAdapter.getNamespaceURI(this.items[i])) {
17768
- case NS.HTML:
17769
- if (tn === tagName) return true;
17770
- if (htmlScope.has(tn)) return false;
17771
- break;
17772
- case NS.SVG:
17773
- if (SCOPING_ELEMENTS_SVG.has(tn)) return false;
17774
- break;
17775
- case NS.MATHML: if (SCOPING_ELEMENTS_MATHML.has(tn)) return false;
17776
- }
18292
+ const key = tagKey(this.treeAdapter.getNamespaceURI(this.items[i]), this.tagIDs[i]);
18293
+ if (key === -1) continue;
18294
+ if ((tagIDs ? tagIDs.includes(key) : key === tagID) && (!element || this.items[i] === element)) return true;
18295
+ if (KEY_CLASSES[key] & scope) return false;
17777
18296
  }
17778
18297
  return true;
17779
18298
  }
17780
- hasInScope(tagName) {
17781
- return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML);
18299
+ /** If `element` is passed, only that element (which has to be a `tagName` element) is looked for. */
18300
+ hasInScope(tagName, element) {
18301
+ if (!this.indexed) return this._scanScope(tagName, null, SCOPE, element);
18302
+ return this._isInScope(element ? this._indexOf(element) : this.keyTops[tagName], SCOPE);
17782
18303
  }
17783
18304
  hasInListItemScope(tagName) {
17784
- return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML_LIST);
18305
+ return this.indexed ? this._isInScope(this.keyTops[tagName], LIST_ITEM_SCOPE) : this._scanScope(tagName, null, LIST_ITEM_SCOPE);
17785
18306
  }
17786
18307
  hasInButtonScope(tagName) {
17787
- return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML_BUTTON);
18308
+ return this.indexed ? this._isInScope(this.keyTops[tagName], BUTTON_SCOPE) : this._scanScope(tagName, null, BUTTON_SCOPE);
17788
18309
  }
17789
18310
  hasNumberedHeaderInScope() {
17790
- for (let i = this.stackTop; i >= 0; i--) {
17791
- const tn = this.tagIDs[i];
17792
- switch (this.treeAdapter.getNamespaceURI(this.items[i])) {
17793
- case NS.HTML:
17794
- if (NUMBERED_HEADERS.has(tn)) return true;
17795
- if (SCOPING_ELEMENTS_HTML.has(tn)) return false;
17796
- break;
17797
- case NS.SVG:
17798
- if (SCOPING_ELEMENTS_SVG.has(tn)) return false;
17799
- break;
17800
- case NS.MATHML: if (SCOPING_ELEMENTS_MATHML.has(tn)) return false;
17801
- }
17802
- }
17803
- return true;
18311
+ return this.indexed ? this._isInScope(this.indexOfTopmostOf(NUMBERED_HEADERS), SCOPE) : this._scanScope(TAG_ID.UNKNOWN, NUMBERED_HEADERS, SCOPE);
17804
18312
  }
17805
18313
  hasInTableScope(tagName) {
17806
- for (let i = this.stackTop; i >= 0; i--) {
17807
- if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) continue;
17808
- switch (this.tagIDs[i]) {
17809
- case tagName: return true;
17810
- case TAG_ID.TABLE:
17811
- case TAG_ID.HTML: return false;
17812
- }
17813
- }
17814
- return true;
18314
+ return this.indexed ? this._isInScope(this.keyTops[tagName], TABLE_SCOPE) : this._scanScope(tagName, null, TABLE_SCOPE);
17815
18315
  }
17816
18316
  hasTableBodyContextInTableScope() {
17817
- for (let i = this.stackTop; i >= 0; i--) {
17818
- if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) continue;
17819
- switch (this.tagIDs[i]) {
17820
- case TAG_ID.TBODY:
17821
- case TAG_ID.THEAD:
17822
- case TAG_ID.TFOOT: return true;
17823
- case TAG_ID.TABLE:
17824
- case TAG_ID.HTML: return false;
17825
- }
17826
- }
17827
- return true;
18317
+ return this.indexed ? this._isInScope(this.indexOfTopmostOf(TABLE_BODIES), TABLE_SCOPE) : this._scanScope(TAG_ID.UNKNOWN, TABLE_BODIES, TABLE_SCOPE);
17828
18318
  }
17829
18319
  hasInSelectScope(tagName) {
17830
- for (let i = this.stackTop; i >= 0; i--) {
18320
+ for (let i = this.stackTop; i >= 0; i = this.slotBelow(i)) {
17831
18321
  if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) continue;
17832
18322
  switch (this.tagIDs[i]) {
17833
18323
  case tagName: return true;
@@ -17839,13 +18329,13 @@ var OpenElementStack = class {
17839
18329
  return true;
17840
18330
  }
17841
18331
  generateImpliedEndTags() {
17842
- while (this.currentTagId !== void 0 && IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId)) this.pop();
18332
+ while (this.currentTagId !== void 0 && IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId) && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML) this.pop();
17843
18333
  }
17844
18334
  generateImpliedEndTagsThoroughly() {
17845
- while (this.currentTagId !== void 0 && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) this.pop();
18335
+ while (this.currentTagId !== void 0 && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId) && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML) this.pop();
17846
18336
  }
17847
18337
  generateImpliedEndTagsWithExclusion(exclusionId) {
17848
- while (this.currentTagId !== void 0 && this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) this.pop();
18338
+ while (this.currentTagId !== void 0 && this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId) && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML) this.pop();
17849
18339
  }
17850
18340
  };
17851
18341
  // node_modules/parse5/dist/parser/formatting-element-list.js
@@ -17855,69 +18345,114 @@ var EntryType;
17855
18345
  EntryType[EntryType["Marker"] = 0] = "Marker";
17856
18346
  EntryType[EntryType["Element"] = 1] = "Element";
17857
18347
  })(EntryType || (EntryType = {}));
17858
- const MARKER = { type: EntryType.Marker };
17859
18348
  var FormattingElementList = class {
17860
- constructor(treeAdapter) {
17861
- this.treeAdapter = treeAdapter;
17862
- this.entries = [];
18349
+ constructor() {
18350
+ this.newest = null;
17863
18351
  this.bookmark = null;
17864
- }
17865
- _getNoahArkConditionCandidates(newElement, neAttrs) {
17866
- const candidates = [];
17867
- const neAttrsLength = neAttrs.length;
17868
- const neTagName = this.treeAdapter.getTagName(newElement);
17869
- const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
17870
- for (let i = 0; i < this.entries.length; i++) {
17871
- const entry = this.entries[i];
17872
- if (entry.type === EntryType.Marker) break;
17873
- const { element } = entry;
17874
- if (this.treeAdapter.getTagName(element) === neTagName && this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) {
17875
- const elementAttrs = this.treeAdapter.getAttrList(element);
17876
- if (elementAttrs.length === neAttrsLength) candidates.push({
17877
- idx: i,
17878
- attrs: elementAttrs
17879
- });
17880
- }
17881
- }
17882
- return candidates;
17883
- }
17884
- _ensureNoahArkCondition(newElement) {
17885
- if (this.entries.length < NOAH_ARK_CAPACITY) return;
17886
- const neAttrs = this.treeAdapter.getAttrList(newElement);
17887
- const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs);
17888
- if (candidates.length < NOAH_ARK_CAPACITY) return;
17889
- const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value]));
17890
- let validCandidates = 0;
17891
- for (let i = 0; i < candidates.length; i++) {
17892
- const candidate = candidates[i];
17893
- if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) {
17894
- validCandidates += 1;
17895
- if (validCandidates >= NOAH_ARK_CAPACITY) this.entries.splice(candidate.idx, 1);
17896
- }
17897
- }
18352
+ /** The index of the entries after the last marker; null only while there are at most NOAH_ARK_CAPACITY of them. */
18353
+ this.index = null;
18354
+ /** The entries by element, except possibly those after the last marker while they are not indexed. */
18355
+ this.elementEntries = /* @__PURE__ */ new Map();
18356
+ }
18357
+ /** Returns the entry's ark, or null if the entries after the last marker are not indexed. */
18358
+ _insertElementEntry(element, token, older) {
18359
+ const newer = older === null ? null : older.newer;
18360
+ const entry = {
18361
+ type: EntryType.Element,
18362
+ element,
18363
+ token,
18364
+ older,
18365
+ newer,
18366
+ ark: null,
18367
+ olderSameTag: null,
18368
+ newerSameTag: null
18369
+ };
18370
+ if (newer === null) this.newest = entry;
18371
+ else newer.older = entry;
18372
+ if (older !== null) older.newer = entry;
18373
+ return this.index === null ? null : this._addToIndex(this.index, entry);
18374
+ }
18375
+ _addToIndex(index, entry) {
18376
+ const { tagName, attrs } = entry.token;
18377
+ const key = tagName + attrs.map(({ name, value }) => `\0${name}\0${value}`).sort().join("");
18378
+ let ark = index.arks.get(key);
18379
+ if (ark === void 0) {
18380
+ ark = {
18381
+ entries: [],
18382
+ key
18383
+ };
18384
+ index.arks.set(key, ark);
18385
+ }
18386
+ ark.entries.push(entry);
18387
+ entry.ark = ark;
18388
+ this.elementEntries.set(entry.element, entry);
18389
+ let head = index.tagNames.get(tagName);
18390
+ if (head === void 0) {
18391
+ head = { olderSameTag: null };
18392
+ index.tagNames.set(tagName, head);
18393
+ }
18394
+ entry.olderSameTag = head.olderSameTag;
18395
+ entry.newerSameTag = head;
18396
+ if (head.olderSameTag !== null) head.olderSameTag.newerSameTag = entry;
18397
+ head.olderSameTag = entry;
18398
+ return ark;
17898
18399
  }
17899
18400
  insertMarker() {
17900
- this.entries.unshift(MARKER);
18401
+ if (this.index === null) for (let entry = this.newest; entry !== null && entry.type === EntryType.Element; entry = entry.older) this.elementEntries.set(entry.element, entry);
18402
+ const marker = {
18403
+ type: EntryType.Marker,
18404
+ older: this.newest,
18405
+ newer: null,
18406
+ outerIndex: this.index
18407
+ };
18408
+ if (this.newest !== null) this.newest.newer = marker;
18409
+ this.newest = marker;
18410
+ this.index = null;
17901
18411
  }
17902
18412
  pushElement(element, token) {
17903
- this._ensureNoahArkCondition(element);
17904
- this.entries.unshift({
17905
- type: EntryType.Element,
17906
- element,
17907
- token
17908
- });
18413
+ if (this.index === null) {
18414
+ let oldest = null;
18415
+ let count = 0;
18416
+ for (let entry = this.newest; entry !== null && entry.type === EntryType.Element; entry = entry.older) {
18417
+ oldest = entry;
18418
+ count++;
18419
+ }
18420
+ if (count >= NOAH_ARK_CAPACITY) {
18421
+ this.index = {
18422
+ arks: /* @__PURE__ */ new Map(),
18423
+ tagNames: /* @__PURE__ */ new Map()
18424
+ };
18425
+ for (let entry = oldest; entry !== null && entry.type === EntryType.Element; entry = entry.newer) this._addToIndex(this.index, entry);
18426
+ }
18427
+ }
18428
+ const ark = this._insertElementEntry(element, token, this.newest);
18429
+ if (ark !== null && ark.entries.length > NOAH_ARK_CAPACITY) this.removeEntry(ark.entries[0]);
17909
18430
  }
17910
18431
  insertElementAfterBookmark(element, token) {
17911
- const bookmarkIdx = this.entries.indexOf(this.bookmark);
17912
- this.entries.splice(bookmarkIdx, 0, {
17913
- type: EntryType.Element,
17914
- element,
17915
- token
17916
- });
18432
+ const { bookmark } = this;
18433
+ this.bookmark = null;
18434
+ this._insertElementEntry(element, token, bookmark);
17917
18435
  }
17918
18436
  removeEntry(entry) {
17919
- const entryIndex = this.entries.indexOf(entry);
17920
- if (entryIndex !== -1) this.entries.splice(entryIndex, 1);
18437
+ var _a;
18438
+ if (entry.newer === null ? this.newest !== entry : entry.newer.older !== entry) return;
18439
+ this.elementEntries.delete(entry.element);
18440
+ if (entry.newer === null) this.newest = entry.older;
18441
+ else entry.newer.older = entry.older;
18442
+ if (entry.older !== null) entry.older.newer = entry.newer;
18443
+ if (entry.ark !== null) {
18444
+ const { entries, key } = entry.ark;
18445
+ entries.splice(entries.indexOf(entry), 1);
18446
+ if (entries.length === 0) (_a = this.index) === null || _a === void 0 || _a.arks.delete(key);
18447
+ }
18448
+ if (entry.newerSameTag !== null) {
18449
+ entry.newerSameTag.olderSameTag = entry.olderSameTag;
18450
+ if (entry.olderSameTag !== null) entry.olderSameTag.newerSameTag = entry.newerSameTag;
18451
+ }
18452
+ }
18453
+ replaceElement(entry, element) {
18454
+ if (this.elementEntries.delete(entry.element)) this.elementEntries.set(element, entry);
18455
+ entry.element = element;
17921
18456
  }
17922
18457
  /**
17923
18458
  * Clears the list of formatting elements up to the last marker.
@@ -17925,19 +18460,28 @@ var FormattingElementList = class {
17925
18460
  * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker
17926
18461
  */
17927
18462
  clearToLastMarker() {
17928
- const markerIdx = this.entries.indexOf(MARKER);
17929
- if (markerIdx === -1) this.entries.length = 0;
17930
- else this.entries.splice(0, markerIdx + 1);
18463
+ let marker = this.newest;
18464
+ for (; marker !== null && marker.type === EntryType.Element; marker = marker.older) this.elementEntries.delete(marker.element);
18465
+ this.newest = marker === null ? null : marker.older;
18466
+ this.index = marker === null ? null : marker.outerIndex;
18467
+ if (this.newest !== null) this.newest.newer = null;
17931
18468
  }
17932
18469
  getElementEntryInScopeWithTagName(tagName) {
17933
- const entry = this.entries.find((entry) => entry.type === EntryType.Marker || this.treeAdapter.getTagName(entry.element) === tagName);
17934
- return entry && entry.type === EntryType.Element ? entry : null;
18470
+ var _a, _b;
18471
+ if (this.index !== null) return (_b = (_a = this.index.tagNames.get(tagName)) === null || _a === void 0 ? void 0 : _a.olderSameTag) !== null && _b !== void 0 ? _b : null;
18472
+ for (let entry = this.newest; entry !== null && entry.type === EntryType.Element; entry = entry.older) if (entry.token.tagName === tagName) return entry;
18473
+ return null;
17935
18474
  }
17936
18475
  getElementEntry(element) {
17937
- return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element);
18476
+ if (this.index === null) {
18477
+ for (let entry = this.newest; entry !== null && entry.type === EntryType.Element; entry = entry.older) if (entry.element === element) return entry;
18478
+ }
18479
+ return this.elementEntries.get(element);
17938
18480
  }
17939
18481
  };
17940
18482
  // node_modules/parse5/dist/tree-adapters/default.js
18483
+ /** The position of each name in the attribute lists `adoptAttributes` merged into, kept for the next merge into that list. */
18484
+ const attrListIndexes = /* @__PURE__ */ new WeakMap();
17941
18485
  const defaultTreeAdapter = {
17942
18486
  createDocument() {
17943
18487
  return {
@@ -17981,8 +18525,9 @@ const defaultTreeAdapter = {
17981
18525
  newNode.parentNode = parentNode;
17982
18526
  },
17983
18527
  insertBefore(parentNode, newNode, referenceNode) {
17984
- const insertionIdx = parentNode.childNodes.indexOf(referenceNode);
17985
- parentNode.childNodes.splice(insertionIdx, 0, newNode);
18528
+ const { childNodes } = parentNode;
18529
+ const insertionIdx = childNodes[childNodes.length - 1] === referenceNode ? childNodes.length - 1 : childNodes.indexOf(referenceNode);
18530
+ childNodes.splice(insertionIdx, 0, newNode);
17986
18531
  newNode.parentNode = parentNode;
17987
18532
  },
17988
18533
  setTemplateContent(templateElement, contentElement) {
@@ -18016,8 +18561,9 @@ const defaultTreeAdapter = {
18016
18561
  },
18017
18562
  detachNode(node) {
18018
18563
  if (node.parentNode) {
18019
- const idx = node.parentNode.childNodes.indexOf(node);
18020
- node.parentNode.childNodes.splice(idx, 1);
18564
+ const { childNodes } = node.parentNode;
18565
+ const idx = childNodes[childNodes.length - 1] === node ? childNodes.length - 1 : childNodes.indexOf(node);
18566
+ childNodes.splice(idx, 1);
18021
18567
  node.parentNode = null;
18022
18568
  }
18023
18569
  },
@@ -18032,13 +18578,36 @@ const defaultTreeAdapter = {
18032
18578
  defaultTreeAdapter.appendChild(parentNode, defaultTreeAdapter.createTextNode(text));
18033
18579
  },
18034
18580
  insertTextBefore(parentNode, text, referenceNode) {
18035
- const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
18581
+ const { childNodes } = parentNode;
18582
+ const prevNode = childNodes[(childNodes[childNodes.length - 1] === referenceNode ? childNodes.length - 1 : childNodes.indexOf(referenceNode)) - 1];
18036
18583
  if (prevNode && defaultTreeAdapter.isTextNode(prevNode)) prevNode.value += text;
18037
18584
  else defaultTreeAdapter.insertBefore(parentNode, defaultTreeAdapter.createTextNode(text), referenceNode);
18038
18585
  },
18586
+ /**
18587
+ * Keeps the recipient's names between merges as a map from name to position. The map is rebuilt when the list changed
18588
+ * length or has a repeated name, or when a merged name it holds no longer names the entry at that position. A name that
18589
+ * other code gives an existing entry between two merges is missed otherwise, and merging it appends it a second time.
18590
+ */
18039
18591
  adoptAttributes(recipient, attrs) {
18040
- const recipientAttrsMap = new Set(recipient.attrs.map((attr) => attr.name));
18592
+ if (attrs.length === 0 || attrs === recipient.attrs) return;
18593
+ const cached = attrListIndexes.get(recipient.attrs);
18594
+ const isIndexed = (cached === null || cached === void 0 ? void 0 : cached.size) === recipient.attrs.length && attrs.every(({ name }) => {
18595
+ var _a;
18596
+ const index = cached.get(name);
18597
+ return index === void 0 || ((_a = recipient.attrs[index]) === null || _a === void 0 ? void 0 : _a.name) === name;
18598
+ });
18599
+ const recipientAttrsMap = isIndexed ? cached : /* @__PURE__ */ new Map();
18600
+ if (!isIndexed) {
18601
+ for (let i = 0; i < recipient.attrs.length; i++) {
18602
+ const attr = recipient.attrs[i];
18603
+ if (attr !== void 0) recipientAttrsMap.set(attr.name, i);
18604
+ }
18605
+ attrListIndexes.set(recipient.attrs, recipientAttrsMap);
18606
+ }
18607
+ const adoptedFrom = recipient.attrs.length;
18041
18608
  for (let j = 0; j < attrs.length; j++) if (!recipientAttrsMap.has(attrs[j].name)) recipient.attrs.push(attrs[j]);
18609
+ for (let j = adoptedFrom; j < recipient.attrs.length; j++) recipientAttrsMap.set(recipient.attrs[j].name, j);
18610
+ if (recipientAttrsMap.size !== recipient.attrs.length) attrListIndexes.delete(recipient.attrs);
18042
18611
  },
18043
18612
  getFirstChild(node) {
18044
18613
  return node.childNodes[0];
@@ -18453,7 +19022,25 @@ function isIntegrationPoint(tn, ns, attrs, foreignNS) {
18453
19022
  return (!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs) || (!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns);
18454
19023
  }
18455
19024
  // node_modules/parse5/dist/parser/index.js
19025
+ const INSERTION_MODE_TAGS = [
19026
+ TAG_ID.TR,
19027
+ TAG_ID.TBODY,
19028
+ TAG_ID.THEAD,
19029
+ TAG_ID.TFOOT,
19030
+ TAG_ID.CAPTION,
19031
+ TAG_ID.COLGROUP,
19032
+ TAG_ID.TABLE,
19033
+ TAG_ID.FRAMESET,
19034
+ TAG_ID.SELECT,
19035
+ TAG_ID.TEMPLATE,
19036
+ TAG_ID.TD,
19037
+ TAG_ID.TH,
19038
+ TAG_ID.HEAD,
19039
+ TAG_ID.BODY,
19040
+ TAG_ID.HTML
19041
+ ];
18456
19042
  const HIDDEN_INPUT_TYPE = "hidden";
19043
+ const EMPTY_ATTRS = [];
18457
19044
  const AA_OUTER_LOOP_ITER = 8;
18458
19045
  const AA_INNER_LOOP_ITER = 3;
18459
19046
  var InsertionMode;
@@ -18520,8 +19107,7 @@ var Parser = class {
18520
19107
  /** Indicates that the current node is not an element in the HTML namespace */
18521
19108
  this.currentNotInHTML = false;
18522
19109
  /**
18523
- * The template insertion mode stack is maintained from the left.
18524
- * Ie. the topmost element will always have index 0.
19110
+ * The topmost template insertion mode is the last element.
18525
19111
  *
18526
19112
  * @internal
18527
19113
  */
@@ -18545,7 +19131,7 @@ var Parser = class {
18545
19131
  if (this.onParseError) this.options.sourceCodeLocationInfo = true;
18546
19132
  this.document = document !== null && document !== void 0 ? document : this.treeAdapter.createDocument();
18547
19133
  this.tokenizer = new Tokenizer(this.options, this);
18548
- this.activeFormattingElements = new FormattingElementList(this.treeAdapter);
19134
+ this.activeFormattingElements = new FormattingElementList();
18549
19135
  this.fragmentContextID = fragmentContext ? getTagID(this.treeAdapter.getTagName(fragmentContext)) : TAG_ID.UNKNOWN;
18550
19136
  this._setContextModes(fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : this.document, this.fragmentContextID);
18551
19137
  this.openElements = new OpenElementStack(this.document, this.treeAdapter, this);
@@ -18563,7 +19149,7 @@ var Parser = class {
18563
19149
  fragmentContext !== null && fragmentContext !== void 0 || (fragmentContext = opts.treeAdapter.createElement(TAG_NAMES.TEMPLATE, NS.HTML, []));
18564
19150
  const documentMock = opts.treeAdapter.createElement("documentmock", NS.HTML, []);
18565
19151
  const parser = new this(opts, documentMock, fragmentContext);
18566
- if (parser.fragmentContextID === TAG_ID.TEMPLATE) parser.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
19152
+ if (parser.fragmentContextID === TAG_ID.TEMPLATE) parser.tmplInsertionModeStack.push(InsertionMode.IN_TEMPLATE);
18567
19153
  parser._initTokenizerForFragmentParsing();
18568
19154
  parser._insertFakeRootElement();
18569
19155
  parser._resetInsertionMode();
@@ -18600,9 +19186,10 @@ var Parser = class {
18600
19186
  }
18601
19187
  /** @internal */
18602
19188
  onItemPop(node, isTop) {
18603
- var _a, _b;
19189
+ var _a, _b, _c;
18604
19190
  if (this.options.sourceCodeLocationInfo) this._setEndLocation(node, this.currentToken);
18605
19191
  (_b = (_a = this.treeAdapter).onItemPop) === null || _b === void 0 || _b.call(_a, node, this.openElements.current);
19192
+ (_c = this.annotationXmlIntegrationPoints) === null || _c === void 0 || _c.delete(node);
18606
19193
  if (isTop) {
18607
19194
  let current;
18608
19195
  let currentTagId;
@@ -18638,7 +19225,7 @@ var Parser = class {
18638
19225
  _findFormInFragmentContext() {
18639
19226
  let node = this.fragmentContext;
18640
19227
  while (node) {
18641
- if (this.treeAdapter.getTagName(node) === TAG_NAMES.FORM) {
19228
+ if (this.treeAdapter.getTagName(node) === TAG_NAMES.FORM && this.treeAdapter.getNamespaceURI(node) === NS.HTML) {
18642
19229
  this.formElement = node;
18643
19230
  break;
18644
19231
  }
@@ -18678,7 +19265,7 @@ var Parser = class {
18678
19265
  }
18679
19266
  }
18680
19267
  /** @protected */
18681
- _attachElementToTree(element, location) {
19268
+ _attachElementToTree(element, location, insertionLocation) {
18682
19269
  if (this.options.sourceCodeLocationInfo) {
18683
19270
  const loc = location && {
18684
19271
  ...location,
@@ -18686,11 +19273,28 @@ var Parser = class {
18686
19273
  };
18687
19274
  this.treeAdapter.setNodeSourceCodeLocation(element, loc);
18688
19275
  }
18689
- if (this._shouldFosterParentOnInsertion()) this._fosterParentElement(element);
18690
- else {
18691
- const parent = this.openElements.currentTmplContentOrNode;
18692
- this.treeAdapter.appendChild(parent !== null && parent !== void 0 ? parent : this.document, element);
18693
- }
19276
+ if (insertionLocation.beforeElement) this.treeAdapter.insertBefore(insertionLocation.parent, element, insertionLocation.beforeElement);
19277
+ else this.treeAdapter.appendChild(insertionLocation.parent, element);
19278
+ }
19279
+ /** @protected */
19280
+ _getInsertionLocation() {
19281
+ var _a;
19282
+ if (this._shouldFosterParentOnInsertion()) return this._findFosterParentingLocation();
19283
+ return {
19284
+ parent: (_a = this.openElements.currentTmplContentOrNode) !== null && _a !== void 0 ? _a : this.document,
19285
+ beforeElement: null
19286
+ };
19287
+ }
19288
+ /** @protected */
19289
+ _createElement(tagName, namespaceURI, attrs, intendedParent) {
19290
+ var _a, _b;
19291
+ const element = this.treeAdapter.createElement(tagName, namespaceURI, attrs);
19292
+ (_b = (_a = this.treeAdapter).onElementCreated) === null || _b === void 0 || _b.call(_a, element, {
19293
+ intendedParent,
19294
+ formElement: this.formElement,
19295
+ isInTemplate: this.openElements.tmplCount > 0
19296
+ });
19297
+ return element;
18694
19298
  }
18695
19299
  /**
18696
19300
  * For self-closing tags. Add an element to the tree, but skip adding it
@@ -18698,35 +19302,39 @@ var Parser = class {
18698
19302
  */
18699
19303
  /** @protected */
18700
19304
  _appendElement(token, namespaceURI) {
18701
- const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
18702
- this._attachElementToTree(element, token.location);
19305
+ const insertionLocation = this._getInsertionLocation();
19306
+ const element = this._createElement(token.tagName, namespaceURI, token.attrs, insertionLocation.parent);
19307
+ this._attachElementToTree(element, token.location, insertionLocation);
18703
19308
  }
18704
19309
  /** @protected */
18705
19310
  _insertElement(token, namespaceURI) {
18706
- const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
18707
- this._attachElementToTree(element, token.location);
19311
+ const insertionLocation = this._getInsertionLocation();
19312
+ const element = this._createElement(token.tagName, namespaceURI, token.attrs, insertionLocation.parent);
19313
+ this._attachElementToTree(element, token.location, insertionLocation);
18708
19314
  this.openElements.push(element, token.tagID);
18709
19315
  }
18710
19316
  /** @protected */
18711
19317
  _insertFakeElement(tagName, tagID) {
18712
- const element = this.treeAdapter.createElement(tagName, NS.HTML, []);
18713
- this._attachElementToTree(element, null);
19318
+ const insertionLocation = this._getInsertionLocation();
19319
+ const element = this._createElement(tagName, NS.HTML, [], insertionLocation.parent);
19320
+ this._attachElementToTree(element, null, insertionLocation);
18714
19321
  this.openElements.push(element, tagID);
18715
19322
  }
18716
19323
  /** @protected */
18717
19324
  _insertTemplate(token) {
18718
- const tmpl = this.treeAdapter.createElement(token.tagName, NS.HTML, token.attrs);
19325
+ const insertionLocation = this._getInsertionLocation();
19326
+ const tmpl = this._createElement(token.tagName, NS.HTML, token.attrs, insertionLocation.parent);
18719
19327
  const content = this.treeAdapter.createDocumentFragment();
18720
19328
  this.treeAdapter.setTemplateContent(tmpl, content);
18721
- this._attachElementToTree(tmpl, token.location);
19329
+ this._attachElementToTree(tmpl, token.location, insertionLocation);
18722
19330
  this.openElements.push(tmpl, token.tagID);
18723
19331
  if (this.options.sourceCodeLocationInfo) this.treeAdapter.setNodeSourceCodeLocation(content, null);
18724
19332
  }
18725
19333
  /** @protected */
18726
19334
  _insertFakeRootElement() {
18727
- const element = this.treeAdapter.createElement(TAG_NAMES.HTML, NS.HTML, []);
19335
+ const element = this._createElement(TAG_NAMES.HTML, NS.HTML, [], this.document);
18728
19336
  if (this.options.sourceCodeLocationInfo) this.treeAdapter.setNodeSourceCodeLocation(element, null);
18729
- this.treeAdapter.appendChild(this.openElements.current, element);
19337
+ this.treeAdapter.appendChild(this.document, element);
18730
19338
  this.openElements.push(element, TAG_ID.HTML);
18731
19339
  }
18732
19340
  /** @protected */
@@ -18761,10 +19369,9 @@ var Parser = class {
18761
19369
  }
18762
19370
  /** @protected */
18763
19371
  _adoptNodes(donor, recipient) {
18764
- for (let child = this.treeAdapter.getFirstChild(donor); child; child = this.treeAdapter.getFirstChild(donor)) {
18765
- this.treeAdapter.detachNode(child);
18766
- this.treeAdapter.appendChild(recipient, child);
18767
- }
19372
+ const children = [...this.treeAdapter.getChildNodes(donor)];
19373
+ for (let i = children.length - 1; i >= 0; i--) this.treeAdapter.detachNode(children[i]);
19374
+ for (const child of children) this.treeAdapter.appendChild(recipient, child);
18768
19375
  }
18769
19376
  /** @protected */
18770
19377
  _setEndLocation(element, closingToken) {
@@ -18824,19 +19431,26 @@ var Parser = class {
18824
19431
  }
18825
19432
  /** @protected */
18826
19433
  _isIntegrationPoint(tid, element, foreignNS) {
18827
- return isIntegrationPoint(tid, this.treeAdapter.getNamespaceURI(element), this.treeAdapter.getAttrList(element), foreignNS);
19434
+ var _a;
19435
+ const ns = this.treeAdapter.getNamespaceURI(element);
19436
+ if (tid === TAG_ID.ANNOTATION_XML && ns === NS.MATHML && foreignNS !== NS.MATHML) {
19437
+ const verdicts = (_a = this.annotationXmlIntegrationPoints) !== null && _a !== void 0 ? _a : this.annotationXmlIntegrationPoints = /* @__PURE__ */ new Map();
19438
+ let isIntegrationPoint$1 = verdicts.get(element);
19439
+ if (isIntegrationPoint$1 === void 0) {
19440
+ isIntegrationPoint$1 = isIntegrationPoint(tid, ns, this.treeAdapter.getAttrList(element));
19441
+ verdicts.set(element, isIntegrationPoint$1);
19442
+ }
19443
+ return isIntegrationPoint$1;
19444
+ }
19445
+ return isIntegrationPoint(tid, ns, EMPTY_ATTRS, foreignNS);
18828
19446
  }
18829
19447
  /** @protected */
18830
19448
  _reconstructActiveFormattingElements() {
18831
- const listLength = this.activeFormattingElements.entries.length;
18832
- if (listLength) {
18833
- const endIndex = this.activeFormattingElements.entries.findIndex((entry) => entry.type === EntryType.Marker || this.openElements.contains(entry.element));
18834
- const unopenIdx = endIndex === -1 ? listLength - 1 : endIndex - 1;
18835
- for (let i = unopenIdx; i >= 0; i--) {
18836
- const entry = this.activeFormattingElements.entries[i];
18837
- this._insertElement(entry.token, this.treeAdapter.getNamespaceURI(entry.element));
18838
- entry.element = this.openElements.current;
18839
- }
19449
+ let oldest = null;
19450
+ for (let entry = this.activeFormattingElements.newest; entry !== null && entry.type === EntryType.Element && !this.openElements.contains(entry.element); entry = entry.older) oldest = entry;
19451
+ for (let entry = oldest; entry !== null && entry.type === EntryType.Element; entry = entry.newer) {
19452
+ this._insertElement(entry.token, this.treeAdapter.getNamespaceURI(entry.element));
19453
+ this.activeFormattingElements.replaceElement(entry, this.openElements.current);
18840
19454
  }
18841
19455
  }
18842
19456
  /** @protected */
@@ -18853,7 +19467,10 @@ var Parser = class {
18853
19467
  }
18854
19468
  /** @protected */
18855
19469
  _resetInsertionMode() {
18856
- for (let i = this.openElements.stackTop; i >= 0; i--) switch (i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i]) {
19470
+ const i = this.openElements.indexOfTopmostOf(INSERTION_MODE_TAGS);
19471
+ const tn = i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i];
19472
+ const node = i === 0 && this.fragmentContext ? this.fragmentContext : this.openElements.items[i];
19473
+ if (node !== void 0 && this.treeAdapter.getNamespaceURI(node) === NS.HTML) switch (tn) {
18857
19474
  case TAG_ID.TR:
18858
19475
  this.insertionMode = InsertionMode.IN_ROW;
18859
19476
  return;
@@ -18881,7 +19498,7 @@ var Parser = class {
18881
19498
  this._resetInsertionModeForSelect(i);
18882
19499
  return;
18883
19500
  case TAG_ID.TEMPLATE:
18884
- this.insertionMode = this.tmplInsertionModeStack[0];
19501
+ this.insertionMode = this.tmplInsertionModeStack[this.tmplInsertionModeStack.length - 1];
18885
19502
  return;
18886
19503
  case TAG_ID.HTML:
18887
19504
  this.insertionMode = this.headElement ? InsertionMode.AFTER_HEAD : InsertionMode.BEFORE_HEAD;
@@ -18902,10 +19519,9 @@ var Parser = class {
18902
19519
  }
18903
19520
  /** @protected */
18904
19521
  _resetInsertionModeForSelect(selectIdx) {
18905
- if (selectIdx > 0) for (let i = selectIdx - 1; i > 0; i--) {
18906
- const tn = this.openElements.tagIDs[i];
18907
- if (tn === TAG_ID.TEMPLATE) break;
18908
- else if (tn === TAG_ID.TABLE) {
19522
+ if (selectIdx > 0) {
19523
+ const tableIdx = this.openElements.indexOfTopmost(TAG_ID.TABLE);
19524
+ if (tableIdx > 0 && tableIdx > this.openElements.indexOfTopmost(TAG_ID.TEMPLATE)) {
18909
19525
  this.insertionMode = InsertionMode.IN_SELECT_IN_TABLE;
18910
19526
  return;
18911
19527
  }
@@ -18922,30 +19538,27 @@ var Parser = class {
18922
19538
  }
18923
19539
  /** @protected */
18924
19540
  _findFosterParentingLocation() {
18925
- for (let i = this.openElements.stackTop; i >= 0; i--) {
18926
- const openElement = this.openElements.items[i];
18927
- switch (this.openElements.tagIDs[i]) {
18928
- case TAG_ID.TEMPLATE:
18929
- if (this.treeAdapter.getNamespaceURI(openElement) === NS.HTML) return {
18930
- parent: this.treeAdapter.getTemplateContent(openElement),
18931
- beforeElement: null
18932
- };
18933
- break;
18934
- case TAG_ID.TABLE: {
18935
- const parent = this.treeAdapter.getParentNode(openElement);
18936
- if (parent) return {
18937
- parent,
18938
- beforeElement: openElement
18939
- };
18940
- return {
18941
- parent: this.openElements.items[i - 1],
18942
- beforeElement: null
18943
- };
18944
- }
18945
- }
19541
+ const { openElements } = this;
19542
+ const tableIdx = openElements.indexOfTopmost(TAG_ID.TABLE);
19543
+ const templateIdx = openElements.indexOfTopmost(TAG_ID.TEMPLATE);
19544
+ if (templateIdx > tableIdx) return {
19545
+ parent: this.treeAdapter.getTemplateContent(openElements.items[templateIdx]),
19546
+ beforeElement: null
19547
+ };
19548
+ if (tableIdx !== -1) {
19549
+ const table = openElements.items[tableIdx];
19550
+ const parent = this.treeAdapter.getParentNode(table);
19551
+ if (parent) return {
19552
+ parent,
19553
+ beforeElement: table
19554
+ };
19555
+ return {
19556
+ parent: openElements.items[openElements.slotBelow(tableIdx)],
19557
+ beforeElement: null
19558
+ };
18946
19559
  }
18947
19560
  return {
18948
- parent: this.openElements.items[0],
19561
+ parent: openElements.items[0],
18949
19562
  beforeElement: null
18950
19563
  };
18951
19564
  }
@@ -19375,36 +19988,33 @@ function aaObtainFormattingElementEntry(p, token) {
19375
19988
  if (!p.openElements.contains(formattingElementEntry.element)) {
19376
19989
  p.activeFormattingElements.removeEntry(formattingElementEntry);
19377
19990
  formattingElementEntry = null;
19378
- } else if (!p.openElements.hasInScope(token.tagID)) formattingElementEntry = null;
19991
+ } else if (!p.openElements.hasInScope(token.tagID, formattingElementEntry.element)) formattingElementEntry = null;
19379
19992
  } else genericEndTagInBody(p, token);
19380
19993
  return formattingElementEntry;
19381
19994
  }
19382
19995
  function aaObtainFurthestBlock(p, formattingElementEntry) {
19383
- let furthestBlock = null;
19384
- let idx = p.openElements.stackTop;
19385
- for (; idx >= 0; idx--) {
19386
- const element = p.openElements.items[idx];
19387
- if (element === formattingElementEntry.element) break;
19388
- if (p._isSpecialElement(element, p.openElements.tagIDs[idx])) furthestBlock = element;
19389
- }
19390
- if (!furthestBlock) {
19391
- p.openElements.shortenToLength(Math.max(idx, 0));
19392
- p.activeFormattingElements.removeEntry(formattingElementEntry);
19393
- }
19394
- return furthestBlock;
19996
+ const { openElements } = p;
19997
+ const formattingIdx = openElements._indexOf(formattingElementEntry.element);
19998
+ for (let idx = openElements.slotAbove(formattingIdx); idx !== -1; idx = openElements.slotAbove(idx)) if (p._isSpecialElement(openElements.items[idx], openElements.tagIDs[idx])) return idx;
19999
+ openElements.shortenToLength(formattingIdx);
20000
+ p.activeFormattingElements.removeEntry(formattingElementEntry);
20001
+ return -1;
19395
20002
  }
19396
- function aaInnerLoop(p, furthestBlock, formattingElement) {
20003
+ function aaInnerLoop(p, furthestBlockIdx, formattingElement) {
20004
+ const furthestBlock = p.openElements.items[furthestBlockIdx];
19397
20005
  let lastElement = furthestBlock;
19398
- let nextElement = p.openElements.getCommonAncestor(furthestBlock);
19399
- for (let i = 0, element = nextElement; element !== formattingElement; i++, element = nextElement) {
19400
- nextElement = p.openElements.getCommonAncestor(element);
20006
+ let nextIdx = p.openElements.slotBelow(furthestBlockIdx);
20007
+ const intendedParent = p.openElements.getCommonAncestor(formattingElement);
20008
+ for (let i = 0, idx = nextIdx; p.openElements.items[idx] !== formattingElement; i++, idx = nextIdx) {
20009
+ let element = p.openElements.items[idx];
20010
+ nextIdx = p.openElements.slotBelow(idx);
19401
20011
  const elementEntry = p.activeFormattingElements.getElementEntry(element);
19402
20012
  const counterOverflow = elementEntry && i >= AA_INNER_LOOP_ITER;
19403
20013
  if (!elementEntry || counterOverflow) {
19404
20014
  if (counterOverflow) p.activeFormattingElements.removeEntry(elementEntry);
19405
- p.openElements.remove(element);
20015
+ p.openElements.removeAt(idx);
19406
20016
  } else {
19407
- element = aaRecreateElementFromEntry(p, elementEntry);
20017
+ element = aaRecreateElementFromEntry(p, elementEntry, intendedParent);
19408
20018
  if (lastElement === furthestBlock) p.activeFormattingElements.bookmark = elementEntry;
19409
20019
  p.treeAdapter.detachNode(lastElement);
19410
20020
  p.treeAdapter.appendChild(element, lastElement);
@@ -19413,11 +20023,11 @@ function aaInnerLoop(p, furthestBlock, formattingElement) {
19413
20023
  }
19414
20024
  return lastElement;
19415
20025
  }
19416
- function aaRecreateElementFromEntry(p, elementEntry) {
20026
+ function aaRecreateElementFromEntry(p, elementEntry, intendedParent) {
19417
20027
  const ns = p.treeAdapter.getNamespaceURI(elementEntry.element);
19418
- const newElement = p.treeAdapter.createElement(elementEntry.token.tagName, ns, elementEntry.token.attrs);
20028
+ const newElement = p._createElement(elementEntry.token.tagName, ns, elementEntry.token.attrs, intendedParent);
19419
20029
  p.openElements.replace(elementEntry.element, newElement);
19420
- elementEntry.element = newElement;
20030
+ p.activeFormattingElements.replaceElement(elementEntry, newElement);
19421
20031
  return newElement;
19422
20032
  }
19423
20033
  function aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement) {
@@ -19432,22 +20042,30 @@ function aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement) {
19432
20042
  function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {
19433
20043
  const ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element);
19434
20044
  const { token } = formattingElementEntry;
19435
- const newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);
20045
+ const newElement = p._createElement(token.tagName, ns, token.attrs, furthestBlock);
19436
20046
  p._adoptNodes(furthestBlock, newElement);
19437
20047
  p.treeAdapter.appendChild(furthestBlock, newElement);
19438
20048
  p.activeFormattingElements.insertElementAfterBookmark(newElement, token);
19439
20049
  p.activeFormattingElements.removeEntry(formattingElementEntry);
19440
- p.openElements.remove(formattingElementEntry.element);
19441
- p.openElements.insertAfter(furthestBlock, newElement, token.tagID);
20050
+ const formattingIdx = p.openElements._indexOf(formattingElementEntry.element);
20051
+ let furthestBlockIdx = p.openElements.slotAbove(formattingIdx);
20052
+ while (p.openElements.items[furthestBlockIdx] !== furthestBlock) furthestBlockIdx = p.openElements.slotAbove(furthestBlockIdx);
20053
+ p.openElements.replaceFormattingElement(formattingIdx, furthestBlockIdx, newElement, token.tagID);
19442
20054
  }
19443
20055
  function callAdoptionAgency(p, token) {
20056
+ const { current, currentTagId } = p.openElements;
20057
+ if (currentTagId === token.tagID && p.treeAdapter.getNamespaceURI(current) === NS.HTML && !p.activeFormattingElements.getElementEntry(current)) {
20058
+ p.openElements.pop();
20059
+ return;
20060
+ }
19444
20061
  for (let i = 0; i < AA_OUTER_LOOP_ITER; i++) {
19445
20062
  const formattingElementEntry = aaObtainFormattingElementEntry(p, token);
19446
20063
  if (!formattingElementEntry) break;
19447
- const furthestBlock = aaObtainFurthestBlock(p, formattingElementEntry);
19448
- if (!furthestBlock) break;
20064
+ const furthestBlockIdx = aaObtainFurthestBlock(p, formattingElementEntry);
20065
+ if (furthestBlockIdx === -1) break;
20066
+ const furthestBlock = p.openElements.items[furthestBlockIdx];
19449
20067
  p.activeFormattingElements.bookmark = formattingElementEntry;
19450
- const lastElement = aaInnerLoop(p, furthestBlock, formattingElementEntry.element);
20068
+ const lastElement = aaInnerLoop(p, furthestBlockIdx, formattingElementEntry.element);
19451
20069
  const commonAncestor = p.openElements.getCommonAncestor(formattingElementEntry.element);
19452
20070
  p.treeAdapter.detachNode(lastElement);
19453
20071
  if (commonAncestor) aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement);
@@ -19467,7 +20085,7 @@ function stopParsing(p, token) {
19467
20085
  p.stopped = true;
19468
20086
  if (token.location) {
19469
20087
  const target = p.fragmentContext ? 0 : 2;
19470
- for (let i = p.openElements.stackTop; i >= target; i--) p._setEndLocation(p.openElements.items[i], token);
20088
+ for (let i = p.openElements.stackTop; i >= target; i = p.openElements.slotBelow(i)) p._setEndLocation(p.openElements.items[i], token);
19471
20089
  if (!p.fragmentContext && p.openElements.stackTop >= 0) {
19472
20090
  const htmlElement = p.openElements.items[0];
19473
20091
  const htmlLocation = p.treeAdapter.getNodeSourceCodeLocation(htmlElement);
@@ -19569,7 +20187,7 @@ function startTagInHead(p, token) {
19569
20187
  p.activeFormattingElements.insertMarker();
19570
20188
  p.framesetOk = false;
19571
20189
  p.insertionMode = InsertionMode.IN_TEMPLATE;
19572
- p.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
20190
+ p.tmplInsertionModeStack.push(InsertionMode.IN_TEMPLATE);
19573
20191
  break;
19574
20192
  case TAG_ID.HEAD:
19575
20193
  p._err(token, ERR.misplacedStartTagForHeadElement);
@@ -19600,7 +20218,7 @@ function templateEndTagInHead(p, token) {
19600
20218
  if (p.openElements.currentTagId !== TAG_ID.TEMPLATE) p._err(token, ERR.closingOfElementWithOpenChildElements);
19601
20219
  p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
19602
20220
  p.activeFormattingElements.clearToLastMarker();
19603
- p.tmplInsertionModeStack.shift();
20221
+ p.tmplInsertionModeStack.pop();
19604
20222
  p._resetInsertionMode();
19605
20223
  } else p._err(token, ERR.endTagWithoutMatchingOpenElement);
19606
20224
  }
@@ -19755,7 +20373,7 @@ function addressStartTagInBody(p, token) {
19755
20373
  }
19756
20374
  function numberedHeaderStartTagInBody(p, token) {
19757
20375
  if (p.openElements.hasInButtonScope(TAG_ID.P)) p._closePElement();
19758
- if (p.openElements.currentTagId !== void 0 && NUMBERED_HEADERS.has(p.openElements.currentTagId)) p.openElements.pop();
20376
+ if (p.openElements.currentTagId !== void 0 && NUMBERED_HEADERS$1.has(p.openElements.currentTagId)) p.openElements.pop();
19759
20377
  p._insertElement(token, NS.HTML);
19760
20378
  }
19761
20379
  function preStartTagInBody(p, token) {
@@ -19774,15 +20392,11 @@ function formStartTagInBody(p, token) {
19774
20392
  }
19775
20393
  function listItemStartTagInBody(p, token) {
19776
20394
  p.framesetOk = false;
19777
- const tn = token.tagID;
19778
- for (let i = p.openElements.stackTop; i >= 0; i--) {
19779
- const elementId = p.openElements.tagIDs[i];
19780
- if (tn === TAG_ID.LI && elementId === TAG_ID.LI || (tn === TAG_ID.DD || tn === TAG_ID.DT) && (elementId === TAG_ID.DD || elementId === TAG_ID.DT)) {
19781
- p.openElements.generateImpliedEndTagsWithExclusion(elementId);
19782
- p.openElements.popUntilTagNamePopped(elementId);
19783
- break;
19784
- }
19785
- if (elementId !== TAG_ID.ADDRESS && elementId !== TAG_ID.DIV && elementId !== TAG_ID.P && p._isSpecialElement(p.openElements.items[i], elementId)) break;
20395
+ const idx = token.tagID === TAG_ID.LI ? p.openElements.indexOfTopmost(TAG_ID.LI) : Math.max(p.openElements.indexOfTopmost(TAG_ID.DD), p.openElements.indexOfTopmost(TAG_ID.DT));
20396
+ if (idx !== -1 && !p.openElements.hasListItemBoundaryAbove(idx)) {
20397
+ const elementId = p.openElements.tagIDs[idx];
20398
+ p.openElements.generateImpliedEndTagsWithExclusion(elementId);
20399
+ p.openElements.popUntilTagNamePopped(elementId);
19786
20400
  }
19787
20401
  if (p.openElements.hasInButtonScope(TAG_ID.P)) p._closePElement();
19788
20402
  p._insertElement(token, NS.HTML);
@@ -20176,17 +20790,11 @@ function brEndTagInBody(p) {
20176
20790
  p.framesetOk = false;
20177
20791
  }
20178
20792
  function genericEndTagInBody(p, token) {
20179
- const tn = token.tagName;
20180
20793
  const tid = token.tagID;
20181
- for (let i = p.openElements.stackTop; i > 0; i--) {
20182
- const element = p.openElements.items[i];
20183
- const elementId = p.openElements.tagIDs[i];
20184
- if (tid === elementId && (tid !== TAG_ID.UNKNOWN || p.treeAdapter.getTagName(element) === tn)) {
20185
- p.openElements.generateImpliedEndTagsWithExclusion(tid);
20186
- if (p.openElements.stackTop >= i) p.openElements.shortenToLength(i);
20187
- break;
20188
- }
20189
- if (p._isSpecialElement(element, elementId)) break;
20794
+ const i = tid === TAG_ID.UNKNOWN ? p.openElements.indexOfTopmostByName(NS.HTML, token.tagName) : p.openElements.indexOfTopmost(tid);
20795
+ if (i > 0 && !p.openElements.hasSpecialElementAbove(i)) {
20796
+ p.openElements.generateImpliedEndTagsWithExclusion(tid);
20797
+ if (p.openElements.stackTop >= i) p.openElements.shortenToLength(i);
20190
20798
  }
20191
20799
  }
20192
20800
  function endTagInBody(p, token) {
@@ -20723,7 +21331,7 @@ function startTagInSelect(p, token) {
20723
21331
  function endTagInSelect(p, token) {
20724
21332
  switch (token.tagID) {
20725
21333
  case TAG_ID.OPTGROUP:
20726
- if (p.openElements.stackTop > 0 && p.openElements.currentTagId === TAG_ID.OPTION && p.openElements.tagIDs[p.openElements.stackTop - 1] === TAG_ID.OPTGROUP) p.openElements.pop();
21334
+ if (p.openElements.stackTop > 0 && p.openElements.currentTagId === TAG_ID.OPTION && p.openElements.tagIDs[p.openElements.slotBelow(p.openElements.stackTop)] === TAG_ID.OPTGROUP) p.openElements.pop();
20727
21335
  if (p.openElements.currentTagId === TAG_ID.OPTGROUP) p.openElements.pop();
20728
21336
  break;
20729
21337
  case TAG_ID.OPTION:
@@ -20775,28 +21383,28 @@ function startTagInTemplate(p, token) {
20775
21383
  case TAG_ID.TBODY:
20776
21384
  case TAG_ID.TFOOT:
20777
21385
  case TAG_ID.THEAD:
20778
- p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE;
21386
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_TABLE;
20779
21387
  p.insertionMode = InsertionMode.IN_TABLE;
20780
21388
  startTagInTable(p, token);
20781
21389
  break;
20782
21390
  case TAG_ID.COL:
20783
- p.tmplInsertionModeStack[0] = InsertionMode.IN_COLUMN_GROUP;
21391
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_COLUMN_GROUP;
20784
21392
  p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
20785
21393
  startTagInColumnGroup(p, token);
20786
21394
  break;
20787
21395
  case TAG_ID.TR:
20788
- p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE_BODY;
21396
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_TABLE_BODY;
20789
21397
  p.insertionMode = InsertionMode.IN_TABLE_BODY;
20790
21398
  startTagInTableBody(p, token);
20791
21399
  break;
20792
21400
  case TAG_ID.TD:
20793
21401
  case TAG_ID.TH:
20794
- p.tmplInsertionModeStack[0] = InsertionMode.IN_ROW;
21402
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_ROW;
20795
21403
  p.insertionMode = InsertionMode.IN_ROW;
20796
21404
  startTagInRow(p, token);
20797
21405
  break;
20798
21406
  default:
20799
- p.tmplInsertionModeStack[0] = InsertionMode.IN_BODY;
21407
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_BODY;
20800
21408
  p.insertionMode = InsertionMode.IN_BODY;
20801
21409
  startTagInBody(p, token);
20802
21410
  }
@@ -20806,9 +21414,11 @@ function endTagInTemplate(p, token) {
20806
21414
  }
20807
21415
  function eofInTemplate(p, token) {
20808
21416
  if (p.openElements.tmplCount > 0) {
20809
- p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
20810
- p.activeFormattingElements.clearToLastMarker();
20811
- p.tmplInsertionModeStack.shift();
21417
+ do {
21418
+ p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
21419
+ p.activeFormattingElements.clearToLastMarker();
21420
+ p.tmplInsertionModeStack.pop();
21421
+ } while (p.openElements.tmplCount > 0);
20812
21422
  p._resetInsertionMode();
20813
21423
  p.onEof(token);
20814
21424
  } else stopParsing(p, token);
@@ -20915,99 +21525,32 @@ function endTagInForeignContent(p, token) {
20915
21525
  p._endTagOutsideForeignContent(token);
20916
21526
  return;
20917
21527
  }
20918
- for (let i = p.openElements.stackTop; i > 0; i--) {
20919
- const element = p.openElements.items[i];
20920
- if (p.treeAdapter.getNamespaceURI(element) === NS.HTML) {
20921
- p._endTagOutsideForeignContent(token);
20922
- break;
20923
- }
20924
- const tagName = p.treeAdapter.getTagName(element);
20925
- if (tagName.toLowerCase() === token.tagName) {
20926
- token.tagName = tagName;
20927
- p.openElements.shortenToLength(i);
20928
- break;
20929
- }
20930
- }
21528
+ if (p.openElements.stackTop === 0) return;
21529
+ const { tagName } = token;
21530
+ const adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP.get(tagName);
21531
+ const contextNs = p.fragmentContext ? p.treeAdapter.getNamespaceURI(p.fragmentContext) : NS.HTML;
21532
+ const i = Math.max(p.openElements.indexOfTopmostByName(NS.SVG, tagName), p.openElements.indexOfTopmostByName(NS.MATHML, tagName), adjustedTagName === void 0 ? -1 : p.openElements.indexOfTopmostByName(NS.SVG, adjustedTagName), contextNs === NS.HTML || contextNs === NS.SVG || contextNs === NS.MATHML ? -1 : p.openElements.indexOfTopmostByName(contextNs, tagName));
21533
+ if (i > p.openElements.indexOfTopmostHtmlElement()) {
21534
+ token.tagName = p.treeAdapter.getTagName(p.openElements.items[i]);
21535
+ p.openElements.shortenToLength(i);
21536
+ } else p._endTagOutsideForeignContent(token);
20931
21537
  }
20932
21538
  // node_modules/entities/dist/escape.js
20933
21539
  /**
20934
21540
  * Get the named reference for an XML special character or U+00A0.
20935
21541
  * @param char Code unit matched by one of the escape regexes.
20936
21542
  */
20937
- function getEscape(char) {
21543
+ function getEscape$1(char) {
20938
21544
  return char === 34 ? "&quot;" : char === 38 ? "&amp;" : char === 39 ? "&apos;" : char === 60 ? "&lt;" : char === 62 ? "&gt;" : "&nbsp;";
20939
21545
  }
20940
21546
  /**
20941
- * Matches exactly the characters `encodeXML` escapes: the five XML special
20942
- * characters plus every non-ASCII code unit (lone surrogates included — no
20943
- * `u` flag). Kept in sync with `XML_BITSET_VALUE`.
20944
- *
20945
- * Shared with `encodeNonAsciiHTML` in `encode.ts`. Because the regex is
20946
- * stateful (`g` flag), every call site must set `lastIndex` before use.
20947
- */
20948
- const xmlEncodeRegex = /["&'<>\u0080-\uFFFF]/g;
20949
- /**
20950
- * Whether `code` (a UTF-16 code unit) is escaped by {@link encodeXML}: a
20951
- * non-ASCII unit, or one of the five XML specials flagged in
20952
- * `XML_BITSET_VALUE` (which is only meaningful for code units 32-63).
20953
- * @param code Code unit to test.
20954
- */
20955
- function isXmlEscapable(code) {
20956
- return code >= 128 || code >= 32 && code < 64 && (1342177476 >>> code & 1) === 1;
20957
- }
20958
- /**
20959
- * Encodes all non-ASCII characters, as well as characters not valid in XML
20960
- * documents using XML entities.
20961
- *
20962
- * If a character has no equivalent entity, a numeric hexadecimal reference
20963
- * (eg. `&#xfc;`) will be used.
20964
- * @param input Input string to encode.
20965
- */
20966
- function encodeXML(input) {
20967
- const { length } = input;
20968
- let out;
20969
- let last = 0;
20970
- let index = 0;
20971
- while (index < length) {
20972
- const char = input.charCodeAt(index);
20973
- if (!isXmlEscapable(char)) {
20974
- const bound = Math.min(index + 32, length);
20975
- let next = index + 1;
20976
- while (next < bound && !isXmlEscapable(input.charCodeAt(next))) next++;
20977
- if (next < bound) {
20978
- index = next;
20979
- continue;
20980
- }
20981
- if (next >= length) break;
20982
- xmlEncodeRegex.lastIndex = next;
20983
- if (!xmlEncodeRegex.test(input)) break;
20984
- index = xmlEncodeRegex.lastIndex - 1;
20985
- continue;
20986
- }
20987
- if (out === void 0) out = input.substring(0, index);
20988
- else if (last !== index) out += input.substring(last, index);
20989
- if (char < 64) {
20990
- out += getEscape(char);
20991
- last = index += 1;
20992
- continue;
20993
- }
20994
- const cp = input.codePointAt(index);
20995
- out += `&#x${cp.toString(16)};`;
20996
- if (cp !== char) index++;
20997
- last = index += 1;
20998
- }
20999
- if (out === void 0) return input;
21000
- if (last < length) out += input.substr(last);
21001
- return out;
21002
- }
21003
- /**
21004
21547
  * Escape `data` using `re`, mapping each matched character to its entity.
21005
21548
  * Every match is one UTF-16 code unit, so its index is `lastIndex - 1`.
21006
21549
  * @param re Global regex matching exactly the characters to escape
21007
21550
  * (`"`, `&`, `'`, `<`, `>`, `\u00A0` at most).
21008
21551
  * @param data String to escape.
21009
21552
  */
21010
- function escapeWithRegex(re, data) {
21553
+ function escapeWithRegex$1(re, data) {
21011
21554
  re.lastIndex = 0;
21012
21555
  if (!re.test(data)) return data;
21013
21556
  let out = "";
@@ -21016,28 +21559,28 @@ function escapeWithRegex(re, data) {
21016
21559
  const index = re.lastIndex - 1;
21017
21560
  if (last !== index) out += data.substring(last, index);
21018
21561
  const char = data.charCodeAt(index);
21019
- out += getEscape(char);
21562
+ out += getEscape$1(char);
21020
21563
  last = index + 1;
21021
21564
  } while (re.test(data));
21022
21565
  return out + data.substring(last);
21023
21566
  }
21024
- const attributeEscapeRegex = /["&\u{A0}]/gu;
21567
+ const attributeEscapeRegex$1 = /["&<>\u{A0}]/gu;
21025
21568
  /**
21026
21569
  * Encodes all characters that have to be escaped in HTML attributes,
21027
21570
  * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
21028
21571
  * @param data String to escape.
21029
21572
  */
21030
- function escapeAttribute$1(data) {
21031
- return escapeWithRegex(attributeEscapeRegex, data);
21573
+ function escapeAttribute$2(data) {
21574
+ return escapeWithRegex$1(attributeEscapeRegex$1, data);
21032
21575
  }
21033
- const textEscapeRegex = /[&<>\u{A0}]/gu;
21576
+ const textEscapeRegex$1 = /[&<>\u{A0}]/gu;
21034
21577
  /**
21035
21578
  * Encodes all characters that have to be escaped in HTML text,
21036
21579
  * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
21037
21580
  * @param data String to escape.
21038
21581
  */
21039
- function escapeText$1(data) {
21040
- return escapeWithRegex(textEscapeRegex, data);
21582
+ function escapeText$2(data) {
21583
+ return escapeWithRegex$1(textEscapeRegex$1, data);
21041
21584
  }
21042
21585
  // node_modules/parse5/dist/serializer/index.js
21043
21586
  const VOID_ELEMENTS = /* @__PURE__ */ new Set([
@@ -21090,30 +21633,46 @@ const defaultOpts = {
21090
21633
  * @param options Serialization options.
21091
21634
  */
21092
21635
  function serialize(node, options) {
21636
+ var _a;
21093
21637
  const opts = {
21094
21638
  ...defaultOpts,
21095
21639
  ...options
21096
21640
  };
21097
21641
  if (isVoidElement(node, opts)) return "";
21098
- return serializeChildNodes(node, opts);
21642
+ const { treeAdapter } = opts;
21643
+ const container = treeAdapter.isElementNode(node) && treeAdapter.getTagName(node) === TAG_NAMES.TEMPLATE && treeAdapter.getNamespaceURI(node) === NS.HTML ? treeAdapter.getTemplateContent(node) : node;
21644
+ return serializeNodes((_a = treeAdapter.getChildNodes(container)) !== null && _a !== void 0 ? _a : [], opts);
21099
21645
  }
21100
- function serializeChildNodes(parentNode, options) {
21646
+ function serializeNodes(nodes, options) {
21647
+ var _a;
21648
+ const { treeAdapter } = options;
21649
+ const stack = [];
21101
21650
  let html = "";
21102
- const container = options.treeAdapter.isElementNode(parentNode) && options.treeAdapter.getTagName(parentNode) === TAG_NAMES.TEMPLATE && options.treeAdapter.getNamespaceURI(parentNode) === NS.HTML ? options.treeAdapter.getTemplateContent(parentNode) : parentNode;
21103
- const childNodes = options.treeAdapter.getChildNodes(container);
21104
- if (childNodes) for (const currentNode of childNodes) html += serializeNode(currentNode, options);
21105
- return html;
21106
- }
21107
- function serializeNode(node, options) {
21108
- if (options.treeAdapter.isElementNode(node)) return serializeElement(node, options);
21109
- if (options.treeAdapter.isTextNode(node)) return serializeTextNode(node, options);
21110
- if (options.treeAdapter.isCommentNode(node)) return serializeCommentNode(node, options);
21111
- if (options.treeAdapter.isDocumentTypeNode(node)) return serializeDocumentTypeNode(node, options);
21112
- return "";
21113
- }
21114
- function serializeElement(node, options) {
21115
- const tn = options.treeAdapter.getTagName(node);
21116
- return `<${tn}${serializeAttributes(node, options)}>${isVoidElement(node, options) ? "" : `${serializeChildNodes(node, options)}</${tn}>`}`;
21651
+ let index = 0;
21652
+ for (;;) if (index < nodes.length) {
21653
+ const node = nodes[index++];
21654
+ if (treeAdapter.isElementNode(node)) {
21655
+ const tn = treeAdapter.getTagName(node);
21656
+ html += `<${tn}${serializeAttributes(node, options)}>`;
21657
+ const isHtml = treeAdapter.getNamespaceURI(node) === NS.HTML;
21658
+ if (!(isHtml && VOID_ELEMENTS.has(tn))) {
21659
+ stack.push({
21660
+ nodes,
21661
+ index,
21662
+ endTag: `</${tn}>`
21663
+ });
21664
+ nodes = (_a = treeAdapter.getChildNodes(isHtml && tn === TAG_NAMES.TEMPLATE ? treeAdapter.getTemplateContent(node) : node)) !== null && _a !== void 0 ? _a : [];
21665
+ index = 0;
21666
+ }
21667
+ } else if (treeAdapter.isTextNode(node)) html += serializeTextNode(node, options);
21668
+ else if (treeAdapter.isCommentNode(node)) html += serializeCommentNode(node, options);
21669
+ else if (treeAdapter.isDocumentTypeNode(node)) html += serializeDocumentTypeNode(node, options);
21670
+ } else {
21671
+ const parent = stack.pop();
21672
+ if (!parent) return html;
21673
+ html += parent.endTag;
21674
+ ({nodes, index} = parent);
21675
+ }
21117
21676
  }
21118
21677
  function serializeAttributes(node, { treeAdapter }) {
21119
21678
  let html = "";
@@ -21133,7 +21692,7 @@ function serializeAttributes(node, { treeAdapter }) {
21133
21692
  default: html += `${attr.prefix}:${attr.name}`;
21134
21693
  }
21135
21694
  else html += attr.name;
21136
- html += `="${escapeAttribute$1(attr.value)}"`;
21695
+ html += `="${escapeAttribute$2(attr.value)}"`;
21137
21696
  }
21138
21697
  return html;
21139
21698
  }
@@ -21142,7 +21701,7 @@ function serializeTextNode(node, options) {
21142
21701
  const content = treeAdapter.getTextNodeContent(node);
21143
21702
  const parent = treeAdapter.getParentNode(node);
21144
21703
  const parentTn = parent && treeAdapter.isElementNode(parent) && treeAdapter.getTagName(parent);
21145
- return parentTn && treeAdapter.getNamespaceURI(parent) === NS.HTML && hasUnescapedText(parentTn, options.scriptingEnabled) ? content : escapeText$1(content);
21704
+ return parentTn && treeAdapter.getNamespaceURI(parent) === NS.HTML && hasUnescapedText(parentTn, options.scriptingEnabled) ? content : escapeText$2(content);
21146
21705
  }
21147
21706
  function serializeCommentNode(node, { treeAdapter }) {
21148
21707
  return `<!--${treeAdapter.getCommentNodeContent(node)}-->`;
@@ -27945,7 +28504,8 @@ const adapter = {
27945
28504
  newNode.parent = parentNode;
27946
28505
  },
27947
28506
  insertBefore(parentNode, newNode, referenceNode) {
27948
- const insertionIdx = parentNode.children.indexOf(referenceNode);
28507
+ const { children } = parentNode;
28508
+ const insertionIdx = children[children.length - 1] === referenceNode ? children.length - 1 : children.indexOf(referenceNode);
27949
28509
  const { prev } = referenceNode;
27950
28510
  if (prev) {
27951
28511
  prev.next = newNode;
@@ -27982,13 +28542,14 @@ const adapter = {
27982
28542
  },
27983
28543
  detachNode(node) {
27984
28544
  if (node.parent) {
27985
- const idx = node.parent.children.indexOf(node);
28545
+ const { children } = node.parent;
28546
+ const idx = children[children.length - 1] === node ? children.length - 1 : children.indexOf(node);
27986
28547
  const { prev, next } = node;
27987
28548
  node.prev = null;
27988
28549
  node.next = null;
27989
28550
  if (prev) prev.next = next;
27990
28551
  if (next) next.prev = prev;
27991
- node.parent.children.splice(idx, 1);
28552
+ children.splice(idx, 1);
27992
28553
  node.parent = null;
27993
28554
  }
27994
28555
  },
@@ -27998,7 +28559,7 @@ const adapter = {
27998
28559
  else adapter.appendChild(parentNode, adapter.createTextNode(text));
27999
28560
  },
28000
28561
  insertTextBefore(parentNode, text, referenceNode) {
28001
- const prevNode = parentNode.children[parentNode.children.indexOf(referenceNode) - 1];
28562
+ const prevNode = referenceNode.prev;
28002
28563
  if (prevNode && isText$1(prevNode)) prevNode.data += text;
28003
28564
  else adapter.insertBefore(parentNode, adapter.createTextNode(text), referenceNode);
28004
28565
  },
@@ -29416,7 +29977,7 @@ function scanStartTag(source, tag) {
29416
29977
  }
29417
29978
  // src/server/edit/attribute.ts
29418
29979
  /** Escapes a value for a double-quoted attribute. */
29419
- function escapeAttribute(value) {
29980
+ function escapeAttribute$1(value) {
29420
29981
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
29421
29982
  }
29422
29983
  function splice(source, start, end, insert) {
@@ -29798,7 +30359,7 @@ const RELOCATING = /* @__PURE__ */ new Set([
29798
30359
  ]);
29799
30360
  /** The parser drops one leading newline inside these. */
29800
30361
  const LEADING_NEWLINE_DROPPED = /* @__PURE__ */ new Set(["pre", "listing"]);
29801
- function escapeText(value) {
30362
+ function escapeText$1(value) {
29802
30363
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
29803
30364
  }
29804
30365
  /**
@@ -29832,7 +30393,7 @@ function setText(source, element, value) {
29832
30393
  const written = LEADING_NEWLINE_DROPPED.has(tag) && value.startsWith("\n") ? `\n${value}` : value;
29833
30394
  return {
29834
30395
  ok: true,
29835
- html: source.slice(0, from) + escapeText(written) + source.slice(to)
30396
+ html: source.slice(0, from) + escapeText$1(written) + source.slice(to)
29836
30397
  };
29837
30398
  }
29838
30399
  // src/server/edit/apply.ts
@@ -29900,12 +30461,12 @@ function write(source, element, change) {
29900
30461
  }
29901
30462
  if (change.kind === "attribute") return {
29902
30463
  ok: true,
29903
- html: setRawAttribute(source, element, change.name, escapeAttribute(change.value))
30464
+ html: setRawAttribute(source, element, change.name, escapeAttribute$1(change.value))
29904
30465
  };
29905
30466
  const declarations = change.kind === "styles" ? change.declarations : [change];
29906
30467
  let style = rawAttribute(source, element, "style") ?? "";
29907
30468
  for (const { property, value } of declarations) {
29908
- const next = setDeclaration(style, property, escapeAttribute(value));
30469
+ const next = setDeclaration(style, property, escapeAttribute$1(value));
29909
30470
  if (!next.ok) return refuse$2("open-quote", `the style on <${element.tagName}> ends inside an open quote or comment`);
29910
30471
  style = next.style;
29911
30472
  }
@@ -29943,12 +30504,12 @@ function changesOnlyTarget(before, after, index, change) {
29943
30504
  }
29944
30505
  return serialize(before.document) === serialize(after.document);
29945
30506
  }
29946
- function textOf(element) {
30507
+ function textOf$1(element) {
29947
30508
  return element.childNodes.map((node) => "value" in node && node.nodeName === "#text" ? node.value : "").join("");
29948
30509
  }
29949
30510
  /** Whether the target holds the value the change asked for. */
29950
30511
  function holdsValue(element, change) {
29951
- if (change.kind === "text") return textOf(element) === change.value;
30512
+ if (change.kind === "text") return textOf$1(element) === change.value;
29952
30513
  if (change.kind === "attribute") return element.attrs.find((attribute) => isNamed(attribute, change.name))?.value === change.value;
29953
30514
  const style = element.attrs.find((attribute) => attribute.name === "style")?.value ?? "";
29954
30515
  return (change.kind === "styles" ? change.declarations : [change]).every(({ property, value }) => {
@@ -33127,6 +33688,116 @@ function getElementsByClassName(className, nodes, recurse = true, limit = Number
33127
33688
  function getElementsByTagType(type, nodes, recurse = true, limit = Number.POSITIVE_INFINITY) {
33128
33689
  return filter(Checks["tag_type"](type), nodes, recurse, limit);
33129
33690
  }
33691
+ // node_modules/dom-serializer/node_modules/entities/dist/escape.js
33692
+ /**
33693
+ * Get the named reference for an XML special character or U+00A0.
33694
+ * @param char Code unit matched by one of the escape regexes.
33695
+ */
33696
+ function getEscape(char) {
33697
+ return char === 34 ? "&quot;" : char === 38 ? "&amp;" : char === 39 ? "&apos;" : char === 60 ? "&lt;" : char === 62 ? "&gt;" : "&nbsp;";
33698
+ }
33699
+ /**
33700
+ * Matches exactly the characters `encodeXML` escapes: the five XML special
33701
+ * characters plus every non-ASCII code unit (lone surrogates included — no
33702
+ * `u` flag). Kept in sync with `XML_BITSET_VALUE`.
33703
+ *
33704
+ * Shared with `encodeNonAsciiHTML` in `encode.ts`. Because the regex is
33705
+ * stateful (`g` flag), every call site must set `lastIndex` before use.
33706
+ */
33707
+ const xmlEncodeRegex = /["&'<>\u0080-\uFFFF]/g;
33708
+ /**
33709
+ * Whether `code` (a UTF-16 code unit) is escaped by {@link encodeXML}: a
33710
+ * non-ASCII unit, or one of the five XML specials flagged in
33711
+ * `XML_BITSET_VALUE` (which is only meaningful for code units 32-63).
33712
+ * @param code Code unit to test.
33713
+ */
33714
+ function isXmlEscapable(code) {
33715
+ return code >= 128 || code >= 32 && code < 64 && (1342177476 >>> code & 1) === 1;
33716
+ }
33717
+ /**
33718
+ * Encodes all non-ASCII characters, as well as characters not valid in XML
33719
+ * documents using XML entities.
33720
+ *
33721
+ * If a character has no equivalent entity, a numeric hexadecimal reference
33722
+ * (eg. `&#xfc;`) will be used.
33723
+ * @param input Input string to encode.
33724
+ */
33725
+ function encodeXML(input) {
33726
+ const { length } = input;
33727
+ let out;
33728
+ let last = 0;
33729
+ let index = 0;
33730
+ while (index < length) {
33731
+ const char = input.charCodeAt(index);
33732
+ if (!isXmlEscapable(char)) {
33733
+ const bound = Math.min(index + 32, length);
33734
+ let next = index + 1;
33735
+ while (next < bound && !isXmlEscapable(input.charCodeAt(next))) next++;
33736
+ if (next < bound) {
33737
+ index = next;
33738
+ continue;
33739
+ }
33740
+ if (next >= length) break;
33741
+ xmlEncodeRegex.lastIndex = next;
33742
+ if (!xmlEncodeRegex.test(input)) break;
33743
+ index = xmlEncodeRegex.lastIndex - 1;
33744
+ continue;
33745
+ }
33746
+ if (out === void 0) out = input.substring(0, index);
33747
+ else if (last !== index) out += input.substring(last, index);
33748
+ if (char < 64) {
33749
+ out += getEscape(char);
33750
+ last = index += 1;
33751
+ continue;
33752
+ }
33753
+ const cp = input.codePointAt(index);
33754
+ out += `&#x${cp.toString(16)};`;
33755
+ if (cp !== char) index++;
33756
+ last = index += 1;
33757
+ }
33758
+ if (out === void 0) return input;
33759
+ if (last < length) out += input.substr(last);
33760
+ return out;
33761
+ }
33762
+ /**
33763
+ * Escape `data` using `re`, mapping each matched character to its entity.
33764
+ * Every match is one UTF-16 code unit, so its index is `lastIndex - 1`.
33765
+ * @param re Global regex matching exactly the characters to escape
33766
+ * (`"`, `&`, `'`, `<`, `>`, `\u00A0` at most).
33767
+ * @param data String to escape.
33768
+ */
33769
+ function escapeWithRegex(re, data) {
33770
+ re.lastIndex = 0;
33771
+ if (!re.test(data)) return data;
33772
+ let out = "";
33773
+ let last = 0;
33774
+ do {
33775
+ const index = re.lastIndex - 1;
33776
+ if (last !== index) out += data.substring(last, index);
33777
+ const char = data.charCodeAt(index);
33778
+ out += getEscape(char);
33779
+ last = index + 1;
33780
+ } while (re.test(data));
33781
+ return out + data.substring(last);
33782
+ }
33783
+ const attributeEscapeRegex = /["&\u{A0}]/gu;
33784
+ /**
33785
+ * Encodes all characters that have to be escaped in HTML attributes,
33786
+ * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
33787
+ * @param data String to escape.
33788
+ */
33789
+ function escapeAttribute(data) {
33790
+ return escapeWithRegex(attributeEscapeRegex, data);
33791
+ }
33792
+ const textEscapeRegex = /[&<>\u{A0}]/gu;
33793
+ /**
33794
+ * Encodes all characters that have to be escaped in HTML text,
33795
+ * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
33796
+ * @param data String to escape.
33797
+ */
33798
+ function escapeText(data) {
33799
+ return escapeWithRegex(textEscapeRegex, data);
33800
+ }
33130
33801
  // node_modules/dom-serializer/dist/foreign-names.js
33131
33802
  /**
33132
33803
  * Mixed-case SVG and MathML element names recognized in foreign content.
@@ -33188,7 +33859,7 @@ function renderNode(node, options, xmlMode) {
33188
33859
  case Text$1: {
33189
33860
  const element = node;
33190
33861
  const data = element.data || "";
33191
- if ((options.encodeEntities ?? options.decodeEntities) !== false && !(!xmlMode && element.parent && unencodedElements.has(element.parent.name))) return xmlMode || options.encodeEntities !== "utf8" ? encodeXML(data) : escapeText$1(data);
33862
+ if ((options.encodeEntities ?? options.decodeEntities) !== false && !(!xmlMode && element.parent && unencodedElements.has(element.parent.name))) return xmlMode || options.encodeEntities !== "utf8" ? encodeXML(data) : escapeText(data);
33192
33863
  return data;
33193
33864
  }
33194
33865
  }
@@ -33225,7 +33896,7 @@ function replaceQuotes(value) {
33225
33896
  */
33226
33897
  function formatAttributes(attributes, options, xmlMode) {
33227
33898
  if (!attributes) return "";
33228
- const encode = (options.encodeEntities ?? options.decodeEntities) === false ? replaceQuotes : xmlMode || options.encodeEntities !== "utf8" ? encodeXML : escapeAttribute$1;
33899
+ const encode = (options.encodeEntities ?? options.decodeEntities) === false ? replaceQuotes : xmlMode || options.encodeEntities !== "utf8" ? encodeXML : escapeAttribute;
33229
33900
  const isForeign = xmlMode === "foreign";
33230
33901
  const showEmpty = !!(options.emptyAttrs ?? xmlMode);
33231
33902
  let result = "";
@@ -41435,16 +42106,24 @@ const CUSTOM_PROPERTY_RULES = [{
41435
42106
  id: "unknown-token",
41436
42107
  tier: "exact",
41437
42108
  severity: "warning",
41438
- description: "A var() with no fallback names a custom property no token sheet, frame sheet, or style attribute declares"
42109
+ description: "A var() with no fallback names a custom property no token sheet, frame sheet, style attribute, or script write declares"
41439
42110
  }];
41440
42111
  const finding$8 = findingFor(CUSTOM_PROPERTY_RULES);
41441
42112
  /** A `var()` naming its property, with no fallback after a comma. */
41442
42113
  const BARE_VAR = /var\(\s*(--[\w-]+)\s*\)/g;
41443
42114
  /**
42115
+ * The two ways a script writes a custom property by a name it spells out:
42116
+ * `setProperty('--name', …)`, and a `--name:` declaration in a string it
42117
+ * hands a style attribute or `cssText`. A read such as `getPropertyValue`
42118
+ * matches neither, so it still reports.
42119
+ */
42120
+ const SCRIPT_WRITES = [/\.setProperty\(\s*(['"`])(--[\w-]+)\1/g, /(?<![\w-])(--[\w-]+)\s*:/g];
42121
+ /**
41444
42122
  * `unknown-token`, one finding per bare `var()` in the frame's own sheets
41445
42123
  * and style attributes whose name nothing declares. A token sheet's own
41446
42124
  * references are the board's to answer for, so only its declarations count.
41447
- * A property a script sets reads as unknown, which a fallback silences.
42125
+ * A name a `<script>` writes counts as declared, read off its text since the
42126
+ * check never runs it, so a name the script builds at runtime still reports.
41448
42127
  * A linked sheet's rule matching no element in the frame stays quiet, since a
41449
42128
  * site sheet styles other pages. The frame's own `<style>` keeps reporting,
41450
42129
  * since its theme and state rules match elements no static tree marks.
@@ -41484,10 +42163,14 @@ function checkUnknownTokens(source, tokens) {
41484
42163
  });
41485
42164
  });
41486
42165
  }
42166
+ for (const element of source.elements) {
42167
+ if (element.name !== "script") continue;
42168
+ for (const name of scriptWrites(scriptText(element, source))) declared.add(name);
42169
+ }
41487
42170
  return uses.filter((use) => !declared.has(use.name)).map((use) => finding$8("unknown-token", {
41488
42171
  frame: source.ref,
41489
42172
  path: use.path,
41490
- message: `var(${use.name}) names a custom property nothing declares, so the declaration resolves to nothing. Use a token the project's tokens.css declares, or give it a fallback, such as var(${use.name}, red).`,
42173
+ message: `var(${use.name}) names a custom property nothing declares, so the declaration resolves to nothing. Use a token the project's tokens.css declares, or give it a fallback, such as var(${use.name}, red). If a script sets it at runtime under a name the check cannot read, the fallback is the way out.`,
41491
42174
  location: use.location
41492
42175
  }));
41493
42176
  }
@@ -41507,6 +42190,28 @@ function matchesNothing(node, elements) {
41507
42190
  function bareVars(value) {
41508
42191
  return [...new Set([...value.matchAll(BARE_VAR)].map((match) => match[1] ?? ""))];
41509
42192
  }
42193
+ function scriptWrites(text) {
42194
+ return SCRIPT_WRITES.flatMap((pattern) => [...text.matchAll(pattern)].map((match) => match.at(-1) ?? ""));
42195
+ }
42196
+ /**
42197
+ * A script's inline text, or its `src` file's when the file sits in the
42198
+ * board. A remote, outside, or unreadable `src` reads as empty, since the
42199
+ * write hook never reports a read as failed.
42200
+ */
42201
+ function scriptText(element, source) {
42202
+ const src = element.attribs.src;
42203
+ if (src === void 0) return textOf(element);
42204
+ const file = localTarget(src, source.pageDir);
42205
+ if (!file || !isInside(source.root, file)) return "";
42206
+ try {
42207
+ return readFileSync(file, "utf8");
42208
+ } catch {
42209
+ return "";
42210
+ }
42211
+ }
42212
+ function textOf(element) {
42213
+ return element.children.map((node) => "data" in node ? node.data : "").join("");
42214
+ }
41510
42215
  function parseOrNull(css) {
41511
42216
  try {
41512
42217
  return postcss_default.parse(css);
@@ -43927,6 +44632,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43927
44632
  }));
43928
44633
  // node_modules/ws/lib/buffer-util.js
43929
44634
  var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44635
+ const { websocketMask, websocketUnmask } = __require("http");
43930
44636
  const { EMPTY_BUFFER } = require_constants();
43931
44637
  const FastBuffer = Buffer[Symbol.species];
43932
44638
  /**
@@ -44011,8 +44717,16 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44011
44717
  toBuffer,
44012
44718
  unmask: _unmask
44013
44719
  };
44014
- /* istanbul ignore else */
44015
- if (!process.env.WS_NO_BUFFER_UTIL) try {
44720
+ if (websocketMask) {
44721
+ module.exports.mask = function(source, mask, output, offset, length) {
44722
+ if (length < 24) _mask(source, mask, output, offset, length);
44723
+ else websocketMask(source, mask, output, offset, length);
44724
+ };
44725
+ module.exports.unmask = function(buffer, mask) {
44726
+ if (buffer.length < 24) _unmask(buffer, mask);
44727
+ else websocketUnmask(buffer, mask);
44728
+ };
44729
+ } else if (!process.env.WS_NO_BUFFER_UTIL) try {
44016
44730
  const bufferUtil = __require("bufferutil");
44017
44731
  module.exports.mask = function(source, mask, output, offset, length) {
44018
44732
  if (length < 48) _mask(source, mask, output, offset, length);
@@ -45179,12 +45893,13 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45179
45893
  target[2] = target[3] = 0;
45180
45894
  target.writeUIntBE(dataLength, 4, 6);
45181
45895
  }
45182
- if (!options.mask) return [target, data];
45896
+ if (!options.mask) return dataLength ? [target, data] : [target];
45183
45897
  target[1] |= 128;
45184
45898
  target[offset - 4] = mask[0];
45185
45899
  target[offset - 3] = mask[1];
45186
45900
  target[offset - 2] = mask[2];
45187
45901
  target[offset - 1] = mask[3];
45902
+ if (!dataLength) return [target];
45188
45903
  if (skipMasking) return [target, data];
45189
45904
  if (merge) {
45190
45905
  applyMask(data, mask, target, offset, dataLength);
@@ -46558,9 +47273,14 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46558
47273
  }
46559
47274
  if (parsedUrl.username || parsedUrl.password) opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
46560
47275
  if (isIpcUrl) {
46561
- const parts = opts.path.split(":");
46562
- opts.socketPath = parts[0];
46563
- opts.path = parts[1];
47276
+ const i = opts.path.indexOf(":");
47277
+ if (i === -1) {
47278
+ opts.socketPath = opts.path;
47279
+ opts.path = "";
47280
+ } else {
47281
+ opts.socketPath = opts.path.slice(0, i);
47282
+ opts.path = opts.path.slice(i + 1);
47283
+ }
46564
47284
  }
46565
47285
  let req;
46566
47286
  if (opts.followRedirects) {