chrome-devtools-mcp 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/build/src/BrowserManager.js +132 -13
  2. package/build/src/McpContext.js +188 -138
  3. package/build/src/McpPage.js +348 -96
  4. package/build/src/McpResponse.js +234 -76
  5. package/build/src/McpWorker.js +66 -0
  6. package/build/src/SlimMcpResponse.js +5 -1
  7. package/build/src/TextSnapshot.js +3 -2
  8. package/build/src/ToolHandler.js +80 -42
  9. package/build/src/bin/chrome-devtools-mcp-main.js +8 -7
  10. package/build/src/bin/chrome-devtools-mcp.js +1 -1
  11. package/build/src/bin/chrome-devtools.js +31 -41
  12. package/build/src/collectors/ServiceWorkerCollector.js +18 -11
  13. package/build/src/config/ConfigLocator.js +70 -0
  14. package/build/src/config/ConfigParser.js +264 -0
  15. package/build/src/config/ConfigWatcher.js +93 -0
  16. package/build/src/config/browser-options.js +2 -13
  17. package/build/src/config/category-options.js +15 -30
  18. package/build/src/config/cli-commands.js +165 -5
  19. package/build/src/config/cli-options.js +410 -43
  20. package/build/src/config/mcp-options.js +156 -234
  21. package/build/src/config/puppeteer-options.js +65 -0
  22. package/build/src/config/tool-options.js +60 -0
  23. package/build/src/daemon/client.js +81 -41
  24. package/build/src/daemon/daemon.js +55 -45
  25. package/build/src/daemon/utils.js +44 -11
  26. package/build/src/devtools/DevToolsCommentBridge.js +43 -6
  27. package/build/src/devtools/DevtoolsUtils.js +3 -3
  28. package/build/src/devtools/McpHostBindingAdapter.js +0 -1
  29. package/build/src/formatters/CommentFormatter.js +4 -13
  30. package/build/src/formatters/ConsoleFormatter.js +1 -1
  31. package/build/src/formatters/CssFormatter.js +3 -2
  32. package/build/src/formatters/HeapSnapshotFormatter.js +104 -46
  33. package/build/src/formatters/IssueFormatter.js +33 -32
  34. package/build/src/formatters/NetworkFormatter.js +12 -11
  35. package/build/src/formatters/SnapshotFormatter.js +31 -4
  36. package/build/src/index.js +54 -9
  37. package/build/src/processors/ChunkedTraceParser.js +11 -11
  38. package/build/src/processors/HeapSnapshotManager.js +121 -84
  39. package/build/src/processors/PerformanceTrace.js +9 -9
  40. package/build/src/telemetry/ClearcutLogger.js +1 -1
  41. package/build/src/telemetry/transformation.js +7 -11
  42. package/build/src/telemetry/watchdog/main.js +1 -1
  43. package/build/src/third_party/THIRD_PARTY_NOTICES +10 -367
  44. package/build/src/third_party/bundled-packages.json +7 -8
  45. package/build/src/third_party/devtools-formatter-worker.js +1193 -62
  46. package/build/src/third_party/devtools-heap-snapshot-worker.js +1126 -21
  47. package/build/src/third_party/index.js +8087 -19416
  48. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +0 -1
  49. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantReadOptOut.md +5 -0
  50. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +0 -1
  51. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSetOptOut.md +5 -0
  52. package/build/src/third_party/issue-descriptions/deprecation.md +1 -1
  53. package/build/src/third_party/issue-descriptions/genericGeolocationPromptWithoutUserGesture.md +5 -0
  54. package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +2 -0
  55. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +3 -3
  56. package/build/src/tools/ToolDefinition.js +16 -4
  57. package/build/src/tools/comments.js +20 -1
  58. package/build/src/tools/css.js +4 -2
  59. package/build/src/tools/emulation.js +17 -4
  60. package/build/src/tools/input.js +8 -3
  61. package/build/src/tools/lighthouse.js +112 -4
  62. package/build/src/tools/memory.js +129 -28
  63. package/build/src/tools/pages.js +5 -2
  64. package/build/src/tools/performance.js +21 -3
  65. package/build/src/tools/screencast.js +71 -32
  66. package/build/src/tools/screenshot.js +29 -14
  67. package/build/src/tools/script.js +90 -37
  68. package/build/src/tools/slim/tools.js +6 -8
  69. package/build/src/tools/thirdPartyDeveloper.js +6 -4
  70. package/build/src/tools/tools.js +35 -22
  71. package/build/src/tools/webmcp.js +9 -6
  72. package/build/src/types.js +11 -0
  73. package/build/src/utils/WaitForHelper.js +14 -1
  74. package/build/src/utils/check-for-updates.js +1 -1
  75. package/build/src/utils/errorHandling.js +20 -0
  76. package/build/src/utils/logger.js +15 -5
  77. package/build/src/utils/text.js +15 -0
  78. package/build/src/utils/url.js +99 -3
  79. package/build/src/version.js +1 -1
  80. package/package.json +14 -10
  81. package/skills/a11y-debugging/SKILL.md +4 -4
  82. package/skills/chrome-devtools/SKILL.md +2 -2
  83. package/skills/chrome-devtools-cli/SKILL.md +18 -15
  84. package/skills/cookie-debugging/SKILL.md +8 -5
  85. package/skills/debug-optimize-lcp/SKILL.md +1 -1
  86. package/skills/troubleshooting/SKILL.md +5 -6
@@ -103,14 +103,14 @@ async function saveScreenshot(options) {
103
103
  const screenRectHeight = options.clip.screenRectHeight * scale;
104
104
  const contentLeft = options.clip.visiblePageRectLeft * scale;
105
105
  const contentTop = options.clip.visiblePageRectTop * scale;
106
- canvas = new OffscreenCanvas(Math.floor(screenRectWidth),
107
- Math.min(1 << 14, Math.floor(screenRectHeight)));
106
+ canvas = new OffscreenCanvas(Math.round(screenRectWidth),
107
+ Math.min(1 << 14, Math.round(screenRectHeight)));
108
108
  const ctx = canvas.getContext('2d', { willReadFrequently: true });
109
109
  if (!ctx) {
110
110
  throw new Error('Could not get 2d context from canvas.');
111
111
  }
112
112
  ctx.imageSmoothingEnabled = false;
113
- ctx.drawImage(pageImage, Math.floor(contentLeft), Math.floor(contentTop));
113
+ ctx.drawImage(pageImage, Math.round(contentLeft), Math.round(contentTop));
114
114
  }
115
115
  else {
116
116
  canvas = new OffscreenCanvas(pageImage.naturalWidth, Math.min(1 << 14, Math.floor(pageImage.naturalHeight)));
@@ -2779,6 +2779,7 @@ var ExperimentName;
2779
2779
  ExperimentName["DURABLE_MESSAGES"] = "durable-messages";
2780
2780
  ExperimentName["JPEG_XL"] = "jpeg-xl";
2781
2781
  ExperimentName["PLUS_BUTTON"] = "plus-button";
2782
+ ExperimentName["SOURCE_MAP_SCOPES_IN_SOURCES_PANEL"] = "source-map-scopes-in-sources-panel";
2782
2783
  })(ExperimentName || (ExperimentName = {}));
2783
2784
 
2784
2785
  // Copyright 2016 The Chromium Authors
@@ -3231,7 +3232,7 @@ BIND_LEXICAL = 2,
3231
3232
  BIND_FUNCTION = 3,
3232
3233
  BIND_SIMPLE_CATCH = 4,
3233
3234
  BIND_OUTSIDE = 5;
