context-mode 2.0.0-next.15 → 2.0.0-next.16

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/server.mjs CHANGED
@@ -810,9 +810,9 @@ var Class = class {
810
810
  constructor(..._args) {
811
811
  }
812
812
  };
813
- function members(proto, table) {
814
- for (const key in table) {
815
- const desc = Object.getOwnPropertyDescriptor(table, key);
813
+ function members(proto, table2) {
814
+ for (const key in table2) {
815
+ const desc = Object.getOwnPropertyDescriptor(table2, key);
816
816
  if (desc.get)
817
817
  Object.defineProperty(proto, key, { ...desc, enumerable: false });
818
818
  else
@@ -827,10 +827,10 @@ function hide(inst, key, value) {
827
827
  return own(inst, key, value, false);
828
828
  }
829
829
  // @__NO_SIDE_EFFECTS__
830
- function derived(computes, table) {
830
+ function derived(computes, table2) {
831
831
  for (const key in computes) {
832
832
  const compute = computes[key];
833
- Object.defineProperty(table, key, {
833
+ Object.defineProperty(table2, key, {
834
834
  configurable: true,
835
835
  enumerable: true,
836
836
  get() {
@@ -841,7 +841,7 @@ function derived(computes, table) {
841
841
  }
842
842
  });
843
843
  }
844
- return table;
844
+ return table2;
845
845
  }
846
846
  function defineBound(proto, key, fn) {
847
847
  Object.defineProperty(proto, key, {
@@ -5062,8 +5062,8 @@ var contributors = {
5062
5062
  function aggregateChecks(schema) {
5063
5063
  const agg = {};
5064
5064
  const def = schema._zod.def;
5065
- const list2 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
5066
- for (const ch of list2)
5065
+ const list3 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
5066
+ for (const ch of list3)
5067
5067
  contributors[ch._zod.def.check]?.(agg, ch._zod.def);
5068
5068
  const bag = schema._zod.bag;
5069
5069
  if (bag.minimum !== void 0)
@@ -8391,9 +8391,9 @@ var Class2 = class {
8391
8391
  constructor(..._args) {
8392
8392
  }
8393
8393
  };
8394
- function members2(proto, table) {
8395
- for (const key in table) {
8396
- const desc = Object.getOwnPropertyDescriptor(table, key);
8394
+ function members2(proto, table2) {
8395
+ for (const key in table2) {
8396
+ const desc = Object.getOwnPropertyDescriptor(table2, key);
8397
8397
  if (desc.get)
8398
8398
  Object.defineProperty(proto, key, { ...desc, enumerable: false });
8399
8399
  else
@@ -8408,10 +8408,10 @@ function hide2(inst, key, value) {
8408
8408
  return own2(inst, key, value, false);
8409
8409
  }
8410
8410
  // @__NO_SIDE_EFFECTS__
8411
- function derived2(computes, table) {
8411
+ function derived2(computes, table2) {
8412
8412
  for (const key in computes) {
8413
8413
  const compute = computes[key];
8414
- Object.defineProperty(table, key, {
8414
+ Object.defineProperty(table2, key, {
8415
8415
  configurable: true,
8416
8416
  enumerable: true,
8417
8417
  get() {
@@ -8422,7 +8422,7 @@ function derived2(computes, table) {
8422
8422
  }
8423
8423
  });
8424
8424
  }
8425
- return table;
8425
+ return table2;
8426
8426
  }
8427
8427
  function defineBound2(proto, key, fn) {
8428
8428
  Object.defineProperty(proto, key, {
@@ -12553,8 +12553,8 @@ var contributors2 = {
12553
12553
  function aggregateChecks2(schema) {
12554
12554
  const agg = {};
12555
12555
  const def = schema._zod.def;
12556
- const list2 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
12557
- for (const ch of list2)
12556
+ const list3 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
12557
+ for (const ch of list3)
12558
12558
  contributors2[ch._zod.def.check]?.(agg, ch._zod.def);
12559
12559
  const bag = schema._zod.bag;
12560
12560
  if (bag.minimum !== void 0)
@@ -17405,11 +17405,11 @@ var LADDER_ERROR_HTTP_STATUS = {
17405
17405
  [ProtocolErrorCode.MissingRequiredClientCapability]: 400,
17406
17406
  [HEADER_MISMATCH_ERROR_CODE]: 400
17407
17407
  };
17408
- function rejection(rung, cell4, httpStatus, error42, settled) {
17408
+ function rejection(rung, cell5, httpStatus, error42, settled) {
17409
17409
  return {
17410
17410
  kind: "reject",
17411
17411
  rung,
17412
- cell: cell4,
17412
+ cell: cell5,
17413
17413
  httpStatus,
17414
17414
  code: error42.code,
17415
17415
  message: error42.message,
@@ -19045,8 +19045,8 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin((exports) => {
19045
19045
  }
19046
19046
  if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) return `"${a}${b.slice(1)}`;
19047
19047
  }
19048
- function strConcat(c1, c2) {
19049
- return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str`${c1}${c2}`;
19048
+ function strConcat(c12, c2) {
19049
+ return c2.emptyStr() ? c12 : c12.emptyStr() ? c2 : str`${c12}${c2}`;
19050
19050
  }
19051
19051
  exports.strConcat = strConcat;
19052
19052
  function interpolate(x) {
@@ -19300,7 +19300,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19300
19300
  AND: new code_1._Code("&&"),
19301
19301
  ADD: new code_1._Code("+")
19302
19302
  };
19303
- var Node = class {
19303
+ var Node2 = class {
19304
19304
  optimizeNodes() {
19305
19305
  return this;
19306
19306
  }
@@ -19308,7 +19308,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19308
19308
  return this;
19309
19309
  }
19310
19310
  };
19311
- var Def = class extends Node {
19311
+ var Def = class extends Node2 {
19312
19312
  constructor(varKind, name, rhs) {
19313
19313
  super();
19314
19314
  this.varKind = varKind;
@@ -19329,7 +19329,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19329
19329
  return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
19330
19330
  }
19331
19331
  };
19332
- var Assign = class extends Node {
19332
+ var Assign = class extends Node2 {
19333
19333
  constructor(lhs, rhs, sideEffects) {
19334
19334
  super();
19335
19335
  this.lhs = lhs;
@@ -19357,7 +19357,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19357
19357
  return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
19358
19358
  }
19359
19359
  };
19360
- var Label = class extends Node {
19360
+ var Label = class extends Node2 {
19361
19361
  constructor(label) {
19362
19362
  super();
19363
19363
  this.label = label;
@@ -19367,7 +19367,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19367
19367
  return `${this.label}:` + _n;
19368
19368
  }
19369
19369
  };
19370
- var Break = class extends Node {
19370
+ var Break = class extends Node2 {
19371
19371
  constructor(label) {
19372
19372
  super();
19373
19373
  this.label = label;
@@ -19377,7 +19377,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19377
19377
  return `break${this.label ? ` ${this.label}` : ""};` + _n;
19378
19378
  }
19379
19379
  };
19380
- var Throw = class extends Node {
19380
+ var Throw = class extends Node2 {
19381
19381
  constructor(error42) {
19382
19382
  super();
19383
19383
  this.error = error42;
@@ -19389,7 +19389,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19389
19389
  return this.error.names;
19390
19390
  }
19391
19391
  };
19392
- var AnyCode = class extends Node {
19392
+ var AnyCode = class extends Node2 {
19393
19393
  constructor(code) {
19394
19394
  super();
19395
19395
  this.code = code;
@@ -19408,7 +19408,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19408
19408
  return this.code instanceof code_1._CodeOrName ? this.code.names : {};
19409
19409
  }
19410
19410
  };
19411
- var ParentNode = class extends Node {
19411
+ var ParentNode = class extends Node2 {
19412
19412
  constructor(nodes = []) {
19413
19413
  super();
19414
19414
  this.nodes = nodes;
@@ -19447,7 +19447,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19447
19447
  return "{" + opts._n + super.render(opts) + "}" + opts._n;
19448
19448
  }
19449
19449
  };
19450
- var Root = class extends ParentNode {
19450
+ var Root2 = class extends ParentNode {
19451
19451
  };
19452
19452
  var Else = class extends BlockNode {
19453
19453
  };
@@ -19624,7 +19624,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
19624
19624
  };
19625
19625
  this._extScope = extScope;
19626
19626
  this._scope = new scope_1.Scope({ parent: extScope });
19627
- this._nodes = [new Root()];
19627
+ this._nodes = [new Root2()];
19628
19628
  }
19629
19629
  toString() {
19630
19630
  return this._root.render(this.opts);
@@ -20004,8 +20004,8 @@ var require_util = /* @__PURE__ */ __commonJSMin((exports) => {
20004
20004
  })(Type || (exports.Type = Type = {}));
20005
20005
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
20006
20006
  if (dataProp instanceof codegen_1.Name) {
20007
- const isNumber2 = dataPropType === Type.Num;
20008
- return jsPropertySyntax ? isNumber2 ? (0, codegen_1._)`"[" + ${dataProp} + "]"` : (0, codegen_1._)`"['" + ${dataProp} + "']"` : isNumber2 ? (0, codegen_1._)`"/" + ${dataProp}` : (0, codegen_1._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
20007
+ const isNumber3 = dataPropType === Type.Num;
20008
+ return jsPropertySyntax ? isNumber3 ? (0, codegen_1._)`"[" + ${dataProp} + "]"` : (0, codegen_1._)`"['" + ${dataProp} + "']"` : isNumber3 ? (0, codegen_1._)`"/" + ${dataProp}` : (0, codegen_1._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
20009
20009
  }
20010
20010
  return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
20011
20011
  }
@@ -21236,17 +21236,17 @@ var require_validate = /* @__PURE__ */ __commonJSMin((exports) => {
21236
21236
  const { schemaCode } = this;
21237
21237
  this.fail((0, codegen_1._)`${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`);
21238
21238
  }
21239
- error(append, errorParams, errorPaths) {
21239
+ error(append2, errorParams, errorPaths) {
21240
21240
  if (errorParams) {
21241
21241
  this.setParams(errorParams);
21242
- this._error(append, errorPaths);
21242
+ this._error(append2, errorPaths);
21243
21243
  this.setParams({});
21244
21244
  return;
21245
21245
  }
21246
- this._error(append, errorPaths);
21246
+ this._error(append2, errorPaths);
21247
21247
  }
21248
- _error(append, errorPaths) {
21249
- (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
21248
+ _error(append2, errorPaths) {
21249
+ (append2 ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
21250
21250
  }
21251
21251
  $dataError() {
21252
21252
  (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
@@ -25866,11 +25866,11 @@ var require_dist = /* @__PURE__ */ __commonJSMin((exports, module) => {
25866
25866
  if (!f) throw new Error(`Unknown format "${name}"`);
25867
25867
  return f;
25868
25868
  };
25869
- function addFormats2(ajv, list2, fs2, exportName) {
25869
+ function addFormats2(ajv, list3, fs2, exportName) {
25870
25870
  var _a5;
25871
25871
  var _b;
25872
25872
  (_a5 = (_b = ajv.opts.code).formats) !== null && _a5 !== void 0 || (_b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`);
25873
- for (const f of list2) ajv.addFormat(f, fs2[f]);
25873
+ for (const f of list3) ajv.addFormat(f, fs2[f]);
25874
25874
  }
25875
25875
  module.exports = exports = formatsPlugin;
25876
25876
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -25961,16 +25961,16 @@ function getCompleter(schema) {
25961
25961
  return schema[COMPLETABLE_SYMBOL]?.complete;
25962
25962
  }
25963
25963
  var MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
25964
- function listenFilterAccepts(filter, event) {
25964
+ function listenFilterAccepts(filter2, event) {
25965
25965
  switch (event.kind) {
25966
25966
  case "tools_list_changed":
25967
- return filter.toolsListChanged === true;
25967
+ return filter2.toolsListChanged === true;
25968
25968
  case "prompts_list_changed":
25969
- return filter.promptsListChanged === true;
25969
+ return filter2.promptsListChanged === true;
25970
25970
  case "resources_list_changed":
25971
- return filter.resourcesListChanged === true;
25971
+ return filter2.resourcesListChanged === true;
25972
25972
  case "resource_updated":
25973
- return filter.resourceSubscriptions !== void 0 && filter.resourceSubscriptions.includes(event.uri);
25973
+ return filter2.resourceSubscriptions !== void 0 && filter2.resourceSubscriptions.includes(event.uri);
25974
25974
  }
25975
25975
  }
25976
25976
  function honoredSubset(requested, capabilities) {
@@ -26061,8 +26061,8 @@ var StdioListenRouter = class {
26061
26061
  message: "Subscription limit reached"
26062
26062
  }
26063
26063
  };
26064
- const filter = parseListenFilter(message2);
26065
- if (filter === void 0) return {
26064
+ const filter2 = parseListenFilter(message2);
26065
+ if (filter2 === void 0) return {
26066
26066
  jsonrpc: "2.0",
26067
26067
  id: message2.id,
26068
26068
  error: {
@@ -26070,7 +26070,7 @@ var StdioListenRouter = class {
26070
26070
  message: "Invalid params: 'notifications' is required and must be a valid SubscriptionFilter"
26071
26071
  }
26072
26072
  };
26073
- const honored = honoredSubset(filter, this._serverCapabilities);
26073
+ const honored = honoredSubset(filter2, this._serverCapabilities);
26074
26074
  this._subs.set(message2.id, honored);
26075
26075
  return stampSubscriptionId({
26076
26076
  method: "notifications/subscriptions/acknowledged",
@@ -26100,7 +26100,7 @@ var StdioListenRouter = class {
26100
26100
  const uri = typeof uriParam === "string" ? uriParam : void 0;
26101
26101
  const event = notificationToServerEvent(message2.method, uri);
26102
26102
  const out = [];
26103
- for (const [subscriptionId, filter] of this._subs) if (listenFilterAccepts(filter, event)) out.push(stampSubscriptionId({
26103
+ for (const [subscriptionId, filter2] of this._subs) if (listenFilterAccepts(filter2, event)) out.push(stampSubscriptionId({
26104
26104
  method: message2.method,
26105
26105
  params: message2.params ?? {}
26106
26106
  }, subscriptionId));
@@ -28066,6 +28066,7 @@ var STATE_CLOSE_TAG = "</context_mode_state>";
28066
28066
  var INDEX_WRITE_CHUNK = 1048576;
28067
28067
  var MAX_CHUNK_BYTES = 4096;
28068
28068
  var SEARCH_PAGE_SIZE = 20;
28069
+ var SEARCH_REPLY_HITS = 5;
28069
28070
  var SNIPPET_MAX_BYTES = 800;
28070
28071
  var SNIPPET_CODE_MAX_BYTES = 2048;
28071
28072
  var MAX_CANDIDATES = 85;
@@ -28339,7 +28340,7 @@ var DECISION_SOURCE = "decision";
28339
28340
  var DECISION_USER_LABEL = "decision (user)";
28340
28341
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
28341
28342
  var RELEASE_BRANCH = "release";
28342
- var BUNDLE_SHA = true ? "5ef1f1894d68b94c068a7c7afe5c1203fcb78624" : void 0;
28343
+ var BUNDLE_SHA = true ? "144e3495cd6f2e27afe44cf611493f68e5445793" : void 0;
28343
28344
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
28344
28345
  var DOCTOR_LABEL = Object.freeze({
28345
28346
  D1: "version",
@@ -29597,7 +29598,7 @@ function buildSnippet(row5, given, maxBytes, codeMaxBytes = SNIPPET_CODE_MAX_BYT
29597
29598
  if (blocks.length === 0) return clipLine(row5, 0, row5.length, -1, maxBytes);
29598
29599
  const lower = row5.toLowerCase();
29599
29600
  const hay = lower.length === row5.length ? lower : row5;
29600
- const find = (t) => {
29601
+ const find2 = (t) => {
29601
29602
  const out = [];
29602
29603
  if (t.text === "") return out;
29603
29604
  for (let p = hay.indexOf(t.text); p >= 0 && out.length < MAX_POSITIONS; p = hay.indexOf(t.text, p + 1)) {
@@ -29607,10 +29608,10 @@ function buildSnippet(row5, given, maxBytes, codeMaxBytes = SNIPPET_CODE_MAX_BYT
29607
29608
  return out;
29608
29609
  };
29609
29610
  let terms = given;
29610
- let pos = terms.map(find);
29611
+ let pos = terms.map(find2);
29611
29612
  if (pos.every((p) => p.length === 0)) {
29612
29613
  terms = given.filter((t) => t.text.length >= 5).map((t) => ({ ...t, text: t.text.slice(0, Math.max(4, t.text.length - 2)) }));
29613
- pos = terms.map(find);
29614
+ pos = terms.map(find2);
29614
29615
  }
29615
29616
  const count = (ti, a, b) => {
29616
29617
  const ps = pos[ti];
@@ -31394,6 +31395,8 @@ RETURNING id`;
31394
31395
  var INSERT_CHUNK = `
31395
31396
  INSERT INTO chunks(source_id, session_id, worktree, agent, ord, body, title) VALUES (?, ?, ?, ?, ?, ?, ?)`;
31396
31397
  var TITLE_WEIGHT = 1;
31398
+ var RAW_LABEL_SUFFIX = " (raw)";
31399
+ var NOT_RAW = `AND (:source IS NOT NULL OR substr(s.label, -${RAW_LABEL_SUFFIX.length}) <> '${RAW_LABEL_SUFFIX}')`;
31397
31400
  var PORTER_MATCH = `
31398
31401
  SELECT chunks.rowid AS rid, chunks.source_id AS source_id, chunks.session_id AS session_id,
31399
31402
  chunks.worktree AS worktree, chunks.ord AS ord, s.created_ts AS created_ts,
@@ -31403,7 +31406,8 @@ var PORTER_MATCH = `
31403
31406
  WHERE chunks MATCH :match
31404
31407
  AND (:scope <> 'session' OR chunks.session_id = :session_id)
31405
31408
  AND (:scope <> 'worktree' OR chunks.worktree = :worktree)
31406
- AND (:source IS NULL OR s.label = :source)`;
31409
+ AND (:source IS NULL OR s.label = :source)
31410
+ ${NOT_RAW}`;
31407
31411
  var PORTER_ORDER = `
31408
31412
  ORDER BY (session_id = :session_id) DESC, (worktree = :worktree) DESC, full DESC, score DESC, source_id DESC, ord ASC`;
31409
31413
  var PORTER_RANK_PROJECT = `
@@ -31431,6 +31435,7 @@ WHERE chunks_tri MATCH :match
31431
31435
  AND (:scope <> 'session' OR c.session_id = :session_id)
31432
31436
  AND (:scope <> 'worktree' OR c.worktree = :worktree)
31433
31437
  AND (:source IS NULL OR s.label = :source)
31438
+ ${NOT_RAW}
31434
31439
  ORDER BY bm25(chunks_tri, 1.0, ${TITLE_WEIGHT}) ASC, c.source_id DESC, c.ord ASC`;
31435
31440
  var PAGE_ROWS = `
31436
31441
  SELECT c.rowid AS rid, c.source_id AS source_id, c.ord AS ord, c.body AS body, s.label AS label
@@ -31693,16 +31698,16 @@ function typoTerms(db, words) {
31693
31698
  function ftsQuery(db, q, scope, ctx, sessionId, limit, offset, source) {
31694
31699
  const terms = searchTerms(q);
31695
31700
  if (terms.length === 0) return [];
31696
- const filter = { scope, session_id: sessionId, worktree: ctx.worktree, source: source ?? null };
31701
+ const filter2 = { scope, session_id: sessionId, worktree: ctx.worktree, source: source ?? null };
31697
31702
  const rrf = scope === "project" ? { k: RRF_K } : {};
31698
- const porter = (t) => stmt(db.raw, porterRankSql(scope)).all({ ...filter, match: t.join(" OR "), all: t.join(" "), ...rrf });
31703
+ const porter = (t) => stmt(db.raw, porterRankSql(scope)).all({ ...filter2, match: t.join(" OR "), all: t.join(" "), ...rrf });
31699
31704
  let pList = porter(terms);
31700
31705
  if (pList.length === 0) {
31701
31706
  const fixed = typoTerms(db, terms.map((t) => t.slice(1, -2).replaceAll('""', '"')));
31702
31707
  if (fixed !== null) pList = porter(fixed);
31703
31708
  }
31704
31709
  const tm = trigramMatch(q);
31705
- const tList = tm === "" ? [] : stmt(db.raw, TRI_RANK).all({ ...filter, match: tm });
31710
+ const tList = tm === "" ? [] : stmt(db.raw, TRI_RANK).all({ ...filter2, match: tm });
31706
31711
  const fused = /* @__PURE__ */ new Map();
31707
31712
  pList.forEach((r, i) => fused.set(Number(r.rid), { r, s: 1 / (RRF_K + i + 1), full: Number(r.full ?? 0), p: i }));
31708
31713
  tList.forEach((r, i) => {
@@ -31800,7 +31805,7 @@ function timelineOrder(a, b) {
31800
31805
  return pa < pb ? -1 : pa > pb ? 1 : 0;
31801
31806
  }
31802
31807
  function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memory) {
31803
- const filter = {
31808
+ const filter2 = {
31804
31809
  scope,
31805
31810
  session_id: sessionId,
31806
31811
  worktree: ctx.worktree,
@@ -31810,7 +31815,7 @@ function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memor
31810
31815
  const reserved = DECISION_SOURCE;
31811
31816
  const off = limit - 1;
31812
31817
  const merged = [];
31813
- for (const e of db.raw.prepare(TL_EVENTS).all({ ...filter, after: from, off })) {
31818
+ for (const e of db.raw.prepare(TL_EVENTS).all({ ...filter2, after: from, off })) {
31814
31819
  merged.push({
31815
31820
  origin: "session",
31816
31821
  ts: Number(e.created_at),
@@ -31821,7 +31826,7 @@ function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memor
31821
31826
  text: e.body ?? e.key ?? e.path ?? ""
31822
31827
  });
31823
31828
  }
31824
- const srcRows = db.raw.prepare(TL_SOURCES).all({ ...filter, after: from, off, reserved });
31829
+ const srcRows = db.raw.prepare(TL_SOURCES).all({ ...filter2, after: from, off, reserved });
31825
31830
  if (srcRows.length > 0) {
31826
31831
  const bodies = /* @__PURE__ */ new Map();
31827
31832
  const ids = JSON.stringify(srcRows.map((r) => Number(r.id)));
@@ -31845,7 +31850,7 @@ function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memor
31845
31850
  const rows = merged.slice(0, end);
31846
31851
  if (rows.length === 0) return { rows, more: false };
31847
31852
  if (merged.length > end) return { rows, more: true };
31848
- const res = db.raw.prepare(TL_MORE).get({ ...filter, after: rows[rows.length - 1].ts, reserved });
31853
+ const res = db.raw.prepare(TL_MORE).get({ ...filter2, after: rows[rows.length - 1].ts, reserved });
31849
31854
  return { rows, more: Number(res.more) === 1 };
31850
31855
  }
31851
31856
  var RANK_DDL = `CREATE VIRTUAL TABLE r USING fts5(body, ${FTS_TOKENIZE}, content='')`;
@@ -32063,20 +32068,6 @@ function sweepDeadProjects(configDir) {
32063
32068
  return deleted;
32064
32069
  }
32065
32070
 
32066
- // src/prompt/_generated.ts
32067
- var INSTRUCTIONS = "context-mode keeps large output out of the conversation.\n\nWhen a step counts, sums, filters or finds something in over about 20 lines of data (logs, test or build output, big JSON or CSV, long files, web pages), use ctx_execute and print only the answer, not a raw Bash or Read result.\n\nA large tool result is indexed and cut to its best-matching parts; ctx_search finds the rest. A large file's Read is denied: use offset and limit, or ctx_execute with file set. Use normal tools for small output and edits.\n";
32068
- var TOOL_DESCRIPTIONS = Object.freeze({
32069
- ctx_execute: "Runs code in a sandboxed subprocess in the project directory (shell, powershell, javascript, typescript, python, or another runtime on PATH); only what the code prints comes back. For a large file, set `file` to its local path: the code gets it in the CTX_FILE environment variable. Set `intent` when output may be large: the matching sections come back and the full output is indexed for ctx_search. `timeoutMs` defaults to and caps at 600000; then the whole process tree is killed.\n",
32070
- ctx_batch: "Runs several shell commands, then answers several search queries over their combined output, in one call. Use it to collect facts from more than one command at once, for example test results plus recent commits, when you need specific answers rather than the full text. Returns the matching sections and a one-line footer.",
32071
- ctx_index: "Stores content so it can be searched later: a local file or folder (nested .gitignore files are respected), raw text, or a URL, which is fetched and converted to Markdown. Use it for documentation or large files you will query more than once, then use ctx_search instead of reading the content again. Returns the source label and how many chunks were stored.",
32072
- ctx_search: "Searches content stored with ctx_index and earlier sandbox output in this project. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.",
32073
- ctx_resume: "Returns a summary of up to 2 KB for this session: the last task and user request, files changed, open errors, and search terms for ctx_search. A large row is shown as a pointer line instead of its full text; call `ctx_resume(seq: N)` with that line's number to read the full row. Call it with no `seq` to get the state block on demand. Use it after the conversation was compacted or resumed, before you repeat earlier work.",
32074
- ctx_stats: "Reports how many bytes context-mode kept out of the conversation in this session and in this project, per agent, as a Markdown table. Show the table to the user as it is. Use it when the user asks what context-mode saved.",
32075
- ctx_doctor: "Checks this context-mode install and reports a table with one row per check: version, Node and node:sqlite, host config and hooks for this agent, MCP connection, project and worktree, database health, index contents, and hook timing. Each failed row names its cause and the fix in one line. It changes nothing. Use it when the user asks whether context-mode works, or after a context-mode error.",
32076
- ctx_upgrade: "Updates context-mode to the latest release for this agent and rewrites only context-mode's own entries in the host config. User entries and user settings such as hook timeouts are kept, and old entries are erased. Returns a table of what changed and whether a restart is needed. Use it only when the user asks to update context-mode.",
32077
- ctx_purge: "Deletes stored data: one session, one indexed source, or everything stored for this project. This cannot be undone. Use it only when the user asks to forget or reset data."
32078
- });
32079
-
32080
32071
  // node_modules/zod/v4/classic/external.js
32081
32072
  var external_exports = {};
32082
32073
  __export(external_exports, {
@@ -43216,6 +43207,20 @@ function date9(params) {
43216
43207
  // node_modules/zod/v4/classic/external.js
43217
43208
  config3(en_default3());
43218
43209
 
43210
+ // src/prompt/_generated.ts
43211
+ var INSTRUCTIONS = "context-mode keeps large output out of the conversation.\n\nWhen a step counts, sums, filters or finds something in over about 20 lines of data (logs, test or build output, big JSON or CSV, long files, web pages), use ctx_execute and print only the answer, not a raw Bash or Read result.\n\nA large tool result is indexed and cut to its best-matching parts; ctx_search finds the rest. A large file's Read is denied: use offset and limit, or ctx_execute with file set. Use normal tools for small output and edits.\n";
43212
+ var TOOL_DESCRIPTIONS = Object.freeze({
43213
+ ctx_execute: 'Example: `ctx_execute({language:"shell",code:"git log --oneline -5"})`. Required: language, code.\nRuns code in a sandboxed subprocess in the project directory (shell, powershell, javascript, typescript, python, or another runtime on PATH); only what the code prints comes back. For a large file, set `file` to its local path: the code gets it in the CTX_FILE environment variable. Set `intent` when output may be large: the matching sections come back and the full output is indexed for ctx_search. `timeoutMs` defaults to and caps at 600000; then the whole process tree is killed.',
43214
+ ctx_batch: 'Example: `ctx_batch({commands:["git log --oneline -5"],queries:["recent changes"]})`. Required: commands, queries.\nRuns several shell commands, then answers several search queries over their combined output, in one call. Use it to collect facts from more than one command at once, for example test results plus recent commits, when you need specific answers rather than the full text. Returns the matching sections and a one-line footer.',
43215
+ ctx_index: 'Example: `ctx_index({path:"docs/api.md"})`. Required: one of path, content, url.\nStores content so it can be searched later: a local file or folder (nested .gitignore files are respected), raw text, or a URL, which is fetched and converted to Markdown. Use it for documentation or large files you will query more than once, then use ctx_search instead of reading the content again. Returns the source label and how many chunks were stored.',
43216
+ ctx_search: 'Example: `ctx_search({queries:["auth middleware"]})`. Required: queries.\nSearches content stored with ctx_index and earlier sandbox output in this project. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.',
43217
+ ctx_resume: "Example: `ctx_resume({})`. Required: none.\nReturns a summary of up to 2 KB for this session: the last task and user request, files changed, open errors, and search terms for ctx_search. A large row is shown as a pointer line instead of its full text; call `ctx_resume(seq: N)` with that line's number to read the full row. Call it with no `seq` to get the state block on demand. Use it after the conversation was compacted or resumed, before you repeat earlier work.",
43218
+ ctx_stats: "Example: `ctx_stats({})`. Required: none.\nReports how many bytes context-mode kept out of the conversation in this session and in this project, per agent, as a Markdown table. Show the table to the user as it is. Use it when the user asks what context-mode saved.",
43219
+ ctx_doctor: "Example: `ctx_doctor({})`. Required: none.\nChecks this context-mode install and reports a table with one row per check: version, Node and node:sqlite, host config and hooks for this agent, MCP connection, project and worktree, database health, index contents, and hook timing. Each failed row names its cause and the fix in one line. It changes nothing. Use it when the user asks whether context-mode works, or after a context-mode error.",
43220
+ ctx_upgrade: "Example: `ctx_upgrade({})`. Required: none.\nUpdates context-mode to the latest release for this agent and rewrites only context-mode's own entries in the host config. User entries and user settings such as hook timeouts are kept, and old entries are erased. Returns a table of what changed and whether a restart is needed. Use it only when the user asks to update context-mode.",
43221
+ ctx_purge: 'Example: `ctx_purge({source:"old-docs"})`. Required: one of session, source, project.\nDeletes stored data: one session, one indexed source, or everything stored for this project. This cannot be undone. Use it only when the user asks to forget or reset data.'
43222
+ });
43223
+
43219
43224
  // src/core/index/chunk.ts
43220
43225
  var VOID_TAGS = /* @__PURE__ */ new Set([
43221
43226
  "area",
@@ -43308,10 +43313,10 @@ function lineBlocks(src, md) {
43308
43313
  heading = void 0;
43309
43314
  fenceInfo = void 0;
43310
43315
  };
43311
- const add = (from, to, table) => {
43316
+ const add = (from, to, table2) => {
43312
43317
  if (start < 0) start = from;
43313
43318
  end = to;
43314
- inTable = table;
43319
+ inTable = table2;
43315
43320
  };
43316
43321
  let pos = 0;
43317
43322
  while (pos <= src.length) {
@@ -43332,9 +43337,9 @@ function lineBlocks(src, md) {
43332
43337
  } else {
43333
43338
  const opener = md ? fenceOf(line) : "";
43334
43339
  const head = md && opener === "" ? headingOf(line) : void 0;
43335
- const table = md && opener === "" && head === void 0 && line.includes("|");
43336
- if (md && start >= 0 && (table !== inTable || opener !== "" || head !== void 0)) close();
43337
- add(pos, eol, table);
43340
+ const table2 = md && opener === "" && head === void 0 && line.includes("|");
43341
+ if (md && start >= 0 && (table2 !== inTable || opener !== "" || head !== void 0)) close();
43342
+ add(pos, eol, table2);
43338
43343
  fence = opener;
43339
43344
  if (opener !== "") fenceInfo = { fence: opener, openEnd: eol, closeStart: -1 };
43340
43345
  if (head !== void 0) {
@@ -43903,15 +43908,19 @@ function callText(queries, scope, source, cursor) {
43903
43908
  function decisionQueries(input) {
43904
43909
  return input.source === DECISION_SOURCE && input.queries.length === 0 ? [""] : input.queries;
43905
43910
  }
43911
+ function pageSize(input) {
43912
+ return input.source === DECISION_SOURCE ? SEARCH_PAGE_SIZE : SEARCH_REPLY_HITS;
43913
+ }
43906
43914
  function page(db, q, input, scope, ctx, offset) {
43915
+ const size = pageSize(input);
43907
43916
  if (input.source === DECISION_SOURCE && q.trim() === "") {
43908
- return ftsListSource(db, DECISION_SOURCE, scope, ctx.project, ctx.sessionId, SEARCH_PAGE_SIZE, offset);
43917
+ return ftsListSource(db, DECISION_SOURCE, scope, ctx.project, ctx.sessionId, size, offset);
43909
43918
  }
43910
- const hits = ftsQuery(db, q, scope, ctx.project, ctx.sessionId, SEARCH_PAGE_SIZE, offset, input.source);
43919
+ const hits = ftsQuery(db, q, scope, ctx.project, ctx.sessionId, size, offset, input.source);
43911
43920
  if (hits.length > 0 || input.source === void 0) return hits;
43912
43921
  const any3 = offset === 0 ? hits : ftsQuery(db, q, scope, ctx.project, ctx.sessionId, 1, 0, input.source);
43913
43922
  if (any3.length > 0) return hits;
43914
- return ftsListSource(db, input.source, scope, ctx.project, ctx.sessionId, SEARCH_PAGE_SIZE, offset);
43923
+ return ftsListSource(db, input.source, scope, ctx.project, ctx.sessionId, size, offset);
43915
43924
  }
43916
43925
  var JSON_ROWS_PAGE = 5;
43917
43926
  var JSON_SOURCE_MAX_BYTES = 8 * 1024 * 1024;
@@ -43955,12 +43964,13 @@ function jsonRowsReply(db, input, scope, ctx) {
43955
43964
  function relevance(db, given, scope, ctx) {
43956
43965
  const input = { ...given, queries: decisionQueries(given) };
43957
43966
  const offset = input.offset ?? 0;
43967
+ const size = pageSize(input);
43958
43968
  const seen = /* @__PURE__ */ new Set();
43959
43969
  const entries = [];
43960
43970
  const full = /* @__PURE__ */ new Set();
43961
43971
  input.queries.forEach((q, qi) => {
43962
43972
  const hits = page(db, q, input, scope, ctx, offset);
43963
- if (hits.length === SEARCH_PAGE_SIZE) full.add(qi);
43973
+ if (hits.length === size) full.add(qi);
43964
43974
  hits.forEach((hit, i) => {
43965
43975
  const key = hit.sourceId + ":" + hit.ord;
43966
43976
  if (seen.has(key)) return;
@@ -43971,7 +43981,7 @@ function relevance(db, given, scope, ctx) {
43971
43981
  if (entries.length === 0) return zeroHits(db, scope, ctx, input.source);
43972
43982
  const moreLine3 = (q, pos) => "More: " + callText([q], scope, input.source, "offset:" + pos);
43973
43983
  let reserve = 0;
43974
- for (const q of input.queries) reserve += bytes2(moreLine3(q, offset + SEARCH_PAGE_SIZE)) + 1;
43984
+ for (const q of input.queries) reserve += bytes2(moreLine3(q, offset + size)) + 1;
43975
43985
  const lines = [];
43976
43986
  const more = [];
43977
43987
  let used = 0;
@@ -43995,7 +44005,7 @@ function relevance(db, given, scope, ctx) {
43995
44005
  lines.push(line);
43996
44006
  used += bytes2(line) + 1;
43997
44007
  }
43998
- if (!stopped && full.has(qi)) more.push(moreLine3(q, offset + SEARCH_PAGE_SIZE));
44008
+ if (!stopped && full.has(qi)) more.push(moreLine3(q, offset + size));
43999
44009
  });
44000
44010
  return reply(lines.concat(more).join("\n"), false);
44001
44011
  }
@@ -47098,17 +47108,17 @@ function generateConvertTOMLValue(convertValue) {
47098
47108
  return baseTable;
47099
47109
  },
47100
47110
  TOMLTable(node3, baseTable = {}) {
47101
- const table = getTable(baseTable, resolveValue(node3.key), node3.kind === "array");
47102
- for (const body of node3.body) resolveValue(body, table);
47111
+ const table2 = getTable(baseTable, resolveValue(node3.key), node3.kind === "array");
47112
+ for (const body of node3.body) resolveValue(body, table2);
47103
47113
  return baseTable;
47104
47114
  },
47105
47115
  TOMLArray(node3) {
47106
47116
  return node3.elements.map((e) => resolveValue(e));
47107
47117
  },
47108
47118
  TOMLInlineTable(node3) {
47109
- const table = {};
47110
- for (const body of node3.body) resolveValue(body, table);
47111
- return table;
47119
+ const table2 = {};
47120
+ for (const body of node3.body) resolveValue(body, table2);
47121
+ return table2;
47112
47122
  },
47113
47123
  TOMLKey(node3) {
47114
47124
  return node3.keys.map((key) => resolveValue(key));
@@ -47674,8 +47684,8 @@ function listTarget(key, own4, v1, alt = []) {
47674
47684
  return {
47675
47685
  key: [key],
47676
47686
  next(current) {
47677
- const list2 = Array.isArray(current) ? current.filter((x) => x !== v1) : [];
47678
- return list2.includes(own4) || alt.some((a) => list2.includes(a)) ? list2 : [...list2, own4];
47687
+ const list3 = Array.isArray(current) ? current.filter((x) => x !== v1) : [];
47688
+ return list3.includes(own4) || alt.some((a) => list3.includes(a)) ? list3 : [...list3, own4];
47679
47689
  }
47680
47690
  };
47681
47691
  }
@@ -49349,6 +49359,3807 @@ async function safeFetch(url4, signal) {
49349
49359
  }
49350
49360
  }
49351
49361
 
49362
+ // node_modules/entities/dist/decode-codepoint.js
49363
+ var c1 = [
49364
+ 8364,
49365
+ 0,
49366
+ 8218,
49367
+ 402,
49368
+ 8222,
49369
+ 8230,
49370
+ 8224,
49371
+ 8225,
49372
+ 710,
49373
+ 8240,
49374
+ 352,
49375
+ 8249,
49376
+ 338,
49377
+ 0,
49378
+ 381,
49379
+ 0,
49380
+ 0,
49381
+ 8216,
49382
+ 8217,
49383
+ 8220,
49384
+ 8221,
49385
+ 8226,
49386
+ 8211,
49387
+ 8212,
49388
+ 732,
49389
+ 8482,
49390
+ 353,
49391
+ 8250,
49392
+ 339,
49393
+ 0,
49394
+ 382,
49395
+ 376
49396
+ ];
49397
+ function isInvalidCodePoint(codePoint) {
49398
+ return codePoint === 0 || codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111;
49399
+ }
49400
+ function replaceCodePoint(codePoint) {
49401
+ if (isInvalidCodePoint(codePoint)) {
49402
+ return 65533;
49403
+ }
49404
+ if (codePoint >= 128 && codePoint <= 159) {
49405
+ return c1[codePoint - 128] || codePoint;
49406
+ }
49407
+ return codePoint;
49408
+ }
49409
+ function replaceCodePointXML(codePoint) {
49410
+ return isInvalidCodePoint(codePoint) ? 65533 : codePoint;
49411
+ }
49412
+
49413
+ // node_modules/entities/dist/internal/decode-shared.js
49414
+ var BASE91_INVERSE = /* @__PURE__ */ (() => {
49415
+ const table2 = new Uint8Array(127);
49416
+ let code = 0;
49417
+ for (let char = 33; char <= 126; char++) {
49418
+ if (char !== 34 && char !== 36 && char !== 92) {
49419
+ table2[char] = code++;
49420
+ }
49421
+ }
49422
+ return table2;
49423
+ })();
49424
+ function decodeTrieDict(input, resultLength, atomCount, dict1AtomCount, ngramCount, dictSize) {
49425
+ const base = 91;
49426
+ const inputLength = input.length;
49427
+ const twoCharBias = dictSize * (base - 1);
49428
+ let pos = 0;
49429
+ const readSlotCode = () => {
49430
+ const c12 = BASE91_INVERSE[input.charCodeAt(pos++)];
49431
+ return c12 < dictSize ? c12 : c12 * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
49432
+ };
49433
+ const dict2AtomCount = atomCount - dict1AtomCount;
49434
+ const slotCount = atomCount + ngramCount;
49435
+ const single = new Int32Array(slotCount);
49436
+ single.fill(-1, dict1AtomCount, dictSize);
49437
+ single.fill(-1, dictSize + dict2AtomCount, slotCount);
49438
+ const start = new Int32Array(slotCount);
49439
+ const length = new Int32Array(slotCount);
49440
+ function decodeDelta(count, off) {
49441
+ let previous = 0;
49442
+ let slot = off;
49443
+ const end = off + count;
49444
+ while (slot < end) {
49445
+ const code = BASE91_INVERSE[input.charCodeAt(pos++)];
49446
+ if (code < 89) {
49447
+ previous += code;
49448
+ single[slot++] = previous;
49449
+ } else if (code === 89) {
49450
+ let runLength = BASE91_INVERSE[input.charCodeAt(pos++)] + 2;
49451
+ while (runLength--)
49452
+ single[slot++] = ++previous;
49453
+ } else {
49454
+ const next = BASE91_INVERSE[input.charCodeAt(pos++)];
49455
+ previous += 89 + // eslint-disable-next-line unicorn/prefer-minimal-ternary -- branches read a different number of side-effecting input bytes
49456
+ (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++)]);
49457
+ single[slot++] = previous;
49458
+ }
49459
+ }
49460
+ }
49461
+ decodeDelta(dict1AtomCount, 0);
49462
+ decodeDelta(dict2AtomCount, dictSize);
49463
+ const references = new Int32Array(ngramCount * 2);
49464
+ let poolSize = 0;
49465
+ let ngramIndex = 0;
49466
+ function readNgramReferences(count, startSlot) {
49467
+ for (let index = 0; index < count; index++) {
49468
+ const slot = startSlot + index;
49469
+ const a = readSlotCode();
49470
+ const b = readSlotCode();
49471
+ references[ngramIndex * 2] = a;
49472
+ references[ngramIndex * 2 + 1] = b;
49473
+ ngramIndex += 1;
49474
+ start[slot] = poolSize;
49475
+ const entryLength = (single[a] < 0 ? length[a] : 1) + (single[b] < 0 ? length[b] : 1);
49476
+ length[slot] = entryLength;
49477
+ poolSize += entryLength;
49478
+ }
49479
+ }
49480
+ readNgramReferences(ngramCount - dictSize + dict1AtomCount, dictSize + dict2AtomCount);
49481
+ readNgramReferences(dictSize - dict1AtomCount, dict1AtomCount);
49482
+ const pool = new Uint16Array(poolSize);
49483
+ let write = 0;
49484
+ for (let index = 0; index < ngramIndex; index++) {
49485
+ for (let half = 0; half < 2; half++) {
49486
+ const source = references[index * 2 + half];
49487
+ const value = single[source];
49488
+ if (value < 0) {
49489
+ let read = start[source];
49490
+ const readEnd = read + length[source];
49491
+ while (read < readEnd)
49492
+ pool[write++] = pool[read++];
49493
+ } else {
49494
+ pool[write++] = value;
49495
+ }
49496
+ }
49497
+ }
49498
+ const out = new Uint16Array(resultLength);
49499
+ let outIndex = 0;
49500
+ while (pos < inputLength) {
49501
+ let slot = BASE91_INVERSE[input.charCodeAt(pos++)];
49502
+ if (slot >= dictSize) {
49503
+ slot = slot * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
49504
+ }
49505
+ const value = single[slot];
49506
+ if (value < 0) {
49507
+ let read = start[slot];
49508
+ const readEnd = read + length[slot];
49509
+ while (read < readEnd)
49510
+ out[outIndex++] = pool[read++];
49511
+ } else {
49512
+ out[outIndex++] = value;
49513
+ }
49514
+ }
49515
+ return out;
49516
+ }
49517
+
49518
+ // node_modules/entities/dist/generated/decode-data-html.js
49519
+ var 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~!?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C(0a)a6#B+a%!sQ[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);
49520
+
49521
+ // node_modules/entities/dist/generated/decode-data-xml.js
49522
+ var xmlDecodeTree = /* @__PURE__ */ new Uint16Array([
49523
+ 512,
49524
+ 26465,
49525
+ 29036,
49526
+ 7,
49527
+ 0,
49528
+ 2,
49529
+ 4,
49530
+ 116,
49531
+ 24638,
49532
+ 116,
49533
+ 24636,
49534
+ 8693,
49535
+ 29807,
49536
+ 24610,
49537
+ 621,
49538
+ 1,
49539
+ 0,
49540
+ 0,
49541
+ 3,
49542
+ 112,
49543
+ 24614,
49544
+ 111,
49545
+ 115,
49546
+ 24615
49547
+ ]);
49548
+
49549
+ // node_modules/entities/dist/internal/bin-trie-flags.js
49550
+ var BinTrieFlags;
49551
+ (function(BinTrieFlags2) {
49552
+ BinTrieFlags2[BinTrieFlags2["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
49553
+ BinTrieFlags2[BinTrieFlags2["FLAG13"] = 8192] = "FLAG13";
49554
+ BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
49555
+ BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
49556
+ BinTrieFlags2[BinTrieFlags2["VALUE_MASK"] = 8191] = "VALUE_MASK";
49557
+ })(BinTrieFlags || (BinTrieFlags = {}));
49558
+
49559
+ // node_modules/entities/dist/decode.js
49560
+ var CharCodes;
49561
+ (function(CharCodes3) {
49562
+ CharCodes3[CharCodes3["AMP"] = 38] = "AMP";
49563
+ CharCodes3[CharCodes3["NUM"] = 35] = "NUM";
49564
+ CharCodes3[CharCodes3["SEMI"] = 59] = "SEMI";
49565
+ CharCodes3[CharCodes3["EQUALS"] = 61] = "EQUALS";
49566
+ CharCodes3[CharCodes3["ZERO"] = 48] = "ZERO";
49567
+ CharCodes3[CharCodes3["NINE"] = 57] = "NINE";
49568
+ CharCodes3[CharCodes3["LOWER_A"] = 97] = "LOWER_A";
49569
+ CharCodes3[CharCodes3["LOWER_X"] = 120] = "LOWER_X";
49570
+ })(CharCodes || (CharCodes = {}));
49571
+ var TO_LOWER_BIT = 32;
49572
+ function isNumber2(code) {
49573
+ return code - CharCodes.ZERO >>> 0 <= 9;
49574
+ }
49575
+ function isHexadecimalCharacter(code) {
49576
+ return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 5;
49577
+ }
49578
+ function isAlpha(code) {
49579
+ return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 25;
49580
+ }
49581
+ function isEntityInAttributeInvalidEnd(code) {
49582
+ return code === CharCodes.EQUALS || isAlpha(code) || isNumber2(code);
49583
+ }
49584
+ var EntityDecoderState;
49585
+ (function(EntityDecoderState2) {
49586
+ EntityDecoderState2[EntityDecoderState2["EntityStart"] = 0] = "EntityStart";
49587
+ EntityDecoderState2[EntityDecoderState2["NumericStart"] = 1] = "NumericStart";
49588
+ EntityDecoderState2[EntityDecoderState2["NumericDecimal"] = 2] = "NumericDecimal";
49589
+ EntityDecoderState2[EntityDecoderState2["NumericHex"] = 3] = "NumericHex";
49590
+ EntityDecoderState2[EntityDecoderState2["NamedEntity"] = 4] = "NamedEntity";
49591
+ })(EntityDecoderState || (EntityDecoderState = {}));
49592
+ var DecodingMode;
49593
+ (function(DecodingMode2) {
49594
+ DecodingMode2[DecodingMode2["Legacy"] = 0] = "Legacy";
49595
+ DecodingMode2[DecodingMode2["Strict"] = 1] = "Strict";
49596
+ DecodingMode2[DecodingMode2["Attribute"] = 2] = "Attribute";
49597
+ })(DecodingMode || (DecodingMode = {}));
49598
+ var EntityDecoder = class {
49599
+ decodeTree;
49600
+ emitCodePoint;
49601
+ errors;
49602
+ /** The current state of the decoder. */
49603
+ state = EntityDecoderState.EntityStart;
49604
+ /** Characters that were consumed while parsing an entity. */
49605
+ consumed = 1;
49606
+ /**
49607
+ * The result of the entity.
49608
+ *
49609
+ * For named entities: the trie index of the best legacy match so far
49610
+ * (0 = none). For numeric entities: the accumulated code point.
49611
+ */
49612
+ result = 0;
49613
+ /** The current index in the decode tree. */
49614
+ treeIndex = 0;
49615
+ /**
49616
+ * Characters consumed since the last recorded legacy match, plus one.
49617
+ * Invariant at the top of the `stateNamedEntity` loop: `excess` equals
49618
+ * the number of unrecorded consumed characters + 1.
49619
+ */
49620
+ // biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive (read via destructuring)
49621
+ excess = 1;
49622
+ /** The mode in which the decoder is operating. */
49623
+ decodeMode = DecodingMode.Strict;
49624
+ /** The number of characters that have been consumed in the current run. */
49625
+ // biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive
49626
+ runConsumed = 0;
49627
+ constructor(decodeTree, emitCodePoint, errors) {
49628
+ this.decodeTree = decodeTree;
49629
+ this.emitCodePoint = emitCodePoint;
49630
+ this.errors = errors;
49631
+ }
49632
+ /**
49633
+ * Resets the instance to make it reusable.
49634
+ * @param decodeMode Entity decoding mode to use.
49635
+ */
49636
+ startEntity(decodeMode) {
49637
+ this.decodeMode = decodeMode;
49638
+ this.state = EntityDecoderState.EntityStart;
49639
+ this.result = 0;
49640
+ this.treeIndex = 0;
49641
+ this.excess = 1;
49642
+ this.consumed = 1;
49643
+ this.runConsumed = 0;
49644
+ }
49645
+ /**
49646
+ * Write an entity to the decoder. This can be called multiple times with partial entities.
49647
+ * If the entity is incomplete, the decoder will return -1.
49648
+ *
49649
+ * Mirrors the non-streaming `decodeWithTrie`, but with the ability to stop decoding if the
49650
+ * entity is incomplete, and resume when the next string is written.
49651
+ * @param input The string containing the entity (or a continuation of the entity).
49652
+ * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
49653
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
49654
+ */
49655
+ write(input, offset) {
49656
+ switch (this.state) {
49657
+ case EntityDecoderState.EntityStart: {
49658
+ if (input.charCodeAt(offset) === CharCodes.NUM) {
49659
+ this.state = EntityDecoderState.NumericStart;
49660
+ this.consumed += 1;
49661
+ return this.stateNumericStart(input, offset + 1);
49662
+ }
49663
+ this.state = EntityDecoderState.NamedEntity;
49664
+ return this.stateNamedEntity(input, offset);
49665
+ }
49666
+ case EntityDecoderState.NumericStart: {
49667
+ return this.stateNumericStart(input, offset);
49668
+ }
49669
+ case EntityDecoderState.NumericDecimal: {
49670
+ return this.stateNumericDecimal(input, offset);
49671
+ }
49672
+ case EntityDecoderState.NumericHex: {
49673
+ return this.stateNumericHex(input, offset);
49674
+ }
49675
+ default: {
49676
+ return this.stateNamedEntity(input, offset);
49677
+ }
49678
+ }
49679
+ }
49680
+ /**
49681
+ * Switches between the numeric decimal and hexadecimal states.
49682
+ *
49683
+ * Equivalent to the `Numeric character reference state` in the HTML spec.
49684
+ * @param input The string containing the entity (or a continuation of the entity).
49685
+ * @param offset The current offset.
49686
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
49687
+ */
49688
+ // eslint-disable-next-line unicorn/consistent-class-member-order
49689
+ stateNumericStart(input, offset) {
49690
+ if (offset >= input.length) {
49691
+ return -1;
49692
+ }
49693
+ if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
49694
+ this.state = EntityDecoderState.NumericHex;
49695
+ this.consumed += 1;
49696
+ return this.stateNumericHex(input, offset + 1);
49697
+ }
49698
+ this.state = EntityDecoderState.NumericDecimal;
49699
+ return this.stateNumericDecimal(input, offset);
49700
+ }
49701
+ /**
49702
+ * Parses a hexadecimal numeric entity.
49703
+ *
49704
+ * Equivalent to the `Hexademical character reference state` in the HTML
49705
+ * spec. Digit parsing matches the hex loop in `parseNumericEntity`.
49706
+ * The accumulated value is preserved for numeric validation callbacks.
49707
+ * @param input The string containing the entity (or a continuation of the entity).
49708
+ * @param offset The current offset.
49709
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
49710
+ */
49711
+ stateNumericHex(input, offset) {
49712
+ const inputLength = input.length;
49713
+ let { result } = this;
49714
+ let { consumed } = this;
49715
+ while (offset < inputLength) {
49716
+ const char = input.charCodeAt(offset);
49717
+ if (isNumber2(char) || isHexadecimalCharacter(char)) {
49718
+ const digit = char <= CharCodes.NINE ? char - CharCodes.ZERO : (char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10;
49719
+ result = result * 16 + digit;
49720
+ consumed += 1;
49721
+ offset += 1;
49722
+ } else {
49723
+ this.result = result;
49724
+ this.consumed = consumed;
49725
+ return this.emitNumericEntity(char, 3);
49726
+ }
49727
+ }
49728
+ this.result = result;
49729
+ this.consumed = consumed;
49730
+ return -1;
49731
+ }
49732
+ /**
49733
+ * Parses a decimal numeric entity.
49734
+ *
49735
+ * Equivalent to the `Decimal character reference state` in the HTML
49736
+ * spec. Digit parsing matches the decimal loop in `parseNumericEntity`.
49737
+ * The accumulated value is preserved for numeric validation callbacks.
49738
+ * @param input The string containing the entity (or a continuation of the entity).
49739
+ * @param offset The current offset.
49740
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
49741
+ */
49742
+ stateNumericDecimal(input, offset) {
49743
+ const inputLength = input.length;
49744
+ let { result } = this;
49745
+ let { consumed } = this;
49746
+ while (offset < inputLength) {
49747
+ const digit = input.charCodeAt(offset) - CharCodes.ZERO;
49748
+ if (digit >>> 0 > 9) {
49749
+ this.result = result;
49750
+ this.consumed = consumed;
49751
+ return this.emitNumericEntity(digit + CharCodes.ZERO, 2);
49752
+ }
49753
+ result = result * 10 + digit;
49754
+ consumed += 1;
49755
+ offset += 1;
49756
+ }
49757
+ this.result = result;
49758
+ this.consumed = consumed;
49759
+ return -1;
49760
+ }
49761
+ /**
49762
+ * Validate and emit a numeric entity.
49763
+ *
49764
+ * Implements the logic from the `Hexademical character reference start
49765
+ * state` and `Numeric character reference end state` in the HTML spec.
49766
+ * @param lastCp The last code point of the entity. Used to see if the
49767
+ * entity was terminated with a semicolon.
49768
+ * @param expectedLength The minimum number of characters that should be
49769
+ * consumed. Used to validate that at least one digit
49770
+ * was consumed.
49771
+ * @returns The number of characters that were consumed.
49772
+ */
49773
+ emitNumericEntity(lastCp, expectedLength) {
49774
+ if (this.consumed <= expectedLength) {
49775
+ this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
49776
+ return 0;
49777
+ }
49778
+ if (lastCp === CharCodes.SEMI) {
49779
+ this.consumed += 1;
49780
+ } else if (this.decodeMode === DecodingMode.Strict) {
49781
+ return 0;
49782
+ }
49783
+ this.emitCodePoint((this.decodeTree === xmlDecodeTree ? replaceCodePointXML : replaceCodePoint)(this.result), this.consumed);
49784
+ if (this.errors) {
49785
+ if (lastCp !== CharCodes.SEMI) {
49786
+ this.errors.missingSemicolonAfterCharacterReference();
49787
+ }
49788
+ this.errors.validateNumericCharacterReference(this.result);
49789
+ }
49790
+ return this.consumed;
49791
+ }
49792
+ /**
49793
+ * Flush locally-tracked walk state back to the fields, then emit the
49794
+ * recorded legacy match or reject (cold path — at most once per
49795
+ * entity). Called after failed navigation (leaf node, branch miss, or
49796
+ * compact-run mismatch). In attribute mode, reject if no legacy was
49797
+ * recorded at the current node, if we descended past it, or if the
49798
+ * pending input character is an invalid attribute terminator.
49799
+ * @param consumed Locally-tracked consumed count.
49800
+ * @param excess Locally-tracked excess count.
49801
+ * @param char Pending input character (may be the mismatching char).
49802
+ * @param valueLength Value length at the current trie node.
49803
+ */
49804
+ flushAndEmitLegacyOrReject(consumed, excess, char, valueLength) {
49805
+ this.consumed = consumed;
49806
+ this.excess = excess;
49807
+ return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || excess > 1 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
49808
+ }
49809
+ /**
49810
+ * Parses a named entity.
49811
+ *
49812
+ * Equivalent to the `Named character reference state` in the HTML spec.
49813
+ * @param input The string containing the entity (or a continuation of the entity).
49814
+ * @param offset The current offset.
49815
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
49816
+ */
49817
+ stateNamedEntity(input, offset) {
49818
+ const { decodeTree } = this;
49819
+ const inputLength = input.length;
49820
+ const isStrict = this.decodeMode === DecodingMode.Strict;
49821
+ let { treeIndex } = this;
49822
+ let { excess } = this;
49823
+ let { consumed } = this;
49824
+ let current = decodeTree[treeIndex];
49825
+ while (offset < inputLength) {
49826
+ while ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === 0 && (current & BinTrieFlags.JUMP_TABLE) !== 0) {
49827
+ const char2 = input.charCodeAt(offset);
49828
+ const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
49829
+ const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
49830
+ if (branchCount === 0) {
49831
+ if (char2 !== jumpOffset) {
49832
+ return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
49833
+ }
49834
+ treeIndex += 1;
49835
+ } else {
49836
+ const slot = char2 - jumpOffset;
49837
+ if (slot >>> 0 >= branchCount) {
49838
+ return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
49839
+ }
49840
+ const stored = decodeTree[treeIndex + 1 + slot];
49841
+ if (stored === 0) {
49842
+ return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
49843
+ }
49844
+ treeIndex = treeIndex + branchCount + stored & 65535;
49845
+ }
49846
+ current = decodeTree[treeIndex];
49847
+ offset += 1;
49848
+ excess += 1;
49849
+ if (offset >= inputLength)
49850
+ break;
49851
+ }
49852
+ if (offset >= inputLength)
49853
+ break;
49854
+ if ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === BinTrieFlags.FLAG13) {
49855
+ const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
49856
+ let { runConsumed } = this;
49857
+ if (runConsumed === 0) {
49858
+ const char2 = input.charCodeAt(offset);
49859
+ if (char2 !== (current & BinTrieFlags.JUMP_TABLE)) {
49860
+ return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
49861
+ }
49862
+ offset += 1;
49863
+ excess += 1;
49864
+ runConsumed = 1;
49865
+ }
49866
+ while (runConsumed < runLength) {
49867
+ if (offset >= inputLength) {
49868
+ this.treeIndex = treeIndex;
49869
+ this.excess = excess;
49870
+ this.consumed = consumed;
49871
+ this.runConsumed = runConsumed;
49872
+ return -1;
49873
+ }
49874
+ const charIndexInPacked = runConsumed - 1;
49875
+ const packedWord = decodeTree[treeIndex + 1 + (charIndexInPacked >> 1)];
49876
+ const expectedChar = packedWord >> ((charIndexInPacked & 1) << 3) & 255;
49877
+ const char2 = input.charCodeAt(offset);
49878
+ if (char2 !== expectedChar) {
49879
+ this.runConsumed = 0;
49880
+ return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
49881
+ }
49882
+ offset += 1;
49883
+ excess += 1;
49884
+ runConsumed += 1;
49885
+ }
49886
+ this.runConsumed = 0;
49887
+ treeIndex += 1 + (runLength >> 1);
49888
+ current = decodeTree[treeIndex];
49889
+ continue;
49890
+ }
49891
+ const valueLength = current >>> 14;
49892
+ const char = input.charCodeAt(offset);
49893
+ if (valueLength !== 0) {
49894
+ if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
49895
+ this.result = treeIndex;
49896
+ consumed += excess - 1;
49897
+ excess = 1;
49898
+ }
49899
+ if (char === CharCodes.SEMI) {
49900
+ return this.emitNamedEntityData(treeIndex, valueLength, consumed + excess);
49901
+ }
49902
+ if (valueLength === 1) {
49903
+ return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);
49904
+ }
49905
+ }
49906
+ const next = determineBranch(decodeTree, current, treeIndex + (valueLength || 1), char);
49907
+ if (next < 0) {
49908
+ return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);
49909
+ }
49910
+ treeIndex = next;
49911
+ current = decodeTree[treeIndex];
49912
+ offset += 1;
49913
+ excess += 1;
49914
+ }
49915
+ if (!isStrict && current >>> 14 !== 0 && (current & BinTrieFlags.FLAG13) === 0) {
49916
+ this.result = treeIndex;
49917
+ consumed += excess - 1;
49918
+ excess = 1;
49919
+ }
49920
+ this.treeIndex = treeIndex;
49921
+ this.excess = excess;
49922
+ this.consumed = consumed;
49923
+ return -1;
49924
+ }
49925
+ /**
49926
+ * Emit a named entity that was not terminated with a semicolon.
49927
+ * @returns The number of characters consumed.
49928
+ */
49929
+ emitNotTerminatedNamedEntity() {
49930
+ const { result, decodeTree } = this;
49931
+ const valueLength = decodeTree[result] >>> 14;
49932
+ this.emitNamedEntityData(result, valueLength, this.consumed);
49933
+ this.errors?.missingSemicolonAfterCharacterReference();
49934
+ return this.consumed;
49935
+ }
49936
+ /**
49937
+ * Emit a named entity.
49938
+ * @param result The index of the entity in the decode tree.
49939
+ * @param valueLength Encoded value length (header plus any value words).
49940
+ * @param consumed The number of characters consumed.
49941
+ * @returns The number of characters consumed.
49942
+ */
49943
+ emitNamedEntityData(result, valueLength, consumed) {
49944
+ const { decodeTree } = this;
49945
+ this.emitCodePoint(valueLength === 1 ? decodeTree[result] & BinTrieFlags.VALUE_MASK : decodeTree[result + 1], consumed);
49946
+ if (valueLength === 3) {
49947
+ this.emitCodePoint(decodeTree[result + 2], consumed);
49948
+ }
49949
+ return consumed;
49950
+ }
49951
+ /**
49952
+ * Signal to the parser that the end of the input was reached.
49953
+ *
49954
+ * Remaining data will be emitted and relevant errors will be produced.
49955
+ * @returns The number of characters consumed.
49956
+ */
49957
+ end() {
49958
+ switch (this.state) {
49959
+ case EntityDecoderState.NamedEntity: {
49960
+ return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
49961
+ }
49962
+ // Otherwise, emit a numeric entity if we have one.
49963
+ case EntityDecoderState.NumericDecimal: {
49964
+ return this.emitNumericEntity(0, 2);
49965
+ }
49966
+ case EntityDecoderState.NumericHex: {
49967
+ return this.emitNumericEntity(0, 3);
49968
+ }
49969
+ case EntityDecoderState.NumericStart: {
49970
+ this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
49971
+ return 0;
49972
+ }
49973
+ default: {
49974
+ return 0;
49975
+ }
49976
+ }
49977
+ }
49978
+ };
49979
+ function determineBranch(decodeTree, current, nodeIndex, char) {
49980
+ const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
49981
+ const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
49982
+ if (jumpOffset) {
49983
+ if (branchCount === 0) {
49984
+ return char === jumpOffset ? nodeIndex : -1;
49985
+ }
49986
+ const slot = char - jumpOffset;
49987
+ if (slot >>> 0 >= branchCount)
49988
+ return -1;
49989
+ const stored = decodeTree[nodeIndex + slot];
49990
+ return stored === 0 ? -1 : nodeIndex + branchCount + stored - 1 & 65535;
49991
+ }
49992
+ if (branchCount === 0)
49993
+ return -1;
49994
+ const packedKeySlots = branchCount + 1 >> 1;
49995
+ const branchEnd = nodeIndex + packedKeySlots + branchCount;
49996
+ for (let index = 0; index < branchCount; index++) {
49997
+ const packed = decodeTree[nodeIndex + (index >> 1)];
49998
+ const key = packed >> ((index & 1) << 3) & 255;
49999
+ if (key === char) {
50000
+ const pointerIndex = nodeIndex + packedKeySlots + index;
50001
+ return branchEnd + decodeTree[pointerIndex] & 65535;
50002
+ }
50003
+ if (key > char)
50004
+ return -1;
50005
+ }
50006
+ return -1;
50007
+ }
50008
+
50009
+ // node_modules/htmlparser2/dist/Tokenizer.js
50010
+ var CharCodes2;
50011
+ (function(CharCodes3) {
50012
+ CharCodes3[CharCodes3["Tab"] = 9] = "Tab";
50013
+ CharCodes3[CharCodes3["NewLine"] = 10] = "NewLine";
50014
+ CharCodes3[CharCodes3["FormFeed"] = 12] = "FormFeed";
50015
+ CharCodes3[CharCodes3["CarriageReturn"] = 13] = "CarriageReturn";
50016
+ CharCodes3[CharCodes3["Space"] = 32] = "Space";
50017
+ CharCodes3[CharCodes3["ExclamationMark"] = 33] = "ExclamationMark";
50018
+ CharCodes3[CharCodes3["Number"] = 35] = "Number";
50019
+ CharCodes3[CharCodes3["Amp"] = 38] = "Amp";
50020
+ CharCodes3[CharCodes3["SingleQuote"] = 39] = "SingleQuote";
50021
+ CharCodes3[CharCodes3["DoubleQuote"] = 34] = "DoubleQuote";
50022
+ CharCodes3[CharCodes3["Dash"] = 45] = "Dash";
50023
+ CharCodes3[CharCodes3["Slash"] = 47] = "Slash";
50024
+ CharCodes3[CharCodes3["Zero"] = 48] = "Zero";
50025
+ CharCodes3[CharCodes3["Nine"] = 57] = "Nine";
50026
+ CharCodes3[CharCodes3["Semi"] = 59] = "Semi";
50027
+ CharCodes3[CharCodes3["Lt"] = 60] = "Lt";
50028
+ CharCodes3[CharCodes3["Eq"] = 61] = "Eq";
50029
+ CharCodes3[CharCodes3["Gt"] = 62] = "Gt";
50030
+ CharCodes3[CharCodes3["Questionmark"] = 63] = "Questionmark";
50031
+ CharCodes3[CharCodes3["UpperA"] = 65] = "UpperA";
50032
+ CharCodes3[CharCodes3["LowerA"] = 97] = "LowerA";
50033
+ CharCodes3[CharCodes3["UpperF"] = 70] = "UpperF";
50034
+ CharCodes3[CharCodes3["LowerF"] = 102] = "LowerF";
50035
+ CharCodes3[CharCodes3["UpperZ"] = 90] = "UpperZ";
50036
+ CharCodes3[CharCodes3["LowerZ"] = 122] = "LowerZ";
50037
+ CharCodes3[CharCodes3["LowerX"] = 120] = "LowerX";
50038
+ CharCodes3[CharCodes3["OpeningSquareBracket"] = 91] = "OpeningSquareBracket";
50039
+ })(CharCodes2 || (CharCodes2 = {}));
50040
+ var State;
50041
+ (function(State2) {
50042
+ State2[State2["Text"] = 1] = "Text";
50043
+ State2[State2["BeforeTagName"] = 2] = "BeforeTagName";
50044
+ State2[State2["InTagName"] = 3] = "InTagName";
50045
+ State2[State2["InSelfClosingTag"] = 4] = "InSelfClosingTag";
50046
+ State2[State2["BeforeClosingTagName"] = 5] = "BeforeClosingTagName";
50047
+ State2[State2["InClosingTagName"] = 6] = "InClosingTagName";
50048
+ State2[State2["AfterClosingTagName"] = 7] = "AfterClosingTagName";
50049
+ State2[State2["BeforeAttributeName"] = 8] = "BeforeAttributeName";
50050
+ State2[State2["InAttributeName"] = 9] = "InAttributeName";
50051
+ State2[State2["AfterAttributeName"] = 10] = "AfterAttributeName";
50052
+ State2[State2["BeforeAttributeValue"] = 11] = "BeforeAttributeValue";
50053
+ State2[State2["InAttributeValueDq"] = 12] = "InAttributeValueDq";
50054
+ State2[State2["InAttributeValueSq"] = 13] = "InAttributeValueSq";
50055
+ State2[State2["InAttributeValueNq"] = 14] = "InAttributeValueNq";
50056
+ State2[State2["BeforeDeclaration"] = 15] = "BeforeDeclaration";
50057
+ State2[State2["InDeclaration"] = 16] = "InDeclaration";
50058
+ State2[State2["InProcessingInstruction"] = 17] = "InProcessingInstruction";
50059
+ State2[State2["BeforeComment"] = 18] = "BeforeComment";
50060
+ State2[State2["CDATASequence"] = 19] = "CDATASequence";
50061
+ State2[State2["DeclarationSequence"] = 20] = "DeclarationSequence";
50062
+ State2[State2["InSpecialComment"] = 21] = "InSpecialComment";
50063
+ State2[State2["InCommentLike"] = 22] = "InCommentLike";
50064
+ State2[State2["SpecialStartSequence"] = 23] = "SpecialStartSequence";
50065
+ State2[State2["InSpecialTag"] = 24] = "InSpecialTag";
50066
+ State2[State2["InPlainText"] = 25] = "InPlainText";
50067
+ State2[State2["InEntity"] = 26] = "InEntity";
50068
+ })(State || (State = {}));
50069
+ function isWhitespace2(c) {
50070
+ return c === CharCodes2.Space || c === CharCodes2.NewLine || c === CharCodes2.Tab || c === CharCodes2.FormFeed || c === CharCodes2.CarriageReturn;
50071
+ }
50072
+ function isEndOfTagSection(c) {
50073
+ return c === CharCodes2.Slash || c === CharCodes2.Gt || isWhitespace2(c);
50074
+ }
50075
+ function isASCIIAlpha(c) {
50076
+ return c >= CharCodes2.LowerA && c <= CharCodes2.LowerZ || c >= CharCodes2.UpperA && c <= CharCodes2.UpperZ;
50077
+ }
50078
+ var QuoteType;
50079
+ (function(QuoteType2) {
50080
+ QuoteType2[QuoteType2["NoValue"] = 0] = "NoValue";
50081
+ QuoteType2[QuoteType2["Unquoted"] = 1] = "Unquoted";
50082
+ QuoteType2[QuoteType2["Single"] = 2] = "Single";
50083
+ QuoteType2[QuoteType2["Double"] = 3] = "Double";
50084
+ })(QuoteType || (QuoteType = {}));
50085
+ var Sequences = {
50086
+ Empty: new Uint8Array(0),
50087
+ Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
50088
+ // CDATA[
50089
+ CdataEnd: new Uint8Array([93, 93, 62]),
50090
+ // ]]>
50091
+ CommentEnd: new Uint8Array([45, 45, 33, 62]),
50092
+ // `--!>`
50093
+ Doctype: new Uint8Array([100, 111, 99, 116, 121, 112, 101]),
50094
+ // `doctype`
50095
+ IframeEnd: new Uint8Array([60, 47, 105, 102, 114, 97, 109, 101]),
50096
+ // `</iframe`
50097
+ NoembedEnd: new Uint8Array([
50098
+ 60,
50099
+ 47,
50100
+ 110,
50101
+ 111,
50102
+ 101,
50103
+ 109,
50104
+ 98,
50105
+ 101,
50106
+ 100
50107
+ ]),
50108
+ // `</noembed`
50109
+ NoframesEnd: new Uint8Array([
50110
+ 60,
50111
+ 47,
50112
+ 110,
50113
+ 111,
50114
+ 102,
50115
+ 114,
50116
+ 97,
50117
+ 109,
50118
+ 101,
50119
+ 115
50120
+ ]),
50121
+ // `</noframes`
50122
+ Plaintext: new Uint8Array([
50123
+ 60,
50124
+ 47,
50125
+ 112,
50126
+ 108,
50127
+ 97,
50128
+ 105,
50129
+ 110,
50130
+ 116,
50131
+ 101,
50132
+ 120,
50133
+ 116
50134
+ ]),
50135
+ // `</plaintext`
50136
+ ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
50137
+ // `</script`
50138
+ StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
50139
+ // `</style`
50140
+ TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
50141
+ // `</title`
50142
+ TextareaEnd: new Uint8Array([
50143
+ 60,
50144
+ 47,
50145
+ 116,
50146
+ 101,
50147
+ 120,
50148
+ 116,
50149
+ 97,
50150
+ 114,
50151
+ 101,
50152
+ 97
50153
+ ]),
50154
+ // `</textarea`
50155
+ XmpEnd: new Uint8Array([60, 47, 120, 109, 112])
50156
+ // `</xmp`
50157
+ };
50158
+ var specialStartSequences = /* @__PURE__ */ new Map([
50159
+ [Sequences.IframeEnd[2], Sequences.IframeEnd],
50160
+ [Sequences.NoembedEnd[2], Sequences.NoembedEnd],
50161
+ [Sequences.Plaintext[2], Sequences.Plaintext],
50162
+ [Sequences.ScriptEnd[2], Sequences.ScriptEnd],
50163
+ [Sequences.TitleEnd[2], Sequences.TitleEnd],
50164
+ [Sequences.XmpEnd[2], Sequences.XmpEnd]
50165
+ ]);
50166
+ var Tokenizer2 = class {
50167
+ cbs;
50168
+ /** The current state the tokenizer is in. */
50169
+ state = State.Text;
50170
+ /** The read buffer. */
50171
+ buffer = "";
50172
+ /** The beginning of the section that is currently being read. */
50173
+ sectionStart = 0;
50174
+ /** The index within the buffer that we are currently looking at. */
50175
+ index = 0;
50176
+ /** The start of the last entity. */
50177
+ entityStart = 0;
50178
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
50179
+ baseState = State.Text;
50180
+ /** For special parsing behavior inside of script and style tags. */
50181
+ isSpecial = false;
50182
+ /** Indicates whether the tokenizer has been paused. */
50183
+ running = true;
50184
+ /** The offset of the current buffer. */
50185
+ offset = 0;
50186
+ xmlMode;
50187
+ decodeEntities;
50188
+ recognizeSelfClosing;
50189
+ entityDecoder;
50190
+ constructor({ xmlMode = false, decodeEntities = true, recognizeSelfClosing = xmlMode }, cbs) {
50191
+ this.cbs = cbs;
50192
+ this.xmlMode = xmlMode;
50193
+ this.decodeEntities = decodeEntities;
50194
+ this.recognizeSelfClosing = recognizeSelfClosing;
50195
+ this.entityDecoder = new EntityDecoder(xmlMode ? xmlDecodeTree : htmlDecodeTree, (cp, consumed) => this.emitCodePoint(cp, consumed));
50196
+ }
50197
+ reset() {
50198
+ this.state = State.Text;
50199
+ this.buffer = "";
50200
+ this.sectionStart = 0;
50201
+ this.index = 0;
50202
+ this.baseState = State.Text;
50203
+ this.isSpecial = false;
50204
+ this.currentSequence = Sequences.Empty;
50205
+ this.sequenceIndex = 0;
50206
+ this.running = true;
50207
+ this.offset = 0;
50208
+ }
50209
+ write(chunk) {
50210
+ this.offset += this.buffer.length;
50211
+ this.buffer = chunk;
50212
+ this.parse();
50213
+ }
50214
+ end() {
50215
+ if (this.running)
50216
+ this.finish();
50217
+ }
50218
+ pause() {
50219
+ this.running = false;
50220
+ }
50221
+ resume() {
50222
+ this.running = true;
50223
+ if (this.index < this.buffer.length + this.offset) {
50224
+ this.parse();
50225
+ }
50226
+ }
50227
+ stateText(c) {
50228
+ if (c === CharCodes2.Lt || !this.decodeEntities && this.fastForwardTo(CharCodes2.Lt)) {
50229
+ if (this.index > this.sectionStart) {
50230
+ this.cbs.ontext(this.sectionStart, this.index);
50231
+ }
50232
+ this.state = State.BeforeTagName;
50233
+ this.sectionStart = this.index;
50234
+ } else if (this.decodeEntities && c === CharCodes2.Amp) {
50235
+ this.startEntity();
50236
+ }
50237
+ }
50238
+ currentSequence = Sequences.Empty;
50239
+ sequenceIndex = 0;
50240
+ enterTagBody() {
50241
+ if (this.currentSequence === Sequences.Plaintext) {
50242
+ this.currentSequence = Sequences.Empty;
50243
+ this.state = State.InPlainText;
50244
+ } else if (this.isSpecial) {
50245
+ this.state = State.InSpecialTag;
50246
+ this.sequenceIndex = 0;
50247
+ } else {
50248
+ this.state = State.Text;
50249
+ }
50250
+ }
50251
+ /**
50252
+ * Match the opening tag name against an HTML text-only tag sequence.
50253
+ *
50254
+ * Some tags share an initial prefix (`script`/`style`, `title`/`textarea`,
50255
+ * `noembed`/`noframes`), so we may switch to an alternate sequence at the
50256
+ * first distinguishing byte. On a successful full match we fall back to
50257
+ * the normal tag-name state; a later `>` will enter raw-text, RCDATA, or
50258
+ * plaintext mode based on `currentSequence` / `isSpecial`.
50259
+ * @param c Current character code point.
50260
+ */
50261
+ stateSpecialStartSequence(c) {
50262
+ const lower = c | 32;
50263
+ if (this.sequenceIndex < this.currentSequence.length) {
50264
+ if (lower === this.currentSequence[this.sequenceIndex]) {
50265
+ this.sequenceIndex++;
50266
+ return;
50267
+ }
50268
+ if (this.sequenceIndex === 3) {
50269
+ if (this.currentSequence === Sequences.ScriptEnd && lower === Sequences.StyleEnd[3]) {
50270
+ this.currentSequence = Sequences.StyleEnd;
50271
+ this.sequenceIndex = 4;
50272
+ return;
50273
+ }
50274
+ if (this.currentSequence === Sequences.TitleEnd && lower === Sequences.TextareaEnd[3]) {
50275
+ this.currentSequence = Sequences.TextareaEnd;
50276
+ this.sequenceIndex = 4;
50277
+ return;
50278
+ }
50279
+ } else if (this.sequenceIndex === 4 && this.currentSequence === Sequences.NoembedEnd && lower === Sequences.NoframesEnd[4]) {
50280
+ this.currentSequence = Sequences.NoframesEnd;
50281
+ this.sequenceIndex = 5;
50282
+ return;
50283
+ }
50284
+ } else if (isEndOfTagSection(c)) {
50285
+ this.sequenceIndex = 0;
50286
+ this.state = State.InTagName;
50287
+ this.stateInTagName(c);
50288
+ return;
50289
+ }
50290
+ this.isSpecial = false;
50291
+ this.currentSequence = Sequences.Empty;
50292
+ this.sequenceIndex = 0;
50293
+ this.state = State.InTagName;
50294
+ this.stateInTagName(c);
50295
+ }
50296
+ stateCDATASequence(c) {
50297
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
50298
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
50299
+ this.state = State.InCommentLike;
50300
+ this.currentSequence = Sequences.CdataEnd;
50301
+ this.sequenceIndex = 0;
50302
+ this.sectionStart = this.index + 1;
50303
+ }
50304
+ } else {
50305
+ this.sequenceIndex = 0;
50306
+ if (this.xmlMode) {
50307
+ this.state = State.InDeclaration;
50308
+ this.stateInDeclaration(c);
50309
+ } else {
50310
+ this.state = State.InSpecialComment;
50311
+ this.stateInSpecialComment(c);
50312
+ }
50313
+ }
50314
+ }
50315
+ /**
50316
+ * When we wait for one specific character, we can speed things up
50317
+ * by skipping through the buffer until we find it.
50318
+ * @param c Current character code point.
50319
+ * @returns Whether the character was found.
50320
+ */
50321
+ fastForwardTo(c) {
50322
+ while (++this.index < this.buffer.length + this.offset) {
50323
+ if (this.buffer.charCodeAt(this.index - this.offset) === c) {
50324
+ return true;
50325
+ }
50326
+ }
50327
+ this.index = this.buffer.length + this.offset - 1;
50328
+ return false;
50329
+ }
50330
+ /**
50331
+ * Emit a comment token and return to the text state.
50332
+ * @param offset Number of characters in the end sequence that have already been matched.
50333
+ */
50334
+ emitComment(offset) {
50335
+ this.cbs.oncomment(this.sectionStart, this.index, offset);
50336
+ this.sequenceIndex = 0;
50337
+ this.sectionStart = this.index + 1;
50338
+ this.state = State.Text;
50339
+ }
50340
+ /**
50341
+ * Comments and CDATA end with `-->` and `]]>`.
50342
+ *
50343
+ * Their common qualities are:
50344
+ * - Their end sequences have a distinct character they start with.
50345
+ * - That character is then repeated, so we have to check multiple repeats.
50346
+ * - All characters but the start character of the sequence can be skipped.
50347
+ * @param c Current character code point.
50348
+ */
50349
+ stateInCommentLike(c) {
50350
+ if (!this.xmlMode && this.currentSequence === Sequences.CommentEnd && this.sequenceIndex <= 1 && /*
50351
+ * We're still at the very start of the comment: the only
50352
+ * characters consumed since `<!--` are the dashes that
50353
+ * advanced sequenceIndex (0 for `<!-->`, 1 for `<!--->`).
50354
+ */
50355
+ this.index === this.sectionStart + this.sequenceIndex && c === CharCodes2.Gt) {
50356
+ this.emitComment(this.sequenceIndex);
50357
+ } else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === 2 && c === CharCodes2.Gt) {
50358
+ this.emitComment(2);
50359
+ } else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === this.currentSequence.length - 1 && c !== CharCodes2.Gt) {
50360
+ this.sequenceIndex = Number(c === CharCodes2.Dash);
50361
+ } else if (c === this.currentSequence[this.sequenceIndex]) {
50362
+ if (++this.sequenceIndex === this.currentSequence.length) {
50363
+ if (this.currentSequence === Sequences.CdataEnd) {
50364
+ this.cbs.oncdata(this.sectionStart, this.index, 2);
50365
+ } else {
50366
+ this.cbs.oncomment(this.sectionStart, this.index, 3);
50367
+ }
50368
+ this.sequenceIndex = 0;
50369
+ this.sectionStart = this.index + 1;
50370
+ this.state = State.Text;
50371
+ }
50372
+ } else if (this.sequenceIndex === 0) {
50373
+ if (this.fastForwardTo(this.currentSequence[0])) {
50374
+ this.sequenceIndex = 1;
50375
+ }
50376
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
50377
+ this.sequenceIndex = 0;
50378
+ }
50379
+ }
50380
+ /**
50381
+ * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
50382
+ *
50383
+ * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
50384
+ * We allow anything that wouldn't end the tag.
50385
+ * @param c Current character code point.
50386
+ */
50387
+ isTagStartChar(c) {
50388
+ return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c);
50389
+ }
50390
+ /**
50391
+ * Scan raw-text / RCDATA content for the matching end tag.
50392
+ *
50393
+ * For RCDATA tags (`<title>`, `<textarea>`) entities are decoded inline.
50394
+ * For raw-text tags (`<script>`, `<style>`, etc.) we fast-forward to `<`.
50395
+ * @param c Current character code point.
50396
+ */
50397
+ stateInSpecialTag(c) {
50398
+ if (this.sequenceIndex === this.currentSequence.length) {
50399
+ if (isEndOfTagSection(c)) {
50400
+ const endOfText = this.index - this.currentSequence.length;
50401
+ if (this.sectionStart < endOfText) {
50402
+ const actualIndex = this.index;
50403
+ this.index = endOfText;
50404
+ this.cbs.ontext(this.sectionStart, endOfText);
50405
+ this.index = actualIndex;
50406
+ }
50407
+ this.isSpecial = false;
50408
+ this.sectionStart = endOfText + 2;
50409
+ this.stateInClosingTagName(c);
50410
+ return;
50411
+ }
50412
+ this.sequenceIndex = 0;
50413
+ }
50414
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
50415
+ this.sequenceIndex += 1;
50416
+ } else if (this.sequenceIndex === 0) {
50417
+ if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd) {
50418
+ if (this.decodeEntities && c === CharCodes2.Amp) {
50419
+ this.startEntity();
50420
+ }
50421
+ } else if (this.fastForwardTo(CharCodes2.Lt)) {
50422
+ this.sequenceIndex = 1;
50423
+ }
50424
+ } else {
50425
+ this.sequenceIndex = Number(c === CharCodes2.Lt);
50426
+ }
50427
+ }
50428
+ stateBeforeTagName(c) {
50429
+ if (c === CharCodes2.ExclamationMark) {
50430
+ this.state = State.BeforeDeclaration;
50431
+ this.sectionStart = this.index + 1;
50432
+ } else if (c === CharCodes2.Questionmark) {
50433
+ if (this.xmlMode) {
50434
+ this.state = State.InProcessingInstruction;
50435
+ this.sequenceIndex = 0;
50436
+ this.sectionStart = this.index + 1;
50437
+ } else {
50438
+ this.state = State.InSpecialComment;
50439
+ this.sectionStart = this.index;
50440
+ }
50441
+ } else if (this.isTagStartChar(c)) {
50442
+ this.sectionStart = this.index;
50443
+ const special = this.xmlMode || this.cbs.isInForeignContext?.() ? void 0 : specialStartSequences.get(c | 32);
50444
+ if (special === void 0) {
50445
+ this.state = State.InTagName;
50446
+ } else {
50447
+ this.isSpecial = true;
50448
+ this.currentSequence = special;
50449
+ this.sequenceIndex = 3;
50450
+ this.state = State.SpecialStartSequence;
50451
+ }
50452
+ } else if (c === CharCodes2.Slash) {
50453
+ this.state = State.BeforeClosingTagName;
50454
+ } else {
50455
+ this.state = State.Text;
50456
+ this.stateText(c);
50457
+ }
50458
+ }
50459
+ stateInTagName(c) {
50460
+ if (isEndOfTagSection(c)) {
50461
+ this.cbs.onopentagname(this.sectionStart, this.index);
50462
+ this.sectionStart = -1;
50463
+ this.state = State.BeforeAttributeName;
50464
+ this.stateBeforeAttributeName(c);
50465
+ }
50466
+ }
50467
+ stateBeforeClosingTagName(c) {
50468
+ if (isWhitespace2(c)) {
50469
+ if (this.xmlMode) {
50470
+ } else {
50471
+ this.state = State.InSpecialComment;
50472
+ this.sectionStart = this.index;
50473
+ }
50474
+ } else if (c === CharCodes2.Gt) {
50475
+ this.state = State.Text;
50476
+ if (!this.xmlMode) {
50477
+ this.sectionStart = this.index + 1;
50478
+ }
50479
+ } else {
50480
+ this.state = this.isTagStartChar(c) ? State.InClosingTagName : State.InSpecialComment;
50481
+ this.sectionStart = this.index;
50482
+ }
50483
+ }
50484
+ stateInClosingTagName(c) {
50485
+ if (isEndOfTagSection(c)) {
50486
+ this.cbs.onclosetag(this.sectionStart, this.index);
50487
+ this.sectionStart = -1;
50488
+ this.state = State.AfterClosingTagName;
50489
+ this.stateAfterClosingTagName(c);
50490
+ }
50491
+ }
50492
+ stateAfterClosingTagName(c) {
50493
+ if (c === CharCodes2.Gt || this.fastForwardTo(CharCodes2.Gt)) {
50494
+ this.state = State.Text;
50495
+ this.sectionStart = this.index + 1;
50496
+ }
50497
+ }
50498
+ stateBeforeAttributeName(c) {
50499
+ if (c === CharCodes2.Gt) {
50500
+ this.cbs.onopentagend(this.index);
50501
+ this.enterTagBody();
50502
+ this.sectionStart = this.index + 1;
50503
+ } else if (c === CharCodes2.Slash) {
50504
+ this.state = State.InSelfClosingTag;
50505
+ } else if (!isWhitespace2(c)) {
50506
+ this.state = State.InAttributeName;
50507
+ this.sectionStart = this.index;
50508
+ }
50509
+ }
50510
+ /**
50511
+ * Handle `/` before `>` in an opening tag.
50512
+ *
50513
+ * In HTML mode, text-only tags ignore the self-closing flag and still enter
50514
+ * their raw-text/RCDATA/plaintext state unless self-closing tags are being
50515
+ * recognized. In XML mode, or for ordinary tags, the tokenizer returns to
50516
+ * regular text parsing after emitting the self-closing callback.
50517
+ * @param c Current character code point.
50518
+ */
50519
+ stateInSelfClosingTag(c) {
50520
+ if (c === CharCodes2.Gt) {
50521
+ this.cbs.onselfclosingtag(this.index);
50522
+ this.sectionStart = this.index + 1;
50523
+ if (!this.recognizeSelfClosing) {
50524
+ this.enterTagBody();
50525
+ return;
50526
+ }
50527
+ this.state = State.Text;
50528
+ this.isSpecial = false;
50529
+ this.currentSequence = Sequences.Empty;
50530
+ } else if (!isWhitespace2(c)) {
50531
+ this.state = State.BeforeAttributeName;
50532
+ this.stateBeforeAttributeName(c);
50533
+ }
50534
+ }
50535
+ stateInAttributeName(c) {
50536
+ if (c === CharCodes2.Eq || isEndOfTagSection(c)) {
50537
+ this.cbs.onattribname(this.sectionStart, this.index);
50538
+ this.sectionStart = this.index;
50539
+ this.state = State.AfterAttributeName;
50540
+ this.stateAfterAttributeName(c);
50541
+ }
50542
+ }
50543
+ stateAfterAttributeName(c) {
50544
+ if (c === CharCodes2.Eq) {
50545
+ this.state = State.BeforeAttributeValue;
50546
+ } else if (c === CharCodes2.Slash || c === CharCodes2.Gt) {
50547
+ this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
50548
+ this.sectionStart = -1;
50549
+ this.state = State.BeforeAttributeName;
50550
+ this.stateBeforeAttributeName(c);
50551
+ } else if (!isWhitespace2(c)) {
50552
+ this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
50553
+ this.state = State.InAttributeName;
50554
+ this.sectionStart = this.index;
50555
+ }
50556
+ }
50557
+ stateBeforeAttributeValue(c) {
50558
+ if (c === CharCodes2.DoubleQuote) {
50559
+ this.state = State.InAttributeValueDq;
50560
+ this.sectionStart = this.index + 1;
50561
+ } else if (c === CharCodes2.SingleQuote) {
50562
+ this.state = State.InAttributeValueSq;
50563
+ this.sectionStart = this.index + 1;
50564
+ } else if (!isWhitespace2(c)) {
50565
+ this.sectionStart = this.index;
50566
+ this.state = State.InAttributeValueNq;
50567
+ this.stateInAttributeValueNoQuotes(c);
50568
+ }
50569
+ }
50570
+ handleInAttributeValue(c, quote) {
50571
+ if (c === quote || !this.decodeEntities && this.fastForwardTo(quote)) {
50572
+ this.cbs.onattribdata(this.sectionStart, this.index);
50573
+ this.sectionStart = -1;
50574
+ this.cbs.onattribend(quote === CharCodes2.DoubleQuote ? QuoteType.Double : QuoteType.Single, this.index + 1);
50575
+ this.state = State.BeforeAttributeName;
50576
+ } else if (this.decodeEntities && c === CharCodes2.Amp) {
50577
+ this.startEntity();
50578
+ }
50579
+ }
50580
+ stateInAttributeValueDoubleQuotes(c) {
50581
+ this.handleInAttributeValue(c, CharCodes2.DoubleQuote);
50582
+ }
50583
+ stateInAttributeValueSingleQuotes(c) {
50584
+ this.handleInAttributeValue(c, CharCodes2.SingleQuote);
50585
+ }
50586
+ stateInAttributeValueNoQuotes(c) {
50587
+ if (isWhitespace2(c) || c === CharCodes2.Gt) {
50588
+ this.cbs.onattribdata(this.sectionStart, this.index);
50589
+ this.sectionStart = -1;
50590
+ this.cbs.onattribend(QuoteType.Unquoted, this.index);
50591
+ this.state = State.BeforeAttributeName;
50592
+ this.stateBeforeAttributeName(c);
50593
+ } else if (this.decodeEntities && c === CharCodes2.Amp) {
50594
+ this.startEntity();
50595
+ }
50596
+ }
50597
+ /**
50598
+ * Distinguish between CDATA, declarations, HTML comments, and HTML bogus
50599
+ * comments after `<!`.
50600
+ *
50601
+ * In HTML mode, only real comments and doctypes stay on declaration paths;
50602
+ * everything else becomes a bogus comment terminated by the next `>`.
50603
+ * @param c Current character code point.
50604
+ */
50605
+ stateBeforeDeclaration(c) {
50606
+ if (c === CharCodes2.OpeningSquareBracket) {
50607
+ this.state = State.CDATASequence;
50608
+ this.sequenceIndex = 0;
50609
+ } else if (this.xmlMode) {
50610
+ this.state = c === CharCodes2.Dash ? State.BeforeComment : State.InDeclaration;
50611
+ } else if ((c | 32) === Sequences.Doctype[0]) {
50612
+ this.state = State.DeclarationSequence;
50613
+ this.currentSequence = Sequences.Doctype;
50614
+ this.sequenceIndex = 1;
50615
+ } else if (c === CharCodes2.Gt) {
50616
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
50617
+ this.state = State.Text;
50618
+ this.sectionStart = this.index + 1;
50619
+ } else if (c === CharCodes2.Dash) {
50620
+ this.state = State.BeforeComment;
50621
+ } else {
50622
+ this.state = State.InSpecialComment;
50623
+ }
50624
+ }
50625
+ /**
50626
+ * Continue matching `doctype` after `<!d`.
50627
+ *
50628
+ * A full `doctype` match stays on the declaration path; any other name falls
50629
+ * back to an HTML bogus comment, which matches browser behavior for
50630
+ * non-doctype `<!...>` constructs.
50631
+ * @param c Current character code point.
50632
+ */
50633
+ stateDeclarationSequence(c) {
50634
+ if (this.sequenceIndex === this.currentSequence.length) {
50635
+ this.state = State.InDeclaration;
50636
+ this.stateInDeclaration(c);
50637
+ } else if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
50638
+ this.sequenceIndex += 1;
50639
+ } else if (c === CharCodes2.Gt) {
50640
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
50641
+ this.state = State.Text;
50642
+ this.sectionStart = this.index + 1;
50643
+ } else {
50644
+ this.state = State.InSpecialComment;
50645
+ }
50646
+ }
50647
+ stateInDeclaration(c) {
50648
+ if (c === CharCodes2.Gt || this.fastForwardTo(CharCodes2.Gt)) {
50649
+ this.cbs.ondeclaration(this.sectionStart, this.index);
50650
+ this.state = State.Text;
50651
+ this.sectionStart = this.index + 1;
50652
+ }
50653
+ }
50654
+ /**
50655
+ * XML processing instructions (`<?...?>`).
50656
+ *
50657
+ * In HTML mode `<?` is routed to `InSpecialComment` instead, so this
50658
+ * state is only reachable in XML mode.
50659
+ * @param c Current character code point.
50660
+ */
50661
+ stateInProcessingInstruction(c) {
50662
+ if (c === CharCodes2.Questionmark) {
50663
+ this.sequenceIndex = 1;
50664
+ } else if (c === CharCodes2.Gt && this.sequenceIndex === 1) {
50665
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index - 1);
50666
+ this.sequenceIndex = 0;
50667
+ this.state = State.Text;
50668
+ this.sectionStart = this.index + 1;
50669
+ } else {
50670
+ this.sequenceIndex = Number(this.fastForwardTo(CharCodes2.Questionmark));
50671
+ }
50672
+ }
50673
+ stateBeforeComment(c) {
50674
+ if (c === CharCodes2.Dash) {
50675
+ this.state = State.InCommentLike;
50676
+ this.currentSequence = Sequences.CommentEnd;
50677
+ this.sequenceIndex = 0;
50678
+ this.sectionStart = this.index + 1;
50679
+ } else if (this.xmlMode) {
50680
+ this.state = State.InDeclaration;
50681
+ } else if (c === CharCodes2.Gt) {
50682
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
50683
+ this.state = State.Text;
50684
+ this.sectionStart = this.index + 1;
50685
+ } else {
50686
+ this.state = State.InSpecialComment;
50687
+ }
50688
+ }
50689
+ stateInSpecialComment(c) {
50690
+ if (c === CharCodes2.Gt || this.fastForwardTo(CharCodes2.Gt)) {
50691
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
50692
+ this.state = State.Text;
50693
+ this.sectionStart = this.index + 1;
50694
+ }
50695
+ }
50696
+ startEntity() {
50697
+ this.baseState = this.state;
50698
+ this.state = State.InEntity;
50699
+ this.entityStart = this.index;
50700
+ this.entityDecoder.startEntity(this.xmlMode ? DecodingMode.Strict : this.baseState === State.Text || this.baseState === State.InSpecialTag ? DecodingMode.Legacy : DecodingMode.Attribute);
50701
+ }
50702
+ stateInEntity() {
50703
+ const indexInBuffer = this.index - this.offset;
50704
+ const length = this.entityDecoder.write(this.buffer, indexInBuffer);
50705
+ if (length >= 0) {
50706
+ this.state = this.baseState;
50707
+ if (length === 0) {
50708
+ this.index -= 1;
50709
+ }
50710
+ } else {
50711
+ if (indexInBuffer < this.buffer.length && this.buffer.charCodeAt(indexInBuffer) === CharCodes2.Amp) {
50712
+ this.state = this.baseState;
50713
+ this.index -= 1;
50714
+ return;
50715
+ }
50716
+ this.index = this.offset + this.buffer.length - 1;
50717
+ }
50718
+ }
50719
+ /**
50720
+ * Remove data that has already been consumed from the buffer.
50721
+ */
50722
+ cleanup() {
50723
+ if (this.running && this.sectionStart !== this.index) {
50724
+ if (this.state === State.Text || this.state === State.InPlainText || this.state === State.InSpecialTag && this.sequenceIndex === 0) {
50725
+ this.cbs.ontext(this.sectionStart, this.index);
50726
+ this.sectionStart = this.index;
50727
+ } else if (this.state === State.InAttributeValueDq || this.state === State.InAttributeValueSq || this.state === State.InAttributeValueNq) {
50728
+ this.cbs.onattribdata(this.sectionStart, this.index);
50729
+ this.sectionStart = this.index;
50730
+ }
50731
+ }
50732
+ }
50733
+ shouldContinue() {
50734
+ return this.index < this.buffer.length + this.offset && this.running;
50735
+ }
50736
+ /**
50737
+ * Iterates through the buffer, calling the function corresponding to the current state.
50738
+ *
50739
+ * States that are more likely to be hit are higher up, as a performance improvement.
50740
+ */
50741
+ parse() {
50742
+ while (this.shouldContinue()) {
50743
+ const c = this.buffer.charCodeAt(this.index - this.offset);
50744
+ switch (this.state) {
50745
+ case State.Text: {
50746
+ this.stateText(c);
50747
+ break;
50748
+ }
50749
+ case State.InPlainText: {
50750
+ this.index = this.buffer.length + this.offset - 1;
50751
+ break;
50752
+ }
50753
+ case State.SpecialStartSequence: {
50754
+ this.stateSpecialStartSequence(c);
50755
+ break;
50756
+ }
50757
+ case State.InSpecialTag: {
50758
+ this.stateInSpecialTag(c);
50759
+ break;
50760
+ }
50761
+ case State.CDATASequence: {
50762
+ this.stateCDATASequence(c);
50763
+ break;
50764
+ }
50765
+ case State.DeclarationSequence: {
50766
+ this.stateDeclarationSequence(c);
50767
+ break;
50768
+ }
50769
+ case State.InAttributeValueDq: {
50770
+ this.stateInAttributeValueDoubleQuotes(c);
50771
+ break;
50772
+ }
50773
+ case State.InAttributeName: {
50774
+ this.stateInAttributeName(c);
50775
+ break;
50776
+ }
50777
+ case State.InCommentLike: {
50778
+ this.stateInCommentLike(c);
50779
+ break;
50780
+ }
50781
+ case State.InSpecialComment: {
50782
+ this.stateInSpecialComment(c);
50783
+ break;
50784
+ }
50785
+ case State.BeforeAttributeName: {
50786
+ this.stateBeforeAttributeName(c);
50787
+ break;
50788
+ }
50789
+ case State.InTagName: {
50790
+ this.stateInTagName(c);
50791
+ break;
50792
+ }
50793
+ case State.InClosingTagName: {
50794
+ this.stateInClosingTagName(c);
50795
+ break;
50796
+ }
50797
+ case State.BeforeTagName: {
50798
+ this.stateBeforeTagName(c);
50799
+ break;
50800
+ }
50801
+ case State.AfterAttributeName: {
50802
+ this.stateAfterAttributeName(c);
50803
+ break;
50804
+ }
50805
+ case State.InAttributeValueSq: {
50806
+ this.stateInAttributeValueSingleQuotes(c);
50807
+ break;
50808
+ }
50809
+ case State.BeforeAttributeValue: {
50810
+ this.stateBeforeAttributeValue(c);
50811
+ break;
50812
+ }
50813
+ case State.BeforeClosingTagName: {
50814
+ this.stateBeforeClosingTagName(c);
50815
+ break;
50816
+ }
50817
+ case State.AfterClosingTagName: {
50818
+ this.stateAfterClosingTagName(c);
50819
+ break;
50820
+ }
50821
+ case State.InAttributeValueNq: {
50822
+ this.stateInAttributeValueNoQuotes(c);
50823
+ break;
50824
+ }
50825
+ case State.InSelfClosingTag: {
50826
+ this.stateInSelfClosingTag(c);
50827
+ break;
50828
+ }
50829
+ case State.InDeclaration: {
50830
+ this.stateInDeclaration(c);
50831
+ break;
50832
+ }
50833
+ case State.BeforeDeclaration: {
50834
+ this.stateBeforeDeclaration(c);
50835
+ break;
50836
+ }
50837
+ case State.BeforeComment: {
50838
+ this.stateBeforeComment(c);
50839
+ break;
50840
+ }
50841
+ case State.InProcessingInstruction: {
50842
+ this.stateInProcessingInstruction(c);
50843
+ break;
50844
+ }
50845
+ case State.InEntity: {
50846
+ this.stateInEntity();
50847
+ break;
50848
+ }
50849
+ }
50850
+ this.index++;
50851
+ }
50852
+ this.cleanup();
50853
+ }
50854
+ finish() {
50855
+ if (this.state === State.InEntity) {
50856
+ this.entityDecoder.end();
50857
+ this.state = this.baseState;
50858
+ }
50859
+ this.handleTrailingData();
50860
+ this.cbs.onend();
50861
+ }
50862
+ handleTrailingCommentLikeData(endIndex) {
50863
+ if (this.state !== State.InCommentLike) {
50864
+ return false;
50865
+ }
50866
+ if (this.currentSequence === Sequences.CdataEnd) {
50867
+ if (this.xmlMode) {
50868
+ if (this.sectionStart < endIndex) {
50869
+ this.cbs.oncdata(this.sectionStart, endIndex, 0);
50870
+ }
50871
+ } else {
50872
+ const cdataStart = this.sectionStart - Sequences.Cdata.length - 1;
50873
+ this.cbs.oncomment(cdataStart, endIndex, 0);
50874
+ }
50875
+ } else {
50876
+ const offset = this.xmlMode ? 0 : Math.min(this.sequenceIndex, Sequences.CommentEnd.length - 1);
50877
+ this.cbs.oncomment(this.sectionStart, endIndex, offset);
50878
+ }
50879
+ return true;
50880
+ }
50881
+ handleTrailingMarkupDeclaration(endIndex) {
50882
+ if (this.xmlMode) {
50883
+ switch (this.state) {
50884
+ case State.InSpecialComment:
50885
+ case State.BeforeComment:
50886
+ case State.CDATASequence:
50887
+ case State.DeclarationSequence:
50888
+ case State.InDeclaration: {
50889
+ this.cbs.ontext(this.sectionStart, endIndex);
50890
+ return true;
50891
+ }
50892
+ default: {
50893
+ return false;
50894
+ }
50895
+ }
50896
+ }
50897
+ switch (this.state) {
50898
+ case State.BeforeDeclaration:
50899
+ case State.InSpecialComment:
50900
+ case State.BeforeComment:
50901
+ case State.CDATASequence: {
50902
+ this.cbs.oncomment(this.sectionStart, endIndex, 0);
50903
+ return true;
50904
+ }
50905
+ case State.DeclarationSequence: {
50906
+ if (this.sequenceIndex !== Sequences.Doctype.length) {
50907
+ this.cbs.oncomment(this.sectionStart, endIndex, 0);
50908
+ }
50909
+ return true;
50910
+ }
50911
+ case State.InDeclaration: {
50912
+ return true;
50913
+ }
50914
+ default: {
50915
+ return false;
50916
+ }
50917
+ }
50918
+ }
50919
+ /** Handle any trailing data. */
50920
+ handleTrailingData() {
50921
+ const endIndex = this.buffer.length + this.offset;
50922
+ if (this.handleTrailingCommentLikeData(endIndex) || this.handleTrailingMarkupDeclaration(endIndex)) {
50923
+ return;
50924
+ }
50925
+ if (this.sectionStart >= endIndex) {
50926
+ return;
50927
+ }
50928
+ switch (this.state) {
50929
+ case State.InTagName:
50930
+ case State.BeforeAttributeName:
50931
+ case State.BeforeAttributeValue:
50932
+ case State.AfterAttributeName:
50933
+ case State.InAttributeName:
50934
+ case State.InAttributeValueSq:
50935
+ case State.InAttributeValueDq:
50936
+ case State.InAttributeValueNq:
50937
+ case State.InClosingTagName: {
50938
+ break;
50939
+ }
50940
+ default: {
50941
+ this.cbs.ontext(this.sectionStart, endIndex);
50942
+ }
50943
+ }
50944
+ }
50945
+ emitCodePoint(cp, consumed) {
50946
+ if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) {
50947
+ if (this.sectionStart < this.entityStart) {
50948
+ this.cbs.onattribdata(this.sectionStart, this.entityStart);
50949
+ }
50950
+ this.sectionStart = this.entityStart + consumed;
50951
+ this.index = this.sectionStart - 1;
50952
+ this.cbs.onattribentity(cp);
50953
+ } else {
50954
+ if (this.sectionStart < this.entityStart) {
50955
+ this.cbs.ontext(this.sectionStart, this.entityStart);
50956
+ }
50957
+ this.sectionStart = this.entityStart + consumed;
50958
+ this.index = this.sectionStart - 1;
50959
+ this.cbs.ontextentity(cp, this.sectionStart);
50960
+ }
50961
+ }
50962
+ };
50963
+
50964
+ // node_modules/htmlparser2/dist/Parser.js
50965
+ var { fromCodePoint } = String;
50966
+ var formTags = /* @__PURE__ */ new Set([
50967
+ "input",
50968
+ "option",
50969
+ "optgroup",
50970
+ "select",
50971
+ "button",
50972
+ "datalist",
50973
+ "textarea"
50974
+ ]);
50975
+ var pTag = /* @__PURE__ */ new Set(["p"]);
50976
+ var headingTags = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6", "p"]);
50977
+ var tableSectionTags = /* @__PURE__ */ new Set(["thead", "tbody"]);
50978
+ var ddtTags = /* @__PURE__ */ new Set(["dd", "dt"]);
50979
+ var rtpTags = /* @__PURE__ */ new Set(["rt", "rp"]);
50980
+ var openImpliesClose = /* @__PURE__ */ new Map([
50981
+ ["tr", /* @__PURE__ */ new Set(["tr", "th", "td"])],
50982
+ ["th", /* @__PURE__ */ new Set(["th"])],
50983
+ ["td", /* @__PURE__ */ new Set(["thead", "th", "td"])],
50984
+ ["body", /* @__PURE__ */ new Set(["head", "link", "script"])],
50985
+ ["a", /* @__PURE__ */ new Set(["a"])],
50986
+ ["li", /* @__PURE__ */ new Set(["li"])],
50987
+ ["p", pTag],
50988
+ ["h1", headingTags],
50989
+ ["h2", headingTags],
50990
+ ["h3", headingTags],
50991
+ ["h4", headingTags],
50992
+ ["h5", headingTags],
50993
+ ["h6", headingTags],
50994
+ ["select", formTags],
50995
+ ["input", formTags],
50996
+ ["output", formTags],
50997
+ ["button", formTags],
50998
+ ["datalist", formTags],
50999
+ ["textarea", formTags],
51000
+ ["option", /* @__PURE__ */ new Set(["option"])],
51001
+ ["optgroup", /* @__PURE__ */ new Set(["optgroup", "option"])],
51002
+ ["dd", ddtTags],
51003
+ ["dt", ddtTags],
51004
+ ["address", pTag],
51005
+ ["article", pTag],
51006
+ ["aside", pTag],
51007
+ ["blockquote", pTag],
51008
+ ["details", pTag],
51009
+ ["div", pTag],
51010
+ ["dl", pTag],
51011
+ ["fieldset", pTag],
51012
+ ["figcaption", pTag],
51013
+ ["figure", pTag],
51014
+ ["footer", pTag],
51015
+ ["form", pTag],
51016
+ ["header", pTag],
51017
+ ["hr", pTag],
51018
+ ["main", pTag],
51019
+ ["nav", pTag],
51020
+ ["ol", pTag],
51021
+ ["pre", pTag],
51022
+ ["section", pTag],
51023
+ ["table", pTag],
51024
+ ["ul", pTag],
51025
+ ["rt", rtpTags],
51026
+ ["rp", rtpTags],
51027
+ ["tbody", tableSectionTags],
51028
+ ["tfoot", tableSectionTags]
51029
+ ]);
51030
+ var DOCUMENT_TYPE = "doctype";
51031
+ var voidElements = /* @__PURE__ */ new Set([
51032
+ "area",
51033
+ "base",
51034
+ "basefont",
51035
+ "br",
51036
+ "col",
51037
+ "command",
51038
+ "embed",
51039
+ "frame",
51040
+ "hr",
51041
+ "img",
51042
+ "input",
51043
+ "isindex",
51044
+ "keygen",
51045
+ "link",
51046
+ "meta",
51047
+ "param",
51048
+ "source",
51049
+ "track",
51050
+ "wbr"
51051
+ ]);
51052
+ var foreignContextElements = /* @__PURE__ */ new Set(["math", "svg"]);
51053
+ var htmlIntegrationElements = /* @__PURE__ */ new Set([
51054
+ "mi",
51055
+ "mo",
51056
+ "mn",
51057
+ "ms",
51058
+ "mtext",
51059
+ "annotation-xml",
51060
+ "foreignObject",
51061
+ "desc",
51062
+ "title"
51063
+ ]);
51064
+ var svgTagNameAdjustments = /* @__PURE__ */ new Map([
51065
+ ["altglyph", "altGlyph"],
51066
+ ["altglyphdef", "altGlyphDef"],
51067
+ ["altglyphitem", "altGlyphItem"],
51068
+ ["animatecolor", "animateColor"],
51069
+ ["animatemotion", "animateMotion"],
51070
+ ["animatetransform", "animateTransform"],
51071
+ ["clippath", "clipPath"],
51072
+ ["feblend", "feBlend"],
51073
+ ["fecolormatrix", "feColorMatrix"],
51074
+ ["fecomponenttransfer", "feComponentTransfer"],
51075
+ ["fecomposite", "feComposite"],
51076
+ ["feconvolvematrix", "feConvolveMatrix"],
51077
+ ["fediffuselighting", "feDiffuseLighting"],
51078
+ ["fedisplacementmap", "feDisplacementMap"],
51079
+ ["fedistantlight", "feDistantLight"],
51080
+ ["fedropshadow", "feDropShadow"],
51081
+ ["feflood", "feFlood"],
51082
+ ["fefunca", "feFuncA"],
51083
+ ["fefuncb", "feFuncB"],
51084
+ ["fefuncg", "feFuncG"],
51085
+ ["fefuncr", "feFuncR"],
51086
+ ["fegaussianblur", "feGaussianBlur"],
51087
+ ["feimage", "feImage"],
51088
+ ["femerge", "feMerge"],
51089
+ ["femergenode", "feMergeNode"],
51090
+ ["femorphology", "feMorphology"],
51091
+ ["feoffset", "feOffset"],
51092
+ ["fepointlight", "fePointLight"],
51093
+ ["fespecularlighting", "feSpecularLighting"],
51094
+ ["fespotlight", "feSpotLight"],
51095
+ ["fetile", "feTile"],
51096
+ ["feturbulence", "feTurbulence"],
51097
+ ["foreignobject", "foreignObject"],
51098
+ ["glyphref", "glyphRef"],
51099
+ ["lineargradient", "linearGradient"],
51100
+ ["radialgradient", "radialGradient"],
51101
+ ["textpath", "textPath"]
51102
+ ]);
51103
+ var ForeignContext;
51104
+ (function(ForeignContext2) {
51105
+ ForeignContext2[ForeignContext2["None"] = 0] = "None";
51106
+ ForeignContext2[ForeignContext2["Svg"] = 1] = "Svg";
51107
+ ForeignContext2[ForeignContext2["MathML"] = 2] = "MathML";
51108
+ })(ForeignContext || (ForeignContext = {}));
51109
+ var reNameEnd = /\s|\//;
51110
+ var Parser = class {
51111
+ options;
51112
+ /** The start index of the last event. */
51113
+ startIndex = 0;
51114
+ /** The end index of the last event. */
51115
+ endIndex = 0;
51116
+ /**
51117
+ * Store the start index of the current open tag,
51118
+ * so we can update the start index for attributes.
51119
+ */
51120
+ openTagStart = 0;
51121
+ tagname = "";
51122
+ attribname = "";
51123
+ attribvalue = "";
51124
+ attribs = null;
51125
+ stack = [];
51126
+ foreignContext;
51127
+ cbs;
51128
+ lowerCaseTagNames;
51129
+ lowerCaseAttributeNames;
51130
+ recognizeSelfClosing;
51131
+ /** We are parsing HTML. Inverse of the `xmlMode` option. */
51132
+ htmlMode;
51133
+ tokenizer;
51134
+ buffers = [];
51135
+ bufferOffset = 0;
51136
+ /** The index of the last written buffer. Used when resuming after a `pause()`. */
51137
+ writeIndex = 0;
51138
+ /** Indicates whether the parser has finished running / `.end` has been called. */
51139
+ ended = false;
51140
+ constructor(cbs, options = {}) {
51141
+ this.options = options;
51142
+ this.cbs = cbs ?? {};
51143
+ this.htmlMode = !this.options.xmlMode;
51144
+ this.lowerCaseTagNames = options.lowerCaseTags ?? this.htmlMode;
51145
+ this.lowerCaseAttributeNames = options.lowerCaseAttributeNames ?? this.htmlMode;
51146
+ this.recognizeSelfClosing = options.recognizeSelfClosing ?? !this.htmlMode;
51147
+ this.tokenizer = new (options.Tokenizer ?? Tokenizer2)(this.options, this);
51148
+ this.foreignContext = [ForeignContext.None];
51149
+ this.cbs.onparserinit?.(this);
51150
+ }
51151
+ // Tokenizer event handlers
51152
+ /**
51153
+ * @param start Start index for the current parser event.
51154
+ * @param endIndex End index for the current parser event.
51155
+ * @internal
51156
+ */
51157
+ ontext(start, endIndex) {
51158
+ const data = this.getSlice(start, endIndex);
51159
+ this.endIndex = endIndex - 1;
51160
+ this.cbs.ontext?.(data);
51161
+ this.startIndex = endIndex;
51162
+ }
51163
+ /**
51164
+ * @param cp Current Unicode code point.
51165
+ * @param endIndex End index for the current parser event.
51166
+ * @internal
51167
+ */
51168
+ ontextentity(cp, endIndex) {
51169
+ this.endIndex = endIndex - 1;
51170
+ this.cbs.ontext?.(fromCodePoint(cp));
51171
+ this.startIndex = endIndex;
51172
+ }
51173
+ /** @internal */
51174
+ isInForeignContext() {
51175
+ return this.foreignContext[0] !== ForeignContext.None;
51176
+ }
51177
+ /**
51178
+ * Checks if the current tag is a void element. Override this if you want
51179
+ * to specify your own additional void elements.
51180
+ * @param name Name of the pseudo selector.
51181
+ */
51182
+ isVoidElement(name) {
51183
+ return this.htmlMode && voidElements.has(name);
51184
+ }
51185
+ /**
51186
+ * Read a tag name from the buffer.
51187
+ *
51188
+ * When `lowerCaseTagNames` is enabled (the default in HTML mode), the name
51189
+ * is lowercased and may be adjusted for SVG casing or the `image` → `img`
51190
+ * alias.
51191
+ * @param start Start index of the tag name in the buffer.
51192
+ * @param endIndex End index of the tag name in the buffer.
51193
+ */
51194
+ readTagName(start, endIndex) {
51195
+ const name = this.lowerCaseTagNames ? this.getSlice(start, endIndex).toLowerCase() : this.getSlice(start, endIndex);
51196
+ if (!(this.lowerCaseTagNames && this.htmlMode)) {
51197
+ return name;
51198
+ }
51199
+ if (this.foreignContext[0] === ForeignContext.Svg) {
51200
+ return svgTagNameAdjustments.get(name) ?? name;
51201
+ }
51202
+ if (this.foreignContext.length > 1) {
51203
+ const adjusted = svgTagNameAdjustments.get(name);
51204
+ if (adjusted !== void 0 && this.stack.includes(adjusted)) {
51205
+ return adjusted;
51206
+ }
51207
+ }
51208
+ if (!this.isInForeignContext()) {
51209
+ return name === "image" ? "img" : name;
51210
+ }
51211
+ return name;
51212
+ }
51213
+ /**
51214
+ * @param start Start index for the current parser event.
51215
+ * @param endIndex End index for the current parser event.
51216
+ * @internal
51217
+ */
51218
+ onopentagname(start, endIndex) {
51219
+ this.endIndex = endIndex;
51220
+ this.emitOpenTag(this.readTagName(start, endIndex));
51221
+ }
51222
+ emitOpenTag(name) {
51223
+ this.openTagStart = this.startIndex;
51224
+ this.tagname = name;
51225
+ if (this.htmlMode && name === "form" && this.stack.includes("form")) {
51226
+ this.tagname = "";
51227
+ return;
51228
+ }
51229
+ const impliesClose = this.htmlMode && openImpliesClose.get(name);
51230
+ if (impliesClose) {
51231
+ while (this.stack.length > 0 && impliesClose.has(this.stack[0])) {
51232
+ this.popElement(true);
51233
+ }
51234
+ }
51235
+ if (!this.isVoidElement(name)) {
51236
+ this.stack.unshift(name);
51237
+ if (this.htmlMode) {
51238
+ if (name === "svg") {
51239
+ this.foreignContext.unshift(ForeignContext.Svg);
51240
+ } else if (name === "math") {
51241
+ this.foreignContext.unshift(ForeignContext.MathML);
51242
+ } else if (htmlIntegrationElements.has(name)) {
51243
+ this.foreignContext.unshift(ForeignContext.None);
51244
+ }
51245
+ }
51246
+ }
51247
+ this.cbs.onopentagname?.(name);
51248
+ if (this.cbs.onopentag)
51249
+ this.attribs = {};
51250
+ }
51251
+ endOpenTag(isImplied) {
51252
+ this.startIndex = this.openTagStart;
51253
+ if (this.attribs) {
51254
+ this.cbs.onopentag?.(this.tagname, this.attribs, isImplied);
51255
+ this.attribs = null;
51256
+ }
51257
+ if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) {
51258
+ this.cbs.onclosetag(this.tagname, true);
51259
+ }
51260
+ this.tagname = "";
51261
+ }
51262
+ /**
51263
+ * @param endIndex End index for the current parser event.
51264
+ * @internal
51265
+ */
51266
+ onopentagend(endIndex) {
51267
+ this.endIndex = endIndex;
51268
+ this.endOpenTag(false);
51269
+ this.startIndex = endIndex + 1;
51270
+ }
51271
+ /**
51272
+ * @param start Start index for the current parser event.
51273
+ * @param endIndex End index for the current parser event.
51274
+ * @internal
51275
+ */
51276
+ onclosetag(start, endIndex) {
51277
+ this.endIndex = endIndex;
51278
+ const name = this.readTagName(start, endIndex);
51279
+ if (!this.isVoidElement(name)) {
51280
+ const pos = this.stack.indexOf(name);
51281
+ if (pos !== -1) {
51282
+ for (let index = 0; index < pos; index++) {
51283
+ this.popElement(true);
51284
+ }
51285
+ this.popElement(false);
51286
+ } else if (this.htmlMode && name === "p") {
51287
+ this.emitOpenTag("p");
51288
+ this.closeCurrentTag(true);
51289
+ }
51290
+ } else if (this.htmlMode && name === "br") {
51291
+ this.cbs.onopentagname?.("br");
51292
+ this.cbs.onopentag?.("br", {}, true);
51293
+ this.cbs.onclosetag?.("br", false);
51294
+ }
51295
+ this.startIndex = endIndex + 1;
51296
+ }
51297
+ /**
51298
+ * @param endIndex End index for the current parser event.
51299
+ * @internal
51300
+ */
51301
+ onselfclosingtag(endIndex) {
51302
+ this.endIndex = endIndex;
51303
+ if (this.recognizeSelfClosing || this.isInForeignContext()) {
51304
+ this.closeCurrentTag(false);
51305
+ this.startIndex = endIndex + 1;
51306
+ } else {
51307
+ this.onopentagend(endIndex);
51308
+ }
51309
+ }
51310
+ /**
51311
+ * Pop the top element off the stack, emit a close event, and maintain
51312
+ * the foreign context stack.
51313
+ * @param implied Whether this close is implied (not from an explicit end tag).
51314
+ */
51315
+ popElement(implied) {
51316
+ const element = this.stack.shift();
51317
+ if (this.htmlMode && (foreignContextElements.has(element) || htmlIntegrationElements.has(element))) {
51318
+ this.foreignContext.shift();
51319
+ }
51320
+ this.cbs.onclosetag?.(element, implied);
51321
+ }
51322
+ closeCurrentTag(isOpenImplied) {
51323
+ const name = this.tagname;
51324
+ this.endOpenTag(isOpenImplied);
51325
+ if (this.stack[0] === name) {
51326
+ this.popElement(!isOpenImplied);
51327
+ }
51328
+ }
51329
+ /**
51330
+ * @param start Start index for the current parser event.
51331
+ * @param endIndex End index for the current parser event.
51332
+ * @internal
51333
+ */
51334
+ onattribname(start, endIndex) {
51335
+ this.startIndex = start;
51336
+ const name = this.getSlice(start, endIndex);
51337
+ this.attribname = this.lowerCaseAttributeNames ? name.toLowerCase() : name;
51338
+ }
51339
+ /**
51340
+ * @param start Start index for the current parser event.
51341
+ * @param endIndex End index for the current parser event.
51342
+ * @internal
51343
+ */
51344
+ onattribdata(start, endIndex) {
51345
+ this.attribvalue += this.getSlice(start, endIndex);
51346
+ }
51347
+ /**
51348
+ * @param cp Current Unicode code point.
51349
+ * @internal
51350
+ */
51351
+ onattribentity(cp) {
51352
+ this.attribvalue += fromCodePoint(cp);
51353
+ }
51354
+ /**
51355
+ * @param quote Quote type used for the current attribute.
51356
+ * @param endIndex End index for the current parser event.
51357
+ * @internal
51358
+ */
51359
+ onattribend(quote, endIndex) {
51360
+ this.endIndex = endIndex;
51361
+ this.cbs.onattribute?.(this.attribname, this.attribvalue, quote === QuoteType.Double ? '"' : quote === QuoteType.Single ? "'" : quote === QuoteType.NoValue ? void 0 : null);
51362
+ if (this.attribs && !Object.hasOwn(this.attribs, this.attribname)) {
51363
+ this.attribs[this.attribname] = this.attribvalue;
51364
+ }
51365
+ this.attribvalue = "";
51366
+ }
51367
+ getInstructionName(value) {
51368
+ const index = value.search(reNameEnd);
51369
+ let name = index < 0 ? value : value.substr(0, index);
51370
+ if (this.lowerCaseTagNames) {
51371
+ name = name.toLowerCase();
51372
+ }
51373
+ return name;
51374
+ }
51375
+ /**
51376
+ * @param start Start index for the current parser event.
51377
+ * @param endIndex End index for the current parser event.
51378
+ * @internal
51379
+ */
51380
+ ondeclaration(start, endIndex) {
51381
+ this.endIndex = endIndex;
51382
+ const value = this.getSlice(start, endIndex);
51383
+ if (this.cbs.onprocessinginstruction) {
51384
+ const name = this.htmlMode ? this.lowerCaseTagNames ? DOCUMENT_TYPE : value.slice(0, DOCUMENT_TYPE.length) : this.getInstructionName(value);
51385
+ this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);
51386
+ }
51387
+ this.startIndex = endIndex + 1;
51388
+ }
51389
+ /**
51390
+ * @param start Start index for the current parser event.
51391
+ * @param endIndex End index for the current parser event.
51392
+ * @internal
51393
+ */
51394
+ onprocessinginstruction(start, endIndex) {
51395
+ this.endIndex = endIndex;
51396
+ const value = this.getSlice(start, endIndex);
51397
+ if (this.cbs.onprocessinginstruction) {
51398
+ const name = this.getInstructionName(value);
51399
+ this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);
51400
+ }
51401
+ this.startIndex = endIndex + 1;
51402
+ }
51403
+ /**
51404
+ * @param start Start index for the current parser event.
51405
+ * @param endIndex End index for the current parser event.
51406
+ * @param offset Offset applied when computing parser indices.
51407
+ * @internal
51408
+ */
51409
+ oncomment(start, endIndex, offset) {
51410
+ this.endIndex = endIndex;
51411
+ this.cbs.oncomment?.(this.getSlice(start, endIndex - offset));
51412
+ this.cbs.oncommentend?.();
51413
+ this.startIndex = endIndex + 1;
51414
+ }
51415
+ /**
51416
+ * @param start Start index for the current parser event.
51417
+ * @param endIndex End index for the current parser event.
51418
+ * @param offset Offset applied when computing parser indices.
51419
+ * @internal
51420
+ */
51421
+ oncdata(start, endIndex, offset) {
51422
+ this.endIndex = endIndex;
51423
+ const value = this.getSlice(start, endIndex - offset);
51424
+ if (!this.htmlMode || this.options.recognizeCDATA) {
51425
+ this.cbs.oncdatastart?.();
51426
+ this.cbs.ontext?.(value);
51427
+ this.cbs.oncdataend?.();
51428
+ } else if (this.isInForeignContext()) {
51429
+ this.cbs.ontext?.(value);
51430
+ } else {
51431
+ this.cbs.oncomment?.(`[CDATA[${value}]]`);
51432
+ this.cbs.oncommentend?.();
51433
+ }
51434
+ this.startIndex = endIndex + 1;
51435
+ }
51436
+ /** @internal */
51437
+ onend() {
51438
+ if (this.cbs.onclosetag) {
51439
+ this.endIndex = this.startIndex;
51440
+ for (let index = 0; index < this.stack.length; index++) {
51441
+ this.cbs.onclosetag(this.stack[index], true);
51442
+ }
51443
+ }
51444
+ this.cbs.onend?.();
51445
+ }
51446
+ /**
51447
+ * Resets the parser to a blank state, ready to parse a new HTML document
51448
+ */
51449
+ reset() {
51450
+ this.cbs.onreset?.();
51451
+ this.tokenizer.reset();
51452
+ this.tagname = "";
51453
+ this.attribname = "";
51454
+ this.attribvalue = "";
51455
+ this.attribs = null;
51456
+ this.stack.length = 0;
51457
+ this.startIndex = 0;
51458
+ this.endIndex = 0;
51459
+ this.cbs.onparserinit?.(this);
51460
+ this.buffers.length = 0;
51461
+ this.foreignContext.length = 0;
51462
+ this.foreignContext.unshift(ForeignContext.None);
51463
+ this.bufferOffset = 0;
51464
+ this.writeIndex = 0;
51465
+ this.ended = false;
51466
+ }
51467
+ /**
51468
+ * Resets the parser, then parses a complete document and
51469
+ * pushes it to the handler.
51470
+ * @param data Document to parse.
51471
+ */
51472
+ parseComplete(data) {
51473
+ this.reset();
51474
+ this.end(data);
51475
+ }
51476
+ getSlice(start, end) {
51477
+ if (start === end) {
51478
+ return "";
51479
+ }
51480
+ while (start - this.bufferOffset >= this.buffers[0].length) {
51481
+ this.shiftBuffer();
51482
+ }
51483
+ let slice = this.buffers[0].slice(start - this.bufferOffset, end - this.bufferOffset);
51484
+ while (end - this.bufferOffset > this.buffers[0].length) {
51485
+ this.shiftBuffer();
51486
+ slice += this.buffers[0].slice(0, end - this.bufferOffset);
51487
+ }
51488
+ return slice;
51489
+ }
51490
+ shiftBuffer() {
51491
+ this.bufferOffset += this.buffers[0].length;
51492
+ this.writeIndex--;
51493
+ this.buffers.shift();
51494
+ }
51495
+ /**
51496
+ * Parses a chunk of data and calls the corresponding callbacks.
51497
+ * @param chunk Chunk to parse.
51498
+ */
51499
+ write(chunk) {
51500
+ if (this.ended) {
51501
+ this.cbs.onerror?.(new Error(".write() after done!"));
51502
+ return;
51503
+ }
51504
+ this.buffers.push(chunk);
51505
+ if (this.tokenizer.running) {
51506
+ this.tokenizer.write(chunk);
51507
+ this.writeIndex++;
51508
+ }
51509
+ }
51510
+ /**
51511
+ * Parses the end of the buffer and clears the stack, calls onend.
51512
+ * @param chunk Optional final chunk to parse.
51513
+ */
51514
+ end(chunk) {
51515
+ if (this.ended) {
51516
+ this.cbs.onerror?.(new Error(".end() after done!"));
51517
+ return;
51518
+ }
51519
+ if (chunk)
51520
+ this.write(chunk);
51521
+ this.ended = true;
51522
+ this.tokenizer.end();
51523
+ }
51524
+ /**
51525
+ * Pauses parsing. The parser won't emit events until `resume` is called.
51526
+ */
51527
+ pause() {
51528
+ this.tokenizer.pause();
51529
+ }
51530
+ /**
51531
+ * Resumes parsing after `pause` was called.
51532
+ */
51533
+ resume() {
51534
+ this.tokenizer.resume();
51535
+ while (this.tokenizer.running && this.writeIndex < this.buffers.length) {
51536
+ this.tokenizer.write(this.buffers[this.writeIndex++]);
51537
+ }
51538
+ if (this.ended)
51539
+ this.tokenizer.end();
51540
+ }
51541
+ };
51542
+
51543
+ // node_modules/domelementtype/dist/index.js
51544
+ var ElementType;
51545
+ (function(ElementType2) {
51546
+ ElementType2["Root"] = "root";
51547
+ ElementType2["Text"] = "text";
51548
+ ElementType2["Directive"] = "directive";
51549
+ ElementType2["Comment"] = "comment";
51550
+ ElementType2["Script"] = "script";
51551
+ ElementType2["Style"] = "style";
51552
+ ElementType2["Tag"] = "tag";
51553
+ ElementType2["CDATA"] = "cdata";
51554
+ ElementType2["Doctype"] = "doctype";
51555
+ })(ElementType || (ElementType = {}));
51556
+ function isTag(element) {
51557
+ return element.type === ElementType.Tag || element.type === ElementType.Script || element.type === ElementType.Style;
51558
+ }
51559
+ var Root = ElementType.Root;
51560
+ var Text = ElementType.Text;
51561
+ var Directive = ElementType.Directive;
51562
+ var Comment = ElementType.Comment;
51563
+ var Script = ElementType.Script;
51564
+ var Style = ElementType.Style;
51565
+ var Tag = ElementType.Tag;
51566
+ var CDATA = ElementType.CDATA;
51567
+ var Doctype = ElementType.Doctype;
51568
+
51569
+ // node_modules/domhandler/dist/node.js
51570
+ var Node = class {
51571
+ /** Parent of the node */
51572
+ parent = null;
51573
+ /** Previous sibling */
51574
+ prev = null;
51575
+ /** Next sibling */
51576
+ next = null;
51577
+ /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
51578
+ startIndex = null;
51579
+ /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
51580
+ endIndex = null;
51581
+ // Read-write aliases for properties
51582
+ /**
51583
+ * Same as {@link parent}.
51584
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
51585
+ */
51586
+ get parentNode() {
51587
+ return this.parent;
51588
+ }
51589
+ set parentNode(parent) {
51590
+ this.parent = parent;
51591
+ }
51592
+ /**
51593
+ * Same as {@link prev}.
51594
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
51595
+ */
51596
+ get previousSibling() {
51597
+ return this.prev;
51598
+ }
51599
+ set previousSibling(previous) {
51600
+ this.prev = previous;
51601
+ }
51602
+ /**
51603
+ * Same as {@link next}.
51604
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
51605
+ */
51606
+ get nextSibling() {
51607
+ return this.next;
51608
+ }
51609
+ set nextSibling(next) {
51610
+ this.next = next;
51611
+ }
51612
+ /**
51613
+ * Clone this node, and optionally its children.
51614
+ * @param recursive Clone child nodes as well.
51615
+ * @returns A clone of the node.
51616
+ */
51617
+ cloneNode(recursive3 = false) {
51618
+ return cloneNode(this, recursive3);
51619
+ }
51620
+ };
51621
+ var DataNode = class extends Node {
51622
+ data;
51623
+ /**
51624
+ * @param data The content of the data node
51625
+ */
51626
+ constructor(data) {
51627
+ super();
51628
+ this.data = data;
51629
+ }
51630
+ /**
51631
+ * Same as {@link data}.
51632
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
51633
+ */
51634
+ get nodeValue() {
51635
+ return this.data;
51636
+ }
51637
+ set nodeValue(data) {
51638
+ this.data = data;
51639
+ }
51640
+ };
51641
+ var Text2 = class extends DataNode {
51642
+ type = ElementType.Text;
51643
+ get nodeType() {
51644
+ return 3;
51645
+ }
51646
+ };
51647
+ var Comment2 = class extends DataNode {
51648
+ type = ElementType.Comment;
51649
+ get nodeType() {
51650
+ return 8;
51651
+ }
51652
+ };
51653
+ var ProcessingInstruction = class extends DataNode {
51654
+ type = ElementType.Directive;
51655
+ name;
51656
+ constructor(name, data) {
51657
+ super(data);
51658
+ this.name = name;
51659
+ }
51660
+ get nodeType() {
51661
+ return 1;
51662
+ }
51663
+ /** If this is a doctype, the document type name (parse5 only). */
51664
+ "x-name";
51665
+ /** If this is a doctype, the document type public identifier (parse5 only). */
51666
+ "x-publicId";
51667
+ /** If this is a doctype, the document type system identifier (parse5 only). */
51668
+ "x-systemId";
51669
+ };
51670
+ var NodeWithChildren = class extends Node {
51671
+ children;
51672
+ /**
51673
+ * @param children Children of the node. Only certain node types can have children.
51674
+ */
51675
+ constructor(children) {
51676
+ super();
51677
+ this.children = children;
51678
+ }
51679
+ // Aliases
51680
+ /** First child of the node. */
51681
+ get firstChild() {
51682
+ return this.children[0] ?? null;
51683
+ }
51684
+ /** Last child of the node. */
51685
+ get lastChild() {
51686
+ return this.children.length > 0 ? this.children[this.children.length - 1] : null;
51687
+ }
51688
+ /**
51689
+ * Same as {@link children}.
51690
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
51691
+ */
51692
+ get childNodes() {
51693
+ return this.children;
51694
+ }
51695
+ set childNodes(children) {
51696
+ this.children = children;
51697
+ }
51698
+ };
51699
+ var CDATA2 = class extends NodeWithChildren {
51700
+ type = ElementType.CDATA;
51701
+ get nodeType() {
51702
+ return 4;
51703
+ }
51704
+ };
51705
+ var Document = class extends NodeWithChildren {
51706
+ type = ElementType.Root;
51707
+ get nodeType() {
51708
+ return 9;
51709
+ }
51710
+ };
51711
+ var Element = class extends NodeWithChildren {
51712
+ name;
51713
+ attribs;
51714
+ type;
51715
+ /**
51716
+ * @param name Name of the tag, eg. `div`, `span`.
51717
+ * @param attribs Object mapping attribute names to attribute values.
51718
+ * @param children Children of the node.
51719
+ * @param type Node type used for the new node instance.
51720
+ */
51721
+ constructor(name, attribs, children = [], type = name === "script" ? ElementType.Script : name === "style" ? ElementType.Style : ElementType.Tag) {
51722
+ super(children);
51723
+ this.name = name;
51724
+ this.attribs = attribs;
51725
+ this.type = type;
51726
+ }
51727
+ get nodeType() {
51728
+ return 1;
51729
+ }
51730
+ // DOM Level 1 aliases
51731
+ /**
51732
+ * Same as {@link name}.
51733
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
51734
+ */
51735
+ get tagName() {
51736
+ return this.name;
51737
+ }
51738
+ set tagName(name) {
51739
+ this.name = name;
51740
+ }
51741
+ get attributes() {
51742
+ return Object.keys(this.attribs).map((name) => ({
51743
+ name,
51744
+ value: this.attribs[name],
51745
+ namespace: this["x-attribsNamespace"]?.[name],
51746
+ prefix: this["x-attribsPrefix"]?.[name]
51747
+ }));
51748
+ }
51749
+ /** Element namespace (parse5 only). */
51750
+ namespace;
51751
+ /** Element attribute namespaces (parse5 only). */
51752
+ "x-attribsNamespace";
51753
+ /** Element attribute namespace-related prefixes (parse5 only). */
51754
+ "x-attribsPrefix";
51755
+ };
51756
+ function isTag2(node3) {
51757
+ return isTag(node3);
51758
+ }
51759
+ function isCDATA(node3) {
51760
+ return node3.type === ElementType.CDATA;
51761
+ }
51762
+ function isText(node3) {
51763
+ return node3.type === ElementType.Text;
51764
+ }
51765
+ function isComment(node3) {
51766
+ return node3.type === ElementType.Comment;
51767
+ }
51768
+ function isDirective(node3) {
51769
+ return node3.type === ElementType.Directive;
51770
+ }
51771
+ function isDocument(node3) {
51772
+ return node3.type === ElementType.Root;
51773
+ }
51774
+ function hasChildren(node3) {
51775
+ return Object.hasOwn(node3, "children");
51776
+ }
51777
+ function cloneNode(node3, recursive3 = false) {
51778
+ let result;
51779
+ if (isText(node3)) {
51780
+ result = new Text2(node3.data);
51781
+ } else if (isComment(node3)) {
51782
+ result = new Comment2(node3.data);
51783
+ } else if (isTag2(node3)) {
51784
+ const children = recursive3 ? cloneChildren(node3.children) : [];
51785
+ const clone4 = new Element(node3.name, { ...node3.attribs }, children);
51786
+ for (const child of children) {
51787
+ child.parent = clone4;
51788
+ }
51789
+ if (node3.namespace != null) {
51790
+ clone4.namespace = node3.namespace;
51791
+ }
51792
+ if (node3["x-attribsNamespace"]) {
51793
+ clone4["x-attribsNamespace"] = { ...node3["x-attribsNamespace"] };
51794
+ }
51795
+ if (node3["x-attribsPrefix"]) {
51796
+ clone4["x-attribsPrefix"] = { ...node3["x-attribsPrefix"] };
51797
+ }
51798
+ result = clone4;
51799
+ } else if (isCDATA(node3)) {
51800
+ const children = recursive3 ? cloneChildren(node3.children) : [];
51801
+ const clone4 = new CDATA2(children);
51802
+ for (const child of children) {
51803
+ child.parent = clone4;
51804
+ }
51805
+ result = clone4;
51806
+ } else if (isDocument(node3)) {
51807
+ const children = recursive3 ? cloneChildren(node3.children) : [];
51808
+ const clone4 = new Document(children);
51809
+ for (const child of children) {
51810
+ child.parent = clone4;
51811
+ }
51812
+ if (node3["x-mode"]) {
51813
+ clone4["x-mode"] = node3["x-mode"];
51814
+ }
51815
+ result = clone4;
51816
+ } else if (isDirective(node3)) {
51817
+ const instruction = new ProcessingInstruction(node3.name, node3.data);
51818
+ if (node3["x-name"] != null) {
51819
+ instruction["x-name"] = node3["x-name"];
51820
+ instruction["x-publicId"] = node3["x-publicId"];
51821
+ instruction["x-systemId"] = node3["x-systemId"];
51822
+ }
51823
+ result = instruction;
51824
+ } else {
51825
+ throw new Error(`Not implemented yet: ${node3.type}`);
51826
+ }
51827
+ result.startIndex = node3.startIndex;
51828
+ result.endIndex = node3.endIndex;
51829
+ if (node3.sourceCodeLocation != null) {
51830
+ result.sourceCodeLocation = node3.sourceCodeLocation;
51831
+ }
51832
+ return result;
51833
+ }
51834
+ function cloneChildren(childs) {
51835
+ const children = childs.map((child) => cloneNode(child, true));
51836
+ for (let index = 1; index < children.length; index++) {
51837
+ children[index].prev = children[index - 1];
51838
+ children[index - 1].next = children[index];
51839
+ }
51840
+ return children;
51841
+ }
51842
+
51843
+ // node_modules/domhandler/dist/index.js
51844
+ var defaultOptions = {
51845
+ withStartIndices: false,
51846
+ withEndIndices: false,
51847
+ xmlMode: false
51848
+ };
51849
+ var DomHandler = class {
51850
+ /** The elements of the DOM */
51851
+ dom = [];
51852
+ /** The root element for the DOM */
51853
+ root = new Document(this.dom);
51854
+ /** Called once parsing has completed. */
51855
+ callback;
51856
+ /** Settings for the handler. */
51857
+ options;
51858
+ /** Callback whenever a tag is closed. */
51859
+ elementCB;
51860
+ /** Indicated whether parsing has been completed. */
51861
+ done = false;
51862
+ /** Stack of open tags. */
51863
+ tagStack = [this.root];
51864
+ /** A data node that is still being written to. */
51865
+ lastNode = null;
51866
+ /** Reference to the parser instance. Used for location information. */
51867
+ parser = null;
51868
+ /**
51869
+ * @param callback Called once parsing has completed.
51870
+ * @param options Settings for the handler.
51871
+ * @param elementCB Callback whenever a tag is closed.
51872
+ */
51873
+ constructor(callback, options, elementCB) {
51874
+ if (typeof options === "function") {
51875
+ elementCB = options;
51876
+ options = defaultOptions;
51877
+ }
51878
+ if (typeof callback === "object") {
51879
+ options = callback;
51880
+ callback = void 0;
51881
+ }
51882
+ this.callback = callback ?? null;
51883
+ this.options = options ?? defaultOptions;
51884
+ this.elementCB = elementCB ?? null;
51885
+ }
51886
+ onparserinit(parser) {
51887
+ this.parser = parser;
51888
+ }
51889
+ // Resets the handler back to starting state
51890
+ onreset() {
51891
+ this.dom = [];
51892
+ this.root = new Document(this.dom);
51893
+ this.done = false;
51894
+ this.tagStack = [this.root];
51895
+ this.lastNode = null;
51896
+ this.parser = null;
51897
+ }
51898
+ // Signals the handler that parsing is done
51899
+ onend() {
51900
+ if (this.done)
51901
+ return;
51902
+ this.done = true;
51903
+ this.parser = null;
51904
+ this.handleCallback(null);
51905
+ }
51906
+ onerror(error42) {
51907
+ this.handleCallback(error42);
51908
+ }
51909
+ onclosetag() {
51910
+ this.lastNode = null;
51911
+ const element = this.tagStack.pop();
51912
+ if (this.options.withEndIndices && this.parser) {
51913
+ element.endIndex = this.parser.endIndex;
51914
+ }
51915
+ if (this.elementCB)
51916
+ this.elementCB(element);
51917
+ }
51918
+ onopentag(name, attribs) {
51919
+ const type = this.options.xmlMode ? ElementType.Tag : void 0;
51920
+ const element = new Element(name, attribs, void 0, type);
51921
+ this.addNode(element);
51922
+ this.tagStack.push(element);
51923
+ }
51924
+ ontext(data) {
51925
+ const { lastNode } = this;
51926
+ if (lastNode && lastNode.type === ElementType.Text) {
51927
+ lastNode.data += data;
51928
+ if (this.options.withEndIndices && this.parser) {
51929
+ lastNode.endIndex = this.parser.endIndex;
51930
+ }
51931
+ } else {
51932
+ const node3 = new Text2(data);
51933
+ this.addNode(node3);
51934
+ this.lastNode = node3;
51935
+ }
51936
+ }
51937
+ oncomment(data) {
51938
+ if (this.lastNode && this.lastNode.type === ElementType.Comment) {
51939
+ this.lastNode.data += data;
51940
+ return;
51941
+ }
51942
+ const node3 = new Comment2(data);
51943
+ this.addNode(node3);
51944
+ this.lastNode = node3;
51945
+ }
51946
+ oncommentend() {
51947
+ this.lastNode = null;
51948
+ }
51949
+ oncdatastart() {
51950
+ const text = new Text2("");
51951
+ const node3 = new CDATA2([text]);
51952
+ this.addNode(node3);
51953
+ text.parent = node3;
51954
+ this.lastNode = text;
51955
+ }
51956
+ oncdataend() {
51957
+ this.lastNode = null;
51958
+ }
51959
+ onprocessinginstruction(name, data) {
51960
+ const node3 = new ProcessingInstruction(name, data);
51961
+ this.addNode(node3);
51962
+ }
51963
+ handleCallback(error42) {
51964
+ if (typeof this.callback === "function") {
51965
+ this.callback(error42, this.dom);
51966
+ } else if (error42) {
51967
+ throw error42;
51968
+ }
51969
+ }
51970
+ addNode(node3) {
51971
+ const parent = this.tagStack[this.tagStack.length - 1];
51972
+ const previousSibling = parent.children[parent.children.length - 1];
51973
+ if (this.options.withStartIndices && this.parser) {
51974
+ node3.startIndex = this.parser.startIndex;
51975
+ }
51976
+ if (this.options.withEndIndices && this.parser) {
51977
+ node3.endIndex = this.parser.endIndex;
51978
+ }
51979
+ parent.children.push(node3);
51980
+ if (previousSibling) {
51981
+ node3.prev = previousSibling;
51982
+ previousSibling.next = node3;
51983
+ }
51984
+ node3.parent = parent;
51985
+ this.lastNode = null;
51986
+ }
51987
+ };
51988
+
51989
+ // node_modules/domutils/dist/index.js
51990
+ var dist_exports2 = {};
51991
+ __export(dist_exports2, {
51992
+ DocumentPosition: () => DocumentPosition,
51993
+ append: () => append,
51994
+ appendChild: () => appendChild,
51995
+ compareDocumentPosition: () => compareDocumentPosition,
51996
+ existsOne: () => existsOne,
51997
+ filter: () => filter,
51998
+ find: () => find,
51999
+ findAll: () => findAll,
52000
+ findOne: () => findOne,
52001
+ getAttributeValue: () => getAttributeValue,
52002
+ getChildren: () => getChildren,
52003
+ getElementById: () => getElementById,
52004
+ getElements: () => getElements,
52005
+ getElementsByClassName: () => getElementsByClassName,
52006
+ getElementsByTagName: () => getElementsByTagName,
52007
+ getElementsByTagType: () => getElementsByTagType,
52008
+ getFeed: () => getFeed,
52009
+ getInnerHTML: () => getInnerHTML,
52010
+ getName: () => getName,
52011
+ getOuterHTML: () => getOuterHTML,
52012
+ getParent: () => getParent,
52013
+ getSiblings: () => getSiblings,
52014
+ getText: () => getText,
52015
+ hasAttrib: () => hasAttrib,
52016
+ innerText: () => innerText,
52017
+ nextElementSibling: () => nextElementSibling,
52018
+ prepend: () => prepend,
52019
+ prependChild: () => prependChild,
52020
+ prevElementSibling: () => prevElementSibling,
52021
+ removeElement: () => removeElement,
52022
+ removeSubsets: () => removeSubsets,
52023
+ replaceElement: () => replaceElement,
52024
+ testElement: () => testElement,
52025
+ textContent: () => textContent,
52026
+ uniqueSort: () => uniqueSort
52027
+ });
52028
+
52029
+ // node_modules/domutils/dist/querying.js
52030
+ function filter(test, node3, recurse = true, limit = Number.POSITIVE_INFINITY) {
52031
+ return find(test, Array.isArray(node3) ? node3 : [node3], recurse, limit);
52032
+ }
52033
+ function find(test, nodes, recurse, limit) {
52034
+ const result = [];
52035
+ const nodeStack = [Array.isArray(nodes) ? nodes : [nodes]];
52036
+ const indexStack = [0];
52037
+ for (; ; ) {
52038
+ if (indexStack[0] >= nodeStack[0].length) {
52039
+ if (indexStack.length === 1) {
52040
+ return result;
52041
+ }
52042
+ nodeStack.shift();
52043
+ indexStack.shift();
52044
+ continue;
52045
+ }
52046
+ const element = nodeStack[0][indexStack[0]++];
52047
+ if (test(element)) {
52048
+ result.push(element);
52049
+ if (--limit <= 0)
52050
+ return result;
52051
+ }
52052
+ if (recurse && hasChildren(element) && element.children.length > 0) {
52053
+ indexStack.unshift(0);
52054
+ nodeStack.unshift(element.children);
52055
+ }
52056
+ }
52057
+ }
52058
+ function findOne(test, nodes, recurse = true) {
52059
+ const searchedNodes = Array.isArray(nodes) ? nodes : [nodes];
52060
+ for (const node3 of searchedNodes) {
52061
+ if (isTag2(node3) && test(node3)) {
52062
+ return node3;
52063
+ }
52064
+ if (recurse && hasChildren(node3) && node3.children.length > 0) {
52065
+ const found = findOne(test, node3.children, true);
52066
+ if (found)
52067
+ return found;
52068
+ }
52069
+ }
52070
+ return null;
52071
+ }
52072
+ function existsOne(test, nodes) {
52073
+ return (Array.isArray(nodes) ? nodes : [nodes]).some((node3) => isTag2(node3) && test(node3) || hasChildren(node3) && existsOne(test, node3.children));
52074
+ }
52075
+ function findAll(test, nodes) {
52076
+ const result = [];
52077
+ const nodeStack = [Array.isArray(nodes) ? nodes : [nodes]];
52078
+ const indexStack = [0];
52079
+ for (; ; ) {
52080
+ if (indexStack[0] >= nodeStack[0].length) {
52081
+ if (nodeStack.length === 1) {
52082
+ return result;
52083
+ }
52084
+ nodeStack.shift();
52085
+ indexStack.shift();
52086
+ continue;
52087
+ }
52088
+ const element = nodeStack[0][indexStack[0]++];
52089
+ if (isTag2(element) && test(element))
52090
+ result.push(element);
52091
+ if (hasChildren(element) && element.children.length > 0) {
52092
+ indexStack.unshift(0);
52093
+ nodeStack.unshift(element.children);
52094
+ }
52095
+ }
52096
+ }
52097
+
52098
+ // node_modules/domutils/dist/legacy.js
52099
+ var Checks = {
52100
+ tag_name(name) {
52101
+ if (typeof name === "function") {
52102
+ return (element) => isTag2(element) && name(element.name);
52103
+ }
52104
+ if (name === "*") {
52105
+ return isTag2;
52106
+ }
52107
+ return (element) => isTag2(element) && element.name === name;
52108
+ },
52109
+ tag_type(type) {
52110
+ if (typeof type === "function") {
52111
+ return (element) => type(element.type);
52112
+ }
52113
+ return (element) => element.type === type;
52114
+ },
52115
+ tag_contains(data) {
52116
+ if (typeof data === "function") {
52117
+ return (element) => isText(element) && data(element.data);
52118
+ }
52119
+ return (element) => isText(element) && element.data === data;
52120
+ }
52121
+ };
52122
+ function getAttribCheck(attrib, value) {
52123
+ if (typeof value === "function") {
52124
+ return (element) => isTag2(element) && value(element.attribs[attrib]);
52125
+ }
52126
+ return (element) => isTag2(element) && element.attribs[attrib] === value;
52127
+ }
52128
+ function combineFuncs(a, b) {
52129
+ return (element) => a(element) || b(element);
52130
+ }
52131
+ function compileTest(options) {
52132
+ const funcs = Object.keys(options).map((key) => {
52133
+ const value = options[key];
52134
+ return Object.hasOwn(Checks, key) ? Checks[key](value) : getAttribCheck(key, value);
52135
+ });
52136
+ return funcs.length === 0 ? null : funcs.reduce(combineFuncs);
52137
+ }
52138
+ function testElement(options, node3) {
52139
+ const test = compileTest(options);
52140
+ return test ? test(node3) : true;
52141
+ }
52142
+ function getElements(options, nodes, recurse, limit = Number.POSITIVE_INFINITY) {
52143
+ const test = compileTest(options);
52144
+ return test ? filter(test, nodes, recurse, limit) : [];
52145
+ }
52146
+ function getElementById(id, nodes, recurse = true) {
52147
+ if (!Array.isArray(nodes))
52148
+ nodes = [nodes];
52149
+ return findOne(getAttribCheck("id", id), nodes, recurse);
52150
+ }
52151
+ function getElementsByTagName(tagName, nodes, recurse = true, limit = Number.POSITIVE_INFINITY) {
52152
+ return filter(Checks["tag_name"](tagName), nodes, recurse, limit);
52153
+ }
52154
+ function getElementsByClassName(className, nodes, recurse = true, limit = Number.POSITIVE_INFINITY) {
52155
+ return filter(getAttribCheck("class", className), nodes, recurse, limit);
52156
+ }
52157
+ function getElementsByTagType(type, nodes, recurse = true, limit = Number.POSITIVE_INFINITY) {
52158
+ return filter(Checks["tag_type"](type), nodes, recurse, limit);
52159
+ }
52160
+
52161
+ // node_modules/entities/dist/escape.js
52162
+ function getEscape(char) {
52163
+ return char === 34 ? "&quot;" : char === 38 ? "&amp;" : char === 39 ? "&apos;" : char === 60 ? "&lt;" : char === 62 ? "&gt;" : "&nbsp;";
52164
+ }
52165
+ var XML_BITSET_VALUE = 1342177476;
52166
+ var xmlEncodeRegex = /["&'<>\u0080-\uFFFF]/g;
52167
+ function isXmlEscapable(code) {
52168
+ return code >= 128 || code >= 32 && code < 64 && (XML_BITSET_VALUE >>> code & 1) === 1;
52169
+ }
52170
+ function encodeXML(input) {
52171
+ const { length } = input;
52172
+ let out;
52173
+ let last2 = 0;
52174
+ let index = 0;
52175
+ while (index < length) {
52176
+ const char = input.charCodeAt(index);
52177
+ if (!isXmlEscapable(char)) {
52178
+ const bound = Math.min(index + 32, length);
52179
+ let next = index + 1;
52180
+ while (next < bound && !isXmlEscapable(input.charCodeAt(next))) {
52181
+ next++;
52182
+ }
52183
+ if (next < bound) {
52184
+ index = next;
52185
+ continue;
52186
+ }
52187
+ if (next >= length)
52188
+ break;
52189
+ xmlEncodeRegex.lastIndex = next;
52190
+ if (!xmlEncodeRegex.test(input))
52191
+ break;
52192
+ index = xmlEncodeRegex.lastIndex - 1;
52193
+ continue;
52194
+ }
52195
+ if (out === void 0)
52196
+ out = input.substring(0, index);
52197
+ else if (last2 !== index)
52198
+ out += input.substring(last2, index);
52199
+ if (char < 64) {
52200
+ out += getEscape(char);
52201
+ last2 = index += 1;
52202
+ continue;
52203
+ }
52204
+ const cp = input.codePointAt(index);
52205
+ out += `&#x${cp.toString(16)};`;
52206
+ if (cp !== char)
52207
+ index++;
52208
+ last2 = index += 1;
52209
+ }
52210
+ if (out === void 0)
52211
+ return input;
52212
+ if (last2 < length)
52213
+ out += input.substr(last2);
52214
+ return out;
52215
+ }
52216
+ function escapeWithRegex(re, data) {
52217
+ re.lastIndex = 0;
52218
+ if (!re.test(data))
52219
+ return data;
52220
+ let out = "";
52221
+ let last2 = 0;
52222
+ do {
52223
+ const index = re.lastIndex - 1;
52224
+ if (last2 !== index)
52225
+ out += data.substring(last2, index);
52226
+ const char = data.charCodeAt(index);
52227
+ out += getEscape(char);
52228
+ last2 = index + 1;
52229
+ } while (re.test(data));
52230
+ return out + data.substring(last2);
52231
+ }
52232
+ var attributeEscapeRegex = /["&\u{A0}]/gu;
52233
+ function escapeAttribute(data) {
52234
+ return escapeWithRegex(attributeEscapeRegex, data);
52235
+ }
52236
+ var textEscapeRegex = /[&<>\u{A0}]/gu;
52237
+ function escapeText(data) {
52238
+ return escapeWithRegex(textEscapeRegex, data);
52239
+ }
52240
+
52241
+ // node_modules/entities/dist/index.js
52242
+ var EntityLevel;
52243
+ (function(EntityLevel2) {
52244
+ EntityLevel2[EntityLevel2["XML"] = 0] = "XML";
52245
+ EntityLevel2[EntityLevel2["HTML"] = 1] = "HTML";
52246
+ })(EntityLevel || (EntityLevel = {}));
52247
+ var EncodingMode;
52248
+ (function(EncodingMode2) {
52249
+ EncodingMode2[EncodingMode2["UTF8"] = 0] = "UTF8";
52250
+ EncodingMode2[EncodingMode2["ASCII"] = 1] = "ASCII";
52251
+ EncodingMode2[EncodingMode2["Extensive"] = 2] = "Extensive";
52252
+ EncodingMode2[EncodingMode2["Attribute"] = 3] = "Attribute";
52253
+ EncodingMode2[EncodingMode2["Text"] = 4] = "Text";
52254
+ })(EncodingMode || (EncodingMode = {}));
52255
+
52256
+ // node_modules/dom-serializer/dist/foreign-names.js
52257
+ var elementNames = new Map("altGlyph altGlyphDef altGlyphItem animateColor animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence foreignObject glyphRef linearGradient radialGradient textPath".split(" ").map((name) => [name.toLowerCase(), name]));
52258
+ var attributeNames = new Map("definitionURL attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits diffuseConstant edgeMode filterUnits glyphRef gradientTransform gradientUnits kernelMatrix kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan".split(" ").map((name) => [name.toLowerCase(), name]));
52259
+
52260
+ // node_modules/dom-serializer/dist/index.js
52261
+ var unencodedElements = new Set("style script xmp iframe noembed noframes plaintext noscript".split(" "));
52262
+ var voidElements2 = new Set("area base basefont br col command embed frame hr img input isindex keygen link meta param source track wbr".split(" "));
52263
+ var foreignElements = /* @__PURE__ */ new Set(["svg", "math"]);
52264
+ var foreignModeIntegrationPoints = new Set("mi mo mn ms mtext annotation-xml foreignObject desc title".split(" "));
52265
+ function render2(node3, options = {}) {
52266
+ const nodes = "length" in node3 ? node3 : [node3];
52267
+ const xmlMode = options.xmlMode ?? false;
52268
+ let output = "";
52269
+ for (let index = 0; index < nodes.length; index++) {
52270
+ output += renderNode(nodes[index], options, xmlMode);
52271
+ }
52272
+ return output;
52273
+ }
52274
+ var dist_default = render2;
52275
+ function renderChildren(children, options, xmlMode) {
52276
+ let output = "";
52277
+ for (let index = 0; index < children.length; index++) {
52278
+ output += renderNode(children[index], options, xmlMode);
52279
+ }
52280
+ return output;
52281
+ }
52282
+ function renderNode(node3, options, xmlMode) {
52283
+ switch (node3.type) {
52284
+ case Root: {
52285
+ return renderChildren(node3.children, options, xmlMode);
52286
+ }
52287
+ case Directive: {
52288
+ return `<${node3.data}>`;
52289
+ }
52290
+ case Comment: {
52291
+ return `<!--${node3.data}-->`;
52292
+ }
52293
+ case CDATA: {
52294
+ return `<![CDATA[${node3.children[0].data}]]>`;
52295
+ }
52296
+ case Script:
52297
+ case Style:
52298
+ case Tag: {
52299
+ return renderTag(node3, options, xmlMode);
52300
+ }
52301
+ case Text: {
52302
+ const element = node3;
52303
+ const data = element.data || "";
52304
+ if ((options.encodeEntities ?? options.decodeEntities) !== false && !(!xmlMode && element.parent && unencodedElements.has(element.parent.name))) {
52305
+ return xmlMode || options.encodeEntities !== "utf8" ? encodeXML(data) : escapeText(data);
52306
+ }
52307
+ return data;
52308
+ }
52309
+ }
52310
+ }
52311
+ function renderTag(element, options, xmlMode) {
52312
+ if (xmlMode === "foreign") {
52313
+ element.name = elementNames.get(element.name) ?? element.name;
52314
+ if (element.parent && foreignModeIntegrationPoints.has(element.parent.name)) {
52315
+ xmlMode = false;
52316
+ }
52317
+ }
52318
+ if (!xmlMode && foreignElements.has(element.name)) {
52319
+ xmlMode = "foreign";
52320
+ }
52321
+ const { name, children } = element;
52322
+ const isVoid = !xmlMode && voidElements2.has(name);
52323
+ let tag = `<${name}${formatAttributes(element.attribs, options, xmlMode)}`;
52324
+ if (children.length === 0 && (xmlMode ? options.selfClosingTags !== false : options.selfClosingTags && isVoid)) {
52325
+ tag += xmlMode ? "/>" : " />";
52326
+ } else {
52327
+ tag += ">";
52328
+ if (children.length > 0) {
52329
+ tag += renderChildren(children, options, xmlMode);
52330
+ }
52331
+ if (!isVoid) {
52332
+ tag += `</${name}>`;
52333
+ }
52334
+ }
52335
+ return tag;
52336
+ }
52337
+ function replaceQuotes(value) {
52338
+ return value.replaceAll('"', "&quot;");
52339
+ }
52340
+ function formatAttributes(attributes, options, xmlMode) {
52341
+ if (!attributes)
52342
+ return "";
52343
+ const encode13 = (options.encodeEntities ?? options.decodeEntities) === false ? replaceQuotes : xmlMode || options.encodeEntities !== "utf8" ? encodeXML : escapeAttribute;
52344
+ const isForeign = xmlMode === "foreign";
52345
+ const showEmpty = !!(options.emptyAttrs ?? xmlMode);
52346
+ let result = "";
52347
+ for (const key in attributes) {
52348
+ if (!Object.hasOwn(attributes, key))
52349
+ continue;
52350
+ const value = attributes[key];
52351
+ const k = isForeign ? attributeNames.get(key) ?? key : key;
52352
+ result += !showEmpty && (value == null || value === "") ? ` ${k}` : ` ${k}="${encode13(value == null ? "" : String(value))}"`;
52353
+ }
52354
+ return result;
52355
+ }
52356
+
52357
+ // node_modules/domutils/dist/stringify.js
52358
+ function getOuterHTML(node3, options) {
52359
+ return dist_default(node3, options);
52360
+ }
52361
+ function getInnerHTML(node3, options) {
52362
+ return hasChildren(node3) ? node3.children.map((node4) => getOuterHTML(node4, options)).join("") : "";
52363
+ }
52364
+ function getText(node3) {
52365
+ if (Array.isArray(node3))
52366
+ return node3.map(getText).join("");
52367
+ if (isTag2(node3))
52368
+ return node3.name === "br" ? "\n" : getText(node3.children);
52369
+ if (isCDATA(node3))
52370
+ return getText(node3.children);
52371
+ if (isText(node3))
52372
+ return node3.data;
52373
+ return "";
52374
+ }
52375
+ function textContent(node3) {
52376
+ if (Array.isArray(node3))
52377
+ return node3.map(textContent).join("");
52378
+ if (hasChildren(node3) && !isComment(node3)) {
52379
+ return textContent(node3.children);
52380
+ }
52381
+ if (isText(node3))
52382
+ return node3.data;
52383
+ return "";
52384
+ }
52385
+ function innerText(node3) {
52386
+ if (Array.isArray(node3))
52387
+ return node3.map(innerText).join("");
52388
+ if (hasChildren(node3) && (node3.type === ElementType.Tag || isCDATA(node3))) {
52389
+ return innerText(node3.children);
52390
+ }
52391
+ if (isText(node3))
52392
+ return node3.data;
52393
+ return "";
52394
+ }
52395
+
52396
+ // node_modules/domutils/dist/feeds.js
52397
+ function getFeed(document) {
52398
+ const feedRoot = getOneElement(isValidFeed, document);
52399
+ return feedRoot ? feedRoot.name === "feed" ? getAtomFeed(feedRoot) : getRssFeed(feedRoot) : null;
52400
+ }
52401
+ function getAtomFeed(feedRoot) {
52402
+ const childs = feedRoot.children;
52403
+ const feed = {
52404
+ type: "atom",
52405
+ items: getElementsByTagName("entry", childs).map((item) => {
52406
+ const { children } = item;
52407
+ const entry = { media: getMediaElements(children) };
52408
+ addConditionally(entry, "id", "id", children);
52409
+ addConditionally(entry, "title", "title", children);
52410
+ const href2 = getOneElement("link", children)?.attribs["href"];
52411
+ if (href2) {
52412
+ entry.link = href2;
52413
+ }
52414
+ const description = fetch2("summary", children) || fetch2("content", children);
52415
+ if (description) {
52416
+ entry.description = description;
52417
+ }
52418
+ const pubDate = fetch2("updated", children);
52419
+ if (pubDate) {
52420
+ entry.pubDate = new Date(pubDate);
52421
+ }
52422
+ return entry;
52423
+ })
52424
+ };
52425
+ addConditionally(feed, "id", "id", childs);
52426
+ addConditionally(feed, "title", "title", childs);
52427
+ const href = getOneElement("link", childs)?.attribs["href"];
52428
+ if (href) {
52429
+ feed.link = href;
52430
+ }
52431
+ addConditionally(feed, "description", "subtitle", childs);
52432
+ const updated = fetch2("updated", childs);
52433
+ if (updated) {
52434
+ feed.updated = new Date(updated);
52435
+ }
52436
+ addConditionally(feed, "author", "email", childs, true);
52437
+ return feed;
52438
+ }
52439
+ function getRssFeed(feedRoot) {
52440
+ const childs = getOneElement("channel", feedRoot.children)?.children ?? [];
52441
+ const feed = {
52442
+ type: feedRoot.name.substr(0, 3),
52443
+ id: "",
52444
+ items: getElementsByTagName("item", feedRoot.children).map((item) => {
52445
+ const { children } = item;
52446
+ const entry = { media: getMediaElements(children) };
52447
+ addConditionally(entry, "id", "guid", children);
52448
+ addConditionally(entry, "title", "title", children);
52449
+ addConditionally(entry, "link", "link", children);
52450
+ addConditionally(entry, "description", "description", children);
52451
+ const pubDate = fetch2("pubDate", children) || fetch2("dc:date", children);
52452
+ if (pubDate)
52453
+ entry.pubDate = new Date(pubDate);
52454
+ return entry;
52455
+ })
52456
+ };
52457
+ addConditionally(feed, "title", "title", childs);
52458
+ addConditionally(feed, "link", "link", childs);
52459
+ addConditionally(feed, "description", "description", childs);
52460
+ const updated = fetch2("lastBuildDate", childs);
52461
+ if (updated) {
52462
+ feed.updated = new Date(updated);
52463
+ }
52464
+ addConditionally(feed, "author", "managingEditor", childs, true);
52465
+ return feed;
52466
+ }
52467
+ var MEDIA_KEYS_STRING = ["url", "type", "lang"];
52468
+ var MEDIA_KEYS_INT = [
52469
+ "fileSize",
52470
+ "bitrate",
52471
+ "framerate",
52472
+ "samplingrate",
52473
+ "channels",
52474
+ "duration",
52475
+ "height",
52476
+ "width"
52477
+ ];
52478
+ function getMediaElements(where) {
52479
+ return getElementsByTagName("media:content", where).map((element) => {
52480
+ const { attribs } = element;
52481
+ const media = {
52482
+ medium: attribs["medium"],
52483
+ isDefault: !!attribs["isDefault"]
52484
+ };
52485
+ for (const attrib of MEDIA_KEYS_STRING) {
52486
+ if (attribs[attrib]) {
52487
+ media[attrib] = attribs[attrib];
52488
+ }
52489
+ }
52490
+ for (const attrib of MEDIA_KEYS_INT) {
52491
+ if (attribs[attrib]) {
52492
+ media[attrib] = Number.parseInt(attribs[attrib], 10);
52493
+ }
52494
+ }
52495
+ if (attribs["expression"]) {
52496
+ media.expression = attribs["expression"];
52497
+ }
52498
+ return media;
52499
+ });
52500
+ }
52501
+ function getOneElement(tagName, node3) {
52502
+ return getElementsByTagName(tagName, node3, true, 1)[0];
52503
+ }
52504
+ function fetch2(tagName, where, recurse = false) {
52505
+ return textContent(getElementsByTagName(tagName, where, recurse, 1)).trim();
52506
+ }
52507
+ function addConditionally(object4, property, tagName, where, recurse = false) {
52508
+ const value = fetch2(tagName, where, recurse);
52509
+ if (value)
52510
+ object4[property] = value;
52511
+ }
52512
+ function isValidFeed(value) {
52513
+ return value === "rss" || value === "feed" || value === "rdf:RDF";
52514
+ }
52515
+
52516
+ // node_modules/domutils/dist/helpers.js
52517
+ function removeSubsets(nodes) {
52518
+ let index = nodes.length;
52519
+ while (--index >= 0) {
52520
+ const node3 = nodes[index];
52521
+ if (index > 0 && nodes.lastIndexOf(node3, index - 1) >= 0) {
52522
+ nodes.splice(index, 1);
52523
+ continue;
52524
+ }
52525
+ for (let ancestor = node3.parent; ancestor; ancestor = ancestor.parent) {
52526
+ if (nodes.includes(ancestor)) {
52527
+ nodes.splice(index, 1);
52528
+ break;
52529
+ }
52530
+ }
52531
+ }
52532
+ return nodes;
52533
+ }
52534
+ var DocumentPosition;
52535
+ (function(DocumentPosition2) {
52536
+ DocumentPosition2[DocumentPosition2["DISCONNECTED"] = 1] = "DISCONNECTED";
52537
+ DocumentPosition2[DocumentPosition2["PRECEDING"] = 2] = "PRECEDING";
52538
+ DocumentPosition2[DocumentPosition2["FOLLOWING"] = 4] = "FOLLOWING";
52539
+ DocumentPosition2[DocumentPosition2["CONTAINS"] = 8] = "CONTAINS";
52540
+ DocumentPosition2[DocumentPosition2["CONTAINED_BY"] = 16] = "CONTAINED_BY";
52541
+ })(DocumentPosition || (DocumentPosition = {}));
52542
+ function compareDocumentPosition(nodeA, nodeB) {
52543
+ const aParents = [];
52544
+ const bParents = [];
52545
+ if (nodeA === nodeB) {
52546
+ return 0;
52547
+ }
52548
+ let current = hasChildren(nodeA) ? nodeA : nodeA.parent;
52549
+ while (current) {
52550
+ aParents.unshift(current);
52551
+ current = current.parent;
52552
+ }
52553
+ current = hasChildren(nodeB) ? nodeB : nodeB.parent;
52554
+ while (current) {
52555
+ bParents.unshift(current);
52556
+ current = current.parent;
52557
+ }
52558
+ const maxIndex = Math.min(aParents.length, bParents.length);
52559
+ let index = 0;
52560
+ while (index < maxIndex && aParents[index] === bParents[index]) {
52561
+ index++;
52562
+ }
52563
+ if (index === 0) {
52564
+ return DocumentPosition.DISCONNECTED;
52565
+ }
52566
+ const sharedParent = aParents[index - 1];
52567
+ const siblings = sharedParent.children;
52568
+ const aSibling = aParents[index];
52569
+ const bSibling = bParents[index];
52570
+ if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) {
52571
+ if (sharedParent === nodeB) {
52572
+ return DocumentPosition.FOLLOWING | DocumentPosition.CONTAINED_BY;
52573
+ }
52574
+ return DocumentPosition.FOLLOWING;
52575
+ }
52576
+ if (sharedParent === nodeA) {
52577
+ return DocumentPosition.PRECEDING | DocumentPosition.CONTAINS;
52578
+ }
52579
+ return DocumentPosition.PRECEDING;
52580
+ }
52581
+ function uniqueSort(nodes) {
52582
+ nodes = nodes.filter((node3, index, array4) => !array4.includes(node3, index + 1));
52583
+ nodes.sort((a, b) => {
52584
+ const relative3 = compareDocumentPosition(a, b);
52585
+ if (relative3 & DocumentPosition.PRECEDING) {
52586
+ return -1;
52587
+ }
52588
+ if (relative3 & DocumentPosition.FOLLOWING) {
52589
+ return 1;
52590
+ }
52591
+ return 0;
52592
+ });
52593
+ return nodes;
52594
+ }
52595
+
52596
+ // node_modules/domutils/dist/manipulation.js
52597
+ function removeElement(element) {
52598
+ if (element.prev)
52599
+ element.prev.next = element.next;
52600
+ if (element.next)
52601
+ element.next.prev = element.prev;
52602
+ if (element.parent) {
52603
+ const childs = element.parent.children;
52604
+ const childsIndex = childs.lastIndexOf(element);
52605
+ if (childsIndex !== -1) {
52606
+ childs.splice(childsIndex, 1);
52607
+ }
52608
+ }
52609
+ element.next = null;
52610
+ element.prev = null;
52611
+ element.parent = null;
52612
+ }
52613
+ function replaceElement(element, replacement) {
52614
+ replacement.prev = element.prev;
52615
+ if (replacement.prev) {
52616
+ replacement.prev.next = replacement;
52617
+ }
52618
+ replacement.next = element.next;
52619
+ if (replacement.next) {
52620
+ replacement.next.prev = replacement;
52621
+ }
52622
+ replacement.parent = element.parent;
52623
+ if (replacement.parent) {
52624
+ const { children } = replacement.parent;
52625
+ const elementIndex = children.lastIndexOf(element);
52626
+ if (elementIndex === -1) {
52627
+ return;
52628
+ }
52629
+ children[elementIndex] = replacement;
52630
+ element.parent = null;
52631
+ }
52632
+ }
52633
+ function appendChild(parent, child) {
52634
+ removeElement(child);
52635
+ child.next = null;
52636
+ child.parent = parent;
52637
+ if (parent.children.push(child) > 1) {
52638
+ const sibling = parent.children[parent.children.length - 2];
52639
+ sibling.next = child;
52640
+ child.prev = sibling;
52641
+ } else {
52642
+ child.prev = null;
52643
+ }
52644
+ }
52645
+ function append(element, next) {
52646
+ removeElement(next);
52647
+ const { parent } = element;
52648
+ const currentNext = element.next;
52649
+ next.next = currentNext;
52650
+ next.prev = element;
52651
+ element.next = next;
52652
+ next.parent = parent;
52653
+ if (currentNext) {
52654
+ currentNext.prev = next;
52655
+ if (parent) {
52656
+ const childs = parent.children;
52657
+ childs.splice(childs.lastIndexOf(currentNext), 0, next);
52658
+ }
52659
+ } else if (parent) {
52660
+ parent.children.push(next);
52661
+ }
52662
+ }
52663
+ function prependChild(parent, child) {
52664
+ removeElement(child);
52665
+ child.parent = parent;
52666
+ child.prev = null;
52667
+ if (parent.children.unshift(child) === 1) {
52668
+ child.next = null;
52669
+ } else {
52670
+ const sibling = parent.children[1];
52671
+ sibling.prev = child;
52672
+ child.next = sibling;
52673
+ }
52674
+ }
52675
+ function prepend(element, previous) {
52676
+ removeElement(previous);
52677
+ const { parent } = element;
52678
+ if (parent) {
52679
+ const childs = parent.children;
52680
+ childs.splice(childs.indexOf(element), 0, previous);
52681
+ }
52682
+ if (element.prev) {
52683
+ element.prev.next = previous;
52684
+ }
52685
+ previous.parent = parent;
52686
+ previous.prev = element.prev;
52687
+ previous.next = element;
52688
+ element.prev = previous;
52689
+ }
52690
+
52691
+ // node_modules/domutils/dist/traversal.js
52692
+ function getChildren(element) {
52693
+ return hasChildren(element) ? element.children : [];
52694
+ }
52695
+ function getParent(element) {
52696
+ return element.parent || null;
52697
+ }
52698
+ function getSiblings(element) {
52699
+ const parent = getParent(element);
52700
+ if (parent != null)
52701
+ return getChildren(parent);
52702
+ const siblings = [element];
52703
+ let { prev, next } = element;
52704
+ while (prev != null) {
52705
+ siblings.unshift(prev);
52706
+ ({ prev } = prev);
52707
+ }
52708
+ while (next != null) {
52709
+ siblings.push(next);
52710
+ ({ next } = next);
52711
+ }
52712
+ return siblings;
52713
+ }
52714
+ function getAttributeValue(element, name) {
52715
+ const { attribs } = element;
52716
+ return attribs?.[name];
52717
+ }
52718
+ function hasAttrib(element, name) {
52719
+ const { attribs } = element;
52720
+ return attribs != null && Object.hasOwn(attribs, name) && attribs[name] != null;
52721
+ }
52722
+ function getName(element) {
52723
+ return element.name;
52724
+ }
52725
+ function nextElementSibling(element) {
52726
+ let { next } = element;
52727
+ while (next !== null && !isTag2(next))
52728
+ ({ next } = next);
52729
+ return next;
52730
+ }
52731
+ function prevElementSibling(element) {
52732
+ let { prev } = element;
52733
+ while (prev !== null && !isTag2(prev))
52734
+ ({ prev } = prev);
52735
+ return prev;
52736
+ }
52737
+
52738
+ // node_modules/htmlparser2/dist/index.js
52739
+ function parseDocument(data, options) {
52740
+ const handler9 = new DomHandler(void 0, options);
52741
+ new Parser(handler9, options).end(data);
52742
+ return handler9.root;
52743
+ }
52744
+
52745
+ // src/core/index/html-text.ts
52746
+ function isText2(n) {
52747
+ return n.type === "text";
52748
+ }
52749
+ function isTag3(n) {
52750
+ return n.type === "tag" || n.type === "script" || n.type === "style";
52751
+ }
52752
+ var DROP = /* @__PURE__ */ new Set([
52753
+ "script",
52754
+ "style",
52755
+ "noscript",
52756
+ "template",
52757
+ "svg",
52758
+ "math",
52759
+ "iframe",
52760
+ "canvas",
52761
+ "object",
52762
+ "embed",
52763
+ "head",
52764
+ "title",
52765
+ "nav",
52766
+ "footer",
52767
+ "button",
52768
+ "select",
52769
+ "option",
52770
+ "textarea",
52771
+ "input",
52772
+ "dialog",
52773
+ "audio",
52774
+ "video",
52775
+ "picture",
52776
+ "img"
52777
+ ]);
52778
+ var DROP_ROLES = /* @__PURE__ */ new Set(["navigation", "banner", "contentinfo", "search", "dialog", "tooltip"]);
52779
+ var LINE = /* @__PURE__ */ new Set(["div", "section", "article", "main", "header", "aside", "figure", "figcaption", "details", "summary", "address", "dl", "dt", "dd", "fieldset", "form", "center", "li", "tr", "body", "html", "caption"]);
52780
+ var PARA = /* @__PURE__ */ new Set(["p", "blockquote", "hr", "table", "ul", "ol", "pre", "h1", "h2", "h3", "h4", "h5", "h6"]);
52781
+ var PRE_LINE = /* @__PURE__ */ new Set(["div", "p", "li", "tr"]);
52782
+ var LANG_PREFIXES = ["language-", "lang-", "highlight-source-", "highlight-text-"];
52783
+ var BLOCK_INSIDE_LINK = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "pre", "ul", "ol", "table", "blockquote", "section", "article"]);
52784
+ function isSpace2(c) {
52785
+ return c === " " || c === " " || c === "\n" || c === "\r" || c === "\f" || c === "\xA0";
52786
+ }
52787
+ function isInvisible(c) {
52788
+ return c === "\u200B" || c === "\uFEFF" || c === "\xAD";
52789
+ }
52790
+ function collapse(s) {
52791
+ let out = "";
52792
+ let gap = false;
52793
+ for (const c of s) {
52794
+ if (isInvisible(c)) continue;
52795
+ if (isSpace2(c)) {
52796
+ gap = true;
52797
+ continue;
52798
+ }
52799
+ if (gap) {
52800
+ out += " ";
52801
+ gap = false;
52802
+ }
52803
+ out += c;
52804
+ }
52805
+ return gap ? out + " " : out;
52806
+ }
52807
+ function hidden(el) {
52808
+ const a = el.attribs;
52809
+ if (a.hidden !== void 0 || a["aria-hidden"] === "true") return true;
52810
+ if (a.role !== void 0 && DROP_ROLES.has(a.role.toLowerCase())) return true;
52811
+ if (a.style !== void 0) {
52812
+ let s = "";
52813
+ for (const c of a.style.toLowerCase()) if (!isSpace2(c)) s += c;
52814
+ if (s.includes("display:none")) return true;
52815
+ }
52816
+ return false;
52817
+ }
52818
+ function dropped(el) {
52819
+ return DROP.has(el.name) || hidden(el);
52820
+ }
52821
+ function plainText(node3) {
52822
+ let out = "";
52823
+ const visit2 = (n) => {
52824
+ if (isText2(n)) {
52825
+ out += n.data;
52826
+ return;
52827
+ }
52828
+ if (!isTag3(n) || dropped(n)) return;
52829
+ if (n.name === "br") {
52830
+ out += " ";
52831
+ return;
52832
+ }
52833
+ const block = LINE.has(n.name) || PARA.has(n.name);
52834
+ if (block) out += " ";
52835
+ for (const c of n.children) visit2(c);
52836
+ if (block) out += " ";
52837
+ };
52838
+ visit2(node3);
52839
+ return collapse(out).trim();
52840
+ }
52841
+ function preText(node3) {
52842
+ const buf = [];
52843
+ let last2 = "\n";
52844
+ const put = (s) => {
52845
+ if (s === "") return;
52846
+ buf.push(s);
52847
+ last2 = s[s.length - 1];
52848
+ };
52849
+ const visit2 = (n) => {
52850
+ if (isText2(n)) {
52851
+ let s = "";
52852
+ for (const c of n.data) {
52853
+ if (isInvisible(c)) continue;
52854
+ s += c === "\xA0" ? " " : c;
52855
+ }
52856
+ put(s);
52857
+ return;
52858
+ }
52859
+ if (!isTag3(n) || dropped(n)) return;
52860
+ if (n.name === "br") {
52861
+ put("\n");
52862
+ return;
52863
+ }
52864
+ for (const c of n.children) visit2(c);
52865
+ if (PRE_LINE.has(n.name) && last2 !== "\n") put("\n");
52866
+ };
52867
+ for (const c of node3.children) visit2(c);
52868
+ let code = "";
52869
+ for (const s of buf) code += s;
52870
+ const lines = code.split("\r\n").join("\n").split("\n");
52871
+ while (lines.length > 0 && lines[0].trim() === "") lines.shift();
52872
+ while (lines.length > 0 && lines[lines.length - 1].trim() === "") lines.pop();
52873
+ return lines.join("\n");
52874
+ }
52875
+ function langFrom(classes) {
52876
+ if (classes === void 0) return "";
52877
+ for (const token of classes.split(" ")) {
52878
+ for (const p of LANG_PREFIXES) {
52879
+ if (token.startsWith(p) && token.length > p.length) return token.slice(p.length);
52880
+ }
52881
+ }
52882
+ return "";
52883
+ }
52884
+ function langOf(pre) {
52885
+ const code = dist_exports2.findOne((e) => e.name === "code", pre.children, true);
52886
+ const chain = [pre];
52887
+ if (code !== null) chain.push(code);
52888
+ let up = pre.parent;
52889
+ for (let i = 0; i < 2 && up !== null && isTag3(up); i += 1) {
52890
+ chain.push(up);
52891
+ up = up.parent;
52892
+ }
52893
+ for (const el of chain) {
52894
+ const l = langFrom(el.attribs.class) || el.attribs["data-language"] || el.attribs["data-lang"] || "";
52895
+ if (l !== "") return safeLang(l);
52896
+ }
52897
+ return "";
52898
+ }
52899
+ function safeLang(l) {
52900
+ let out = "";
52901
+ for (const c of l.toLowerCase()) {
52902
+ const ok = c >= "a" && c <= "z" || c >= "0" && c <= "9" || c === "+" || c === "-" || c === "#" || c === "_" || c === ".";
52903
+ if (!ok) return out;
52904
+ out += c;
52905
+ }
52906
+ return out;
52907
+ }
52908
+ var Writer = class {
52909
+ parts = [];
52910
+ pending = 0;
52911
+ fresh = true;
52912
+ endsSpace = false;
52913
+ stack = [];
52914
+ depth() {
52915
+ return this.stack.length;
52916
+ }
52917
+ push(first, rest) {
52918
+ this.stack.push({ first, rest, used: false });
52919
+ }
52920
+ pop() {
52921
+ this.stack.pop();
52922
+ }
52923
+ line() {
52924
+ if (this.pending < 1) this.pending = 1;
52925
+ }
52926
+ block() {
52927
+ this.pending = 2;
52928
+ }
52929
+ prefix() {
52930
+ let p = "";
52931
+ for (const l of this.stack) {
52932
+ p += l.used ? l.rest : l.first;
52933
+ l.used = true;
52934
+ }
52935
+ return p;
52936
+ }
52937
+ flush() {
52938
+ if (this.parts.length > 0 && this.pending > 0) {
52939
+ const i = this.parts.length - 1;
52940
+ let end = this.parts[i].length;
52941
+ while (end > 0 && this.parts[i][end - 1] === " ") end -= 1;
52942
+ this.parts[i] = this.parts[i].slice(0, end);
52943
+ this.parts.push("\n".repeat(this.pending));
52944
+ this.fresh = true;
52945
+ this.endsSpace = false;
52946
+ }
52947
+ this.pending = 0;
52948
+ if (this.fresh) {
52949
+ this.parts.push(this.prefix());
52950
+ this.fresh = false;
52951
+ }
52952
+ }
52953
+ text(raw) {
52954
+ let s = raw;
52955
+ if ((this.fresh || this.pending > 0 || this.endsSpace) && s.startsWith(" ")) s = s.slice(1);
52956
+ if (s === "") return;
52957
+ this.flush();
52958
+ this.parts.push(s);
52959
+ this.endsSpace = s.endsWith(" ");
52960
+ }
52961
+ /** One whole line, white space kept (a code line, a table row). */
52962
+ emitLine(s) {
52963
+ this.line();
52964
+ this.flush();
52965
+ this.parts.push(s);
52966
+ this.endsSpace = false;
52967
+ this.line();
52968
+ }
52969
+ code(lang, code) {
52970
+ let run = 0;
52971
+ let most = 0;
52972
+ for (const c of code) {
52973
+ run = c === "`" ? run + 1 : 0;
52974
+ if (run > most) most = run;
52975
+ }
52976
+ const fence = "`".repeat(Math.max(3, most + 1));
52977
+ this.block();
52978
+ this.emitLine(fence + lang);
52979
+ for (const l of code.split("\n")) this.emitLine(l);
52980
+ this.emitLine(fence);
52981
+ this.block();
52982
+ }
52983
+ result() {
52984
+ let s = "";
52985
+ for (const p of this.parts) s += p;
52986
+ return s.trimEnd();
52987
+ }
52988
+ };
52989
+ function resolveHref(href, base) {
52990
+ if (href === void 0) return void 0;
52991
+ const h = href.trim();
52992
+ if (h === "" || h.startsWith("#")) return void 0;
52993
+ try {
52994
+ const u = base !== void 0 ? new URL(h, base) : new URL(h);
52995
+ return u.protocol === "http:" || u.protocol === "https:" ? u.href : void 0;
52996
+ } catch {
52997
+ return base === void 0 && !h.includes(":") ? h : void 0;
52998
+ }
52999
+ }
53000
+ function hasBlock(el) {
53001
+ return dist_exports2.findOne((e) => BLOCK_INSIDE_LINK.has(e.name), el.children, true) !== null;
53002
+ }
53003
+ function inlineCode(text) {
53004
+ let run = 0;
53005
+ let most = 0;
53006
+ for (const c of text) {
53007
+ run = c === "`" ? run + 1 : 0;
53008
+ if (run > most) most = run;
53009
+ }
53010
+ const tick = "`".repeat(most === 0 ? 1 : most + 1);
53011
+ const pad = text.startsWith("`") || text.endsWith("`") ? " " : "";
53012
+ return tick + pad + text + pad + tick;
53013
+ }
53014
+ function cell2(el) {
53015
+ const t = plainText(el);
53016
+ let out = "";
53017
+ for (const c of t) out += c === "|" ? "\\|" : c;
53018
+ return out;
53019
+ }
53020
+ function table(st, el) {
53021
+ const rows = dist_exports2.findAll((e) => e.name === "tr", el.children).map((tr) => tr.children.filter((c) => isTag3(c) && (c.name === "td" || c.name === "th")).map(cell2));
53022
+ const cols = rows.reduce((m, r) => Math.max(m, r.length), 0);
53023
+ if (cols === 0) return;
53024
+ st.w.block();
53025
+ rows.forEach((r, i) => {
53026
+ const padded = r.concat(Array.from({ length: cols - r.length }, () => ""));
53027
+ st.w.emitLine("| " + padded.join(" | ") + " |");
53028
+ if (i === 0) st.w.emitLine("|" + " --- |".repeat(cols));
53029
+ });
53030
+ st.w.block();
53031
+ }
53032
+ function list2(st, el) {
53033
+ const ordered = el.name === "ol";
53034
+ const start = Number.parseInt(el.attribs.start ?? "1", 10);
53035
+ let n = Number.isFinite(start) ? start : 1;
53036
+ if (st.w.depth() === 0) st.w.block();
53037
+ else st.w.line();
53038
+ for (const c of el.children) {
53039
+ if (isTag3(c) && c.name === "li" && !dropped(c)) {
53040
+ const marker = ordered ? String(n) + ". " : "- ";
53041
+ n += 1;
53042
+ st.w.line();
53043
+ st.w.push(marker, " ".repeat(marker.length));
53044
+ for (const k of c.children) walk(st, k);
53045
+ st.w.pop();
53046
+ st.w.line();
53047
+ } else {
53048
+ walk(st, c);
53049
+ }
53050
+ }
53051
+ if (st.w.depth() === 0) st.w.block();
53052
+ else st.w.line();
53053
+ }
53054
+ function walk(st, node3) {
53055
+ if (isText2(node3)) {
53056
+ st.w.text(collapse(node3.data));
53057
+ return;
53058
+ }
53059
+ if (!isTag3(node3) || dropped(node3)) return;
53060
+ const name = node3.name;
53061
+ if (name.length === 2 && name[0] === "h" && name[1] >= "1" && name[1] <= "6") {
53062
+ const t = plainText(node3);
53063
+ if (t === "") return;
53064
+ if (name === "h1") st.sawH1 = true;
53065
+ st.w.block();
53066
+ st.w.text("#".repeat(Number(name[1])) + " " + t);
53067
+ st.w.block();
53068
+ return;
53069
+ }
53070
+ switch (name) {
53071
+ case "pre": {
53072
+ const code = preText(node3);
53073
+ if (code !== "") st.w.code(langOf(node3), code);
53074
+ return;
53075
+ }
53076
+ case "ul":
53077
+ case "ol":
53078
+ list2(st, node3);
53079
+ return;
53080
+ case "table":
53081
+ table(st, node3);
53082
+ return;
53083
+ case "br":
53084
+ st.w.line();
53085
+ return;
53086
+ case "hr":
53087
+ st.w.block();
53088
+ st.w.text("---");
53089
+ st.w.block();
53090
+ return;
53091
+ case "blockquote":
53092
+ st.w.block();
53093
+ st.w.push("> ", "> ");
53094
+ for (const c of node3.children) walk(st, c);
53095
+ st.w.pop();
53096
+ st.w.block();
53097
+ return;
53098
+ case "code": {
53099
+ const t = plainText(node3);
53100
+ if (t !== "") st.w.text(inlineCode(t));
53101
+ return;
53102
+ }
53103
+ case "a": {
53104
+ if (hasBlock(node3)) break;
53105
+ const t = plainText(node3);
53106
+ if (t === "") return;
53107
+ const href = resolveHref(node3.attribs.href, st.base);
53108
+ st.w.text(href === void 0 ? t : "[" + t + "](" + href + ")");
53109
+ return;
53110
+ }
53111
+ default:
53112
+ }
53113
+ const para = PARA.has(name);
53114
+ const line = LINE.has(name);
53115
+ if (para) st.w.block();
53116
+ else if (line) st.w.line();
53117
+ for (const c of node3.children) walk(st, c);
53118
+ if (para) st.w.block();
53119
+ else if (line) st.w.line();
53120
+ }
53121
+ function isWordChar2(c) {
53122
+ return c.toLowerCase() !== c.toUpperCase() || c >= "0" && c <= "9";
53123
+ }
53124
+ function wordCount(text) {
53125
+ let n = 0;
53126
+ for (const w of text.split(" ").join("\n").split("\n")) {
53127
+ for (const c of w) if (isWordChar2(c)) {
53128
+ n += 1;
53129
+ break;
53130
+ }
53131
+ }
53132
+ return n;
53133
+ }
53134
+ var SPARSE_MAX_WORDS = 20;
53135
+ var SPARSE_RATIO = 20;
53136
+ function contentRoot(children) {
53137
+ const main = dist_exports2.findOne((e) => e.name === "main", children, true);
53138
+ if (main !== null) return [main];
53139
+ const articles = dist_exports2.findAll((e) => e.name === "article", children);
53140
+ if (articles.length === 1) return articles;
53141
+ const body = dist_exports2.findOne((e) => e.name === "body", children, true);
53142
+ return body !== null ? [body] : children;
53143
+ }
53144
+ function htmlToReadable(html, baseUrl) {
53145
+ const doc = parseDocument(html);
53146
+ const titleEl = dist_exports2.findOne((e) => e.name === "title", doc.children, true);
53147
+ const title = titleEl === null ? "" : collapse(titleEl.children.map((c) => isText2(c) ? c.data : "").join("")).trim();
53148
+ let base;
53149
+ try {
53150
+ base = baseUrl === void 0 ? void 0 : new URL(baseUrl);
53151
+ } catch {
53152
+ base = void 0;
53153
+ }
53154
+ const st = { w: new Writer(), base, sawH1: false };
53155
+ for (const n of contentRoot(doc.children)) walk(st, n);
53156
+ const body = st.w.result();
53157
+ const words = wordCount(body);
53158
+ const text = !st.sawH1 && title !== "" && words > 0 ? "# " + title + "\n\n" + body : body;
53159
+ const sparse = words < SPARSE_MAX_WORDS && html.length > SPARSE_RATIO * Math.max(text.length, 1);
53160
+ return { text: text === "" ? "" : text + "\n", title, words, sparse };
53161
+ }
53162
+
49352
53163
  // src/core/tools/index.ts
49353
53164
  var ctxIndexSchema = external_exports.object({
49354
53165
  path: external_exports.string().optional(),
@@ -49413,7 +53224,7 @@ async function itemsOf(input, ctx) {
49413
53224
  const res = await safeFetch(input.url ?? "", AbortSignal.any([ctx.signal, AbortSignal.timeout(EXEC_TIMEOUT_MS)]));
49414
53225
  const text = res.body.toString("utf8");
49415
53226
  const label = res.finalUrl;
49416
- return { items: [{ sourceKind: "url", label, kind: kindOfType(res.contentType), read: () => text }], from: label };
53227
+ return { items: [{ sourceKind: "url", label, kind: kindOfType(res.contentType), read: () => text, base: label }], from: label };
49417
53228
  }
49418
53229
  async function handler4(input, ctx) {
49419
53230
  const given = INPUT_FIELDS.filter((f) => input[f] !== void 0);
@@ -49427,21 +53238,45 @@ async function handler4(input, ctx) {
49427
53238
  let chunks = 0;
49428
53239
  let bytes4 = 0;
49429
53240
  let lastId = 0;
53241
+ const notes = [];
49430
53242
  try {
49431
53243
  for (const it of items) {
49432
53244
  const text = it.read();
49433
53245
  if (text === void 0) continue;
53246
+ bytes4 += Buffer.byteLength(text, "utf8");
53247
+ if (it.kind === "html") {
53248
+ let readable;
53249
+ try {
53250
+ readable = htmlToReadable(text, it.base);
53251
+ } catch {
53252
+ readable = void 0;
53253
+ }
53254
+ if (readable !== void 0) {
53255
+ const rawLabel = it.label + RAW_LABEL_SUFFIX;
53256
+ const raw = storeText(db, ctx.project, ctx.sessionId, it.sourceKind, rawLabel, text, "text");
53257
+ notes.push('Raw HTML kept as "' + rawLabel + '" (' + raw.chunks + " chunk(s)); pass it as `source` to search the markup.");
53258
+ lastId = raw.sourceId;
53259
+ if (readable.words === 0 || readable.sparse) {
53260
+ notes.unshift("No readable text found in " + it.label + " (the page is client-rendered or empty); nothing was added to default search.");
53261
+ continue;
53262
+ }
53263
+ const stored2 = storeText(db, ctx.project, ctx.sessionId, it.sourceKind, it.label, readable.text, "md");
53264
+ chunks += stored2.chunks;
53265
+ lastId = stored2.sourceId;
53266
+ sources += 1;
53267
+ continue;
53268
+ }
53269
+ }
49434
53270
  const stored = storeText(db, ctx.project, ctx.sessionId, it.sourceKind, it.label, text, it.kind);
49435
53271
  chunks += stored.chunks;
49436
53272
  lastId = stored.sourceId;
49437
- bytes4 += Buffer.byteLength(text, "utf8");
49438
53273
  sources += 1;
49439
53274
  }
49440
53275
  } finally {
49441
53276
  closeDb(db);
49442
53277
  }
49443
53278
  const shown2 = Buffer.byteLength(from, "utf8") > ECHO_MAX_BYTES ? sourceHandle(lastId) : from;
49444
- const line = "Indexed " + sources + " source(s), " + chunks + " chunk(s) from " + shown2 + ".";
53279
+ const line = ["Indexed " + sources + " source(s), " + chunks + " chunk(s) from " + shown2 + ".", ...notes].join("\n");
49445
53280
  return {
49446
53281
  text: capBytes(line, OUTPUT_CAP).text,
49447
53282
  isError: false,
@@ -49531,8 +53366,8 @@ function make(section, row5, text, repeatCount, query) {
49531
53366
  if (bytes4 < 1) throw new Error("compaction: empty candidate line (DECISIONS-r9 M9).");
49532
53367
  return { section, seq: row5.seq, turn: row5.turn, text, bytes: bytes4, repeatCount, pinned: section === "last_request", query };
49533
53368
  }
49534
- function capSection(list2) {
49535
- return list2.length > MAX_CANDIDATES ? list2.slice(list2.length - MAX_CANDIDATES) : list2;
53369
+ function capSection(list3) {
53370
+ return list3.length > MAX_CANDIDATES ? list3.slice(list3.length - MAX_CANDIDATES) : list3;
49536
53371
  }
49537
53372
  function emptySet() {
49538
53373
  return { lastRequest: null, openErrors: [], changedFiles: [], decisions: [], earlierRequests: [], indexedSources: [] };
@@ -49869,7 +53704,7 @@ async function handler7(_input, ctx) {
49869
53704
  const project = sum(groups);
49870
53705
  const allTime = project;
49871
53706
  const agentIds = [.../* @__PURE__ */ new Set([...groups.map((g) => g.agent), ctx.project.agent])].sort();
49872
- const table = [
53707
+ const table2 = [
49873
53708
  "| " + STATS_COLUMNS.join(" | ") + " |",
49874
53709
  "|" + STATS_COLUMNS.map(() => "---").join("|") + "|",
49875
53710
  tableRow("session", session),
@@ -49878,7 +53713,7 @@ async function handler7(_input, ctx) {
49878
53713
  ...agentIds.map((a) => tableRow("agent " + a, sum(groups.filter((g) => g.agent === a))))
49879
53714
  ].join("\n");
49880
53715
  const summary = STATS_SUMMARY(reductionPct(allTime), reductionPct(session));
49881
- return { text: capBytes(summary + "\n\n" + table, OUTPUT_CAP).text, isError: false, sandboxBytes: 0 };
53716
+ return { text: capBytes(summary + "\n\n" + table2, OUTPUT_CAP).text, isError: false, sandboxBytes: 0 };
49882
53717
  }
49883
53718
  var ctxStats = Object.freeze({
49884
53719
  name: "ctx_stats",
@@ -49913,11 +53748,11 @@ function hostConfigPath(agent, home, env) {
49913
53748
  return join15(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
49914
53749
  }
49915
53750
  }
49916
- function cell2(value) {
53751
+ function cell3(value) {
49917
53752
  return value === void 0 ? "" : JSON.stringify(value);
49918
53753
  }
49919
53754
  function toRow(file2, edit) {
49920
- return { area: file2 + UPGRADE_AREA_KEY_SEP + edit.path, before: cell2(edit.before), after: cell2(edit.after) };
53755
+ return { area: file2 + UPGRADE_AREA_KEY_SEP + edit.path, before: cell3(edit.before), after: cell3(edit.after) };
49921
53756
  }
49922
53757
  function writeWithRollback(file2, text, write, atomic) {
49923
53758
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
@@ -50253,16 +54088,16 @@ function removeV1(agent, findings) {
50253
54088
  } else done.set(f, UPGRADE_NOT_FOUND);
50254
54089
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
50255
54090
  }
50256
- for (const [file2, list2] of entries) {
54091
+ for (const [file2, list3] of entries) {
50257
54092
  if (!existsSync18(file2)) {
50258
- for (const f of list2) done.set(f, UPGRADE_NOT_FOUND);
54093
+ for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
50259
54094
  continue;
50260
54095
  }
50261
54096
  if (file2.endsWith(TOML_EXT)) {
50262
54097
  const rawToml = readFileSync11(file2, "utf8");
50263
54098
  const tomlLayout = hostLayout(rawToml);
50264
54099
  let text = hostText(rawToml);
50265
- for (const f of list2) {
54100
+ for (const f of list3) {
50266
54101
  const next = cutTomlTable(text, f.path);
50267
54102
  if (next === null) {
50268
54103
  done.set(f, UPGRADE_NOT_FOUND);
@@ -50271,14 +54106,14 @@ function removeV1(agent, findings) {
50271
54106
  text = next;
50272
54107
  done.set(f, UPGRADE_REMOVED);
50273
54108
  }
50274
- if (list2.some((f) => done.get(f) === UPGRADE_REMOVED)) {
54109
+ if (list3.some((f) => done.get(f) === UPGRADE_REMOVED)) {
50275
54110
  keepOriginal(file2, kept, undo);
50276
54111
  writeAtomic(file2, withLayout(text, tomlLayout));
50277
54112
  }
50278
54113
  continue;
50279
54114
  }
50280
- const hit = stripJsonEntries(agent, file2, list2, kept, undo);
50281
- for (const f of list2) done.set(f, hit.has(f) ? UPGRADE_REMOVED : UPGRADE_NOT_FOUND);
54115
+ const hit = stripJsonEntries(agent, file2, list3, kept, undo);
54116
+ for (const f of list3) done.set(f, hit.has(f) ? UPGRADE_REMOVED : UPGRADE_NOT_FOUND);
50282
54117
  }
50283
54118
  return {
50284
54119
  rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
@@ -50315,12 +54150,12 @@ function parseSums(text) {
50315
54150
  }
50316
54151
  return sums;
50317
54152
  }
50318
- function walk(dir, prefix, out) {
54153
+ function walk2(dir, prefix, out) {
50319
54154
  for (const entry of readdirSync9(dir, { withFileTypes: true })) {
50320
54155
  const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
50321
54156
  if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
50322
54157
  const abs = join19(dir, entry.name);
50323
- if (entry.isDirectory()) walk(abs, rel, out);
54158
+ if (entry.isDirectory()) walk2(abs, rel, out);
50324
54159
  else if (entry.isFile()) out.set(rel, abs);
50325
54160
  else throw mismatch();
50326
54161
  }
@@ -50331,7 +54166,7 @@ function verifySums(dir) {
50331
54166
  if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
50332
54167
  const sums = parseSums(readFileSync12(sumsPath, "utf8"));
50333
54168
  const files = /* @__PURE__ */ new Map();
50334
- walk(dir, "", files);
54169
+ walk2(dir, "", files);
50335
54170
  if (files.size !== sums.size) throw mismatch();
50336
54171
  for (const [rel, abs] of files) {
50337
54172
  const want = sums.get(rel);
@@ -50401,12 +54236,12 @@ async function upgrade(adapter, deps, home) {
50401
54236
  throw err;
50402
54237
  }
50403
54238
  }
50404
- function cell3(text) {
54239
+ function cell4(text) {
50405
54240
  return text.split(TABLE_PIPE).join(TABLE_PIPE_ESCAPED);
50406
54241
  }
50407
54242
  function renderTable(rows) {
50408
54243
  const lines = [UPGRADE_TABLE_HEADER, UPGRADE_TABLE_RULE];
50409
- for (const r of rows) lines.push(TABLE_ROW_START + [r.area, r.before, r.after].map(cell3).join(TABLE_CELL_SEP) + TABLE_ROW_END);
54244
+ for (const r of rows) lines.push(TABLE_ROW_START + [r.area, r.before, r.after].map(cell4).join(TABLE_CELL_SEP) + TABLE_ROW_END);
50410
54245
  return lines.join("\n");
50411
54246
  }
50412
54247
  async function runUpgrade(input, deps) {
@@ -50462,6 +54297,26 @@ function define(name) {
50462
54297
  };
50463
54298
  }
50464
54299
  var TOOLS = Object.freeze(TOOL_ORDER.map(define));
54300
+ function callExample(tool) {
54301
+ const a = tool.description.indexOf("`");
54302
+ const b = tool.description.indexOf("`", a + 1);
54303
+ return a < 0 || b < 0 ? tool.name + "({})" : tool.description.slice(a + 1, b);
54304
+ }
54305
+ function invalidCallLine(tool, issues) {
54306
+ const parts = [];
54307
+ for (const issue4 of issues.slice(0, 3)) {
54308
+ const where = issue4.path.length === 0 ? "" : issue4.path.map(String).join(".") + ": ";
54309
+ let one = (where + issue4.message).split("\n").join(" ").trim();
54310
+ while (one.endsWith(".")) one = one.slice(0, -1);
54311
+ parts.push(one);
54312
+ }
54313
+ const detail = parts.length === 0 ? "Invalid arguments" : parts.join("; ");
54314
+ return tool.name + ": " + detail + ". Correct call: " + callExample(tool);
54315
+ }
54316
+ function checkCall(tool, input) {
54317
+ const parsed = tool.schema.safeParse(input);
54318
+ return parsed.success ? { ok: true, data: parsed.data } : { ok: false, line: invalidCallLine(tool, parsed.error.issues) };
54319
+ }
50465
54320
 
50466
54321
  // src/entries/is-entry.ts
50467
54322
  import { realpathSync as realpathSync8 } from "node:fs";
@@ -50494,6 +54349,17 @@ function versionAtLeast(have, min) {
50494
54349
  const [lower] = [have, min].sort(NUMERIC.compare);
50495
54350
  return lower === min;
50496
54351
  }
54352
+ function passThrough(tool) {
54353
+ const json2 = () => external_exports.toJSONSchema(tool.schema, { target: "draft-2020-12", io: "input" });
54354
+ return {
54355
+ "~standard": {
54356
+ version: 1,
54357
+ vendor: "context-mode",
54358
+ validate: (value) => ({ value }),
54359
+ jsonSchema: { input: json2, output: json2 }
54360
+ }
54361
+ };
54362
+ }
50497
54363
  async function isDegraded() {
50498
54364
  if (!versionAtLeast(process.versions.node, NODE_MIN)) return true;
50499
54365
  try {
@@ -50591,10 +54457,15 @@ async function startServer(argv, env) {
50591
54457
  protocolVersion: server.server.getNegotiatedProtocolVersion() ?? ""
50592
54458
  };
50593
54459
  let reply4;
50594
- try {
50595
- reply4 = await tool.handler(input, ctx);
50596
- } catch (err) {
50597
- reply4 = errorReply(err);
54460
+ const checked = checkCall(tool, input);
54461
+ if (!checked.ok) {
54462
+ reply4 = { text: checked.line, isError: true, sandboxBytes: 0 };
54463
+ } else {
54464
+ try {
54465
+ reply4 = await tool.handler(checked.data, ctx);
54466
+ } catch (err) {
54467
+ reply4 = errorReply(err);
54468
+ }
50598
54469
  }
50599
54470
  if (stopRequested()) {
50600
54471
  setTimeout(stopSelf, UPGRADE_STOP_DELAY_MS);
@@ -50636,7 +54507,7 @@ async function startServer(argv, env) {
50636
54507
  {
50637
54508
  description: tool.description,
50638
54509
  // zod 3.25 `zod/v4` has no ~standard.jsonSchema type; the SDK converts it with z.toJSONSchema (DEVIATIONS).
50639
- inputSchema: tool.schema,
54510
+ inputSchema: passThrough(tool),
50640
54511
  ...tool.readOnly ? { annotations: { readOnlyHint: true } } : {},
50641
54512
  ...tool.alwaysLoad ? { _meta: { "anthropic/alwaysLoad": true } } : {}
50642
54513
  },