UNPKG

ranui

Version:

A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.

94 lines 62.4 kB
const w=require("./builder-Cb6jFd2B.cjs"),st=require("./purify.es-B4W7nftu.cjs");function ie(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var L=ie();function Oe(e){L=e}var E={exec:()=>null};function z(e){let t=[];return r=>{let n=Math.max(0,Math.min(3,r-1)),l=t[n];return l||(l=e(n),t[n]=l),l}}function p(e,t=""){let r=typeof e=="string"?e:e.source,n={replace:(l,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(k.caret,"$1"),r=r.replace(l,a),n},getRegex:()=>new RegExp(r,t)};return n}var at=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),k={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:e=>new RegExp(`^( {0,3}${e})((?:[	 ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:z(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ 	][^\\n]*)?(?:\\n|$))`)),hrRegex:z(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:z(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:z(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:z(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:z(e=>new RegExp(`^ {0,${e}}>`))},ot=/^(?:[ \t]*(?:\n|$))+/,ct=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ut=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,q=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ht=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,se=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ne=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,De=p(Ne).replace(/bull/g,se).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(),pt=p(Ne).replace(/bull/g,se).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(),ae=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,ft=/^[^\n]+/,oe=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,gt=p(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",oe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),dt=p(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,se).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",ce=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,kt=p("^ {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",ce).replace("tag",Q).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Be=e=>p(ae).replace("hr",q).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",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Q).getRegex(),bt=Be(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),xt=Be(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),ue={blockquote:p(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xt).getRegex(),code:ct,def:gt,fences:ut,heading:ht,hr:q,html:kt,lheading:De,list:dt,newline:ot,paragraph:bt,table:E,text:ft},xe=p("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",q).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",Q).getRegex(),mt={...ue,lheading:pt,table:xe,paragraph:p(ae).replace("hr",q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",xe).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Q).getRegex()},wt={...ue,html:p(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ce).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:E,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:p(ae).replace("hr",q).replace("heading",` *#{1,6} *[^
]`).replace("lheading",De).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},vt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,$t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Me=/^( {2,}|\\)\n(?!\s*$)/,yt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,R=/[\p{P}\p{S}]/u,O=/[\s\p{P}\p{S}]/u,H=/[^\s\p{P}\p{S}]/u,St=p(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,O).getRegex(),Rt=/[\p{Pi}\p{Ps}"']/u,qe=/(?!~)[\p{P}\p{S}]/u,_t=/(?!~)[\s\p{P}\p{S}]/u,Tt=/(?:[^\s\p{P}\p{S}]|~)/u,At=p(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",at?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),He=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Et=p(He,"u").replace(/punct/g,R).getRegex(),It=p(He,"u").replace(/punct/g,qe).getRegex(),Lt=p(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,"u").replace(/openQuote/g,Rt).replace(/punct/g,R).getRegex(),Ke="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Pt=p(Ke,"gu").replace(/notPunctSpace/g,H).replace(/punctSpace/g,O).replace(/punct/g,R).getRegex(),zt=p(Ke,"gu").replace(/notPunctSpace/g,Tt).replace(/punctSpace/g,_t).replace(/punct/g,qe).getRegex(),Ct=p("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,H).replace(/punctSpace/g,O).replace(/punct/g,R).getRegex(),Ot=p("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,H).replace(/punctSpace/g,O).replace(/punct/g,R).getRegex(),Nt=p("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,H).replace(/punctSpace/g,O).replace(/punct/g,R).getRegex(),Dt=p(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,R).getRegex(),Bt=p("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,H).replace(/punctSpace/g,O).replace(/punct/g,R).getRegex(),Mt=p(/\\(punct)/,"gu").replace(/punct/g,R).getRegex(),qt=p(/^<(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(),Ht=p(ce).replace("(?:-->|$)","-->").getRegex(),Kt=p("^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",Ht).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),W=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Gt=p(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",W).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ge=p(/^!?\[(label)\]\[(ref)\]/).replace("label",W).replace("ref",oe).getRegex(),We=p(/^!?\[(ref)\](?:\[\])?/).replace("ref",oe).getRegex(),Wt=p("reflink|nolink(?!\\()","g").replace("reflink",Ge).replace("nolink",We).getRegex(),me=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,he={_backpedal:E,anyPunctuation:Mt,autolink:qt,blockSkip:At,br:Me,code:$t,del:E,delLDelim:E,delRDelim:E,emStrongLDelim:Et,emStrongRDelimAst:Pt,emStrongRDelimUnd:Ot,escape:vt,link:Gt,nolink:We,punctuation:St,reflink:Ge,reflinkSearch:Wt,tag:Kt,text:yt,url:E},Ut={...he,emStrongLDelim:Lt,emStrongRDelimAst:Ct,emStrongRDelimUnd:Nt,link:p(/^!?\[(label)\]\((.*?)\)/).replace("label",W).getRegex(),reflink:p(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",W).getRegex()},Y={...he,emStrongRDelimAst:zt,emStrongLDelim:It,delLDelim:Dt,delRDelim:Bt,url:p(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",me).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:p(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",me).getRegex()},Zt={...Y,br:p(Me).replace("{2,}","*").getRegex(),text:p(Y.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},K={normal:ue,gfm:mt,pedantic:wt},B={normal:he,gfm:Y,breaks:Zt,pedantic:Ut},Qt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},we=e=>Qt[e];function S(e,t){if(t){if(k.escapeTest.test(e))return e.replace(k.escapeReplace,we)}else if(k.escapeTestNoEncode.test(e))return e.replace(k.escapeReplaceNoEncode,we);return e}function ve(e){try{e=encodeURI(e).replace(k.percentDecode,"%")}catch{return null}return e}function $e(e,t){let r=e.replace(k.findPipe,(l,i,a)=>{let s=!1,o=i;for(;--o>=0&&a[o]==="\\";)s=!s;return s?"|":" |"}).split(k.splitPipe),n=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;n<r.length;n++)r[n]=r[n].trim().replace(k.slashPipe,"|");return r}function _(e,t,r){let n=e.length;if(n===0)return"";let l=0;for(;l<n;){let i=e.charAt(n-l-1);if(i===t&&!r)l++;else if(i!==t&&r)l++;else break}return e.slice(0,n-l)}function ye(e){let t=e.split(`
`),r=t.length-1;for(;r>=0&&k.blankLine.test(t[r]);)r--;return t.length-r<=2?e:t.slice(0,r+1).join(`
`)}function jt(e,t){if(e.indexOf(t[1])===-1)return-1;let r=0;for(let n=0;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]===t[0])r++;else if(e[n]===t[1]&&(r--,r<0))return n;return r>0?-2:-1}function Ft(e,t=0){let r=t,n="";for(let l of e)if(l==="	"){let i=4-r%4;n+=" ".repeat(i),r+=i}else n+=l,r++;return n}function Se(e,t,r,n,l){let i=t.href,a=t.title||null,s=e[1].replace(l.other.outputLinkReplace,"$1");n.state.inLink=!0;let o={type:e[0].charAt(0)==="!"?"image":"link",raw:r,href:i,title:a,text:s,tokens:n.inlineTokens(s)};return n.state.inLink=!1,o}function Xt(e,t,r){let n=e.match(r.other.indentCodeCompensation);if(n===null)return t;let l=n[1];return t.split(`
`).map(i=>{let a=i.match(r.other.beginningSpace);if(a===null)return i;let[s]=a;return s.length>=l.length?i.slice(l.length):i}).join(`
`)}var U=class{options;rules;lexer;constructor(e){this.options=e||L}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let r=this.options.pedantic?t[0]:ye(t[0]);return{type:"code",raw:r,codeBlockStyle:"indented",text:r.replace(this.rules.other.codeRemoveIndent,"")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let r=t[0],n=Xt(r,t[3]||"",this.rules);return{type:"code",raw:r,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let r=t[2].trim();if(this.rules.other.endingHash.test(r)){let n=_(r,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(r=n.trim())}return{type:"heading",raw:_(t[0],`
`),depth:t[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:_(t[0],`
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let r=_(t[0],`
`).split(`
`),n="",l="",i=[];for(;r.length>0;){let a=!1,s=[],o;for(o=0;o<r.length;o++)if(this.rules.other.blockquoteStart.test(r[o]))s.push(r[o]),a=!0;else if(!a)s.push(r[o]);else break;r=r.slice(o);let c=s.join(`
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
    $1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
${c}`:c,l=l?`${l}
${u}`:u;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=h,r.length===0)break;let f=i.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let b=f,d=r.join(`
`),y=b.raw+`
`+d.replace(this.rules.other.blockquoteSetextReplace2,""),N=this.blockquote(y);i[i.length-1]=N,n=`${n}
${d}`,l=l.substring(0,l.length-b.text.length)+N.text;break}else if(f?.type==="list"){let b=f,d=b.raw+`
`+r.join(`
`),y=this.list(d);i[i.length-1]=y,n=n.substring(0,n.length-f.raw.length)+y.raw,l=l.substring(0,l.length-b.raw.length)+y.raw,r=d.substring(i.at(-1).raw.length).split(`
`);continue}}return{type:"blockquote",raw:n,tokens:i,text:l}}}list(e){let t=this.rules.block.list.exec(e);if(t){let r=t[1].trim(),n=r.length>1,l={type:"list",raw:"",ordered:n,start:n?+r.slice(0,-1):"",loose:!1,items:[]};r=n?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=n?r:"[*+-]");let i=this.rules.other.listItemRegex(r),a=!1;for(;e;){let o=!1,c="",u="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let h=Ft(t[2].split(`
`,1)[0],t[1].length),f=e.split(`
`,1)[0],b=!h.trim(),d=0;if(this.options.pedantic?(d=2,u=h.trimStart()):b?d=t[1].length+1:(d=h.search(this.rules.other.nonSpaceChar),d=d>4?1:d,u=h.slice(d),d+=t[1].length),b&&this.rules.other.blankLine.test(f)&&(c+=f+`
`,e=e.substring(f.length+1),o=!0),!o){let y=this.rules.other.nextBulletRegex(d),N=this.rules.other.hrRegex(d),ke=this.rules.other.fencesBeginRegex(d),be=this.rules.other.headingBeginRegex(d),lt=this.rules.other.htmlBeginRegex(d),it=this.rules.other.blockquoteBeginRegex(d);for(;e;){let F=e.split(`
`,1)[0],D;if(f=F,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting,"  "),D=f):D=f.replace(this.rules.other.tabCharGlobal,"    "),ke.test(f)||be.test(f)||lt.test(f)||it.test(f)||y.test(f)||N.test(f))break;if(D.search(this.rules.other.nonSpaceChar)>=d||!f.trim())u+=`
`+D.slice(d);else{if(b||h.replace(this.rules.other.tabCharGlobal,"    ").search(this.rules.other.nonSpaceChar)>=4||ke.test(h)||be.test(h)||N.test(h))break;u+=`
`+f}b=!f.trim(),c+=F+`
`,e=e.substring(F.length+1),h=D.slice(d)}}l.loose||(a?l.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),l.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),l.raw+=c}let s=l.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;l.raw=l.raw.trimEnd();for(let o of l.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 h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(o.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};o.checked=h.checked,l.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=h.raw+o.tokens[0].raw,o.tokens[0].text=h.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(h)):o.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):o.tokens.unshift(h)}}else o.task&&(o.task=!1);if(!l.loose){let u=o.tokens.filter(h=>h.type==="space");l.loose=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw))}}if(l.loose)for(let o of l.items){o.loose=!0;for(let c of o.tokens)c.type==="text"&&(c.type="paragraph")}return l}}html(e){let t=this.rules.block.html.exec(e);if(t){let r=ye(t[0]);return{type:"html",block:!0,raw:r,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:r}}}def(e){let t=this.rules.block.def.exec(e);if(t){let r=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:r,raw:_(t[0],`
`),href:n,title:l}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let r=$e(t[1]),n=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),l=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
`):[],i={type:"table",raw:_(t[0],`
`),header:[],align:[],rows:[]};if(r.length===n.length){for(let a of n)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<r.length;a++)i.header.push({text:r[a],tokens:this.lexer.inline(r[a]),header:!0,align:i.align[a]});for(let a of l)i.rows.push($e(a,i.header.length).map((s,o)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:i.align[o]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let r=t[1].trim();return{type:"heading",raw:_(t[0],`
`),depth:t[2].charAt(0)==="="?1:2,text:r,tokens:this.lexer.inline(r)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let r=t[1].charAt(t[1].length-1)===`
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:r,tokens:this.lexer.inline(r)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let i=_(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{let i=jt(t[2],"()");if(i===-2)return;if(i>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let n=t[2],l="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(n);i&&(n=i[1],l=i[3])}else l=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?n=n.slice(1):n=n.slice(1,-1)),Se(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let n=t[(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!n){let l=r[0].charAt(0);return{type:"text",raw:l,text:l}}return Se(r,n,r[0],this.lexer,this.rules)}}emStrong(e,t,r=""){let n=this.rules.inline.emStrongLDelim.exec(e);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!r||this.rules.inline.punctuation.exec(r))){let l=[...n[0]].length-1,i,a,s=l,o=0,c=n[0][0],u=r===c,h=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+l);(n=h.exec(t))!==null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(a=[...i].length,n[3]||n[4]){s+=a;continue}else if(n[5]||n[6]){if(l%3&&!((l+a)%3)){o+=a;continue}if(u)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+o);let f=[...n[0]][0].length,b=e.slice(0,l+n.index+f+a);if(Math.min(l,a)%2){let y=b.slice(1,-1);return{type:"em",raw:b,text:y,tokens:this.lexer.inlineTokens(y)}}let d=b.slice(2,-2);return{type:"strong",raw:b,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let r=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(r),l=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return n&&l&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:t[0],text:r}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,r=""){let n=this.rules.inline.delLDelim.exec(e);if(n&&(!n[1]||!r||this.rules.inline.punctuation.exec(r))){let l=[...n[0]].length-1,i,a,s=l,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*e.length+l);(n=o.exec(t))!==null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i||(a=[...i].length,a!==l))continue;if(n[3]||n[4]){s+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s);let c=[...n[0]][0].length,u=e.slice(0,l+n.index+c+a),h=u.slice(l,-l);return{type:"del",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let r,n;return t[2]==="@"?(r=t[1],n="mailto:"+r):(r=t[1],n=r),{type:"link",raw:t[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let r,n;if(t[2]==="@")r=t[0],n="mailto:"+r;else{let l;do l=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(l!==t[0]);r=t[0],t[1]==="www."?n="http://"+t[0]:n=t[0]}return{type:"link",raw:t[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let r=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:r}}}},v=class ee{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||L,this.options.tokenizer=this.options.tokenizer||new U,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:k,block:K.normal,inline:B.normal};this.options.pedantic?(r.block=K.pedantic,r.inline=B.pedantic):this.options.gfm&&(r.block=K.gfm,this.options.breaks?r.inline=B.breaks:r.inline=B.gfm),this.tokenizer.rules=r}static get rules(){return{block:K,inline:B}}static lex(t,r){return new ee(r).lex(t)}static lexInline(t,r){return new ee(r).inlineTokens(t)}lex(t){t=t.replace(k.carriageReturn,`
`),this.blockTokens(t,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let n=this.inlineQueue[r];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,r=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(k.tabCharGlobal,"    ").replace(k.spaceLine,""));let l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(s=>(i=s.call({lexer:this},t,r))?(t=t.substring(i.raw.length),r.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let s=r.at(-1);i.raw.length===1&&s!==void 0?s.raw+=`
`:r.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let s=r.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
`)?"":`
`)+i.raw,s.text+=`
`+i.text,this.inlineQueue.at(-1).src=s.text):r.push(i);continue}if(i=this.tokenizer.fences(t)){t=t.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.heading(t)){t=t.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.hr(t)){t=t.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.blockquote(t)){t=t.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.list(t)){t=t.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.html(t)){t=t.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.def(t)){t=t.substring(i.raw.length);let s=r.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
`)?"":`
`)+i.raw,s.text+=`
`+i.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},r.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),r.push(i);continue}let a=t;if(this.options.extensions?.startBlock){let s=1/0,o=t.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},o),typeof c=="number"&&c>=0&&(s=Math.min(s,c))}),s<1/0&&s>=0&&(a=t.substring(0,s+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let s=r.at(-1);n&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
`)?"":`
`)+i.raw,s.text+=`
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(i),n=a.length!==t.length,t=t.substring(i.raw.length);continue}if(i=this.tokenizer.text(t)){t=t.substring(i.raw.length);let s=r.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
`)?"":`
`)+i.raw,s.text+=`
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(i);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,r}inline(t,r=[]){return this.inlineQueue.push({src:t,tokens:r}),r}inlineTokens(t,r=[]){this.tokenizer.lexer=this;let n=t;if(this.tokens.links){let s=Object.keys(this.tokens.links);s.length>0&&(n=n.replace(this.tokenizer.rules.inline.reflinkSearch,o=>s.includes(o.slice(o.lastIndexOf("[")+1,-1))?"["+"a".repeat(o.length-2)+"]":o))}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),n=n.replace(this.tokenizer.rules.inline.blockSkip,(s,o,c)=>{let u=c?c.length:0;return s.slice(0,u)+"["+"a".repeat(s.length-u-2)+"]"}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let l=!1,i="",a=1/0;for(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}l||(i=""),l=!1;let s;if(this.options.extensions?.inline?.some(c=>(s=c.call({lexer:this},t,r))?(t=t.substring(s.raw.length),r.push(s),!0):!1))continue;if(s=this.tokenizer.escape(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.tag(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.link(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(s.raw.length);let c=r.at(-1);s.type==="text"&&c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):r.push(s);continue}if(s=this.tokenizer.emStrong(t,n,i)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.codespan(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.br(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.del(t,n,i)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.autolink(t)){t=t.substring(s.raw.length),r.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(t))){t=t.substring(s.raw.length),r.push(s);continue}let o=t;if(this.options.extensions?.startInline){let c=1/0,u=t.slice(1),h;this.options.extensions.startInline.forEach(f=>{h=f.call({lexer:this},u),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),c<1/0&&c>=0&&(o=t.substring(0,c+1))}if(s=this.tokenizer.inlineText(o)){t=t.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(i=s.raw.slice(-1)),l=!0;let c=r.at(-1);c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):r.push(s);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return r}infiniteLoopError(t){let r="Infinite loop on byte: "+t;if(this.options.silent)console.error(r);else throw new Error(r)}},Z=class{options;parser;constructor(e){this.options=e||L}space(e){return""}code({text:e,lang:t,escaped:r}){let n=(t||"").match(k.notSpaceStart)?.[0],l=e.replace(k.endingNewline,"")+`
`;return n?'<pre><code class="language-'+S(n)+'">'+(r?l:S(l,!0))+`</code></pre>
`:"<pre><code>"+(r?l:S(l,!0))+`</code></pre>
`}blockquote({tokens:e}){return`<blockquote>
${this.parser.parse(e)}</blockquote>
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
`}hr(e){return`<hr>
`}list(e){let t=e.ordered,r=e.start,n="";for(let a=0;a<e.items.length;a++){let s=e.items[a];n+=this.listitem(s)}let l=t?"ol":"ul",i=t&&r!==1?' start="'+r+'"':"";return"<"+l+i+`>
`+n+"</"+l+`>
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
`}table(e){let t="",r="";for(let l=0;l<e.header.length;l++)r+=this.tablecell(e.header[l]);t+=this.tablerow({text:r});let n="";for(let l=0;l<e.rows.length;l++){let i=e.rows[l];r="";for(let a=0;a<i.length;a++)r+=this.tablecell(i[a]);n+=this.tablerow({text:r})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
<thead>
`+t+`</thead>
`+n+`</table>
`}tablerow({text:e}){return`<tr>
${e}</tr>
`}tablecell(e){let t=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+t+`</${r}>
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${S(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:r}){let n=this.parser.parseInline(r),l=ve(e);if(l===null)return n;e=l;let i='<a href="'+e+'"';return t&&(i+=' title="'+S(t)+'"'),i+=">"+n+"</a>",i}image({href:e,title:t,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let l=ve(e);if(l===null)return S(r);e=l;let i=`<img src="${e}" alt="${S(r)}"`;return t&&(i+=` title="${S(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:S(e.text)}},pe=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},$=class te{options;renderer;textRenderer;constructor(t){this.options=t||L,this.options.renderer=this.options.renderer||new Z,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new pe}static parse(t,r){return new te(r).parse(t)}static parseInline(t,r){return new te(r).parseInline(t)}parse(t){this.renderer.parser=this;let r="";for(let n=0;n<t.length;n++){let l=t[n];if(this.options.extensions?.renderers?.[l.type]){let a=l,s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){r+=s||"";continue}}let i=l;switch(i.type){case"space":r+=this.renderer.space(i);break;case"hr":r+=this.renderer.hr(i);break;case"heading":r+=this.renderer.heading(i);break;case"code":r+=this.renderer.code(i);break;case"table":r+=this.renderer.table(i);break;case"blockquote":r+=this.renderer.blockquote(i);break;case"list":r+=this.renderer.list(i);break;case"checkbox":r+=this.renderer.checkbox(i);break;case"html":r+=this.renderer.html(i);break;case"def":r+=this.renderer.def(i);break;case"paragraph":r+=this.renderer.paragraph(i);break;case"text":r+=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 r}parseInline(t,r=this.renderer){this.renderer.parser=this;let n="";for(let l=0;l<t.length;l++){let i=t[l];if(this.options.extensions?.renderers?.[i.type]){let s=this.options.extensions.renderers[i.type].call({parser:this},i);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(i.type)){n+=s||"";continue}}let a=i;switch(a.type){case"escape":n+=r.text(a);break;case"html":n+=r.html(a);break;case"link":n+=r.link(a);break;case"image":n+=r.image(a);break;case"checkbox":n+=r.checkbox(a);break;case"strong":n+=r.strong(a);break;case"em":n+=r.em(a);break;case"codespan":n+=r.codespan(a);break;case"br":n+=r.br(a);break;case"del":n+=r.del(a);break;case"text":n+=r.text(a);break;default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}},M=class{options;block;constructor(e){this.options=e||L}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?v.lex:v.lexInline}provideParser(e=this.block){return e?$.parse:$.parseInline}},Ue=class{defaults=ie();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=$;Renderer=Z;TextRenderer=pe;Lexer=v;Tokenizer=U;Hooks=M;constructor(...e){this.use(...e)}walkTokens(e,t){let r=[];for(let n of e)switch(r=r.concat(t.call(this,n)),n.type){case"table":{let l=n;for(let i of l.header)r=r.concat(this.walkTokens(i.tokens,t));for(let i of l.rows)for(let a of i)r=r.concat(this.walkTokens(a.tokens,t));break}case"list":{let l=n;r=r.concat(this.walkTokens(l.items,t));break}default:{let l=n;this.defaults.extensions?.childTokens?.[l.type]?this.defaults.extensions.childTokens[l.type].forEach(i=>{let a=l[i].flat(1/0);r=r.concat(this.walkTokens(a,t))}):l.tokens&&(r=r.concat(this.walkTokens(l.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{let n={...r};if(n.async=this.defaults.async||n.async||!1,r.extensions&&(r.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){let i=t.renderers[l.name];i?t.renderers[l.name]=function(...a){let s=l.renderer.apply(this,a);return s===!1&&(s=i.apply(this,a)),s}:t.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[l.level];i?i.unshift(l.tokenizer):t[l.level]=[l.tokenizer],l.start&&(l.level==="block"?t.startBlock?t.startBlock.push(l.start):t.startBlock=[l.start]:l.level==="inline"&&(t.startInline?t.startInline.push(l.start):t.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(t.childTokens[l.name]=l.childTokens)}),n.extensions=t),r.renderer){let l=this.defaults.renderer||new Z(this.defaults);for(let i in r.renderer){if(!(i in l))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,s=r.renderer[a],o=l[a];l[a]=(...c)=>{let u=s.apply(l,c);return u===!1&&(u=o.apply(l,c)),u||""}}n.renderer=l}if(r.tokenizer){let l=this.defaults.tokenizer||new U(this.defaults);for(let i in r.tokenizer){if(!(i in l))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,s=r.tokenizer[a],o=l[a];l[a]=(...c)=>{let u=s.apply(l,c);return u===!1&&(u=o.apply(l,c)),u}}n.tokenizer=l}if(r.hooks){let l=this.defaults.hooks||new M;for(let i in r.hooks){if(!(i in l))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,s=r.hooks[a],o=l[a];M.passThroughHooks.has(i)?l[a]=c=>{if(this.defaults.async&&M.passThroughHooksRespectAsync.has(i))return(async()=>{let h=await s.call(l,c);return o.call(l,h)})();let u=s.call(l,c);return o.call(l,u)}:l[a]=(...c)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(l,c);return h===!1&&(h=await o.apply(l,c)),h})();let u=s.apply(l,c);return u===!1&&(u=o.apply(l,c)),u}}n.hooks=l}if(r.walkTokens){let l=this.defaults.walkTokens,i=r.walkTokens;n.walkTokens=function(a){let s=[];return s.push(i.call(this,a)),l&&(s=s.concat(l.call(this,a))),s}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return v.lex(e,t??this.defaults)}parser(e,t){return $.parse(e,t??this.defaults)}parseMarkdown(e){return(t,r)=>{let n={...r},l={...this.defaults,...n},i=this.onError(!!l.silent,!!l.async);if(this.defaults.async===!0&&n.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 t>"u"||t===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(l.hooks&&(l.hooks.options=l,l.hooks.block=e),l.async)return(async()=>{let a=l.hooks?await l.hooks.preprocess(t):t,s=await(l.hooks?await l.hooks.provideLexer(e):e?v.lex:v.lexInline)(a,l),o=l.hooks?await l.hooks.processAllTokens(s):s;l.walkTokens&&await Promise.all(this.walkTokens(o,l.walkTokens));let c=await(l.hooks?await l.hooks.provideParser(e):e?$.parse:$.parseInline)(o,l);return l.hooks?await l.hooks.postprocess(c):c})().catch(i);try{l.hooks&&(t=l.hooks.preprocess(t));let a=(l.hooks?l.hooks.provideLexer(e):e?v.lex:v.lexInline)(t,l);l.hooks&&(a=l.hooks.processAllTokens(a)),l.walkTokens&&this.walkTokens(a,l.walkTokens);let s=(l.hooks?l.hooks.provideParser(e):e?$.parse:$.parseInline)(a,l);return l.hooks&&(s=l.hooks.postprocess(s)),s}catch(a){return i(a)}}}onError(e,t){return r=>{if(r.message+=`
Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+S(r.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(r);throw r}}},I=new Ue;function g(e,t){return I.parse(e,t)}g.options=g.setOptions=function(e){return I.setOptions(e),g.defaults=I.defaults,Oe(g.defaults),g};g.getDefaults=ie;g.defaults=L;function Vt(...e){return I.use(...e),g.defaults=I.defaults,Oe(g.defaults),g}g.use=Vt;g.walkTokens=function(e,t){return I.walkTokens(e,t)};g.parseInline=I.parseInline;g.Parser=$;g.parser=$.parse;g.Renderer=Z;g.TextRenderer=pe;g.Lexer=v;g.lexer=v.lex;g.Tokenizer=U;g.Hooks=M;g.parse=g;var Mn=g.options,qn=g.setOptions,Hn=g.walkTokens,Kn=g.parseInline,Gn=$.parse,Wn=v.lex,Jt=Object.defineProperty,Yt=Object.defineProperties,er=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ze=(e,t)=>{for(var r in t||(t={}))tr.call(t,r)&&_e(e,r,t[r]);if(Re)for(var r of Re(t))rr.call(t,r)&&_e(e,r,t[r]);return e},Qe=(e,t)=>Yt(e,er(t)),m=(e,t)=>{let r=!1,n=!1;for(let l=0;l<t;l+=1){if(e[l]==="\\"&&l+1<e.length&&e[l+1]==="`"){l+=1;continue}if(e.substring(l,l+3)==="```"){n=!n,l+=2;continue}!n&&e[l]==="`"&&(r=!r)}return r||n},nr=(e,t)=>{let r=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",l=t>1&&e.substring(t-2,t+1)==="```";return r||n||l},lr=e=>{let t=0;for(let r=0;r<e.length;r+=1){if(e[r]==="\\"&&r+1<e.length&&e[r+1]==="`"){r+=1;continue}e[r]==="`"&&!nr(e,r)&&(t+=1)}return t},T=(e,t)=>{let r=!1,n=!1,l=-1;for(let i=0;i<e.length;i+=1){if(e[i]==="\\"&&i+1<e.length&&e[i+1]==="`"){i+=1;continue}if(e.substring(i,i+3)==="```"){n=!n,i+=2;continue}if(!n&&e[i]==="`")if(r){if(l<t&&t<i)return!0;r=!1,l=-1}else r=!0,l=i}return!1},ir=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,sr=e=>!e||typeof e!="string"||!e.includes(">")?e:e.replace(ir,(t,r,n,l)=>m(e,l)?t:`${r}\\>${n}`),ar=/(\*\*)([^*]*\*?)$/,or=/(__)([^_]*?)$/,cr=/(\*\*\*)([^*]*?)$/,ur=/(\*)([^*]*?)$/,hr=/(_)([^_]*?)$/,pr=/(`)([^`]*?)$/,fr=/(~~)([^~]*?)$/,P=/^[\s_~*`]*$/,je=/^[\s]*[-*+][\s]+$/,gr=/[\p{L}\p{N}_]/u,dr=/^```[^`\n]*```?$/,kr=/^\*{4,}$/,br=/(__)([^_]+)_$/,xr=/(~~)([^~]+)~$/,Te=/~~/g,A=e=>{if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?!0:gr.test(e)},mr=(e,t)=>{let r=1;for(let n=t-1;n>=0;n-=1)if(e[n]==="]")r+=1;else if(e[n]==="["&&(r-=1,r===0))return n;return-1},Fe=(e,t)=>{let r=1;for(let n=t+1;n<e.length;n+=1)if(e[n]==="[")r+=1;else if(e[n]==="]"&&(r-=1,r===0))return n;return-1},j=(e,t)=>{let r=!1,n=!1;for(let l=0;l<e.length&&l<t;l+=1){if(e[l]==="\\"&&e[l+1]==="$"){l+=1;continue}e[l]==="$"&&(e[l+1]==="$"?(n=!n,l+=1,r=!1):n||(r=!r))}return r||n},wr=(e,t)=>{for(let r=t;r<e.length;r+=1){if(e[r]===")")return!0;if(e[r]===`
`)return!1}return!1},Xe=(e,t)=>{for(let r=t-1;r>=0;r-=1){if(e[r]===")")return!1;if(e[r]==="(")return r>0&&e[r-1]==="]"?wr(e,t):!1;if(e[r]===`
`)return!1}return!1},vr=(e,t)=>{for(let r=t-1;r>=0;r-=1){if(e[r]===">")return!1;if(e[r]==="<"){let n=r+1<e.length?e[r+1]:"";return n>="a"&&n<="z"||n>="A"&&n<="Z"||n==="/"}if(e[r]===`
`)return!1}return!1},fe=(e,t,r)=>{let n=0;for(let o=t-1;o>=0;o-=1)if(e[o]===`
`){n=o+1;break}let l=e.length;for(let o=t;o<e.length;o+=1)if(e[o]===`
`){l=o;break}let i=e.substring(n,l),a=0,s=!1;for(let o of i)if(o===r)a+=1;else if(o!==" "&&o!=="	"){s=!0;break}return a>=3&&!s},$r=(e,t,r,n)=>r==="\\"||e.includes("$")&&j(e,t)?!0:r!=="*"&&n==="*"?(t<e.length-2?e[t+2]:"")!=="*":!!(r==="*"||r&&n&&A(r)&&A(n)||(!r||r===" "||r==="	"||r===`
`)&&(!n||n===" "||n==="	"||n===`
`)),Ve=e=>{let t=0,r=!1,n=e.length;for(let l=0;l<n;l+=1){if(e[l]==="`"&&l+2<n&&e[l+1]==="`"&&e[l+2]==="`"){r=!r,l+=2;continue}if(r||e[l]!=="*")continue;let i=l>0?e[l-1]:"",a=l<n-1?e[l+1]:"";$r(e,l,i,a)||(t+=1)}return t},yr=(e,t,r,n)=>!!(r==="\\"||e.includes("$")&&j(e,t)||Xe(e,t)||vr(e,t)||r==="_"||n==="_"||r&&n&&A(r)&&A(n)),Sr=e=>{let t=0,r=!1,n=e.length;for(let l=0;l<n;l+=1){if(e[l]==="`"&&l+2<n&&e[l+1]==="`"&&e[l+2]==="`"){r=!r,l+=2;continue}if(r||e[l]!=="_")continue;let i=l>0?e[l-1]:"",a=l<n-1?e[l+1]:"";yr(e,l,i,a)||(t+=1)}return t},Rr=e=>{let t=0,r=0,n=!1;for(let l=0;l<e.length;l+=1){if(e[l]==="`"&&l+2<e.length&&e[l+1]==="`"&&e[l+2]==="`"){r>=3&&(t+=Math.floor(r/3)),r=0,n=!n,l+=2;continue}n||(e[l]==="*"?r+=1:(r>=3&&(t+=Math.floor(r/3)),r=0))}return r>=3&&(t+=Math.floor(r/3)),t},ge=e=>{let t=0,r=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){r=!r,n+=2;continue}r||e[n]==="*"&&n+1<e.length&&e[n+1]==="*"&&(t+=1,n+=1)}return t},Ae=e=>{let t=0,r=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){r=!r,n+=2;continue}r||e[n]==="_"&&n+1<e.length&&e[n+1]==="_"&&(t+=1,n+=1)}return t},_r=(e,t,r)=>{if(!t||P.test(t))return!0;let n=e.substring(0,r).lastIndexOf(`
`),l=n===-1?0:n+1,i=e.substring(l,r);return je.test(i)&&t.includes(`
`)?!0:fe(e,r,"*")},Tr=e=>{let t=e.match(ar);if(!t)return e;let r=t[2],n=e.lastIndexOf(t[1]);return m(e,n)||T(e,n)||_r(e,r,n)?e:ge(e)%2===1?r.endsWith("*")?`${e}*`:`${e}**`:e},Ar=(e,t,r)=>{if(!t||P.test(t))return!0;let n=e.substring(0,r).lastIndexOf(`
`),l=n===-1?0:n+1,i=e.substring(l,r);return je.test(i)&&t.includes(`
`)?!0:fe(e,r,"_")},Er=e=>{let t=e.match(or);if(!t){let l=e.match(br);if(l){let i=e.lastIndexOf(l[1]);if(!(m(e,i)||T(e,i))&&Ae(e)%2===1)return`${e}_`}return e}let r=t[2],n=e.lastIndexOf(t[1]);return m(e,n)||T(e,n)||Ar(e,r,n)?e:Ae(e)%2===1?`${e}__`:e},Ir=e=>{let t=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){t=!t,r+=2;continue}if(!t&&e[r]==="*"&&e[r-1]!=="*"&&e[r+1]!=="*"&&e[r-1]!=="\\"&&!j(e,r)){let n=r>0?e[r-1]:"",l=r<e.length-1?e[r+1]:"";if((!n||n===" "||n==="	"||n===`
`)&&(!l||l===" "||l==="	"||l===`
`)||n&&l&&A(n)&&A(l))continue;return r}}return-1},Lr=e=>{if(!e.match(ur))return e;let t=Ir(e);if(t===-1||m(e,t)||T(e,t))return e;let r=e.substring(t+1);return!r||P.test(r)?e:Ve(e)%2===1?`${e}*`:e},Je=e=>{let t=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){t=!t,r+=2;continue}if(!t&&e[r]==="_"&&e[r-1]!=="_"&&e[r+1]!=="_"&&e[r-1]!=="\\"&&!j(e,r)&&!Xe(e,r)){let n=r>0?e[r-1]:"",l=r<e.length-1?e[r+1]:"";if(n&&l&&A(n)&&A(l))continue;return r}}return-1},Pr=e=>{let t=e.length;for(;t>0&&e[t-1]===`
`;)t-=1;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},zr=e=>{if(!e.endsWith("**"))return null;let t=e.slice(0,-2);if(ge(t)%2!==1)return null;let r=t.indexOf("**"),n=Je(t);return r!==-1&&n!==-1&&r<n?`${t}_**`:null},Cr=e=>{if(!e.match(hr))return e;let t=Je(e);if(t===-1)return e;let r=e.substring(t+1);if(!r||P.test(r)||m(e,t)||T(e,t))return e;if(Sr(e)%2===1){let n=zr(e);return n!==null?n:Pr(e)}return e},Or=e=>{let t=ge(e),r=Ve(e);return t%2===0&&r%2===0},Nr=(e,t,r)=>!t||P.test(t)||m(e,r)||T(e,r)?!0:fe(e,r,"*"),Dr=e=>{if(kr.test(e))return e;let t=e.match(cr);if(!t)return e;let r=t[2];return Nr(e,r,e.lastIndexOf(t[1]))?e:Rr(e)%2===1?Or(e)?e:`${e}***`:e},Br=/<[a-zA-Z/][^>]*$/,Mr=e=>{let t=e.match(Br);return!t||t.index===void 0||m(e,t.index)?e:e.substring(0,t.index).trimEnd()},qr=e=>!e.match(dr)||e.includes(`
`)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,Hr=e=>(e.match(/```/g)||[]).length%2===1,Kr=e=>{let t=qr(e);if(t!==null)return t;let r=e.match(pr);if(r&&!Hr(e)){let n=r[2];if(!n||P.test(n))return e;if(lr(e)%2===1)return`${e}\``}return e},Ye=(e,t)=>t>=2&&e.substring(t-2,t+1)==="```"||t>=1&&e.substring(t-1,t+2)==="```"||t<=e.length-3&&e.substring(t,t+3)==="```",Gr=e=>{let t=0,r=!1;for(let n=0;n<e.length-1;n+=1)e[n]==="`"&&!Ye(e,n)&&(r=!r),!r&&e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},Wr=e=>{let t=0,r=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="\\"){n+=1;continue}if(e[n]==="`"&&!Ye(e,n)){r=!r;continue}!r&&e[n]==="$"&&(n+1<e.length&&e[n+1]==="$"?n+=1:t+=1)}return t},Ur=e=>{if(e.endsWith("$")&&!e.endsWith("$$"))return`${e}$`;let t=e.indexOf("$$");return t!==-1&&e.indexOf(`
`,t)!==-1&&!e.endsWith(`
`)?`${e}
$$`:`${e}$$`},Zr=e=>Gr(e)%2===0?e:Ur(e),Qr=e=>Wr(e)%2===1?`${e}$`:e,jr=(e,t,r)=>{if(e.substring(t+2).includes(")"))return null;let n=mr(e,t);if(n===-1||m(e,n))return null;let l=n>0&&e[n-1]==="!",i=l?n-1:n,a=e.substring(0,i);if(l)return a;let s=e.substring(n+1,t);return r==="text-only"?`${a}${s}`:`${a}[${s}](streamdown:incomplete-link)`},Ee=(e,t)=>{for(let r=0;r<t;r++)if(e[r]==="["&&!m(e,r)){if(r>0&&e[r-1]==="!")continue;let n=Fe(e,r);if(n===-1)return r;if(n+1<e.length&&e[n+1]==="("){let l=e.indexOf(")",n+2);l!==-1&&(r=l)}}return t},Fr=(e,t,r)=>{let n=t>0&&e[t-1]==="!",l=n?t-1:t;if(!e.substring(t+1).includes("]")){let i=e.substring(0,l);if(n)return i;if(r==="text-only"){let a=Ee(e,t);return e.substring(0,a)+e.substring(a+1)}return`${e}](streamdown:incomplete-link)`}if(Fe(e,t)===-1){let i=e.substring(0,l);if(n)return i;if(r==="text-only"){let a=Ee(e,t);return e.substring(0,a)+e.substring(a+1)}return`${e}](streamdown:incomplete-link)`}return null},et=(e,t="protocol")=>{let r=e.lastIndexOf("](");if(r!==-1&&!m(e,r)){let n=jr(e,r,t);if(n!==null)return n}for(let n=e.length-1;n>=0;n-=1)if(e[n]==="["&&!m(e,n)){let l=Fr(e,n,t);if(l!==null)return l}return e},Xr=/^-{1,2}$/,Vr=/^[\s]*-{1,2}[\s]+$/,Jr=/^={1,2}$/,Yr=/^[\s]*={1,2}[\s]+$/,en=e=>{if(!e||typeof e!="string")return e;let t=e.lastIndexOf(`
`);if(t===-1)return e;let r=e.substring(t+1),n=e.substring(0,t),l=r.trim();if(Xr.test(l)&&!r.match(Vr)){let i=n.split(`
`).at(-1);if(i&&i.trim().length>0)return`${e}​`}if(Jr.test(l)&&!r.match(Yr)){let i=n.split(`
`).at(-1);if(i&&i.trim().length>0)return`${e}​`}return e},tn=new RegExp("(?<=[\\p{L}\\p{N}_])~(?!~)(?=[\\p{L}\\p{N}_])","gu"),rn=e=>!e||typeof e!="string"||!e.includes("~")?e:e.replace(tn,(t,r)=>m(e,r)?t:"\\~"),nn=e=>{var t,r;let n=e.match(fr);if(n){let l=n[2];if(!l||P.test(l))return e;let i=e.lastIndexOf(n[1]);if(m(e,i)||T(e,i))return e;if(((t=e.match(Te))==null?void 0:t.length)%2===1)return`${e}~~`}else{let l=e.match(xr);if(l){let i=e.lastIndexOf(l[0].slice(0,2));if(m(e,i)||T(e,i))return e;if(((r=e.match(Te))==null?void 0:r.length)%2===1)return`${e}~`}}return e},X=e=>e!==!1,ln=e=>e===!0,x={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},sn=[{handler:{name:"singleTilde",handle:rn,priority:x.SINGLE_TILDE},optionKey:"singleTilde"},{handler:{name:"comparisonOperators",handle:sr,priority:x.COMPARISON_OPERATORS},optionKey:"comparisonOperators"},{handler:{name:"htmlTags",handle:Mr,priority:x.HTML_TAGS},optionKey:"htmlTags"},{handler:{name:"setextHeadings",handle:en,priority:x.SETEXT_HEADINGS},optionKey:"setextHeadings"},{handler:{name:"links",handle:et,priority:x.LINKS},optionKey:"links",earlyReturn:e=>e.endsWith("](streamdown:incomplete-link)")},{handler:{name:"boldItalic",handle:Dr,priority:x.BOLD_ITALIC},optionKey:"boldItalic"},{handler:{name:"bold",handle:Tr,priority:x.BOLD},optionKey:"bold"},{handler:{name:"italicDoubleUnderscore",handle:Er,priority:x.ITALIC_DOUBLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"italicSingleAsterisk",handle:Lr,priority:x.ITALIC_SINGLE_ASTERISK},optionKey:"italic"},{handler:{name:"italicSingleUnderscore",handle:Cr,priority:x.ITALIC_SINGLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"inlineCode",handle:Kr,priority:x.INLINE_CODE},optionKey:"inlineCode"},{handler:{name:"strikethrough",handle:nn,priority:x.STRIKETHROUGH},optionKey:"strikethrough"},{handler:{name:"katex",handle:Zr,priority:x.KATEX},optionKey:"katex"},{handler:{name:"inlineKatex",handle:Qr,priority:x.INLINE_KATEX},optionKey:"inlineKatex"}],an=e=>{var t;let r=(t=e?.linkMode)!=null?t:"protocol";return sn.filter(({handler:n,optionKey:l})=>n.name==="links"?X(e?.links)||X(e?.images):n.name==="inlineKatex"?ln(e?.inlineKatex):X(e?.[l])).map(({handler:n,earlyReturn:l})=>n.name==="links"?{handler:Qe(Ze({},n),{handle:i=>et(i,r)}),earlyReturn:r==="protocol"?l:void 0}:{handler:n,earlyReturn:l})},on=(e,t)=>{var r;if(!e||typeof e!="string")return e;let n=e.endsWith(" ")&&!e.endsWith("  ")?e.slice(0,-1):e,l=an(t),i=((r=t?.handlers)!=null?r:[]).map(s=>{var o;return{handler:Qe(Ze({},s),{priority:(o=s.priority)!=null?o:x.DEFAULT}),earlyReturn:void 0}}),a=[...l,...i].sort((s,o)=>{var c,u;return((c=s.handler.priority)!=null?c:0)-((u=o.handler.priority)!=null?u:0)});for(let{handler:s,earlyReturn:o}of a)if(n=s.handle(n),o!=null&&o(n))return n;return n},cn=on,C=null,Ie=e=>{if(typeof document>"u")return!1;C||(C=document.createElement("template")),C.innerHTML=`${e}<i data-ran-probe=""></i>`;const t=C.content.querySelector("[data-ran-probe]"),r=t!==null&&t.parentNode!==C.content;return C.innerHTML="",r},un=e=>{const t=[];let r="";for(const n of e){const l=t[t.length-1];if(r){l.push(n),n.type==="html"&&(r+=n.raw,Ie(r)||(r=""));continue}if(n.type==="space"||n.type==="def"){l&&l.push(n);continue}t.push([n]),n.type==="html"&&n.block&&Ie(n.raw)&&(r=n.raw)}return t},hn=/^[ \t]{0,3}(`{3,}|~{3,})/,pn=e=>{let t=null,r=0;for(const n of e.split(`
`)){const l=hn.exec(n);t===null?l&&(t=l[1][0],r=l[1].length):l&&l[1][0]===t&&l[1].length>=r&&(t=null,r=0)}return t!==null},re=null,de=null,G=null,ne=new Set,tt=new Set,V=new Map,fn=()=>G||(G=Promise.all([Promise.resolve().then(()=>require("./bundle-web-SWwL-9RE.cjs")),Promise.resolve().then(()=>require("./engine-javascript-D6BWoCfG.cjs"))]).then(async([e,t])=>{re=e;const r=await e.createHighlighter({themes:[],langs:[],engine:t.createJavaScriptRegexEngine({forgiving:!0})});return de=r,r}),G),Le=e=>{const t=(e||"").trim().toLowerCase();return!t||t==="text"||t==="plain"||t==="plaintext"||t==="txt"?"text":re?t in re.bundledLanguages?t:"text":t},J=(e,t)=>{const r=`${e}:${t}`,n=e==="theme"?ne:tt;if(n.has(t))return Promise.resolve();const l=V.get(r);if(l)return l;const i=fn().then(async a=>{e==="theme"?await a.loadTheme(t):t!=="text"&&await a.loadLanguage(t),n.add(t)}).finally(()=>V.delete(r));return V.set(r,i),i},gn=(e,t)=>!!de&&ne.has(t.light)&&ne.has(t.dark)&&(e==="text"||tt.has(e)),Pe=(e,t,r)=>de.codeToHtml(e,{lang:t,themes:{light:r.light,dark:r.dark},defaultColor:!1}),dn=(e,t,r)=>{const n=Le(t);return gn(n,r)?Pe(e,n,r):Promise.all([J("theme",r.light),J("theme",r.dark)]).then(()=>{const l=Le(t);return J("lang",l).then(()=>Pe(e,l,r))}).catch(()=>null)},kn={light:"github-light",dark:"github-dark"},bn=e=>{const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?kn:t.length===1?{light:t[0],dark:t[0]}:{light:t[0],dark:t[1]}},rt=(e,t)=>`<span class="ran-md-math" data-ran-math="${w.Yt(e)}" data-display="${t}"></span>`,le=(e,t,r,n)=>{if(!e.startsWith(t))return null;const l=t.length,i=e.indexOf(r,l);if(i===-1||i===l)return null;let a=i+r.length;if(n){if(a!==e.length&&e[a]!==`
`)return null;for(;e[a]===`
`;)a+=1}return{raw:e.slice(0,a),text:e.slice(l,i).trim()}},xn={name:"ranMathBlock",level:"block",start(e){const t=e.indexOf("$$"),r=e.indexOf("\\[");return t===-1?r===-1?void 0:r:r===-1?t:Math.min(t,r)},tokenizer(e){const t=le(e,"$$","$$",!0)||le(e,"\\[","\\]",!0);if(t)return{type:"ranMathBlock",raw:t.raw,text:t.text}},renderer(e){return`<p class="ran-md-math-block">${rt(e.text,"block")}</p>
`}},mn=e=>{for(let t=0;t<e.length;t+=1)if(e[t]==="$"){if(e[t+1]==="$"){t+=1;continue}if(!(t>0&&e[t-1]==="$"))return t}return-1},wn=/^\$(?!\s)((?:\\.|[^$\\\n])+?)(?<!\s)\$(?!\d)/,vn=e=>({name:"ranMathInline",level:"inline",start(t){const r=t.indexOf("\\("),n=e?mn(t):-1;return r===-1?n===-1?void 0:n:n===-1?r:Math.min(r,n)},tokenizer(t){const r=le(t,"\\(","\\)",!1);if(r)return{type:"ranMathInline",raw:r.raw,text:r.text};const n=e?wn.exec(t):null;if(n)return{type:"ranMathInline",raw:n[0],text:n[1].trim()}},renderer(t){return rt(t.text,"inline")}}),ze=new Map,$n=e=>{const t=e?"dollar":"default";let r=ze.get(t);return r||(r=new Ue({gfm:!0,breaks:!1,async:!1}),r.use({extensions:[xn,vn(e)]}),ze.set(t,r)),r},yn={USE_PROFILES:{html:!0},FORBID_TAGS:["style","form","textarea","select","button","iframe","object","embed"],FORBID_ATTR:["style"],ADD_ATTR:["target"],RETURN_DOM_FRAGMENT:!0},Sn="\0",Rn=(e,t)=>{let r="",n=!1;for(const i of e)r+=i.raw,i.type==="table"&&(n=!0);const l=e[e.length-1];return{tokens:e,raw:r,key:t?`${r}${Sn}${t}`:r,hasTable:n,incompleteCode:l?.type==="code"&&pn(l.raw)}},_n=(e,t={})=>{const r=$n(!!t.inlineMath),n=a=>st.purify.sanitize(r.parser(a.tokens),yn);if(!e.trim())return{blocks:[],render:n};const l=r.lexer(e);let i="";for(const a of l)a.type==="def"&&(i+=a.raw);return{blocks:(t.split===!1?[Array.from(l)]:un(l)).map(a=>Rn(a,i)),render:n}},Tn="language-",An=e=>{const t=Array.from(e.classList).find(n=>n.startsWith(Tn)),r=e.textContent||"";return{lang:t?t.slice(9).toLowerCase():"",code:r.endsWith(`
`)?r.slice(0,-1):r}},Ce=(e,t,r,n)=>{const l=w.createRef();return w.ButtonBuilder().class("ran-md-btn").part("button").attr("type","button").data("md-action",e).aria("label",r).attr("title",r).children(w.View("r-icon").attr("name",t).attr("size","16").attr("color","currentColor").ref(l)).on("click",()=>n(l.current)).build()},En=e=>{const t=e.split(`
`);return t.length>1&&t[t.length-1]===""&&t.pop(),t.flatMap((r,n)=>{const l=w.Span().class("line").text(r).build();return n===0?[l]:[document.createTextNode(`
`),l]})},In=e=>w.View("pre").class("ran-md-pre").children(w.View("code").children(...En(e))).build(),Ln=(e,t,r,n,l,i)=>{const a=dn(r,n,l),s=o=>{if(!o||!e.isConnected||Number(e.dataset.renderToken)!==i)return;const c=document.createElement("template");c.innerHTML=o;const u=c.content.firstElementChild;!u||u.tagName!=="PRE"||(u.classList.add("ran-md-pre"),u.removeAttribute("style"),u.removeAttribute("tabindex"),t.pre.replaceWith(u),t.pre=u)};typeof a=="string"?s(a):a.then(s)},Pn=0,zn=(e,t)=>w.View("r-mermaid").class("ran-md-mermaid").attr("code",encodeURIComponent(e.trim())).attr("theme",t.theme).boolAttr("copy",t.copy).boolAttr("download",t.download).boolAttr("fullscreen",!0).build(),nt=(e,t)=>w.View("r-math").attr("latex",encodeURIComponent(e)).attr("display",t).build(),Cn=(e,t)=>{const r=e.firstElementChild;if(!r||r.tagName!=="CODE")return null;const{lang:n,code:l}=An(r);if(n==="mermaid"&&!t.incomplete){Promise.resolve().then(()=>require("./mermaid-D4XprSTL.cjs")).then(h=>h.mermaid_exports);const u=zn(l,t);return e.replaceWith(u),u}if((n==="math"||n==="latex")&&!t.incomplete)return Promise.resolve().then(()=>require("./math-Dj_xUXUk.cjs")).then(u=>u.math_exports),e.replaceWith(nt(l.trim(),"block")),null;const i=++Pn,a=[];t.copy&&a.push(Ce("copy","copy",t.labels.copy,u=>t.onCopy(u,l,n))),t.download&&a.push(Ce("download","download",t.labels.download,()=>t.onDownload(l,n)));const s=n||a.length?w.Div().class("ran-md-code-header").part("code-header").children(w.Span().class("ran-md-code-lang").part("code-lang").text(n),w.Span().class("ran-md-code-actions").part("code-actions").children(...a)):null,o={pre:In(l)},c=w.Div().class("ran-md-code").part("code").data("render-token",String(i)).children(s,o.pre).build();return n&&(c.dataset.language=n),t.incomplete&&(c.dataset.incomplete=""),t.lineNumbers&&(c.dataset.lineNumbers=""),e.replaceWith(c),t.highlight&&Ln(c,o,l,n,t.highlight,i),null},On=/[\u3000-\u303f\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/u,Nn=/^(https?:\/\/|www\.)([^/?#]*)/,Dn=e=>{const t=e.textContent??"",r=e.getAttribute("href")??"";let n=r;try{n=decodeURI(r)}catch{}if(t!==n)return;const l=Nn.exec(t);if(l===null)return;const i=l[2].search(On);if(i<0)return;const a=t.slice(0,l[1].length+i);e.textContent=a,e.setAttribute("href",a),e.after(document.createTextNode(t.slice(a.length)))},Bn=(e,t)=>{const r=[],n=[],l=[],i=[],a=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let c=s.nextNode();c;c=s.nextNode()){const u=c;switch(u.tagName){case"PRE":r.push(u);break;case"A":n.push(u);break;case"TABLE":l.push(u);break;case"IMG":i.push(u);break;case"SPAN":u.dataset.ranMath!==void 0&&a.push(u)}}const o=[];for(const c of r){const u=Cn(c,t);u&&o.push(u)}if(a.length>0){Promise.resolve().then(()=>require("./math-Dj_xUXUk.cjs")).then(c=>c.math_exports);for(const c of a)c.replaceWith(nt(c.dataset.ranMath||"",c.dataset.display==="inline"?"inline":"block"))}for(const c of n){const u=c.getAttribute("href");if(!u){c.dataset.incomplete="";continue}u.startsWith("#")||(Dn(c),t.linkTarget&&t.linkTarget!=="_self"&&(c.setAttribute("target",t.linkTarget),c.setAttribute("rel","noopener noreferrer")))}for(const c of l){const u=w.Div().class("ran-md-table-wrap").part("table").build();c.replaceWith(u),u.appendChild(c)}for(const c of i)c.hasAttribute("loading")||c.setAttribute("loading","lazy");return{themed:o}};exports.enhance=Bn;exports.parseDocument=_n;exports.parseThemes=bn;exports.remend=cn;