import{p as L,a as d,f as B,B as W,g as u,c as f,e as q,t as z,l as U,n as V,r as X,I as N}from"./index-DW7rebFp.js";import{p as j}from"./purify.es-HRjpPm7y.js";import A from"./katex-XbL3y5x-.js";/* empty css                  */var G=B("<div><!></div>");function Z(T,o){L(o,!0);let _=d(o,"content",3,""),O=d(o,"allowHtml",3,!1),b=d(o,"syntaxHighlight",3,!0),g=d(o,"mathEnabled",3,!0);const x=t=>t.replace(/</g,"&lt;").replace(/>/g,"&gt;"),k=()=>{const t=new N.Renderer;return O()||(t.html=({text:l})=>x(l)),b()||(t.code=({text:l,lang:e})=>`<pre><code class="${e?`language-${e}`:""}">${x(l)}</code></pre>`),t},C=t=>{if(!g()||typeof DOMParser>"u")return t;try{const e=new DOMParser().parseFromString(t,"text/html"),p=e.createTreeWalker(e.body,NodeFilter.SHOW_TEXT),E=[];for(;p.nextNode();){const a=p.currentNode,n=a.parentElement;n&&(n.tagName==="CODE"||n.tagName==="PRE")||E.push(a)}const P=/\$\$([^$]+)\$\$|\$([^$\n]+)\$/g;for(const a of E){const n=a.nodeValue??"";let r,s=0,w=!1;const c=e.createDocumentFragment();for(;(r=P.exec(n))!==null;){w=!0;const m=r[0],v=r[1],$=r[2],I=(v??$??"").trim(),H=!!v;r.index>s&&c.appendChild(e.createTextNode(n.slice(s,r.index)));let h=m;try{h=A.renderToString(I,{displayMode:H,throwOnError:!1})}catch{h=m}const M=e.createElement(H?"div":"span");M.innerHTML=h,c.appendChild(M),s=r.index+m.length}w&&(s<n.length&&c.appendChild(e.createTextNode(n.slice(s))),a.parentNode?.replaceChild(c,a))}return e.body.innerHTML}catch{return t}},R=f(k),S=f(()=>N.parse(_()||"",{async:!1,renderer:u(R)})),D=f(()=>j.sanitize(C(u(S)),{USE_PROFILES:{html:!0,svg:!1}}));var i=G();let y;var F=q(i);W(F,()=>u(D)),z(()=>y=U(i,1,"markdown svelte-yueq7f",null,y,{math:g()})),V(T,i),X()}export{Z as default};