3234
- var Parser$1 = function Parser(options, input, startPos) {
3235
+ var Parser$2 = function Parser(options, input, startPos) {
3235
3236
  this.options = options = getOptions(options);
3236
3237
  this.sourceFile = options.sourceFile;
3237
3238
  this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
@@ -3283,7 +3284,7 @@ var Parser$1 = function Parser(options, input, startPos) {
3283
3284
  this.privateNameStack = [];
3284
3285
  };
3285
3286
  var prototypeAccessors = { inFunction: { configurable: true }, inGenerator: { configurable: true }, inAsync: { configurable: true }, canAwait: { configurable: true }, allowReturn: { configurable: true }, allowSuper: { configurable: true }, allowDirectSuper: { configurable: true }, treatFunctionsAsVar: { configurable: true }, allowNewDotTarget: { configurable: true }, allowUsing: { configurable: true }, inClassStaticBlock: { configurable: true } };
3286
- Parser$1.prototype.parse = function parse() {
3287
+ Parser$2.prototype.parse = function parse() {
3287
3288
  var node = this.options.program || this.startNode();
3288
3289
  this.nextToken();
3289
3290
  return this.parseTopLevel(node);
@@ -3345,7 +3346,7 @@ prototypeAccessors.allowUsing.get = function () {
3345
3346
  prototypeAccessors.inClassStaticBlock.get = function () {
3346
3347
  return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0;
3347
3348
  };
3348
- Parser$1.extend = function extend() {
3349
+ Parser$2.extend = function extend() {
3349
3350
  var plugins = [], len = arguments.length;
3350
3351
  while (len--)
3351
3352
  plugins[len] = arguments[len];
@@ -3355,19 +3356,19 @@ Parser$1.extend = function extend() {
3355
3356
  }
3356
3357
  return cls;
3357
3358
  };
3358
- Parser$1.parse = function parse(input, options) {
3359
+ Parser$2.parse = function parse(input, options) {
3359
3360
  return new this(options, input).parse();
3360
3361
  };
3361
- Parser$1.parseExpressionAt = function parseExpressionAt(input, pos, options) {
3362
+ Parser$2.parseExpressionAt = function parseExpressionAt(input, pos, options) {
3362
3363
  var parser = new this(options, input, pos);
3363
3364
  parser.nextToken();
3364
3365
  return parser.parseExpression();
3365
3366
  };
3366
- Parser$1.tokenizer = function tokenizer(input, options) {
3367
+ Parser$2.tokenizer = function tokenizer(input, options) {
3367
3368
  return new this(options, input);
3368
3369
  };
3369
- Object.defineProperties(Parser$1.prototype, prototypeAccessors);
3370
- var pp$9 = Parser$1.prototype;
3370
+ Object.defineProperties(Parser$2.prototype, prototypeAccessors);
3371
+ var pp$9 = Parser$2.prototype;
3371
3372
  var literal = /^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;
3372
3373
  pp$9.strictDirective = function (start) {
3373
3374
  if (this.options.ecmaVersion < 5) {
@@ -3505,7 +3506,7 @@ pp$9.isSimpleAssignTarget = function (expr) {
3505
3506
  }
3506
3507
  return expr.type === "Identifier" || expr.type === "MemberExpression";
3507
3508
  };
3508
- var pp$8 = Parser$1.prototype;
3509
+ var pp$8 = Parser$2.prototype;
3509
3510
  pp$8.parseTopLevel = function (node) {
3510
3511
  var exports = Object.create(null);
3511
3512
  if (!node.body) {
@@ -4707,7 +4708,7 @@ pp$8.isDirectiveCandidate = function (statement) {
4707
4708
  typeof statement.expression.value === "string" &&
4708
4709
  (this.input[statement.start] === "\"" || this.input[statement.start] === "'"));
4709
4710
  };
4710
- var pp$7 = Parser$1.prototype;
4711
+ var pp$7 = Parser$2.prototype;
4711
4712
  pp$7.toAssignable = function (node, isBinding, refDestructuringErrors) {
4712
4713
  if (this.options.ecmaVersion >= 6 && node) {
4713
4714
  switch (node.type) {
@@ -4975,7 +4976,7 @@ var types = {
4975
4976
  f_expr_gen: new TokContext("function", true, false, null, true),
4976
4977
  f_gen: new TokContext("function", false, false, null, true)
4977
4978
  };
4978
- var pp$6 = Parser$1.prototype;
4979
+ var pp$6 = Parser$2.prototype;
4979
4980
  pp$6.initialContext = function () {
4980
4981
  return [types.b_stat];
4981
4982
  };
@@ -5105,7 +5106,7 @@ types$1.name.updateContext = function (prevType) {
5105
5106
  }
5106
5107
  this.exprAllowed = allowed;
5107
5108
  };
5108
- var pp$5 = Parser$1.prototype;
5109
+ var pp$5 = Parser$2.prototype;
5109
5110
  pp$5.checkPropClash = function (prop, propHash, refDestructuringErrors) {
5110
5111
  if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") {
5111
5112
  return;
@@ -6215,7 +6216,7 @@ pp$5.parseAwait = function (forInit) {
6215
6216
  node.argument = this.parseMaybeUnary(null, true, false, forInit);
6216
6217
  return this.finishNode(node, "AwaitExpression");
6217
6218
  };
6218
- var pp$4 = Parser$1.prototype;
6219
+ var pp$4 = Parser$2.prototype;
6219
6220
  pp$4.raise = function (pos, message) {
6220
6221
  var loc = getLineInfo(this.input, pos);
6221
6222
  message += " (" + loc.line + ":" + loc.column + ")";
@@ -6234,7 +6235,7 @@ pp$4.curPosition = function () {
6234
6235
  return new Position(this.curLine, this.pos - this.lineStart);
6235
6236
  }
6236
6237
  };
6237
- var pp$3 = Parser$1.prototype;
6238
+ var pp$3 = Parser$2.prototype;
6238
6239
  var Scope$1 = function Scope(flags) {
6239
6240
  this.flags = flags;
6240
6241
  this.var = [];
@@ -6335,7 +6336,7 @@ var Node = function Node(parser, pos, loc) {
6335
6336
  this.range = [pos, 0];
6336
6337
  }
6337
6338
  };
6338
- var pp$2 = Parser$1.prototype;
6339
+ var pp$2 = Parser$2.prototype;
6339
6340
  pp$2.startNode = function () {
6340
6341
  return new Node(this, this.start, this.startLoc);
6341
6342
  };
@@ -6424,7 +6425,7 @@ for (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) {
6424
6425
  var ecmaVersion = list[i];
6425
6426
  buildUnicodeData(ecmaVersion);
6426
6427
  }
6427
- var pp$1 = Parser$1.prototype;
6428
+ var pp$1 = Parser$2.prototype;
6428
6429
  var BranchID = function BranchID(parent, base) {
6429
6430
  this.parent = parent;
6430
6431
  this.base = base || this;
@@ -7615,7 +7616,7 @@ var Token$1 = function Token(p) {
7615
7616
  this.range = [p.start, p.end];
7616
7617
  }
7617
7618
  };
7618
- var pp = Parser$1.prototype;
7619
+ var pp = Parser$2.prototype;
7619
7620
  pp.next = function (ignoreEscapeSequenceInKeyword) {
7620
7621
  if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc) {
7621
7622
  this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword);
@@ -8426,8 +8427,8 @@ pp.readWord = function () {
8426
8427
  return this.finishToken(type, word);
8427
8428
  };
8428
8429
  var version = "8.16.0";
8429
- Parser$1.acorn = {
8430
- Parser: Parser$1,
8430
+ Parser$2.acorn = {
8431
+ Parser: Parser$2,
8431
8432
  version: version,
8432
8433
  defaultOptions: defaultOptions,
8433
8434
  Position: Position,
@@ -8449,8 +8450,9 @@ Parser$1.acorn = {
8449
8450
  };
8450
8451
 
8451
8452
  // Copyright (c) 2020 The Chromium Authors. All rights reserved.
8452
- Parser$1.tokenizer.bind(Parser$1);
8453
- const parse$1 = Parser$1.parse.bind(Parser$1);
8453
+ const Parser$1 = Parser$2;
8454
+ Parser$2.tokenizer.bind(Parser$2);
8455
+ const parse$1 = Parser$2.parse.bind(Parser$2);
8454
8456
 
8455
8457
  // Copyright 2020 The Chromium Authors
8456
8458
  const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -10508,6 +10510,12 @@ const LAYOUT_LINES_HIGHLIGHT_COLOR = [127, 32, 210];
10508
10510
  GapBackground: Legacy.fromRGBA([...LAYOUT_LINES_HIGHLIGHT_COLOR, .3]),
10509
10511
  GapHatch: Legacy.fromRGBA([...LAYOUT_LINES_HIGHLIGHT_COLOR, .8]),
10510
10512
  GridAreaBorder: Legacy.fromRGBA([26, 115, 232, 1]),
10513
+ AnchorIMCB: Legacy.fromRGBA([127, 32, 210, 1]),
10514
+ AnchorIMCBBackground: Legacy.fromRGBA([127, 32, 210, 0.15]),
10515
+ AnchorInsetsBackground: Legacy.fromRGBA([246, 178, 107, 0.25]),
10516
+ AnchorInsetsHatch: Legacy.fromRGBA([246, 178, 107, 0.8]),
10517
+ AnchorTarget: Legacy.fromRGBA([26, 115, 232, 1]),
10518
+ AnchorTargetBackground: Legacy.fromRGBA([26, 115, 232, 0.15]),
10511
10519
  });
10512
10520
  ({
10513
10521
  ParentOutline: Legacy.fromRGBA([224, 90, 183, 1]),
@@ -12579,7 +12587,11 @@ class ParsedURL {
12579
12587
  preEncodedPath = 'file:///' + preEncodedPath;
12580
12588
  }
12581
12589
  }
12582
- return new URL(preEncodedPath).toString();
12590
+ let url = new URL(preEncodedPath).toString();
12591
+ while (url.endsWith('/') && url.length > 'file:///'.length) {
12592
+ url = url.substring(0, url.length - 1);
12593
+ }
12594
+ return url;
12583
12595
  }
12584
12596
  static relativePathToUrlString(relativePath, baseURL) {
12585
12597
  const preEncodedPath = ParsedURL.preEncodeSpecialCharactersInPath(relativePath.replace(/\\/g, '/'));
@@ -12639,7 +12651,7 @@ class ParsedURL {
12639
12651
  }
12640
12652
  const schemeRegex = /([A-Za-z][A-Za-z0-9+.-]*):\/\//;
12641
12653
  const userRegex = /(?:([A-Za-z0-9\-._~%!$&'()*+,;=:]*)@)?/;
12642
- const hostRegex = /((?:\[::\d?\])|(?:[^\s\/:]*))/;
12654
+ const hostRegex = /((?:\[[0-9a-fA-F:.]*:[0-9a-fA-F:.]*\])|(?:[^\s\/:]*))/;
12643
12655
  const portRegex = /(?::([\d]+))?/;
12644
12656
  const pathRegex = /(\/[^#?]*)?/;
12645
12657
  const queryRegex = /(?:\?([^#]*))?/;
@@ -13292,6 +13304,979 @@ new FinalizationRegistry(url => {
13292
13304
  URL.revokeObjectURL(url);
13293
13305
  });
13294
13306
 
13307
+ /**
13308
+ * marked v18.0.4 - a markdown parser
13309
+ * Copyright (c) 2018-2026, MarkedJS. (MIT License)
13310
+ * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
13311
+ * https://github.com/markedjs/marked
13312
+ */
13313
+ function M() { return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null }; }
13314
+ var T = M();
13315
+ function N(l) { T = l; }
13316
+ var _ = { exec: () => null };
13317
+ function E(l) { let e = []; return t => { let n = Math.max(0, Math.min(3, t - 1)), s = e[n]; return s || (s = l(n), e[n] = s), s; }; }
13318
+ function d(l, e = "") { let t = typeof l == "string" ? l : l.source, n = { replace: (s, r) => { let i = typeof r == "string" ? r : r.source; return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n; }, getRegex: () => new RegExp(t, e) }; return n; }
13319
+ var Te = ((l = "") => { try {
13320
+ return !!new RegExp("(?<=1)(?<!1)" + l);
13321
+ }
13322
+ catch {
13323
+ return false;
13324
+ } })(), m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: l => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: E(l => new RegExp(`^ {0,${l}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: E(l => new RegExp(`^ {0,${l}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: E(l => new RegExp(`^ {0,${l}}(?:\`\`\`|~~~)`)), headingBeginRegex: E(l => new RegExp(`^ {0,${l}}#`)), htmlBeginRegex: E(l => new RegExp(`^ {0,${l}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: E(l => new RegExp(`^ {0,${l}}>`)) }, Oe = /^(?:[ \t]*(?:\n|$))+/, we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, B = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, j = / {0,3}(?:[*+-]|\d{1,9}[.)])/, oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ae = d(oe).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Se = d(oe).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, $e = /^[^\n]+/, U = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Le = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", U).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), _e = d(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, j).getRegex(), H = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", K = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, ze = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", K).replace("tag", H).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), le = d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex(), Me = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", le).getRegex(), W = { blockquote: Me, code: we, def: Le, fences: ye, heading: Pe, hr: B, html: ze, lheading: ae, list: _e, newline: Oe, paragraph: le, table: _, text: $e }, se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex(), Ee = { ...W, lheading: Se, table: se, paragraph: d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex() }, Ie = { ...W, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", K).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(F).replace("hr", B).replace("heading", ` *#{1,6} *[^
13325
+ ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ue = /^( {2,}|\\)\n(?!\s*$)/, Be = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, I = /[\p{P}\p{S}]/u, Z = /[\s\p{P}\p{S}]/u, X = /[^\s\p{P}\p{S}]/u, De = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Z).getRegex(), pe = /(?!~)[\p{P}\p{S}]/u, qe = /(?!~)[\s\p{P}\p{S}]/u, ve = /(?:[^\s\p{P}\p{S}]|~)/u, He = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, Ze = d(ce, "u").replace(/punct/g, I).getRegex(), Ge = d(ce, "u").replace(/punct/g, pe).getRegex(), he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Ne = d(he, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex(), Qe = d(he, "gu").replace(/notPunctSpace/g, ve).replace(/punctSpace/g, qe).replace(/punct/g, pe).getRegex(), je = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex(), Fe = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, I).getRegex(), Ue = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", Ke = d(Ue, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex(), We = d(/\\(punct)/, "gu").replace(/punct/g, I).getRegex(), Xe = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), Je = d(K).replace("(?:-->|$)", "-->").getRegex(), Ve = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), v = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, Ye = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", v).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ke = d(/^!?\[(label)\]\[(ref)\]/).replace("label", v).replace("ref", U).getRegex(), de = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", U).getRegex(), et = d("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex(), ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, J = { _backpedal: _, anyPunctuation: We, autolink: Xe, blockSkip: He, br: ue, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: Ze, emStrongRDelimAst: Ne, emStrongRDelimUnd: je, escape: Ae, link: Ye, nolink: de, punctuation: De, reflink: ke, reflinkSearch: et, tag: Ve, text: Be, url: _ }, tt = { ...J, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", v).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", v).getRegex() }, Q = { ...J, emStrongRDelimAst: Qe, emStrongLDelim: Ge, delLDelim: Fe, delRDelim: Ke, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() }, nt = { ...Q, br: d(ue).replace("{2,}", "*").getRegex(), text: d(Q.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, D = { normal: W, gfm: Ee, pedantic: Ie }, A = { normal: J, gfm: Q, breaks: nt, pedantic: tt };
13326
+ var rt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, ge = l => rt[l];
13327
+ function O(l, e) { if (e) {
13328
+ if (m.escapeTest.test(l))
13329
+ return l.replace(m.escapeReplace, ge);
13330
+ }
13331
+ else if (m.escapeTestNoEncode.test(l))
13332
+ return l.replace(m.escapeReplaceNoEncode, ge); return l; }
13333
+ function V(l) { try {
13334
+ l = encodeURI(l).replace(m.percentDecode, "%");
13335
+ }
13336
+ catch {
13337
+ return null;
13338
+ } return l; }
13339
+ function Y(l, e) { let t = l.replace(m.findPipe, (r, i, o) => { let u = false, a = i; for (; --a >= 0 && o[a] === "\\";)
13340
+ u = !u; return u ? "|" : " |"; }), n = t.split(m.splitPipe), s = 0; if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
13341
+ if (n.length > e)
13342
+ n.splice(e);
13343
+ else
13344
+ for (; n.length < e;)
13345
+ n.push(""); for (; s < n.length; s++)
13346
+ n[s] = n[s].trim().replace(m.slashPipe, "|"); return n; }
13347
+ function $(l, e, t) { let n = l.length; if (n === 0)
13348
+ return ""; let s = 0; for (; s < n;) {
13349
+ let r = l.charAt(n - s - 1);
13350
+ if (r === e && true)
13351
+ s++;
13352
+ else break;
13353
+ } return l.slice(0, n - s); }
13354
+ function ee(l) {
13355
+ let e = l.split(`
13356
+ `), t = e.length - 1;
13357
+ for (; t >= 0 && m.blankLine.test(e[t]);)
13358
+ t--;
13359
+ return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
13360
+ `);
13361
+ }
13362
+ function fe(l, e) { if (l.indexOf(e[1]) === -1)
13363
+ return -1; let t = 0; for (let n = 0; n < l.length; n++)
13364
+ if (l[n] === "\\")
13365
+ n++;
13366
+ else if (l[n] === e[0])
13367
+ t++;
13368
+ else if (l[n] === e[1] && (t--, t < 0))
13369
+ return n; return t > 0 ? -2 : -1; }
13370
+ function me(l, e = 0) { let t = e, n = ""; for (let s of l)
13371
+ if (s === " ") {
13372
+ let r = 4 - t % 4;
13373
+ n += " ".repeat(r), t += r;
13374
+ }
13375
+ else
13376
+ n += s, t++; return n; }
13377
+ function xe(l, e, t, n, s) { let r = e.href, i = e.title || null, o = l[1].replace(s.other.outputLinkReplace, "$1"); n.state.inLink = true; let u = { type: l[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) }; return n.state.inLink = false, u; }
13378
+ function st(l, e, t) {
13379
+ let n = l.match(t.other.indentCodeCompensation);
13380
+ if (n === null)
13381
+ return e;
13382
+ let s = n[1];
13383
+ return e.split(`
13384
+ `).map(r => { let i = r.match(t.other.beginningSpace); if (i === null)
13385
+ return r; let [o] = i; return o.length >= s.length ? r.slice(s.length) : r; }).join(`
13386
+ `);
13387
+ }
13388
+ var w = class {
13389
+ options;
13390
+ rules;
13391
+ lexer;
13392
+ constructor(e) { this.options = e || T; }
13393
+ space(e) { let t = this.rules.block.newline.exec(e); if (t && t[0].length > 0)
13394
+ return { type: "space", raw: t[0] }; }
13395
+ code(e) { let t = this.rules.block.code.exec(e); if (t) {
13396
+ let n = this.options.pedantic ? t[0] : ee(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
13397
+ return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
13398
+ } }
13399
+ fences(e) { let t = this.rules.block.fences.exec(e); if (t) {
13400
+ let n = t[0], s = st(n, t[3] || "", this.rules);
13401
+ return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
13402
+ } }
13403
+ heading(e) {
13404
+ let t = this.rules.block.heading.exec(e);
13405
+ if (t) {
13406
+ let n = t[2].trim();
13407
+ if (this.rules.other.endingHash.test(n)) {
13408
+ let s = $(n, "#");
13409
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
13410
+ }
13411
+ return { type: "heading", raw: $(t[0], `
13412
+ `), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
13413
+ }
13414
+ }
13415
+ hr(e) {
13416
+ let t = this.rules.block.hr.exec(e);
13417
+ if (t)
13418
+ return { type: "hr", raw: $(t[0], `
13419
+ `) };
13420
+ }
13421
+ blockquote(e) {
13422
+ let t = this.rules.block.blockquote.exec(e);
13423
+ if (t) {
13424
+ let n = $(t[0], `
13425
+ `).split(`
13426
+ `), s = "", r = "", i = [];
13427
+ for (; n.length > 0;) {
13428
+ let o = false, u = [], a;
13429
+ for (a = 0; a < n.length; a++)
13430
+ if (this.rules.other.blockquoteStart.test(n[a]))
13431
+ u.push(n[a]), o = true;
13432
+ else if (!o)
13433
+ u.push(n[a]);
13434
+ else
13435
+ break;
13436
+ n = n.slice(a);
13437
+ let c = u.join(`
13438
+ `), p = c.replace(this.rules.other.blockquoteSetextReplace, `
13439
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
13440
+ s = s ? `${s}
13441
+ ${c}` : c, r = r ? `${r}
13442
+ ${p}` : p;
13443
+ let k = this.lexer.state.top;
13444
+ if (this.lexer.state.top = true, this.lexer.blockTokens(p, i, true), this.lexer.state.top = k, n.length === 0)
13445
+ break;
13446
+ let h = i.at(-1);
13447
+ if (h?.type === "code")
13448
+ break;
13449
+ if (h?.type === "blockquote") {
13450
+ let R = h, f = R.raw + `
13451
+ ` + n.join(`
13452
+ `), S = this.blockquote(f);
13453
+ i[i.length - 1] = S, s = s.substring(0, s.length - R.raw.length) + S.raw, r = r.substring(0, r.length - R.text.length) + S.text;
13454
+ break;
13455
+ }
13456
+ else if (h?.type === "list") {
13457
+ let R = h, f = R.raw + `
13458
+ ` + n.join(`
13459
+ `), S = this.list(f);
13460
+ i[i.length - 1] = S, s = s.substring(0, s.length - h.raw.length) + S.raw, r = r.substring(0, r.length - R.raw.length) + S.raw, n = f.substring(i.at(-1).raw.length).split(`
13461
+ `);
13462
+ continue;
13463
+ }
13464
+ }
13465
+ return { type: "blockquote", raw: s, tokens: i, text: r };
13466
+ }
13467
+ }
13468
+ list(e) {
13469
+ let t = this.rules.block.list.exec(e);
13470
+ if (t) {
13471
+ let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
13472
+ n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
13473
+ let i = this.rules.other.listItemRegex(n), o = false;
13474
+ for (; e;) {
13475
+ let a = false, c = "", p = "";
13476
+ if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
13477
+ break;
13478
+ c = t[0], e = e.substring(c.length);
13479
+ let k = me(t[2].split(`
13480
+ `, 1)[0], t[1].length), h = e.split(`
13481
+ `, 1)[0], R = !k.trim(), f = 0;
13482
+ if (this.options.pedantic ? (f = 2, p = k.trimStart()) : R ? f = t[1].length + 1 : (f = k.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, p = k.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (c += h + `
13483
+ `, e = e.substring(h.length + 1), a = true), !a) {
13484
+ let S = this.rules.other.nextBulletRegex(f), te = this.rules.other.hrRegex(f), ne = this.rules.other.fencesBeginRegex(f), re = this.rules.other.headingBeginRegex(f), be = this.rules.other.htmlBeginRegex(f), Re = this.rules.other.blockquoteBeginRegex(f);
13485
+ for (; e;) {
13486
+ let G = e.split(`
13487
+ `, 1)[0], C;
13488
+ if (h = G, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), C = h) : C = h.replace(this.rules.other.tabCharGlobal, " "), ne.test(h) || re.test(h) || be.test(h) || Re.test(h) || S.test(h) || te.test(h))
13489
+ break;
13490
+ if (C.search(this.rules.other.nonSpaceChar) >= f || !h.trim())
13491
+ p += `
13492
+ ` + C.slice(f);
13493
+ else {
13494
+ if (R || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(k) || re.test(k) || te.test(k))
13495
+ break;
13496
+ p += `
13497
+ ` + h;
13498
+ }
13499
+ R = !h.trim(), c += G + `
13500
+ `, e = e.substring(G.length + 1), k = C.slice(f);
13501
+ }
13502
+ }
13503
+ r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(c) && (o = true)), r.items.push({ type: "list_item", raw: c, task: !!this.options.gfm && this.rules.other.listIsTask.test(p), loose: false, text: p, tokens: [] }), r.raw += c;
13504
+ }
13505
+ let u = r.items.at(-1);
13506
+ if (u)
13507
+ u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
13508
+ else
13509
+ return;
13510
+ r.raw = r.raw.trimEnd();
13511
+ for (let a of r.items) {
13512
+ this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
13513
+ let c = a.tokens[0];
13514
+ if (a.task && (c?.type === "text" || c?.type === "paragraph")) {
13515
+ a.text = a.text.replace(this.rules.other.listReplaceTask, ""), c.raw = c.raw.replace(this.rules.other.listReplaceTask, ""), c.text = c.text.replace(this.rules.other.listReplaceTask, "");
13516
+ for (let k = this.lexer.inlineQueue.length - 1; k >= 0; k--)
13517
+ if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
13518
+ this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
13519
+ break;
13520
+ }
13521
+ let p = this.rules.other.listTaskCheckbox.exec(a.raw);
13522
+ if (p) {
13523
+ let k = { type: "checkbox", raw: p[0] + " ", checked: p[0] !== "[ ]" };
13524
+ a.checked = k.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = k.raw + a.tokens[0].raw, a.tokens[0].text = k.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(k)) : a.tokens.unshift({ type: "paragraph", raw: k.raw, text: k.raw, tokens: [k] }) : a.tokens.unshift(k);
13525
+ }
13526
+ }
13527
+ else
13528
+ a.task && (a.task = false);
13529
+ if (!r.loose) {
13530
+ let p = a.tokens.filter(h => h.type === "space"), k = p.length > 0 && p.some(h => this.rules.other.anyLine.test(h.raw));
13531
+ r.loose = k;
13532
+ }
13533
+ }
13534
+ if (r.loose)
13535
+ for (let a of r.items) {
13536
+ a.loose = true;
13537
+ for (let c of a.tokens)
13538
+ c.type === "text" && (c.type = "paragraph");
13539
+ }
13540
+ return r;
13541
+ }
13542
+ }
13543
+ html(e) { let t = this.rules.block.html.exec(e); if (t) {
13544
+ let n = ee(t[0]);
13545
+ return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
13546
+ } }
13547
+ def(e) {
13548
+ let t = this.rules.block.def.exec(e);
13549
+ if (t) {
13550
+ let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
13551
+ return { type: "def", tag: n, raw: $(t[0], `
13552
+ `), href: s, title: r };
13553
+ }
13554
+ }
13555
+ table(e) {
13556
+ let t = this.rules.block.table.exec(e);
13557
+ if (!t || !this.rules.other.tableDelimiter.test(t[2]))
13558
+ return;
13559
+ let n = Y(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
13560
+ `) : [], i = { type: "table", raw: $(t[0], `
13561
+ `), header: [], align: [], rows: [] };
13562
+ if (n.length === s.length) {
13563
+ for (let o of s)
13564
+ this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
13565
+ for (let o = 0; o < n.length; o++)
13566
+ i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
13567
+ for (let o of r)
13568
+ i.rows.push(Y(o, i.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: i.align[a] })));
13569
+ return i;
13570
+ }
13571
+ }
13572
+ lheading(e) {
13573
+ let t = this.rules.block.lheading.exec(e);
13574
+ if (t) {
13575
+ let n = t[1].trim();
13576
+ return { type: "heading", raw: $(t[0], `
13577
+ `), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
13578
+ }
13579
+ }
13580
+ paragraph(e) {
13581
+ let t = this.rules.block.paragraph.exec(e);
13582
+ if (t) {
13583
+ let n = t[1].charAt(t[1].length - 1) === `
13584
+ ` ? t[1].slice(0, -1) : t[1];
13585
+ return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
13586
+ }
13587
+ }
13588
+ text(e) { let t = this.rules.block.text.exec(e); if (t)
13589
+ return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) }; }
13590
+ escape(e) { let t = this.rules.inline.escape.exec(e); if (t)
13591
+ return { type: "escape", raw: t[0], text: t[1] }; }
13592
+ tag(e) { let t = this.rules.inline.tag.exec(e); if (t)
13593
+ return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] }; }
13594
+ link(e) { let t = this.rules.inline.link.exec(e); if (t) {
13595
+ let n = t[2].trim();
13596
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
13597
+ if (!this.rules.other.endAngleBracket.test(n))
13598
+ return;
13599
+ let i = $(n.slice(0, -1), "\\");
13600
+ if ((n.length - i.length) % 2 === 0)
13601
+ return;
13602
+ }
13603
+ else {
13604
+ let i = fe(t[2], "()");
13605
+ if (i === -2)
13606
+ return;
13607
+ if (i > -1) {
13608
+ let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
13609
+ t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
13610
+ }
13611
+ }
13612
+ let s = t[2], r = "";
13613
+ if (this.options.pedantic) {
13614
+ let i = this.rules.other.pedanticHrefTitle.exec(s);
13615
+ i && (s = i[1], r = i[3]);
13616
+ }
13617
+ else
13618
+ r = t[3] ? t[3].slice(1, -1) : "";
13619
+ return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
13620
+ } }
13621
+ reflink(e, t) { let n; if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
13622
+ let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
13623
+ if (!r) {
13624
+ let i = n[0].charAt(0);
13625
+ return { type: "text", raw: i, text: i };
13626
+ }
13627
+ return xe(n, r, n[0], this.lexer, this.rules);
13628
+ } }
13629
+ emStrong(e, t, n = "") { let s = this.rules.inline.emStrongLDelim.exec(e); if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric))
13630
+ return; if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
13631
+ let i = [...s[0]].length - 1, o, u, a = i, c = 0, p = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
13632
+ for (p.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = p.exec(t)) !== null;) {
13633
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o)
13634
+ continue;
13635
+ if (u = [...o].length, s[3] || s[4]) {
13636
+ a += u;
13637
+ continue;
13638
+ }
13639
+ else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
13640
+ c += u;
13641
+ continue;
13642
+ }
13643
+ if (a -= u, a > 0)
13644
+ continue;
13645
+ u = Math.min(u, u + a + c);
13646
+ let k = [...s[0]][0].length, h = e.slice(0, i + s.index + k + u);
13647
+ if (Math.min(i, u) % 2) {
13648
+ let f = h.slice(1, -1);
13649
+ return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
13650
+ }
13651
+ let R = h.slice(2, -2);
13652
+ return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
13653
+ }
13654
+ } }
13655
+ codespan(e) { let t = this.rules.inline.code.exec(e); if (t) {
13656
+ let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
13657
+ return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
13658
+ } }
13659
+ br(e) { let t = this.rules.inline.br.exec(e); if (t)
13660
+ return { type: "br", raw: t[0] }; }
13661
+ del(e, t, n = "") { let s = this.rules.inline.delLDelim.exec(e); if (!s)
13662
+ return; if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
13663
+ let i = [...s[0]].length - 1, o, u, a = i, c = this.rules.inline.delRDelim;
13664
+ for (c.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = c.exec(t)) !== null;) {
13665
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i))
13666
+ continue;
13667
+ if (s[3] || s[4]) {
13668
+ a += u;
13669
+ continue;
13670
+ }
13671
+ if (a -= u, a > 0)
13672
+ continue;
13673
+ u = Math.min(u, u + a);
13674
+ let p = [...s[0]][0].length, k = e.slice(0, i + s.index + p + u), h = k.slice(i, -i);
13675
+ return { type: "del", raw: k, text: h, tokens: this.lexer.inlineTokens(h) };
13676
+ }
13677
+ } }
13678
+ autolink(e) { let t = this.rules.inline.autolink.exec(e); if (t) {
13679
+ let n, s;
13680
+ return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
13681
+ } }
13682
+ url(e) { let t; if (t = this.rules.inline.url.exec(e)) {
13683
+ let n, s;
13684
+ if (t[2] === "@")
13685
+ n = t[0], s = "mailto:" + n;
13686
+ else {
13687
+ let r;
13688
+ do
13689
+ r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
13690
+ while (r !== t[0]);
13691
+ n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
13692
+ }
13693
+ return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
13694
+ } }
13695
+ inlineText(e) { let t = this.rules.inline.text.exec(e); if (t) {
13696
+ let n = this.lexer.state.inRawBlock;
13697
+ return { type: "text", raw: t[0], text: t[0], escaped: n };
13698
+ } }
13699
+ };
13700
+ var x = class l {
13701
+ tokens;
13702
+ options;
13703
+ state;
13704
+ inlineQueue;
13705
+ tokenizer;
13706
+ constructor(e) { this.tokens = [], this.tokens.links = Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true }; let t = { other: m, block: D.normal, inline: A.normal }; this.options.pedantic ? (t.block = D.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = D.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t; }
13707
+ static get rules() { return { block: D, inline: A }; }
13708
+ static lex(e, t) { return new l(t).lex(e); }
13709
+ static lexInline(e, t) { return new l(t).inlineTokens(e); }
13710
+ lex(e) {
13711
+ e = e.replace(m.carriageReturn, `
13712
+ `), this.blockTokens(e, this.tokens);
13713
+ for (let t = 0; t < this.inlineQueue.length; t++) {
13714
+ let n = this.inlineQueue[t];
13715
+ this.inlineTokens(n.src, n.tokens);
13716
+ }
13717
+ return this.inlineQueue = [], this.tokens;
13718
+ }
13719
+ blockTokens(e, t = [], n = false) {
13720
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
13721
+ let s = 1 / 0;
13722
+ for (; e;) {
13723
+ if (e.length < s)
13724
+ s = e.length;
13725
+ else {
13726
+ this.infiniteLoopError(e.charCodeAt(0));
13727
+ break;
13728
+ }
13729
+ let r;
13730
+ if (this.options.extensions?.block?.some(o => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false))
13731
+ continue;
13732
+ if (r = this.tokenizer.space(e)) {
13733
+ e = e.substring(r.raw.length);
13734
+ let o = t.at(-1);
13735
+ r.raw.length === 1 && o !== void 0 ? o.raw += `
13736
+ ` : t.push(r);
13737
+ continue;
13738
+ }
13739
+ if (r = this.tokenizer.code(e)) {
13740
+ e = e.substring(r.raw.length);
13741
+ let o = t.at(-1);
13742
+ o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
13743
+ `) ? "" : `
13744
+ `) + r.raw, o.text += `
13745
+ ` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
13746
+ continue;
13747
+ }
13748
+ if (r = this.tokenizer.fences(e)) {
13749
+ e = e.substring(r.raw.length), t.push(r);
13750
+ continue;
13751
+ }
13752
+ if (r = this.tokenizer.heading(e)) {
13753
+ e = e.substring(r.raw.length), t.push(r);
13754
+ continue;
13755
+ }
13756
+ if (r = this.tokenizer.hr(e)) {
13757
+ e = e.substring(r.raw.length), t.push(r);
13758
+ continue;
13759
+ }
13760
+ if (r = this.tokenizer.blockquote(e)) {
13761
+ e = e.substring(r.raw.length), t.push(r);
13762
+ continue;
13763
+ }
13764
+ if (r = this.tokenizer.list(e)) {
13765
+ e = e.substring(r.raw.length), t.push(r);
13766
+ continue;
13767
+ }
13768
+ if (r = this.tokenizer.html(e)) {
13769
+ e = e.substring(r.raw.length), t.push(r);
13770
+ continue;
13771
+ }
13772
+ if (r = this.tokenizer.def(e)) {
13773
+ e = e.substring(r.raw.length);
13774
+ let o = t.at(-1);
13775
+ o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
13776
+ `) ? "" : `
13777
+ `) + r.raw, o.text += `
13778
+ ` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
13779
+ continue;
13780
+ }
13781
+ if (r = this.tokenizer.table(e)) {
13782
+ e = e.substring(r.raw.length), t.push(r);
13783
+ continue;
13784
+ }
13785
+ if (r = this.tokenizer.lheading(e)) {
13786
+ e = e.substring(r.raw.length), t.push(r);
13787
+ continue;
13788
+ }
13789
+ let i = e;
13790
+ if (this.options.extensions?.startBlock) {
13791
+ let o = 1 / 0, u = e.slice(1), a;
13792
+ this.options.extensions.startBlock.forEach(c => { a = c.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a)); }), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
13793
+ }
13794
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
13795
+ let o = t.at(-1);
13796
+ n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
13797
+ `) ? "" : `
13798
+ `) + r.raw, o.text += `
13799
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
13800
+ continue;
13801
+ }
13802
+ if (r = this.tokenizer.text(e)) {
13803
+ e = e.substring(r.raw.length);
13804
+ let o = t.at(-1);
13805
+ o?.type === "text" ? (o.raw += (o.raw.endsWith(`
13806
+ `) ? "" : `
13807
+ `) + r.raw, o.text += `
13808
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
13809
+ continue;
13810
+ }
13811
+ if (e) {
13812
+ this.infiniteLoopError(e.charCodeAt(0));
13813
+ break;
13814
+ }
13815
+ }
13816
+ return this.state.top = true, t;
13817
+ }
13818
+ inline(e, t = []) { return this.inlineQueue.push({ src: e, tokens: t }), t; }
13819
+ inlineTokens(e, t = []) { this.tokenizer.lexer = this; let n = e, s = null; if (this.tokens.links) {
13820
+ let a = Object.keys(this.tokens.links);
13821
+ if (a.length > 0)
13822
+ for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null;)
13823
+ a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
13824
+ } for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null;)
13825
+ n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex); let r; for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null;)
13826
+ r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex); n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n; let i = false, o = "", u = 1 / 0; for (; e;) {
13827
+ if (e.length < u)
13828
+ u = e.length;
13829
+ else {
13830
+ this.infiniteLoopError(e.charCodeAt(0));
13831
+ break;
13832
+ }
13833
+ i || (o = ""), i = false;
13834
+ let a;
13835
+ if (this.options.extensions?.inline?.some(p => (a = p.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false))
13836
+ continue;
13837
+ if (a = this.tokenizer.escape(e)) {
13838
+ e = e.substring(a.raw.length), t.push(a);
13839
+ continue;
13840
+ }
13841
+ if (a = this.tokenizer.tag(e)) {
13842
+ e = e.substring(a.raw.length), t.push(a);
13843
+ continue;
13844
+ }
13845
+ if (a = this.tokenizer.link(e)) {
13846
+ e = e.substring(a.raw.length), t.push(a);
13847
+ continue;
13848
+ }
13849
+ if (a = this.tokenizer.reflink(e, this.tokens.links)) {
13850
+ e = e.substring(a.raw.length);
13851
+ let p = t.at(-1);
13852
+ a.type === "text" && p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
13853
+ continue;
13854
+ }
13855
+ if (a = this.tokenizer.emStrong(e, n, o)) {
13856
+ e = e.substring(a.raw.length), t.push(a);
13857
+ continue;
13858
+ }
13859
+ if (a = this.tokenizer.codespan(e)) {
13860
+ e = e.substring(a.raw.length), t.push(a);
13861
+ continue;
13862
+ }
13863
+ if (a = this.tokenizer.br(e)) {
13864
+ e = e.substring(a.raw.length), t.push(a);
13865
+ continue;
13866
+ }
13867
+ if (a = this.tokenizer.del(e, n, o)) {
13868
+ e = e.substring(a.raw.length), t.push(a);
13869
+ continue;
13870
+ }
13871
+ if (a = this.tokenizer.autolink(e)) {
13872
+ e = e.substring(a.raw.length), t.push(a);
13873
+ continue;
13874
+ }
13875
+ if (!this.state.inLink && (a = this.tokenizer.url(e))) {
13876
+ e = e.substring(a.raw.length), t.push(a);
13877
+ continue;
13878
+ }
13879
+ let c = e;
13880
+ if (this.options.extensions?.startInline) {
13881
+ let p = 1 / 0, k = e.slice(1), h;
13882
+ this.options.extensions.startInline.forEach(R => { h = R.call({ lexer: this }, k), typeof h == "number" && h >= 0 && (p = Math.min(p, h)); }), p < 1 / 0 && p >= 0 && (c = e.substring(0, p + 1));
13883
+ }
13884
+ if (a = this.tokenizer.inlineText(c)) {
13885
+ e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = true;
13886
+ let p = t.at(-1);
13887
+ p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
13888
+ continue;
13889
+ }
13890
+ if (e) {
13891
+ this.infiniteLoopError(e.charCodeAt(0));
13892
+ break;
13893
+ }
13894
+ } return t; }
13895
+ infiniteLoopError(e) { let t = "Infinite loop on byte: " + e; if (this.options.silent)
13896
+ console.error(t);
13897
+ else
13898
+ throw new Error(t); }
13899
+ };
13900
+ var y = class {
13901
+ options;
13902
+ parser;
13903
+ constructor(e) { this.options = e || T; }
13904
+ space(e) { return ""; }
13905
+ code({ text: e, lang: t, escaped: n }) {
13906
+ let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
13907
+ `;
13908
+ return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
13909
+ ` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
13910
+ `;
13911
+ }
13912
+ blockquote({ tokens: e }) {
13913
+ return `<blockquote>
13914
+ ${this.parser.parse(e)}</blockquote>
13915
+ `;
13916
+ }
13917
+ html({ text: e }) { return e; }
13918
+ def(e) { return ""; }
13919
+ heading({ tokens: e, depth: t }) {
13920
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
13921
+ `;
13922
+ }
13923
+ hr(e) {
13924
+ return `<hr>
13925
+ `;
13926
+ }
13927
+ list(e) {
13928
+ let t = e.ordered, n = e.start, s = "";
13929
+ for (let o = 0; o < e.items.length; o++) {
13930
+ let u = e.items[o];
13931
+ s += this.listitem(u);
13932
+ }
13933
+ let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
13934
+ return "<" + r + i + `>
13935
+ ` + s + "</" + r + `>
13936
+ `;
13937
+ }
13938
+ listitem(e) {
13939
+ return `<li>${this.parser.parse(e.tokens)}</li>
13940
+ `;
13941
+ }
13942
+ checkbox({ checked: e }) { return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> '; }
13943
+ paragraph({ tokens: e }) {
13944
+ return `<p>${this.parser.parseInline(e)}</p>
13945
+ `;
13946
+ }
13947
+ table(e) {
13948
+ let t = "", n = "";
13949
+ for (let r = 0; r < e.header.length; r++)
13950
+ n += this.tablecell(e.header[r]);
13951
+ t += this.tablerow({ text: n });
13952
+ let s = "";
13953
+ for (let r = 0; r < e.rows.length; r++) {
13954
+ let i = e.rows[r];
13955
+ n = "";
13956
+ for (let o = 0; o < i.length; o++)
13957
+ n += this.tablecell(i[o]);
13958
+ s += this.tablerow({ text: n });
13959
+ }
13960
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
13961
+ <thead>
13962
+ ` + t + `</thead>
13963
+ ` + s + `</table>
13964
+ `;
13965
+ }
13966
+ tablerow({ text: e }) {
13967
+ return `<tr>
13968
+ ${e}</tr>
13969
+ `;
13970
+ }
13971
+ tablecell(e) {
13972
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
13973
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
13974
+ `;
13975
+ }
13976
+ strong({ tokens: e }) { return `<strong>${this.parser.parseInline(e)}</strong>`; }
13977
+ em({ tokens: e }) { return `<em>${this.parser.parseInline(e)}</em>`; }
13978
+ codespan({ text: e }) { return `<code>${O(e, true)}</code>`; }
13979
+ br(e) { return "<br>"; }
13980
+ del({ tokens: e }) { return `<del>${this.parser.parseInline(e)}</del>`; }
13981
+ link({ href: e, title: t, tokens: n }) { let s = this.parser.parseInline(n), r = V(e); if (r === null)
13982
+ return s; e = r; let i = '<a href="' + e + '"'; return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i; }
13983
+ image({ href: e, title: t, text: n, tokens: s }) { s && (n = this.parser.parseInline(s, this.parser.textRenderer)); let r = V(e); if (r === null)
13984
+ return O(n); e = r; let i = `<img src="${e}" alt="${O(n)}"`; return t && (i += ` title="${O(t)}"`), i += ">", i; }
13985
+ text(e) { return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text); }
13986
+ };
13987
+ var L = class {
13988
+ strong({ text: e }) { return e; }
13989
+ em({ text: e }) { return e; }
13990
+ codespan({ text: e }) { return e; }
13991
+ del({ text: e }) { return e; }
13992
+ html({ text: e }) { return e; }
13993
+ text({ text: e }) { return e; }
13994
+ link({ text: e }) { return "" + e; }
13995
+ image({ text: e }) { return "" + e; }
13996
+ br() { return ""; }
13997
+ checkbox({ raw: e }) { return e; }
13998
+ };
13999
+ var b = class l {
14000
+ options;
14001
+ renderer;
14002
+ textRenderer;
14003
+ constructor(e) { this.options = e || T, this.options.renderer = this.options.renderer || new y, this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L; }
14004
+ static parse(e, t) { return new l(t).parse(e); }
14005
+ static parseInline(e, t) { return new l(t).parseInline(e); }
14006
+ parse(e) { this.renderer.parser = this; let t = ""; for (let n = 0; n < e.length; n++) {
14007
+ let s = e[n];
14008
+ if (this.options.extensions?.renderers?.[s.type]) {
14009
+ let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
14010
+ if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
14011
+ t += o || "";
14012
+ continue;
14013
+ }
14014
+ }
14015
+ let r = s;
14016
+ switch (r.type) {
14017
+ case "space": {
14018
+ t += this.renderer.space(r);
14019
+ break;
14020
+ }
14021
+ case "hr": {
14022
+ t += this.renderer.hr(r);
14023
+ break;
14024
+ }
14025
+ case "heading": {
14026
+ t += this.renderer.heading(r);
14027
+ break;
14028
+ }
14029
+ case "code": {
14030
+ t += this.renderer.code(r);
14031
+ break;
14032
+ }
14033
+ case "table": {
14034
+ t += this.renderer.table(r);
14035
+ break;
14036
+ }
14037
+ case "blockquote": {
14038
+ t += this.renderer.blockquote(r);
14039
+ break;
14040
+ }
14041
+ case "list": {
14042
+ t += this.renderer.list(r);
14043
+ break;
14044
+ }
14045
+ case "checkbox": {
14046
+ t += this.renderer.checkbox(r);
14047
+ break;
14048
+ }
14049
+ case "html": {
14050
+ t += this.renderer.html(r);
14051
+ break;
14052
+ }
14053
+ case "def": {
14054
+ t += this.renderer.def(r);
14055
+ break;
14056
+ }
14057
+ case "paragraph": {
14058
+ t += this.renderer.paragraph(r);
14059
+ break;
14060
+ }
14061
+ case "text": {
14062
+ t += this.renderer.text(r);
14063
+ break;
14064
+ }
14065
+ default: {
14066
+ let i = 'Token with "' + r.type + '" type was not found.';
14067
+ if (this.options.silent)
14068
+ return console.error(i), "";
14069
+ throw new Error(i);
14070
+ }
14071
+ }
14072
+ } return t; }
14073
+ parseInline(e, t = this.renderer) { this.renderer.parser = this; let n = ""; for (let s = 0; s < e.length; s++) {
14074
+ let r = e[s];
14075
+ if (this.options.extensions?.renderers?.[r.type]) {
14076
+ let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
14077
+ if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
14078
+ n += o || "";
14079
+ continue;
14080
+ }
14081
+ }
14082
+ let i = r;
14083
+ switch (i.type) {
14084
+ case "escape": {
14085
+ n += t.text(i);
14086
+ break;
14087
+ }
14088
+ case "html": {
14089
+ n += t.html(i);
14090
+ break;
14091
+ }
14092
+ case "link": {
14093
+ n += t.link(i);
14094
+ break;
14095
+ }
14096
+ case "image": {
14097
+ n += t.image(i);
14098
+ break;
14099
+ }
14100
+ case "checkbox": {
14101
+ n += t.checkbox(i);
14102
+ break;
14103
+ }
14104
+ case "strong": {
14105
+ n += t.strong(i);
14106
+ break;
14107
+ }
14108
+ case "em": {
14109
+ n += t.em(i);
14110
+ break;
14111
+ }
14112
+ case "codespan": {
14113
+ n += t.codespan(i);
14114
+ break;
14115
+ }
14116
+ case "br": {
14117
+ n += t.br(i);
14118
+ break;
14119
+ }
14120
+ case "del": {
14121
+ n += t.del(i);
14122
+ break;
14123
+ }
14124
+ case "text": {
14125
+ n += t.text(i);
14126
+ break;
14127
+ }
14128
+ default: {
14129
+ let o = 'Token with "' + i.type + '" type was not found.';
14130
+ if (this.options.silent)
14131
+ return console.error(o), "";
14132
+ throw new Error(o);
14133
+ }
14134
+ }
14135
+ } return n; }
14136
+ };
14137
+ var P = class {
14138
+ options;
14139
+ block;
14140
+ constructor(e) { this.options = e || T; }
14141
+ static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
14142
+ static passThroughHooksRespectAsync = new Set(["preprocess", "postprocess", "processAllTokens"]);
14143
+ preprocess(e) { return e; }
14144
+ postprocess(e) { return e; }
14145
+ processAllTokens(e) { return e; }
14146
+ emStrongMask(e) { return e; }
14147
+ provideLexer(e = this.block) { return e ? x.lex : x.lexInline; }
14148
+ provideParser(e = this.block) { return e ? b.parse : b.parseInline; }
14149
+ };
14150
+ var q = class {
14151
+ defaults = M();
14152
+ options = this.setOptions;
14153
+ parse = this.parseMarkdown(true);
14154
+ parseInline = this.parseMarkdown(false);
14155
+ Parser = b;
14156
+ Renderer = y;
14157
+ TextRenderer = L;
14158
+ Lexer = x;
14159
+ Tokenizer = w;
14160
+ Hooks = P;
14161
+ constructor(...e) { this.use(...e); }
14162
+ walkTokens(e, t) { let n = []; for (let s of e)
14163
+ switch (n = n.concat(t.call(this, s)), s.type) {
14164
+ case "table": {
14165
+ let r = s;
14166
+ for (let i of r.header)
14167
+ n = n.concat(this.walkTokens(i.tokens, t));
14168
+ for (let i of r.rows)
14169
+ for (let o of i)
14170
+ n = n.concat(this.walkTokens(o.tokens, t));
14171
+ break;
14172
+ }
14173
+ case "list": {
14174
+ let r = s;
14175
+ n = n.concat(this.walkTokens(r.items, t));
14176
+ break;
14177
+ }
14178
+ default: {
14179
+ let r = s;
14180
+ this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach(i => { let o = r[i].flat(1 / 0); n = n.concat(this.walkTokens(o, t)); }) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
14181
+ }
14182
+ } return n; }
14183
+ use(...e) { let t = this.defaults.extensions || { renderers: {}, childTokens: {} }; return e.forEach(n => { let s = { ...n }; if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach(r => { if (!r.name)
14184
+ throw new Error("extension name required"); if ("renderer" in r) {
14185
+ let i = t.renderers[r.name];
14186
+ i ? t.renderers[r.name] = function (...o) { let u = r.renderer.apply(this, o); return u === false && (u = i.apply(this, o)), u; } : t.renderers[r.name] = r.renderer;
14187
+ } if ("tokenizer" in r) {
14188
+ if (!r.level || r.level !== "block" && r.level !== "inline")
14189
+ throw new Error("extension level must be 'block' or 'inline'");
14190
+ let i = t[r.level];
14191
+ i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
14192
+ } "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens); }), s.extensions = t), n.renderer) {
14193
+ let r = this.defaults.renderer || new y(this.defaults);
14194
+ for (let i in n.renderer) {
14195
+ if (!(i in r))
14196
+ throw new Error(`renderer '${i}' does not exist`);
14197
+ if (["options", "parser"].includes(i))
14198
+ continue;
14199
+ let o = i, u = n.renderer[o], a = r[o];
14200
+ r[o] = (...c) => { let p = u.apply(r, c); return p === false && (p = a.apply(r, c)), p || ""; };
14201
+ }
14202
+ s.renderer = r;
14203
+ } if (n.tokenizer) {
14204
+ let r = this.defaults.tokenizer || new w(this.defaults);
14205
+ for (let i in n.tokenizer) {
14206
+ if (!(i in r))
14207
+ throw new Error(`tokenizer '${i}' does not exist`);
14208
+ if (["options", "rules", "lexer"].includes(i))
14209
+ continue;
14210
+ let o = i, u = n.tokenizer[o], a = r[o];
14211
+ r[o] = (...c) => { let p = u.apply(r, c); return p === false && (p = a.apply(r, c)), p; };
14212
+ }
14213
+ s.tokenizer = r;
14214
+ } if (n.hooks) {
14215
+ let r = this.defaults.hooks || new P;
14216
+ for (let i in n.hooks) {
14217
+ if (!(i in r))
14218
+ throw new Error(`hook '${i}' does not exist`);
14219
+ if (["options", "block"].includes(i))
14220
+ continue;
14221
+ let o = i, u = n.hooks[o], a = r[o];
14222
+ P.passThroughHooks.has(i) ? r[o] = c => { if (this.defaults.async && P.passThroughHooksRespectAsync.has(i))
14223
+ return (async () => { let k = await u.call(r, c); return a.call(r, k); })(); let p = u.call(r, c); return a.call(r, p); } : r[o] = (...c) => { if (this.defaults.async)
14224
+ return (async () => { let k = await u.apply(r, c); return k === false && (k = await a.apply(r, c)), k; })(); let p = u.apply(r, c); return p === false && (p = a.apply(r, c)), p; };
14225
+ }
14226
+ s.hooks = r;
14227
+ } if (n.walkTokens) {
14228
+ let r = this.defaults.walkTokens, i = n.walkTokens;
14229
+ s.walkTokens = function (o) { let u = []; return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u; };
14230
+ } this.defaults = { ...this.defaults, ...s }; }), this; }
14231
+ setOptions(e) { return this.defaults = { ...this.defaults, ...e }, this; }
14232
+ lexer(e, t) { return x.lex(e, t ?? this.defaults); }
14233
+ parser(e, t) { return b.parse(e, t ?? this.defaults); }
14234
+ parseMarkdown(e) { return (n, s) => { let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async); if (this.defaults.async === true && r.async === false)
14235
+ return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.")); if (typeof n > "u" || n === null)
14236
+ return o(new Error("marked(): input parameter is undefined or null")); if (typeof n != "string")
14237
+ return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected")); if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async)
14238
+ return (async () => { let u = i.hooks ? await i.hooks.preprocess(n) : n, c = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), p = i.hooks ? await i.hooks.processAllTokens(c) : c; i.walkTokens && await Promise.all(this.walkTokens(p, i.walkTokens)); let h = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p, i); return i.hooks ? await i.hooks.postprocess(h) : h; })().catch(o); try {
14239
+ i.hooks && (n = i.hooks.preprocess(n));
14240
+ let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
14241
+ i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
14242
+ let p = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
14243
+ return i.hooks && (p = i.hooks.postprocess(p)), p;
14244
+ }
14245
+ catch (u) {
14246
+ return o(u);
14247
+ } }; }
14248
+ onError(e, t) {
14249
+ return n => {
14250
+ if (n.message += `
14251
+ Please report this to https://github.com/markedjs/marked.`, e) {
14252
+ let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
14253
+ return t ? Promise.resolve(s) : s;
14254
+ }
14255
+ if (t)
14256
+ return Promise.reject(n);
14257
+ throw n;
14258
+ };
14259
+ }
14260
+ };
14261
+ var z = new q;
14262
+ function g(l, e) { return z.parse(l, e); }
14263
+ g.options = g.setOptions = function (l) { return z.setOptions(l), g.defaults = z.defaults, N(g.defaults), g; };
14264
+ g.getDefaults = M;
14265
+ g.defaults = T;
14266
+ g.use = function (...l) { return z.use(...l), g.defaults = z.defaults, N(g.defaults), g; };
14267
+ g.walkTokens = function (l, e) { return z.walkTokens(l, e); };
14268
+ g.parseInline = z.parseInline;
14269
+ g.Parser = b;
14270
+ g.parser = b.parse;
14271
+ g.Renderer = y;
14272
+ g.TextRenderer = L;
14273
+ g.Lexer = x;
14274
+ g.lexer = x.lex;
14275
+ g.Tokenizer = w;
14276
+ g.Hooks = P;
14277
+ g.parse = g;
14278
+ g.options; g.setOptions; g.use; g.walkTokens; g.parseInline; b.parse; x.lex;
14279
+
13295
14280
  // Copyright 2014 The Chromium Authors
13296
14281
  class AcornTokenizer {
13297
14282
  #textCursor;
@@ -14084,7 +15069,25 @@ class HTMLFormatter {
14084
15069
  this.#builder.decreaseNestingLevel();
14085
15070
  this.#builder.addNewLine();
14086
15071
  }
14087
- #afterCloseTag(_element) {
15072
+ #afterCloseTag(element) {
15073
+ if (!this.#model) {
15074
+ return;
15075
+ }
15076
+ if (!element.children.length && element !== this.#model.document()) {
15077
+ const nextToken = this.#model.peekToken();
15078
+ if (nextToken) {
15079
+ if (isTextToken(nextToken)) {
15080
+ return;
15081
+ }
15082
+ const followingToken = this.#model.peekToken(1);
15083
+ if (isWhitespace(nextToken.value) && !/[\r\n]/.test(nextToken.value) &&
15084
+ followingToken && isTextToken(followingToken)) {
15085
+ this.#model.nextToken();
15086
+ this.#builder.addToken(nextToken.value, nextToken.startOffset);
15087
+ return;
15088
+ }
15089
+ }
15090
+ }
14088
15091
  this.#builder.addNewLine();
14089
15092
  }
14090
15093
  #formatToken(element, token) {
@@ -14202,6 +15205,11 @@ function scriptTagIsJSON(element) {
14202
15205
  function hasTokenInSet(tokenTypes, type) {
14203
15206
  return tokenTypes.has(type) || tokenTypes.has(`xml-${type}`);
14204
15207
  }
15208
+ function isTextToken(token) {
15209
+ return !isWhitespace(token.value) && !hasTokenInSet(token.type, 'tag') &&
15210
+ !hasTokenInSet(token.type, 'attribute') && !hasTokenInSet(token.type, 'bracket') &&
15211
+ !hasTokenInSet(token.type, 'comment') && !hasTokenInSet(token.type, 'meta');
15212
+ }
14205
15213
  class HTMLModel {
14206
15214
  #state = "Initial" ;
14207
15215
  #document;
@@ -14232,9 +15240,7 @@ class HTMLModel {
14232
15240
  if (element && (hasTokenInSet(token.type, 'comment') || hasTokenInSet(token.type, 'meta'))) {
14233
15241
  element.hasComments = true;
14234
15242
  }
14235
- if (element && !isWhitespace(token.value) && !hasTokenInSet(token.type, 'tag') &&
14236
- !hasTokenInSet(token.type, 'attribute') && !hasTokenInSet(token.type, 'bracket') &&
14237
- !hasTokenInSet(token.type, 'comment') && !hasTokenInSet(token.type, 'meta')) {
15243
+ if (element && isTextToken(token)) {
14238
15244
  element.hasContent = true;
14239
15245
  }
14240
15246
  if (element && (element.name === 'script' || element.name === 'style') &&
@@ -14416,8 +15422,8 @@ class HTMLModel {
14416
15422
  newElement.openTag = openTag;
14417
15423
  this.#stack.push(newElement);
14418
15424
  }
14419
- peekToken() {
14420
- return this.#tokenIndex < this.#tokens.length ? this.#tokens[this.#tokenIndex] : null;
15425
+ peekToken(offset = 0) {
15426
+ return this.#tokenIndex + offset < this.#tokens.length ? this.#tokens[this.#tokenIndex + offset] : null;
14421
15427
  }
14422
15428
  nextToken() {
14423
15429
  return this.#tokens[this.#tokenIndex++];
@@ -14528,7 +15534,13 @@ class IdentityFormatter {
14528
15534
  function parseScopes(expression, sourceType = 'script') {
14529
15535
  let root = null;
14530
15536
  try {
14531
- root = parse$1(expression, { ecmaVersion: ECMA_VERSION, allowAwaitOutsideFunction: true, ranges: false, sourceType });
15537
+ root = parse$1(expression, {
15538
+ ecmaVersion: ECMA_VERSION,
15539
+ allowAwaitOutsideFunction: true,
15540
+ checkPrivateFields: false,
15541
+ ranges: false,
15542
+ sourceType,
15543
+ });
14532
15544
  }
14533
15545
  catch {
14534
15546
  return null;
@@ -15042,11 +16054,37 @@ function indexOfCharInBounds(str, needle, start, end) {
15042
16054
  }
15043
16055
 
15044
16056
  // Copyright 2022 The Chromium Authors
15045
- function substituteExpression(expression, nameMap) {
15046
- const replacements = computeSubstitution(expression, nameMap);
16057
+ function substituteExpression(expression, scopes) {
16058
+ const replacements = computeSubstitution(expression, scopes);
15047
16059
  return applySubstitution(expression, replacements);
15048
16060
  }
15049
- function computeSubstitution(expression, nameMap) {
16061
+ function parseBindingExpression(expression) {
16062
+ const options = {
16063
+ ecmaVersion: ECMA_VERSION,
16064
+ allowAwaitOutsideFunction: true,
16065
+ allowImportExportEverywhere: true,
16066
+ checkPrivateFields: false,
16067
+ ranges: false,
16068
+ };
16069
+ const root = parse$1(`(${expression})`, options);
16070
+ const exprAt = Parser$1.parseExpressionAt(expression, 0, options);
16071
+ if (root.body.length !== 1 || root.body[0].type !== 'ExpressionStatement') {
16072
+ throw new SyntaxError(`Invalid binding expression '${expression}'`);
16073
+ }
16074
+ const expr = root.body[0].expression;
16075
+ if (exprAt.start !== expr.start - 1 || exprAt.end !== expr.end - 1) {
16076
+ throw new SyntaxError(`Invalid binding expression '${expression}'`);
16077
+ }
16078
+ const analysis = new ScopeVariableAnalysis(root, `(${expression})`);
16079
+ analysis.run();
16080
+ const needsParens = expr.type !== 'Identifier' && expr.type !== 'MemberExpression' && expr.type !== 'ThisExpression';
16081
+ return {
16082
+ replacement: needsParens ? `(${expression})` : expression,
16083
+ freeVariables: [...analysis.getFreeVariables().keys()],
16084
+ allNames: analysis.getAllNames(),
16085
+ };
16086
+ }
16087
+ function computeSubstitution(expression, scopes) {
15050
16088
  const root = parse$1(expression, {
15051
16089
  ecmaVersion: ECMA_VERSION,
15052
16090
  allowAwaitOutsideFunction: true,
@@ -15059,10 +16097,34 @@ function computeSubstitution(expression, nameMap) {
15059
16097
  const freeVariables = scopeVariables.getFreeVariables();
15060
16098
  const result = [];
15061
16099
  const allNames = scopeVariables.getAllNames();
15062
- for (const rename of nameMap.values()) {
15063
- if (rename) {
15064
- allNames.add(rename);
16100
+ const nameMap = new Map();
16101
+ const parsedBindings = new Map();
16102
+ const shadowedNames = new Set();
16103
+ for (const { bindings, generatedNames } of scopes) {
16104
+ const scopeNames = new Set(generatedNames);
16105
+ for (const [name, rename] of bindings.entries()) {
16106
+ let parsed;
16107
+ if (rename !== null) {
16108
+ try {
16109
+ parsed = parseBindingExpression(rename);
16110
+ parsed.allNames.forEach(id => allNames.add(id));
16111
+ parsed.freeVariables.forEach(id => scopeNames.add(id));
16112
+ }
16113
+ catch (error) {
16114
+ if (!nameMap.has(name) && freeVariables.has(name)) {
16115
+ throw error;
16116
+ }
16117
+ }
16118
+ }
16119
+ if (!nameMap.has(name)) {
16120
+ const isShadowed = parsed?.freeVariables.some(id => shadowedNames.has(id));
16121
+ nameMap.set(name, isShadowed ? null : rename);
16122
+ if (parsed && !isShadowed) {
16123
+ parsedBindings.set(name, parsed);
16124
+ }
16125
+ }
15065
16126
  }
16127
+ scopeNames.forEach(id => shadowedNames.add(id));
15066
16128
  }
15067
16129
  function getNewName(base) {
15068
16130
  let i = 1;
@@ -15073,6 +16135,7 @@ function computeSubstitution(expression, nameMap) {
15073
16135
  allNames.add(newName);
15074
16136
  return newName;
15075
16137
  }
16138
+ const capturedBinders = new Map();
15076
16139
  for (const [name, rename] of nameMap.entries()) {
15077
16140
  const defUse = freeVariables.get(name);
15078
16141
  if (!defUse) {
@@ -15081,31 +16144,39 @@ function computeSubstitution(expression, nameMap) {
15081
16144
  if (rename === null) {
15082
16145
  throw new Error(`Cannot substitute '${name}' as the underlying variable '${rename}' is unavailable`);
15083
16146
  }
15084
- const binders = [];
16147
+ const parsed = parsedBindings.get(name);
16148
+ if (!parsed) {
16149
+ continue;
16150
+ }
16151
+ const freeIds = [...parsed.freeVariables];
15085
16152
  for (const use of defUse) {
15086
16153
  result.push({
15087
16154
  from: name,
15088
- to: rename,
16155
+ to: parsed.replacement,
15089
16156
  offset: use.offset,
15090
16157
  isShorthandAssignmentProperty: use.isShorthandAssignmentProperty,
15091
16158
  });
15092
- binders.push(...use.scope.findBinders(rename));
15093
- }
15094
- for (const binder of binders) {
15095
- if (binder.definitionKind === 3 ) {
15096
- throw new Error(`Cannot avoid capture of '${rename}'`);
15097
- }
15098
- const newName = getNewName(rename);
15099
- for (const use of binder.uses) {
15100
- result.push({
15101
- from: rename,
15102
- to: newName,
15103
- offset: use.offset,
15104
- isShorthandAssignmentProperty: use.isShorthandAssignmentProperty,
15105
- });
16159
+ for (const freeId of freeIds) {
16160
+ for (const binder of use.scope.findBinders(freeId)) {
16161
+ capturedBinders.set(binder, freeId);
16162
+ }
15106
16163
  }
15107
16164
  }
15108
16165
  }
16166
+ for (const [binder, freeId] of capturedBinders.entries()) {
16167
+ if (binder.definitionKind === 3 ) {
16168
+ throw new Error(`Cannot avoid capture of '${freeId}'`);
16169
+ }
16170
+ const newName = getNewName(freeId);
16171
+ for (const use of binder.uses) {
16172
+ result.push({
16173
+ from: freeId,
16174
+ to: newName,
16175
+ offset: use.offset,
16176
+ isShorthandAssignmentProperty: use.isShorthandAssignmentProperty,
16177
+ });
16178
+ }
16179
+ }
15109
16180
  result.sort((l, r) => l.offset - r.offset);
15110
16181
  return result;
15111
16182
  }
@@ -15208,6 +16279,7 @@ const cssTrimEnd = (tokenValue) => {
15208
16279
  };
15209
16280
  class CSSFormatter {
15210
16281
  #builder;
16282
+ #text;
15211
16283
  #toOffset;
15212
16284
  #fromOffset;
15213
16285
  #lineEndings;
@@ -15218,6 +16290,7 @@ class CSSFormatter {
15218
16290
  this.#builder = builder;
15219
16291
  }
15220
16292
  format(text, lineEndings, fromOffset, toOffset) {
16293
+ this.#text = text;
15221
16294
  this.#lineEndings = lineEndings;
15222
16295
  this.#fromOffset = fromOffset;
15223
16296
  this.#toOffset = toOffset;
@@ -15229,6 +16302,50 @@ class CSSFormatter {
15229
16302
  tokenize(text.substring(this.#fromOffset, this.#toOffset), this.#tokenCallback.bind(this));
15230
16303
  this.#builder.setEnforceSpaceBetweenWords(oldEnforce);
15231
16304
  }
16305
+ #isSelectorPseudoColon(colonOffset) {
16306
+ let parenDepth = 0;
16307
+ for (let i = colonOffset + 1; i < this.#toOffset; ++i) {
16308
+ const ch = this.#text[i];
16309
+ if (ch === '/' && this.#text[i + 1] === '*') {
16310
+ const commentEnd = this.#text.indexOf('*/', i + 2);
16311
+ if (commentEnd === -1) {
16312
+ break;
16313
+ }
16314
+ i = commentEnd + 1;
16315
+ continue;
16316
+ }
16317
+ if (ch === '\'' || ch === '"') {
16318
+ const quote = ch;
16319
+ for (++i; i < this.#toOffset; ++i) {
16320
+ if (this.#text[i] === '\\') {
16321
+ ++i;
16322
+ }
16323
+ else if (this.#text[i] === quote) {
16324
+ break;
16325
+ }
16326
+ }
16327
+ continue;
16328
+ }
16329
+ if (ch === '(') {
16330
+ ++parenDepth;
16331
+ }
16332
+ else if (ch === ')') {
16333
+ if (parenDepth === 0) {
16334
+ return false;
16335
+ }
16336
+ --parenDepth;
16337
+ }
16338
+ else if (parenDepth === 0) {
16339
+ if (ch === '{') {
16340
+ return true;
16341
+ }
16342
+ if (ch === ';' || ch === '}') {
16343
+ return false;
16344
+ }
16345
+ }
16346
+ }
16347
+ return false;
16348
+ }
15232
16349
  #tokenCallback(token, type, startPosition) {
15233
16350
  startPosition += this.#fromOffset;
15234
16351
  while (this.#currentLineIndex < this.#lineEndings.length &&
@@ -15267,16 +16384,23 @@ class CSSFormatter {
15267
16384
  this.#builder.decreaseNestingLevel();
15268
16385
  this.#state.afterClosingBrace = true;
15269
16386
  this.#state.inPropertyValue = false;
16387
+ this.#state.seenProperty = false;
15270
16388
  }
15271
16389
  else if (token === ':' && !this.#state.inPropertyValue && this.#state.seenProperty) {
15272
- this.#builder.addToken(token, startPosition);
15273
- this.#builder.addSoftSpace();
15274
- this.#state.eatWhitespace = true;
15275
- this.#state.inPropertyValue = true;
15276
- this.#state.seenProperty = false;
15277
- return;
16390
+ if (this.#isSelectorPseudoColon(startPosition)) {
16391
+ this.#state.seenProperty = false;
16392
+ }
16393
+ else {
16394
+ this.#builder.addToken(token, startPosition);
16395
+ this.#builder.addSoftSpace();
16396
+ this.#state.eatWhitespace = true;
16397
+ this.#state.inPropertyValue = true;
16398
+ this.#state.seenProperty = false;
16399
+ return;
16400
+ }
15278
16401
  }
15279
16402
  else if (token === '{') {
16403
+ this.#state.seenProperty = false;
15280
16404
  this.#builder.addSoftSpace();
15281
16405
  this.#builder.addToken(token, startPosition);
15282
16406
  this.#builder.addNewLine();
@@ -15480,7 +16604,14 @@ HOST_RUNTIME.workerScope.onmessage = function (event) {
15480
16604
  parseCSS(params.content, self.postMessage);
15481
16605
  break;
15482
16606
  case "javaScriptSubstitute" : {
15483
- HOST_RUNTIME.workerScope.postMessage(substituteExpression(params.content, params.mapping));
16607
+ let result;
16608
+ try {
16609
+ result = substituteExpression(params.content, params.mapping);
16610
+ }
16611
+ catch (error) {
16612
+ result = { error: error instanceof Error ? error.message : String(error) };
16613
+ }
16614
+ HOST_RUNTIME.workerScope.postMessage(result);
15484
16615
  break;
15485
16616
  }
15486
16617
  case "javaScriptScopeTree" : {