@vectojs/markdown 0.22.0 → 0.23.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.js CHANGED
@@ -161,9 +161,9 @@ var StreamControllerImpl = class {
161
161
  this.resetPacingIfIdle();
162
162
  }
163
163
  close() {
164
+ if (this.closePromise) return this.closePromise;
164
165
  if (this.currentState === "closed") return Promise.resolve();
165
166
  if (this.currentState === "aborted") return Promise.reject(this.terminalReason);
166
- if (this.closePromise) return this.closePromise;
167
167
  let resolveClose;
168
168
  let rejectClose;
169
169
  const closePromise = new Promise((resolve, reject) => {
@@ -2592,6 +2592,7 @@ function lastIndexOfImage(tokens) {
2592
2592
  return -1;
2593
2593
  }
2594
2594
  var inlineImageRasters = /* @__PURE__ */ new Map();
2595
+ var INLINE_IMAGE_RASTER_LIMIT = 256;
2595
2596
  var inlineImageRasterWaiters = /* @__PURE__ */ new Set();
2596
2597
  function subscribeInlineImageRaster(notify) {
2597
2598
  inlineImageRasterWaiters.add(notify);
@@ -2601,9 +2602,18 @@ function unsubscribeInlineImageRaster(notify) {
2601
2602
  }
2602
2603
  function ensureInlineImageRaster(src) {
2603
2604
  const existing = inlineImageRasters.get(src);
2604
- if (existing) return existing;
2605
+ if (existing) {
2606
+ inlineImageRasters.delete(src);
2607
+ inlineImageRasters.set(src, existing);
2608
+ return existing;
2609
+ }
2605
2610
  const entry = { decoded: false };
2606
2611
  inlineImageRasters.set(src, entry);
2612
+ while (inlineImageRasters.size > INLINE_IMAGE_RASTER_LIMIT) {
2613
+ const oldest = inlineImageRasters.keys().next().value;
2614
+ if (oldest === void 0 || oldest === src) break;
2615
+ inlineImageRasters.delete(oldest);
2616
+ }
2607
2617
  if (typeof globalThis.Image !== "undefined") {
2608
2618
  const bitmap = new globalThis.Image();
2609
2619
  bitmap.onload = () => {
@@ -2650,6 +2660,7 @@ function applyTypography(text) {
2650
2660
  out = out.replace(/\(tm\)/gi, "\u2122");
2651
2661
  out = out.replace(/\(c\)/gi, "\xA9");
2652
2662
  out = out.replace(/\(r\)/gi, "\xAE");
2663
+ out = out.replace(/\+-/g, "\xB1");
2653
2664
  out = out.replace(/---/g, "\u2014");
2654
2665
  out = out.replace(/--/g, "\u2013");
2655
2666
  out = out.replace(/\.{3}/g, "\u2026");
@@ -3334,7 +3345,7 @@ function unquote(value) {
3334
3345
  }
3335
3346
 
3336
3347
  // src/MarkdownWorkerSource.ts
3337
- 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 P=K();function ke(t){P=t}var I={exec:()=>null};function M(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:M(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:M(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:M(t=>new RegExp(`^ {0,${t}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:M(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:M(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:M(t=>new RegExp(`^ {0,${t}}>`))},Xe=/^(?:[ \\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|$)|$)/,D=/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/,Ge=/^ {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(),Ue=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:We,heading:Ge,hr:D,html:Ye,lheading:be,list:Ve,newline:Xe,paragraph:et,table:I,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:Ue,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:I,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)))/,E=/[\\p{P}\\p{S}]/u,O=/[\\s\\p{P}\\p{S}]/u,B=/[^\\s\\p{P}\\p{S}]/u,ot=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,O).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,E).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,E).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,O).replace(/punct/g,E).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,O).replace(/punct/g,E).getRegex(),yt=g("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,O).replace(/punct/g,E).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,O).replace(/punct/g,E).getRegex(),_t=g(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,E).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,O).replace(/punct/g,E).getRegex(),Et=g(/\\\\(punct)/,"gu").replace(/punct/g,E).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:I,anyPunctuation:Et,autolink:zt,blockSkip:ht,br:we,code:lt,del:I,delLDelim:I,delRDelim:I,emStrongLDelim:gt,emStrongRDelimAst:xt,emStrongRDelimUnd:yt,escape:it,link:It,nolink:Se,punctuation:ot,reflink:_e,reflinkSearch:Ct,tag:Lt,text:at,url:I},Pt={...re,emStrongLDelim:kt,emStrongRDelimAst:wt,emStrongRDelimUnd:Tt,link:g(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",Q).getRegex(),reflink:g(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",Q).getRegex()},G={...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={...G,br:g(we).replace("{2,}","*").getRegex(),text:g(G.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},j={normal:ne,gfm:rt,pedantic:st},N={normal:re,gfm:G,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 A(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||P}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=A(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:A(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:A(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=A(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),z=this.rules.other.headingBeginRegex(d),W=this.rules.other.htmlBeginRegex(d),L=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)||z.test(h)||W.test(h)||L.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)||z.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:A(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:A(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:A(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=A(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 U{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||P,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 U(n).lex(e)}static lexInline(e,n){return new U(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||P}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||P,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||P}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}}},C=new Bt;function f(t,e){return C.parse(t,e)}f.options=f.setOptions=function(t){return C.setOptions(t),f.defaults=C.defaults,ke(f.defaults),f};f.getDefaults=K;f.defaults=P;function qt(...t){return C.use(...t),f.defaults=C.defaults,ke(f.defaults),f}f.use=qt;f.walkTokens=function(t,e){return C.walkTokens(t,e)};f.parseInline=C.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 sn=f.options,ln=f.setOptions,an=f.walkTokens,on=f.parseInline;var cn=T.parse,pn=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 Wt(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:Wt(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 Gt=/^ {0,3}\\*\\[([^\\]\\n]+)\\]:[ \\t]*([^\\n]*)(?:\\n|$)/,qe=[{name:"abbrDef",level:"block",tokenizer(t){let e=Gt.exec(t);if(e)return{type:"abbrDef",raw:e[0],term:e[1],definition:e[2]}},renderer(t){return t.raw}}];var Ut=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=Ut[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 $=new Map,rn=256;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"&&$.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=$.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){$.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=$.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(),z;try{z=k()}finally{x&&nn(x)}let W=performance.now()-y,L=z.tokens,w=0;if(d!==null){let _=Math.min(d.length,L.length);for(;w<_&&d[w]===L[w].raw;w++);}else if(m!==null){let _=m,oe=Math.min(_.length,L.length);for(w=Math.min(z.reusedTokens,oe);w<oe&&_[w].raw===L[w].raw;w++);}p!==null&&h!==null&&($.delete(p),$.set(p,{version:h+1,lex:z.cache}),$.size>rn&&$.delete($.keys().next().value)),self.postMessage({id:n,matchLen:w,tail:L.slice(w),lexerMs:W,sourceCharsLexed:z.charsLexed})}catch(x){p!==null&&$.delete(p),self.postMessage({id:n,error:String(x)})}};})();\n';
3348
+ 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 P=K();function ke(t){P=t}var I={exec:()=>null};function M(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:M(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:M(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:M(t=>new RegExp(`^ {0,${t}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:M(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:M(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:M(t=>new RegExp(`^ {0,${t}}>`))},Xe=/^(?:[ \\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|$)|$)/,D=/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/,Ge=/^ {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(),Ue=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:We,heading:Ge,hr:D,html:Ye,lheading:be,list:Ve,newline:Xe,paragraph:et,table:I,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:Ue,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:I,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)))/,z=/[\\p{P}\\p{S}]/u,O=/[\\s\\p{P}\\p{S}]/u,B=/[^\\s\\p{P}\\p{S}]/u,ot=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,O).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,z).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,z).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,O).replace(/punct/g,z).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,O).replace(/punct/g,z).getRegex(),yt=g("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,O).replace(/punct/g,z).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,O).replace(/punct/g,z).getRegex(),_t=g(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,z).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,O).replace(/punct/g,z).getRegex(),Et=g(/\\\\(punct)/,"gu").replace(/punct/g,z).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:I,anyPunctuation:Et,autolink:zt,blockSkip:ht,br:we,code:lt,del:I,delLDelim:I,delRDelim:I,emStrongLDelim:gt,emStrongRDelimAst:xt,emStrongRDelimUnd:yt,escape:it,link:It,nolink:Se,punctuation:ot,reflink:_e,reflinkSearch:Ct,tag:Lt,text:at,url:I},Pt={...re,emStrongLDelim:kt,emStrongRDelimAst:wt,emStrongRDelimUnd:Tt,link:g(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",Q).getRegex(),reflink:g(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",Q).getRegex()},G={...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={...G,br:g(we).replace("{2,}","*").getRegex(),text:g(G.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},j={normal:ne,gfm:rt,pedantic:st},N={normal:re,gfm:G,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 A(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||P}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=A(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:A(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:A(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=A(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),W=this.rules.other.htmlBeginRegex(d),L=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)||W.test(h)||L.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:A(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:A(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:A(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=A(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 U{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||P,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 U(n).lex(e)}static lexInline(e,n){return new U(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||P}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||P,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||P}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}}},C=new Bt;function f(t,e){return C.parse(t,e)}f.options=f.setOptions=function(t){return C.setOptions(t),f.defaults=C.defaults,ke(f.defaults),f};f.getDefaults=K;f.defaults=P;function qt(...t){return C.use(...t),f.defaults=C.defaults,ke(f.defaults),f}f.use=qt;f.walkTokens=function(t,e){return C.walkTokens(t,e)};f.parseInline=C.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 sn=f.options,ln=f.setOptions,an=f.walkTokens,on=f.parseInline;var cn=T.parse,pn=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 Wt(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:Wt(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 Gt=/^ {0,3}\\*\\[([^\\]\\n]+)\\]:[ \\t]*([^\\n]*)(?:\\n|$)/,qe=[{name:"abbrDef",level:"block",tokenizer(t){let e=Gt.exec(t);if(e)return{type:"abbrDef",raw:e[0],term:e[1],definition:e[2]}},renderer(t){return t.raw}}];var Ut=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=Ut[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 $=new Map,rn=256;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"&&$.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=$.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){$.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=$.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 W=performance.now()-y,L=E.tokens,w=0;if(d!==null){let _=Math.min(d.length,L.length);for(;w<_&&d[w]===L[w].raw;w++);}else if(m!==null){let _=m,oe=Math.min(_.length,L.length);for(w=Math.min(E.reusedTokens,oe);w<oe&&_[w].raw===L[w].raw;w++);}p!==null&&h!==null&&($.delete(p),$.set(p,{version:h+1,lex:E.cache}),$.size>rn&&$.delete($.keys().next().value)),self.postMessage({id:n,matchLen:w,tail:L.slice(w),lexerMs:W,sourceCharsLexed:E.charsLexed,stablePrefixChars:E.cache.stableOffset})}catch(x){p!==null&&$.delete(p),self.postMessage({id:n,error:String(x)})}};})();\n';
3338
3349
 
3339
3350
  // src/Markdown.ts
3340
3351
  var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
@@ -3436,7 +3447,16 @@ if (typeof Worker !== "undefined") {
3436
3447
  });
3437
3448
  markdownWorker = new Worker(URL.createObjectURL(blob));
3438
3449
  markdownWorker.onmessage = (e) => {
3439
- const { id, matchLen, tail, error, needResync, lexerMs, sourceCharsLexed } = e.data;
3450
+ const {
3451
+ id,
3452
+ matchLen,
3453
+ tail,
3454
+ error,
3455
+ needResync,
3456
+ lexerMs,
3457
+ sourceCharsLexed,
3458
+ stablePrefixChars
3459
+ } = e.data;
3440
3460
  const entry = workerCallbacks.get(id);
3441
3461
  if (entry) {
3442
3462
  workerCallbacks.delete(id);
@@ -3447,7 +3467,8 @@ if (typeof Worker !== "undefined") {
3447
3467
  } else if (!error) {
3448
3468
  entry.cb(matchLen, tail, false, {
3449
3469
  lexerMs: typeof lexerMs === "number" ? lexerMs : 0,
3450
- sourceCharsLexed: typeof sourceCharsLexed === "number" ? sourceCharsLexed : 0
3470
+ sourceCharsLexed: typeof sourceCharsLexed === "number" ? sourceCharsLexed : 0,
3471
+ stablePrefixChars: typeof stablePrefixChars === "number" ? stablePrefixChars : 0
3451
3472
  });
3452
3473
  } else {
3453
3474
  runSyncFallback(entry);
@@ -3467,7 +3488,47 @@ if (typeof Worker !== "undefined") {
3467
3488
  var Markdown = class _Markdown extends import_ui4.UIComponent {
3468
3489
  content;
3469
3490
  maxWidth;
3470
- theme;
3491
+ /**
3492
+ * Resolved once in the constructor and never re-applied: entities capture
3493
+ * colors, fonts and sizes at build time, so assigning this after construction
3494
+ * would paint blocks built afterwards in the new palette while everything
3495
+ * earlier kept the old one. Exposed read-only to keep that trap unreachable
3496
+ * (#657); the supported post-construction path is {@link setTheme}, which
3497
+ * re-renders instead of leaving blocks half-migrated.
3498
+ *
3499
+ * Backed by {@link currentTheme} rather than a `readonly` field because the
3500
+ * blockquote arm legally swaps the render-time theme for its own subtree and
3501
+ * restores it afterwards — an internal, exception-safe scope, not a re-theme.
3502
+ */
3503
+ get theme() {
3504
+ return this.currentTheme;
3505
+ }
3506
+ currentTheme;
3507
+ /**
3508
+ * Swap the document theme and rebuild every rendered block.
3509
+ *
3510
+ * Accepts the same shapes as {@link MarkdownOptions.theme}: a preset name or
3511
+ * a full/partial {@link MarkdownTheme}, resolved through
3512
+ * {@link resolvePresetTheme}. This is the only supported way to change theme
3513
+ * after construction — {@link theme} is a read-only view (#657) precisely so
3514
+ * tokens cannot be swapped underneath already-built blocks without the
3515
+ * rebuild performed here.
3516
+ *
3517
+ * The rebuild goes through {@link setContent} rather than an in-place
3518
+ * repaint: entities capture colors and fonts at build time, so nothing short
3519
+ * of re-rendering applies a palette, and an active stream needs the same
3520
+ * teardown an explicit content replacement gets.
3521
+ *
3522
+ * @returns `this` for chaining.
3523
+ */
3524
+ setTheme(theme) {
3525
+ this.assertNotInStableCallback("setTheme");
3526
+ const next = resolvePresetTheme(theme);
3527
+ if (next.blockGap !== this.currentTheme.blockGap) this.content.gap = next.blockGap;
3528
+ this.currentTheme = next;
3529
+ this.setContent(this.rawMarkdown);
3530
+ return this;
3531
+ }
3471
3532
  onLinkClick;
3472
3533
  selectable;
3473
3534
  /**
@@ -3723,8 +3784,10 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3723
3784
  /** Longest single worker round trip, which is what a dropped frame feels. */
3724
3785
  workerMsMax: 0,
3725
3786
  /**
3726
- * Source length of the stable prefix on the most recent append: the text the
3727
- * worker matched and did not re-read.
3787
+ * Source length of the stable prefix on the most recent append: the text
3788
+ * whose tokens the lex did not re-read. Reported by the worker's lex from
3789
+ * its own `IncrementalLexCache.stableOffset` rather than re-summed per
3790
+ * response, which made a stream of n chunks O(n²) in this one stat (#657).
3728
3791
  */
3729
3792
  stablePrefixChars: 0,
3730
3793
  /** Source length of the tail whose tokens changed on the most recent append. */
@@ -3797,7 +3860,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3797
3860
  constructor(markdownText, opts = {}) {
3798
3861
  super();
3799
3862
  this.maxWidth = opts.maxWidth ?? 800;
3800
- this.theme = resolvePresetTheme(opts.theme);
3863
+ this.currentTheme = resolvePresetTheme(opts.theme);
3801
3864
  this.onLinkClick = opts.onLinkClick;
3802
3865
  this.selectable = opts.selectable ?? true;
3803
3866
  this._userTiming = opts.userTiming ?? false;
@@ -4192,7 +4255,11 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4192
4255
  }
4193
4256
  case "blockMath":
4194
4257
  case "code": {
4195
- if (entity instanceof CodeBlock) entity.setWidth(availableWidth);
4258
+ const target = entity instanceof BlockWithAffordances ? entity.block : entity;
4259
+ if (target instanceof CodeBlock) {
4260
+ target.setWidth(availableWidth);
4261
+ if (entity instanceof BlockWithAffordances) entity.refreshAffordances();
4262
+ }
4196
4263
  return;
4197
4264
  }
4198
4265
  case "blockquote": {
@@ -4264,7 +4331,11 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4264
4331
  return;
4265
4332
  }
4266
4333
  case "table": {
4267
- if (entity instanceof import_ui4.Table) entity.setWidth(availableWidth);
4334
+ const target = entity instanceof BlockWithAffordances ? entity.block : entity;
4335
+ if (target instanceof import_ui4.Table) {
4336
+ target.setWidth(availableWidth);
4337
+ if (entity instanceof BlockWithAffordances) entity.refreshAffordances();
4338
+ }
4268
4339
  return;
4269
4340
  }
4270
4341
  case "hr": {
@@ -4343,12 +4414,6 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4343
4414
  this.renderMarkdown(body);
4344
4415
  return this;
4345
4416
  }
4346
- /**
4347
- * Tear down this Markdown block: drop any in-flight worker callbacks (each
4348
- * pins `this` via its closure, so a mid-stream destroy would otherwise keep
4349
- * the whole subtree alive until the worker replied), then recurse into the
4350
- * content subtree via `super.destroy()` so every block's resources are freed.
4351
- */
4352
4417
  /**
4353
4418
  * Repaint this document when an inline formula's raster finishes decoding.
4354
4419
  *
@@ -4470,6 +4535,12 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4470
4535
  };
4471
4536
  return checkBlocks(this.tokens);
4472
4537
  }
4538
+ /**
4539
+ * Tear down this Markdown block: drop any in-flight worker callbacks (each
4540
+ * pins `this` via its closure, so a mid-stream destroy would otherwise keep
4541
+ * the whole subtree alive until the worker replied), then recurse into the
4542
+ * content subtree via `super.destroy()` so every block's resources are freed.
4543
+ */
4473
4544
  destroy() {
4474
4545
  this.isDestroyed = true;
4475
4546
  this.optimisticTail = null;
@@ -4751,7 +4822,11 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4751
4822
  if (elapsed > this.streamStats.workerMsMax) this.streamStats.workerMsMax = elapsed;
4752
4823
  this.workerSourceLen = local ? 0 : sentLength;
4753
4824
  let prefixChars = 0;
4754
- for (let i = 0; i < matchLen; i++) prefixChars += oldTokensSnapshot[i]?.raw.length ?? 0;
4825
+ if (lex) {
4826
+ prefixChars = lex.stablePrefixChars;
4827
+ } else {
4828
+ for (let i = 0; i < matchLen; i++) prefixChars += oldTokensSnapshot[i]?.raw.length ?? 0;
4829
+ }
4755
4830
  this.streamStats.stablePrefixChars = prefixChars;
4756
4831
  this.streamStats.changedTailChars = this.rawMarkdown.length - prefixChars;
4757
4832
  this.appendInFlight = false;
@@ -4821,30 +4896,6 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4821
4896
  if (spans.length === 0) spans.push({ text: token.text });
4822
4897
  return spans;
4823
4898
  }
4824
- /**
4825
- * Update a reused blockquote's tail child in place, or report that it cannot be.
4826
- *
4827
- * The render arm builds `container[border, innerStack]` where every inner block
4828
- * sits in its own single-child `wrapper`, so the tail entity is
4829
- * `innerStack.children.at(-1).children[0]`. Only the LAST inner block may be
4830
- * updated: the inner token list is prefix-stable exactly like the top level (a
4831
- * growing quote keeps its earlier blocks byte-identical), so anything before the
4832
- * tail is untouched and anything more complicated than a changed tail falls back
4833
- * to the caller's rebuild.
4834
- *
4835
- * Returns `false` without mutating anything when the shape is not the simple
4836
- * grow-the-tail case, which is the signal for the caller to rebuild. Every early
4837
- * return has to leave the entity untouched, or a rejected reuse would leave a
4838
- * half-updated quote on screen.
4839
- */
4840
- /**
4841
- * Build one list item's spans: inline content plus its marker.
4842
- *
4843
- * Shared by the `list` render arm and the streamed-reuse path below, because
4844
- * the two must produce byte-identical spans — a reused list that disagreed with
4845
- * a rebuilt one about its marker or its entity decoding would make a streamed
4846
- * document differ from the same source pasted at once.
4847
- */
4848
4899
  /**
4849
4900
  * Inline spans for one table cell.
4850
4901
  *
@@ -4894,31 +4945,6 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4894
4945
  onLinkClick: this.onLinkClick
4895
4946
  });
4896
4947
  }
4897
- /**
4898
- * One image inside a paragraph, sized by a guess until its bitmap decodes.
4899
- *
4900
- * Width and height start at a 16:10 guess because the intrinsic size is not
4901
- * known until the browser has the bitmap; `onLoad` corrects both from
4902
- * `naturalWidth`/`naturalHeight`. Extracted from the render arm so the streamed
4903
- * path reuses this exact entity rather than constructing a second variant.
4904
- *
4905
- * `markDirty()` is unconditional, matching the display-math sibling. It used
4906
- * to sit inside the `naturalWidth && naturalHeight` check, which meant a
4907
- * source that loads successfully while reporting a zero dimension left the
4908
- * scene un-notified. `Image` sets `loaded` before invoking this callback, so
4909
- * its `render()` starts drawing the bitmap either way — the cost was not a
4910
- * stale placeholder but a box frozen at the guess: measured on Chromium and
4911
- * Firefox, an `<svg width="0" height="0">` paragraph image kept 800x480 of
4912
- * reserved layout forever while a normal raster corrected to 80x60. An
4913
- * `onDemand` scene repaints only when marked, so nothing reclaimed it.
4914
- *
4915
- * The box is deliberately left at the guess when the bitmap reports zero.
4916
- * Collapsing it to 0x0 would make the paragraph reflow correctly but would
4917
- * also silently delete a reserved region on the strength of one browser
4918
- * quirk, and `Image.render()` still blits whatever the bitmap holds. Sizing
4919
- * policy for a zero-dimension source is a separate decision from notifying
4920
- * the scene, which is the actual defect here.
4921
- */
4922
4948
  /**
4923
4949
  * Wraps a block in its copy / download controls, or returns it untouched.
4924
4950
  *
@@ -5006,6 +5032,31 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5006
5032
  focusColor: this.theme.codeColor
5007
5033
  };
5008
5034
  }
5035
+ /**
5036
+ * One image inside a paragraph, sized by a guess until its bitmap decodes.
5037
+ *
5038
+ * Width and height start at a 16:10 guess because the intrinsic size is not
5039
+ * known until the browser has the bitmap; `onLoad` corrects both from
5040
+ * `naturalWidth`/`naturalHeight`. Extracted from the render arm so the streamed
5041
+ * path reuses this exact entity rather than constructing a second variant.
5042
+ *
5043
+ * `markDirty()` is unconditional, matching the display-math sibling. It used
5044
+ * to sit inside the `naturalWidth && naturalHeight` check, which meant a
5045
+ * source that loads successfully while reporting a zero dimension left the
5046
+ * scene un-notified. `Image` sets `loaded` before invoking this callback, so
5047
+ * its `render()` starts drawing the bitmap either way — the cost was not a
5048
+ * stale placeholder but a box frozen at the guess: measured on Chromium and
5049
+ * Firefox, an `<svg width="0" height="0">` paragraph image kept 800x480 of
5050
+ * reserved layout forever while a normal raster corrected to 80x60. An
5051
+ * `onDemand` scene repaints only when marked, so nothing reclaimed it.
5052
+ *
5053
+ * The box is deliberately left at the guess when the bitmap reports zero.
5054
+ * Collapsing it to 0x0 would make the paragraph reflow correctly but would
5055
+ * also silently delete a reserved region on the strength of one browser
5056
+ * quirk, and `Image.render()` still blits whatever the bitmap holds. Sizing
5057
+ * policy for a zero-dimension source is a separate decision from notifying
5058
+ * the scene, which is the actual defect here.
5059
+ */
5009
5060
  paragraphImage(imgToken, availableWidth) {
5010
5061
  const initialWidth = Math.min(800, availableWidth);
5011
5062
  const initialHeight = Math.round(initialWidth * 0.6);
@@ -5253,6 +5304,14 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5253
5304
  }
5254
5305
  return stack;
5255
5306
  }
5307
+ /**
5308
+ * Build one list item's spans: inline content plus its marker.
5309
+ *
5310
+ * Shared by the `list` render arm and the streamed-reuse path below, because
5311
+ * the two must produce byte-identical spans — a reused list that disagreed with
5312
+ * a rebuilt one about its marker or its entity decoding would make a streamed
5313
+ * document differ from the same source pasted at once.
5314
+ */
5256
5315
  listItemSpans(token, index) {
5257
5316
  const item = token.items[index];
5258
5317
  const num = Number(token.start ?? 1) + index;
@@ -5452,7 +5511,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5452
5511
  * (its keys are `text`/`tokens`/`header`/`align`).
5453
5512
  */
5454
5513
  updateStreamedTable(entity, oldToken, newToken) {
5455
- if (!(entity instanceof import_ui4.Table)) return false;
5514
+ const target = entity instanceof BlockWithAffordances ? entity.block : entity;
5515
+ if (!(target instanceof import_ui4.Table)) return false;
5456
5516
  if (oldToken.header.length !== newToken.header.length) return false;
5457
5517
  for (let c = 0; c < oldToken.header.length; c++) {
5458
5518
  if (oldToken.header[c].text !== newToken.header[c].text) return false;
@@ -5461,7 +5521,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5461
5521
  if (oldToken.align?.[c] !== newToken.align?.[c]) return false;
5462
5522
  }
5463
5523
  if (newToken.rows.length < oldToken.rows.length) return false;
5464
- if (entity.rows.length !== oldToken.rows.length) return false;
5524
+ if (target.rows.length !== oldToken.rows.length) return false;
5465
5525
  const lastRetained = oldToken.rows.length - 1;
5466
5526
  for (let r = 0; r < lastRetained; r++) {
5467
5527
  const oldRow = oldToken.rows[r];
@@ -5472,7 +5532,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5472
5532
  }
5473
5533
  if (lastRetained >= 0) {
5474
5534
  for (let c = 0; c < oldToken.header.length; c++) {
5475
- const cell = entity.rows[lastRetained]?.[c];
5535
+ const cell = target.rows[lastRetained]?.[c];
5476
5536
  if (!(cell instanceof import_ui4.RichText)) return false;
5477
5537
  }
5478
5538
  }
@@ -5483,19 +5543,35 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5483
5543
  const newRow = newToken.rows[lastRetained];
5484
5544
  for (let c = 0; c < oldToken.header.length; c++) {
5485
5545
  if (oldRow[c]?.text === newRow[c]?.text) continue;
5486
- const cell = entity.rows[lastRetained][c];
5546
+ const cell = target.rows[lastRetained][c];
5487
5547
  cell.setSpans(this.tableCellSpans(newRow[c], t));
5488
5548
  changed = true;
5489
5549
  }
5490
5550
  }
5491
5551
  if (newToken.rows.length > oldToken.rows.length) {
5492
5552
  const added = newToken.rows.slice(oldToken.rows.length).map((row) => row.map((cell) => this.tableCellRichText(cell, false, t)));
5493
- entity.appendRows(added);
5553
+ target.appendRows(added);
5494
5554
  } else if (changed) {
5495
- entity.layout();
5555
+ target.layout();
5496
5556
  }
5497
5557
  return true;
5498
5558
  }
5559
+ /**
5560
+ * Update a reused blockquote's tail child in place, or report that it cannot be.
5561
+ *
5562
+ * The render arm builds `container[border, innerStack]` where every inner block
5563
+ * sits in its own single-child `wrapper`, so the tail entity is
5564
+ * `innerStack.children.at(-1).children[0]`. Only the LAST inner block may be
5565
+ * updated: the inner token list is prefix-stable exactly like the top level (a
5566
+ * growing quote keeps its earlier blocks byte-identical), so anything before the
5567
+ * tail is untouched and anything more complicated than a changed tail falls back
5568
+ * to the caller's rebuild.
5569
+ *
5570
+ * Returns `false` without mutating anything when the shape is not the simple
5571
+ * grow-the-tail case, which is the signal for the caller to rebuild. Every early
5572
+ * return has to leave the entity untouched, or a rejected reuse would leave a
5573
+ * half-updated quote on screen.
5574
+ */
5499
5575
  updateBlockquoteTail(container, oldInner, newInner) {
5500
5576
  if (oldInner.length !== newInner.length || newInner.length === 0) return false;
5501
5577
  const tail = newInner.length - 1;
@@ -5522,9 +5598,14 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5522
5598
  entity.setSpans(
5523
5599
  this.headingSpans(newTail)
5524
5600
  );
5525
- } else if (newTail.type === "code" && entity instanceof CodeBlock && !rendersAsMath(newTail)) {
5601
+ } else if (newTail.type === "code") {
5602
+ const target = entity instanceof BlockWithAffordances ? entity.block : entity;
5603
+ if (!(target instanceof CodeBlock) || rendersAsMath(newTail)) {
5604
+ return false;
5605
+ }
5526
5606
  const codeToken = newTail;
5527
- entity.setCode(codeToken.text, codeToken.lang ?? void 0);
5607
+ target.setCode(codeToken.text, codeToken.lang ?? void 0);
5608
+ if (entity instanceof BlockWithAffordances) entity.refreshAffordances();
5528
5609
  } else {
5529
5610
  return false;
5530
5611
  }
@@ -5626,13 +5707,6 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5626
5707
  return void 0;
5627
5708
  }
5628
5709
  }
5629
- /**
5630
- * Re-render the paragraph currently showing a guess from its own tokens, with
5631
- * no overlay, and forget it.
5632
- *
5633
- * Idempotent and free when no guess is live, which is what lets `close()`,
5634
- * `abort()`, and a mid-stream staleness check all call it unconditionally.
5635
- */
5636
5710
  /**
5637
5711
  * Start the MathJax load, and re-typeset this document once it resolves.
5638
5712
  *
@@ -5692,6 +5766,13 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5692
5766
  this.height = this.content.height;
5693
5767
  this.scene?.markDirty();
5694
5768
  }
5769
+ /**
5770
+ * Re-render the paragraph currently showing a guess from its own tokens, with
5771
+ * no overlay, and forget it.
5772
+ *
5773
+ * Idempotent and free when no guess is live, which is what lets `close()`,
5774
+ * `abort()`, and a mid-stream staleness check all call it unconditionally.
5775
+ */
5695
5776
  unwindOptimisticTail() {
5696
5777
  const tail = this.optimisticTail;
5697
5778
  this.optimisticTail = null;
@@ -5807,11 +5888,15 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5807
5888
  if (isMath && rendersAsMath(oldCodeToken) && oldCodeToken.text === codeToken.text) {
5808
5889
  this.streamStats.inPlaceUpdates++;
5809
5890
  matchLen++;
5810
- } else if (existingEntity instanceof CodeBlock && !isMath) {
5811
- existingEntity.setCode(codeToken.text, codeToken.lang ?? void 0);
5812
- this.streamStats.inPlaceUpdates++;
5813
- matchLen++;
5814
- this.content.resizeLastChild(existingEntity);
5891
+ } else {
5892
+ const target = existingEntity instanceof BlockWithAffordances ? existingEntity.block : existingEntity;
5893
+ if (target instanceof CodeBlock && !isMath) {
5894
+ target.setCode(codeToken.text, codeToken.lang ?? void 0);
5895
+ if (existingEntity instanceof BlockWithAffordances) existingEntity.refreshAffordances();
5896
+ this.streamStats.inPlaceUpdates++;
5897
+ matchLen++;
5898
+ this.content.resizeLastChild(existingEntity);
5899
+ }
5815
5900
  }
5816
5901
  } else if (lastTokenSameType && newTokens[matchLen]?.type === "paragraph") {
5817
5902
  const entityIdx = oldTokenToChild[matchLen];
@@ -5875,6 +5960,9 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
5875
5960
  )) {
5876
5961
  this.streamStats.inPlaceUpdates++;
5877
5962
  matchLen++;
5963
+ if (existingEntity instanceof BlockWithAffordances) {
5964
+ existingEntity.refreshAffordances();
5965
+ }
5878
5966
  this.content.resizeLastChild(existingEntity);
5879
5967
  }
5880
5968
  }
@@ -6159,7 +6247,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
6159
6247
  };
6160
6248
  const outerTheme = this.theme;
6161
6249
  if (t.quoteTextColor !== t.textColor) {
6162
- this.theme = { ...outerTheme, textColor: t.quoteTextColor };
6250
+ this.currentTheme = { ...outerTheme, textColor: t.quoteTextColor };
6163
6251
  }
6164
6252
  try {
6165
6253
  if (bqToken.tokens) {
@@ -6176,7 +6264,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
6176
6264
  }
6177
6265
  }
6178
6266
  } finally {
6179
- this.theme = outerTheme;
6267
+ this.currentTheme = outerTheme;
6180
6268
  }
6181
6269
  const border = new QuoteBorder(
6182
6270
  innerStack.height || 20,