import{d as z,r as x,c as C,a as w,w as K,o as I,b as V,e as b,k as A,h as L,g as P,i as U,T as W,n as B,t as j,l as F,m as X}from"./tailwind-D5NWkpcg.js";import{$ as q,y as G,w as J,e as Q,D as Y,a as Z,z as ee,T as le,j as ae}from"./sidepanel-VcS0zCOq.js";import"./TooltipContent.vue_vue_type_script_setup_true_lang-BuJLrO89.js";import"./ext-utils-BLHv4ziY.js";var D=(y,l,n)=>new Promise((h,s)=>{var t=u=>{try{i(n.next(u))}catch(c){s(c)}},r=u=>{try{i(n.throw(u))}catch(c){s(c)}},i=u=>u.done?h(u.value):Promise.resolve(u.value).then(t,r);i((n=n.apply(y,l)).next())});const ne=["data-markstream-mode"],te={key:0,class:"math-loading-overlay"},oe=["innerHTML"],re={key:1,class:"math-block__fallback text-left"},S=q(z({__name:"MathBlockNode",props:{node:{},indexKey:{},cacheScope:{}},setup(y){const l=y,n=x(null),h=C(()=>G(l.node.content)),s=function(){if(!l.node.content)return{html:"",text:l.node.raw,loading:!1};const e=J();if(!e)return{html:"",text:l.node.loading?"":l.node.raw,loading:l.node.loading};try{return{html:e.renderToString(h.value,{throwOnError:l.node.loading,displayMode:!0}),text:"",loading:!1}}catch{return{html:"",text:l.node.loading?"":l.node.raw,loading:l.node.loading}}}(),t=x(s.html),r=x(s.text);let i=!1,u=0,c=!1,m=null;const g=Q(),H=Y();let v=null,k=null;const d=x(s.loading),p=x(E());function R(){var e;if(l.indexKey==null)return"";const a=(e=l.cacheScope)!=null?e:g==null?void 0:g.scope;return`${a!=null&&String(a).length>0?`${String(a)}:`:""}math-block:${String(l.indexKey)}`}function E(){var e;const a=R();return a&&(e=g==null?void 0:g.cache.get(a))!=null?e:0}function $(e){if(!Number.isFinite(e)||e<=0)return;const a=Math.max(p.value,e);if(a===p.value)return;p.value=a;const o=R();o&&(g==null||g.cache.set(o,a))}function f(){X(()=>{var e,a;$((a=(e=n.value)==null?void 0:e.offsetHeight)!=null?a:0)})}function M(){return D(this,null,function*(){if(c)return;if(!l.node.content)return d.value=!1,t.value="",r.value=l.node.raw,i=!0,void f();if(!i)try{!v&&n.value&&(v=H(n.value)),yield v==null?void 0:v.whenVisible}catch{}m&&(m.abort(),m=null);const e=++u,a=new AbortController;m=a,Z(h.value,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:a.signal}).then(o=>{c||e!==u||(t.value=o,r.value="",i=!0,d.value=!1,f())}).catch(o=>D(null,null,function*(){if(c||e!==u)return;const _=(o==null?void 0:o.code)||(o==null?void 0:o.name),N=_==="KATEX_DISABLED";if(_==="WORKER_INIT_ERROR"||o!=null&&o.fallbackToRenderer||_===ee||_==="WORKER_TIMEOUT"){const O=yield le();if(O){try{const T=O.renderToString(h.value,{throwOnError:l.node.loading,displayMode:!0});t.value=T,r.value="",i=!0,d.value=!1,f(),ae(h.value,!0,T)}catch{}return}}if(N)return d.value=!1,t.value="",r.value=l.node.raw,void f();i||(d.value=!0),l.node.loading||(d.value=!1,t.value="",r.value=l.node.raw,f())}))})}return(s.html||s.text)&&(i=!0),K(()=>l.node.content,()=>{M()}),K([()=>l.indexKey,()=>l.cacheScope],()=>{p.value=E(),f()}),I(()=>{typeof ResizeObserver<"u"&&n.value&&(k=new ResizeObserver(()=>{var e,a;$((a=(e=n.value)==null?void 0:e.offsetHeight)!=null?a:0)}),k.observe(n.value)),f(),t.value||M()}),V(()=>{var e;c=!0,m&&(m.abort(),m=null),k==null||k.disconnect(),k=null,(e=v==null?void 0:v.destroy)==null||e.call(v),v=null}),(e,a)=>(b(),w("div",{ref_key:"containerEl",ref:n,class:"math-block text-center overflow-x-auto relative","data-markstream-math":"block","data-markstream-mode":t.value?"katex":r.value?"fallback":"loading",style:F(p.value?{minHeight:`${p.value}px`}:void 0)},[A(W,{name:"math-fade"},{default:L(()=>[!d.value||t.value||r.value?P("",!0):(b(),w("div",te,[...a[0]||(a[0]=[U("div",{class:"math-loading-spinner"},null,-1)])]))]),_:1}),t.value?(b(),w("div",{key:0,class:B(["math-block__content",{"math-rendering":d.value}]),innerHTML:t.value},null,10,oe)):r.value?(b(),w("pre",re,j(r.value),1)):(b(),w("div",{key:2,class:B(["math-block__content",{"math-rendering":d.value}])},null,2))],12,ne))}}),[["__scopeId","data-v-2dc0a6cd"]]);S.install=y=>{y.component(S.__name,S)};export{S as default};
