var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var _a;
import { a as decodeEntities } from "./chunk-S3R3BYOJ-mQeCz5CE.js";
import { i as log, r as __name, t as select_default } from "./src-Bf2iLOlr.js";
import { I as sanitizeText, N as renderKatexSanitized, O as hasKatex, s as common_default, y as getConfig } from "./chunk-ABZYJK2D-D0cLy8Bb.js";
var defaultIconDimensions = Object.freeze({
  left: 0,
  top: 0,
  width: 16,
  height: 16
}), defaultIconTransformations = Object.freeze({
  rotate: 0,
  vFlip: false,
  hFlip: false
}), defaultIconProps = Object.freeze({
  ...defaultIconDimensions,
  ...defaultIconTransformations
}), defaultExtendedIconProps = Object.freeze({
  ...defaultIconProps,
  body: "",
  hidden: false
}), defaultIconSizeCustomisations = Object.freeze({
  width: null,
  height: null
}), defaultIconCustomisations = Object.freeze({
  ...defaultIconSizeCustomisations,
  ...defaultIconTransformations
}), stringToIcon = (e3, o, s, c = "") => {
  let l = e3.split(":");
  if (e3.slice(0, 1) === "@") {
    if (l.length < 2 || l.length > 3) return null;
    c = l.shift().slice(1);
  }
  if (l.length > 3 || !l.length) return null;
  if (l.length > 1) {
    let e4 = l.pop(), s2 = l.pop(), u2 = {
      provider: l.length > 0 ? l[0] : c,
      prefix: s2,
      name: e4
    };
    return o && !validateIconName(u2) ? null : u2;
  }
  let u = l[0], f = u.split("-");
  if (f.length > 1) {
    let e4 = {
      provider: c,
      prefix: f.shift(),
      name: f.join("-")
    };
    return o && !validateIconName(e4) ? null : e4;
  }
  if (s && c === "") {
    let e4 = {
      provider: c,
      prefix: "",
      name: u
    };
    return o && !validateIconName(e4, s) ? null : e4;
  }
  return null;
}, validateIconName = (e3, o) => e3 ? !!((o && e3.prefix === "" || e3.prefix) && e3.name) : false;
function mergeIconTransformations(e3, o) {
  let s = {};
  !e3.hFlip != !o.hFlip && (s.hFlip = true), !e3.vFlip != !o.vFlip && (s.vFlip = true);
  let c = ((e3.rotate || 0) + (o.rotate || 0)) % 4;
  return c && (s.rotate = c), s;
}
function mergeIconData(e3, o) {
  let s = mergeIconTransformations(e3, o);
  for (let c in defaultExtendedIconProps) c in defaultIconTransformations ? c in e3 && !(c in s) && (s[c] = defaultIconTransformations[c]) : c in o ? s[c] = o[c] : c in e3 && (s[c] = e3[c]);
  return s;
}
function getIconsTree(e3, o) {
  let s = e3.icons, c = e3.aliases || /* @__PURE__ */ Object.create(null), l = /* @__PURE__ */ Object.create(null);
  function u(e4) {
    if (s[e4]) return l[e4] = [];
    if (!(e4 in l)) {
      l[e4] = null;
      let o2 = c[e4] && c[e4].parent, s2 = o2 && u(o2);
      s2 && (l[e4] = [o2].concat(s2));
    }
    return l[e4];
  }
  return (o || Object.keys(s).concat(Object.keys(c))).forEach(u), l;
}
function internalGetIconData(e3, o, s) {
  let c = e3.icons, l = e3.aliases || /* @__PURE__ */ Object.create(null), u = {};
  function f(e4) {
    u = mergeIconData(c[e4] || l[e4], u);
  }
  return f(o), s.forEach(f), mergeIconData(e3, u);
}
function getIconData(e3, o) {
  if (e3.icons[o]) return internalGetIconData(e3, o, []);
  let s = getIconsTree(e3, [o])[o];
  return s ? internalGetIconData(e3, o, s) : null;
}
var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g, unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
function calculateSize(e3, o, s) {
  if (o === 1) return e3;
  if (s || (s = 100), typeof e3 == "number") return Math.ceil(e3 * o * s) / s;
  if (typeof e3 != "string") return e3;
  let c = e3.split(unitsSplit);
  if (c === null || !c.length) return e3;
  let l = [], u = c.shift(), f = unitsTest.test(u);
  for (; ; ) {
    if (f) {
      let e4 = parseFloat(u);
      isNaN(e4) ? l.push(u) : l.push(Math.ceil(e4 * o * s) / s);
    } else l.push(u);
    if (u = c.shift(), u === void 0) return l.join("");
    f = !f;
  }
}
function splitSVGDefs(e3, o = "defs") {
  let s = "", c = e3.indexOf("<" + o);
  for (; c >= 0; ) {
    let l = e3.indexOf(">", c), u = e3.indexOf("</" + o);
    if (l === -1 || u === -1) break;
    let f = e3.indexOf(">", u);
    if (f === -1) break;
    s += e3.slice(l + 1, u).trim(), e3 = e3.slice(0, c).trim() + e3.slice(f + 1);
  }
  return {
    defs: s,
    content: e3
  };
}
function mergeDefsAndContent(e3, o) {
  return e3 ? "<defs>" + e3 + "</defs>" + o : o;
}
function wrapSVGContent(e3, o, s) {
  let c = splitSVGDefs(e3);
  return mergeDefsAndContent(c.defs, o + c.content + s);
}
var isUnsetKeyword = (e3) => e3 === "unset" || e3 === "undefined" || e3 === "none";
function iconToSVG(e3, o) {
  let s = {
    ...defaultIconProps,
    ...e3
  }, c = {
    ...defaultIconCustomisations,
    ...o
  }, l = {
    left: s.left,
    top: s.top,
    width: s.width,
    height: s.height
  }, u = s.body;
  [s, c].forEach((e4) => {
    let o2 = [], s2 = e4.hFlip, c2 = e4.vFlip, f2 = e4.rotate;
    s2 ? c2 ? f2 += 2 : (o2.push("translate(" + (l.width + l.left).toString() + " " + (0 - l.top).toString() + ")"), o2.push("scale(-1 1)"), l.top = l.left = 0) : c2 && (o2.push("translate(" + (0 - l.left).toString() + " " + (l.height + l.top).toString() + ")"), o2.push("scale(1 -1)"), l.top = l.left = 0);
    let p2;
    switch (f2 < 0 && (f2 -= Math.floor(f2 / 4) * 4), f2 %= 4, f2) {
      case 1:
        p2 = l.height / 2 + l.top, o2.unshift("rotate(90 " + p2.toString() + " " + p2.toString() + ")");
        break;
      case 2:
        o2.unshift("rotate(180 " + (l.width / 2 + l.left).toString() + " " + (l.height / 2 + l.top).toString() + ")");
        break;
      case 3:
        p2 = l.width / 2 + l.left, o2.unshift("rotate(-90 " + p2.toString() + " " + p2.toString() + ")");
        break;
    }
    f2 % 2 == 1 && (l.left !== l.top && (p2 = l.left, l.left = l.top, l.top = p2), l.width !== l.height && (p2 = l.width, l.width = l.height, l.height = p2)), o2.length && (u = wrapSVGContent(u, '<g transform="' + o2.join(" ") + '">', "</g>"));
  });
  let f = c.width, p = c.height, g = l.width, x = l.height, T, A;
  f === null ? (A = p === null ? "1em" : p === "auto" ? x : p, T = calculateSize(A, g / x)) : (T = f === "auto" ? g : f, A = p === null ? calculateSize(T, x / g) : p === "auto" ? x : p);
  let B = {}, Y = (e4, o2) => {
    isUnsetKeyword(o2) || (B[e4] = o2.toString());
  };
  Y("width", T), Y("height", A);
  let Z = [
    l.left,
    l.top,
    g,
    x
  ];
  return B.viewBox = Z.join(" "), {
    attributes: B,
    viewBox: Z,
    body: u
  };
}
var regex = /\sid="(\S+)"/g, randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16), counter = 0;
function replaceIDs(e3, o = randomPrefix) {
  let s = [], c;
  for (; c = regex.exec(e3); ) s.push(c[1]);
  if (!s.length) return e3;
  let l = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
  return s.forEach((s2) => {
    let c2 = typeof o == "function" ? o(s2) : o + (counter++).toString(), u = s2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
    e3 = e3.replace(RegExp('([#;"])(' + u + ')([")]|\\.[a-z])', "g"), "$1" + c2 + l + "$3");
  }), e3 = e3.replace(new RegExp(l, "g"), ""), e3;
}
function iconToHTML(e3, o) {
  let s = e3.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
  for (let e4 in o) s += " " + e4 + '="' + o[e4] + '"';
  return '<svg xmlns="http://www.w3.org/2000/svg"' + s + ">" + e3 + "</svg>";
}
function L() {
  return {
    async: false,
    breaks: false,
    extensions: null,
    gfm: true,
    hooks: null,
    pedantic: false,
    renderer: null,
    silent: false,
    tokenizer: null,
    walkTokens: null
  };
}
var O = L();
function H(e3) {
  O = e3;
}
var E = { exec: () => null };
function h(e3, o = "") {
  let s = typeof e3 == "string" ? e3 : e3.source, c = {
    replace: (e4, o2) => {
      let l = typeof o2 == "string" ? o2 : o2.source;
      return l = l.replace(m.caret, "$1"), s = s.replace(e4, l), c;
    },
    getRegex: () => new RegExp(s, o)
  };
  return c;
}
var m = {
  codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
  outputLinkReplace: /\\([\[\]])/g,
  indentCodeCompensation: /^(\s+)(?:```)/,
  beginningSpace: /^\s+/,
  endingHash: /#$/,
  startingSpaceChar: /^ /,
  endingSpaceChar: / $/,
  nonSpaceChar: /[^ ]/,
  newLineCharGlobal: /\n/g,
  tabCharGlobal: /\t/g,
  multipleSpaceGlobal: /\s+/g,
  blankLine: /^[ \t]*$/,
  doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
  blockquoteStart: /^ {0,3}>/,
  blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
  blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
  listReplaceTabs: /^\t+/,
  listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
  listIsTask: /^\[[ xX]\] /,
  listReplaceTask: /^\[[ 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,
  unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,
  caret: /(^|[^\[])\^/g,
  percentDecode: /%25/g,
  findPipe: /\|/g,
  splitPipe: / \|/,
  slashPipe: /\\\|/g,
  carriageReturn: /\r\n|\r/g,
  spaceLine: /^ +$/gm,
  notSpaceStart: /^\S*/,
  endingNewline: /\n$/,
  listItemRegex: (e3) => /* @__PURE__ */ RegExp(`^( {0,3}${e3})((?:[	 ][^\\n]*)?(?:\\n|$))`),
  nextBulletRegex: (e3) => /* @__PURE__ */ RegExp(`^ {0,${Math.min(3, e3 - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ 	][^\\n]*)?(?:\\n|$))`),
  hrRegex: (e3) => /* @__PURE__ */ RegExp(`^ {0,${Math.min(3, e3 - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
  fencesBeginRegex: (e3) => /* @__PURE__ */ RegExp(`^ {0,${Math.min(3, e3 - 1)}}(?:\`\`\`|~~~)`),
  headingBeginRegex: (e3) => /* @__PURE__ */ RegExp(`^ {0,${Math.min(3, e3 - 1)}}#`),
  htmlBeginRegex: (e3) => RegExp(`^ {0,${Math.min(3, e3 - 1)}}<(?:[a-z].*>|!--)`, "i")
}, xe = /^(?:[ \t]*(?:\n|$))+/, be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Re = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, C = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Oe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, j = /(?:[*+-]|\d{1,9}[.)])/, se = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ie = h(se).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Te = h(se).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, we = /^[^\n]+/, Q = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, ye = h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Q).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Pe = h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, j).getRegex(), v = "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", U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Se = h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ 	]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ 	]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ 	]*)+\\n|$))", "i").replace("comment", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), oe = h(F).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex(), K = {
  blockquote: h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex(),
  code: be,
  def: ye,
  fences: Re,
  heading: Oe,
  hr: C,
  html: Se,
  lheading: ie,
  list: Pe,
  newline: xe,
  paragraph: oe,
  table: E,
  text: we
}, re = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}	)[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex(), _e = {
  ...K,
  lheading: Te,
  table: re,
  paragraph: h(F).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex()
}, Le = {
  ...K,
  html: h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).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: E,
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
  paragraph: h(F).replace("hr", C).replace("heading", " *#{1,6} *[^\n]").replace("lheading", ie).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
}, Me = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, ze = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ae = /^( {2,}|\\)\n(?!\s*$)/, Ae = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, D = /[\p{P}\p{S}]/u, W = /[\s\p{P}\p{S}]/u, le = /[^\s\p{P}\p{S}]/u, Ee = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, W).getRegex(), ue = /(?!~)[\p{P}\p{S}]/u, Ce = /(?!~)[\s\p{P}\p{S}]/u, Ie = /(?:[^\s\p{P}\p{S}]|~)/u, Be = /\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g, pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, qe = h(pe, "u").replace(/punct/g, D).getRegex(), ve = h(pe, "u").replace(/punct/g, ue).getRegex(), ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", De = h(ce, "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(), Ze = h(ce, "gu").replace(/notPunctSpace/g, Ie).replace(/punctSpace/g, Ce).replace(/punct/g, ue).getRegex(), Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(), He = h(/\\(punct)/, "gu").replace(/punct/g, D).getRegex(), Ne = h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), je = h(U).replace("(?:-->|$)", "-->").getRegex(), Fe = h("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/, Qe = h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), he = h(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", Q).getRegex(), de = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Q).getRegex(), X = {
  _backpedal: E,
  anyPunctuation: He,
  autolink: Ne,
  blockSkip: Be,
  br: ae,
  code: ze,
  del: E,
  emStrongLDelim: qe,
  emStrongRDelimAst: De,
  emStrongRDelimUnd: Ge,
  escape: Me,
  link: Qe,
  nolink: de,
  punctuation: Ee,
  reflink: he,
  reflinkSearch: h("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", de).getRegex(),
  tag: Fe,
  text: Ae,
  url: E
}, Ke = {
  ...X,
  link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(),
  reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex()
}, N = {
  ...X,
  emStrongRDelimAst: Ze,
  emStrongLDelim: ve,
  url: h(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").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: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
}, We = {
  ...N,
  br: h(ae).replace("{2,}", "*").getRegex(),
  text: h(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
}, I = {
  normal: K,
  gfm: _e,
  pedantic: Le
}, M = {
  normal: X,
  gfm: N,
  breaks: We,
  pedantic: Ke
}, Xe = {
  "&": "&amp;",
  "<": "&lt;",
  ">": "&gt;",
  '"': "&quot;",
  "'": "&#39;"
}, ke = (e3) => Xe[e3];
function w(e3, o) {
  if (o) {
    if (m.escapeTest.test(e3)) return e3.replace(m.escapeReplace, ke);
  } else if (m.escapeTestNoEncode.test(e3)) return e3.replace(m.escapeReplaceNoEncode, ke);
  return e3;
}
function J(e3) {
  try {
    e3 = encodeURI(e3).replace(m.percentDecode, "%");
  } catch {
    return null;
  }
  return e3;
}
function V(e3, o) {
  var _a2;
  let s = e3.replace(m.findPipe, (e4, o2, s2) => {
    let c2 = false, l = o2;
    for (; --l >= 0 && s2[l] === "\\"; ) c2 = !c2;
    return c2 ? "|" : " |";
  }).split(m.splitPipe), c = 0;
  if (s[0].trim() || s.shift(), s.length > 0 && !((_a2 = s.at(-1)) == null ? void 0 : _a2.trim()) && s.pop(), o) if (s.length > o) s.splice(o);
  else for (; s.length < o; ) s.push("");
  for (; c < s.length; c++) s[c] = s[c].trim().replace(m.slashPipe, "|");
  return s;
}
function z(e3, o, s) {
  let c = e3.length;
  if (c === 0) return "";
  let l = 0;
  for (; l < c; ) {
    let u = e3.charAt(c - l - 1);
    if (u === o && !s) l++;
    else if (u !== o && s) l++;
    else break;
  }
  return e3.slice(0, c - l);
}
function ge(e3, o) {
  if (e3.indexOf(o[1]) === -1) return -1;
  let s = 0;
  for (let c = 0; c < e3.length; c++) if (e3[c] === "\\") c++;
  else if (e3[c] === o[0]) s++;
  else if (e3[c] === o[1] && (s--, s < 0)) return c;
  return s > 0 ? -2 : -1;
}
function fe(e3, o, s, c, l) {
  let u = o.href, f = o.title || null, p = e3[1].replace(l.other.outputLinkReplace, "$1");
  c.state.inLink = true;
  let g = {
    type: e3[0].charAt(0) === "!" ? "image" : "link",
    raw: s,
    href: u,
    title: f,
    text: p,
    tokens: c.inlineTokens(p)
  };
  return c.state.inLink = false, g;
}
function Je(e3, o, s) {
  let c = e3.match(s.other.indentCodeCompensation);
  if (c === null) return o;
  let l = c[1];
  return o.split("\n").map((e4) => {
    let o2 = e4.match(s.other.beginningSpace);
    if (o2 === null) return e4;
    let [c2] = o2;
    return c2.length >= l.length ? e4.slice(l.length) : e4;
  }).join("\n");
}
var y = class {
  constructor(e3) {
    __publicField(this, "options");
    __publicField(this, "rules");
    __publicField(this, "lexer");
    this.options = e3 || O;
  }
  space(e3) {
    let o = this.rules.block.newline.exec(e3);
    if (o && o[0].length > 0) return {
      type: "space",
      raw: o[0]
    };
  }
  code(e3) {
    let o = this.rules.block.code.exec(e3);
    if (o) {
      let e4 = o[0].replace(this.rules.other.codeRemoveIndent, "");
      return {
        type: "code",
        raw: o[0],
        codeBlockStyle: "indented",
        text: this.options.pedantic ? e4 : z(e4, "\n")
      };
    }
  }
  fences(e3) {
    let o = this.rules.block.fences.exec(e3);
    if (o) {
      let e4 = o[0], s = Je(e4, o[3] || "", this.rules);
      return {
        type: "code",
        raw: e4,
        lang: o[2] ? o[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : o[2],
        text: s
      };
    }
  }
  heading(e3) {
    let o = this.rules.block.heading.exec(e3);
    if (o) {
      let e4 = o[2].trim();
      if (this.rules.other.endingHash.test(e4)) {
        let o2 = z(e4, "#");
        (this.options.pedantic || !o2 || this.rules.other.endingSpaceChar.test(o2)) && (e4 = o2.trim());
      }
      return {
        type: "heading",
        raw: o[0],
        depth: o[1].length,
        text: e4,
        tokens: this.lexer.inline(e4)
      };
    }
  }
  hr(e3) {
    let o = this.rules.block.hr.exec(e3);
    if (o) return {
      type: "hr",
      raw: z(o[0], "\n")
    };
  }
  blockquote(e3) {
    let o = this.rules.block.blockquote.exec(e3);
    if (o) {
      let e4 = z(o[0], "\n").split("\n"), s = "", c = "", l = [];
      for (; e4.length > 0; ) {
        let o2 = false, u = [], f;
        for (f = 0; f < e4.length; f++) if (this.rules.other.blockquoteStart.test(e4[f])) u.push(e4[f]), o2 = true;
        else if (!o2) u.push(e4[f]);
        else break;
        e4 = e4.slice(f);
        let p = u.join("\n"), g = p.replace(this.rules.other.blockquoteSetextReplace, "\n    $1").replace(this.rules.other.blockquoteSetextReplace2, "");
        s = s ? `${s}
${p}` : p, c = c ? `${c}
${g}` : g;
        let x = this.lexer.state.top;
        if (this.lexer.state.top = true, this.lexer.blockTokens(g, l, true), this.lexer.state.top = x, e4.length === 0) break;
        let T = l.at(-1);
        if ((T == null ? void 0 : T.type) === "code") break;
        if ((T == null ? void 0 : T.type) === "blockquote") {
          let o3 = T, u2 = o3.raw + "\n" + e4.join("\n"), f2 = this.blockquote(u2);
          l[l.length - 1] = f2, s = s.substring(0, s.length - o3.raw.length) + f2.raw, c = c.substring(0, c.length - o3.text.length) + f2.text;
          break;
        } else if ((T == null ? void 0 : T.type) === "list") {
          let o3 = T, u2 = o3.raw + "\n" + e4.join("\n"), f2 = this.list(u2);
          l[l.length - 1] = f2, s = s.substring(0, s.length - T.raw.length) + f2.raw, c = c.substring(0, c.length - o3.raw.length) + f2.raw, e4 = u2.substring(l.at(-1).raw.length).split("\n");
          continue;
        }
      }
      return {
        type: "blockquote",
        raw: s,
        tokens: l,
        text: c
      };
    }
  }
  list(e3) {
    let o = this.rules.block.list.exec(e3);
    if (o) {
      let s = o[1].trim(), c = s.length > 1, l = {
        type: "list",
        raw: "",
        ordered: c,
        start: c ? +s.slice(0, -1) : "",
        loose: false,
        items: []
      };
      s = c ? `\\d{1,9}\\${s.slice(-1)}` : `\\${s}`, this.options.pedantic && (s = c ? s : "[*+-]");
      let u = this.rules.other.listItemRegex(s), f = false;
      for (; e3; ) {
        let s2 = false, c2 = "", p2 = "";
        if (!(o = u.exec(e3)) || this.rules.block.hr.test(e3)) break;
        c2 = o[0], e3 = e3.substring(c2.length);
        let g = o[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (e4) => " ".repeat(3 * e4.length)), x = e3.split("\n", 1)[0], T = !g.trim(), k = 0;
        if (this.options.pedantic ? (k = 2, p2 = g.trimStart()) : T ? k = o[1].length + 1 : (k = o[2].search(this.rules.other.nonSpaceChar), k = k > 4 ? 1 : k, p2 = g.slice(k), k += o[1].length), T && this.rules.other.blankLine.test(x) && (c2 += x + "\n", e3 = e3.substring(x.length + 1), s2 = true), !s2) {
          let o2 = this.rules.other.nextBulletRegex(k), s3 = this.rules.other.hrRegex(k), l2 = this.rules.other.fencesBeginRegex(k), u2 = this.rules.other.headingBeginRegex(k), f2 = this.rules.other.htmlBeginRegex(k);
          for (; e3; ) {
            let A2 = e3.split("\n", 1)[0], B2;
            if (x = A2, this.options.pedantic ? (x = x.replace(this.rules.other.listReplaceNesting, "  "), B2 = x) : B2 = x.replace(this.rules.other.tabCharGlobal, "    "), l2.test(x) || u2.test(x) || f2.test(x) || o2.test(x) || s3.test(x)) break;
            if (B2.search(this.rules.other.nonSpaceChar) >= k || !x.trim()) p2 += "\n" + B2.slice(k);
            else {
              if (T || g.replace(this.rules.other.tabCharGlobal, "    ").search(this.rules.other.nonSpaceChar) >= 4 || l2.test(g) || u2.test(g) || s3.test(g)) break;
              p2 += "\n" + x;
            }
            !T && !x.trim() && (T = true), c2 += A2 + "\n", e3 = e3.substring(A2.length + 1), g = B2.slice(k);
          }
        }
        l.loose || (f ? l.loose = true : this.rules.other.doubleBlankLine.test(c2) && (f = true));
        let A = null, B;
        this.options.gfm && (A = this.rules.other.listIsTask.exec(p2), A && (B = A[0] !== "[ ] ", p2 = p2.replace(this.rules.other.listReplaceTask, ""))), l.items.push({
          type: "list_item",
          raw: c2,
          task: !!A,
          checked: B,
          loose: false,
          text: p2,
          tokens: []
        }), l.raw += c2;
      }
      let p = l.items.at(-1);
      if (p) p.raw = p.raw.trimEnd(), p.text = p.text.trimEnd();
      else return;
      l.raw = l.raw.trimEnd();
      for (let e4 = 0; e4 < l.items.length; e4++) if (this.lexer.state.top = false, l.items[e4].tokens = this.lexer.blockTokens(l.items[e4].text, []), !l.loose) {
        let o2 = l.items[e4].tokens.filter((e5) => e5.type === "space");
        l.loose = o2.length > 0 && o2.some((e5) => this.rules.other.anyLine.test(e5.raw));
      }
      if (l.loose) for (let e4 = 0; e4 < l.items.length; e4++) l.items[e4].loose = true;
      return l;
    }
  }
  html(e3) {
    let o = this.rules.block.html.exec(e3);
    if (o) return {
      type: "html",
      block: true,
      raw: o[0],
      pre: o[1] === "pre" || o[1] === "script" || o[1] === "style",
      text: o[0]
    };
  }
  def(e3) {
    let o = this.rules.block.def.exec(e3);
    if (o) {
      let e4 = o[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = o[2] ? o[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", c = o[3] ? o[3].substring(1, o[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : o[3];
      return {
        type: "def",
        tag: e4,
        raw: o[0],
        href: s,
        title: c
      };
    }
  }
  table(e3) {
    var _a2;
    let o = this.rules.block.table.exec(e3);
    if (!o || !this.rules.other.tableDelimiter.test(o[2])) return;
    let s = V(o[1]), c = o[2].replace(this.rules.other.tableAlignChars, "").split("|"), l = ((_a2 = o[3]) == null ? void 0 : _a2.trim()) ? o[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], u = {
      type: "table",
      raw: o[0],
      header: [],
      align: [],
      rows: []
    };
    if (s.length === c.length) {
      for (let e4 of c) this.rules.other.tableAlignRight.test(e4) ? u.align.push("right") : this.rules.other.tableAlignCenter.test(e4) ? u.align.push("center") : this.rules.other.tableAlignLeft.test(e4) ? u.align.push("left") : u.align.push(null);
      for (let e4 = 0; e4 < s.length; e4++) u.header.push({
        text: s[e4],
        tokens: this.lexer.inline(s[e4]),
        header: true,
        align: u.align[e4]
      });
      for (let e4 of l) u.rows.push(V(e4, u.header.length).map((e5, o2) => ({
        text: e5,
        tokens: this.lexer.inline(e5),
        header: false,
        align: u.align[o2]
      })));
      return u;
    }
  }
  lheading(e3) {
    let o = this.rules.block.lheading.exec(e3);
    if (o) return {
      type: "heading",
      raw: o[0],
      depth: o[2].charAt(0) === "=" ? 1 : 2,
      text: o[1],
      tokens: this.lexer.inline(o[1])
    };
  }
  paragraph(e3) {
    let o = this.rules.block.paragraph.exec(e3);
    if (o) {
      let e4 = o[1].charAt(o[1].length - 1) === "\n" ? o[1].slice(0, -1) : o[1];
      return {
        type: "paragraph",
        raw: o[0],
        text: e4,
        tokens: this.lexer.inline(e4)
      };
    }
  }
  text(e3) {
    let o = this.rules.block.text.exec(e3);
    if (o) return {
      type: "text",
      raw: o[0],
      text: o[0],
      tokens: this.lexer.inline(o[0])
    };
  }
  escape(e3) {
    let o = this.rules.inline.escape.exec(e3);
    if (o) return {
      type: "escape",
      raw: o[0],
      text: o[1]
    };
  }
  tag(e3) {
    let o = this.rules.inline.tag.exec(e3);
    if (o) return !this.lexer.state.inLink && this.rules.other.startATag.test(o[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(o[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(o[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(o[0]) && (this.lexer.state.inRawBlock = false), {
      type: "html",
      raw: o[0],
      inLink: this.lexer.state.inLink,
      inRawBlock: this.lexer.state.inRawBlock,
      block: false,
      text: o[0]
    };
  }
  link(e3) {
    let o = this.rules.inline.link.exec(e3);
    if (o) {
      let e4 = o[2].trim();
      if (!this.options.pedantic && this.rules.other.startAngleBracket.test(e4)) {
        if (!this.rules.other.endAngleBracket.test(e4)) return;
        let o2 = z(e4.slice(0, -1), "\\");
        if ((e4.length - o2.length) % 2 == 0) return;
      } else {
        let e5 = ge(o[2], "()");
        if (e5 === -2) return;
        if (e5 > -1) {
          let s2 = (o[0].indexOf("!") === 0 ? 5 : 4) + o[1].length + e5;
          o[2] = o[2].substring(0, e5), o[0] = o[0].substring(0, s2).trim(), o[3] = "";
        }
      }
      let s = o[2], c = "";
      if (this.options.pedantic) {
        let e5 = this.rules.other.pedanticHrefTitle.exec(s);
        e5 && (s = e5[1], c = e5[3]);
      } else c = o[3] ? o[3].slice(1, -1) : "";
      return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (s = this.options.pedantic && !this.rules.other.endAngleBracket.test(e4) ? s.slice(1) : s.slice(1, -1)), fe(o, {
        href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
        title: c && c.replace(this.rules.inline.anyPunctuation, "$1")
      }, o[0], this.lexer, this.rules);
    }
  }
  reflink(e3, o) {
    let s;
    if ((s = this.rules.inline.reflink.exec(e3)) || (s = this.rules.inline.nolink.exec(e3))) {
      let e4 = o[(s[2] || s[1]).replace(this.rules.other.multipleSpaceGlobal, " ").toLowerCase()];
      if (!e4) {
        let e5 = s[0].charAt(0);
        return {
          type: "text",
          raw: e5,
          text: e5
        };
      }
      return fe(s, e4, s[0], this.lexer, this.rules);
    }
  }
  emStrong(e3, o, s = "") {
    let c = this.rules.inline.emStrongLDelim.exec(e3);
    if (!(!c || c[3] && s.match(this.rules.other.unicodeAlphaNumeric)) && (!(c[1] || c[2]) || !s || this.rules.inline.punctuation.exec(s))) {
      let s2 = [...c[0]].length - 1, l, u, f = s2, p = 0, g = c[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
      for (g.lastIndex = 0, o = o.slice(-1 * e3.length + s2); (c = g.exec(o)) != null; ) {
        if (l = c[1] || c[2] || c[3] || c[4] || c[5] || c[6], !l) continue;
        if (u = [...l].length, c[3] || c[4]) {
          f += u;
          continue;
        } else if ((c[5] || c[6]) && s2 % 3 && !((s2 + u) % 3)) {
          p += u;
          continue;
        }
        if (f -= u, f > 0) continue;
        u = Math.min(u, u + f + p);
        let o2 = [...c[0]][0].length, g2 = e3.slice(0, s2 + c.index + o2 + u);
        if (Math.min(s2, u) % 2) {
          let e4 = g2.slice(1, -1);
          return {
            type: "em",
            raw: g2,
            text: e4,
            tokens: this.lexer.inlineTokens(e4)
          };
        }
        let x = g2.slice(2, -2);
        return {
          type: "strong",
          raw: g2,
          text: x,
          tokens: this.lexer.inlineTokens(x)
        };
      }
    }
  }
  codespan(e3) {
    let o = this.rules.inline.code.exec(e3);
    if (o) {
      let e4 = o[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(e4), c = this.rules.other.startingSpaceChar.test(e4) && this.rules.other.endingSpaceChar.test(e4);
      return s && c && (e4 = e4.substring(1, e4.length - 1)), {
        type: "codespan",
        raw: o[0],
        text: e4
      };
    }
  }
  br(e3) {
    let o = this.rules.inline.br.exec(e3);
    if (o) return {
      type: "br",
      raw: o[0]
    };
  }
  del(e3) {
    let o = this.rules.inline.del.exec(e3);
    if (o) return {
      type: "del",
      raw: o[0],
      text: o[2],
      tokens: this.lexer.inlineTokens(o[2])
    };
  }
  autolink(e3) {
    let o = this.rules.inline.autolink.exec(e3);
    if (o) {
      let e4, s;
      return o[2] === "@" ? (e4 = o[1], s = "mailto:" + e4) : (e4 = o[1], s = e4), {
        type: "link",
        raw: o[0],
        text: e4,
        href: s,
        tokens: [{
          type: "text",
          raw: e4,
          text: e4
        }]
      };
    }
  }
  url(e3) {
    var _a2;
    let o;
    if (o = this.rules.inline.url.exec(e3)) {
      let e4, s;
      if (o[2] === "@") e4 = o[0], s = "mailto:" + e4;
      else {
        let c;
        do
          c = o[0], o[0] = ((_a2 = this.rules.inline._backpedal.exec(o[0])) == null ? void 0 : _a2[0]) ?? "";
        while (c !== o[0]);
        e4 = o[0], s = o[1] === "www." ? "http://" + o[0] : o[0];
      }
      return {
        type: "link",
        raw: o[0],
        text: e4,
        href: s,
        tokens: [{
          type: "text",
          raw: e4,
          text: e4
        }]
      };
    }
  }
  inlineText(e3) {
    let o = this.rules.inline.text.exec(e3);
    if (o) {
      let e4 = this.lexer.state.inRawBlock;
      return {
        type: "text",
        raw: o[0],
        text: o[0],
        escaped: e4
      };
    }
  }
}, b = class e {
  constructor(e3) {
    __publicField(this, "tokens");
    __publicField(this, "options");
    __publicField(this, "state");
    __publicField(this, "tokenizer");
    __publicField(this, "inlineQueue");
    this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e3 || O, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
      inLink: false,
      inRawBlock: false,
      top: true
    };
    let o = {
      other: m,
      block: I.normal,
      inline: M.normal
    };
    this.options.pedantic ? (o.block = I.pedantic, o.inline = M.pedantic) : this.options.gfm && (o.block = I.gfm, this.options.breaks ? o.inline = M.breaks : o.inline = M.gfm), this.tokenizer.rules = o;
  }
  static get rules() {
    return {
      block: I,
      inline: M
    };
  }
  static lex(o, s) {
    return new e(s).lex(o);
  }
  static lexInline(o, s) {
    return new e(s).inlineTokens(o);
  }
  lex(e3) {
    e3 = e3.replace(m.carriageReturn, "\n"), this.blockTokens(e3, this.tokens);
    for (let e4 = 0; e4 < this.inlineQueue.length; e4++) {
      let o = this.inlineQueue[e4];
      this.inlineTokens(o.src, o.tokens);
    }
    return this.inlineQueue = [], this.tokens;
  }
  blockTokens(e3, o = [], s = false) {
    var _a2, _b, _c;
    for (this.options.pedantic && (e3 = e3.replace(m.tabCharGlobal, "    ").replace(m.spaceLine, "")); e3; ) {
      let c;
      if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.block) == null ? void 0 : _b.some((s2) => (c = s2.call({ lexer: this }, e3, o)) ? (e3 = e3.substring(c.raw.length), o.push(c), true) : false)) continue;
      if (c = this.tokenizer.space(e3)) {
        e3 = e3.substring(c.raw.length);
        let s2 = o.at(-1);
        c.raw.length === 1 && s2 !== void 0 ? s2.raw += "\n" : o.push(c);
        continue;
      }
      if (c = this.tokenizer.code(e3)) {
        e3 = e3.substring(c.raw.length);
        let s2 = o.at(-1);
        (s2 == null ? void 0 : s2.type) === "paragraph" || (s2 == null ? void 0 : s2.type) === "text" ? (s2.raw += (s2.raw.endsWith("\n") ? "" : "\n") + c.raw, s2.text += "\n" + c.text, this.inlineQueue.at(-1).src = s2.text) : o.push(c);
        continue;
      }
      if (c = this.tokenizer.fences(e3)) {
        e3 = e3.substring(c.raw.length), o.push(c);
        continue;
      }
      if (c = this.tokenizer.heading(e3)) {
        e3 = e3.substring(c.raw.length), o.push(c);
        continue;
      }
      if (c = this.tokenizer.hr(e3)) {
        e3 = e3.substring(c.raw.length), o.push(c);
        continue;
      }
      if (c = this.tokenizer.blockquote(e3)) {
        e3 = e3.substring(c.raw.length), o.push(c);
        continue;
      }
      if (c = this.tokenizer.list(e3)) {
        e3 = e3.substring(c.raw.length), o.push(c);
        continue;
      }
      if (c = this.tokenizer.html(e3)) {
        e3 = e3.substring(c.raw.length), o.push(c);
        continue;
      }
      if (c = this.tokenizer.def(e3)) {
        e3 = e3.substring(c.raw.length);
        let s2 = o.at(-1);
        (s2 == null ? void 0 : s2.type) === "paragraph" || (s2 == null ? void 0 : s2.type) === "text" ? (s2.raw += (s2.raw.endsWith("\n") ? "" : "\n") + c.raw, s2.text += "\n" + c.raw, this.inlineQueue.at(-1).src = s2.text) : this.tokens.links[c.tag] || (this.tokens.links[c.tag] = {
          href: c.href,
          title: c.title
        }, o.push(c));
        continue;
      }
      if (c = this.tokenizer.table(e3)) {
        e3 = e3.substring(c.raw.length), o.push(c);
        continue;
      }
      if (c = this.tokenizer.lheading(e3)) {
        e3 = e3.substring(c.raw.length), o.push(c);
        continue;
      }
      let l = e3;
      if ((_c = this.options.extensions) == null ? void 0 : _c.startBlock) {
        let o2 = Infinity, s2 = e3.slice(1), c2;
        this.options.extensions.startBlock.forEach((e4) => {
          c2 = e4.call({ lexer: this }, s2), typeof c2 == "number" && c2 >= 0 && (o2 = Math.min(o2, c2));
        }), o2 < Infinity && o2 >= 0 && (l = e3.substring(0, o2 + 1));
      }
      if (this.state.top && (c = this.tokenizer.paragraph(l))) {
        let u = o.at(-1);
        s && (u == null ? void 0 : u.type) === "paragraph" ? (u.raw += (u.raw.endsWith("\n") ? "" : "\n") + c.raw, u.text += "\n" + c.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = u.text) : o.push(c), s = l.length !== e3.length, e3 = e3.substring(c.raw.length);
        continue;
      }
      if (c = this.tokenizer.text(e3)) {
        e3 = e3.substring(c.raw.length);
        let s2 = o.at(-1);
        (s2 == null ? void 0 : s2.type) === "text" ? (s2.raw += (s2.raw.endsWith("\n") ? "" : "\n") + c.raw, s2.text += "\n" + c.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s2.text) : o.push(c);
        continue;
      }
      if (e3) {
        let o2 = "Infinite loop on byte: " + e3.charCodeAt(0);
        if (this.options.silent) {
          console.error(o2);
          break;
        } else throw Error(o2);
      }
    }
    return this.state.top = true, o;
  }
  inline(e3, o = []) {
    return this.inlineQueue.push({
      src: e3,
      tokens: o
    }), o;
  }
  inlineTokens(e3, o = []) {
    var _a2, _b, _c;
    let s = e3, c = null;
    if (this.tokens.links) {
      let e4 = Object.keys(this.tokens.links);
      if (e4.length > 0) for (; (c = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; ) e4.includes(c[0].slice(c[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, c.index) + "[" + "a".repeat(c[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
    }
    for (; (c = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; ) s = s.slice(0, c.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
    for (; (c = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; ) s = s.slice(0, c.index) + "[" + "a".repeat(c[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
    let l = false, u = "";
    for (; e3; ) {
      l || (u = ""), l = false;
      let c2;
      if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.inline) == null ? void 0 : _b.some((s2) => (c2 = s2.call({ lexer: this }, e3, o)) ? (e3 = e3.substring(c2.raw.length), o.push(c2), true) : false)) continue;
      if (c2 = this.tokenizer.escape(e3)) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      if (c2 = this.tokenizer.tag(e3)) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      if (c2 = this.tokenizer.link(e3)) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      if (c2 = this.tokenizer.reflink(e3, this.tokens.links)) {
        e3 = e3.substring(c2.raw.length);
        let s2 = o.at(-1);
        c2.type === "text" && (s2 == null ? void 0 : s2.type) === "text" ? (s2.raw += c2.raw, s2.text += c2.text) : o.push(c2);
        continue;
      }
      if (c2 = this.tokenizer.emStrong(e3, s, u)) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      if (c2 = this.tokenizer.codespan(e3)) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      if (c2 = this.tokenizer.br(e3)) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      if (c2 = this.tokenizer.del(e3)) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      if (c2 = this.tokenizer.autolink(e3)) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      if (!this.state.inLink && (c2 = this.tokenizer.url(e3))) {
        e3 = e3.substring(c2.raw.length), o.push(c2);
        continue;
      }
      let f = e3;
      if ((_c = this.options.extensions) == null ? void 0 : _c.startInline) {
        let o2 = Infinity, s2 = e3.slice(1), c3;
        this.options.extensions.startInline.forEach((e4) => {
          c3 = e4.call({ lexer: this }, s2), typeof c3 == "number" && c3 >= 0 && (o2 = Math.min(o2, c3));
        }), o2 < Infinity && o2 >= 0 && (f = e3.substring(0, o2 + 1));
      }
      if (c2 = this.tokenizer.inlineText(f)) {
        e3 = e3.substring(c2.raw.length), c2.raw.slice(-1) !== "_" && (u = c2.raw.slice(-1)), l = true;
        let s2 = o.at(-1);
        (s2 == null ? void 0 : s2.type) === "text" ? (s2.raw += c2.raw, s2.text += c2.text) : o.push(c2);
        continue;
      }
      if (e3) {
        let o2 = "Infinite loop on byte: " + e3.charCodeAt(0);
        if (this.options.silent) {
          console.error(o2);
          break;
        } else throw Error(o2);
      }
    }
    return o;
  }
}, P = class {
  constructor(e3) {
    __publicField(this, "options");
    __publicField(this, "parser");
    this.options = e3 || O;
  }
  space(e3) {
    return "";
  }
  code({ text: e3, lang: o, escaped: s }) {
    var _a2;
    let c = (_a2 = (o || "").match(m.notSpaceStart)) == null ? void 0 : _a2[0], l = e3.replace(m.endingNewline, "") + "\n";
    return c ? '<pre><code class="language-' + w(c) + '">' + (s ? l : w(l, true)) + "</code></pre>\n" : "<pre><code>" + (s ? l : w(l, true)) + "</code></pre>\n";
  }
  blockquote({ tokens: e3 }) {
    return `<blockquote>
${this.parser.parse(e3)}</blockquote>
`;
  }
  html({ text: e3 }) {
    return e3;
  }
  def(e3) {
    return "";
  }
  heading({ tokens: e3, depth: o }) {
    return `<h${o}>${this.parser.parseInline(e3)}</h${o}>
`;
  }
  hr(e3) {
    return "<hr>\n";
  }
  list(e3) {
    let o = e3.ordered, s = e3.start, c = "";
    for (let o2 = 0; o2 < e3.items.length; o2++) {
      let s2 = e3.items[o2];
      c += this.listitem(s2);
    }
    let l = o ? "ol" : "ul", u = o && s !== 1 ? ' start="' + s + '"' : "";
    return "<" + l + u + ">\n" + c + "</" + l + ">\n";
  }
  listitem(e3) {
    var _a2;
    let o = "";
    if (e3.task) {
      let s = this.checkbox({ checked: !!e3.checked });
      e3.loose ? ((_a2 = e3.tokens[0]) == null ? void 0 : _a2.type) === "paragraph" ? (e3.tokens[0].text = s + " " + e3.tokens[0].text, e3.tokens[0].tokens && e3.tokens[0].tokens.length > 0 && e3.tokens[0].tokens[0].type === "text" && (e3.tokens[0].tokens[0].text = s + " " + w(e3.tokens[0].tokens[0].text), e3.tokens[0].tokens[0].escaped = true)) : e3.tokens.unshift({
        type: "text",
        raw: s + " ",
        text: s + " ",
        escaped: true
      }) : o += s + " ";
    }
    return o += this.parser.parse(e3.tokens, !!e3.loose), `<li>${o}</li>
`;
  }
  checkbox({ checked: e3 }) {
    return "<input " + (e3 ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
  }
  paragraph({ tokens: e3 }) {
    return `<p>${this.parser.parseInline(e3)}</p>
`;
  }
  table(e3) {
    let o = "", s = "";
    for (let o2 = 0; o2 < e3.header.length; o2++) s += this.tablecell(e3.header[o2]);
    o += this.tablerow({ text: s });
    let c = "";
    for (let o2 = 0; o2 < e3.rows.length; o2++) {
      let l = e3.rows[o2];
      s = "";
      for (let e4 = 0; e4 < l.length; e4++) s += this.tablecell(l[e4]);
      c += this.tablerow({ text: s });
    }
    return c && (c = `<tbody>${c}</tbody>`), "<table>\n<thead>\n" + o + "</thead>\n" + c + "</table>\n";
  }
  tablerow({ text: e3 }) {
    return `<tr>
${e3}</tr>
`;
  }
  tablecell(e3) {
    let o = this.parser.parseInline(e3.tokens), s = e3.header ? "th" : "td";
    return (e3.align ? `<${s} align="${e3.align}">` : `<${s}>`) + o + `</${s}>
`;
  }
  strong({ tokens: e3 }) {
    return `<strong>${this.parser.parseInline(e3)}</strong>`;
  }
  em({ tokens: e3 }) {
    return `<em>${this.parser.parseInline(e3)}</em>`;
  }
  codespan({ text: e3 }) {
    return `<code>${w(e3, true)}</code>`;
  }
  br(e3) {
    return "<br>";
  }
  del({ tokens: e3 }) {
    return `<del>${this.parser.parseInline(e3)}</del>`;
  }
  link({ href: e3, title: o, tokens: s }) {
    let c = this.parser.parseInline(s), l = J(e3);
    if (l === null) return c;
    e3 = l;
    let u = '<a href="' + e3 + '"';
    return o && (u += ' title="' + w(o) + '"'), u += ">" + c + "</a>", u;
  }
  image({ href: e3, title: o, text: s, tokens: c }) {
    c && (s = this.parser.parseInline(c, this.parser.textRenderer));
    let l = J(e3);
    if (l === null) return w(s);
    e3 = l;
    let u = `<img src="${e3}" alt="${s}"`;
    return o && (u += ` title="${w(o)}"`), u += ">", u;
  }
  text(e3) {
    return "tokens" in e3 && e3.tokens ? this.parser.parseInline(e3.tokens) : "escaped" in e3 && e3.escaped ? e3.text : w(e3.text);
  }
}, S = class {
  strong({ text: e3 }) {
    return e3;
  }
  em({ text: e3 }) {
    return e3;
  }
  codespan({ text: e3 }) {
    return e3;
  }
  del({ text: e3 }) {
    return e3;
  }
  html({ text: e3 }) {
    return e3;
  }
  text({ text: e3 }) {
    return e3;
  }
  link({ text: e3 }) {
    return "" + e3;
  }
  image({ text: e3 }) {
    return "" + e3;
  }
  br() {
    return "";
  }
}, R = class e2 {
  constructor(e3) {
    __publicField(this, "options");
    __publicField(this, "renderer");
    __publicField(this, "textRenderer");
    this.options = e3 || O, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new S();
  }
  static parse(o, s) {
    return new e2(s).parse(o);
  }
  static parseInline(o, s) {
    return new e2(s).parseInline(o);
  }
  parse(e3, o = true) {
    var _a2, _b;
    let s = "";
    for (let c = 0; c < e3.length; c++) {
      let l = e3[c];
      if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[l.type]) {
        let e4 = l, o2 = this.options.extensions.renderers[e4.type].call({ parser: this }, e4);
        if (o2 !== false || ![
          "space",
          "hr",
          "heading",
          "code",
          "table",
          "blockquote",
          "list",
          "html",
          "def",
          "paragraph",
          "text"
        ].includes(e4.type)) {
          s += o2 || "";
          continue;
        }
      }
      let u = l;
      switch (u.type) {
        case "space":
          s += this.renderer.space(u);
          continue;
        case "hr":
          s += this.renderer.hr(u);
          continue;
        case "heading":
          s += this.renderer.heading(u);
          continue;
        case "code":
          s += this.renderer.code(u);
          continue;
        case "table":
          s += this.renderer.table(u);
          continue;
        case "blockquote":
          s += this.renderer.blockquote(u);
          continue;
        case "list":
          s += this.renderer.list(u);
          continue;
        case "html":
          s += this.renderer.html(u);
          continue;
        case "def":
          s += this.renderer.def(u);
          continue;
        case "paragraph":
          s += this.renderer.paragraph(u);
          continue;
        case "text": {
          let l2 = u, f = this.renderer.text(l2);
          for (; c + 1 < e3.length && e3[c + 1].type === "text"; ) l2 = e3[++c], f += "\n" + this.renderer.text(l2);
          o ? s += this.renderer.paragraph({
            type: "paragraph",
            raw: f,
            text: f,
            tokens: [{
              type: "text",
              raw: f,
              text: f,
              escaped: true
            }]
          }) : s += f;
          continue;
        }
        default: {
          let e4 = 'Token with "' + u.type + '" type was not found.';
          if (this.options.silent) return console.error(e4), "";
          throw Error(e4);
        }
      }
    }
    return s;
  }
  parseInline(e3, o = this.renderer) {
    var _a2, _b;
    let s = "";
    for (let c = 0; c < e3.length; c++) {
      let l = e3[c];
      if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[l.type]) {
        let e4 = this.options.extensions.renderers[l.type].call({ parser: this }, l);
        if (e4 !== false || ![
          "escape",
          "html",
          "link",
          "image",
          "strong",
          "em",
          "codespan",
          "br",
          "del",
          "text"
        ].includes(l.type)) {
          s += e4 || "";
          continue;
        }
      }
      let u = l;
      switch (u.type) {
        case "escape":
          s += o.text(u);
          break;
        case "html":
          s += o.html(u);
          break;
        case "link":
          s += o.link(u);
          break;
        case "image":
          s += o.image(u);
          break;
        case "strong":
          s += o.strong(u);
          break;
        case "em":
          s += o.em(u);
          break;
        case "codespan":
          s += o.codespan(u);
          break;
        case "br":
          s += o.br(u);
          break;
        case "del":
          s += o.del(u);
          break;
        case "text":
          s += o.text(u);
          break;
        default: {
          let e4 = 'Token with "' + u.type + '" type was not found.';
          if (this.options.silent) return console.error(e4), "";
          throw Error(e4);
        }
      }
    }
    return s;
  }
}, $ = (_a = class {
  constructor(e3) {
    __publicField(this, "options");
    __publicField(this, "block");
    this.options = e3 || O;
  }
  preprocess(e3) {
    return e3;
  }
  postprocess(e3) {
    return e3;
  }
  processAllTokens(e3) {
    return e3;
  }
  provideLexer() {
    return this.block ? b.lex : b.lexInline;
  }
  provideParser() {
    return this.block ? R.parse : R.parseInline;
  }
}, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set([
  "preprocess",
  "postprocess",
  "processAllTokens"
])), _a), _ = new class {
  constructor(...e3) {
    __publicField(this, "defaults", L());
    __publicField(this, "options", this.setOptions);
    __publicField(this, "parse", this.parseMarkdown(true));
    __publicField(this, "parseInline", this.parseMarkdown(false));
    __publicField(this, "Parser", R);
    __publicField(this, "Renderer", P);
    __publicField(this, "TextRenderer", S);
    __publicField(this, "Lexer", b);
    __publicField(this, "Tokenizer", y);
    __publicField(this, "Hooks", $);
    this.use(...e3);
  }
  walkTokens(e3, o) {
    var _a2, _b;
    let s = [];
    for (let c of e3) switch (s = s.concat(o.call(this, c)), c.type) {
      case "table": {
        let e4 = c;
        for (let c2 of e4.header) s = s.concat(this.walkTokens(c2.tokens, o));
        for (let c2 of e4.rows) for (let e5 of c2) s = s.concat(this.walkTokens(e5.tokens, o));
        break;
      }
      case "list": {
        let e4 = c;
        s = s.concat(this.walkTokens(e4.items, o));
        break;
      }
      default: {
        let e4 = c;
        ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[e4.type]) ? this.defaults.extensions.childTokens[e4.type].forEach((c2) => {
          let l = e4[c2].flat(Infinity);
          s = s.concat(this.walkTokens(l, o));
        }) : e4.tokens && (s = s.concat(this.walkTokens(e4.tokens, o)));
      }
    }
    return s;
  }
  use(...e3) {
    let o = this.defaults.extensions || {
      renderers: {},
      childTokens: {}
    };
    return e3.forEach((e4) => {
      let s = { ...e4 };
      if (s.async = this.defaults.async || s.async || false, e4.extensions && (e4.extensions.forEach((e5) => {
        if (!e5.name) throw Error("extension name required");
        if ("renderer" in e5) {
          let s2 = o.renderers[e5.name];
          s2 ? o.renderers[e5.name] = function(...o2) {
            let c = e5.renderer.apply(this, o2);
            return c === false && (c = s2.apply(this, o2)), c;
          } : o.renderers[e5.name] = e5.renderer;
        }
        if ("tokenizer" in e5) {
          if (!e5.level || e5.level !== "block" && e5.level !== "inline") throw Error("extension level must be 'block' or 'inline'");
          let s2 = o[e5.level];
          s2 ? s2.unshift(e5.tokenizer) : o[e5.level] = [e5.tokenizer], e5.start && (e5.level === "block" ? o.startBlock ? o.startBlock.push(e5.start) : o.startBlock = [e5.start] : e5.level === "inline" && (o.startInline ? o.startInline.push(e5.start) : o.startInline = [e5.start]));
        }
        "childTokens" in e5 && e5.childTokens && (o.childTokens[e5.name] = e5.childTokens);
      }), s.extensions = o), e4.renderer) {
        let o2 = this.defaults.renderer || new P(this.defaults);
        for (let s2 in e4.renderer) {
          if (!(s2 in o2)) throw Error(`renderer '${s2}' does not exist`);
          if (["options", "parser"].includes(s2)) continue;
          let c = s2, l = e4.renderer[c], u = o2[c];
          o2[c] = (...e5) => {
            let s3 = l.apply(o2, e5);
            return s3 === false && (s3 = u.apply(o2, e5)), s3 || "";
          };
        }
        s.renderer = o2;
      }
      if (e4.tokenizer) {
        let o2 = this.defaults.tokenizer || new y(this.defaults);
        for (let s2 in e4.tokenizer) {
          if (!(s2 in o2)) throw Error(`tokenizer '${s2}' does not exist`);
          if ([
            "options",
            "rules",
            "lexer"
          ].includes(s2)) continue;
          let c = s2, l = e4.tokenizer[c], u = o2[c];
          o2[c] = (...e5) => {
            let s3 = l.apply(o2, e5);
            return s3 === false && (s3 = u.apply(o2, e5)), s3;
          };
        }
        s.tokenizer = o2;
      }
      if (e4.hooks) {
        let o2 = this.defaults.hooks || new $();
        for (let s2 in e4.hooks) {
          if (!(s2 in o2)) throw Error(`hook '${s2}' does not exist`);
          if (["options", "block"].includes(s2)) continue;
          let c = s2, l = e4.hooks[c], u = o2[c];
          $.passThroughHooks.has(s2) ? o2[c] = (e5) => {
            if (this.defaults.async) return Promise.resolve(l.call(o2, e5)).then((e6) => u.call(o2, e6));
            let s3 = l.call(o2, e5);
            return u.call(o2, s3);
          } : o2[c] = (...e5) => {
            let s3 = l.apply(o2, e5);
            return s3 === false && (s3 = u.apply(o2, e5)), s3;
          };
        }
        s.hooks = o2;
      }
      if (e4.walkTokens) {
        let o2 = this.defaults.walkTokens, c = e4.walkTokens;
        s.walkTokens = function(e5) {
          let s2 = [];
          return s2.push(c.call(this, e5)), o2 && (s2 = s2.concat(o2.call(this, e5))), s2;
        };
      }
      this.defaults = {
        ...this.defaults,
        ...s
      };
    }), this;
  }
  setOptions(e3) {
    return this.defaults = {
      ...this.defaults,
      ...e3
    }, this;
  }
  lexer(e3, o) {
    return b.lex(e3, o ?? this.defaults);
  }
  parser(e3, o) {
    return R.parse(e3, o ?? this.defaults);
  }
  parseMarkdown(e3) {
    return (o, s) => {
      let c = { ...s }, l = {
        ...this.defaults,
        ...c
      }, u = this.onError(!!l.silent, !!l.async);
      if (this.defaults.async === true && c.async === false) return u(/* @__PURE__ */ 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 o > "u" || o === null) return u(/* @__PURE__ */ Error("marked(): input parameter is undefined or null"));
      if (typeof o != "string") return u(/* @__PURE__ */ Error("marked(): input parameter is of type " + Object.prototype.toString.call(o) + ", string expected"));
      l.hooks && (l.hooks.options = l, l.hooks.block = e3);
      let f = l.hooks ? l.hooks.provideLexer() : e3 ? b.lex : b.lexInline, p = l.hooks ? l.hooks.provideParser() : e3 ? R.parse : R.parseInline;
      if (l.async) return Promise.resolve(l.hooks ? l.hooks.preprocess(o) : o).then((e4) => f(e4, l)).then((e4) => l.hooks ? l.hooks.processAllTokens(e4) : e4).then((e4) => l.walkTokens ? Promise.all(this.walkTokens(e4, l.walkTokens)).then(() => e4) : e4).then((e4) => p(e4, l)).then((e4) => l.hooks ? l.hooks.postprocess(e4) : e4).catch(u);
      try {
        l.hooks && (o = l.hooks.preprocess(o));
        let e4 = f(o, l);
        l.hooks && (e4 = l.hooks.processAllTokens(e4)), l.walkTokens && this.walkTokens(e4, l.walkTokens);
        let s2 = p(e4, l);
        return l.hooks && (s2 = l.hooks.postprocess(s2)), s2;
      } catch (e4) {
        return u(e4);
      }
    };
  }
  onError(e3, o) {
    return (s) => {
      if (s.message += "\nPlease report this to https://github.com/markedjs/marked.", e3) {
        let e4 = "<p>An error occurred:</p><pre>" + w(s.message + "", true) + "</pre>";
        return o ? Promise.resolve(e4) : e4;
      }
      if (o) return Promise.reject(s);
      throw s;
    };
  }
}();
function d(e3, o) {
  return _.parse(e3, o);
}
d.options = d.setOptions = function(e3) {
  return _.setOptions(e3), d.defaults = _.defaults, H(d.defaults), d;
}, d.getDefaults = L, d.defaults = O, d.use = function(...e3) {
  return _.use(...e3), d.defaults = _.defaults, H(d.defaults), d;
}, d.walkTokens = function(e3, o) {
  return _.walkTokens(e3, o);
}, d.parseInline = _.parseInline, d.Parser = R, d.parser = R.parse, d.Renderer = P, d.TextRenderer = S, d.Lexer = b, d.lexer = b.lex, d.Tokenizer = y, d.Hooks = $, d.parse = d, d.options, d.setOptions, d.use, d.walkTokens, d.parseInline, R.parse, b.lex;
function dedent(e3) {
  var o = [...arguments].slice(1), s = Array.from(typeof e3 == "string" ? [e3] : e3);
  s[s.length - 1] = s[s.length - 1].replace(/\r?\n([\t ]*)$/, "");
  var c = s.reduce(function(e4, o2) {
    var s2 = o2.match(/\n([\t ]+|(?!\s).)/g);
    return s2 ? e4.concat(s2.map(function(e5) {
      var _a2;
      return ((_a2 = e5.match(/[\t ]/g)) == null ? void 0 : _a2.length) ?? 0;
    })) : e4;
  }, []);
  if (c.length) {
    var l = RegExp("\n[	 ]{" + Math.min.apply(Math, c) + "}", "g");
    s = s.map(function(e4) {
      return e4.replace(l, "\n");
    });
  }
  s[0] = s[0].replace(/^\r?\n/, "");
  var u = s[0];
  return o.forEach(function(e4, o2) {
    var c2 = u.match(/(?:^|\n)( *)$/), l2 = c2 ? c2[1] : "", f = e4;
    typeof e4 == "string" && e4.includes("\n") && (f = String(e4).split("\n").map(function(e5, o3) {
      return o3 === 0 ? e5 : "" + l2 + e5;
    }).join("\n")), u += f + s[o2 + 1];
  }), u;
}
var unknownIcon = {
  body: '<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/><text transform="translate(21.16 64.67)" style="fill: #fff; font-family: ArialMT, Arial; font-size: 67.75px;"><tspan x="0" y="0">?</tspan></text></g>',
  height: 80,
  width: 80
}, iconsStore = /* @__PURE__ */ new Map(), loaderStore = /* @__PURE__ */ new Map(), registerIconPacks = /* @__PURE__ */ __name((e3) => {
  for (let s of e3) {
    if (!s.name) throw Error('Invalid icon loader. Must have a "name" property with non-empty string value.');
    if (log.debug("Registering icon pack:", s.name), "loader" in s) loaderStore.set(s.name, s.loader);
    else if ("icons" in s) iconsStore.set(s.name, s.icons);
    else throw log.error("Invalid icon loader:", s), Error('Invalid icon loader. Must have either "icons" or "loader" property.');
  }
}, "registerIconPacks"), getRegisteredIconData = /* @__PURE__ */ __name(async (e3, s) => {
  let c = stringToIcon(e3, true, s !== void 0);
  if (!c) throw Error(`Invalid icon name: ${e3}`);
  let l = c.prefix || s;
  if (!l) throw Error(`Icon name must contain a prefix: ${e3}`);
  let u = iconsStore.get(l);
  if (!u) {
    let e4 = loaderStore.get(l);
    if (!e4) throw Error(`Icon set not found: ${c.prefix}`);
    try {
      u = {
        ...await e4(),
        prefix: l
      }, iconsStore.set(l, u);
    } catch (e5) {
      throw log.error(e5), Error(`Failed to load icon set: ${c.prefix}`);
    }
  }
  let f = getIconData(u, c.name);
  if (!f) throw Error(`Icon not found: ${e3}`);
  return f;
}, "getRegisteredIconData"), isIconAvailable = /* @__PURE__ */ __name(async (e3) => {
  try {
    return await getRegisteredIconData(e3), true;
  } catch {
    return false;
  }
}, "isIconAvailable"), getIconSVG = /* @__PURE__ */ __name(async (e3, s, c) => {
  let u;
  try {
    u = await getRegisteredIconData(e3, s == null ? void 0 : s.fallbackPrefix);
  } catch (e4) {
    log.error(e4), u = unknownIcon;
  }
  let f = iconToSVG(u, s);
  return sanitizeText(iconToHTML(replaceIDs(f.body), {
    ...f.attributes,
    ...c
  }), getConfig());
}, "getIconSVG");
function preprocessMarkdown(e3, { markdownAutoWrap: o }) {
  let s = dedent(e3.replace(/<br\/>/g, "\n").replace(/\n{2,}/g, "\n"));
  return o === false ? s.replace(/ /g, "&nbsp;") : s;
}
__name(preprocessMarkdown, "preprocessMarkdown");
function markdownToLines(e3, o = {}) {
  let c = preprocessMarkdown(e3, o), l = d.lexer(c), u = [[]], f = 0;
  function p(e4, o2 = "normal") {
    e4.type === "text" ? e4.text.split("\n").forEach((e5, s) => {
      s !== 0 && (f++, u.push([])), e5.split(" ").forEach((e6) => {
        e6 = e6.replace(/&#39;/g, "'"), e6 && u[f].push({
          content: e6,
          type: o2
        });
      });
    }) : e4.type === "strong" || e4.type === "em" ? e4.tokens.forEach((o3) => {
      p(o3, e4.type);
    }) : e4.type === "html" && u[f].push({
      content: e4.text,
      type: "normal"
    });
  }
  return __name(p, "processNode"), l.forEach((e4) => {
    var _a2;
    e4.type === "paragraph" ? (_a2 = e4.tokens) == null ? void 0 : _a2.forEach((e5) => {
      p(e5);
    }) : e4.type === "html" ? u[f].push({
      content: e4.text,
      type: "normal"
    }) : u[f].push({
      content: e4.raw,
      type: "normal"
    });
  }), u;
}
__name(markdownToLines, "markdownToLines");
function markdownToHTML(e3, { markdownAutoWrap: c } = {}) {
  let l = d.lexer(e3);
  function u(e4) {
    var _a2, _b, _c;
    return e4.type === "text" ? c === false ? e4.text.replace(/\n */g, "<br/>").replace(/ /g, "&nbsp;") : e4.text.replace(/\n */g, "<br/>") : e4.type === "strong" ? `<strong>${(_a2 = e4.tokens) == null ? void 0 : _a2.map(u).join("")}</strong>` : e4.type === "em" ? `<em>${(_b = e4.tokens) == null ? void 0 : _b.map(u).join("")}</em>` : e4.type === "paragraph" ? `<p>${(_c = e4.tokens) == null ? void 0 : _c.map(u).join("")}</p>` : e4.type === "space" ? "" : e4.type === "html" ? `${e4.text}` : e4.type === "escape" ? e4.text : (log.warn(`Unsupported markdown: ${e4.type}`), e4.raw);
  }
  return __name(u, "output"), l.map(u).join("");
}
__name(markdownToHTML, "markdownToHTML");
function splitTextToChars(e3) {
  return Intl.Segmenter ? [...new Intl.Segmenter().segment(e3)].map((e4) => e4.segment) : [...e3];
}
__name(splitTextToChars, "splitTextToChars");
function splitWordToFitWidth(e3, o) {
  return splitWordToFitWidthRecursion(e3, [], splitTextToChars(o.content), o.type);
}
__name(splitWordToFitWidth, "splitWordToFitWidth");
function splitWordToFitWidthRecursion(e3, o, s, c) {
  if (s.length === 0) return [{
    content: o.join(""),
    type: c
  }, {
    content: "",
    type: c
  }];
  let [l, ...u] = s, f = [...o, l];
  return e3([{
    content: f.join(""),
    type: c
  }]) ? splitWordToFitWidthRecursion(e3, f, u, c) : (o.length === 0 && l && (o.push(l), s.shift()), [{
    content: o.join(""),
    type: c
  }, {
    content: s.join(""),
    type: c
  }]);
}
__name(splitWordToFitWidthRecursion, "splitWordToFitWidthRecursion");
function splitLineToFitWidth(e3, o) {
  if (e3.some(({ content: e4 }) => e4.includes("\n"))) throw Error("splitLineToFitWidth does not support newlines in the line");
  return splitLineToFitWidthRecursion(e3, o);
}
__name(splitLineToFitWidth, "splitLineToFitWidth");
function splitLineToFitWidthRecursion(e3, o, s = [], c = []) {
  if (e3.length === 0) return c.length > 0 && s.push(c), s.length > 0 ? s : [];
  let l = "";
  e3[0].content === " " && (l = " ", e3.shift());
  let u = e3.shift() ?? {
    content: " ",
    type: "normal"
  }, f = [...c];
  if (l !== "" && f.push({
    content: l,
    type: "normal"
  }), f.push(u), o(f)) return splitLineToFitWidthRecursion(e3, o, s, f);
  if (c.length > 0) s.push(c), e3.unshift(u);
  else if (u.content) {
    let [c2, l2] = splitWordToFitWidth(o, u);
    s.push([c2]), l2.content && e3.unshift(l2);
  }
  return splitLineToFitWidthRecursion(e3, o, s);
}
__name(splitLineToFitWidthRecursion, "splitLineToFitWidthRecursion");
function applyStyle(e3, o) {
  o && e3.attr("style", o);
}
__name(applyStyle, "applyStyle");
async function addHtmlSpan(e3, o, s, c, x = false, T = getConfig()) {
  let k = e3.append("foreignObject");
  k.attr("width", `${10 * s}px`), k.attr("height", `${10 * s}px`);
  let A = k.append("xhtml:div"), B = hasKatex(o.label) ? await renderKatexSanitized(o.label.replace(common_default.lineBreakRegex, "\n"), T) : sanitizeText(o.label, T), G = o.isNode ? "nodeLabel" : "edgeLabel", Y = A.append("span");
  Y.html(B), applyStyle(Y, o.labelStyle), Y.attr("class", `${G} ${c}`), applyStyle(A, o.labelStyle), A.style("display", "table-cell"), A.style("white-space", "nowrap"), A.style("line-height", "1.5"), A.style("max-width", s + "px"), A.style("text-align", "center"), A.attr("xmlns", "http://www.w3.org/1999/xhtml"), x && A.attr("class", "labelBkg");
  let Z = A.node().getBoundingClientRect();
  return Z.width === s && (A.style("display", "table"), A.style("white-space", "break-spaces"), A.style("width", s + "px"), Z = A.node().getBoundingClientRect()), k.node();
}
__name(addHtmlSpan, "addHtmlSpan");
function createTspan(e3, o, s) {
  return e3.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", o * s - 0.1 + "em").attr("dy", s + "em");
}
__name(createTspan, "createTspan");
function computeWidthOfText(e3, o, s) {
  let c = e3.append("text"), l = createTspan(c, 1, o);
  updateTextContentAndStyles(l, s);
  let u = l.node().getComputedTextLength();
  return c.remove(), u;
}
__name(computeWidthOfText, "computeWidthOfText");
function computeDimensionOfText(e3, o, s) {
  var _a2;
  let c = e3.append("text"), l = createTspan(c, 1, o);
  updateTextContentAndStyles(l, [{
    content: s,
    type: "normal"
  }]);
  let u = (_a2 = l.node()) == null ? void 0 : _a2.getBoundingClientRect();
  return u && c.remove(), u;
}
__name(computeDimensionOfText, "computeDimensionOfText");
function createFormattedText(e3, o, c, l = false) {
  let u = 1.1, f = o.append("g"), p = f.insert("rect").attr("class", "background").attr("style", "stroke: none"), g = f.append("text").attr("y", "-10.1"), x = 0;
  for (let o2 of c) {
    let c2 = /* @__PURE__ */ __name((o3) => computeWidthOfText(f, u, o3) <= e3, "checkWidth"), l2 = c2(o2) ? [o2] : splitLineToFitWidth(o2, c2);
    for (let e4 of l2) updateTextContentAndStyles(createTspan(g, x, u), e4), x++;
  }
  if (l) {
    let e4 = g.node().getBBox();
    return p.attr("x", e4.x - 2).attr("y", e4.y - 2).attr("width", e4.width + 4).attr("height", e4.height + 4), f.node();
  } else return g.node();
}
__name(createFormattedText, "createFormattedText");
function updateTextContentAndStyles(e3, o) {
  e3.text(""), o.forEach((o2, s) => {
    let c = e3.append("tspan").attr("font-style", o2.type === "em" ? "italic" : "normal").attr("class", "text-inner-tspan").attr("font-weight", o2.type === "strong" ? "bold" : "normal");
    s === 0 ? c.text(o2.content) : c.text(" " + o2.content);
  });
}
__name(updateTextContentAndStyles, "updateTextContentAndStyles");
async function replaceIconSubstring(e3, o = {}) {
  let s = [];
  e3.replace(/(fa[bklrs]?):fa-([\w-]+)/g, (e4, c2, u) => (s.push((async () => {
    let s2 = `${c2}:${u}`;
    return await isIconAvailable(s2) ? await getIconSVG(s2, void 0, { class: "label-icon" }) : `<i class='${sanitizeText(e4, o).replace(":", " ")}'></i>`;
  })()), e4));
  let c = await Promise.all(s);
  return e3.replace(/(fa[bklrs]?):fa-([\w-]+)/g, () => c.shift() ?? "");
}
__name(replaceIconSubstring, "replaceIconSubstring");
var createText = /* @__PURE__ */ __name(async (s, l = "", { style: u = "", isTitle: p = false, classes: g = "", useHtmlLabels: x = true, isNode: T = true, width: k = 200, addSvgBackground: A = false } = {}, B) => {
  if (log.debug("XYZ createText", l, u, p, g, x, T, "addSvgBackground: ", A), x) {
    let o = await replaceIconSubstring(decodeEntities(markdownToHTML(l, B)), B), c = l.replace(/\\\\/g, "\\");
    return await addHtmlSpan(s, {
      isNode: T,
      label: hasKatex(l) ? c : o,
      labelStyle: u.replace("fill:", "color:")
    }, k, g, A, B);
  } else {
    let e3 = createFormattedText(k, s, markdownToLines(l.replace(/<br\s*\/?>/g, "<br/>").replace("<br>", "<br/>"), B), l ? A : false);
    if (T) {
      /stroke:/.exec(u) && (u = u.replace("stroke:", "lineColor:"));
      let o = u.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/color:/g, "fill:");
      select_default(e3).attr("style", o);
    } else {
      let o = u.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/background:/g, "fill:");
      select_default(e3).select("rect").attr("style", o.replace(/background:/g, "fill:"));
      let s2 = u.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/color:/g, "fill:");
      select_default(e3).select("text").attr("style", s2);
    }
    return e3;
  }
}, "createText");
export {
  replaceIconSubstring as a,
  registerIconPacks as i,
  createText as n,
  unknownIcon as o,
  getIconSVG as r,
  dedent as s,
  computeDimensionOfText as t
};
