markstream-vue 0.0.9-beta.0 → 0.0.9-beta.2

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/exports.js CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,i=(n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,a=(e,n)=>{for(var t in n||(n={}))r.call(n,t)&&i(e,t,n[t]);if(o)for(var t of o(n))l.call(n,t)&&i(e,t,n[t]);return e},s=(e,o)=>n(e,t(o)),d=(e,n,t)=>i(e,"symbol"!=typeof n?n+"":n,t),u=(e,n,t)=>new Promise((o,r)=>{var l=e=>{try{a(t.next(e))}catch(n){r(n)}},i=e=>{try{a(t.throw(e))}catch(n){r(n)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);a((t=t.apply(e,n)).next())});import{getMarkdown as c,parseMarkdownToStructure as m,setDefaultMathOptions as h}from"stream-markdown-parser";import{defineComponent as p,openBlock as f,createElementBlock as v,withMemo as g,createVNode as y,unref as w,createElementVNode as k,Fragment as x,renderList as b,toDisplayString as _,shallowRef as M,h as T,computed as C,ref as B,watch as I,onMounted as $,onBeforeUnmount as S,normalizeClass as E,createApp as L,inject as j,provide as N,Transition as H,withCtx as P,normalizeStyle as D,renderSlot as R,createCommentVNode as O,readonly as K,defineAsyncComponent as z,createBlock as A,resolveDynamicComponent as W,useAttrs as F,mergeProps as V,isMemoSame as U,markRaw as X,reactive as q,nextTick as G,withDirectives as Y,vShow as Z,Teleport as J}from"vue";import{autoUpdate as Q,offset as ee,flip as ne,shift as te,computePosition as oe}from"@floating-ui/dom";const re=["cite"],le=(e,n)=>{const t=e.__vccOpts||e;for(const[o,r]of n)t[o]=r;return t},ie=/* @__PURE__ */le(/* @__PURE__ */p({__name:"BlockquoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(t,o)=>(f(),v("blockquote",{class:"blockquote",dir:"auto",cite:e.node.cite},[g([n.node.children],()=>y(w(zt),{"index-key":`blockquote-${n.indexKey}`,nodes:n.node.children||[],"custom-id":n.customId,typewriter:n.typewriter,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))},null,8,["index-key","nodes","custom-id","typewriter"]),o,1)],8,re))}}),[["__scopeId","data-v-eeadc8a3"]]);ie.install=e=>{e.component(ie.__name,ie)};const ae={class:"checkbox-node"},se=["checked"],de=/* @__PURE__ */le(/* @__PURE__ */p({__name:"CheckboxNode",props:{node:{}},setup:e=>(n,t)=>(f(),v("span",ae,[k("input",{type:"checkbox",checked:e.node.checked,disabled:"",class:"checkbox-input"},null,8,se)]))}),[["__scopeId","data-v-8dc6c46f"]]);de.install=e=>{e.component(de.__name,de)};const ue={class:"definition-list"},ce={class:"definition-term"},me={class:"definition-desc"},he=/* @__PURE__ */le(/* @__PURE__ */p({__name:"DefinitionListNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(e,t)=>(f(),v("dl",ue,[(f(!0),v(x,null,b(n.node.items,(o,r)=>(f(),v(x,{key:r},[k("dt",ce,[y(w(zt),{"index-key":`definition-term-${n.indexKey}-${r}`,nodes:o.term,"custom-id":n.customId,typewriter:n.typewriter,onCopy:t[0]||(t[0]=n=>e.$emit("copy",n))},null,8,["index-key","nodes","custom-id","typewriter"])]),k("dd",me,[y(w(zt),{"index-key":`definition-desc-${n.indexKey}-${r}`,nodes:o.definition,"custom-id":n.customId,typewriter:n.typewriter,onCopy:t[1]||(t[1]=n=>e.$emit("copy",n))},null,8,["index-key","nodes","custom-id","typewriter"])])],64))),128))]))}}),[["__scopeId","data-v-f88691d6"]]);he.install=e=>{e.component(he.__name,he)};const pe={class:"emoji-node"},fe=/* @__PURE__ */le(/* @__PURE__ */p({__name:"EmojiNode",props:{node:{}},setup:e=>(n,t)=>(f(),v("span",pe,_(e.node.name),1))}),[["__scopeId","data-v-de55dc97"]]);fe.install=e=>{e.component(fe.__name,fe)};const ve="__global__",ge="__MARKSTREAM_VUE_CUSTOM_COMPONENTS_STORE__",ye=(()=>{const e=globalThis;if(e[ge])return e[ge];const n={scopedCustomComponents:{},revision:M(0)};return e[ge]=n,n})(),we=ye.revision;function ke(e,n){"string"==typeof e?ye.scopedCustomComponents[e]=n||{}:ye.scopedCustomComponents[ve]=e||{},we.value++}function xe(e){const n=ye.scopedCustomComponents[ve]||{};if(!e)return n;const t=ye.scopedCustomComponents[e]||{};return n&&0!==Object.keys(n).length?t&&0!==Object.keys(t).length?a(a({},n),t):n:t}function be(e){if(e===ve)throw new Error("removeCustomComponents: use clearGlobalCustomComponents() to clear the global mapping");delete ye.scopedCustomComponents[e],we.value++}function _e(){delete ye.scopedCustomComponents[ve],we.value++}const Me=["id"],Te=["title"],Ce=/* @__PURE__ */le(/* @__PURE__ */p({__name:"FootnoteReferenceNode",props:{node:{}},setup(e){const n=`#footnote-${e.node.id}`;function t(){if("undefined"==typeof document)return;const e=document.querySelector(n);e?e.scrollIntoView({behavior:"smooth"}):console.warn(`Element with href: ${n} not found`)}return(o,r)=>(f(),v("sup",{id:`fnref-${e.node.id}`,class:"footnote-reference",onClick:t},[k("span",{href:n,title:`查看脚注 ${e.node.id}`,class:"footnote-link cursor-pointer"},"["+_(e.node.id)+"]",9,Te)],8,Me))}}),[["__scopeId","data-v-01af0fee"]]);Ce.install=e=>{e.component(Ce.__name,Ce)};const Be=/* @__PURE__ */new Set(["onclick","onerror","onload","onmouseover","onmouseout","onmousedown","onmouseup","onkeydown","onkeyup","onfocus","onblur","onsubmit","onreset","onchange","onselect","ondblclick","ontouchstart","ontouchend","ontouchmove","ontouchcancel","onwheel","onscroll","oncopy","oncut","onpaste","oninput","oninvalid","onreset","onsearch","onsubmit"]),Ie=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e=/* @__PURE__ */new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),Se=/<([a-z][a-z0-9-]*)\b[^>]*>/gi,Ee=/* @__PURE__ */new Set(["script"]),Le=/* @__PURE__ */new Set(["href","src","srcset","xlink:href","formaction"]),je=(()=>{try{return Boolean(!1)}catch(e){}return!1})();function Ne(e){je&&console.warn(e)}function He(e){const n=function(e){let n="";for(const t of e){const e=t.charCodeAt(0);e<=31||127===e||/\s/u.test(t)||(n+=t)}return n}(e).toLowerCase();return!(!n.startsWith("javascript:")&&!n.startsWith("vbscript:"))||!!n.startsWith("data:")&&!(n.startsWith("data:image/")||n.startsWith("data:video/")||n.startsWith("data:audio/"))}function Pe(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function De(e,n){const t=e.toLowerCase();return!$e.has(t)&&(Pe(n,t)||Pe(n,e))}function Re(e){const n={};for(const[t,o]of Object.entries(e)){const e=t.toLowerCase();Be.has(e)||Le.has(e)&&o&&He(o)||(n[t]=o)}return n}function Oe(e,n){const t=n.toLowerCase();if(["checked","disabled","readonly","required","autofocus","multiple","hidden"].includes(t))return"true"===e||""===e||e===n;if(["value","min","max","step","width","height","size","maxlength"].includes(t)){const n=Number(e);if(""!==e&&!Number.isNaN(n))return n}return e}function Ke(e){return e.trim().length>0}function ze(e,n,t,o,r){if(Ee.has(e.toLowerCase()))return null;const l=Re(n),i=l.key,d=null!=i&&""!==i?i:r;if(De(e,o)){const n=o[e]||o[e.toLowerCase()],r=function(e){const n={};for(const[t,o]of Object.entries(e))n[t]=Oe(o,t);return n}(l);return T(n,s(a({},r),{key:d}),t.length>0?t:void 0)}return T(e,s(a({},l),{innerHTML:void 0,key:d}),t.length>0?t:void 0)}function Ae(e,n){if(!e||!e.includes("<"))return!1;if(!n||0===Object.keys(n).length)return!1;let t;for(Se.lastIndex=0;null!==(t=Se.exec(e));)if(De(t[1],n))return!0;return!1}function We(e,n){if(!e)return[];try{const t=function(e,n){let t=0;const o=[],r=[];for(const l of e)if("text"===l.type)(o.length>0?o[o.length-1].children:r).push(l.content);else if("self_closing"===l.type){const e=ze(l.tagName,l.attrs||{},[],n,"ms-html-"+t++),i=o.length>0?o[o.length-1].children:r;null!=e&&i.push(e)}else if("tag_open"===l.type)o.push({tagName:l.tagName,children:[],attrs:l.attrs,autoKey:"ms-html-"+t++});else if("tag_close"===l.type){const e=l.tagName.toLowerCase();let t=-1;for(let n=o.length-1;n>=0;n--)if(o[n].tagName.toLowerCase()===e){t=n;break}if(-1!==t)for(;o.length>t;){const l=o.pop(),i=ze(l.tagName,l.attrs||{},l.children,n,l.autoKey);o.length>0?null!=i&&o[o.length-1].children.push(i):null!=i&&r.push(i),l.tagName.toLowerCase()!==e&&o.length>t&&Ne(`Auto-closing unclosed tag: <${l.tagName}>`)}else Ne(`Ignoring closing tag with no matching opening tag: </${l.tagName}>`)}for(;o.length>0;){const e=o.pop(),t=ze(e.tagName,e.attrs||{},e.children,n,e.autoKey);o.length>0?null!=t&&o[o.length-1].children.push(t):null!=t&&r.push(t),Ne(`Auto-closing unclosed tag: <${e.tagName}>`)}return r}(function(e){var n,t,o;const r=[];let l=0;for(;l<e.length;){if(e.startsWith("\x3c!--",l)){const n=e.indexOf("--\x3e",l);if(-1!==n){l=n+3;continue}break}const i=e.indexOf("<",l);if(-1===i){if(l<e.length){const n=e.slice(l);Ke(n)&&r.push({type:"text",content:n})}break}if(i>l){const n=e.slice(l,i);Ke(n)&&r.push({type:"text",content:n})}if(e.startsWith("![CDATA[",i+1)){const n=e.indexOf("]]>",i);if(-1!==n){r.push({type:"text",content:e.slice(i,n+3)}),l=n+3;continue}break}if(e.startsWith("!",i+1)){const n=e.indexOf(">",i);if(-1!==n){l=n+1;continue}break}const a=e.indexOf(">",i);if(-1===a)break;const s=e.slice(i+1,a).trim(),d=s.startsWith("/"),u=s.endsWith("/");if(d){const e=s.slice(1).trim();r.push({type:"tag_close",tagName:e})}else{const e=s.indexOf(" ");let l,i="";-1===e?l=u?s.slice(0,-1).trim():s.trim():(l=s.slice(0,e).trim(),i=s.slice(e+1));const a={};if(i){const e=/([^\s=]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S*)))?/g;let r;for(;null!==(r=e.exec(i));){const e=r[1],l=null!=(o=null!=(t=null!=(n=r[2])?n:r[3])?t:r[4])?o:"";e&&!e.endsWith("/")&&(a[e]=l)}}r.push({type:u||Ie.has(l.toLowerCase())?"self_closing":"tag_open",tagName:l,attrs:a})}l=a+1}return r}(e),n);return t}catch(o){return t=o,je&&console.error("Failed to parse HTML to VNodes:",t),null}var t}const Fe=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HtmlInlineNode",props:{node:{},customId:{}},setup(e){const n=e,t=C(()=>(we.value,xe(n.customId))),o=p({name:"DynamicRenderer",props:{nodes:{type:Array,required:!0}},render(){return this.nodes}}),r=C(()=>{const e=n.node.content;if(!e)return{mode:"html",content:""};if(n.node.loading&&n.node.autoClosed){const n=We(e,t.value);if(null!==n)return{mode:"dynamic",nodes:n}}if(!Ae(e,t.value))return{mode:"html",content:e};const o=We(e,t.value);return null===o?{mode:"html",content:e}:{mode:"dynamic",nodes:o}}),l=B(null),i="undefined"!=typeof window,a=B({mode:"",content:"",el:null});let s=null;function d(e,n){if(!i||!l.value)return;const t=l.value,o=a.value;if(o.el!==t||o.mode!==e||o.content!==n){if("text"===e)t.textContent=n;else{const e=(!s&&i&&(s=document.createElement("template")),s);if(e){e.innerHTML=n;const o=e.content.cloneNode(!0);"function"==typeof t.replaceChildren?t.replaceChildren(o):(t.innerHTML="",t.appendChild(o))}else t.innerHTML=n}a.value={mode:e,content:n,el:t}}}function u(){d("html",n.node.content)}function c(){d("text",n.node.content)}return I(()=>[n.node.content,n.node.loading,n.node.autoClosed,r.value.mode],()=>{"html"===r.value.mode&&(n.node.loading&&!n.node.autoClosed?c():u())}),$(()=>{"html"===r.value.mode&&(n.node.loading&&!n.node.autoClosed?c():u())}),S(()=>{l.value&&(l.value.innerHTML="",a.value={mode:"",content:"",el:null})}),(e,t)=>"dynamic"===r.value.mode?(f(),v("span",{key:0,class:E(["html-inline-node",{"html-inline-node--loading":n.node.loading}])},[y(w(o),{nodes:r.value.nodes},null,8,["nodes"])],2)):(f(),v("span",{key:1,ref_key:"containerRef",ref:l,class:E(["html-inline-node",{"html-inline-node--loading":n.node.loading}])},null,2))}}),[["__scopeId","data-v-4add5e85"]]);Fe.install=e=>{e.component(Fe.__name,Fe)};const Ve={class:"inline text-[85%] px-1 py-0.5 rounded font-mono bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full before:content-[''] after:content-['']"},Ue=/* @__PURE__ */p({__name:"InlineCodeNode",props:{node:{}},setup:e=>(n,t)=>(f(),v("code",Ve,_(e.node.code),1))});Ue.install=e=>{e.component(Ue.__name,Ue)};const Xe=B(!1),qe=B(""),Ge=B("top"),Ye=B(null),Ze=B(null),Je=B(null),Qe=B(null),en=B(null);let nn=null,tn=null;function on(){nn&&(clearTimeout(nn),nn=null),tn&&(clearTimeout(tn),tn=null)}let rn=!1,ln=null;function an(e,n,t="top",o=!1,r,l){if(!e)return;rn||"undefined"!=typeof document&&(ln||(ln=Promise.resolve().then(()=>mr).then(({default:e})=>{rn=!0;const n=document.createElement("div");n.setAttribute("data-singleton-tooltip","1"),document.body.appendChild(n),L({setup:()=>()=>{var n;return T(e,{visible:Xe.value,"anchor-el":Ye.value,content:qe.value,placement:Ge.value,id:Ze.value,originX:Je.value,originY:Qe.value,isDark:null!=(n=en.value)?n:void 0})}}).mount(n)}).catch(e=>{ln=null,rn=!1,console.warn("[markstream-vue] Failed to load Tooltip component. Tooltips will be disabled.",e)}))),on();const i=()=>{var o,i;Ze.value=`tooltip-${Date.now()}-${Math.floor(1e3*Math.random())}`,Ye.value=e,qe.value=n,Ge.value=t,Je.value=null!=(o=null==r?void 0:r.x)?o:null,Qe.value=null!=(i=null==r?void 0:r.y)?i:null,en.value="boolean"==typeof l?l:null,Xe.value=!0;try{e.setAttribute("aria-describedby",Ze.value)}catch(a){}};o?i():nn=setTimeout(i,80)}function sn(e=!1){on();const n=()=>{if(Ye.value&&Ze.value)try{Ye.value.removeAttribute("aria-describedby")}catch(e){}Xe.value=!1,Ye.value=null,Ze.value=null,Je.value=null,Qe.value=null};e?n():tn=setTimeout(n,120)}const dn={"common.copy":"Copy","common.copied":"Copied","common.decrease":"Decrease","common.reset":"Reset","common.increase":"Increase","common.expand":"Expand","common.collapse":"Collapse","common.preview":"Preview","common.source":"Source","common.export":"Export","common.open":"Open","common.zoomIn":"Zoom in","common.zoomOut":"Zoom out","common.resetZoom":"Reset zoom","image.loadError":"Image failed to load","image.loading":"Loading image..."};function un(e){Object.assign(dn,e)}function cn(){try{const n=globalThis.$vueI18nUse||null;if(n&&"function"==typeof n)try{const e=n();if(e&&"function"==typeof e.t)return{t:e.t.bind(e)}}catch(e){}}catch(e){}return u(null,null,function*(){try{const n=yield import("vue-i18n"),t=n.useI18n||n.default&&n.default.useI18n;if(t&&"function"==typeof t)try{const n=t();if(n&&"function"==typeof n.t)try{globalThis.$vueI18nUse=()=>n}catch(e){}}catch(e){}}catch(e){}}),{t:e=>{var n;return null!=(n=dn[e])?n:function(e){return(e.split(".").pop()||e).replace(/[_-]/g," ").replace(/([A-Z])/g," $1").replace(/\s+/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}(e)}}}const mn=/* @__PURE__ */Symbol("ViewportPriority");function hn(e,n){const t="undefined"!=typeof window&&"undefined"!=typeof document,o="boolean"==typeof n?B(n):n;let r=null,l=null;const i=/* @__PURE__ */new Map;const a=(n,a)=>{const s=B(!1);let d,u=!1;const c=new Promise(e=>{d=()=>{u||(u=!0,e())}}),m=()=>{try{null==r||r.unobserve(n)}catch(e){}if(i.delete(n),!i.size){try{null==r||r.disconnect()}catch(e){}r=null,l=null}};if(!t||!o.value)return s.value=!0,d(),{isVisible:s,whenVisible:c,destroy:m};const h=function(n,o){if(!t)return r;if("undefined"==typeof IntersectionObserver)return null;const a=function(n,t){var o,r,l;return{root:null!=(o=null==e?void 0:e(null!=n?n:null))?o:null,rootMargin:null!=(r=null==t?void 0:t.rootMargin)?r:"300px",threshold:null!=(l=null==t?void 0:t.threshold)?l:0}}(n,o);if(r&&(d=a,(s=l)&&s.root===d.root&&s.rootMargin===d.rootMargin&&s.threshold===d.threshold))return r;var s,d;if(r)try{r.disconnect()}catch(u){}r=new IntersectionObserver(e=>{for(const n of e){const e=i.get(n.target);if(e&&(n.isIntersecting||n.intersectionRatio>0)){if(!e.visible.value){e.visible.value=!0;try{e.resolve()}catch(u){}}null==r||r.unobserve(n.target),i.delete(n.target)}}},{root:a.root,rootMargin:a.rootMargin,threshold:a.threshold}),l=a;for(const e of i.keys())r.observe(e);return r}(n,a);return h?(i.set(n,{resolve:d,visible:s}),h.observe(n),{isVisible:s,whenVisible:c,destroy:m}):(s.value=!0,d(),{isVisible:s,whenVisible:c,destroy:m})};return N(mn,a),a}function pn(){const e=j(mn,void 0);if(e)return e;const n=/* @__PURE__ */new WeakMap;let t=null;return e=>{const o=B(!1);let r,l=!1;const i=new Promise(e=>{r=()=>{l||(l=!0,e())}}),a=()=>{try{null==t||t.unobserve(e)}catch(o){}n.delete(e)},s=t||("undefined"==typeof window||"undefined"==typeof IntersectionObserver?null:(t=new IntersectionObserver(e=>{for(const r of e){const e=n.get(r.target);if(e&&(r.isIntersecting||r.intersectionRatio>0)){if(!e.visible.value){e.visible.value=!0;try{e.resolve()}catch(o){}}null==t||t.unobserve(r.target),n.delete(r.target)}}},{root:null,rootMargin:"300px",threshold:0}),t));return s?(n.set(e,{resolve:r,visible:o}),s.observe(e),{isVisible:o,whenVisible:i,destroy:a}):(o.value=!0,r(),{isVisible:o,whenVisible:i,destroy:a})}}const fn={class:"relative inline-block"},vn=["src","alt","title","loading","tabindex","aria-label"],gn={class:"text-sm whitespace-nowrap"},yn={key:1,class:"text-sm text-gray-500"},wn={key:"error",class:"px-4 py-2 bg-gray-100 flex items-center justify-center rounded-lg gap-2 text-red-500"},kn={class:"text-sm whitespace-nowrap"},xn={key:0,class:"mt-2 text-sm text-gray-500 italic"},bn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"ImageNode",props:{node:{},fallbackSrc:{default:""},showCaption:{type:Boolean,default:!1},lazy:{type:Boolean,default:!0},svgMinHeight:{default:"12rem"},usePlaceholder:{type:Boolean,default:!0}},emits:["load","error","click"],setup(e,{emit:n}){const t=e,o=n,r=B(!1),l=B(!1),i=B(!1),a=B(null),s=pn(),d=B(null),u=B("undefined"==typeof window);"undefined"!=typeof window&&I(()=>a.value,e=>{var n;if(null==(n=d.value)||n.destroy(),d.value=null,!e)return void(u.value=!1);const t=s(e,{rootMargin:"400px"});d.value=t,u.value=t.isVisible.value,t.whenVisible.then(()=>{u.value=!0})},{immediate:!0}),S(()=>{var e;null==(e=d.value)||e.destroy(),d.value=null});const c=C(()=>l.value&&t.fallbackSrc?t.fallbackSrc:t.node.src),m=C(()=>!t.lazy||u.value),h=C(()=>/\.svg(?:\?|$)/i.test(c.value));function p(){t.fallbackSrc&&!i.value?(i.value=!0,l.value=!0):(l.value=!0,o("error",t.node.src))}function g(){r.value=!0,l.value=!1,o("load",c.value)}function x(e){e.preventDefault(),r.value&&!l.value&&o("click",[e,c.value])}const{t:b}=cn();return I(c,()=>{r.value=!1,l.value=!1}),(n,o)=>(f(),v("figure",{ref_key:"figureRef",ref:a,class:"text-center my-8"},[k("div",fn,[y(H,{name:"img-switch",mode:"out-in"},{default:P(()=>{var i,a,s,d,u;return[e.node.loading||l.value||!m.value?l.value?e.node.loading||t.fallbackSrc?O("",!0):(f(),v("div",wn,[R(n.$slots,"error",{node:t.node,displaySrc:c.value,imageLoaded:r.value,hasError:l.value,fallbackSrc:t.fallbackSrc,lazy:t.lazy,isSvg:h.value},()=>[o[1]||(o[1]=k("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24"},[k("path",{fill:"currentColor",d:"M2 2h20v10h-2V4H4v9.586l5-5L14.414 14L13 15.414l-4-4l-5 5V20h8v2H2zm13.547 5a1 1 0 1 0 0 2a1 1 0 0 0 0-2m-3 1a3 3 0 1 1 6 0a3 3 0 0 1-6 0m3.625 6.757L19 17.586l2.828-2.829l1.415 1.415L20.414 19l2.829 2.828l-1.415 1.415L19 20.414l-2.828 2.829l-1.415-1.415L17.586 19l-2.829-2.828z"})],-1)),k("span",kn,_(w(b)("image.loadError")),1)],!0)])):(f(),v("div",{key:"placeholder",class:"placeholder-layer max-w-96 inline-flex items-center justify-center gap-2",style:D(h.value?{minHeight:t.svgMinHeight,width:"100%"}:{minHeight:"6rem"})},[t.usePlaceholder?R(n.$slots,"placeholder",{key:0,node:t.node,displaySrc:c.value,imageLoaded:r.value,hasError:l.value,fallbackSrc:t.fallbackSrc,lazy:t.lazy,isSvg:h.value},()=>[o[0]||(o[0]=k("div",{class:"w-4 h-4 rounded-full border-2 border-solid border-current border-t-transparent animate-spin","aria-hidden":"true"},null,-1)),k("span",gn,_(w(b)("image.loading")),1)],!0):(f(),v("span",yn,_(e.node.raw),1))],4)):(f(),v("img",{key:"image",src:c.value,alt:String(null!=(a=null!=(i=t.node.alt)?i:t.node.title)?a:""),title:String(null!=(d=null!=(s=t.node.title)?s:t.node.alt)?d:""),class:E(["max-w-96 h-auto rounded-lg transition-opacity duration-200 ease-in-out",{"opacity-0":!r.value,"opacity-100":r.value,"cursor-pointer":r.value}]),style:D(h.value?{minHeight:t.svgMinHeight,width:"100%",height:"auto",objectFit:"contain"}:void 0),loading:t.lazy?"lazy":"eager",decoding:"async",tabindex:r.value?0:-1,"aria-label":null!=(u=t.node.alt)?u:w(b)("image.preview"),onError:p,onLoad:g,onClick:x},null,46,vn))]}),_:3})]),t.showCaption&&t.node.alt?(f(),v("figcaption",xn,_(t.node.alt),1)):O("",!0)],512))}}),[["__scopeId","data-v-7ca79b66"]]);bn.install=e=>{e.component(bn.__name,bn)};let _n=null,Mn=!1,Tn=In;function Cn(e){var n;const t=null!=(n=null==e?void 0:e.default)?n:e;return t&&"function"==typeof t.renderToString?t:null}function Bn(){try{const e=globalThis;return Cn(null==e?void 0:e.katex)}catch(e){return null}}function In(){return u(null,null,function*(){const e=Bn();if(e)return e;const n=yield import("katex");try{yield import("katex/dist/contrib/mhchem")}catch(t){}return Cn(n)})}function $n(e){Tn=e,_n=null,Mn=!1}function Sn(e){$n(null!=e?e:In)}function En(){$n(null)}function Ln(){return"function"==typeof Tn}function jn(){return u(this,null,function*(){var e;const n=Bn();if(n)return _n=n,_n;if(_n)return _n;if(Mn)return null;const t=Tn;if(!t)return Mn=!0,null;try{const n=yield t();if(n)return _n=null!=(e=Cn(n))?e:n,_n}catch(o){}return Mn=!0,null})}const Nn=M(!1);let Hn=null;function Pn(){return Hn||(Hn=jn().then(e=>{Nn.value=!!e}).catch(()=>{Nn.value=!1})),K(Nn)}const Dn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"TextNode",props:{node:{}},emits:["copy"],setup(e){const n=Pn();return(t,o)=>(f(),v("span",{class:E([[w(n)&&e.node.center?"text-node-center":""],"whitespace-pre-wrap break-words text-node"])},_(e.node.content),3))}}),[["__scopeId","data-v-56f30838"]]);Dn.install=e=>{e.component(Dn.__name,Dn)};const Rn=z(()=>u(null,null,function*(){var e,n;if("undefined"!=typeof globalThis&&void 0!==globalThis.process&&"test"===(null==(n=null==(e=globalThis.process)?void 0:e.env)?void 0:n.NODE_ENV))return e=>{var n,t;return T(Dn,s(a({},e),{node:s(a({},e.node),{content:null!=(t=e.node.raw)?t:`$${null!=(n=e.node.content)?n:""}$`})}))};try{if(yield jn())return(yield import("./index2.js")).default}catch(t){console.warn('[markstream-vue] Optional peer dependencies for MathInlineNode are missing. Falling back to text rendering. To enable full math rendering features, please install "katex".',t)}return e=>{var n,t;return T(Dn,s(a({},e),{node:s(a({},e.node),{content:null!=(t=e.node.raw)?t:`$${null!=(n=e.node.content)?n:""}$`})}))}})),On=z(()=>u(null,null,function*(){try{if(yield jn())return(yield import("./index3.js")).default}catch(e){console.warn('[markstream-vue] Optional peer dependencies for MathBlockNode are missing. Falling back to text rendering. To enable full math rendering features, please install "katex".',e)}return e=>{var n,t;return T(Dn,s(a({},e),{node:s(a({},e.node),{content:null!=(t=e.node.raw)?t:`$$${null!=(n=e.node.content)?n:""}$$`})}))}})),Kn=/* @__PURE__ */p({__name:"ReferenceNode",props:{node:{},messageId:{},threadId:{}},emits:["click","mouseEnter","mouseLeave"],setup:e=>(n,t)=>(f(),v("span",{class:"reference-node cursor-pointer bg-[hsl(var(--muted))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]",role:"button",tabindex:"0",onClick:t[0]||(t[0]=t=>n.$emit("click",t,e.node.id,e.messageId,e.threadId)),onMouseenter:t[1]||(t[1]=t=>n.$emit("mouseEnter",t,e.node.id,e.messageId,e.threadId)),onMouseleave:t[2]||(t[2]=t=>n.$emit("mouseLeave",t,e.node.id,e.messageId,e.threadId))},_(e.node.id),33))});Kn.install=e=>{e.component(Kn.__name,Kn)};const zn={class:"superscript-node"},An={key:1},Wn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"SuperscriptNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,footnote_reference:Ce,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,emoji:fe,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("sup",zn,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),v(x,{key:`${e.indexKey||"superscript"}-${r}`},[o[t.type]?(f(),A(W(o[t.type]),{key:0,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"superscript"}-${r}`},null,8,["node","custom-id","index-key"])):(f(),v("span",An,_(t.content||t.raw),1))],64))),128))]))}}),[["__scopeId","data-v-6dc1e3ba"]]);Wn.install=e=>{e.component(Wn.__name,Wn)};const Fn={class:"subscript-node"},Vn={key:1},Un=/* @__PURE__ */le(/* @__PURE__ */p({__name:"SubscriptNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,footnote_reference:Ce,strikethrough:Yn,highlight:it,insert:rt,superscript:Wn,emoji:fe,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("sub",Fn,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),v(x,{key:`${e.indexKey||"subscript"}-${r}`},[o[t.type]?(f(),A(W(o[t.type]),{key:0,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"subscript"}-${r}`},null,8,["node","custom-id","index-key"])):(f(),v("span",Vn,_(t.content||t.raw),1))],64))),128))]))}}),[["__scopeId","data-v-69de9b81"]]);Un.install=e=>{e.component(Un.__name,Un)};const Xn={class:"strong-node"},qn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"StrongNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,emphasis:st,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("strong",Xn,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"strong"}-${r}`,"index-key":`${e.indexKey||"strong"}-${r}`,node:t,"custom-id":n.customId},null,8,["index-key","node","custom-id"]))),128))]))}}),[["__scopeId","data-v-af3ce037"]]);qn.install=e=>{e.component(qn.__name,qn)};const Gn={class:"strikethrough-node"},Yn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"StrikethroughNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("del",Gn,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"strikethrough"}-${r}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"strikethrough"}-${r}`},null,8,["node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-904d5bd1"]]);Yn.install=e=>{e.component(Yn.__name,Yn)};const Zn=["href","title","aria-label","aria-hidden"],Jn=["aria-hidden"],Qn={class:"link-text-wrapper relative inline-flex"},et={class:"leading-[normal] link-text"},nt={class:"leading-[normal] link-text"},tt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"LinkNode",props:{node:{},indexKey:{},customId:{},showTooltip:{type:Boolean,default:!0},color:{},underlineHeight:{},underlineBottom:{},animationDuration:{},animationOpacity:{},animationTiming:{},animationIteration:{}},setup(e){const n=e,t=j("markstreamShowTooltips",void 0),o=C(()=>{const e=null==t?void 0:t.value;return"boolean"==typeof e?e:n.showTooltip}),r=C(()=>{var e,t,o,r,l,i;const a=void 0!==n.underlineBottom?"number"==typeof n.underlineBottom?`${n.underlineBottom}px`:String(n.underlineBottom):"-3px";return{"--link-color":null!=(e=n.color)?e:"#0366d6","--underline-height":`${null!=(t=n.underlineHeight)?t:2}px`,"--underline-bottom":a,"--underline-opacity":String(null!=(o=n.animationOpacity)?o:.9),"--underline-duration":`${null!=(r=n.animationDuration)?r:.8}s`,"--underline-timing":null!=(l=n.animationTiming)?l:"linear","--underline-iteration":"number"==typeof n.animationIteration?String(n.animationIteration):null!=(i=n.animationIteration)?i:"infinite"}}),l={text:Dn,strong:qn,strikethrough:Yn,emphasis:st,image:bn,html_inline:Fe,inline_code:Ue},i=C(()=>(we.value,xe(n.customId))),s=F(),d=C(()=>{var e,t;const o=null==(e=n.node)?void 0:e.attrs;if(!o||"object"!=typeof o)return{};const r={};if(Array.isArray(o))for(const n of o)Array.isArray(n)&&n[0]&&(r[String(n[0])]=String(null!=(t=n[1])?t:""));else for(const[n,l]of Object.entries(o))n&&null!=l&&!1!==l&&(r[n]=!0===l?"":String(l));return Re(r)}),u=C(()=>{const e=a(a({},s),d.value);return delete e.title,e});function c(){o.value&&sn()}const m=C(()=>{var e,t,o;const r=null==(e=n.node)?void 0:e.title;return"string"==typeof r&&r.trim().length>0?r:String(null!=(o=null==(t=n.node)?void 0:t.href)?o:"")});return(t,a)=>e.node.loading?(f(),v("span",V({key:1,class:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":e.node.loading?"false":"true"},w(s),{style:r.value}),[k("span",Qn,[k("span",et,[k("span",nt,_(e.node.text),1)]),a[1]||(a[1]=k("span",{class:"underline-anim","aria-hidden":"true"},null,-1))])],16,Jn)):(f(),v("a",V({key:0,class:"link-node",href:e.node.href,title:o.value?"":m.value,"aria-label":`Link: ${m.value}`,"aria-hidden":e.node.loading?"true":"false",target:"_blank",rel:"noopener noreferrer"},u.value,{style:r.value,onMouseenter:a[0]||(a[0]=e=>function(e){var t,r,l;if(!o.value)return;const i=e,a=null!=(null==i?void 0:i.clientX)&&null!=(null==i?void 0:i.clientY)?{x:i.clientX,y:i.clientY}:void 0,s=(null==(t=n.node)?void 0:t.title)||(null==(r=n.node)?void 0:r.href)||(null==(l=n.node)?void 0:l.text)||"";an(e.currentTarget,s,"top",!1,a)}(e)),onMouseleave:c}),[(f(!0),v(x,null,b(e.node.children,(t,o)=>(f(),A(W(function(e){return i.value[e.type]||l[e.type]||null}(t)),{key:`${e.indexKey||"emphasis"}-${o}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"link-text"}-${o}`},null,8,["node","custom-id","index-key"]))),128))],16,Zn))}}),[["__scopeId","data-v-c59222d4"]]);tt.install=e=>{e.component(tt.__name,tt)};const ot={class:"insert-node"},rt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"InsertNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,strikethrough:Yn,highlight:it,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("ins",ot,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"insert"}-${r}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"insert"}-${r}`},null,8,["node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-ab1ec9bc"]]);rt.install=e=>{e.component(rt.__name,rt)};const lt={class:"highlight-node"},it=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HighlightNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,strikethrough:Yn,insert:rt,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("mark",lt,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"highlight"}-${r}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"highlight"}-${r}`},null,8,["node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-38e31bf6"]]);it.install=e=>{e.component(it.__name,it)};const at={class:"emphasis-node"},st=/* @__PURE__ */le(/* @__PURE__ */p({__name:"EmphasisNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("em",at,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"emphasis"}-${r}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"emphasis"}-${r}`},null,8,["node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-8264674d"]]);st.install=e=>{e.component(st.__name,st)};const dt=["href","title"],ut=/* @__PURE__ */le(/* @__PURE__ */p({__name:"FootnoteAnchorNode",props:{node:{}},setup(e){const n=e;function t(e){var t;if(e.preventDefault(),"undefined"==typeof document)return;const o=`fnref-${String(null!=(t=n.node.id)?t:"")}`,r=document.getElementById(o);r&&r.scrollIntoView({behavior:"smooth"})}return(n,o)=>(f(),v("a",{class:"footnote-anchor text-sm text-[#0366d6] hover:underline cursor-pointer",href:`#fnref-${e.node.id}`,title:`返回引用 ${e.node.id}`,onClick:t}," ↩︎ ",8,dt))}}),[["__scopeId","data-v-4756ce0d"]]);ut.install=e=>{e.component(ut.__name,ut)};const ct=["id"],mt={class:"flex-1"},ht=/* @__PURE__ */p({__name:"FootnoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(t,o)=>(f(),v("div",{id:`fnref--${e.node.id}`,class:"flex mt-2 mb-2 text-sm leading-relaxed border-t border-[#eaecef] pt-2"},[k("div",mt,[g([n.node.children],()=>y(w(zt),{"index-key":`footnote-${n.indexKey}`,nodes:n.node.children,"custom-id":n.customId,typewriter:n.typewriter,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))},null,8,["index-key","nodes","custom-id","typewriter"]),o,1)])],8,ct))}});ht.install=e=>{e.component(ht.__name,ht)};const pt={class:"hard-break"},ft=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HardBreakNode",props:{node:{}},setup:e=>(e,n)=>(f(),v("br",pt))}),[["__scopeId","data-v-50c58f70"]]);ft.install=e=>{e.component(ft.__name,ft)};const vt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HeadingNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,image:bn,strong:qn,emphasis:st,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,checkbox:de,checkbox_input:de,footnote_reference:Ce,hardbreak:ft,math_inline:Rn,reference:Kn},t);return(t,r)=>g([e.node.level,e.node.children,e.node.attrs],()=>(f(),A(W(`h${e.node.level}`),V({class:["heading-node",[`heading-${e.node.level}`]],dir:"auto"},e.node.attrs),{default:P(()=>[(f(!0),v(x,null,b(e.node.children,(t,r,l,i)=>{const a=[t];if(i&&i.key===`${e.indexKey||"heading"}-${r}`&&U(i,a))return i;const s=(f(),A(W(o[t.type]),{key:`${e.indexKey||"heading"}-${r}`,"custom-id":n.customId,node:t,"index-key":`${e.indexKey||"heading"}-${r}`},null,8,["custom-id","node","index-key"]));return s.memo=a,s},r,0),128))]),_:1},16,["class"])),r,2)}}),[["__scopeId","data-v-af2f957a"]]),gt=vt;gt.install=e=>{e.component(vt.__name,vt)};const yt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"ListItemNode",props:{node:{},item:{},indexKey:{},value:{},customId:{},typewriter:{type:Boolean},showTooltips:{type:Boolean}},emits:["copy"],setup(e){const n=e,t=C(()=>{var e;return null!=(e=n.node)?e:n.item}),o=C(()=>null==n.value?{}:{value:n.value});return(e,r)=>{var l;return f(),v("li",V({class:"list-item pl-1.5 my-2",dir:"auto"},o.value),[g([null==(l=t.value)?void 0:l.children],()=>{var o,l;return y(w(zt),V({showTooltips:n.showTooltips},{"index-key":`list-item-${n.indexKey}`,nodes:null!=(l=null==(o=t.value)?void 0:o.children)?l:[],"custom-id":n.customId,typewriter:n.typewriter,"batch-rendering":!1,onCopy:r[0]||(r[0]=n=>e.$emit("copy",n))}),null,16,["index-key","nodes","custom-id","typewriter"])},r,1)],16)}}}),[["__scopeId","data-v-1410f3a8"]]);yt.install=e=>{e.component(yt.__name,yt)};const wt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"ListNode",props:{node:{},customId:{},indexKey:{},typewriter:{type:Boolean},showTooltips:{type:Boolean}},emits:["copy"],setup(e){const n=C(()=>(we.value,xe(e.customId).list_item||yt));return(t,o)=>(f(),A(W(e.node.ordered?"ol":"ul"),{class:E(["list-node",{"list-decimal":e.node.ordered,"list-disc":!e.node.ordered}])},{default:P(()=>[(f(!0),v(x,null,b(e.node.items,(r,l,i,a)=>{var s;const d=[r];if(a&&a.key===`${e.indexKey||"list"}-${l}`&&U(a,d))return a;const u=(f(),A(W(n.value),V({key:`${e.indexKey||"list"}-${l}`},{ref_for:!0},{showTooltips:e.showTooltips},{node:r,"custom-id":e.customId,"index-key":`${e.indexKey||"list"}-${l}`,typewriter:e.typewriter,value:e.node.ordered?(null!=(s=e.node.start)?s:1)+l:void 0,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))}),null,16,["node","custom-id","index-key","typewriter","value"]));return u.memo=d,u},o,1),128))]),_:1},8,["class"]))}}),[["__scopeId","data-v-ce9c5cfb"]]);wt.install=e=>{e.component(wt.__name,wt)};const kt={key:1,class:"html-block-node__raw"},xt={key:1,class:"html-block-node__placeholder"},bt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HtmlBlockNode",props:{node:{},customId:{}},setup(e){const n=e,t=C(()=>{const e=n.node.attrs;if(e){if(Array.isArray(e)){const n={};for(const t of e){if(!t||t.length<2)continue;const[e,o]=t;null!=e&&(n[String(e)]=null==o?"":String(o))}return n}return e}}),o=C(()=>(we.value,xe(n.customId))),r=p({name:"DynamicRenderer",props:{nodes:{type:Array,required:!0}},render(){return this.nodes}}),l=B(null),i=B("undefined"==typeof window),a=B(n.node.content),s=C(()=>{var e,t,r;if(!i.value)return{mode:"html",content:null!=(e=a.value)?e:""};const l=null!=(t=a.value)?t:n.node.content;if(!l)return{mode:"html",content:""};if(n.node.loading){const e=We(l,o.value);return null===e?{mode:"text",content:null!=(r=n.node.raw)?r:l}:{mode:"dynamic",nodes:e}}if(!Ae(l,o.value))return{mode:"html",content:l};const s=We(l,o.value);return null===s?{mode:"html",content:l}:{mode:"dynamic",nodes:s}}),d=pn(),u=B(null),c=!!n.node.loading;return"undefined"!=typeof window?(I(l,e=>{var t,o;if(null==(o=null==(t=u.value)?void 0:t.destroy)||o.call(t),u.value=null,!c)return i.value=!0,void(a.value=n.node.content);if(!e)return void(i.value=!1);const r=d(e,{rootMargin:"400px"});u.value=r,i.value=r.isVisible.value,r.whenVisible.then(()=>{i.value=!0})},{immediate:!0}),I(()=>n.node.content,e=>{c&&!i.value||(a.value=e)})):i.value=!0,S(()=>{var e,n;null==(n=null==(e=u.value)?void 0:e.destroy)||n.call(e),u.value=null}),(n,o)=>(f(),v("div",V({ref_key:"htmlRef",ref:l,class:"html-block-node"},t.value),[i.value?(f(),v(x,{key:0},["dynamic"===s.value.mode?(f(),A(w(r),{key:0,nodes:s.value.nodes},null,8,["nodes"])):"text"===s.value.mode?(f(),v("pre",kt,_(s.value.content),1)):g([a.value],()=>(f(),v("div",{key:2,innerHTML:a.value},null,8,["innerHTML"])),o,0)],64)):(f(),v("div",xt,[R(n.$slots,"placeholder",{node:e.node},()=>[o[1]||(o[1]=k("span",{class:"html-block-node__placeholder-bar"},null,-1)),o[2]||(o[2]=k("span",{class:"html-block-node__placeholder-bar w-4/5"},null,-1)),o[3]||(o[3]=k("span",{class:"html-block-node__placeholder-bar w-2/3"},null,-1))],!0)]))],16))}}),[["__scopeId","data-v-6797fa3c"]]);bt.install=e=>{e.component(bt.__name,bt)};const _t={dir:"auto",class:"paragraph-node"},Mt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"ParagraphNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({inline_code:Ue,image:bn,link:tt,hardbreak:ft,emphasis:st,strong:qn,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,html_inline:Fe,html_block:bt,emoji:fe,checkbox:de,math_inline:Rn,checkbox_input:de,reference:Kn,footnote_anchor:ut,footnote_reference:Ce},t),r=Pn();return(t,l)=>(f(),v("p",_t,[(f(!0),v(x,null,b(e.node.children,(t,l)=>(f(),v(x,{key:`${e.indexKey||"paragraph"}-${l}`},["text"!==t.type?(f(),A(W(o[t.type]),{key:0,node:t,"index-key":`${e.indexKey}-${l}`,"custom-id":n.customId},null,8,["node","index-key","custom-id"])):(f(),v("span",{key:1,class:E([[w(r)&&t.center?"text-node-center":""],"whitespace-pre-wrap break-words text-node"])},_(t.content),3))],64))),128))]))}}),[["__scopeId","data-v-4e2afdbc"]]);Mt.install=e=>{e.component(Mt.__name,Mt)};const Tt=["aria-busy","aria-label","data-language"],Ct=["textContent"],Bt=/* @__PURE__ */p({__name:"PreCodeNode",props:{node:{}},setup(e){const n=e,t=C(()=>{var e,t,o;const r=String(null!=(t=null==(e=n.node)?void 0:e.language)?t:"");return String(null!=(o=String(r).split(/\s+/g)[0])?o:"").toLowerCase().replace(/[^\w-]/g,"")||"plaintext"}),o=C(()=>`language-${t.value}`),r=C(()=>{const e=t.value;return e?`Code block: ${e}`:"Code block"});return(n,l)=>(f(),v("pre",{class:E([o.value]),"aria-busy":!0===e.node.loading,"aria-label":r.value,"data-language":t.value,tabindex:"0"},[k("code",{translate:"no",textContent:_(e.node.code)},null,8,Ct)],10,Tt))}});Bt.install=e=>{e.component(Bt.__name,Bt)};const It={class:"table-node-wrapper"},$t=["aria-busy"],St={class:"border-[var(--table-border,#cbd5e1)]"},Et={class:"border-b"},Lt={key:0,class:"table-node__loading",role:"status","aria-live":"polite"},jt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"TableNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e,t=C(()=>{var e;return null!=(e=n.node.loading)&&e}),o=C(()=>{var e;return null!=(e=n.node.rows)?e:[]});return(r,l)=>(f(),v("div",It,[k("table",{class:E(["my-8 text-sm table-node",{"table-node--loading":t.value}]),"aria-busy":t.value},[k("thead",St,[k("tr",Et,[(f(!0),v(x,null,b(e.node.header.cells,(e,t)=>(f(),v("th",{key:`header-${t}`,dir:"auto",class:E(["font-semibold p-[calc(4/7*1em)]",["right"===e.align?"text-right":"center"===e.align?"text-center":"text-left"]])},[y(w(zt),{nodes:e.children,"index-key":`table-th-${n.indexKey}`,"custom-id":n.customId,typewriter:n.typewriter,onCopy:l[0]||(l[0]=e=>r.$emit("copy",e))},null,8,["nodes","index-key","custom-id","typewriter"])],2))),128))])]),k("tbody",null,[(f(!0),v(x,null,b(o.value,(e,t)=>(f(),v("tr",{key:`row-${t}`,class:E(["border-[var(--table-border,#cbd5e1)]",[t<o.value.length-1?"border-b":""]])},[(f(!0),v(x,null,b(e.cells,(e,o)=>(f(),v("td",{key:`cell-${t}-${o}`,class:E(["p-[calc(4/7*1em)]",["right"===e.align?"text-right":"center"===e.align?"text-center":"text-left"]]),dir:"auto"},[y(w(zt),{nodes:e.children,"index-key":`table-td-${n.indexKey}`,"custom-id":n.customId,typewriter:n.typewriter,onCopy:l[1]||(l[1]=e=>r.$emit("copy",e))},null,8,["nodes","index-key","custom-id","typewriter"])],2))),128))],2))),128))])],10,$t),y(H,{name:"table-node-fade"},{default:P(()=>[t.value?(f(),v("div",Lt,[R(r.$slots,"loading",{isLoading:t.value},()=>[l[2]||(l[2]=k("span",{class:"table-node__spinner animate-spin","aria-hidden":"true"},null,-1)),l[3]||(l[3]=k("span",{class:"sr-only"},"Loading",-1))],!0)])):O("",!0)]),_:3})]))}}),[["__scopeId","data-v-369096fa"]]);jt.install=e=>{e.component(jt.__name,jt)};const Nt={class:"hr-node"},Ht=/* @__PURE__ */le({},[["render",function(e,n){return f(),v("hr",Nt)}],["__scopeId","data-v-639cbad9"]]);Ht.install=e=>{e.component(Ht.__name,Ht)};const Pt={class:"unknown-node"},Dt=/* @__PURE__ */p({__name:"FallbackComponent",props:{node:{}},setup:e=>(n,t)=>(f(),v("div",Pt,_(e.node.raw),1))}),Rt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"VmrContainerNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},customId:{}},setup(e){const n=e,t=C(()=>`vmr-container vmr-container-${n.node.name}`),o=xe(n.customId),r=a({text:Dn,paragraph:Mt,heading:gt,inline_code:Ue,link:tt,image:bn,strong:qn,emphasis:st,strikethrough:Yn,insert:rt,subscript:Un,superscript:Wn,checkbox:de,checkbox_input:de,hardbreak:ft,math_inline:Rn,reference:Kn,list:wt,math_block:On,table:jt},o);return(o,l)=>(f(),v("div",V({class:t.value},e.node.attrs),[(f(!0),v(x,null,b(e.node.children,(t,o,l,i)=>{const a=[t];if(i&&i.key===`${e.indexKey||"vmr-container"}-${o}`&&U(i,a))return i;const s=(f(),A(W((d=t.type,r[d]||Dt)),{key:`${e.indexKey||"vmr-container"}-${o}`,"custom-id":n.customId,node:t,"index-key":`${e.indexKey||"vmr-container"}-${o}`},null,8,["custom-id","node","index-key"]));var d;return s.memo=a,s},l,0),128))],16))}}),[["__scopeId","data-v-fac7405d"]]);Rt.install=e=>{e.component(Rt.__name,Rt)};const Ot=["data-custom-id"],Kt=["data-node-index","data-node-type"],zt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"NodeRenderer",props:{content:{},nodes:{},final:{type:Boolean},parseOptions:{},customMarkdownIt:{},debugPerformance:{type:Boolean,default:!1},customHtmlTags:{},viewportPriority:{type:Boolean},codeBlockStream:{type:Boolean,default:!0},codeBlockDarkTheme:{},codeBlockLightTheme:{},codeBlockMonacoOptions:{},renderCodeBlocksAsPre:{type:Boolean},codeBlockMinWidth:{},codeBlockMaxWidth:{},codeBlockProps:{},mermaidProps:{},d2Props:{},infographicProps:{},showTooltips:{type:Boolean,default:!0},themes:{},isDark:{type:Boolean},customId:{},indexKey:{},typewriter:{type:Boolean,default:!0},batchRendering:{type:Boolean,default:!0},initialRenderBatchSize:{default:40},renderBatchSize:{default:80},renderBatchDelay:{default:16},renderBatchBudgetMs:{default:6},renderBatchIdleTimeoutMs:{default:120},deferNodesUntilVisible:{type:Boolean,default:!0},maxLiveNodes:{default:320},liveNodeBuffer:{default:60}},emits:["copy","handleArtifactClick","click","mouseover","mouseout"],setup(e,{emit:n}){var t,o,r;const l=e,i=n,d=B(),h=B(!1),p=/auto|scroll|overlay/i,g="undefined"!=typeof window,y=C(()=>l.debugPerformance&&g&&"undefined"!=typeof console),w=F(),k=C(()=>{var e;if("boolean"==typeof l.showTooltips)return l.showTooltips;const n=null!=(e=w.showTooltips)?e:w["show-tooltips"];return""===n||!0===n||"true"===n||!1!==n&&"false"!==n&&void 0});function _(e,n){y.value&&console.info(`[markstream-vue][perf] ${e}`,n)}function M(e){if("undefined"==typeof window)return null;const n=null!=e?e:d.value;if(!n)return null;const t=n.ownerDocument||document,o=t.scrollingElement||t.documentElement;let r=n;for(;r&&r!==t.body&&r!==o;){const e=window.getComputedStyle(r),n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(p.test(n)||p.test(t))return r;r=r.parentElement}return null}N("markstreamShowTooltips",k);const T=l.customId?`renderer-${l.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,$=c(T),L=/* @__PURE__ */new Map,j=C(()=>{const{key:e,tags:n}=function(e){if(!e||0===e.length)return{key:"",tags:[]};const n=/* @__PURE__ */new Set,t=[];for(const o of e){const e=K(o);e&&!n.has(e)&&(n.add(e),t.push(e))}return 0===t.length?{key:"",tags:[]}:{key:t.join(","),tags:t}}(l.customHtmlTags);if(!e)return $;const t=L.get(e);if(t)return t;const o=c(T,{customHtmlTags:n});return L.set(e,o),o}),R=C(()=>{const e=j.value;return l.customMarkdownIt?l.customMarkdownIt(e):e});function K(e){const n=String(null!=e?e:"").trim();if(!n)return"";const t=n.match(/^[<\s/]*([A-Z][\w-]*)/i);return t?t[1].toLowerCase():""}const U=C(()=>{var e,n,t,o;const r=null!=(e=l.parseOptions)?e:{},i=null!=(n=l.final)?n:r.final,s=[...null!=(t=l.customHtmlTags)?t:[],...null!=(o=r.customHtmlTags)?o:[]].map(K).filter(Boolean),d=null!=i,u=s.length>0;return d||u?a(a(a({},r),d?{final:i}:{}),u?{customHtmlTags:Array.from(new Set(s))}:{}):r}),Y=C(()=>{var e;if(null==(e=l.nodes)?void 0:e.length)return X(l.nodes.slice());if(l.content){const e=y.value?performance.now():0,n=m(l.content,R.value,U.value);return y.value&&_("parse(sync)",{ms:Math.round(performance.now()-e),nodes:n.length,contentLength:l.content.length}),X(n)}return[]}),Z=C(()=>{var e;return Math.max(1,null!=(e=l.maxLiveNodes)?e:320)}),J=C(()=>{var e;return!((null!=(e=l.maxLiveNodes)?e:0)<=0)&&Y.value.length>Z.value}),Q=C(()=>!1!==l.viewportPriority&&!h.value),ee=hn(e=>{var n;return M(null!=(n=null!=e?e:d.value)?n:null)},Q),ne=g&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame.bind(window):null,te=g&&"function"==typeof window.cancelAnimationFrame?window.cancelAnimationFrame.bind(window):null,oe="undefined"!=typeof globalThis&&void 0!==globalThis.process&&"test"===(null==(o=null==(t=globalThis.process)?void 0:t.env)?void 0:o.NODE_ENV),re=g&&"function"==typeof window.requestIdleCallback,le=C(()=>{var e;const n=Math.trunc(null!=(e=l.renderBatchSize)?e:80);return Number.isFinite(n)?Math.max(0,n):0}),ae=C(()=>{var e;const n=Math.trunc(null!=(e=l.initialRenderBatchSize)?e:le.value);return Number.isFinite(n)?Math.max(0,n):le.value}),se=C(()=>!1!==l.batchRendering&&le.value>0&&g&&!oe),ue=B(0),ce=B({key:l.indexKey,total:0}),me=B(Math.max(1,le.value||1)),pe=q({}),ve=/* @__PURE__ */new Map,ge=/* @__PURE__ */new Map,ye=/* @__PURE__ */new Map,ke=/* @__PURE__ */new WeakMap,be=B(0),_e=C(()=>(be.value,Array.from(ye.entries()).sort((e,n)=>e[0]-n[0]))),Me=B(0),Te=B([]),Be=B([]),Ie=B(null);let $e=null,Se=null;const Ee=C(()=>{var e;return!1!==l.deferNodesUntilVisible&&!((null!=(e=l.maxLiveNodes)?e:0)<=0)&&!J.value&&!(Y.value.length>900)&&Q.value}),Le=C(()=>{var e;return se.value&&(null!=(e=l.maxLiveNodes)?e:0)<=0}),je=B({batchSize:le.value,initial:ae.value,delay:null!=(r=l.renderBatchDelay)?r:16,enabled:Le.value}),Ne=C(()=>!!ee&&(Ee.value||J.value)),He=C(()=>{var e;return Math.max(0,null!=(e=l.liveNodeBuffer)?e:60)}),Pe=B(0),De=q({start:0,end:0}),Re=/* @__PURE__ */new Map,Oe=C(()=>{if(!J.value)return Y.value.length;const e=He.value,n=Math.max(De.end+e,ae.value),t=Math.min(Y.value.length,n);return Math.max(ue.value,t)});function Ke(e){var n,t,o,r;const l=M(null!=(n=null!=e?e:d.value)?n:null);if(l)return l;const i=null!=(r=null!=(o=null==e?void 0:e.ownerDocument)?o:null==(t=d.value)?void 0:t.ownerDocument)?r:"undefined"!=typeof document?document:null;return(null==i?void 0:i.scrollingElement)||(null==i?void 0:i.documentElement)||null}function ze(e){if(!g)return!1;try{const n=window.getComputedStyle(e);return!!(n.display||"").toLowerCase().includes("flex")&&(n.flexDirection||"").toLowerCase().endsWith("reverse")}catch(n){return!1}}function Ae(){$e&&($e(),$e=null),Ie.value=null}function We(){if(!g||!J.value)return;const e=Ke();if(!e||Ie.value===e)return;Ae();const n=()=>Xe();e.addEventListener("scroll",n,{passive:!0}),Ie.value=e,$e=()=>{e.removeEventListener("scroll",n)}}function Ve(){var e,n,t;if(!Se)return;const o=null!=(t=null==(n=null==(e=d.value)?void 0:e.ownerDocument)?void 0:n.defaultView)?t:"undefined"!=typeof window?window:null;Se.viaTimeout?o?o.clearTimeout(Se.id):clearTimeout(Se.id):null==te||te(Se.id),Se=null}function Xe(e={}){var n,t,o;if(!J.value)return;if(!g)return void qe(!0);if(e.immediate)return Ve(),void qe(!0);if(Se)return;const r=()=>{Se=null,qe()};if(ne)Se={id:ne(r),viaTimeout:!1};else{const e=null!=(o=null==(t=null==(n=d.value)?void 0:n.ownerDocument)?void 0:t.defaultView)?o:"undefined"!=typeof window?window:null,l=e?e.setTimeout(r,16):setTimeout(r,16);Se={id:l,viaTimeout:!0}}}function qe(e=!1){var n,t,o,r,l,i,a;if(!J.value)return;const s=Ie.value||Ke();if(!s)return;const u=s.ownerDocument||(null==(n=d.value)?void 0:n.ownerDocument)||document,c=(null==u?void 0:u.defaultView)||("undefined"!=typeof window?window:null),m=s===(null==u?void 0:u.documentElement)||s===(null==u?void 0:u.body),h=Y.value.length;if(!m&&h>0&&ze(s)){const n=s.clientHeight||0,t=s.scrollTop,o=t<0?-t:t,r=function(e){var n;const t=Y.value;if(!t.length)return 0;if(e<=0)return Math.max(0,t.length-1);if(Me.value===t.length){const n=rn(0,t.length);return dn(Math.max(0,n-e))}let o=e;for(let r=t.length-1;r>=0;r--){const e=null!=(n=Ye[r])?n:on.value;if(o<=e)return r;o-=e}return 0}(Math.max(0,o)+.5*Math.max(0,n)),l=Ge(r,0,Math.max(0,h-1));return void((e||Math.abs(l-Pe.value)>1)&&(Pe.value=l))}const p=m?null:s.getBoundingClientRect(),f=m?0:p.top,v=m?null!=(o=null!=(t=null==c?void 0:c.innerHeight)?t:s.clientHeight)?o:0:p.bottom,g=_e.value;let y=null,w=null;for(const[d,x]of g){if(!x)continue;const e=x.getBoundingClientRect();e.bottom<=f||e.top>=v||(null==y&&(y=d),w=d)}if(null==y||null==w){const e=d.value;if(!e)return;const n=m?{top:0}:s.getBoundingClientRect(),t=function(e,n,t){var o,r,l,i,a,s;if(t)return null!=(i=null!=(l=null==(o=null==n?void 0:n.documentElement)?void 0:o.scrollTop)?l:null==(r=null==n?void 0:n.body)?void 0:r.scrollTop)?i:0;const d=e.scrollTop;if(!ze(e))return d;const u=d<0?-d:d;return Math.max(0,(null!=(a=e.scrollHeight)?a:0)-(null!=(s=e.clientHeight)?s:0))-u}(s,u,m),o=m?(()=>{const t=e.getBoundingClientRect(),o=(m?0:n.top)-t.top;return Math.max(0,o)})():(()=>{const n=function(e,n){let t=e,o=0,r=0;for(;t&&t!==n&&r++<64;)o+=t.offsetTop||0,t=t.offsetParent;return o}(e,s);return Math.max(0,t-n)})(),h=m?null!=(a=null!=(i=null!=(l=null==c?void 0:c.innerHeight)?l:null==(r=null==u?void 0:u.documentElement)?void 0:r.clientHeight)?i:s.clientHeight)?a:0:s.clientHeight,p=dn(o+.5*Math.max(0,h));return void(Pe.value=Ge(p,0,Math.max(0,Y.value.length-1)))}const k=Math.round((y+w)/2);!e&&Math.abs(k-Pe.value)<=1||(Pe.value=Ge(k,0,Math.max(0,Y.value.length-1)))}function Ge(e,n,t){return Math.min(Math.max(e,n),t)}const Ye=q({}),Ze=q({total:0,count:0});function Je(){for(const e of Object.keys(Ye))delete Ye[Number(e)];Ze.total=0,Ze.count=0,Me.value=0,Te.value=[],Be.value=[]}function Qe(e,n,t){for(let o=n+1;o<e.length;o+=o&-o)e[o]+=t}function en(e,n){let t=0;for(let o=n+1;o>0;o-=o&-o)t+=e[o];return t}function nn(e,n,t){if(t<=n)return 0;const o=en(e,t-1);return n<=0?o:o-en(e,n-1)}function tn(e){Me.value=e;const n=new Array(e+1).fill(0),t=new Array(e+1).fill(0);for(const[o,r]of Object.entries(Ye)){const l=Number(o),i=Number(r);!Number.isFinite(l)||l<0||l>=e||!Number.isFinite(i)||i<=0||(Qe(n,l,i),Qe(t,l,1))}Te.value=n,Be.value=t}const on=C(()=>Ze.count>0?Math.max(12,Ze.total/Ze.count):32);function rn(e,n){var t,o;if(e>=n)return 0;if(Me.value!==Y.value.length){let o=0;for(let r=e;r<n;r++)o+=null!=(t=Ye[r])?t:on.value;return o}const r=Te.value,l=Be.value;if(!r.length||!l.length){let t=0;for(let r=e;r<n;r++)t+=null!=(o=Ye[r])?o:on.value;return t}return nn(r,e,n)+(n-e-nn(l,e,n))*on.value}I(()=>Y.value.length,e=>{e<=0?Je():(e<Me.value&&function(e){if(e<=0)return void Je();let n=0,t=0;for(const[o,r]of Object.entries(Ye)){const l=Number(o),i=Number(r);!Number.isFinite(l)||l<0||l>=e||!Number.isFinite(i)||i<=0?delete Ye[l]:(n+=i,t++)}Ze.total=n,Ze.count=t}(e),e!==Me.value&&tn(e))},{immediate:!0});const ln=C(()=>{if(!J.value)return Y.value.map((e,n)=>({node:e,index:n}));const e=Y.value.length,n=Ge(De.start,0,e),t=Ge(De.end,n,e);return Y.value.slice(n,t).map((e,t)=>({node:e,index:n+t}))}),an=C(()=>J.value?rn(0,Math.min(De.start,Y.value.length)):0),sn=C(()=>{if(!J.value)return 0;const e=Y.value.length;return rn(Math.min(De.end,e),e)});function dn(e){var n;if(e<=0)return 0;const t=Y.value;if(Me.value===t.length&&Te.value.length&&Be.value.length){const n=on.value,o=Te.value,r=Be.value,l=e=>e<=0?0:en(o,e-1)+(e-en(r,e-1))*n;let i=0,a=t.length-1,s=t.length-1;for(;i<=a;){const n=i+a>>1;l(n+1)>=e?(s=n,a=n-1):i=n+1}return s}let o=e;for(let r=0;r<t.length;r++){const e=null!=(n=Ye[r])?n:on.value;if(o<=e)return r;o-=e}return Math.max(0,t.length-1)}function un(){be.value+=1}function cn(e){if(!ve.size)return;if(!J.value)return;let n=!1;for(const[t,o]of ve)t>=e&&(o.destroy(),ve.delete(t),Ee.value&&delete pe[t],_n(t),ye.delete(t)&&(n=!0));n&&un()}function mn(e,n){Ee.value&&(pe[e]=n),n&&(J.value?Xe():Pe.value=Ge(e,0,Math.max(0,Y.value.length-1)))}function pn(e){const n=ve.get(e);n&&(n.destroy(),ve.delete(e)),_n(e)}function fn(e,n){let t=!1;if(n){const o=ye.get(e);ye.set(e,n),o!==n&&(t=!0)}else ye.delete(e)&&(t=!0);if(t&&un(),n||_n(e),!Ne.value||!ee)return pn(e),void(n?mn(e,!0):Ee.value&&delete pe[e]);if(!J.value&&Ee.value&&!h.value&&ve.size>=640&&(function(){if(!h.value){h.value=!0;for(const e of ve.values())e.destroy();if(ve.clear(),g)for(const e of ge.values())window.clearTimeout(e);ge.clear();for(const e of Object.keys(pe))delete pe[e]}}(),!Ne.value||!ee))return pn(e),void(n?mn(e,!0):Ee.value&&delete pe[e]);if(e<ae.value&&!J.value)return pn(e),void mn(e,!0);if(!n)return pn(e),void(Ee.value&&delete pe[e]);pn(e);const o=ee(n,{rootMargin:"400px"});o&&(ve.set(e,o),mn(e,o.isVisible.value),Ee.value&&function(e){if(!g||!Ee.value)return;_n(e);const n=e%17*23,t=window.setTimeout(()=>{var n,t;if(ge.delete(e),!Ee.value)return;if(!0===pe[e])return;const o=ye.get(e);if(!o)return void delete pe[e];const r=Ke(o),l=o.ownerDocument||document,i=l.defaultView||window,a=!r||r===l.documentElement||r===l.body,s=!a&&r?r.getBoundingClientRect():null,d=a?0:s.top,u=a?null!=(t=null!=(n=i.innerHeight)?n:null==r?void 0:r.clientHeight)?t:0:s.bottom,c=o.getBoundingClientRect();c.bottom>=d-500&&c.top<=u+500&&mn(e,!0)},1800+n);ge.set(e,t)}(e),o.whenVisible.then(()=>{_n(e),mn(e,!0)}).catch(()=>{}).finally(()=>{ve.get(e)===o&&ve.delete(e);try{o.destroy()}catch(n){}}),J.value&&Xe())}let vn=null,gn=null,yn=!1,wn=null,kn=null;function xn(){g&&(null!=vn&&(null==te||te(vn),vn=null),null!=gn&&(window.clearTimeout(gn),gn=null),null!=kn&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(kn),kn=null),yn=!1,wn=null)}function _n(e){if(!g)return;const n=ge.get(e);null!=n&&(window.clearTimeout(n),ge.delete(e))}function Mn(e,n={}){var t,o;if(!Le.value)return;const r=Oe.value;if(ue.value>=r)return;const i=Math.max(1,e),a=e=>{var n;vn=null,gn=null,kn=null,yn=!1;const t=null!=wn?wn:i;wn=null;const o=Math.max(2,null!=(n=l.renderBatchBudgetMs)?n:6),a=e=>{const n="undefined"!=typeof performance?performance.now():Date.now();ue.value=Math.min(r,ue.value+Math.max(1,e)),cn(ue.value);const t=("undefined"!=typeof performance?performance.now():Date.now())-n;return function(e){var n;if(!Le.value)return;const t=Math.max(2,null!=(n=l.renderBatchBudgetMs)?n:6),o=Math.max(1,le.value||1),r=Math.max(1,Math.floor(o/4));e>1.2*t?me.value=Math.max(r,Math.floor(.7*me.value)):e<.5*t&&me.value<o&&(me.value=Math.min(o,Math.ceil(1.2*me.value)))}(t),t};let s=t;for(;(a(s),!(ue.value>=r)&&e)&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)s=Math.max(1,Math.round(me.value));ue.value<r&&Tn()};if(!g||n.immediate)return void a();const s=Math.max(0,null!=(t=l.renderBatchDelay)?t:16);if(wn=null!=wn?Math.max(wn,i):i,!yn){if(yn=!0,!oe&&re&&window.requestIdleCallback){const e=Math.max(0,null!=(o=l.renderBatchIdleTimeoutMs)?o:120);return void(kn=window.requestIdleCallback(e=>{a(e)},{timeout:e}))}ne&&!oe?vn=ne(()=>{0!==s?gn=window.setTimeout(()=>a(),s):a()}):gn=window.setTimeout(()=>a(),s)}}function Tn(){Le.value&&Mn(se.value?Math.max(1,Math.round(me.value)):Math.max(1,le.value))}I([()=>Y.value,()=>Y.value.length,()=>Le.value,()=>le.value,()=>ae.value,()=>l.renderBatchDelay,()=>l.indexKey],()=>{var e;const n=Y.value.length,t=ce.value,o=l.indexKey,r=void 0!==o&&o!==t.key,i=n!==t.total,a=r||i;ce.value={key:o,total:n};const s=je.value,d=null!=(e=l.renderBatchDelay)?e:16,u=s.batchSize!==le.value||s.initial!==ae.value||s.delay!==d||s.enabled!==Le.value;je.value={batchSize:le.value,initial:ae.value,delay:d,enabled:Le.value},r&&(Je(),n>0&&tn(n)),(a||u||!Le.value)&&xn(),(a||u)&&(me.value=Math.max(1,le.value||1)),a&&J.value&&Xe({immediate:!0});const c=Oe.value;if(!n)return ue.value=0,void cn(0);if(!Le.value)return ue.value=c,void cn(ue.value);const m=r||0===t.total;ue.value=m||u?Math.min(c,ae.value):Math.min(ue.value,c);const h=Math.max(1,ae.value||le.value||n);ue.value<c?Mn(h,{immediate:!g}):cn(ue.value)},{immediate:!0}),I(()=>J.value,e=>{if(!e)return Ae(),void Ve();We(),Xe({immediate:!0})},{immediate:!0}),I([()=>Y.value.length,()=>J.value],e=>u(null,[e],function*([e,n]){n&&e&&g&&(yield G(),Xe({immediate:!0}))}),{flush:"post"}),I(()=>d.value,()=>{J.value&&(We(),Xe({immediate:!0}))}),I(()=>Y.value.length,()=>{J.value&&Xe({immediate:!0})}),I(()=>Ee.value,e=>{if(e)for(const[n,t]of ye)fn(n,t);else{for(const e of ve.values())e.destroy();ve.clear();for(const e of Array.from(ge.keys()))_n(e);for(const e of Object.keys(pe))delete pe[e];for(const[e,n]of ye)n&&mn(e,!0)}},{immediate:!1}),I([()=>l.viewportPriority,()=>Y.value.length],([e,n])=>{!1!==e?h.value&&n<=200&&(h.value=!1):h.value=!1}),I(()=>ue.value,()=>{J.value&&Xe({immediate:!0})}),I([Pe,Z,He,()=>Y.value.length,J],()=>{!function(){const e=Y.value.length;if(!J.value||0===e)return De.start=0,void(De.end=e);const n=Math.min(Z.value,e),t=He.value,o=Ge(Pe.value-t,0,Math.max(0,e-n));De.start=o,De.end=Math.min(e,o+n)}()},{immediate:!0}),I([()=>Y.value.length,J,Z,He,()=>De.start,()=>De.end],([e,n,t,o,r,l])=>{y.value&&_("virtualization",{nodes:e,virtualization:n,maxLiveNodes:t,buffer:o,focusIndex:Pe.value,scroll:n?(()=>{const e=Ie.value||Ke();return e?{reverse:ze(e),scrollTop:Math.round(e.scrollTop),scrollTopAbs:Math.round(Math.abs(e.scrollTop)),scrollHeight:Math.round(e.scrollHeight),clientHeight:Math.round(e.clientHeight)}:null})():null,liveRange:{start:r,end:l},rendered:ue.value})}),I(()=>Oe.value,(e,n)=>{Le.value&&("number"==typeof n&&e<=n||e>ue.value&&Tn())}),S(()=>{xn();for(const e of ve.values())e.destroy();ve.clear();for(const e of Array.from(ge.keys()))_n(e);Ae(),Ve()});const Cn=z(()=>u(null,null,function*(){try{return(yield import("./index4.js")).default}catch(e){return console.warn('[markstream-vue] Optional peer dependencies for CodeBlockNode are missing. Falling back to inline-code rendering (no Monaco). To enable full code block features, please install "stream-monaco".',e),Bt}})),Bn=z(()=>u(null,null,function*(){try{return(yield import("./index5.js")).default}catch(e){return console.warn('[markstream-vue] Optional peer dependencies for MermaidBlockNode are missing. Falling back to preformatted code rendering. To enable Mermaid rendering, please install "mermaid".',e),Bt}})),In=z(()=>u(null,null,function*(){try{return(yield import("./index6.js")).default}catch(e){return console.warn('[markstream-vue] Optional peer dependencies for InfographicBlockNode are missing. Falling back to preformatted code rendering. To enable Infographic rendering, please install "@antv/infographic".',e),Bt}})),$n=z(()=>u(null,null,function*(){try{return(yield import("./index7.js")).default}catch(e){return console.warn('[markstream-vue] Optional peer dependencies for D2BlockNode are missing. Falling back to preformatted code rendering. To enable D2 rendering, please install "@terrastruct/d2".',e),Bt}})),Sn=C(()=>l.renderCodeBlocksAsPre?Bt:Cn),En={text:Dn,paragraph:Mt,heading:gt,code_block:Cn,list:wt,list_item:yt,blockquote:ie,table:jt,definition_list:he,footnote:ht,footnote_reference:Ce,footnote_anchor:ut,admonition:qt,vmr_container:Rt,hardbreak:ft,link:tt,image:bn,thematic_break:Ht,math_inline:Rn,math_block:On,strong:qn,emphasis:st,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,checkbox:de,checkbox_input:de,inline_code:Ue,html_inline:Fe,reference:Kn,html_block:bt},Ln=C(()=>(we.value,xe(l.customId))),jn=C(()=>null!=l.indexKey?String(l.indexKey):"markdown-renderer"),Nn=C(()=>a(a({stream:l.codeBlockStream,darkTheme:l.codeBlockDarkTheme,lightTheme:l.codeBlockLightTheme,monacoOptions:l.codeBlockMonacoOptions,themes:l.themes,minWidth:l.codeBlockMinWidth,maxWidth:l.codeBlockMaxWidth},"boolean"==typeof k.value?{showTooltips:k.value}:{}),l.codeBlockProps||{})),Hn=C(()=>a({},l.mermaidProps||{})),Pn=C(()=>a({},l.d2Props||{})),zn=C(()=>a({},l.infographicProps||{})),An=C(()=>({typewriter:l.typewriter})),Fn=C(()=>a(a({},An.value),"boolean"==typeof k.value?{showTooltip:k.value}:{})),Vn=C(()=>a(a({},An.value),"boolean"==typeof k.value?{showTooltips:k.value}:{})),Xn=C(()=>ln.value.map(e=>{const n=function(e){var n,t,o,r,l,i,s;if("code_block"!==e.type)return e;const d=e,u=[String(null!=(n=d.language)?n:""),String(null!=(t=d.loading)?t:""),String(null!=(o=d.diff)?o:""),String(null!=(r=d.code)?r:""),String(null!=(l=d.originalCode)?l:""),String(null!=(i=d.updatedCode)?i:""),String(null!=(s=d.raw)?s:"")].join("\0"),c=ke.get(d);if(c&&c.signature===u)return c.node;const m=a({},d);return ke.set(d,{signature:u,node:m}),m}(e.node),t=Gn(n);return s(a({},e),{node:n,component:Zn(n,t),bindings:Jn(n,t),isCodeBlock:"code_block"===n.type,indexKey:`${jn.value}-${e.index}`})}));function Gn(e){var n;return"code_block"===(null==e?void 0:e.type)?String(null!=(n=e.language)?n:"").trim().toLowerCase():""}function Zn(e,n){if(!e)return Dt;const t=Ln.value,o=t[String(e.type)];if("code_block"===e.type){const r=null!=n?n:Gn(e);if("mermaid"===r)return t.mermaid||Bn;if("infographic"===r)return t.infographic||In;if("d2"===r||"d2lang"===r)return t.d2||$n;if(o)return o;return t.code_block||Sn.value}return o||En[String(e.type)]||Dt}function Jn(e,n){const t=null!=n?n:Gn(e);return"mermaid"===t?Hn.value:"infographic"===t?zn.value:"d2"===t||"d2lang"===t?Pn.value:"link"===e.type?Fn.value:"list"===e.type?Vn.value:"code_block"===e.type?Nn.value:An.value}function Qn(e){i("click",e)}function et(e){var n;(null==(n=e.target)?void 0:n.closest("[data-node-index]"))&&i("mouseover",e)}function nt(e){var n;(null==(n=e.target)?void 0:n.closest("[data-node-index]"))&&i("mouseout",e)}return(e,n)=>(f(),v("div",{ref_key:"containerRef",ref:d,class:E(["markstream-vue markdown-renderer",[{dark:l.isDark},{virtualized:J.value}]]),"data-custom-id":l.customId,onClick:Qn,onMouseover:et,onMouseout:nt},[J.value?(f(),v("div",{key:0,class:"node-spacer",style:D({height:`${an.value}px`}),"aria-hidden":"true"},null,4)):O("",!0),(f(!0),v(x,null,b(Xn.value,e=>{var t,o;return f(),v("div",{key:e.index,ref_for:!0,ref:n=>fn(e.index,n),class:"node-slot","data-node-index":e.index,"data-node-type":e.node.type},[(o=e.index,Le.value&&o>=ue.value||Ee.value&&!(o<ae.value)&&!0!==pe[o]?(f(),v("div",{key:1,class:"node-placeholder",style:D({height:`${null!=(t=Ye[e.index])?t:on.value}px`})},null,4)):(f(),v("div",{key:0,ref_for:!0,ref:n=>function(e,n){n?(Re.set(e,n),queueMicrotask(()=>{!function(e,n){if(!Number.isFinite(n)||n<=0)return;const t=Ye[e];if(Ye[e]=n,t?Ze.total+=n-t:(Ze.total+=n,Ze.count++),Me.value>e){const o=Te.value,r=Be.value;if(o.length&&r.length)if(t){const r=n-t;0!==r&&Qe(o,e,r)}else Qe(o,e,n),Qe(r,e,1)}}(e,n.offsetHeight)})):Re.delete(e)}(e.index,n),class:"node-content"},[e.isCodeBlock||!1===l.typewriter?(f(),A(W(e.component),V({key:1,node:e.node,loading:e.node.loading,"index-key":e.indexKey},{ref_for:!0},e.bindings,{"custom-id":l.customId,"is-dark":l.isDark,onCopy:n[2]||(n[2]=e=>i("copy",e)),onHandleArtifactClick:n[3]||(n[3]=e=>i("handleArtifactClick",e))}),null,16,["node","loading","index-key","custom-id","is-dark"])):(f(),A(H,{key:0,name:"typewriter",appear:""},{default:P(()=>[(f(),A(W(e.component),V({node:e.node,loading:e.node.loading,"index-key":e.indexKey},{ref_for:!0},e.bindings,{"custom-id":l.customId,"is-dark":l.isDark,onCopy:n[0]||(n[0]=e=>i("copy",e)),onHandleArtifactClick:n[1]||(n[1]=e=>i("handleArtifactClick",e))}),null,16,["node","loading","index-key","custom-id","is-dark"]))]),_:2},1024))],512)))],8,Kt)}),128)),J.value?(f(),v("div",{key:1,class:"node-spacer",style:D({height:`${sn.value}px`}),"aria-hidden":"true"},null,4)):O("",!0)],42,Ot))}}),[["__scopeId","data-v-116eecac"]]);zt.install=e=>{var n,t;const o=null!=(t=null!=(n=zt.__name)?n:zt.name)?t:"NodeRenderer";e.component(o,zt)};const At={key:0,class:"admonition-icon"},Wt={class:"admonition-title"},Ft=["aria-expanded","aria-controls","title"],Vt={key:0},Ut={key:1},Xt=["id"],qt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"AdmonitionNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e,{emit:n}){var t;const o=e,r=n,l={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"},i=C(()=>{if(o.node.title&&o.node.title.trim().length)return o.node.title;const e=o.node.kind||"note";return e.charAt(0).toUpperCase()+e.slice(1)}),a=B(!!o.node.collapsible&&!(null==(t=o.node.open)||t));function s(){o.node.collapsible&&(a.value=!a.value)}const d=`admonition-${Math.random().toString(36).slice(2,9)}`;return(n,t)=>(f(),v("div",{class:E(["admonition",[`admonition-${o.node.kind}`,o.isDark?"is-dark":""]])},[k("div",{id:d,class:"admonition-header"},[l[o.node.kind]?(f(),v("span",At,_(l[o.node.kind]),1)):O("",!0),k("span",Wt,_(i.value),1),o.node.collapsible?(f(),v("button",{key:1,class:"admonition-toggle","aria-expanded":!a.value,"aria-controls":`${d}-content`,title:a.value?"Expand":"Collapse",onClick:s},[a.value?(f(),v("span",Vt,"▶")):(f(),v("span",Ut,"▼"))],8,Ft)):O("",!0)]),Y(k("div",{id:`${d}-content`,class:"admonition-content","aria-labelledby":d},[g([o.node.children],()=>y(w(zt),{"index-key":`admonition-${e.indexKey}`,nodes:o.node.children,"custom-id":o.customId,typewriter:o.typewriter,onCopy:t[0]||(t[0]=e=>r("copy",e))},null,8,["index-key","nodes","custom-id","typewriter"]),t,1)],8,Xt),[[Z,!a.value]])],2))}}),[["__scopeId","data-v-5e95c2b7"]]);qt.install=e=>{e.component(qt.__name,qt)};const Gt=()=>import("@terrastruct/d2");let Yt=null,Zt=Gt;function Jt(e){Zt=e,Yt=null}function Qt(e){Jt(null!=e?e:Gt)}function eo(){Jt(null)}function no(){return"function"==typeof Zt}function to(){return u(this,null,function*(){if(Yt)return Yt;const e=Zt;if(!e)return null;let n;try{n=yield e()}catch(t){if(e===Gt)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw t}return n?(Yt=function(e){var n;if(!e)return e;if(e.D2&&"function"==typeof e.D2)return e.D2;if(e.default&&e.default.D2&&"function"==typeof e.default.D2)return e.default.D2;const t=null!=(n=e.default)?n:e;return"function"==typeof t?t:(null==t?void 0:t.D2)&&"function"==typeof t.D2?t.D2:t}(n),Yt):null})}let oo=!1,ro=null,lo=!1;function io(){return u(this,null,function*(){if(ro)return ro;if(lo)return null;try{return ro=yield import("stream-monaco"),yield function(e){return u(this,null,function*(){if(oo)return;oo=!0;const n=null==globalThis?void 0:globalThis.MonacoEnvironment;return!n||"function"!=typeof n.getWorker&&"function"!=typeof n.getWorkerUrl?e.preloadMonacoWorkers():void 0})}(ro),(yield function(e){return u(this,null,function*(){const n=null==e?void 0:e.getOrCreateHighlighter;if("function"!=typeof n)return!0;try{const e=yield n(["vitesse-dark","vitesse-light"],["plaintext","text","javascript"]);return e&&"function"==typeof e.codeToTokens&&e.codeToTokens("const a = 1",{lang:"javascript",theme:"vitesse-dark"}),!0}catch(t){return console.warn("[markstream-vue] Failed to warm up Shiki tokenizer; disabling stream-monaco for this session.",t),!1}})}(ro))?ro:(ro=null,lo=!0,null)}catch(e){return lo=!0,null}})}function ao({R:e,H:n=0,B:t=50}){const o=e*(1-n)||1e-6;return Math.max(1,Math.floor(t/o))}function so(e){const n=e.length+10*(e.match(/\\/g)||[]).length;return n<10?"simple":n<40?"medium":"complex"}function uo(e){switch(e){case"simple":return 3;case"medium":return 10;case"complex":return 30}}function co(e,n){var t,o;let r=0;for(const l of e){const e=uo(so(l));e>r&&(r=e)}return ao({R:r,H:null!=(t=null==n?void 0:n.H)?t:0,B:null!=(o=null==n?void 0:n.B)?o:50})}const mo='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#8caaee" d="m 6.665625,1.0107144 c 0.54375,0.090628 0.9125,0.6062693 0.821875,1.1500367 L 7.18125,3.9983098 h 2.971875 L 10.5125,1.8326156 c 0.09063,-0.5437673 0.60625,-0.9125291 1.15,-0.8219012 0.54375,0.090628 0.9125,0.6062693 0.821875,1.1500367 L 12.18125,3.9983098 H 14 c 0.553125,0 1,0.4468892 1,1.0000319 0,0.5531426 -0.446875,1.0000319 -1,1.0000319 H 11.846875 L 11.18125,9.9985013 H 13 c 0.553125,0 1,0.4468897 1,1.0000317 0,0.553143 -0.446875,1.000032 -1,1.000032 H 10.846875 L 10.4875,14.164259 c -0.09063,0.543768 -0.60625,0.912529 -1.15,0.821902 -0.54375,-0.09063 -0.9125,-0.60627 -0.821875,-1.150037 l 0.30625,-1.834434 h -2.975 L 5.4875,14.167384 c -0.090625,0.543768 -0.60625,0.91253 -1.15,0.821902 C 3.79375,14.898658 3.425,14.383016 3.515625,13.839249 L 3.81875,11.998565 H 2 c -0.553125,0 -1,-0.446889 -1,-1.000032 C 1,10.445391 1.446875,9.9985013 2,9.9985013 H 4.153125 L 4.81875,5.9983736 H 3 c -0.553125,0 -1,-0.4468893 -1,-1.0000319 C 2,4.445199 2.446875,3.9983098 3,3.9983098 H 5.153125 L 5.5125,1.8326156 C 5.603125,1.2888483 6.11875,0.9200865 6.6625,1.0107144 Z M 6.846875,5.9983736 6.18125,9.9985013 H 9.153125 L 9.81875,5.9983736 Z" />\n</svg>\n',ho='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round">\n <path d="M2 15.5c-.7 0-1.5-.8-1.5-1.5V5c0-.7.8-1.5 1.5-1.5h9c.7 0 1.5.8 1.5 1.5v9c0 .7-.8 1.5-1.5 1.5z" />\n <path d="m1.2 3.8 3.04-2.5S5.17.5 5.7.5h8.4c.66 0 1.4.73 1.4 1.4v7.73a2.7 2.7 0 01-.7 1.75l-2.68 3.51M3 8.5l3 2-3 2m4 0h2" />\n </g>\n</svg>\n',po='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#c6d0f5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M13.5 6.5v6a2 2 0 01-2 2h-7a2 2 0 01-2-2v-9c0-1.1.9-2 2-2h4.01" />\n <path d="m8.5 1.5 5 5h-4a1 1 0 01-1-1zm-3 10h5m-5-3h5m-5-3h1" />\n </g>\n</svg>\n';let fo=null,vo=null,go=null;const yo=M(0),wo={"":po,plain:po,text:po,javascript:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#e5c890" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4.5 11c0 .828427.6715729 1.5 1.5 1.5.8284271 0 1.5-.671573 1.5-1.5V7.5M12.5 8.75C12.5 8.05964406 11.9627417 7.5 11.3 7.5L10.7 7.5C10.0372583 7.5 9.5 8.05964406 9.5 8.75 9.5 9.44035594 10.0372583 10 10.7 10L11.3 10C11.9627417 10 12.5 10.5596441 12.5 11.25 12.5 11.9403559 11.9627417 12.5 11.3 12.5L10.7 12.5C10.0372583 12.5 9.5 11.9403559 9.5 11.25" />\n <path d="m 4,1.5 h 8 c 1.385,0 2.5,1.115 2.5,2.5 v 8 c 0,1.385 -1.115,2.5 -2.5,2.5 H 4 C 2.615,14.5 1.5,13.385 1.5,12 V 4 C 1.5,2.615 2.615,1.5 4,1.5 Z" />\n </g>\n</svg>\n',typescript:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 1.5h8A2.5 2.5 0 0114.5 4v8a2.5 2.5 0 01-2.5 2.5H4A2.5 2.5 0 011.5 12V4A2.5 2.5 0 014 1.5" />\n <path d="M12.5 8.75c0-.69-.54-1.25-1.2-1.25h-.6c-.66 0-1.2.56-1.2 1.25S10.04 10 10.7 10h.6c.66 0 1.2.56 1.2 1.25s-.54 1.25-1.2 1.25h-.6c-.66 0-1.2-.56-1.2-1.25m-3-3.75v5M5 7.5h3" />\n </g>\n</svg>\n',jsx:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#99d1db" stroke-linecap="round" stroke-linejoin="round">\n <path d="M8 10.8c4.14 0 7.5-1.25 7.5-2.8S12.14 5.2 8 5.2.5 6.45.5 8s3.36 2.8 7.5 2.8" />\n <path d="M5.52 9.4c2.07 3.5 4.86 5.72 6.23 4.95 1.37-.78.8-4.24-1.27-7.75C8.41 3.1 5.62.88 4.25 1.65c-1.37.78-.8 4.24 1.27 7.75" />\n <path d="M5.52 6.6c-2.07 3.5-2.64 6.97-1.27 7.75 1.37.77 4.16-1.45 6.23-4.95s2.64-6.97 1.27-7.75C10.38.88 7.59 3.1 5.52 6.6" />\n <path d="M8.5 8a.5.5 0 01-.5.5.5.5 0 01-.5-.5.5.5 0 01.5-.5.5.5 0 01.5.5" />\n </g>\n</svg>\n',tsx:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round">\n <path d="M8 11.3c4.14 0 7.5-1.28 7.5-2.86S12.14 5.58 8 5.58.5 6.86.5 8.44s3.36 2.87 7.5 2.87Z" />\n <path d="M5.52 9.87c2.07 3.6 4.86 5.86 6.23 5.07 1.37-.8.8-4.34-1.27-7.93S5.62 1.16 4.25 1.95s-.8 4.34 1.27 7.92" />\n <path d="M5.52 7.01c-2.07 3.59-2.64 7.14-1.27 7.93s4.16-1.48 6.23-5.07c2.07-3.58 2.64-7.13 1.27-7.92-1.37-.8-4.16 1.47-6.23 5.06" />\n <path d="M8.5 8.44a.5.5 0 01-.5.5.5.5 0 01-.5-.5.5.5 0 01.5-.5.5.5 0 01.5.5" />\n </g>\n</svg>\n',html:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="#ef9f76" d="M1.5 1.5h13L13 13l-5 2-5-2z" />\n <path stroke="#c6d0f5" d="M11 4.5H5l.25 3h5.5l-.25 3-2.5 1-2.5-1-.08-1" />\n </g>\n</svg>\n',css:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#ca9ee6" stroke-linecap="round" stroke-linejoin="round">\n <path d="m4 1.5h8c1.38 0 2.5 1.12 2.5 2.5v8c0 1.38-1.12 2.5-2.5 2.5h-8c-1.38 0-2.5-1.12-2.5-2.5v-8c0-1.38 1.12-2.5 2.5-2.5z" />\n <path stroke-width=".814" d="m 10.240861,11.529149 c 0,0.58011 0.437448,1.039154 0.96002,1.035371 l 0.451635,-0.0032 c 0.522572,-0.0036 0.949379,-0.451477 0.949379,-1.032848 0,-0.581372 -0.426807,-1.065638 -0.949379,-1.065638 l -0.451635,3.4e-5 c -0.522572,3.9e-5 -0.949379,-0.4855273 -0.949379,-1.0656374 0,-0.5801104 0.426807,-1.0378931 0.949379,-1.0378931 l 0.451635,2.825e-4 c 0.522572,3.267e-4 0.951743,0.4577827 0.951743,1.0378931 M 6.8003972,11.529149 c 0,0.58011 0.4374474,1.039154 0.9600196,1.035371 l 0.46464,-0.0032 c 0.5225722,-0.0035 0.9363738,-0.451477 0.9363738,-1.031587 0,-0.580111 -0.4090724,-1.065638 -0.9316446,-1.065638 l -0.4693692,3.4e-5 c -0.5225722,3.8e-5 -0.949379,-0.4855272 -0.949379,-1.0656373 0,-0.5801104 0.4268068,-1.0378931 0.949379,-1.0378931 h 0.4516348 c 0.5225722,0 0.9635665,0.4577827 0.9635665,1.0378931 M 3.4072246,11.529149 c 0,0.58011 0.4374474,1.051765 0.9600196,1.051765 H 4.818879 c 0.5225722,0 0.949379,-0.456521 0.949379,-1.037893 m 0.01129,-2.1312747 c 0,-0.5801103 -0.4374474,-1.037893 -0.9600196,-1.037893 L 4.3678939,8.3741358 C 3.8453217,8.3744624 3.4078743,8.8420074 3.4078743,9.4233788 v 2.1186642" />\n </g>\n</svg>\n',scss:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#f4b8e4" stroke-linecap="round" stroke-linejoin="round" d="M6.75 6.38c1.85 1.07 3.35.74 4.83-.2 1.5-.95 2.7-2.78 1.3-4.15-.7-.68-3.25-.8-5.62.19-2.36.99-4.59 3.02-4.74 4.11-.31 2.19 3.15 2.88 3.64 4.23s.28 1.98-.2 2.83c-.5.85-1.96 1.62-2.8.68-.83-.95 1.67-2.75 2.98-3.25 1.3-.5 3.1-.4 3.69.25.58.64-.07 1.79-.03 1.79" />\n</svg>\n',json:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#e5c890" stroke-linecap="round" stroke-linejoin="round" d="M4.5 2.5H4c-.75 0-1.5.75-1.5 1.5v2c0 1.1-1 2-1.83 2 .83 0 1.83.9 1.83 2v2c0 .75.75 1.5 1.5 1.5h.5m7-11h.5c.75 0 1.5.75 1.5 1.5v2c0 1.1 1 2 1.83 2-.83 0-1.83.9-1.83 2v2c0 .74-.75 1.5-1.5 1.5h-.5m-6.5-3a.5.5 0 100-1 .5.5 0 000 1m3 0a.5.5 0 100-1 .5.5 0 000 1m3 0a.5.5 0 100-1 .5.5 0 000 1" />\n</svg>\n',python:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="#8caaee" d="M8.5 5.5h-3m6 0V3c0-.8-.7-1.5-1.5-1.5H7c-.8 0-1.5.7-1.5 1.5v2.5H3c-.8 0-1.5.7-1.5 1.5v2c0 .8.7 1.5 1.48 1.5" />\n <path stroke="#e5c890" d="M10.5 10.5h-3m-3 0V13c0 .8.7 1.5 1.5 1.5h3c.8 0 1.5-.7 1.5-1.5v-2.5H13c.8 0 1.5-.7 1.5-1.5V7c0-.8-.7-1.5-1.48-1.5H11.5c0 1.5 0 2-1 2h-2" />\n <path stroke="#8caaee" d="M2.98 10.5H4.5c0-1.5 0-2 1-2h2M7.5 3.5v0" />\n <path stroke="#e5c890" d="m 8.5,12.5 v 0" />\n </g>\n</svg>\n',ruby:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#e78284" stroke-linecap="round" stroke-linejoin="round" d="M1.5 9.06v2.5c.02.86.36 1.61.9 2.15 1.76 1.76 5.71.65 8.84-2.47 3.12-3.13 4.23-7.08 2.47-8.84a3.1 3.1 0 00-2.15-.9h-2.5M14.5 4l-.25 10.25L4 14.5m4.39-6.11c2.34-2.35 3.29-5.2 2.12-6.37S6.49 1.8 4.14 4.14C1.8 6.5.85 9.34 2.02 10.51s4.02.22 6.37-2.12M5.5 14.5l.25-3.75L11 11l-.25-5.25 3.75-.25" />\n</svg>\n',go:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#85c1dc" stroke-linecap="round" stroke-linejoin="round" d="m15.48 8.06-4.85.48m4.85-.48a4.98 4.98 0 01-4.54 5.42 5 5 0 112.95-8.66l-1.7 1.84a2.5 2.5 0 00-4.18 2.06c.05.57.3 1.1.69 1.51.25.27 1 .83 1.78.82.8-.02 1.58-.25 2.07-.81 0 0 .8-.96.68-1.88M2.5 8.5l-2 .01m1.5 2h1.5m-2-3.99 2-.02" />\n</svg>\n',java:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="#c6d0f5" d="M10.73 8.41c.57 3 1.59 5.83 2.77 7.09-6.63-3.45-9.76-1.75-10.5 0-.66-3.4-.54-5.74.09-7.78" />\n <path stroke="#e78284" d="M8.5 7c.63.34 1.82 1.07 2.24 1.41-.54-2.9-.64-5.96-.74-7.91-2.13.58-5.73 1.98-6.9 7.22.52-.69 1.72-1.05 2.4-1.22" />\n <path stroke="#e78284" d="M5.5 7A1.5 1.5 0 007 8.5 1.5 1.5 0 008.5 7 1.5 1.5 0 007 5.5 1.5 1.5 0 005.5 7" />\n </g>\n</svg>\n',kotlin:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="#ca9ee6" d="M2.5 13.5h11L8 8" />\n <path stroke="#ef9f76" d="M8.03 2.5h5.47l-8 8" />\n <path stroke="#e78284" d="M2.5 13.5V8" />\n <path stroke="#85c1dc" d="M8 2.5H2.5V8l3-2.5" />\n </g>\n</svg>\n',c:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round" d="m 4.0559072,12.951629 c 2.7459832,2.734744 7.1981158,2.734744 9.9441188,0 l -1.789955,-1.782586 c -1.75742,1.750224 -4.6067879,1.750224 -6.3642294,0 -1.7574416,-1.7502236 -1.7574416,-4.587893 0,-6.338097 1.7574415,-1.750224 4.6068094,-1.750224 6.3642294,0 l 0.894977,-0.8912929 0.894978,-0.891293 c -2.746003,-2.73472867 -7.1981359,-2.73472867 -9.944119,0 -2.7459858,2.7347089 -2.7459858,7.1685599 2e-7,9.9032689 z" clip-rule="evenodd" />\n</svg>\n',cpp:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round" d="m 2.5559121,12.951629 c 2.7459832,2.734744 7.1981158,2.734744 9.9441189,0 l -1.789955,-1.782586 c -1.7574201,1.750224 -4.606788,1.750224 -6.3642295,0 -1.7574416,-1.7502236 -1.7574416,-4.587893 0,-6.338097 1.7574415,-1.750224 4.6068094,-1.750224 6.3642295,0 l 0.894977,-0.8912929 0.894978,-0.891293 c -2.7460031,-2.73472867 -7.198136,-2.73472867 -9.9441191,0 -2.74598585,2.7347089 -2.74598585,7.1685599 2e-7,9.9032689 z" clip-rule="evenodd" />\n <path fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round" d="M7.5 6v4M5.513524 7.9999996H9.51304M13.486476 5.9999996v4M11.5 7.9999992h3.999516" />\n</svg>\n',cs:mo,csharp:mo,php:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round" d="M0.5,12.5 L0.5,13.24 C0.5,14 1.27360724,14.5 2,14.5 C2.9375516,14.5 3.5,14 3.5,13.2445661 L3.5,6.00089968 C3.5,4.28551107 4.99401107,2.52263547 7.14960413,2.5 C9.49387886,2.5 11,4.0579782 11,5.5 C11.1657296,8.48962302 9.57820404,9.63684469 7.49621582,10.5 L7.49621582,14.5 L15.4979764,14.5 L15.4979764,9 C15.5394484,8.36478228 14.9387379,7.15595371 14.1308258,6.5 C13.1942239,5.80827275 12.0584852,5.50253264 11,5.5 M11.5,14.5 L11.5,11.5 M6,6.5 C6.27614237,6.5 6.5,6.27614237 6.5,6 C6.5,5.72385763 6.27614237,5.5 6,5.5 C5.72385763,5.5 5.5,5.72385763 5.5,6 C5.5,6.27614237 5.72385763,6.5 6,6.5 Z" />\n</svg>\n',shell:ho,powershell:ho,sql:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#e5c890" stroke-linecap="round" stroke-linejoin="round" d="M8 6.5c3.59 0 6.5-1.4 6.5-2.68S11.59 1.5 8 1.5 1.5 2.54 1.5 3.82 4.41 6.5 8 6.5M14.5 8c0 .83-1.24 1.79-3.25 2.2s-4.49.41-6.5 0S1.5 8.83 1.5 8m13 4.18c0 .83-1.24 1.6-3.25 2-2.01.42-4.49.42-6.5 0-2.01-.4-3.25-1.17-3.25-2m0-8.3v8.3m13-8.3v8.3" />\n</svg>\n',yaml:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#e78284" stroke-linecap="round" stroke-linejoin="round" d="M2.5 1.5h3l3 4 3-4h3l-9 13h-3L7 8z" />\n</svg>\n',markdown:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#85c1dc" stroke-linecap="round" stroke-linejoin="round" d="m9.25 8.25 2.25 2.25 2.25-2.25M3.5 11V5.5l2.04 3 1.96-3V11m4-.5V5M1.65 2.5h12.7c.59 0 1.15.49 1.15 1v9c0 .51-.56 1-1.15 1H1.65c-.59 0-1.15-.49-1.15-1V3.58c0-.5.56-1.08 1.15-1.08" />\n</svg>\n',xml:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#ef9f76" stroke-linecap="round" stroke-linejoin="round" d="M4.5 4.5 1 8 4.5 11.5M11.5 4.5 15 8 11.5 11.5M9.5 2 6.5 14" />\n</svg>\n',rust:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#ef9f76" stroke-linecap="round" stroke-linejoin="round">\n <path d="M15.5 9.5Q8 13.505.5 9.5l1-1-1-2 2-.5V4.5h2l.5-2 1.5 1 1.5-2 1.5 2 1.5-1 .5 2h2V6l2 .5-1 2z" />\n <path d="M6.5 7.5a1 1 0 01-1 1 1 1 0 01-1-1 1 1 0 011-1 1 1 0 011 1m5 0a1 1 0 01-1 1 1 1 0 01-1-1 1 1 0 011-1 1 1 0 011 1M4 11.02c-.67.37-1.5.98-1.5 2.23s1.22 1.22 2 1.25v-2M12 11c.67.37 1.5 1 1.5 2.25s-1.22 1.22-2 1.25v-2" />\n </g>\n</svg>\n',vue:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#a6d189" stroke-linecap="round" stroke-linejoin="round">\n <path d="M1 1.5h5.44L8 4.56 9.56 1.5H15l-6.99 13z" />\n <path d="M12.05 1.73 8 9.28 3.95 1.73" />\n </g>\n</svg>\n',mermaid:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#ca9ee6" stroke-linecap="round" stroke-linejoin="round" d="M1.5 2.5c0 6 2.25 5.75 4 7 .83.67 1.17 2 1 4h3c-.17-2 .17-3.33 1-4 1.75-1.25 4-1 4-7C12 2.5 10 3 8 7 6 3 4 2.5 1.5 2.5" />\n</svg>\n'},ko={"":"",javascript:"javascript",js:"javascript",mjs:"javascript",cjs:"javascript",typescript:"typescript",ts:"typescript",jsx:"jsx",tsx:"tsx",golang:"go",py:"python",rb:"ruby",sh:"shell",bash:"shell",zsh:"shell",shellscript:"shell",bat:"shell",batch:"shell",ps1:"powershell",plaintext:"plain",text:"plain","c++":"cpp","c#":"csharp","objective-c":"objectivec","objective-c++":"objectivecpp",yml:"yaml",md:"markdown",rs:"rust",kt:"kotlin"};function xo(){return u(this,null,function*(){return vo||(go||(go=import("./languageIconExtended.js").then(e=>(vo=e.EXTENDED_LANGUAGE_ICON_MAP,yo.value++,vo)).catch(()=>null)),go)})}function bo(e){fo=null!=e?e:null}function _o(e){var n;const t=function(e){if(!e)return"";const n=e.trim();if(!n)return"";const[t]=n.split(/\s+/),[o]=t.split(":");return o.toLowerCase()}(e);return null!=(n=ko[t])?n:t}function Mo(e){const n=_o(e);if(!n)return"plaintext";switch(n){case"plain":return"plaintext";case"jsx":return"javascript";case"tsx":return"typescript";default:return n}}function To(){return u(this,null,function*(){yield xo()})}function Co(e){if(fo){const n=fo(e);if(null!=n&&""!==n)return n}const n=_o(e),t=wo[n];if(t)return t;return(null==vo?void 0:vo[n])||(xo(),'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">\x3c!-- Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE --\x3e<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="m10 9l-3 3l3 3m4 0l3-3l-3-3"/><rect width="18" height="18" x="3" y="3" rx="2"/></g></svg>')}const Bo={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",html:"HTML",css:"CSS",scss:"SCSS",json:"JSON",py:"Python",python:"Python",rb:"Ruby",go:"Go",java:"Java",c:"C",cpp:"C++",cs:"C#",php:"PHP",sh:"Shell",bash:"Bash",sql:"SQL",yaml:"YAML",md:"Markdown",d2:"D2",d2lang:"D2","":"Plain Text",plain:"Plain Text"},Io=new class{constructor(){d(this,"metrics",[]),d(this,"enabled",!1),d(this,"maxMetrics",1e3)}enable(){this.enabled=!0}disable(){this.enabled=!1}recordRender(e){this.enabled&&(this.metrics.push(e),this.metrics.length>this.maxMetrics&&this.metrics.shift())}getStats(){if(0===this.metrics.length)return{totalRenders:0,cacheHitRate:0,averageWorkerTime:0,averageDirectTime:0,averageCacheHitTime:0,workerSavings:0,recommendation:"Insufficient data"};const e=this.metrics.filter(e=>"worker"===e.type&&e.success),n=this.metrics.filter(e=>"direct"===e.type&&e.success),t=this.metrics.filter(e=>"cache-hit"===e.type),o=this.metrics.length,r=t.length,l=r/o*100,i=e.length>0?e.reduce((e,n)=>e+n.duration,0)/e.length:0,a=n.length>0?n.reduce((e,n)=>e+n.duration,0)/n.length:0,s=t.length>0?t.reduce((e,n)=>e+n.duration,0)/t.length:0,d=o*a-(e.reduce((e,n)=>e+n.duration,0)+n.reduce((e,n)=>e+n.duration,0)+t.reduce((e,n)=>e+n.duration,0));let u="";return u=l>70&&i<2*a?"✅ Worker + Cache is highly beneficial":l>50?"✅ Worker + Cache is beneficial":i>3*a?"⚠️ Worker overhead too high, consider direct rendering":a<5?"⚠️ Formulas too simple, Worker overhead may not be worth it":"✅ Worker prevents main thread blocking",{totalRenders:o,cacheHits:r,cacheHitRate:l.toFixed(1),workerCalls:e.length,directCalls:n.length,averageWorkerTime:i.toFixed(2),averageDirectTime:a.toFixed(2),averageCacheHitTime:s.toFixed(3),workerSavings:d.toFixed(2),recommendation:u}}printReport(){const e=this.getStats();return console.group("📊 KaTeX Rendering Performance Report"),e.totalRenders,e.cacheHits,e.cacheHitRate,e.workerCalls,e.directCalls,e.averageWorkerTime,e.averageDirectTime,e.averageCacheHitTime,e.workerSavings,e.recommendation,console.groupEnd(),e}reset(){this.metrics=[]}exportMetrics(){return{metrics:[...this.metrics],stats:this.getStats(),timestamp:Date.now()}}};function $o(){Io.enable()}function So(){Io.disable()}function Eo(){return Io.printReport()}function Lo(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch(n){}return globalThis.setTimeout(e,0)}function jo(e){try{if(null==e)return;if("undefined"!=typeof globalThis&&"function"==typeof globalThis.cancelAnimationFrame)return void globalThis.cancelAnimationFrame(e)}catch(n){}try{globalThis.clearTimeout(e)}catch(n){}}"undefined"!=typeof window&&(window.__katexPerfReport=Eo,window.__katexPerfMonitor=Io);const No={key:0,class:"code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:{color:"var(--vscode-editor-foreground)","background-color":"var(--vscode-editor-background)"}},Ho={class:"flex items-center gap-x-2"},Po=["innerHTML"],Do={class:"text-sm font-medium font-mono"},Ro={class:"flex items-center gap-x-2"},Oo=["aria-pressed"],Ko=["disabled"],zo=["disabled"],Ao=["disabled"],Wo=["aria-label"],Fo={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},Vo={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},Uo=["aria-pressed"],Xo={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24"},qo={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24"},Go=["aria-label"],Yo=["innerHTML"],Zo={class:"code-loading-placeholder"},Jo=/* @__PURE__ */le(/* @__PURE__ */p({__name:"MarkdownCodeBlockNode",props:{node:{},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isDark:{type:Boolean,default:!1},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean}},emits:["previewCode","copy"],setup(e,{emit:n}){const t=e,o=n,{t:r}=cn(),l=B(_o(t.node.language)),i=B(!1),a=B(!1),s=B(!1),d=B(null),c=B(null),m=B(""),h=B(!1);let p;const g=B(!0),y=B(0),b=B(14),M=B(b.value),T=C(()=>{const e=b.value,n=M.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),L=C(()=>{const e=l.value.trim().toLowerCase();return Bo[e]||e.charAt(0).toUpperCase()+e.slice(1)}),j=C(()=>(yo.value,Co(l.value.trim().toLowerCase().split(":")[0]))),N=C(()=>{const e=l.value.trim().toLowerCase();return t.isShowPreview&&("html"===e||"svg"===e)}),H=C(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},o=n(t.minWidth),r=n(t.maxWidth);return o&&(e.minWidth=o),r&&(e.maxWidth=r),e}),P=C(()=>({fontSize:`${M.value}px`})),K=C(()=>!1!==t.showTooltips);function z(){return t.isDark?t.darkTheme:t.lightTheme}function A(e){if(null==p||p.disconnect(),p=void 0,!e)return m.value="",void(h.value=!1);var n;m.value=`<pre class="shiki shiki-fallback"><code>${n=e,n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}</code></pre>`,h.value=!1}function W(){m.value="",h.value=!0}function F(){var e;const n=c.value;return!!n&&(n.childNodes.length>0||Boolean(null==(e=n.textContent)?void 0:e.trim().length))}function V(){return u(this,null,function*(){if(yield G(),F())return void W();const e=c.value;e&&(null==p||p.disconnect(),p=new MutationObserver(()=>{F()&&(W(),null==p||p.disconnect(),p=void 0)}),p.observe(e,{childList:!0,subtree:!0}))})}let U,X,q,J;const Q=/* @__PURE__ */new Set,ee=/* @__PURE__ */new Set,ne=void 0!==import.meta&&Boolean(!1);function te(e,n){return u(this,null,function*(){if(!U)return;const t=function(e,n=!1){var t;const[o]=String(null!=e?e:"").split(":"),r=null!=(t=null==o?void 0:o.trim().toLowerCase())?t:"";return r?!J||J.has(r)?r:(n&&ne&&!Q.has(r)&&(Q.add(r),console.warn(`[MarkdownCodeBlockNode] Language "${r}" not preloaded in stream-markdown; falling back to plaintext.`)),"plaintext"):"plaintext"}(n,Boolean(e&&e.length));try{yield U.updateCode(e,t)}catch(o){"plaintext"!==t?(ne&&!ee.has(t)&&(ee.add(t),console.warn(`[MarkdownCodeBlockNode] Failed to render language "${t}", retrying as plaintext.`,o)),yield U.updateCode(e,"plaintext")):ne&&console.warn("[MarkdownCodeBlockNode] Failed to render code block even as plaintext.",o)}})}function oe(){return u(this,null,function*(){yield function(){return u(this,null,function*(){if(!X)try{const e=yield import("stream-markdown");X=e.createShikiStreamRenderer,q=e.registerHighlight;const n=Array.isArray(e.defaultLanguages)?e.defaultLanguages:void 0;J=n?new Set(n.map(e=>e.toLowerCase())):void 0,null==q||q({themes:t.themes})}catch(e){console.warn("[MarkdownCodeBlockNode] stream-markdown not available:",e)}})}(),d.value&&c.value?(null==q||q({themes:t.themes}),!U&&X&&(U=X(c.value,{theme:z()}),h.value=!0),U?!1===t.stream&&t.loading?A(t.node.code):(A(t.node.code),yield te(t.node.code,l.value),yield V()):A(t.node.code)):A(t.node.code)})}function re(){const e=d.value;if(!e||a.value)return;const n=e.scrollTop;n<y.value?g.value=!1:function(e,n=50){return e.scrollHeight-e.scrollTop-e.clientHeight<=n}(e)&&(g.value=!0),y.value=n}function le(){return u(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(t.node.code)),i.value=!0,o("copy",t.node.code),setTimeout(()=>{i.value=!1},1e3)}catch(e){console.error("Copy failed:",e)}})}function ie(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}function ae(e,n,o="top"){if(!K.value)return;const r=ie(e);if(!r)return;const l=e;an(r,n,o,!1,null!=(null==l?void 0:l.clientX)&&null!=(null==l?void 0:l.clientY)?{x:l.clientX,y:l.clientY}:void 0,t.isDark)}function se(){K.value&&sn()}function de(e){if(!K.value)return;const n=ie(e);if(!n)return;const o=e;an(n,i.value?r("common.copied")||"Copied":r("common.copy")||"Copy","top",!1,null!=(null==o?void 0:o.clientX)&&null!=(null==o?void 0:o.clientY)?{x:o.clientX,y:o.clientY}:void 0,t.isDark)}function ue(){a.value=!a.value;const e=d.value;e&&(a.value?(e.style.maxHeight="none",e.style["overflow-y"]="visible",e.style["overflow-x"]="auto"):(e.style.maxHeight="500px",e.style.overflow="auto",g.value=!0,G(()=>{e.scrollHeight>e.clientHeight&&(e.scrollTop=e.scrollHeight)})))}function ce(){s.value=!s.value}function me(){if(!N.value)return;const e=(l.value||t.node.language).toLowerCase(),n="html"===e?"HTML Preview":"SVG Preview";o("previewCode",{type:"html"===e?"text/html":"image/svg+xml",content:t.node.code,title:n})}return oe(),$(()=>{oe()}),S(()=>{null==p||p.disconnect(),p=void 0}),I(()=>t.themes,()=>u(null,null,function*(){q&&q({themes:t.themes})})),I(()=>t.loading,e=>{e||oe()}),I(K,e=>{e||sn()}),I(()=>[t.node.code,t.node.language],e=>u(null,[e],function*([e,n]){const o=_o(n);o!==l.value&&(l.value=o),d.value&&c.value?(U||(A(e),yield oe()),U&&e&&(!1===t.stream&&t.loading||(A(e),yield te(e,n),yield V()))):A(e)})),I(()=>[t.darkTheme,t.lightTheme],()=>u(null,null,function*(){d.value&&c.value&&(U||(yield oe()),null==U||U.setTheme(z()))})),I(()=>t.node.code,()=>u(null,null,function*(){if(a.value||!g.value)return;yield G();const e=d.value;e&&e.scrollHeight>e.clientHeight&&(e.scrollTop=e.scrollHeight)})),(n,o)=>(f(),v("div",{style:D(H.value),class:E(["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",[t.isDark?"border-gray-700/30 bg-gray-900":"border-gray-200 bg-white",t.isDark?"is-dark":""]])},[t.showHeader?(f(),v("div",No,[R(n.$slots,"header-left",{},()=>[k("div",Ho,[k("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:j.value},null,8,Po),k("span",Do,_(L.value),1)])],!0),R(n.$slots,"header-right",{},()=>[k("div",Ro,[t.showCollapseButton?(f(),v("button",{key:0,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":s.value,onClick:ce,onMouseenter:o[0]||(o[0]=e=>ae(e,s.value?w(r)("common.expand")||"Expand":w(r)("common.collapse")||"Collapse")),onFocus:o[1]||(o[1]=e=>ae(e,s.value?w(r)("common.expand")||"Expand":w(r)("common.collapse")||"Collapse")),onMouseleave:se,onBlur:se},[(f(),v("svg",{style:D({rotate:s.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[...o[17]||(o[17]=[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,Oo)):O("",!0),t.showFontSizeButtons&&t.enableFontSizeControl?(f(),v(x,{key:1},[k("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!!Number.isFinite(M.value)&&M.value<=10,onClick:o[2]||(o[2]=e=>function(){const e=Math.max(10,M.value-1);M.value=e}()),onMouseenter:o[3]||(o[3]=e=>ae(e,w(r)("common.decrease")||"Decrease")),onFocus:o[4]||(o[4]=e=>ae(e,w(r)("common.decrease")||"Decrease")),onMouseleave:se,onBlur:se},[...o[18]||(o[18]=[k("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)])],40,Ko),k("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!T.value||M.value===b.value,onClick:o[5]||(o[5]=e=>{M.value=b.value}),onMouseenter:o[6]||(o[6]=e=>ae(e,w(r)("common.reset")||"Reset")),onFocus:o[7]||(o[7]=e=>ae(e,w(r)("common.reset")||"Reset")),onMouseleave:se,onBlur:se},[...o[19]||(o[19]=[k("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[k("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[k("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),k("path",{d:"M3 3v5h5"})])],-1)])],40,zo),k("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!!Number.isFinite(M.value)&&M.value>=36,onClick:o[8]||(o[8]=e=>function(){const e=Math.min(36,M.value+1);M.value=e}()),onMouseenter:o[9]||(o[9]=e=>ae(e,w(r)("common.increase")||"Increase")),onFocus:o[10]||(o[10]=e=>ae(e,w(r)("common.increase")||"Increase")),onMouseleave:se,onBlur:se},[...o[20]||(o[20]=[k("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)])],40,Ao)],64)):O("",!0),t.showCopyButton?(f(),v("button",{key:2,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":i.value?w(r)("common.copied")||"Copied":w(r)("common.copy")||"Copy",onClick:le,onMouseenter:o[11]||(o[11]=e=>de(e)),onFocus:o[12]||(o[12]=e=>de(e)),onMouseleave:se,onBlur:se},[i.value?(f(),v("svg",Vo,[...o[22]||(o[22]=[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(f(),v("svg",Fo,[...o[21]||(o[21]=[k("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[k("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),k("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,Wo)):O("",!0),t.showExpandButton?(f(),v("button",{key:3,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":a.value,onClick:ue,onMouseenter:o[13]||(o[13]=e=>ae(e,a.value?w(r)("common.collapse")||"Collapse":w(r)("common.expand")||"Expand")),onFocus:o[14]||(o[14]=e=>ae(e,a.value?w(r)("common.collapse")||"Collapse":w(r)("common.expand")||"Expand")),onMouseleave:se,onBlur:se},[a.value?(f(),v("svg",Xo,[...o[23]||(o[23]=[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])])):(f(),v("svg",qo,[...o[24]||(o[24]=[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])]))],40,Uo)):O("",!0),N.value&&t.showPreviewButton?(f(),v("button",{key:4,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":w(r)("common.preview")||"Preview",onClick:me,onMouseenter:o[15]||(o[15]=e=>ae(e,w(r)("common.preview")||"Preview")),onFocus:o[16]||(o[16]=e=>ae(e,w(r)("common.preview")||"Preview")),onMouseleave:se,onBlur:se},[...o[25]||(o[25]=[k("svg",{"data-v-3d59cc65":"",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[k("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[k("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),k("circle",{cx:"12",cy:"12",r:"3"})])],-1)])],40,Go)):O("",!0)])],!0)])):O("",!0),Y(k("div",{ref_key:"codeBlockContent",ref:d,class:"code-block-content",style:D(P.value),onScroll:re},[k("div",{ref_key:"rendererTarget",ref:c,class:"code-block-render"},null,512),h.value?O("",!0):(f(),v("div",{key:0,class:"code-fallback-plain",innerHTML:m.value},null,8,Yo))],36),[[Z,!(s.value||!e.stream&&e.loading)]]),Y(k("div",Zo,[R(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[o[26]||(o[26]=k("div",{class:"loading-skeleton"},[k("div",{class:"skeleton-line"}),k("div",{class:"skeleton-line"}),k("div",{class:"skeleton-line short"})],-1))],!0)],512),[[Z,!e.stream&&e.loading]])],6))}}),[["__scopeId","data-v-3397f01a"]]);Jo.install=e=>{e.component(Jo.__name,Jo)};const Qo=()=>import("mermaid");let er=null,nr=Qo;function tr(e){nr=e,er=null}function or(e){tr(null!=e?e:Qo)}function rr(){tr(null)}function lr(){return"function"==typeof nr}function ir(e){if(!e)return e;const n=e&&e.default?e.default:e;if(n&&("function"==typeof n.render||"function"==typeof n.parse||"function"==typeof n.initialize))return n;if(n&&n.mermaidAPI&&("function"==typeof n.mermaidAPI.render||"function"==typeof n.mermaidAPI.parse)){const e=n.mermaidAPI;return s(a({},n),{render:e.render.bind(e),parse:e.parse?e.parse.bind(e):void 0,initialize:t=>"function"==typeof n.initialize?n.initialize(t):e.initialize?e.initialize(t):void 0})}return e.mermaid&&"function"==typeof e.mermaid.render?e.mermaid:n}function ar(e){if(e)try{const n=null==e?void 0:e.initialize;e.initialize=t=>{const o=a({suppressErrorRendering:!0},t||{});return"function"==typeof n?n.call(e,o):(null==e?void 0:e.mermaidAPI)&&"function"==typeof e.mermaidAPI.initialize?e.mermaidAPI.initialize(o):void 0}}catch(n){}}function sr(){return u(this,null,function*(){if(er)return er;const e=function(){try{const e=globalThis;return ir(null==e?void 0:e.mermaid)}catch(e){return null}}();if(e)return er=e,ar(er),er;const n=nr;if(!n)return null;let t;try{t=yield n()}catch(o){if(n===Qo)throw new Error('Optional dependency "mermaid" is not installed. Please install it to enable mermaid diagrams.');throw o}return t?(er=ir(t),ar(er),er):null})}const dr={class:"markstream-vue"},ur=["id"],cr=/* @__PURE__ */le(/* @__PURE__ */p({__name:"Tooltip",props:{visible:{type:Boolean},anchorEl:{},content:{},placement:{},offset:{},originX:{},originY:{},id:{},isDark:{type:[Boolean,null]}},setup(e){const n=e,t=C(()=>{if(void 0!==n.isDark&&null!==n.isDark)return Boolean(n.isDark);if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0;if((null==window?void 0:window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)return!0}catch(e){}return!1}),o=B(null),r=B({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),l=B(!1);let i=null;function a(){return u(this,null,function*(){var e,t;if(!n.anchorEl||!o.value)return;const l=[ee(null!=(e=n.offset)?e:8),ne(),te({padding:8})],{x:i,y:a}=yield oe(n.anchorEl,o.value,{placement:null!=(t=n.placement)?t:"top",middleware:l,strategy:"fixed"});r.value.transform=`translate3d(${Math.round(i)}px, ${Math.round(a)}px, 0)`,r.value.left="0px",r.value.top="0px"})}return I(()=>n.visible,e=>u(null,null,function*(){if(e)if(l.value=!1,yield G(),n.anchorEl&&o.value)try{const e=n.anchorEl.getBoundingClientRect();yield a();const t=r.value.transform;if(null!=n.originX&&null!=n.originY){const o=Math.abs(Number(n.originX)-e.left),i=Math.abs(Number(n.originY)-e.top);Math.hypot(o,i)>120?(r.value.transform=`translate3d(${Math.round(n.originX)}px, ${Math.round(n.originY)}px, 0)`,yield G(),l.value=!0,yield G(),r.value.transform=t):l.value=!0}else l.value=!0;i=Q(n.anchorEl,o.value,a)}catch(t){yield a(),l.value=!0,i=Q(n.anchorEl,o.value,a)}else l.value=!0;else l.value=!1,i&&(i(),i=null)})),I([()=>n.anchorEl,()=>n.placement,()=>n.content],()=>u(null,null,function*(){n.visible&&n.anchorEl&&o.value&&(yield G(),yield a())})),S(()=>{i&&i()}),(i,a)=>(f(),A(J,{to:"body"},[k("div",dr,[y(H,{name:"tooltip",appear:""},{default:P(()=>[Y(k("div",{id:n.id,ref_key:"tooltip",ref:o,style:D({position:"fixed",left:r.value.left,top:r.value.top,transform:r.value.transform}),class:E(["z-[9999] inline-block text-base py-2 px-3 rounded-md shadow-md whitespace-nowrap pointer-events-none tooltip-element border",[t.value?"bg-gray-900 text-white border-gray-700 border is-dark":"bg-white text-gray-900 border-gray-200 border"]]),role:"tooltip"},_(e.content),15,ur),[[Z,e.visible&&l.value]])]),_:1})])]))}}),[["__scopeId","data-v-d524cc01"]]),mr=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:cr},Symbol.toStringTag,{value:"Module"}));function hr(e){return JSON.stringify(e)}function pr(e){var n;const t=null!=(n=e.mode)?n:"classic",o=e.katexUrl,r=e.mhchemUrl,l=hr(a({throwOnError:!0,displayMode:!0,output:"html",strict:"ignore"},e.renderOptions||{})),i=hr(o),s=r?hr(r):'""';return"module"===t?`\nlet DEBUG = false\nlet katex = null\nlet katexLoadError = null\nlet loadPromise = null\n\nfunction normalizeKaTeX(mod) {\n const resolved = (mod && mod.default) ? mod.default : mod\n if (resolved && typeof resolved.renderToString === 'function')\n return resolved\n return null\n}\n\nasync function loadKaTeX() {\n if (katex || katexLoadError)\n return\n if (!loadPromise) {\n loadPromise = (async () => {\n try {\n const mod = await import(${i})\n katex = normalizeKaTeX(mod) || null\n const mhchemUrl = ${s}\n if (mhchemUrl) {\n try {\n await import(mhchemUrl)\n }\n catch (e) {\n // ignore optional mhchem load failures\n if (DEBUG)\n console.warn('[katex-cdn-worker] failed to load mhchem', e)\n }\n }\n }\n catch (e) {\n katexLoadError = e\n }\n })()\n }\n await loadPromise\n}\n\nglobalThis.addEventListener('message', async (ev) => {\n const data = ev.data || {}\n if (data.type === 'init') {\n DEBUG = !!data.debug\n if (DEBUG)\n console.debug('[katex-cdn-worker] debug enabled')\n return\n }\n const id = data.id ?? ''\n const content = data.content ?? ''\n const displayMode = data.displayMode ?? true\n\n await loadKaTeX()\n\n if (!katex) {\n const reason = katexLoadError ? String(katexLoadError?.message || katexLoadError) : 'KaTeX is not available in worker'\n globalThis.postMessage({ id, error: reason, content, displayMode })\n return\n }\n\n try {\n const opts = ${l}\n const html = katex.renderToString(content, { ...opts, displayMode: !!displayMode })\n globalThis.postMessage({ id, html, content, displayMode })\n }\n catch (err) {\n const msg = String(err?.message || err)\n globalThis.postMessage({ id, error: msg, content, displayMode })\n }\n})\n`.trimStart():`\nlet DEBUG = false\nlet katex = null\nlet katexLoadError = null\n\nfunction normalizeKaTeX(val) {\n const resolved = (val && val.default) ? val.default : val\n if (resolved && typeof resolved.renderToString === 'function')\n return resolved\n return null\n}\n\nfunction loadKaTeXClassic() {\n if (katex || katexLoadError)\n return\n try {\n importScripts(${i})\n const mhchemUrl = ${s}\n if (mhchemUrl) {\n try {\n importScripts(mhchemUrl)\n }\n catch (e) {\n // ignore optional mhchem load failures\n if (DEBUG)\n console.warn('[katex-cdn-worker] failed to load mhchem', e)\n }\n }\n katex = normalizeKaTeX(globalThis.katex)\n }\n catch (e) {\n katexLoadError = e\n }\n}\n\nloadKaTeXClassic()\n\nglobalThis.addEventListener('message', (ev) => {\n const data = ev.data || {}\n if (data.type === 'init') {\n DEBUG = !!data.debug\n if (DEBUG)\n console.debug('[katex-cdn-worker] debug enabled')\n return\n }\n const id = data.id ?? ''\n const content = data.content ?? ''\n const displayMode = data.displayMode ?? true\n\n if (!katex && !katexLoadError)\n loadKaTeXClassic()\n\n if (!katex) {\n const reason = katexLoadError ? String(katexLoadError?.message || katexLoadError) : 'KaTeX is not available in worker'\n globalThis.postMessage({ id, error: reason, content, displayMode })\n return\n }\n\n try {\n const opts = ${l}\n const html = katex.renderToString(content, { ...opts, displayMode: !!displayMode })\n globalThis.postMessage({ id, html, content, displayMode })\n }\n catch (err) {\n const msg = String(err?.message || err)\n globalThis.postMessage({ id, error: msg, content, displayMode })\n }\n})\n`.trimStart()}function fr(e){var n,t;const o=pr(e);if("undefined"==typeof Worker||"undefined"==typeof URL||"undefined"==typeof Blob)return{worker:null,dispose:()=>{},source:o};const r=new Blob([o],{type:"text/javascript"}),l=URL.createObjectURL(r);let i=!1;const d="module"===(null!=(n=e.mode)?n:"classic")?s(a({},null!=(t=e.workerOptions)?t:{}),{type:"module"}):e.workerOptions,u=new Worker(l,d);if(e.debug)try{u.postMessage({type:"init",debug:!0})}catch(c){}return{worker:u,dispose:()=>{if(!i){i=!0;try{URL.revokeObjectURL(l)}catch(c){}}},source:o}}cr.install=e=>{e.component(cr.__name,cr)};let vr=null,gr=null,yr=!1;const wr=/* @__PURE__ */new Map,kr=/* @__PURE__ */new Map;let xr=5;const br=/* @__PURE__ */new Set;function _r(){if(wr.size<xr&&br.size){const n=Array.from(br);br.clear();for(const t of n)try{t()}catch(e){}}}function Mr(e){vr=e,gr=null,vr.onmessage=e=>{const{id:n,html:t,error:o}=e.data,r=wr.get(n);if(r)if(wr.delete(n),clearTimeout(r.timeoutId),_r(),o)r.reject(new Error(o));else{const{content:n,displayMode:o}=e.data;if(n){const e=`${o?"d":"i"}:${n}`;if(kr.set(e,t),kr.size>200){const e=kr.keys().next().value;kr.delete(e)}}r.resolve(t)}},vr.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[n,t]of wr.entries())clearTimeout(t.timeoutId),t.reject(new Error(`Worker error: ${e.message}`));wr.clear(),_r()}}function Tr(){var e;vr&&(null==(e=vr.terminate)||e.call(vr)),vr=null,gr=null}function Cr(e){yr=!!e,vr&&vr.postMessage({type:"init",debug:yr})}function Br(e,n=!0,t=2e3,o){return u(this,null,function*(){if(performance.now(),!Ln()){const e=new Error("KaTeX rendering disabled");return e.name="KaTeXDisabled",e.code="KATEX_DISABLED",Promise.reject(e)}if(gr)return Promise.reject(gr);const r=`${n?"d":"i"}:${e}`,l=kr.get(r);if(l)return Promise.resolve(l);const i=vr||(gr=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),gr.name="WorkerInitError",gr.code="WORKER_INIT_ERROR",null);if(!i)return Promise.reject(gr);if(wr.size>=xr){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code="WORKER_BUSY",e.busy=!0,e.inFlight=wr.size,e.max=xr,Promise.reject(e)}return new Promise((r,l)=>{if(null==o?void 0:o.aborted){const e=new Error("Aborted");return e.name="AbortError",void l(e)}const a=Math.random().toString(36).slice(2),s=globalThis.setTimeout(()=>{wr.delete(a);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",l(e),_r()},t);o&&o.addEventListener("abort",()=>{globalThis.clearTimeout(s),wr.has(a)&&wr.delete(a);const e=new Error("Aborted");e.name="AbortError",l(e),_r()},{once:!0});const d=r,u=l;wr.set(a,{resolve:e=>{d(e)},reject:e=>{u(e)},timeoutId:s}),i.postMessage({id:a,content:e,displayMode:n})})})}function Ir(e,n=!0,t){const o=`${n?"d":"i"}:${e}`;if(kr.set(o,t),kr.size>200){const e=kr.keys().next().value;kr.delete(e)}}function $r(){return{inFlight:wr.size,max:xr}}function Sr(e){Number.isFinite(e)&&e>0&&(xr=Math.floor(e))}const Er="WORKER_BUSY";function Lr(){return wr.size>=xr}function jr(e=2e3,n){return wr.size<xr?Promise.resolve():new Promise((t,o)=>{let r,l=!1;const i=()=>{l||(l=!0,r&&globalThis.clearTimeout(r),br.delete(i),t())};if(br.add(i),r=globalThis.setTimeout(()=>{if(l)return;l=!0,br.delete(i);const e=new Error("Wait for worker slot timed out");e.name="WorkerBusyTimeout",e.code="WORKER_BUSY_TIMEOUT",o(e)},e),queueMicrotask(()=>_r()),n){const e=()=>{if(l)return;l=!0,r&&globalThis.clearTimeout(r),br.delete(i);const e=new Error("Aborted");e.name="AbortError",o(e)};n.aborted?e():n.addEventListener("abort",e,{once:!0})}})}const Nr={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function Hr(e){null!=e.timeout&&(Nr.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(Nr.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(Nr.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(Nr.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function Pr(){return a({},Nr)}function Dr(e){return u(this,arguments,function*(e,n=!0,t={}){var o,r,l,i;if(!Ln()){const e=new Error("KaTeX rendering disabled");throw e.name="KaTeXDisabled",e.code="KATEX_DISABLED",e}const a=null!=(o=t.timeout)?o:Nr.timeout,s=null!=(r=t.waitTimeout)?r:Nr.waitTimeout,d=null!=(l=t.backoffMs)?l:Nr.backoffMs,u=null!=(i=t.maxRetries)?i:Nr.maxRetries,c=Number.isFinite(u)?Math.max(0,Math.min(Math.floor(u),8)):Nr.maxRetries,m=t.signal;let h=0;for(;;){if(null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}try{return yield Br(e,n,a,m)}catch(p){if((null==p?void 0:p.code)!==Er||h>=c)throw p;if(h++,yield jr(s,m).catch(()=>{}),null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}d>0&&(yield new Promise(e=>globalThis.setTimeout(e,d*h)))}}})}function Rr(e){return JSON.stringify(e)}function Or(e){var n;const t=null!=(n=e.mode)?n:"module",o=Rr(e.mermaidUrl),r=`\nlet DEBUG = false\nlet mermaid = null\nlet mermaidLoadError = null\n\nfunction normalizeMermaidModule(mod) {\n if (!mod)\n return mod\n const candidate = (mod && mod.default) ? mod.default : mod\n if (candidate && (typeof candidate.render === 'function' || typeof candidate.parse === 'function' || typeof candidate.initialize === 'function'))\n return candidate\n if (candidate && candidate.mermaidAPI && (typeof candidate.mermaidAPI.render === 'function' || typeof candidate.mermaidAPI.parse === 'function')) {\n const api = candidate.mermaidAPI\n return {\n ...candidate,\n render: api.render ? api.render.bind(api) : undefined,\n parse: api.parse ? api.parse.bind(api) : undefined,\n initialize: (opts) => {\n if (typeof candidate.initialize === 'function')\n return candidate.initialize(opts)\n return api.initialize ? api.initialize(opts) : undefined\n },\n }\n }\n if (mod && mod.mermaid && typeof mod.mermaid.parse === 'function')\n return mod.mermaid\n return candidate\n}\n\nfunction applyThemeTo(code, theme) {\n const themeValue = theme === 'dark' ? 'dark' : 'default'\n const themeConfig = \`%%{init: {"theme": "\${themeValue}"}}%%\\n\`\n const trimmed = (code || '').trimStart()\n if (trimmed.startsWith('%%{'))\n return code\n return themeConfig + code\n}\n\nfunction findHeaderIndex(lines) {\n const headerRe = /^(?:graph|flowchart|flowchart\\s+tb|flowchart\\s+lr|sequenceDiagram|gantt|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|pie|quadrantChart|timeline|xychart(?:-beta)?)\\b/\n for (let i = 0; i < lines.length; i++) {\n const l = (lines[i] || '').trim()\n if (!l)\n continue\n if (l.startsWith('%%'))\n continue\n if (headerRe.test(l))\n return i\n }\n return -1\n}\n\nasync function canParse(code, theme) {\n const themed = applyThemeTo(code, theme)\n const anyMermaid = mermaid\n if (anyMermaid && typeof anyMermaid.parse === 'function') {\n await anyMermaid.parse(themed)\n return true\n }\n throw new Error('mermaid.parse not available in worker')\n}\n\nasync function findLastRenderablePrefix(baseCode, theme) {\n const lines = String(baseCode || '').split('\\n')\n const headerIdx = findHeaderIndex(lines)\n if (headerIdx === -1)\n return null\n const head = lines.slice(0, headerIdx + 1)\n await canParse(head.join('\\n'), theme)\n\n let low = headerIdx + 1\n let high = lines.length\n let lastGood = headerIdx + 1\n let tries = 0\n const MAX_TRIES = 12\n\n while (low <= high && tries < MAX_TRIES) {\n const mid = Math.floor((low + high) / 2)\n const candidate = [...head, ...lines.slice(headerIdx + 1, mid)].join('\\n')\n tries++\n try {\n await canParse(candidate, theme)\n lastGood = mid\n low = mid + 1\n }\n catch {\n high = mid - 1\n }\n }\n\n return [...head, ...lines.slice(headerIdx + 1, lastGood)].join('\\n')\n}\n\nfunction initMermaidOnce() {\n if (!mermaid)\n return\n try {\n if (typeof mermaid.initialize === 'function')\n mermaid.initialize(${Rr(a({startOnLoad:!1,securityLevel:"loose"},e.initializeOptions||{}))})\n }\n catch (e) {\n if (DEBUG)\n console.warn('[mermaid-cdn-worker] initialize failed', e)\n }\n}\n\nglobalThis.addEventListener('message', async (ev) => {\n const msg = ev.data || {}\n if (msg.type === 'init') {\n DEBUG = !!msg.debug\n if (DEBUG)\n console.debug('[mermaid-cdn-worker] debug enabled')\n return\n }\n\n const id = msg.id\n const action = msg.action\n const payload = msg.payload || {}\n\n if (!mermaid) {\n const errMsg = mermaidLoadError ? String(mermaidLoadError?.message || mermaidLoadError) : 'Mermaid is not available in worker'\n globalThis.postMessage({ id, ok: false, error: errMsg })\n return\n }\n\n try {\n if (action === 'canParse') {\n const ok = await canParse(payload.code, payload.theme)\n globalThis.postMessage({ id, ok: true, result: ok })\n return\n }\n if (action === 'findPrefix') {\n const res = await findLastRenderablePrefix(payload.code, payload.theme)\n globalThis.postMessage({ id, ok: true, result: res })\n return\n }\n globalThis.postMessage({ id, ok: false, error: 'Unknown action' })\n }\n catch (e) {\n globalThis.postMessage({ id, ok: false, error: String(e?.message || e) })\n }\n})\n`.trimStart();return"module"===t?`\n${r}\n\nlet loadPromise = null\nasync function loadMermaid() {\n if (mermaid || mermaidLoadError)\n return\n if (!loadPromise) {\n loadPromise = (async () => {\n try {\n const mod = await import(${o})\n mermaid = normalizeMermaidModule(mod) || null\n initMermaidOnce()\n }\n catch (e) {\n mermaidLoadError = e\n }\n })()\n }\n await loadPromise\n}\n\n// Load immediately; failures are reported per-request\nawait loadMermaid()\n`.trimStart():`\n${r}\n\nfunction loadMermaidClassic() {\n if (mermaid || mermaidLoadError)\n return\n try {\n importScripts(${o})\n mermaid = normalizeMermaidModule(globalThis.mermaid) || null\n initMermaidOnce()\n }\n catch (e) {\n mermaidLoadError = e\n }\n}\n\nloadMermaidClassic()\n`.trimStart()}function Kr(e){var n,t;const o=Or(e);if("undefined"==typeof Worker||"undefined"==typeof URL||"undefined"==typeof Blob)return{worker:null,dispose:()=>{},source:o};const r=new Blob([o],{type:"text/javascript"}),l=URL.createObjectURL(r);let i=!1;const d="module"===(null!=(n=e.mode)?n:"module")?s(a({},null!=(t=e.workerOptions)?t:{}),{type:"module"}):e.workerOptions,u=new Worker(l,d);if(e.debug)try{u.postMessage({type:"init",debug:!0})}catch(c){}return{worker:u,dispose:()=>{if(!i){i=!0;try{URL.revokeObjectURL(l)}catch(c){}}},source:o}}let zr=null,Ar=null;const Wr=/* @__PURE__ */new Map;let Fr=5,Vr=!1;function Ur(e){Vr=!!e}function Xr(e){Number.isFinite(e)&&e>0&&(Fr=Math.floor(e))}function qr(){return{inFlight:Wr.size,max:Fr}}const Gr="WORKER_BUSY",Yr="MERMAID_DISABLED";function Zr(e){zr=e,Ar=null;const n=e;zr.onmessage=e=>{if(zr!==n)return;const{id:t,ok:o,result:r,error:l}=e.data,i=Wr.get(t);i&&(!1===o||l?i.reject(new Error(l||"Unknown error")):i.resolve(r))},zr.onerror=e=>{var t,o;if(zr===n)if(0!==Wr.size){try{Vr?console.error("[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e):null==(o=console.debug)||o.call(console,"[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e)}catch(r){}for(const[n,t]of Wr.entries())t.reject(new Error(`Worker error: ${e.message}`));Wr.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},zr.onmessageerror=e=>{var t,o;if(zr===n)if(0!==Wr.size){try{Vr?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(o=console.debug)||o.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch(r){}for(const[e,n]of Wr.entries())n.reject(new Error("Worker messageerror"));Wr.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function Jr(){var e;if(zr)try{for(const[e,n]of Wr.entries())n.reject(new Error("Worker cleared"));Wr.clear(),null==(e=zr.terminate)||e.call(zr)}catch(n){}zr=null,Ar=null}function Qr(e,n,t=1400){if(!lr()){const e=new Error("Mermaid rendering disabled");return e.name="MermaidDisabled",e.code=Yr,Promise.reject(e)}if(Ar)return Promise.reject(Ar);const o=zr||(Ar=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Ar.name="WorkerInitError",Ar.code="WORKER_INIT_ERROR",null);if(!o)return Promise.reject(Ar);if(Wr.size>=Fr){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Gr,e.inFlight=Wr.size,e.max=Fr,Promise.reject(e)}return new Promise((r,l)=>{const i=Math.random().toString(36).slice(2);let a,s=!1;const d=()=>{s||(s=!0,null!=a&&globalThis.clearTimeout(a),Wr.delete(i))},u={resolve:e=>{d(),r(e)},reject:e=>{d(),l(e)}};Wr.set(i,u);try{o.postMessage({id:i,action:e,payload:n})}catch(c){return Wr.delete(i),void l(c)}a=globalThis.setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const n=Wr.get(i);n&&n.reject(e)},t)})}function el(e,n,t=1400){return u(this,null,function*(){try{return yield Qr("canParse",{code:e,theme:n},t)}catch(o){return Promise.reject(o)}})}function nl(e,n,t=1400){return u(this,null,function*(){try{return yield Qr("findPrefix",{code:e,theme:n},t)}catch(o){return Promise.reject(o)}})}function tl(){if(zr)try{for(const[e,n]of Wr.entries())n.reject(new Error("Worker terminated"));Wr.clear(),zr.terminate()}finally{zr=null}}const ol=z(()=>import("./index4.js")),rl=z(()=>import("./index3.js")),ll=z(()=>import("./index2.js")),il=z(()=>import("./index5.js")),al=z(()=>import("./index6.js")),sl=z(()=>import("./index7.js")),dl={AdmonitionNode:qt,BlockquoteNode:ie,CheckboxNode:de,CodeBlockNode:ol,DefinitionListNode:he,EmojiNode:fe,EmphasisNode:st,FootnoteNode:ht,FootnoteReferenceNode:Ce,FootnoteAnchorNode:ut,HardBreakNode:ft,HeadingNode:gt,HtmlBlockNode:bt,HtmlInlineNode:Fe,HighlightNode:it,ImageNode:bn,D2BlockNode:sl,InfographicBlockNode:al,InlineCodeNode:Ue,PreCodeNode:Bt,InsertNode:rt,LinkNode:tt,ListItemNode:yt,ListNode:wt,MathBlockNode:rl,MathInlineNode:ll,MermaidBlockNode:il,ParagraphNode:Mt,StrikethroughNode:Yn,StrongNode:qn,SubscriptNode:Un,SuperscriptNode:Wn,TableNode:jt,TextNode:Dn,ThematicBreakNode:Ht,VmrContainerNode:Rt,ReferenceNode:Kn,MarkdownCodeBlockNode:Jo},ul={install(e,n){Object.entries(dl).forEach(([n,t])=>{e.component(n,t)}),(null==n?void 0:n.getLanguageIcon)&&bo(n.getLanguageIcon),(null==n?void 0:n.mathOptions)&&h(n.mathOptions)}};export{Mt as $,qt as A,ie as B,de as C,sl as D,fe as E,ut as F,gt as G,ft as H,it as I,bt as J,Fe as K,bn as L,al as M,Ue as N,rt as O,tt as P,yt as Q,wt as R,Yr as S,Gr as T,Jo as U,zt as V,Er as W,rl as X,ll as Y,il as Z,le as _,pn as a,Kn as a0,Yn as a1,qn as a2,Un as a3,Wn as a4,jt as a5,Dn as a6,Ht as a7,cr as a8,Rt as a9,lr as aA,Io as aB,To as aC,co as aD,ao as aE,be as aF,Br as aG,ke as aH,Jt as aI,un as aJ,Hr as aK,Mr as aL,Cr as aM,Sr as aN,$n as aO,bo as aP,tr as aQ,Zr as aR,Ur as aS,Xr as aT,jr as aU,ul as aa,pr as ab,Or as ac,_e as ad,Tr as ae,Jr as af,fr as ag,Kr as ah,uo as ai,eo as aj,En as ak,rr as al,So as am,Qt as an,Sn as ao,or as ap,$o as aq,so as ar,xe as as,Pr as at,$r as au,qr as av,Eo as aw,no as ax,Lr as ay,Ln as az,yo as b,Co as c,Bt as d,an as e,jo as f,io as g,sn as h,Dr as i,jn as j,Ir as k,Bo as l,sr as m,_o as n,el as o,nl as p,to as q,Mo as r,Lo as s,tl as t,cn as u,ol as v,he as w,st as x,ht as y,Ce as z};
1
+ var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,i=(n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,a=(e,n)=>{for(var t in n||(n={}))r.call(n,t)&&i(e,t,n[t]);if(o)for(var t of o(n))l.call(n,t)&&i(e,t,n[t]);return e},s=(e,o)=>n(e,t(o)),d=(e,n,t)=>i(e,"symbol"!=typeof n?n+"":n,t),u=(e,n,t)=>new Promise((o,r)=>{var l=e=>{try{a(t.next(e))}catch(n){r(n)}},i=e=>{try{a(t.throw(e))}catch(n){r(n)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);a((t=t.apply(e,n)).next())});import{getMarkdown as c,parseMarkdownToStructure as m,setDefaultMathOptions as h}from"stream-markdown-parser";import{defineComponent as p,openBlock as f,createElementBlock as v,withMemo as g,createVNode as y,unref as w,createElementVNode as k,Fragment as x,renderList as b,toDisplayString as _,shallowRef as M,h as T,computed as C,ref as B,watch as I,onMounted as $,onBeforeUnmount as S,normalizeClass as E,createApp as L,inject as j,provide as N,Transition as H,withCtx as P,normalizeStyle as D,renderSlot as R,createCommentVNode as O,readonly as K,defineAsyncComponent as z,createBlock as A,resolveDynamicComponent as W,useAttrs as F,mergeProps as V,isMemoSame as U,markRaw as X,reactive as q,nextTick as G,withDirectives as Y,vShow as Z,Teleport as J}from"vue";import{autoUpdate as Q,offset as ee,flip as ne,shift as te,computePosition as oe}from"@floating-ui/dom";const re=["cite"],le=(e,n)=>{const t=e.__vccOpts||e;for(const[o,r]of n)t[o]=r;return t},ie=/* @__PURE__ */le(/* @__PURE__ */p({__name:"BlockquoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(t,o)=>(f(),v("blockquote",{class:"blockquote",dir:"auto",cite:e.node.cite},[g([n.node.children],()=>y(w(zt),{"index-key":`blockquote-${n.indexKey}`,nodes:n.node.children||[],"custom-id":n.customId,typewriter:n.typewriter,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))},null,8,["index-key","nodes","custom-id","typewriter"]),o,1)],8,re))}}),[["__scopeId","data-v-eeadc8a3"]]);ie.install=e=>{e.component(ie.__name,ie)};const ae={class:"checkbox-node"},se=["checked"],de=/* @__PURE__ */le(/* @__PURE__ */p({__name:"CheckboxNode",props:{node:{}},setup:e=>(n,t)=>(f(),v("span",ae,[k("input",{type:"checkbox",checked:e.node.checked,disabled:"",class:"checkbox-input"},null,8,se)]))}),[["__scopeId","data-v-8dc6c46f"]]);de.install=e=>{e.component(de.__name,de)};const ue={class:"definition-list"},ce={class:"definition-term"},me={class:"definition-desc"},he=/* @__PURE__ */le(/* @__PURE__ */p({__name:"DefinitionListNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(e,t)=>(f(),v("dl",ue,[(f(!0),v(x,null,b(n.node.items,(o,r)=>(f(),v(x,{key:r},[k("dt",ce,[y(w(zt),{"index-key":`definition-term-${n.indexKey}-${r}`,nodes:o.term,"custom-id":n.customId,typewriter:n.typewriter,onCopy:t[0]||(t[0]=n=>e.$emit("copy",n))},null,8,["index-key","nodes","custom-id","typewriter"])]),k("dd",me,[y(w(zt),{"index-key":`definition-desc-${n.indexKey}-${r}`,nodes:o.definition,"custom-id":n.customId,typewriter:n.typewriter,onCopy:t[1]||(t[1]=n=>e.$emit("copy",n))},null,8,["index-key","nodes","custom-id","typewriter"])])],64))),128))]))}}),[["__scopeId","data-v-f88691d6"]]);he.install=e=>{e.component(he.__name,he)};const pe={class:"emoji-node"},fe=/* @__PURE__ */le(/* @__PURE__ */p({__name:"EmojiNode",props:{node:{}},setup:e=>(n,t)=>(f(),v("span",pe,_(e.node.name),1))}),[["__scopeId","data-v-de55dc97"]]);fe.install=e=>{e.component(fe.__name,fe)};const ve="__global__",ge="__MARKSTREAM_VUE_CUSTOM_COMPONENTS_STORE__",ye=(()=>{const e=globalThis;if(e[ge])return e[ge];const n={scopedCustomComponents:{},revision:M(0)};return e[ge]=n,n})(),we=ye.revision;function ke(e,n){"string"==typeof e?ye.scopedCustomComponents[e]=n||{}:ye.scopedCustomComponents[ve]=e||{},we.value++}function xe(e){const n=ye.scopedCustomComponents[ve]||{};if(!e)return n;const t=ye.scopedCustomComponents[e]||{};return n&&0!==Object.keys(n).length?t&&0!==Object.keys(t).length?a(a({},n),t):n:t}function be(e){if(e===ve)throw new Error("removeCustomComponents: use clearGlobalCustomComponents() to clear the global mapping");delete ye.scopedCustomComponents[e],we.value++}function _e(){delete ye.scopedCustomComponents[ve],we.value++}const Me=["id"],Te=["title"],Ce=/* @__PURE__ */le(/* @__PURE__ */p({__name:"FootnoteReferenceNode",props:{node:{}},setup(e){const n=`#footnote-${e.node.id}`;function t(){if("undefined"==typeof document)return;const e=document.querySelector(n);e?e.scrollIntoView({behavior:"smooth"}):console.warn(`Element with href: ${n} not found`)}return(o,r)=>(f(),v("sup",{id:`fnref-${e.node.id}`,class:"footnote-reference",onClick:t},[k("span",{href:n,title:`查看脚注 ${e.node.id}`,class:"footnote-link cursor-pointer"},"["+_(e.node.id)+"]",9,Te)],8,Me))}}),[["__scopeId","data-v-01af0fee"]]);Ce.install=e=>{e.component(Ce.__name,Ce)};const Be=/* @__PURE__ */new Set(["onclick","onerror","onload","onmouseover","onmouseout","onmousedown","onmouseup","onkeydown","onkeyup","onfocus","onblur","onsubmit","onreset","onchange","onselect","ondblclick","ontouchstart","ontouchend","ontouchmove","ontouchcancel","onwheel","onscroll","oncopy","oncut","onpaste","oninput","oninvalid","onreset","onsearch","onsubmit"]),Ie=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e=/* @__PURE__ */new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),Se=/<([a-z][a-z0-9-]*)\b[^>]*>/gi,Ee=/* @__PURE__ */new Set(["script"]),Le=/* @__PURE__ */new Set(["href","src","srcset","xlink:href","formaction"]),je=(()=>{try{return Boolean(!1)}catch(e){}return!1})();function Ne(e){je&&console.warn(e)}function He(e){const n=function(e){let n="";for(const t of e){const e=t.charCodeAt(0);e<=31||127===e||/\s/u.test(t)||(n+=t)}return n}(e).toLowerCase();return!(!n.startsWith("javascript:")&&!n.startsWith("vbscript:"))||!!n.startsWith("data:")&&!(n.startsWith("data:image/")||n.startsWith("data:video/")||n.startsWith("data:audio/"))}function Pe(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function De(e,n){const t=e.toLowerCase();return!$e.has(t)&&(Pe(n,t)||Pe(n,e))}function Re(e){const n={};for(const[t,o]of Object.entries(e)){const e=t.toLowerCase();Be.has(e)||Le.has(e)&&o&&He(o)||(n[t]=o)}return n}function Oe(e,n){const t=n.toLowerCase();if(["checked","disabled","readonly","required","autofocus","multiple","hidden"].includes(t))return"true"===e||""===e||e===n;if(["value","min","max","step","width","height","size","maxlength"].includes(t)){const n=Number(e);if(""!==e&&!Number.isNaN(n))return n}return e}function Ke(e){return e.trim().length>0}function ze(e,n,t,o,r){if(Ee.has(e.toLowerCase()))return null;const l=Re(n),i=l.key,d=null!=i&&""!==i?i:r;if(De(e,o)){const n=o[e]||o[e.toLowerCase()],r=function(e){const n={};for(const[t,o]of Object.entries(e))n[t]=Oe(o,t);return n}(l);return T(n,s(a({},r),{key:d}),t.length>0?t:void 0)}return T(e,s(a({},l),{innerHTML:void 0,key:d}),t.length>0?t:void 0)}function Ae(e,n){if(!e||!e.includes("<"))return!1;if(!n||0===Object.keys(n).length)return!1;let t;for(Se.lastIndex=0;null!==(t=Se.exec(e));)if(De(t[1],n))return!0;return!1}function We(e,n){if(!e)return[];try{const t=function(e,n){let t=0;const o=[],r=[];for(const l of e)if("text"===l.type)(o.length>0?o[o.length-1].children:r).push(l.content);else if("self_closing"===l.type){const e=ze(l.tagName,l.attrs||{},[],n,"ms-html-"+t++),i=o.length>0?o[o.length-1].children:r;null!=e&&i.push(e)}else if("tag_open"===l.type)o.push({tagName:l.tagName,children:[],attrs:l.attrs,autoKey:"ms-html-"+t++});else if("tag_close"===l.type){const e=l.tagName.toLowerCase();let t=-1;for(let n=o.length-1;n>=0;n--)if(o[n].tagName.toLowerCase()===e){t=n;break}if(-1!==t)for(;o.length>t;){const l=o.pop(),i=ze(l.tagName,l.attrs||{},l.children,n,l.autoKey);o.length>0?null!=i&&o[o.length-1].children.push(i):null!=i&&r.push(i),l.tagName.toLowerCase()!==e&&o.length>t&&Ne(`Auto-closing unclosed tag: <${l.tagName}>`)}else Ne(`Ignoring closing tag with no matching opening tag: </${l.tagName}>`)}for(;o.length>0;){const e=o.pop(),t=ze(e.tagName,e.attrs||{},e.children,n,e.autoKey);o.length>0?null!=t&&o[o.length-1].children.push(t):null!=t&&r.push(t),Ne(`Auto-closing unclosed tag: <${e.tagName}>`)}return r}(function(e){var n,t,o;const r=[];let l=0;for(;l<e.length;){if(e.startsWith("\x3c!--",l)){const n=e.indexOf("--\x3e",l);if(-1!==n){l=n+3;continue}break}const i=e.indexOf("<",l);if(-1===i){if(l<e.length){const n=e.slice(l);Ke(n)&&r.push({type:"text",content:n})}break}if(i>l){const n=e.slice(l,i);Ke(n)&&r.push({type:"text",content:n})}if(e.startsWith("![CDATA[",i+1)){const n=e.indexOf("]]>",i);if(-1!==n){r.push({type:"text",content:e.slice(i,n+3)}),l=n+3;continue}break}if(e.startsWith("!",i+1)){const n=e.indexOf(">",i);if(-1!==n){l=n+1;continue}break}const a=e.indexOf(">",i);if(-1===a)break;const s=e.slice(i+1,a).trim(),d=s.startsWith("/"),u=s.endsWith("/");if(d){const e=s.slice(1).trim();r.push({type:"tag_close",tagName:e})}else{const e=s.indexOf(" ");let l,i="";-1===e?l=u?s.slice(0,-1).trim():s.trim():(l=s.slice(0,e).trim(),i=s.slice(e+1));const a={};if(i){const e=/([^\s=]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S*)))?/g;let r;for(;null!==(r=e.exec(i));){const e=r[1],l=null!=(o=null!=(t=null!=(n=r[2])?n:r[3])?t:r[4])?o:"";e&&!e.endsWith("/")&&(a[e]=l)}}r.push({type:u||Ie.has(l.toLowerCase())?"self_closing":"tag_open",tagName:l,attrs:a})}l=a+1}return r}(e),n);return t}catch(o){return t=o,je&&console.error("Failed to parse HTML to VNodes:",t),null}var t}const Fe=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HtmlInlineNode",props:{node:{},customId:{}},setup(e){const n=e,t=C(()=>(we.value,xe(n.customId))),o=p({name:"DynamicRenderer",props:{nodes:{type:Array,required:!0}},render(){return this.nodes}}),r=C(()=>{const e=n.node.content;if(!e)return{mode:"html",content:""};if(n.node.loading&&n.node.autoClosed){const n=We(e,t.value);if(null!==n)return{mode:"dynamic",nodes:n}}if(!Ae(e,t.value))return{mode:"html",content:e};const o=We(e,t.value);return null===o?{mode:"html",content:e}:{mode:"dynamic",nodes:o}}),l=B(null),i="undefined"!=typeof window,a=B({mode:"",content:"",el:null});let s=null;function d(e,n){if(!i||!l.value)return;const t=l.value,o=a.value;if(o.el!==t||o.mode!==e||o.content!==n){if("text"===e)t.textContent=n;else{const e=(!s&&i&&(s=document.createElement("template")),s);if(e){e.innerHTML=n;const o=e.content.cloneNode(!0);"function"==typeof t.replaceChildren?t.replaceChildren(o):(t.innerHTML="",t.appendChild(o))}else t.innerHTML=n}a.value={mode:e,content:n,el:t}}}function u(){d("html",n.node.content)}function c(){d("text",n.node.content)}return I(()=>[n.node.content,n.node.loading,n.node.autoClosed,r.value.mode],()=>{"html"===r.value.mode&&(n.node.loading&&!n.node.autoClosed?c():u())}),$(()=>{"html"===r.value.mode&&(n.node.loading&&!n.node.autoClosed?c():u())}),S(()=>{l.value&&(l.value.innerHTML="",a.value={mode:"",content:"",el:null})}),(e,t)=>"dynamic"===r.value.mode?(f(),v("span",{key:0,class:E(["html-inline-node",{"html-inline-node--loading":n.node.loading}])},[y(w(o),{nodes:r.value.nodes},null,8,["nodes"])],2)):(f(),v("span",{key:1,ref_key:"containerRef",ref:l,class:E(["html-inline-node",{"html-inline-node--loading":n.node.loading}])},null,2))}}),[["__scopeId","data-v-4add5e85"]]);Fe.install=e=>{e.component(Fe.__name,Fe)};const Ve={class:"inline text-[85%] px-1 py-0.5 rounded font-mono bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full before:content-[''] after:content-['']"},Ue=/* @__PURE__ */p({__name:"InlineCodeNode",props:{node:{}},setup:e=>(n,t)=>(f(),v("code",Ve,_(e.node.code),1))});Ue.install=e=>{e.component(Ue.__name,Ue)};const Xe=B(!1),qe=B(""),Ge=B("top"),Ye=B(null),Ze=B(null),Je=B(null),Qe=B(null),en=B(null);let nn=null,tn=null;function on(){nn&&(clearTimeout(nn),nn=null),tn&&(clearTimeout(tn),tn=null)}let rn=!1,ln=null;function an(e,n,t="top",o=!1,r,l){if(!e)return;rn||"undefined"!=typeof document&&(ln||(ln=Promise.resolve().then(()=>mr).then(({default:e})=>{rn=!0;const n=document.createElement("div");n.setAttribute("data-singleton-tooltip","1"),document.body.appendChild(n),L({setup:()=>()=>{var n;return T(e,{visible:Xe.value,"anchor-el":Ye.value,content:qe.value,placement:Ge.value,id:Ze.value,originX:Je.value,originY:Qe.value,isDark:null!=(n=en.value)?n:void 0})}}).mount(n)}).catch(e=>{ln=null,rn=!1,console.warn("[markstream-vue] Failed to load Tooltip component. Tooltips will be disabled.",e)}))),on();const i=()=>{var o,i;Ze.value=`tooltip-${Date.now()}-${Math.floor(1e3*Math.random())}`,Ye.value=e,qe.value=n,Ge.value=t,Je.value=null!=(o=null==r?void 0:r.x)?o:null,Qe.value=null!=(i=null==r?void 0:r.y)?i:null,en.value="boolean"==typeof l?l:null,Xe.value=!0;try{e.setAttribute("aria-describedby",Ze.value)}catch(a){}};o?i():nn=setTimeout(i,80)}function sn(e=!1){on();const n=()=>{if(Ye.value&&Ze.value)try{Ye.value.removeAttribute("aria-describedby")}catch(e){}Xe.value=!1,Ye.value=null,Ze.value=null,Je.value=null,Qe.value=null};e?n():tn=setTimeout(n,120)}const dn={"common.copy":"Copy","common.copied":"Copied","common.decrease":"Decrease","common.reset":"Reset","common.increase":"Increase","common.expand":"Expand","common.collapse":"Collapse","common.preview":"Preview","common.source":"Source","common.export":"Export","common.open":"Open","common.zoomIn":"Zoom in","common.zoomOut":"Zoom out","common.resetZoom":"Reset zoom","image.loadError":"Image failed to load","image.loading":"Loading image..."};function un(e){Object.assign(dn,e)}function cn(){try{const n=globalThis.$vueI18nUse||null;if(n&&"function"==typeof n)try{const e=n();if(e&&"function"==typeof e.t)return{t:e.t.bind(e)}}catch(e){}}catch(e){}return u(null,null,function*(){try{const n=yield import("vue-i18n"),t=n.useI18n||n.default&&n.default.useI18n;if(t&&"function"==typeof t)try{const n=t();if(n&&"function"==typeof n.t)try{globalThis.$vueI18nUse=()=>n}catch(e){}}catch(e){}}catch(e){}}),{t:e=>{var n;return null!=(n=dn[e])?n:function(e){return(e.split(".").pop()||e).replace(/[_-]/g," ").replace(/([A-Z])/g," $1").replace(/\s+/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}(e)}}}const mn=/* @__PURE__ */Symbol("ViewportPriority");function hn(e,n){const t="undefined"!=typeof window&&"undefined"!=typeof document,o="boolean"==typeof n?B(n):n;let r=null,l=null;const i=/* @__PURE__ */new Map;const a=(n,a)=>{const s=B(!1);let d,u=!1;const c=new Promise(e=>{d=()=>{u||(u=!0,e())}}),m=()=>{try{null==r||r.unobserve(n)}catch(e){}if(i.delete(n),!i.size){try{null==r||r.disconnect()}catch(e){}r=null,l=null}};if(!t||!o.value)return s.value=!0,d(),{isVisible:s,whenVisible:c,destroy:m};const h=function(n,o){if(!t)return r;if("undefined"==typeof IntersectionObserver)return null;const a=function(n,t){var o,r,l;return{root:null!=(o=null==e?void 0:e(null!=n?n:null))?o:null,rootMargin:null!=(r=null==t?void 0:t.rootMargin)?r:"300px",threshold:null!=(l=null==t?void 0:t.threshold)?l:0}}(n,o);if(r&&(d=a,(s=l)&&s.root===d.root&&s.rootMargin===d.rootMargin&&s.threshold===d.threshold))return r;var s,d;if(r)try{r.disconnect()}catch(u){}r=new IntersectionObserver(e=>{for(const n of e){const e=i.get(n.target);if(e&&(n.isIntersecting||n.intersectionRatio>0)){if(!e.visible.value){e.visible.value=!0;try{e.resolve()}catch(u){}}null==r||r.unobserve(n.target),i.delete(n.target)}}},{root:a.root,rootMargin:a.rootMargin,threshold:a.threshold}),l=a;for(const e of i.keys())r.observe(e);return r}(n,a);return h?(i.set(n,{resolve:d,visible:s}),h.observe(n),{isVisible:s,whenVisible:c,destroy:m}):(s.value=!0,d(),{isVisible:s,whenVisible:c,destroy:m})};return N(mn,a),a}function pn(){const e=j(mn,void 0);if(e)return e;const n=/* @__PURE__ */new WeakMap;let t=null;return e=>{const o=B(!1);let r,l=!1;const i=new Promise(e=>{r=()=>{l||(l=!0,e())}}),a=()=>{try{null==t||t.unobserve(e)}catch(o){}n.delete(e)},s=t||("undefined"==typeof window||"undefined"==typeof IntersectionObserver?null:(t=new IntersectionObserver(e=>{for(const r of e){const e=n.get(r.target);if(e&&(r.isIntersecting||r.intersectionRatio>0)){if(!e.visible.value){e.visible.value=!0;try{e.resolve()}catch(o){}}null==t||t.unobserve(r.target),n.delete(r.target)}}},{root:null,rootMargin:"300px",threshold:0}),t));return s?(n.set(e,{resolve:r,visible:o}),s.observe(e),{isVisible:o,whenVisible:i,destroy:a}):(o.value=!0,r(),{isVisible:o,whenVisible:i,destroy:a})}}const fn={class:"relative inline-block"},vn=["src","alt","title","loading","tabindex","aria-label"],gn={class:"text-sm whitespace-nowrap"},yn={key:1,class:"text-sm text-gray-500"},wn={key:"error",class:"px-4 py-2 bg-gray-100 flex items-center justify-center rounded-lg gap-2 text-red-500"},kn={class:"text-sm whitespace-nowrap"},xn={key:0,class:"mt-2 text-sm text-gray-500 italic"},bn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"ImageNode",props:{node:{},fallbackSrc:{default:""},showCaption:{type:Boolean,default:!1},lazy:{type:Boolean,default:!0},svgMinHeight:{default:"12rem"},usePlaceholder:{type:Boolean,default:!0}},emits:["load","error","click"],setup(e,{emit:n}){const t=e,o=n,r=B(!1),l=B(!1),i=B(!1),a=B(null),s=pn(),d=B(null),u=B("undefined"==typeof window);"undefined"!=typeof window&&I(()=>a.value,e=>{var n;if(null==(n=d.value)||n.destroy(),d.value=null,!e)return void(u.value=!1);const t=s(e,{rootMargin:"400px"});d.value=t,u.value=t.isVisible.value,t.whenVisible.then(()=>{u.value=!0})},{immediate:!0}),S(()=>{var e;null==(e=d.value)||e.destroy(),d.value=null});const c=C(()=>l.value&&t.fallbackSrc?t.fallbackSrc:t.node.src),m=C(()=>!t.lazy||u.value),h=C(()=>/\.svg(?:\?|$)/i.test(c.value));function p(){t.fallbackSrc&&!i.value?(i.value=!0,l.value=!0):(l.value=!0,o("error",t.node.src))}function g(){r.value=!0,l.value=!1,o("load",c.value)}function x(e){e.preventDefault(),r.value&&!l.value&&o("click",[e,c.value])}const{t:b}=cn();return I(c,()=>{r.value=!1,l.value=!1}),(n,o)=>(f(),v("figure",{ref_key:"figureRef",ref:a,class:"text-center my-8"},[k("div",fn,[y(H,{name:"img-switch",mode:"out-in"},{default:P(()=>{var i,a,s,d,u;return[e.node.loading||l.value||!m.value?l.value?e.node.loading||t.fallbackSrc?O("",!0):(f(),v("div",wn,[R(n.$slots,"error",{node:t.node,displaySrc:c.value,imageLoaded:r.value,hasError:l.value,fallbackSrc:t.fallbackSrc,lazy:t.lazy,isSvg:h.value},()=>[o[1]||(o[1]=k("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24"},[k("path",{fill:"currentColor",d:"M2 2h20v10h-2V4H4v9.586l5-5L14.414 14L13 15.414l-4-4l-5 5V20h8v2H2zm13.547 5a1 1 0 1 0 0 2a1 1 0 0 0 0-2m-3 1a3 3 0 1 1 6 0a3 3 0 0 1-6 0m3.625 6.757L19 17.586l2.828-2.829l1.415 1.415L20.414 19l2.829 2.828l-1.415 1.415L19 20.414l-2.828 2.829l-1.415-1.415L17.586 19l-2.829-2.828z"})],-1)),k("span",kn,_(w(b)("image.loadError")),1)],!0)])):(f(),v("div",{key:"placeholder",class:"placeholder-layer max-w-96 inline-flex items-center justify-center gap-2",style:D(h.value?{minHeight:t.svgMinHeight,width:"100%"}:{minHeight:"6rem"})},[t.usePlaceholder?R(n.$slots,"placeholder",{key:0,node:t.node,displaySrc:c.value,imageLoaded:r.value,hasError:l.value,fallbackSrc:t.fallbackSrc,lazy:t.lazy,isSvg:h.value},()=>[o[0]||(o[0]=k("div",{class:"w-4 h-4 rounded-full border-2 border-solid border-current border-t-transparent animate-spin","aria-hidden":"true"},null,-1)),k("span",gn,_(w(b)("image.loading")),1)],!0):(f(),v("span",yn,_(e.node.raw),1))],4)):(f(),v("img",{key:"image",src:c.value,alt:String(null!=(a=null!=(i=t.node.alt)?i:t.node.title)?a:""),title:String(null!=(d=null!=(s=t.node.title)?s:t.node.alt)?d:""),class:E(["max-w-96 h-auto rounded-lg transition-opacity duration-200 ease-in-out",{"opacity-0":!r.value,"opacity-100":r.value,"cursor-pointer":r.value}]),style:D(h.value?{minHeight:t.svgMinHeight,width:"100%",height:"auto",objectFit:"contain"}:void 0),loading:t.lazy?"lazy":"eager",decoding:"async",tabindex:r.value?0:-1,"aria-label":null!=(u=t.node.alt)?u:w(b)("image.preview"),onError:p,onLoad:g,onClick:x},null,46,vn))]}),_:3})]),t.showCaption&&t.node.alt?(f(),v("figcaption",xn,_(t.node.alt),1)):O("",!0)],512))}}),[["__scopeId","data-v-7ca79b66"]]);bn.install=e=>{e.component(bn.__name,bn)};let _n=null,Mn=!1,Tn=In;function Cn(e){var n;const t=null!=(n=null==e?void 0:e.default)?n:e;return t&&"function"==typeof t.renderToString?t:null}function Bn(){try{const e=globalThis;return Cn(null==e?void 0:e.katex)}catch(e){return null}}function In(){return u(null,null,function*(){const e=Bn();if(e)return e;const n=yield import("katex");try{yield import("katex/dist/contrib/mhchem")}catch(t){}return Cn(n)})}function $n(e){Tn=e,_n=null,Mn=!1}function Sn(e){$n(null!=e?e:In)}function En(){$n(null)}function Ln(){return"function"==typeof Tn}function jn(){return u(this,null,function*(){var e;const n=Bn();if(n)return _n=n,_n;if(_n)return _n;if(Mn)return null;const t=Tn;if(!t)return Mn=!0,null;try{const n=yield t();if(n)return _n=null!=(e=Cn(n))?e:n,_n}catch(o){}return Mn=!0,null})}const Nn=M(!1);let Hn=null;function Pn(){return Hn||(Hn=jn().then(e=>{Nn.value=!!e}).catch(()=>{Nn.value=!1})),K(Nn)}const Dn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"TextNode",props:{node:{}},emits:["copy"],setup(e){const n=Pn();return(t,o)=>(f(),v("span",{class:E([[w(n)&&e.node.center?"text-node-center":""],"whitespace-pre-wrap break-words text-node"])},_(e.node.content),3))}}),[["__scopeId","data-v-56f30838"]]);Dn.install=e=>{e.component(Dn.__name,Dn)};const Rn=z(()=>u(null,null,function*(){var e,n;if("undefined"!=typeof globalThis&&void 0!==globalThis.process&&"test"===(null==(n=null==(e=globalThis.process)?void 0:e.env)?void 0:n.NODE_ENV))return e=>{var n,t;return T(Dn,s(a({},e),{node:s(a({},e.node),{content:null!=(t=e.node.raw)?t:`$${null!=(n=e.node.content)?n:""}$`})}))};try{if(yield jn())return(yield import("./index2.js")).default}catch(t){console.warn('[markstream-vue] Optional peer dependencies for MathInlineNode are missing. Falling back to text rendering. To enable full math rendering features, please install "katex".',t)}return e=>{var n,t;return T(Dn,s(a({},e),{node:s(a({},e.node),{content:null!=(t=e.node.raw)?t:`$${null!=(n=e.node.content)?n:""}$`})}))}})),On=z(()=>u(null,null,function*(){try{if(yield jn())return(yield import("./index3.js")).default}catch(e){console.warn('[markstream-vue] Optional peer dependencies for MathBlockNode are missing. Falling back to text rendering. To enable full math rendering features, please install "katex".',e)}return e=>{var n,t;return T(Dn,s(a({},e),{node:s(a({},e.node),{content:null!=(t=e.node.raw)?t:`$$${null!=(n=e.node.content)?n:""}$$`})}))}})),Kn=/* @__PURE__ */p({__name:"ReferenceNode",props:{node:{},messageId:{},threadId:{}},emits:["click","mouseEnter","mouseLeave"],setup:e=>(n,t)=>(f(),v("span",{class:"reference-node cursor-pointer bg-[hsl(var(--muted))] text-[hsl(var(--muted-foreground))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]",role:"button",tabindex:"0",onClick:t[0]||(t[0]=t=>n.$emit("click",t,e.node.id,e.messageId,e.threadId)),onMouseenter:t[1]||(t[1]=t=>n.$emit("mouseEnter",t,e.node.id,e.messageId,e.threadId)),onMouseleave:t[2]||(t[2]=t=>n.$emit("mouseLeave",t,e.node.id,e.messageId,e.threadId))},_(e.node.id),33))});Kn.install=e=>{e.component(Kn.__name,Kn)};const zn={class:"superscript-node"},An={key:1},Wn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"SuperscriptNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,footnote_reference:Ce,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,emoji:fe,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("sup",zn,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),v(x,{key:`${e.indexKey||"superscript"}-${r}`},[o[t.type]?(f(),A(W(o[t.type]),{key:0,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"superscript"}-${r}`},null,8,["node","custom-id","index-key"])):(f(),v("span",An,_(t.content||t.raw),1))],64))),128))]))}}),[["__scopeId","data-v-6dc1e3ba"]]);Wn.install=e=>{e.component(Wn.__name,Wn)};const Fn={class:"subscript-node"},Vn={key:1},Un=/* @__PURE__ */le(/* @__PURE__ */p({__name:"SubscriptNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,footnote_reference:Ce,strikethrough:Yn,highlight:it,insert:rt,superscript:Wn,emoji:fe,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("sub",Fn,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),v(x,{key:`${e.indexKey||"subscript"}-${r}`},[o[t.type]?(f(),A(W(o[t.type]),{key:0,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"subscript"}-${r}`},null,8,["node","custom-id","index-key"])):(f(),v("span",Vn,_(t.content||t.raw),1))],64))),128))]))}}),[["__scopeId","data-v-69de9b81"]]);Un.install=e=>{e.component(Un.__name,Un)};const Xn={class:"strong-node"},qn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"StrongNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,emphasis:st,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("strong",Xn,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"strong"}-${r}`,"index-key":`${e.indexKey||"strong"}-${r}`,node:t,"custom-id":n.customId},null,8,["index-key","node","custom-id"]))),128))]))}}),[["__scopeId","data-v-af3ce037"]]);qn.install=e=>{e.component(qn.__name,qn)};const Gn={class:"strikethrough-node"},Yn=/* @__PURE__ */le(/* @__PURE__ */p({__name:"StrikethroughNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("del",Gn,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"strikethrough"}-${r}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"strikethrough"}-${r}`},null,8,["node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-904d5bd1"]]);Yn.install=e=>{e.component(Yn.__name,Yn)};const Zn=["href","title","aria-label","aria-hidden"],Jn=["aria-hidden"],Qn={class:"link-text-wrapper relative inline-flex"},et={class:"leading-[normal] link-text"},nt={class:"leading-[normal] link-text"},tt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"LinkNode",props:{node:{},indexKey:{},customId:{},showTooltip:{type:Boolean,default:!0},color:{},underlineHeight:{},underlineBottom:{},animationDuration:{},animationOpacity:{},animationTiming:{},animationIteration:{}},setup(e){const n=e,t=j("markstreamShowTooltips",void 0),o=C(()=>{const e=null==t?void 0:t.value;return"boolean"==typeof e?e:n.showTooltip}),r=C(()=>{var e,t,o,r,l,i;const a=void 0!==n.underlineBottom?"number"==typeof n.underlineBottom?`${n.underlineBottom}px`:String(n.underlineBottom):"-3px";return{"--link-color":null!=(e=n.color)?e:"#0366d6","--underline-height":`${null!=(t=n.underlineHeight)?t:2}px`,"--underline-bottom":a,"--underline-opacity":String(null!=(o=n.animationOpacity)?o:.9),"--underline-duration":`${null!=(r=n.animationDuration)?r:.8}s`,"--underline-timing":null!=(l=n.animationTiming)?l:"linear","--underline-iteration":"number"==typeof n.animationIteration?String(n.animationIteration):null!=(i=n.animationIteration)?i:"infinite"}}),l={text:Dn,strong:qn,strikethrough:Yn,emphasis:st,image:bn,html_inline:Fe,inline_code:Ue},i=C(()=>(we.value,xe(n.customId))),s=F(),d=C(()=>{var e,t;const o=null==(e=n.node)?void 0:e.attrs;if(!o||"object"!=typeof o)return{};const r={};if(Array.isArray(o))for(const n of o)Array.isArray(n)&&n[0]&&(r[String(n[0])]=String(null!=(t=n[1])?t:""));else for(const[n,l]of Object.entries(o))n&&null!=l&&!1!==l&&(r[n]=!0===l?"":String(l));return Re(r)}),u=C(()=>{const e=a(a({},s),d.value);return delete e.title,e});function c(){o.value&&sn()}const m=C(()=>{var e,t,o;const r=null==(e=n.node)?void 0:e.title;return"string"==typeof r&&r.trim().length>0?r:String(null!=(o=null==(t=n.node)?void 0:t.href)?o:"")});return(t,a)=>e.node.loading?(f(),v("span",V({key:1,class:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":e.node.loading?"false":"true"},w(s),{style:r.value}),[k("span",Qn,[k("span",et,[k("span",nt,_(e.node.text),1)]),a[1]||(a[1]=k("span",{class:"underline-anim","aria-hidden":"true"},null,-1))])],16,Jn)):(f(),v("a",V({key:0,class:"link-node",href:e.node.href,title:o.value?"":m.value,"aria-label":`Link: ${m.value}`,"aria-hidden":e.node.loading?"true":"false",target:"_blank",rel:"noopener noreferrer"},u.value,{style:r.value,onMouseenter:a[0]||(a[0]=e=>function(e){var t,r,l;if(!o.value)return;const i=e,a=null!=(null==i?void 0:i.clientX)&&null!=(null==i?void 0:i.clientY)?{x:i.clientX,y:i.clientY}:void 0,s=(null==(t=n.node)?void 0:t.title)||(null==(r=n.node)?void 0:r.href)||(null==(l=n.node)?void 0:l.text)||"";an(e.currentTarget,s,"top",!1,a)}(e)),onMouseleave:c}),[(f(!0),v(x,null,b(e.node.children,(t,o)=>(f(),A(W(function(e){return i.value[e.type]||l[e.type]||null}(t)),{key:`${e.indexKey||"emphasis"}-${o}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"link-text"}-${o}`},null,8,["node","custom-id","index-key"]))),128))],16,Zn))}}),[["__scopeId","data-v-c59222d4"]]);tt.install=e=>{e.component(tt.__name,tt)};const ot={class:"insert-node"},rt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"InsertNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,strikethrough:Yn,highlight:it,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("ins",ot,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"insert"}-${r}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"insert"}-${r}`},null,8,["node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-ab1ec9bc"]]);rt.install=e=>{e.component(rt.__name,rt)};const lt={class:"highlight-node"},it=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HighlightNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,emphasis:st,strikethrough:Yn,insert:rt,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("mark",lt,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"highlight"}-${r}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"highlight"}-${r}`},null,8,["node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-38e31bf6"]]);it.install=e=>{e.component(it.__name,it)};const at={class:"emphasis-node"},st=/* @__PURE__ */le(/* @__PURE__ */p({__name:"EmphasisNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,html_inline:Fe,strong:qn,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,footnote_reference:Ce,math_inline:Rn,reference:Kn},t);return(t,r)=>(f(),v("em",at,[(f(!0),v(x,null,b(e.node.children,(t,r)=>(f(),A(W(o[t.type]),{key:`${e.indexKey||"emphasis"}-${r}`,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"emphasis"}-${r}`},null,8,["node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-8264674d"]]);st.install=e=>{e.component(st.__name,st)};const dt=["href","title"],ut=/* @__PURE__ */le(/* @__PURE__ */p({__name:"FootnoteAnchorNode",props:{node:{}},setup(e){const n=e;function t(e){var t;if(e.preventDefault(),"undefined"==typeof document)return;const o=`fnref-${String(null!=(t=n.node.id)?t:"")}`,r=document.getElementById(o);r&&r.scrollIntoView({behavior:"smooth"})}return(n,o)=>(f(),v("a",{class:"footnote-anchor text-sm text-[#0366d6] hover:underline cursor-pointer",href:`#fnref-${e.node.id}`,title:`返回引用 ${e.node.id}`,onClick:t}," ↩︎ ",8,dt))}}),[["__scopeId","data-v-4756ce0d"]]);ut.install=e=>{e.component(ut.__name,ut)};const ct=["id"],mt={class:"flex-1"},ht=/* @__PURE__ */p({__name:"FootnoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(t,o)=>(f(),v("div",{id:`fnref--${e.node.id}`,class:"flex mt-2 mb-2 text-sm leading-relaxed border-t border-[#eaecef] pt-2"},[k("div",mt,[g([n.node.children],()=>y(w(zt),{"index-key":`footnote-${n.indexKey}`,nodes:n.node.children,"custom-id":n.customId,typewriter:n.typewriter,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))},null,8,["index-key","nodes","custom-id","typewriter"]),o,1)])],8,ct))}});ht.install=e=>{e.component(ht.__name,ht)};const pt={class:"hard-break"},ft=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HardBreakNode",props:{node:{}},setup:e=>(e,n)=>(f(),v("br",pt))}),[["__scopeId","data-v-50c58f70"]]);ft.install=e=>{e.component(ft.__name,ft)};const vt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HeadingNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({text:Dn,inline_code:Ue,link:tt,image:bn,strong:qn,emphasis:st,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,checkbox:de,checkbox_input:de,footnote_reference:Ce,hardbreak:ft,math_inline:Rn,reference:Kn},t);return(t,r)=>g([e.node.level,e.node.children,e.node.attrs],()=>(f(),A(W(`h${e.node.level}`),V({class:["heading-node",[`heading-${e.node.level}`]],dir:"auto"},e.node.attrs),{default:P(()=>[(f(!0),v(x,null,b(e.node.children,(t,r,l,i)=>{const a=[t];if(i&&i.key===`${e.indexKey||"heading"}-${r}`&&U(i,a))return i;const s=(f(),A(W(o[t.type]),{key:`${e.indexKey||"heading"}-${r}`,"custom-id":n.customId,node:t,"index-key":`${e.indexKey||"heading"}-${r}`},null,8,["custom-id","node","index-key"]));return s.memo=a,s},r,0),128))]),_:1},16,["class"])),r,2)}}),[["__scopeId","data-v-af2f957a"]]),gt=vt;gt.install=e=>{e.component(vt.__name,vt)};const yt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"ListItemNode",props:{node:{},item:{},indexKey:{},value:{},customId:{},typewriter:{type:Boolean},showTooltips:{type:Boolean}},emits:["copy"],setup(e){const n=e,t=C(()=>{var e;return null!=(e=n.node)?e:n.item}),o=C(()=>null==n.value?{}:{value:n.value});return(e,r)=>{var l;return f(),v("li",V({class:"list-item pl-1.5 my-2",dir:"auto"},o.value),[g([null==(l=t.value)?void 0:l.children],()=>{var o,l;return y(w(zt),V({showTooltips:n.showTooltips},{"index-key":`list-item-${n.indexKey}`,nodes:null!=(l=null==(o=t.value)?void 0:o.children)?l:[],"custom-id":n.customId,typewriter:n.typewriter,"batch-rendering":!1,onCopy:r[0]||(r[0]=n=>e.$emit("copy",n))}),null,16,["index-key","nodes","custom-id","typewriter"])},r,1)],16)}}}),[["__scopeId","data-v-1410f3a8"]]);yt.install=e=>{e.component(yt.__name,yt)};const wt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"ListNode",props:{node:{},customId:{},indexKey:{},typewriter:{type:Boolean},showTooltips:{type:Boolean}},emits:["copy"],setup(e){const n=C(()=>(we.value,xe(e.customId).list_item||yt));return(t,o)=>(f(),A(W(e.node.ordered?"ol":"ul"),{class:E(["list-node",{"list-decimal":e.node.ordered,"list-disc":!e.node.ordered}])},{default:P(()=>[(f(!0),v(x,null,b(e.node.items,(r,l,i,a)=>{var s;const d=[r];if(a&&a.key===`${e.indexKey||"list"}-${l}`&&U(a,d))return a;const u=(f(),A(W(n.value),V({key:`${e.indexKey||"list"}-${l}`},{ref_for:!0},{showTooltips:e.showTooltips},{node:r,"custom-id":e.customId,"index-key":`${e.indexKey||"list"}-${l}`,typewriter:e.typewriter,value:e.node.ordered?(null!=(s=e.node.start)?s:1)+l:void 0,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))}),null,16,["node","custom-id","index-key","typewriter","value"]));return u.memo=d,u},o,1),128))]),_:1},8,["class"]))}}),[["__scopeId","data-v-ce9c5cfb"]]);wt.install=e=>{e.component(wt.__name,wt)};const kt={key:1,class:"html-block-node__raw"},xt={key:1,class:"html-block-node__placeholder"},bt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"HtmlBlockNode",props:{node:{},customId:{}},setup(e){const n=e,t=C(()=>{const e=n.node.attrs;if(e){if(Array.isArray(e)){const n={};for(const t of e){if(!t||t.length<2)continue;const[e,o]=t;null!=e&&(n[String(e)]=null==o?"":String(o))}return n}return e}}),o=C(()=>(we.value,xe(n.customId))),r=p({name:"DynamicRenderer",props:{nodes:{type:Array,required:!0}},render(){return this.nodes}}),l=B(null),i=B("undefined"==typeof window),a=B(n.node.content),s=C(()=>{var e,t,r;if(!i.value)return{mode:"html",content:null!=(e=a.value)?e:""};const l=null!=(t=a.value)?t:n.node.content;if(!l)return{mode:"html",content:""};if(n.node.loading){const e=We(l,o.value);return null===e?{mode:"text",content:null!=(r=n.node.raw)?r:l}:{mode:"dynamic",nodes:e}}if(!Ae(l,o.value))return{mode:"html",content:l};const s=We(l,o.value);return null===s?{mode:"html",content:l}:{mode:"dynamic",nodes:s}}),d=pn(),u=B(null),c=!!n.node.loading;return"undefined"!=typeof window?(I(l,e=>{var t,o;if(null==(o=null==(t=u.value)?void 0:t.destroy)||o.call(t),u.value=null,!c)return i.value=!0,void(a.value=n.node.content);if(!e)return void(i.value=!1);const r=d(e,{rootMargin:"400px"});u.value=r,i.value=r.isVisible.value,r.whenVisible.then(()=>{i.value=!0})},{immediate:!0}),I(()=>n.node.content,e=>{c&&!i.value||(a.value=e)})):i.value=!0,S(()=>{var e,n;null==(n=null==(e=u.value)?void 0:e.destroy)||n.call(e),u.value=null}),(n,o)=>(f(),v("div",V({ref_key:"htmlRef",ref:l,class:"html-block-node"},t.value),[i.value?(f(),v(x,{key:0},["dynamic"===s.value.mode?(f(),A(w(r),{key:0,nodes:s.value.nodes},null,8,["nodes"])):"text"===s.value.mode?(f(),v("pre",kt,_(s.value.content),1)):g([a.value],()=>(f(),v("div",{key:2,innerHTML:a.value},null,8,["innerHTML"])),o,0)],64)):(f(),v("div",xt,[R(n.$slots,"placeholder",{node:e.node},()=>[o[1]||(o[1]=k("span",{class:"html-block-node__placeholder-bar"},null,-1)),o[2]||(o[2]=k("span",{class:"html-block-node__placeholder-bar w-4/5"},null,-1)),o[3]||(o[3]=k("span",{class:"html-block-node__placeholder-bar w-2/3"},null,-1))],!0)]))],16))}}),[["__scopeId","data-v-6797fa3c"]]);bt.install=e=>{e.component(bt.__name,bt)};const _t={dir:"auto",class:"paragraph-node"},Mt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"ParagraphNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=xe(n.customId),o=a({inline_code:Ue,image:bn,link:tt,hardbreak:ft,emphasis:st,strong:qn,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,html_inline:Fe,html_block:bt,emoji:fe,checkbox:de,math_inline:Rn,checkbox_input:de,reference:Kn,footnote_anchor:ut,footnote_reference:Ce},t),r=Pn();return(t,l)=>(f(),v("p",_t,[(f(!0),v(x,null,b(e.node.children,(t,l)=>(f(),v(x,{key:`${e.indexKey||"paragraph"}-${l}`},["text"!==t.type?(f(),A(W(o[t.type]),{key:0,node:t,"index-key":`${e.indexKey}-${l}`,"custom-id":n.customId},null,8,["node","index-key","custom-id"])):(f(),v("span",{key:1,class:E([[w(r)&&t.center?"text-node-center":""],"whitespace-pre-wrap break-words text-node"])},_(t.content),3))],64))),128))]))}}),[["__scopeId","data-v-4e2afdbc"]]);Mt.install=e=>{e.component(Mt.__name,Mt)};const Tt=["aria-busy","aria-label","data-language"],Ct=["textContent"],Bt=/* @__PURE__ */p({__name:"PreCodeNode",props:{node:{}},setup(e){const n=e,t=C(()=>{var e,t,o;const r=String(null!=(t=null==(e=n.node)?void 0:e.language)?t:"");return String(null!=(o=String(r).split(/\s+/g)[0])?o:"").toLowerCase().replace(/[^\w-]/g,"")||"plaintext"}),o=C(()=>`language-${t.value}`),r=C(()=>{const e=t.value;return e?`Code block: ${e}`:"Code block"});return(n,l)=>(f(),v("pre",{class:E([o.value]),"aria-busy":!0===e.node.loading,"aria-label":r.value,"data-language":t.value,tabindex:"0"},[k("code",{translate:"no",textContent:_(e.node.code)},null,8,Ct)],10,Tt))}});Bt.install=e=>{e.component(Bt.__name,Bt)};const It={class:"table-node-wrapper"},$t=["aria-busy"],St={class:"border-[var(--table-border,#cbd5e1)]"},Et={class:"border-b"},Lt={key:0,class:"table-node__loading",role:"status","aria-live":"polite"},jt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"TableNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e,t=C(()=>{var e;return null!=(e=n.node.loading)&&e}),o=C(()=>{var e;return null!=(e=n.node.rows)?e:[]});return(r,l)=>(f(),v("div",It,[k("table",{class:E(["my-8 text-sm table-node",{"table-node--loading":t.value}]),"aria-busy":t.value},[k("thead",St,[k("tr",Et,[(f(!0),v(x,null,b(e.node.header.cells,(e,t)=>(f(),v("th",{key:`header-${t}`,dir:"auto",class:E(["font-semibold p-[calc(4/7*1em)]",["right"===e.align?"text-right":"center"===e.align?"text-center":"text-left"]])},[y(w(zt),{nodes:e.children,"index-key":`table-th-${n.indexKey}`,"custom-id":n.customId,typewriter:n.typewriter,onCopy:l[0]||(l[0]=e=>r.$emit("copy",e))},null,8,["nodes","index-key","custom-id","typewriter"])],2))),128))])]),k("tbody",null,[(f(!0),v(x,null,b(o.value,(e,t)=>(f(),v("tr",{key:`row-${t}`,class:E(["border-[var(--table-border,#cbd5e1)]",[t<o.value.length-1?"border-b":""]])},[(f(!0),v(x,null,b(e.cells,(e,o)=>(f(),v("td",{key:`cell-${t}-${o}`,class:E(["p-[calc(4/7*1em)]",["right"===e.align?"text-right":"center"===e.align?"text-center":"text-left"]]),dir:"auto"},[y(w(zt),{nodes:e.children,"index-key":`table-td-${n.indexKey}`,"custom-id":n.customId,typewriter:n.typewriter,onCopy:l[1]||(l[1]=e=>r.$emit("copy",e))},null,8,["nodes","index-key","custom-id","typewriter"])],2))),128))],2))),128))])],10,$t),y(H,{name:"table-node-fade"},{default:P(()=>[t.value?(f(),v("div",Lt,[R(r.$slots,"loading",{isLoading:t.value},()=>[l[2]||(l[2]=k("span",{class:"table-node__spinner animate-spin","aria-hidden":"true"},null,-1)),l[3]||(l[3]=k("span",{class:"sr-only"},"Loading",-1))],!0)])):O("",!0)]),_:3})]))}}),[["__scopeId","data-v-369096fa"]]);jt.install=e=>{e.component(jt.__name,jt)};const Nt={class:"hr-node"},Ht=/* @__PURE__ */le({},[["render",function(e,n){return f(),v("hr",Nt)}],["__scopeId","data-v-639cbad9"]]);Ht.install=e=>{e.component(Ht.__name,Ht)};const Pt={class:"unknown-node"},Dt=/* @__PURE__ */p({__name:"FallbackComponent",props:{node:{}},setup:e=>(n,t)=>(f(),v("div",Pt,_(e.node.raw),1))}),Rt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"VmrContainerNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},customId:{}},setup(e){const n=e,t=C(()=>`vmr-container vmr-container-${n.node.name}`),o=xe(n.customId),r=a({text:Dn,paragraph:Mt,heading:gt,inline_code:Ue,link:tt,image:bn,strong:qn,emphasis:st,strikethrough:Yn,insert:rt,subscript:Un,superscript:Wn,checkbox:de,checkbox_input:de,hardbreak:ft,math_inline:Rn,reference:Kn,list:wt,math_block:On,table:jt},o);return(o,l)=>(f(),v("div",V({class:t.value},e.node.attrs),[(f(!0),v(x,null,b(e.node.children,(t,o,l,i)=>{const a=[t];if(i&&i.key===`${e.indexKey||"vmr-container"}-${o}`&&U(i,a))return i;const s=(f(),A(W((d=t.type,r[d]||Dt)),{key:`${e.indexKey||"vmr-container"}-${o}`,"custom-id":n.customId,node:t,"index-key":`${e.indexKey||"vmr-container"}-${o}`},null,8,["custom-id","node","index-key"]));var d;return s.memo=a,s},l,0),128))],16))}}),[["__scopeId","data-v-fac7405d"]]);Rt.install=e=>{e.component(Rt.__name,Rt)};const Ot=["data-custom-id"],Kt=["data-node-index","data-node-type"],zt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"NodeRenderer",props:{content:{},nodes:{},final:{type:Boolean},parseOptions:{},customMarkdownIt:{},debugPerformance:{type:Boolean,default:!1},customHtmlTags:{},viewportPriority:{type:Boolean},codeBlockStream:{type:Boolean,default:!0},codeBlockDarkTheme:{},codeBlockLightTheme:{},codeBlockMonacoOptions:{},renderCodeBlocksAsPre:{type:Boolean},codeBlockMinWidth:{},codeBlockMaxWidth:{},codeBlockProps:{},mermaidProps:{},d2Props:{},infographicProps:{},showTooltips:{type:Boolean,default:!0},themes:{},isDark:{type:Boolean},customId:{},indexKey:{},typewriter:{type:Boolean,default:!0},batchRendering:{type:Boolean,default:!0},initialRenderBatchSize:{default:40},renderBatchSize:{default:80},renderBatchDelay:{default:16},renderBatchBudgetMs:{default:6},renderBatchIdleTimeoutMs:{default:120},deferNodesUntilVisible:{type:Boolean,default:!0},maxLiveNodes:{default:320},liveNodeBuffer:{default:60}},emits:["copy","handleArtifactClick","click","mouseover","mouseout"],setup(e,{emit:n}){var t,o,r;const l=e,i=n,d=B(),h=B(!1),p=/auto|scroll|overlay/i,g="undefined"!=typeof window,y=C(()=>l.debugPerformance&&g&&"undefined"!=typeof console),w=F(),k=C(()=>{var e;if("boolean"==typeof l.showTooltips)return l.showTooltips;const n=null!=(e=w.showTooltips)?e:w["show-tooltips"];return""===n||!0===n||"true"===n||!1!==n&&"false"!==n&&void 0});function _(e,n){y.value&&console.info(`[markstream-vue][perf] ${e}`,n)}function M(e){if("undefined"==typeof window)return null;const n=null!=e?e:d.value;if(!n)return null;const t=n.ownerDocument||document,o=t.scrollingElement||t.documentElement;let r=n;for(;r&&r!==t.body&&r!==o;){const e=window.getComputedStyle(r),n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(p.test(n)||p.test(t))return r;r=r.parentElement}return null}N("markstreamShowTooltips",k);const T=l.customId?`renderer-${l.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,$=c(T),L=/* @__PURE__ */new Map,j=C(()=>{const{key:e,tags:n}=function(e){if(!e||0===e.length)return{key:"",tags:[]};const n=/* @__PURE__ */new Set,t=[];for(const o of e){const e=K(o);e&&!n.has(e)&&(n.add(e),t.push(e))}return 0===t.length?{key:"",tags:[]}:{key:t.join(","),tags:t}}(l.customHtmlTags);if(!e)return $;const t=L.get(e);if(t)return t;const o=c(T,{customHtmlTags:n});return L.set(e,o),o}),R=C(()=>{const e=j.value;return l.customMarkdownIt?l.customMarkdownIt(e):e});function K(e){const n=String(null!=e?e:"").trim();if(!n)return"";const t=n.match(/^[<\s/]*([A-Z][\w-]*)/i);return t?t[1].toLowerCase():""}const U=C(()=>{var e,n,t,o;const r=null!=(e=l.parseOptions)?e:{},i=null!=(n=l.final)?n:r.final,s=[...null!=(t=l.customHtmlTags)?t:[],...null!=(o=r.customHtmlTags)?o:[]].map(K).filter(Boolean),d=null!=i,u=s.length>0;return d||u?a(a(a({},r),d?{final:i}:{}),u?{customHtmlTags:Array.from(new Set(s))}:{}):r}),Y=C(()=>{var e;if(null==(e=l.nodes)?void 0:e.length)return X(l.nodes.slice());if(l.content){const e=y.value?performance.now():0,n=m(l.content,R.value,U.value);return y.value&&_("parse(sync)",{ms:Math.round(performance.now()-e),nodes:n.length,contentLength:l.content.length}),X(n)}return[]}),Z=C(()=>{var e;return Math.max(1,null!=(e=l.maxLiveNodes)?e:320)}),J=C(()=>{var e;return!((null!=(e=l.maxLiveNodes)?e:0)<=0)&&Y.value.length>Z.value}),Q=C(()=>!1!==l.viewportPriority&&!h.value),ee=hn(e=>{var n;return M(null!=(n=null!=e?e:d.value)?n:null)},Q),ne=g&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame.bind(window):null,te=g&&"function"==typeof window.cancelAnimationFrame?window.cancelAnimationFrame.bind(window):null,oe="undefined"!=typeof globalThis&&void 0!==globalThis.process&&"test"===(null==(o=null==(t=globalThis.process)?void 0:t.env)?void 0:o.NODE_ENV),re=g&&"function"==typeof window.requestIdleCallback,le=C(()=>{var e;const n=Math.trunc(null!=(e=l.renderBatchSize)?e:80);return Number.isFinite(n)?Math.max(0,n):0}),ae=C(()=>{var e;const n=Math.trunc(null!=(e=l.initialRenderBatchSize)?e:le.value);return Number.isFinite(n)?Math.max(0,n):le.value}),se=C(()=>!1!==l.batchRendering&&le.value>0&&g&&!oe),ue=B(0),ce=B({key:l.indexKey,total:0}),me=B(Math.max(1,le.value||1)),pe=q({}),ve=/* @__PURE__ */new Map,ge=/* @__PURE__ */new Map,ye=/* @__PURE__ */new Map,ke=/* @__PURE__ */new WeakMap,be=B(0),_e=C(()=>(be.value,Array.from(ye.entries()).sort((e,n)=>e[0]-n[0]))),Me=B(0),Te=B([]),Be=B([]),Ie=B(null);let $e=null,Se=null;const Ee=C(()=>{var e;return!1!==l.deferNodesUntilVisible&&!((null!=(e=l.maxLiveNodes)?e:0)<=0)&&!J.value&&!(Y.value.length>900)&&Q.value}),Le=C(()=>{var e;return se.value&&(null!=(e=l.maxLiveNodes)?e:0)<=0}),je=B({batchSize:le.value,initial:ae.value,delay:null!=(r=l.renderBatchDelay)?r:16,enabled:Le.value}),Ne=C(()=>!!ee&&(Ee.value||J.value)),He=C(()=>{var e;return Math.max(0,null!=(e=l.liveNodeBuffer)?e:60)}),Pe=B(0),De=q({start:0,end:0}),Re=/* @__PURE__ */new Map,Oe=C(()=>{if(!J.value)return Y.value.length;const e=He.value,n=Math.max(De.end+e,ae.value),t=Math.min(Y.value.length,n);return Math.max(ue.value,t)});function Ke(e){var n,t,o,r;const l=M(null!=(n=null!=e?e:d.value)?n:null);if(l)return l;const i=null!=(r=null!=(o=null==e?void 0:e.ownerDocument)?o:null==(t=d.value)?void 0:t.ownerDocument)?r:"undefined"!=typeof document?document:null;return(null==i?void 0:i.scrollingElement)||(null==i?void 0:i.documentElement)||null}function ze(e){if(!g)return!1;try{const n=window.getComputedStyle(e);return!!(n.display||"").toLowerCase().includes("flex")&&(n.flexDirection||"").toLowerCase().endsWith("reverse")}catch(n){return!1}}function Ae(){$e&&($e(),$e=null),Ie.value=null}function We(){if(!g||!J.value)return;const e=Ke();if(!e||Ie.value===e)return;Ae();const n=()=>Xe();e.addEventListener("scroll",n,{passive:!0}),Ie.value=e,$e=()=>{e.removeEventListener("scroll",n)}}function Ve(){var e,n,t;if(!Se)return;const o=null!=(t=null==(n=null==(e=d.value)?void 0:e.ownerDocument)?void 0:n.defaultView)?t:"undefined"!=typeof window?window:null;Se.viaTimeout?o?o.clearTimeout(Se.id):clearTimeout(Se.id):null==te||te(Se.id),Se=null}function Xe(e={}){var n,t,o;if(!J.value)return;if(!g)return void qe(!0);if(e.immediate)return Ve(),void qe(!0);if(Se)return;const r=()=>{Se=null,qe()};if(ne)Se={id:ne(r),viaTimeout:!1};else{const e=null!=(o=null==(t=null==(n=d.value)?void 0:n.ownerDocument)?void 0:t.defaultView)?o:"undefined"!=typeof window?window:null,l=e?e.setTimeout(r,16):setTimeout(r,16);Se={id:l,viaTimeout:!0}}}function qe(e=!1){var n,t,o,r,l,i,a;if(!J.value)return;const s=Ie.value||Ke();if(!s)return;const u=s.ownerDocument||(null==(n=d.value)?void 0:n.ownerDocument)||document,c=(null==u?void 0:u.defaultView)||("undefined"!=typeof window?window:null),m=s===(null==u?void 0:u.documentElement)||s===(null==u?void 0:u.body),h=Y.value.length;if(!m&&h>0&&ze(s)){const n=s.clientHeight||0,t=s.scrollTop,o=t<0?-t:t,r=function(e){var n;const t=Y.value;if(!t.length)return 0;if(e<=0)return Math.max(0,t.length-1);if(Me.value===t.length){const n=rn(0,t.length);return dn(Math.max(0,n-e))}let o=e;for(let r=t.length-1;r>=0;r--){const e=null!=(n=Ye[r])?n:on.value;if(o<=e)return r;o-=e}return 0}(Math.max(0,o)+.5*Math.max(0,n)),l=Ge(r,0,Math.max(0,h-1));return void((e||Math.abs(l-Pe.value)>1)&&(Pe.value=l))}const p=m?null:s.getBoundingClientRect(),f=m?0:p.top,v=m?null!=(o=null!=(t=null==c?void 0:c.innerHeight)?t:s.clientHeight)?o:0:p.bottom,g=_e.value;let y=null,w=null;for(const[d,x]of g){if(!x)continue;const e=x.getBoundingClientRect();e.bottom<=f||e.top>=v||(null==y&&(y=d),w=d)}if(null==y||null==w){const e=d.value;if(!e)return;const n=m?{top:0}:s.getBoundingClientRect(),t=function(e,n,t){var o,r,l,i,a,s;if(t)return null!=(i=null!=(l=null==(o=null==n?void 0:n.documentElement)?void 0:o.scrollTop)?l:null==(r=null==n?void 0:n.body)?void 0:r.scrollTop)?i:0;const d=e.scrollTop;if(!ze(e))return d;const u=d<0?-d:d;return Math.max(0,(null!=(a=e.scrollHeight)?a:0)-(null!=(s=e.clientHeight)?s:0))-u}(s,u,m),o=m?(()=>{const t=e.getBoundingClientRect(),o=(m?0:n.top)-t.top;return Math.max(0,o)})():(()=>{const n=function(e,n){let t=e,o=0,r=0;for(;t&&t!==n&&r++<64;)o+=t.offsetTop||0,t=t.offsetParent;return o}(e,s);return Math.max(0,t-n)})(),h=m?null!=(a=null!=(i=null!=(l=null==c?void 0:c.innerHeight)?l:null==(r=null==u?void 0:u.documentElement)?void 0:r.clientHeight)?i:s.clientHeight)?a:0:s.clientHeight,p=dn(o+.5*Math.max(0,h));return void(Pe.value=Ge(p,0,Math.max(0,Y.value.length-1)))}const k=Math.round((y+w)/2);!e&&Math.abs(k-Pe.value)<=1||(Pe.value=Ge(k,0,Math.max(0,Y.value.length-1)))}function Ge(e,n,t){return Math.min(Math.max(e,n),t)}const Ye=q({}),Ze=q({total:0,count:0});function Je(){for(const e of Object.keys(Ye))delete Ye[Number(e)];Ze.total=0,Ze.count=0,Me.value=0,Te.value=[],Be.value=[]}function Qe(e,n,t){for(let o=n+1;o<e.length;o+=o&-o)e[o]+=t}function en(e,n){let t=0;for(let o=n+1;o>0;o-=o&-o)t+=e[o];return t}function nn(e,n,t){if(t<=n)return 0;const o=en(e,t-1);return n<=0?o:o-en(e,n-1)}function tn(e){Me.value=e;const n=new Array(e+1).fill(0),t=new Array(e+1).fill(0);for(const[o,r]of Object.entries(Ye)){const l=Number(o),i=Number(r);!Number.isFinite(l)||l<0||l>=e||!Number.isFinite(i)||i<=0||(Qe(n,l,i),Qe(t,l,1))}Te.value=n,Be.value=t}const on=C(()=>Ze.count>0?Math.max(12,Ze.total/Ze.count):32);function rn(e,n){var t,o;if(e>=n)return 0;if(Me.value!==Y.value.length){let o=0;for(let r=e;r<n;r++)o+=null!=(t=Ye[r])?t:on.value;return o}const r=Te.value,l=Be.value;if(!r.length||!l.length){let t=0;for(let r=e;r<n;r++)t+=null!=(o=Ye[r])?o:on.value;return t}return nn(r,e,n)+(n-e-nn(l,e,n))*on.value}I(()=>Y.value.length,e=>{e<=0?Je():(e<Me.value&&function(e){if(e<=0)return void Je();let n=0,t=0;for(const[o,r]of Object.entries(Ye)){const l=Number(o),i=Number(r);!Number.isFinite(l)||l<0||l>=e||!Number.isFinite(i)||i<=0?delete Ye[l]:(n+=i,t++)}Ze.total=n,Ze.count=t}(e),e!==Me.value&&tn(e))},{immediate:!0});const ln=C(()=>{if(!J.value)return Y.value.map((e,n)=>({node:e,index:n}));const e=Y.value.length,n=Ge(De.start,0,e),t=Ge(De.end,n,e);return Y.value.slice(n,t).map((e,t)=>({node:e,index:n+t}))}),an=C(()=>J.value?rn(0,Math.min(De.start,Y.value.length)):0),sn=C(()=>{if(!J.value)return 0;const e=Y.value.length;return rn(Math.min(De.end,e),e)});function dn(e){var n;if(e<=0)return 0;const t=Y.value;if(Me.value===t.length&&Te.value.length&&Be.value.length){const n=on.value,o=Te.value,r=Be.value,l=e=>e<=0?0:en(o,e-1)+(e-en(r,e-1))*n;let i=0,a=t.length-1,s=t.length-1;for(;i<=a;){const n=i+a>>1;l(n+1)>=e?(s=n,a=n-1):i=n+1}return s}let o=e;for(let r=0;r<t.length;r++){const e=null!=(n=Ye[r])?n:on.value;if(o<=e)return r;o-=e}return Math.max(0,t.length-1)}function un(){be.value+=1}function cn(e){if(!ve.size)return;if(!J.value)return;let n=!1;for(const[t,o]of ve)t>=e&&(o.destroy(),ve.delete(t),Ee.value&&delete pe[t],_n(t),ye.delete(t)&&(n=!0));n&&un()}function mn(e,n){Ee.value&&(pe[e]=n),n&&(J.value?Xe():Pe.value=Ge(e,0,Math.max(0,Y.value.length-1)))}function pn(e){const n=ve.get(e);n&&(n.destroy(),ve.delete(e)),_n(e)}function fn(e,n){let t=!1;if(n){const o=ye.get(e);ye.set(e,n),o!==n&&(t=!0)}else ye.delete(e)&&(t=!0);if(t&&un(),n||_n(e),!Ne.value||!ee)return pn(e),void(n?mn(e,!0):Ee.value&&delete pe[e]);if(!J.value&&Ee.value&&!h.value&&ve.size>=640&&(function(){if(!h.value){h.value=!0;for(const e of ve.values())e.destroy();if(ve.clear(),g)for(const e of ge.values())window.clearTimeout(e);ge.clear();for(const e of Object.keys(pe))delete pe[e]}}(),!Ne.value||!ee))return pn(e),void(n?mn(e,!0):Ee.value&&delete pe[e]);if(e<ae.value&&!J.value)return pn(e),void mn(e,!0);if(!n)return pn(e),void(Ee.value&&delete pe[e]);pn(e);const o=ee(n,{rootMargin:"400px"});o&&(ve.set(e,o),mn(e,o.isVisible.value),Ee.value&&function(e){if(!g||!Ee.value)return;_n(e);const n=e%17*23,t=window.setTimeout(()=>{var n,t;if(ge.delete(e),!Ee.value)return;if(!0===pe[e])return;const o=ye.get(e);if(!o)return void delete pe[e];const r=Ke(o),l=o.ownerDocument||document,i=l.defaultView||window,a=!r||r===l.documentElement||r===l.body,s=!a&&r?r.getBoundingClientRect():null,d=a?0:s.top,u=a?null!=(t=null!=(n=i.innerHeight)?n:null==r?void 0:r.clientHeight)?t:0:s.bottom,c=o.getBoundingClientRect();c.bottom>=d-500&&c.top<=u+500&&mn(e,!0)},1800+n);ge.set(e,t)}(e),o.whenVisible.then(()=>{_n(e),mn(e,!0)}).catch(()=>{}).finally(()=>{ve.get(e)===o&&ve.delete(e);try{o.destroy()}catch(n){}}),J.value&&Xe())}let vn=null,gn=null,yn=!1,wn=null,kn=null;function xn(){g&&(null!=vn&&(null==te||te(vn),vn=null),null!=gn&&(window.clearTimeout(gn),gn=null),null!=kn&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(kn),kn=null),yn=!1,wn=null)}function _n(e){if(!g)return;const n=ge.get(e);null!=n&&(window.clearTimeout(n),ge.delete(e))}function Mn(e,n={}){var t,o;if(!Le.value)return;const r=Oe.value;if(ue.value>=r)return;const i=Math.max(1,e),a=e=>{var n;vn=null,gn=null,kn=null,yn=!1;const t=null!=wn?wn:i;wn=null;const o=Math.max(2,null!=(n=l.renderBatchBudgetMs)?n:6),a=e=>{const n="undefined"!=typeof performance?performance.now():Date.now();ue.value=Math.min(r,ue.value+Math.max(1,e)),cn(ue.value);const t=("undefined"!=typeof performance?performance.now():Date.now())-n;return function(e){var n;if(!Le.value)return;const t=Math.max(2,null!=(n=l.renderBatchBudgetMs)?n:6),o=Math.max(1,le.value||1),r=Math.max(1,Math.floor(o/4));e>1.2*t?me.value=Math.max(r,Math.floor(.7*me.value)):e<.5*t&&me.value<o&&(me.value=Math.min(o,Math.ceil(1.2*me.value)))}(t),t};let s=t;for(;(a(s),!(ue.value>=r)&&e)&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)s=Math.max(1,Math.round(me.value));ue.value<r&&Tn()};if(!g||n.immediate)return void a();const s=Math.max(0,null!=(t=l.renderBatchDelay)?t:16);if(wn=null!=wn?Math.max(wn,i):i,!yn){if(yn=!0,!oe&&re&&window.requestIdleCallback){const e=Math.max(0,null!=(o=l.renderBatchIdleTimeoutMs)?o:120);return void(kn=window.requestIdleCallback(e=>{a(e)},{timeout:e}))}ne&&!oe?vn=ne(()=>{0!==s?gn=window.setTimeout(()=>a(),s):a()}):gn=window.setTimeout(()=>a(),s)}}function Tn(){Le.value&&Mn(se.value?Math.max(1,Math.round(me.value)):Math.max(1,le.value))}I([()=>Y.value,()=>Y.value.length,()=>Le.value,()=>le.value,()=>ae.value,()=>l.renderBatchDelay,()=>l.indexKey],()=>{var e;const n=Y.value.length,t=ce.value,o=l.indexKey,r=void 0!==o&&o!==t.key,i=n!==t.total,a=r||i;ce.value={key:o,total:n};const s=je.value,d=null!=(e=l.renderBatchDelay)?e:16,u=s.batchSize!==le.value||s.initial!==ae.value||s.delay!==d||s.enabled!==Le.value;je.value={batchSize:le.value,initial:ae.value,delay:d,enabled:Le.value},r&&(Je(),n>0&&tn(n)),(a||u||!Le.value)&&xn(),(a||u)&&(me.value=Math.max(1,le.value||1)),a&&J.value&&Xe({immediate:!0});const c=Oe.value;if(!n)return ue.value=0,void cn(0);if(!Le.value)return ue.value=c,void cn(ue.value);const m=r||0===t.total;ue.value=m||u?Math.min(c,ae.value):Math.min(ue.value,c);const h=Math.max(1,ae.value||le.value||n);ue.value<c?Mn(h,{immediate:!g}):cn(ue.value)},{immediate:!0}),I(()=>J.value,e=>{if(!e)return Ae(),void Ve();We(),Xe({immediate:!0})},{immediate:!0}),I([()=>Y.value.length,()=>J.value],e=>u(null,[e],function*([e,n]){n&&e&&g&&(yield G(),Xe({immediate:!0}))}),{flush:"post"}),I(()=>d.value,()=>{J.value&&(We(),Xe({immediate:!0}))}),I(()=>Y.value.length,()=>{J.value&&Xe({immediate:!0})}),I(()=>Ee.value,e=>{if(e)for(const[n,t]of ye)fn(n,t);else{for(const e of ve.values())e.destroy();ve.clear();for(const e of Array.from(ge.keys()))_n(e);for(const e of Object.keys(pe))delete pe[e];for(const[e,n]of ye)n&&mn(e,!0)}},{immediate:!1}),I([()=>l.viewportPriority,()=>Y.value.length],([e,n])=>{!1!==e?h.value&&n<=200&&(h.value=!1):h.value=!1}),I(()=>ue.value,()=>{J.value&&Xe({immediate:!0})}),I([Pe,Z,He,()=>Y.value.length,J],()=>{!function(){const e=Y.value.length;if(!J.value||0===e)return De.start=0,void(De.end=e);const n=Math.min(Z.value,e),t=He.value,o=Ge(Pe.value-t,0,Math.max(0,e-n));De.start=o,De.end=Math.min(e,o+n)}()},{immediate:!0}),I([()=>Y.value.length,J,Z,He,()=>De.start,()=>De.end],([e,n,t,o,r,l])=>{y.value&&_("virtualization",{nodes:e,virtualization:n,maxLiveNodes:t,buffer:o,focusIndex:Pe.value,scroll:n?(()=>{const e=Ie.value||Ke();return e?{reverse:ze(e),scrollTop:Math.round(e.scrollTop),scrollTopAbs:Math.round(Math.abs(e.scrollTop)),scrollHeight:Math.round(e.scrollHeight),clientHeight:Math.round(e.clientHeight)}:null})():null,liveRange:{start:r,end:l},rendered:ue.value})}),I(()=>Oe.value,(e,n)=>{Le.value&&("number"==typeof n&&e<=n||e>ue.value&&Tn())}),S(()=>{xn();for(const e of ve.values())e.destroy();ve.clear();for(const e of Array.from(ge.keys()))_n(e);Ae(),Ve()});const Cn=z(()=>u(null,null,function*(){try{return(yield import("./index4.js")).default}catch(e){return console.warn('[markstream-vue] Optional peer dependencies for CodeBlockNode are missing. Falling back to inline-code rendering (no Monaco). To enable full code block features, please install "stream-monaco".',e),Bt}})),Bn=z(()=>u(null,null,function*(){try{return(yield import("./index5.js")).default}catch(e){return console.warn('[markstream-vue] Optional peer dependencies for MermaidBlockNode are missing. Falling back to preformatted code rendering. To enable Mermaid rendering, please install "mermaid".',e),Bt}})),In=z(()=>u(null,null,function*(){try{return(yield import("./index6.js")).default}catch(e){return console.warn('[markstream-vue] Optional peer dependencies for InfographicBlockNode are missing. Falling back to preformatted code rendering. To enable Infographic rendering, please install "@antv/infographic".',e),Bt}})),$n=z(()=>u(null,null,function*(){try{return(yield import("./index7.js")).default}catch(e){return console.warn('[markstream-vue] Optional peer dependencies for D2BlockNode are missing. Falling back to preformatted code rendering. To enable D2 rendering, please install "@terrastruct/d2".',e),Bt}})),Sn=C(()=>l.renderCodeBlocksAsPre?Bt:Cn),En={text:Dn,paragraph:Mt,heading:gt,code_block:Cn,list:wt,list_item:yt,blockquote:ie,table:jt,definition_list:he,footnote:ht,footnote_reference:Ce,footnote_anchor:ut,admonition:qt,vmr_container:Rt,hardbreak:ft,link:tt,image:bn,thematic_break:Ht,math_inline:Rn,math_block:On,strong:qn,emphasis:st,strikethrough:Yn,highlight:it,insert:rt,subscript:Un,superscript:Wn,emoji:fe,checkbox:de,checkbox_input:de,inline_code:Ue,html_inline:Fe,reference:Kn,html_block:bt},Ln=C(()=>(we.value,xe(l.customId))),jn=C(()=>null!=l.indexKey?String(l.indexKey):"markdown-renderer"),Nn=C(()=>a(a({stream:l.codeBlockStream,darkTheme:l.codeBlockDarkTheme,lightTheme:l.codeBlockLightTheme,monacoOptions:l.codeBlockMonacoOptions,themes:l.themes,minWidth:l.codeBlockMinWidth,maxWidth:l.codeBlockMaxWidth},"boolean"==typeof k.value?{showTooltips:k.value}:{}),l.codeBlockProps||{})),Hn=C(()=>a({},l.mermaidProps||{})),Pn=C(()=>a({},l.d2Props||{})),zn=C(()=>a({},l.infographicProps||{})),An=C(()=>({typewriter:l.typewriter})),Fn=C(()=>a(a({},An.value),"boolean"==typeof k.value?{showTooltip:k.value}:{})),Vn=C(()=>a(a({},An.value),"boolean"==typeof k.value?{showTooltips:k.value}:{})),Xn=C(()=>ln.value.map(e=>{const n=function(e){var n,t,o,r,l,i,s;if("code_block"!==e.type)return e;const d=e,u=[String(null!=(n=d.language)?n:""),String(null!=(t=d.loading)?t:""),String(null!=(o=d.diff)?o:""),String(null!=(r=d.code)?r:""),String(null!=(l=d.originalCode)?l:""),String(null!=(i=d.updatedCode)?i:""),String(null!=(s=d.raw)?s:"")].join("\0"),c=ke.get(d);if(c&&c.signature===u)return c.node;const m=a({},d);return ke.set(d,{signature:u,node:m}),m}(e.node),t=Gn(n);return s(a({},e),{node:n,component:Zn(n,t),bindings:Jn(n,t),isCodeBlock:"code_block"===n.type,indexKey:`${jn.value}-${e.index}`})}));function Gn(e){var n;return"code_block"===(null==e?void 0:e.type)?String(null!=(n=e.language)?n:"").trim().toLowerCase():""}function Zn(e,n){if(!e)return Dt;const t=Ln.value,o=t[String(e.type)];if("code_block"===e.type){const r=null!=n?n:Gn(e);if("mermaid"===r)return t.mermaid||Bn;if("infographic"===r)return t.infographic||In;if("d2"===r||"d2lang"===r)return t.d2||$n;if(o)return o;return t.code_block||Sn.value}return o||En[String(e.type)]||Dt}function Jn(e,n){const t=null!=n?n:Gn(e);return"mermaid"===t?Hn.value:"infographic"===t?zn.value:"d2"===t||"d2lang"===t?Pn.value:"link"===e.type?Fn.value:"list"===e.type?Vn.value:"code_block"===e.type?Nn.value:An.value}function Qn(e){i("click",e)}function et(e){var n;(null==(n=e.target)?void 0:n.closest("[data-node-index]"))&&i("mouseover",e)}function nt(e){var n;(null==(n=e.target)?void 0:n.closest("[data-node-index]"))&&i("mouseout",e)}return(e,n)=>(f(),v("div",{ref_key:"containerRef",ref:d,class:E(["markstream-vue markdown-renderer",[{dark:l.isDark},{virtualized:J.value}]]),"data-custom-id":l.customId,onClick:Qn,onMouseover:et,onMouseout:nt},[J.value?(f(),v("div",{key:0,class:"node-spacer",style:D({height:`${an.value}px`}),"aria-hidden":"true"},null,4)):O("",!0),(f(!0),v(x,null,b(Xn.value,e=>{var t,o;return f(),v("div",{key:e.index,ref_for:!0,ref:n=>fn(e.index,n),class:"node-slot","data-node-index":e.index,"data-node-type":e.node.type},[(o=e.index,Le.value&&o>=ue.value||Ee.value&&!(o<ae.value)&&!0!==pe[o]?(f(),v("div",{key:1,class:"node-placeholder",style:D({height:`${null!=(t=Ye[e.index])?t:on.value}px`})},null,4)):(f(),v("div",{key:0,ref_for:!0,ref:n=>function(e,n){n?(Re.set(e,n),queueMicrotask(()=>{!function(e,n){if(!Number.isFinite(n)||n<=0)return;const t=Ye[e];if(Ye[e]=n,t?Ze.total+=n-t:(Ze.total+=n,Ze.count++),Me.value>e){const o=Te.value,r=Be.value;if(o.length&&r.length)if(t){const r=n-t;0!==r&&Qe(o,e,r)}else Qe(o,e,n),Qe(r,e,1)}}(e,n.offsetHeight)})):Re.delete(e)}(e.index,n),class:"node-content"},[e.isCodeBlock||!1===l.typewriter?(f(),A(W(e.component),V({key:1,node:e.node,loading:e.node.loading,"index-key":e.indexKey},{ref_for:!0},e.bindings,{"custom-id":l.customId,"is-dark":l.isDark,onCopy:n[2]||(n[2]=e=>i("copy",e)),onHandleArtifactClick:n[3]||(n[3]=e=>i("handleArtifactClick",e))}),null,16,["node","loading","index-key","custom-id","is-dark"])):(f(),A(H,{key:0,name:"typewriter",appear:""},{default:P(()=>[(f(),A(W(e.component),V({node:e.node,loading:e.node.loading,"index-key":e.indexKey},{ref_for:!0},e.bindings,{"custom-id":l.customId,"is-dark":l.isDark,onCopy:n[0]||(n[0]=e=>i("copy",e)),onHandleArtifactClick:n[1]||(n[1]=e=>i("handleArtifactClick",e))}),null,16,["node","loading","index-key","custom-id","is-dark"]))]),_:2},1024))],512)))],8,Kt)}),128)),J.value?(f(),v("div",{key:1,class:"node-spacer",style:D({height:`${sn.value}px`}),"aria-hidden":"true"},null,4)):O("",!0)],42,Ot))}}),[["__scopeId","data-v-7f3cfaaf"]]);zt.install=e=>{var n,t;const o=null!=(t=null!=(n=zt.__name)?n:zt.name)?t:"NodeRenderer";e.component(o,zt)};const At={key:0,class:"admonition-icon"},Wt={class:"admonition-title"},Ft=["aria-expanded","aria-controls","title"],Vt={key:0},Ut={key:1},Xt=["id"],qt=/* @__PURE__ */le(/* @__PURE__ */p({__name:"AdmonitionNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},customId:{}},emits:["copy"],setup(e,{emit:n}){var t;const o=e,r=n,l={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"},i=C(()=>{if(o.node.title&&o.node.title.trim().length)return o.node.title;const e=o.node.kind||"note";return e.charAt(0).toUpperCase()+e.slice(1)}),a=B(!!o.node.collapsible&&!(null==(t=o.node.open)||t));function s(){o.node.collapsible&&(a.value=!a.value)}const d=`admonition-${Math.random().toString(36).slice(2,9)}`;return(n,t)=>(f(),v("div",{class:E(["admonition",[`admonition-${o.node.kind}`,o.isDark?"is-dark":""]])},[k("div",{id:d,class:"admonition-header"},[l[o.node.kind]?(f(),v("span",At,_(l[o.node.kind]),1)):O("",!0),k("span",Wt,_(i.value),1),o.node.collapsible?(f(),v("button",{key:1,class:"admonition-toggle","aria-expanded":!a.value,"aria-controls":`${d}-content`,title:a.value?"Expand":"Collapse",onClick:s},[a.value?(f(),v("span",Vt,"▶")):(f(),v("span",Ut,"▼"))],8,Ft)):O("",!0)]),Y(k("div",{id:`${d}-content`,class:"admonition-content","aria-labelledby":d},[g([o.node.children],()=>y(w(zt),{"index-key":`admonition-${e.indexKey}`,nodes:o.node.children,"custom-id":o.customId,typewriter:o.typewriter,onCopy:t[0]||(t[0]=e=>r("copy",e))},null,8,["index-key","nodes","custom-id","typewriter"]),t,1)],8,Xt),[[Z,!a.value]])],2))}}),[["__scopeId","data-v-5e95c2b7"]]);qt.install=e=>{e.component(qt.__name,qt)};const Gt=()=>import("@terrastruct/d2");let Yt=null,Zt=Gt;function Jt(e){Zt=e,Yt=null}function Qt(e){Jt(null!=e?e:Gt)}function eo(){Jt(null)}function no(){return"function"==typeof Zt}function to(){return u(this,null,function*(){if(Yt)return Yt;const e=Zt;if(!e)return null;let n;try{n=yield e()}catch(t){if(e===Gt)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw t}return n?(Yt=function(e){var n;if(!e)return e;if(e.D2&&"function"==typeof e.D2)return e.D2;if(e.default&&e.default.D2&&"function"==typeof e.default.D2)return e.default.D2;const t=null!=(n=e.default)?n:e;return"function"==typeof t?t:(null==t?void 0:t.D2)&&"function"==typeof t.D2?t.D2:t}(n),Yt):null})}let oo=!1,ro=null,lo=!1;function io(){return u(this,null,function*(){if(ro)return ro;if(lo)return null;try{return ro=yield import("stream-monaco"),yield function(e){return u(this,null,function*(){if(oo)return;oo=!0;const n=null==globalThis?void 0:globalThis.MonacoEnvironment;return!n||"function"!=typeof n.getWorker&&"function"!=typeof n.getWorkerUrl?e.preloadMonacoWorkers():void 0})}(ro),(yield function(e){return u(this,null,function*(){const n=null==e?void 0:e.getOrCreateHighlighter;if("function"!=typeof n)return!0;try{const e=yield n(["vitesse-dark","vitesse-light"],["plaintext","text","javascript"]);return e&&"function"==typeof e.codeToTokens&&e.codeToTokens("const a = 1",{lang:"javascript",theme:"vitesse-dark"}),!0}catch(t){return console.warn("[markstream-vue] Failed to warm up Shiki tokenizer; disabling stream-monaco for this session.",t),!1}})}(ro))?ro:(ro=null,lo=!0,null)}catch(e){return lo=!0,null}})}function ao({R:e,H:n=0,B:t=50}){const o=e*(1-n)||1e-6;return Math.max(1,Math.floor(t/o))}function so(e){const n=e.length+10*(e.match(/\\/g)||[]).length;return n<10?"simple":n<40?"medium":"complex"}function uo(e){switch(e){case"simple":return 3;case"medium":return 10;case"complex":return 30}}function co(e,n){var t,o;let r=0;for(const l of e){const e=uo(so(l));e>r&&(r=e)}return ao({R:r,H:null!=(t=null==n?void 0:n.H)?t:0,B:null!=(o=null==n?void 0:n.B)?o:50})}const mo='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#8caaee" d="m 6.665625,1.0107144 c 0.54375,0.090628 0.9125,0.6062693 0.821875,1.1500367 L 7.18125,3.9983098 h 2.971875 L 10.5125,1.8326156 c 0.09063,-0.5437673 0.60625,-0.9125291 1.15,-0.8219012 0.54375,0.090628 0.9125,0.6062693 0.821875,1.1500367 L 12.18125,3.9983098 H 14 c 0.553125,0 1,0.4468892 1,1.0000319 0,0.5531426 -0.446875,1.0000319 -1,1.0000319 H 11.846875 L 11.18125,9.9985013 H 13 c 0.553125,0 1,0.4468897 1,1.0000317 0,0.553143 -0.446875,1.000032 -1,1.000032 H 10.846875 L 10.4875,14.164259 c -0.09063,0.543768 -0.60625,0.912529 -1.15,0.821902 -0.54375,-0.09063 -0.9125,-0.60627 -0.821875,-1.150037 l 0.30625,-1.834434 h -2.975 L 5.4875,14.167384 c -0.090625,0.543768 -0.60625,0.91253 -1.15,0.821902 C 3.79375,14.898658 3.425,14.383016 3.515625,13.839249 L 3.81875,11.998565 H 2 c -0.553125,0 -1,-0.446889 -1,-1.000032 C 1,10.445391 1.446875,9.9985013 2,9.9985013 H 4.153125 L 4.81875,5.9983736 H 3 c -0.553125,0 -1,-0.4468893 -1,-1.0000319 C 2,4.445199 2.446875,3.9983098 3,3.9983098 H 5.153125 L 5.5125,1.8326156 C 5.603125,1.2888483 6.11875,0.9200865 6.6625,1.0107144 Z M 6.846875,5.9983736 6.18125,9.9985013 H 9.153125 L 9.81875,5.9983736 Z" />\n</svg>\n',ho='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round">\n <path d="M2 15.5c-.7 0-1.5-.8-1.5-1.5V5c0-.7.8-1.5 1.5-1.5h9c.7 0 1.5.8 1.5 1.5v9c0 .7-.8 1.5-1.5 1.5z" />\n <path d="m1.2 3.8 3.04-2.5S5.17.5 5.7.5h8.4c.66 0 1.4.73 1.4 1.4v7.73a2.7 2.7 0 01-.7 1.75l-2.68 3.51M3 8.5l3 2-3 2m4 0h2" />\n </g>\n</svg>\n',po='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#c6d0f5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M13.5 6.5v6a2 2 0 01-2 2h-7a2 2 0 01-2-2v-9c0-1.1.9-2 2-2h4.01" />\n <path d="m8.5 1.5 5 5h-4a1 1 0 01-1-1zm-3 10h5m-5-3h5m-5-3h1" />\n </g>\n</svg>\n';let fo=null,vo=null,go=null;const yo=M(0),wo={"":po,plain:po,text:po,javascript:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#e5c890" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4.5 11c0 .828427.6715729 1.5 1.5 1.5.8284271 0 1.5-.671573 1.5-1.5V7.5M12.5 8.75C12.5 8.05964406 11.9627417 7.5 11.3 7.5L10.7 7.5C10.0372583 7.5 9.5 8.05964406 9.5 8.75 9.5 9.44035594 10.0372583 10 10.7 10L11.3 10C11.9627417 10 12.5 10.5596441 12.5 11.25 12.5 11.9403559 11.9627417 12.5 11.3 12.5L10.7 12.5C10.0372583 12.5 9.5 11.9403559 9.5 11.25" />\n <path d="m 4,1.5 h 8 c 1.385,0 2.5,1.115 2.5,2.5 v 8 c 0,1.385 -1.115,2.5 -2.5,2.5 H 4 C 2.615,14.5 1.5,13.385 1.5,12 V 4 C 1.5,2.615 2.615,1.5 4,1.5 Z" />\n </g>\n</svg>\n',typescript:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 1.5h8A2.5 2.5 0 0114.5 4v8a2.5 2.5 0 01-2.5 2.5H4A2.5 2.5 0 011.5 12V4A2.5 2.5 0 014 1.5" />\n <path d="M12.5 8.75c0-.69-.54-1.25-1.2-1.25h-.6c-.66 0-1.2.56-1.2 1.25S10.04 10 10.7 10h.6c.66 0 1.2.56 1.2 1.25s-.54 1.25-1.2 1.25h-.6c-.66 0-1.2-.56-1.2-1.25m-3-3.75v5M5 7.5h3" />\n </g>\n</svg>\n',jsx:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#99d1db" stroke-linecap="round" stroke-linejoin="round">\n <path d="M8 10.8c4.14 0 7.5-1.25 7.5-2.8S12.14 5.2 8 5.2.5 6.45.5 8s3.36 2.8 7.5 2.8" />\n <path d="M5.52 9.4c2.07 3.5 4.86 5.72 6.23 4.95 1.37-.78.8-4.24-1.27-7.75C8.41 3.1 5.62.88 4.25 1.65c-1.37.78-.8 4.24 1.27 7.75" />\n <path d="M5.52 6.6c-2.07 3.5-2.64 6.97-1.27 7.75 1.37.77 4.16-1.45 6.23-4.95s2.64-6.97 1.27-7.75C10.38.88 7.59 3.1 5.52 6.6" />\n <path d="M8.5 8a.5.5 0 01-.5.5.5.5 0 01-.5-.5.5.5 0 01.5-.5.5.5 0 01.5.5" />\n </g>\n</svg>\n',tsx:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round">\n <path d="M8 11.3c4.14 0 7.5-1.28 7.5-2.86S12.14 5.58 8 5.58.5 6.86.5 8.44s3.36 2.87 7.5 2.87Z" />\n <path d="M5.52 9.87c2.07 3.6 4.86 5.86 6.23 5.07 1.37-.8.8-4.34-1.27-7.93S5.62 1.16 4.25 1.95s-.8 4.34 1.27 7.92" />\n <path d="M5.52 7.01c-2.07 3.59-2.64 7.14-1.27 7.93s4.16-1.48 6.23-5.07c2.07-3.58 2.64-7.13 1.27-7.92-1.37-.8-4.16 1.47-6.23 5.06" />\n <path d="M8.5 8.44a.5.5 0 01-.5.5.5.5 0 01-.5-.5.5.5 0 01.5-.5.5.5 0 01.5.5" />\n </g>\n</svg>\n',html:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="#ef9f76" d="M1.5 1.5h13L13 13l-5 2-5-2z" />\n <path stroke="#c6d0f5" d="M11 4.5H5l.25 3h5.5l-.25 3-2.5 1-2.5-1-.08-1" />\n </g>\n</svg>\n',css:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#ca9ee6" stroke-linecap="round" stroke-linejoin="round">\n <path d="m4 1.5h8c1.38 0 2.5 1.12 2.5 2.5v8c0 1.38-1.12 2.5-2.5 2.5h-8c-1.38 0-2.5-1.12-2.5-2.5v-8c0-1.38 1.12-2.5 2.5-2.5z" />\n <path stroke-width=".814" d="m 10.240861,11.529149 c 0,0.58011 0.437448,1.039154 0.96002,1.035371 l 0.451635,-0.0032 c 0.522572,-0.0036 0.949379,-0.451477 0.949379,-1.032848 0,-0.581372 -0.426807,-1.065638 -0.949379,-1.065638 l -0.451635,3.4e-5 c -0.522572,3.9e-5 -0.949379,-0.4855273 -0.949379,-1.0656374 0,-0.5801104 0.426807,-1.0378931 0.949379,-1.0378931 l 0.451635,2.825e-4 c 0.522572,3.267e-4 0.951743,0.4577827 0.951743,1.0378931 M 6.8003972,11.529149 c 0,0.58011 0.4374474,1.039154 0.9600196,1.035371 l 0.46464,-0.0032 c 0.5225722,-0.0035 0.9363738,-0.451477 0.9363738,-1.031587 0,-0.580111 -0.4090724,-1.065638 -0.9316446,-1.065638 l -0.4693692,3.4e-5 c -0.5225722,3.8e-5 -0.949379,-0.4855272 -0.949379,-1.0656373 0,-0.5801104 0.4268068,-1.0378931 0.949379,-1.0378931 h 0.4516348 c 0.5225722,0 0.9635665,0.4577827 0.9635665,1.0378931 M 3.4072246,11.529149 c 0,0.58011 0.4374474,1.051765 0.9600196,1.051765 H 4.818879 c 0.5225722,0 0.949379,-0.456521 0.949379,-1.037893 m 0.01129,-2.1312747 c 0,-0.5801103 -0.4374474,-1.037893 -0.9600196,-1.037893 L 4.3678939,8.3741358 C 3.8453217,8.3744624 3.4078743,8.8420074 3.4078743,9.4233788 v 2.1186642" />\n </g>\n</svg>\n',scss:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#f4b8e4" stroke-linecap="round" stroke-linejoin="round" d="M6.75 6.38c1.85 1.07 3.35.74 4.83-.2 1.5-.95 2.7-2.78 1.3-4.15-.7-.68-3.25-.8-5.62.19-2.36.99-4.59 3.02-4.74 4.11-.31 2.19 3.15 2.88 3.64 4.23s.28 1.98-.2 2.83c-.5.85-1.96 1.62-2.8.68-.83-.95 1.67-2.75 2.98-3.25 1.3-.5 3.1-.4 3.69.25.58.64-.07 1.79-.03 1.79" />\n</svg>\n',json:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#e5c890" stroke-linecap="round" stroke-linejoin="round" d="M4.5 2.5H4c-.75 0-1.5.75-1.5 1.5v2c0 1.1-1 2-1.83 2 .83 0 1.83.9 1.83 2v2c0 .75.75 1.5 1.5 1.5h.5m7-11h.5c.75 0 1.5.75 1.5 1.5v2c0 1.1 1 2 1.83 2-.83 0-1.83.9-1.83 2v2c0 .74-.75 1.5-1.5 1.5h-.5m-6.5-3a.5.5 0 100-1 .5.5 0 000 1m3 0a.5.5 0 100-1 .5.5 0 000 1m3 0a.5.5 0 100-1 .5.5 0 000 1" />\n</svg>\n',python:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="#8caaee" d="M8.5 5.5h-3m6 0V3c0-.8-.7-1.5-1.5-1.5H7c-.8 0-1.5.7-1.5 1.5v2.5H3c-.8 0-1.5.7-1.5 1.5v2c0 .8.7 1.5 1.48 1.5" />\n <path stroke="#e5c890" d="M10.5 10.5h-3m-3 0V13c0 .8.7 1.5 1.5 1.5h3c.8 0 1.5-.7 1.5-1.5v-2.5H13c.8 0 1.5-.7 1.5-1.5V7c0-.8-.7-1.5-1.48-1.5H11.5c0 1.5 0 2-1 2h-2" />\n <path stroke="#8caaee" d="M2.98 10.5H4.5c0-1.5 0-2 1-2h2M7.5 3.5v0" />\n <path stroke="#e5c890" d="m 8.5,12.5 v 0" />\n </g>\n</svg>\n',ruby:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#e78284" stroke-linecap="round" stroke-linejoin="round" d="M1.5 9.06v2.5c.02.86.36 1.61.9 2.15 1.76 1.76 5.71.65 8.84-2.47 3.12-3.13 4.23-7.08 2.47-8.84a3.1 3.1 0 00-2.15-.9h-2.5M14.5 4l-.25 10.25L4 14.5m4.39-6.11c2.34-2.35 3.29-5.2 2.12-6.37S6.49 1.8 4.14 4.14C1.8 6.5.85 9.34 2.02 10.51s4.02.22 6.37-2.12M5.5 14.5l.25-3.75L11 11l-.25-5.25 3.75-.25" />\n</svg>\n',go:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#85c1dc" stroke-linecap="round" stroke-linejoin="round" d="m15.48 8.06-4.85.48m4.85-.48a4.98 4.98 0 01-4.54 5.42 5 5 0 112.95-8.66l-1.7 1.84a2.5 2.5 0 00-4.18 2.06c.05.57.3 1.1.69 1.51.25.27 1 .83 1.78.82.8-.02 1.58-.25 2.07-.81 0 0 .8-.96.68-1.88M2.5 8.5l-2 .01m1.5 2h1.5m-2-3.99 2-.02" />\n</svg>\n',java:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="#c6d0f5" d="M10.73 8.41c.57 3 1.59 5.83 2.77 7.09-6.63-3.45-9.76-1.75-10.5 0-.66-3.4-.54-5.74.09-7.78" />\n <path stroke="#e78284" d="M8.5 7c.63.34 1.82 1.07 2.24 1.41-.54-2.9-.64-5.96-.74-7.91-2.13.58-5.73 1.98-6.9 7.22.52-.69 1.72-1.05 2.4-1.22" />\n <path stroke="#e78284" d="M5.5 7A1.5 1.5 0 007 8.5 1.5 1.5 0 008.5 7 1.5 1.5 0 007 5.5 1.5 1.5 0 005.5 7" />\n </g>\n</svg>\n',kotlin:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="#ca9ee6" d="M2.5 13.5h11L8 8" />\n <path stroke="#ef9f76" d="M8.03 2.5h5.47l-8 8" />\n <path stroke="#e78284" d="M2.5 13.5V8" />\n <path stroke="#85c1dc" d="M8 2.5H2.5V8l3-2.5" />\n </g>\n</svg>\n',c:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round" d="m 4.0559072,12.951629 c 2.7459832,2.734744 7.1981158,2.734744 9.9441188,0 l -1.789955,-1.782586 c -1.75742,1.750224 -4.6067879,1.750224 -6.3642294,0 -1.7574416,-1.7502236 -1.7574416,-4.587893 0,-6.338097 1.7574415,-1.750224 4.6068094,-1.750224 6.3642294,0 l 0.894977,-0.8912929 0.894978,-0.891293 c -2.746003,-2.73472867 -7.1981359,-2.73472867 -9.944119,0 -2.7459858,2.7347089 -2.7459858,7.1685599 2e-7,9.9032689 z" clip-rule="evenodd" />\n</svg>\n',cpp:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round" d="m 2.5559121,12.951629 c 2.7459832,2.734744 7.1981158,2.734744 9.9441189,0 l -1.789955,-1.782586 c -1.7574201,1.750224 -4.606788,1.750224 -6.3642295,0 -1.7574416,-1.7502236 -1.7574416,-4.587893 0,-6.338097 1.7574415,-1.750224 4.6068094,-1.750224 6.3642295,0 l 0.894977,-0.8912929 0.894978,-0.891293 c -2.7460031,-2.73472867 -7.198136,-2.73472867 -9.9441191,0 -2.74598585,2.7347089 -2.74598585,7.1685599 2e-7,9.9032689 z" clip-rule="evenodd" />\n <path fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round" d="M7.5 6v4M5.513524 7.9999996H9.51304M13.486476 5.9999996v4M11.5 7.9999992h3.999516" />\n</svg>\n',cs:mo,csharp:mo,php:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#8caaee" stroke-linecap="round" stroke-linejoin="round" d="M0.5,12.5 L0.5,13.24 C0.5,14 1.27360724,14.5 2,14.5 C2.9375516,14.5 3.5,14 3.5,13.2445661 L3.5,6.00089968 C3.5,4.28551107 4.99401107,2.52263547 7.14960413,2.5 C9.49387886,2.5 11,4.0579782 11,5.5 C11.1657296,8.48962302 9.57820404,9.63684469 7.49621582,10.5 L7.49621582,14.5 L15.4979764,14.5 L15.4979764,9 C15.5394484,8.36478228 14.9387379,7.15595371 14.1308258,6.5 C13.1942239,5.80827275 12.0584852,5.50253264 11,5.5 M11.5,14.5 L11.5,11.5 M6,6.5 C6.27614237,6.5 6.5,6.27614237 6.5,6 C6.5,5.72385763 6.27614237,5.5 6,5.5 C5.72385763,5.5 5.5,5.72385763 5.5,6 C5.5,6.27614237 5.72385763,6.5 6,6.5 Z" />\n</svg>\n',shell:ho,powershell:ho,sql:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#e5c890" stroke-linecap="round" stroke-linejoin="round" d="M8 6.5c3.59 0 6.5-1.4 6.5-2.68S11.59 1.5 8 1.5 1.5 2.54 1.5 3.82 4.41 6.5 8 6.5M14.5 8c0 .83-1.24 1.79-3.25 2.2s-4.49.41-6.5 0S1.5 8.83 1.5 8m13 4.18c0 .83-1.24 1.6-3.25 2-2.01.42-4.49.42-6.5 0-2.01-.4-3.25-1.17-3.25-2m0-8.3v8.3m13-8.3v8.3" />\n</svg>\n',yaml:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#e78284" stroke-linecap="round" stroke-linejoin="round" d="M2.5 1.5h3l3 4 3-4h3l-9 13h-3L7 8z" />\n</svg>\n',markdown:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#85c1dc" stroke-linecap="round" stroke-linejoin="round" d="m9.25 8.25 2.25 2.25 2.25-2.25M3.5 11V5.5l2.04 3 1.96-3V11m4-.5V5M1.65 2.5h12.7c.59 0 1.15.49 1.15 1v9c0 .51-.56 1-1.15 1H1.65c-.59 0-1.15-.49-1.15-1V3.58c0-.5.56-1.08 1.15-1.08" />\n</svg>\n',xml:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#ef9f76" stroke-linecap="round" stroke-linejoin="round" d="M4.5 4.5 1 8 4.5 11.5M11.5 4.5 15 8 11.5 11.5M9.5 2 6.5 14" />\n</svg>\n',rust:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#ef9f76" stroke-linecap="round" stroke-linejoin="round">\n <path d="M15.5 9.5Q8 13.505.5 9.5l1-1-1-2 2-.5V4.5h2l.5-2 1.5 1 1.5-2 1.5 2 1.5-1 .5 2h2V6l2 .5-1 2z" />\n <path d="M6.5 7.5a1 1 0 01-1 1 1 1 0 01-1-1 1 1 0 011-1 1 1 0 011 1m5 0a1 1 0 01-1 1 1 1 0 01-1-1 1 1 0 011-1 1 1 0 011 1M4 11.02c-.67.37-1.5.98-1.5 2.23s1.22 1.22 2 1.25v-2M12 11c.67.37 1.5 1 1.5 2.25s-1.22 1.22-2 1.25v-2" />\n </g>\n</svg>\n',vue:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <g fill="none" stroke="#a6d189" stroke-linecap="round" stroke-linejoin="round">\n <path d="M1 1.5h5.44L8 4.56 9.56 1.5H15l-6.99 13z" />\n <path d="M12.05 1.73 8 9.28 3.95 1.73" />\n </g>\n</svg>\n',mermaid:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#ca9ee6" stroke-linecap="round" stroke-linejoin="round" d="M1.5 2.5c0 6 2.25 5.75 4 7 .83.67 1.17 2 1 4h3c-.17-2 .17-3.33 1-4 1.75-1.25 4-1 4-7C12 2.5 10 3 8 7 6 3 4 2.5 1.5 2.5" />\n</svg>\n'},ko={"":"",javascript:"javascript",js:"javascript",mjs:"javascript",cjs:"javascript",typescript:"typescript",ts:"typescript",jsx:"jsx",tsx:"tsx",golang:"go",py:"python",rb:"ruby",sh:"shell",bash:"shell",zsh:"shell",shellscript:"shell",bat:"shell",batch:"shell",ps1:"powershell",plaintext:"plain",text:"plain","c++":"cpp","c#":"csharp","objective-c":"objectivec","objective-c++":"objectivecpp",yml:"yaml",md:"markdown",rs:"rust",kt:"kotlin"};function xo(){return u(this,null,function*(){return vo||(go||(go=import("./languageIconExtended.js").then(e=>(vo=e.EXTENDED_LANGUAGE_ICON_MAP,yo.value++,vo)).catch(()=>null)),go)})}function bo(e){fo=null!=e?e:null}function _o(e){var n;const t=function(e){if(!e)return"";const n=e.trim();if(!n)return"";const[t]=n.split(/\s+/),[o]=t.split(":");return o.toLowerCase()}(e);return null!=(n=ko[t])?n:t}function Mo(e){const n=_o(e);if(!n)return"plaintext";switch(n){case"plain":return"plaintext";case"jsx":return"javascript";case"tsx":return"typescript";default:return n}}function To(){return u(this,null,function*(){yield xo()})}function Co(e){if(fo){const n=fo(e);if(null!=n&&""!==n)return n}const n=_o(e),t=wo[n];if(t)return t;return(null==vo?void 0:vo[n])||(xo(),'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">\x3c!-- Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE --\x3e<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="m10 9l-3 3l3 3m4 0l3-3l-3-3"/><rect width="18" height="18" x="3" y="3" rx="2"/></g></svg>')}const Bo={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",html:"HTML",css:"CSS",scss:"SCSS",json:"JSON",py:"Python",python:"Python",rb:"Ruby",go:"Go",java:"Java",c:"C",cpp:"C++",cs:"C#",php:"PHP",sh:"Shell",bash:"Bash",sql:"SQL",yaml:"YAML",md:"Markdown",d2:"D2",d2lang:"D2","":"Plain Text",plain:"Plain Text"},Io=new class{constructor(){d(this,"metrics",[]),d(this,"enabled",!1),d(this,"maxMetrics",1e3)}enable(){this.enabled=!0}disable(){this.enabled=!1}recordRender(e){this.enabled&&(this.metrics.push(e),this.metrics.length>this.maxMetrics&&this.metrics.shift())}getStats(){if(0===this.metrics.length)return{totalRenders:0,cacheHitRate:0,averageWorkerTime:0,averageDirectTime:0,averageCacheHitTime:0,workerSavings:0,recommendation:"Insufficient data"};const e=this.metrics.filter(e=>"worker"===e.type&&e.success),n=this.metrics.filter(e=>"direct"===e.type&&e.success),t=this.metrics.filter(e=>"cache-hit"===e.type),o=this.metrics.length,r=t.length,l=r/o*100,i=e.length>0?e.reduce((e,n)=>e+n.duration,0)/e.length:0,a=n.length>0?n.reduce((e,n)=>e+n.duration,0)/n.length:0,s=t.length>0?t.reduce((e,n)=>e+n.duration,0)/t.length:0,d=o*a-(e.reduce((e,n)=>e+n.duration,0)+n.reduce((e,n)=>e+n.duration,0)+t.reduce((e,n)=>e+n.duration,0));let u="";return u=l>70&&i<2*a?"✅ Worker + Cache is highly beneficial":l>50?"✅ Worker + Cache is beneficial":i>3*a?"⚠️ Worker overhead too high, consider direct rendering":a<5?"⚠️ Formulas too simple, Worker overhead may not be worth it":"✅ Worker prevents main thread blocking",{totalRenders:o,cacheHits:r,cacheHitRate:l.toFixed(1),workerCalls:e.length,directCalls:n.length,averageWorkerTime:i.toFixed(2),averageDirectTime:a.toFixed(2),averageCacheHitTime:s.toFixed(3),workerSavings:d.toFixed(2),recommendation:u}}printReport(){const e=this.getStats();return console.group("📊 KaTeX Rendering Performance Report"),e.totalRenders,e.cacheHits,e.cacheHitRate,e.workerCalls,e.directCalls,e.averageWorkerTime,e.averageDirectTime,e.averageCacheHitTime,e.workerSavings,e.recommendation,console.groupEnd(),e}reset(){this.metrics=[]}exportMetrics(){return{metrics:[...this.metrics],stats:this.getStats(),timestamp:Date.now()}}};function $o(){Io.enable()}function So(){Io.disable()}function Eo(){return Io.printReport()}function Lo(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch(n){}return globalThis.setTimeout(e,0)}function jo(e){try{if(null==e)return;if("undefined"!=typeof globalThis&&"function"==typeof globalThis.cancelAnimationFrame)return void globalThis.cancelAnimationFrame(e)}catch(n){}try{globalThis.clearTimeout(e)}catch(n){}}"undefined"!=typeof window&&(window.__katexPerfReport=Eo,window.__katexPerfMonitor=Io);const No={key:0,class:"code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:{color:"var(--vscode-editor-foreground)","background-color":"var(--vscode-editor-background)"}},Ho={class:"flex items-center gap-x-2"},Po=["innerHTML"],Do={class:"text-sm font-medium font-mono"},Ro={class:"flex items-center gap-x-2"},Oo=["aria-pressed"],Ko=["disabled"],zo=["disabled"],Ao=["disabled"],Wo=["aria-label"],Fo={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},Vo={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},Uo=["aria-pressed"],Xo={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24"},qo={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24"},Go=["aria-label"],Yo=["innerHTML"],Zo={class:"code-loading-placeholder"},Jo=/* @__PURE__ */le(/* @__PURE__ */p({__name:"MarkdownCodeBlockNode",props:{node:{},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isDark:{type:Boolean,default:!1},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean}},emits:["previewCode","copy"],setup(e,{emit:n}){const t=e,o=n,{t:r}=cn(),l=B(_o(t.node.language)),i=B(!1),a=B(!1),s=B(!1),d=B(null),c=B(null),m=B(""),h=B(!1);let p;const g=B(!0),y=B(0),b=B(14),M=B(b.value),T=C(()=>{const e=b.value,n=M.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),L=C(()=>{const e=l.value.trim().toLowerCase();return Bo[e]||e.charAt(0).toUpperCase()+e.slice(1)}),j=C(()=>(yo.value,Co(l.value.trim().toLowerCase().split(":")[0]))),N=C(()=>{const e=l.value.trim().toLowerCase();return t.isShowPreview&&("html"===e||"svg"===e)}),H=C(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},o=n(t.minWidth),r=n(t.maxWidth);return o&&(e.minWidth=o),r&&(e.maxWidth=r),e}),P=C(()=>({fontSize:`${M.value}px`})),K=C(()=>!1!==t.showTooltips);function z(){return t.isDark?t.darkTheme:t.lightTheme}function A(e){if(null==p||p.disconnect(),p=void 0,!e)return m.value="",void(h.value=!1);var n;m.value=`<pre class="shiki shiki-fallback"><code>${n=e,n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}</code></pre>`,h.value=!1}function W(){m.value="",h.value=!0}function F(){var e;const n=c.value;return!!n&&(n.childNodes.length>0||Boolean(null==(e=n.textContent)?void 0:e.trim().length))}function V(){return u(this,null,function*(){if(yield G(),F())return void W();const e=c.value;e&&(null==p||p.disconnect(),p=new MutationObserver(()=>{F()&&(W(),null==p||p.disconnect(),p=void 0)}),p.observe(e,{childList:!0,subtree:!0}))})}let U,X,q,J;const Q=/* @__PURE__ */new Set,ee=/* @__PURE__ */new Set,ne=void 0!==import.meta&&Boolean(!1);function te(e,n){return u(this,null,function*(){if(!U)return;const t=function(e,n=!1){var t;const[o]=String(null!=e?e:"").split(":"),r=null!=(t=null==o?void 0:o.trim().toLowerCase())?t:"";return r?!J||J.has(r)?r:(n&&ne&&!Q.has(r)&&(Q.add(r),console.warn(`[MarkdownCodeBlockNode] Language "${r}" not preloaded in stream-markdown; falling back to plaintext.`)),"plaintext"):"plaintext"}(n,Boolean(e&&e.length));try{yield U.updateCode(e,t)}catch(o){"plaintext"!==t?(ne&&!ee.has(t)&&(ee.add(t),console.warn(`[MarkdownCodeBlockNode] Failed to render language "${t}", retrying as plaintext.`,o)),yield U.updateCode(e,"plaintext")):ne&&console.warn("[MarkdownCodeBlockNode] Failed to render code block even as plaintext.",o)}})}function oe(){return u(this,null,function*(){yield function(){return u(this,null,function*(){if(!X)try{const e=yield import("stream-markdown");X=e.createShikiStreamRenderer,q=e.registerHighlight;const n=Array.isArray(e.defaultLanguages)?e.defaultLanguages:void 0;J=n?new Set(n.map(e=>e.toLowerCase())):void 0,null==q||q({themes:t.themes})}catch(e){console.warn("[MarkdownCodeBlockNode] stream-markdown not available:",e)}})}(),d.value&&c.value?(null==q||q({themes:t.themes}),!U&&X&&(U=X(c.value,{theme:z()}),h.value=!0),U?!1===t.stream&&t.loading?A(t.node.code):(A(t.node.code),yield te(t.node.code,l.value),yield V()):A(t.node.code)):A(t.node.code)})}function re(){const e=d.value;if(!e||a.value)return;const n=e.scrollTop;n<y.value?g.value=!1:function(e,n=50){return e.scrollHeight-e.scrollTop-e.clientHeight<=n}(e)&&(g.value=!0),y.value=n}function le(){return u(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(t.node.code)),i.value=!0,o("copy",t.node.code),setTimeout(()=>{i.value=!1},1e3)}catch(e){console.error("Copy failed:",e)}})}function ie(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}function ae(e,n,o="top"){if(!K.value)return;const r=ie(e);if(!r)return;const l=e;an(r,n,o,!1,null!=(null==l?void 0:l.clientX)&&null!=(null==l?void 0:l.clientY)?{x:l.clientX,y:l.clientY}:void 0,t.isDark)}function se(){K.value&&sn()}function de(e){if(!K.value)return;const n=ie(e);if(!n)return;const o=e;an(n,i.value?r("common.copied")||"Copied":r("common.copy")||"Copy","top",!1,null!=(null==o?void 0:o.clientX)&&null!=(null==o?void 0:o.clientY)?{x:o.clientX,y:o.clientY}:void 0,t.isDark)}function ue(){a.value=!a.value;const e=d.value;e&&(a.value?(e.style.maxHeight="none",e.style["overflow-y"]="visible",e.style["overflow-x"]="auto"):(e.style.maxHeight="500px",e.style.overflow="auto",g.value=!0,G(()=>{e.scrollHeight>e.clientHeight&&(e.scrollTop=e.scrollHeight)})))}function ce(){s.value=!s.value}function me(){if(!N.value)return;const e=(l.value||t.node.language).toLowerCase(),n="html"===e?"HTML Preview":"SVG Preview";o("previewCode",{type:"html"===e?"text/html":"image/svg+xml",content:t.node.code,title:n})}return oe(),$(()=>{oe()}),S(()=>{null==p||p.disconnect(),p=void 0}),I(()=>t.themes,()=>u(null,null,function*(){q&&q({themes:t.themes})})),I(()=>t.loading,e=>{e||oe()}),I(K,e=>{e||sn()}),I(()=>[t.node.code,t.node.language],e=>u(null,[e],function*([e,n]){const o=_o(n);o!==l.value&&(l.value=o),d.value&&c.value?(U||(A(e),yield oe()),U&&e&&(!1===t.stream&&t.loading||(A(e),yield te(e,n),yield V()))):A(e)})),I(()=>[t.darkTheme,t.lightTheme],()=>u(null,null,function*(){d.value&&c.value&&(U||(yield oe()),null==U||U.setTheme(z()))})),I(()=>t.node.code,()=>u(null,null,function*(){if(a.value||!g.value)return;yield G();const e=d.value;e&&e.scrollHeight>e.clientHeight&&(e.scrollTop=e.scrollHeight)})),(n,o)=>(f(),v("div",{style:D(H.value),class:E(["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",[t.isDark?"border-gray-700/30 bg-gray-900":"border-gray-200 bg-white",t.isDark?"is-dark":""]])},[t.showHeader?(f(),v("div",No,[R(n.$slots,"header-left",{},()=>[k("div",Ho,[k("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:j.value},null,8,Po),k("span",Do,_(L.value),1)])],!0),R(n.$slots,"header-right",{},()=>[k("div",Ro,[t.showCollapseButton?(f(),v("button",{key:0,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":s.value,onClick:ce,onMouseenter:o[0]||(o[0]=e=>ae(e,s.value?w(r)("common.expand")||"Expand":w(r)("common.collapse")||"Collapse")),onFocus:o[1]||(o[1]=e=>ae(e,s.value?w(r)("common.expand")||"Expand":w(r)("common.collapse")||"Collapse")),onMouseleave:se,onBlur:se},[(f(),v("svg",{style:D({rotate:s.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[...o[17]||(o[17]=[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,Oo)):O("",!0),t.showFontSizeButtons&&t.enableFontSizeControl?(f(),v(x,{key:1},[k("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!!Number.isFinite(M.value)&&M.value<=10,onClick:o[2]||(o[2]=e=>function(){const e=Math.max(10,M.value-1);M.value=e}()),onMouseenter:o[3]||(o[3]=e=>ae(e,w(r)("common.decrease")||"Decrease")),onFocus:o[4]||(o[4]=e=>ae(e,w(r)("common.decrease")||"Decrease")),onMouseleave:se,onBlur:se},[...o[18]||(o[18]=[k("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)])],40,Ko),k("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!T.value||M.value===b.value,onClick:o[5]||(o[5]=e=>{M.value=b.value}),onMouseenter:o[6]||(o[6]=e=>ae(e,w(r)("common.reset")||"Reset")),onFocus:o[7]||(o[7]=e=>ae(e,w(r)("common.reset")||"Reset")),onMouseleave:se,onBlur:se},[...o[19]||(o[19]=[k("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[k("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[k("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),k("path",{d:"M3 3v5h5"})])],-1)])],40,zo),k("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!!Number.isFinite(M.value)&&M.value>=36,onClick:o[8]||(o[8]=e=>function(){const e=Math.min(36,M.value+1);M.value=e}()),onMouseenter:o[9]||(o[9]=e=>ae(e,w(r)("common.increase")||"Increase")),onFocus:o[10]||(o[10]=e=>ae(e,w(r)("common.increase")||"Increase")),onMouseleave:se,onBlur:se},[...o[20]||(o[20]=[k("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)])],40,Ao)],64)):O("",!0),t.showCopyButton?(f(),v("button",{key:2,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":i.value?w(r)("common.copied")||"Copied":w(r)("common.copy")||"Copy",onClick:le,onMouseenter:o[11]||(o[11]=e=>de(e)),onFocus:o[12]||(o[12]=e=>de(e)),onMouseleave:se,onBlur:se},[i.value?(f(),v("svg",Vo,[...o[22]||(o[22]=[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(f(),v("svg",Fo,[...o[21]||(o[21]=[k("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[k("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),k("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,Wo)):O("",!0),t.showExpandButton?(f(),v("button",{key:3,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":a.value,onClick:ue,onMouseenter:o[13]||(o[13]=e=>ae(e,a.value?w(r)("common.collapse")||"Collapse":w(r)("common.expand")||"Expand")),onFocus:o[14]||(o[14]=e=>ae(e,a.value?w(r)("common.collapse")||"Collapse":w(r)("common.expand")||"Expand")),onMouseleave:se,onBlur:se},[a.value?(f(),v("svg",Xo,[...o[23]||(o[23]=[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])])):(f(),v("svg",qo,[...o[24]||(o[24]=[k("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])]))],40,Uo)):O("",!0),N.value&&t.showPreviewButton?(f(),v("button",{key:4,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":w(r)("common.preview")||"Preview",onClick:me,onMouseenter:o[15]||(o[15]=e=>ae(e,w(r)("common.preview")||"Preview")),onFocus:o[16]||(o[16]=e=>ae(e,w(r)("common.preview")||"Preview")),onMouseleave:se,onBlur:se},[...o[25]||(o[25]=[k("svg",{"data-v-3d59cc65":"",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[k("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[k("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),k("circle",{cx:"12",cy:"12",r:"3"})])],-1)])],40,Go)):O("",!0)])],!0)])):O("",!0),Y(k("div",{ref_key:"codeBlockContent",ref:d,class:"code-block-content",style:D(P.value),onScroll:re},[k("div",{ref_key:"rendererTarget",ref:c,class:"code-block-render"},null,512),h.value?O("",!0):(f(),v("div",{key:0,class:"code-fallback-plain",innerHTML:m.value},null,8,Yo))],36),[[Z,!(s.value||!e.stream&&e.loading)]]),Y(k("div",Zo,[R(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[o[26]||(o[26]=k("div",{class:"loading-skeleton"},[k("div",{class:"skeleton-line"}),k("div",{class:"skeleton-line"}),k("div",{class:"skeleton-line short"})],-1))],!0)],512),[[Z,!e.stream&&e.loading]])],6))}}),[["__scopeId","data-v-3397f01a"]]);Jo.install=e=>{e.component(Jo.__name,Jo)};const Qo=()=>import("mermaid");let er=null,nr=Qo;function tr(e){nr=e,er=null}function or(e){tr(null!=e?e:Qo)}function rr(){tr(null)}function lr(){return"function"==typeof nr}function ir(e){if(!e)return e;const n=e&&e.default?e.default:e;if(n&&("function"==typeof n.render||"function"==typeof n.parse||"function"==typeof n.initialize))return n;if(n&&n.mermaidAPI&&("function"==typeof n.mermaidAPI.render||"function"==typeof n.mermaidAPI.parse)){const e=n.mermaidAPI;return s(a({},n),{render:e.render.bind(e),parse:e.parse?e.parse.bind(e):void 0,initialize:t=>"function"==typeof n.initialize?n.initialize(t):e.initialize?e.initialize(t):void 0})}return e.mermaid&&"function"==typeof e.mermaid.render?e.mermaid:n}function ar(e){if(e)try{const n=null==e?void 0:e.initialize;e.initialize=t=>{const o=a({suppressErrorRendering:!0},t||{});return"function"==typeof n?n.call(e,o):(null==e?void 0:e.mermaidAPI)&&"function"==typeof e.mermaidAPI.initialize?e.mermaidAPI.initialize(o):void 0}}catch(n){}}function sr(){return u(this,null,function*(){if(er)return er;const e=function(){try{const e=globalThis;return ir(null==e?void 0:e.mermaid)}catch(e){return null}}();if(e)return er=e,ar(er),er;const n=nr;if(!n)return null;let t;try{t=yield n()}catch(o){if(n===Qo)throw new Error('Optional dependency "mermaid" is not installed. Please install it to enable mermaid diagrams.');throw o}return t?(er=ir(t),ar(er),er):null})}const dr={class:"markstream-vue"},ur=["id"],cr=/* @__PURE__ */le(/* @__PURE__ */p({__name:"Tooltip",props:{visible:{type:Boolean},anchorEl:{},content:{},placement:{},offset:{},originX:{},originY:{},id:{},isDark:{type:[Boolean,null]}},setup(e){const n=e,t=C(()=>{if(void 0!==n.isDark&&null!==n.isDark)return Boolean(n.isDark);if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0;if((null==window?void 0:window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)return!0}catch(e){}return!1}),o=B(null),r=B({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),l=B(!1);let i=null;function a(){return u(this,null,function*(){var e,t;if(!n.anchorEl||!o.value)return;const l=[ee(null!=(e=n.offset)?e:8),ne(),te({padding:8})],{x:i,y:a}=yield oe(n.anchorEl,o.value,{placement:null!=(t=n.placement)?t:"top",middleware:l,strategy:"fixed"});r.value.transform=`translate3d(${Math.round(i)}px, ${Math.round(a)}px, 0)`,r.value.left="0px",r.value.top="0px"})}return I(()=>n.visible,e=>u(null,null,function*(){if(e)if(l.value=!1,yield G(),n.anchorEl&&o.value)try{const e=n.anchorEl.getBoundingClientRect();yield a();const t=r.value.transform;if(null!=n.originX&&null!=n.originY){const o=Math.abs(Number(n.originX)-e.left),i=Math.abs(Number(n.originY)-e.top);Math.hypot(o,i)>120?(r.value.transform=`translate3d(${Math.round(n.originX)}px, ${Math.round(n.originY)}px, 0)`,yield G(),l.value=!0,yield G(),r.value.transform=t):l.value=!0}else l.value=!0;i=Q(n.anchorEl,o.value,a)}catch(t){yield a(),l.value=!0,i=Q(n.anchorEl,o.value,a)}else l.value=!0;else l.value=!1,i&&(i(),i=null)})),I([()=>n.anchorEl,()=>n.placement,()=>n.content],()=>u(null,null,function*(){n.visible&&n.anchorEl&&o.value&&(yield G(),yield a())})),S(()=>{i&&i()}),(i,a)=>(f(),A(J,{to:"body"},[k("div",dr,[y(H,{name:"tooltip",appear:""},{default:P(()=>[Y(k("div",{id:n.id,ref_key:"tooltip",ref:o,style:D({position:"fixed",left:r.value.left,top:r.value.top,transform:r.value.transform}),class:E(["z-[9999] inline-block text-base py-2 px-3 rounded-md shadow-md whitespace-nowrap pointer-events-none tooltip-element border",[t.value?"bg-gray-900 text-white border-gray-700 border is-dark":"bg-white text-gray-900 border-gray-200 border"]]),role:"tooltip"},_(e.content),15,ur),[[Z,e.visible&&l.value]])]),_:1})])]))}}),[["__scopeId","data-v-d524cc01"]]),mr=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:cr},Symbol.toStringTag,{value:"Module"}));function hr(e){return JSON.stringify(e)}function pr(e){var n;const t=null!=(n=e.mode)?n:"classic",o=e.katexUrl,r=e.mhchemUrl,l=hr(a({throwOnError:!0,displayMode:!0,output:"html",strict:"ignore"},e.renderOptions||{})),i=hr(o),s=r?hr(r):'""';return"module"===t?`\nlet DEBUG = false\nlet katex = null\nlet katexLoadError = null\nlet loadPromise = null\n\nfunction normalizeKaTeX(mod) {\n const resolved = (mod && mod.default) ? mod.default : mod\n if (resolved && typeof resolved.renderToString === 'function')\n return resolved\n return null\n}\n\nasync function loadKaTeX() {\n if (katex || katexLoadError)\n return\n if (!loadPromise) {\n loadPromise = (async () => {\n try {\n const mod = await import(${i})\n katex = normalizeKaTeX(mod) || null\n const mhchemUrl = ${s}\n if (mhchemUrl) {\n try {\n await import(mhchemUrl)\n }\n catch (e) {\n // ignore optional mhchem load failures\n if (DEBUG)\n console.warn('[katex-cdn-worker] failed to load mhchem', e)\n }\n }\n }\n catch (e) {\n katexLoadError = e\n }\n })()\n }\n await loadPromise\n}\n\nglobalThis.addEventListener('message', async (ev) => {\n const data = ev.data || {}\n if (data.type === 'init') {\n DEBUG = !!data.debug\n if (DEBUG)\n console.debug('[katex-cdn-worker] debug enabled')\n return\n }\n const id = data.id ?? ''\n const content = data.content ?? ''\n const displayMode = data.displayMode ?? true\n\n await loadKaTeX()\n\n if (!katex) {\n const reason = katexLoadError ? String(katexLoadError?.message || katexLoadError) : 'KaTeX is not available in worker'\n globalThis.postMessage({ id, error: reason, content, displayMode })\n return\n }\n\n try {\n const opts = ${l}\n const html = katex.renderToString(content, { ...opts, displayMode: !!displayMode })\n globalThis.postMessage({ id, html, content, displayMode })\n }\n catch (err) {\n const msg = String(err?.message || err)\n globalThis.postMessage({ id, error: msg, content, displayMode })\n }\n})\n`.trimStart():`\nlet DEBUG = false\nlet katex = null\nlet katexLoadError = null\n\nfunction normalizeKaTeX(val) {\n const resolved = (val && val.default) ? val.default : val\n if (resolved && typeof resolved.renderToString === 'function')\n return resolved\n return null\n}\n\nfunction loadKaTeXClassic() {\n if (katex || katexLoadError)\n return\n try {\n importScripts(${i})\n const mhchemUrl = ${s}\n if (mhchemUrl) {\n try {\n importScripts(mhchemUrl)\n }\n catch (e) {\n // ignore optional mhchem load failures\n if (DEBUG)\n console.warn('[katex-cdn-worker] failed to load mhchem', e)\n }\n }\n katex = normalizeKaTeX(globalThis.katex)\n }\n catch (e) {\n katexLoadError = e\n }\n}\n\nloadKaTeXClassic()\n\nglobalThis.addEventListener('message', (ev) => {\n const data = ev.data || {}\n if (data.type === 'init') {\n DEBUG = !!data.debug\n if (DEBUG)\n console.debug('[katex-cdn-worker] debug enabled')\n return\n }\n const id = data.id ?? ''\n const content = data.content ?? ''\n const displayMode = data.displayMode ?? true\n\n if (!katex && !katexLoadError)\n loadKaTeXClassic()\n\n if (!katex) {\n const reason = katexLoadError ? String(katexLoadError?.message || katexLoadError) : 'KaTeX is not available in worker'\n globalThis.postMessage({ id, error: reason, content, displayMode })\n return\n }\n\n try {\n const opts = ${l}\n const html = katex.renderToString(content, { ...opts, displayMode: !!displayMode })\n globalThis.postMessage({ id, html, content, displayMode })\n }\n catch (err) {\n const msg = String(err?.message || err)\n globalThis.postMessage({ id, error: msg, content, displayMode })\n }\n})\n`.trimStart()}function fr(e){var n,t;const o=pr(e);if("undefined"==typeof Worker||"undefined"==typeof URL||"undefined"==typeof Blob)return{worker:null,dispose:()=>{},source:o};const r=new Blob([o],{type:"text/javascript"}),l=URL.createObjectURL(r);let i=!1;const d="module"===(null!=(n=e.mode)?n:"classic")?s(a({},null!=(t=e.workerOptions)?t:{}),{type:"module"}):e.workerOptions,u=new Worker(l,d);if(e.debug)try{u.postMessage({type:"init",debug:!0})}catch(c){}return{worker:u,dispose:()=>{if(!i){i=!0;try{URL.revokeObjectURL(l)}catch(c){}}},source:o}}cr.install=e=>{e.component(cr.__name,cr)};let vr=null,gr=null,yr=!1;const wr=/* @__PURE__ */new Map,kr=/* @__PURE__ */new Map;let xr=5;const br=/* @__PURE__ */new Set;function _r(){if(wr.size<xr&&br.size){const n=Array.from(br);br.clear();for(const t of n)try{t()}catch(e){}}}function Mr(e){vr=e,gr=null,vr.onmessage=e=>{const{id:n,html:t,error:o}=e.data,r=wr.get(n);if(r)if(wr.delete(n),clearTimeout(r.timeoutId),_r(),o)r.reject(new Error(o));else{const{content:n,displayMode:o}=e.data;if(n){const e=`${o?"d":"i"}:${n}`;if(kr.set(e,t),kr.size>200){const e=kr.keys().next().value;kr.delete(e)}}r.resolve(t)}},vr.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[n,t]of wr.entries())clearTimeout(t.timeoutId),t.reject(new Error(`Worker error: ${e.message}`));wr.clear(),_r()}}function Tr(){var e;vr&&(null==(e=vr.terminate)||e.call(vr)),vr=null,gr=null}function Cr(e){yr=!!e,vr&&vr.postMessage({type:"init",debug:yr})}function Br(e,n=!0,t=2e3,o){return u(this,null,function*(){if(performance.now(),!Ln()){const e=new Error("KaTeX rendering disabled");return e.name="KaTeXDisabled",e.code="KATEX_DISABLED",Promise.reject(e)}if(gr)return Promise.reject(gr);const r=`${n?"d":"i"}:${e}`,l=kr.get(r);if(l)return Promise.resolve(l);const i=vr||(gr=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),gr.name="WorkerInitError",gr.code="WORKER_INIT_ERROR",null);if(!i)return Promise.reject(gr);if(wr.size>=xr){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code="WORKER_BUSY",e.busy=!0,e.inFlight=wr.size,e.max=xr,Promise.reject(e)}return new Promise((r,l)=>{if(null==o?void 0:o.aborted){const e=new Error("Aborted");return e.name="AbortError",void l(e)}const a=Math.random().toString(36).slice(2),s=globalThis.setTimeout(()=>{wr.delete(a);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",l(e),_r()},t);o&&o.addEventListener("abort",()=>{globalThis.clearTimeout(s),wr.has(a)&&wr.delete(a);const e=new Error("Aborted");e.name="AbortError",l(e),_r()},{once:!0});const d=r,u=l;wr.set(a,{resolve:e=>{d(e)},reject:e=>{u(e)},timeoutId:s}),i.postMessage({id:a,content:e,displayMode:n})})})}function Ir(e,n=!0,t){const o=`${n?"d":"i"}:${e}`;if(kr.set(o,t),kr.size>200){const e=kr.keys().next().value;kr.delete(e)}}function $r(){return{inFlight:wr.size,max:xr}}function Sr(e){Number.isFinite(e)&&e>0&&(xr=Math.floor(e))}const Er="WORKER_BUSY";function Lr(){return wr.size>=xr}function jr(e=2e3,n){return wr.size<xr?Promise.resolve():new Promise((t,o)=>{let r,l=!1;const i=()=>{l||(l=!0,r&&globalThis.clearTimeout(r),br.delete(i),t())};if(br.add(i),r=globalThis.setTimeout(()=>{if(l)return;l=!0,br.delete(i);const e=new Error("Wait for worker slot timed out");e.name="WorkerBusyTimeout",e.code="WORKER_BUSY_TIMEOUT",o(e)},e),queueMicrotask(()=>_r()),n){const e=()=>{if(l)return;l=!0,r&&globalThis.clearTimeout(r),br.delete(i);const e=new Error("Aborted");e.name="AbortError",o(e)};n.aborted?e():n.addEventListener("abort",e,{once:!0})}})}const Nr={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function Hr(e){null!=e.timeout&&(Nr.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(Nr.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(Nr.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(Nr.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function Pr(){return a({},Nr)}function Dr(e){return u(this,arguments,function*(e,n=!0,t={}){var o,r,l,i;if(!Ln()){const e=new Error("KaTeX rendering disabled");throw e.name="KaTeXDisabled",e.code="KATEX_DISABLED",e}const a=null!=(o=t.timeout)?o:Nr.timeout,s=null!=(r=t.waitTimeout)?r:Nr.waitTimeout,d=null!=(l=t.backoffMs)?l:Nr.backoffMs,u=null!=(i=t.maxRetries)?i:Nr.maxRetries,c=Number.isFinite(u)?Math.max(0,Math.min(Math.floor(u),8)):Nr.maxRetries,m=t.signal;let h=0;for(;;){if(null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}try{return yield Br(e,n,a,m)}catch(p){if((null==p?void 0:p.code)!==Er||h>=c)throw p;if(h++,yield jr(s,m).catch(()=>{}),null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}d>0&&(yield new Promise(e=>globalThis.setTimeout(e,d*h)))}}})}function Rr(e){return JSON.stringify(e)}function Or(e){var n;const t=null!=(n=e.mode)?n:"module",o=Rr(e.mermaidUrl),r=`\nlet DEBUG = false\nlet mermaid = null\nlet mermaidLoadError = null\n\nfunction normalizeMermaidModule(mod) {\n if (!mod)\n return mod\n const candidate = (mod && mod.default) ? mod.default : mod\n if (candidate && (typeof candidate.render === 'function' || typeof candidate.parse === 'function' || typeof candidate.initialize === 'function'))\n return candidate\n if (candidate && candidate.mermaidAPI && (typeof candidate.mermaidAPI.render === 'function' || typeof candidate.mermaidAPI.parse === 'function')) {\n const api = candidate.mermaidAPI\n return {\n ...candidate,\n render: api.render ? api.render.bind(api) : undefined,\n parse: api.parse ? api.parse.bind(api) : undefined,\n initialize: (opts) => {\n if (typeof candidate.initialize === 'function')\n return candidate.initialize(opts)\n return api.initialize ? api.initialize(opts) : undefined\n },\n }\n }\n if (mod && mod.mermaid && typeof mod.mermaid.parse === 'function')\n return mod.mermaid\n return candidate\n}\n\nfunction applyThemeTo(code, theme) {\n const themeValue = theme === 'dark' ? 'dark' : 'default'\n const themeConfig = \`%%{init: {"theme": "\${themeValue}"}}%%\\n\`\n const trimmed = (code || '').trimStart()\n if (trimmed.startsWith('%%{'))\n return code\n return themeConfig + code\n}\n\nfunction findHeaderIndex(lines) {\n const headerRe = /^(?:graph|flowchart|flowchart\\s+tb|flowchart\\s+lr|sequenceDiagram|gantt|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|pie|quadrantChart|timeline|xychart(?:-beta)?)\\b/\n for (let i = 0; i < lines.length; i++) {\n const l = (lines[i] || '').trim()\n if (!l)\n continue\n if (l.startsWith('%%'))\n continue\n if (headerRe.test(l))\n return i\n }\n return -1\n}\n\nasync function canParse(code, theme) {\n const themed = applyThemeTo(code, theme)\n const anyMermaid = mermaid\n if (anyMermaid && typeof anyMermaid.parse === 'function') {\n await anyMermaid.parse(themed)\n return true\n }\n throw new Error('mermaid.parse not available in worker')\n}\n\nasync function findLastRenderablePrefix(baseCode, theme) {\n const lines = String(baseCode || '').split('\\n')\n const headerIdx = findHeaderIndex(lines)\n if (headerIdx === -1)\n return null\n const head = lines.slice(0, headerIdx + 1)\n await canParse(head.join('\\n'), theme)\n\n let low = headerIdx + 1\n let high = lines.length\n let lastGood = headerIdx + 1\n let tries = 0\n const MAX_TRIES = 12\n\n while (low <= high && tries < MAX_TRIES) {\n const mid = Math.floor((low + high) / 2)\n const candidate = [...head, ...lines.slice(headerIdx + 1, mid)].join('\\n')\n tries++\n try {\n await canParse(candidate, theme)\n lastGood = mid\n low = mid + 1\n }\n catch {\n high = mid - 1\n }\n }\n\n return [...head, ...lines.slice(headerIdx + 1, lastGood)].join('\\n')\n}\n\nfunction initMermaidOnce() {\n if (!mermaid)\n return\n try {\n if (typeof mermaid.initialize === 'function')\n mermaid.initialize(${Rr(a({startOnLoad:!1,securityLevel:"loose"},e.initializeOptions||{}))})\n }\n catch (e) {\n if (DEBUG)\n console.warn('[mermaid-cdn-worker] initialize failed', e)\n }\n}\n\nglobalThis.addEventListener('message', async (ev) => {\n const msg = ev.data || {}\n if (msg.type === 'init') {\n DEBUG = !!msg.debug\n if (DEBUG)\n console.debug('[mermaid-cdn-worker] debug enabled')\n return\n }\n\n const id = msg.id\n const action = msg.action\n const payload = msg.payload || {}\n\n if (!mermaid) {\n const errMsg = mermaidLoadError ? String(mermaidLoadError?.message || mermaidLoadError) : 'Mermaid is not available in worker'\n globalThis.postMessage({ id, ok: false, error: errMsg })\n return\n }\n\n try {\n if (action === 'canParse') {\n const ok = await canParse(payload.code, payload.theme)\n globalThis.postMessage({ id, ok: true, result: ok })\n return\n }\n if (action === 'findPrefix') {\n const res = await findLastRenderablePrefix(payload.code, payload.theme)\n globalThis.postMessage({ id, ok: true, result: res })\n return\n }\n globalThis.postMessage({ id, ok: false, error: 'Unknown action' })\n }\n catch (e) {\n globalThis.postMessage({ id, ok: false, error: String(e?.message || e) })\n }\n})\n`.trimStart();return"module"===t?`\n${r}\n\nlet loadPromise = null\nasync function loadMermaid() {\n if (mermaid || mermaidLoadError)\n return\n if (!loadPromise) {\n loadPromise = (async () => {\n try {\n const mod = await import(${o})\n mermaid = normalizeMermaidModule(mod) || null\n initMermaidOnce()\n }\n catch (e) {\n mermaidLoadError = e\n }\n })()\n }\n await loadPromise\n}\n\n// Load immediately; failures are reported per-request\nawait loadMermaid()\n`.trimStart():`\n${r}\n\nfunction loadMermaidClassic() {\n if (mermaid || mermaidLoadError)\n return\n try {\n importScripts(${o})\n mermaid = normalizeMermaidModule(globalThis.mermaid) || null\n initMermaidOnce()\n }\n catch (e) {\n mermaidLoadError = e\n }\n}\n\nloadMermaidClassic()\n`.trimStart()}function Kr(e){var n,t;const o=Or(e);if("undefined"==typeof Worker||"undefined"==typeof URL||"undefined"==typeof Blob)return{worker:null,dispose:()=>{},source:o};const r=new Blob([o],{type:"text/javascript"}),l=URL.createObjectURL(r);let i=!1;const d="module"===(null!=(n=e.mode)?n:"module")?s(a({},null!=(t=e.workerOptions)?t:{}),{type:"module"}):e.workerOptions,u=new Worker(l,d);if(e.debug)try{u.postMessage({type:"init",debug:!0})}catch(c){}return{worker:u,dispose:()=>{if(!i){i=!0;try{URL.revokeObjectURL(l)}catch(c){}}},source:o}}let zr=null,Ar=null;const Wr=/* @__PURE__ */new Map;let Fr=5,Vr=!1;function Ur(e){Vr=!!e}function Xr(e){Number.isFinite(e)&&e>0&&(Fr=Math.floor(e))}function qr(){return{inFlight:Wr.size,max:Fr}}const Gr="WORKER_BUSY",Yr="MERMAID_DISABLED";function Zr(e){zr=e,Ar=null;const n=e;zr.onmessage=e=>{if(zr!==n)return;const{id:t,ok:o,result:r,error:l}=e.data,i=Wr.get(t);i&&(!1===o||l?i.reject(new Error(l||"Unknown error")):i.resolve(r))},zr.onerror=e=>{var t,o;if(zr===n)if(0!==Wr.size){try{Vr?console.error("[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e):null==(o=console.debug)||o.call(console,"[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e)}catch(r){}for(const[n,t]of Wr.entries())t.reject(new Error(`Worker error: ${e.message}`));Wr.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},zr.onmessageerror=e=>{var t,o;if(zr===n)if(0!==Wr.size){try{Vr?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(o=console.debug)||o.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch(r){}for(const[e,n]of Wr.entries())n.reject(new Error("Worker messageerror"));Wr.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function Jr(){var e;if(zr)try{for(const[e,n]of Wr.entries())n.reject(new Error("Worker cleared"));Wr.clear(),null==(e=zr.terminate)||e.call(zr)}catch(n){}zr=null,Ar=null}function Qr(e,n,t=1400){if(!lr()){const e=new Error("Mermaid rendering disabled");return e.name="MermaidDisabled",e.code=Yr,Promise.reject(e)}if(Ar)return Promise.reject(Ar);const o=zr||(Ar=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Ar.name="WorkerInitError",Ar.code="WORKER_INIT_ERROR",null);if(!o)return Promise.reject(Ar);if(Wr.size>=Fr){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Gr,e.inFlight=Wr.size,e.max=Fr,Promise.reject(e)}return new Promise((r,l)=>{const i=Math.random().toString(36).slice(2);let a,s=!1;const d=()=>{s||(s=!0,null!=a&&globalThis.clearTimeout(a),Wr.delete(i))},u={resolve:e=>{d(),r(e)},reject:e=>{d(),l(e)}};Wr.set(i,u);try{o.postMessage({id:i,action:e,payload:n})}catch(c){return Wr.delete(i),void l(c)}a=globalThis.setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const n=Wr.get(i);n&&n.reject(e)},t)})}function el(e,n,t=1400){return u(this,null,function*(){try{return yield Qr("canParse",{code:e,theme:n},t)}catch(o){return Promise.reject(o)}})}function nl(e,n,t=1400){return u(this,null,function*(){try{return yield Qr("findPrefix",{code:e,theme:n},t)}catch(o){return Promise.reject(o)}})}function tl(){if(zr)try{for(const[e,n]of Wr.entries())n.reject(new Error("Worker terminated"));Wr.clear(),zr.terminate()}finally{zr=null}}const ol=z(()=>import("./index4.js")),rl=z(()=>import("./index3.js")),ll=z(()=>import("./index2.js")),il=z(()=>import("./index5.js")),al=z(()=>import("./index6.js")),sl=z(()=>import("./index7.js")),dl={AdmonitionNode:qt,BlockquoteNode:ie,CheckboxNode:de,CodeBlockNode:ol,DefinitionListNode:he,EmojiNode:fe,EmphasisNode:st,FootnoteNode:ht,FootnoteReferenceNode:Ce,FootnoteAnchorNode:ut,HardBreakNode:ft,HeadingNode:gt,HtmlBlockNode:bt,HtmlInlineNode:Fe,HighlightNode:it,ImageNode:bn,D2BlockNode:sl,InfographicBlockNode:al,InlineCodeNode:Ue,PreCodeNode:Bt,InsertNode:rt,LinkNode:tt,ListItemNode:yt,ListNode:wt,MathBlockNode:rl,MathInlineNode:ll,MermaidBlockNode:il,ParagraphNode:Mt,StrikethroughNode:Yn,StrongNode:qn,SubscriptNode:Un,SuperscriptNode:Wn,TableNode:jt,TextNode:Dn,ThematicBreakNode:Ht,VmrContainerNode:Rt,ReferenceNode:Kn,MarkdownCodeBlockNode:Jo},ul={install(e,n){Object.entries(dl).forEach(([n,t])=>{e.component(n,t)}),(null==n?void 0:n.getLanguageIcon)&&bo(n.getLanguageIcon),(null==n?void 0:n.mathOptions)&&h(n.mathOptions)}};export{Mt as $,qt as A,ie as B,de as C,sl as D,fe as E,ut as F,gt as G,ft as H,it as I,bt as J,Fe as K,bn as L,al as M,Ue as N,rt as O,tt as P,yt as Q,wt as R,Yr as S,Gr as T,Jo as U,zt as V,Er as W,rl as X,ll as Y,il as Z,le as _,pn as a,Kn as a0,Yn as a1,qn as a2,Un as a3,Wn as a4,jt as a5,Dn as a6,Ht as a7,cr as a8,Rt as a9,lr as aA,Io as aB,To as aC,co as aD,ao as aE,be as aF,Br as aG,ke as aH,Jt as aI,un as aJ,Hr as aK,Mr as aL,Cr as aM,Sr as aN,$n as aO,bo as aP,tr as aQ,Zr as aR,Ur as aS,Xr as aT,jr as aU,ul as aa,pr as ab,Or as ac,_e as ad,Tr as ae,Jr as af,fr as ag,Kr as ah,uo as ai,eo as aj,En as ak,rr as al,So as am,Qt as an,Sn as ao,or as ap,$o as aq,so as ar,xe as as,Pr as at,$r as au,qr as av,Eo as aw,no as ax,Lr as ay,Ln as az,yo as b,Co as c,Bt as d,an as e,jo as f,io as g,sn as h,Dr as i,jn as j,Ir as k,Bo as l,sr as m,_o as n,el as o,nl as p,to as q,Mo as r,Lo as s,tl as t,cn as u,ol as v,he as w,st as x,ht as y,Ce as z};