UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

71 lines (70 loc) 49.5 kB
import{c as ue,d as de}from"./chunk-TDFULVG6.mjs";import{r as Z}from"./chunk-QADHU5CF.mjs";import{B as G,E as O,G as pe,H as he,u as ce}from"./chunk-FE53TMRB.mjs";import{b as _,h as R}from"./chunk-L2B47AAZ.mjs";import{a as h}from"./chunk-QVIEFLGF.mjs";function ge(n){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];var s=Array.from(typeof n=="string"?[n]:n);s[s.length-1]=s[s.length-1].replace(/\r?\n([\t ]*)$/,"");var t=s.reduce(function(l,o){var c=o.match(/\n([\t ]+|(?!\s).)/g);return c?l.concat(c.map(function(p){var u,d;return(d=(u=p.match(/[\t ]/g))===null||u===void 0?void 0:u.length)!==null&&d!==void 0?d:0})):l},[]);if(t.length){var a=new RegExp(` [ ]{`+Math.min.apply(Math,t)+"}","g");s=s.map(function(l){return l.replace(a,` `)})}s[0]=s[0].replace(/^\r?\n/,"");var i=s[0];return e.forEach(function(l,o){var c=i.match(/(?:^|\n)( *)$/),p=c?c[1]:"",u=l;typeof l=="string"&&l.includes(` `)&&(u=String(l).split(` `).map(function(d,m){return m===0?d:""+p+d}).join(` `)),i+=u+s[o+1]}),i}h(ge,"dedent");var qt=typeof performance<"u"&&typeof performance.now=="function";globalThis.injected??={includeLargeFeatures:!0,profiling:!1,version:"0.0.0"};function V(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}h(V,"L");var $=V();function we(n){$=n}h(we,"G");var P={exec:h(()=>null,"exec")};function k(n,e=""){let r=typeof n=="string"?n:n.source,s={replace:h((t,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(b.caret,"$1"),r=r.replace(t,i),s},"replace"),getRegex:h(()=>new RegExp(r,e),"getRegex")};return s}h(k,"h");var 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,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:h(n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),"listItemRegex"),nextBulletRegex:h(n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),"nextBulletRegex"),hrRegex:h(n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),"hrRegex"),fencesBeginRegex:h(n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),"fencesBeginRegex"),headingBeginRegex:h(n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),"headingBeginRegex"),htmlBeginRegex:h(n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),"htmlBeginRegex")},Ne=/^(?:[ \t]*(?:\n|$))+/,Qe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ve=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,E=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ue=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,U=/(?:[*+-]|\d{1,9}[.)])/,ye=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Se=k(ye).replace(/bull/g,U).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Xe=k(ye).replace(/bull/g,U).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),X=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ke=/^[^\n]+/,K=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ye=k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",K).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Je=k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,U).getRegex(),q="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Y=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,et=k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Y).replace("tag",q).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Te=k(X).replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q).getRegex(),tt=k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Te).getRegex(),J={blockquote:tt,code:Qe,def:Ye,fences:Ve,heading:Ue,hr:E,html:et,lheading:Se,list:Je,newline:Ne,paragraph:Te,table:P,text:Ke},fe=k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q).getRegex(),nt={...J,lheading:Xe,table:fe,paragraph:k(X).replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",fe).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q).getRegex()},rt={...J,html:k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Y).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:P,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(X).replace("hr",E).replace("heading",` *#{1,6} *[^ ]`).replace("lheading",Se).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},st=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,it=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$e=/^( {2,}|\\)\n(?!\s*$)/,lt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,W=/[\p{P}\p{S}]/u,ee=/[\s\p{P}\p{S}]/u,Re=/[^\s\p{P}\p{S}]/u,at=k(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ee).getRegex(),ve=/(?!~)[\p{P}\p{S}]/u,ot=/(?!~)[\s\p{P}\p{S}]/u,ct=/(?:[^\s\p{P}\p{S}]|~)/u,pt=/\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,ze=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ht=k(ze,"u").replace(/punct/g,W).getRegex(),ut=k(ze,"u").replace(/punct/g,ve).getRegex(),Le="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",dt=k(Le,"gu").replace(/notPunctSpace/g,Re).replace(/punctSpace/g,ee).replace(/punct/g,W).getRegex(),gt=k(Le,"gu").replace(/notPunctSpace/g,ct).replace(/punctSpace/g,ot).replace(/punct/g,ve).getRegex(),ft=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Re).replace(/punctSpace/g,ee).replace(/punct/g,W).getRegex(),kt=k(/\\(punct)/,"gu").replace(/punct/g,W).getRegex(),mt=k(/^<(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(),xt=k(Y).replace("(?:-->|$)","-->").getRegex(),bt=k("^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",xt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),C=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/,wt=k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",C).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Me=k(/^!?\[(label)\]\[(ref)\]/).replace("label",C).replace("ref",K).getRegex(),Ae=k(/^!?\[(ref)\](?:\[\])?/).replace("ref",K).getRegex(),yt=k("reflink|nolink(?!\\()","g").replace("reflink",Me).replace("nolink",Ae).getRegex(),te={_backpedal:P,anyPunctuation:kt,autolink:mt,blockSkip:pt,br:$e,code:it,del:P,emStrongLDelim:ht,emStrongRDelimAst:dt,emStrongRDelimUnd:ft,escape:st,link:wt,nolink:Ae,punctuation:at,reflink:Me,reflinkSearch:yt,tag:bt,text:lt,url:P},St={...te,link:k(/^!?\[(label)\]\((.*?)\)/).replace("label",C).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",C).getRegex()},H={...te,emStrongRDelimAst:gt,emStrongLDelim:ut,url:k(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Tt={...H,br:k($e).replace("{2,}","*").getRegex(),text:k(H.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},I={normal:J,gfm:nt,pedantic:rt},L={normal:te,gfm:H,breaks:Tt,pedantic:St},$t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ke=h(n=>$t[n],"ke");function w(n,e){if(e){if(b.escapeTest.test(n))return n.replace(b.escapeReplace,ke)}else if(b.escapeTestNoEncode.test(n))return n.replace(b.escapeReplaceNoEncode,ke);return n}h(w,"w");function me(n){try{n=encodeURI(n).replace(b.percentDecode,"%")}catch{return null}return n}h(me,"J");function xe(n,e){let r=n.replace(b.findPipe,(a,i,l)=>{let o=!1,c=i;for(;--c>=0&&l[c]==="\\";)o=!o;return o?"|":" |"}),s=r.split(b.splitPipe),t=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(;t<s.length;t++)s[t]=s[t].trim().replace(b.slashPipe,"|");return s}h(xe,"V");function M(n,e,r){let s=n.length;if(s===0)return"";let t=0;for(;t<s;){let a=n.charAt(s-t-1);if(a===e&&!r)t++;else if(a!==e&&r)t++;else break}return n.slice(0,s-t)}h(M,"z");function Rt(n,e){if(n.indexOf(e[1])===-1)return-1;let r=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])r++;else if(n[s]===e[1]&&(r--,r<0))return s;return r>0?-2:-1}h(Rt,"ge");function be(n,e,r,s,t){let a=e.href,i=e.title||null,l=n[1].replace(t.other.outputLinkReplace,"$1");s.state.inLink=!0;let o={type:n[0].charAt(0)==="!"?"image":"link",raw:r,href:a,title:i,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,o}h(be,"fe");function vt(n,e,r){let s=n.match(r.other.indentCodeCompensation);if(s===null)return e;let t=s[1];return e.split(` `).map(a=>{let i=a.match(r.other.beginningSpace);if(i===null)return a;let[l]=i;return l.length>=t.length?a.slice(t.length):a}).join(` `)}h(vt,"Je");var B=class{static{h(this,"y")}options;rules;lexer;constructor(n){this.options=n||$}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let r=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?r:M(r,` `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let r=e[0],s=vt(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let s=M(r,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(r=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:M(e[0],` `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let r=M(e[0],` `).split(` `),s="",t="",a=[];for(;r.length>0;){let i=!1,l=[],o;for(o=0;o<r.length;o++)if(this.rules.other.blockquoteStart.test(r[o]))l.push(r[o]),i=!0;else if(!i)l.push(r[o]);else break;r=r.slice(o);let c=l.join(` `),p=c.replace(this.rules.other.blockquoteSetextReplace,` $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s} ${c}`:c,t=t?`${t} ${p}`:p;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,a,!0),this.lexer.state.top=u,r.length===0)break;let d=a.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let m=d,g=m.raw+` `+r.join(` `),x=this.blockquote(g);a[a.length-1]=x,s=s.substring(0,s.length-m.raw.length)+x.raw,t=t.substring(0,t.length-m.text.length)+x.text;break}else if(d?.type==="list"){let m=d,g=m.raw+` `+r.join(` `),x=this.list(g);a[a.length-1]=x,s=s.substring(0,s.length-d.raw.length)+x.raw,t=t.substring(0,t.length-m.raw.length)+x.raw,r=g.substring(a.at(-1).raw.length).split(` `);continue}}return{type:"blockquote",raw:s,tokens:a,text:t}}}list(n){let e=this.rules.block.list.exec(n);if(e){let r=e[1].trim(),s=r.length>1,t={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");let a=this.rules.other.listItemRegex(r),i=!1;for(;n;){let o=!1,c="",p="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;c=e[0],n=n.substring(c.length);let u=e[2].split(` `,1)[0].replace(this.rules.other.listReplaceTabs,D=>" ".repeat(3*D.length)),d=n.split(` `,1)[0],m=!u.trim(),g=0;if(this.options.pedantic?(g=2,p=u.trimStart()):m?g=e[1].length+1:(g=e[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,p=u.slice(g),g+=e[1].length),m&&this.rules.other.blankLine.test(d)&&(c+=d+` `,n=n.substring(d.length+1),o=!0),!o){let D=this.rules.other.nextBulletRegex(g),le=this.rules.other.hrRegex(g),ae=this.rules.other.fencesBeginRegex(g),oe=this.rules.other.headingBeginRegex(g),He=this.rules.other.htmlBeginRegex(g);for(;n;){let F=n.split(` `,1)[0],z;if(d=F,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),z=d):z=d.replace(this.rules.other.tabCharGlobal," "),ae.test(d)||oe.test(d)||He.test(d)||D.test(d)||le.test(d))break;if(z.search(this.rules.other.nonSpaceChar)>=g||!d.trim())p+=` `+z.slice(g);else{if(m||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ae.test(u)||oe.test(u)||le.test(u))break;p+=` `+d}!m&&!d.trim()&&(m=!0),c+=F+` `,n=n.substring(F.length+1),u=z.slice(g)}}t.loose||(i?t.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(i=!0));let x=null,v;this.options.gfm&&(x=this.rules.other.listIsTask.exec(p),x&&(v=x[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),t.items.push({type:"list_item",raw:c,task:!!x,checked:v,loose:!1,text:p,tokens:[]}),t.raw+=c}let l=t.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;t.raw=t.raw.trimEnd();for(let o=0;o<t.items.length;o++)if(this.lexer.state.top=!1,t.items[o].tokens=this.lexer.blockTokens(t.items[o].text,[]),!t.loose){let c=t.items[o].tokens.filter(u=>u.type==="space"),p=c.length>0&&c.some(u=>this.rules.other.anyLine.test(u.raw));t.loose=p}if(t.loose)for(let o=0;o<t.items.length;o++)t.items[o].loose=!0;return t}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let r=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"):"",t=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:e[0],href:s,title:t}}}table(n){let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=xe(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),t=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(` `):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(let i of s)this.rules.other.tableAlignRight.test(i)?a.align.push("right"):this.rules.other.tableAlignCenter.test(i)?a.align.push("center"):this.rules.other.tableAlignLeft.test(i)?a.align.push("left"):a.align.push(null);for(let i=0;i<r.length;i++)a.header.push({text:r[i],tokens:this.lexer.inline(r[i]),header:!0,align:a.align[i]});for(let i of t)a.rows.push(xe(i,a.header.length).map((l,o)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:a.align[o]})));return a}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let r=e[1].charAt(e[1].length-1)===` `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);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(n){let e=this.rules.inline.link.exec(n);if(e){let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let a=M(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{let a=Rt(e[2],"()");if(a===-2)return;if(a>-1){let i=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,i).trim(),e[3]=""}}let s=e[2],t="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],t=a[3])}else t=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(r)?s=s.slice(1):s=s.slice(1,-1)),be(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:t&&t.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){let s=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),t=e[s.toLowerCase()];if(!t){let a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return be(r,t,r[0],this.lexer,this.rules)}}emStrong(n,e,r=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!(!s||s[3]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!r||this.rules.inline.punctuation.exec(r))){let t=[...s[0]].length-1,a,i,l=t,o=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*n.length+t);(s=c.exec(e))!=null;){if(a=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!a)continue;if(i=[...a].length,s[3]||s[4]){l+=i;continue}else if((s[5]||s[6])&&t%3&&!((t+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);let p=[...s[0]][0].length,u=n.slice(0,t+s.index+p+i);if(Math.min(t,i)%2){let m=u.slice(1,-1);return{type:"em",raw:u,text:m,tokens:this.lexer.inlineTokens(m)}}let d=u.slice(2,-2);return{type:"strong",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(r),t=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return s&&t&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){let e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let r,s;return e[2]==="@"?(r=e[1],s="mailto:"+r):(r=e[1],s=r),{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let r,s;if(e[2]==="@")r=e[0],s="mailto:"+r;else{let t;do t=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(t!==e[0]);r=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},y=class N{static{h(this,"l")}tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||$,this.options.tokenizer=this.options.tokenizer||new B,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 r={other:b,block:I.normal,inline:L.normal};this.options.pedantic?(r.block=I.pedantic,r.inline=L.pedantic):this.options.gfm&&(r.block=I.gfm,this.options.breaks?r.inline=L.breaks:r.inline=L.gfm),this.tokenizer.rules=r}static get rules(){return{block:I,inline:L}}static lex(e,r){return new N(r).lex(e)}static lexInline(e,r){return new N(r).inlineTokens(e)}lex(e){e=e.replace(b.carriageReturn,` `),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let s=this.inlineQueue[r];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],s=!1){for(this.options.pedantic&&(e=e.replace(b.tabCharGlobal," ").replace(b.spaceLine,""));e;){let t;if(this.options.extensions?.block?.some(i=>(t=i.call({lexer:this},e,r))?(e=e.substring(t.raw.length),r.push(t),!0):!1))continue;if(t=this.tokenizer.space(e)){e=e.substring(t.raw.length);let i=r.at(-1);t.raw.length===1&&i!==void 0?i.raw+=` `:r.push(t);continue}if(t=this.tokenizer.code(e)){e=e.substring(t.raw.length);let i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(` `)?"":` `)+t.raw,i.text+=` `+t.text,this.inlineQueue.at(-1).src=i.text):r.push(t);continue}if(t=this.tokenizer.fences(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.heading(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.hr(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.blockquote(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.list(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.html(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.def(e)){e=e.substring(t.raw.length);let i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(` `)?"":` `)+t.raw,i.text+=` `+t.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[t.tag]||(this.tokens.links[t.tag]={href:t.href,title:t.title},r.push(t));continue}if(t=this.tokenizer.table(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.lheading(e)){e=e.substring(t.raw.length),r.push(t);continue}let a=e;if(this.options.extensions?.startBlock){let i=1/0,l=e.slice(1),o;this.options.extensions.startBlock.forEach(c=>{o=c.call({lexer:this},l),typeof o=="number"&&o>=0&&(i=Math.min(i,o))}),i<1/0&&i>=0&&(a=e.substring(0,i+1))}if(this.state.top&&(t=this.tokenizer.paragraph(a))){let i=r.at(-1);s&&i?.type==="paragraph"?(i.raw+=(i.raw.endsWith(` `)?"":` `)+t.raw,i.text+=` `+t.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(t),s=a.length!==e.length,e=e.substring(t.raw.length);continue}if(t=this.tokenizer.text(e)){e=e.substring(t.raw.length);let i=r.at(-1);i?.type==="text"?(i.raw+=(i.raw.endsWith(` `)?"":` `)+t.raw,i.text+=` `+t.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(t);continue}if(e){let i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){let s=e,t=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(t=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)l.includes(t[0].slice(t[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,t.index)+"["+"a".repeat(t[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(t=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,t.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(t=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,t.index)+"["+"a".repeat(t[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let a=!1,i="";for(;e;){a||(i=""),a=!1;let l;if(this.options.extensions?.inline?.some(c=>(l=c.call({lexer:this},e,r))?(e=e.substring(l.raw.length),r.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let c=r.at(-1);l.type==="text"&&c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):r.push(l);continue}if(l=this.tokenizer.emStrong(e,s,i)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.del(e)){e=e.substring(l.raw.length),r.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),r.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),r.push(l);continue}let o=e;if(this.options.extensions?.startInline){let c=1/0,p=e.slice(1),u;this.options.extensions.startInline.forEach(d=>{u=d.call({lexer:this},p),typeof u=="number"&&u>=0&&(c=Math.min(c,u))}),c<1/0&&c>=0&&(o=e.substring(0,c+1))}if(l=this.tokenizer.inlineText(o)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(i=l.raw.slice(-1)),a=!0;let c=r.at(-1);c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):r.push(l);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return r}},j=class{static{h(this,"P")}options;parser;constructor(n){this.options=n||$}space(n){return""}code({text:n,lang:e,escaped:r}){let s=(e||"").match(b.notSpaceStart)?.[0],t=n.replace(b.endingNewline,"")+` `;return s?'<pre><code class="language-'+w(s)+'">'+(r?t:w(t,!0))+`</code></pre> `:"<pre><code>"+(r?t:w(t,!0))+`</code></pre> `}blockquote({tokens:n}){return`<blockquote> ${this.parser.parse(n)}</blockquote> `}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}> `}hr(n){return`<hr> `}list(n){let e=n.ordered,r=n.start,s="";for(let i=0;i<n.items.length;i++){let l=n.items[i];s+=this.listitem(l)}let t=e?"ol":"ul",a=e&&r!==1?' start="'+r+'"':"";return"<"+t+a+`> `+s+"</"+t+`> `}listitem(n){let e="";if(n.task){let r=this.checkbox({checked:!!n.checked});n.loose?n.tokens[0]?.type==="paragraph"?(n.tokens[0].text=r+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=r+" "+w(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):e+=r+" "}return e+=this.parser.parse(n.tokens,!!n.loose),`<li>${e}</li> `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p> `}table(n){let e="",r="";for(let t=0;t<n.header.length;t++)r+=this.tablecell(n.header[t]);e+=this.tablerow({text:r});let s="";for(let t=0;t<n.rows.length;t++){let a=n.rows[t];r="";for(let i=0;i<a.length;i++)r+=this.tablecell(a[i]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table> <thead> `+e+`</thead> `+s+`</table> `}tablerow({text:n}){return`<tr> ${n}</tr> `}tablecell(n){let e=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+`</${r}> `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${w(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:r}){let s=this.parser.parseInline(r),t=me(n);if(t===null)return s;n=t;let a='<a href="'+n+'"';return e&&(a+=' title="'+w(e)+'"'),a+=">"+s+"</a>",a}image({href:n,title:e,text:r,tokens:s}){s&&(r=this.parser.parseInline(s,this.parser.textRenderer));let t=me(n);if(t===null)return w(r);n=t;let a=`<img src="${n}" alt="${r}"`;return e&&(a+=` title="${w(e)}"`),a+=">",a}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:w(n.text)}},ne=class{static{h(this,"$")}strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}},S=class Q{static{h(this,"l")}options;renderer;textRenderer;constructor(e){this.options=e||$,this.options.renderer=this.options.renderer||new j,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ne}static parse(e,r){return new Q(r).parse(e)}static parseInline(e,r){return new Q(r).parseInline(e)}parse(e,r=!0){let s="";for(let t=0;t<e.length;t++){let a=e[t];if(this.options.extensions?.renderers?.[a.type]){let l=a,o=this.options.extensions.renderers[l.type].call({parser:this},l);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){s+=o||"";continue}}let i=a;switch(i.type){case"space":{s+=this.renderer.space(i);continue}case"hr":{s+=this.renderer.hr(i);continue}case"heading":{s+=this.renderer.heading(i);continue}case"code":{s+=this.renderer.code(i);continue}case"table":{s+=this.renderer.table(i);continue}case"blockquote":{s+=this.renderer.blockquote(i);continue}case"list":{s+=this.renderer.list(i);continue}case"html":{s+=this.renderer.html(i);continue}case"def":{s+=this.renderer.def(i);continue}case"paragraph":{s+=this.renderer.paragraph(i);continue}case"text":{let l=i,o=this.renderer.text(l);for(;t+1<e.length&&e[t+1].type==="text";)l=e[++t],o+=` `+this.renderer.text(l);r?s+=this.renderer.paragraph({type:"paragraph",raw:o,text:o,tokens:[{type:"text",raw:o,text:o,escaped:!0}]}):s+=o;continue}default:{let l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}parseInline(e,r=this.renderer){let s="";for(let t=0;t<e.length;t++){let a=e[t];if(this.options.extensions?.renderers?.[a.type]){let l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=l||"";continue}}let i=a;switch(i.type){case"escape":{s+=r.text(i);break}case"html":{s+=r.html(i);break}case"link":{s+=r.link(i);break}case"image":{s+=r.image(i);break}case"strong":{s+=r.strong(i);break}case"em":{s+=r.em(i);break}case"codespan":{s+=r.codespan(i);break}case"br":{s+=r.br(i);break}case"del":{s+=r.del(i);break}case"text":{s+=r.text(i);break}default:{let l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},A=class{static{h(this,"S")}options;block;constructor(n){this.options=n||$}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?y.lex:y.lexInline}provideParser(){return this.block?S.parse:S.parseInline}},zt=class{static{h(this,"B")}defaults=V();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=S;Renderer=j;TextRenderer=ne;Lexer=y;Tokenizer=B;Hooks=A;constructor(...n){this.use(...n)}walkTokens(n,e){let r=[];for(let s of n)switch(r=r.concat(e.call(this,s)),s.type){case"table":{let t=s;for(let a of t.header)r=r.concat(this.walkTokens(a.tokens,e));for(let a of t.rows)for(let i of a)r=r.concat(this.walkTokens(i.tokens,e));break}case"list":{let t=s;r=r.concat(this.walkTokens(t.items,e));break}default:{let t=s;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach(a=>{let i=t[a].flat(1/0);r=r.concat(this.walkTokens(i,e))}):t.tokens&&(r=r.concat(this.walkTokens(t.tokens,e)))}}return r}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(r=>{let s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let a=e.renderers[t.name];a?e.renderers[t.name]=function(...i){let l=t.renderer.apply(this,i);return l===!1&&(l=a.apply(this,i)),l}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[t.level];a?a.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)}),s.extensions=e),r.renderer){let t=this.defaults.renderer||new j(this.defaults);for(let a in r.renderer){if(!(a in t))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let i=a,l=r.renderer[i],o=t[i];t[i]=(...c)=>{let p=l.apply(t,c);return p===!1&&(p=o.apply(t,c)),p||""}}s.renderer=t}if(r.tokenizer){let t=this.defaults.tokenizer||new B(this.defaults);for(let a in r.tokenizer){if(!(a in t))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let i=a,l=r.tokenizer[i],o=t[i];t[i]=(...c)=>{let p=l.apply(t,c);return p===!1&&(p=o.apply(t,c)),p}}s.tokenizer=t}if(r.hooks){let t=this.defaults.hooks||new A;for(let a in r.hooks){if(!(a in t))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let i=a,l=r.hooks[i],o=t[i];A.passThroughHooks.has(a)?t[i]=c=>{if(this.defaults.async&&A.passThroughHooksRespectAsync.has(a))return Promise.resolve(l.call(t,c)).then(u=>o.call(t,u));let p=l.call(t,c);return o.call(t,p)}:t[i]=(...c)=>{let p=l.apply(t,c);return p===!1&&(p=o.apply(t,c)),p}}s.hooks=t}if(r.walkTokens){let t=this.defaults.walkTokens,a=r.walkTokens;s.walkTokens=function(i){let l=[];return l.push(a.call(this,i)),t&&(l=l.concat(t.call(this,i))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return y.lex(n,e??this.defaults)}parser(n,e){return S.parse(n,e??this.defaults)}parseMarkdown(n){return(e,r)=>{let s={...r},t={...this.defaults,...s},a=this.onError(!!t.silent,!!t.async);if(this.defaults.async===!0&&s.async===!1)return a(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 a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));t.hooks&&(t.hooks.options=t,t.hooks.block=n);let i=t.hooks?t.hooks.provideLexer():n?y.lex:y.lexInline,l=t.hooks?t.hooks.provideParser():n?S.parse:S.parseInline;if(t.async)return Promise.resolve(t.hooks?t.hooks.preprocess(e):e).then(o=>i(o,t)).then(o=>t.hooks?t.hooks.processAllTokens(o):o).then(o=>t.walkTokens?Promise.all(this.walkTokens(o,t.walkTokens)).then(()=>o):o).then(o=>l(o,t)).then(o=>t.hooks?t.hooks.postprocess(o):o).catch(a);try{t.hooks&&(e=t.hooks.preprocess(e));let o=i(e,t);t.hooks&&(o=t.hooks.processAllTokens(o)),t.walkTokens&&this.walkTokens(o,t.walkTokens);let c=l(o,t);return t.hooks&&(c=t.hooks.postprocess(c)),c}catch(o){return a(o)}}}onError(n,e){return r=>{if(r.message+=` Please report this to https://github.com/markedjs/marked.`,n){let s="<p>An error occurred:</p><pre>"+w(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},T=new zt;function f(n,e){return T.parse(n,e)}h(f,"d");f.options=f.setOptions=function(n){return T.setOptions(n),f.defaults=T.defaults,we(f.defaults),f};f.getDefaults=V;f.defaults=$;f.use=function(...n){return T.use(...n),f.defaults=T.defaults,we(f.defaults),f};f.walkTokens=function(n,e){return T.walkTokens(n,e)};f.parseInline=T.parseInline;f.Parser=S;f.parser=S.parse;f.Renderer=j;f.TextRenderer=ne;f.Lexer=y;f.lexer=y.lex;f.Tokenizer=B;f.Hooks=A;f.parse=f;var Ft=f.options,Gt=f.setOptions,Ot=f.use,Zt=f.walkTokens,Ht=f.parseInline;var Nt=S.parse,Qt=y.lex;function Lt(n,{markdownAutoWrap:e}){let s=n.replace(/<br\/>/g,` `).replace(/\n{2,}/g,` `);return ge(s)}h(Lt,"preprocessMarkdown");function Pe(n){return n.split(/\\n|\n|<br\s*\/?>/gi).map(e=>e.trim().match(/<[^>]+>|[^\s<>]+/g)?.map(r=>({content:r,type:"normal"}))??[])}h(Pe,"nonMarkdownToLines");function Ee(n,e={}){let r=Lt(n,e),s=f.lexer(r),t=[[]],a=0;function i(l,o="normal"){l.type==="text"?l.text.split(` `).forEach((p,u)=>{u!==0&&(a++,t.push([])),p.split(" ").forEach(d=>{d=d.replace(/&#39;/g,"'"),d&&t[a].push({content:d,type:o})})}):l.type==="strong"||l.type==="em"?l.tokens.forEach(c=>{i(c,l.type)}):l.type==="html"&&t[a].push({content:l.text,type:"normal"})}return h(i,"processNode"),s.forEach(l=>{l.type==="paragraph"?l.tokens?.forEach(o=>{i(o)}):l.type==="html"?t[a].push({content:l.text,type:"normal"}):t[a].push({content:l.raw,type:"normal"})}),t}h(Ee,"markdownToLines");function _e(n){return n?`<p>${n.replace(/\\n|\n/g,"<br />")}</p>`:""}h(_e,"nonMarkdownToHTML");function Ie(n,{markdownAutoWrap:e}={}){let r=f.lexer(n);function s(t){return t.type==="text"?e===!1?t.text.replace(/\n */g,"<br/>").replace(/ /g,"&nbsp;"):t.text.replace(/\n */g,"<br/>"):t.type==="strong"?`<strong>${t.tokens?.map(s).join("")}</strong>`:t.type==="em"?`<em>${t.tokens?.map(s).join("")}</em>`:t.type==="paragraph"?`<p>${t.tokens?.map(s).join("")}</p>`:t.type==="space"?"":t.type==="html"?`${t.text}`:t.type==="escape"?t.text:(_.warn(`Unsupported markdown: ${t.type}`),t.raw)}return h(s,"output"),r.map(s).join("")}h(Ie,"markdownToHTML");var Ce=(function(n){"use strict";var e=function(){},r=n.requestAnimationFrame||n.webkitRequestAnimationFrame||n.mozRequestAnimationFrame||n.msRequestAnimationFrame||function(c){return setTimeout(c,16)};function s(){var c=this;c.reads=[],c.writes=[],c.raf=r.bind(n),e("initialized",c)}h(s,"FastDom"),s.prototype={constructor:s,runTasks:h(function(c){e("run tasks");for(var p;p=c.shift();)p()},"runTasks"),measure:h(function(c,p){e("measure");var u=p?c.bind(p):c;return this.reads.push(u),t(this),u},"measure"),mutate:h(function(c,p){e("mutate");var u=p?c.bind(p):c;return this.writes.push(u),t(this),u},"mutate"),clear:h(function(c){return e("clear",c),i(this.reads,c)||i(this.writes,c)},"clear"),extend:h(function(c){if(e("extend",c),typeof c!="object")throw new Error("expected object");var p=Object.create(this);return l(p,c),p.fastdom=this,p.initialize&&p.initialize(),p},"extend"),catch:null};function t(c){c.scheduled||(c.scheduled=!0,c.raf(a.bind(null,c)),e("flush scheduled"))}h(t,"scheduleFlush");function a(c){e("flush");var p=c.writes,u=c.reads,d;try{e("flushing reads",u.length),c.runTasks(u),e("flushing writes",p.length),c.runTasks(p)}catch(m){d=m}if(c.scheduled=!1,(u.length||p.length)&&t(c),d)if(e("task errored",d.message),c.catch)c.catch(d);else throw d}h(a,"flush");function i(c,p){var u=c.indexOf(p);return!!~u&&!!c.splice(u,1)}h(i,"remove");function l(c,p){for(var u in p)p.hasOwnProperty(u)&&(c[u]=p[u])}h(l,"mixin");var o=n.fastdom=n.fastdom||new s;return o})(typeof window<"u"?window:globalThis);var je={initialize:h(function(){this._tasks=new Map},"initialize"),mutate:h(function(n,e){return Be(this,"mutate",n,e)},"mutate"),measure:h(function(n,e){return Be(this,"measure",n,e)},"measure"),clear:h(function(n){var e=this._tasks,r=e.get(n);this.fastdom.clear(r),e.delete(n)},"clear")};function Be(n,e,r,s){var t=n._tasks,a=n.fastdom,i,l=new Promise(function(o,c){i=a[e](function(){t.delete(l);try{o(s?r.call(s):r())}catch(p){c(p)}},s)});return t.set(l,i),l}h(Be,"create");var{initialize:cn,mutate:pn,measure:hn,clear:un}=je,qe=je;var Mt=Ce.extend({raf(n){typeof queueMicrotask=="function"?queueMicrotask(n):setTimeout(n,0)}}).extend(qe),We=Mt;function At(n){return Intl.Segmenter?[...new Intl.Segmenter().segment(n)].map(e=>e.segment):[...n]}h(At,"splitTextToChars");function Pt(n,e){let r=At(e.content);return De(n,[],r,e.type)}h(Pt,"splitWordToFitWidth");function De(n,e,r,s){if(r.length===0)return[{content:e.join(""),type:s},{content:"",type:s}];let[t,...a]=r,i=[...e,t];return n([{content:i.join(""),type:s}])?De(n,i,a,s):(e.length===0&&t&&(e.push(t),r.shift()),[{content:e.join(""),type:s},{content:r.join(""),type:s}])}h(De,"splitWordToFitWidthRecursion");function Fe(n,e){if(n.some(({content:r})=>r.includes(` `)))throw new Error("splitLineToFitWidth does not support newlines in the line");return re(n,e)}h(Fe,"splitLineToFitWidth");function re(n,e,r=[],s=[]){if(n.length===0)return s.length>0&&r.push(s),r.length>0?r:[];let t="";n[0].content===" "&&(t=" ",n.shift());let a=n.shift()??{content:" ",type:"normal"},i=[...s];if(t!==""&&i.push({content:t,type:"normal"}),i.push(a),e(i))return re(n,e,r,i);if(s.length>0)r.push(s),n.unshift(a);else if(a.content){let[l,o]=Pt(e,a);r.push([l]),o.content&&n.unshift(o)}return re(n,e,r)}h(re,"splitLineToFitWidthRecursion");function Ge(n,e){e&&n.attr("style",e)}h(Ge,"applyStyle");var Oe=16384;async function Et(n,e,r,s,t=!1,a=ce(),i=0){let l=n.append("foreignObject");l.attr("width",`${Math.min(10*r,Oe)}px`),l.attr("height",`${Math.min(10*r,Oe)}px`);let o=l.append("xhtml:div"),c=O(e.label)?await pe(e.label.replace(he.lineBreakRegex,` `),a):G(e.label,a),p=e.isNode?"nodeLabel":"edgeLabel",u=o.append("span");u.html(c),Ge(u,e.labelStyle),u.attr("class",`${p} ${s}`),Ge(o,e.labelStyle),o.style("display","table-cell"),o.style("white-space","nowrap"),o.style("line-height","1.5"),r!==Number.POSITIVE_INFINITY&&(o.style("max-width",r+"px"),o.style("text-align","center")),o.attr("xmlns","http://www.w3.org/1999/xhtml"),t&&o.attr("class","labelBkg");let d=await We.measure(()=>o.node().getBoundingClientRect());return d.width===r?(o.style("display","table"),o.style("white-space","break-spaces"),o.style("width",r+"px")):d.width<i&&(o.style("display","table"),o.style("width",i+"px"),o.style("text-align","center")),l.node()}h(Et,"addHtmlSpan");function se(n,e,r,s=!1){let t=n.append("tspan").attr("class","text-outer-tspan").attr("x",0).attr("y",e*r-.1+"em").attr("dy",r+"em");return s&&t.attr("text-anchor","middle"),t}h(se,"createTspan");function _t(n,e,r){let s=n.append("text"),t=se(s,1,e);ie(t,r);let a=t.node().getComputedTextLength();return s.remove(),a}h(_t,"computeWidthOfText");function Pn(n,e,r){let s=n.append("text"),t=se(s,1,e);ie(t,[{content:r,type:"normal"}]);let a=t.node()?.getBoundingClientRect();return a&&s.remove(),a}h(Pn,"computeDimensionOfText");function It(n,e,r,s=!1,t=!1){let i=e.append("g"),l=i.insert("rect").attr("class","background").attr("style","stroke: none"),o=i.append("text").attr("y","-10.1");t&&o.attr("text-anchor","middle");let c=0;for(let p of r){let u=h(m=>_t(i,1.1,m)<=n,"checkWidth"),d=u(p)?[p]:Fe(p,u);for(let m of d){let g=se(o,c,1.1,t);ie(g,m),c++}}if(s){let p=o.node().getBBox(),u=2;return l.attr("x",p.x-u).attr("y",p.y-u).attr("width",p.width+2*u).attr("height",p.height+2*u),i.node()}else return o.node()}h(It,"createFormattedText");function Ze(n){let e=/&(amp|lt|gt);/g;return n.replace(e,(r,s)=>{switch(s){case"amp":return"&";case"lt":return"<";case"gt":return">";default:return r}})}h(Ze,"decodeHTMLEntities");function ie(n,e){n.text(""),e.forEach((r,s)=>{let t=n.append("tspan").attr("font-style",r.type==="em"?"italic":"normal").attr("class","text-inner-tspan").attr("font-weight",r.type==="strong"?"bold":"normal");s===0?t.text(Ze(r.content)):t.text(" "+Ze(r.content))})}h(ie,"updateTextContentAndStyles");async function Ct(n,e={}){let r=[];n.replace(/(fa[bklrs]?):fa-([\w-]+)/g,(t,a,i)=>(r.push((async()=>{let l=`${a}:${i}`;return await ue(l)?await de(l,void 0,{class:"label-icon"}):`<i class='${G(t,e).replace(":"," ")}'></i>`})()),t));let s=await Promise.all(r);return n.replace(/(fa[bklrs]?):fa-([\w-]+)/g,()=>s.shift()??"")}h(Ct,"replaceIconSubstring");var En=h(async(n,e="",{style:r="",isTitle:s=!1,classes:t="",useHtmlLabels:a=!0,markdown:i=!0,isNode:l=!0,width:o=200,minWidth:c=0,addSvgBackground:p=!1}={},u)=>{if(_.debug("XYZ createText",e,r,s,t,a,l,"addSvgBackground: ",p),a){let d=i?Ie(e,u):_e(e),m=await Ct(Z(d),u),g=e.replace(/\\\\/g,"\\"),x={isNode:l,label:O(e)?g:m,labelStyle:r.replace("fill:","color:")};return await Et(n,x,o,t,p,u,c)}else{let d=Z(e.replace(/<br\s*\/?>/g,"<br/>")),m=i?Ee(d.replace("<br>","<br/>"),u):Pe(d),g=It(o,n,m,e?p:!1,!l);if(l){/stroke:/.exec(r)&&(r=r.replace("stroke:","lineColor:"));let x=r.replace(/stroke:[^;]+;?/g,"").replace(/stroke-width:[^;]+;?/g,"").replace(/fill:[^;]+;?/g,"").replace(/color:/g,"fill:");R(g).attr("style",x)}else{let x=r.replace(/stroke:[^;]+;?/g,"").replace(/stroke-width:[^;]+;?/g,"").replace(/fill:[^;]+;?/g,"").replace(/background:/g,"fill:");R(g).select("rect").attr("style",x.replace(/background:/g,"fill:"));let v=r.replace(/stroke:[^;]+;?/g,"").replace(/stroke-width:[^;]+;?/g,"").replace(/fill:[^;]+;?/g,"").replace(/color:/g,"fill:");R(g).select("text").attr("style",v)}return s?R(g).selectAll("tspan.text-outer-tspan").classed("title-row",!0):R(g).selectAll("tspan.text-outer-tspan").classed("row",!0),g}},"createText");export{ge as a,Ee as b,We as c,Pn as d,En as e};