@macintacos/caret 1.7.0 → 1.8.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 (113) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +10 -7
  3. package/dist/cli.js +849 -655
  4. package/opencode/caret.core.ts +14 -6
  5. package/opencode/caret.plugin.v2.ts +41 -15
  6. package/opencode/caret.tui.ts +290 -17
  7. package/opencode/opentui-solid.d.ts +8 -0
  8. package/opencode/permission.ts +3 -44
  9. package/opencode/review-bridge.ts +19 -4
  10. package/package.json +2 -2
  11. package/ui/dist/assets/{angular-html-DbhcQrGG.js → angular-html-BXFKQGXA.js} +1 -1
  12. package/ui/dist/assets/{angular-ts-Cum7bwhS.js → angular-ts-BteBaZbv.js} +1 -1
  13. package/ui/dist/assets/{apl-C7ktlLa5.js → apl-Boa3o4y5.js} +1 -1
  14. package/ui/dist/assets/{astro-VpFubXJn.js → astro-BeBp_x10.js} +1 -1
  15. package/ui/dist/assets/{blade-_p0dlQ-o.js → blade-BsWYzT9U.js} +1 -1
  16. package/ui/dist/assets/{c-BRhF-xdb.js → c-CiG9bK25.js} +1 -1
  17. package/ui/dist/assets/{chapel-BgKEyCON.js → chapel-7fNKKqpl.js} +1 -1
  18. package/ui/dist/assets/{cobol-r_HdzaUV.js → cobol-B1HBnyA6.js} +1 -1
  19. package/ui/dist/assets/{coffee-BnTujJ8N.js → coffee-BR4Q34UF.js} +1 -1
  20. package/ui/dist/assets/{cpp-BlwBQZ9R.js → cpp-C3wngvr5.js} +1 -1
  21. package/ui/dist/assets/{crystal-Dfws0EvT.js → crystal-DiIiTPBe.js} +1 -1
  22. package/ui/dist/assets/{css-BxzS_9W2.js → css-BX3gLifs.js} +1 -1
  23. package/ui/dist/assets/{dist-CCaNNKok.js → dist-50vAtYCv.js} +1 -1
  24. package/ui/dist/assets/{dist-CWEzdJiQ.js → dist-BoVp9dqK.js} +1 -1
  25. package/ui/dist/assets/{dist-CrA0chnO.js → dist-BqrHiigI.js} +1 -1
  26. package/ui/dist/assets/{dist-BurvsmJN.js → dist-C79XSdY8.js} +1 -1
  27. package/ui/dist/assets/{dist-BW8E7IFp.js → dist-CMPsnKBn.js} +2 -2
  28. package/ui/dist/assets/{dist-BtudxTi6.js → dist-CP875olq.js} +1 -1
  29. package/ui/dist/assets/{dist-Ccfk4NCv.js → dist-D7HvdIC5.js} +1 -1
  30. package/ui/dist/assets/{dist-C5H8xzaz.js → dist-DXddG2tW.js} +1 -1
  31. package/ui/dist/assets/{dist-kZ0GiOwO.js → dist-DaLa-fRf.js} +1 -1
  32. package/ui/dist/assets/{dist-C0kJT6Lc.js → dist-H9wPekMH.js} +1 -1
  33. package/ui/dist/assets/{dist-BzruqOsf.js → dist-NwnWQZNa.js} +1 -1
  34. package/ui/dist/assets/{dist-rTQz7rmj.js → dist-SYZxBIS_.js} +1 -1
  35. package/ui/dist/assets/{dist-COFU7QsL.js → dist-anXz8tLl.js} +1 -1
  36. package/ui/dist/assets/{dist-BBCKJuIA.js → dist-jDKYW61p.js} +1 -1
  37. package/ui/dist/assets/{dist-ldnZ9m94.js → dist-p9qfYPbt.js} +1 -1
  38. package/ui/dist/assets/{dist-BBGx42PS.js → dist-r7n7YX8s.js} +1 -1
  39. package/ui/dist/assets/{dist--iE_Uraw.js → dist-sf8u9yOd.js} +1 -1
  40. package/ui/dist/assets/{dist-DSyCej7W.js → dist-yYI7sEVm.js} +1 -1
  41. package/ui/dist/assets/{edge-kMKV375d.js → edge-D6eM3HKg.js} +1 -1
  42. package/ui/dist/assets/{elixir-jC73nVO2.js → elixir-BiXwbjRd.js} +1 -1
  43. package/ui/dist/assets/{elm-BkX-ZQK-.js → elm-uPrh5C1H.js} +1 -1
  44. package/ui/dist/assets/{erb-CsTgzHh3.js → erb-C01CNhsq.js} +1 -1
  45. package/ui/dist/assets/{git-rebase-C3e9EoS5.js → git-rebase-BctEis_g.js} +1 -1
  46. package/ui/dist/assets/{glimmer-js-DvtSC46Q.js → glimmer-js-gguWPKCT.js} +1 -1
  47. package/ui/dist/assets/{glimmer-ts-CsMz3ept.js → glimmer-ts-ByonKsDM.js} +1 -1
  48. package/ui/dist/assets/{glsl-BSqxLuLL.js → glsl-Buh4zHgg.js} +1 -1
  49. package/ui/dist/assets/{graphql-DFOyfgu2.js → graphql-DtmB7miI.js} +1 -1
  50. package/ui/dist/assets/{hack-IDWwqJuy.js → hack-qTVQw4Zz.js} +1 -1
  51. package/ui/dist/assets/{haml-DhDWyr66.js → haml-Bt2RhQj7.js} +1 -1
  52. package/ui/dist/assets/{handlebars-n6yGx2-r.js → handlebars-QJ7q0AEL.js} +1 -1
  53. package/ui/dist/assets/{html-DnapKdPk.js → html-Db-D3rXr.js} +1 -1
  54. package/ui/dist/assets/{html-derivative-D5IfM48b.js → html-derivative-DX0FUICr.js} +1 -1
  55. package/ui/dist/assets/{http-BDPi0Fzu.js → http-CF8QPtf7.js} +1 -1
  56. package/ui/dist/assets/hurl-GyiNlLSJ.js +1 -0
  57. package/ui/dist/assets/index-CfQ31NDJ.js +4303 -0
  58. package/ui/dist/assets/index-P_fbn8LU.css +1 -0
  59. package/ui/dist/assets/{java-Crffk4_D.js → java-7GW5fJMj.js} +1 -1
  60. package/ui/dist/assets/{javascript-k6mYfToP.js → javascript-DLle3-Wd.js} +1 -1
  61. package/ui/dist/assets/{jinja-DBbl2lbx.js → jinja-DyZ1srCs.js} +1 -1
  62. package/ui/dist/assets/{jison-CLttg-R0.js → jison-B5gggSJ6.js} +1 -1
  63. package/ui/dist/assets/{json-B-h9fM-h.js → json-CQEsMxfE.js} +1 -1
  64. package/ui/dist/assets/{jsx-Doicuuz6.js → jsx-BP9hEOr_.js} +1 -1
  65. package/ui/dist/assets/julia-CIVTqrrA.js +1 -0
  66. package/ui/dist/assets/{just-CEA3yRxr.js → just-D4NdkezD.js} +1 -1
  67. package/ui/dist/assets/{latex-BbhHfcvt.js → latex-CFviGdV1.js} +1 -1
  68. package/ui/dist/assets/{liquid-C44fO2N7.js → liquid-Dtx11Zuh.js} +1 -1
  69. package/ui/dist/assets/{lua-QlnLKi7-.js → lua-kGMOY_yZ.js} +1 -1
  70. package/ui/dist/assets/marko-OjkhOEN7.js +1 -0
  71. package/ui/dist/assets/{mdc-B7jyRA-3.js → mdc-wyhjzzvx.js} +1 -1
  72. package/ui/dist/assets/{nginx-C5QBw-9w.js → nginx-C6dVmlUS.js} +1 -1
  73. package/ui/dist/assets/{nim-CYyBsOc5.js → nim-BX63w2ay.js} +1 -1
  74. package/ui/dist/assets/{org-lhZNod3T.js → org-DZgxDttS.js} +1 -1
  75. package/ui/dist/assets/{perl-D3PP4FNf.js → perl-JXbylPLY.js} +1 -1
  76. package/ui/dist/assets/{php-4SpRxnxb.js → php-5EbhLfI_.js} +1 -1
  77. package/ui/dist/assets/{pug-DWnInaKi.js → pug-C6Iv2U2H.js} +1 -1
  78. package/ui/dist/assets/{qml-r0QDhCU6.js → qml-CqGs5UjC.js} +1 -1
  79. package/ui/dist/assets/{r-Cw0NLWip.js → r-BKwdj1Ob.js} +1 -1
  80. package/ui/dist/assets/{razor-C5C4Yme1.js → razor-CAmmpIRM.js} +1 -1
  81. package/ui/dist/assets/{regexp-BcY4174s.js → regexp-D-P27PhL.js} +1 -1
  82. package/ui/dist/assets/rst-BtBzILBo.js +1 -0
  83. package/ui/dist/assets/{ruby-3WaChjj1.js → ruby-BFChMOIO.js} +1 -1
  84. package/ui/dist/assets/{sas-DQZ23qju.js → sas-BHer69PY.js} +1 -1
  85. package/ui/dist/assets/{scss-B2aiLKWU.js → scss-B5xzD0OV.js} +1 -1
  86. package/ui/dist/assets/{shellscript-BC3CwnWH.js → shellscript-Dzit1Ttv.js} +1 -1
  87. package/ui/dist/assets/{shellsession-BWYoBj6b.js → shellsession-CMvz-BMu.js} +1 -1
  88. package/ui/dist/assets/{soy-COgXxeAt.js → soy-D7ynJc6J.js} +1 -1
  89. package/ui/dist/assets/{sql-C1jESGE1.js → sql-bRew6PYM.js} +1 -1
  90. package/ui/dist/assets/{stata-BhDPsrCT.js → stata-22_vRW2L.js} +1 -1
  91. package/ui/dist/assets/{surrealql-C8x1KtGL.js → surrealql-C34aKiyl.js} +1 -1
  92. package/ui/dist/assets/{svelte-CPqCsGOT.js → svelte-Dto-0MeJ.js} +1 -1
  93. package/ui/dist/assets/{templ-Cf3ROOCh.js → templ-DtacKQ1n.js} +1 -1
  94. package/ui/dist/assets/{tex-CP0vZv7G.js → tex-CS5XiOvi.js} +1 -1
  95. package/ui/dist/assets/{ts-tags-DASj8WEr.js → ts-tags-BdzU5K8A.js} +1 -1
  96. package/ui/dist/assets/{tsx-DleCywXl.js → tsx-Butg554t.js} +1 -1
  97. package/ui/dist/assets/{twig-Chlh_dlU.js → twig-CZKpRnni.js} +1 -1
  98. package/ui/dist/assets/{typescript-BmrXHOFg.js → typescript-CZA7NJZI.js} +1 -1
  99. package/ui/dist/assets/typst-DIVncoNE.js +1 -0
  100. package/ui/dist/assets/{vue-DiqBK2nm.js → vue-Bn3_aUS9.js} +1 -1
  101. package/ui/dist/assets/{vue-html-qSJAH0He.js → vue-html-B7r3yzLD.js} +1 -1
  102. package/ui/dist/assets/{vue-vine-CwCMGlwz.js → vue-vine-B3JnxtKQ.js} +1 -1
  103. package/ui/dist/assets/{xml-B5tofRe_.js → xml-DKhH88k1.js} +1 -1
  104. package/ui/dist/assets/{xsl-Cvsp-ony.js → xsl-boEEflBZ.js} +1 -1
  105. package/ui/dist/assets/{yaml-B8qT_WhX.js → yaml-B2pr6j9H.js} +1 -1
  106. package/ui/dist/index.html +3 -3
  107. package/ui/dist/assets/hurl-B3mNDy-2.js +0 -1
  108. package/ui/dist/assets/index-CBhfbXzU.js +0 -4291
  109. package/ui/dist/assets/index-DQnrXSH7.css +0 -1
  110. package/ui/dist/assets/julia-DrUq5Tw4.js +0 -1
  111. package/ui/dist/assets/marko-XfLSxn-3.js +0 -1
  112. package/ui/dist/assets/rst-nGONHPYl.js +0 -1
  113. package/ui/dist/assets/typst-W0jO6w7-.js +0 -1
package/dist/cli.js CHANGED
@@ -1557,25 +1557,42 @@ var init_codex = __esm(() => {
1557
1557
  });
1558
1558
 
1559
1559
  // src/adapters/opencode/approve.ts
1560
- var APPROVE_VARIANTS3;
1560
+ function declaredApproveVariants(ids) {
1561
+ if (!Array.isArray(ids) || !ids.includes(BUILD_VARIANT.id))
1562
+ return;
1563
+ return [...APPROVE_VARIANTS3, BUILD_VARIANT];
1564
+ }
1565
+ var APPROVE_VARIANTS3, BUILD_VARIANT;
1561
1566
  var init_approve3 = __esm(() => {
1562
1567
  APPROVE_VARIANTS3 = [
1563
1568
  { id: "default", label: "Approve", description: "Approve this plan" }
1564
1569
  ];
1570
+ BUILD_VARIANT = {
1571
+ id: "build",
1572
+ label: "Approve & build",
1573
+ description: "Approve and switch this session to the build agent"
1574
+ };
1565
1575
  });
1566
1576
 
1567
1577
  // src/adapters/opencode/feedback.ts
1568
1578
  function toWireDecision(input) {
1569
1579
  if (input.behavior === "allow") {
1570
1580
  const notes = input.feedback?.trim();
1571
- return notes ? { behavior: "allow", feedback: notes } : { behavior: "allow" };
1581
+ const buildMode = input.acceptMode === BUILD_VARIANT.id ? input.acceptMode : undefined;
1582
+ return {
1583
+ behavior: "allow",
1584
+ ...notes && { feedback: notes },
1585
+ ...buildMode && { acceptMode: buildMode }
1586
+ };
1572
1587
  }
1573
1588
  return { behavior: "deny", feedback: denyMessage(input.feedback) };
1574
1589
  }
1575
1590
  function fatalDenyLine(reason) {
1576
1591
  return JSON.stringify({ behavior: "deny", feedback: reason });
1577
1592
  }
1578
- var init_feedback3 = () => {};
1593
+ var init_feedback3 = __esm(() => {
1594
+ init_approve3();
1595
+ });
1579
1596
 
1580
1597
  // node_modules/jsonc-parser/lib/esm/impl/scanner.js
