markstream-vue
Version:
Vue 3 Markdown renderer optimized for large docs: progressive Mermaid, streaming diff code blocks, and fast real-time preview.
4 lines • 149 kB
JavaScript
"use strict";var so=Object.create;var hn=Object.defineProperty,co=Object.defineProperties,uo=Object.getOwnPropertyDescriptor,mo=Object.getOwnPropertyDescriptors,fo=Object.getOwnPropertyNames,En=Object.getOwnPropertySymbols,ho=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable;var Nn=(t,o,n)=>o in t?hn(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,Z=(t,o)=>{for(var n in o||(o={}))Tn.call(o,n)&&Nn(t,n,o[n]);if(En)for(var n of En(o))po.call(o,n)&&Nn(t,n,o[n]);return t},qe=(t,o)=>co(t,mo(o));var vo=(t,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of fo(o))!Tn.call(t,r)&&r!==n&&hn(t,r,{get:()=>o[r],enumerable:!(s=uo(o,r))||s.enumerable});return t};var gt=(t,o,n)=>(n=t!=null?so(ho(t)):{},vo(o||!t||!t.__esModule?hn(n,"default",{value:t,enumerable:!0}):n,t));var V=(t,o,n)=>new Promise((s,r)=>{var l=m=>{try{v(n.next(m))}catch(d){r(d)}},i=m=>{try{v(n.throw(m))}catch(d){r(d)}},v=m=>m.done?s(m.value):Promise.resolve(m.value).then(l,i);v((n=n.apply(t,o)).next())});const vn=require("stream-markdown-parser"),e=require("vue"),kt=require("@floating-ui/dom"),go=["cite"],ko=e.defineComponent({__name:"BlockquoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean}},emits:["copy"],setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("blockquote",{class:"blockquote",dir:"auto",cite:t.node.cite},[e.withMemo([t.node.children],()=>e.createVNode(e.unref(Ee),{"index-key":`blockquote-${t.indexKey}`,nodes:t.node.children||[],typewriter:t.typewriter,onCopy:n[0]||(n[0]=s=>o.$emit("copy",s))},null,8,["index-key","nodes","typewriter"]),n,1)],8,go))}}),R=(t,o)=>{const n=t.__vccOpts||t;for(const[s,r]of o)n[s]=r;return n},wt=R(ko,[["__scopeId","data-v-adfdba00"]]);wt.install=t=>{t.component(wt.__name,wt)};const wo={class:"checkbox-node"},yo=["checked"],xo=e.defineComponent({__name:"CheckboxNode",props:{node:{}},setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("span",wo,[e.createElementVNode("input",{type:"checkbox",checked:t.node.checked,disabled:"",class:"checkbox-input"},null,8,yo)]))}}),Le=R(xo,[["__scopeId","data-v-8dc6c46f"]]);Le.install=t=>{t.component(Le.__name,Le)};const bo={class:"definition-list"},Bo={class:"definition-term"},Mo={class:"definition-desc"},Co=e.defineComponent({__name:"DefinitionListNode",props:{node:{},indexKey:{},typewriter:{type:Boolean}},emits:["copy"],setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("dl",bo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.items,(s,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:r},[e.createElementVNode("dt",Bo,[e.createVNode(e.unref(Ee),{"index-key":`definition-term-${t.indexKey}-${r}`,nodes:s.term,typewriter:t.typewriter,onCopy:n[0]||(n[0]=l=>o.$emit("copy",l))},null,8,["index-key","nodes","typewriter"])]),e.createElementVNode("dd",Mo,[e.createVNode(e.unref(Ee),{"index-key":`definition-desc-${t.indexKey}-${r}`,nodes:s.definition,typewriter:t.typewriter,onCopy:n[1]||(n[1]=l=>o.$emit("copy",l))},null,8,["index-key","nodes","typewriter"])])],64))),128))]))}}),yt=R(Co,[["__scopeId","data-v-5a21f288"]]);yt.install=t=>{t.component(yt.__name,yt)};const Eo={class:"emoji-node"},No=e.defineComponent({__name:"EmojiNode",props:{node:{}},setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("span",Eo,e.toDisplayString(t.node.name),1))}}),se=R(No,[["__scopeId","data-v-de55dc97"]]);se.install=t=>{t.component(se.__name,se)};const At="__global__",it={};function To(t,o){typeof t=="string"?it[t]=o||{}:it[At]=t||{}}function Ne(t){return t?it[t]||it[At]||{}:it[At]||{}}function $o(t){if(t===At)throw new Error("removeCustomComponents: use clearGlobalCustomComponents() to clear the global mapping");delete it[t]}function So(){delete it[At]}const Vo=["id"],Io=["title"],_o=e.defineComponent({__name:"FootnoteReferenceNode",props:{node:{}},setup(t){const n=`#footnote-${t.node.id}`;function s(){if(typeof document=="undefined")return;const r=document.querySelector(n);r?r.scrollIntoView({behavior:"smooth"}):console.warn(`Element with href: ${n} not found`)}return(r,l)=>(e.openBlock(),e.createElementBlock("sup",{id:`fnref-${t.node.id}`,class:"footnote-reference",onClick:s},[e.createElementVNode("span",{href:n,title:`查看脚注 ${t.node.id}`,class:"footnote-link cursor-pointer"},"["+e.toDisplayString(t.node.id)+"]",9,Io)],8,Vo))}}),ce=R(_o,[["__scopeId","data-v-01af0fee"]]);ce.install=t=>{t.component(ce.__name,ce)};const Lo={class:"inline text-[85%] px-1 py-0.5 rounded font-mono bg-secondary whitespace-normal break-words max-w-full before:content-[''] after:content-['']"},de=e.defineComponent({__name:"InlineCodeNode",props:{node:{}},setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("code",Lo,e.toDisplayString(t.node.code),1))}});de.install=t=>{t.component(de.__name,de)};const Do=["id"],zo=e.defineComponent({__name:"Tooltip",props:{visible:{type:Boolean},anchorEl:{},content:{},placement:{},offset:{},originX:{},originY:{},id:{},isDark:{type:[Boolean,null]}},setup(t){const o=t,n=e.computed(()=>{if(o.isDark!==void 0&&o.isDark!==null)return!!o.isDark;if(typeof document!="undefined")try{if(document.documentElement.classList.contains("dark")||window!=null&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches)return!0}catch(m){}return!1}),s=e.ref(null),r=e.ref({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),l=e.ref(!1);let i=null;function v(){return V(this,null,function*(){var h,b;if(!o.anchorEl||!s.value)return;const m=[kt.offset((h=o.offset)!=null?h:8),kt.flip(),kt.shift({padding:8})],{x:d,y:g}=yield kt.computePosition(o.anchorEl,s.value,{placement:(b=o.placement)!=null?b:"top",middleware:m,strategy:"fixed"});r.value.transform=`translate3d(${Math.round(d)}px, ${Math.round(g)}px, 0)`,r.value.left="0px",r.value.top="0px"})}return e.watch(()=>o.visible,m=>V(null,null,function*(){if(m)if(l.value=!1,yield e.nextTick(),o.anchorEl&&s.value)try{const d=o.anchorEl.getBoundingClientRect();yield v();const g=r.value.transform;if(o.originX!=null&&o.originY!=null){const h=Math.abs(Number(o.originX)-d.left),b=Math.abs(Number(o.originY)-d.top);Math.hypot(h,b)>120?(r.value.transform=`translate3d(${Math.round(o.originX)}px, ${Math.round(o.originY)}px, 0)`,yield e.nextTick(),l.value=!0,yield e.nextTick(),r.value.transform=g):l.value=!0}else l.value=!0;i=kt.autoUpdate(o.anchorEl,s.value,v)}catch(d){yield v(),l.value=!0,i=kt.autoUpdate(o.anchorEl,s.value,v)}else l.value=!0;else l.value=!1,i&&(i(),i=null)})),e.watch([()=>o.anchorEl,()=>o.placement,()=>o.content],()=>V(null,null,function*(){o.visible&&o.anchorEl&&s.value&&(yield e.nextTick(),yield v())})),e.onBeforeUnmount(()=>{i&&i()}),(m,d)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"tooltip",appear:""},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{id:o.id,ref_key:"tooltip",ref:s,style:e.normalizeStyle({position:"fixed",left:r.value.left,top:r.value.top,transform:r.value.transform}),class:e.normalizeClass(["z-[9999] inline-block text-base py-2 px-3 rounded-md shadow-md whitespace-nowrap pointer-events-none tooltip-element border",[n.value?"bg-gray-900 text-white border-gray-700 border is-dark":"bg-white text-gray-900 border-gray-200 border"]]),role:"tooltip"},e.toDisplayString(t.content),15,Do),[[e.vShow,t.visible&&l.value]])]),_:1})]))}}),Ro=R(zo,[["__scopeId","data-v-993f63aa"]]),xn=e.ref(!1),jn=e.ref(""),Pn=e.ref("top"),jt=e.ref(null),Wt=e.ref(null),bn=e.ref(null),Bn=e.ref(null),An=e.ref(null);let Qt=null,en=null;function Wn(){Qt&&(clearTimeout(Qt),Qt=null),en&&(clearTimeout(en),en=null)}let $n=!1;function Ho(){if($n||typeof document=="undefined")return;$n=!0;const t=document.createElement("div");t.setAttribute("data-singleton-tooltip","1"),document.body.appendChild(t);const o={setup(){return()=>{var n;return e.h(Ro,{visible:xn.value,"anchor-el":jt.value,content:jn.value,placement:Pn.value,id:Wt.value,originX:bn.value,originY:Bn.value,isDark:(n=An.value)!=null?n:void 0})}}};e.createApp(o).mount(t)}function Tt(t,o,n="top",s=!1,r,l){if(!t)return;Ho(),Wn();const i=()=>{var v,m;Wt.value=`tooltip-${Date.now()}-${Math.floor(Math.random()*1e3)}`,jt.value=t,jn.value=o,Pn.value=n,bn.value=(v=r==null?void 0:r.x)!=null?v:null,Bn.value=(m=r==null?void 0:r.y)!=null?m:null,An.value=typeof l=="boolean"?l:null,xn.value=!0;try{t.setAttribute("aria-describedby",Wt.value)}catch(d){}};s?i():Qt=setTimeout(i,80)}function nn(t=!1){Wn();const o=()=>{if(jt.value&&Wt.value)try{jt.value.removeAttribute("aria-describedby")}catch(n){}xn.value=!1,jt.value=null,Wt.value=null,bn.value=null,Bn.value=null};t?o():en=setTimeout(o,120)}function jo(t){return(t.split(".").pop()||t).replace(/[_-]/g," ").replace(/([A-Z])/g," $1").replace(/\s+/g," ").replace(/\b\w/g,n=>n.toUpperCase()).trim()}const Kn={"common.copy":"Copy","common.copySuccess":"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 Po(t){Object.assign(Kn,t)}function on(){try{const o=globalThis.$vueI18nUse||null;if(o&&typeof o=="function")try{const n=o();if(n&&typeof n.t=="function")return{t:n.t.bind(n)}}catch(n){}}catch(o){}const t=o=>{var n;return(n=Kn[o])!=null?n:jo(o)};return V(null,null,function*(){try{const o=yield import("vue-i18n"),n=o.useI18n||o.default&&o.default.useI18n;if(n&&typeof n=="function")try{const s=n();if(s&&typeof s.t=="function")try{globalThis.$vueI18nUse=()=>s}catch(r){}}catch(s){}}catch(o){}}),{t}}const Fn=Symbol("ViewportPriority");function Ao(t,o){const n=typeof window!="undefined"&&typeof document!="undefined",s=typeof o=="boolean"?e.ref(o):o;let r=null;const l=new WeakMap;function i(){var d;if(r||!n)return r;if(typeof IntersectionObserver=="undefined")return null;const m=(d=t())!=null?d:null;return r=new IntersectionObserver(g=>{for(const h of g){const b=l.get(h.target);if(!b)continue;if(h.isIntersecting||h.intersectionRatio>0){if(!b.visible.value){b.visible.value=!0;try{b.resolve()}catch(H){}}r==null||r.unobserve(h.target),l.delete(h.target)}}},{root:m,rootMargin:"300px",threshold:0}),r}const v=(m,d)=>{const g=e.ref(!1);let h=!1,b;const M=new Promise(z=>{b=()=>{h||(h=!0,z())}}),H=()=>{try{r==null||r.unobserve(m)}catch(z){}l.delete(m)};if(!n||!s.value)return g.value=!0,b(),{isVisible:g,whenVisible:M,destroy:H};const _=i();return _?(l.set(m,{resolve:b,visible:g}),_.observe(m),{isVisible:g,whenVisible:M,destroy:H}):(g.value=!0,b(),{isVisible:g,whenVisible:M,destroy:H})};return e.provide(Fn,v),v}function rn(){const t=e.inject(Fn,void 0);if(t)return t;const o=new WeakMap;let n=null;const s=()=>n||(typeof window=="undefined"||typeof IntersectionObserver=="undefined"?null:(n=new IntersectionObserver(l=>{for(const i of l){const v=o.get(i.target);if(!v)continue;if(i.isIntersecting||i.intersectionRatio>0){if(!v.visible.value){v.visible.value=!0;try{v.resolve()}catch(d){}}n==null||n.unobserve(i.target),o.delete(i.target)}}},{root:null,rootMargin:"300px",threshold:0}),n));return l=>{const i=e.ref(!1);let v=!1,m;const d=new Promise(b=>{m=()=>{v||(v=!0,b())}}),g=()=>{try{n==null||n.unobserve(l)}catch(b){}o.delete(l)},h=s();return h?(o.set(l,{resolve:m,visible:i}),h.observe(l),{isVisible:i,whenVisible:d,destroy:g}):(i.value=!0,m(),{isVisible:i,whenVisible:d,destroy:g})}}const Wo={class:"relative inline-block"},Ko=["src","alt","title","loading","tabindex","aria-label"],Fo={class:"text-sm whitespace-nowrap"},Oo={key:1,class:"text-sm text-gray-500"},Xo={key:"error",class:"px-4 py-2 bg-gray-100 flex items-center justify-center rounded-lg gap-2 text-red-500"},Yo={class:"text-sm whitespace-nowrap"},qo={key:0,class:"mt-2 text-sm text-gray-500 italic"},Uo=e.defineComponent({__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(t,{emit:o}){const n=t,s=o,r=e.ref(!1),l=e.ref(!1),i=e.ref(!1),v=e.ref(null),m=rn(),d=e.ref(null),g=e.ref(typeof window=="undefined");typeof window!="undefined"&&e.watch(()=>v.value,T=>{var D;if((D=d.value)==null||D.destroy(),d.value=null,!T){g.value=!1;return}const ae=m(T,{rootMargin:"400px"});d.value=ae,g.value=ae.isVisible.value,ae.whenVisible.then(()=>{g.value=!0})},{immediate:!0}),e.onBeforeUnmount(()=>{var T;(T=d.value)==null||T.destroy(),d.value=null});const h=e.computed(()=>l.value&&n.fallbackSrc?n.fallbackSrc:n.node.src),b=e.computed(()=>!n.lazy||g.value),M=e.computed(()=>/\.svg(?:\?|$)/i.test(h.value));function H(){n.fallbackSrc&&!i.value?(i.value=!0,l.value=!0):(l.value=!0,s("error",n.node.src))}function _(){r.value=!0,l.value=!1,s("load",h.value)}function z(T){T.preventDefault(),!(!r.value||l.value)&&s("click",[T,h.value])}const{t:$}=on();return e.watch(h,()=>{r.value=!1,l.value=!1}),(T,ae)=>(e.openBlock(),e.createElementBlock("figure",{ref_key:"figureRef",ref:v,class:"text-center my-8"},[e.createElementVNode("div",Wo,[e.createVNode(e.Transition,{name:"img-switch",mode:"out-in"},{default:e.withCtx(()=>{var D,W,E,G,X;return[!t.node.loading&&!l.value&&b.value?(e.openBlock(),e.createElementBlock("img",{key:"image",src:h.value,alt:String((W=(D=n.node.alt)!=null?D:n.node.title)!=null?W:""),title:String((G=(E=n.node.title)!=null?E:n.node.alt)!=null?G:""),class:e.normalizeClass(["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:e.normalizeStyle(M.value?{minHeight:n.svgMinHeight,width:"100%",height:"auto",objectFit:"contain"}:void 0),loading:n.lazy?"lazy":"eager",decoding:"async",tabindex:r.value?0:-1,"aria-label":(X=n.node.alt)!=null?X:e.unref($)("image.preview"),onError:H,onLoad:_,onClick:z},null,46,Ko)):l.value?!t.node.loading&&!n.fallbackSrc?(e.openBlock(),e.createElementBlock("div",Xo,[e.renderSlot(T.$slots,"error",{node:n.node,displaySrc:h.value,imageLoaded:r.value,hasError:l.value,fallbackSrc:n.fallbackSrc,lazy:n.lazy,isSvg:M.value},()=>[ae[1]||(ae[1]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24"},[e.createElementVNode("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)),e.createElementVNode("span",Yo,e.toDisplayString(e.unref($)("image.loadError")),1)],!0)])):e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:"placeholder",class:"placeholder-layer max-w-96 inline-flex items-center justify-center gap-2",style:e.normalizeStyle(M.value?{minHeight:n.svgMinHeight,width:"100%"}:{minHeight:"6rem"})},[n.usePlaceholder?e.renderSlot(T.$slots,"placeholder",{key:0,node:n.node,displaySrc:h.value,imageLoaded:r.value,hasError:l.value,fallbackSrc:n.fallbackSrc,lazy:n.lazy,isSvg:M.value},()=>[ae[0]||(ae[0]=e.createElementVNode("div",{class:"w-4 h-4 rounded-full border-2 border-solid border-current border-t-transparent animate-spin","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Fo,e.toDisplayString(e.unref($)("image.loading")),1)],!0):(e.openBlock(),e.createElementBlock("span",Oo,e.toDisplayString(t.node.raw),1))],4))]}),_:3})]),n.showCaption&&n.node.alt?(e.openBlock(),e.createElementBlock("figcaption",qo,e.toDisplayString(n.node.alt),1)):e.createCommentVNode("",!0)],512))}}),Xe=R(Uo,[["__scopeId","data-v-7ca79b66"]]);Xe.install=t=>{t.component(Xe.__name,Xe)};let Jt=null,Sn=!1;function an(){return V(this,null,function*(){if(Jt)return Jt;if(Sn)return null;try{return Jt=yield import("katex"),yield import("katex/contrib/mhchem"),Jt}catch(t){return Sn=!0,null}})}const pn=e.shallowRef(!1);let Vn=null;function On(){return Vn||(Vn=an().then(t=>{pn.value=!!t}).catch(()=>{pn.value=!1})),e.readonly(pn)}const Zo=e.defineComponent({__name:"TextNode",props:{node:{}},emits:["copy"],setup(t){const o=On();return(n,s)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass([[e.unref(o)&&t.node.center?"text-node-center":""],"whitespace-pre-wrap break-words text-node"])},e.toDisplayString(t.node.content),3))}}),te=R(Zo,[["__scopeId","data-v-56f30838"]]);te.install=t=>{t.component(te.__name,te)};const He=e.defineAsyncComponent(()=>V(null,null,function*(){var o,n;if(typeof globalThis!="undefined"&&typeof globalThis.process!="undefined"&&((n=(o=globalThis.process)==null?void 0:o.env)==null?void 0:n.NODE_ENV)==="test")return s=>{var r,l;return e.h(te,qe(Z({},s),{node:qe(Z({},s.node),{content:(l=s.node.raw)!=null?l:`$${(r=s.node.content)!=null?r:""}$`})}))};try{if(yield an())return(yield Promise.resolve().then(()=>require("./index-CoB_G9GJ.cjs"))).default}catch(s){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".',s)}return s=>{var r,l;return e.h(te,qe(Z({},s),{node:qe(Z({},s.node),{content:(l=s.node.raw)!=null?l:`$${(r=s.node.content)!=null?r:""}$`})}))}})),Go=e.defineAsyncComponent(()=>V(null,null,function*(){try{if(yield an())return(yield Promise.resolve().then(()=>require("./index-DbbC_URx.cjs"))).default}catch(t){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".',t)}return t=>{var o,n;return e.h(te,qe(Z({},t),{node:qe(Z({},t.node),{content:(n=t.node.raw)!=null?n:`$$${(o=t.node.content)!=null?o:""}$$`})}))}})),ue=e.defineComponent({__name:"ReferenceNode",props:{node:{},messageId:{},threadId:{}},emits:["click","mouseEnter","mouseLeave"],setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("span",{class:"reference-node cursor-pointer bg-accent text-xs rounded-md px-1.5 mx-0.5 hover:bg-secondary",role:"button",tabindex:"0",onClick:n[0]||(n[0]=s=>o.$emit("click",s,t.node.id,t.messageId,t.threadId)),onMouseenter:n[1]||(n[1]=s=>o.$emit("mouseEnter",s,t.node.id,t.messageId,t.threadId)),onMouseleave:n[2]||(n[2]=s=>o.$emit("mouseLeave",s,t.node.id,t.messageId,t.threadId))},e.toDisplayString(t.node.id),33))}});ue.install=t=>{t.component(ue.__name,ue)};const Jo={class:"superscript-node"},Qo={key:1},er=e.defineComponent({__name:"SuperscriptNode",props:{node:{},customId:{},indexKey:{}},setup(t){const o=t,n=Z({text:te,inline_code:de,link:he,strong:me,emphasis:Te,footnote_reference:ce,strikethrough:fe,highlight:Be,insert:be,subscript:xe,emoji:se,math_inline:He,reference:ue},Ne(o.customId));return(s,r)=>(e.openBlock(),e.createElementBlock("sup",Jo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(l,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${t.indexKey||"superscript"}-${i}`},[n[l.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.type]),{key:0,node:l,"custom-id":o.customId,"index-key":`${t.indexKey||"superscript"}-${i}`},null,8,["node","custom-id","index-key"])):(e.openBlock(),e.createElementBlock("span",Qo,e.toDisplayString(l.content||l.raw),1))],64))),128))]))}}),ye=R(er,[["__scopeId","data-v-0ca396bb"]]);ye.install=t=>{t.component(ye.__name,ye)};const tr={class:"subscript-node"},nr={key:1},or=e.defineComponent({__name:"SubscriptNode",props:{node:{},customId:{},indexKey:{}},setup(t){const o=t,n=Z({text:te,inline_code:de,link:he,strong:me,emphasis:Te,footnote_reference:ce,strikethrough:fe,highlight:Be,insert:be,superscript:ye,emoji:se,math_inline:He,reference:ue},Ne(o.customId));return(s,r)=>(e.openBlock(),e.createElementBlock("sub",tr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(l,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${t.indexKey||"subscript"}-${i}`},[n[l.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.type]),{key:0,node:l,"custom-id":o.customId,"index-key":`${t.indexKey||"subscript"}-${i}`},null,8,["node","custom-id","index-key"])):(e.openBlock(),e.createElementBlock("span",nr,e.toDisplayString(l.content||l.raw),1))],64))),128))]))}}),xe=R(or,[["__scopeId","data-v-5e1f04df"]]);xe.install=t=>{t.component(xe.__name,xe)};const rr={class:"strong-node"},ar=e.defineComponent({__name:"StrongNode",props:{node:{},customId:{},indexKey:{}},setup(t){const o=t,n=Z({text:te,inline_code:de,link:he,emphasis:Te,strikethrough:fe,highlight:Be,insert:be,subscript:xe,superscript:ye,emoji:se,footnote_reference:ce,math_inline:He,reference:ue},Ne(o.customId));return(s,r)=>(e.openBlock(),e.createElementBlock("strong",rr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(l,i)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.type]),{key:`${t.indexKey||"strong"}-${i}`,"index-key":`${t.indexKey||"strong"}-${i}`,node:l,"custom-id":o.customId},null,8,["index-key","node","custom-id"]))),128))]))}}),me=R(ar,[["__scopeId","data-v-53b6c7df"]]);me.install=t=>{t.component(me.__name,me)};const lr={class:"strikethrough-node"},ir=e.defineComponent({__name:"StrikethroughNode",props:{node:{},customId:{},indexKey:{}},setup(t){const o=t,n=Z({text:te,inline_code:de,link:he,strong:me,emphasis:Te,highlight:Be,insert:be,subscript:xe,superscript:ye,emoji:se,footnote_reference:ce,math_inline:He,reference:ue},Ne(o.customId));return(s,r)=>(e.openBlock(),e.createElementBlock("del",lr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(l,i)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.type]),{key:`${t.indexKey||"strikethrough"}-${i}`,node:l,"custom-id":o.customId,"index-key":`${t.indexKey||"strikethrough"}-${i}`},null,8,["node","custom-id","index-key"]))),128))]))}}),fe=R(ir,[["__scopeId","data-v-3716d25c"]]);fe.install=t=>{t.component(fe.__name,fe)};const sr=["href","title","aria-label","aria-hidden"],cr=["aria-hidden"],dr={class:"link-text-wrapper relative inline-flex"},ur={class:"leading-[normal] link-text"},mr={class:"leading-[normal] link-text"},fr=e.defineComponent({__name:"LinkNode",props:{node:{},indexKey:{},customId:{},showTooltip:{type:Boolean,default:!0},color:{},underlineHeight:{},underlineBottom:{},animationDuration:{},animationOpacity:{},animationTiming:{},animationIteration:{}},setup(t){const o=t,n=e.computed(()=>{var d,g,h,b,M,H;const m=o.underlineBottom!==void 0?typeof o.underlineBottom=="number"?`${o.underlineBottom}px`:String(o.underlineBottom):"-3px";return{"--link-color":(d=o.color)!=null?d:"#0366d6","--underline-height":`${(g=o.underlineHeight)!=null?g:2}px`,"--underline-bottom":m,"--underline-opacity":String((h=o.animationOpacity)!=null?h:.9),"--underline-duration":`${(b=o.animationDuration)!=null?b:.8}s`,"--underline-timing":(M=o.animationTiming)!=null?M:"linear","--underline-iteration":typeof o.animationIteration=="number"?String(o.animationIteration):(H=o.animationIteration)!=null?H:"infinite"}}),s={text:te,strong:me,strikethrough:fe,emphasis:Te,image:Xe},r=e.useAttrs();function l(m){var b,M,H,_,z,$;if(!o.showTooltip)return;const d=m,g=(d==null?void 0:d.clientX)!=null&&(d==null?void 0:d.clientY)!=null?{x:d.clientX,y:d.clientY}:void 0,h=($=(z=(H=(b=o.node)==null?void 0:b.href)!=null?H:(M=o.node)==null?void 0:M.title)!=null?z:(_=o.node)==null?void 0:_.text)!=null?$:"";Tt(m.currentTarget,h,"top",!1,g)}function i(){o.showTooltip&&nn()}const v=e.computed(()=>{var m,d;return String((d=(m=o.node.title)!=null?m:o.node.href)!=null?d:"")});return(m,d)=>t.node.loading?(e.openBlock(),e.createElementBlock("span",e.mergeProps({key:1,class:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":t.node.loading?"false":"true"},e.unref(r),{style:n.value}),[e.createElementVNode("span",dr,[e.createElementVNode("span",ur,[e.createElementVNode("span",mr,e.toDisplayString(t.node.text),1)]),d[1]||(d[1]=e.createElementVNode("span",{class:"underline-anim","aria-hidden":"true"},null,-1))])],16,cr)):(e.openBlock(),e.createElementBlock("a",e.mergeProps({key:0,class:"link-node",href:t.node.href,title:v.value,"aria-label":`Link: ${v.value}`,"aria-hidden":t.node.loading?"true":"false",target:"_blank",rel:"noopener noreferrer"},e.unref(r),{style:n.value,onMouseenter:d[0]||(d[0]=g=>l(g)),onMouseleave:i}),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(g,h)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s[g.type]),{key:`${t.indexKey||"emphasis"}-${h}`,node:g,"custom-id":o.customId,"index-key":`${t.indexKey||"link-text"}-${h}`},null,8,["node","custom-id","index-key"]))),128))],16,sr))}}),he=R(fr,[["__scopeId","data-v-0ea92a03"]]);he.install=t=>{t.component(he.__name,he)};const hr={class:"insert-node"},pr=e.defineComponent({__name:"InsertNode",props:{node:{},customId:{},indexKey:{}},setup(t){const o=t,n=Z({text:te,inline_code:de,link:he,strong:me,emphasis:Te,strikethrough:fe,highlight:Be,subscript:xe,superscript:ye,emoji:se,footnote_reference:ce,math_inline:He,reference:ue},Ne(o.customId));return(s,r)=>(e.openBlock(),e.createElementBlock("ins",hr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(l,i)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.type]),{key:`${t.indexKey||"insert"}-${i}`,node:l,"custom-id":o.customId,"index-key":`${t.indexKey||"insert"}-${i}`},null,8,["node","custom-id","index-key"]))),128))]))}}),be=R(pr,[["__scopeId","data-v-b8737de3"]]);be.install=t=>{t.component(be.__name,be)};const vr={class:"highlight-node"},gr=e.defineComponent({__name:"HighlightNode",props:{node:{},customId:{},indexKey:{}},setup(t){const o=t,n=Z({text:te,inline_code:de,link:he,strong:me,emphasis:Te,strikethrough:fe,insert:be,subscript:xe,superscript:ye,emoji:se,footnote_reference:ce,math_inline:He,reference:ue},Ne(o.customId));return(s,r)=>(e.openBlock(),e.createElementBlock("mark",vr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(l,i)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.type]),{key:`${t.indexKey||"highlight"}-${i}`,node:l,"custom-id":o.customId,"index-key":`${t.indexKey||"highlight"}-${i}`},null,8,["node","custom-id","index-key"]))),128))]))}}),Be=R(gr,[["__scopeId","data-v-fc52b444"]]);Be.install=t=>{t.component(Be.__name,Be)};const kr={class:"emphasis-node"},wr=e.defineComponent({__name:"EmphasisNode",props:{node:{},customId:{},indexKey:{}},setup(t){const o=t,n=Z({text:te,inline_code:de,link:he,strong:me,strikethrough:fe,highlight:Be,insert:be,subscript:xe,superscript:ye,emoji:se,footnote_reference:ce,math_inline:He,reference:ue},Ne(o.customId));return(s,r)=>(e.openBlock(),e.createElementBlock("em",kr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(l,i)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.type]),{key:`${t.indexKey||"emphasis"}-${i}`,node:l,"custom-id":o.customId,"index-key":`${t.indexKey||"emphasis"}-${i}`},null,8,["node","custom-id","index-key"]))),128))]))}}),Te=R(wr,[["__scopeId","data-v-c25e2822"]]);Te.install=t=>{t.component(Te.__name,Te)};const yr=["href","title"],xr=e.defineComponent({__name:"FootnoteAnchorNode",props:{node:{}},setup(t){const o=t;function n(s){var i;if(s.preventDefault(),typeof document=="undefined")return;const r=`fnref-${String((i=o.node.id)!=null?i:"")}`,l=document.getElementById(r);l&&l.scrollIntoView({behavior:"smooth"})}return(s,r)=>(e.openBlock(),e.createElementBlock("a",{class:"footnote-anchor text-sm text-[#0366d6] hover:underline cursor-pointer",href:`#fnref-${t.node.id}`,title:`返回引用 ${t.node.id}`,onClick:n}," ↩︎ ",8,yr))}}),st=R(xr,[["__scopeId","data-v-4756ce0d"]]);st.install=t=>{t.component(st.__name,st)};const br=["id"],Br={class:"flex-1"},xt=e.defineComponent({__name:"FootnoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean}},emits:["copy"],setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("div",{id:`fnref--${t.node.id}`,class:"flex mt-2 mb-2 text-sm leading-relaxed border-t border-[#eaecef] pt-2"},[e.createElementVNode("div",Br,[e.withMemo([t.node.children],()=>e.createVNode(e.unref(Ee),{"index-key":`footnote-${t.indexKey}`,nodes:t.node.children,typewriter:t.typewriter,onCopy:n[0]||(n[0]=s=>o.$emit("copy",s))},null,8,["index-key","nodes","typewriter"]),n,1)])],8,br))}});xt.install=t=>{t.component(xt.__name,xt)};const Mr={class:"hard-break"},Cr=e.defineComponent({__name:"HardBreakNode",props:{node:{}},setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("br",Mr))}}),Ue=R(Cr,[["__scopeId","data-v-50c58f70"]]);Ue.install=t=>{t.component(Ue.__name,Ue)};const Er=e.defineComponent({__name:"HeadingNode",props:{node:{},customId:{},indexKey:{}},setup(t){const o=t,n=Z({text:te,inline_code:de,link:he,image:Xe,strong:me,emphasis:Te,strikethrough:fe,highlight:Be,insert:be,subscript:xe,superscript:ye,emoji:se,checkbox:Le,checkbox_input:Le,footnote_reference:ce,hardbreak:Ue,math_inline:He,reference:ue},Ne(o.customId));return(s,r)=>e.withMemo([t.node.children],()=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(`h${t.node.level}`),{class:e.normalizeClass(["heading-node",[`heading-${t.node.level}`]]),dir:"auto"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(l,i,v,m)=>{const d=[l];if(m&&m.key===`${t.indexKey||"heading"}-${i}`&&e.isMemoSame(m,d))return m;const g=(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.type]),{key:`${t.indexKey||"heading"}-${i}`,"custom-id":o.customId,node:l,"index-key":`${t.indexKey||"heading"}-${i}`},null,8,["custom-id","node","index-key"]));return g.memo=d,g},r,0),128))]),_:1},8,["class"])),r,2)}}),gn=R(Er,[["__scopeId","data-v-d8e179e9"]]),ln=gn;ln.install=t=>{t.component(gn.__name,gn)};const Nr=e.defineComponent({__name:"ListItemNode",props:{item:{},indexKey:{},value:{},typewriter:{type:Boolean}},emits:["copy"],setup(t){const o=t,n=e.computed(()=>o.value==null?{}:{value:o.value});return(s,r)=>(e.openBlock(),e.createElementBlock("li",e.mergeProps({class:"list-item pl-1.5 my-2",dir:"auto"},n.value),[e.withMemo([o.item.children],()=>e.createVNode(e.unref(Ee),{"index-key":`list-item-${o.indexKey}`,nodes:o.item.children,typewriter:o.typewriter,"batch-rendering":!1,onCopy:r[0]||(r[0]=l=>s.$emit("copy",l))},null,8,["index-key","nodes","typewriter"]),r,1)],16))}}),bt=R(Nr,[["__scopeId","data-v-e7aa2cc3"]]);bt.install=t=>{t.component(bt.__name,bt)};const Tr=e.defineComponent({__name:"ListNode",props:{node:{},customId:{},indexKey:{},typewriter:{type:Boolean}},emits:["copy"],setup(t){return(o,n)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.node.ordered?"ol":"ul"),{class:e.normalizeClass(["list-node",{"list-decimal":t.node.ordered,"list-disc":!t.node.ordered}])},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.items,(s,r,l,i)=>{var d;const v=[s];if(i&&i.key===`${t.indexKey||"list"}-${r}`&&e.isMemoSame(i,v))return i;const m=(e.openBlock(),e.createBlock(e.unref(bt),{key:`${t.indexKey||"list"}-${r}`,item:s,"custom-id":t.customId,"index-key":`${t.indexKey||"list"}-${r}`,typewriter:t.typewriter,value:t.node.ordered?((d=t.node.start)!=null?d:1)+r:void 0,onCopy:n[0]||(n[0]=g=>o.$emit("copy",g))},null,8,["item","custom-id","index-key","typewriter","value"]));return m.memo=v,m},n,1),128))]),_:1},8,["class"]))}}),Bt=R(Tr,[["__scopeId","data-v-79057d57"]]);Bt.install=t=>{t.component(Bt.__name,Bt)};const $r="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20width='16'%20height='16'%3e%3cpath%20fill='none'%20stroke='%23ca9ee6'%20stroke-linecap='round'%20stroke-linejoin='round'%20d='M1.5%202.5c0%206%202.25%205.75%204%207%20.83.67%201.17%202%201%204h3c-.17-2%20.17-3.33%201-4%201.75-1.25%204-1%204-7C12%202.5%2010%203%208%207%206%203%204%202.5%201.5%202.5'%20/%3e%3c/svg%3e";function Xn(t){try{if(typeof globalThis!="undefined"&&typeof globalThis.requestAnimationFrame=="function")return globalThis.requestAnimationFrame(t)}catch(o){}return globalThis.setTimeout(t,0)}let re=null,Ze=null;const ee=new Map,Sr=5;let tn=Sr,kn=!1;function Vr(t){kn=!!t}function Ir(t){Number.isFinite(t)&&t>0&&(tn=Math.floor(t))}function _r(){return{inFlight:ee.size,max:tn}}const Yn="WORKER_BUSY";function Lr(t){re=t,Ze=null;const o=t;re.onmessage=n=>{if(re!==o)return;const{id:s,ok:r,result:l,error:i}=n.data,v=ee.get(s);v&&(r===!1||i?v.reject(new Error(i||"Unknown error")):v.resolve(l))},re.onerror=n=>{var s,r;if(re===o){if(ee.size===0){(s=console.debug)==null||s.call(console,"[mermaidWorkerClient] Worker error (no pending):",(n==null?void 0:n.message)||n);return}try{kn?console.error("[mermaidWorkerClient] Worker error:",(n==null?void 0:n.message)||n):(r=console.debug)==null||r.call(console,"[mermaidWorkerClient] Worker error:",(n==null?void 0:n.message)||n)}catch(l){}for(const[l,i]of ee.entries())i.reject(new Error(`Worker error: ${n.message}`));ee.clear()}},re.onmessageerror=n=>{var s,r;if(re===o){if(ee.size===0){(s=console.debug)==null||s.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",n);return}try{kn?console.error("[mermaidWorkerClient] Worker messageerror:",n):(r=console.debug)==null||r.call(console,"[mermaidWorkerClient] Worker messageerror:",n)}catch(l){}for(const[l,i]of ee.entries())i.reject(new Error("Worker messageerror"));ee.clear()}}}function Dr(){var t;if(re)try{for(const[o,n]of ee.entries())n.reject(new Error("Worker cleared"));ee.clear(),(t=re.terminate)==null||t.call(re)}catch(o){}re=null,Ze=null}function zr(){return re||(Ze=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Ze.name="WorkerInitError",Ze.code="WORKER_INIT_ERROR",null)}function qn(t,o,n=1400){if(Ze)return Promise.reject(Ze);const s=zr();if(!s)return Promise.reject(Ze);if(ee.size>=tn){const r=new Error("Worker busy");return r.name="WorkerBusy",r.code=Yn,r.inFlight=ee.size,r.max=tn,Promise.reject(r)}return new Promise((r,l)=>{const i=Math.random().toString(36).slice(2);let v=!1,m;const d=()=>{v||(v=!0,m!=null&&globalThis.clearTimeout(m),ee.delete(i))},g={resolve:h=>{d(),r(h)},reject:h=>{d(),l(h)}};ee.set(i,g);try{s.postMessage({id:i,action:t,payload:o})}catch(h){ee.delete(i),l(h);return}m=globalThis.setTimeout(()=>{const h=new Error("Worker call timed out");h.name="WorkerTimeout",h.code="WORKER_TIMEOUT";const b=ee.get(i);b&&b.reject(h)},n)})}function Un(t,o,n=1400){return V(this,null,function*(){try{return yield qn("canParse",{code:t,theme:o},n)}catch(s){return Promise.reject(s)}})}function Zn(t,o,n=1400){return V(this,null,function*(){try{return yield qn("findPrefix",{code:t,theme:o},n)}catch(s){return Promise.reject(s)}})}function wn(){if(re)try{for(const[t,o]of ee.entries())o.reject(new Error("Worker terminated"));ee.clear(),re.terminate()}finally{re=null}}let oe=null;function Rr(){return V(this,null,function*(){if(oe)return oe;try{const t=yield import("mermaid"),o=t&&t.default?t.default:t;if(o&&(typeof o.render=="function"||typeof o.parse=="function"||typeof o.initialize=="function"))oe=o;else if(o&&o.mermaidAPI&&(typeof o.mermaidAPI.render=="function"||typeof o.mermaidAPI.parse=="function")){const n=o.mermaidAPI;oe=qe(Z({},o),{render:n.render.bind(n),parse:n.parse?n.parse.bind(n):void 0,initialize:s=>typeof o.initialize=="function"?o.initialize(s):n.initialize?n.initialize(s):void 0})}else t.mermaid&&typeof t.mermaid.render=="function"?oe=t.mermaid:oe=o}catch(t){throw new Error('Optional dependency "mermaid" is not installed. Please install it to enable mermaid diagrams.')}try{const t=oe==null?void 0:oe.initialize;oe.initialize=o=>{const n=Z({suppressErrorRendering:!0},o||{});if(typeof t=="function")return t.call(oe,n);if(oe!=null&&oe.mermaidAPI&&typeof oe.mermaidAPI.initialize=="function")return oe.mermaidAPI.initialize(n)}}catch(t){}return oe})}const Hr={key:0},jr={key:1,class:"flex items-center space-x-2 overflow-hidden"},Pr=["src"],Ar={key:2},Wr={class:"flex items-center space-x-1"},Kr={class:"flex items-center space-x-1"},Fr={key:4},Or={key:5,class:"flex items-center space-x-1"},Xr=["aria-pressed"],Yr={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"},qr={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"},Ur=["disabled"],Zr=["disabled"],Gr={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"},Jr={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"},Qr={key:1,class:"relative"},ea={key:0,class:"absolute top-2 right-2 z-10 rounded-lg"},ta={class:"flex items-center gap-2 backdrop-blur rounded-lg"},na={class:"absolute top-6 right-6 z-50 flex items-center gap-2"},oa=300,ra=500,aa=e.defineComponent({__name:"MermaidBlockNode",props:{node:{},maxHeight:{default:"500px"},loading:{type:Boolean,default:!0},isDark:{type:Boolean},workerTimeoutMs:{default:1400},parseTimeoutMs:{default:1800},renderTimeoutMs:{default:2500},fullRenderTimeoutMs:{default:4e3},showHeader:{type:Boolean,default:!0},showModeToggle:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExportButton:{type:Boolean,default:!0},showFullscreenButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showZoomControls:{type:Boolean,default:!0}},emits:["copy","export","openModal","toggleMode"],setup(t,{emit:o}){var Mn,Cn;const n=t,s=o,{t:r}=on();let l=null;const i=e.ref(!1);typeof window!="undefined"&&V(null,null,function*(){var c;l=yield Rr(),i.value=!!l,(c=l==null?void 0:l.initialize)==null||c.call(l,{startOnLoad:!1,securityLevel:"loose"})});const v=e.ref(!1),m=e.ref(!1),d=e.ref(),g=e.ref(),h=e.ref(),b=e.ref(),M=e.ref(null),H=rn(),_=e.ref(null),z=e.ref(typeof window=="undefined"),$=e.ref(),T=e.computed(()=>n.node.code.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"));function ae(c){const a=T.value,y=`%%{init: {"theme": "${c==="dark"?"dark":"default"}"}}%%
`;return a.trim().startsWith("%%{")?a:y+a}const D=e.ref(1),W=e.ref(0),E=e.ref(0),G=e.ref(!1),X=e.ref({x:0,y:0}),P=e.ref(!1),pe=e.ref(!1),K=e.ref(!1),Ye=e.ref(null),je=e.ref(0),Pe=e.ref(!1);let $e=null;const U=e.ref("360px");let Y=null;const I=e.ref(!1),le=e.ref(!1),Me=e.ref({}),Ae=e.ref(null),ve=e.ref(""),Je=e.ref(0);let ne=null;const ge=e.ref(!1),Se=e.ref({zoom:1,translateX:0,translateY:0,containerHeight:"360px"}),w=e.computed(()=>{var c,a,u,y;return{worker:(c=n.workerTimeoutMs)!=null?c:1400,parse:(a=n.parseTimeoutMs)!=null?a:1800,render:(u=n.renderTimeoutMs)!=null?u:2500,fullRender:(y=n.fullRenderTimeoutMs)!=null?y:4e3}}),k=(Mn=globalThis.cancelIdleCallback)!=null?Mn:(c=>clearTimeout(c));let B=null,q=null,J=!1,Qe=800,ie=null,et=0,$t=!0;typeof window!="undefined"&&e.watch(()=>d.value,c=>{var u;if((u=_.value)==null||u.destroy(),_.value=null,!c){z.value=!1;return}const a=H(c,{rootMargin:"400px"});_.value=a,z.value=a.isVisible.value,a.whenVisible.then(()=>{z.value=!0})},{immediate:!0}),e.onBeforeUnmount(()=>{var c;(c=_.value)==null||c.destroy(),_.value=null});function De(c,a){const u=a==null?void 0:a.timeoutMs,y=a==null?void 0:a.signal;if(y!=null&&y.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));let N=null,C=!1,L=null;return new Promise((j,Ce)=>{const Q=()=>{N!=null&&clearTimeout(N),L&&y&&y.removeEventListener("abort",L)};u&&u>0&&(N=globalThis.setTimeout(()=>{C||(C=!0,Q(),Ce(new Error("Operation timed out")))},u)),y&&(L=()=>{C||(C=!0,Q(),Ce(new DOMException("Aborted","AbortError")))},y.addEventListener("abort",L)),c().then(vt=>{C||(C=!0,Q(),j(vt))}).catch(vt=>{C||(C=!0,Q(),Ce(vt))})})}function We(c){if(typeof document=="undefined"||!h.value)return;const a=document.createElement("div");a.className="text-red-500 p-4",a.textContent="Failed to render diagram: ";const u=document.createElement("span");u.textContent=c instanceof Error?c.message:"Unknown error",a.appendChild(u),h.value.innerHTML="",h.value.appendChild(a),U.value="360px",ge.value=!0,at()}function tt(c){const a=c;return!a||a.disabled}function F(c,a,u="top"){if(tt(c.currentTarget))return;const y=c,N=(y==null?void 0:y.clientX)!=null&&(y==null?void 0:y.clientY)!=null?{x:y.clientX,y:y.clientY}:void 0;Tt(c.currentTarget,a,u,!1,N,n.isDark)}function O(){nn()}function St(c){if(tt(c.currentTarget))return;const a=v.value?r("common.copied")||"Copied":r("common.copy")||"Copy",u=c,y=(u==null?void 0:u.clientX)!=null&&(u==null?void 0:u.clientY)!=null?{x:u.clientX,y:u.clientY}:void 0;Tt(c.currentTarget,a,"top",!1,y,n.isDark)}function Vt(c,a){const y=`%%{init: {"theme": "${a==="dark"?"dark":"default"}"}}%%
`;return c.trimStart().startsWith("%%{")?c:y+c}function It(){return $t&&!P.value&&!I.value&&!ge.value}function Ft(c){const a=c.split(/\r?\n/);for(;a.length>0;){const y=a[a.length-1].trimEnd();if(y===""){a.pop();continue}if(/^[-=~>|<\s]+$/.test(y.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(y)||/[-|><]$/.test(y)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(y)){a.pop();continue}break}return a.join(`
`)}function Ot(c,a,u){return V(this,null,function*(){var L,j;if(!l)return;const y=l,N=Vt(c,a);if(typeof y.parse=="function")return yield De(()=>y.parse(N),{timeoutMs:(L=u==null?void 0:u.timeoutMs)!=null?L:w.value.parse,signal:u==null?void 0:u.signal}),!0;const C=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return yield De(()=>l.render(C,N),{timeoutMs:(j=u==null?void 0:u.timeoutMs)!=null?j:w.value.render,signal:u==null?void 0:u.signal}),!0})}function mt(c,a,u){return V(this,null,function*(){var y;try{return yield Un(c,a,(y=u==null?void 0:u.timeoutMs)!=null?y:w.value.worker)}catch(N){return yield Ot(c,a,u)}})}function sn(c,a,u){return V(this,null,function*(){var N;try{if(yield mt(c,a,u))return{fullOk:!0,prefixOk:!1}}catch(C){if((C==null?void 0:C.name)==="AbortError")throw C}let y=Ft(c);if(y&&y.trim()&&y!==c)try{try{const L=yield Zn(c,a,(N=u==null?void 0:u.timeoutMs)!=null?N:w.value.worker);L&&L.trim()&&(y=L)}catch(L){}if(yield mt(y,a,u))return{fullOk:!1,prefixOk:!0,prefix:y}}catch(C){if((C==null?void 0:C.name)==="AbortError")throw C}return{fullOk:!1,prefixOk:!1}})}const nt=e.computed(()=>P.value||K.value||m.value);function ft(c){if(!d.value||!h.value)return;const a=h.value.querySelector("svg");if(!a)return;let u=0,y=0;const N=a.getAttribute("viewBox"),C=a.getAttribute("width"),L=a.getAttribute("height");if(N){const j=N.split(" ");j.length===4&&(u=Number.parseFloat(j[2]),y=Number.parseFloat(j[3]))}if((!u||!y)&&C&&L&&(u=Number.parseFloat(C),y=Number.parseFloat(L)),Number.isNaN(u)||Number.isNaN(y)||u<=0||y<=0)try{const j=a.getBBox();j&&j.width>0&&j.height>0&&(u=j.width,y=j.height)}catch(j){console.error("Failed to get SVG BBox:",j);return}if(u>0&&y>0){const j=y/u;let Q=(c!=null?c:d.value.clientWidth)*j;Q>y&&(Q=y),U.value=`${Q}px`}}const ze=e.ref(!1),_t=e.computed(()=>({transform:`translate(${W.value}px, ${E.value}px) scale(${D.value})`}));function Xt(c){c.key==="Escape"&&ze.value&&ht()}function Yt(){if(ze.value=!0,typeof document!="undefined")try{document.body.style.overflow="hidden"}catch(c){}if(typeof window!="undefined")try{window.addEventListener("keydown",Xt)}catch(c){}e.nextTick(()=>{if(d.value&&b.value){const c=d.value.cloneNode(!0);c.classList.add("fullscreen");const a=c.querySelector("[data-mermaid-wrapper]");a&&(M.value=a,a.style.transform=_t.value.transform),b.value.innerHTML="",b.value.appendChild(c)}})}function ht(){if(ze.value=!1,b.value&&(b.value.innerHTML=""),M.value=null,typeof document!="undefined")try{document.body.style.overflow=""}catch(c){}if(typeof window!="undefined")try{window.removeEventListener("keydown",Xt)}catch(c){}}function qt(c,a){let u=null;return(...y)=>{u&&clearTimeout(u),u=setTimeout(()=>c(...y),a)}}function f(){if(!P.value||!i.value)return;const c=T.value.length;c!==je.value&&(Pe.value=!0,je.value=c,$e&&clearTimeout($e),$e=setTimeout(()=>{Pe.value&&P.value&&T.value.trim()&&(Pe.value=!1,Dt("preview"))},ra))}e.watch(_t,c=>{ze.value&&M.value&&(M.value.style.transform=c.transform)},{immediate:!0});function p(){D.value<3&&(D.value+=.1)}function x(){D.value>.5&&(D.value-=.1)}function A(){D.value=1,W.value=0,E.value=0}function S(c){G.value=!0,c instanceof MouseEvent?X.value={x:c.clientX-W.value,y:c.clientY-E.value}:X.value={x:c.touches[0].clientX-W.value,y:c.touches[0].clientY-E.value}}function ke(c){if(!G.value)return;let a,u;c instanceof MouseEvent?(a=c.clientX,u=c.clientY):(a=c.touches[0].clientX,u=c.touches[0].clientY),W.value=a-X.value.x,E.value=u-X.value.y}function Ve(){G.value=!1}function Ke(c){if(c.ctrlKey||c.metaKey){if(c.preventDefault(),!d.value)return;const a=d.value.getBoundingClientRect(),u=c.clientX-a.left,y=c.clientY-a.top,N=a.width/2,C=a.height/2,L=u-N,j=y-C,Ce=(L-W.value)/D.value,Q=(j-E.value)/D.value,io=-c.deltaY*.01,Gt=Math.min(Math.max(D.value+io,.5),3);Gt!==D.value&&(W.value=L-Ce*Gt,E.value=j-Q*Gt,D.value=Gt)}}function Ie(){return V(this,null,function*(){try{typeof navigator!="undefined"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function"&&(yield navigator.clipboard.writeText(T.value)),v.value=!0,s("copy",T.value),setTimeout(()=>{v.value=!1},1e3)}catch(c){console.error("Failed to copy:",c)}})}function ot(c,a=null){return V(this,null,function*(){try{const u=a!=null?a:new XMLSerializer().serializeToString(c),y=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),N=URL.createObjectURL(y);if(typeof document!="undefined"){const C=document.createElement("a");C.href=N,C.download=`mermaid-diagram-${Date.now()}.svg`;try{document.body.appendChild(C),C.click(),document.body.removeChild(C)}catch(L){}URL.revokeObjectURL(N)}}catch(u){console.error("Failed to export SVG:",u)}})}function pt(){var y;const c=(y=h.value)==null?void 0:y.querySelector("svg");if(!c){console.error("SVG element not found");return}const a=new XMLSerializer().serializeToString(c),u={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:c,svgString:a};s("export",u),u.defaultPrevented||ot(c,a)}function cn(){var y,N;const c=(N=(y=h.value)==null?void 0:y.querySelector("svg"))!=null?N:null,a=c?new XMLSerializer().serializeToString(c):null,u={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:c,svgString:a};s("openModal",u),u.defaultPrevented||Yt()}function Lt(c){const a={payload:{type:"toggle-mode",target:c},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};s("toggleMode",c,a),a.defaultPrevented||Dt(c)}function Dt(c){return V(this,null,function*(){const a=$.value;if(!a){pe.value=!0,P.value=c==="source";return}const u=a.getBoundingClientRect().height;a.style.height=`${u}px`,a.style.overflow="hidden",pe.value=!0,P.value=c==="source",yield e.nextTick();const y=a.scrollHeight;a.style.transition="height 180ms ease",a.offsetHeight,a.style.height=`${y}px`;const N=()=>{a.style.transition="",a.style.height="",a.style.overflow="",a.removeEventListener("transitionend",C)};function C(){N()}a.addEventListener("transitionend",C),setTimeout(()=>N(),220)})}function rt(){return V(this,null,function*(){if(K.value)return Ye.value;if(!h.value&&(yield e.nextTick(),!h.value)){console.warn("Mermaid container not ready");return}return K.value=!0,Ye.value=V(null,null,function*(){var c;if(l){h.value&&(h.value.style.opacity="0");try{const a=`mermaid-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;!I.value&&!le.value&&((c=l.initialize)==null||c.call(l,{securityLevel:"loose",startOnLoad:!1}));const u=n.isDark?"dark":"light",y=ae(u),N=yield De(()=>l.render(a,y),{timeoutMs:w.value.fullRender}),C=N==null?void 0:N.svg,L=N==null?void 0:N.bindFunctions;if(h.value){h.value.innerHTML=C,L==null||L(h.value),!I.value&&!le.value&&(ft(),I.value=!0,Se.value={zoom:D.value,translateX:W.value,translateY:E.value,containerHeight:U.value});const j=n.isDark?"dark":"light";Me.value[j]=C,le.value&&(le.value=!1),ge.value=!1}}catch(a){console.error("Failed to render mermaid diagram:",a),n.loading===!1&&We(a)}finally{yield e.nextTick(),h.value&&(h.value.style.opacity="1"),K.value=!1,Ye.value=null}}}),Ye.value})}function dn(c){return V(this,null,function*(){if(It()&&!(!h.value&&(yield e.nextTick(),!h.value))&&!K.value){K.value=!0;try{if(!l)return;const a=`mermaid-partial-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,u=n.isDark?"dark":"light",y=Ft(c),N=y&&y.trim()?y:c,C=Vt(N,u);h.value&&(h.value.style.opacity="0");const L=yield De(()=>l.render(a,C),{timeoutMs:w.value.render}),j=L==null?void 0:L.svg,Ce=L==null?void 0:L.bindFunctions;h.value&&j&&(h.value.innerHTML=j,Ce==null||Ce(h.value),ft())}catch(a){}finally{yield e.nextTick(),h.value&&(h.value.style.opacity="1"),K.value=!1}}})}const un=(Cn=globalThis.requestIdleCallback)!=null?Cn:((c,a)=>setTimeout(()=>c({didTimeout:!0}),16));function zt(){return V(this,null,function*(){var j,Ce;const c=Date.now(),a=++Je.value;ne&&ne.abort(),ne=new AbortController;const u=ne.signal,y=n.isDark?"dark":"light",N=T.value,C=N.replace(/\s+/g,"");if(!N.trim()){h.value&&(h.value.innerHTML=""),Ae.value=null,ve.value="",ge.value=!1;return}if(C===ve.value)return;try{const Q=yield sn(N,y,{signal:u,timeoutMs:w.value.worker});if(Q.fullOk){yield rt(),Je.value===a&&(Ae.value=(Ce=(j=h.value)==null?void 0:j.innerHTML)!=null?Ce:null,ve.value=C,ge.value=!1);return}const vt=et&&c<=et;if(Q.prefixOk&&Q.prefix&&It()&&!vt){yield dn(Q.prefix);return}}catch(Q){if((Q==null?void 0:Q.name)==="AbortError")return}if(Je.value!==a||ge.value)return;