@vectojs/markdown 0.18.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -531,6 +531,7 @@ var DEFAULT_THEME = {
531
531
  headingColor: "#f8fafc",
532
532
  codeColor: "#a5f3fc",
533
533
  codeBgColor: "rgba(30, 41, 59, 0.85)",
534
+ codeBorderColor: "transparent",
534
535
  quoteBorderColor: "#6366f1",
535
536
  quoteTextColor: "#e2e8f0",
536
537
  hrColor: "rgba(148, 163, 184, 0.3)",
@@ -554,11 +555,13 @@ var DEFAULT_THEME = {
554
555
  syntaxStringColor: "#86efac",
555
556
  syntaxCommentColor: "#64748b",
556
557
  syntaxNumberColor: "#fbbf24",
558
+ codeLangColor: "#64748b",
557
559
  bodyFont: "Inter, system-ui, sans-serif",
558
560
  codeFont: 'ui-monospace, "JetBrains Mono", "Fira Code", monospace',
559
561
  fontSize: 16,
560
562
  headingSizes: [32, 28, 24, 20, 18, 16],
561
563
  codeFontSize: 15,
564
+ codeLangFontSize: 12,
562
565
  tableFontSize: 14,
563
566
  footnoteMarkerScale: 0.75,
564
567
  subscriptScale: 0.75,
@@ -593,6 +596,12 @@ function resolveTheme(theme) {
593
596
  if (theme?.footnoteColor === void 0) {
594
597
  merged.footnoteColor = merged.linkColor;
595
598
  }
599
+ if (theme?.codeLangColor === void 0) {
600
+ merged.codeLangColor = merged.syntaxCommentColor;
601
+ }
602
+ if (theme?.codeLangFontSize === void 0) {
603
+ merged.codeLangFontSize = Math.max(1, merged.codeFontSize - 3);
604
+ }
596
605
  return merged;
597
606
  }
598
607
  function headingSize(theme, depth) {
@@ -932,14 +941,215 @@ var KEYWORD_SETS = {
932
941
  "static"
933
942
  ])
934
943
  };
944
+ KEYWORD_SETS["bash"] = /* @__PURE__ */ new Set([
945
+ // Shell builtins and control words. Deliberately not the whole of coreutils:
946
+ // a keyword table that includes every command name colors an entire script
947
+ // uniformly, which reads worse than coloring only the control flow.
948
+ "if",
949
+ "then",
950
+ "else",
951
+ "elif",
952
+ "fi",
953
+ "for",
954
+ "while",
955
+ "until",
956
+ "do",
957
+ "done",
958
+ "case",
959
+ "esac",
960
+ "in",
961
+ "function",
962
+ "return",
963
+ "exit",
964
+ "break",
965
+ "continue",
966
+ "local",
967
+ "export",
968
+ "readonly",
969
+ "declare",
970
+ "unset",
971
+ "shift",
972
+ "source",
973
+ "alias",
974
+ "set",
975
+ "trap",
976
+ "echo",
977
+ "cd",
978
+ "sudo",
979
+ "true",
980
+ "false"
981
+ ]);
982
+ KEYWORD_SETS["json"] = /* @__PURE__ */ new Set(["true", "false", "null"]);
983
+ KEYWORD_SETS["css"] = /* @__PURE__ */ new Set([
984
+ "important",
985
+ "inherit",
986
+ "initial",
987
+ "unset",
988
+ "revert",
989
+ "auto",
990
+ "none",
991
+ "var",
992
+ "calc"
993
+ ]);
994
+ KEYWORD_SETS["html"] = /* @__PURE__ */ new Set([
995
+ // Tag names are the meaningful tokens a reader scans for. The tokenizer is
996
+ // word-based, so `<div>` yields the word `div`.
997
+ "html",
998
+ "head",
999
+ "body",
1000
+ "title",
1001
+ "meta",
1002
+ "link",
1003
+ "script",
1004
+ "style",
1005
+ "div",
1006
+ "span",
1007
+ "p",
1008
+ "a",
1009
+ "img",
1010
+ "ul",
1011
+ "ol",
1012
+ "li",
1013
+ "table",
1014
+ "tr",
1015
+ "td",
1016
+ "th",
1017
+ "form",
1018
+ "input",
1019
+ "button",
1020
+ "label",
1021
+ "select",
1022
+ "option",
1023
+ "textarea",
1024
+ "header",
1025
+ "footer",
1026
+ "nav",
1027
+ "main",
1028
+ "section",
1029
+ "article",
1030
+ "aside",
1031
+ "canvas",
1032
+ "svg",
1033
+ "template",
1034
+ "slot"
1035
+ ]);
935
1036
  KEYWORD_SETS["javascript"] = KEYWORD_SETS["js"];
936
1037
  KEYWORD_SETS["typescript"] = KEYWORD_SETS["ts"];
937
1038
  KEYWORD_SETS["python"] = KEYWORD_SETS["py"];
938
1039
  KEYWORD_SETS["rs"] = KEYWORD_SETS["rust"];
939
- function highlightLine(line, lang, theme) {
940
- const keywords = KEYWORD_SETS[lang];
941
- if (!keywords) {
942
- return [{ text: line, color: theme.codeColor }];
1040
+ KEYWORD_SETS["jsx"] = KEYWORD_SETS["js"];
1041
+ KEYWORD_SETS["mjs"] = KEYWORD_SETS["js"];
1042
+ KEYWORD_SETS["cjs"] = KEYWORD_SETS["js"];
1043
+ KEYWORD_SETS["tsx"] = KEYWORD_SETS["ts"];
1044
+ KEYWORD_SETS["mts"] = KEYWORD_SETS["ts"];
1045
+ KEYWORD_SETS["cts"] = KEYWORD_SETS["ts"];
1046
+ KEYWORD_SETS["sh"] = KEYWORD_SETS["bash"];
1047
+ KEYWORD_SETS["zsh"] = KEYWORD_SETS["bash"];
1048
+ KEYWORD_SETS["shell"] = KEYWORD_SETS["bash"];
1049
+ KEYWORD_SETS["console"] = KEYWORD_SETS["bash"];
1050
+ KEYWORD_SETS["jsonc"] = KEYWORD_SETS["json"];
1051
+ KEYWORD_SETS["json5"] = KEYWORD_SETS["json"];
1052
+ KEYWORD_SETS["scss"] = KEYWORD_SETS["css"];
1053
+ KEYWORD_SETS["sass"] = KEYWORD_SETS["css"];
1054
+ KEYWORD_SETS["less"] = KEYWORD_SETS["css"];
1055
+ KEYWORD_SETS["vue"] = KEYWORD_SETS["html"];
1056
+ KEYWORD_SETS["svelte"] = KEYWORD_SETS["html"];
1057
+ KEYWORD_SETS["xml"] = KEYWORD_SETS["html"];
1058
+ KEYWORD_SETS["svg"] = KEYWORD_SETS["html"];
1059
+ var C_LIKE = {
1060
+ lineComments: ["//"],
1061
+ quotes: ['"', "'", "`"],
1062
+ numbers: true,
1063
+ blockComments: [["/*", "*/"]],
1064
+ // A JS/TS template literal spans lines. Listed here as well as in `quotes`:
1065
+ // `quotes` handles the common single-line case, and this carries the rest.
1066
+ multilineStrings: ["`"]
1067
+ };
1068
+ var HASH_COMMENT = {
1069
+ lineComments: ["#"],
1070
+ quotes: ['"', "'"],
1071
+ numbers: true
1072
+ };
1073
+ var LANGUAGE_SYNTAX = {
1074
+ js: C_LIKE,
1075
+ ts: C_LIKE,
1076
+ // A Python docstring is the language's block comment in practice, and it is
1077
+ // lexically a string, so it is carried as one rather than invented as a third
1078
+ // kind. Triple delimiters are listed before the single ones so the longest
1079
+ // match wins.
1080
+ py: { ...HASH_COMMENT, multilineStrings: ['"""', "'''"] },
1081
+ // Rust has `//` line comments AND `'` lifetimes. The unterminated-quote
1082
+ // fallback already keeps a lifetime from swallowing the line, so `'` stays
1083
+ // listed: `'a'` is a valid char literal and should color as a string.
1084
+ rust: C_LIKE,
1085
+ bash: HASH_COMMENT,
1086
+ // JSON has no comments and no single-quoted strings. JSONC does have `//`,
1087
+ // and is aliased separately below rather than sharing this entry.
1088
+ json: { lineComments: [], quotes: ['"'], numbers: true },
1089
+ // CSS has only block comments — which now span lines, so this entry claims
1090
+ // them. Numbers are everywhere in CSS and coloring them is most of the visible
1091
+ // benefit.
1092
+ css: {
1093
+ lineComments: [],
1094
+ quotes: ['"', "'"],
1095
+ numbers: true,
1096
+ blockComments: [["/*", "*/"]]
1097
+ },
1098
+ // Markup: no line comments, and numbers inside attribute values are noise
1099
+ // rather than signal. An SGML comment spans lines like any other block form.
1100
+ html: {
1101
+ lineComments: [],
1102
+ quotes: ['"', "'"],
1103
+ numbers: false,
1104
+ blockComments: [["<!--", "-->"]]
1105
+ }
1106
+ };
1107
+ LANGUAGE_SYNTAX["javascript"] = LANGUAGE_SYNTAX["js"];
1108
+ LANGUAGE_SYNTAX["typescript"] = LANGUAGE_SYNTAX["ts"];
1109
+ LANGUAGE_SYNTAX["python"] = LANGUAGE_SYNTAX["py"];
1110
+ LANGUAGE_SYNTAX["rs"] = LANGUAGE_SYNTAX["rust"];
1111
+ LANGUAGE_SYNTAX["jsx"] = LANGUAGE_SYNTAX["js"];
1112
+ LANGUAGE_SYNTAX["mjs"] = LANGUAGE_SYNTAX["js"];
1113
+ LANGUAGE_SYNTAX["cjs"] = LANGUAGE_SYNTAX["js"];
1114
+ LANGUAGE_SYNTAX["tsx"] = LANGUAGE_SYNTAX["ts"];
1115
+ LANGUAGE_SYNTAX["mts"] = LANGUAGE_SYNTAX["ts"];
1116
+ LANGUAGE_SYNTAX["cts"] = LANGUAGE_SYNTAX["ts"];
1117
+ LANGUAGE_SYNTAX["sh"] = LANGUAGE_SYNTAX["bash"];
1118
+ LANGUAGE_SYNTAX["zsh"] = LANGUAGE_SYNTAX["bash"];
1119
+ LANGUAGE_SYNTAX["shell"] = LANGUAGE_SYNTAX["bash"];
1120
+ LANGUAGE_SYNTAX["console"] = LANGUAGE_SYNTAX["bash"];
1121
+ LANGUAGE_SYNTAX["yaml"] = HASH_COMMENT;
1122
+ LANGUAGE_SYNTAX["yml"] = HASH_COMMENT;
1123
+ LANGUAGE_SYNTAX["toml"] = HASH_COMMENT;
1124
+ LANGUAGE_SYNTAX["ini"] = HASH_COMMENT;
1125
+ LANGUAGE_SYNTAX["dockerfile"] = HASH_COMMENT;
1126
+ LANGUAGE_SYNTAX["makefile"] = HASH_COMMENT;
1127
+ LANGUAGE_SYNTAX["make"] = HASH_COMMENT;
1128
+ LANGUAGE_SYNTAX["jsonc"] = { lineComments: ["//"], quotes: ['"'], numbers: true };
1129
+ LANGUAGE_SYNTAX["json5"] = { lineComments: ["//"], quotes: ['"', "'"], numbers: true };
1130
+ LANGUAGE_SYNTAX["scss"] = C_LIKE;
1131
+ LANGUAGE_SYNTAX["sass"] = C_LIKE;
1132
+ LANGUAGE_SYNTAX["less"] = C_LIKE;
1133
+ LANGUAGE_SYNTAX["glsl"] = C_LIKE;
1134
+ LANGUAGE_SYNTAX["c"] = C_LIKE;
1135
+ LANGUAGE_SYNTAX["cpp"] = C_LIKE;
1136
+ LANGUAGE_SYNTAX["go"] = C_LIKE;
1137
+ LANGUAGE_SYNTAX["java"] = C_LIKE;
1138
+ LANGUAGE_SYNTAX["kotlin"] = C_LIKE;
1139
+ LANGUAGE_SYNTAX["swift"] = C_LIKE;
1140
+ LANGUAGE_SYNTAX["vue"] = LANGUAGE_SYNTAX["html"];
1141
+ LANGUAGE_SYNTAX["svelte"] = LANGUAGE_SYNTAX["html"];
1142
+ LANGUAGE_SYNTAX["xml"] = LANGUAGE_SYNTAX["html"];
1143
+ LANGUAGE_SYNTAX["svg"] = LANGUAGE_SYNTAX["html"];
1144
+ function highlightedLanguages() {
1145
+ return [.../* @__PURE__ */ new Set([...Object.keys(LANGUAGE_SYNTAX), ...Object.keys(KEYWORD_SETS)])].sort();
1146
+ }
1147
+ function highlightLine(line, lang, theme, carry = null) {
1148
+ const key = lang.trim().toLowerCase().split(/[\s:,{]/)[0] ?? "";
1149
+ const keywords = KEYWORD_SETS[key];
1150
+ const syntax = LANGUAGE_SYNTAX[key];
1151
+ if (!keywords && !syntax) {
1152
+ return { segments: [{ text: line, color: theme.codeColor }], carry: null };
943
1153
  }
944
1154
  const segments = [];
945
1155
  const KEYWORD_COLOR = theme.syntaxKeywordColor;
@@ -954,19 +1164,63 @@ function highlightLine(line, lang, theme) {
954
1164
  buf = "";
955
1165
  }
956
1166
  };
1167
+ const lexical = syntax ?? C_LIKE;
1168
+ const findClose = (from, close, isString) => {
1169
+ let j = from;
1170
+ while (j < line.length) {
1171
+ if (isString && line[j] === "\\") {
1172
+ j += 2;
1173
+ continue;
1174
+ }
1175
+ if (line.startsWith(close, j)) return j + close.length;
1176
+ j++;
1177
+ }
1178
+ return -1;
1179
+ };
1180
+ if (carry) {
1181
+ const color = carry.kind === "comment" ? COMMENT_COLOR : STRING_COLOR;
1182
+ const end = findClose(0, carry.close, carry.kind === "string");
1183
+ if (end === -1) {
1184
+ if (line.length > 0) segments.push({ text: line, color });
1185
+ return { segments, carry };
1186
+ }
1187
+ segments.push({ text: line.slice(0, end), color });
1188
+ i = end;
1189
+ }
957
1190
  while (i < line.length) {
958
1191
  const ch = line[i];
959
- if (ch === "/" && line[i + 1] === "/") {
1192
+ const block = lexical.blockComments?.find(([open]) => line.startsWith(open, i));
1193
+ if (block) {
1194
+ const [open, close] = block;
960
1195
  flush(theme.codeColor);
961
- segments.push({ text: line.slice(i), color: COMMENT_COLOR });
962
- return segments;
1196
+ const end = findClose(i + open.length, close, false);
1197
+ if (end === -1) {
1198
+ segments.push({ text: line.slice(i), color: COMMENT_COLOR });
1199
+ return { segments, carry: { kind: "comment", close } };
1200
+ }
1201
+ segments.push({ text: line.slice(i, end), color: COMMENT_COLOR });
1202
+ i = end;
1203
+ continue;
963
1204
  }
964
- if (ch === "#" && (lang === "py" || lang === "python" || lang === "rust" || lang === "rs")) {
1205
+ const comment = lexical.lineComments.find((prefix) => line.startsWith(prefix, i));
1206
+ if (comment !== void 0) {
965
1207
  flush(theme.codeColor);
966
1208
  segments.push({ text: line.slice(i), color: COMMENT_COLOR });
967
- return segments;
1209
+ return { segments, carry: null };
1210
+ }
1211
+ const multi = lexical.multilineStrings?.find((delim) => line.startsWith(delim, i));
1212
+ if (multi !== void 0) {
1213
+ flush(theme.codeColor);
1214
+ const end = findClose(i + multi.length, multi, true);
1215
+ if (end === -1) {
1216
+ segments.push({ text: line.slice(i), color: STRING_COLOR });
1217
+ return { segments, carry: { kind: "string", close: multi } };
1218
+ }
1219
+ segments.push({ text: line.slice(i, end), color: STRING_COLOR });
1220
+ i = end;
1221
+ continue;
968
1222
  }
969
- if (ch === '"' || ch === "'" || ch === "`") {
1223
+ if (lexical.quotes.includes(ch)) {
970
1224
  const quote = ch;
971
1225
  let j = i + 1;
972
1226
  let closed = false;
@@ -991,7 +1245,7 @@ function highlightLine(line, lang, theme) {
991
1245
  i++;
992
1246
  continue;
993
1247
  }
994
- if (/\d/.test(ch) && (i === 0 || /[\s(,=+\-*/<>[\]{}:;]/.test(line[i - 1]))) {
1248
+ if (lexical.numbers && /\d/.test(ch) && (i === 0 || /[\s(,=+\-*/<>[\]{}:;]/.test(line[i - 1]))) {
995
1249
  flush(theme.codeColor);
996
1250
  let j = i;
997
1251
  while (j < line.length && /[\d._xXa-fA-F]/.test(line[j])) j++;
@@ -1006,7 +1260,9 @@ function highlightLine(line, lang, theme) {
1006
1260
  const word = line.slice(i, j);
1007
1261
  segments.push({
1008
1262
  text: word,
1009
- color: keywords.has(word) ? KEYWORD_COLOR : theme.codeColor
1263
+ // A language may have lexical syntax but no keywords (plain YAML, TOML,
1264
+ // a Dockerfile). Those still get comments, strings and numbers.
1265
+ color: keywords?.has(word) ? KEYWORD_COLOR : theme.codeColor
1010
1266
  });
1011
1267
  i = j;
1012
1268
  continue;
@@ -1015,10 +1271,18 @@ function highlightLine(line, lang, theme) {
1015
1271
  i++;
1016
1272
  }
1017
1273
  flush(theme.codeColor);
1018
- return segments;
1274
+ return { segments, carry: null };
1019
1275
  }
1020
1276
  var CodeBlock = class extends UIComponent {
1021
1277
  lines;
1278
+ /**
1279
+ * Lexical state ENTERING each line, index-aligned with {@link lines}.
1280
+ *
1281
+ * Entering rather than leaving, so a streamed append can resume tokenizing at
1282
+ * the prefix-reuse boundary by reading one entry instead of re-scanning the
1283
+ * document for an unclosed block comment.
1284
+ */
1285
+ lineCarry = [];
1022
1286
  grid = null;
1023
1287
  /** Raw (unhighlighted) lines of the last build, for prefix reuse in buildLines. */
1024
1288
  rawLines = null;
@@ -1026,6 +1290,19 @@ var CodeBlock = class extends UIComponent {
1026
1290
  source;
1027
1291
  /** Bumped by {@link buildLines} and {@link setSelectable}; read by `Scene`. */
1028
1292
  contentEpoch = 0;
1293
+ /**
1294
+ * Horizontal scroll offset in local px, always in `[0, maxScrollX]`.
1295
+ *
1296
+ * Code does not wrap, so a line wider than the box would otherwise have an
1297
+ * unreachable tail. This offset is subtracted from BOTH the painted cell x and
1298
+ * the projected line x in the same frame — never one without the other, or the
1299
+ * DOM selection carriers detach from the glyphs they are supposed to cover
1300
+ * (the defect class `5cf7119` and `ee1de6f` fixed on the vertical axis).
1301
+ */
1302
+ scrollXValue = 0;
1303
+ /** Memoized widest prepared line, keyed by the grid identity it came from. */
1304
+ contentWidthGrid = null;
1305
+ contentWidthValue = 0;
1029
1306
  lang;
1030
1307
  theme;
1031
1308
  /**
@@ -1037,6 +1314,10 @@ var CodeBlock = class extends UIComponent {
1037
1314
  pad;
1038
1315
  codeFont;
1039
1316
  selectable;
1317
+ /** Whether the language header band is drawn. See {@link CodeBlockOptions.showLanguage}. */
1318
+ showLanguage;
1319
+ /** Font of the header label, resolved once from the theme. */
1320
+ langFont;
1040
1321
  /**
1041
1322
  * @param theme Any subset of {@link MarkdownTheme}, or the name of a built-in
1042
1323
  * preset (see {@link MarkdownThemePresetName}). Accepting a partial theme
@@ -1048,7 +1329,7 @@ var CodeBlock = class extends UIComponent {
1048
1329
  * be constructed directly with a preset name without going through
1049
1330
  * `Markdown`.
1050
1331
  */
1051
- constructor(code, lang, maxWidth, theme, selectable = true) {
1332
+ constructor(code, lang, maxWidth, theme, selectable = true, options = {}) {
1052
1333
  super();
1053
1334
  const resolved = resolvePresetTheme(theme);
1054
1335
  this.source = code;
@@ -1058,15 +1339,129 @@ var CodeBlock = class extends UIComponent {
1058
1339
  this.pad = resolved.codePadding;
1059
1340
  this.codeFont = `${resolved.codeFontSize}px ${resolved.codeFont}`;
1060
1341
  this.selectable = selectable;
1342
+ this.langFont = `${resolved.codeLangFontSize}px ${resolved.codeFont}`;
1343
+ this.showLanguage = options.showLanguage === true && this.languageLabel() !== "";
1061
1344
  this.lines = [];
1062
1345
  this.width = maxWidth;
1063
1346
  this.buildLines(code);
1347
+ this.on("wheel", (e) => {
1348
+ const max = this.maxScrollX;
1349
+ if (max <= 0) return;
1350
+ if (e.ctrlKey === true) return;
1351
+ const deltaMode = e.deltaMode ?? 0;
1352
+ let deltaX = e.deltaX ?? 0;
1353
+ let deltaY = e.deltaY ?? 0;
1354
+ if (deltaMode === 1) {
1355
+ deltaX *= 16;
1356
+ deltaY *= 16;
1357
+ } else if (deltaMode === 2) {
1358
+ deltaX *= this.width;
1359
+ deltaY *= this.height;
1360
+ }
1361
+ const horizontal = e.shiftKey === true ? deltaY || deltaX : deltaX;
1362
+ if (horizontal === 0) return;
1363
+ const before = this.scrollX;
1364
+ this.setScrollX(before + horizontal);
1365
+ if (this.scrollX !== before) e.nativeEvent?.preventDefault?.();
1366
+ });
1367
+ }
1368
+ /**
1369
+ * The language name shown in the header, or `''` when there is nothing to show.
1370
+ *
1371
+ * Normalized exactly as the highlighter normalizes its lookup key, so the label
1372
+ * and the colouring can never disagree about which language this is: a fence
1373
+ * may be written ` ```Bash ` or carry attributes (` ```ts title="a.ts" `), and
1374
+ * the label has to be the language, not the raw info string.
1375
+ *
1376
+ * Lowercased for the same reason `streamdown` lowercases its own
1377
+ * (`lib/code-block/header.tsx:15`): the fence's capitalization is incidental,
1378
+ * and a document mixing ` ```JS ` with ` ```js ` should not render two
1379
+ * different-looking labels for one language.
1380
+ */
1381
+ languageLabel() {
1382
+ return this.lang.trim().toLowerCase().split(/[\s:,{]/)[0] ?? "";
1383
+ }
1384
+ /**
1385
+ * Height in px of the header band, or `0` when it is off.
1386
+ *
1387
+ * The label sits in a band of its own rather than floating over the code,
1388
+ * because a translucent overlay above real glyphs is unreadable at small sizes
1389
+ * and would fight the horizontal scroll: the code slides under it, so any text
1390
+ * drawn on top would collide with a different token every frame.
1391
+ */
1392
+ headerHeight() {
1393
+ if (!this.showLanguage) return 0;
1394
+ return this.theme.codeLangFontSize + Math.round(this.pad * 0.75);
1395
+ }
1396
+ /**
1397
+ * Local y of the first line of code.
1398
+ *
1399
+ * Everything that positions a row — the painter, the projection, the grid's
1400
+ * own origin — goes through this, so the header offset cannot be applied to
1401
+ * one and forgotten on another. That class of mismatch is exactly what
1402
+ * detaches selection carriers from the glyphs they cover.
1403
+ */
1404
+ contentTop() {
1405
+ return this.headerHeight() + this.pad;
1406
+ }
1407
+ /**
1408
+ * Current horizontal scroll offset in local px, clamped to what the content
1409
+ * currently allows.
1410
+ *
1411
+ * Clamped on READ, not only on write, because `setWidth()` may shrink the box
1412
+ * after a scroll and is contractually forbidden from rebuilding anything. Both
1413
+ * the painter and the projection read through here, which is what keeps the
1414
+ * glyphs and the selection carriers on the same offset within a frame.
1415
+ */
1416
+ get scrollX() {
1417
+ return Math.min(this.scrollXValue, this.maxScrollX);
1418
+ }
1419
+ /**
1420
+ * Widest line's overflow past the padded box, i.e. the maximum useful
1421
+ * {@link scrollX}. `0` when every line already fits.
1422
+ */
1423
+ get maxScrollX() {
1424
+ return Math.max(0, this.contentWidth() - (this.width - this.pad * 2));
1425
+ }
1426
+ /**
1427
+ * Widest prepared line, memoized against the grid that produced it.
1428
+ *
1429
+ * Read by {@link scrollX}, which both `render()` and `getContentProjection()`
1430
+ * call every synced frame, so an O(lines) scan here would be an O(document) cost
1431
+ * per frame on a long block — the exact shape the per-line projection window
1432
+ * exists to avoid. The grid is rebuilt only when the content changes, so the
1433
+ * cache key is identity of the grid object.
1434
+ */
1435
+ contentWidth() {
1436
+ const grid = this.ensureGrid();
1437
+ if (this.contentWidthGrid === grid) return this.contentWidthValue;
1438
+ let widest = 0;
1439
+ for (const line of grid.lines) {
1440
+ if (line.width > widest) widest = line.width;
1441
+ }
1442
+ this.contentWidthGrid = grid;
1443
+ this.contentWidthValue = widest;
1444
+ return widest;
1445
+ }
1446
+ /**
1447
+ * Scroll horizontally to `x`, clamped to `[0, maxScrollX]`.
1448
+ *
1449
+ * @returns `this` for chaining.
1450
+ */
1451
+ setScrollX(x) {
1452
+ const next = Math.max(0, Math.min(this.maxScrollX, x));
1453
+ if (next === this.scrollXValue) return this;
1454
+ this.scrollXValue = next;
1455
+ this.contentEpoch++;
1456
+ this.scene?.markDirty();
1457
+ return this;
1064
1458
  }
1065
1459
  /** Re-parse code content (e.g. for live editing). */
1066
1460
  setCode(code, lang) {
1067
1461
  if (lang !== void 0) this.lang = lang;
1068
1462
  this.source = code;
1069
1463
  this.buildLines(code);
1464
+ this.scrollXValue = Math.min(this.scrollXValue, this.maxScrollX);
1070
1465
  this.scene?.markDirty();
1071
1466
  return this;
1072
1467
  }
@@ -1086,9 +1481,13 @@ var CodeBlock = class extends UIComponent {
1086
1481
  * Deliberately does **not** rebuild the grid or the highlight, because code does
1087
1482
  * not reflow: lines are placed on a fixed monospace grid at `col × cellWidth` and
1088
1483
  * a long line overflows rather than wrapping, so `height` is a function of line
1089
- * *count* alone. The width only sizes the rounded background. Anything that would
1090
- * change the glyph geometry — the source, the language, the font — goes through
1091
- * {@link setCode} and invalidates the grid there.
1484
+ * *count* alone. The width sizes the rounded background and the clip. Anything
1485
+ * that would change the glyph geometry — the source, the language, the font —
1486
+ * goes through {@link setCode} and invalidates the grid there.
1487
+ *
1488
+ * A narrower box can leave {@link scrollX} past the new end of travel. That is
1489
+ * resolved by clamping on read rather than by adjusting anything here, so this
1490
+ * method keeps costing nothing.
1092
1491
  *
1093
1492
  * @returns `this` for chaining.
1094
1493
  */
@@ -1102,16 +1501,21 @@ var CodeBlock = class extends UIComponent {
1102
1501
  getContentProjection(hint) {
1103
1502
  if (!this.source) return null;
1104
1503
  const grid = this.ensureGrid();
1504
+ const scrollX = this.scrollX;
1105
1505
  const rows = [];
1106
1506
  rows.length = grid.lines.length;
1107
1507
  for (let row = 0; row < grid.lines.length; row++) {
1108
1508
  const line = grid.lines[row];
1109
- const y = this.pad + row * this.lineH;
1509
+ const y = this.contentTop() + row * this.lineH;
1110
1510
  if (!contentLineInHint(hint, y, this.lineH)) continue;
1111
1511
  rows[row] = {
1112
1512
  text: this.source.slice(line.sourceStart, line.sourceEnd),
1113
1513
  separatorAfter: this.source.slice(line.sourceEnd, line.nextSourceStart) || void 0,
1114
- x: this.pad,
1514
+ // The SAME offset `render()` subtracts, read through the same clamping
1515
+ // accessor. Cell carriers are `position: relative` inside this `absolute`
1516
+ // line box, so shifting the line's x translates every cell of the line
1517
+ // rigidly and selection stays over the glyphs.
1518
+ x: this.pad - scrollX,
1115
1519
  y,
1116
1520
  baseline: this.lineH * 0.75,
1117
1521
  font: this.codeFont,
@@ -1131,6 +1535,12 @@ var CodeBlock = class extends UIComponent {
1131
1535
  // render() draws cell-by-cell (no ligatures can form); the DOM copy
1132
1536
  // must not ligate either or Firefox selection geometry drifts.
1133
1537
  ligatures: "none",
1538
+ // `render()` clips the glyph pass to this box, so the DOM copy must too.
1539
+ // A line wider than the box otherwise projects carriers past the entity,
1540
+ // and the browser paints their selection highlight over whatever is drawn
1541
+ // beside the block — measured 1580px of carrier against a 1566px viewport
1542
+ // on a real page, the highlight running through the prose to its right.
1543
+ clipToBounds: true,
1134
1544
  grid
1135
1545
  };
1136
1546
  }
@@ -1145,6 +1555,11 @@ var CodeBlock = class extends UIComponent {
1145
1555
  *
1146
1556
  * The last previously-seen line is deliberately NOT reused: a chunk usually
1147
1557
  * lands mid-line, so that line's text (and therefore its tokenization) changes.
1558
+ *
1559
+ * Prefix reuse survives multi-line constructs because {@link lineCarry} records
1560
+ * the state ENTERING each line, so resuming at the reuse boundary needs no
1561
+ * rescan: a carried state is a pure function of the preceding text, and that
1562
+ * text is byte-identical over the reused prefix by construction.
1148
1563
  */
1149
1564
  buildLines(code) {
1150
1565
  this.contentEpoch++;
@@ -1155,18 +1570,20 @@ var CodeBlock = class extends UIComponent {
1155
1570
  const limit = Math.min(previous.length - 1, rawLines.length);
1156
1571
  while (reusable < limit && previous[reusable] === rawLines[reusable]) reusable++;
1157
1572
  }
1158
- if (reusable > 0) {
1159
- const next = this.lines.slice(0, reusable);
1160
- for (let i = reusable; i < rawLines.length; i++) {
1161
- next.push(highlightLine(rawLines[i], this.lang, this.theme));
1162
- }
1163
- this.lines = next;
1164
- } else {
1165
- this.lines = rawLines.map((l) => highlightLine(l, this.lang, this.theme));
1573
+ const lines = reusable > 0 ? this.lines.slice(0, reusable) : [];
1574
+ const carries = reusable > 0 ? this.lineCarry.slice(0, reusable) : [];
1575
+ let carry = reusable > 0 ? this.lineCarry[reusable] ?? null : null;
1576
+ for (let i = reusable; i < rawLines.length; i++) {
1577
+ carries.push(carry);
1578
+ const result = highlightLine(rawLines[i], this.lang, this.theme, carry);
1579
+ lines.push(result.segments);
1580
+ carry = result.carry;
1166
1581
  }
1582
+ this.lines = lines;
1583
+ this.lineCarry = carries;
1167
1584
  this.rawLines = rawLines;
1168
1585
  this.grid = null;
1169
- this.height = this.pad * 2 + rawLines.length * this.lineH;
1586
+ this.height = this.contentTop() + this.pad + rawLines.length * this.lineH;
1170
1587
  }
1171
1588
  ensureGrid() {
1172
1589
  const cellWidth = this.cellWidth || Math.max(1, measureText("M", this.codeFont));
@@ -1180,7 +1597,15 @@ var CodeBlock = class extends UIComponent {
1180
1597
  }
1181
1598
  return this.grid;
1182
1599
  }
1183
- /** Code blocks are decorative — not interactive. */
1600
+ /**
1601
+ * Not hit-testable, and deliberately still not `interactive`, even though the
1602
+ * block now consumes wheel events to scroll.
1603
+ *
1604
+ * The wheel arrives from the content-projection div rather than from canvas
1605
+ * hit-testing, so no a11y shadow node is needed. Creating one would place a
1606
+ * `pointer-events: auto` element above the transparent text mirror and swallow
1607
+ * the mousedown that starts a native drag-selection.
1608
+ */
1184
1609
  isPointInside() {
1185
1610
  return false;
1186
1611
  }
@@ -1188,12 +1613,34 @@ var CodeBlock = class extends UIComponent {
1188
1613
  r.beginPath();
1189
1614
  r.roundRect(0, 0, this.width, this.height, this.theme.codeRadius);
1190
1615
  r.fill(this.theme.codeBgColor);
1616
+ if (this.theme.codeBorderColor && this.theme.codeBorderColor !== "transparent") {
1617
+ r.beginPath();
1618
+ r.roundRect(0.5, 0.5, this.width - 1, this.height - 1, this.theme.codeRadius);
1619
+ r.stroke(this.theme.codeBorderColor, 1);
1620
+ }
1191
1621
  const grid = this.ensureGrid();
1192
1622
  const atlas = codeGlyphAtlas(r);
1193
1623
  const atlasSource = atlas?.source ?? null;
1194
1624
  const blit = atlas ? r.drawImageRect : void 0;
1625
+ const header = this.headerHeight();
1626
+ if (header > 0) {
1627
+ r.fillText(
1628
+ this.languageLabel(),
1629
+ this.pad,
1630
+ // Vertically centred in the band by its own cap height rather than by
1631
+ // font size: `fillText` takes a baseline, so centring the em box would
1632
+ // sit the visible letterforms low. 0.7 of the label size below the band's
1633
+ // centre line is where a lowercase-plus-cap run reads as centred.
1634
+ (header + this.theme.codeLangFontSize * 0.7) / 2,
1635
+ this.langFont,
1636
+ this.theme.codeLangColor
1637
+ );
1638
+ }
1639
+ r.save();
1640
+ r.clip(0, header, this.width, this.height - header);
1641
+ const scrollX = this.scrollX;
1195
1642
  for (let row = 0; row < grid.lines.length; row++) {
1196
- const yBaseline = this.pad + row * this.lineH + this.lineH * 0.75;
1643
+ const yBaseline = this.contentTop() + row * this.lineH + this.lineH * 0.75;
1197
1644
  const segments = this.lines[row];
1198
1645
  let segmentIndex = 0;
1199
1646
  let segmentEnd = segments[0]?.text.length ?? 0;
@@ -1207,7 +1654,8 @@ var CodeBlock = class extends UIComponent {
1207
1654
  const sourceText = this.source.slice(cell.sourceStart, cell.sourceEnd);
1208
1655
  if (cell.advance <= 0 || sourceText === " " || sourceText === " ") continue;
1209
1656
  const color = segments[segmentIndex]?.color ?? this.theme.codeColor;
1210
- const x = this.pad + cell.x;
1657
+ const x = this.pad + cell.x - scrollX;
1658
+ if (x + cell.advance < 0 || x > this.width) continue;
1211
1659
  if (blit && atlas) {
1212
1660
  const slot = atlas.get(this.codeFont, color, cell.glyph);
1213
1661
  const src = atlasSource ?? atlas.source;
@@ -1230,6 +1678,7 @@ var CodeBlock = class extends UIComponent {
1230
1678
  r.fillText(cell.glyph, x, yBaseline, this.codeFont, color);
1231
1679
  }
1232
1680
  }
1681
+ r.restore();
1233
1682
  }
1234
1683
  };
1235
1684
  var codeAtlases = /* @__PURE__ */ new Map();
@@ -2481,6 +2930,30 @@ function defaultSaveFile(filename, content, mimeType) {
2481
2930
  doc.body.removeChild(anchor);
2482
2931
  URL.revokeObjectURL(url);
2483
2932
  }
2933
+ function resolveBlockAffordanceConfig(config = {}) {
2934
+ const copy = config.copy ?? true;
2935
+ const download = config.download ?? true;
2936
+ return {
2937
+ copy,
2938
+ download,
2939
+ code: {
2940
+ copy: config.code?.copy ?? copy,
2941
+ download: config.code?.download ?? download
2942
+ },
2943
+ table: {
2944
+ copy: config.table?.copy ?? copy,
2945
+ download: config.table?.download ?? download
2946
+ },
2947
+ labels: {
2948
+ copyCode: config.labels?.copyCode ?? "Copy code",
2949
+ downloadCode: config.labels?.downloadCode ?? "Download code",
2950
+ copyTable: config.labels?.copyTable ?? "Copy table",
2951
+ downloadTable: config.labels?.downloadTable ?? "Download table",
2952
+ copied: config.labels?.copied ?? "Copied",
2953
+ saved: config.labels?.saved ?? "Saved"
2954
+ }
2955
+ };
2956
+ }
2484
2957
  var BlockAffordanceButton = class _BlockAffordanceButton extends Button {
2485
2958
  constructor(label, successLabel, act, opts = {}) {
2486
2959
  super(label, { ...opts, onClick: () => this.run() });
@@ -2658,7 +3131,7 @@ function unquote(value) {
2658
3131
  }
2659
3132
 
2660
3133
  // src/MarkdownWorkerSource.ts
2661
- var WORKER_SOURCE_STRING = '"use strict";(()=>{function J(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var I=J();function ke(t){I=t}var A={exec:()=>null};function C(t){let e=[];return n=>{let s=Math.max(0,Math.min(3,n-1)),r=e[s];return r||(r=t(s),e[s]=r),r}}function g(t,e=""){let n=typeof t=="string"?t:t.source,s={replace:(r,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(x.caret,"$1"),n=n.replace(r,a),s},getRegex:()=>new RegExp(n,e)};return s}var Xe=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),x={codeRemoveIndent:/^(?: {1,4}| {0,3}\\t)/gm,outputLinkReplace:/\\\\([\\[\\]])/g,indentCodeCompensation:/^(\\s+)(?:```)/,beginningSpace:/^\\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\\n/g,tabCharGlobal:/\\t/g,multipleSpaceGlobal:/\\s+/g,blankLine:/^[ \\t]*$/,doubleBlankLine:/\\n[ \\t]*\\n[ \\t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\\n {0,3}((?:=+|-+) *)(?=\\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \\t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\\[[ xX]\\] +\\S/,listReplaceTask:/^\\[[ xX]\\] +/,listTaskCheckbox:/\\[[ xX]\\]/,anyLine:/\\n.*\\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\\||\\| *$/g,tableRowBlankLine:/\\n[ \\t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\\s|>)/i,endPreScriptTag:/^<\\/(pre|code|kbd|script)(\\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^\'"]*[^\\s])\\s+([\'"])(.*)\\2/,unicodeAlphaNumeric:/[\\p{L}\\p{N}]/u,escapeTest:/[&<>"\']/,escapeReplace:/[&<>"\']/g,escapeTestNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/,escapeReplaceNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/g,caret:/(^|[^\\[])\\^/g,percentDecode:/%25/g,findPipe:/\\|/g,splitPipe:/ \\|/,slashPipe:/\\\\\\|/g,carriageReturn:/\\r\\n|\\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\\S*/,endingNewline:/\\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\\\n]*)?(?:\\\\n|$))`),nextBulletRegex:C(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:C(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:C(t=>new RegExp(`^ {0,${t}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:C(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:C(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:C(t=>new RegExp(`^ {0,${t}}>`))},Qe=/^(?:[ \\t]*(?:\\n|$))+/,He=/^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/,We=/^ {0,3}(`{3,}(?=[^`\\n]*(?:\\n|$))|~{3,})([^\\n]*)(?:\\n|$)(?:|([\\s\\S]*?)(?:\\n|$))(?: {0,3}\\1[~`]* *(?=\\n|$)|$)/,v=/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/,Ge=/^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/,K=/ {0,3}(?:[*+-]|\\d{1,9}[.)])/,xe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,be=g(xe).replace(/bull/g,K).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(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/\\|table/g,"").getRegex(),Ue=g(xe).replace(/bull/g,K).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(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/table/g,/ {0,3}\\|?(?:[:\\- ]*\\|)+[\\:\\- ]*\\n/).getRegex(),V=/^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \\t]+\\n)[^\\n]+)*)/,Je=/^[^\\n]+/,Y=/(?!\\s*\\])(?:\\\\[\\s\\S]|[^\\[\\]\\\\])+/,Ke=g(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace("label",Y).replace("title",/(?:"(?:\\\\"?|[^"\\\\])*"|\'[^\'\\n]*(?:\\n[^\'\\n]+)*\\n?\'|\\([^()]*\\))/).getRegex(),Ve=g(/^(bull)([ \\t][^\\n]*?)?(?:\\n|$)/).replace(/bull/g,K).getRegex(),X="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",ee=/<!--(?:-?>|[\\s\\S]*?(?:-->|$))/,Ye=g("^ {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[ ]*)+\\\\n|$)|<(?!script|pre|style|textarea)([a-z][\\\\w-]*)(?:attribute)*? */?>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$)|</(?!script|pre|style|textarea)[a-z][\\\\w-]*\\\\s*>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$))","i").replace("comment",ee).replace("tag",X).replace("attribute",/ +[a-zA-Z:_][\\w.:-]*(?: *= *"[^"\\n]*"| *= *\'[^\'\\n]*\'| *= *[^\\s"\'=<>`]+)?/).getRegex(),me=t=>g(V).replace("hr",v).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",t).replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",X).getRegex(),et=me(/ {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]/),tt=me(/ {0,3}(?:[*+-]|\\d{1,9}[.)])(?:[ \\t]|\\n|$)/),nt=g(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace("paragraph",tt).getRegex(),te={blockquote:nt,code:He,def:Ke,fences:We,heading:Ge,hr:v,html:Ye,lheading:be,list:Ve,newline:Qe,paragraph:et,table:A,text:Je},ce=g("^ *([^\\\\n ].*)\\\\n {0,3}((?:\\\\| *)?:?-+:? *(?:\\\\| *:?-+:? *)*(?:\\\\| *)?)(?:\\\\n((?:(?! *\\\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\\\n|$))*)\\\\n*|$)").replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",X).getRegex(),rt={...te,lheading:Ue,table:ce,paragraph:g(V).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("table",ce).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]+[^ \\\\t\\\\n]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",X).getRegex()},st={...te,html:g(`^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\\\s[^\'"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))`).replace("comment",ee).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:A,lheading:/^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,paragraph:g(V).replace("hr",v).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",be).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},it=/^\\\\([!"#$%&\'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/,lt=/^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/,we=/^( {2,}|\\\\)\\n(?!\\s*$)/,at=/^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/,P=/[\\p{P}\\p{S}]/u,Q=/[\\s\\p{P}\\p{S}]/u,ne=/[^\\s\\p{P}\\p{S}]/u,ot=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Q).getRegex(),ye=/(?!~)[\\p{P}\\p{S}]/u,ct=/(?!~)[\\s\\p{P}\\p{S}]/u,ut=/(?:[^\\s\\p{P}\\p{S}]|~)/u,ht=g(/link|precode-code|html/,"g").replace("link",/\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)/).replace("precode-",Xe?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Re=/^(?:\\*+(?:((?!\\*)punct)|([^\\s*]))?)|^_+(?:((?!_)punct)|([^\\s_]))?/,pt=g(Re,"u").replace(/punct/g,P).getRegex(),ft=g(Re,"u").replace(/punct/g,ye).getRegex(),Te="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)",gt=g(Te,"gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,Q).replace(/punct/g,P).getRegex(),dt=g(Te,"gu").replace(/notPunctSpace/g,ut).replace(/punctSpace/g,ct).replace(/punct/g,ye).getRegex(),kt=g("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,Q).replace(/punct/g,P).getRegex(),xt=g(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,P).getRegex(),bt="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",mt=g(bt,"gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,Q).replace(/punct/g,P).getRegex(),wt=g(/\\\\(punct)/,"gu").replace(/punct/g,P).getRegex(),yt=g(/^<(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(),Rt=g(ee).replace("(?:-->|$)","-->").getRegex(),Tt=g("^comment|^</[a-zA-Z][\\\\w:-]*\\\\s*>|^<[a-zA-Z][\\\\w-]*(?:attribute)*?\\\\s*/?>|^<\\\\?[\\\\s\\\\S]*?\\\\?>|^<![a-zA-Z]+\\\\s[\\\\s\\\\S]*?>|^<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?\\\\]\\\\]>").replace("comment",Rt).replace("attribute",/\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*"[^"]*"|\\s*=\\s*\'[^\']*\'|\\s*=\\s*[^\\s"\'=<>`]+)?/).getRegex(),Z=/(?:\\[(?:\\\\[\\s\\S]|[^\\[\\]\\\\])*\\]|\\\\[\\s\\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\\])|[^\\[\\]\\\\`])*?/,St=g(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]+(?:\\n[ \\t]*)?|\\n[ \\t]*)(title))?\\s*\\)/).replace("label",Z).replace("href",/<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]+|(?=\\))/).replace("title",/"(?:\\\\"?|[^"\\\\])*"|\'(?:\\\\\'?|[^\'\\\\])*\'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex(),Se=g(/^!?\\[(label)\\]\\[(ref)\\]/).replace("label",Z).replace("ref",Y).getRegex(),_e=g(/^!?\\[(ref)\\](?:\\[\\])?/).replace("ref",Y).getRegex(),_t=g("reflink|nolink(?!\\\\()","g").replace("reflink",Se).replace("nolink",_e).getRegex(),ue=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,re={_backpedal:A,anyPunctuation:wt,autolink:yt,blockSkip:ht,br:we,code:lt,del:A,delLDelim:A,delRDelim:A,emStrongLDelim:pt,emStrongRDelimAst:gt,emStrongRDelimUnd:kt,escape:it,link:St,nolink:_e,punctuation:ot,reflink:Se,reflinkSearch:_t,tag:Tt,text:at,url:A},$t={...re,link:g(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",Z).getRegex(),reflink:g(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",Z).getRegex()},W={...re,emStrongRDelimAst:dt,emStrongLDelim:ft,delLDelim:xt,delRDelim:mt,url:g(/^((?:protocol):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/).replace("protocol",ue).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_\'"~()&]+|\\([^)]*\\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_\'"~)]+(?!$))+/,del:/^(~~?)(?=[^\\s~])((?:\\\\[\\s\\S]|[^\\\\])*?(?:\\\\[\\s\\S]|[^\\s~\\\\]))\\1(?=[^~]|$)/,text:g(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|protocol:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)))/).replace("protocol",ue).getRegex()},Et={...W,br:g(we).replace("{2,}","*").getRegex(),text:g(W.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},q={normal:te,gfm:rt,pedantic:st},O={normal:re,gfm:W,breaks:Et,pedantic:$t},zt={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"},he=t=>zt[t];function _(t,e){if(e){if(x.escapeTest.test(t))return t.replace(x.escapeReplace,he)}else if(x.escapeTestNoEncode.test(t))return t.replace(x.escapeReplaceNoEncode,he);return t}function pe(t){try{t=encodeURI(t).replace(x.percentDecode,"%")}catch{return null}return t}function fe(t,e){let n=t.replace(x.findPipe,(i,a,l)=>{let o=!1,c=a;for(;--c>=0&&l[c]==="\\\\";)o=!o;return o?"|":" |"}),s=n.split(x.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(x.slashPipe,"|");return s}function E(t,e,n){let s=t.length;if(s===0)return"";let r=0;for(;r<s;){let i=t.charAt(s-r-1);if(i===e&&!n)r++;else if(i!==e&&n)r++;else break}return t.slice(0,s-r)}function ge(t){let e=t.split(`\n`),n=e.length-1;for(;n>=0&&x.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`\n`)}function At(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let s=0;s<t.length;s++)if(t[s]==="\\\\")s++;else if(t[s]===e[0])n++;else if(t[s]===e[1]&&(n--,n<0))return s;return n>0?-2:-1}function Lt(t,e=0){let n=e,s="";for(let r of t)if(r===" "){let i=4-n%4;s+=" ".repeat(i),n+=i}else s+=r,n++;return s}function de(t,e,n,s,r){let i=e.href,a=e.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let o={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:a,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,o}function It(t,e,n){let s=t.match(n.other.indentCodeCompensation);if(s===null)return e;let r=s[1];return e.split(`\n`).map(i=>{let a=i.match(n.other.beginningSpace);if(a===null)return i;let[l]=a;return l.length>=r.length?i.slice(r.length):i}).join(`\n`)}var j=class{options;rules;lexer;constructor(t){this.options=t||I}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:ge(e[0]),s=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:s}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],s=It(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let s=E(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:E(e[0],`\n`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:E(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=E(e[0],`\n`).split(`\n`),s="",r="",i=[];for(;n.length>0;){let a=!1,l=[],o;for(o=0;o<n.length;o++)if(this.rules.other.blockquoteStart.test(n[o]))l.push(n[o]),a=!0;else if(!a)l.push(n[o]);else break;n=n.slice(o);let c=l.join(`\n`),h=c.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}\n${c}`:c,r=r?`${r}\n${h}`:h;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=u,n.length===0)break;let p=i.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){let k=p,d=k.raw+`\n`+n.join(`\n`),m=this.blockquote(d);i[i.length-1]=m,s=s.substring(0,s.length-k.raw.length)+m.raw,r=r.substring(0,r.length-k.text.length)+m.text;break}else if(p?.type==="list"){let k=p,d=k.raw+`\n`+n.join(`\n`),m=this.list(d);i[i.length-1]=m,s=s.substring(0,s.length-p.raw.length)+m.raw,r=r.substring(0,r.length-k.raw.length)+m.raw,n=d.substring(i.at(-1).raw.length).split(`\n`);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\\\d{1,9}\\\\${n.slice(-1)}`:`\\\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let i=this.rules.other.listItemRegex(n),a=!1;for(;t;){let o=!1,c="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let u=Lt(e[2].split(`\n`,1)[0],e[1].length),p=t.split(`\n`,1)[0],k=!u.trim(),d=0;if(this.options.pedantic?(d=2,h=u.trimStart()):k?d=e[1].length+1:(d=u.search(this.rules.other.nonSpaceChar),d=d>4?1:d,h=u.slice(d),d+=e[1].length),k&&this.rules.other.blankLine.test(p)&&(c+=p+`\n`,t=t.substring(p.length+1),o=!0),!o){let m=this.rules.other.nextBulletRegex(d),w=this.rules.other.hrRegex(d),y=this.rules.other.fencesBeginRegex(d),$=this.rules.other.headingBeginRegex(d),H=this.rules.other.htmlBeginRegex(d),z=this.rules.other.blockquoteBeginRegex(d);for(;t;){let b=t.split(`\n`,1)[0],S;if(p=b,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),S=p):S=p.replace(this.rules.other.tabCharGlobal," "),y.test(p)||$.test(p)||H.test(p)||z.test(p)||m.test(p)||w.test(p))break;if(S.search(this.rules.other.nonSpaceChar)>=d||!p.trim())h+=`\n`+S.slice(d);else{if(k||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(u)||$.test(u)||w.test(u))break;h+=`\n`+p}k=!p.trim(),c+=b+`\n`,t=t.substring(b.length+1),u=S.slice(d)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let o of r.items){this.lexer.state.top=!1,o.tokens=this.lexer.blockTokens(o.text,[]);let c=o.tokens[0];if(o.task&&(c?.type==="text"||c?.type==="paragraph")){o.text=o.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}let h=this.rules.other.listTaskCheckbox.exec(o.raw);if(h){let u={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};o.checked=u.checked,r.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=u.raw+o.tokens[0].raw,o.tokens[0].text=u.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(u)):o.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):o.tokens.unshift(u)}}else o.task&&(o.task=!1);if(!r.loose){let h=o.tokens.filter(p=>p.type==="space"),u=h.length>0&&h.some(p=>this.rules.other.anyLine.test(p.raw));r.loose=u}}if(r.loose)for(let o of r.items){o.loose=!0;for(let c of o.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=ge(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:E(e[0],`\n`),href:s,title:r}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=fe(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`\n`):[],i={type:"table",raw:E(e[0],`\n`),header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of r)i.rows.push(fe(a,i.header.length).map((l,o)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[o]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:E(e[0],`\n`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`\n`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=E(n.slice(0,-1),"\\\\");if((n.length-i.length)%2===0)return}else{let i=At(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let s=e[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),de(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[s.toLowerCase()];if(!r){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return de(n,r,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,a,l=r,o=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+r);(s=c.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(a=[...i].length,s[3]||s[4]){l+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){o+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+o);let h=[...s[0]][0].length,u=t.slice(0,r+s.index+h+a);if(Math.min(r,a)%2){let k=u.slice(1,-1);return{type:"em",raw:u,text:k,tokens:this.lexer.inlineTokens(k)}}let p=u.slice(2,-2);return{type:"strong",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[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);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let s=this.rules.inline.delLDelim.exec(t);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,a,l=r,o=this.rules.inline.delRDelim;for(o.lastIndex=0,e=e.slice(-1*t.length+r);(s=o.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(a=[...i].length,a!==r))continue;if(s[3]||s[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let c=[...s[0]][0].length,h=t.slice(0,r+s.index+c+a),u=h.slice(r,-r);return{type:"del",raw:h,text:u,tokens:this.lexer.inlineTokens(u)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,s;return e[2]==="@"?(n=e[1],s="mailto:"+n):(n=e[1],s=n),{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,s;if(e[2]==="@")n=e[0],s="mailto:"+n;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);n=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},R=class G{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||I,this.options.tokenizer=this.options.tokenizer||new j,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:x,block:q.normal,inline:O.normal};this.options.pedantic?(n.block=q.pedantic,n.inline=O.pedantic):this.options.gfm&&(n.block=q.gfm,this.options.breaks?n.inline=O.breaks:n.inline=O.gfm),this.tokenizer.rules=n}static get rules(){return{block:q,inline:O}}static lex(e,n){return new G(n).lex(e)}static lexInline(e,n){return new G(n).inlineTokens(e)}lex(e){e=e.replace(x.carriageReturn,`\n`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],s=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(x.tabCharGlobal," ").replace(x.spaceLine,""));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(l=>(i=l.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let l=n.at(-1);i.raw.length===1&&l!==void 0?l.raw+=`\n`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.at(-1).src=l.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let l=1/0,o=e.slice(1),c;this.options.extensions.startBlock.forEach(h=>{c=h.call({lexer:this},o),typeof c=="number"&&c>=0&&(l=Math.min(l,c))}),l<1/0&&l>=0&&(a=e.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let l=n.at(-1);s&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(i),s=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let s=e;if(this.tokens.links){let l=Object.keys(this.tokens.links);l.length>0&&(s=s.replace(this.tokenizer.rules.inline.reflinkSearch,o=>l.includes(o.slice(o.lastIndexOf("[")+1,-1))?"["+"a".repeat(o.length-2)+"]":o))}s=s.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),s=s.replace(this.tokenizer.rules.inline.blockSkip,(l,o,c)=>{let h=c?c.length:0;return l.slice(0,h)+"["+"a".repeat(l.length-h-2)+"]"}),s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let r=!1,i="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=""),r=!1;let l;if(this.options.extensions?.inline?.some(c=>(l=c.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let c=n.at(-1);l.type==="text"&&c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(e,s,i)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(e,s,i)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),n.push(l);continue}let o=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),u;this.options.extensions.startInline.forEach(p=>{u=p.call({lexer:this},h),typeof u=="number"&&u>=0&&(c=Math.min(c,u))}),c<1/0&&c>=0&&(o=e.substring(0,c+1))}if(l=this.tokenizer.inlineText(o)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(i=l.raw.slice(-1)),r=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},F=class{options;parser;constructor(t){this.options=t||I}space(t){return""}code({text:t,lang:e,escaped:n}){let s=(e||"").match(x.notSpaceStart)?.[0],r=t.replace(x.endingNewline,"")+`\n`;return s?\'<pre><code class="language-\'+_(s)+\'">\'+(n?r:_(r,!0))+`</code></pre>\n`:"<pre><code>"+(n?r:_(r,!0))+`</code></pre>\n`}blockquote({tokens:t}){return`<blockquote>\n${this.parser.parse(t)}</blockquote>\n`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>\n`}hr(t){return`<hr>\n`}list(t){let e=t.ordered,n=t.start,s="";for(let a=0;a<t.items.length;a++){let l=t.items[a];s+=this.listitem(l)}let r=e?"ol":"ul",i=e&&n!==1?\' start="\'+n+\'"\':"";return"<"+r+i+`>\n`+s+"</"+r+`>\n`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>\n`}checkbox({checked:t}){return"<input "+(t?\'checked="" \':"")+\'disabled="" type="checkbox"> \'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>\n`}table(t){let e="",n="";for(let r=0;r<t.header.length;r++)n+=this.tablecell(t.header[r]);e+=this.tablerow({text:n});let s="";for(let r=0;r<t.rows.length;r++){let i=t.rows[r];n="";for(let a=0;a<i.length;a++)n+=this.tablecell(i[a]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>\n<thead>\n`+e+`</thead>\n`+s+`</table>\n`}tablerow({text:t}){return`<tr>\n${t}</tr>\n`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${_(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let s=this.parser.parseInline(n),r=pe(t);if(r===null)return s;t=r;let i=\'<a href="\'+t+\'"\';return e&&(i+=\' title="\'+_(e)+\'"\'),i+=">"+s+"</a>",i}image({href:t,title:e,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=pe(t);if(r===null)return _(n);t=r;let i=`<img src="${t}" alt="${_(n)}"`;return e&&(i+=` title="${_(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:_(t.text)}},se=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},T=class U{options;renderer;textRenderer;constructor(e){this.options=e||I,this.options.renderer=this.options.renderer||new F,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new se}static parse(e,n){return new U(n).parse(e)}static parseInline(e,n){return new U(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let r=e[s];if(this.options.extensions?.renderers?.[r.type]){let a=r,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){n+=l||"";continue}}let i=r;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let a=\'Token with "\'+i.type+\'" type was not found.\';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=l||"";continue}}let a=i;switch(a.type){case"escape":{s+=n.text(a);break}case"html":{s+=n.html(a);break}case"link":{s+=n.link(a);break}case"image":{s+=n.image(a);break}case"checkbox":{s+=n.checkbox(a);break}case"strong":{s+=n.strong(a);break}case"em":{s+=n.em(a);break}case"codespan":{s+=n.codespan(a);break}case"br":{s+=n.br(a);break}case"del":{s+=n.del(a);break}case"text":{s+=n.text(a);break}default:{let l=\'Token with "\'+a.type+\'" type was not found.\';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},N=class{options;block;constructor(t){this.options=t||I}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?R.lex:R.lexInline}provideParser(t=this.block){return t?T.parse:T.parseInline}},Ct=class{defaults=J();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=T;Renderer=F;TextRenderer=se;Lexer=R;Tokenizer=j;Hooks=N;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let s of t)switch(n=n.concat(e.call(this,s)),s.type){case"table":{let r=s;for(let i of r.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of r.rows)for(let a of i)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let r=s;n=n.concat(this.walkTokens(r.items,e));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{let a=r[i].flat(1/0);n=n.concat(this.walkTokens(a,e))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=e.renderers[r.name];i?e.renderers[r.name]=function(...a){let l=r.renderer.apply(this,a);return l===!1&&(l=i.apply(this,a)),l}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be \'block\' or \'inline\'");let i=e[r.level];i?i.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),s.extensions=e),n.renderer){let r=this.defaults.renderer||new F(this.defaults);for(let i in n.renderer){if(!(i in r))throw new Error(`renderer \'${i}\' does not exist`);if(["options","parser"].includes(i))continue;let a=i,l=n.renderer[a],o=r[a];r[a]=(...c)=>{let h=l.apply(r,c);return h===!1&&(h=o.apply(r,c)),h||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new j(this.defaults);for(let i in n.tokenizer){if(!(i in r))throw new Error(`tokenizer \'${i}\' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,l=n.tokenizer[a],o=r[a];r[a]=(...c)=>{let h=l.apply(r,c);return h===!1&&(h=o.apply(r,c)),h}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new N;for(let i in n.hooks){if(!(i in r))throw new Error(`hook \'${i}\' does not exist`);if(["options","block"].includes(i))continue;let a=i,l=n.hooks[a],o=r[a];N.passThroughHooks.has(i)?r[a]=c=>{if(this.defaults.async&&N.passThroughHooksRespectAsync.has(i))return(async()=>{let u=await l.call(r,c);return o.call(r,u)})();let h=l.call(r,c);return o.call(r,h)}:r[a]=(...c)=>{if(this.defaults.async)return(async()=>{let u=await l.apply(r,c);return u===!1&&(u=await o.apply(r,c)),u})();let h=l.apply(r,c);return h===!1&&(h=o.apply(r,c)),h}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,i=n.walkTokens;s.walkTokens=function(a){let l=[];return l.push(i.call(this,a)),r&&(l=l.concat(r.call(this,a))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return R.lex(t,e??this.defaults)}parser(t,e){return T.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let s={...n},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)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."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let a=r.hooks?await r.hooks.preprocess(e):e,l=await(r.hooks?await r.hooks.provideLexer(t):t?R.lex:R.lexInline)(a,r),o=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(o,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(t):t?T.parse:T.parseInline)(o,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(i);try{r.hooks&&(e=r.hooks.preprocess(e));let a=(r.hooks?r.hooks.provideLexer(t):t?R.lex:R.lexInline)(e,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(t):t?T.parse:T.parseInline)(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}onError(t,e){return n=>{if(n.message+=`\nPlease report this to https://github.com/markedjs/marked.`,t){let s="<p>An error occurred:</p><pre>"+_(n.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}},L=new Ct;function f(t,e){return L.parse(t,e)}f.options=f.setOptions=function(t){return L.setOptions(t),f.defaults=L.defaults,ke(f.defaults),f};f.getDefaults=J;f.defaults=I;f.use=function(...t){return L.use(...t),f.defaults=L.defaults,ke(f.defaults),f};f.walkTokens=function(t,e){return L.walkTokens(t,e)};f.parseInline=L.parseInline;f.Parser=T;f.parser=T.parse;f.Renderer=F;f.TextRenderer=se;f.Lexer=R;f.lexer=R.lex;f.Tokenizer=j;f.Hooks=N;f.parse=f;var Ut=f.options,Jt=f.setOptions,Kt=f.use,Vt=f.walkTokens,Yt=f.parseInline;var en=T.parse,tn=R.lex;var $e=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*(?:\\n|$)/,Pt=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*$/;function Mt(t){let e=1,n=0;for(;n<t.length;){let s=t.indexOf(`\n`,n),r=s===-1?t.slice(n):t.slice(n,s),i=Pt.exec(r);if(i){if(i[1]!==void 0)e++;else if(e--,e===0)return n}if(s===-1)break;n=s+1}return-1}var Ee=[{name:"container",level:"block",tokenizer(t){let e=$e.exec(t);if(!e)return;let n=t.slice(e[0].length),s=Mt(n);if(s<0)return;let r=n.slice(0,s),i=n.indexOf(`\n`,s),a=i===-1?n.length:i+1,l=e[0]+n.slice(0,a),o=this.lexer.blockTokens(r,[]);return{type:"container",raw:l,kind:e[1],tokens:o}},renderer(t){return t.raw}}];function ie(t){return t.includes(":::")===!1?!1:new RegExp($e.source,"m").test(t)}var Le="([^\\\\]\\\\s]+)",Ot=new RegExp(`^\\\\[\\\\^${Le}\\\\]`),Ie=new RegExp(`^ {0,3}\\\\[\\\\^${Le}\\\\]:[ \\\\t]*([^\\\\n]*)\\\\n?`);function ze(t){return/^[ \\t]*$/.test(t)}var Ae=/^(?: {4}| {0,3}\\t)/;function Nt(t){let e=0;for(;;){let s=e;for(;;){let l=t.indexOf(`\n`,s);if(l===-1)return n(e,!0);let o=t.slice(s,l);if(!ze(o))break;s=l+1}let r=t.indexOf(`\n`,s),i=r===-1?t.slice(s):t.slice(s,r+1),a=r===-1?t.slice(s):t.slice(s,r);if(!Ae.test(a))return n(e,!1);if(e=s+i.length,r===-1)return n(e,!0)}function n(s,r){let i=t.slice(0,s),a=i.split(`\n`).map(l=>ze(l)?"":l.replace(Ae,"")).join(`\n`);return{raw:i,body:a,open:r}}}function le(t){return t.includes("[^")===!1?!1:new RegExp(Ie.source,"m").test(t)}var Ce=[{name:"footnoteRef",level:"inline",tokenizer(t){let e=Ot.exec(t);if(e)return{type:"footnoteRef",raw:e[0],label:e[1]}},renderer(t){return t.raw}},{name:"footnoteDef",level:"block",tokenizer(t){let e=Ie.exec(t);if(!e)return;let n=t.slice(e[0].length),s=Nt(n),r=s.body.trim()?this.lexer.blockTokens(s.body,[]):[];return{type:"footnoteDef",raw:e[0]+s.raw,label:e[1],body:e[2],tokens:r}},renderer(t){return t.raw}}];function Me(t,e,n){let s=0;for(let r=e;r<n;r++)s+=t[r].raw.length;return s}function vt(t,e){let n=t;return n.links=e,n}function Oe(t,e){for(let n=e;n+1<t.length;n++)if(t[n].type==="paragraph"&&t[n+1].type==="paragraph")return n;return t.length}function Dt(t,e){return t[e-2]?.type!=="list"?!0:e+1<t.length}function Ne(t,e,n){let s=Math.min(t.length-2,n-1);for(let r=s;r>=e;r--)if(t[r].type==="space"&&Dt(t,r+1)!==!1)return r+1;return-1}function ve(t){let e=t.links;if(!e)return!1;for(let n in e)return!0;return!1}function De(t,e,n,s,r){let i=r;for(let a=e;a<n;a++){let l=t[a].raw;if(s.startsWith(l,i)===!1)return!1;i+=l.length}return!0}function B(t,e,n){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!0,degradedReason:n}}function Pe(t,e){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!1,degradedReason:null}}function Bt(t,e){if(ve(e))return B(t,e,"link-definition");if(t.includes("\\r"))return B(t,e,"carriage-return");if(ie(t))return B(t,e,"container");if(le(t))return B(t,e,"footnote-def");let n=Oe(e,0),s=Ne(e,1,n);if(s<0||De(e,0,s,t,0)===!1)return Pe(t,e);let r=Me(e,0,s);return{source:t,tail:t.slice(r),tokens:e,stableCount:s,stableOffset:r,degraded:!1,degradedReason:null}}function ae(t){let e=f.lexer(t);return{tokens:e,cache:Bt(t,e),charsLexed:t.length,reusedTokens:0}}function D(t,e){let n=f.lexer(t);return{tokens:n,cache:B(t,n,e),charsLexed:t.length,reusedTokens:0}}function Be(t,e){let n=t.source+e;if(t.degraded)return D(n,t.degradedReason??"link-definition");if(e.includes("\\r"))return D(n,"carriage-return");if(t.stableCount===0)return ae(n);let s=t.tail+e;if(ie(s))return D(n,"container");if(le(s))return D(n,"footnote-def");let r=f.lexer(s);if(ve(r))return D(n,"link-definition");let i=t.tokens.slice(0,t.stableCount),a=vt([...i,...r],r.links),l=t.stableCount,o=t.stableOffset,c=s,h=Ne(a,t.stableCount+1,Oe(a,t.stableCount));if(h>t.stableCount&&De(a,t.stableCount,h,s,0)){let u=Me(a,t.stableCount,h);l=h,o=t.stableOffset+u,c=s.slice(u)}return{tokens:a,cache:{source:n,tail:c,tokens:a,stableCount:l,stableOffset:o,degraded:!1,degradedReason:null},charsLexed:s.length,reusedTokens:t.stableCount}}var qt=/^ {0,3}\\*\\[([^\\]\\n]+)\\]:[ \\t]*([^\\n]*)(?:\\n|$)/,qe=[{name:"abbrDef",level:"block",tokenizer(t){let e=qt.exec(t);if(e)return{type:"abbrDef",raw:e[0],term:e[1],definition:e[2]}},renderer(t){return t.raw}}];var Zt=Object.freeze({grinning:"\\u{1F600}",smiley:"\\u{1F603}",smile:"\\u{1F604}",grin:"\\u{1F601}",laughing:"\\u{1F606}",satisfied:"\\u{1F606}",sweat_smile:"\\u{1F605}",rofl:"\\u{1F923}",joy:"\\u{1F602}",slightly_smiling_face:"\\u{1F642}",upside_down_face:"\\u{1F643}",wink:"\\u{1F609}",blush:"\\u{1F60A}",innocent:"\\u{1F607}",heart_eyes:"\\u{1F60D}",star_struck:"\\u{1F929}",kissing_heart:"\\u{1F618}",yum:"\\u{1F60B}",stuck_out_tongue:"\\u{1F61B}",stuck_out_tongue_winking_eye:"\\u{1F61C}",stuck_out_tongue_closed_eyes:"\\u{1F61D}",hugs:"\\u{1F917}",thinking:"\\u{1F914}",neutral_face:"\\u{1F610}",expressionless:"\\u{1F611}",no_mouth:"\\u{1F636}",smirk:"\\u{1F60F}",unamused:"\\u{1F612}",roll_eyes:"\\u{1F644}",grimacing:"\\u{1F62C}",relieved:"\\u{1F60C}",pensive:"\\u{1F614}",sleepy:"\\u{1F62A}",sleeping:"\\u{1F634}",mask:"\\u{1F637}",dizzy_face:"\\u{1F635}",sunglasses:"\\u{1F60E}",nerd_face:"\\u{1F913}",confused:"\\u{1F615}",worried:"\\u{1F61F}",open_mouth:"\\u{1F62E}",hushed:"\\u{1F62F}",astonished:"\\u{1F632}",flushed:"\\u{1F633}",pleading_face:"\\u{1F97A}",fearful:"\\u{1F628}",cold_sweat:"\\u{1F630}",cry:"\\u{1F622}",sob:"\\u{1F62D}",scream:"\\u{1F631}",disappointed:"\\u{1F61E}",sweat:"\\u{1F613}",weary:"\\u{1F629}",tired_face:"\\u{1F62B}",triumph:"\\u{1F624}",rage:"\\u{1F621}",angry:"\\u{1F620}",smiling_imp:"\\u{1F608}",imp:"\\u{1F47F}",skull:"\\u{1F480}",clown_face:"\\u{1F921}",poop:"\\u{1F4A9}",ghost:"\\u{1F47B}",alien:"\\u{1F47D}",robot:"\\u{1F916}",thumbsup:"\\u{1F44D}","+1":"\\u{1F44D}",thumbsdown:"\\u{1F44E}","-1":"\\u{1F44E}",punch:"\\u{1F44A}",fist:"\\u270A",clap:"\\u{1F44F}",raised_hands:"\\u{1F64C}",open_hands:"\\u{1F450}",handshake:"\\u{1F91D}",pray:"\\u{1F64F}",muscle:"\\u{1F4AA}",eyes:"\\u{1F440}",wave:"\\u{1F44B}",point_up:"\\u261D\\uFE0F",point_down:"\\u{1F447}",point_left:"\\u{1F448}",point_right:"\\u{1F449}",ok_hand:"\\u{1F44C}",v:"\\u270C\\uFE0F",crossed_fingers:"\\u{1F91E}",heart:"\\u2764\\uFE0F",broken_heart:"\\u{1F494}",two_hearts:"\\u{1F495}",sparkling_heart:"\\u{1F496}",heartpulse:"\\u{1F497}",blue_heart:"\\u{1F499}",green_heart:"\\u{1F49A}",yellow_heart:"\\u{1F49B}",orange_heart:"\\u{1F9E1}",purple_heart:"\\u{1F49C}",black_heart:"\\u{1F5A4}",white_heart:"\\u{1F90D}",100:"\\u{1F4AF}",boom:"\\u{1F4A5}",collision:"\\u{1F4A5}",dizzy:"\\u{1F4AB}",sweat_drops:"\\u{1F4A6}",dash:"\\u{1F4A8}",zzz:"\\u{1F4A4}",fire:"\\u{1F525}",sparkles:"\\u2728",star:"\\u2B50",star2:"\\u{1F31F}",tada:"\\u{1F389}",confetti_ball:"\\u{1F38A}",balloon:"\\u{1F388}",gift:"\\u{1F381}",rocket:"\\u{1F680}",dart:"\\u{1F3AF}",trophy:"\\u{1F3C6}",warning:"\\u26A0\\uFE0F",no_entry_sign:"\\u{1F6AB}",white_check_mark:"\\u2705",x:"\\u274C",heavy_check_mark:"\\u2714\\uFE0F",question:"\\u2753",exclamation:"\\u2757",bulb:"\\u{1F4A1}",bell:"\\u{1F514}",computer:"\\u{1F4BB}",iphone:"\\u{1F4F1}",link:"\\u{1F517}",lock:"\\u{1F512}",unlock:"\\u{1F513}",key:"\\u{1F511}",mag:"\\u{1F50D}",bug:"\\u{1F41B}",package:"\\u{1F4E6}",memo:"\\u{1F4DD}",pencil2:"\\u270F\\uFE0F",book:"\\u{1F4D6}",books:"\\u{1F4DA}",pushpin:"\\u{1F4CC}",paperclip:"\\u{1F4CE}",calendar:"\\u{1F4C5}",file_folder:"\\u{1F4C1}",hammer:"\\u{1F528}",wrench:"\\u{1F527}",gear:"\\u2699\\uFE0F",chart_with_upwards_trend:"\\u{1F4C8}",chart_with_downwards_trend:"\\u{1F4C9}",bar_chart:"\\u{1F4CA}",construction:"\\u{1F6A7}",hourglass:"\\u23F3",stopwatch:"\\u23F1\\uFE0F",pizza:"\\u{1F355}",coffee:"\\u2615",beer:"\\u{1F37A}",cake:"\\u{1F382}",birthday:"\\u{1F382}",apple:"\\u{1F34E}",rainbow:"\\u{1F308}",sun_with_face:"\\u{1F31E}",crescent_moon:"\\u{1F319}",earth_americas:"\\u{1F30E}",dog:"\\u{1F436}",cat:"\\u{1F431}",fox_face:"\\u{1F98A}",bear:"\\u{1F43B}",panda_face:"\\u{1F43C}",monkey_face:"\\u{1F435}",see_no_evil:"\\u{1F648}",hear_no_evil:"\\u{1F649}",speak_no_evil:"\\u{1F64A}"}),jt=/^:([A-Za-z0-9_+-]+):/,Ze=[{name:"emoji",level:"inline",start(t){return t.match(/:/)?.index},tokenizer(t){let e=jt.exec(t);if(!e)return;let n=Zt[e[1]];if(n!==void 0)return{type:"emoji",raw:e[0],text:n}},renderer(t){return t.raw}}];var Ft=/^\\+\\+(?!\\s)((?:\\\\[\\s\\S]|(?!\\+\\+)[\\s\\S])+?)(?<!\\s)\\+\\+/,Xt=/^==(?!\\s)((?:\\\\[\\s\\S]|(?!==)[\\s\\S])+?)(?<!\\s)==/,je=[{name:"ins",level:"inline",start(t){return t.match(/(?<!\\\\)\\+\\+(?!\\s)/)?.index},tokenizer(t){let e=Ft.exec(t);if(e)return{type:"ins",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}},{name:"mark",level:"inline",start(t){return t.match(/(?<!\\\\)==(?!\\s)/)?.index},tokenizer(t){let e=Xt.exec(t);if(e)return{type:"mark",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var Qt=/^\\^((?:\\\\[\\s\\S]|[^\\s^\\\\])+)\\^/,Fe=[{name:"sup",level:"inline",start(t){return t.match(/(?<!\\\\)\\^(?!\\s)/)?.index},tokenizer(t){let e=Qt.exec(t);if(e)return{type:"sup",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var Ht=0;function Wt(t){if(typeof t!="string"||typeof performance.mark!="function"||typeof performance.measure!="function")return null;let e=Ht++,n={name:t,startMark:`${t}:start:${e}`,endMark:`${t}:end:${e}`};try{return performance.mark(n.startMark),n}catch{return null}}function Gt(t){if(t)try{performance.mark(t.endMark),performance.measure(t.name,t.startMark,t.endMark)}catch{}finally{try{performance.clearMarks?.(t.startMark),performance.clearMarks?.(t.endMark)}catch{}}}f.use({extensions:[...Ce,...Fe,...je,...Ze,...Ee,...qe,{name:"blockMath",level:"block",start(t){return t.match(/^ {0,3}\\$\\$/m)?.index},tokenizer(t){let e=/^ {0,3}\\$\\$((?:(?!\\n[ \\t]*\\n)[\\s\\S])+?)\\$\\$[ \\t]*(?:\\n|$)/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1].trim()}},renderer(t){return t.raw}},{name:"inlineMath",level:"inline",start(t){return t.match(/(?<![\\\\$])\\$(?![$\\s])/)?.index},tokenizer(t){let e=/^\\$(?![$\\s\\d])((?:\\\\\\$|[^$\\n])*?)(?<!\\s)\\$(?!\\d)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1].trim()}},renderer(t){return t.raw}}]});var M=new Map;self.onmessage=t=>{let e=t.data;if(typeof e!="object"||e===null)return;let{id:n,text:s,append:r,expectedLength:i,oldRaws:a,instance:l,baseVersion:o,dispose:c,userTimingName:h}=e;if(c===!0){typeof l=="string"&&M.delete(l);return}let u=typeof l=="string"?l:null,p=typeof o=="number"?o:null,k,d=null,m=null;if(typeof r=="string"){if(u===null||p===null){self.postMessage({id:n,needResync:!0});return}let w=M.get(u);if(!w||w.version!==p){self.postMessage({id:n,needResync:!0});return}if(typeof i=="number"&&w.lex.source.length+r.length!==i){M.delete(u),self.postMessage({id:n,needResync:!0});return}let y=w.lex;k=()=>Be(y,r),m=y.tokens}else if(typeof s=="string"){let w=s;if(k=()=>ae(w),Array.isArray(a))d=a;else if(u!==null&&p!==null){let y=M.get(u);if(y&&y.version===p)m=y.lex.tokens;else{self.postMessage({id:n,needResync:!0});return}}}else return;try{let w=typeof h=="string"?Wt(h):null,y=performance.now(),$;try{$=k()}finally{w&&Gt(w)}let H=performance.now()-y,z=$.tokens,b=0;if(d!==null){let S=Math.min(d.length,z.length);for(;b<S&&d[b]===z[b].raw;b++);}else if(m!==null){let S=m,oe=Math.min(S.length,z.length);for(b=Math.min($.reusedTokens,oe);b<oe&&S[b].raw===z[b].raw;b++);}u!==null&&p!==null&&M.set(u,{version:p+1,lex:$.cache}),self.postMessage({id:n,matchLen:b,tail:z.slice(b),lexerMs:H,sourceCharsLexed:$.charsLexed})}catch(w){u!==null&&M.delete(u),self.postMessage({id:n,error:String(w)})}};})();\n';
3134
+ var WORKER_SOURCE_STRING = '"use strict";(()=>{function K(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var C=K();function ke(t){C=t}var L={exec:()=>null};function P(t){let e=[];return n=>{let s=Math.max(0,Math.min(3,n-1)),r=e[s];return r||(r=t(s),e[s]=r),r}}function g(t,e=""){let n=typeof t=="string"?t:t.source,s={replace:(r,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(b.caret,"$1"),n=n.replace(r,a),s},getRegex:()=>new RegExp(n,e)};return s}var Fe=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),b={codeRemoveIndent:/^(?: {1,4}| {0,3}\\t)/gm,outputLinkReplace:/\\\\([\\[\\]])/g,indentCodeCompensation:/^(\\s+)(?:```)/,beginningSpace:/^\\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\\n/g,tabCharGlobal:/\\t/g,multipleSpaceGlobal:/\\s+/g,blankLine:/^[ \\t]*$/,doubleBlankLine:/\\n[ \\t]*\\n[ \\t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\\n {0,3}((?:=+|-+) *)(?=\\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \\t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\\[[ xX]\\] +\\S/,listReplaceTask:/^\\[[ xX]\\] +/,listTaskCheckbox:/\\[[ xX]\\]/,anyLine:/\\n.*\\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\\||\\| *$/g,tableRowBlankLine:/\\n[ \\t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\\s|>)/i,endPreScriptTag:/^<\\/(pre|code|kbd|script)(\\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^\'"]*[^\\s])\\s+([\'"])(.*)\\2/,unicodeAlphaNumeric:/[\\p{L}\\p{N}]/u,escapeTest:/[&<>"\']/,escapeReplace:/[&<>"\']/g,escapeTestNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/,escapeReplaceNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/g,caret:/(^|[^\\[])\\^/g,percentDecode:/%25/g,findPipe:/\\|/g,splitPipe:/ \\|/,slashPipe:/\\\\\\|/g,carriageReturn:/\\r\\n|\\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\\S*/,endingNewline:/\\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\\\n]*)?(?:\\\\n|$))`),nextBulletRegex:P(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:P(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:P(t=>new RegExp(`^ {0,${t}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:P(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:P(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:P(t=>new RegExp(`^ {0,${t}}>`))},Xe=/^(?:[ \\t]*(?:\\n|$))+/,He=/^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/,Ge=/^ {0,3}(`{3,}(?=[^`\\n]*(?:\\n|$))|~{3,})([^\\n]*)(?:\\n|$)(?:|([\\s\\S]*?)(?:\\n|$))(?: {0,3}\\1[~`]* *(?=\\n|$)|$)/,D=/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/,Ue=/^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/,V=/ {0,3}(?:[*+-]|\\d{1,9}[.)])/,xe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,be=g(xe).replace(/bull/g,V).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(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/\\|table/g,"").getRegex(),We=g(xe).replace(/bull/g,V).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(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/table/g,/ {0,3}\\|?(?:[:\\- ]*\\|)+[\\:\\- ]*\\n/).getRegex(),Y=/^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \\t]+\\n)[^\\n]+)*)/,Je=/^[^\\n]+/,ee=/(?!\\s*\\])(?:\\\\[\\s\\S]|[^\\[\\]\\\\])+/,Ke=g(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace("label",ee).replace("title",/(?:"(?:\\\\"?|[^"\\\\])*"|\'[^\'\\n]*(?:\\n[^\'\\n]+)*\\n?\'|\\([^()]*\\))/).getRegex(),Ve=g(/^(bull)([ \\t][^\\n]*?)?(?:\\n|$)/).replace(/bull/g,V).getRegex(),H="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",te=/<!--(?:-?>|[\\s\\S]*?(?:-->|$))/,Ye=g("^ {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[ ]*)+\\\\n|$)|<(?!script|pre|style|textarea)([a-z][\\\\w-]*)(?:attribute)*? */?>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$)|</(?!script|pre|style|textarea)[a-z][\\\\w-]*\\\\s*>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$))","i").replace("comment",te).replace("tag",H).replace("attribute",/ +[a-zA-Z:_][\\w.:-]*(?: *= *"[^"\\n]*"| *= *\'[^\'\\n]*\'| *= *[^\\s"\'=<>`]+)?/).getRegex(),me=t=>g(Y).replace("hr",D).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",t).replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex(),et=me(/ {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]/),tt=me(/ {0,3}(?:[*+-]|\\d{1,9}[.)])(?:[ \\t]|\\n|$)/),nt=g(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace("paragraph",tt).getRegex(),ne={blockquote:nt,code:He,def:Ke,fences:Ge,heading:Ue,hr:D,html:Ye,lheading:be,list:Ve,newline:Xe,paragraph:et,table:L,text:Je},ce=g("^ *([^\\\\n ].*)\\\\n {0,3}((?:\\\\| *)?:?-+:? *(?:\\\\| *:?-+:? *)*(?:\\\\| *)?)(?:\\\\n((?:(?! *\\\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\\\n|$))*)\\\\n*|$)").replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex(),rt={...ne,lheading:We,table:ce,paragraph:g(Y).replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("table",ce).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]+[^ \\\\t\\\\n]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex()},st={...ne,html:g(`^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\\\s[^\'"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))`).replace("comment",te).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:L,lheading:/^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,paragraph:g(Y).replace("hr",D).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",be).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},it=/^\\\\([!"#$%&\'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/,lt=/^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/,we=/^( {2,}|\\\\)\\n(?!\\s*$)/,at=/^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/,$=/[\\p{P}\\p{S}]/u,M=/[\\s\\p{P}\\p{S}]/u,B=/[^\\s\\p{P}\\p{S}]/u,ot=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,M).getRegex(),ct=/[\\p{Pi}\\p{Ps}"\']/u,ye=/(?!~)[\\p{P}\\p{S}]/u,pt=/(?!~)[\\s\\p{P}\\p{S}]/u,ut=/(?:[^\\s\\p{P}\\p{S}]|~)/u,ht=g(/link|precode-code|html/,"g").replace("link",/\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)/).replace("precode-",Fe?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Re=/^(?:\\*+(?:((?!\\*)punct)|([^\\s*]))?)|^_+(?:((?!_)punct)|([^\\s_]))?/,gt=g(Re,"u").replace(/punct/g,$).getRegex(),ft=g(Re,"u").replace(/punct/g,ye).getRegex(),dt=/^(?:\\*+(?:((?!\\*)(?!openQuote)punct)|([^\\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\\s_]))?/,kt=g(dt,"u").replace(/openQuote/g,ct).replace(/punct/g,$).getRegex(),Te="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)",xt=g(Te,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,$).getRegex(),bt=g(Te,"gu").replace(/notPunctSpace/g,ut).replace(/punctSpace/g,pt).replace(/punct/g,ye).getRegex(),mt="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)[\\\\s](\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|(?:(?!\\\\*)punct|notPunctSpace)(\\\\*+)(?!\\\\*)(?=notPunctSpace)",wt=g(mt,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,$).getRegex(),yt=g("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,$).getRegex(),Rt="^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\\\s](_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Tt=g(Rt,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,$).getRegex(),_t=g(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,$).getRegex(),St="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",$t=g(St,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,$).getRegex(),Et=g(/\\\\(punct)/,"gu").replace(/punct/g,$).getRegex(),zt=g(/^<(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(),At=g(te).replace("(?:-->|$)","-->").getRegex(),Lt=g("^comment|^</[a-zA-Z][\\\\w:-]*\\\\s*>|^<[a-zA-Z][\\\\w-]*(?:attribute)*?\\\\s*/?>|^<\\\\?[\\\\s\\\\S]*?\\\\?>|^<![a-zA-Z]+\\\\s[\\\\s\\\\S]*?>|^<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?\\\\]\\\\]>").replace("comment",At).replace("attribute",/\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*"[^"]*"|\\s*=\\s*\'[^\']*\'|\\s*=\\s*[^\\s"\'=<>`]+)?/).getRegex(),Q=/(?:\\[(?:\\\\[\\s\\S]|[^\\[\\]\\\\])*\\]|\\\\[\\s\\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\\])|[^\\[\\]\\\\`])*?/,It=g(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]+(?:\\n[ \\t]*)?|\\n[ \\t]*)(title))?\\s*\\)/).replace("label",Q).replace("href",/<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]+|(?=\\))/).replace("title",/"(?:\\\\"?|[^"\\\\])*"|\'(?:\\\\\'?|[^\'\\\\])*\'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex(),_e=g(/^!?\\[(label)\\]\\[(ref)\\]/).replace("label",Q).replace("ref",ee).getRegex(),Se=g(/^!?\\[(ref)\\](?:\\[\\])?/).replace("ref",ee).getRegex(),Ct=g("reflink|nolink(?!\\\\()","g").replace("reflink",_e).replace("nolink",Se).getRegex(),pe=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,re={_backpedal:L,anyPunctuation:Et,autolink:zt,blockSkip:ht,br:we,code:lt,del:L,delLDelim:L,delRDelim:L,emStrongLDelim:gt,emStrongRDelimAst:xt,emStrongRDelimUnd:yt,escape:it,link:It,nolink:Se,punctuation:ot,reflink:_e,reflinkSearch:Ct,tag:Lt,text:at,url:L},Pt={...re,emStrongLDelim:kt,emStrongRDelimAst:wt,emStrongRDelimUnd:Tt,link:g(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",Q).getRegex(),reflink:g(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",Q).getRegex()},U={...re,emStrongRDelimAst:bt,emStrongLDelim:ft,delLDelim:_t,delRDelim:$t,url:g(/^((?:protocol):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/).replace("protocol",pe).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_\'"~()&]+|\\([^)]*\\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_\'"~)]+(?!$))+/,del:/^(~~?)(?=[^\\s~])((?:\\\\[\\s\\S]|[^\\\\])*?(?:\\\\[\\s\\S]|[^\\s~\\\\]))\\1(?=[^~]|$)/,text:g(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|protocol:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)))/).replace("protocol",pe).getRegex()},Mt={...U,br:g(we).replace("{2,}","*").getRegex(),text:g(U.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},j={normal:ne,gfm:rt,pedantic:st},N={normal:re,gfm:U,breaks:Mt,pedantic:Pt},Ot={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"},ue=t=>Ot[t];function S(t,e){if(e){if(b.escapeTest.test(t))return t.replace(b.escapeReplace,ue)}else if(b.escapeTestNoEncode.test(t))return t.replace(b.escapeReplaceNoEncode,ue);return t}function he(t){try{t=encodeURI(t).replace(b.percentDecode,"%")}catch{return null}return t}function ge(t,e){let n=t.replace(b.findPipe,(i,a,l)=>{let o=!1,c=a;for(;--c>=0&&l[c]==="\\\\";)o=!o;return o?"|":" |"}),s=n.split(b.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(b.slashPipe,"|");return s}function z(t,e,n){let s=t.length;if(s===0)return"";let r=0;for(;r<s;){let i=t.charAt(s-r-1);if(i===e&&!n)r++;else if(i!==e&&n)r++;else break}return t.slice(0,s-r)}function fe(t){let e=t.split(`\n`),n=e.length-1;for(;n>=0&&b.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`\n`)}function Nt(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let s=0;s<t.length;s++)if(t[s]==="\\\\")s++;else if(t[s]===e[0])n++;else if(t[s]===e[1]&&(n--,n<0))return s;return n>0?-2:-1}function vt(t,e=0){let n=e,s="";for(let r of t)if(r===" "){let i=4-n%4;s+=" ".repeat(i),n+=i}else s+=r,n++;return s}function de(t,e,n,s,r){let i=e.href,a=e.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let o={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:a,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,o}function Dt(t,e,n){let s=t.match(n.other.indentCodeCompensation);if(s===null)return e;let r=s[1];return e.split(`\n`).map(i=>{let a=i.match(n.other.beginningSpace);if(a===null)return i;let[l]=a;return l.length>=r.length?i.slice(r.length):i}).join(`\n`)}var F=class{options;rules;lexer;constructor(t){this.options=t||C}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:fe(e[0]),s=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:s}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],s=Dt(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let s=z(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:z(e[0],`\n`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:z(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=z(e[0],`\n`).split(`\n`),s="",r="",i=[];for(;n.length>0;){let a=!1,l=[],o;for(o=0;o<n.length;o++)if(this.rules.other.blockquoteStart.test(n[o]))l.push(n[o]),a=!0;else if(!a)l.push(n[o]);else break;n=n.slice(o);let c=l.join(`\n`),u=c.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}\n${c}`:c,r=r?`${r}\n${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=p,n.length===0)break;let h=i.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let k=h,d=n.join(`\n`),m=k.raw+`\n`+d.replace(this.rules.other.blockquoteSetextReplace2,""),x=this.blockquote(m);i[i.length-1]=x,s=`${s}\n${d}`,r=r.substring(0,r.length-k.text.length)+x.text;break}else if(h?.type==="list"){let k=h,d=k.raw+`\n`+n.join(`\n`),m=this.list(d);i[i.length-1]=m,s=s.substring(0,s.length-h.raw.length)+m.raw,r=r.substring(0,r.length-k.raw.length)+m.raw,n=d.substring(i.at(-1).raw.length).split(`\n`);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\\\d{1,9}\\\\${n.slice(-1)}`:`\\\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let i=this.rules.other.listItemRegex(n),a=!1;for(;t;){let o=!1,c="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let p=vt(e[2].split(`\n`,1)[0],e[1].length),h=t.split(`\n`,1)[0],k=!p.trim(),d=0;if(this.options.pedantic?(d=2,u=p.trimStart()):k?d=e[1].length+1:(d=p.search(this.rules.other.nonSpaceChar),d=d>4?1:d,u=p.slice(d),d+=e[1].length),k&&this.rules.other.blankLine.test(h)&&(c+=h+`\n`,t=t.substring(h.length+1),o=!0),!o){let m=this.rules.other.nextBulletRegex(d),x=this.rules.other.hrRegex(d),y=this.rules.other.fencesBeginRegex(d),E=this.rules.other.headingBeginRegex(d),G=this.rules.other.htmlBeginRegex(d),A=this.rules.other.blockquoteBeginRegex(d);for(;t;){let w=t.split(`\n`,1)[0],_;if(h=w,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),_=h):_=h.replace(this.rules.other.tabCharGlobal," "),y.test(h)||E.test(h)||G.test(h)||A.test(h)||m.test(h)||x.test(h))break;if(_.search(this.rules.other.nonSpaceChar)>=d||!h.trim())u+=`\n`+_.slice(d);else{if(k||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(p)||E.test(p)||x.test(p))break;u+=`\n`+h}k=!h.trim(),c+=w+`\n`,t=t.substring(w.length+1),p=_.slice(d)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let o of r.items){this.lexer.state.top=!1,o.tokens=this.lexer.blockTokens(o.text,[]);let c=o.tokens[0];if(o.task&&(c?.type==="text"||c?.type==="paragraph")){o.text=o.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(o.raw);if(u){let p={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};o.checked=p.checked,r.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=p.raw+o.tokens[0].raw,o.tokens[0].text=p.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(p)):o.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):o.tokens.unshift(p)}}else o.task&&(o.task=!1);if(!r.loose){let u=o.tokens.filter(h=>h.type==="space"),p=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));r.loose=p}}if(r.loose)for(let o of r.items){o.loose=!0;for(let c of o.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=fe(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:z(e[0],`\n`),href:s,title:r}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=ge(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`\n`):[],i={type:"table",raw:z(e[0],`\n`),header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of r)i.rows.push(ge(a,i.header.length).map((l,o)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[o]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:z(e[0],`\n`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`\n`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=z(n.slice(0,-1),"\\\\");if((n.length-i.length)%2===0)return}else{let i=Nt(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let s=e[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),de(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[s.toLowerCase()];if(!r){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return de(n,r,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,a,l=r,o=0,c=s[0][0],u=n===c,p=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,e=e.slice(-1*t.length+r);(s=p.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(a=[...i].length,s[3]||s[4]){l+=a;continue}else if(s[5]||s[6]){if(r%3&&!((r+a)%3)){o+=a;continue}if(u)break}if(l-=a,l>0)continue;a=Math.min(a,a+l+o);let h=[...s[0]][0].length,k=t.slice(0,r+s.index+h+a);if(Math.min(r,a)%2){let m=k.slice(1,-1);return{type:"em",raw:k,text:m,tokens:this.lexer.inlineTokens(m)}}let d=k.slice(2,-2);return{type:"strong",raw:k,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[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);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let s=this.rules.inline.delLDelim.exec(t);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,a,l=r,o=this.rules.inline.delRDelim;for(o.lastIndex=0,e=e.slice(-1*t.length+r);(s=o.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(a=[...i].length,a!==r))continue;if(s[3]||s[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let c=[...s[0]][0].length,u=t.slice(0,r+s.index+c+a),p=u.slice(r,-r);return{type:"del",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,s;return e[2]==="@"?(n=e[1],s="mailto:"+n):(n=e[1],s=n),{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,s;if(e[2]==="@")n=e[0],s="mailto:"+n;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);n=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},R=class W{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||C,this.options.tokenizer=this.options.tokenizer||new F,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:b,block:j.normal,inline:N.normal};this.options.pedantic?(n.block=j.pedantic,n.inline=N.pedantic):this.options.gfm&&(n.block=j.gfm,this.options.breaks?n.inline=N.breaks:n.inline=N.gfm),this.tokenizer.rules=n}static get rules(){return{block:j,inline:N}}static lex(e,n){return new W(n).lex(e)}static lexInline(e,n){return new W(n).inlineTokens(e)}lex(e){e=e.replace(b.carriageReturn,`\n`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],s=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(b.tabCharGlobal," ").replace(b.spaceLine,""));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(l=>(i=l.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let l=n.at(-1);i.raw.length===1&&l!==void 0?l.raw+=`\n`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.at(-1).src=l.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let l=1/0,o=e.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},o),typeof c=="number"&&c>=0&&(l=Math.min(l,c))}),l<1/0&&l>=0&&(a=e.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let l=n.at(-1);s&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(i),s=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let s=e;if(this.tokens.links){let l=Object.keys(this.tokens.links);l.length>0&&(s=s.replace(this.tokenizer.rules.inline.reflinkSearch,o=>l.includes(o.slice(o.lastIndexOf("[")+1,-1))?"["+"a".repeat(o.length-2)+"]":o))}s=s.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),s=s.replace(this.tokenizer.rules.inline.blockSkip,(l,o,c)=>{let u=c?c.length:0;return l.slice(0,u)+"["+"a".repeat(l.length-u-2)+"]"}),s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let r=!1,i="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=""),r=!1;let l;if(this.options.extensions?.inline?.some(c=>(l=c.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let c=n.at(-1);l.type==="text"&&c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(e,s,i)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(e,s,i)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),n.push(l);continue}let o=e;if(this.options.extensions?.startInline){let c=1/0,u=e.slice(1),p;this.options.extensions.startInline.forEach(h=>{p=h.call({lexer:this},u),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(o=e.substring(0,c+1))}if(l=this.tokenizer.inlineText(o)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(i=l.raw.slice(-1)),r=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},X=class{options;parser;constructor(t){this.options=t||C}space(t){return""}code({text:t,lang:e,escaped:n}){let s=(e||"").match(b.notSpaceStart)?.[0],r=t.replace(b.endingNewline,"")+`\n`;return s?\'<pre><code class="language-\'+S(s)+\'">\'+(n?r:S(r,!0))+`</code></pre>\n`:"<pre><code>"+(n?r:S(r,!0))+`</code></pre>\n`}blockquote({tokens:t}){return`<blockquote>\n${this.parser.parse(t)}</blockquote>\n`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>\n`}hr(t){return`<hr>\n`}list(t){let e=t.ordered,n=t.start,s="";for(let a=0;a<t.items.length;a++){let l=t.items[a];s+=this.listitem(l)}let r=e?"ol":"ul",i=e&&n!==1?\' start="\'+n+\'"\':"";return"<"+r+i+`>\n`+s+"</"+r+`>\n`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>\n`}checkbox({checked:t}){return"<input "+(t?\'checked="" \':"")+\'disabled="" type="checkbox"> \'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>\n`}table(t){let e="",n="";for(let r=0;r<t.header.length;r++)n+=this.tablecell(t.header[r]);e+=this.tablerow({text:n});let s="";for(let r=0;r<t.rows.length;r++){let i=t.rows[r];n="";for(let a=0;a<i.length;a++)n+=this.tablecell(i[a]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>\n<thead>\n`+e+`</thead>\n`+s+`</table>\n`}tablerow({text:t}){return`<tr>\n${t}</tr>\n`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${S(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let s=this.parser.parseInline(n),r=he(t);if(r===null)return s;t=r;let i=\'<a href="\'+t+\'"\';return e&&(i+=\' title="\'+S(e)+\'"\'),i+=">"+s+"</a>",i}image({href:t,title:e,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=he(t);if(r===null)return S(n);t=r;let i=`<img src="${t}" alt="${S(n)}"`;return e&&(i+=` title="${S(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:S(t.text)}},se=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},T=class J{options;renderer;textRenderer;constructor(e){this.options=e||C,this.options.renderer=this.options.renderer||new X,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new se}static parse(e,n){return new J(n).parse(e)}static parseInline(e,n){return new J(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let r=e[s];if(this.options.extensions?.renderers?.[r.type]){let a=r,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=l||"";continue}}let i=r;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let a=\'Token with "\'+i.type+\'" type was not found.\';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(i.type)){s+=l||"";continue}}let a=i;switch(a.type){case"escape":{s+=n.text(a);break}case"html":{s+=n.html(a);break}case"link":{s+=n.link(a);break}case"image":{s+=n.image(a);break}case"checkbox":{s+=n.checkbox(a);break}case"strong":{s+=n.strong(a);break}case"em":{s+=n.em(a);break}case"codespan":{s+=n.codespan(a);break}case"br":{s+=n.br(a);break}case"del":{s+=n.del(a);break}case"text":{s+=n.text(a);break}default:{let l=\'Token with "\'+a.type+\'" type was not found.\';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},v=class{options;block;constructor(t){this.options=t||C}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?R.lex:R.lexInline}provideParser(t=this.block){return t?T.parse:T.parseInline}},Bt=class{defaults=K();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=T;Renderer=X;TextRenderer=se;Lexer=R;Tokenizer=F;Hooks=v;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let s of t)switch(n=n.concat(e.call(this,s)),s.type){case"table":{let r=s;for(let i of r.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of r.rows)for(let a of i)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let r=s;n=n.concat(this.walkTokens(r.items,e));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{let a=r[i].flat(1/0);n=n.concat(this.walkTokens(a,e))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=e.renderers[r.name];i?e.renderers[r.name]=function(...a){let l=r.renderer.apply(this,a);return l===!1&&(l=i.apply(this,a)),l}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be \'block\' or \'inline\'");let i=e[r.level];i?i.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),s.extensions=e),n.renderer){let r=this.defaults.renderer||new X(this.defaults);for(let i in n.renderer){if(!(i in r))throw new Error(`renderer \'${i}\' does not exist`);if(["options","parser"].includes(i))continue;let a=i,l=n.renderer[a],o=r[a];r[a]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=o.apply(r,c)),u||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new F(this.defaults);for(let i in n.tokenizer){if(!(i in r))throw new Error(`tokenizer \'${i}\' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,l=n.tokenizer[a],o=r[a];r[a]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=o.apply(r,c)),u}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new v;for(let i in n.hooks){if(!(i in r))throw new Error(`hook \'${i}\' does not exist`);if(["options","block"].includes(i))continue;let a=i,l=n.hooks[a],o=r[a];v.passThroughHooks.has(i)?r[a]=c=>{if(this.defaults.async&&v.passThroughHooksRespectAsync.has(i))return(async()=>{let p=await l.call(r,c);return o.call(r,p)})();let u=l.call(r,c);return o.call(r,u)}:r[a]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(r,c);return p===!1&&(p=await o.apply(r,c)),p})();let u=l.apply(r,c);return u===!1&&(u=o.apply(r,c)),u}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,i=n.walkTokens;s.walkTokens=function(a){let l=[];return l.push(i.call(this,a)),r&&(l=l.concat(r.call(this,a))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return R.lex(t,e??this.defaults)}parser(t,e){return T.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let s={...n},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)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."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let a=r.hooks?await r.hooks.preprocess(e):e,l=await(r.hooks?await r.hooks.provideLexer(t):t?R.lex:R.lexInline)(a,r),o=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(o,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(t):t?T.parse:T.parseInline)(o,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(i);try{r.hooks&&(e=r.hooks.preprocess(e));let a=(r.hooks?r.hooks.provideLexer(t):t?R.lex:R.lexInline)(e,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(t):t?T.parse:T.parseInline)(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}onError(t,e){return n=>{if(n.message+=`\nPlease report this to https://github.com/markedjs/marked.`,t){let s="<p>An error occurred:</p><pre>"+S(n.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}},I=new Bt;function f(t,e){return I.parse(t,e)}f.options=f.setOptions=function(t){return I.setOptions(t),f.defaults=I.defaults,ke(f.defaults),f};f.getDefaults=K;f.defaults=C;function qt(...t){return I.use(...t),f.defaults=I.defaults,ke(f.defaults),f}f.use=qt;f.walkTokens=function(t,e){return I.walkTokens(t,e)};f.parseInline=I.parseInline;f.Parser=T;f.parser=T.parse;f.Renderer=X;f.TextRenderer=se;f.Lexer=R;f.lexer=R.lex;f.Tokenizer=F;f.Hooks=v;f.parse=f;var rn=f.options,sn=f.setOptions,ln=f.walkTokens,an=f.parseInline;var on=T.parse,cn=R.lex;var $e=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*(?:\\n|$)/,Zt=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*$/;function jt(t){let e=1,n=0;for(;n<t.length;){let s=t.indexOf(`\n`,n),r=s===-1?t.slice(n):t.slice(n,s),i=Zt.exec(r);if(i){if(i[1]!==void 0)e++;else if(e--,e===0)return n}if(s===-1)break;n=s+1}return-1}var Ee=[{name:"container",level:"block",tokenizer(t){let e=$e.exec(t);if(!e)return;let n=t.slice(e[0].length),s=jt(n);if(s<0)return;let r=n.slice(0,s),i=n.indexOf(`\n`,s),a=i===-1?n.length:i+1,l=e[0]+n.slice(0,a),o=this.lexer.blockTokens(r,[]);return{type:"container",raw:l,kind:e[1],tokens:o}},renderer(t){return t.raw}}];function ie(t){return t.includes(":::")===!1?!1:new RegExp($e.source,"m").test(t)}var Le="([^\\\\]\\\\s]+)",Qt=new RegExp(`^\\\\[\\\\^${Le}\\\\]`),Ie=new RegExp(`^ {0,3}\\\\[\\\\^${Le}\\\\]:[ \\\\t]*([^\\\\n]*)\\\\n?`);function ze(t){return/^[ \\t]*$/.test(t)}var Ae=/^(?: {4}| {0,3}\\t)/;function Ft(t){let e=0;for(;;){let s=e;for(;;){let l=t.indexOf(`\n`,s);if(l===-1)return n(e,!0);let o=t.slice(s,l);if(!ze(o))break;s=l+1}let r=t.indexOf(`\n`,s),i=r===-1?t.slice(s):t.slice(s,r+1),a=r===-1?t.slice(s):t.slice(s,r);if(!Ae.test(a))return n(e,!1);if(e=s+i.length,r===-1)return n(e,!0)}function n(s,r){let i=t.slice(0,s),a=i.split(`\n`).map(l=>ze(l)?"":l.replace(Ae,"")).join(`\n`);return{raw:i,body:a,open:r}}}function le(t){return t.includes("[^")===!1?!1:new RegExp(Ie.source,"m").test(t)}var Ce=[{name:"footnoteRef",level:"inline",tokenizer(t){let e=Qt.exec(t);if(e)return{type:"footnoteRef",raw:e[0],label:e[1]}},renderer(t){return t.raw}},{name:"footnoteDef",level:"block",tokenizer(t){let e=Ie.exec(t);if(!e)return;let n=t.slice(e[0].length),s=Ft(n),r=s.body.trim()?this.lexer.blockTokens(s.body,[]):[];return{type:"footnoteDef",raw:e[0]+s.raw,label:e[1],body:e[2],tokens:r}},renderer(t){return t.raw}}];function Me(t,e,n){let s=0;for(let r=e;r<n;r++)s+=t[r].raw.length;return s}function Xt(t,e){let n=t;return n.links=e,n}function Oe(t,e){for(let n=e;n+1<t.length;n++)if(t[n].type==="paragraph"&&t[n+1].type==="paragraph")return n;return t.length}function Ht(t,e){return t[e-2]?.type!=="list"?!0:e+1<t.length}function Ne(t,e,n){let s=Math.min(t.length-2,n-1);for(let r=s;r>=e;r--)if(t[r].type==="space"&&Ht(t,r+1)!==!1)return r+1;return-1}function ve(t){let e=t.links;if(!e)return!1;for(let n in e)return!0;return!1}function De(t,e,n,s,r){let i=r;for(let a=e;a<n;a++){let l=t[a].raw;if(s.startsWith(l,i)===!1)return!1;i+=l.length}return!0}function Z(t,e,n){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!0,degradedReason:n}}function Pe(t,e){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!1,degradedReason:null}}function Gt(t,e){if(ve(e))return Z(t,e,"link-definition");if(t.includes("\\r"))return Z(t,e,"carriage-return");if(ie(t))return Z(t,e,"container");if(le(t))return Z(t,e,"footnote-def");let n=Oe(e,0),s=Ne(e,1,n);if(s<0||De(e,0,s,t,0)===!1)return Pe(t,e);let r=Me(e,0,s);return{source:t,tail:t.slice(r),tokens:e,stableCount:s,stableOffset:r,degraded:!1,degradedReason:null}}function ae(t){let e=f.lexer(t);return{tokens:e,cache:Gt(t,e),charsLexed:t.length,reusedTokens:0}}function q(t,e){let n=f.lexer(t);return{tokens:n,cache:Z(t,n,e),charsLexed:t.length,reusedTokens:0}}function Be(t,e){let n=t.source+e;if(t.degraded)return q(n,t.degradedReason??"link-definition");if(e.includes("\\r"))return q(n,"carriage-return");if(t.stableCount===0)return ae(n);let s=t.tail+e;if(ie(s))return q(n,"container");if(le(s))return q(n,"footnote-def");let r=f.lexer(s);if(ve(r))return q(n,"link-definition");let i=t.tokens.slice(0,t.stableCount),a=Xt([...i,...r],r.links),l=t.stableCount,o=t.stableOffset,c=s,u=Ne(a,t.stableCount+1,Oe(a,t.stableCount));if(u>t.stableCount&&De(a,t.stableCount,u,s,0)){let p=Me(a,t.stableCount,u);l=u,o=t.stableOffset+p,c=s.slice(p)}return{tokens:a,cache:{source:n,tail:c,tokens:a,stableCount:l,stableOffset:o,degraded:!1,degradedReason:null},charsLexed:s.length,reusedTokens:t.stableCount}}var Ut=/^ {0,3}\\*\\[([^\\]\\n]+)\\]:[ \\t]*([^\\n]*)(?:\\n|$)/,qe=[{name:"abbrDef",level:"block",tokenizer(t){let e=Ut.exec(t);if(e)return{type:"abbrDef",raw:e[0],term:e[1],definition:e[2]}},renderer(t){return t.raw}}];var Wt=Object.freeze({grinning:"\\u{1F600}",smiley:"\\u{1F603}",smile:"\\u{1F604}",grin:"\\u{1F601}",laughing:"\\u{1F606}",satisfied:"\\u{1F606}",sweat_smile:"\\u{1F605}",rofl:"\\u{1F923}",joy:"\\u{1F602}",slightly_smiling_face:"\\u{1F642}",upside_down_face:"\\u{1F643}",wink:"\\u{1F609}",blush:"\\u{1F60A}",innocent:"\\u{1F607}",heart_eyes:"\\u{1F60D}",star_struck:"\\u{1F929}",kissing_heart:"\\u{1F618}",yum:"\\u{1F60B}",stuck_out_tongue:"\\u{1F61B}",stuck_out_tongue_winking_eye:"\\u{1F61C}",stuck_out_tongue_closed_eyes:"\\u{1F61D}",hugs:"\\u{1F917}",thinking:"\\u{1F914}",neutral_face:"\\u{1F610}",expressionless:"\\u{1F611}",no_mouth:"\\u{1F636}",smirk:"\\u{1F60F}",unamused:"\\u{1F612}",roll_eyes:"\\u{1F644}",grimacing:"\\u{1F62C}",relieved:"\\u{1F60C}",pensive:"\\u{1F614}",sleepy:"\\u{1F62A}",sleeping:"\\u{1F634}",mask:"\\u{1F637}",dizzy_face:"\\u{1F635}",sunglasses:"\\u{1F60E}",nerd_face:"\\u{1F913}",confused:"\\u{1F615}",worried:"\\u{1F61F}",open_mouth:"\\u{1F62E}",hushed:"\\u{1F62F}",astonished:"\\u{1F632}",flushed:"\\u{1F633}",pleading_face:"\\u{1F97A}",fearful:"\\u{1F628}",cold_sweat:"\\u{1F630}",cry:"\\u{1F622}",sob:"\\u{1F62D}",scream:"\\u{1F631}",disappointed:"\\u{1F61E}",sweat:"\\u{1F613}",weary:"\\u{1F629}",tired_face:"\\u{1F62B}",triumph:"\\u{1F624}",rage:"\\u{1F621}",angry:"\\u{1F620}",smiling_imp:"\\u{1F608}",imp:"\\u{1F47F}",skull:"\\u{1F480}",clown_face:"\\u{1F921}",poop:"\\u{1F4A9}",ghost:"\\u{1F47B}",alien:"\\u{1F47D}",robot:"\\u{1F916}",thumbsup:"\\u{1F44D}","+1":"\\u{1F44D}",thumbsdown:"\\u{1F44E}","-1":"\\u{1F44E}",punch:"\\u{1F44A}",fist:"\\u270A",clap:"\\u{1F44F}",raised_hands:"\\u{1F64C}",open_hands:"\\u{1F450}",handshake:"\\u{1F91D}",pray:"\\u{1F64F}",muscle:"\\u{1F4AA}",eyes:"\\u{1F440}",wave:"\\u{1F44B}",point_up:"\\u261D\\uFE0F",point_down:"\\u{1F447}",point_left:"\\u{1F448}",point_right:"\\u{1F449}",ok_hand:"\\u{1F44C}",v:"\\u270C\\uFE0F",crossed_fingers:"\\u{1F91E}",heart:"\\u2764\\uFE0F",broken_heart:"\\u{1F494}",two_hearts:"\\u{1F495}",sparkling_heart:"\\u{1F496}",heartpulse:"\\u{1F497}",blue_heart:"\\u{1F499}",green_heart:"\\u{1F49A}",yellow_heart:"\\u{1F49B}",orange_heart:"\\u{1F9E1}",purple_heart:"\\u{1F49C}",black_heart:"\\u{1F5A4}",white_heart:"\\u{1F90D}",100:"\\u{1F4AF}",boom:"\\u{1F4A5}",collision:"\\u{1F4A5}",dizzy:"\\u{1F4AB}",sweat_drops:"\\u{1F4A6}",dash:"\\u{1F4A8}",zzz:"\\u{1F4A4}",fire:"\\u{1F525}",sparkles:"\\u2728",star:"\\u2B50",star2:"\\u{1F31F}",tada:"\\u{1F389}",confetti_ball:"\\u{1F38A}",balloon:"\\u{1F388}",gift:"\\u{1F381}",rocket:"\\u{1F680}",dart:"\\u{1F3AF}",trophy:"\\u{1F3C6}",warning:"\\u26A0\\uFE0F",no_entry_sign:"\\u{1F6AB}",white_check_mark:"\\u2705",x:"\\u274C",heavy_check_mark:"\\u2714\\uFE0F",question:"\\u2753",exclamation:"\\u2757",bulb:"\\u{1F4A1}",bell:"\\u{1F514}",computer:"\\u{1F4BB}",iphone:"\\u{1F4F1}",link:"\\u{1F517}",lock:"\\u{1F512}",unlock:"\\u{1F513}",key:"\\u{1F511}",mag:"\\u{1F50D}",bug:"\\u{1F41B}",package:"\\u{1F4E6}",memo:"\\u{1F4DD}",pencil2:"\\u270F\\uFE0F",book:"\\u{1F4D6}",books:"\\u{1F4DA}",pushpin:"\\u{1F4CC}",paperclip:"\\u{1F4CE}",calendar:"\\u{1F4C5}",file_folder:"\\u{1F4C1}",hammer:"\\u{1F528}",wrench:"\\u{1F527}",gear:"\\u2699\\uFE0F",chart_with_upwards_trend:"\\u{1F4C8}",chart_with_downwards_trend:"\\u{1F4C9}",bar_chart:"\\u{1F4CA}",construction:"\\u{1F6A7}",hourglass:"\\u23F3",stopwatch:"\\u23F1\\uFE0F",pizza:"\\u{1F355}",coffee:"\\u2615",beer:"\\u{1F37A}",cake:"\\u{1F382}",birthday:"\\u{1F382}",apple:"\\u{1F34E}",rainbow:"\\u{1F308}",sun_with_face:"\\u{1F31E}",crescent_moon:"\\u{1F319}",earth_americas:"\\u{1F30E}",dog:"\\u{1F436}",cat:"\\u{1F431}",fox_face:"\\u{1F98A}",bear:"\\u{1F43B}",panda_face:"\\u{1F43C}",monkey_face:"\\u{1F435}",see_no_evil:"\\u{1F648}",hear_no_evil:"\\u{1F649}",speak_no_evil:"\\u{1F64A}"}),Jt=/^:([A-Za-z0-9_+-]+):/,Ze=[{name:"emoji",level:"inline",start(t){return t.match(/:/)?.index},tokenizer(t){let e=Jt.exec(t);if(!e)return;let n=Wt[e[1]];if(n!==void 0)return{type:"emoji",raw:e[0],text:n}},renderer(t){return t.raw}}];var Kt=/^\\+\\+(?!\\s)((?:\\\\[\\s\\S]|(?!\\+\\+)[\\s\\S])+?)(?<!\\s)\\+\\+/,Vt=/^==(?!\\s)((?:\\\\[\\s\\S]|(?!==)[\\s\\S])+?)(?<!\\s)==/,je=[{name:"ins",level:"inline",start(t){return t.match(/(?<!\\\\)\\+\\+(?!\\s)/)?.index},tokenizer(t){let e=Kt.exec(t);if(e)return{type:"ins",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}},{name:"mark",level:"inline",start(t){return t.match(/(?<!\\\\)==(?!\\s)/)?.index},tokenizer(t){let e=Vt.exec(t);if(e)return{type:"mark",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var Yt=/^\\^((?:\\\\[\\s\\S]|[^\\s^\\\\])+)\\^/,Qe=[{name:"sup",level:"inline",start(t){return t.match(/(?<!\\\\)\\^(?!\\s)/)?.index},tokenizer(t){let e=Yt.exec(t);if(e)return{type:"sup",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var en=0;function tn(t){if(typeof t!="string"||typeof performance.mark!="function"||typeof performance.measure!="function")return null;let e=en++,n={name:t,startMark:`${t}:start:${e}`,endMark:`${t}:end:${e}`};try{return performance.mark(n.startMark),n}catch{return null}}function nn(t){if(t)try{performance.mark(t.endMark),performance.measure(t.name,t.startMark,t.endMark)}catch{}finally{try{performance.clearMarks?.(t.startMark),performance.clearMarks?.(t.endMark)}catch{}}}f.use({extensions:[...Ce,...Qe,...je,...Ze,...Ee,...qe,{name:"blockMath",level:"block",start(t){return t.match(/^ {0,3}\\$\\$/m)?.index},tokenizer(t){let e=/^ {0,3}\\$\\$((?:(?!\\n[ \\t]*\\n)[\\s\\S])+?)\\$\\$[ \\t]*(?:\\n|$)/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1].trim()}},renderer(t){return t.raw}},{name:"inlineMath",level:"inline",start(t){return t.match(/(?<![\\\\$])\\$(?![$\\s])/)?.index},tokenizer(t){let e=/^\\$(?![$\\s\\d])((?:\\\\\\$|[^$\\n])*?)(?<!\\s)\\$(?!\\d)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1].trim()}},renderer(t){return t.raw}}]});var O=new Map;self.onmessage=t=>{let e=t.data;if(typeof e!="object"||e===null)return;let{id:n,text:s,append:r,expectedLength:i,oldRaws:a,instance:l,baseVersion:o,dispose:c,userTimingName:u}=e;if(c===!0){typeof l=="string"&&O.delete(l);return}let p=typeof l=="string"?l:null,h=typeof o=="number"?o:null,k,d=null,m=null;if(typeof r=="string"){if(p===null||h===null){self.postMessage({id:n,needResync:!0});return}let x=O.get(p);if(!x||x.version!==h){self.postMessage({id:n,needResync:!0});return}if(typeof i=="number"&&x.lex.source.length+r.length!==i){O.delete(p),self.postMessage({id:n,needResync:!0});return}let y=x.lex;k=()=>Be(y,r),m=y.tokens}else if(typeof s=="string"){let x=s;if(k=()=>ae(x),Array.isArray(a))d=a;else if(p!==null&&h!==null){let y=O.get(p);if(y&&y.version===h)m=y.lex.tokens;else{self.postMessage({id:n,needResync:!0});return}}}else return;try{let x=typeof u=="string"?tn(u):null,y=performance.now(),E;try{E=k()}finally{x&&nn(x)}let G=performance.now()-y,A=E.tokens,w=0;if(d!==null){let _=Math.min(d.length,A.length);for(;w<_&&d[w]===A[w].raw;w++);}else if(m!==null){let _=m,oe=Math.min(_.length,A.length);for(w=Math.min(E.reusedTokens,oe);w<oe&&_[w].raw===A[w].raw;w++);}p!==null&&h!==null&&O.set(p,{version:h+1,lex:E.cache}),self.postMessage({id:n,matchLen:w,tail:A.slice(w),lexerMs:G,sourceCharsLexed:E.charsLexed})}catch(x){p!==null&&O.delete(p),self.postMessage({id:n,error:String(x)})}};})();\n';
2662
3135
 
2663
3136
  // src/Markdown.ts
2664
3137
  var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
@@ -2802,6 +3275,22 @@ var Markdown = class _Markdown extends UIComponent3 {
2802
3275
  * affordance.
2803
3276
  */
2804
3277
  blockAffordances;
3278
+ /**
3279
+ * Which controls a block carries and what they are called, with defaults
3280
+ * applied.
3281
+ *
3282
+ * Resolved once in the constructor rather than per block: the defaults are
3283
+ * fixed, and re-deriving them for every code fence in a long document would
3284
+ * repeat the same six `??` fallbacks for no benefit.
3285
+ */
3286
+ affordanceConfig;
3287
+ /**
3288
+ * Whether code blocks show their language in a header band.
3289
+ *
3290
+ * Read when a block entity is built, exactly like {@link blockAffordances}, so
3291
+ * it affects blocks rendered from here on rather than retroactively.
3292
+ */
3293
+ showCodeLanguage;
2805
3294
  /** Clipboard writer used by the copy controls. */
2806
3295
  writeClipboard;
2807
3296
  /** File saver used by the download controls. */
@@ -3084,6 +3573,8 @@ var Markdown = class _Markdown extends UIComponent3 {
3084
3573
  this.selectable = opts.selectable ?? true;
3085
3574
  this._userTiming = opts.userTiming ?? false;
3086
3575
  this.blockAffordances = opts.blockAffordances ?? false;
3576
+ this.affordanceConfig = resolveBlockAffordanceConfig(opts.affordances);
3577
+ this.showCodeLanguage = opts.showCodeLanguage ?? false;
3087
3578
  this.writeClipboard = opts.writeClipboard ?? defaultWriteClipboard;
3088
3579
  this.saveFile = opts.saveFile ?? defaultSaveFile;
3089
3580
  this.content = new Stack({
@@ -4045,40 +4536,60 @@ var Markdown = class _Markdown extends UIComponent3 {
4045
4536
  const controls = make();
4046
4537
  return controls.length > 0 ? new BlockWithAffordances(block, controls) : block;
4047
4538
  }
4048
- /** Copy and download controls for one fenced code block. */
4539
+ /** Copy and download controls for one fenced code block, per {@link affordanceConfig}. */
4049
4540
  codeBlockAffordances(source, lang) {
4050
4541
  const opts = this.affordanceButtonOptions();
4051
- return [
4052
- new BlockAffordanceButton("Copy code", "Copied", () => this.writeClipboard(source), opts),
4053
- new BlockAffordanceButton(
4054
- "Download code",
4055
- "Saved",
4056
- () => this.saveFile(`code.${extensionForLanguage(lang)}`, source, mimeForLanguage(lang)),
4057
- opts
4058
- )
4059
- ];
4060
- }
4061
- /** Copy (as Markdown) and download (as CSV) controls for one table. */
4542
+ const { code, labels } = this.affordanceConfig;
4543
+ const controls = [];
4544
+ if (code.copy) {
4545
+ controls.push(
4546
+ new BlockAffordanceButton(
4547
+ labels.copyCode,
4548
+ labels.copied,
4549
+ () => this.writeClipboard(source),
4550
+ opts
4551
+ )
4552
+ );
4553
+ }
4554
+ if (code.download) {
4555
+ controls.push(
4556
+ new BlockAffordanceButton(
4557
+ labels.downloadCode,
4558
+ labels.saved,
4559
+ () => this.saveFile(`code.${extensionForLanguage(lang)}`, source, mimeForLanguage(lang)),
4560
+ opts
4561
+ )
4562
+ );
4563
+ }
4564
+ return controls;
4565
+ }
4566
+ /** Copy (as Markdown) and download (as CSV) controls for one table, per {@link affordanceConfig}. */
4062
4567
  tableAffordances(tblToken) {
4568
+ const { table, labels } = this.affordanceConfig;
4063
4569
  const content = tableContentOf(tblToken);
4064
4570
  const opts = this.affordanceButtonOptions();
4065
- return [
4066
- // Markdown rather than CSV for the clipboard: the reader copied it out of a
4067
- // Markdown document and the overwhelmingly likely destination is another
4068
- // one. CSV is what the download is for, where a spreadsheet is the target.
4069
- new BlockAffordanceButton(
4070
- "Copy table",
4071
- "Copied",
4072
- () => this.writeClipboard(tableToMarkdown(content)),
4073
- opts
4074
- ),
4075
- new BlockAffordanceButton(
4076
- "Download table",
4077
- "Saved",
4078
- () => this.saveFile("table.csv", tableToCsv(content), "text/csv;charset=utf-8"),
4079
- opts
4080
- )
4081
- ];
4571
+ const controls = [];
4572
+ if (table.copy) {
4573
+ controls.push(
4574
+ new BlockAffordanceButton(
4575
+ labels.copyTable,
4576
+ labels.copied,
4577
+ () => this.writeClipboard(tableToMarkdown(content)),
4578
+ opts
4579
+ )
4580
+ );
4581
+ }
4582
+ if (table.download) {
4583
+ controls.push(
4584
+ new BlockAffordanceButton(
4585
+ labels.downloadTable,
4586
+ labels.saved,
4587
+ () => this.saveFile("table.csv", tableToCsv(content), "text/csv;charset=utf-8"),
4588
+ opts
4589
+ )
4590
+ );
4591
+ }
4592
+ return controls;
4082
4593
  }
4083
4594
  /**
4084
4595
  * Button styling for the affordances, derived from the document theme.
@@ -5222,7 +5733,9 @@ var Markdown = class _Markdown extends UIComponent3 {
5222
5733
  }
5223
5734
  }
5224
5735
  return this.withBlockAffordances(
5225
- new CodeBlock(codeToken.text, lang, availableWidth, t, this.selectable),
5736
+ new CodeBlock(codeToken.text, lang, availableWidth, t, this.selectable, {
5737
+ showLanguage: this.showCodeLanguage
5738
+ }),
5226
5739
  () => this.codeBlockAffordances(codeToken.text, lang)
5227
5740
  );
5228
5741
  }
@@ -5453,6 +5966,7 @@ export {
5453
5966
  extensionForLanguage,
5454
5967
  footnoteMarker,
5455
5968
  hasFencedBlockRenderer,
5969
+ highlightedLanguages,
5456
5970
  isFencedBlockRendererReady,
5457
5971
  isMathJaxReady,
5458
5972
  isPresetName,
@@ -5461,6 +5975,7 @@ export {
5461
5975
  preloadMathJax,
5462
5976
  registerFencedBlockRenderer,
5463
5977
  renderFencedBlock,
5978
+ resolveBlockAffordanceConfig,
5464
5979
  resolvePresetTheme,
5465
5980
  scanFrontMatter,
5466
5981
  tableContentOf,