@vectojs/markdown 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,994 @@
1
+ // src/Markdown.ts
2
+ import {
3
+ Entity,
4
+ prepareContentGrid,
5
+ SVGEntity
6
+ } from "@vectojs/core";
7
+ import { marked } from "marked";
8
+ import { mathjax } from "mathjax-full/js/mathjax.js";
9
+ import { TeX } from "mathjax-full/js/input/tex.js";
10
+ import { SVG } from "mathjax-full/js/output/svg.js";
11
+ import { liteAdaptor } from "mathjax-full/js/adaptors/liteAdaptor.js";
12
+ import { RegisterHTMLHandler } from "mathjax-full/js/handlers/html.js";
13
+ import { AllPackages } from "mathjax-full/js/input/tex/AllPackages.js";
14
+ import { measureText, RichText, Stack, Table, Text, Image, UIComponent } from "@vectojs/ui";
15
+
16
+ // src/MarkdownWorkerSource.ts
17
+ var WORKER_SOURCE_STRING = '"use strict";(()=>{function H(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var T=H();function ae(r){T=r}var R={exec:()=>null};function z(r){let e=[];return t=>{let s=Math.max(0,Math.min(3,t-1)),n=e[s];return n||(n=r(s),e[s]=n),n}}function u(r,e=""){let t=typeof r=="string"?r:r.source,s={replace:(n,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(x.caret,"$1"),t=t.replace(n,l),s},getRegex:()=>new RegExp(t,e)};return s}var we=((r="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+r)}catch{return!1}})(),x={codeRemoveIndent:/^(?: {1,4}| {0,3}\\t)/gm,outputLinkReplace:/\\\\([\\[\\]])/g,indentCodeCompensation:/^(\\s+)(?:```)/,beginningSpace:/^\\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\\n/g,tabCharGlobal:/\\t/g,multipleSpaceGlobal:/\\s+/g,blankLine:/^[ \\t]*$/,doubleBlankLine:/\\n[ \\t]*\\n[ \\t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\\n {0,3}((?:=+|-+) *)(?=\\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \\t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\\[[ xX]\\] +\\S/,listReplaceTask:/^\\[[ xX]\\] +/,listTaskCheckbox:/\\[[ xX]\\]/,anyLine:/\\n.*\\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\\||\\| *$/g,tableRowBlankLine:/\\n[ \\t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\\s|>)/i,endPreScriptTag:/^<\\/(pre|code|kbd|script)(\\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^\'"]*[^\\s])\\s+([\'"])(.*)\\2/,unicodeAlphaNumeric:/[\\p{L}\\p{N}]/u,escapeTest:/[&<>"\']/,escapeReplace:/[&<>"\']/g,escapeTestNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/,escapeReplaceNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/g,caret:/(^|[^\\[])\\^/g,percentDecode:/%25/g,findPipe:/\\|/g,splitPipe:/ \\|/,slashPipe:/\\\\\\|/g,carriageReturn:/\\r\\n|\\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\\S*/,endingNewline:/\\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\\\n]*)?(?:\\\\n|$))`),nextBulletRegex:z(r=>new RegExp(`^ {0,${r}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:z(r=>new RegExp(`^ {0,${r}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:z(r=>new RegExp(`^ {0,${r}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:z(r=>new RegExp(`^ {0,${r}}#`)),htmlBeginRegex:z(r=>new RegExp(`^ {0,${r}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:z(r=>new RegExp(`^ {0,${r}}>`))},me=/^(?:[ \\t]*(?:\\n|$))+/,ye=/^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/,$e=/^ {0,3}(`{3,}(?=[^`\\n]*(?:\\n|$))|~{3,})([^\\n]*)(?:\\n|$)(?:|([\\s\\S]*?)(?:\\n|$))(?: {0,3}\\1[~`]* *(?=\\n|$)|$)/,I=/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/,Re=/^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/,O=/ {0,3}(?:[*+-]|\\d{1,9}[.)])/,oe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,ce=u(oe).replace(/bull/g,O).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(),Se=u(oe).replace(/bull/g,O).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(),N=/^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\\n)[^\\n]+)*)/,Te=/^[^\\n]+/,G=/(?!\\s*\\])(?:\\\\[\\s\\S]|[^\\[\\]\\\\])+/,ze=u(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace("label",G).replace("title",/(?:"(?:\\\\"?|[^"\\\\])*"|\'[^\'\\n]*(?:\\n[^\'\\n]+)*\\n?\'|\\([^()]*\\))/).getRegex(),Ae=u(/^(bull)([ \\t][^\\n]*?)?(?:\\n|$)/).replace(/bull/g,O).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",X=/<!--(?:-?>|[\\s\\S]*?(?:-->|$))/,Pe=u("^ {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",X).replace("tag",q).replace("attribute",/ +[a-zA-Z:_][\\w.:-]*(?: *= *"[^"\\n]*"| *= *\'[^\'\\n]*\'| *= *[^\\s"\'=<>`]+)?/).getRegex(),he=r=>u(N).replace("hr",I).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",r).replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q).getRegex(),_e=he(/ {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]/),Le=he(/ {0,3}(?:[*+-]|\\d{1,9}[.)])[ \\t]+[^ \\t\\n]/),Ie=u(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace("paragraph",Le).getRegex(),W={blockquote:Ie,code:ye,def:ze,fences:$e,heading:Re,hr:I,html:Pe,lheading:ce,list:Ae,newline:me,paragraph:_e,table:R,text:Te},ee=u("^ *([^\\\\n ].*)\\\\n {0,3}((?:\\\\| *)?:?-+:? *(?:\\\\| *:?-+:? *)*(?:\\\\| *)?)(?:\\\\n((?:(?! *\\\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\\\n|$))*)\\\\n*|$)").replace("hr",I).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[.)])[ \\\\t]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q).getRegex(),Ee={...W,lheading:Se,table:ee,paragraph:u(N).replace("hr",I).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("table",ee).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~{3,})[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]+[^ \\\\t\\\\n]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q).getRegex()},Ce={...W,html:u(`^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\\\s[^\'"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))`).replace("comment",X).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:R,lheading:/^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,paragraph:u(N).replace("hr",I).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",ce).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ve=/^\\\\([!"#$%&\'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/,Be=/^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/,pe=/^( {2,}|\\\\)\\n(?!\\s*$)/,qe=/^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/,A=/[\\p{P}\\p{S}]/u,Z=/[\\s\\p{P}\\p{S}]/u,F=/[^\\s\\p{P}\\p{S}]/u,Ze=u(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Z).getRegex(),ue=/(?!~)[\\p{P}\\p{S}]/u,De=/(?!~)[\\s\\p{P}\\p{S}]/u,Me=/(?:[^\\s\\p{P}\\p{S}]|~)/u,Qe=u(/link|precode-code|html/,"g").replace("link",/\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)/).replace("precode-",we?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ge=/^(?:\\*+(?:((?!\\*)punct)|([^\\s*]))?)|^_+(?:((?!_)punct)|([^\\s_]))?/,je=u(ge,"u").replace(/punct/g,A).getRegex(),He=u(ge,"u").replace(/punct/g,ue).getRegex(),ke="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)",Oe=u(ke,"gu").replace(/notPunctSpace/g,F).replace(/punctSpace/g,Z).replace(/punct/g,A).getRegex(),Ne=u(ke,"gu").replace(/notPunctSpace/g,Me).replace(/punctSpace/g,De).replace(/punct/g,ue).getRegex(),Ge=u("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,F).replace(/punctSpace/g,Z).replace(/punct/g,A).getRegex(),Xe=u(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,A).getRegex(),We="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Fe=u(We,"gu").replace(/notPunctSpace/g,F).replace(/punctSpace/g,Z).replace(/punct/g,A).getRegex(),Ue=u(/\\\\(punct)/,"gu").replace(/punct/g,A).getRegex(),Je=u(/^<(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(),Ke=u(X).replace("(?:-->|$)","-->").getRegex(),Ve=u("^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",Ke).replace("attribute",/\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*"[^"]*"|\\s*=\\s*\'[^\']*\'|\\s*=\\s*[^\\s"\'=<>`]+)?/).getRegex(),C=/(?:\\[(?:\\\\[\\s\\S]|[^\\[\\]\\\\])*\\]|\\\\[\\s\\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\\])|[^\\[\\]\\\\`])*?/,Ye=u(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]+(?:\\n[ \\t]*)?|\\n[ \\t]*)(title))?\\s*\\)/).replace("label",C).replace("href",/<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]+|(?=\\))/).replace("title",/"(?:\\\\"?|[^"\\\\])*"|\'(?:\\\\\'?|[^\'\\\\])*\'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex(),de=u(/^!?\\[(label)\\]\\[(ref)\\]/).replace("label",C).replace("ref",G).getRegex(),fe=u(/^!?\\[(ref)\\](?:\\[\\])?/).replace("ref",G).getRegex(),et=u("reflink|nolink(?!\\\\()","g").replace("reflink",de).replace("nolink",fe).getRegex(),te=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,U={_backpedal:R,anyPunctuation:Ue,autolink:Je,blockSkip:Qe,br:pe,code:Be,del:R,delLDelim:R,delRDelim:R,emStrongLDelim:je,emStrongRDelimAst:Oe,emStrongRDelimUnd:Ge,escape:ve,link:Ye,nolink:fe,punctuation:Ze,reflink:de,reflinkSearch:et,tag:Ve,text:qe,url:R},tt={...U,link:u(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",C).getRegex(),reflink:u(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",C).getRegex()},M={...U,emStrongRDelimAst:Ne,emStrongLDelim:He,delLDelim:Xe,delRDelim:Fe,url:u(/^((?:protocol):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/).replace("protocol",te).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:u(/^([`~]+|[^`~])(?:(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|protocol:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)))/).replace("protocol",te).getRegex()},rt={...M,br:u(pe).replace("{2,}","*").getRegex(),text:u(M.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},E={normal:W,gfm:Ee,pedantic:Ce},_={normal:U,gfm:M,breaks:rt,pedantic:tt},nt={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"},re=r=>nt[r];function m(r,e){if(e){if(x.escapeTest.test(r))return r.replace(x.escapeReplace,re)}else if(x.escapeTestNoEncode.test(r))return r.replace(x.escapeReplaceNoEncode,re);return r}function ne(r){try{r=encodeURI(r).replace(x.percentDecode,"%")}catch{return null}return r}function se(r,e){let t=r.replace(x.findPipe,(i,l,a)=>{let c=!1,o=l;for(;--o>=0&&a[o]==="\\\\";)c=!c;return c?"|":" |"}),s=t.split(x.splitPipe),n=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(;n<s.length;n++)s[n]=s[n].trim().replace(x.slashPipe,"|");return s}function $(r,e,t){let s=r.length;if(s===0)return"";let n=0;for(;n<s;){let i=r.charAt(s-n-1);if(i===e&&!t)n++;else if(i!==e&&t)n++;else break}return r.slice(0,s-n)}function ie(r){let e=r.split(`\n`),t=e.length-1;for(;t>=0&&x.blankLine.test(e[t]);)t--;return e.length-t<=2?r:e.slice(0,t+1).join(`\n`)}function st(r,e){if(r.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<r.length;s++)if(r[s]==="\\\\")s++;else if(r[s]===e[0])t++;else if(r[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function it(r,e=0){let t=e,s="";for(let n of r)if(n===" "){let i=4-t%4;s+=" ".repeat(i),t+=i}else s+=n,t++;return s}function le(r,e,t,s,n){let i=e.href,l=e.title||null,a=r[1].replace(n.other.outputLinkReplace,"$1");s.state.inLink=!0;let c={type:r[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:l,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,c}function lt(r,e,t){let s=r.match(t.other.indentCodeCompensation);if(s===null)return e;let n=s[1];return e.split(`\n`).map(i=>{let l=i.match(t.other.beginningSpace);if(l===null)return i;let[a]=l;return a.length>=n.length?i.slice(n.length):i}).join(`\n`)}var v=class{options;rules;lexer;constructor(r){this.options=r||T}space(r){let e=this.rules.block.newline.exec(r);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(r){let e=this.rules.block.code.exec(r);if(e){let t=this.options.pedantic?e[0]:ie(e[0]),s=t.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t,codeBlockStyle:"indented",text:s}}}fences(r){let e=this.rules.block.fences.exec(r);if(e){let t=e[0],s=lt(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(r){let e=this.rules.block.heading.exec(r);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let s=$(t,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(t=s.trim())}return{type:"heading",raw:$(e[0],`\n`),depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(r){let e=this.rules.block.hr.exec(r);if(e)return{type:"hr",raw:$(e[0],`\n`)}}blockquote(r){let e=this.rules.block.blockquote.exec(r);if(e){let t=$(e[0],`\n`).split(`\n`),s="",n="",i=[];for(;t.length>0;){let l=!1,a=[],c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),l=!0;else if(!l)a.push(t[c]);else break;t=t.slice(c);let o=a.join(`\n`),p=o.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}\n${o}`:o,n=n?`${n}\n${p}`:p;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,i,!0),this.lexer.state.top=h,t.length===0)break;let g=i.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let f=g,d=f.raw+`\n`+t.join(`\n`),y=this.blockquote(d);i[i.length-1]=y,s=s.substring(0,s.length-f.raw.length)+y.raw,n=n.substring(0,n.length-f.text.length)+y.text;break}else if(g?.type==="list"){let f=g,d=f.raw+`\n`+t.join(`\n`),y=this.list(d);i[i.length-1]=y,s=s.substring(0,s.length-g.raw.length)+y.raw,n=n.substring(0,n.length-f.raw.length)+y.raw,t=d.substring(i.at(-1).raw.length).split(`\n`);continue}}return{type:"blockquote",raw:s,tokens:i,text:n}}}list(r){let e=this.rules.block.list.exec(r);if(e){let t=e[1].trim(),s=t.length>1,n={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\\\d{1,9}\\\\${t.slice(-1)}`:`\\\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");let i=this.rules.other.listItemRegex(t),l=!1;for(;r;){let c=!1,o="",p="";if(!(e=i.exec(r))||this.rules.block.hr.test(r))break;o=e[0],r=r.substring(o.length);let h=it(e[2].split(`\n`,1)[0],e[1].length),g=r.split(`\n`,1)[0],f=!h.trim(),d=0;if(this.options.pedantic?(d=2,p=h.trimStart()):f?d=e[1].length+1:(d=h.search(this.rules.other.nonSpaceChar),d=d>4?1:d,p=h.slice(d),d+=e[1].length),f&&this.rules.other.blankLine.test(g)&&(o+=g+`\n`,r=r.substring(g.length+1),c=!0),!c){let y=this.rules.other.nextBulletRegex(d),K=this.rules.other.hrRegex(d),V=this.rules.other.fencesBeginRegex(d),Y=this.rules.other.headingBeginRegex(d),xe=this.rules.other.htmlBeginRegex(d),be=this.rules.other.blockquoteBeginRegex(d);for(;r;){let D=r.split(`\n`,1)[0],P;if(g=D,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),P=g):P=g.replace(this.rules.other.tabCharGlobal," "),V.test(g)||Y.test(g)||xe.test(g)||be.test(g)||y.test(g)||K.test(g))break;if(P.search(this.rules.other.nonSpaceChar)>=d||!g.trim())p+=`\n`+P.slice(d);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||V.test(h)||Y.test(h)||K.test(h))break;p+=`\n`+g}f=!g.trim(),o+=D+`\n`,r=r.substring(D.length+1),h=P.slice(d)}}n.loose||(l?n.loose=!0:this.rules.other.doubleBlankLine.test(o)&&(l=!0)),n.items.push({type:"list_item",raw:o,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),n.raw+=o}let a=n.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let c of n.items){this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]);let o=c.tokens[0];if(c.task&&(o?.type==="text"||o?.type==="paragraph")){c.text=c.text.replace(this.rules.other.listReplaceTask,""),o.raw=o.raw.replace(this.rules.other.listReplaceTask,""),o.text=o.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 p=this.rules.other.listTaskCheckbox.exec(c.raw);if(p){let h={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};c.checked=h.checked,n.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=h.raw+c.tokens[0].raw,c.tokens[0].text=h.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(h)):c.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):c.tokens.unshift(h)}}else c.task&&(c.task=!1);if(!n.loose){let p=c.tokens.filter(g=>g.type==="space"),h=p.length>0&&p.some(g=>this.rules.other.anyLine.test(g.raw));n.loose=h}}if(n.loose)for(let c of n.items){c.loose=!0;for(let o of c.tokens)o.type==="text"&&(o.type="paragraph")}return n}}html(r){let e=this.rules.block.html.exec(r);if(e){let t=ie(e[0]);return{type:"html",block:!0,raw:t,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:t}}}def(r){let e=this.rules.block.def.exec(r);if(e){let t=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"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:$(e[0],`\n`),href:s,title:n}}}table(r){let e=this.rules.block.table.exec(r);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=se(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`\n`):[],i={type:"table",raw:$(e[0],`\n`),header:[],align:[],rows:[]};if(t.length===s.length){for(let l of s)this.rules.other.tableAlignRight.test(l)?i.align.push("right"):this.rules.other.tableAlignCenter.test(l)?i.align.push("center"):this.rules.other.tableAlignLeft.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<t.length;l++)i.header.push({text:t[l],tokens:this.lexer.inline(t[l]),header:!0,align:i.align[l]});for(let l of n)i.rows.push(se(l,i.header.length).map((a,c)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:i.align[c]})));return i}}lheading(r){let e=this.rules.block.lheading.exec(r);if(e){let t=e[1].trim();return{type:"heading",raw:$(e[0],`\n`),depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(r){let e=this.rules.block.paragraph.exec(r);if(e){let t=e[1].charAt(e[1].length-1)===`\n`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(r){let e=this.rules.block.text.exec(r);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(r){let e=this.rules.inline.escape.exec(r);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(r){let e=this.rules.inline.tag.exec(r);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(r){let e=this.rules.inline.link.exec(r);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let i=$(t.slice(0,-1),"\\\\");if((t.length-i.length)%2===0)return}else{let i=st(e[2],"()");if(i===-2)return;if(i>-1){let l=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let s=e[2],n="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],n=i[3])}else n=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(t)?s=s.slice(1):s=s.slice(1,-1)),le(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(r,e){let t;if((t=this.rules.inline.reflink.exec(r))||(t=this.rules.inline.nolink.exec(r))){let s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[s.toLowerCase()];if(!n){let i=t[0].charAt(0);return{type:"text",raw:i,text:i}}return le(t,n,t[0],this.lexer,this.rules)}}emStrong(r,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(r);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!t||this.rules.inline.punctuation.exec(t))){let n=[...s[0]].length-1,i,l,a=n,c=0,o=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(o.lastIndex=0,e=e.slice(-1*r.length+n);(s=o.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(l=[...i].length,s[3]||s[4]){a+=l;continue}else if((s[5]||s[6])&&n%3&&!((n+l)%3)){c+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a+c);let p=[...s[0]][0].length,h=r.slice(0,n+s.index+p+l);if(Math.min(n,l)%2){let f=h.slice(1,-1);return{type:"em",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}let g=h.slice(2,-2);return{type:"strong",raw:h,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(r){let e=this.rules.inline.code.exec(r);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(t),n=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return s&&n&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(r){let e=this.rules.inline.br.exec(r);if(e)return{type:"br",raw:e[0]}}del(r,e,t=""){let s=this.rules.inline.delLDelim.exec(r);if(s&&(!s[1]||!t||this.rules.inline.punctuation.exec(t))){let n=[...s[0]].length-1,i,l,a=n,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*r.length+n);(s=c.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(l=[...i].length,l!==n))continue;if(s[3]||s[4]){a+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a);let o=[...s[0]][0].length,p=r.slice(0,n+s.index+o+l),h=p.slice(n,-n);return{type:"del",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(r){let e=this.rules.inline.autolink.exec(r);if(e){let t,s;return e[2]==="@"?(t=e[1],s="mailto:"+t):(t=e[1],s=t),{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}url(r){let e;if(e=this.rules.inline.url.exec(r)){let t,s;if(e[2]==="@")t=e[0],s="mailto:"+t;else{let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);t=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(r){let e=this.rules.inline.text.exec(r);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},b=class Q{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||T,this.options.tokenizer=this.options.tokenizer||new v,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 t={other:x,block:E.normal,inline:_.normal};this.options.pedantic?(t.block=E.pedantic,t.inline=_.pedantic):this.options.gfm&&(t.block=E.gfm,this.options.breaks?t.inline=_.breaks:t.inline=_.gfm),this.tokenizer.rules=t}static get rules(){return{block:E,inline:_}}static lex(e,t){return new Q(t).lex(e)}static lexInline(e,t){return new Q(t).inlineTokens(e)}lex(e){e=e.replace(x.carriageReturn,`\n`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(x.tabCharGlobal," ").replace(x.spaceLine,""));let n=1/0;for(;e;){if(e.length<n)n=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(a=>(i=a.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let a=t.at(-1);i.raw.length===1&&a!==void 0?a.raw+=`\n`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`\n`)?"":`\n`)+i.raw,a.text+=`\n`+i.text,this.inlineQueue.at(-1).src=a.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`\n`)?"":`\n`)+i.raw,a.text+=`\n`+i.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let l=e;if(this.options.extensions?.startBlock){let a=1/0,c=e.slice(1),o;this.options.extensions.startBlock.forEach(p=>{o=p.call({lexer:this},c),typeof o=="number"&&o>=0&&(a=Math.min(a,o))}),a<1/0&&a>=0&&(l=e.substring(0,a+1))}if(this.state.top&&(i=this.tokenizer.paragraph(l))){let a=t.at(-1);s&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`\n`)?"":`\n`)+i.raw,a.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(i),s=l.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let a=t.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`\n`)?"":`\n`)+i.raw,a.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let s=e,n=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)o.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,n.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(n=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)i=n[2]?n[2].length:0,s=s.slice(0,n.index+i)+"["+"a".repeat(n[0].length-i-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let l=!1,a="",c=1/0;for(;e;){if(e.length<c)c=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}l||(a=""),l=!1;let o;if(this.options.extensions?.inline?.some(h=>(o=h.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let h=t.at(-1);o.type==="text"&&h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,s,a)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,s,a)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let p=e;if(this.options.extensions?.startInline){let h=1/0,g=e.slice(1),f;this.options.extensions.startInline.forEach(d=>{f=d.call({lexer:this},g),typeof f=="number"&&f>=0&&(h=Math.min(h,f))}),h<1/0&&h>=0&&(p=e.substring(0,h+1))}if(o=this.tokenizer.inlineText(p)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(a=o.raw.slice(-1)),l=!0;let h=t.at(-1);h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw new Error(t)}},B=class{options;parser;constructor(r){this.options=r||T}space(r){return""}code({text:r,lang:e,escaped:t}){let s=(e||"").match(x.notSpaceStart)?.[0],n=r.replace(x.endingNewline,"")+`\n`;return s?\'<pre><code class="language-\'+m(s)+\'">\'+(t?n:m(n,!0))+`</code></pre>\n`:"<pre><code>"+(t?n:m(n,!0))+`</code></pre>\n`}blockquote({tokens:r}){return`<blockquote>\n${this.parser.parse(r)}</blockquote>\n`}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:e}){return`<h${e}>${this.parser.parseInline(r)}</h${e}>\n`}hr(r){return`<hr>\n`}list(r){let e=r.ordered,t=r.start,s="";for(let l=0;l<r.items.length;l++){let a=r.items[l];s+=this.listitem(a)}let n=e?"ol":"ul",i=e&&t!==1?\' start="\'+t+\'"\':"";return"<"+n+i+`>\n`+s+"</"+n+`>\n`}listitem(r){return`<li>${this.parser.parse(r.tokens)}</li>\n`}checkbox({checked:r}){return"<input "+(r?\'checked="" \':"")+\'disabled="" type="checkbox"> \'}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p>\n`}table(r){let e="",t="";for(let n=0;n<r.header.length;n++)t+=this.tablecell(r.header[n]);e+=this.tablerow({text:t});let s="";for(let n=0;n<r.rows.length;n++){let i=r.rows[n];t="";for(let l=0;l<i.length;l++)t+=this.tablecell(i[l]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table>\n<thead>\n`+e+`</thead>\n`+s+`</table>\n`}tablerow({text:r}){return`<tr>\n${r}</tr>\n`}tablecell(r){let e=this.parser.parseInline(r.tokens),t=r.header?"th":"td";return(r.align?`<${t} align="${r.align}">`:`<${t}>`)+e+`</${t}>\n`}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${m(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:e,tokens:t}){let s=this.parser.parseInline(t),n=ne(r);if(n===null)return s;r=n;let i=\'<a href="\'+r+\'"\';return e&&(i+=\' title="\'+m(e)+\'"\'),i+=">"+s+"</a>",i}image({href:r,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));let n=ne(r);if(n===null)return m(t);r=n;let i=`<img src="${r}" alt="${m(t)}"`;return e&&(i+=` title="${m(e)}"`),i+=">",i}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:m(r.text)}},J=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},w=class j{options;renderer;textRenderer;constructor(e){this.options=e||T,this.options.renderer=this.options.renderer||new B,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new J}static parse(e,t){return new j(t).parse(e)}static parseInline(e,t){return new j(t).parseInline(e)}parse(e){this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let n=e[s];if(this.options.extensions?.renderers?.[n.type]){let l=n,a=this.options.extensions.renderers[l.type].call({parser:this},l);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){t+=a||"";continue}}let i=n;switch(i.type){case"space":{t+=this.renderer.space(i);break}case"hr":{t+=this.renderer.hr(i);break}case"heading":{t+=this.renderer.heading(i);break}case"code":{t+=this.renderer.code(i);break}case"table":{t+=this.renderer.table(i);break}case"blockquote":{t+=this.renderer.blockquote(i);break}case"list":{t+=this.renderer.list(i);break}case"checkbox":{t+=this.renderer.checkbox(i);break}case"html":{t+=this.renderer.html(i);break}case"def":{t+=this.renderer.def(i);break}case"paragraph":{t+=this.renderer.paragraph(i);break}case"text":{t+=this.renderer.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 t}parseInline(e,t=this.renderer){this.renderer.parser=this;let s="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=a||"";continue}}let l=i;switch(l.type){case"escape":{s+=t.text(l);break}case"html":{s+=t.html(l);break}case"link":{s+=t.link(l);break}case"image":{s+=t.image(l);break}case"checkbox":{s+=t.checkbox(l);break}case"strong":{s+=t.strong(l);break}case"em":{s+=t.em(l);break}case"codespan":{s+=t.codespan(l);break}case"br":{s+=t.br(l);break}case"del":{s+=t.del(l);break}case"text":{s+=t.text(l);break}default:{let a=\'Token with "\'+l.type+\'" type was not found.\';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}},L=class{options;block;constructor(r){this.options=r||T}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(r=this.block){return r?b.lex:b.lexInline}provideParser(r=this.block){return r?w.parse:w.parseInline}},at=class{defaults=H();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=w;Renderer=B;TextRenderer=J;Lexer=b;Tokenizer=v;Hooks=L;constructor(...r){this.use(...r)}walkTokens(r,e){let t=[];for(let s of r)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let n=s;for(let i of n.header)t=t.concat(this.walkTokens(i.tokens,e));for(let i of n.rows)for(let l of i)t=t.concat(this.walkTokens(l.tokens,e));break}case"list":{let n=s;t=t.concat(this.walkTokens(n.items,e));break}default:{let n=s;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(i=>{let l=n[i].flat(1/0);t=t.concat(this.walkTokens(l,e))}):n.tokens&&(t=t.concat(this.walkTokens(n.tokens,e)))}}return t}use(...r){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(t=>{let s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let i=e.renderers[n.name];i?e.renderers[n.name]=function(...l){let a=n.renderer.apply(this,l);return a===!1&&(a=i.apply(this,l)),a}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be \'block\' or \'inline\'");let i=e[n.level];i?i.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),s.extensions=e),t.renderer){let n=this.defaults.renderer||new B(this.defaults);for(let i in t.renderer){if(!(i in n))throw new Error(`renderer \'${i}\' does not exist`);if(["options","parser"].includes(i))continue;let l=i,a=t.renderer[l],c=n[l];n[l]=(...o)=>{let p=a.apply(n,o);return p===!1&&(p=c.apply(n,o)),p||""}}s.renderer=n}if(t.tokenizer){let n=this.defaults.tokenizer||new v(this.defaults);for(let i in t.tokenizer){if(!(i in n))throw new Error(`tokenizer \'${i}\' does not exist`);if(["options","rules","lexer"].includes(i))continue;let l=i,a=t.tokenizer[l],c=n[l];n[l]=(...o)=>{let p=a.apply(n,o);return p===!1&&(p=c.apply(n,o)),p}}s.tokenizer=n}if(t.hooks){let n=this.defaults.hooks||new L;for(let i in t.hooks){if(!(i in n))throw new Error(`hook \'${i}\' does not exist`);if(["options","block"].includes(i))continue;let l=i,a=t.hooks[l],c=n[l];L.passThroughHooks.has(i)?n[l]=o=>{if(this.defaults.async&&L.passThroughHooksRespectAsync.has(i))return(async()=>{let h=await a.call(n,o);return c.call(n,h)})();let p=a.call(n,o);return c.call(n,p)}:n[l]=(...o)=>{if(this.defaults.async)return(async()=>{let h=await a.apply(n,o);return h===!1&&(h=await c.apply(n,o)),h})();let p=a.apply(n,o);return p===!1&&(p=c.apply(n,o)),p}}s.hooks=n}if(t.walkTokens){let n=this.defaults.walkTokens,i=t.walkTokens;s.walkTokens=function(l){let a=[];return a.push(i.call(this,l)),n&&(a=a.concat(n.call(this,l))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,e){return b.lex(r,e??this.defaults)}parser(r,e){return w.parse(r,e??this.defaults)}parseMarkdown(r){return(e,t)=>{let s={...t},n={...this.defaults,...s},i=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&s.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=r),n.async)return(async()=>{let l=n.hooks?await n.hooks.preprocess(e):e,a=await(n.hooks?await n.hooks.provideLexer(r):r?b.lex:b.lexInline)(l,n),c=n.hooks?await n.hooks.processAllTokens(a):a;n.walkTokens&&await Promise.all(this.walkTokens(c,n.walkTokens));let o=await(n.hooks?await n.hooks.provideParser(r):r?w.parse:w.parseInline)(c,n);return n.hooks?await n.hooks.postprocess(o):o})().catch(i);try{n.hooks&&(e=n.hooks.preprocess(e));let l=(n.hooks?n.hooks.provideLexer(r):r?b.lex:b.lexInline)(e,n);n.hooks&&(l=n.hooks.processAllTokens(l)),n.walkTokens&&this.walkTokens(l,n.walkTokens);let a=(n.hooks?n.hooks.provideParser(r):r?w.parse:w.parseInline)(l,n);return n.hooks&&(a=n.hooks.postprocess(a)),a}catch(l){return i(l)}}}onError(r,e){return t=>{if(t.message+=`\nPlease report this to https://github.com/markedjs/marked.`,r){let s="<p>An error occurred:</p><pre>"+m(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},S=new at;function k(r,e){return S.parse(r,e)}k.options=k.setOptions=function(r){return S.setOptions(r),k.defaults=S.defaults,ae(k.defaults),k};k.getDefaults=H;k.defaults=T;k.use=function(...r){return S.use(...r),k.defaults=S.defaults,ae(k.defaults),k};k.walkTokens=function(r,e){return S.walkTokens(r,e)};k.parseInline=S.parseInline;k.Parser=w;k.parser=w.parse;k.Renderer=B;k.TextRenderer=J;k.Lexer=b;k.lexer=b.lex;k.Tokenizer=v;k.Hooks=L;k.parse=k;var ot=k.options,ct=k.setOptions,ht=k.use,pt=k.walkTokens,ut=k.parseInline;var gt=w.parse,kt=b.lex;k.use({extensions:[{name:"inlineMath",level:"inline",start(r){return r.match(/\\$/)?.index},tokenizer(r){let e=/^\\$([^$]+)\\$/.exec(r);if(e)return{type:"inlineMath",raw:e[0],text:e[1].trim()}},renderer(r){return r.raw}}]});self.onmessage=r=>{let e=r.data;if(typeof e!="object"||e===null)return;let{id:t,text:s,oldRaws:n}=e;if(typeof s=="string")try{let i=k.lexer(s),l=0;if(Array.isArray(n)){let a=Math.min(n.length,i.length);for(;l<a&&n[l]===i[l].raw;l++);}self.postMessage({id:t,matchLen:l,tail:i.slice(l)})}catch(i){self.postMessage({id:t,error:String(i)})}};})();\n';
18
+
19
+ // src/Markdown.ts
20
+ marked.use({
21
+ extensions: [
22
+ {
23
+ name: "inlineMath",
24
+ level: "inline",
25
+ start(src) {
26
+ return src.match(/\$/)?.index;
27
+ },
28
+ tokenizer(src) {
29
+ const match = /^\$([^$]+)\$/.exec(src);
30
+ if (match) {
31
+ return {
32
+ type: "inlineMath",
33
+ raw: match[0],
34
+ text: match[1].trim()
35
+ };
36
+ }
37
+ return void 0;
38
+ },
39
+ renderer(token) {
40
+ return token.raw;
41
+ }
42
+ }
43
+ ]
44
+ });
45
+ var adaptor = liteAdaptor();
46
+ RegisterHTMLHandler(adaptor);
47
+ var tex = new TeX({ packages: AllPackages });
48
+ var svg = new SVG({ fontCache: "local" });
49
+ var htmlMathJax = mathjax.document("", { InputJax: tex, OutputJax: svg });
50
+ function renderMathToSVGDataURI(formula, displayMode) {
51
+ try {
52
+ const node = htmlMathJax.convert(formula, { display: displayMode });
53
+ const svgString = adaptor.innerHTML(node);
54
+ const wMatch = svgString.match(/width="([^"]+)ex"/);
55
+ const hMatch = svgString.match(/height="([^"]+)ex"/);
56
+ const wEx = wMatch ? parseFloat(wMatch[1]) : 10;
57
+ const hEx = hMatch ? parseFloat(hMatch[1]) : 2;
58
+ const width = wEx * 8;
59
+ const height = hEx * 8;
60
+ const base64 = btoa(unescape(encodeURIComponent(svgString)));
61
+ return { uri: `data:image/svg+xml;base64,${base64}`, width, height };
62
+ } catch (e) {
63
+ console.error("MathJax error", e);
64
+ return null;
65
+ }
66
+ }
67
+ var markdownWorker = null;
68
+ var workerIdCounter = 0;
69
+ var workerCallbacks = /* @__PURE__ */ new Map();
70
+ function runSyncFallback(entry) {
71
+ try {
72
+ entry.cb(0, marked.lexer(entry.text));
73
+ } catch (err) {
74
+ console.warn("Markdown sync fallback parse failed", err);
75
+ }
76
+ }
77
+ if (typeof Worker !== "undefined") {
78
+ try {
79
+ const blob = new Blob([WORKER_SOURCE_STRING], { type: "application/javascript" });
80
+ markdownWorker = new Worker(URL.createObjectURL(blob));
81
+ markdownWorker.onmessage = (e) => {
82
+ const { id, matchLen, tail, error } = e.data;
83
+ const entry = workerCallbacks.get(id);
84
+ if (entry) {
85
+ workerCallbacks.delete(id);
86
+ if (!error) entry.cb(matchLen, tail);
87
+ else runSyncFallback(entry);
88
+ }
89
+ };
90
+ markdownWorker.onerror = () => {
91
+ const pending = [...workerCallbacks.values()];
92
+ workerCallbacks.clear();
93
+ markdownWorker = null;
94
+ for (const entry of pending) runSyncFallback(entry);
95
+ };
96
+ } catch (err) {
97
+ console.warn("Failed to initialize MarkdownWorker", err);
98
+ }
99
+ }
100
+ var DEFAULT_THEME = {
101
+ textColor: "#e2e8f0",
102
+ headingColor: "#f8fafc",
103
+ codeColor: "#a5f3fc",
104
+ codeBgColor: "rgba(30, 41, 59, 0.85)",
105
+ quoteBorderColor: "#6366f1",
106
+ quoteTextColor: "#94a3b8",
107
+ hrColor: "rgba(148, 163, 184, 0.3)",
108
+ tableBgColor: "rgba(15, 15, 25, 0.4)",
109
+ tableHeaderBgColor: "rgba(255, 255, 255, 0.08)",
110
+ bodyFont: "Inter, system-ui, sans-serif",
111
+ codeFont: 'ui-monospace, "JetBrains Mono", "Fira Code", monospace',
112
+ fontSize: 16
113
+ };
114
+ var HorizontalRule = class extends Entity {
115
+ color;
116
+ constructor(w, color) {
117
+ super();
118
+ this.width = w;
119
+ this.height = 1;
120
+ this.color = color;
121
+ }
122
+ isPointInside() {
123
+ return false;
124
+ }
125
+ render(r) {
126
+ r.beginPath();
127
+ r.moveTo(0, 0);
128
+ r.lineTo(this.width, 0);
129
+ r.stroke(this.color, 1);
130
+ }
131
+ };
132
+ var QuoteBorder = class extends Entity {
133
+ color;
134
+ constructor(height, color) {
135
+ super();
136
+ this.width = 4;
137
+ this.height = height;
138
+ this.color = color;
139
+ }
140
+ isPointInside() {
141
+ return false;
142
+ }
143
+ render(r) {
144
+ r.beginPath();
145
+ r.roundRect(0, 0, this.width, this.height, 2);
146
+ r.fill(this.color);
147
+ }
148
+ };
149
+ var MarkdownContainer = class extends Entity {
150
+ isPointInside(_globalX, _globalY) {
151
+ return false;
152
+ }
153
+ render(_r) {
154
+ }
155
+ };
156
+ var KEYWORD_SETS = {
157
+ js: /* @__PURE__ */ new Set([
158
+ "const",
159
+ "let",
160
+ "var",
161
+ "function",
162
+ "return",
163
+ "if",
164
+ "else",
165
+ "for",
166
+ "while",
167
+ "class",
168
+ "extends",
169
+ "new",
170
+ "this",
171
+ "import",
172
+ "export",
173
+ "from",
174
+ "default",
175
+ "async",
176
+ "await",
177
+ "try",
178
+ "catch",
179
+ "throw",
180
+ "of",
181
+ "in",
182
+ "typeof",
183
+ "instanceof",
184
+ "switch",
185
+ "case",
186
+ "break",
187
+ "continue",
188
+ "null",
189
+ "undefined",
190
+ "true",
191
+ "false"
192
+ ]),
193
+ ts: /* @__PURE__ */ new Set([
194
+ "const",
195
+ "let",
196
+ "var",
197
+ "function",
198
+ "return",
199
+ "if",
200
+ "else",
201
+ "for",
202
+ "while",
203
+ "class",
204
+ "extends",
205
+ "new",
206
+ "this",
207
+ "import",
208
+ "export",
209
+ "from",
210
+ "default",
211
+ "async",
212
+ "await",
213
+ "try",
214
+ "catch",
215
+ "throw",
216
+ "of",
217
+ "in",
218
+ "typeof",
219
+ "instanceof",
220
+ "switch",
221
+ "case",
222
+ "break",
223
+ "continue",
224
+ "null",
225
+ "undefined",
226
+ "true",
227
+ "false",
228
+ "type",
229
+ "interface",
230
+ "enum",
231
+ "as",
232
+ "is",
233
+ "readonly",
234
+ "implements",
235
+ "abstract",
236
+ "public",
237
+ "private",
238
+ "protected",
239
+ "static",
240
+ "void",
241
+ "never",
242
+ "any",
243
+ "unknown"
244
+ ]),
245
+ py: /* @__PURE__ */ new Set([
246
+ "def",
247
+ "class",
248
+ "return",
249
+ "if",
250
+ "elif",
251
+ "else",
252
+ "for",
253
+ "while",
254
+ "import",
255
+ "from",
256
+ "as",
257
+ "with",
258
+ "try",
259
+ "except",
260
+ "raise",
261
+ "finally",
262
+ "pass",
263
+ "break",
264
+ "continue",
265
+ "and",
266
+ "or",
267
+ "not",
268
+ "in",
269
+ "is",
270
+ "None",
271
+ "True",
272
+ "False",
273
+ "yield",
274
+ "lambda",
275
+ "global",
276
+ "nonlocal",
277
+ "del",
278
+ "assert",
279
+ "async",
280
+ "await"
281
+ ]),
282
+ rust: /* @__PURE__ */ new Set([
283
+ "fn",
284
+ "let",
285
+ "mut",
286
+ "const",
287
+ "if",
288
+ "else",
289
+ "for",
290
+ "while",
291
+ "loop",
292
+ "match",
293
+ "return",
294
+ "struct",
295
+ "enum",
296
+ "impl",
297
+ "trait",
298
+ "pub",
299
+ "use",
300
+ "mod",
301
+ "crate",
302
+ "self",
303
+ "super",
304
+ "where",
305
+ "as",
306
+ "in",
307
+ "ref",
308
+ "move",
309
+ "async",
310
+ "await",
311
+ "true",
312
+ "false",
313
+ "type",
314
+ "unsafe",
315
+ "extern",
316
+ "dyn",
317
+ "static"
318
+ ])
319
+ };
320
+ KEYWORD_SETS["javascript"] = KEYWORD_SETS["js"];
321
+ KEYWORD_SETS["typescript"] = KEYWORD_SETS["ts"];
322
+ KEYWORD_SETS["python"] = KEYWORD_SETS["py"];
323
+ KEYWORD_SETS["rs"] = KEYWORD_SETS["rust"];
324
+ function highlightLine(line, lang, theme) {
325
+ const keywords = KEYWORD_SETS[lang];
326
+ if (!keywords) {
327
+ return [{ text: line, color: theme.codeColor }];
328
+ }
329
+ const segments = [];
330
+ const KEYWORD_COLOR = "#c084fc";
331
+ const STRING_COLOR = "#86efac";
332
+ const COMMENT_COLOR = "#64748b";
333
+ const NUMBER_COLOR = "#fbbf24";
334
+ let i = 0;
335
+ let buf = "";
336
+ const flush = (color) => {
337
+ if (buf) {
338
+ segments.push({ text: buf, color });
339
+ buf = "";
340
+ }
341
+ };
342
+ while (i < line.length) {
343
+ const ch = line[i];
344
+ if (ch === "/" && line[i + 1] === "/") {
345
+ flush(theme.codeColor);
346
+ segments.push({ text: line.slice(i), color: COMMENT_COLOR });
347
+ return segments;
348
+ }
349
+ if (ch === "#" && (lang === "py" || lang === "python" || lang === "rust" || lang === "rs")) {
350
+ flush(theme.codeColor);
351
+ segments.push({ text: line.slice(i), color: COMMENT_COLOR });
352
+ return segments;
353
+ }
354
+ if (ch === '"' || ch === "'" || ch === "`") {
355
+ flush(theme.codeColor);
356
+ const quote = ch;
357
+ let j = i + 1;
358
+ while (j < line.length && line[j] !== quote) {
359
+ if (line[j] === "\\") j++;
360
+ j++;
361
+ }
362
+ j++;
363
+ segments.push({ text: line.slice(i, j), color: STRING_COLOR });
364
+ i = j;
365
+ continue;
366
+ }
367
+ if (/\d/.test(ch) && (i === 0 || /[\s(,=+\-*/<>[\]{}:;]/.test(line[i - 1]))) {
368
+ flush(theme.codeColor);
369
+ let j = i;
370
+ while (j < line.length && /[\d._xXa-fA-F]/.test(line[j])) j++;
371
+ segments.push({ text: line.slice(i, j), color: NUMBER_COLOR });
372
+ i = j;
373
+ continue;
374
+ }
375
+ if (/[a-zA-Z_]/.test(ch)) {
376
+ flush(theme.codeColor);
377
+ let j = i;
378
+ while (j < line.length && /[a-zA-Z0-9_]/.test(line[j])) j++;
379
+ const word = line.slice(i, j);
380
+ segments.push({ text: word, color: keywords.has(word) ? KEYWORD_COLOR : theme.codeColor });
381
+ i = j;
382
+ continue;
383
+ }
384
+ buf += ch;
385
+ i++;
386
+ }
387
+ flush(theme.codeColor);
388
+ return segments;
389
+ }
390
+ var CodeBlock = class extends UIComponent {
391
+ lines;
392
+ grid = null;
393
+ cellWidth = 0;
394
+ source;
395
+ lang;
396
+ theme;
397
+ lineH = 24;
398
+ pad = 18;
399
+ codeFont;
400
+ selectable;
401
+ constructor(code, lang, maxWidth, theme, selectable = true) {
402
+ super();
403
+ this.source = code;
404
+ this.lang = lang;
405
+ this.theme = theme;
406
+ this.codeFont = `15px ${theme.codeFont}`;
407
+ this.selectable = selectable;
408
+ this.lines = [];
409
+ this.width = maxWidth;
410
+ this.buildLines(code);
411
+ }
412
+ /** Re-parse code content (e.g. for live editing). */
413
+ setCode(code, lang) {
414
+ if (lang !== void 0) this.lang = lang;
415
+ this.source = code;
416
+ this.buildLines(code);
417
+ this.scene?.markDirty();
418
+ return this;
419
+ }
420
+ /** Enable or disable browser-native selection for this code block. */
421
+ setSelectable(selectable) {
422
+ this.selectable = selectable;
423
+ this.scene?.markDirty();
424
+ return this;
425
+ }
426
+ getContentProjection() {
427
+ if (!this.source) return null;
428
+ const grid = this.ensureGrid();
429
+ return {
430
+ text: this.source,
431
+ font: this.codeFont,
432
+ lineHeight: this.lineH,
433
+ // Every row is absolutely positioned from the same local coordinates as
434
+ // render(). A single pre-wrap DOM text node would introduce browser
435
+ // wrapping for long source lines that canvas intentionally keeps intact.
436
+ lines: grid.lines.map((line, row) => ({
437
+ text: this.source.slice(line.sourceStart, line.sourceEnd),
438
+ separatorAfter: this.source.slice(line.sourceEnd, line.nextSourceStart) || void 0,
439
+ x: this.pad,
440
+ y: this.pad + row * this.lineH,
441
+ baseline: this.lineH * 0.75,
442
+ font: this.codeFont,
443
+ lineHeight: this.lineH
444
+ })),
445
+ selectable: this.selectable,
446
+ // render() draws cell-by-cell (no ligatures can form); the DOM copy
447
+ // must not ligate either or Firefox selection geometry drifts.
448
+ ligatures: "none",
449
+ grid
450
+ };
451
+ }
452
+ buildLines(code) {
453
+ const rawLines = code.split(/\r\n|\r|\n/);
454
+ this.lines = rawLines.map((l) => highlightLine(l, this.lang, this.theme));
455
+ this.grid = null;
456
+ this.height = this.pad * 2 + rawLines.length * this.lineH;
457
+ }
458
+ ensureGrid() {
459
+ const cellWidth = this.cellWidth || Math.max(1, measureText("M", this.codeFont));
460
+ if (!this.grid || this.grid.source !== this.source || this.grid.font !== this.codeFont || this.grid.cellWidth !== cellWidth) {
461
+ this.grid = prepareContentGrid(this.source, {
462
+ font: this.codeFont,
463
+ cellWidth,
464
+ lineHeight: this.lineH,
465
+ baseline: this.lineH * 0.75
466
+ });
467
+ }
468
+ return this.grid;
469
+ }
470
+ /** Code blocks are decorative — not interactive. */
471
+ isPointInside() {
472
+ return false;
473
+ }
474
+ render(r) {
475
+ r.beginPath();
476
+ r.roundRect(0, 0, this.width, this.height, 8);
477
+ r.fill(this.theme.codeBgColor);
478
+ const grid = this.ensureGrid();
479
+ for (let row = 0; row < grid.lines.length; row++) {
480
+ const yBaseline = this.pad + row * this.lineH + this.lineH * 0.75;
481
+ const segments = this.lines[row];
482
+ let segmentIndex = 0;
483
+ let segmentEnd = segments[0]?.text.length ?? 0;
484
+ const lineStart = grid.lines[row].sourceStart;
485
+ for (const cell of grid.lines[row].cells) {
486
+ const localSourceStart = cell.sourceStart - lineStart;
487
+ while (segmentIndex < segments.length - 1 && localSourceStart >= segmentEnd) {
488
+ segmentIndex++;
489
+ segmentEnd += segments[segmentIndex].text.length;
490
+ }
491
+ const sourceText = this.source.slice(cell.sourceStart, cell.sourceEnd);
492
+ if (cell.advance <= 0 || sourceText === " " || sourceText === " ") continue;
493
+ r.fillText(
494
+ cell.glyph,
495
+ this.pad + cell.x,
496
+ yBaseline,
497
+ this.codeFont,
498
+ segments[segmentIndex]?.color ?? this.theme.codeColor
499
+ );
500
+ }
501
+ }
502
+ }
503
+ };
504
+ function decodeEntities(text) {
505
+ return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, "&");
506
+ }
507
+ function collectSpans(tokens, inherited, theme, out) {
508
+ for (const token of tokens) {
509
+ switch (token.type) {
510
+ case "strong": {
511
+ const t = token;
512
+ if (t.tokens) {
513
+ collectSpans(t.tokens, { ...inherited, bold: true }, theme, out);
514
+ } else {
515
+ out.push({ text: decodeEntities(t.text), style: { ...inherited, bold: true } });
516
+ }
517
+ break;
518
+ }
519
+ case "em": {
520
+ const t = token;
521
+ if (t.tokens) {
522
+ collectSpans(t.tokens, { ...inherited, italic: true }, theme, out);
523
+ } else {
524
+ out.push({ text: decodeEntities(t.text), style: { ...inherited, italic: true } });
525
+ }
526
+ break;
527
+ }
528
+ case "codespan": {
529
+ const t = token;
530
+ out.push({ text: decodeEntities(t.text), style: { ...inherited, color: theme.codeColor } });
531
+ break;
532
+ }
533
+ case "br": {
534
+ out.push({ text: "\n" });
535
+ break;
536
+ }
537
+ case "html": {
538
+ const t = token;
539
+ const raw = t.raw ?? t.text ?? "";
540
+ const brCount = (raw.match(/<br\s*\/?>/gi) ?? []).length;
541
+ for (let i = 0; i < brCount; i++) out.push({ text: "\n" });
542
+ break;
543
+ }
544
+ case "inlineMath": {
545
+ const t = token;
546
+ out.push({ text: decodeEntities(t.raw), style: { ...inherited, color: "#fcd34d" } });
547
+ break;
548
+ }
549
+ case "link": {
550
+ const t = token;
551
+ const linkStyle = { ...inherited, href: t.href, color: "#38bdf8" };
552
+ if (t.tokens && t.tokens.length > 0) {
553
+ collectSpans(t.tokens, linkStyle, theme, out);
554
+ } else {
555
+ out.push({ text: decodeEntities(t.text), style: linkStyle });
556
+ }
557
+ break;
558
+ }
559
+ case "text": {
560
+ const t = token;
561
+ if ("tokens" in t && t.tokens?.length) {
562
+ collectSpans(t.tokens, inherited, theme, out);
563
+ } else {
564
+ const decoded = decodeEntities(t.text);
565
+ if (decoded) {
566
+ const style = Object.keys(inherited).length > 0 ? inherited : void 0;
567
+ out.push({ text: decoded, style });
568
+ }
569
+ }
570
+ break;
571
+ }
572
+ default: {
573
+ if ("text" in token) {
574
+ const decoded = decodeEntities(token.text);
575
+ if (decoded) {
576
+ const style = Object.keys(inherited).length > 0 ? inherited : void 0;
577
+ out.push({ text: decoded, style });
578
+ }
579
+ }
580
+ break;
581
+ }
582
+ }
583
+ }
584
+ }
585
+ function renderInlineToRichText(tokens, fallbackText, font, color, maxWidth, theme, selectable, onLinkClick) {
586
+ const spans = [];
587
+ if (tokens && tokens.length > 0) {
588
+ collectSpans(tokens, {}, theme, spans);
589
+ }
590
+ if (spans.length === 0) {
591
+ spans.push({ text: decodeEntities(fallbackText) });
592
+ }
593
+ return new RichText(spans, {
594
+ font,
595
+ color,
596
+ maxWidth,
597
+ linkColor: "#38bdf8",
598
+ selectable,
599
+ onLinkClick
600
+ });
601
+ }
602
+ var Markdown = class extends UIComponent {
603
+ content;
604
+ maxWidth;
605
+ theme;
606
+ onLinkClick;
607
+ selectable;
608
+ onLayoutUpdated;
609
+ rawMarkdown;
610
+ tokens;
611
+ // At most one worker lex request in flight at a time. Required for the
612
+ // delta-transfer protocol below to be safe: the request captures a
613
+ // snapshot of `this.tokens` to reconstruct the full array from the
614
+ // worker's (matchLen, tail) response, and that snapshot would go stale if
615
+ // another request's callback could run — and mutate `this.tokens` — while
616
+ // this one is still pending. `appendPending` means "more text arrived
617
+ // while a request was in flight"; the in-flight callback re-dispatches
618
+ // with the latest accumulated text once it resolves.
619
+ appendInFlight = false;
620
+ appendPending = false;
621
+ constructor(markdownText, opts = {}) {
622
+ super();
623
+ this.maxWidth = opts.maxWidth ?? 800;
624
+ this.theme = { ...DEFAULT_THEME, ...opts.theme };
625
+ this.onLinkClick = opts.onLinkClick;
626
+ this.selectable = opts.selectable ?? true;
627
+ this.content = new Stack({ direction: "vertical", gap: 16 });
628
+ this.add(this.content);
629
+ this.rawMarkdown = markdownText;
630
+ this.tokens = [];
631
+ this.renderMarkdown(markdownText);
632
+ }
633
+ renderMarkdown(text) {
634
+ const tokens = marked.lexer(text);
635
+ this.tokens = tokens;
636
+ for (const token of tokens) {
637
+ const el = this.renderToken(token);
638
+ if (el) {
639
+ this.content.add(el);
640
+ }
641
+ }
642
+ this.width = this.content.width;
643
+ this.height = this.content.height;
644
+ }
645
+ /** Replace all markdown content (full rebuild). */
646
+ setContent(markdown) {
647
+ this.rawMarkdown = markdown;
648
+ while (this.content.children.length > 0) {
649
+ this.content.remove(this.content.children[this.content.children.length - 1]);
650
+ }
651
+ this.tokens = [];
652
+ this.renderMarkdown(markdown);
653
+ return this;
654
+ }
655
+ /** Enable or disable native selection for existing and future Markdown text. */
656
+ setSelectable(selectable) {
657
+ this.selectable = selectable;
658
+ const apply = (entity) => {
659
+ const candidate = entity;
660
+ candidate.setSelectable?.(selectable);
661
+ for (const child of entity.children) apply(child);
662
+ };
663
+ for (const child of this.content.children) apply(child);
664
+ this.scene?.markDirty();
665
+ return this;
666
+ }
667
+ /** Append a markdown chunk incrementally. Reuses unchanged prefix entities. */
668
+ appendMarkdown(chunk) {
669
+ this.rawMarkdown += chunk;
670
+ if (!markdownWorker) {
671
+ const newTokens = marked.lexer(this.rawMarkdown);
672
+ this.updateTokens(newTokens);
673
+ return this;
674
+ }
675
+ if (this.appendInFlight) {
676
+ this.appendPending = true;
677
+ return this;
678
+ }
679
+ this.dispatchAppend();
680
+ return this;
681
+ }
682
+ dispatchAppend() {
683
+ if (!markdownWorker) return;
684
+ this.appendInFlight = true;
685
+ const id = workerIdCounter++;
686
+ const oldTokensSnapshot = this.tokens;
687
+ const oldRaws = oldTokensSnapshot.map((t) => t.raw);
688
+ workerCallbacks.set(id, {
689
+ cb: (matchLen, tail) => {
690
+ this.appendInFlight = false;
691
+ const newTokens = [...oldTokensSnapshot.slice(0, matchLen), ...tail];
692
+ this.updateTokens(newTokens);
693
+ if (this.appendPending) {
694
+ this.appendPending = false;
695
+ this.dispatchAppend();
696
+ }
697
+ },
698
+ text: this.rawMarkdown
699
+ });
700
+ markdownWorker.postMessage({ id, text: this.rawMarkdown, oldRaws });
701
+ }
702
+ updateTokens(newTokens) {
703
+ const oldTokens = this.tokens;
704
+ const oldChildren = [...this.content.children];
705
+ let matchLen = 0;
706
+ const minLen = Math.min(oldTokens.length, newTokens.length);
707
+ let childIdx = 0;
708
+ const oldTokenToChild = [];
709
+ for (let i = 0; i < oldTokens.length; i++) {
710
+ oldTokenToChild.push(childIdx);
711
+ if (oldTokens[i].type !== "space") childIdx++;
712
+ }
713
+ for (let i = 0; i < minLen; i++) {
714
+ if (oldTokens[i].raw === newTokens[i].raw) {
715
+ matchLen++;
716
+ } else {
717
+ break;
718
+ }
719
+ }
720
+ if (matchLen === oldTokens.length - 1 && matchLen < newTokens.length && oldTokens[matchLen]?.type === newTokens[matchLen]?.type && newTokens[matchLen]?.type === "paragraph") {
721
+ const entityIdx = oldTokenToChild[matchLen];
722
+ const existingEntity = oldChildren[entityIdx];
723
+ if (existingEntity && "setSpans" in existingEntity) {
724
+ const pToken = newTokens[matchLen];
725
+ const t = this.theme;
726
+ const spans = [];
727
+ if (pToken.tokens && pToken.tokens.length > 0) {
728
+ collectSpans(pToken.tokens, {}, t, spans);
729
+ }
730
+ if (spans.length === 0) {
731
+ spans.push({ text: pToken.text });
732
+ }
733
+ existingEntity.setSpans(spans);
734
+ matchLen++;
735
+ this.content.resizeLastChild(existingEntity);
736
+ }
737
+ }
738
+ for (let i = 0; i < oldTokens.length; i++) {
739
+ if (i >= matchLen && oldTokens[i].type !== "space") {
740
+ const idx = oldTokenToChild[i];
741
+ if (idx < oldChildren.length) {
742
+ this.content.remove(oldChildren[idx]);
743
+ }
744
+ }
745
+ }
746
+ for (let i = matchLen; i < newTokens.length; i++) {
747
+ const el = this.renderToken(newTokens[i]);
748
+ if (el) this.content.add(el);
749
+ }
750
+ this.tokens = newTokens;
751
+ this.width = this.content.width;
752
+ this.height = this.content.height;
753
+ this.scene?.markDirty();
754
+ if (this.onLayoutUpdated) {
755
+ this.onLayoutUpdated();
756
+ }
757
+ }
758
+ renderToken(token) {
759
+ const t = this.theme;
760
+ const bodyFont = `${t.fontSize}px ${t.bodyFont}`;
761
+ switch (token.type) {
762
+ // ── Headings ─────────────────────────────────────────────────────
763
+ case "heading": {
764
+ const hToken = token;
765
+ const sizes = [32, 28, 24, 20, 18, 16];
766
+ const size = sizes[Math.min(hToken.depth - 1, 5)];
767
+ const headingFont = `bold ${size}px ${t.bodyFont}`;
768
+ return renderInlineToRichText(
769
+ hToken.tokens,
770
+ hToken.text,
771
+ headingFont,
772
+ t.headingColor,
773
+ this.maxWidth,
774
+ t,
775
+ this.selectable,
776
+ this.onLinkClick
777
+ );
778
+ }
779
+ // ── Paragraphs ───────────────────────────────────────────────────
780
+ case "paragraph": {
781
+ const pToken = token;
782
+ if (!pToken.tokens || !pToken.tokens.some((t2) => t2.type === "image")) {
783
+ return renderInlineToRichText(
784
+ pToken.tokens,
785
+ pToken.text,
786
+ bodyFont,
787
+ t.textColor,
788
+ this.maxWidth,
789
+ t,
790
+ this.selectable,
791
+ this.onLinkClick
792
+ );
793
+ }
794
+ const stack = new Stack({ direction: "vertical", gap: 16, maxWidth: this.maxWidth });
795
+ let currentTokens = [];
796
+ const flushText = () => {
797
+ if (currentTokens.length > 0) {
798
+ stack.add(
799
+ renderInlineToRichText(
800
+ currentTokens,
801
+ "",
802
+ bodyFont,
803
+ t.textColor,
804
+ this.maxWidth,
805
+ t,
806
+ this.selectable,
807
+ this.onLinkClick
808
+ )
809
+ );
810
+ currentTokens = [];
811
+ }
812
+ };
813
+ for (const child of pToken.tokens) {
814
+ if (child.type === "image") {
815
+ flushText();
816
+ const imgToken = child;
817
+ const initialWidth = Math.min(800, this.maxWidth);
818
+ const initialHeight = Math.round(initialWidth * 0.6);
819
+ const img = new Image(imgToken.href, {
820
+ width: initialWidth,
821
+ height: initialHeight,
822
+ alt: imgToken.text,
823
+ radius: 8,
824
+ onLoad: () => {
825
+ const bmp = img.bitmap;
826
+ if (bmp && bmp.naturalWidth && bmp.naturalHeight) {
827
+ const aspect = bmp.naturalHeight / bmp.naturalWidth;
828
+ img.width = Math.min(bmp.naturalWidth, this.maxWidth);
829
+ img.height = Math.round(img.width * aspect);
830
+ if (this.scene) this.scene.markDirty();
831
+ }
832
+ }
833
+ });
834
+ stack.add(img);
835
+ } else {
836
+ currentTokens.push(child);
837
+ }
838
+ }
839
+ flushText();
840
+ return stack;
841
+ }
842
+ // ── Code blocks ──────────────────────────────────────────────────
843
+ case "code": {
844
+ const codeToken = token;
845
+ const lang = (codeToken.lang ?? "").toLowerCase();
846
+ if (lang === "math" || lang === "latex" || lang === "tex") {
847
+ const mathData = renderMathToSVGDataURI(codeToken.text, true);
848
+ if (mathData) {
849
+ const mathImg = new Image(mathData.uri, {
850
+ width: Math.min(this.maxWidth, mathData.width),
851
+ height: mathData.height * Math.min(1, this.maxWidth / mathData.width),
852
+ alt: codeToken.text
853
+ });
854
+ const wrapper = new MarkdownContainer();
855
+ mathImg.x = 16;
856
+ mathImg.y = 8;
857
+ wrapper.add(mathImg);
858
+ wrapper.width = mathImg.width + 16;
859
+ wrapper.height = mathImg.height + 16;
860
+ return wrapper;
861
+ }
862
+ }
863
+ return new CodeBlock(codeToken.text, lang, this.maxWidth, t, this.selectable);
864
+ }
865
+ // ── Blockquotes ──────────────────────────────────────────────────
866
+ case "blockquote": {
867
+ const bqToken = token;
868
+ const innerStack = new Stack({ direction: "vertical", gap: 8 });
869
+ if (bqToken.tokens) {
870
+ for (const inner of bqToken.tokens) {
871
+ const el = this.renderToken(inner);
872
+ if (el) {
873
+ const wrapper = new MarkdownContainer();
874
+ el.x = 16;
875
+ wrapper.add(el);
876
+ wrapper.width = el.width + 16;
877
+ wrapper.height = el.height;
878
+ innerStack.add(wrapper);
879
+ }
880
+ }
881
+ }
882
+ const border = new QuoteBorder(innerStack.height || 20, t.quoteBorderColor);
883
+ const container = new MarkdownContainer();
884
+ border.x = 0;
885
+ border.y = 0;
886
+ container.add(border);
887
+ innerStack.y = 0;
888
+ innerStack.x = 0;
889
+ container.add(innerStack);
890
+ container.width = this.maxWidth;
891
+ container.height = Math.max(border.height, innerStack.height);
892
+ return container;
893
+ }
894
+ // ── Lists ────────────────────────────────────────────────────────
895
+ case "list": {
896
+ const listToken = token;
897
+ const listStack = new Stack({ direction: "vertical", gap: 6 });
898
+ for (let i = 0; i < listToken.items.length; i++) {
899
+ const item = listToken.items[i];
900
+ const bullet = listToken.ordered ? `${Number(listToken.start ?? 1) + i}. ` : "\u2022 ";
901
+ const itemSpans = [{ text: bullet }];
902
+ if (item.tokens && item.tokens.length > 0) {
903
+ for (const inner of item.tokens) {
904
+ if (inner.type === "text" && "tokens" in inner && inner.tokens?.length) {
905
+ collectSpans(inner.tokens, {}, t, itemSpans);
906
+ } else if ("tokens" in inner && inner.tokens?.length) {
907
+ collectSpans(inner.tokens, {}, t, itemSpans);
908
+ } else if ("text" in inner) {
909
+ itemSpans.push({ text: decodeEntities(inner.text) });
910
+ }
911
+ }
912
+ } else {
913
+ itemSpans.push({ text: decodeEntities(item.text) });
914
+ }
915
+ const itemRt = new RichText(itemSpans, {
916
+ font: bodyFont,
917
+ color: t.textColor,
918
+ maxWidth: this.maxWidth - 24,
919
+ linkColor: "#38bdf8",
920
+ selectable: this.selectable,
921
+ onLinkClick: this.onLinkClick
922
+ });
923
+ itemRt.x = 12;
924
+ listStack.add(itemRt);
925
+ }
926
+ return listStack;
927
+ }
928
+ // ── Table ────────────────────────────────────────────────────────
929
+ case "table": {
930
+ const tblToken = token;
931
+ const buildCell = (cell, header) => {
932
+ const spans = [];
933
+ collectSpans(cell.tokens, {}, t, spans);
934
+ if (spans.length === 0) return decodeEntities(cell.text);
935
+ return new RichText(spans, {
936
+ font: `${t.fontSize - 2}px ${t.bodyFont}`,
937
+ color: header ? t.headingColor : t.textColor,
938
+ baseStyle: header ? { bold: true } : void 0,
939
+ linkColor: "#38bdf8",
940
+ selectable: this.selectable,
941
+ onLinkClick: this.onLinkClick
942
+ });
943
+ };
944
+ const headers = tblToken.header.map((cell) => buildCell(cell, true));
945
+ const rows = tblToken.rows.map((row) => row.map((cell) => buildCell(cell, false)));
946
+ return new Table({
947
+ headers,
948
+ rows,
949
+ width: this.maxWidth,
950
+ textColor: t.textColor,
951
+ headerTextColor: t.headingColor,
952
+ font: `${t.fontSize - 2}px ${t.bodyFont}`,
953
+ borderColor: t.hrColor,
954
+ bg: t.tableBgColor,
955
+ headerBg: t.tableHeaderBgColor,
956
+ selectable: this.selectable
957
+ });
958
+ }
959
+ // ── Horizontal rule ──────────────────────────────────────────────
960
+ case "hr":
961
+ return new HorizontalRule(this.maxWidth, t.hrColor);
962
+ // ── Whitespace ───────────────────────────────────────────────────
963
+ case "space":
964
+ return null;
965
+ // ── HTML (Support raw SVGs) ──────────────────────────────────────
966
+ case "html": {
967
+ const htmlToken = token;
968
+ if (htmlToken.text.toLowerCase().includes("<svg") && htmlToken.text.toLowerCase().includes("</svg>")) {
969
+ return new SVGEntity(htmlToken.text);
970
+ }
971
+ return null;
972
+ }
973
+ // ── Fallback ─────────────────────────────────────────────────────
974
+ default:
975
+ if ("text" in token) {
976
+ return new Text(token.text, {
977
+ font: bodyFont,
978
+ color: t.textColor,
979
+ maxWidth: this.maxWidth,
980
+ lineHeight: 24,
981
+ selectable: this.selectable
982
+ });
983
+ }
984
+ return null;
985
+ }
986
+ }
987
+ /** Structural — children draw themselves. */
988
+ render(_r) {
989
+ }
990
+ };
991
+ export {
992
+ CodeBlock,
993
+ Markdown
994
+ };