@arcgis/coding-components
Version:
Contains components for editing code in different languages. The currently supported languages are html, css, json, TypeScript, JavaScript, and Arcade.
50 lines (49 loc) • 40.3 kB
JavaScript
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
v4.33.14 */
import{k as X}from"./ESHR3OJV.js";import{ck as F,jk as Q,kk as se,pk as B}from"./GMVUIEZO.js";se();async function re(i,t){return await(await X()).colorize(i,t,{tabSize:2})}async function Se(i,t){if(!i)return;let n=Array.from(i.querySelectorAll("code.language-arcade, code.language-sql"),async e=>await ie(e,e.textContent,t));await Promise.all(n)}async function ie(i,t,n){!i||i.tagName!=="CODE"||(i.innerHTML=await re(t??"",n))}function Re(){let i=B.get(Q).getColorTheme();return F(i.tokenTheme.getColorMap())}function Te(i){return B.get(Q).onDidColorThemeChange(()=>i())}function H(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}var I=H();function Y(i){I=i}var ee=/[&<>"']/,le=new RegExp(ee.source,"g"),te=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ae=new RegExp(te.source,"g"),oe={"&":"&","<":"<",">":">",'"':""","'":"'"},G=i=>oe[i];function w(i,t){if(t){if(ee.test(i))return i.replace(le,G)}else if(te.test(i))return i.replace(ae,G);return i}var ce=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ne(i){return i.replace(ce,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}var he=/(^|[^\[])\^/g;function m(i,t){i=typeof i=="string"?i:i.source,t=t||"";let n={replace:(e,s)=>(s=s.source||s,s=s.replace(he,"$1"),i=i.replace(e,s),n),getRegex:()=>new RegExp(i,t)};return n}var pe=/[^\w:]/g,ue=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function V(i,t,n){if(i){let e;try{e=decodeURIComponent(ne(n)).replace(pe,"").toLowerCase()}catch{return null}if(e.indexOf("javascript:")===0||e.indexOf("vbscript:")===0||e.indexOf("data:")===0)return null}t&&!ue.test(n)&&(n=fe(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}var O={},ge=/^[^:]+:\/*[^/]*$/,de=/^([^:]+:)[\s\S]*$/,ke=/^([^:]+:\/*[^/]*)[\s\S]*$/;function fe(i,t){O[" "+i]||(ge.test(i)?O[" "+i]=i+"/":O[" "+i]=U(i,"/",!0)),i=O[" "+i];let n=i.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:i.replace(de,"$1")+t:t.charAt(0)==="/"?n?t:i.replace(ke,"$1")+t:i+t}var j={exec:function(){}};function J(i,t){let n=i.replace(/\|/g,(r,l,a)=>{let c=!1,u=l;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),e=n.split(/ \|/),s=0;if(e[0].trim()||e.shift(),e.length>0&&!e[e.length-1].trim()&&e.pop(),e.length>t)e.splice(t);else for(;e.length<t;)e.push("");for(;s<e.length;s++)e[s]=e[s].trim().replace(/\\\|/g,"|");return e}function U(i,t,n){let e=i.length;if(e===0)return"";let s=0;for(;s<e;){let r=i.charAt(e-s-1);if(r===t&&!n)s++;else if(r!==t&&n)s++;else break}return i.slice(0,e-s)}function me(i,t){if(i.indexOf(t[1])===-1)return-1;let n=i.length,e=0,s=0;for(;s<n;s++)if(i[s]==="\\")s++;else if(i[s]===t[0])e++;else if(i[s]===t[1]&&(e--,e<0))return s;return-1}function xe(i,t){!i||i.silent||(t&&console.warn("marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async"),(i.sanitize||i.sanitizer)&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options"),(i.highlight||i.langPrefix!=="language-")&&console.warn("marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight."),i.mangle&&console.warn("marked(): mangle parameter is enabled by default, but is deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-mangle, or disable by setting `{mangle: false}`."),i.baseUrl&&console.warn("marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url."),i.smartypants&&console.warn("marked(): smartypants parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-smartypants."),i.xhtml&&console.warn("marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml."),(i.headerIds||i.headerPrefix)&&console.warn("marked(): headerIds and headerPrefix parameters enabled by default, but are deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-gfm-heading-id, or disable by setting `{headerIds: false}`."))}function K(i,t,n,e){let s=t.href,r=t.title?w(t.title):null,l=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){e.state.inLink=!0;let a={type:"link",raw:n,href:s,title:r,text:l,tokens:e.inlineTokens(l)};return e.state.inLink=!1,a}return{type:"image",raw:n,href:s,title:r,text:w(l)}}function be(i,t){let n=i.match(/^(\s+)(?:```)/);if(n===null)return t;let e=n[1];return t.split(`
`).map(s=>{let r=s.match(/^\s+/);if(r===null)return s;let[l]=r;return l.length>=e.length?s.slice(e.length):s}).join(`
`)}var C=class{constructor(t){this.options=t||I}space(t){let n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){let n=this.rules.block.code.exec(t);if(n){let e=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?e:U(e,`
`)}}}fences(t){let n=this.rules.block.fences.exec(t);if(n){let e=n[0],s=be(e,n[3]||"");return{type:"code",raw:e,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:s}}}heading(t){let n=this.rules.block.heading.exec(t);if(n){let e=n[2].trim();if(/#$/.test(e)){let s=U(e,"#");(this.options.pedantic||!s||/ $/.test(s))&&(e=s.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(t){let n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){let n=this.rules.block.blockquote.exec(t);if(n){let e=n[0].replace(/^ *>[ \t]?/gm,""),s=this.lexer.state.top;this.lexer.state.top=!0;let r=this.lexer.blockTokens(e);return this.lexer.state.top=s,{type:"blockquote",raw:n[0],tokens:r,text:e}}}list(t){let n=this.rules.block.list.exec(t);if(n){let e,s,r,l,a,c,u,g,k,d,h,y,_=n[1].trim(),A=_.length>1,x={type:"list",raw:"",ordered:A,start:A?+_.slice(0,-1):"",loose:!1,items:[]};_=A?`\\d{1,9}\\${_.slice(-1)}`:`\\${_}`,this.options.pedantic&&(_=A?_:"[*+-]");let b=new RegExp(`^( {0,3}${_})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(y=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(e=n[0],t=t.substring(e.length),g=n[2].split(`
`,1)[0].replace(/^\t+/,S=>" ".repeat(3*S.length)),k=t.split(`
`,1)[0],this.options.pedantic?(l=2,h=g.trimLeft()):(l=n[2].search(/[^ ]/),l=l>4?1:l,h=g.slice(l),l+=n[1].length),c=!1,!g&&/^ *$/.test(k)&&(e+=k+`
`,t=t.substring(k.length+1),y=!0),!y){let S=new RegExp(`^ {0,${Math.min(3,l-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),$=new RegExp(`^ {0,${Math.min(3,l-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),z=new RegExp(`^ {0,${Math.min(3,l-1)}}(?:\`\`\`|~~~)`),Z=new RegExp(`^ {0,${Math.min(3,l-1)}}#`);for(;t&&(d=t.split(`
`,1)[0],k=d,this.options.pedantic&&(k=k.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(z.test(k)||Z.test(k)||S.test(k)||$.test(t)));){if(k.search(/[^ ]/)>=l||!k.trim())h+=`
`+k.slice(l);else{if(c||g.search(/[^ ]/)>=4||z.test(g)||Z.test(g)||$.test(g))break;h+=`
`+k}!c&&!k.trim()&&(c=!0),e+=d+`
`,t=t.substring(d.length+1),g=k.slice(l)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(e)&&(u=!0)),this.options.gfm&&(s=/^\[[ xX]\] /.exec(h),s&&(r=s[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:e,task:!!s,checked:r,loose:!1,text:h}),x.raw+=e}x.items[x.items.length-1].raw=e.trimRight(),x.items[x.items.length-1].text=h.trimRight(),x.raw=x.raw.trimRight();let E=x.items.length;for(a=0;a<E;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){let S=x.items[a].tokens.filter(z=>z.type==="space"),$=S.length>0&&S.some(z=>/\n.*\n/.test(z.raw));x.loose=$}if(x.loose)for(a=0;a<E;a++)x.items[a].loose=!0;return x}}html(t){let n=this.rules.block.html.exec(t);if(n){let e={type:"html",block:!0,raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){let s=this.options.sanitizer?this.options.sanitizer(n[0]):w(n[0]);e.type="paragraph",e.text=s,e.tokens=this.lexer.inline(s)}return e}}def(t){let n=this.rules.block.def.exec(t);if(n){let e=n[1].toLowerCase().replace(/\s+/g," "),s=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",r=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:e,raw:n[0],href:s,title:r}}}table(t){let n=this.rules.block.table.exec(t);if(n){let e={type:"table",header:J(n[1]).map(s=>({text:s})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
`):[]};if(e.header.length===e.align.length){e.raw=n[0];let s=e.align.length,r,l,a,c;for(r=0;r<s;r++)/^ *-+: *$/.test(e.align[r])?e.align[r]="right":/^ *:-+: *$/.test(e.align[r])?e.align[r]="center":/^ *:-+ *$/.test(e.align[r])?e.align[r]="left":e.align[r]=null;for(s=e.rows.length,r=0;r<s;r++)e.rows[r]=J(e.rows[r],e.header.length).map(u=>({text:u}));for(s=e.header.length,l=0;l<s;l++)e.header[l].tokens=this.lexer.inline(e.header[l].text);for(s=e.rows.length,l=0;l<s;l++)for(c=e.rows[l],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[a].text);return e}}}lheading(t){let n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){let n=this.rules.block.paragraph.exec(t);if(n){let e=n[1].charAt(n[1].length-1)===`
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:e,tokens:this.lexer.inline(e)}}}text(t){let n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){let n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:w(n[1])}}tag(t){let n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):w(n[0]):n[0]}}link(t){let n=this.rules.inline.link.exec(t);if(n){let e=n[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;let l=U(e.slice(0,-1),"\\");if((e.length-l.length)%2===0)return}else{let l=me(n[2],"()");if(l>-1){let a=(n[0].indexOf("!")===0?5:4)+n[1].length+l;n[2]=n[2].substring(0,l),n[0]=n[0].substring(0,a).trim(),n[3]=""}}let s=n[2],r="";if(this.options.pedantic){let l=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);l&&(s=l[1],r=l[3])}else r=n[3]?n[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(e)?s=s.slice(1):s=s.slice(1,-1)),K(n,{href:s&&s.replace(this.rules.inline._escapes,"$1"),title:r&&r.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(t,n){let e;if((e=this.rules.inline.reflink.exec(t))||(e=this.rules.inline.nolink.exec(t))){let s=(e[2]||e[1]).replace(/\s+/g," ");if(s=n[s.toLowerCase()],!s){let r=e[0].charAt(0);return{type:"text",raw:r,text:r}}return K(e,s,e[0],this.lexer)}}emStrong(t,n,e=""){let s=this.rules.inline.emStrong.lDelim.exec(t);if(!(!s||s[3]&&e.match(/[\p{L}\p{N}]/u))&&(!(s[1]||s[2])||!e||this.rules.inline.punctuation.exec(e))){let r=s[0].length-1,l,a,c=r,u=0,g=s[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(g.lastIndex=0,n=n.slice(-1*t.length+r);(s=g.exec(n))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(a=l.length,s[3]||s[4]){c+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){u+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+u);let k=t.slice(0,r+s.index+a+1);if(Math.min(r,a)%2){let h=k.slice(1,-1);return{type:"em",raw:k,text:h,tokens:this.lexer.inlineTokens(h)}}let d=k.slice(2,-2);return{type:"strong",raw:k,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(t){let n=this.rules.inline.code.exec(t);if(n){let e=n[2].replace(/\n/g," "),s=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return s&&r&&(e=e.substring(1,e.length-1)),e=w(e,!0),{type:"codespan",raw:n[0],text:e}}}br(t){let n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){let n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){let e=this.rules.inline.autolink.exec(t);if(e){let s,r;return e[2]==="@"?(s=w(this.options.mangle?n(e[1]):e[1]),r="mailto:"+s):(s=w(e[1]),r=s),{type:"link",raw:e[0],text:s,href:r,tokens:[{type:"text",raw:s,text:s}]}}}url(t,n){let e;if(e=this.rules.inline.url.exec(t)){let s,r;if(e[2]==="@")s=w(this.options.mangle?n(e[0]):e[0]),r="mailto:"+s;else{let l;do l=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])[0];while(l!==e[0]);s=w(e[0]),e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:s,href:r,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t,n){let e=this.rules.inline.text.exec(t);if(e){let s;return this.lexer.state.inRawBlock?s=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(e[0]):w(e[0]):e[0]:s=w(this.options.smartypants?n(e[0]):e[0]),{type:"text",raw:e[0],text:s}}}},p={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:j,lheading:/^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};p._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;p._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;p.def=m(p.def).replace("label",p._label).replace("title",p._title).getRegex();p.bullet=/(?:[*+-]|\d{1,9}[.)])/;p.listItemStart=m(/^( *)(bull) */).replace("bull",p.bullet).getRegex();p.list=m(p.list).replace(/bull/g,p.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+p.def.source+")").getRegex();p._tag="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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";p._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/;p.html=m(p.html,"i").replace("comment",p._comment).replace("tag",p._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();p.lheading=m(p.lheading).replace(/bull/g,p.bullet).getRegex();p.paragraph=m(p._paragraph).replace("hr",p.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",p._tag).getRegex();p.blockquote=m(p.blockquote).replace("paragraph",p.paragraph).getRegex();p.normal={...p};p.gfm={...p.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};p.gfm.table=m(p.gfm.table).replace("hr",p.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",p._tag).getRegex();p.gfm.paragraph=m(p._paragraph).replace("hr",p.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",p.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",p._tag).getRegex();p.pedantic={...p.normal,html:m(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",p._comment).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:j,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:m(p.normal._paragraph).replace("hr",p.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",p.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};var o={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:j,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,rDelimAst:/^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:j,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^((?![*_])[\spunctuation])/};o._punctuation="\\p{P}$+<=>`^|~";o.punctuation=m(o.punctuation,"u").replace(/punctuation/g,o._punctuation).getRegex();o.blockSkip=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;o.anyPunctuation=/\\[punct]/g;o._escapes=/\\([punct])/g;o._comment=m(p._comment).replace("(?:-->|$)","-->").getRegex();o.emStrong.lDelim=m(o.emStrong.lDelim,"u").replace(/punct/g,o._punctuation).getRegex();o.emStrong.rDelimAst=m(o.emStrong.rDelimAst,"gu").replace(/punct/g,o._punctuation).getRegex();o.emStrong.rDelimUnd=m(o.emStrong.rDelimUnd,"gu").replace(/punct/g,o._punctuation).getRegex();o.anyPunctuation=m(o.anyPunctuation,"gu").replace(/punct/g,o._punctuation).getRegex();o._escapes=m(o._escapes,"gu").replace(/punct/g,o._punctuation).getRegex();o._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;o._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])?)+(?![-_])/;o.autolink=m(o.autolink).replace("scheme",o._scheme).replace("email",o._email).getRegex();o._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;o.tag=m(o.tag).replace("comment",o._comment).replace("attribute",o._attribute).getRegex();o._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;o._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;o._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;o.link=m(o.link).replace("label",o._label).replace("href",o._href).replace("title",o._title).getRegex();o.reflink=m(o.reflink).replace("label",o._label).replace("ref",p._label).getRegex();o.nolink=m(o.nolink).replace("ref",p._label).getRegex();o.reflinkSearch=m(o.reflinkSearch,"g").replace("reflink",o.reflink).replace("nolink",o.nolink).getRegex();o.normal={...o};o.pedantic={...o.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:m(/^!?\[(label)\]\((.*?)\)/).replace("label",o._label).getRegex(),reflink:m(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",o._label).getRegex()};o.gfm={...o.normal,escape:m(o.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/};o.gfm.url=m(o.gfm.url,"i").replace("email",o.gfm._extended_email).getRegex();o.breaks={...o.gfm,br:m(o.br).replace("{2,}","*").getRegex(),text:m(o.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function we(i){return i.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function W(i){let t="",n,e,s=i.length;for(n=0;n<s;n++)e=i.charCodeAt(n),Math.random()>.5&&(e="x"+e.toString(16)),t+="&#"+e+";";return t}var R=class i{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||I,this.options.tokenizer=this.options.tokenizer||new C,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={block:p.normal,inline:o.normal};this.options.pedantic?(n.block=p.pedantic,n.inline=o.pedantic):this.options.gfm&&(n.block=p.gfm,this.options.breaks?n.inline=o.breaks:n.inline=o.gfm),this.tokenizer.rules=n}static get rules(){return{block:p,inline:o}}static lex(t,n){return new i(n).lex(t)}static lexInline(t,n){return new i(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,c,u)=>c+" ".repeat(u.length));let e,s,r,l;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(e=a.call({lexer:this},t,n))?(t=t.substring(e.raw.length),n.push(e),!0):!1))){if(e=this.tokenizer.space(t)){t=t.substring(e.raw.length),e.raw.length===1&&n.length>0?n[n.length-1].raw+=`
`:n.push(e);continue}if(e=this.tokenizer.code(t)){t=t.substring(e.raw.length),s=n[n.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=`
`+e.raw,s.text+=`
`+e.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text):n.push(e);continue}if(e=this.tokenizer.fences(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.heading(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.hr(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.blockquote(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.list(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.html(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.def(t)){t=t.substring(e.raw.length),s=n[n.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=`
`+e.raw,s.text+=`
`+e.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text):this.tokens.links[e.tag]||(this.tokens.links[e.tag]={href:e.href,title:e.title});continue}if(e=this.tokenizer.table(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.lheading(t)){t=t.substring(e.raw.length),n.push(e);continue}if(r=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0,c=t.slice(1),u;this.options.extensions.startBlock.forEach(function(g){u=g.call({lexer:this},c),typeof u=="number"&&u>=0&&(a=Math.min(a,u))}),a<1/0&&a>=0&&(r=t.substring(0,a+1))}if(this.state.top&&(e=this.tokenizer.paragraph(r))){s=n[n.length-1],l&&s.type==="paragraph"?(s.raw+=`
`+e.raw,s.text+=`
`+e.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):n.push(e),l=r.length!==t.length,t=t.substring(e.raw.length);continue}if(e=this.tokenizer.text(t)){t=t.substring(e.raw.length),s=n[n.length-1],s&&s.type==="text"?(s.raw+=`
`+e.raw,s.text+=`
`+e.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):n.push(e);continue}if(t){let a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let e,s,r,l=t,a,c,u;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(l))!=null;)g.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(l))!=null;)l=l.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(l))!=null;)l=l.slice(0,a.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(c||(u=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(g=>(e=g.call({lexer:this},t,n))?(t=t.substring(e.raw.length),n.push(e),!0):!1))){if(e=this.tokenizer.escape(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.tag(t)){t=t.substring(e.raw.length),s=n[n.length-1],s&&e.type==="text"&&s.type==="text"?(s.raw+=e.raw,s.text+=e.text):n.push(e);continue}if(e=this.tokenizer.link(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(e.raw.length),s=n[n.length-1],s&&e.type==="text"&&s.type==="text"?(s.raw+=e.raw,s.text+=e.text):n.push(e);continue}if(e=this.tokenizer.emStrong(t,l,u)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.codespan(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.br(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.del(t)){t=t.substring(e.raw.length),n.push(e);continue}if(e=this.tokenizer.autolink(t,W)){t=t.substring(e.raw.length),n.push(e);continue}if(!this.state.inLink&&(e=this.tokenizer.url(t,W))){t=t.substring(e.raw.length),n.push(e);continue}if(r=t,this.options.extensions&&this.options.extensions.startInline){let g=1/0,k=t.slice(1),d;this.options.extensions.startInline.forEach(function(h){d=h.call({lexer:this},k),typeof d=="number"&&d>=0&&(g=Math.min(g,d))}),g<1/0&&g>=0&&(r=t.substring(0,g+1))}if(e=this.tokenizer.inlineText(r,we)){t=t.substring(e.raw.length),e.raw.slice(-1)!=="_"&&(u=e.raw.slice(-1)),c=!0,s=n[n.length-1],s&&s.type==="text"?(s.raw+=e.raw,s.text+=e.text):n.push(e);continue}if(t){let g="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(g);break}else throw new Error(g)}}return n}},q=class{constructor(t){this.options=t||I}code(t,n,e){let s=(n||"").match(/\S*/)[0];if(this.options.highlight){let r=this.options.highlight(t,s);r!=null&&r!==t&&(e=!0,t=r)}return t=t.replace(/\n$/,"")+`
`,s?'<pre><code class="'+this.options.langPrefix+w(s)+'">'+(e?t:w(t,!0))+`</code></pre>
`:"<pre><code>"+(e?t:w(t,!0))+`</code></pre>
`}blockquote(t){return`<blockquote>
${t}</blockquote>
`}html(t,n){return t}heading(t,n,e,s){if(this.options.headerIds){let r=this.options.headerPrefix+s.slug(e);return`<h${n} id="${r}">${t}</h${n}>
`}return`<h${n}>${t}</h${n}>
`}hr(){return this.options.xhtml?`<hr/>
`:`<hr>
`}list(t,n,e){let s=n?"ol":"ul",r=n&&e!==1?' start="'+e+'"':"";return"<"+s+r+`>
`+t+"</"+s+`>
`}listitem(t){return`<li>${t}</li>
`}checkbox(t){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(t){return`<p>${t}</p>
`}table(t,n){return n&&(n=`<tbody>${n}</tbody>`),`<table>
<thead>
`+t+`</thead>
`+n+`</table>
`}tablerow(t){return`<tr>
${t}</tr>
`}tablecell(t,n){let e=n.header?"th":"td";return(n.align?`<${e} align="${n.align}">`:`<${e}>`)+t+`</${e}>
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,e){if(t=V(this.options.sanitize,this.options.baseUrl,t),t===null)return e;let s='<a href="'+t+'"';return n&&(s+=' title="'+n+'"'),s+=">"+e+"</a>",s}image(t,n,e){if(t=V(this.options.sanitize,this.options.baseUrl,t),t===null)return e;let s=`<img src="${t}" alt="${e}"`;return n&&(s+=` title="${n}"`),s+=this.options.xhtml?"/>":">",s}text(t){return t}},L=class{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,e){return""+e}image(t,n,e){return""+e}br(){return""}},D=class{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let e=t,s=0;if(this.seen.hasOwnProperty(e)){s=this.seen[t];do s++,e=t+"-"+s;while(this.seen.hasOwnProperty(e))}return n||(this.seen[t]=s,this.seen[e]=0),e}slug(t,n={}){let e=this.serialize(t);return this.getNextSafeSlug(e,n.dryrun)}},T=class i{constructor(t){this.options=t||I,this.options.renderer=this.options.renderer||new q,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new L,this.slugger=new D}static parse(t,n){return new i(n).parse(t)}static parseInline(t,n){return new i(n).parseInline(t)}parse(t,n=!0){let e="",s,r,l,a,c,u,g,k,d,h,y,_,A,x,b,E,S,$,z,Z=t.length;for(s=0;s<Z;s++){if(h=t[s],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]&&(z=this.options.extensions.renderers[h.type].call({parser:this},h),z!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(h.type))){e+=z||"";continue}switch(h.type){case"space":continue;case"hr":{e+=this.renderer.hr();continue}case"heading":{e+=this.renderer.heading(this.parseInline(h.tokens),h.depth,ne(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue}case"code":{e+=this.renderer.code(h.text,h.lang,h.escaped);continue}case"table":{for(k="",g="",a=h.header.length,r=0;r<a;r++)g+=this.renderer.tablecell(this.parseInline(h.header[r].tokens),{header:!0,align:h.align[r]});for(k+=this.renderer.tablerow(g),d="",a=h.rows.length,r=0;r<a;r++){for(u=h.rows[r],g="",c=u.length,l=0;l<c;l++)g+=this.renderer.tablecell(this.parseInline(u[l].tokens),{header:!1,align:h.align[l]});d+=this.renderer.tablerow(g)}e+=this.renderer.table(k,d);continue}case"blockquote":{d=this.parse(h.tokens),e+=this.renderer.blockquote(d);continue}case"list":{for(y=h.ordered,_=h.start,A=h.loose,a=h.items.length,d="",r=0;r<a;r++)b=h.items[r],E=b.checked,S=b.task,x="",b.task&&($=this.renderer.checkbox(E),A?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=$+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=$+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:$}):x+=$),x+=this.parse(b.tokens,A),d+=this.renderer.listitem(x,S,E);e+=this.renderer.list(d,y,_);continue}case"html":{e+=this.renderer.html(h.text,h.block);continue}case"paragraph":{e+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(d=h.tokens?this.parseInline(h.tokens):h.text;s+1<Z&&t[s+1].type==="text";)h=t[++s],d+=`
`+(h.tokens?this.parseInline(h.tokens):h.text);e+=n?this.renderer.paragraph(d):d;continue}default:{let N='Token with "'+h.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return e}parseInline(t,n){n=n||this.renderer;let e="",s,r,l,a=t.length;for(s=0;s<a;s++){if(r=t[s],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]&&(l=this.options.extensions.renderers[r.type].call({parser:this},r),l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type))){e+=l||"";continue}switch(r.type){case"escape":{e+=n.text(r.text);break}case"html":{e+=n.html(r.text);break}case"link":{e+=n.link(r.href,r.title,this.parseInline(r.tokens,n));break}case"image":{e+=n.image(r.href,r.title,r.text);break}case"strong":{e+=n.strong(this.parseInline(r.tokens,n));break}case"em":{e+=n.em(this.parseInline(r.tokens,n));break}case"codespan":{e+=n.codespan(r.text);break}case"br":{e+=n.br();break}case"del":{e+=n.del(this.parseInline(r.tokens,n));break}case"text":{e+=n.text(r.text);break}default:{let c='Token with "'+r.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return e}},P=class{constructor(t){this.options=t||I}static passThroughHooks=new Set(["preprocess","postprocess"]);preprocess(t){return t}postprocess(t){return t}},M=class{defaults=H();options=this.setOptions;parse=this.#e(R.lex,T.parse);parseInline=this.#e(R.lexInline,T.parseInline);Parser=T;parser=T.parse;Renderer=q;TextRenderer=L;Lexer=R;lexer=R.lex;Tokenizer=C;Slugger=D;Hooks=P;constructor(...t){this.use(...t)}walkTokens(t,n){let e=[];for(let s of t)switch(e=e.concat(n.call(this,s)),s.type){case"table":{for(let r of s.header)e=e.concat(this.walkTokens(r.tokens,n));for(let r of s.rows)for(let l of r)e=e.concat(this.walkTokens(l.tokens,n));break}case"list":{e=e.concat(this.walkTokens(s.items,n));break}default:this.defaults.extensions&&this.defaults.extensions.childTokens&&this.defaults.extensions.childTokens[s.type]?this.defaults.extensions.childTokens[s.type].forEach(r=>{e=e.concat(this.walkTokens(s[r],n))}):s.tokens&&(e=e.concat(this.walkTokens(s.tokens,n)))}return e}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(e=>{let s={...e};if(s.async=this.defaults.async||s.async||!1,e.extensions&&(e.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if(r.renderer){let l=n.renderers[r.name];l?n.renderers[r.name]=function(...a){let c=r.renderer.apply(this,a);return c===!1&&(c=l.apply(this,a)),c}:n.renderers[r.name]=r.renderer}if(r.tokenizer){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");n[r.level]?n[r.level].unshift(r.tokenizer):n[r.level]=[r.tokenizer],r.start&&(r.level==="block"?n.startBlock?n.startBlock.push(r.start):n.startBlock=[r.start]:r.level==="inline"&&(n.startInline?n.startInline.push(r.start):n.startInline=[r.start]))}r.childTokens&&(n.childTokens[r.name]=r.childTokens)}),s.extensions=n),e.renderer){let r=this.defaults.renderer||new q(this.defaults);for(let l in e.renderer){let a=r[l];r[l]=(...c)=>{let u=e.renderer[l].apply(r,c);return u===!1&&(u=a.apply(r,c)),u}}s.renderer=r}if(e.tokenizer){let r=this.defaults.tokenizer||new C(this.defaults);for(let l in e.tokenizer){let a=r[l];r[l]=(...c)=>{let u=e.tokenizer[l].apply(r,c);return u===!1&&(u=a.apply(r,c)),u}}s.tokenizer=r}if(e.hooks){let r=this.defaults.hooks||new P;for(let l in e.hooks){let a=r[l];P.passThroughHooks.has(l)?r[l]=c=>{if(this.defaults.async)return Promise.resolve(e.hooks[l].call(r,c)).then(g=>a.call(r,g));let u=e.hooks[l].call(r,c);return a.call(r,u)}:r[l]=(...c)=>{let u=e.hooks[l].apply(r,c);return u===!1&&(u=a.apply(r,c)),u}}s.hooks=r}if(e.walkTokens){let r=this.defaults.walkTokens;s.walkTokens=function(l){let a=[];return a.push(e.walkTokens.call(this,l)),r&&(a=a.concat(r.call(this,l))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}#e(t,n){return(e,s,r)=>{typeof s=="function"&&(r=s,s=null);let l={...s};s={...this.defaults,...l};let a=this.#t(s.silent,s.async,r);if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(xe(s,r),s.hooks&&(s.hooks.options=s),r){let c=s.highlight,u;try{s.hooks&&(e=s.hooks.preprocess(e)),u=t(e,s)}catch(d){return a(d)}let g=d=>{let h;if(!d)try{s.walkTokens&&this.walkTokens(u,s.walkTokens),h=n(u,s),s.hooks&&(h=s.hooks.postprocess(h))}catch(y){d=y}return s.highlight=c,d?a(d):r(null,h)};if(!c||c.length<3||(delete s.highlight,!u.length))return g();let k=0;this.walkTokens(u,d=>{d.type==="code"&&(k++,setTimeout(()=>{c(d.text,d.lang,(h,y)=>{if(h)return g(h);y!=null&&y!==d.text&&(d.text=y,d.escaped=!0),k--,k===0&&g()})},0))}),k===0&&g();return}if(s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(e):e).then(c=>t(c,s)).then(c=>s.walkTokens?Promise.all(this.walkTokens(c,s.walkTokens)).then(()=>c):c).then(c=>n(c,s)).then(c=>s.hooks?s.hooks.postprocess(c):c).catch(a);try{s.hooks&&(e=s.hooks.preprocess(e));let c=t(e,s);s.walkTokens&&this.walkTokens(c,s.walkTokens);let u=n(c,s);return s.hooks&&(u=s.hooks.postprocess(u)),u}catch(c){return a(c)}}}#t(t,n,e){return s=>{if(s.message+=`
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+w(s.message+"",!0)+"</pre>";if(n)return Promise.resolve(r);if(e){e(null,r);return}return r}if(n)return Promise.reject(s);if(e){e(s);return}throw s}}},v=new M(I);function f(i,t,n){return v.parse(i,t,n)}f.options=f.setOptions=function(i){return v.setOptions(i),f.defaults=v.defaults,Y(f.defaults),f};f.getDefaults=H;f.defaults=I;f.use=function(...i){return v.use(...i),f.defaults=v.defaults,Y(f.defaults),f};f.walkTokens=function(i,t){return v.walkTokens(i,t)};f.parseInline=v.parseInline;f.Parser=T;f.parser=T.parse;f.Renderer=q;f.TextRenderer=L;f.Lexer=R;f.lexer=R.lex;f.Tokenizer=C;f.Slugger=D;f.Hooks=P;f.parse=f;f.options;f.setOptions;f.use;f.walkTokens;f.parseInline;T.parse;R.lex;f.use({gfm:!0,breaks:!0,async:!1,mangle:!1,headerIds:!1,renderer:{link(i,t,n){return`<calcite-link href="${i}" title="${t??n}" target="Arcade Help">${n}</calcite-link>`}}});function Ae(i){return i==null?"":f.parse(typeof i=="string"?i:i.value)}export{Se as a,ie as b,Re as c,Te as d,Ae as e};