1581
1598
  function createScanner(text, ignoreTrivia = false) {
@@ -3390,12 +3407,13 @@ function hostCheck(hosts, keys, ignoredFiles) {
3390
3407
  const faults = [];
3391
3408
  const remedies = [];
3392
3409
  for (const { bin, version } of hosts) {
3393
- if (version === null || isV2Host(version))
3410
+ if (version === null)
3394
3411
  continue;
3395
3412
  const shown = version.join(".");
3396
- if (isNewer(V1_FLOOR, shown)) {
3397
- faults.push(`OpenCode ${shown} at ${bin} is older than ${V1_FLOOR}, the first that loads caret`);
3398
- remedies.push(`upgrade OpenCode to ${V1_FLOOR} or later`);
3413
+ const [floor, reason] = isV2Host(version) ? [V2_FLOOR, "the first where caret can review a plan file by `path`"] : [V1_FLOOR, "the first that loads caret"];
3414
+ if (isNewer(floor, shown)) {
3415
+ faults.push(`OpenCode ${shown} at ${bin} is older than ${floor}, ${reason}`);
3416
+ remedies.push(`upgrade OpenCode to ${floor} or later`);
3399
3417
  }
3400
3418
  }
3401
3419
  const wrongKey = keys.find((k) => k !== pluginKeyFor(sharedHost(hosts)));
@@ -3425,7 +3443,7 @@ function hostCheck(hosts, keys, ignoredFiles) {
3425
3443
  remedy: [...new Set(remedies)].join("; ")
3426
3444
  };
3427
3445
  }
3428
- var OPENCODE_VERSION_TIMEOUT_MS = 5000, V1_FLOOR = "1.3.4";
3446
+ var OPENCODE_VERSION_TIMEOUT_MS = 5000, V1_FLOOR = "1.3.4", V2_FLOOR = "2.0.29";
3429
3447
  var init_host = __esm(() => {
3430
3448
  init_paths2();
3431
3449
  });
@@ -21369,7 +21387,7 @@ var package_default;
21369
21387
  var init_package = __esm(() => {
21370
21388
  package_default = {
21371
21389
  name: "@macintacos/caret",
21372
- version: "1.7.0",
21390
+ version: "1.8.0",
21373
21391
  license: "MIT",
21374
21392
  type: "module",
21375
21393
  description: "A Claude Code plugin that replaces the terminal plan-approval prompt with a local web UI for inline review, annotation, and approval.",
@@ -21423,7 +21441,7 @@ var init_package = __esm(() => {
21423
21441
  "@laststance/tailwind-suggest-canonical-classes": "^0.1.1",
21424
21442
  "@lezer/highlight": "^1.2.3",
21425
21443
  "@modelcontextprotocol/sdk": "^1.30.0",
21426
- "@opencode/plugin": "^2.0.18",
21444
+ "@opencode/plugin": "^2.0.29",
21427
21445
  "@pierre/diffs": "1.5.2",
21428
21446
  "@pierre/trees": "1.0.0-beta.6",
21429
21447
  "@playwright/test": "^1.62.1",
@@ -21748,7 +21766,8 @@ var init_opencode = __esm(() => {
21748
21766
  sessionId: hook.session_id,
21749
21767
  cwd: hook.cwd,
21750
21768
  plan: hook.tool_input?.plan,
21751
- planFilePath: hook.tool_input?.planFilePath
21769
+ planFilePath: hook.tool_input?.planFilePath,
21770
+ approveVariants: declaredApproveVariants(hook.approve_variants)
21752
21771
  };
21753
21772
  },
21754
21773
  emitDecision(decision) {
@@ -23959,7 +23978,7 @@ var require_on_exit_leak_free = __commonJS(function(exports, module) {
23959
23978
  var require_package = __commonJS(function(exports, module) {
23960
23979
  module.exports = {
23961
23980
  name: "thread-stream",
23962
- version: "4.2.0",
23981
+ version: "4.2.1",
23963
23982
  description: "A streaming way to send data to a Node.js Worker Thread",
23964
23983
  main: "index.js",
23965
23984
  types: "index.d.ts",
@@ -23970,7 +23989,7 @@ var require_package = __commonJS(function(exports, module) {
23970
23989
  "real-require": "^1.0.0"
23971
23990
  },
23972
23991
  devDependencies: {
23973
- "@types/node": "^25.0.2",
23992
+ "@types/node": "^26.1.1",
23974
23993
  "@yao-pkg/pkg": "^6.0.0",
23975
23994
  borp: "^1.0.0",
23976
23995
  desm: "^1.3.0",
@@ -23980,16 +23999,21 @@ var require_package = __commonJS(function(exports, module) {
23980
23999
  "pino-elasticsearch": "^9.0.0",
23981
24000
  "sonic-boom": "^5.0.0",
23982
24001
  "ts-node": "^10.8.0",
24002
+ tsd: "^0.33.0",
23983
24003
  typescript: "~5.7.3"
23984
24004
  },
23985
24005
  scripts: {
23986
24006
  build: "tsc --noEmit",
23987
24007
  lint: "eslint",
23988
- test: 'npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',
23989
- "test:ci": 'npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',
23990
- "test:yarn": 'npm run transpile && borp --pattern "test/*.test.js"',
24008
+ test: 'npm run lint && npm run build && npm run test:types && npm run transpile && borp --expose-gc --pattern "test/*.test.{js,mjs}"',
24009
+ "test:ci": 'npm run lint && npm run test:types && npm run transpile && borp --expose-gc --pattern "test/*.test.{js,mjs}"',
24010
+ "test:types": "tsd",
24011
+ "test:yarn": 'npm run transpile && borp --expose-gc --pattern "test/*.test.js"',
23991
24012
  transpile: "sh ./test/ts/transpile.sh"
23992
24013
  },
24014
+ tsd: {
24015
+ directory: "test/types"
24016
+ },
23993
24017
  repository: {
23994
24018
  type: "git",
23995
24019
  url: "git+https://github.com/mcollina/thread-stream.git"
@@ -24014,12 +24038,16 @@ var require_wait = __commonJS(function(exports, module) {
24014
24038
  var WAIT_MS = 1e4;
24015
24039
  function wait(state, index, expected, timeout, done) {
24016
24040
  const max = timeout === Infinity ? Infinity : Date.now() + timeout;
24017
- const check = () => {
24041
+ const check = (previous) => {
24018
24042
  const current = Atomics.load(state, index);
24019
- if (current === expected) {
24043
+ if (current >= expected) {
24020
24044
  done(null, "ok");
24021
24045
  return;
24022
24046
  }
24047
+ if (previous !== undefined && current !== previous) {
24048
+ done(null, "not-equal");
24049
+ return;
24050
+ }
24023
24051
  if (max !== Infinity && Date.now() > max) {
24024
24052
  done(null, "timed-out");
24025
24053
  return;
@@ -24027,9 +24055,16 @@ var require_wait = __commonJS(function(exports, module) {
24027
24055
  const remaining = max === Infinity ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
24028
24056
  const result = Atomics.waitAsync(state, index, current, remaining);
24029
24057
  if (result.async) {
24030
- result.value.then(check);
24058
+ result.value.then((res) => {
24059
+ if (res === "ok") {
24060
+ const latest = Atomics.load(state, index);
24061
+ done(null, latest >= expected ? "ok" : "not-equal");
24062
+ return;
24063
+ }
24064
+ check(current);
24065
+ });
24031
24066
  } else {
24032
- setImmediate(check);
24067
+ setImmediate(done, null, "not-equal");
24033
24068
  }
24034
24069
  };
24035
24070
  check();
@@ -24107,6 +24142,7 @@ var require_thread_stream = __commonJS(function(exports, module) {
24107
24142
  Atomics.store(stream[kImpl].state, READ_INDEX, 0);
24108
24143
  Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
24109
24144
  });
24145
+ Atomics.notify(stream[kImpl].state, READ_INDEX);
24110
24146
  }
24111
24147
 
24112
24148
  class FakeWeakRef {
@@ -24166,6 +24202,9 @@ var require_thread_stream = __commonJS(function(exports, module) {
24166
24202
  function nextFlush(stream) {
24167
24203
  while (true) {
24168
24204
  const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
24205
+ if (stream.destroyed || writeIndex < 0) {
24206
+ return;
24207
+ }
24169
24208
  const leftover = stream[kImpl].data.length - writeIndex;
24170
24209
  if (leftover > 0) {
24171
24210
  if (stream[kImpl].bufLen === 0) {
@@ -24209,7 +24248,9 @@ var require_thread_stream = __commonJS(function(exports, module) {
24209
24248
  }
24210
24249
  switch (msg.code) {
24211
24250
  case "READY":
24212
- this.stream = new WeakRef2(stream);
24251
+ if (!stream[kImpl].ending) {
24252
+ this.stream = new WeakRef2(stream);
24253
+ }
24213
24254
  waitForRead(stream, () => {
24214
24255
  stream[kImpl].ready = true;
24215
24256
  stream.emit("ready");
@@ -24281,6 +24322,8 @@ var require_thread_stream = __commonJS(function(exports, module) {
24281
24322
  this[kImpl].bufLen = 0;
24282
24323
  this[kImpl].flushCallbacks = new Map;
24283
24324
  this[kImpl].nextFlushId = 0;
24325
+ this[kImpl].flushRetainCount = 0;
24326
+ this[kImpl].userRef = true;
24284
24327
  this.worker = createWorker(this, opts);
24285
24328
  this.on("message", (message, transferList) => {
24286
24329
  this.worker.postMessage(message, transferList);
@@ -24328,16 +24371,32 @@ var require_thread_stream = __commonJS(function(exports, module) {
24328
24371
  return;
24329
24372
  }
24330
24373
  this[kImpl].ending = true;
24374
+ this.worker.stream = new FakeWeakRef(this);
24331
24375
  end(this);
24332
24376
  }
24333
24377
  flush(cb) {
24334
- cb = typeof cb === "function" ? cb : noop;
24378
+ const userCb = typeof cb === "function" ? cb : null;
24379
+ cb = userCb || noop;
24380
+ if (userCb) {
24381
+ retainWorkerForPendingFlush(this);
24382
+ }
24383
+ let finished = false;
24384
+ const done = (err) => {
24385
+ if (finished) {
24386
+ return;
24387
+ }
24388
+ finished = true;
24389
+ if (userCb) {
24390
+ releaseWorkerForPendingFlush(this);
24391
+ }
24392
+ cb(err);
24393
+ };
24335
24394
  flushBuffer(this, (err) => {
24336
24395
  if (err) {
24337
- process.nextTick(cb, err);
24396
+ process.nextTick(done, err);
24338
24397
  return;
24339
24398
  }
24340
- requestWorkerFlush(this, cb);
24399
+ requestWorkerFlush(this, done);
24341
24400
  });
24342
24401
  }
24343
24402
  flushSync() {
@@ -24348,9 +24407,13 @@ var require_thread_stream = __commonJS(function(exports, module) {
24348
24407
  flushSync(this);
24349
24408
  }
24350
24409
  unref() {
24351
- this.worker.unref();
24410
+ this[kImpl].userRef = false;
24411
+ if (this[kImpl].flushRetainCount === 0) {
24412
+ this.worker.unref();
24413
+ }
24352
24414
  }
24353
24415
  ref() {
24416
+ this[kImpl].userRef = true;
24354
24417
  this.worker.ref();
24355
24418
  }
24356
24419
  get ready() {
@@ -24407,6 +24470,21 @@ var require_thread_stream = __commonJS(function(exports, module) {
24407
24470
  cb();
24408
24471
  });
24409
24472
  }
24473
+ function retainWorkerForPendingFlush(stream) {
24474
+ if (stream[kImpl].flushRetainCount === 0) {
24475
+ stream.worker.ref();
24476
+ }
24477
+ stream[kImpl].flushRetainCount++;
24478
+ }
24479
+ function releaseWorkerForPendingFlush(stream) {
24480
+ if (stream[kImpl].flushRetainCount === 0) {
24481
+ return;
24482
+ }
24483
+ stream[kImpl].flushRetainCount--;
24484
+ if (stream[kImpl].flushRetainCount === 0 && !stream[kImpl].userRef) {
24485
+ stream.worker.unref();
24486
+ }
24487
+ }
24410
24488
  function requestWorkerFlush(stream, cb) {
24411
24489
  if (stream[kImpl].destroyed) {
24412
24490
  process.nextTick(cb, new Error("the worker has exited"));
@@ -24558,6 +24636,9 @@ var require_thread_stream = __commonJS(function(exports, module) {
24558
24636
  stream[kImpl].flushing = false;
24559
24637
  while (stream[kImpl].bufLen !== 0) {
24560
24638
  const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
24639
+ if (writeIndex < 0) {
24640
+ throw new Error("_writeSync failed");
24641
+ }
24561
24642
  const leftover = stream[kImpl].data.length - writeIndex;
24562
24643
  if (leftover === 0) {
24563
24644
  flushSync(stream);
@@ -26679,6 +26760,7 @@ function toClientReview(review) {
26679
26760
  generalCommentDraft: review.generalCommentDraft ?? "",
26680
26761
  composerScratches: cur.composerScratches ?? [],
26681
26762
  agentCopyMatches: cur.agentCopyMatches ?? false,
26763
+ approveVariants: review.approveVariants,
26682
26764
  createdAt: review.createdAt,
26683
26765
  updatedAt: review.updatedAt,
26684
26766
  decision: review.decision
@@ -28390,7 +28472,7 @@ function runValidation(e, a) {
28390
28472
  return e(a);
28391
28473
  }
28392
28474
 
28393
- class y2 {
28475
+ class y {
28394
28476
  input;
28395
28477
  output;
28396
28478
  _abortSignal;
@@ -28548,10 +28630,10 @@ function g(l, e) {
28548
28630
  if (e)
28549
28631
  return l ? e : e[0];
28550
28632
  }
28551
- function M2(r) {
28633
+ function M(r) {
28552
28634
  return [...r].map((t) => _2[t]);
28553
28635
  }
28554
- function P(r) {
28636
+ function P2(r) {
28555
28637
  const i = new Intl.DateTimeFormat(r, {
28556
28638
  year: "numeric",
28557
28639
  month: "2-digit",
@@ -28565,18 +28647,18 @@ function P(r) {
28565
28647
  function p(r) {
28566
28648
  return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
28567
28649
  }
28568
- function f2(r) {
28650
+ function f(r) {
28569
28651
  return {
28570
28652
  year: p(r.year),
28571
28653
  month: p(r.month),
28572
28654
  day: p(r.day)
28573
28655
  };
28574
28656
  }
28575
- function c(r, t) {
28657
+ function c2(r, t) {
28576
28658
  return new Date(r || 2001, t || 1, 0).getDate();
28577
28659
  }
28578
28660
  function b(r) {
28579
- const { year: t, month: i, day: s } = f2(r);
28661
+ const { year: t, month: i, day: s } = f(r);
28580
28662
  if (!t || t < 0 || t > 9999 || !i || i < 1 || i > 12 || !s || s < 1)
28581
28663
  return;
28582
28664
  const n = new Date(Date.UTC(t, i - 1, s));
@@ -28602,10 +28684,10 @@ function T2(r, t, i, s) {
28602
28684
  max: e && t.year === e.year ? e.month : 12
28603
28685
  } : {
28604
28686
  min: n && t.year === n.year && t.month === n.month ? n.day : 1,
28605
- max: e && t.year === e.year && t.month === e.month ? e.day : c(t.year, t.month)
28687
+ max: e && t.year === e.year && t.month === e.month ? e.day : c2(t.year, t.month)
28606
28688
  };
28607
28689
  }
28608
- var import_sisteransi, a$1, t, settings2, R, CANCEL_SYMBOL, getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20, T$1, r, _2, U2, u$2, o, h2, a, u$1, n$1, u, n;
28690
+ var import_sisteransi, a$1, t, settings2, R, CANCEL_SYMBOL, getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20, T$1, r, _2, U, u$2, o, h, a, u$1, n$1, u, n;
28609
28691
  var init_dist4 = __esm(() => {
28610
28692
  init_main2();
28611
28693
  import_sisteransi = __toESM(require_src(), 1);
@@ -28653,7 +28735,7 @@ var init_dist4 = __esm(() => {
28653
28735
  };
28654
28736
  R = globalThis.process.platform.startsWith("win");
28655
28737
  CANCEL_SYMBOL = Symbol("clack:cancel");
28656
- T$1 = class T extends y2 {
28738
+ T$1 = class T extends y {
28657
28739
  filteredOptions;
28658
28740
  multiple;
28659
28741
  isNavigating = false;
@@ -28725,7 +28807,7 @@ var init_dist4 = __esm(() => {
28725
28807
  }
28726
28808
  }
28727
28809
  };
28728
- r = class r extends y2 {
28810
+ r = class r extends y {
28729
28811
  get cursor() {
28730
28812
  return this.value ? 0 : 1;
28731
28813
  }
@@ -28747,7 +28829,7 @@ var init_dist4 = __esm(() => {
28747
28829
  M: { type: "month", len: 2 },
28748
28830
  D: { type: "day", len: 2 }
28749
28831
  };
28750
- U2 = class U2 extends y2 {
28832
+ U = class U extends y {
28751
28833
  #i;
28752
28834
  #o;
28753
28835
  #t;
@@ -28779,7 +28861,7 @@ var init_dist4 = __esm(() => {
28779
28861
  this._setUserInput(this.#l(this.#t)), this._setValue(C2(this.#t) ?? undefined);
28780
28862
  }
28781
28863
  constructor(t) {
28782
- const i = t.format ? { segments: M2(t.format), separator: t.separator ?? "/" } : P(t.locale), s = t.separator ?? i.separator, n = t.format ? M2(t.format) : i.segments, e = t.initialValue ?? t.defaultValue, m = e ? {
28864
+ const i = t.format ? { segments: M(t.format), separator: t.separator ?? "/" } : P2(t.locale), s = t.separator ?? i.separator, n = t.format ? M(t.format) : i.segments, e = t.initialValue ?? t.defaultValue, m = e ? {
28783
28865
  year: String(e.getUTCFullYear()).padStart(4, "0"),
28784
28866
  month: String(e.getUTCMonth() + 1).padStart(2, "0"),
28785
28867
  day: String(e.getUTCDate()).padStart(2, "0")
@@ -28800,7 +28882,7 @@ var init_dist4 = __esm(() => {
28800
28882
  const i = this.#a();
28801
28883
  if (!i)
28802
28884
  return;
28803
- const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T2(s.type, f2(this.#t), this.#h, this.#u);
28885
+ const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T2(s.type, f(this.#t), this.#h, this.#u);
28804
28886
  let a;
28805
28887
  e ? a = t === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m + t), o.min), this.#t = {
28806
28888
  ...this.#t,
@@ -28875,7 +28957,7 @@ var init_dist4 = __esm(() => {
28875
28957
  this.inlineError = "", this.#t[e.type] = l;
28876
28958
  const y = l.includes("_") ? undefined : b(this.#t);
28877
28959
  if (y) {
28878
- const { year: h, month: d } = y, g = c(h, d);
28960
+ const { year: h, month: d } = y, g = c2(h, d);
28879
28961
  this.#t = {
28880
28962
  year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
28881
28963
  month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
@@ -28888,16 +28970,16 @@ var init_dist4 = __esm(() => {
28888
28970
  }
28889
28971
  }
28890
28972
  #g(t, i) {
28891
- const { month: s, day: n } = f2(t);
28973
+ const { month: s, day: n } = f(t);
28892
28974
  if (i.type === "month" && (s < 0 || s > 12))
28893
28975
  return settings2.date.messages.invalidMonth;
28894
28976
  if (i.type === "day" && (n < 0 || n > 31))
28895
28977
  return settings2.date.messages.invalidDay(31, "any month");
28896
28978
  }
28897
28979
  #p(t) {
28898
- const { year: i, month: s, day: n } = f2(this.#t);
28980
+ const { year: i, month: s, day: n } = f(this.#t);
28899
28981
  if (i && s && n) {
28900
- const e = c(i, s);
28982
+ const e = c2(i, s);
28901
28983
  this.#t = {
28902
28984
  ...this.#t,
28903
28985
  day: String(Math.min(n, e)).padStart(2, "0")
@@ -28906,7 +28988,7 @@ var init_dist4 = __esm(() => {
28906
28988
  this.value = C2(this.#t) ?? t.defaultValue ?? undefined;
28907
28989
  }
28908
28990
  };
28909
- u$2 = class u extends y2 {
28991
+ u$2 = class u extends y {
28910
28992
  options;
28911
28993
  cursor = 0;
28912
28994
  #t;
@@ -28958,7 +29040,7 @@ var init_dist4 = __esm(() => {
28958
29040
  }
28959
29041
  };
28960
29042
  o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
28961
- h2 = class h2 extends y2 {
29043
+ h = class h extends y {
28962
29044
  #t = false;
28963
29045
  #s;
28964
29046
  focused = "editor";
@@ -29041,7 +29123,7 @@ ${i}` : `${s}${styleText("inverse", r)}${i}`;
29041
29123
  });
29042
29124
  }
29043
29125
  };
29044
- a = class a extends y2 {
29126
+ a = class a extends y {
29045
29127
  options;
29046
29128
  cursor = 0;
29047
29129
  get _value() {
@@ -29088,7 +29170,7 @@ ${i}` : `${s}${styleText("inverse", r)}${i}`;
29088
29170
  });
29089
29171
  }
29090
29172
  };
29091
- u$1 = class u extends y2 {
29173
+ u$1 = class u extends y {
29092
29174
  _mask = "\u2022";
29093
29175
  get cursor() {
29094
29176
  return this._cursor;
@@ -29116,7 +29198,7 @@ ${i}` : `${s}${styleText("inverse", r)}${i}`;
29116
29198
  });
29117
29199
  }
29118
29200
  };
29119
- n$1 = class n extends y2 {
29201
+ n$1 = class n extends y {
29120
29202
  options;
29121
29203
  cursor = 0;
29122
29204
  get _selectedValue() {
@@ -29144,7 +29226,7 @@ ${i}` : `${s}${styleText("inverse", r)}${i}`;
29144
29226
  });
29145
29227
  }
29146
29228
  };
29147
- u = class u extends y2 {
29229
+ u = class u extends y {
29148
29230
  options;
29149
29231
  cursor = 0;
29150
29232
  constructor(t) {
@@ -29161,7 +29243,7 @@ ${i}` : `${s}${styleText("inverse", r)}${i}`;
29161
29243
  });
29162
29244
  }
29163
29245
  };
29164
- n = class n extends y2 {
29246
+ n = class n extends y {
29165
29247
  get userInputWithCursor() {
29166
29248
  if (this.state === "submit")
29167
29249
  return this.userInput;
@@ -29268,10 +29350,10 @@ function formatInstructionFooter(o, e) {
29268
29350
  const r = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o.join(" \u2022 ")}`];
29269
29351
  return e && r.push(styleText2("cyan", S_BAR_END)), r;
29270
29352
  }
29271
- function E(t) {
29353
+ function E2(t) {
29272
29354
  return t.label ?? String(t.value ?? "");
29273
29355
  }
29274
- function P2(t, c) {
29356
+ function P3(t, c) {
29275
29357
  if (!t)
29276
29358
  return true;
29277
29359
  const n = (c.label ?? String(c.value ?? "")).toLowerCase(), i = (c.hint ?? "").toLowerCase(), r = String(c.value).toLowerCase(), o = t.toLowerCase();
@@ -29426,14 +29508,14 @@ var import_sisteransi2, unicode, isCI = () => process.env.CI === "true", isTTY =
29426
29508
  initialUserInput: t.initialUserInput,
29427
29509
  placeholder: t.placeholder,
29428
29510
  completeOnTab: t.completeOnTab,
29429
- filter: t.filter ?? ((n, i) => P2(n, i)),
29511
+ filter: t.filter ?? ((n, i) => P3(n, i)),
29430
29512
  signal: t.signal,
29431
29513
  input: t.input,
29432
29514
  output: t.output,
29433
29515
  validate: t.validate,
29434
29516
  render() {
29435
29517
  const n = t.withGuide ?? settings2.withGuide, i = n ? [`${styleText2("gray", S_BAR)}`, `${symbol(this.state)} ${t.message}`] : [`${symbol(this.state)} ${t.message}`], r = this.userInput, o = this.options, m = t.placeholder, p = r === "" && m !== undefined, $ = (l, s) => {
29436
- const a = E(l), u = l.hint && l.value === this.focusedValue ? styleText2("dim", ` (${l.hint})`) : "";
29518
+ const a = E2(l), u = l.hint && l.value === this.focusedValue ? styleText2("dim", ` (${l.hint})`) : "";
29437
29519
  switch (s) {
29438
29520
  case "active":
29439
29521
  return `${styleText2("green", S_RADIO_ACTIVE)} ${a}${u}`;
@@ -29445,7 +29527,7 @@ var import_sisteransi2, unicode, isCI = () => process.env.CI === "true", isTTY =
29445
29527
  };
29446
29528
  switch (this.state) {
29447
29529
  case "submit": {
29448
- const l = j2(this.selectedValues, o), s = l.length > 0 ? ` ${styleText2("dim", l.map(E).join(", "))}` : "", a = n ? styleText2("gray", S_BAR) : "";
29530
+ const l = j2(this.selectedValues, o), s = l.length > 0 ? ` ${styleText2("dim", l.map(E2).join(", "))}` : "", a = n ? styleText2("gray", S_BAR) : "";
29449
29531
  return `${i.join(`
29450
29532
  `)}
29451
29533
  ${a}${s}`;
@@ -29497,7 +29579,7 @@ ${s}${l}`;
29497
29579
  options: t.options,
29498
29580
  multiple: true,
29499
29581
  placeholder: t.placeholder,
29500
- filter: t.filter ?? ((i, r) => P2(i, r)),
29582
+ filter: t.filter ?? ((i, r) => P3(i, r)),
29501
29583
  validate: () => {
29502
29584
  if (t.required && n.selectedValues.length === 0)
29503
29585
  return "Please select at least one item";
@@ -29546,8 +29628,8 @@ ${s}${l}`;
29546
29628
  }
29547
29629
  });
29548
29630
  return n.prompt();
29549
- }, K2, Q2, U3 = (n) => n, box = (n = "", e = "", t) => {
29550
- const o = t?.output ?? process.stdout, i = getColumns(o), R = 1 * 2, u = t?.titlePadding ?? 1, h = t?.contentPadding ?? 2, w = t?.width === undefined || t.width === "auto" ? 1 : Math.min(1, t.width), m = t?.withGuide ?? settings2.withGuide ? `${styleText2("gray", S_BAR)} ` : "", b = t?.formatBorder ?? U3, a = ((t?.rounded) ? K2 : Q2).map(b), _ = b(S_BAR_H), p = b(S_BAR), x = dist_default2(m), B = dist_default2(e), y = i - x;
29631
+ }, K2, Q, U2 = (n) => n, box = (n = "", e = "", t) => {
29632
+ const o = t?.output ?? process.stdout, i = getColumns(o), R = 1 * 2, u = t?.titlePadding ?? 1, h = t?.contentPadding ?? 2, w = t?.width === undefined || t.width === "auto" ? 1 : Math.min(1, t.width), m = t?.withGuide ?? settings2.withGuide ? `${styleText2("gray", S_BAR)} ` : "", b = t?.formatBorder ?? U2, a = ((t?.rounded) ? K2 : Q).map(b), _ = b(S_BAR_H), p = b(S_BAR), x = dist_default2(m), B = dist_default2(e), y = i - x;
29551
29633
  let r = Math.floor(i * w) - x;
29552
29634
  if (t?.width === "auto") {
29553
29635
  const c = n.split(`
@@ -29612,7 +29694,7 @@ ${g}
29612
29694
  }).prompt();
29613
29695
  }, date3 = (e) => {
29614
29696
  const r = e.validate;
29615
- return new U2({
29697
+ return new U({
29616
29698
  ...e,
29617
29699
  validate(t) {
29618
29700
  if (t === undefined)
@@ -29861,7 +29943,7 @@ ${styleText2("gray", S_BAR_END)} ` : "";
29861
29943
  i.write(`${e}${o}
29862
29944
 
29863
29945
  `);
29864
- }, multiline = (e) => new h2({
29946
+ }, multiline = (e) => new h({
29865
29947
  validate: e.validate,
29866
29948
  placeholder: e.placeholder,
29867
29949
  defaultValue: e.defaultValue,
@@ -29990,7 +30072,7 @@ ${n}
29990
30072
  }
29991
30073
  }
29992
30074
  });
29993
- }, W = (l) => styleText2("magenta", l), spinner = ({
30075
+ }, W2 = (l) => styleText2("magenta", l), spinner = ({
29994
30076
  indicator: l = "dots",
29995
30077
  onCancel: h,
29996
30078
  output: n = process.stdout,
@@ -30003,7 +30085,7 @@ ${n}
30003
30085
  } = {}) => {
30004
30086
  const u = isCI();
30005
30087
  let M, T, d = false, S = false, s = "", p, w = performance.now();
30006
- const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
30088
+ const x = getColumns(n), k = I?.styleFrame ?? W2, g = (e) => {
30007
30089
  const r = e > 1 ? O ?? settings2.messages.error : G ?? settings2.messages.cancel;
30008
30090
  S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
30009
30091
  }, f = () => g(2), i = () => g(1), A = () => {
@@ -30070,7 +30152,7 @@ ${n}
30070
30152
  return S;
30071
30153
  }
30072
30154
  };
30073
- }, u2, SELECT_INSTRUCTIONS, c2 = (t, o) => t.includes(`
30155
+ }, u2, SELECT_INSTRUCTIONS, c3 = (t, o) => t.includes(`
30074
30156
  `) ? t.split(`
30075
30157
  `).map((d) => o(d)).join(`
30076
30158
  `) : o(t), select = (t) => {
@@ -30080,15 +30162,15 @@ ${n}
30080
30162
  const s = n.label ?? String(n.value);
30081
30163
  switch (m) {
30082
30164
  case "disabled":
30083
- return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (i) => styleText2("gray", i))}${n.hint ? ` ${styleText2("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
30165
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${c3(s, (i) => styleText2("gray", i))}${n.hint ? ` ${styleText2("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
30084
30166
  case "selected":
30085
- return `${c2(s, (i) => styleText2("dim", i))}`;
30167
+ return `${c3(s, (i) => styleText2("dim", i))}`;
30086
30168
  case "active":
30087
30169
  return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n.hint ? ` ${styleText2("dim", `(${n.hint})`)}` : ""}`;
30088
30170
  case "cancelled":
30089
- return `${c2(s, (i) => styleText2(["strikethrough", "dim"], i))}`;
30171
+ return `${c3(s, (i) => styleText2(["strikethrough", "dim"], i))}`;
30090
30172
  default:
30091
- return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (i) => styleText2("dim", i))}`;
30173
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${c3(s, (i) => styleText2("dim", i))}`;
30092
30174
  }
30093
30175
  }, d = t.showInstructions ?? true;
30094
30176
  return new n$1({
@@ -30178,7 +30260,7 @@ ${r}
30178
30260
  const n = await t.task(s.message);
30179
30261
  s.stop(n || t.title);
30180
30262
  }
30181
- }, A2 = (l) => l.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), taskLog = (l) => {
30263
+ }, A = (l) => l.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), taskLog = (l) => {
30182
30264
  const r = l.output ?? process.stdout, O = getColumns(r), i = styleText2("gray", S_BAR), p = l.spacing ?? 1, k = 3, m = l.retainLog === true, d = !isCI() && isTTY(r);
30183
30265
  r.write(`${i}
30184
30266
  `), r.write(`${styleText2("green", S_STEP_SUBMIT)} ${l.title}
@@ -30233,7 +30315,7 @@ ${e.value}` : e.value;
30233
30315
  }
30234
30316
  }, L = (e, s, t) => {
30235
30317
  if (f(false), (t?.raw !== true || !v) && e.value !== "" && (e.value += `
30236
- `), e.value += A2(s), v = t?.raw === true, l.limit !== undefined) {
30318
+ `), e.value += A(s), v = t?.raw === true, l.limit !== undefined) {
30237
30319
  const o = e.value.split(`
30238
30320
  `), a = o.length - l.limit;
30239
30321
  if (a > 0) {
@@ -30369,7 +30451,7 @@ var init_dist5 = __esm(() => {
30369
30451
  S_CORNER_BOTTOM_LEFT,
30370
30452
  S_CORNER_BOTTOM_RIGHT
30371
30453
  ];
30372
- Q2 = [S_BAR_START, S_BAR_START_RIGHT, S_BAR_END, S_BAR_END_RIGHT];
30454
+ Q = [S_BAR_START, S_BAR_START_RIGHT, S_BAR_END, S_BAR_END_RIGHT];
30373
30455
  p2 = {
30374
30456
  year: "yyyy",
30375
30457
  month: "mm",
@@ -30464,7 +30546,8 @@ function buildEnvelope(plan, ctx) {
30464
30546
  return JSON.stringify({
30465
30547
  session_id: ctx.sessionID,
30466
30548
  cwd: ctx.directory,
30467
- tool_input: { plan, planFilePath: ctx.planFilePath }
30549
+ tool_input: { plan, planFilePath: ctx.planFilePath },
30550
+ approve_variants: ctx.approveVariants
30468
30551
  });
30469
30552
  }
30470
30553
  function parseDecision(stdout) {
@@ -30474,7 +30557,12 @@ function parseDecision(stdout) {
30474
30557
  const parsed = JSON.parse(line);
30475
30558
  if (parsed.behavior === "allow") {
30476
30559
  const notes = typeof parsed.feedback === "string" ? parsed.feedback.trim() : "";
30477
- return notes ? { behavior: "allow", feedback: notes } : { behavior: "allow" };
30560
+ const acceptMode = typeof parsed.acceptMode === "string" ? parsed.acceptMode : "";
30561
+ return {
30562
+ behavior: "allow",
30563
+ ...notes && { feedback: notes },
30564
+ ...acceptMode && { acceptMode }
30565
+ };
30478
30566
  }
30479
30567
  if (parsed.behavior === "deny") {
30480
30568
  return {
@@ -45412,6 +45500,15 @@ class McpServer {
45412
45500
  this._promptHandlersInitialized = false;
45413
45501
  this.server = new Server(serverInfo, options);
45414
45502
  this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
45503
+ if (options?.capabilities?.tools) {
45504
+ this.setToolRequestHandlers();
45505
+ }
45506
+ if (options?.capabilities?.resources) {
45507
+ this.setResourceRequestHandlers();
45508
+ }
45509
+ if (options?.capabilities?.prompts) {
45510
+ this.setPromptRequestHandlers();
45511
+ }
45415
45512
  }
45416
45513
  get experimental() {
45417
45514
  if (!this._experimental) {
@@ -46755,184 +46852,184 @@ init_client();
46755
46852
  init_log();
46756
46853
 
46757
46854
  // node_modules/marked/lib/marked.esm.js
46758
- function B() {
46855
+ function H() {
46759
46856
  return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
46760
46857
  }
46761
- var y = B();
46762
- function V(a) {
46763
- y = a;
46858
+ var S = H();
46859
+ function se(a) {
46860
+ S = a;
46764
46861
  }
46765
- var M = { exec: () => null };
46862
+ var B = { exec: () => null };
46766
46863
  function D(a) {
46767
46864
  let e = [];
46768
46865
  return (t) => {
46769
- let n = Math.max(0, Math.min(3, t - 1)), i = e[n];
46770
- return i || (i = a(n), e[n] = i), i;
46866
+ let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
46867
+ return s || (s = a(n), e[n] = s), s;
46771
46868
  };
46772
46869
  }
46773
- function h(a, e = "") {
46774
- let t = typeof a == "string" ? a : a.source, n = { replace: (i, r) => {
46870
+ function c(a, e = "") {
46871
+ let t = typeof a == "string" ? a : a.source, n = { replace: (s, r) => {
46775
46872
  let o = typeof r == "string" ? r : r.source;
46776
- return o = o.replace(x.caret, "$1"), t = t.replace(i, o), n;
46873
+ return o = o.replace(T.caret, "$1"), t = t.replace(s, o), n;
46777
46874
  }, getRegex: () => new RegExp(t, e) };
46778
46875
  return n;
46779
46876
  }
46780
- var ze = ((a = "") => {
46877
+ var Te = ((a = "") => {
46781
46878
  try {
46782
46879
  return !!new RegExp("(?<=1)(?<!1)" + a);
46783
46880
  } catch {
46784
46881
  return false;
46785
46882
  }
46786
46883
  })();
46787
- var x = { codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, leadingSpaceTab: /^[ \t]+/, 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, numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/, numericCharacterReferenceOrAmpersand: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, 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: (a) => new RegExp(`^( {0,3}${a})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: D((a) => new RegExp(`^ {0,${a}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: D((a) => new RegExp(`^ {0,${a}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)), fencesBeginRegex: D((a) => new RegExp(`^ {0,${a}}(?:\`\`\`|~~~)`)), headingBeginRegex: D((a) => new RegExp(`^ {0,${a}}#`)), htmlBeginRegex: D((a) => new RegExp(`^ {0,${a}}(?:</?(?:${Q})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, "i")), blockquoteBeginRegex: D((a) => new RegExp(`^ {0,${a}}>`)) };
46788
- var Ee = /^(?:[ \t]*(?:\n|$))+/;
46789
- var Me = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
46790
- var Ce = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
46791
- var N = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
46792
- var Ie = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
46793
- var Y = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
46794
- var fe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
46795
- var me = h(fe).replace(/bull/g, Y).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}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
46796
- var Be = h(fe).replace(/bull/g, Y).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}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
46797
- var ee = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
46798
- var De = /^[^\n]+/;
46799
- var te = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
46800
- var qe = h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", te).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
46801
- var Ze = h(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, Y).getRegex();
46802
- var Q = "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";
46803
- var ne = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
46804
- var ve = h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))", "i").replace("comment", ne).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
46805
- var xe = (a) => h(ee).replace("hr", N).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", a).replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", Q).getRegex();
46806
- var He = xe(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
46807
- var Ge = xe(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
46808
- var Ne = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Ge).getRegex();
46809
- var re = { blockquote: Ne, code: Me, def: qe, fences: Ce, heading: Ie, hr: N, html: ve, lheading: me, list: Ze, newline: Ee, paragraph: He, table: M, text: De };
46810
- var de = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", N).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}\t)[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", Q).getRegex();
46811
- var Qe = { ...re, lheading: Be, table: de, paragraph: h(ee).replace("hr", N).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", de).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", Q).getRegex() };
46812
- var je = { ...re, html: h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", ne).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: M, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: h(ee).replace("hr", N).replace("heading", ` *#{1,6} *[^
46813
- ]`).replace("lheading", me).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
46814
- var Fe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
46815
- var Ue = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
46816
- var be = /^( {2,}|\\)\n(?!\s*$)[ \t]*/;
46817
- var Ke = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
46818
- var S = /[\p{P}\p{S}]/u;
46819
- var q = /[\s\p{P}\p{S}]/u;
46820
- var j = /[^\s\p{P}\p{S}]/u;
46821
- var Xe = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, q).getRegex();
46822
- var We = /[\p{Pi}\p{Ps}"']/u;
46823
- var Re = /(?!~)[\p{P}\p{S}]/u;
46824
- var Ve = /(?!~)[\s\p{P}\p{S}]/u;
46825
- var Je = /(?:[^\s\p{P}\p{S}]|~)/u;
46826
- var Ye = h(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", ze ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
46827
- var Te = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
46828
- var et = h(Te, "u").replace(/punct/g, S).getRegex();
46829
- var tt = h(Te, "u").replace(/punct/g, Re).getRegex();
46830
- var nt = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
46831
- var rt = h(nt, "u").replace(/openQuote/g, We).replace(/punct/g, S).getRegex();
46832
- var Oe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
46833
- var st = h(Oe, "gu").replace(/notPunctSpace/g, j).replace(/punctSpace/g, q).replace(/punct/g, S).getRegex();
46834
- var it = h(Oe, "gu").replace(/notPunctSpace/g, Je).replace(/punctSpace/g, Ve).replace(/punct/g, Re).getRegex();
46835
- var ot = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
46836
- var at = h(ot, "gu").replace(/notPunctSpace/g, j).replace(/punctSpace/g, q).replace(/punct/g, S).getRegex();
46837
- var lt = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, j).replace(/punctSpace/g, q).replace(/punct/g, S).getRegex();
46838
- var ut = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
46839
- var pt = h(ut, "gu").replace(/notPunctSpace/g, j).replace(/punctSpace/g, q).replace(/punct/g, S).getRegex();
46840
- var ct = h(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, S).getRegex();
46841
- var ht = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
46842
- var dt = h(ht, "gu").replace(/notPunctSpace/g, j).replace(/punctSpace/g, q).replace(/punct/g, S).getRegex();
46843
- var kt = h(/\\(punct)/, "gu").replace(/punct/g, S).getRegex();
46844
- var gt = h(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/, "gu").replace(/punct/g, S).getRegex();
46845
- var ft = h(/^<(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();
46846
- var mt = h(ne).replace("(?:-->|$)", "-->").getRegex();
46847
- var xt = h("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", mt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
46848
- var we = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
46849
- var K = h(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", we).getRegex();
46850
- var bt = h(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", K).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
46851
- var Rt = h(/^!?\[(label)\]\[(ref)\]/).replace("label", K).replace("ref", te).getRegex();
46852
- var Tt = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", te).getRegex();
46853
- var ke = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/;
46854
- var Ot = h(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", we).getRegex();
46855
- var wt = h("reflink|nolink(?!\\()", "g").replace("reflink", h(/^!?\[(label)\]\[(ref)\]/).replace("label", Ot).replace("ref", ke).getRegex()).replace("nolink", h(/^!?\[(ref)\](?:\[\])?/).replace("ref", ke).getRegex()).getRegex();
46856
- var ge = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
46857
- var Pt = /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/;
46858
- var yt = h(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, Pt).getRegex();
46859
- var se = { _backpedal: M, anyPunctuation: kt, anyPunctuationOutsideCode: gt, autolink: ft, blockSkip: Ye, br: be, code: Ue, del: M, delLDelim: M, delRDelim: M, emStrongLDelim: et, emStrongRDelimAst: st, emStrongRDelimUnd: lt, escape: Fe, link: bt, nolink: Tt, punctuation: Xe, reflink: Rt, reflinkSearch: wt, tag: xt, text: Ke, url: M };
46860
- var St = { ...se, emStrongLDelim: rt, emStrongRDelimAst: at, emStrongRDelimUnd: pt, link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", K).getRegex(), reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", K).getRegex() };
46861
- var J = { ...se, emStrongRDelimAst: it, emStrongLDelim: tt, delLDelim: ct, delRDelim: dt, url: h(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", yt).replace("protocol", ge).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: h(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", ge).replace(/emailProtocol/g, /(?:mailto|xmpp):/).getRegex() };
46862
- var _t = { ...J, br: h(be).replace("{2,}", "*").getRegex(), text: h(J.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
46863
- var F = { normal: re, gfm: Qe, pedantic: je };
46864
- var Z = { normal: se, gfm: J, breaks: _t, pedantic: St };
46865
- var $t = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
46866
- var Pe = (a) => $t[a];
46867
- function w(a, e) {
46884
+ var T = { codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, leadingSpaceTab: /^[ \t]+/, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, blockquoteMarkerWhitespace: /^( {0,3}>)([ \t]+)/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\][ \t]+\S/, listReplaceTask: /^\[[ xX]\][ \t]+/, 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, numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/, numericCharacterReferenceOrAmpersand: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, 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: (a) => new RegExp(`^( {0,3}${a})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: D((a) => new RegExp(`^ {0,${a}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: D((a) => new RegExp(`^ {0,${a}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)), fencesBeginRegex: D((a) => new RegExp(`^ {0,${a}}(?:\`\`\`|~~~)`)), headingBeginRegex: D((a) => new RegExp(`^ {0,${a}}#{1,6}(?:\\s|$)`)), pedanticHeadingBeginRegex: D((a) => new RegExp(`^ {0,${a}}#`)), htmlBeginRegex: D((a) => new RegExp(`^ {0,${a}}(?:</?(?:${K})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, "i")), blockquoteBeginRegex: D((a) => new RegExp(`^ {0,${a}}>`)) };
46885
+ var ve = /^(?:[ \t]*(?:\n|$))+/;
46886
+ var Ze = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
46887
+ var He = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/;
46888
+ var W = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
46889
+ var je = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
46890
+ var oe = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
46891
+ var Oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/;
46892
+ var we = c(Oe).replace(/bull/g, oe).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}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
46893
+ var Ge = c(Oe).replace(/bull/g, oe).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}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
46894
+ var ae = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
46895
+ var Ne = /^[^\n]+/;
46896
+ var le = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/;
46897
+ var Fe = c(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", le).replace("title", /(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex();
46898
+ var Qe = c(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, oe).getRegex();
46899
+ var K = "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";
46900
+ var ue = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
46901
+ var Ue = c("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))", "i").replace("comment", ue).replace("tag", K).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
46902
+ var Pe = (a) => c(ae).replace("hr", W).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", a).replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", K).getRegex();
46903
+ var We = Pe(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
46904
+ var Ke = Pe(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
46905
+ var Xe = c(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace("paragraph", Ke).getRegex();
46906
+ var pe = { blockquote: Xe, code: Ze, def: Fe, fences: He, heading: je, hr: W, html: Ue, lheading: we, list: Qe, newline: ve, paragraph: We, table: B, text: Ne };
46907
+ var xe = c("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", W).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}\t)[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", K).getRegex();
46908
+ var Ve = { ...pe, lheading: Ge, table: xe, paragraph: c(ae).replace("hr", W).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", xe).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", K).getRegex() };
46909
+ var Je = { ...pe, html: c(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace("comment", ue).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: B, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: c(ae).replace("hr", W).replace("heading", ` *#{1,6} *[^
46910
+ ]`).replace("lheading", we).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
46911
+ var Ye = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
46912
+ var et = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
46913
+ var Se = /^( {2,}|\\)\n(?!\s*$)[ \t]*/;
46914
+ var tt = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
46915
+ var $ = /[\p{P}\p{S}]/u;
46916
+ var j = /[\s\p{P}\p{S}]/u;
46917
+ var X = /[^\s\p{P}\p{S}]/u;
46918
+ var nt = c(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, j).getRegex();
46919
+ var rt = /[\p{Pi}\p{Ps}"']/u;
46920
+ var ye = /(?!~)[\p{P}\p{S}]/u;
46921
+ var st = /(?!~)[\s\p{P}\p{S}]/u;
46922
+ var it = /(?:[^\s\p{P}\p{S}]|~)/u;
46923
+ var ot = c(/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();
46924
+ var _e = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
46925
+ var at = c(_e, "u").replace(/punct/g, $).getRegex();
46926
+ var lt = c(_e, "u").replace(/punct/g, ye).getRegex();
46927
+ var ut = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
46928
+ var pt = c(ut, "u").replace(/openQuote/g, rt).replace(/punct/g, $).getRegex();
46929
+ var $e = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
46930
+ var ct = c($e, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, j).replace(/punct/g, $).getRegex();
46931
+ var ht = c($e, "gu").replace(/notPunctSpace/g, it).replace(/punctSpace/g, st).replace(/punct/g, ye).getRegex();
46932
+ var dt = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
46933
+ var gt = c(dt, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, j).replace(/punct/g, $).getRegex();
46934
+ var kt = c("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, j).replace(/punct/g, $).getRegex();
46935
+ var ft = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
46936
+ var mt = c(ft, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, j).replace(/punct/g, $).getRegex();
46937
+ var xt = c(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, $).getRegex();
46938
+ var bt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
46939
+ var Rt = c(bt, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, j).replace(/punct/g, $).getRegex();
46940
+ var Tt = c(/\\(punct)/, "gu").replace(/punct/g, $).getRegex();
46941
+ var Ot = c(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/, "gu").replace(/punct/g, $).getRegex();
46942
+ var wt = c(/^<(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();
46943
+ var Pt = c(ue).replace("(?:-->|$)", "-->").getRegex();
46944
+ var St = c("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Pt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
46945
+ var Le = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
46946
+ var re = c(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", Le).getRegex();
46947
+ var yt = c(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", re).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex();
46948
+ var _t = c(/^!?\[(label)\]\[(ref)\]/).replace("label", re).replace("ref", le).getRegex();
46949
+ var $t = c(/^!?\[(ref)\](?:\[\])?/).replace("ref", le).getRegex();
46950
+ var be = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/;
46951
+ var Lt = c(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", Le).getRegex();
46952
+ var Ct = c("reflink|nolink(?!\\()", "g").replace("reflink", c(/^!?\[(label)\]\[(ref)\]/).replace("label", Lt).replace("ref", be).getRegex()).replace("nolink", c(/^!?\[(ref)\](?:\[\])?/).replace("ref", be).getRegex()).getRegex();
46953
+ var Re = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
46954
+ var It = /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/;
46955
+ var At = c(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, It).getRegex();
46956
+ var ce = { _backpedal: B, anyPunctuation: Tt, anyPunctuationOutsideCode: Ot, autolink: wt, blockSkip: ot, br: Se, code: et, del: B, delLDelim: B, delRDelim: B, emStrongLDelim: at, emStrongRDelimAst: ct, emStrongRDelimUnd: kt, escape: Ye, link: yt, nolink: $t, punctuation: nt, reflink: _t, reflinkSearch: Ct, tag: St, text: tt, url: B };
46957
+ var Et = { ...ce, emStrongLDelim: pt, emStrongRDelimAst: gt, emStrongRDelimUnd: mt, link: c(/^!?\[(label)\]\((.*?)\)/).replace("label", re).getRegex(), reflink: c(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", re).getRegex() };
46958
+ var ie = { ...ce, emStrongRDelimAst: ht, emStrongLDelim: lt, delLDelim: xt, delRDelim: Rt, url: c(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", At).replace("protocol", Re).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: c(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", Re).replace(/emailProtocol/g, /(?:mailto|xmpp):/).replace("wwwStart", Te ? "(?<![^\\s*_~(])www\\." : "www\\.").getRegex() };
46959
+ var zt = { ...ie, br: c(Se).replace("{2,}", "*").getRegex(), text: c(ie.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
46960
+ var V = { normal: pe, gfm: Ve, pedantic: Je };
46961
+ var G = { normal: ce, gfm: ie, breaks: zt, pedantic: Et };
46962
+ var Mt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
46963
+ var Ce = (a) => Mt[a];
46964
+ function P(a, e) {
46868
46965
  if (e) {
46869
- if (x.escapeTest.test(a))
46870
- return a.replace(x.escapeReplace, Pe);
46871
- } else if (x.escapeTestNoEncode.test(a))
46872
- return a.replace(x.escapeReplaceNoEncode, Pe);
46966
+ if (T.escapeTest.test(a))
46967
+ return a.replace(T.escapeReplace, Ce);
46968
+ } else if (T.escapeTestNoEncode.test(a))
46969
+ return a.replace(T.escapeReplaceNoEncode, Ce);
46873
46970
  return a;
46874
46971
  }
46875
- function ye(a) {
46876
- return x.numericCharacterReference.test(a) ? a.replace(x.numericCharacterReferenceOrAmpersand, (e, t, n) => {
46972
+ function Ie(a) {
46973
+ return T.numericCharacterReference.test(a) ? a.replace(T.numericCharacterReferenceOrAmpersand, (e, t, n) => {
46877
46974
  if (t === undefined && n === undefined)
46878
46975
  return "&amp;";
46879
- let i = t === undefined ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
46880
- return i === 0 || i > 1114111 || i >= 55296 && i <= 57343 ? "\uFFFD" : i === 38 ? "&amp;" : String.fromCodePoint(i);
46976
+ let s = t === undefined ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
46977
+ return s === 0 || s > 1114111 || s >= 55296 && s <= 57343 ? "\uFFFD" : s === 38 ? "&amp;" : String.fromCodePoint(s);
46881
46978
  }) : a;
46882
46979
  }
46883
- function ie(a) {
46980
+ function he(a) {
46884
46981
  try {
46885
- a = encodeURI(a).replace(x.percentDecode, "%");
46982
+ a = encodeURI(a).replace(T.percentDecode, "%");
46886
46983
  } catch {
46887
46984
  return null;
46888
46985
  }
46889
46986
  return a;
46890
46987
  }
46891
- function oe(a, e) {
46892
- let t = a.replace(x.findPipe, (r, o, s) => {
46893
- let l = false, u = o;
46894
- for (;--u >= 0 && s[u] === "\\"; )
46988
+ function de(a, e) {
46989
+ let t = a.replace(T.findPipe, (r, o, i) => {
46990
+ let l = false, p = o;
46991
+ for (;--p >= 0 && i[p] === "\\"; )
46895
46992
  l = !l;
46896
46993
  return l ? "|" : " |";
46897
- }), n = t.split(x.splitPipe), i = 0;
46994
+ }), n = t.split(T.splitPipe), s = 0;
46898
46995
  if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
46899
46996
  if (n.length > e)
46900
46997
  n.splice(e);
46901
46998
  else
46902
46999
  for (;n.length < e; )
46903
47000
  n.push("");
46904
- for (;i < n.length; i++)
46905
- n[i] = n[i].trim().replace(x.slashPipe, "|");
47001
+ for (;s < n.length; s++)
47002
+ n[s] = n[s].trim().replace(T.slashPipe, "|");
46906
47003
  return n;
46907
47004
  }
46908
- function A(a, e, t) {
47005
+ function L(a, e, t) {
46909
47006
  let n = a.length;
46910
47007
  if (n === 0)
46911
47008
  return "";
46912
- let i = 0;
46913
- for (;i < n; ) {
46914
- let r = a.charAt(n - i - 1);
47009
+ let s = 0;
47010
+ for (;s < n; ) {
47011
+ let r = a.charAt(n - s - 1);
46915
47012
  if (r === e && !t)
46916
- i++;
47013
+ s++;
46917
47014
  else if (r !== e && t)
46918
- i++;
47015
+ s++;
46919
47016
  else
46920
47017
  break;
46921
47018
  }
46922
- return a.slice(0, n - i);
47019
+ return a.slice(0, n - s);
46923
47020
  }
46924
- function ae(a) {
47021
+ function ge(a) {
46925
47022
  let e = a.split(`
46926
47023
  `), t = e.length - 1;
46927
- for (;t >= 0 && x.blankLine.test(e[t]); )
47024
+ for (;t >= 0 && T.blankLine.test(e[t]); )
46928
47025
  t--;
46929
47026
  return e.length - t <= 2 ? a : e.slice(0, t + 1).join(`
46930
47027
  `);
46931
47028
  }
46932
- function v(a) {
46933
- return a.trim().toLowerCase().toUpperCase().toLowerCase();
47029
+ function F(a) {
47030
+ return a.trim().replace(T.multipleSpaceGlobal, " ").toLowerCase().toUpperCase().toLowerCase();
46934
47031
  }
46935
- function le(a, e) {
47032
+ function ke(a, e) {
46936
47033
  if (a.indexOf(e[0]) === -1 && a.indexOf(e[1]) === -1)
46937
47034
  return -1;
46938
47035
  let t = 0;
@@ -46945,66 +47042,98 @@ function le(a, e) {
46945
47042
  return n;
46946
47043
  return t > 0 ? -2 : -1;
46947
47044
  }
46948
- function X(a, e = 0) {
47045
+ var N = new WeakMap;
47046
+ function fe(a) {
47047
+ let e = { "*": -1, _: -1 }, t = -1, n = a.length;
47048
+ for (let s = 0;s < n; s++) {
47049
+ let r = a[s];
47050
+ if (r !== "*" && r !== "_" && r !== "~")
47051
+ continue;
47052
+ let o = s === 0 ? `
47053
+ ` : a[s - 1], i = s + 1;
47054
+ for (;i < n && a[i] === r; )
47055
+ i++;
47056
+ o !== " " && o !== "\t" && o !== `
47057
+ ` && o !== "\r" && o !== "\f" && (r === "~" ? t = s : e[r] = s), s = i - 1;
47058
+ }
47059
+ return { maskedSrc: a, lastPossibleEmStrongCloserIndex: e, lastPossibleDelCloserIndex: t };
47060
+ }
47061
+ function Ae(a, e) {
47062
+ let t = fe(e), n = N.get(a);
47063
+ n ? n.push(t) : N.set(a, [t]);
47064
+ }
47065
+ function Ee(a) {
47066
+ let e = N.get(a);
47067
+ e && (e.pop(), e.length === 0 && N.delete(a));
47068
+ }
47069
+ function ze(a, e, t) {
47070
+ let n = N.get(a)?.at(-1);
47071
+ return n && n.maskedSrc === e ? n.lastPossibleEmStrongCloserIndex[t] : fe(e).lastPossibleEmStrongCloserIndex[t];
47072
+ }
47073
+ function Me(a, e) {
47074
+ let t = N.get(a)?.at(-1);
47075
+ return t && t.maskedSrc === e ? t.lastPossibleDelCloserIndex : fe(e).lastPossibleDelCloserIndex;
47076
+ }
47077
+ function J(a, e = 0) {
46949
47078
  let t = e, n = "";
46950
- for (let i of a)
46951
- if (i === "\t") {
47079
+ for (let s of a)
47080
+ if (s === "\t") {
46952
47081
  let r = 4 - t % 4;
46953
47082
  n += " ".repeat(r), t += r;
46954
47083
  } else
46955
- n += i, t++;
47084
+ n += s, t++;
46956
47085
  return n;
46957
47086
  }
46958
- function Se(a, e, t, n, i) {
46959
- let r = e.href, o = e.title || null, s = a[1].replace(i.other.outputLinkReplace, "$1"), l = a[0].charAt(0) === "!", u = n.state.inLink, c = n.state.linkEmitted, p = n.state.inRawBlock;
47087
+ function De(a, e, t, n, s) {
47088
+ let r = e.href, o = e.title || null, i = a[1].replace(s.other.outputLinkReplace, "$1"), l = a[0].charAt(0) === "!", p = n.state.inLink, h = n.state.linkEmitted, u = n.state.inRawBlock;
46960
47089
  n.state.inLink = true, n.state.linkEmitted = false;
46961
- let d = n.inlineTokens(s), g = n.state.linkEmitted;
46962
- if (n.state.linkEmitted = c, n.state.inLink = u, !l) {
46963
- if (g) {
46964
- n.state.inRawBlock = p;
47090
+ let d = n.inlineTokens(i), k = n.state.linkEmitted;
47091
+ if (n.state.linkEmitted = h, n.state.inLink = p, !l) {
47092
+ if (k) {
47093
+ n.state.inRawBlock = u;
46965
47094
  return;
46966
47095
  }
46967
47096
  n.state.linkEmitted = true;
46968
47097
  }
46969
- return { type: l ? "image" : "link", raw: t, href: r, title: o, text: s, tokens: d };
47098
+ return { type: l ? "image" : "link", raw: t, href: r, title: o, text: i, tokens: d };
46970
47099
  }
46971
- function Lt(a, e, t) {
47100
+ function Dt(a, e, t) {
46972
47101
  let n = a.match(t.other.indentCodeCompensation);
46973
47102
  if (n === null)
46974
47103
  return e;
46975
- let i = n[1];
47104
+ let s = n[1];
46976
47105
  return e.split(`
46977
47106
  `).map((r) => {
46978
47107
  let o = r.match(t.other.beginningSpace);
46979
47108
  if (o === null)
46980
47109
  return r;
46981
- let [s] = o;
46982
- return r.slice(Math.min(s.length, i.length));
47110
+ let [i] = o;
47111
+ return r.slice(Math.min(i.length, s.length));
46983
47112
  }).join(`
46984
47113
  `);
46985
47114
  }
46986
- function _e(a, e, t, n) {
47115
+ function Be(a, e, t, n) {
46987
47116
  if (!e.includes("<"))
46988
47117
  return false;
46989
- for (let i = 0;i < e.length; i++) {
46990
- if (e[i] === "\\") {
46991
- i++;
47118
+ for (let s = 0;s < e.length; s++) {
47119
+ if (e[s] === "\\") {
47120
+ s++;
46992
47121
  continue;
46993
47122
  }
46994
- if (e[i] === "`") {
46995
- let s = n.inline.code.exec(e.slice(i));
46996
- if (s) {
46997
- i += s[0].length - 1;
47123
+ if (e[s] === "`") {
47124
+ let i = n.inline.code.exec(e.slice(s));
47125
+ if (i) {
47126
+ s += i[0].length - 1;
46998
47127
  continue;
46999
47128
  }
47000
47129
  }
47001
- if (e[i] !== "<")
47130
+ if (e[s] !== "<")
47002
47131
  continue;
47003
- let r = a.slice(t + i), o = n.inline.tag.exec(r) || n.inline.autolink.exec(r);
47132
+ let r = a.slice(t + s), o = n.inline.tag.exec(r) || n.inline.autolink.exec(r);
47004
47133
  if (o) {
47005
- if (o[0].length > e.length - i)
47134
+ if (o[0].length > e.length - s)
47006
47135
  return true;
47007
- i += o[0].length - 1;
47136
+ s += o[0].length - 1;
47008
47137
  }
47009
47138
  }
47010
47139
  return false;
@@ -47014,7 +47143,7 @@ var _ = class {
47014
47143
  rules;
47015
47144
  lexer;
47016
47145
  constructor(e) {
47017
- this.options = e || y;
47146
+ this.options = e || S;
47018
47147
  }
47019
47148
  space(e) {
47020
47149
  let t = this.rules.block.newline.exec(e);
@@ -47024,15 +47153,15 @@ var _ = class {
47024
47153
  code(e) {
47025
47154
  let t = this.rules.block.code.exec(e);
47026
47155
  if (t) {
47027
- let n = this.options.pedantic ? t[0] : ae(t[0]), i = n.replace(this.rules.other.codeRemoveIndent, "");
47028
- return { type: "code", raw: n, codeBlockStyle: "indented", text: i };
47156
+ let n = this.options.pedantic ? t[0] : ge(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
47157
+ return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
47029
47158
  }
47030
47159
  }
47031
47160
  fences(e) {
47032
47161
  let t = this.rules.block.fences.exec(e);
47033
47162
  if (t) {
47034
- let n = t[0], i = Lt(n, t[3] || "", this.rules);
47035
- return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: i };
47163
+ let n = t[0], s = Dt(n, t[3] || "", this.rules);
47164
+ return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
47036
47165
  }
47037
47166
  }
47038
47167
  heading(e) {
@@ -47040,175 +47169,187 @@ var _ = class {
47040
47169
  if (t) {
47041
47170
  let n = t[2].trim();
47042
47171
  if (this.rules.other.endingHash.test(n)) {
47043
- let i = A(n, "#");
47044
- (this.options.pedantic || !i || this.rules.other.endingSpaceTabChar.test(i)) && (n = i.trim());
47172
+ let s = L(n, "#");
47173
+ (this.options.pedantic || !s || this.rules.other.endingSpaceTabChar.test(s)) && (n = s.trim());
47045
47174
  }
47046
- return { type: "heading", raw: A(t[0], `
47175
+ return { type: "heading", raw: L(t[0], `
47047
47176
  `), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
47048
47177
  }
47049
47178
  }
47050
47179
  hr(e) {
47051
47180
  let t = this.rules.block.hr.exec(e);
47052
47181
  if (t)
47053
- return { type: "hr", raw: A(t[0], `
47182
+ return { type: "hr", raw: L(t[0], `
47054
47183
  `) };
47055
47184
  }
47056
47185
  blockquote(e) {
47057
47186
  let t = this.rules.block.blockquote.exec(e);
47058
47187
  if (t) {
47059
- let n = A(t[0], `
47188
+ let n = L(t[0], `
47060
47189
  `).split(`
47061
- `), i = "", r = "", o = [];
47190
+ `), s = "", r = "", o = [];
47062
47191
  for (;n.length > 0; ) {
47063
- let s = false, l = [], u;
47064
- for (u = 0;u < n.length; u++)
47065
- if (this.rules.other.blockquoteStart.test(n[u]))
47066
- l.push(n[u]), s = true;
47067
- else if (!s)
47068
- l.push(n[u]);
47192
+ let i = false, l = [], p;
47193
+ for (p = 0;p < n.length; p++)
47194
+ if (this.rules.other.blockquoteStart.test(n[p]))
47195
+ l.push(n[p]), i = true;
47196
+ else if (!i)
47197
+ l.push(n[p]);
47069
47198
  else
47070
47199
  break;
47071
- n = n.slice(u);
47072
- let c = l.join(`
47073
- `), p = c.replace(this.rules.other.blockquoteSetextReplace, `
47200
+ n = n.slice(p);
47201
+ let h = l.join(`
47202
+ `), u = h.replace(this.rules.other.blockquoteMarkerWhitespace, (g, b, m) => b + J(m, b.length)).replace(this.rules.other.blockquoteSetextReplace, `
47074
47203
  $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
47075
- i = i ? `${i}
47076
- ${c}` : c, r = r ? `${r}
47077
- ${p}` : p;
47204
+ s = s ? `${s}
47205
+ ${h}` : h, r = r ? `${r}
47206
+ ${u}` : u;
47078
47207
  let d = this.lexer.state.top;
47079
- if (this.lexer.state.top = true, this.lexer.blockTokens(p, o, true), this.lexer.state.top = d, n.length === 0)
47208
+ if (this.lexer.state.top = true, this.lexer.blockTokens(u, o, true), this.lexer.state.top = d, n.length === 0)
47080
47209
  break;
47081
- let g = o.at(-1);
47082
- if (g?.type === "code" || g?.type === "heading" || g?.type === "hr" || g?.type === "html")
47210
+ let k = o.at(-1);
47211
+ if (k?.type === "code" || k?.type === "heading" || k?.type === "hr" || k?.type === "html" || k?.type === "table")
47083
47212
  break;
47084
- if (g?.type === "blockquote") {
47085
- let k = g, P = n.join(`
47086
- `), R = k.raw + `
47087
- ` + P.replace(this.rules.other.blockquoteSetextReplace2, ""), m = this.blockquote(R);
47088
- o[o.length - 1] = m;
47089
- let E = R.substring(m.raw.length).replace(/^\n/, ""), b = E ? E.split(`
47090
- `).length : 0, H = b ? n.slice(0, -b) : n;
47091
- H.length > 0 && (i = `${i}
47092
- ${H.join(`
47093
- `)}`), r = r.substring(0, r.length - k.text.length) + m.text;
47213
+ if (k?.type === "blockquote") {
47214
+ let g = k, b = n.join(`
47215
+ `), m = g.raw + `
47216
+ ` + b.replace(this.rules.other.blockquoteSetextReplace2, ""), f = this.blockquote(m);
47217
+ o[o.length - 1] = f;
47218
+ let y = m.substring(f.raw.length).replace(/^\n/, ""), R = y ? y.split(`
47219
+ `).length : 0, A = R ? n.slice(0, -R) : n;
47220
+ if (A.length > 0 && (s = `${s}
47221
+ ${A.join(`
47222
+ `)}`), r = r.substring(0, r.length - g.text.length) + f.text, n = n.slice(A.length), n.length > 0 && this.rules.other.blockquoteStart.test(n[0]))
47223
+ continue;
47094
47224
  break;
47095
- } else if (g?.type === "list") {
47096
- let k = g, P = k.raw + `
47225
+ } else if (k?.type === "list") {
47226
+ let g = k, b = g.raw + `
47097
47227
  ` + n.join(`
47098
- `), R = this.list(P);
47099
- o[o.length - 1] = R, i = i.substring(0, i.length - g.raw.length) + R.raw, r = r.substring(0, r.length - k.raw.length) + R.raw, n = P.substring(o.at(-1).raw.length).split(`
47228
+ `), m = this.list(b);
47229
+ o[o.length - 1] = m;
47230
+ let f = m.raw.length > g.raw.length ? b.slice(g.raw.length + 1, m.raw.length).split(`
47231
+ `).length : 0;
47232
+ if (f > 0) {
47233
+ let y = n.slice(0, f).join(`
47100
47234
  `);
47235
+ s = `${s}
47236
+ ${y}`, r = `${r}
47237
+ ${y}`;
47238
+ }
47239
+ n = n.slice(f);
47101
47240
  continue;
47102
47241
  }
47103
47242
  }
47104
- return { type: "blockquote", raw: i, tokens: o, text: r };
47243
+ return { type: "blockquote", raw: s, tokens: o, text: r };
47105
47244
  }
47106
47245
  }
47107
47246
  list(e) {
47108
47247
  let t = this.rules.block.list.exec(e);
47109
47248
  if (t) {
47110
- let n = e, i = () => n.length - e.length, r = t[1].trim(), o = r.length > 1, s = { type: "list", raw: "", ordered: o, start: o ? +r.slice(0, -1) : "", loose: false, items: [] };
47249
+ let n = e, s = () => n.length - e.length, r = t[1].trim(), o = r.length > 1, i = { type: "list", raw: "", ordered: o, start: o ? +r.slice(0, -1) : "", loose: false, items: [] };
47111
47250
  r = o ? `\\d{1,9}\\${r.slice(-1)}` : `\\${r}`, this.options.pedantic && (r = o ? r : "[*+-]");
47112
- let l = this.rules.other.listItemRegex(r), u = false;
47251
+ let l = this.rules.other.listItemRegex(r), p = false;
47113
47252
  for (;e; ) {
47114
- let p = false, d = "";
47253
+ let u = false, d = "";
47115
47254
  if (!(t = l.exec(e)) || this.rules.block.hr.test(e))
47116
47255
  break;
47117
- let g = i();
47256
+ let k = s();
47118
47257
  e = e.substring(t[0].length);
47119
- let k = t[2].split(`
47120
- `, 1)[0], P = t[1].length, R = this.options.pedantic ? X(k, P) : k.replace(this.rules.other.leadingSpaceTab, (W) => X(W, P)), m = e.split(`
47121
- `, 1)[0], E = !R.trim(), b = 0;
47122
- if (this.options.pedantic ? (b = 2, d = R.trimStart()) : E ? b = P + 1 : (b = R.search(this.rules.other.nonSpaceChar), b = b > 4 ? 1 : b, d = R.slice(b), b += P), E && this.rules.other.blankLine.test(m) && (e = e.substring(m.length + 1), p = true), !p) {
47123
- let W = this.rules.other.nextBulletRegex(b), ue = this.rules.other.hrRegex(b), pe = this.rules.other.fencesBeginRegex(b), ce = this.rules.other.headingBeginRegex(b), $e = this.rules.other.htmlBeginRegex(b), Le = this.rules.other.blockquoteBeginRegex(b);
47258
+ let g = t[2].split(`
47259
+ `, 1)[0], b = t[1].length, m = this.options.pedantic ? J(g, b) : g.replace(this.rules.other.leadingSpaceTab, (v) => J(v, b)), f = e.split(`
47260
+ `, 1)[0], y = !m.trim(), R = 0;
47261
+ if (this.options.pedantic ? (R = 2, d = m.trimStart()) : y ? R = b + 1 : (R = m.search(this.rules.other.nonSpaceChar), R = R > 4 ? 1 : R, d = m.slice(R), R += b), y && this.rules.other.blankLine.test(f) && (e = e.substring(f.length + 1), u = true), !u) {
47262
+ let v = this.rules.other.nextBulletRegex(R), Q = this.rules.other.hrRegex(R), ee = this.rules.other.fencesBeginRegex(R), te = this.options.pedantic ? this.rules.other.pedanticHeadingBeginRegex(R) : this.rules.other.headingBeginRegex(R), M = this.rules.other.htmlBeginRegex(R), ne = this.rules.other.blockquoteBeginRegex(R);
47124
47263
  for (;e; ) {
47125
- let he = e.split(`
47126
- `, 1)[0], G;
47127
- if (m = he, this.options.pedantic ? (m = m.replace(this.rules.other.listReplaceNesting, " "), G = m) : G = m.replace(this.rules.other.leadingSpaceTab, (Ae) => X(Ae)), pe.test(m) || ce.test(m) || $e.test(m) || Le.test(m) || W.test(m) || ue.test(m))
47264
+ let U = e.split(`
47265
+ `, 1)[0], Z;
47266
+ if (f = U, this.options.pedantic ? (f = f.replace(this.rules.other.listReplaceNesting, " "), Z = f) : Z = f.replace(this.rules.other.leadingSpaceTab, (me) => J(me)), ee.test(f) || te.test(f) || M.test(f) || ne.test(f) || v.test(f) || Q.test(f))
47128
47267
  break;
47129
- if (G.search(this.rules.other.nonSpaceChar) >= b || !m.trim())
47268
+ if (Z.search(this.rules.other.nonSpaceChar) >= R || !f.trim())
47130
47269
  d += `
47131
- ` + G.slice(b);
47270
+ ` + Z.slice(R);
47132
47271
  else {
47133
- if (E || R.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || pe.test(R) || ce.test(R) || ue.test(R))
47272
+ if (y || m.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ee.test(m) || te.test(m) || M.test(m) || Q.test(m))
47134
47273
  break;
47274
+ let qe = !this.options.pedantic && /^ {0,3}(?:=+|-+) *$/.test(f) && this.rules.block.lheading.test(`${m}
47275
+ ${f}`) ? ` ${Z.replace(/^ {0,3}/, "")}` : f;
47135
47276
  d += `
47136
- ` + m;
47277
+ ` + qe;
47137
47278
  }
47138
- E = !m.trim(), e = e.substring(he.length + 1), R = G.slice(b);
47279
+ y = !f.trim(), e = e.substring(U.length + 1), m = Z.slice(R);
47139
47280
  }
47140
47281
  }
47141
- let H = n.slice(g, i());
47142
- s.loose || (u ? s.loose = true : this.rules.other.doubleBlankLine.test(H) && (u = true)), s.items.push({ type: "list_item", raw: H, task: !!this.options.gfm && this.rules.other.listIsTask.test(d), loose: false, text: d, tokens: [] });
47282
+ let A = n.slice(k, s());
47283
+ i.loose || (p ? i.loose = true : this.rules.other.doubleBlankLine.test(A) && (p = true)), i.items.push({ type: "list_item", raw: A, task: !!this.options.gfm && this.rules.other.listIsTask.test(d), loose: false, text: d, tokens: [] });
47143
47284
  }
47144
- let c = s.items.at(-1);
47145
- if (c)
47146
- c.raw = c.raw.trimEnd(), c.text = c.text.trimEnd();
47285
+ let h = i.items.at(-1);
47286
+ if (h)
47287
+ h.raw = h.raw.trimEnd(), h.text = h.text.trimEnd();
47147
47288
  else
47148
47289
  return;
47149
- s.raw = n.slice(0, i()).trimEnd();
47150
- for (let p of s.items)
47151
- if (this.lexer.state.top = false, p.tokens = this.lexer.blockTokens(p.text, []), !s.loose) {
47152
- let d = p.tokens.filter((k) => k.type === "space"), g = d.length > 0 && d.some((k) => this.rules.other.anyLine.test(k.raw));
47153
- s.loose = g;
47154
- }
47155
- for (let p of s.items) {
47156
- let d = p.tokens[0];
47157
- if (p.task && (d?.type === "text" || d?.type === "paragraph")) {
47158
- p.text = p.text.replace(this.rules.other.listReplaceTask, ""), d.raw = d.raw.replace(this.rules.other.listReplaceTask, ""), d.text = d.text.replace(this.rules.other.listReplaceTask, "");
47159
- for (let k = this.lexer.inlineQueue.length - 1;k >= 0; k--)
47160
- if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
47161
- this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
47290
+ i.raw = n.slice(0, s()).trimEnd();
47291
+ for (let u of i.items)
47292
+ if (this.lexer.state.top = false, u.tokens = this.lexer.blockTokens(u.text, []), !i.loose) {
47293
+ let d = u.tokens.filter((g) => g.type === "space"), k = d.length > 0 && d.some((g) => this.rules.other.anyLine.test(g.raw));
47294
+ i.loose = k;
47295
+ }
47296
+ for (let u of i.items) {
47297
+ let d = u.tokens[0];
47298
+ if (u.task && (d?.type === "text" || d?.type === "paragraph")) {
47299
+ u.text = u.text.replace(this.rules.other.listReplaceTask, ""), d.raw = d.raw.replace(this.rules.other.listReplaceTask, ""), d.text = d.text.replace(this.rules.other.listReplaceTask, "");
47300
+ for (let g = this.lexer.inlineQueue.length - 1;g >= 0; g--)
47301
+ if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[g].src)) {
47302
+ this.lexer.inlineQueue[g].src = this.lexer.inlineQueue[g].src.replace(this.rules.other.listReplaceTask, "");
47162
47303
  break;
47163
47304
  }
47164
- let g = this.rules.other.listTaskCheckbox.exec(p.raw);
47165
- if (g) {
47166
- let k = { type: "checkbox", raw: g[0] + " ", checked: g[0] !== "[ ]" };
47167
- p.checked = k.checked, s.loose ? p.tokens[0] && ["paragraph", "text"].includes(p.tokens[0].type) && "tokens" in p.tokens[0] && p.tokens[0].tokens ? (p.tokens[0].raw = k.raw + p.tokens[0].raw, p.tokens[0].text = k.raw + p.tokens[0].text, p.tokens[0].tokens.unshift(k)) : p.tokens.unshift({ type: "paragraph", raw: k.raw, text: k.raw, tokens: [k] }) : p.tokens.unshift(k);
47305
+ let k = this.rules.other.listTaskCheckbox.exec(u.raw);
47306
+ if (k) {
47307
+ let g = { type: "checkbox", raw: k[0] + " ", checked: k[0] !== "[ ]" };
47308
+ u.checked = g.checked, i.loose ? u.tokens[0] && ["paragraph", "text"].includes(u.tokens[0].type) && "tokens" in u.tokens[0] && u.tokens[0].tokens ? (u.tokens[0].raw = g.raw + u.tokens[0].raw, u.tokens[0].text = g.raw + u.tokens[0].text, u.tokens[0].tokens.unshift(g)) : u.tokens.unshift({ type: "paragraph", raw: g.raw, text: g.raw, tokens: [g] }) : u.tokens.unshift(g);
47168
47309
  }
47169
47310
  } else
47170
- p.task && (p.task = false);
47311
+ u.task && (u.task = false);
47171
47312
  }
47172
- if (s.loose)
47173
- for (let p of s.items) {
47174
- p.loose = true;
47175
- for (let d of p.tokens)
47313
+ if (i.loose)
47314
+ for (let u of i.items) {
47315
+ u.loose = true;
47316
+ for (let d of u.tokens)
47176
47317
  d.type === "text" && (d.type = "paragraph");
47177
47318
  }
47178
- return s;
47319
+ return i;
47179
47320
  }
47180
47321
  }
47181
47322
  html(e) {
47182
47323
  let t = this.rules.block.html.exec(e);
47183
47324
  if (t) {
47184
- let n = ae(t[0]);
47325
+ let n = ge(t[0]);
47185
47326
  return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
47186
47327
  }
47187
47328
  }
47188
47329
  def(e) {
47189
47330
  let t = this.rules.block.def.exec(e);
47190
47331
  if (t) {
47191
- if (!this.rules.other.startAngleBracket.test(t[2]) && le(t[2], "()") !== -1)
47332
+ if (!this.rules.other.startAngleBracket.test(t[2]) && ke(t[2], "()") !== -1)
47192
47333
  return;
47193
- let n = v(t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = 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];
47194
- return { type: "def", tag: n, raw: A(t[0], `
47195
- `), href: i, title: r };
47334
+ let n = F(t[1]), 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];
47335
+ return { type: "def", tag: n, raw: L(t[0], `
47336
+ `), href: s, title: r };
47196
47337
  }
47197
47338
  }
47198
47339
  table(e) {
47199
47340
  let t = this.rules.block.table.exec(e);
47200
47341
  if (!t || !this.rules.other.tableDelimiter.test(t[2]))
47201
47342
  return;
47202
- let n = oe(t[1]), i = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
47203
- `) : [], o = { type: "table", raw: A(t[0], `
47343
+ let n = de(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
47344
+ `) : [], o = { type: "table", raw: L(t[0], `
47204
47345
  `), header: [], align: [], rows: [] };
47205
- if (n.length === i.length) {
47206
- for (let s of i)
47207
- this.rules.other.tableAlignRight.test(s) ? o.align.push("right") : this.rules.other.tableAlignCenter.test(s) ? o.align.push("center") : this.rules.other.tableAlignLeft.test(s) ? o.align.push("left") : o.align.push(null);
47208
- for (let s = 0;s < n.length; s++)
47209
- o.header.push({ text: n[s], tokens: this.lexer.inline(n[s]), header: true, align: o.align[s] });
47210
- for (let s of r)
47211
- o.rows.push(oe(s, o.header.length).map((l, u) => ({ text: l, tokens: this.lexer.inline(l), header: false, align: o.align[u] })));
47346
+ if (n.length === s.length) {
47347
+ for (let i of s)
47348
+ this.rules.other.tableAlignRight.test(i) ? o.align.push("right") : this.rules.other.tableAlignCenter.test(i) ? o.align.push("center") : this.rules.other.tableAlignLeft.test(i) ? o.align.push("left") : o.align.push(null);
47349
+ for (let i = 0;i < n.length; i++)
47350
+ o.header.push({ text: n[i], tokens: this.lexer.inline(n[i]), header: true, align: o.align[i] });
47351
+ for (let i of r)
47352
+ o.rows.push(de(i, o.header.length).map((l, p) => ({ text: l, tokens: this.lexer.inline(l), header: false, align: o.align[p] })));
47212
47353
  return o;
47213
47354
  }
47214
47355
  }
@@ -47216,7 +47357,7 @@ ${H.join(`
47216
47357
  let t = this.rules.block.lheading.exec(e);
47217
47358
  if (t) {
47218
47359
  let n = t[1].trim();
47219
- return { type: "heading", raw: A(t[0], `
47360
+ return { type: "heading", raw: L(t[0], `
47220
47361
  `), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
47221
47362
  }
47222
47363
  }
@@ -47249,85 +47390,104 @@ ${H.join(`
47249
47390
  let t = this.rules.inline.link.exec(e);
47250
47391
  if (t) {
47251
47392
  let n = t[0].charAt(0) === "!" ? 2 : 1;
47252
- if (!this.options.pedantic && _e(e, t[1], n, this.rules))
47393
+ if (!this.options.pedantic && Be(e, t[1], n, this.rules))
47253
47394
  return;
47254
- let i = t[2].trim();
47255
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(i)) {
47256
- if (!this.rules.other.endAngleBracket.test(i))
47395
+ let s = t[2].trim();
47396
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(s)) {
47397
+ if (!this.rules.other.endAngleBracket.test(s))
47257
47398
  return;
47258
- let s = A(i.slice(0, -1), "\\");
47259
- if ((i.length - s.length) % 2 === 0)
47399
+ let l = L(s.slice(0, -1), "\\");
47400
+ if ((s.length - l.length) % 2 === 0)
47260
47401
  return;
47261
47402
  } else {
47262
- let s = le(t[2], "()");
47263
- if (s === -2)
47403
+ let l = ke(t[2], "()");
47404
+ if (l === -2)
47264
47405
  return;
47265
- if (s > -1) {
47266
- let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
47267
- t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, u).trim(), t[3] = "";
47406
+ if (l > -1) {
47407
+ let h = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + l;
47408
+ t[2] = t[2].substring(0, l), t[0] = t[0].substring(0, h).trim(), t[3] = "";
47268
47409
  }
47269
47410
  }
47270
- let r = t[2], o = "";
47411
+ let r = L(t[0].slice(0, -1), "\\");
47412
+ if ((t[0].length - r.length) % 2 === 0)
47413
+ return;
47414
+ let o = t[2], i = "";
47271
47415
  if (this.options.pedantic) {
47272
- let s = this.rules.other.pedanticHrefTitle.exec(r);
47273
- s && (r = s[1], o = s[3]);
47416
+ let l = this.rules.other.pedanticHrefTitle.exec(o);
47417
+ l && (o = l[1], i = l[3]);
47274
47418
  } else
47275
- o = t[3] ? t[3].slice(1, -1) : "";
47276
- return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(i) ? r = r.slice(1) : r = r.slice(1, -1)), Se(t, { href: r && r.replace(this.rules.inline.anyPunctuation, "$1"), title: o && o.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
47419
+ i = t[3] ? t[3].slice(1, -1) : "";
47420
+ return o = o.trim(), this.rules.other.startAngleBracket.test(o) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(s) ? o = o.slice(1) : o = o.slice(1, -1)), De(t, { href: o && o.replace(this.rules.inline.anyPunctuation, "$1"), title: i && i.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
47277
47421
  }
47278
47422
  }
47279
47423
  reflink(e, t) {
47280
47424
  let n;
47281
47425
  if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
47282
- let i = n[0].charAt(0) === "!" ? 2 : 1;
47283
- if (!this.options.pedantic && _e(e, n[1], i, this.rules))
47426
+ let s = n[0].charAt(0) === "!" ? 2 : 1;
47427
+ if (!this.options.pedantic && Be(e, n[1], s, this.rules))
47284
47428
  return;
47285
- let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), o = t[v(r)];
47286
- if (!o) {
47287
- let s = n[0].charAt(0);
47288
- return { type: "text", raw: s, text: s };
47429
+ let r = t[F(n[2] || n[1])];
47430
+ if (!r) {
47431
+ let o = n[0].charAt(0);
47432
+ return { type: "text", raw: o, text: o };
47289
47433
  }
47290
- return Se(n, o, n[0], this.lexer, this.rules);
47434
+ return De(n, r, n[0], this.lexer, this.rules);
47291
47435
  }
47292
47436
  }
47293
47437
  emStrong(e, t, n = "") {
47294
- let i = this.rules.inline.emStrongLDelim.exec(e);
47295
- if (!i || !i[1] && !i[2] && !i[3] && !i[4] || i[4] && n.match(this.rules.other.unicodeAlphaNumeric))
47438
+ let s = this.rules.inline.emStrongLDelim.exec(e);
47439
+ if (!s || !s[1] && !s[2] && !s[3] && !s[4])
47296
47440
  return;
47297
- if (!(i[1] || i[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
47298
- let o = [...i[0]].length - 1, s, l, u = o, c = 0, p = i[0][0], d = n === p, g = p === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
47299
- for (g.lastIndex = 0, t = t.slice(-1 * e.length + o);(i = g.exec(t)) !== null; ) {
47300
- if (s = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !s)
47441
+ let r = s[0][0], o = n === r, i = t.length - e.length, l = i;
47442
+ for (;!this.options.pedantic && l > 0 && t[l - 1] === r; )
47443
+ l--;
47444
+ let p = [...t.slice(Math.max(0, l - 2), l)].at(-1) ?? "", h = p === "*" || p === "_" || !!this.rules.inline.punctuation.exec(p);
47445
+ l < i && (n = p);
47446
+ let u = l < i ? h : !!this.rules.inline.punctuation.exec(n);
47447
+ if (s[4] && n.match(this.rules.other.unicodeAlphaNumeric))
47448
+ return;
47449
+ let d = s[1] || s[3] || "";
47450
+ if (!d || !n || u) {
47451
+ let k = [...s[0]].length - 1, g, b, m = k, f = 0, y = i - l + k, R = !this.options.pedantic && !!p.trim() && (!!d || r === "*" && !h);
47452
+ if (r !== "*" && r !== "_")
47453
+ return;
47454
+ let A = r === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd, v = ze(this, t, r), Q = t.length - e.length + k;
47455
+ if (v < Q)
47456
+ return;
47457
+ t = t.slice(-1 * e.length + k);
47458
+ let ee = v - Q;
47459
+ for (A.lastIndex = 0;(s = A.exec(t)) !== null && !(s.index > ee); ) {
47460
+ if (g = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !g)
47301
47461
  continue;
47302
- if (l = [...s].length, i[3] || i[4]) {
47303
- u += l;
47462
+ if (b = [...g].length, s[3] || s[4]) {
47463
+ m += b;
47304
47464
  continue;
47305
- } else if (i[5] || i[6]) {
47306
- if (o % 3 && !((o + l) % 3)) {
47307
- c += l;
47465
+ } else if (s[5] || s[6] || R) {
47466
+ if (o && (s[5] || s[6]))
47467
+ break;
47468
+ if (y % 3 && !((y + b) % 3)) {
47469
+ f += b;
47308
47470
  continue;
47309
47471
  }
47310
- if (d)
47311
- break;
47312
47472
  }
47313
- if (u -= l, u > 0)
47473
+ if (m -= b, m > 0)
47314
47474
  continue;
47315
- l = Math.min(l, l + u + c);
47316
- let k = [...i[0]][0].length, P = e.slice(0, o + i.index + k + l);
47317
- if (Math.min(o, l) % 2) {
47318
- let m = P.slice(1, -1);
47319
- return { type: "em", raw: P, text: m, tokens: this.lexer.inlineTokens(m) };
47475
+ b = Math.min(b, b + m + f);
47476
+ let te = [...s[0]][0].length, M = e.slice(0, k + s.index + te + b);
47477
+ if (Math.min(k, b) % 2) {
47478
+ let U = M.slice(1, -1);
47479
+ return { type: "em", raw: M, text: U, tokens: this.lexer.inlineTokens(U) };
47320
47480
  }
47321
- let R = P.slice(2, -2);
47322
- return { type: "strong", raw: P, text: R, tokens: this.lexer.inlineTokens(R) };
47481
+ let ne = M.slice(2, -2);
47482
+ return { type: "strong", raw: M, text: ne, tokens: this.lexer.inlineTokens(ne) };
47323
47483
  }
47324
47484
  }
47325
47485
  }
47326
47486
  codespan(e) {
47327
47487
  let t = this.rules.inline.code.exec(e);
47328
47488
  if (t) {
47329
- let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), i = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
47330
- return i && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
47489
+ 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);
47490
+ return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
47331
47491
  }
47332
47492
  }
47333
47493
  br(e) {
@@ -47336,70 +47496,74 @@ ${H.join(`
47336
47496
  return { type: "br", raw: t[0] };
47337
47497
  }
47338
47498
  del(e, t, n = "") {
47339
- let i = this.rules.inline.delLDelim.exec(e);
47340
- if (!i)
47499
+ let s = this.rules.inline.delLDelim.exec(e);
47500
+ if (!s)
47341
47501
  return;
47342
- if (!(i[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
47343
- let o = [...i[0]].length - 1, s, l, u = o, c = this.rules.inline.delRDelim;
47344
- for (c.lastIndex = 0, t = t.slice(-1 * e.length + o);(i = c.exec(t)) !== null; ) {
47345
- if (s = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !s || (l = [...s].length, l !== o))
47502
+ if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
47503
+ let o = [...s[0]].length - 1, i, l, p = o, h = this.rules.inline.delRDelim, u = Me(this, t), d = t.length - e.length + o;
47504
+ if (u < d)
47505
+ return;
47506
+ t = t.slice(-1 * e.length + o);
47507
+ let k = u - d;
47508
+ for (h.lastIndex = 0;(s = h.exec(t)) !== null && !(s.index > k); ) {
47509
+ if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (l = [...i].length, l !== o))
47346
47510
  continue;
47347
- if (i[3] || i[4]) {
47348
- u += l;
47511
+ if (s[3] || s[4]) {
47512
+ p += l;
47349
47513
  continue;
47350
47514
  }
47351
- if (u -= l, u > 0)
47515
+ if (p -= l, p > 0)
47352
47516
  continue;
47353
- l = Math.min(l, l + u);
47354
- let p = [...i[0]][0].length, d = e.slice(0, o + i.index + p + l), g = d.slice(o, -o);
47355
- return { type: "del", raw: d, text: g, tokens: this.lexer.inlineTokens(g) };
47517
+ l = Math.min(l, l + p);
47518
+ let g = [...s[0]][0].length, b = e.slice(0, o + s.index + g + l), m = b.slice(o, -o);
47519
+ return { type: "del", raw: b, text: m, tokens: this.lexer.inlineTokens(m) };
47356
47520
  }
47357
47521
  }
47358
47522
  }
47359
47523
  autolink(e) {
47360
47524
  let t = this.rules.inline.autolink.exec(e);
47361
47525
  if (t) {
47362
- let n, i;
47363
- return t[2] === "@" ? (n = t[1], i = "mailto:" + n) : (n = t[1], i = n), { type: "link", raw: t[0], text: n, href: i, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
47526
+ let n, s;
47527
+ return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
47364
47528
  }
47365
47529
  }
47366
47530
  url(e) {
47367
47531
  let t;
47368
47532
  if (t = this.rules.inline.url.exec(e)) {
47369
- let n, i;
47533
+ let n, s;
47370
47534
  if (t[2] === "@")
47371
- n = t[0], i = "mailto:" + n;
47535
+ n = t[0], s = "mailto:" + n;
47372
47536
  else {
47373
47537
  let r;
47374
47538
  do
47375
47539
  r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
47376
47540
  while (r !== t[0]);
47377
- n = t[0], t[1] === "www." ? i = "http://" + t[0] : i = t[0];
47541
+ n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
47378
47542
  }
47379
- return { type: "link", raw: t[0], text: n, href: i, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
47543
+ return { type: "link", raw: t[0], text: n, href: s, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
47380
47544
  }
47381
47545
  }
47382
47546
  inlineText(e) {
47383
47547
  let t = this.rules.inline.text.exec(e);
47384
47548
  if (t) {
47385
47549
  let n = this.lexer.state.inRawBlock;
47386
- return { type: "text", raw: t[0], text: n ? t[0] : ye(t[0]), escaped: n };
47550
+ return { type: "text", raw: t[0], text: n ? t[0] : Ie(t[0]), escaped: n };
47387
47551
  }
47388
47552
  }
47389
47553
  };
47390
- var T = class a {
47554
+ var O = class a {
47391
47555
  tokens;
47392
47556
  options;
47393
47557
  state;
47394
47558
  inlineQueue;
47395
47559
  tokenizer;
47396
47560
  constructor(e) {
47397
- this.tokens = [], this.tokens.links = Object.create(null), this.options = e || y, this.options.tokenizer = this.options.tokenizer || new _, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, linkParenPossible: true, top: true };
47398
- let t = { other: x, block: F.normal, inline: Z.normal };
47399
- this.options.pedantic ? (t.block = F.pedantic, t.inline = Z.pedantic) : this.options.gfm && (t.block = F.gfm, this.options.breaks ? t.inline = Z.breaks : t.inline = Z.gfm), this.tokenizer.rules = t;
47561
+ this.tokens = [], this.tokens.links = Object.create(null), this.options = e || S, this.options.tokenizer = this.options.tokenizer || new _, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, linkParenPossible: true, top: true };
47562
+ let t = { other: T, block: V.normal, inline: G.normal };
47563
+ this.options.pedantic ? (t.block = V.pedantic, t.inline = G.pedantic) : this.options.gfm && (t.block = V.gfm, this.options.breaks ? t.inline = G.breaks : t.inline = G.gfm), this.tokenizer.rules = t;
47400
47564
  }
47401
47565
  static get rules() {
47402
- return { block: F, inline: Z };
47566
+ return { block: V, inline: G };
47403
47567
  }
47404
47568
  static lex(e, t) {
47405
47569
  return new a(t).lex(e);
@@ -47408,41 +47572,41 @@ var T = class a {
47408
47572
  return new a(t).inlineTokens(e);
47409
47573
  }
47410
47574
  lex(e) {
47411
- e = e.replace(x.carriageReturn, `
47575
+ e = e.replace(T.carriageReturn, `
47412
47576
  `), this.blockTokens(e, this.tokens);
47413
47577
  for (let t = 0;t < this.inlineQueue.length; t++) {
47414
47578
  let n = this.inlineQueue[t];
47415
- this.inlineTokens(n.src, n.tokens);
47579
+ this.state.inRawBlock = false, this.inlineTokens(n.src, n.tokens);
47416
47580
  }
47417
47581
  return this.inlineQueue = [], this.tokens;
47418
47582
  }
47419
47583
  blockTokens(e, t = [], n = false) {
47420
- this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(x.tabCharGlobal, " ").replace(x.spaceLine, ""));
47421
- let i = 1 / 0;
47584
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(T.tabCharGlobal, " ").replace(T.spaceLine, ""));
47585
+ let s = 1 / 0;
47422
47586
  for (;e; ) {
47423
- if (e.length < i)
47424
- i = e.length;
47587
+ if (e.length < s)
47588
+ s = e.length;
47425
47589
  else {
47426
47590
  this.infiniteLoopError(e.charCodeAt(0));
47427
47591
  break;
47428
47592
  }
47429
47593
  let r;
47430
- if (this.options.extensions?.block?.some((s) => (r = s.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false))
47594
+ if (this.options.extensions?.block?.some((i) => (r = i.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false))
47431
47595
  continue;
47432
47596
  if (r = this.tokenizer.space(e)) {
47433
47597
  e = e.substring(r.raw.length);
47434
- let s = t.at(-1);
47435
- r.raw.length === 1 && s !== undefined ? s.raw += `
47598
+ let i = t.at(-1);
47599
+ r.raw.length === 1 && i !== undefined ? i.raw += `
47436
47600
  ` : t.push(r);
47437
47601
  continue;
47438
47602
  }
47439
47603
  if (r = this.tokenizer.code(e)) {
47440
47604
  e = e.substring(r.raw.length);
47441
- let s = t.at(-1);
47442
- s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(`
47605
+ let i = t.at(-1);
47606
+ i?.type === "paragraph" || i?.type === "text" ? (i.raw += (i.raw.endsWith(`
47443
47607
  `) ? "" : `
47444
- `) + r.raw, s.text += `
47445
- ` + r.text, this.inlineQueue.at(-1).src = s.text) : t.push(r);
47608
+ `) + r.raw, i.text += `
47609
+ ` + r.text, this.inlineQueue.at(-1).src = i.text) : t.push(r);
47446
47610
  continue;
47447
47611
  }
47448
47612
  if (r = this.tokenizer.fences(e)) {
@@ -47471,11 +47635,11 @@ var T = class a {
47471
47635
  }
47472
47636
  if (r = this.tokenizer.def(e)) {
47473
47637
  e = e.substring(r.raw.length);
47474
- let s = t.at(-1);
47475
- s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(`
47638
+ let i = t.at(-1);
47639
+ i?.type === "paragraph" || i?.type === "text" ? (i.raw += (i.raw.endsWith(`
47476
47640
  `) ? "" : `
47477
- `) + r.raw, s.text += `
47478
- ` + r.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
47641
+ `) + r.raw, i.text += `
47642
+ ` + r.raw, this.inlineQueue.at(-1).src = i.text) : (this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }), t.push(r));
47479
47643
  continue;
47480
47644
  }
47481
47645
  if (r = this.tokenizer.table(e)) {
@@ -47488,26 +47652,26 @@ var T = class a {
47488
47652
  }
47489
47653
  let o = e;
47490
47654
  if (this.options.extensions?.startBlock) {
47491
- let s = 1 / 0, l = e.slice(1), u;
47492
- this.options.extensions.startBlock.forEach((c) => {
47493
- u = c.call({ lexer: this }, l), typeof u == "number" && u >= 0 && (s = Math.min(s, u));
47494
- }), s < 1 / 0 && s >= 0 && (o = e.substring(0, s + 1));
47655
+ let i = 1 / 0, l = e.slice(1), p;
47656
+ this.options.extensions.startBlock.forEach((h) => {
47657
+ p = h.call({ lexer: this }, l), typeof p == "number" && p >= 0 && (i = Math.min(i, p));
47658
+ }), i < 1 / 0 && i >= 0 && (o = e.substring(0, i + 1));
47495
47659
  }
47496
47660
  if (this.state.top && (r = this.tokenizer.paragraph(o))) {
47497
- let s = t.at(-1);
47498
- n && s?.type === "paragraph" ? (s.raw += (s.raw.endsWith(`
47661
+ let i = t.at(-1);
47662
+ n && i?.type === "paragraph" ? (i.raw += (i.raw.endsWith(`
47499
47663
  `) ? "" : `
47500
- `) + r.raw, s.text += `
47501
- ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r), n = o.length !== e.length, e = e.substring(r.raw.length);
47664
+ `) + r.raw, i.text += `
47665
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = i.text) : t.push(r), n = o.length !== e.length, e = e.substring(r.raw.length);
47502
47666
  continue;
47503
47667
  }
47504
47668
  if (r = this.tokenizer.text(e)) {
47505
47669
  e = e.substring(r.raw.length);
47506
- let s = t.at(-1);
47507
- s?.type === "text" ? (s.raw += (s.raw.endsWith(`
47670
+ let i = t.at(-1);
47671
+ i?.type === "text" ? (i.raw += (i.raw.endsWith(`
47508
47672
  `) ? "" : `
47509
- `) + r.raw, s.text += `
47510
- ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r);
47673
+ `) + r.raw, i.text += `
47674
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = i.text) : t.push(r);
47511
47675
  continue;
47512
47676
  }
47513
47677
  if (e) {
@@ -47528,8 +47692,8 @@ var T = class a {
47528
47692
  if (t.test(n[0]) && e.charAt(n.index - 1) !== "!")
47529
47693
  return true;
47530
47694
  for (let n of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
47531
- let i = n[0], r = i.lastIndexOf("[");
47532
- if (!(i.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, v(i.slice(r + 1, -1)))) && !(r > 1 && this.linkInText(i.slice(1, r - 1))))
47695
+ let s = n[0], r = s.lastIndexOf("[");
47696
+ if (!(s.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, F(s.slice(r + 1, -1)))) && !(r > 1 && this.linkInText(s.slice(1, r - 1))))
47533
47697
  return true;
47534
47698
  }
47535
47699
  return false;
@@ -47545,26 +47709,16 @@ var T = class a {
47545
47709
  }
47546
47710
  }
47547
47711
  #e(e, t) {
47548
- let n = e;
47549
- if (this.tokens.links && e.includes("[")) {
47550
- let s = this.tokenizer.rules.inline.reflinkSearch, l = (u) => {
47551
- let c = u.lastIndexOf("[");
47552
- if (!Object.hasOwn(this.tokens.links, v(u.slice(c + 1, -1))))
47553
- return u;
47554
- if (c > 1 && u.charAt(0) !== "!") {
47555
- let p = u.slice(1, c - 1);
47556
- if (this.linkInText(p))
47557
- return "[" + p.replace(s, l) + "][" + "a".repeat(u.length - c - 2) + "]";
47558
- }
47559
- return "[" + "a".repeat(u.length - 2) + "]";
47560
- };
47561
- n = n.replace(s, l);
47712
+ let n = e.includes("*") || e.includes("_") || e.includes("~") || this.options.hooks?.emStrongMask || this.tokenizer.emStrong !== _.prototype.emStrong || this.tokenizer.del !== _.prototype.del ? this.#n(e) : e;
47713
+ Ae(this.tokenizer, n);
47714
+ try {
47715
+ return this.#t(e, n, t);
47716
+ } finally {
47717
+ Ee(this.tokenizer);
47562
47718
  }
47563
- n = n.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode, (s, l, u) => u ? "+".repeat(s.length) : l ? l + s.slice(l.length, -l.length).replace(/`/g, "+") + l : s), n = n.replace(this.tokenizer.rules.inline.blockSkip, (s, l, u) => {
47564
- let c = u ? u.length : 0;
47565
- return s.slice(0, c) + "[" + "a".repeat(s.length - c - 2) + "]";
47566
- }), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
47567
- let i = false, r = "", o = 1 / 0;
47719
+ }
47720
+ #t(e, t, n) {
47721
+ let s = false, r = "", o = 1 / 0;
47568
47722
  for (;e; ) {
47569
47723
  if (e.length < o)
47570
47724
  o = e.length;
@@ -47572,63 +47726,63 @@ var T = class a {
47572
47726
  this.infiniteLoopError(e.charCodeAt(0));
47573
47727
  break;
47574
47728
  }
47575
- i || (r = ""), i = false;
47576
- let s;
47577
- if (this.options.extensions?.inline?.some((u) => (s = u.call({ lexer: this }, e, t)) ? (e = e.substring(s.raw.length), t.push(s), true) : false))
47729
+ s || (r = ""), s = false;
47730
+ let i;
47731
+ if (this.options.extensions?.inline?.some((p) => (i = p.call({ lexer: this }, e, n)) ? (e = e.substring(i.raw.length), n.push(i), true) : false))
47578
47732
  continue;
47579
- if (s = this.tokenizer.escape(e)) {
47580
- e = e.substring(s.raw.length), t.push(s);
47733
+ if (i = this.tokenizer.escape(e)) {
47734
+ e = e.substring(i.raw.length), n.push(i);
47581
47735
  continue;
47582
47736
  }
47583
- if (s = this.tokenizer.tag(e)) {
47584
- e = e.substring(s.raw.length), t.push(s);
47737
+ if (i = this.tokenizer.tag(e)) {
47738
+ e = e.substring(i.raw.length), n.push(i);
47585
47739
  continue;
47586
47740
  }
47587
- if (s = this.tokenizer.link(e)) {
47588
- e = e.substring(s.raw.length), t.push(s);
47741
+ if (i = this.tokenizer.link(e)) {
47742
+ e = e.substring(i.raw.length), n.push(i);
47589
47743
  continue;
47590
47744
  }
47591
- if (s = this.tokenizer.reflink(e, this.tokens.links)) {
47592
- e = e.substring(s.raw.length);
47593
- let u = t.at(-1);
47594
- s.type === "text" && u?.type === "text" ? (u.raw += s.raw, u.text += s.text) : t.push(s);
47745
+ if (i = this.tokenizer.reflink(e, this.tokens.links)) {
47746
+ e = e.substring(i.raw.length);
47747
+ let p = n.at(-1);
47748
+ i.type === "text" && p?.type === "text" ? (p.raw += i.raw, p.text += i.text) : n.push(i);
47595
47749
  continue;
47596
47750
  }
47597
- if (s = this.tokenizer.emStrong(e, n, r)) {
47598
- e = e.substring(s.raw.length), t.push(s);
47751
+ if (i = this.tokenizer.emStrong(e, t, r)) {
47752
+ e = e.substring(i.raw.length), n.push(i);
47599
47753
  continue;
47600
47754
  }
47601
- if (s = this.tokenizer.codespan(e)) {
47602
- e = e.substring(s.raw.length), t.push(s);
47755
+ if (i = this.tokenizer.codespan(e)) {
47756
+ e = e.substring(i.raw.length), n.push(i);
47603
47757
  continue;
47604
47758
  }
47605
- if (s = this.tokenizer.br(e)) {
47606
- e = e.substring(s.raw.length), t.push(s);
47759
+ if (i = this.tokenizer.br(e)) {
47760
+ e = e.substring(i.raw.length), n.push(i);
47607
47761
  continue;
47608
47762
  }
47609
- if (s = this.tokenizer.del(e, n, r)) {
47610
- e = e.substring(s.raw.length), t.push(s);
47763
+ if (i = this.tokenizer.del(e, t, r)) {
47764
+ e = e.substring(i.raw.length), n.push(i);
47611
47765
  continue;
47612
47766
  }
47613
- if (s = this.tokenizer.autolink(e)) {
47614
- e = e.substring(s.raw.length), t.push(s);
47767
+ if (i = this.tokenizer.autolink(e)) {
47768
+ e = e.substring(i.raw.length), n.push(i);
47615
47769
  continue;
47616
47770
  }
47617
- if (!this.state.inLink && (s = this.tokenizer.url(e))) {
47618
- e = e.substring(s.raw.length), t.push(s);
47771
+ if (!this.state.inLink && (i = this.tokenizer.url(e))) {
47772
+ e = e.substring(i.raw.length), n.push(i);
47619
47773
  continue;
47620
47774
  }
47621
47775
  let l = e;
47622
47776
  if (this.options.extensions?.startInline) {
47623
- let u = 1 / 0, c = e.slice(1), p;
47777
+ let p = 1 / 0, h = e.slice(1), u;
47624
47778
  this.options.extensions.startInline.forEach((d) => {
47625
- p = d.call({ lexer: this }, c), typeof p == "number" && p >= 0 && (u = Math.min(u, p));
47626
- }), u < 1 / 0 && u >= 0 && (l = e.substring(0, u + 1));
47779
+ u = d.call({ lexer: this }, h), typeof u == "number" && u >= 0 && (p = Math.min(p, u));
47780
+ }), p < 1 / 0 && p >= 0 && (l = e.substring(0, p + 1));
47627
47781
  }
47628
- if (s = this.tokenizer.inlineText(l)) {
47629
- e = e.substring(s.raw.length), s.raw.slice(-1) !== "_" && (r = s.raw.slice(-1)), i = true;
47630
- let u = t.at(-1);
47631
- u?.type === "text" ? (u.raw += s.raw, u.text += s.text) : t.push(s);
47782
+ if (i = this.tokenizer.inlineText(l)) {
47783
+ e = e.substring(i.raw.length), i.raw.slice(-1) !== "_" && (r = i.raw.slice(-1)), s = true;
47784
+ let p = n.at(-1);
47785
+ p?.type === "text" ? (p.raw += i.raw, p.text += i.text) : n.push(i);
47632
47786
  continue;
47633
47787
  }
47634
47788
  if (e) {
@@ -47636,7 +47790,28 @@ var T = class a {
47636
47790
  break;
47637
47791
  }
47638
47792
  }
47639
- return t;
47793
+ return n;
47794
+ }
47795
+ #n(e) {
47796
+ let t = e;
47797
+ if (this.tokens.links && e.includes("[")) {
47798
+ let n = this.tokenizer.rules.inline.reflinkSearch, s = (r) => {
47799
+ let o = r.lastIndexOf("[");
47800
+ if (!Object.hasOwn(this.tokens.links, F(r.slice(o + 1, -1))))
47801
+ return r;
47802
+ if (o > 1 && r.charAt(0) !== "!") {
47803
+ let i = r.slice(1, o - 1);
47804
+ if (this.linkInText(i))
47805
+ return "[" + i.replace(n, s) + "][" + "a".repeat(r.length - o - 2) + "]";
47806
+ }
47807
+ return "[" + "a".repeat(r.length - 2) + "]";
47808
+ };
47809
+ t = t.replace(n, s);
47810
+ }
47811
+ return t = t.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode, (n, s, r) => r ? "+".repeat(n.length) : s ? s + n.slice(s.length, -s.length).replace(/`/g, "+") + s : n), t = t.replace(this.tokenizer.rules.inline.blockSkip, (n, s, r) => {
47812
+ let o = r ? r.length : 0;
47813
+ return n.slice(0, o) + "[" + "a".repeat(n.length - o - 2) + "]";
47814
+ }), t = this.options.hooks?.emStrongMask?.call({ lexer: this }, t) ?? t, t;
47640
47815
  }
47641
47816
  infiniteLoopError(e) {
47642
47817
  let t = "Infinite loop on byte: " + e;
@@ -47646,20 +47821,20 @@ var T = class a {
47646
47821
  throw new Error(t);
47647
47822
  }
47648
47823
  };
47649
- var $ = class {
47824
+ var C = class {
47650
47825
  options;
47651
47826
  parser;
47652
47827
  constructor(e) {
47653
- this.options = e || y;
47828
+ this.options = e || S;
47654
47829
  }
47655
47830
  space(e) {
47656
47831
  return "";
47657
47832
  }
47658
47833
  code({ text: e, lang: t, escaped: n }) {
47659
- let i = (t || "").match(x.notSpaceStart)?.[0], r = e ? e.replace(x.endingNewline, "") + `
47834
+ let s = (t || "").match(T.notSpaceStart)?.[0], r = e ? e.replace(T.endingNewline, "") + `
47660
47835
  ` : "";
47661
- return i ? '<pre><code class="language-' + w(i) + '">' + (n ? r : w(r, true)) + `</code></pre>
47662
- ` : "<pre><code>" + (n ? r : w(r, true)) + `</code></pre>
47836
+ return s ? '<pre><code class="language-' + P(s) + '">' + (n ? r : P(r, true)) + `</code></pre>
47837
+ ` : "<pre><code>" + (n ? r : P(r, true)) + `</code></pre>
47663
47838
  `;
47664
47839
  }
47665
47840
  blockquote({ tokens: e }) {
@@ -47682,14 +47857,14 @@ ${this.parser.parse(e)}</blockquote>
47682
47857
  `;
47683
47858
  }
47684
47859
  list(e) {
47685
- let { ordered: t, start: n } = e, i = "";
47686
- for (let s = 0;s < e.items.length; s++) {
47687
- let l = e.items[s];
47688
- i += this.listitem(l);
47860
+ let { ordered: t, start: n } = e, s = "";
47861
+ for (let i = 0;i < e.items.length; i++) {
47862
+ let l = e.items[i];
47863
+ s += this.listitem(l);
47689
47864
  }
47690
47865
  let r = t ? "ol" : "ul", o = t && n !== 1 ? ' start="' + n + '"' : "";
47691
47866
  return "<" + r + o + `>
47692
- ` + i + "</" + r + `>
47867
+ ` + s + "</" + r + `>
47693
47868
  `;
47694
47869
  }
47695
47870
  listitem(e) {
@@ -47708,18 +47883,18 @@ ${this.parser.parse(e)}</blockquote>
47708
47883
  for (let r = 0;r < e.header.length; r++)
47709
47884
  n += this.tablecell(e.header[r]);
47710
47885
  t += this.tablerow({ text: n });
47711
- let i = "";
47886
+ let s = "";
47712
47887
  for (let r = 0;r < e.rows.length; r++) {
47713
47888
  let o = e.rows[r];
47714
47889
  n = "";
47715
- for (let s = 0;s < o.length; s++)
47716
- n += this.tablecell(o[s]);
47717
- i += this.tablerow({ text: n });
47890
+ for (let i = 0;i < o.length; i++)
47891
+ n += this.tablecell(o[i]);
47892
+ s += this.tablerow({ text: n });
47718
47893
  }
47719
- return i && (i = `<tbody>${i}</tbody>`), `<table>
47894
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
47720
47895
  <thead>
47721
47896
  ` + t + `</thead>
47722
- ` + i + `</table>
47897
+ ` + s + `</table>
47723
47898
  `;
47724
47899
  }
47725
47900
  tablerow({ text: e }) {
@@ -47739,7 +47914,7 @@ ${e}</tr>
47739
47914
  return `<em>${this.parser.parseInline(e)}</em>`;
47740
47915
  }
47741
47916
  codespan({ text: e }) {
47742
- return `<code>${w(e, true)}</code>`;
47917
+ return `<code>${P(e, true)}</code>`;
47743
47918
  }
47744
47919
  br(e) {
47745
47920
  return "<br>";
@@ -47747,39 +47922,40 @@ ${e}</tr>
47747
47922
  del({ tokens: e }) {
47748
47923
  return `<del>${this.parser.parseInline(e)}</del>`;
47749
47924
  }
47750
- link({ href: e, title: t, text: n, tokens: i, autolink: r }) {
47751
- let o = r ? w(n, true) : this.parser.parseInline(i), s = ie(e);
47752
- if (s === null)
47925
+ link({ href: e, title: t, text: n, tokens: s, autolink: r }) {
47926
+ let o = r ? P(n, true) : this.parser.parseInline(s), i = he(e);
47927
+ if (i === null)
47753
47928
  return o;
47754
- e = w(s, r);
47929
+ e = P(i, r);
47755
47930
  let l = '<a href="' + e + '"';
47756
- return t && (l += ' title="' + w(t) + '"'), l += ">" + o + "</a>", l;
47931
+ return t && (l += ' title="' + P(t) + '"'), l += ">" + o + "</a>", l;
47757
47932
  }
47758
- image({ href: e, title: t, text: n, tokens: i }) {
47759
- i && (n = this.parser.parseInline(i, this.parser.textRenderer));
47760
- let r = ie(e);
47933
+ image({ href: e, title: t, text: n, tokens: s }) {
47934
+ s && (n = this.parser.parseInline(s, this.parser.textRenderer));
47935
+ let r = he(e);
47761
47936
  if (r === null)
47762
- return w(n);
47937
+ return P(n);
47763
47938
  e = r;
47764
- let o = `<img src="${w(e)}" alt="${w(n)}"`;
47765
- return t && (o += ` title="${w(t)}"`), o += ">", o;
47939
+ let o = `<img src="${P(e)}" alt="${P(n)}"`;
47940
+ return t && (o += ` title="${P(t)}"`), o += ">", o;
47766
47941
  }
47767
47942
  text(e) {
47768
- return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : w(e.text);
47943
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : P(e.text);
47769
47944
  }
47770
47945
  };
47771
- var z = class {
47772
- strong({ text: e }) {
47773
- return e;
47946
+ var E = class {
47947
+ parser;
47948
+ strong({ text: e, tokens: t }) {
47949
+ return t ? this.parser.parseInline(t, this) : e;
47774
47950
  }
47775
- em({ text: e }) {
47776
- return e;
47951
+ em({ text: e, tokens: t }) {
47952
+ return t ? this.parser.parseInline(t, this) : e;
47777
47953
  }
47778
47954
  codespan({ text: e }) {
47779
47955
  return e;
47780
47956
  }
47781
- del({ text: e }) {
47782
- return e;
47957
+ del({ text: e, tokens: t }) {
47958
+ return t ? this.parser.parseInline(t, this) : e;
47783
47959
  }
47784
47960
  html({ text: e }) {
47785
47961
  return e;
@@ -47787,11 +47963,11 @@ var z = class {
47787
47963
  text({ text: e }) {
47788
47964
  return e;
47789
47965
  }
47790
- link({ text: e }) {
47791
- return "" + e;
47966
+ link({ text: e, tokens: t }) {
47967
+ return t ? this.parser.parseInline(t, this) : e;
47792
47968
  }
47793
- image({ text: e }) {
47794
- return "" + e;
47969
+ image({ text: e, tokens: t }) {
47970
+ return t ? this.parser.parseInline(t, this) : e;
47795
47971
  }
47796
47972
  br() {
47797
47973
  return "";
@@ -47800,12 +47976,12 @@ var z = class {
47800
47976
  return e;
47801
47977
  }
47802
47978
  };
47803
- var O = class a {
47979
+ var w = class a {
47804
47980
  options;
47805
47981
  renderer;
47806
47982
  textRenderer;
47807
47983
  constructor(e) {
47808
- this.options = e || y, this.options.renderer = this.options.renderer || new $, this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new z;
47984
+ this.options = e || S, this.options.renderer = this.options.renderer || new C, this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new E, this.textRenderer.parser = this;
47809
47985
  }
47810
47986
  static parse(e, t) {
47811
47987
  return new a(t).parse(e);
@@ -47817,15 +47993,15 @@ var O = class a {
47817
47993
  this.renderer.parser = this;
47818
47994
  let t = "";
47819
47995
  for (let n = 0;n < e.length; n++) {
47820
- let i = e[n];
47821
- if (this.options.extensions?.renderers?.[i.type]) {
47822
- let o = i, s = this.options.extensions.renderers[o.type].call({ parser: this }, o);
47823
- if (s !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(o.type)) {
47824
- t += s || "";
47996
+ let s = e[n];
47997
+ if (this.options.extensions?.renderers?.[s.type]) {
47998
+ let o = s, i = this.options.extensions.renderers[o.type].call({ parser: this }, o);
47999
+ if (i !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(o.type)) {
48000
+ t += i || "";
47825
48001
  continue;
47826
48002
  }
47827
48003
  }
47828
- let r = i;
48004
+ let r = s;
47829
48005
  switch (r.type) {
47830
48006
  case "space": {
47831
48007
  t += this.renderer.space(r);
@@ -47888,12 +48064,12 @@ var O = class a {
47888
48064
  parseInline(e, t = this.renderer) {
47889
48065
  this.renderer.parser = this;
47890
48066
  let n = "";
47891
- for (let i = 0;i < e.length; i++) {
47892
- let r = e[i];
48067
+ for (let s = 0;s < e.length; s++) {
48068
+ let r = e[s];
47893
48069
  if (this.options.extensions?.renderers?.[r.type]) {
47894
- let s = this.options.extensions.renderers[r.type].call({ parser: this }, r);
47895
- if (s !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
47896
- n += s || "";
48070
+ let i = this.options.extensions.renderers[r.type].call({ parser: this }, r);
48071
+ if (i !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
48072
+ n += i || "";
47897
48073
  continue;
47898
48074
  }
47899
48075
  }
@@ -47944,21 +48120,21 @@ var O = class a {
47944
48120
  break;
47945
48121
  }
47946
48122
  default: {
47947
- let s = 'Token with "' + o.type + '" type was not found.';
48123
+ let i = 'Token with "' + o.type + '" type was not found.';
47948
48124
  if (this.options.silent)
47949
- return console.error(s), "";
47950
- throw new Error(s);
48125
+ return console.error(i), "";
48126
+ throw new Error(i);
47951
48127
  }
47952
48128
  }
47953
48129
  }
47954
48130
  return n;
47955
48131
  }
47956
48132
  };
47957
- var L = class {
48133
+ var I = class {
47958
48134
  options;
47959
48135
  block;
47960
48136
  constructor(e) {
47961
- this.options = e || y;
48137
+ this.options = e || S;
47962
48138
  }
47963
48139
  static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
47964
48140
  static passThroughHooksRespectAsync = new Set(["preprocess", "postprocess", "processAllTokens"]);
@@ -47975,73 +48151,73 @@ var L = class {
47975
48151
  return e;
47976
48152
  }
47977
48153
  provideLexer(e = this.block) {
47978
- return e ? T.lex : T.lexInline;
48154
+ return e ? O.lex : O.lexInline;
47979
48155
  }
47980
48156
  provideParser(e = this.block) {
47981
- return e ? O.parse : O.parseInline;
48157
+ return e ? w.parse : w.parseInline;
47982
48158
  }
47983
48159
  };
47984
- function C(a, e) {
48160
+ function z(a, e) {
47985
48161
  if (Array.isArray(e))
47986
48162
  for (let t = 0;t < e.length; t++)
47987
48163
  a.push(e[t]);
47988
48164
  else
47989
48165
  a.push(e);
47990
48166
  }
47991
- var U = class {
47992
- defaults = B();
48167
+ var Y = class {
48168
+ defaults = H();
47993
48169
  options = this.setOptions;
47994
48170
  parse = this.parseMarkdown(true);
47995
48171
  parseInline = this.parseMarkdown(false);
47996
- Parser = O;
47997
- Renderer = $;
47998
- TextRenderer = z;
47999
- Lexer = T;
48172
+ Parser = w;
48173
+ Renderer = C;
48174
+ TextRenderer = E;
48175
+ Lexer = O;
48000
48176
  Tokenizer = _;
48001
- Hooks = L;
48177
+ Hooks = I;
48002
48178
  constructor(...e) {
48003
48179
  this.use(...e);
48004
48180
  }
48005
48181
  walkTokens(e, t) {
48006
48182
  let n = [];
48007
- for (let i of e)
48008
- switch (C(n, t.call(this, i)), i.type) {
48183
+ for (let s of e)
48184
+ switch (z(n, t.call(this, s)), s.type) {
48009
48185
  case "table": {
48010
- let r = i;
48186
+ let r = s;
48011
48187
  for (let o of r.header)
48012
- C(n, this.walkTokens(o.tokens, t));
48188
+ z(n, this.walkTokens(o.tokens, t));
48013
48189
  for (let o of r.rows)
48014
- for (let s of o)
48015
- C(n, this.walkTokens(s.tokens, t));
48190
+ for (let i of o)
48191
+ z(n, this.walkTokens(i.tokens, t));
48016
48192
  break;
48017
48193
  }
48018
48194
  case "list": {
48019
- let r = i;
48020
- C(n, this.walkTokens(r.items, t));
48195
+ let r = s;
48196
+ z(n, this.walkTokens(r.items, t));
48021
48197
  break;
48022
48198
  }
48023
48199
  default: {
48024
- let r = i;
48200
+ let r = s;
48025
48201
  this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((o) => {
48026
- let s = r[o].flat(1 / 0);
48027
- C(n, this.walkTokens(s, t));
48028
- }) : r.tokens && C(n, this.walkTokens(r.tokens, t));
48202
+ let i = r[o].flat(1 / 0);
48203
+ z(n, this.walkTokens(i, t));
48204
+ }) : r.tokens && z(n, this.walkTokens(r.tokens, t));
48029
48205
  }
48030
48206
  }
48031
48207
  return n;
48032
48208
  }
48033
48209
  use(...e) {
48034
- let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
48210
+ let t = this.defaults.extensions || { renderers: Object.create(null), childTokens: Object.create(null) };
48035
48211
  return e.forEach((n) => {
48036
- let i = { ...n };
48037
- if (i.async = this.defaults.async || i.async || false, n.extensions && (n.extensions.forEach((r) => {
48212
+ let s = { ...n };
48213
+ if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
48038
48214
  if (!r.name)
48039
48215
  throw new Error("extension name required");
48040
48216
  if ("renderer" in r) {
48041
48217
  let o = t.renderers[r.name];
48042
- o ? t.renderers[r.name] = function(...s) {
48043
- let l = r.renderer.apply(this, s);
48044
- return l === false && (l = o.apply(this, s)), l;
48218
+ o ? t.renderers[r.name] = function(...i) {
48219
+ let l = r.renderer.apply(this, i);
48220
+ return l === false && (l = o.apply(this, i)), l;
48045
48221
  } : t.renderers[r.name] = r.renderer;
48046
48222
  }
48047
48223
  if ("tokenizer" in r) {
@@ -48051,20 +48227,20 @@ var U = class {
48051
48227
  o ? o.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]));
48052
48228
  }
48053
48229
  "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
48054
- }), i.extensions = t), n.renderer) {
48055
- let r = this.defaults.renderer || new $(this.defaults);
48230
+ }), s.extensions = t), n.renderer) {
48231
+ let r = this.defaults.renderer || new C(this.defaults);
48056
48232
  for (let o in n.renderer) {
48057
48233
  if (!(o in r))
48058
48234
  throw new Error(`renderer '${o}' does not exist`);
48059
48235
  if (["options", "parser"].includes(o))
48060
48236
  continue;
48061
- let s = o, l = n.renderer[s], u = r[s];
48062
- r[s] = (...c) => {
48063
- let p = l.apply(r, c);
48064
- return p === false && (p = u.apply(r, c)), p || "";
48237
+ let i = o, l = n.renderer[i], p = r[i];
48238
+ r[i] = (...h) => {
48239
+ let u = l.apply(r, h);
48240
+ return u === false && (u = p.apply(r, h)), u === false ? "" : u ?? "";
48065
48241
  };
48066
48242
  }
48067
- i.renderer = r;
48243
+ s.renderer = r;
48068
48244
  }
48069
48245
  if (n.tokenizer) {
48070
48246
  let r = this.defaults.tokenizer || new _(this.defaults);
@@ -48073,85 +48249,85 @@ var U = class {
48073
48249
  throw new Error(`tokenizer '${o}' does not exist`);
48074
48250
  if (["options", "rules", "lexer"].includes(o))
48075
48251
  continue;
48076
- let s = o, l = n.tokenizer[s], u = r[s];
48077
- r[s] = (...c) => {
48078
- let p = l.apply(r, c);
48079
- return p === false && (p = u.apply(r, c)), p;
48252
+ let i = o, l = n.tokenizer[i], p = r[i];
48253
+ r[i] = (...h) => {
48254
+ let u = l.apply(r, h);
48255
+ return u === false && (u = p.apply(r, h)), u;
48080
48256
  };
48081
48257
  }
48082
- i.tokenizer = r;
48258
+ s.tokenizer = r;
48083
48259
  }
48084
48260
  if (n.hooks) {
48085
- let r = this.defaults.hooks || new L;
48261
+ let r = this.defaults.hooks || new I;
48086
48262
  for (let o in n.hooks) {
48087
48263
  if (!(o in r))
48088
48264
  throw new Error(`hook '${o}' does not exist`);
48089
48265
  if (["options", "block"].includes(o))
48090
48266
  continue;
48091
- let s = o, l = n.hooks[s], u = r[s];
48092
- L.passThroughHooks.has(o) ? r[s] = (c) => {
48093
- if (this.defaults.async && L.passThroughHooksRespectAsync.has(o))
48267
+ let i = o, l = n.hooks[i], p = r[i];
48268
+ I.passThroughHooks.has(o) ? r[i] = (h) => {
48269
+ if (r.options.async && I.passThroughHooksRespectAsync.has(o))
48094
48270
  return (async () => {
48095
- let d = await l.call(r, c);
48096
- return u.call(r, d);
48271
+ let d = await l.call(r, h);
48272
+ return p.call(r, d);
48097
48273
  })();
48098
- let p = l.call(r, c);
48099
- return u.call(r, p);
48100
- } : r[s] = (...c) => {
48101
- if (this.defaults.async)
48274
+ let u = l.call(r, h);
48275
+ return p.call(r, u);
48276
+ } : r[i] = (...h) => {
48277
+ if (r.options.async)
48102
48278
  return (async () => {
48103
- let d = await l.apply(r, c);
48104
- return d === false && (d = await u.apply(r, c)), d;
48279
+ let d = await l.apply(r, h);
48280
+ return d === false && (d = await p.apply(r, h)), d;
48105
48281
  })();
48106
- let p = l.apply(r, c);
48107
- return p === false && (p = u.apply(r, c)), p;
48282
+ let u = l.apply(r, h);
48283
+ return u === false && (u = p.apply(r, h)), u;
48108
48284
  };
48109
48285
  }
48110
- i.hooks = r;
48286
+ s.hooks = r;
48111
48287
  }
48112
48288
  if (n.walkTokens) {
48113
48289
  let r = this.defaults.walkTokens, o = n.walkTokens;
48114
- i.walkTokens = function(s) {
48290
+ s.walkTokens = function(i) {
48115
48291
  let l = [];
48116
- return l.push(o.call(this, s)), r && C(l, r.call(this, s)), l;
48292
+ return z(l, o.call(this, i)), r && z(l, r.call(this, i)), l;
48117
48293
  };
48118
48294
  }
48119
- this.defaults = { ...this.defaults, ...i };
48295
+ this.defaults = { ...this.defaults, ...s };
48120
48296
  }), this;
48121
48297
  }
48122
48298
  setOptions(e) {
48123
48299
  return this.defaults = { ...this.defaults, ...e }, this;
48124
48300
  }
48125
48301
  lexer(e, t) {
48126
- return T.lex(e, t ?? this.defaults);
48302
+ return O.lex(e, t ?? this.defaults);
48127
48303
  }
48128
48304
  parser(e, t) {
48129
- return O.parse(e, t ?? this.defaults);
48305
+ return w.parse(e, t ?? this.defaults);
48130
48306
  }
48131
48307
  parseMarkdown(e) {
48132
- return (n, i) => {
48133
- let r = { ...i }, o = { ...this.defaults, ...r }, s = this.onError(!!o.silent, !!o.async);
48308
+ return (n, s) => {
48309
+ let r = { ...s }, o = { ...this.defaults, ...r }, i = this.onError(!!o.silent, !!o.async);
48134
48310
  if (this.defaults.async === true && r.async === false)
48135
- return s(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."));
48311
+ return i(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."));
48136
48312
  if (typeof n > "u" || n === null)
48137
- return s(new Error("marked(): input parameter is undefined or null"));
48313
+ return i(new Error("marked(): input parameter is undefined or null"));
48138
48314
  if (typeof n != "string")
48139
- return s(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
48315
+ return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
48140
48316
  if (o.hooks && (o.hooks.options = o, o.hooks.block = e), o.async)
48141
48317
  return (async () => {
48142
- let l = o.hooks ? await o.hooks.preprocess(n) : n, c = await (o.hooks ? await o.hooks.provideLexer(e) : e ? T.lex : T.lexInline)(l, o), p = o.hooks ? await o.hooks.processAllTokens(c) : c;
48143
- o.walkTokens && await Promise.all(this.walkTokens(p, o.walkTokens));
48144
- let g = await (o.hooks ? await o.hooks.provideParser(e) : e ? O.parse : O.parseInline)(p, o);
48145
- return o.hooks ? await o.hooks.postprocess(g) : g;
48146
- })().catch(s);
48318
+ let l = o.hooks ? await o.hooks.preprocess(n) : n, h = await (o.hooks ? await o.hooks.provideLexer(e) : e ? O.lex : O.lexInline)(l, o), u = o.hooks ? await o.hooks.processAllTokens(h) : h;
48319
+ o.walkTokens && await Promise.all(this.walkTokens(u, o.walkTokens));
48320
+ let k = await (o.hooks ? await o.hooks.provideParser(e) : e ? w.parse : w.parseInline)(u, o);
48321
+ return o.hooks ? await o.hooks.postprocess(k) : k;
48322
+ })().catch(i);
48147
48323
  try {
48148
48324
  o.hooks && (n = o.hooks.preprocess(n));
48149
- let u = (o.hooks ? o.hooks.provideLexer(e) : e ? T.lex : T.lexInline)(n, o);
48150
- o.hooks && (u = o.hooks.processAllTokens(u)), o.walkTokens && this.walkTokens(u, o.walkTokens);
48151
- let p = (o.hooks ? o.hooks.provideParser(e) : e ? O.parse : O.parseInline)(u, o);
48152
- return o.hooks && (p = o.hooks.postprocess(p)), p;
48325
+ let p = (o.hooks ? o.hooks.provideLexer(e) : e ? O.lex : O.lexInline)(n, o);
48326
+ o.hooks && (p = o.hooks.processAllTokens(p)), o.walkTokens && this.walkTokens(p, o.walkTokens);
48327
+ let u = (o.hooks ? o.hooks.provideParser(e) : e ? w.parse : w.parseInline)(p, o);
48328
+ return o.hooks && (u = o.hooks.postprocess(u)), u;
48153
48329
  } catch (l) {
48154
- return s(l);
48330
+ return i(l);
48155
48331
  }
48156
48332
  };
48157
48333
  }
@@ -48159,8 +48335,8 @@ var U = class {
48159
48335
  return (n) => {
48160
48336
  if (n.message += `
48161
48337
  Please report this to https://github.com/markedjs/marked.`, e) {
48162
- let i = "<p>An error occurred:</p><pre>" + w(n.message + "", true) + "</pre>";
48163
- return t ? Promise.resolve(i) : i;
48338
+ let s = "<p>An error occurred:</p><pre>" + P(n.message + "", true) + "</pre>";
48339
+ return t ? Promise.resolve(s) : s;
48164
48340
  }
48165
48341
  if (t)
48166
48342
  return Promise.reject(n);
@@ -48168,38 +48344,38 @@ Please report this to https://github.com/markedjs/marked.`, e) {
48168
48344
  };
48169
48345
  }
48170
48346
  };
48171
- var I = new U;
48172
- function f(a, e) {
48173
- return I.parse(a, e);
48347
+ var q = new Y;
48348
+ function x(a, e) {
48349
+ return q.parse(a, e);
48174
48350
  }
48175
- f.options = f.setOptions = function(a) {
48176
- return I.setOptions(a), f.defaults = I.defaults, V(f.defaults), f;
48351
+ x.options = x.setOptions = function(a) {
48352
+ return q.setOptions(a), x.defaults = q.defaults, se(x.defaults), x;
48177
48353
  };
48178
- f.getDefaults = B;
48179
- f.defaults = y;
48180
- function At(...a) {
48181
- return I.use(...a), f.defaults = I.defaults, V(f.defaults), f;
48182
- }
48183
- f.use = At;
48184
- f.walkTokens = function(a, e) {
48185
- return I.walkTokens(a, e);
48354
+ x.getDefaults = H;
48355
+ x.defaults = S;
48356
+ function Bt(...a) {
48357
+ return q.use(...a), x.defaults = q.defaults, se(x.defaults), x;
48358
+ }
48359
+ x.use = Bt;
48360
+ x.walkTokens = function(a, e) {
48361
+ return q.walkTokens(a, e);
48186
48362
  };
48187
- f.parseInline = I.parseInline;
48188
- f.Parser = O;
48189
- f.parser = O.parse;
48190
- f.Renderer = $;
48191
- f.TextRenderer = z;
48192
- f.Lexer = T;
48193
- f.lexer = T.lex;
48194
- f.Tokenizer = _;
48195
- f.Hooks = L;
48196
- f.parse = f;
48197
- var Rn = f.options;
48198
- var Tn = f.setOptions;
48199
- var On = f.walkTokens;
48200
- var wn = f.parseInline;
48201
- var yn = O.parse;
48202
- var Sn = T.lex;
48363
+ x.parseInline = q.parseInline;
48364
+ x.Parser = w;
48365
+ x.parser = w.parse;
48366
+ x.Renderer = C;
48367
+ x.TextRenderer = E;
48368
+ x.Lexer = O;
48369
+ x.lexer = O.lex;
48370
+ x.Tokenizer = _;
48371
+ x.Hooks = I;
48372
+ x.parse = x;
48373
+ var _n = x.options;
48374
+ var $n = x.setOptions;
48375
+ var Ln = x.walkTokens;
48376
+ var Cn = x.parseInline;
48377
+ var An = w.parse;
48378
+ var En = O.lex;
48203
48379
 
48204
48380
  // src/plan/format.ts
48205
48381
  var PLAN_FORMAT_DENY_MESSAGE = "caret: this plan has a code block with no language marker, so it can't be " + "syntax-highlighted in the review UI. Add a language tag to every code block's " + "opening fence (e.g. ```ts, ```bash, ```json), and use `text` for non-code " + "blocks like directory trees, console output, or ASCII art. Then resubmit the plan.";
@@ -48207,7 +48383,7 @@ var PLAN_EMPTY_DENY_MESSAGE = "caret: no plan text reached caret, so there is no
48207
48383
  function hasUntaggedCodeBlock(plan) {
48208
48384
  if (!plan?.trim())
48209
48385
  return false;
48210
- const marked = new U({ gfm: true, breaks: false });
48386
+ const marked = new Y({ gfm: true, breaks: false });
48211
48387
  let untagged = false;
48212
48388
  marked.walkTokens(marked.lexer(plan), (token) => {
48213
48389
  if (token.type === "code" && !(token.lang ?? "").trim())
@@ -48413,6 +48589,9 @@ async function reviewHookInput(parsed, deps, readPlan) {
48413
48589
  const input = fromFile?.trim() ? { ...payload, plan: fromFile } : payload;
48414
48590
  return { decision: await runReview({ input }, deps), input };
48415
48591
  }
48592
+ function declareApproveVariants(input, adapterVariants) {
48593
+ return input.approveVariants ? input : { ...input, approveVariants: [...adapterVariants] };
48594
+ }
48416
48595
  async function runReviewSubcommand() {
48417
48596
  const loaded = loadSettings();
48418
48597
  bootHookLogging(loaded);
@@ -48441,7 +48620,7 @@ async function runReviewSubcommand() {
48441
48620
  deps.onPosted = (handle) => {
48442
48621
  posted = handle;
48443
48622
  };
48444
- const { decision: out, input } = await reviewHookInput(parseHook(adapter.parseHookInput, stdin), deps, readPlanFile);
48623
+ const { decision: out, input } = await reviewHookInput(parseHook((raw) => declareApproveVariants(adapter.parseHookInput(raw), adapter.approveVariants), stdin), deps, readPlanFile);
48445
48624
  hookInput = input;
48446
48625
  const target = notesAppendTarget(out, hookInput?.planFilePath, posted);
48447
48626
  if (target === "skip-moved-on") {
@@ -48471,18 +48650,19 @@ async function awaitPendingReview(deps, attempts = 25, intervalMs = 200) {
48471
48650
  return;
48472
48651
  }
48473
48652
  async function runBandLinkSubcommand(opts) {
48653
+ const { session } = opts;
48474
48654
  try {
48475
48655
  const s = loadSettings();
48476
48656
  bootHookLogging(s);
48477
48657
  setLogContext({ sessionId: opts.session });
48478
48658
  if (opts.open || s.review.band) {
48479
48659
  const baseUrl = daemonBaseUrl(s);
48480
- const id = await awaitPendingReview({
48481
- pendingReviewId: async () => (await sessionReview(baseUrl, opts.session))?.id,
48660
+ const reviewId = session === undefined ? undefined : await awaitPendingReview({
48661
+ pendingReviewId: async () => (await sessionReview(baseUrl, session))?.id,
48482
48662
  sleep: Bun.sleep
48483
48663
  }, opts.open ? 1 : undefined);
48484
- logDebug("band", "band link resolved", { found: id !== undefined });
48485
- const url = browserReviewLink(baseUrl, localHostname(s.daemon.host), id, browserLoginToken(s.daemon));
48664
+ logDebug("band", "band link resolved", { found: reviewId !== undefined });
48665
+ const url = browserReviewLink(baseUrl, localHostname(s.daemon.host), reviewId, browserLoginToken(s.daemon));
48486
48666
  if (opts.open)
48487
48667
  openBrowser(url);
48488
48668
  else
@@ -49605,12 +49785,18 @@ function logReviewText(log, version, decision) {
49605
49785
 
49606
49786
  // src/daemon/schemas.ts
49607
49787
  init_zod();
49788
+ var ApproveVariantSchema = object({
49789
+ id: string2().min(1),
49790
+ label: string2().min(1),
49791
+ description: string2().optional()
49792
+ });
49608
49793
  var PlanInputSchema = object({
49609
49794
  sessionId: string2().optional(),
49610
49795
  cwd: string2().optional(),
49611
49796
  plan: string2().optional(),
49612
49797
  planFilePath: string2().optional(),
49613
- cmux: object({ workspaceId: string2().min(1), surfaceId: string2().min(1) }).optional().catch(undefined)
49798
+ cmux: object({ workspaceId: string2().min(1), surfaceId: string2().min(1) }).optional().catch(undefined),
49799
+ approveVariants: array(ApproveVariantSchema).min(1).optional().catch(undefined)
49614
49800
  }).catch({});
49615
49801
  var MAX_FILE_REFS = 1000;
49616
49802
  var FileRefsBodySchema = object({ paths: array(string2()).catch([]) }).catch({ paths: [] });
@@ -50078,23 +50264,23 @@ import { chmodSync as chmodSync3, existsSync as existsSync9, mkdirSync as mkdirS
50078
50264
  import { mkdtemp, rm as rm3 } from "fs/promises";
50079
50265
  import { tmpdir } from "os";
50080
50266
  import { dirname as dirname7, join as join17 } from "path";
50081
- var RUMDL_VERSION = "0.3.0";
50267
+ var RUMDL_VERSION = "0.3.2";
50082
50268
  var ASSETS = {
50083
50269
  "darwin-arm64": {
50084
50270
  url: `https://github.com/rvben/rumdl/releases/download/v${RUMDL_VERSION}/rumdl-v${RUMDL_VERSION}-aarch64-apple-darwin.tar.gz`,
50085
- sha256: "bc62f4176dd9257547c939fa152b535b6f393365acd352fcfd94e5e19a792bb4"
50271
+ sha256: "a1eefb1cd2e0cafa42f0ca98d3f8713d7e73f9eba77fc8ef0ed6836875197935"
50086
50272
  },
50087
50273
  "darwin-x64": {
50088
50274
  url: `https://github.com/rvben/rumdl/releases/download/v${RUMDL_VERSION}/rumdl-v${RUMDL_VERSION}-x86_64-apple-darwin.tar.gz`,
50089
- sha256: "beb48c38948fcb9bb4eb4994af9830cbb6b8a0b97a3ec0ea3233151065d2e56e"
50275
+ sha256: "ab35f245127a06374833127162eebdbdec1be17c1e3d8274f02f1b909645635c"
50090
50276
  },
50091
50277
  "linux-arm64": {
50092
50278
  url: `https://github.com/rvben/rumdl/releases/download/v${RUMDL_VERSION}/rumdl-v${RUMDL_VERSION}-aarch64-unknown-linux-musl.tar.gz`,
50093
- sha256: "5a6274e69bf22164ee6adb47381c870f61ece4648a89fa8b178f0ed24857154a"
50279
+ sha256: "afc6dd91f1c4f2a8cf4a40ab99f8e52e06e6dddfc5334f1c1db8b158d353d143"
50094
50280
  },
50095
50281
  "linux-x64": {
50096
50282
  url: `https://github.com/rvben/rumdl/releases/download/v${RUMDL_VERSION}/rumdl-v${RUMDL_VERSION}-x86_64-unknown-linux-musl.tar.gz`,
50097
- sha256: "6c90c398f04c11a09dcbd2da08bdaa6d53d9b14393e3cd32dbdf4da5620eec5c"
50283
+ sha256: "395c4061041c5a25301c7b3564a93c4a661ed4df93427a77b6fc9e426ec8a13a"
50098
50284
  }
50099
50285
  };
50100
50286
  function rumdlAsset(platform = process.platform, arch = process.arch) {
@@ -50232,7 +50418,7 @@ function newReviewId() {
50232
50418
  return randomBytes2(8).toString("base64url");
50233
50419
  }
50234
50420
  function deriveTitle(plan) {
50235
- const tokens = new T({ gfm: true }).blockTokens(plan.replace(/\r\n?/g, `
50421
+ const tokens = new O({ gfm: true }).blockTokens(plan.replace(/\r\n?/g, `
50236
50422
  `));
50237
50423
  const heading = (depth) => tokens.find((t) => t.type === "heading" && t.depth === depth && t.text.trim() !== "")?.text;
50238
50424
  const prose = tokens.find((t) => t.type === "paragraph")?.text.split(`
@@ -50266,6 +50452,7 @@ async function routeIncomingPlan(input, store, log = noopLogger) {
50266
50452
  r.title = deriveTitle(plan);
50267
50453
  r.status = "pending";
50268
50454
  r.cmux = input.cmux ?? r.cmux;
50455
+ r.approveVariants = input.approveVariants ?? r.approveVariants;
50269
50456
  r.decision = undefined;
50270
50457
  });
50271
50458
  log.info("review", `review appended: ${shortId(latest.id)} v${version}`, {
@@ -50290,6 +50477,7 @@ async function routeIncomingPlan(input, store, log = noopLogger) {
50290
50477
  title: deriveTitle(plan),
50291
50478
  status: "pending",
50292
50479
  cmux: input.cmux,
50480
+ approveVariants: input.approveVariants,
50293
50481
  versions: [{ version: 1, plan, annotations: [], agentCopyMatches, createdAt: now }],
50294
50482
  createdAt: now,
50295
50483
  updatedAt: now
@@ -50551,7 +50739,6 @@ function resolveOptions(opts) {
50551
50739
  commit: opts.commit,
50552
50740
  stateDir: opts.stateDir,
50553
50741
  instanceId: opts.instanceId,
50554
- approveVariants: opts.approveVariants,
50555
50742
  approveCarriesNotes: opts.approveCarriesNotes,
50556
50743
  source: opts.source,
50557
50744
  listSkills: opts.listSkills,
@@ -50589,6 +50776,9 @@ function ifNoneMatchHit(header, etag) {
50589
50776
  function isStaleVersion(review, version) {
50590
50777
  return review !== undefined && version !== undefined && currentVersion(review).version !== version;
50591
50778
  }
50779
+ function offersVariant(declared, id) {
50780
+ return id === undefined || declared === undefined || declared.some((v) => v.id === id);
50781
+ }
50592
50782
  function expiredDeny() {
50593
50783
  return {
50594
50784
  behavior: "deny",
@@ -50603,7 +50793,7 @@ function createServer(opts) {
50603
50793
  const cfg = resolveOptions(opts);
50604
50794
  const { store, idle, heartbeat, resident, assets, onShutdown, routePlan, configPath, log } = cfg;
50605
50795
  const { buildId, assetDigest, commit, stateDir, instanceId } = cfg;
50606
- const { approveVariants, approveCarriesNotes, source, lockPath } = cfg;
50796
+ const { approveCarriesNotes, source, lockPath } = cfg;
50607
50797
  const { awaitDecision, resolveDecision, clearDecision, openDecisionCount, unreadDecisionCount } = createDecisions(log);
50608
50798
  const configWriter = createConfigWriter(configPath);
50609
50799
  const { themeWriter } = cfg;
@@ -50658,7 +50848,6 @@ function createServer(opts) {
50658
50848
  resident,
50659
50849
  supervised: isSupervised(),
50660
50850
  ...process.env.CARET_FRESH === "1" ? { fresh: true } : {},
50661
- ...approveVariants ? { approveVariants: [...approveVariants] } : {},
50662
50851
  ...approveCarriesNotes === undefined ? {} : { approveCarriesNotes },
50663
50852
  ...source ? { source } : {},
50664
50853
  ...cfg.restartHint ? { restartHint: cfg.restartHint } : {},
@@ -51023,6 +51212,12 @@ function createServer(opts) {
51023
51212
  }
51024
51213
  if (existing?.status !== "pending")
51025
51214
  return notFound();
51215
+ if (body.behavior !== "deny" && !offersVariant(existing.approveVariants, body.acceptMode)) {
51216
+ route.log.info("resolve", "resolve refused: approve variant not offered", {
51217
+ acceptMode: body.acceptMode
51218
+ });
51219
+ return Response.json({ error: `approve variant "${body.acceptMode}" is not offered for this review` }, { status: 400 });
51220
+ }
51026
51221
  const decision = {
51027
51222
  behavior: body.behavior === "deny" ? "deny" : "allow",
51028
51223
  feedback: body.feedback,
@@ -51594,7 +51789,6 @@ async function runDaemon(opts) {
51594
51789
  commit: built.commit,
51595
51790
  stateDir: stateDir(),
51596
51791
  instanceId: randomUUID().slice(0, 8),
51597
- approveVariants: adapter.approveVariants,
51598
51792
  approveCarriesNotes: adapter.approveCarriesNotes,
51599
51793
  source: adapter.id,
51600
51794
  listSkills: (cwd) => adapter.listSkills(cwd),
@@ -56156,7 +56350,7 @@ function buildProgram() {
56156
56350
  program.command("review").description("review a plan from stdin (ExitPlanMode hook)").action(() => runReviewSubcommand());
56157
56351
  program.command("mcp").description("serve caret's plan-review tool over MCP stdio (Claude Code plugin)").action(async () => (await Promise.resolve().then(() => (init_mcp2(), exports_mcp))).runMcpSubcommand());
56158
56352
  program.command("reconcile").description("reconcile a terminal plan approval into the daemon (ExitPlanMode PostToolUse hook)").action(() => runReconcileSubcommand());
56159
- program.command("band-link").description("print or open the link Claude Code's plan-waiting band shows (mod hook)").requiredOption("--session <id>", "the Claude Code session id").option("--open", "open the link in a browser instead of printing it").action((opts) => runBandLinkSubcommand(opts));
56353
+ program.command("band-link").description("print or open the link to a session's pending review, else caret's home page (Claude Code's band, OpenCode's /caret)").option("--session <id>", "the Claude Code or OpenCode session whose review to link").option("--open", "open the link in a browser instead of printing it").action((opts) => runBandLinkSubcommand(opts));
56160
56354
  program.command("steer").description("steer the model to title its plan (EnterPlanMode PostToolUse / UserPromptSubmit hook)").action(() => runSteerSubcommand());
56161
56355
  program.command("redact").description("write redacted copies of the logs").action(() => runRedactSubcommand());
56162
56356
  program.command("convert-theme").description("convert a VS Code color theme into a caret theme file").argument("<file>", "the VS Code theme JSON to convert").option("-o, --out <file>", "write the theme file here instead of to stdout").action((file, opts) => runConvertTheme(file, { out: opts.out }));