markstream-vue 2.0.14 → 2.0.16
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 +1 -1
- package/dist/index.css +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.js +1 -1
- package/dist/index9.js +1 -1
- package/dist/tailwind.js +0 -0
- package/package.json +3 -3
package/dist/exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,r=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={}))l.call(n,t)&&i(e,t,n[t]);if(o)for(var t of o(n))r.call(n,t)&&i(e,t,n[t]);return e},u=(e,o)=>n(e,t(o)),s=(e,n,t)=>new Promise((o,l)=>{var r=e=>{try{a(t.next(e))}catch(n){l(n)}},i=e=>{try{a(t.throw(e))}catch(n){l(n)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);a((t=t.apply(e,n)).next())});import{normalizeCustomHtmlTagName as d,tokenizeHtml as c,sanitizeHtmlAttrs as m,sanitizeHtmlTokenAttrs as f,tokenAttrsToRecord as v,isCustomHtmlComponentTag as h,convertHtmlAttrsToProps as p,BLOCKED_HTML_TAGS as g,isHtmlTagHardBlocked as y,isHtmlTagBlocked as b,sanitizeHtmlContent as k,sanitizeImageSrc as w,shouldOpenLinkInNewTab as x,NON_STRUCTURING_HTML_TAGS as S,normalizeCustomHtmlTags as M,getHtmlTagFromContent as C,shouldRenderUnknownHtmlTagAsText as N,getMarkdown as _,mergeCustomHtmlTags as T,resolveCustomHtmlTags as B,parseMarkdownToStructure as I,EXTENDED_STANDARD_HTML_TAGS as H,stripCustomHtmlWrapper as $,setDefaultMathOptions as R}from"stream-markdown-parser";import{shallowRef as P,inject as F,computed as A,defineComponent as O,openBlock as K,createElementBlock as j,createElementVNode as z,toDisplayString as L,h as E,normalizeClass as D,createVNode as W,unref as V,ref as q,useAttrs as U,watch as X,Fragment as Y,createTextVNode as Z,createCommentVNode as G,renderList as J,getCurrentInstance as Q,provide as ee,onBeforeUnmount as ne,renderSlot as te,nextTick as oe,defineAsyncComponent as le,createBlock as re,resolveDynamicComponent as ie,mergeProps as ae,withCtx as ue,normalizeStyle as se,onScopeDispose as de,withDirectives as ce,vShow as me,markRaw as fe,normalizeProps as ve,guardReactiveProps as he,Transition as pe,reactive as ge,getCurrentScope as ye,onMounted as be,watchEffect as ke,triggerRef as we,resolveComponent as xe,toRaw as Se,toValue as Me}from"vue";import{M as Ce,n as Ne,c as _e,g as Te,s as Be,h as Ie}from"./index2.js";import{b as He}from"./workers-katexWorkerClient.js";import{createDiffMatchCache as $e,buildDiffPreviewPanes as Re,normalizeShikiLanguage as Pe,createSmoothMarkdownStream as Fe}from"markstream-core";import{d as Ae,g as Oe,b as Ke,f as je,c as ze,p as Le,e as Ee}from"./diagramHeight.js";import"./workers-mermaidWorkerClient.js";import"./workers/katexCdnWorker.js";import"./workers/mermaidCdnWorker.js";import"./utils/katex-threshold.js";import"./utils/performance-monitor.js";import"./utils/safeRaf.js";const De="__global__",We="__MARKSTREAM_VUE_CUSTOM_COMPONENTS_STORE__",Ve=(()=>{const e=globalThis;if(e[We])return e[We];const n={scopedCustomComponents:{},revision:P(0)};return e[We]=n,n})(),qe=Ve.revision,Ue=/* @__PURE__ */Symbol("markstreamCustomComponents"),Xe=/* @__PURE__ */new Set(["text","paragraph","heading","code_block","list","list_item","blockquote","table","table_row","table_cell","definition_list","definition_item","footnote","footnote_reference","footnote_anchor","admonition","hardbreak","link","image","thematic_break","math_inline","math_block","strong","emphasis","strikethrough","highlight","insert","subscript","superscript","emoji","checkbox","checkbox_input","inline_code","html_inline","html_block","reference","mermaid","infographic","d2","vmr_container"]);function Ye(e){return Xe.has(String(e).trim().toLowerCase())}function Ze(e){return e.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function Ge(e={}){const n={};for(const[t,o]of Object.entries(e))if(null!=o){n[t]=o;for(const e of/* @__PURE__ */new Set([d(t),d(Ze(t))]))!e||Ye(e)||Object.prototype.hasOwnProperty.call(n,e)||(n[e]=o)}return n}function Je(e,n){"string"==typeof e?Ve.scopedCustomComponents[e]=Ge(n||{}):Ve.scopedCustomComponents[De]=Ge(e||{}),qe.value++}function Qe(e){const n=Ge(Ve.scopedCustomComponents[De]||{});if(!e)return n;const t=Ge(Ve.scopedCustomComponents[e]||{});return n&&0!==Object.keys(n).length?t&&0!==Object.keys(t).length?a(a({},n),t):n:t}function en(e){const n=F(Ue,null);return A(()=>{var t;return qe.value,function(e,n={}){return qe.value,a(a(a({},Ge(Ve.scopedCustomComponents[De]||{})),Ge(n)),Ge(function(e){return e&&Ve.scopedCustomComponents[e]||{}}(e)))}(null==e?void 0:e(),null!=(t=null==n?void 0:n.value)?t:{})})}function nn(e){if(e===De)throw new Error("removeCustomComponents: use clearGlobalCustomComponents() to clear the global mapping");delete Ve.scopedCustomComponents[e],qe.value++}function tn(){delete Ve.scopedCustomComponents[De],qe.value++}const on=["aria-label"],ln={key:0,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",class:"checkbox-icon checkbox-unchecked"},rn={key:1,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",class:"checkbox-icon checkbox-checked"},an=(e,n)=>{const t=e.__vccOpts||e;for(const[o,l]of n)t[o]=l;return t},un=/* @__PURE__ */an(/* @__PURE__ */O({__name:"CheckboxNode",props:{node:{}},setup:e=>(n,t)=>(K(),j("span",{class:"checkbox-node",role:"img","aria-label":e.node.checked?"checked":"unchecked"},[e.node.checked?(K(),j("svg",rn,[...t[1]||(t[1]=[z("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4",fill:"currentColor"},null,-1),z("path",{d:"M9 12l2 2 4-4",stroke:"hsl(var(--ms-background))","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(K(),j("svg",ln,[...t[0]||(t[0]=[z("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4",stroke:"currentColor","stroke-width":"2"},null,-1)])]))],8,on))}),[["__scopeId","data-v-be21ab83"]]);un.install=e=>{e.component(un.__name,un)};const sn={class:"emoji-node"},dn=/* @__PURE__ */an(/* @__PURE__ */O({__name:"EmojiNode",props:{node:{}},setup:e=>(n,t)=>(K(),j("span",sn,L(e.node.name),1))}),[["__scopeId","data-v-de55dc97"]]);dn.install=e=>{e.component(dn.__name,dn)};const cn=["id"],mn=["title"],fn=/* @__PURE__ */an(/* @__PURE__ */O({__name:"FootnoteReferenceNode",props:{node:{}},setup(e){const n=`#fnref--${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,l)=>(K(),j("sup",{id:`fnref-${e.node.id}`,class:"footnote-reference",onClick:t},[z("span",{href:n,title:`查看脚注 ${e.node.id}`,class:"footnote-link cursor-pointer"},"["+L(e.node.id)+"]",9,mn)],8,cn))}}),[["__scopeId","data-v-c1463a29"]]);fn.install=e=>{e.component(fn.__name,fn)};const vn=(()=>{try{return Boolean(!1)}catch(e){}return!1})();function hn(e){vn&&console.warn(e)}function pn(e,n){return h(e,n)}function gn(e,n="safe",t){return m(e,n,t)}function yn(e){return p(e)}function bn(e){return!0===e?"":!1===e?"false":null==e?null:String(e)}function kn(e,n="safe"){const t=String(e.tag||e.type||"").trim(),o=f((l=e.attrs)?Array.isArray(l)?l.every(Array.isArray)?l.map(([e,n])=>[String(e),bn(n)]):l.filter(e=>e&&"object"==typeof e&&!Array.isArray(e)&&"name"in e).map(e=>[String(e.name),bn(e.value)]):Object.entries(l).map(([e,n])=>[e,bn(n)]):null,n,t);var l;if(!o)return;const r=yn(v(o));return Object.keys(r).length>0?r:void 0}function wn(e,n,t=!1){const o=Object.entries(null!=n?n:{}),l=o.length>0?o.map(([e,n])=>""===n?` ${e}`:` ${e}="${n}"`).join(""):"";return t?`<${e}${l} />`:`<${e}${l}>`}function xn(e,n){Array.isArray(n)?e.push(...n):null!=n&&e.push(n)}function Sn(e,n,t,o,l,r,i=!1){const s=pn(e,o);if(g.has(e.toLowerCase())||!s&&y(e,r))return null;if(!s&&b(e,r))return i?[wn(e,n,!0)]:[wn(e,n),...t,`</${e}>`];const d=m(n,r,e),c=d.key,f=null!=c&&""!==c?c:l;if(s){const n=o[e]||o[e.toLowerCase()],l=yn(d);return E(n,u(a({},l),{key:f}),t.length>0?t:void 0)}return E(e,u(a({},d),{innerHTML:void 0,key:f}),t.length>0?t:void 0)}function Mn(e,n,t="safe",o=!1){var l,r;try{if(!o&&0===Object.keys(n).length)return{ok:!0,hasCustomComponents:!1,nodes:null};const r=c(e);let i=!1;for(const e of r)if(("tag_open"===e.type||"self_closing"===e.type)&&pn(null!=(l=e.tagName)?l:"",n)){i=!0;break}const a=o||i?function(e,n,t="safe"){let o=0;const l=[],r=[];for(const i of e)if("text"===i.type)(l.length>0?l[l.length-1].children:r).push(i.content);else if("self_closing"===i.type){const e=Sn(i.tagName,i.attrs||{},[],n,"ms-html-"+o++,t,!0);xn(l.length>0?l[l.length-1].children:r,e)}else if("tag_open"===i.type)l.push({tagName:i.tagName,children:[],attrs:i.attrs,autoKey:"ms-html-"+o++});else if("tag_close"===i.type){const e=i.tagName.toLowerCase();let o=-1;for(let n=l.length-1;n>=0;n--)if(l[n].tagName.toLowerCase()===e){o=n;break}if(-1!==o)for(;l.length>o;){const i=l.pop(),a=Sn(i.tagName,i.attrs||{},i.children,n,i.autoKey,t);l.length>0?xn(l[l.length-1].children,a):xn(r,a),i.tagName.toLowerCase()!==e&&l.length>o&&hn(`Auto-closing unclosed tag: <${i.tagName}>`)}else hn(`Ignoring closing tag with no matching opening tag: </${i.tagName}>`)}for(;l.length>0;){const e=l.pop(),o=Sn(e.tagName,e.attrs||{},e.children,n,e.autoKey,t);l.length>0?xn(l[l.length-1].children,o):xn(r,o),hn(`Auto-closing unclosed tag: <${e.tagName}>`)}return r}(r,n,t):null;return{ok:!0,hasCustomComponents:i,nodes:a}}catch(i){return r=i,vn&&console.error("Failed to parse HTML to VNodes:",r),{ok:!1,hasCustomComponents:!1,nodes:null}}}const Cn=["innerHTML"],Nn=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HtmlInlineNode",props:{node:{},customId:{},htmlPolicy:{}},setup(e){const n=e,t=F("markstreamHtmlPolicy",void 0),o=A(()=>{var e,o;return null!=(o=null!=(e=n.htmlPolicy)?e:null==t?void 0:t.value)?o:"safe"}),l=en(()=>n.customId),r=O({name:"DynamicRenderer",props:{nodes:{type:Array,required:!0}},render(){return this.nodes}}),i=A(()=>{const e=n.node.content;if(!e)return{mode:"html",content:""};if("escape"===o.value)return{mode:"html",content:k(e,o.value)};if(n.node.loading&&!n.node.autoClosed)return{mode:"text",content:e};const t=!0===n.node.loading&&!0===n.node.autoClosed,r=Mn(e,l.value,o.value,t);return r.ok&&(t||r.hasCustomComponents)?{mode:"dynamic",nodes:r.nodes}:{mode:"html",content:k(e,o.value)}});return(e,t)=>"dynamic"===i.value.mode?(K(),j("span",{key:0,class:D(["html-inline-node",{"html-inline-node--loading":n.node.loading}])},[W(V(r),{nodes:i.value.nodes},null,8,["nodes"])],2)):"text"===i.value.mode?(K(),j("span",{key:1,class:D(["html-inline-node",{"html-inline-node--loading":n.node.loading}])},L(i.value.content),3)):(K(),j("span",{key:2,class:D(["html-inline-node",{"html-inline-node--loading":n.node.loading}]),innerHTML:i.value.content},null,10,Cn))}}),[["__scopeId","data-v-fbbbc497"]]);function _n(e){const n=q(e),t=P([]);let o=e,l=0;function r(){let e=0,o="";for(const n of t.value){if(!n.finished)break;o+=n.content,e++}e&&(n.value+=o,t.value=t.value.slice(e))}return{settledContent:n,segments:t,update:function(e,r,i){if(i&&e===o&&(!r||r===e||t.value.length>0))return;const s=null!=r?r:o;if(i&&s&&e.length>s.length&&e.startsWith(s)){s!==o&&(n.value=s,t.value=[]);const r=e.slice(s.length),i=performance.now(),d=t.value.at(-1);d&&(i-d.startedAt<50||t.value.length>=4)?t.value=[...t.value.slice(0,-1),u(a({},d),{content:d.content+r})]:t.value=[...t.value,{id:l++,content:r,startedAt:i,finished:!1}]}else n.value=e,t.value=[];o=e},finish:function(e,n=!1){const o=t.value.find(n=>n.id===e);o&&(o.finished=!0,n||r())},settleFinished:r}}Nn.install=e=>{e.component(Nn.__name,Nn)};const Tn={class:"inline-code"},Bn={key:0},In=["onAnimationend"],Hn=/* @__PURE__ */an(/* @__PURE__ */O({__name:"InlineCodeNode",props:{node:{}},setup(e){const n=e,t=U(),o=F("markstreamFade",void 0),l=F("markstreamTextStreamState",void 0),r=A(()=>{const e=t.fade;return""===e||!0===e||"true"===e||!1!==e&&"false"!==e&&void 0}),i=A(()=>"boolean"==typeof r.value?r.value:"boolean"!=typeof(null==o?void 0:o.value)||o.value),a=A(()=>{var e;return String(null!=(e=n.node.code)?e:"")}),u=A(()=>!i.value),s=A(()=>{var e;const n=null!=(e=t["index-key"])?e:t.indexKey;return null==n||""===n?"":String(n)}),{settledContent:d,segments:c,update:m,finish:f}=_n(n.node.code);return X([()=>n.node.code,s,i],([e])=>{const n=String(null!=e?e:""),t=s.value;m(n,t?null==l?void 0:l.get(t):void 0,i.value),t&&(null==l||l.set(t,n))},{immediate:!0}),(e,n)=>(K(),j("code",Tn,[u.value?(K(),j(Y,{key:0},[Z(L(a.value),1)],64)):(K(),j(Y,{key:1},[V(d)?(K(),j("span",Bn,L(V(d)),1)):G("",!0),(K(!0),j(Y,null,J(V(c),e=>(K(),j("span",{key:e.id,class:"inline-code-stream-delta",onAnimationend:n=>V(f)(e.id)},L(e.content),41,In))),128))],64))]))}}),[["__scopeId","data-v-557cf4dd"]]);Hn.install=e=>{e.component(Hn.__name,Hn)};const $n=q(!1),Rn=q(""),Pn=q("top"),Fn=q(null),An=q(null),On=q(null),Kn=q(null),jn=q(null);let zn=null,Ln=null,En=0;function Dn(){zn&&(clearTimeout(zn),zn=null),Ln&&(clearTimeout(Ln),Ln=null)}let Wn=!1,Vn=null,qn=!1;function Un(e,n,t="top",o=!1,l,r){if(!e)return;const i=++En;Dn();const a=()=>s(null,null,function*(){var o,a;if(yield function(){return s(this,null,function*(){if(!Wn&&!qn&&"undefined"!=typeof document){null!=Vn||(Vn=s(null,null,function*(){const[{createApp:e,h:n},{default:t}]=yield Promise.all([import("vue"),import("./Tooltip.js")]),o=document.createElement("div");o.setAttribute("data-singleton-tooltip","1"),document.body.appendChild(o),e({setup:()=>()=>{var e;return n(t,{visible:$n.value,"anchor-el":Fn.value,content:Rn.value,placement:Pn.value,id:An.value,originX:On.value,originY:Kn.value,isDark:null!=(e=jn.value)?e:void 0})}}).mount(o),Wn=!0}));try{yield Vn}catch(e){Wn=!1,Vn=null,qn=!0,console.warn("[markstream-vue] Failed to mount Tooltip component. Tooltips will be disabled.",e)}}})}(),Wn&&i===En){An.value=`tooltip-${Date.now()}-${Math.floor(1e3*Math.random())}`,Fn.value=e,Rn.value=n,Pn.value=t,On.value=null!=(o=null==l?void 0:l.x)?o:null,Kn.value=null!=(a=null==l?void 0:l.y)?a:null,jn.value="boolean"==typeof r?r:null,$n.value=!0;try{e.setAttribute("aria-describedby",An.value)}catch(u){}}});o?a():zn=setTimeout(a,80)}function Xn(e=!1){En+=1,Dn();const n=()=>{if(Fn.value&&An.value)try{Fn.value.removeAttribute("aria-describedby")}catch(e){}$n.value=!1,Fn.value=null,An.value=null,On.value=null,Kn.value=null};e?n():Ln=setTimeout(n,120)}const Yn={"common.copy":"Copy","common.selectCopy":"全选(复制)","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.minimize":"Minimize","common.zoomIn":"Zoom in","common.zoomOut":"Zoom out","common.resetZoom":"Reset zoom","image.loadError":"Image failed to load","image.loading":"Loading image..."},Zn=/* @__PURE__ */Symbol("markstreamI18nFallback");function Gn(e){Object.assign(Yn,e)}function Jn(e,n){var t;return null!=(t=null==n?void 0:n[e])?t:Yn[e]}const Qn=(e,n)=>{var t;return null!=(t=Jn(e,n))?t: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)};function et(e,n){return{t(t){const o=Jn(t,n);if(e.te&&null!=o&&!e.te(t))return Qn(t,n);const l=e.t(t);return l===t&&null!=o?Qn(t,n):l}}}function nt(){const e=function(){var e,n,t;try{const o=Q(),l=Zn,r=null==o?void 0:o.provides,i=null==(e=null==o?void 0:o.appContext)?void 0:e.provides;return null!=(t=null!=(n=null==r?void 0:r[l])?n:null==i?void 0:i[l])?t:null}catch(o){}return null}(),n=function(){var e,n;try{const t=Q(),o=null==t?void 0:t.proxy,l=null==o?void 0:o.$t;if("function"==typeof l){const e=null==o?void 0:o.$te;return{t:l.bind(o),te:"function"==typeof e?e.bind(o):void 0}}const r=null==(n=null==(e=null==t?void 0:t.appContext)?void 0:e.config)?void 0:n.globalProperties,i=null==r?void 0:r.$t;if("function"==typeof i){const e=null==r?void 0:r.$te;return{t:i.bind(r),te:"function"==typeof e?e.bind(r):void 0}}}catch(t){}return null}();if(n)return et(n,e);try{const n=globalThis.$vueI18nUse||null;if(n&&"function"==typeof n)try{const t=n();if(t&&"function"==typeof t.t)return et({t:t.t.bind(t),te:"function"==typeof t.te?t.te.bind(t):void 0},e)}catch(t){}}catch(t){}return{t:n=>Qn(n,e)}}const tt=/* @__PURE__ */Symbol("ViewportPriority"),ot=/* @__PURE__ */Symbol("ViewportPriorityOptions"),lt=/* @__PURE__ */Symbol("OffscreenHeavyNodeDeferral"),rt=A(()=>!1),it="400px";function at(){return F(ot,void 0)}function ut(){return F(lt,rt)}function st(e,n){var t,o;const l="undefined"!=typeof window&&"undefined"!=typeof document,r="boolean"==typeof n?q(n):n,i=l?null!=(t=window.requestIdleCallback)?t:e=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),16):null,a=l?null!=(o=window.cancelIdleCallback)?o:e=>window.clearTimeout(e):null,u=/* @__PURE__ */new WeakMap;let s=1;const d=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map,m=/* @__PURE__ */new Set;let f=null,v=null;function h(e){if(!e)return"viewport";let n=u.get(e);return n||(n=s++,u.set(e,n)),String(n)}function p(){if(null!=f){try{null==a||a(f)}catch(e){}f=null}}function g(e){if(e){const t=d.get(e);if(t&&!t.targets.size){try{t.io.disconnect()}catch(n){}d.delete(e)}}c.size||m.size||p()}function y(e){const n=c.get(e);if(!n)return;const t=d.get(n.bucketKey);if(!n.visible.value){n.visible.value=!0;try{n.resolve()}catch(o){}}try{null==t||t.io.unobserve(e)}catch(o){}null==t||t.targets.delete(e),c.delete(e),m.delete(e),g(n.bucketKey)}function b(){!0!==window.__MARKSTREAM_DISABLE_VIEWPORT_PRIORITY_IDLE_DRAIN__&&i&&null==f&&m.size&&(f=i(()=>{f=null;const e=m.values().next().value;e&&(m.delete(e),y(e),m.size&&b())},{timeout:1200}))}function k(n,t){if(!l)return null;if("undefined"==typeof IntersectionObserver)return null;const o=function(n,t){var o,l,r;return{root:null!=(o=null==e?void 0:e(null!=n?n:null))?o:null,rootMargin:null!=(l=null==t?void 0:t.rootMargin)?l:it,threshold:null!=(r=null==t?void 0:t.threshold)?r:0}}(n,t),r=[h((i=o).root),i.rootMargin,i.threshold].join("\0");var i;const a=d.get(r);if(a)return{key:r,bucket:a};let u;try{u=new IntersectionObserver(e=>{for(const n of e)(n.isIntersecting||n.intersectionRatio>0)&&y(n.target)},{root:o.root,rootMargin:o.rootMargin,threshold:o.threshold})}catch(c){return null}const s={io:u,targets:/* @__PURE__ */new Map};return d.set(r,s),{key:r,bucket:s}}function w(){if(l&&r.value)for(const[n,t]of Array.from(c.entries())){const o=k(n,t.opts);if(!o){y(n);continue}if(o.key===t.bucketKey)continue;const l=t.bucketKey,r=d.get(l);try{null==r||r.io.unobserve(n)}catch(e){}null==r||r.targets.delete(n),t.bucketKey=o.key,o.bucket.targets.set(n,t),o.bucket.io.observe(n),g(l)}}X(r,e=>{if(!e){for(const e of Array.from(c.keys()))y(e);p()}},{flush:"sync"});const x=(e,n)=>{const t=q(!1);let o,i=!1;const a=new Promise(e=>{o=()=>{i||(i=!0,e())}}),u=()=>{const n=c.get(e);if(!n)return m.delete(e),void g();const t=d.get(n.bucketKey);try{null==t||t.io.unobserve(e)}catch(o){}null==t||t.targets.delete(e),c.delete(e),m.delete(e),g(n.bucketKey)};if(!l||!r.value)return t.value=!0,o(),{isVisible:t,whenVisible:a,destroy:u};const s=k(e,n);if(!s)return t.value=!0,o(),{isVisible:t,whenVisible:a,destroy:u};const f={resolve:o,visible:t,bucketKey:s.key,opts:n};return c.set(e,f),s.bucket.targets.set(e,f),s.bucket.io.observe(e),l&&null==v&&(v=window.requestAnimationFrame(()=>{v=null,w()})),!1!==(null==n?void 0:n.allowIdle)&&(m.add(e),b()),{isVisible:t,whenVisible:a,destroy:u}};return x.refresh=w,ee(tt,x),x}function dt(){var e,n;const t=F(tt,void 0);if(t)return t;const o=/* @__PURE__ */new WeakMap,l=/* @__PURE__ */new Map,r=/* @__PURE__ */new Set;let i=null;const a="undefined"!=typeof window?null!=(e=window.requestIdleCallback)?e:e=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),16):null,u="undefined"!=typeof window?null!=(n=window.cancelIdleCallback)?n:e=>window.clearTimeout(e):null,s=()=>{if(null!=i){try{null==u||u(i)}catch(e){}i=null}},d=e=>{if(!e)return;const n=l.get(e);if(n&&!n.targets.size){try{n.io.disconnect()}catch(t){}l.delete(e)}},c=e=>{const n=o.get(e);if(!n)return;const t=l.get(n.bucketKey);if(!n.visible.value){n.visible.value=!0;try{n.resolve()}catch(i){}}try{null==t||t.io.unobserve(e)}catch(i){}o.delete(e),null==t||t.targets.delete(e),r.delete(e),d(n.bucketKey),r.size||s()},m=()=>{!0!==window.__MARKSTREAM_DISABLE_VIEWPORT_PRIORITY_IDLE_DRAIN__&&a&&null==i&&r.size&&(i=a(()=>{i=null;const e=r.values().next().value;e&&(r.delete(e),c(e),r.size&&m())},{timeout:1200}))};return(e,n)=>{const t=q(!1);let i,a=!1;const u=new Promise(e=>{i=()=>{a||(a=!0,e())}}),f=()=>{const n=o.get(e);if(!n)return r.delete(e),void(r.size||s());const t=l.get(n.bucketKey);try{null==t||t.io.unobserve(e)}catch(i){}o.delete(e),null==t||t.targets.delete(e),r.delete(e),d(n.bucketKey),r.size||s()},v=(e=>{var n,t;if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return null;const o=(e=>{var n,t;return[null!=(n=null==e?void 0:e.rootMargin)?n:it,null!=(t=null==e?void 0:e.threshold)?t:0].join("\0")})(e),r=l.get(o);if(r)return{key:o,bucket:r};const i=null!=(n=null==e?void 0:e.rootMargin)?n:it;let a;try{a=new IntersectionObserver(e=>{for(const n of e)(n.isIntersecting||n.intersectionRatio>0)&&c(n.target)},{root:null,rootMargin:i,threshold:null!=(t=null==e?void 0:e.threshold)?t:0})}catch(s){return null}const u={io:a,targets:/* @__PURE__ */new Set};return l.set(o,u),{key:o,bucket:u}})(n);return v?(o.set(e,{resolve:i,visible:t,bucketKey:v.key}),v.bucket.targets.add(e),v.bucket.io.observe(e),!1!==(null==n?void 0:n.allowIdle)&&(r.add(e),m()),{isVisible:t,whenVisible:u,destroy:f}):(t.value=!0,i(),{isVisible:t,whenVisible:u,destroy:f})}}function ct(e,n){var t,o;const l=null!=(o=null!=(t=e.indexKey)?t:n["index-key"])?o:n.indexKey;return null==l||""===l?"":String(l)}const mt=["data-markstream-viewport-pending"],ft=["src","alt","title","loading","fetchpriority","decoding","tabindex","aria-label"],vt={key:1,class:"image-placeholder"},ht={key:1,class:"image-node__raw-text"},pt={key:2,class:"image-error"},gt=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ImageNode",props:{node:{},fallbackSrc:{default:""},lazy:{type:Boolean,default:!1},usePlaceholder:{type:Boolean,default:!0}},emits:["load","error","click"],setup(e,{emit:n}){var t,o,l;const r=e,i=n,a=q(!1),u=q(!1),d=q(!1),c=q(""),m=q("primary"),f=q(null),v=U(),h=F(Ce,null),p=dt(),g=at(),y=ut(),b=A(()=>w(r.node.src)),k=A(()=>w(r.fallbackSrc)),x=null==(l=null==(o=null==(t=Q())?void 0:t.vnode.el)?void 0:o.querySelector)?void 0:l.call(o,"img"),S="undefined"!=typeof window&&(null==x?void 0:x.getAttribute("src"))===(b.value||k.value),M=q("undefined"==typeof window||S||!y.value),C=P(null);let N="",_=null;const T=A(()=>c.value),B=A(()=>!r.lazy),I=A(()=>"undefined"!=typeof window&&y.value&&!S),H=A(()=>!I.value||M.value),$=A(()=>H.value?T.value:""),R=A(()=>{var e,n;return null!=(n=null!=(e=null==g?void 0:g.value.heavyBlockMargin)?e:null==g?void 0:g.value.rootMargin)?n:it}),O=A(()=>!r.node.loading&&"failed"!==m.value&&c.value.length>0),E=A(()=>"failed"===m.value),W=A(()=>(u.value||!B.value||I.value)&&!a.value&&!d.value&&"failed"!==m.value&&c.value.length>0),Y=A(()=>ct(r,v));function Z(e=Y.value){e&&f.value&&(null==h||h.reportHeight(e,f.value.offsetHeight))}function J(e=Y.value){e&&oe(()=>{Z(e)})}function ee(){_&&(clearTimeout(_),_=null)}function le(){const e=Y.value;e&&N!==e&&(N&&(null==h||h.markSettled(N)),ee(),N=e,null==h||h.markPending(e),"undefined"!=typeof window&&(_=window.setTimeout(()=>{N===e&&(J(e),re())},8e3)))}function re(){return s(this,null,function*(){const e=N;e&&(ee(),N="",yield oe(),Z(e),null==h||h.markSettled(e))})}function ie(){if("primary"===m.value&&k.value&&k.value!==c.value)return m.value="fallback",c.value=k.value,a.value=!1,d.value=!1,void J();m.value="failed",d.value=!0,i("error",c.value),J()}function ae(){a.value=!0,u.value=!1,d.value=!1,i("load",T.value),J()}function ue(e){e.preventDefault(),a.value&&!d.value&&i("click",[e,T.value])}const{t:se}=nt();return X([b,k,()=>r.node.loading],()=>(a.value=!1,d.value=!1,r.node.loading?(u.value=!0,c.value=b.value,void(m.value="primary")):b.value?(c.value=b.value,void(m.value="primary")):k.value?(c.value=k.value,void(m.value="fallback")):(c.value="",m.value="failed",void(d.value=!0))),{immediate:!0}),"undefined"!=typeof window&&X([f,I],([e,n],t,o)=>{var l;if(null==(l=C.value)||l.destroy(),C.value=null,!n||M.value)return void(M.value=!0);if(!e)return void(M.value=!1);let r=!0;const i=p(e,{rootMargin:R.value,allowIdle:!1});C.value=i,M.value=i.isVisible.value,i.whenVisible.then(()=>{r&&C.value===i&&(M.value=!0)}),o(()=>{r=!1,i.destroy(),C.value===i&&(C.value=null)})},{immediate:!0}),X([O,a,d,T,()=>r.lazy,H],([e,n,t,o,l,r])=>e&&o&&!t&&r?n?(re(),void J()):l?(le(),void J()):void(n||t||le()):(re(),void J()),{flush:"post",immediate:!0}),ne(()=>{var e;null==(e=C.value)||e.destroy(),C.value=null,function(){const e=N;e&&(ee(),N="",null==h||h.markSettled(e))}()}),(n,t)=>{var o,l,i,u,s;return K(),j("span",{ref_key:"rootRef",ref:f,class:"image-node-container","data-markstream-viewport-pending":I.value&&!M.value?"true":void 0},[O.value?(K(),j("img",{key:0,src:$.value||void 0,alt:String(null!=(l=null!=(o=r.node.alt)?o:r.node.title)?l:""),title:String(null!=(u=null!=(i=r.node.title)?i:r.node.alt)?u:""),class:D(["image-node__img",{"has-placeholder":e.node.loading||W.value,"is-loading":!B.value&&!a.value,"is-loaded":B.value||a.value,"has-natural-size":a.value,"cursor-pointer":a.value}]),loading:r.lazy?"lazy":void 0,fetchpriority:B.value?"high":void 0,decoding:B.value?"sync":"async",tabindex:a.value?0:-1,"aria-label":null!=(s=r.node.alt)?s:V(se)("image.preview"),onError:ie,onLoad:ae,onClick:ue},null,42,ft)):G("",!0),!e.node.loading&&!W.value||d.value?G("",!0):(K(),j("span",vt,[r.usePlaceholder?te(n.$slots,"placeholder",{key:0,node:r.node,displaySrc:T.value,imageLoaded:a.value,hasError:d.value,fallbackSrc:r.fallbackSrc,lazy:r.lazy},()=>[t[0]||(t[0]=z("span",{class:"image-shimmer"},null,-1))],!0):(K(),j("span",ht,L(e.node.raw),1))])),E.value?(K(),j("span",pt,[te(n.$slots,"error",{node:r.node,displaySrc:T.value,imageLoaded:a.value,hasError:d.value,fallbackSrc:r.fallbackSrc,lazy:r.lazy},()=>[t[1]||(t[1]=z("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24"},[z("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)),z("span",null,L(V(se)("image.loadError")),1)],!0)])):G("",!0)],8,mt)}}}),[["__scopeId","data-v-e4e45fcb"]]);gt.install=e=>{e.component(gt.__name,gt)};const yt=le({loader:()=>Promise.resolve().then(()=>mi),suspensible:!1}),bt={key:2},kt=/* @__PURE__ */O({__name:"NodeChildRenderer",props:{node:{},components:{},customId:{},indexKey:{},fallbackToText:{type:Boolean,default:!1}},setup(e){const n=e,t=en(()=>n.customId),o=F("markstreamHtmlPolicy",void 0),l=F("markstreamNestedRendererProps",void 0),r=A(()=>{var e;return null!=(e=null==o?void 0:o.value)?e:"safe"}),i=A(()=>{var e,t;const o=null!=(e=null==l?void 0:l.value)?e:{};return u(a({},o),{customId:null!=(t=n.customId)?t:o.customId,htmlPolicy:r.value})}),s=A(()=>n.components[String(n.node.type)]),d=A(()=>Boolean(s.value&&t.value[n.node.type]&&!Ye(String(n.node.type)))),c=A(()=>d.value?kn(n.node,r.value):void 0),m=A(()=>Array.isArray(n.node.children)&&n.node.children.length>0),f=A(()=>{var e;return String(null!=(e=n.node.content)?e:"")}),v=A(()=>{var e,t;return String(null!=(t=null!=(e=n.node.content)?e:n.node.raw)?t:"")});return(n,t)=>s.value&&d.value?(K(),re(ie(s.value),ae({key:0},c.value,{node:e.node,loading:e.node.loading,"index-key":e.indexKey,"custom-id":e.customId,"is-dark":i.value.isDark,"data-markstream-reference-id":"reference"===e.node.type?String(e.node.id):void 0}),{default:ue(()=>[m.value?(K(),re(V(yt),ae({key:0},i.value,{nodes:e.node.children,"index-key":e.indexKey,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes","index-key"])):f.value?(K(),re(V(yt),ae({key:1},i.value,{content:f.value,final:!e.node.loading,"index-key":`${e.indexKey||"child"}-content`,"smooth-streaming":!1,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["content","final","index-key"])):G("",!0)]),_:1},16,["node","loading","index-key","custom-id","is-dark","data-markstream-reference-id"])):s.value?(K(),re(ie(s.value),{key:1,node:e.node,"custom-id":e.customId,"index-key":e.indexKey,"data-markstream-reference-id":"reference"===e.node.type?String(e.node.id):void 0},null,8,["node","custom-id","index-key","data-markstream-reference-id"])):e.fallbackToText?(K(),j("span",bt,L(v.value),1)):G("",!0)}}),wt=["aria-busy","aria-label","data-language","data-markstream-line-numbers"],xt={key:0,translate:"no",class:"markstream-pre__diff-code"},St={class:"markstream-pre__diff-pane-content"},Mt={key:0,class:"markstream-pre__diff-collapsed-icon","aria-hidden":"true"},Ct={class:"markstream-pre__diff-number","aria-hidden":"true"},Nt={class:"markstream-pre__diff-content"},_t={class:"markstream-pre__diff-content-inner"},Tt={key:0,translate:"no",class:"markstream-pre__code markstream-pre__code--wrapped"},Bt=["data-line-number","textContent"],It={key:0,class:"markstream-pre__line-numbers","aria-hidden":"true"},Ht=["textContent"],$t=["textContent"],Rt=/* @__PURE__ */O({__name:"PreCodeNode",props:{node:{},loading:{type:Boolean},showLineNumbers:{type:Boolean},diffInline:{type:Boolean},diffHideUnchangedRegions:{type:[Boolean,Object]},reservedHeightPx:{}},setup(e){const n=e,t=U(),o=$e();function l(e,n){const t=String(null!=e?e:"");return n?t:t.replace(/\r\n$|\n$|\r$/,"")}const r=A(()=>{var e,t,o;const l=String(null!=(t=null==(e=n.node)?void 0:e.language)?t:"");return String(null!=(o=String(l).split(/\s+/g)[0])?o:"").toLowerCase().replace(/[^\w-]/g,"")||"plaintext"}),i=A(()=>`language-${r.value}`),a=A(()=>{var e;return!0===n.loading||!0===(null==(e=n.node)?void 0:e.loading)}),u=A(()=>{var e;return l(null==(e=n.node)?void 0:e.code,a.value)});let s="",d=1;const c=A(()=>function(e){let n=0,t=1;e.startsWith(s)&&(n=s.length,t=d,n>0&&"\r"===e[n-1]&&"\n"===e[n]&&n++);for(let o=n;o<e.length;o++)"\n"===e[o]?t++:"\r"===e[o]&&(t++,"\n"===e[o+1]&&o++);return s=e,d=t,t}(u.value));let m="",f=[],v=0,h=0;const p=new RegExp("(?<=\\n)|(?<=\\r)(?!\\n)"),g=A(()=>function(e){const n=e.length>m.length&&e.startsWith(m),t=n?f:[],o=n?h:0;n&&(t.length=v);for(const r of e.slice(o).split(p))t.push(r);const l=e[e.length-1];return"\n"===l?(v=t.length,h=e.length,t.push("")):(v=t.length-1,h=e.length-t[t.length-1].length,"\r"===l&&t.push("")),m=e,f=t,t}(u.value)),y=A(()=>{var e;return!0===n.showLineNumbers&&!0===(null==(e=n.node)?void 0:e.diff)}),b=A(()=>{var e;if(D(t.class).split(/\s+/).includes("is-wrap"))return!0;const n=se(t.style);return"string"==typeof n?/(?:^|;)\s*white-space\s*:\s*(?:pre-wrap|break-spaces)(?:\s*!important)?\s*(?:;|$)/i.test(n):["pre-wrap","break-spaces"].includes(String(null!=(e=null==n?void 0:n.whiteSpace)?e:null==n?void 0:n["white-space"]))}),k=A(()=>y.value&&b.value);let w=0,x="";const S=A(()=>{const e=c.value;e<w&&(w=0,x="");for(let n=w+1;n<=e;n++)x+=`${x?"\n":""}${n}`;return w=e,x}),M=A(()=>y.value&&!0===n.diffInline),C=A(()=>{const e=Number(n.reservedHeightPx);if(!Number.isFinite(e)||e<=0)return;const t=`${Math.ceil(e)}px`;return a.value?{maxHeight:t,overflow:"auto"}:{height:t,minHeight:t,maxHeight:t,overflow:"auto"}});function N(e,n){const t=l(e,n);if(!t)return 0;let o=1;for(let l=0;l<t.length;l++)"\n"===t[l]?o++:"\r"===t[l]&&(o++,"\n"===t[l+1]&&l++);return o}const _=A(()=>{var e,t,l,r,i;return y.value?Re({code:null==(e=n.node)?void 0:e.code,hideUnchangedRegions:n.diffHideUnchangedRegions,inline:M.value,language:null==(t=n.node)?void 0:t.language,loading:a.value,matchCache:o,originalCode:null==(l=n.node)?void 0:l.originalCode,raw:null==(r=n.node)?void 0:r.raw,updatedCode:null==(i=n.node)?void 0:i.updatedCode}):[]}),T=A(()=>{const e=_.value;let n=1,t=!1;for(const o of e)for(const e of o.lines)"collapsed"===e.kind&&(t=!0),"number"==typeof e.number&&e.number>n&&(n=e.number);return{maxNumberedLine:n,hasCollapsed:t}}),B=A(()=>{var e,t;if(!0!==n.showLineNumbers)return;let o=y.value?1:c.value;y.value&&(o=Math.max(o,N(null==(e=n.node)?void 0:e.originalCode,a.value),N(null==(t=n.node)?void 0:t.updatedCode,a.value),T.value.maxNumberedLine));const l=`${Math.max(2,String(o).length)}ch`;return{"--markstream-pre-line-number-width":l,"--markstream-pre-diff-line-number-width":l,"--markstream-code-padding-left":"calc(var(--markstream-pre-line-number-padding-left, 2ch) + var(--markstream-pre-line-number-width, 2ch) + var(--markstream-pre-line-number-padding-right, 1ch) + var(--markstream-pre-line-number-separator-width, 2px) + var(--markstream-pre-line-number-gap-to-code, 1ch))"}}),I=A(()=>y.value&&T.value.hasCollapsed),H=A(()=>{const e=r.value;return e?`Code block: ${e}`:"Code block"}),$=q(null),R=q([]);let P=null,F=null,O=!1,E=null;function W(){if(O||"undefined"==typeof window||!y.value||M.value||!k.value)return;if(null!=P)return;const e=null!=F?F:F=import("./preCodeDiffMetrics.js");P=window.requestAnimationFrame(()=>{e.then(({measurePreCodeDiffLines:e})=>{!O&&$.value&&(R.value=e($.value,R.value))},()=>{F=null}).finally(()=>{P=null})})}function V(e){null==E||E.disconnect(),E=null,e&&y.value&&!M.value&&k.value&&"undefined"!=typeof ResizeObserver&&(E=new ResizeObserver(()=>{W()}),E.observe(e))}function Z(e,n){if(!k.value)return;const t=R.value[e];if(!t)return;const o="original"===n?t.originalHeight:t.modifiedHeight;return{"--markstream-pre-diff-synced-row-height":`${Math.ceil(t.rowHeight)}px`,"--markstream-pre-diff-content-height":`${Math.ceil(o)}px`}}return X($,e=>{V(e),W()},{flush:"post"}),X([y,M,_,k],()=>{V($.value),y.value&&!M.value&&k.value?W():R.value.length&&(R.value=[])},{flush:"post",immediate:!0}),ne(()=>{O=!0,null!=P&&(window.cancelAnimationFrame(P),P=null),null==E||E.disconnect(),E=null}),(e,t)=>{return K(),j("pre",{ref_key:"preRef",ref:$,style:se([C.value,B.value]),class:D([i.value,{"markstream-pre--line-numbers":n.showLineNumbers,"markstream-pre--diff-preview":y.value,"markstream-pre--diff-inline":M.value,"markstream-pre--diff-collapsed":I.value}]),"aria-busy":a.value,"aria-label":H.value,"data-language":r.value,"data-markstream-line-numbers":n.showLineNumbers?"1":void 0,"data-markstream-pre":"1",tabindex:"0"},[y.value?(K(),j("code",xt,[(K(!0),j(Y,null,J(_.value,e=>(K(),j("span",{key:e.key,class:D(["markstream-pre__diff-pane",e.className])},[z("span",St,[(K(!0),j(Y,null,J(e.lines,(n,o)=>(K(),j("span",{key:n.key,class:D(["markstream-pre__diff-line",[`markstream-pre__diff-line--${n.kind}`,n.metadataKind?`markstream-pre__diff-line--metadata-${n.metadataKind}`:"",{"markstream-pre__diff-line--empty":n.empty,"markstream-pre__diff-line--collapsed-first":!0===n.collapsedFirst,"markstream-pre__diff-line--collapsed-last":!0===n.collapsedLast}]]),style:se(Z(o,e.key))},[t[1]||(t[1]=z("span",{class:"markstream-pre__diff-rail","aria-hidden":"true"},null,-1)),"collapsed"===n.kind?(K(),j("span",Mt,[...t[0]||(t[0]=[z("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[z("path",{d:"M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06"})],-1)])])):G("",!0),z("span",Ct,L(n.number),1),z("span",Nt,[z("span",_t,L(n.code),1)])],6))),128))])],2))),128))])):(K(),j(Y,{key:1},[!0===n.showLineNumbers&&!0!==(null==(o=n.node)?void 0:o.diff)&&b.value?(K(),j("code",Tt,[(K(!0),j(Y,null,J(g.value,(e,n)=>(K(),j("span",{key:n,class:"markstream-pre__logical-line","data-line-number":n+1,textContent:L(e)},null,8,Bt))),128))])):(K(),j(Y,{key:1},[n.showLineNumbers?(K(),j("span",It,[z("span",{class:"markstream-pre__line-numbers-text",textContent:L(S.value)},null,8,Ht)])):G("",!0),z("code",{translate:"no",class:"markstream-pre__code",textContent:L(u.value)},null,8,$t)],64))],64))],14,wt);var o}}});Rt.install=e=>{e.component(Rt.__name,Rt)};const Pt=["onAnimationend"],Ft=/* @__PURE__ */an(/* @__PURE__ */O({__name:"TextNode",props:{node:{}},emits:["copy"],setup(e){const n=e,t=U(),o=F("markstreamFade",void 0),l=F("markstreamTextStreamState",void 0),r=A(()=>{const e=t.fade;return""===e||!0===e||"true"===e||!1!==e&&"false"!==e&&void 0}),i=A(()=>"boolean"==typeof r.value?r.value:"boolean"!=typeof(null==o?void 0:o.value)||o.value),a=A(()=>{var e;const n=null!=(e=t["index-key"])?e:t.indexKey;return null==n||""===n?"":String(n)}),{settledContent:u,segments:s,update:d,finish:c,settleFinished:m}=_n(n.node.content),f=q(null),v=q(null),h=q([]);let p,g="",y=null,b=null,k=!1;function w(){var e;if(!h.value.length)return!1;const n=null==(e=document.getSelection)?void 0:e.call(document);if(!n||n.isCollapsed)return!1;for(let t=0;t<n.rangeCount;t++){const e=n.getRangeAt(t);if(h.value.some(n=>e.intersectsNode(n)))return!0}return!1}function x(e){const n=a.value;d(e,n?null==l?void 0:l.get(n):void 0,i.value),n&&(null==l||l.set(n,e))}X([u,f,v],function(){var e,n;const t=f.value;if(!t)return;const o=String(null!=(e=u.value)?e:""),l=v.value;return y||(y=t.firstChild,g=null!=(n=null==y?void 0:y.data)?n:""),o.startsWith(g)?!y&&o?(t.textContent=o,y=t.firstChild,void(g=o)):void(o.length>g.length&&l&&(l.appendChild(document.createTextNode(o.slice(g.length))),g=o,function(e){var n,t;if(e.childNodes.length<=4)return;if(function(e){var n;const t=null==(n=document.getSelection)?void 0:n.call(document);if(!t||0===t.rangeCount)return!1;const{anchorNode:o,focusNode:l}=t;return null!=o&&e.contains(o)||null!=l&&e.contains(l)}(e))return;let o="";for(let l=0;l<e.childNodes.length;l++)o+=null!=(t=null==(n=e.childNodes[l])?void 0:n.textContent)?t:"";e.textContent=o}(l))):(t.textContent=o,y=t.firstChild,l&&(l.textContent=""),void(g=o))},{immediate:!0}),X([()=>n.node.content,a,i],([e])=>{const n=String(null!=e?e:"");if(w())return b=n,void C();b=null,k=!1,x(n)},{immediate:!0});const S=q(u.value);function M(){if(!w())if(N(),null!=b){const e=b;b=null,k=!1,x(e),m()}else k&&(k=!1,m())}function C(){p||(p=document,p.addEventListener("selectionchange",M))}function N(){null==p||p.removeEventListener("selectionchange",M),p=void 0}return de(N),(n,t)=>(K(),j("span",{class:D([[e.node.center?"text-node-center":""],"text-node"])},[ce(z("span",{ref_key:"settledTextEl",ref:f},L(S.value),513),[[me,""!==V(u)]]),ce(z("span",{ref_key:"settledAppendsEl",ref:v},null,512),[[me,""!==V(u)]]),(K(!0),j(Y,null,J(V(s),e=>(K(),j("span",{key:e.id,ref_for:!0,ref_key:"streamedDeltaEls",ref:h,class:"text-node-stream-delta",onAnimationend:n=>function(e){const n=w();c(e,n),n&&(k=!0,C())}(e.id)},L(e.content),41,Pt))),128))],2))}}),[["__scopeId","data-v-3be01052"]]);function At(e){var n;if("boolean"==typeof e)return e;const t=e;if(!0===(null==t?void 0:t.expandUnchanged))return!1;const o=Number(null==(n=null==t?void 0:t.parseDiffOptions)?void 0:n.context),l=Number(null==t?void 0:t.collapsedContextThreshold);return{enabled:!0,contextLineCount:isFinite(o)&&o>=0?Math.floor(o):2,minimumLineCount:isFinite(l)&&l>=0?Math.floor(l)+1:6,revealLineCount:5}}function Ot(e){return"unified"===e.diffStyle}function Kt(e){var n,t;const o=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";if(o.length<3)return"";const l=o[0];if("`"!==l&&"~"!==l||o[1]!==l||o[2]!==l)return"";let r=3;for(;o[r]===l;)r+=1;return o.slice(r).trim()}function jt(e){var n;return"diff"===(null!=(n=String(null!=e?e:"").trim().split(/\s+/,1)[0])?n:"")}function zt(e){var n;return!0===e.diff||jt(e.language)||jt(Kt(String(null!=(n=e.raw)?n:"")))}function Lt(e,n,t){const o=function(e){const n=Kt(e);if(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const o="diff"===t[0]?t.slice(1):t;for(const l of o){const e=l.includes(":")?l.slice(l.indexOf(":")+1):l;if(e&&/[./\\-]/.test(e))return e}return""}(e);return{title:o||n,caption:o?t?`Diff / ${n}`:n:""}}function Et(e){const n=String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"");return n?n.split(/\r\n|\n|\r/):[]}Ft.install=e=>{e.component(Ft.__name,Ft)};let Dt="",Wt="",Vt=null;function qt(e,n){var t;if(Vt&&Dt===e&&Wt===n)return Vt;const o=Et(e),l=Et(n);let r=0,i=o.length-1,a=l.length-1;for(;r<=i&&r<=a&&o[r]===l[r];)r++;for(;i>=r&&a>=r&&o[i]===l[a];)i--,a--;const u=Math.max(0,i-r+1),s=Math.max(0,a-r+1);let d;if(0===u||0===s)d={removed:u,added:s};else if((u+1)*(s+1)<=15e5){const e=/* @__PURE__ */new Map,n=new Uint32Array(s);for(let t=0;t<s;t++){const o=l[r+t];let i=e.get(o);void 0===i&&(i=e.size+1,e.set(o,i)),n[t]=i}const i=new Uint32Array(u);for(let l=0;l<u;l++)i[l]=null!=(t=e.get(o[r+l]))?t:0;const a=s+1;let c=new Uint32Array(a),m=new Uint32Array(a);for(let t=u-1;t>=0;t--){m[s]=0;for(let o=s-1;o>=0;o--)m[o]=i[t]===n[o]?c[o+1]+1:Math.max(c[o],m[o+1]);const e=c;c=m,m=e}const f=c[0];d={removed:u-f,added:s-f}}else d={removed:u,added:s};return Dt=e,Wt=n,Vt=d,d}function Ut(e){var n,t,o,l,r;const i=e.isDark?"dark":"light";return void 0!==e.theme?"string"==typeof e.theme?e.theme:e.theme[i]:null!=(r=e.isDark?null!=(t=e.darkTheme)?t:null==(n=e.themes)?void 0:n[0]:null!=(l=e.lightTheme)?l:null==(o=e.themes)?void 0:o[1])?r:`vitesse-${i}`}function Xt(e,n=!1){const t=e.toLowerCase();return t?/dark|night|moon|black|dracula|mocha|frappe|macchiato|ocean|poimandres|monokai|laserwave|tokyo|rose-pine|material-theme/.test(t)&&!/light|latte|dawn|lotus/.test(t):n}function Yt(e){const n=Ut(e),t="vitesse-dark"===n||"vitesse-light"!==n&&Xt(n,!0===e.isDark);if("vitesse-dark"!==n&&"vitesse-light"!==n){const e=t?"var(--markstream-code-theme-bg, #121212)":"var(--markstream-code-theme-bg, #ffffff)";return{builtin:!1,dark:t,name:n,background:e,diffAddedLine:`color-mix(in lab, ${e} ${t?"80%":"88%"}, ${t?"#4d9375":"#1e754f"})`,diffAddedNumber:`color-mix(in lab, ${e} ${t?"85%":"91%"}, ${t?"#4d9375":"#1e754f"})`,diffRemovedLine:`color-mix(in lab, ${e} ${t?"80%":"88%"}, ${t?"#cb7676":"#ab5959"})`,diffRemovedNumber:`color-mix(in lab, ${e} ${t?"85%":"91%"}, ${t?"#cb7676":"#ab5959"})`,foreground:t?"var(--markstream-code-theme-fg, #dbd7caee)":"var(--markstream-code-theme-fg, #393a34)",lineNumber:t?"var(--markstream-code-theme-line-number, #dedcd550)":"var(--markstream-code-theme-line-number, #393a3450)"}}return t?{builtin:!0,dark:!0,name:n,background:"#121212",diffAddedLine:"color-mix(in lab, #121212 80%, #4d9375)",diffAddedNumber:"color-mix(in lab, #121212 85%, #4d9375)",diffRemovedLine:"color-mix(in lab, #121212 80%, #cb7676)",diffRemovedNumber:"color-mix(in lab, #121212 85%, #cb7676)",foreground:"#dbd7caee",lineNumber:"#dedcd550"}:{builtin:!0,dark:!1,name:n,background:"#ffffff",diffAddedLine:"color-mix(in lab, #ffffff 88%, #1e754f)",diffAddedNumber:"color-mix(in lab, #ffffff 91%, #1e754f)",diffRemovedLine:"color-mix(in lab, #ffffff 88%, #ab5959)",diffRemovedNumber:"color-mix(in lab, #ffffff 91%, #ab5959)",foreground:"#393a34",lineNumber:"#393a3450"}}const Zt=12,Gt=18;function Jt(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:void 0}function Qt(e){var n,t,o,l,r,i;const a=null!=(n=Jt(null==e?void 0:e.fontSize))?n:12,u=null!=(t=Jt(null==e?void 0:e.lineHeight))?t:12===a?18:Math.max(12,Math.round(1.5*a)),s="string"==typeof(null==e?void 0:e.fontFamily)&&e.fontFamily.trim()?e.fontFamily.trim():'"SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono", "Courier New", monospace',d=null!=(o="number"==typeof(c=null==e?void 0:e.padding)&&Number.isFinite(c)&&c>=0?c:void 0)?o:8;var c;return{fontFamily:s,fontSize:a,lineHeight:u,maxHeight:null!=(l=Jt(null==e?void 0:e.maxHeight))?l:500,overflow:null!=(r=null==e?void 0:e.overflow)?r:"wrap",padding:d,paddingBottom:d,scrollbarGutter:6,tabSize:null!=(i=Jt(null==e?void 0:e.tabSize))?i:4}}function eo(e,n,t){return O({name:e,inheritAttrs:!1,setup(e,{attrs:o,slots:l}){var r,i;const s=dt(),d=at(),c=ut(),m="undefined"!=typeof window&&1===(null==(i=null==(r=Q())?void 0:r.vnode.el)?void 0:i.nodeType),f=q("undefined"==typeof window||m||!c.value),v=P(null);let h=null;function p(e){const n=e&&"$el"in e?e.$el:e;v.value=n instanceof HTMLElement?n:null}return"undefined"!=typeof window&&X([v,c],([e,n],t,o)=>{if(null==h||h.destroy(),h=null,!n||f.value)return void(f.value=!0);if(!e)return;let l=!0;const r=s(e,{rootMargin:null==d?void 0:d.value.heavyBlockMargin,allowIdle:!1});h=r,f.value=r.isVisible.value,r.whenVisible.then(()=>{l&&h===r&&(f.value=!0)}),o(()=>{l=!1,r.destroy(),h===r&&(h=null)})},{immediate:!0}),ne(()=>{null==h||h.destroy(),h=null}),()=>E(f.value?n:t,u(a({},o),{ref:p}),l)}})}const no=O({name:"CodeBlockNodeLoadingShell",inheritAttrs:!1,props:["node","isDark","loading","stream","codeBlockOptions","showLineNumbers","theme","darkTheme","lightTheme","isShowPreview","showHeader","showCopyButton","showExpandButton","showPreviewButton","showCollapseButton","showFontSizeButtons","enableFontSizeControl","minWidth","maxWidth","themes","showTooltips","htmlPreviewAllowScripts","htmlPreviewSandbox","customId","indexKey","estimatedHeightPx","estimatedContentHeightPx","estimatedDiffInline","diffInline","diffHideUnchangedRegions","reservedHeightPx"],emits:["click","mouseover","mouseout","copy","previewCode","handleArtifactClick"],setup(e,{attrs:n}){const t=e,o=$e();return()=>{var e,l,r,i,s,d,c,m,f,v,h,p;const g=null!=(e=t.codeBlockOptions)?e:{},y=Qt(g),b=Yt({darkTheme:t.darkTheme,isDark:t.isDark,lightTheme:t.lightTheme,theme:t.theme,themes:t.themes}),k=Ne(String(null!=(r=null==(l=t.node)?void 0:l.language)?r:"")),w=zt(t.node),x=Lt(String(null!=(s=null==(i=t.node)?void 0:i.raw)?s:""),_e[k]||("typescript"===k?"TypeScript":k?k.charAt(0).toUpperCase()+k.slice(1):_e[""]),w),S=w?Re({originalCode:null==(d=t.node)?void 0:d.originalCode,updatedCode:null==(c=t.node)?void 0:c.updatedCode,loading:!0,matchCache:o}).flatMap(e=>e.lines):[],M=w?{removed:S.filter(e=>"removed"===e.kind).length,added:S.filter(e=>"added"===e.kind).length}:null,C=Number(null!=(m=t.estimatedContentHeightPx)?m:t.reservedHeightPx),N=!w&&Number.isFinite(C)&&C>0?Math.min(y.maxHeight,Math.ceil(C)):void 0,_=e=>E("button",{class:`code-action-btn code-loading-action code-loading-action--${e} inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0`,"aria-hidden":"true",disabled:!0,tabindex:-1,type:"button"}),T=!1!==t.showExpandButton||!1!==t.showPreviewButton&&!1!==t.isShowPreview&&("html"===k||"svg"===k)||!1!==t.showFontSizeButtons&&!1!==t.enableFontSizeControl,B=e=>null==e?void 0:"number"==typeof e?`${e}px`:String(e),I={"--code-bg":b.background,"--code-fg":b.foreground,"--code-line-number":b.lineNumber,"--markstream-code-fallback-bg":b.background,"--markstream-code-fallback-fg":b.foreground,"--markstream-diff-added-line-fill":b.diffAddedLine,"--markstream-diff-added-number-fill":b.diffAddedNumber,"--markstream-diff-editor-bg":b.background,"--markstream-diff-metadata-bg":b.background,"--markstream-diff-metadata-fg":b.lineNumber,"--markstream-diff-removed-line-fill":b.diffRemovedLine,"--markstream-diff-removed-number-fill":b.diffRemovedNumber,"--markstream-diff-shell-bg":b.background,"--markstream-pre-resolved-theme-bg":b.background,"--markstream-pre-resolved-theme-fg":b.foreground,"--markstream-pre-resolved-theme-line-number":b.lineNumber};return E("div",u(a({},n),{class:["code-block-container rounded-lg border",{dark:!0===t.isDark,"is-dark":b.dark,"is-rendering":!1!==t.loading,"is-diff":w},n.class],style:[a(u(a({},I),{backgroundColor:b.background,color:b.foreground,minWidth:B(t.minWidth),maxWidth:B(t.maxWidth)}),w?{}:{borderColor:"var(--markstream-code-border-color, var(--code-border))"}),n.style],"data-markstream-code-block":"1","data-markstream-enhanced":"false","data-markstream-code-block-state":t.loading?"streaming":"settled","data-markstream-code-loading":"1"}),[!1===t.showHeader?null:E("div",{class:"code-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)] border-[var(--code-border)] bg-[var(--code-header-bg)] text-[var(--code-fg)]"},[E("div",{class:"code-header-main"},[E("span",{class:"icon-slot h-4 w-4 flex-shrink-0","aria-hidden":"true",innerHTML:Te(k)}),E("div",{class:"code-header-copy"},[E("div",{class:"code-header-title"},x.title),x.caption?E("div",{class:"code-header-caption"},x.caption):null])]),E("div",{class:"flex items-center gap-0.5"},[M?E("div",{class:"code-diff-stats","aria-label":`-${M.removed} +${M.added}`},[E("span",{class:"code-diff-stat removed"},`-${M.removed}`),E("span",{class:"code-diff-stat added"},`+${M.added}`)]):null,!1===t.showCopyButton?null:_("copy"),!1===t.showCollapseButton?null:_("collapse"),T?E("div",{class:"relative"},[_("more")]):null])]),E("div",{class:"code-block-shell-content",style:!1!==t.stream||!1===t.loading?void 0:{display:"none"}},[E(Rt,{node:t.node,loading:t.loading,showLineNumbers:null!=(f=t.showLineNumbers)?f:!0!==g.disableLineNumbers,diffInline:w&&Boolean(null!=(h=null!=(v=t.diffInline)?v:t.estimatedDiffInline)?h:"unified"===g.diffStyle),diffHideUnchangedRegions:w?null!=(p=t.diffHideUnchangedRegions)?p:At(g):void 0,reservedHeightPx:N,class:["code-pre-fallback",{"is-wrap":"wrap"===y.overflow}],style:u(a({},I),{"--markstream-code-padding-x":`${y.padding}px`,"--markstream-code-padding-y":`${y.padding}px`,"--markstream-code-tab-size":y.tabSize,"--markstream-pre-diff-line-height":`${y.lineHeight}px`,backgroundColor:b.background,color:b.foreground,fontFamily:y.fontFamily,fontSize:`${y.fontSize}px`,lineHeight:`${y.lineHeight}px`,maxHeight:`${null!=N?N:y.maxHeight}px`,overflow:"auto",paddingTop:`${y.padding}px`,paddingBottom:`${y.paddingBottom}px`,tabSize:y.tabSize,whiteSpace:"wrap"===y.overflow?"pre-wrap":"pre",overflowWrap:"wrap"===y.overflow?"anywhere":"normal"}),"data-markstream-code-loading":"1"})]),E("div",{class:"code-loading-placeholder",style:!1===t.stream&&!1!==t.loading?void 0:{display:"none"}},[E("div",{class:"loading-skeleton"},[E("div",{class:"skeleton-line"}),E("div",{class:"skeleton-line"}),E("div",{class:"skeleton-line short"})])])])}}}),to=le({loader:()=>import("./PreCodeBlock.js"),loadingComponent:no,delay:0,suspensible:!0}),oo=eo("ViewportDeferredCodeBlockNode",le({loader:()=>s(null,null,function*(){try{return(yield import("./CodeBlockNode.js")).default}catch(e){return console.warn('[markstream-vue] Failed to load the enhanced CodeBlockNode chunk; falling back to preformatted code rendering. Enhanced code blocks require the optional "stream-diffs" peer.',e),Rt}}),loadingComponent:no,delay:0,suspensible:!1}),no),lo=le(()=>s(null,null,function*(){var e;if("test"===(null==(e=function(){const e=Reflect.get(globalThis,"process");return null==e?void 0:e.env}())?void 0:e.NODE_ENV)&&"undefined"!=typeof window)return e=>{var n,t,o,l;return E(Ft,u(a({},e),{node:{type:"text",content:null!=(t=e.node.raw)?t:`$${null!=(n=e.node.content)?n:""}$`,raw:null!=(l=e.node.raw)?l:`$${null!=(o=e.node.content)?o:""}$`}}))};try{return yield He(),(yield import("./index6.js")).default}catch(n){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".',n)}return e=>{var n,t,o,l;return E(Ft,u(a({},e),{node:{type:"text",content:null!=(t=e.node.raw)?t:`$${null!=(n=e.node.content)?n:""}$`,raw:null!=(l=e.node.raw)?l:`$${null!=(o=e.node.content)?o:""}$`}}))}})),ro=le(()=>s(null,null,function*(){try{return yield He(),(yield import("./index5.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,o,l;return E(Ft,u(a({},e),{node:{type:"text",content:null!=(t=e.node.raw)?t:`$$${null!=(n=e.node.content)?n:""}$$`,raw:null!=(l=e.node.raw)?l:`$$${null!=(o=e.node.content)?o:""}$$`}}))}})),io=["data-reference-id","data-markstream-reference-id"],ao=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ReferenceNode",props:{node:{},messageId:{},threadId:{}},emits:["click","mouseEnter","mouseLeave"],setup:e=>(n,t)=>(K(),j("span",{class:"reference-node cursor-pointer text-xs rounded-md px-1.5 mx-0.5",role:"button",tabindex:"0","data-reference-id":e.node.id,"data-markstream-reference-id":e.node.id,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))},L(e.node.id),41,io))}),[["__scopeId","data-v-b96c91c3"]]);ao.install=e=>{e.component(ao.__name,ao)};const uo={class:"superscript-node"},so=/* @__PURE__ */an(/* @__PURE__ */O({__name:"SuperscriptNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ft,inline_code:Hn,link:wo,html_inline:Nn,strong:vo,emphasis:_o,footnote_reference:fn,strikethrough:po,highlight:Co,insert:So,subscript:mo,emoji:dn,math_inline:lo,reference:ao},t.value));return(t,l)=>(K(),j("sup",uo,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(kt),{key:`${e.indexKey||"superscript"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"superscript"}-${l}`,"fallback-to-text":""},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-24160b22"]]);so.install=e=>{e.component(so.__name,so)};const co={class:"subscript-node"},mo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"SubscriptNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ft,inline_code:Hn,link:wo,html_inline:Nn,strong:vo,emphasis:_o,footnote_reference:fn,strikethrough:po,highlight:Co,insert:So,superscript:so,emoji:dn,math_inline:lo,reference:ao},t.value));return(t,l)=>(K(),j("sub",co,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(kt),{key:`${e.indexKey||"subscript"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"subscript"}-${l}`,"fallback-to-text":""},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-197fa13b"]]);mo.install=e=>{e.component(mo.__name,mo)};const fo={class:"strong-node"},vo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"StrongNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ft,inline_code:Hn,link:wo,html_inline:Nn,emphasis:_o,strikethrough:po,highlight:Co,insert:So,subscript:mo,superscript:so,emoji:dn,footnote_reference:fn,math_inline:lo,reference:ao},t.value));return(t,l)=>(K(),j("strong",fo,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(kt),{key:`${e.indexKey||"strong"}-${l}`,components:o.value,node:t,"index-key":`${e.indexKey||"strong"}-${l}`,"custom-id":n.customId},null,8,["components","node","index-key","custom-id"]))),128))]))}}),[["__scopeId","data-v-a8647104"]]);vo.install=e=>{e.component(vo.__name,vo)};const ho={class:"strikethrough-node"},po=/* @__PURE__ */an(/* @__PURE__ */O({__name:"StrikethroughNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ft,inline_code:Hn,link:wo,html_inline:Nn,strong:vo,emphasis:_o,highlight:Co,insert:So,subscript:mo,superscript:so,emoji:dn,footnote_reference:fn,math_inline:lo,reference:ao},t.value));return(t,l)=>(K(),j("del",ho,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(kt),{key:`${e.indexKey||"strikethrough"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"strikethrough"}-${l}`},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-b7a531fa"]]);po.install=e=>{e.component(po.__name,po)};const go=["href","title","aria-label","aria-hidden","target","rel"],yo=["aria-hidden"],bo={class:"link-text-wrapper relative inline-flex"},ko={class:"leading-[normal] link-text"},wo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"LinkNode",props:{node:{},indexKey:{},customId:{},showTooltip:{type:Boolean,default:!0},color:{},underlineHeight:{},underlineBottom:{},animationDuration:{},animationOpacity:{},animationTiming:{},animationIteration:{}},setup(e){const n=e,t=F("markstreamShowTooltips",void 0),o=A(()=>{const e=null==t?void 0:t.value;return"boolean"==typeof e?e:n.showTooltip}),l=A(()=>{var e,t,o,l,r;const i=void 0!==n.underlineBottom?"number"==typeof n.underlineBottom?`${n.underlineBottom}px`:String(n.underlineBottom):"-3px",a=null!=(e=n.animationOpacity)?e:.35,u=Math.max(.12,Math.min(.5*a,a)),s={"--underline-height":`${null!=(t=n.underlineHeight)?t:2}px`,"--underline-bottom":i,"--underline-opacity":String(a),"--underline-rest-opacity":String(u),"--underline-duration":`${null!=(o=n.animationDuration)?o:1.6}s`,"--underline-timing":null!=(l=n.animationTiming)?l:"ease-in-out","--underline-iteration":"number"==typeof n.animationIteration?String(n.animationIteration):null!=(r=n.animationIteration)?r:"infinite"};return n.color&&(s["--link-color"]=n.color),s}),r=en(()=>n.customId),i=A(()=>a({text:Ft,strong:vo,strikethrough:po,emphasis:_o,image:gt,html_inline:Nn,inline_code:Hn},r.value)),u=U(),s=A(()=>{var e,t;const o=null==(e=n.node)?void 0:e.attrs;if(!o||"object"!=typeof o)return{};const l={};if(Array.isArray(o))for(const n of o)Array.isArray(n)&&n[0]&&(l[String(n[0])]=String(null!=(t=n[1])?t:""));else for(const[n,r]of Object.entries(o))n&&null!=r&&!1!==r&&(l[n]=!0===r?"":String(r));return gn(l,"safe","a")}),d=A(()=>a(a({},u),s.value)),c=A(()=>{var e,t;return gn({href:String(null!=(t=null==(e=n.node)?void 0:e.href)?t:"")},"safe","a").href}),m=A(()=>{if(!c.value)return;const e=d.value.target;return("string"==typeof e?e.trim():String(null!=e?e:"").trim())||(x(c.value)?"_blank":void 0)}),f=A(()=>{var e;return"_blank"===String(null!=(e=m.value)?e:"").trim().toLowerCase()}),v=A(()=>{if(!c.value)return;const e=d.value.rel,n=new Set(("string"==typeof e?e:String(null!=e?e:"")).split(/\s+/).filter(Boolean)),t=new Set(Array.from(n).filter(e=>"opener"!==e.toLowerCase()));return f.value&&(t.add("noopener"),t.add("noreferrer")),t.size>0?Array.from(t).join(" "):void 0}),h=A(()=>{const e=a({},d.value);return delete e.title,delete e.href,delete e.target,delete e.rel,e});function p(){o.value&&Xn()}const g=A(()=>{var e,t;const o=null==(e=n.node)?void 0:e.title;return"string"==typeof o&&o.trim().length>0?o:String(null!=(t=c.value)?t:"")});return(t,r)=>{var a,s;return e.node.loading?(K(),j("span",ae({key:1,class:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":e.node.loading?"false":"true"},V(u),{style:l.value}),[z("span",bo,[z("span",ko,[W(V(Ft),{class:"leading-[normal] link-text",node:{type:"text",content:String(null!=(a=e.node.text)?a:""),raw:String(null!=(s=e.node.text)?s:"")},"index-key":`${e.indexKey||"link-text"}-loading`},null,8,["node","index-key"])]),r[1]||(r[1]=z("span",{class:"link-loading-indicator","aria-hidden":"true"},null,-1))])],16,yo)):(K(),j("a",ae({key:0,class:"link-node",href:c.value,title:o.value?"":g.value,"aria-label":`Link: ${g.value}`,"aria-hidden":e.node.loading?"true":"false",target:m.value,rel:v.value},h.value,{style:l.value,onMouseenter:r[0]||(r[0]=e=>function(e){var t,l,r,i;if(!o.value)return;const a=e,u=null!=(null==a?void 0:a.clientX)&&null!=(null==a?void 0:a.clientY)?{x:a.clientX,y:a.clientY}:void 0,s=(null==(t=n.node)?void 0:t.title)||((null==(l=c.value)?void 0:l.includes("xn--"))&&(null==(i=null==(r=n.node)?void 0:r.text)?void 0:i.includes("://"))?n.node.text:c.value)||"";Un(e.currentTarget,s,"top",!1,u)}(e)),onMouseleave:p}),[(K(!0),j(Y,null,J(e.node.children,(t,o)=>(K(),re(V(kt),{key:`${e.indexKey||"emphasis"}-${o}`,components:i.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"link-text"}-${o}`},null,8,["components","node","custom-id","index-key"]))),128))],16,go))}}}),[["__scopeId","data-v-a414d325"]]);wo.install=e=>{e.component(wo.__name,wo)};const xo={class:"insert-node"},So=/* @__PURE__ */an(/* @__PURE__ */O({__name:"InsertNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ft,inline_code:Hn,link:wo,html_inline:Nn,strong:vo,emphasis:_o,strikethrough:po,highlight:Co,subscript:mo,superscript:so,emoji:dn,footnote_reference:fn,math_inline:lo,reference:ao},t.value));return(t,l)=>(K(),j("ins",xo,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(kt),{key:`${e.indexKey||"insert"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"insert"}-${l}`},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-1e2c29d4"]]);So.install=e=>{e.component(So.__name,So)};const Mo={class:"highlight-node"},Co=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HighlightNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ft,inline_code:Hn,link:wo,html_inline:Nn,strong:vo,emphasis:_o,strikethrough:po,insert:So,subscript:mo,superscript:so,emoji:dn,footnote_reference:fn,math_inline:lo,reference:ao},t.value));return(t,l)=>(K(),j("mark",Mo,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(kt),{key:`${e.indexKey||"highlight"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"highlight"}-${l}`},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-7a62982a"]]);Co.install=e=>{e.component(Co.__name,Co)};const No={class:"emphasis-node"},_o=/* @__PURE__ */an(/* @__PURE__ */O({__name:"EmphasisNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ft,inline_code:Hn,link:wo,html_inline:Nn,strong:vo,strikethrough:po,highlight:Co,insert:So,subscript:mo,superscript:so,emoji:dn,footnote_reference:fn,math_inline:lo,reference:ao},t.value));return(t,l)=>(K(),j("em",No,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(kt),{key:`${e.indexKey||"emphasis"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"emphasis"}-${l}`},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-2a5aafbf"]]);_o.install=e=>{e.component(_o.__name,_o)};const To={class:"hard-break"},Bo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HardBreakNode",props:{node:{}},setup:e=>(e,n)=>(K(),j("br",To))}),[["__scopeId","data-v-50c58f70"]]);Bo.install=e=>{e.component(Bo.__name,Bo)};const Io=/* @__PURE__ */O({__name:"SimpleInlineRenderer",props:{nodes:{},customId:{},indexKey:{}},setup(e){const n=e,t=fe({checkbox:un,checkbox_input:un,emoji:dn,emphasis:_o,hardbreak:Bo,highlight:Co,inline_code:Hn,insert:So,link:wo,reference:ao,strikethrough:po,strong:vo,subscript:mo,superscript:so,text:Ft}),o=en(()=>n.customId),l=A(()=>{const e=o.value;return Object.keys(e).length>0?a(a({},t),e):t});return(t,o)=>(K(!0),j(Y,null,J(e.nodes,(t,o)=>(K(),re(V(kt),{key:o,components:l.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"inline"}-${o}`},null,8,["components","node","custom-id","index-key"]))),128))}});function Ho(e){if(!e||"object"!=typeof e)return!1;const n=`|${e.type}|`;if(!"|checkbox|checkbox_input|emoji|emphasis|hardbreak|highlight|inline_code|insert|link|reference|strikethrough|strong|subscript|superscript|text|".includes(n))return!1;if(!"|emphasis|highlight|insert|link|strikethrough|strong|subscript|superscript|".includes(n))return!0;const t=e.children;return Array.isArray(t)&&t.every(Ho)}function $o(e,n=!0,t=!1){if(!e||!t&&0===e.length)return null;if(e.every(Ho))return e;if(!n||1!==e.length)return null;const o=e[0];if("paragraph"!==(null==o?void 0:o.type)||!Array.isArray(o.children))return null;const l=o.children;return(t||l.length>0)&&l.every(Ho)?l:null}function Ro(e){var n,t;if(!(null==e?void 0:e.length))return null;let o="";for(const l of e){if("text"!==(null==l?void 0:l.type)||!0===l.center)return null;o+=String(null!=(t=null!=(n=l.content)?n:l.raw)?t:"")}return o}const Po=["cite"],Fo={key:0,dir:"auto",class:"paragraph-node"},Ao=["custom-id"],Oo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"BlockquoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},fade:{type:Boolean},customId:{},showTooltips:{type:Boolean}},emits:["copy"],setup(e){const n=e,t=en(()=>n.customId),o=A(()=>Boolean(t.value.paragraph)),l=A(()=>Boolean(t.value.text)),r=A(()=>$o(n.node.children,!o.value)),i=A(()=>!1!==n.fade||l.value?null:Ro(r.value));return ee("markstreamShowTooltips",A(()=>n.showTooltips)),ee("markstreamFade",A(()=>n.fade)),(t,o)=>(K(),j("blockquote",{class:"blockquote blockquote-node",dir:"auto",cite:e.node.cite},[r.value?(K(),j("p",Fo,[null!==i.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(i.value),9,Ao)):(K(),re(V(Io),{key:1,nodes:r.value,"custom-id":n.customId,"index-key":`blockquote-${n.indexKey}-paragraph`},null,8,["nodes","custom-id","index-key"]))])):(K(),re(V(ci),{key:1,"show-tooltips":n.showTooltips,"index-key":`blockquote-${n.indexKey}`,nodes:n.node.children||[],"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))},null,8,["show-tooltips","index-key","nodes","custom-id","typewriter","fade"]))],8,Po))}}),[["__scopeId","data-v-abfecebc"]]);Oo.install=e=>{e.component(Oo.__name,Oo)};const Ko={class:"definition-list"},jo={class:"definition-term"},zo={class:"definition-desc"},Lo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"DefinitionListNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},fade:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(e,t)=>(K(),j("dl",Ko,[(K(!0),j(Y,null,J(n.node.items,(o,l)=>(K(),j(Y,{key:l},[z("dt",jo,[W(V(ci),{"index-key":`definition-term-${n.indexKey}-${l}`,nodes:o.term,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,onCopy:t[0]||(t[0]=n=>e.$emit("copy",n))},null,8,["index-key","nodes","custom-id","typewriter","fade"])]),z("dd",zo,[W(V(ci),{"index-key":`definition-desc-${n.indexKey}-${l}`,nodes:o.definition,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,onCopy:t[1]||(t[1]=n=>e.$emit("copy",n))},null,8,["index-key","nodes","custom-id","typewriter","fade"])])],64))),128))]))}}),[["__scopeId","data-v-4e103b30"]]);Lo.install=e=>{e.component(Lo.__name,Lo)};const Eo=["href","title"],Do=/* @__PURE__ */an(/* @__PURE__ */O({__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:"")}`,l=document.getElementById(o);l&&l.scrollIntoView({behavior:"smooth",block:"center"})}return(n,o)=>(K(),j("a",{class:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${e.node.id}`,title:`返回引用 ${e.node.id}`,onClick:t}," ↩︎ ",8,Eo))}}),[["__scopeId","data-v-e1eb37b6"]]);Do.install=e=>{e.component(Do.__name,Do)};const Wo=["id"],Vo={class:"flex-1"},qo=/* @__PURE__ */O({__name:"FootnoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},fade:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(t,o)=>(K(),j("div",{id:`fnref--${e.node.id}`,class:"footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border)] pt-2"},[z("div",Vo,[W(V(ci),{"index-key":`footnote-${n.indexKey}`,nodes:n.node.children,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))},null,8,["index-key","nodes","custom-id","typewriter","fade"])])],8,Wo))}});qo.install=e=>{e.component(qo.__name,qo)};const Uo=["custom-id"],Xo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HeadingNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=F("markstreamFade",void 0),l=A(()=>!1!==(null==o?void 0:o.value)||t.value.text?null:Ro(n.node.children)),r=A(()=>a({text:Ft,inline_code:Hn,link:wo,image:gt,strong:vo,emphasis:_o,strikethrough:po,highlight:Co,insert:So,subscript:mo,superscript:so,emoji:dn,checkbox:un,checkbox_input:un,footnote_reference:fn,hardbreak:Bo,math_inline:lo,reference:ao},t.value));return(t,o)=>(K(),re(ie(`h${e.node.level}`),ae({class:["heading-node",[`heading-${e.node.level}`]],dir:"auto"},e.node.attrs),{default:ue(()=>[null!==l.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(l.value),9,Uo)):(K(!0),j(Y,{key:1},J(e.node.children,(t,o)=>(K(),re(V(kt),{key:o,components:r.value,"custom-id":n.customId,node:t,"index-key":`${e.indexKey||"heading"}-${o}`},null,8,["components","custom-id","node","index-key"]))),128))]),_:1},16,["class"]))}}),[["__scopeId","data-v-7122dbe1"]]),Yo=Xo;Yo.install=e=>{e.component(Xo.__name,Xo)};const Zo={key:0,dir:"auto",class:"paragraph-node"},Go=["custom-id"],Jo={dir:"auto",class:"paragraph-node"},Qo=["custom-id"],el=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ListItemNode",props:{node:{},item:{},indexKey:{},customId:{},typewriter:{type:Boolean},fade:{type:Boolean},showTooltips:{type:Boolean},value:{},isDark:{type:Boolean}},emits:["copy"],setup(e){const n=e,t=A(()=>{var e;return null!=(e=n.node)?e:n.item}),o=en(()=>n.customId),l=A(()=>Boolean(o.value.paragraph)),r=A(()=>Boolean(o.value.text)),i=A(()=>{var e;return $o(null==(e=t.value)?void 0:e.children,!l.value)}),a=A(()=>{var e;if(l.value)return null;const n=null==(e=t.value)?void 0:e.children;if(!Array.isArray(n)||n.length<2)return null;const o=n[0];if("paragraph"!==(null==o?void 0:o.type)||!Array.isArray(o.children))return null;const r=n.slice(1);if(!r.every(e=>"list"===(null==e?void 0:e.type)))return null;const i=$o([o]);return i?{paragraphChildren:i,nestedLists:r}:null});function u(){return!1===n.fade&&!r.value}const s=A(()=>u()?Ro(i.value):null),d=A(()=>{var e;return u()?Ro(null==(e=a.value)?void 0:e.paragraphChildren):null}),c=Object.freeze({}),m=A(()=>{const{value:e}=n;return"number"==typeof e&&Number.isFinite(e)?{value:e}:c});return ee("markstreamShowTooltips",A(()=>n.showTooltips)),ee("markstreamFade",A(()=>n.fade)),(e,o)=>{var l,r;return K(),j("li",ae({class:"list-item",dir:"auto"},m.value),[i.value?(K(),j("p",Zo,[null!==s.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(s.value),9,Go)):(K(),re(V(Io),{key:1,nodes:i.value,"custom-id":n.customId,"index-key":`list-item-${n.indexKey}-paragraph`},null,8,["nodes","custom-id","index-key"]))])):a.value?(K(),j(Y,{key:1},[z("p",Jo,[null!==d.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(d.value),9,Qo)):(K(),re(V(Io),{key:1,nodes:a.value.paragraphChildren,"custom-id":n.customId,"index-key":`list-item-${n.indexKey}-paragraph`},null,8,["nodes","custom-id","index-key"]))]),(K(!0),j(Y,null,J(a.value.nestedLists,(t,l)=>(K(),re(V(ci),{key:l,nodes:[t],"custom-id":n.customId,"index-key":`list-item-${n.indexKey}-nested-${l}`,"show-tooltips":n.showTooltips,typewriter:n.typewriter,fade:n.fade,"is-dark":n.isDark,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0,onCopy:o[0]||(o[0]=n=>e.$emit("copy",n))},null,8,["nodes","custom-id","index-key","show-tooltips","typewriter","fade","is-dark"]))),128))],64)):(K(),re(V(ci),{key:2,"show-tooltips":n.showTooltips,"index-key":`list-item-${n.indexKey}`,nodes:null!=(r=null==(l=t.value)?void 0:l.children)?r:[],"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,"is-dark":n.isDark,"batch-rendering":!1,onCopy:o[1]||(o[1]=n=>e.$emit("copy",n))},null,8,["show-tooltips","index-key","nodes","custom-id","typewriter","fade","is-dark"]))],16)}}}),[["__scopeId","data-v-617214f9"]]);el.install=e=>{e.component(el.__name,el)};const nl=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ListNode",props:{node:{},customId:{},indexKey:{},typewriter:{type:Boolean},fade:{type:Boolean},showTooltips:{type:Boolean},isDark:{type:Boolean}},emits:["copy"],setup(e){const n=en(()=>e.customId),t=A(()=>n.value.list_item||el);return(n,o)=>(K(),re(ie(e.node.ordered?"ol":"ul"),{class:D(["list-node",{"list-decimal":e.node.ordered,"list-disc":!e.node.ordered}])},{default:ue(()=>[(K(!0),j(Y,null,J(e.node.items,(l,r)=>{var i;return K(),re(ie(t.value),ae({key:`${e.indexKey||"list"}-${r}`},{ref_for:!0},{showTooltips:e.showTooltips},{node:l,"custom-id":e.customId,"index-key":`${e.indexKey||"list"}-${r}`,typewriter:e.typewriter,fade:e.fade,"is-dark":e.isDark,value:e.node.ordered?(null!=(i=e.node.start)?i:1)+r:void 0,onCopy:o[0]||(o[0]=e=>n.$emit("copy",e))}),null,16,["node","custom-id","index-key","typewriter","fade","is-dark","value"])}),128))]),_:1},8,["class"]))}}),[["__scopeId","data-v-99cb95e0"]]);nl.install=e=>{e.component(nl.__name,nl)};const tl={key:2,class:"html-block-node__raw"},ol=["innerHTML"],ll={key:1,class:"html-block-node__placeholder"},rl=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HtmlBlockNode",props:{node:{},customId:{},htmlPolicy:{}},setup(e){var n;const t=e,o=F("markstreamHtmlPolicy",void 0),l=F("markstreamNestedRendererProps",void 0),r=A(()=>{var e,n;return null!=(n=null!=(e=t.htmlPolicy)?e:null==o?void 0:o.value)?n:"safe"}),i=A(()=>{var e,n;const o=null!=(e=null==l?void 0:l.value)?e:{};return u(a({},o),{customId:null!=(n=t.customId)?n:o.customId,htmlPolicy:r.value})}),d=le({loader:()=>Promise.resolve().then(()=>mi),suspensible:!1}),c=A(()=>{const e=f(t.node.attrs,r.value);if(!e)return;const n=v(e);return Object.keys(n).length>0?n:void 0}),m=A(()=>{const e=String(t.node.tag||"").trim(),n=f(t.node.attrs,r.value,e);if(!n)return;const o=v(n);return Object.keys(o).length>0?o:void 0}),h=en(()=>t.customId),p=O({name:"DynamicRenderer",props:{nodes:{type:Array,required:!0}},render(){return this.nodes}}),g=q(null);function y(e,n,t,o){if(!0!==e)return!1;const l=String(null!=n?n:"");if(!l)return!1;if(l!==String(null!=t?t:""))return!0;const r=String(null!=o?o:"").trim();return!!r&&!1===l.toLowerCase().includes(`</${r.toLowerCase()}`)}const w=q(y(t.node.loading,t.node.raw,t.node.content,t.node.tag)),x=q("undefined"==typeof window||w.value),M=q(t.node.content),C=q(0),N=q(String(null!=(n=t.node.raw)?n:"")),_=A(()=>Array.isArray(t.node.children)?t.node.children:[]);X(()=>[t.node.loading,t.node.raw,t.node.content,t.node.tag],([e,n,t,o])=>{const l=String(null!=n?n:""),r=!N.value||l.startsWith(N.value),i=y(e,n,t,o);r?i&&(w.value=!0):(w.value=i,C.value=0),i&&(x.value=!0),N.value=l},{flush:"sync"});const T=A(()=>String(t.node.tag||"div")),B=A(()=>{var e;if("details"!==T.value.trim().toLowerCase())return null;if(null==(e=t.node.attrs)?void 0:e.some(([e])=>"open"===String(e).toLowerCase()))return null;const n=_.value[0];return"html_block"===(null==n?void 0:n.type)&&"summary"===String(n.tag||"").toLowerCase()?n:null}),I=A(()=>{var e;return Ro(null==(e=B.value)?void 0:e.children)}),H=A(()=>{const e=B.value;if(!e)return;const n=f(e.attrs,r.value,"summary");if(!n)return;const t=v(n);return Object.keys(t).length>0?t:void 0}),$=A(()=>null==I.value?_.value:_.value.slice(1)),R=A(()=>{const e=T.value.trim().toLowerCase();return S.has(e)||b(e,r.value)}),E=A(()=>_.value.length>0&&!!t.node.tag&&!R.value),D=A(()=>{var e,n,o;if(E.value)return{mode:"structured"};if(!x.value)return{mode:"html",content:null!=(e=M.value)?e:""};const l=null!=(n=M.value)?n:t.node.content;if(!l)return{mode:"html",content:""};if("escape"===r.value)return{mode:"html",content:k(l,r.value)};const i=w.value||!0===t.node.loading,a=Mn(l,h.value,r.value,i);return a.ok&&(i||a.hasCustomComponents)?{mode:"dynamic",nodes:a.nodes}:i?{mode:"text",content:null!=(o=t.node.raw)?o:l}:{mode:"html",content:k(l,r.value)}}),W=dt(),U=at(),Z=ut(),J=P(null),Q=!!t.node.loading;let ee=null;return"undefined"!=typeof window?(X([()=>g.value,()=>t.node.loading,w],([e,n,o],l,r)=>{if(null==ee||ee.disconnect(),ee=null,!e||!o||!1===n||"undefined"==typeof ResizeObserver)return;const i=new ResizeObserver(e=>{var n,o;if(!w.value||!1===t.node.loading)return;const l=e[0],r=Array.isArray(null==l?void 0:l.borderBoxSize)?l.borderBoxSize[0]:null==l?void 0:l.borderBoxSize,i=null!=(o=null!=(n=null==r?void 0:r.blockSize)?n:null==l?void 0:l.contentRect.height)?o:0;i>C.value&&(C.value=i)});ee=i,i.observe(e),r(()=>i.disconnect())},{immediate:!0}),X(()=>t.node.loading,e=>s(null,null,function*(){!1!==e||!w.value||C.value<=0||(yield oe(),requestAnimationFrame(()=>{!1===t.node.loading&&(C.value=0)}))})),X([()=>g.value,()=>null==U?void 0:U.value.heavyBlockMargin,()=>null==U?void 0:U.value.rootMargin],([e],n,o)=>{var l,r,i,a;if(null==(r=null==(l=J.value)?void 0:l.destroy)||r.call(l),J.value=null,!Q)return x.value=!0,void(M.value=t.node.content);if(!e)return void(w.value||(x.value=!1));let u=!0;const s=null!=(a=null!=(i=null==U?void 0:U.value.heavyBlockMargin)?i:null==U?void 0:U.value.rootMargin)?a:it,d=W(e,{rootMargin:s,allowIdle:!Z.value});J.value=d,x.value=x.value||d.isVisible.value,d.whenVisible.then(()=>{u&&J.value===d&&(x.value=!0)}),o(()=>{u=!1,d.destroy(),J.value===d&&(J.value=null)})},{immediate:!0}),X(()=>t.node.content,e=>{Q&&!x.value||(M.value=e)})):x.value=!0,ne(()=>{var e,n;null==ee||ee.disconnect(),ee=null,null==(n=null==(e=J.value)?void 0:e.destroy)||n.call(e),J.value=null}),(n,t)=>(K(),re(ie(E.value?T.value:"div"),ae({ref_key:"htmlRef",ref:g,class:"html-block-node",style:C.value>0?{boxSizing:"border-box",minHeight:`${C.value}px`}:void 0,"data-markstream-viewport-pending":V(Z)&&!x.value?"true":void 0},E.value?m.value:void 0),{default:ue(()=>[x.value?(K(),j(Y,{key:0},["structured"===D.value.mode?(K(),j(Y,{key:0},[null!==I.value?(K(),j(Y,{key:0},[z("summary",ve(he(H.value)),L(I.value),17),$.value.length?(K(),re(V(d),ae({key:0},i.value,{nodes:$.value,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes"])):G("",!0)],64)):(K(),re(V(d),ae({key:1},i.value,{nodes:_.value,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes"]))],64)):"dynamic"===D.value.mode?(K(),re(V(p),{key:1,nodes:D.value.nodes},null,8,["nodes"])):"text"===D.value.mode?(K(),j("pre",tl,L(D.value.content),1)):(K(),j("div",ae({key:3},c.value,{innerHTML:D.value.content}),null,16,ol))],64)):(K(),j("div",ll,[te(n.$slots,"placeholder",{node:e.node},()=>[t[0]||(t[0]=z("span",{class:"html-block-node__placeholder-bar"},null,-1)),t[1]||(t[1]=z("span",{class:"html-block-node__placeholder-bar w-4/5"},null,-1)),t[2]||(t[2]=z("span",{class:"html-block-node__placeholder-bar w-2/3"},null,-1))],!0)]))]),_:3},16,["style","data-markstream-viewport-pending"]))}}),[["__scopeId","data-v-08559f85"]]);rl.install=e=>{e.component(rl.__name,rl)};const il={dir:"auto",class:"paragraph-node"},al=["custom-id"],ul=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ParagraphNode",props:{node:{},customId:{},indexKey:{},customHtmlTags:{},parseOptions:{},customMarkdownIt:{type:Function}},setup(e){const n=e,t=en(()=>n.customId),o=F("markstreamHtmlPolicy",void 0),l=F("markstreamFade",void 0),r=F("markstreamParseOptions",void 0),i=F("markstreamCustomMarkdownIt",void 0),s=F("markstreamNestedRendererProps",void 0),d=A(()=>{var e;return null!=(e=null==o?void 0:o.value)?e:"safe"}),c=A(()=>{var e;return null!=(e=n.parseOptions)?e:null==r?void 0:r.value}),m=A(()=>{var e;return null!=(e=n.customMarkdownIt)?e:null==i?void 0:i.value}),f=A(()=>{var e,t;return null!=(t=n.customHtmlTags)?t:null==(e=null==s?void 0:s.value)?void 0:e.customHtmlTags}),v=A(()=>{var e,t;const o=null!=(e=null==s?void 0:s.value)?e:{};return u(a({},o),{customId:null!=(t=n.customId)?t:o.customId,customHtmlTags:f.value,parseOptions:c.value,customMarkdownIt:m.value,htmlPolicy:d.value})});function h(e){var n;return"text"===e.type&&""===String(null!=(n=e.content)?n:"").trim()}const p=A(()=>n.node.children.filter(e=>!h(e))),g=A(()=>p.value.length>0&&p.value.every(e=>"image"===e.type||function(e){var n;const t=function(e){return"link"===e.type&&Array.isArray(e.children)?e.children.filter(e=>!h(e)):[]}(e);return 1===t.length&&"image"===(null==(n=t[0])?void 0:n.type)}(e))),y=A(()=>new Set(M(f.value))),b=A(()=>{if(!g.value||p.value.length<=1)return n.node.children;const e=[];for(let t=0;t<n.node.children.length;t++){const o=n.node.children[t];if(!h(o)){e.push(o);continue}const l=e.length>0,r=n.node.children.slice(t+1).some(e=>!h(e));l&&r&&e.push(u(a({},o),{content:" ",raw:" "}))}return e}),k=A(()=>!1===(null==l?void 0:l.value)&&!t.value.text),w=A(()=>k.value?Ro(b.value):null);function x(e,t){return a({node:e,"index-key":`${n.indexKey}-${t}`,"custom-id":n.customId,"custom-html-tags":f.value},"reference"===e.type?{"data-markstream-reference-id":String(e.id)}:{})}function S(e){var n,o;const l=e,r=String(l.type);if(t.value[r])return null;const i=function(e){if(!Array.isArray(e))return"";const n=[];for(const t of e){if(!t||"object"!=typeof t)return null;const e=S(t);if(null==e)return null;n.push(e)}return n.join("")}(l.children);if(null==i)return null;const a=[r,l.loading,i];switch(r){case"text":return[...a,l.content,l.center].join("");case"inline_code":return[...a,l.code].join("");case"image":return[...a,l.src,l.alt,l.title].join("");case"link":return[...a,l.href,l.title,l.text,JSON.stringify(null!=(n=l.attrs)?n:null)].join("");case"html_inline":case"html_block":return[...a,l.tag,l.content,l.autoClosed,JSON.stringify(null!=(o=l.attrs)?o:null)].join("");case"emoji":return[...a,l.name,l.markup].join("");case"checkbox":case"checkbox_input":return[...a,l.checked].join("");case"math_inline":return[...a,l.content,l.markup].join("");case"reference":case"footnote_anchor":case"footnote_reference":return[...a,l.id].join("");case"hardbreak":case"emphasis":case"strong":case"strikethrough":case"highlight":case"insert":case"subscript":case"superscript":return a.join("");default:return null}}const _=/* @__PURE__ */new Map,T=A(()=>a({inline_code:Hn,image:gt,link:wo,hardbreak:Bo,emphasis:_o,strong:vo,strikethrough:po,highlight:Co,insert:So,subscript:mo,superscript:so,html_inline:Nn,html_block:rl,emoji:dn,checkbox:un,math_inline:lo,checkbox_input:un,reference:ao,footnote_anchor:Do,footnote_reference:fn,text:Ft},t.value)),B=A(()=>{const e=b.value;if(_.size>e.length)for(const n of _.keys())n>=e.length&&_.delete(n);return e.map((e,o)=>{var l;const r=S(e),i=_.get(o),s=null!=r&&(null==i?void 0:i.sig)===r?i.child:e;null==r?_.delete(o):_.set(o,{child:s,sig:r});const c=function(e){var n,o,l,r;if("html_block"===e.type||"html_inline"===e.type){const t=String(null!=(n=e.tag)?n:"").trim().toLowerCase()||C(e.content);if(t&&!y.value.has(t)&&N(null!=(o=e.content)?o:e.raw,t)){const n=String(null!=(r=null!=(l=e.content)?l:e.raw)?r:"");return{child:{type:"text",content:n,raw:n},component:Ft,isCustomComponent:!1}}}return{child:e,component:T.value[e.type],isCustomComponent:Boolean(t.value[e.type]&&!Ye(String(e.type)))}}(s);return u(a({},c),{index:o,key:`${n.indexKey||"paragraph"}-${o}`,customAttrs:c.isCustomComponent?kn(c.child,d.value):void 0,hasSlotChildren:Array.isArray(c.child.children)&&c.child.children.length>0,slotContent:String(null!=(l=c.child.content)?l:""),originalChild:s})})});return(e,t)=>(K(),j("p",il,[null!==w.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(w.value),9,al)):(K(!0),j(Y,{key:1},J(B.value,e=>{return K(),j(Y,{key:e.key},[g.value&&h(e.originalChild)?(K(),j(Y,{key:0},[Z(L((t=e.originalChild,String(null!=(o=t.content)?o:""))),1)],64)):e.isCustomComponent?(K(),re(ie(e.component),ae({key:1,ref_for:!0},e.customAttrs,{node:e.child,loading:e.child.loading,"index-key":e.key,"custom-id":n.customId,"custom-html-tags":f.value,"is-dark":v.value.isDark}),{default:ue(()=>[e.hasSlotChildren?(K(),re(V(yt),ae({key:0,ref_for:!0},v.value,{nodes:e.child.children,"index-key":e.key,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes","index-key"])):e.slotContent?(K(),re(V(yt),ae({key:1,ref_for:!0},v.value,{content:e.slotContent,final:!e.child.loading,"index-key":`${e.key}-content`,"smooth-streaming":!1,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["content","final","index-key"])):G("",!0)]),_:2},1040,["node","loading","index-key","custom-id","custom-html-tags","is-dark"])):(K(),re(ie(e.component),ae({key:2,ref_for:!0},x(e.child,e.index)),null,16))],64);var t,o}),128))]))}}),[["__scopeId","data-v-0498f5d7"]]);ul.install=e=>{e.component(ul.__name,ul)};const sl={class:"table-node-wrapper"},dl=["aria-busy"],cl={key:0},ml=["custom-id"],fl=["aria-label","onPointerdown"],vl=["custom-id"],hl={key:0,class:"table-node__loading",role:"status","aria-live":"polite"},pl=/* @__PURE__ */an(/* @__PURE__ */O({__name:"TableNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},fade:{type:Boolean},customId:{},showTooltips:{type:Boolean}},emits:["copy"],setup(e){const n=e,t=A(()=>{var e;return null!=(e=n.node.loading)&&e}),o=A(()=>{var e;return null!=(e=n.node.rows)?e:[]}),l=q(null),r=q([]);let i=null;const a=A(()=>n.node.header.cells.length),u=A(()=>r.value.some(e=>Number.isFinite(e)&&e>0)),s=A(()=>u.value?r.value.map(e=>e>0?{width:`${e}px`}:void 0):[]);ee("markstreamShowTooltips",A(()=>n.showTooltips)),ee("markstreamFade",A(()=>n.fade));const d=en(()=>n.customId),c=A(()=>Boolean(d.value.text)),m=A(()=>Boolean(d.value.paragraph)),f=/* @__PURE__ */new WeakMap;function v(e){const t=!1===n.fade&&!c.value,o=!m.value,l=f.get(e);if((null==l?void 0:l.children)===e.children&&l.textFastPath===t&&l.paragraphFastPath===o)return l.info;const r=$o(e.children,o,!0),i={simpleChildren:r,plainText:r&&t?Ro(r):null};return f.set(e,{children:e.children,textFastPath:t,paragraphFastPath:o,info:i}),i}function h(e){if(!i)return;e.preventDefault();const n=i.startWidth+i.nextStartWidth,t=Math.min(48,Math.floor(n/2)),o=Math.max(t,Math.min(n-t,Math.round(i.startWidth+e.clientX-i.startX))),l=[...i.widths];l[i.index]=o,l[i.index+1]=n-o,r.value=l}function p(){i&&(window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),i=null)}return X(a,()=>{p(),r.value=[]}),ne(p),(a,d)=>(K(),j("div",sl,[z("table",{ref_key:"tableRef",ref:l,class:D(["table-node",{"table-node--loading":t.value}]),"aria-busy":t.value},[u.value?(K(),j("colgroup",cl,[(K(!0),j(Y,null,J(e.node.header.cells,(e,n)=>(K(),j("col",{key:n,style:se(s.value[n])},null,4))),128))])):G("",!0),z("thead",null,[z("tr",null,[(K(!0),j(Y,null,J(e.node.header.cells,(t,o)=>(K(),j("th",{key:o,dir:"auto",class:D(["right"===t.align?"text-right":"center"===t.align?"text-center":"text-left"])},[null!==v(t).plainText?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(v(t).plainText),9,ml)):v(t).simpleChildren?(K(),re(V(Io),{key:1,nodes:v(t).simpleChildren,"custom-id":n.customId,"index-key":`table-th-${n.indexKey}-${o}`},null,8,["nodes","custom-id","index-key"])):(K(),re(V(ci),{key:2,nodes:t.children,"index-key":`table-th-${n.indexKey}`,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,"show-tooltips":n.showTooltips,onCopy:d[0]||(d[0]=e=>a.$emit("copy",e))},null,8,["nodes","index-key","custom-id","typewriter","fade","show-tooltips"])),o<e.node.header.cells.length-1?(K(),j("button",{key:3,type:"button",class:"table-node__resize-handle","aria-label":`Resize columns ${o+1} and ${o+2}`,onPointerdown:e=>function(e,n){if(0!==n.button)return;const t=function(){var e;const n=null==(e=l.value)?void 0:e.querySelectorAll("thead th");return Array.from(null!=n?n:[],e=>Math.round(e.getBoundingClientRect().width))}(),o=t[e],a=t[e+1];o&&a&&(n.preventDefault(),i={index:e,startX:n.clientX,startWidth:o,nextStartWidth:a,widths:t},r.value=t,window.addEventListener("pointermove",h),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p))}(o,e)},null,40,fl)):G("",!0)],2))),128))])]),z("tbody",null,[(K(!0),j(Y,null,J(o.value,(e,t)=>(K(),j("tr",{key:t},[(K(!0),j(Y,null,J(e.cells,(e,o)=>(K(),j("td",{key:o,class:D(["right"===e.align?"text-right":"center"===e.align?"text-center":"text-left"]),dir:"auto"},[null!==v(e).plainText?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(v(e).plainText),9,vl)):v(e).simpleChildren?(K(),re(V(Io),{key:1,nodes:v(e).simpleChildren,"custom-id":n.customId,"index-key":`table-td-${n.indexKey}-${t}-${o}`},null,8,["nodes","custom-id","index-key"])):(K(),re(V(ci),{key:2,nodes:e.children,"index-key":`table-td-${n.indexKey}`,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,"show-tooltips":n.showTooltips,onCopy:d[1]||(d[1]=e=>a.$emit("copy",e))},null,8,["nodes","index-key","custom-id","typewriter","fade","show-tooltips"]))],2))),128))]))),128))])],10,dl),W(pe,{name:"table-node-fade"},{default:ue(()=>[t.value?(K(),j("div",hl,[te(a.$slots,"loading",{isLoading:t.value},()=>[d[2]||(d[2]=z("span",{class:"table-node__spinner animate-spin","aria-hidden":"true"},null,-1)),d[3]||(d[3]=z("span",{class:"sr-only"},"Loading",-1))],!0)])):G("",!0)]),_:3})]))}}),[["__scopeId","data-v-cd7fd3ec"]]);pl.install=e=>{e.component(pl.__name,pl)};const gl={class:"hr-node"},yl=/* @__PURE__ */an({},[["render",function(e,n){return K(),j("hr",gl)}],["__scopeId","data-v-39b2349c"]]);yl.install=e=>{e.component(yl.__name,yl)};const bl={class:"unknown-node"},kl=/* @__PURE__ */O({__name:"FallbackComponent",props:{node:{}},setup:e=>(n,t)=>(K(),j("div",bl,L(e.node.raw),1))}),wl=/* @__PURE__ */an(/* @__PURE__ */O({__name:"VmrContainerNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},fade:{type:Boolean},customId:{}},setup(e){const n=e,t=A(()=>`vmr-container vmr-container-${n.node.name}`),o=en(()=>n.customId),l=A(()=>a({text:Ft,paragraph:ul,heading:Yo,inline_code:Hn,link:wo,image:gt,strong:vo,emphasis:_o,strikethrough:po,insert:So,subscript:mo,superscript:so,checkbox:un,checkbox_input:un,hardbreak:Bo,math_inline:lo,reference:ao,list:nl,math_block:ro,table:pl},o.value));return(o,r)=>(K(),j("div",ae({class:t.value},e.node.attrs),[(K(!0),j(Y,null,J(e.node.children,(t,o)=>{return K(),re(ie((r=t.type,l.value[r]||kl)),{key:`${e.indexKey||"vmr-container"}-${o}`,"custom-id":n.customId,node:t,"index-key":`${e.indexKey||"vmr-container"}-${o}`,typewriter:n.typewriter,fade:n.fade,"data-markstream-reference-id":"reference"===t.type?String(t.id):void 0},null,8,["custom-id","node","index-key","typewriter","fade","data-markstream-reference-id"]);var r}),128))],16))}}),[["__scopeId","data-v-672fe0a7"]]);wl.install=e=>{e.component(wl.__name,wl)};const xl="__MARKSTREAM_VUE_HEIGHT_ESTIMATION_EXPERIMENT__",Sl=["diff ","index ","--- ","+++ ","@@ "],Ml=(()=>{const e=globalThis;if(e[xl])return e[xl];const n={configs:{},controllers:{},revision:P(0),preparedCache:/* @__PURE__ */new Map,blockEstimateCache:/* @__PURE__ */new Map};return e[xl]=n,n})();let Cl=null,Nl=null,_l=null;function Tl(){return Nl||"undefined"==typeof window?null:(_l||(_l=import("./layout.js").then(e=>(Nl=e,Ml.revision.value++,e)).catch(()=>null)),_l.then(()=>{}))}const Bl=Ml.revision;function Il(e){var n;return e&&null!=(n=Ml.configs[e])?n:null}function Hl(e,n){const t=Number.parseFloat(String(null!=e?e:""));return Number.isFinite(t)&&t>0?t:n}function $l(e){return"text"===(null==e?void 0:e.type)||"emoji"===(null==e?void 0:e.type)||"hardbreak"===(null==e?void 0:e.type)}function Rl(e){var n,t,o;if(!Array.isArray(e)||0===e.length)return null;let l="";for(const r of e){if(!$l(r))return null;"text"===r.type?l+=String(null!=(n=r.content)?n:""):"emoji"===r.type?l+=String(null!=(o=null!=(t=r.name)?t:r.raw)?o:""):"hardbreak"===r.type&&(l+="\n")}return l.length>0?l:null}function Pl(e,n,t){var o,l;if(!e||!Number.isFinite(n)||n<=0||!function(){var e;if(null!=Cl)return Cl;if("undefined"==typeof document)return!1;try{const n=document.createElement("canvas");return Cl=!!(null==(e=n.getContext)?void 0:e.call(n,"2d")),Cl}catch(n){return Cl=!1,!1}}())return null;const r=Nl;if(!r)return Tl(),null;try{const i=Math.round(100*n)/100,a=[null!=(o=t.whiteSpace)?o:"pre-wrap",t.font,t.lineHeight,t.wrapperOverhead,t.widthAdjustment,i,e].join("\0"),u=Ml.blockEstimateCache.get(a);if(u)return Ml.blockEstimateCache.delete(a),Ml.blockEstimateCache.set(a,u),{kind:"simple-text",height:u.height,contentHeight:u.contentHeight};const s=null!=(l=t.whiteSpace)?l:"pre-wrap",d=function(e,n,t,o){const l=`${o}\0${t}\0${n}`,r=Ml.preparedCache.get(l);if(r)return Ml.preparedCache.delete(l),Ml.preparedCache.set(l,r),r.prepared;const i=e.prepare(n,t,{whiteSpace:o});for(Ml.preparedCache.set(l,{prepared:i});Ml.preparedCache.size>240;){const e=Ml.preparedCache.keys().next().value;if(!e)break;Ml.preparedCache.delete(e)}return i}(r,e,t.font,s),c=Math.max(24,i-t.widthAdjustment),m=r.layout(d,c,t.lineHeight),f=Math.max(t.lineHeight,m.height),v=Math.max(t.lineHeight,Math.round(f+t.wrapperOverhead));for(Ml.blockEstimateCache.set(a,{height:v,contentHeight:Math.round(f)});Ml.blockEstimateCache.size>4e3;){const e=Ml.blockEstimateCache.keys().next().value;if(!e)break;Ml.blockEstimateCache.delete(e)}return{kind:"simple-text",height:v,contentHeight:Math.round(f)}}catch(i){return null}}function Fl(e,n,t){var o,l;if(!t||!e||!Number.isFinite(n)||n<=0)return null;if("paragraph"===e.type){const o=Rl(e.children);return o&&t.paragraph?Pl(o,n,t.paragraph):null}if("heading"===e.type){const o=Number(e.level||0),l=Rl(e.children),r=t.headings[o];return l&&r?Pl(l,n,r):null}if("list_item"===e.type){const r=Array.isArray(e.children)?e.children:[];if(1!==r.length||"paragraph"!==(null==(o=r[0])?void 0:o.type)||!t.listItem)return null;const i=Rl(null==(l=r[0])?void 0:l.children);return i?Pl(i,n,t.listItem):null}if("list"===e.type){const o=Array.isArray(e.items)?e.items:[];if(!o.length)return null;let l=Math.max(0,t.listWrapperOverhead);for(const e of o){const o=Fl(e,n,t);if(!o)return null;l+=o.height}return{kind:"simple-text",height:Math.max(1,Math.round(l)),contentHeight:Math.max(1,Math.round(l))}}return null}function Al(e){if(!e)return 1;const n=String(e).split(/\r\n|\n|\r/);return Math.max(1,n.length)}function Ol(e,n){const t=String(null!=e?e:"");return n?t:t.replace(/\r\n$|\n$|\r$/,"")}function Kl(e,n){return e.diff?Ot({diffStyle:n})?function(e){const n=Ol(e.raw);if(n){const t=n.split(/\r?\n/);return null!=e.originalCode||null!=e.updatedCode?Math.max(1,t.filter(e=>!Sl.some(n=>e.startsWith(n))).length):Math.max(1,t.length)}return Al(Ol(e.originalCode))+Al(Ol(e.updatedCode))}(e):function(e){const n=e.originalCode,t=e.updatedCode;if(null!=n||null!=t)return Math.max(Al(Ol(n)),Al(Ol(t)));const o=Ol(e.code).split(/\r?\n/);let l=0,r=0;for(const i of o)i.startsWith("+")&&!i.startsWith("+++")?r++:i.startsWith("-")&&!i.startsWith("---")?l++:(l++,r++);return Math.max(1,l,r)}(e):Al(Ol(e.code,!0===e.loading))}function jl(e,n,t){return Math.max(1,Math.ceil(function(e,n){let t=0;for(const o of e)t+="\t"===o?n-t%n:o>="ᄀ"?2:1;return t}(e,t)/n))}function zl(e,n,t,o,l,r){var i,a,u;const s=e/(r?2:1),d=null==(null==(i=l.codeBlockOptions)?void 0:i.padding)?n:o.padding,c=null!=(u=l.showLineNumbers)?u:!0!==(null==(a=l.codeBlockOptions)?void 0:a.disableLineNumbers),m=Math.max(2,String(Math.max(1,t)).length)*n,f=c?3*n+m+2:0;return Math.max(1,Math.floor((s-f-2*d)/n))}function Ll(e){return e?`${e.fontStyle||"normal"} ${e.fontWeight||"400"} ${e.fontSize||"16px"} ${e.fontFamily||"sans-serif"}`:""}function El(e,n,t="pre-wrap"){if(!e||!n||"undefined"==typeof window)return null;const o=window.getComputedStyle(n),l=e.offsetHeight,r=Hl(o.lineHeight,1.5*Hl(o.fontSize,16)),i=e.getBoundingClientRect().width,a=n.getBoundingClientRect().width;return{font:Ll(o),lineHeight:r,wrapperOverhead:Math.max(0,l-r),widthAdjustment:Math.max(0,i-a),whiteSpace:t}}const Dl=/* @__PURE__ */new Set(["node","key","ref","ctx","renderNode","indexKey","__proto__","prototype","constructor"]);function Wl(e,n={}){var t;const o={},l=new Set(null!=(t=n.omit)?t:[]);if(!e||"object"!=typeof e)return o;const r=Object.getOwnPropertyDescriptors(e);for(const[i,a]of Object.entries(r))Dl.has(i)||l.has(i)||a.enumerable&&"value"in a&&(o[i]=a.value);return o}function Vl(e,n){const t=n.trim().toLowerCase();if(t)for(const o of[t,Ne(t),Pe(t),"d2lang"===t?"d2":""]){const n=o&&e[o];if(n)return n}}const ql=!1;function Ul(e,n,t,o){var l;const r=function(e){return Math.max(0,Math.ceil(e.scrollHeight||0)-Math.ceil(e.clientHeight||0))}(e),i=function(e,n){return Number.isFinite(e)?Math.min(Math.max(0,e),n):0}(t,r);if(!o.isReverseFlexScrollRoot(e))return void(e.scrollTop=i);const a=Math.max(0,r-i),u=[-a,a];let s=u[0],d=Number.POSITIVE_INFINITY;for(const m of u){e.scrollTop=m;const t=o.getNormalizedScrollTop(e,n,!1),l=Math.abs(t-i);l<d&&(d=l,s=m)}e.scrollTop=s;const c=null!=(l=o.epsilonPx)?l:2;Math.abs(o.getNormalizedScrollTop(e,n,!1)-i)>c&&(e.scrollTop=s)}function Xl(e,n){let t=0,o=null,l=null;const r=()=>{const n=l;l=null,o=null,n&&(t=Date.now(),e(...n))};return function(...i){const a=Date.now(),u=n-(a-t);l=i,u<=0?(o&&(clearTimeout(o),o=null),t=a,l=null,e(...i)):o||(o=setTimeout(r,u))}}function Yl(e){return"simple"===e?"simple":!0===e||"true"===e||"precise"===e?"precise":"off"}function Zl(e){return"off"!==Yl(e)}const Gl=/* @__PURE__ */Symbol("MarkstreamMathBlockMinHeightCache");function Jl(){return F(Gl,null)}const Ql=/* @__PURE__ */new Set(["text","inline_code","emoji","footnote_reference"]),er=/* @__PURE__ */new Set(["strong","emphasis","strikethrough","highlight","insert","subscript","superscript","link"]);function nr(e){const n=Number(e);return!Number.isFinite(n)||n<=0?-1:Math.round(n/32)}function tr(e,n,t,o=22){const l=String(null!=e?e:"");if(!l)return t;const r=Math.max(18,Math.floor(Math.max(320,n)/8)),i=l.split(/\r?\n/).length,a=Math.ceil(l.length/r),u=Math.max(1,i,a);return Math.max(t,Math.ceil(u*o+12))}function or(e){var n;if(!e||"object"!=typeof e)return!1;const t=e,o=String(null!=(n=t.type)?n:"");if(Ql.has(o))return!0;if(!er.has(o))return!1;const l=t.children;return!Array.isArray(l)||!l.length||l.every(or)}function lr(e){var n,t,o,l,r,i,a,u;if(!e||"object"!=typeof e)return"";const s=e,d=String(null!=(n=s.type)?n:"");if("text"===d)return String(null!=(o=null!=(t=s.content)?t:s.raw)?o:"");if("inline_code"===d)return String(null!=(i=null!=(r=null!=(l=s.code)?l:s.content)?r:s.raw)?i:"");if("emoji"===d)return String(null!=(u=null!=(a=s.name)?a:s.raw)?u:"");if("string"==typeof s.text)return s.text;const c=[];for(const m of["children","items","cells","rows"]){const e=s[m];if(Array.isArray(e)){const n=e.map(lr).filter(Boolean).join(" ");n&&c.push(n)}}return c.join(" ").replace(/\s+/g," ").trim()}function rr(e){if(!e||"object"!=typeof e)return!1;const n=e;return"inline_code"===n.type||["children","items","cells","rows"].some(e=>{const t=n[e];return Array.isArray(t)&&t.some(rr)})}function ir(e,n){if(!e)return 30;const t=Math.max(18,Math.floor(Math.max(320,n)/8)),o=e.split(/\r?\n/).length,l=Math.ceil(e.length/t),r=Math.max(1,o,l);return 30+26*Math.max(0,r-1)}function ar(e,n){var t,o,l,r,i,a,u,s,d,c,m,f,v,h;if(!e||"object"!=typeof e)return 32;const p=e,g=String(null!=(t=p.type)?t:""),y=Number.isFinite(n)&&n>0?n:640;switch(g){case"heading":return function(e){var n;const t=Number(null!=(n=e.level)?n:e.depth);return t>=4?20:3===t?30:2===t?32:44}(p);case"paragraph":return function(e,n){const t=String(null!=e?e:"");if(!t)return 28;const o=Math.max(18,Math.floor(Math.max(320,n)/8)),l=t.split(/\r?\n/).length,r=Math.ceil(t.length/o);return Math.max(1,l,r)<=1?28:tr(t,n,34)}(String(null!=(l=null!=(o=p.raw)?o:p.content)?l:""),y);case"list":return function(e,n){var t;const o=Array.isArray(e.items)?e.items:[];if(!o.length)return 48;const l=Math.max(48,30*o.length+12);let r=12;for(const u of o)r+=ir(lr(u)||String(null!=(t=u.raw)?t:""),n);const i=Math.max(0,r-l);if(o.length>20){const e=Math.round(2.4*o.length);return Math.round(l+Math.max(e,Math.min(i,3*o.length)))}if(i<=0)return l;const a=o.length>8?8*o.length:i;return Math.round(l+Math.min(i,a))}(p,y);case"list_item":return tr(String(null!=(i=null!=(r=p.raw)?r:p.content)?i:""),y,34);case"blockquote":return tr(String(null!=(u=null!=(a=p.raw)?a:p.content)?u:""),y,56);case"table":return function(e,n){const t=[...e.header?[e.header]:[],...Array.isArray(e.rows)?e.rows:[]];if(!t.length){const n=Array.isArray(e.children)?e.children.length:3;return Math.max(120,38*n+48)}return Math.max(120,Math.round(4+t.reduce((e,t)=>e+function(e,n){const t=Math.max(1,e.length),o=Math.max(80,(n-32)/t),l=Math.max(10,Math.floor(o/8)),r=Math.max(1,...e.map(e=>{var n;const t=lr(e)||String(null!=(n=null==e?void 0:e.raw)?n:"");return Math.ceil(t.length/l)||1}));return 54+34*Math.max(0,r-1)+(t<=3&&e.some(rr)?14:0)}(function(e){var n;return Array.isArray(null==e?void 0:e.cells)&&null!=(n=e.cells)?n:[]}(t),n),0)))}(p,y);case"code_block":{const e=String(null!=(s=p.language)?s:"").trim().toLowerCase(),n=String(null!=(c=null!=(d=p.code)?d:p.raw)?c:"");return"mermaid"===e?Ae(Oe(n)):"infographic"===e?Ke(je(n)):tr(n,y,96,20)}case"math_block":return 72;case"image":return 220;case"admonition":case"vmr_container":case"html_block":return function(e,n){var t,o,l;const r=e.match(/^\s*<details\b([^>]*)>/i);return r&&!/(?:^|\s)open(?:\s|=|$)/i.test(null!=(t=r[1])?t:"")?tr((null==(l=null==(o=e.match(/<summary\b[^>]*>([\s\S]*?)<\/summary>/i))?void 0:o[1])?void 0:l.replace(/<[^>]*>/g,"").trim())||"Details",n,28,28):tr(e,n,96)}(String(null!=(f=null!=(m=p.raw)?m:p.content)?f:""),y);case"thematic_break":return 24;default:return tr(String(null!=(h=null!=(v=p.raw)?v:p.content)?h:""),y,40)}}function ur(e,n,t){return Math.min(Math.max(e,n),t)}const sr=/* @__PURE__ */new WeakMap;function dr(e,n,t){var o;const l=e;if(t.has(l))return t.get(l);const r=String(e.type).trim().toLowerCase();if(n[r])return t.set(l,!0),!0;if("code_block"===r){const r=String(null!=(o=e.language)?o:"").trim().toLowerCase();if(r&&Vl(n,r))return t.set(l,!0),!0}const i=e;t.set(l,!1);const a=Object.values(i).some(e=>Array.isArray(e)?e.some(e=>Nr(e)&&dr(e,n,t)):Nr(e)&&dr(e,n,t));return t.set(l,a),a}const cr=["total","cacheHits","appendHits","tailHits","fullParses","chunkedParses"],mr=["tokenCloneMs","processTokensInputTokens","processTokensReusedTopLevelNodes","processTokensMs","safeMarkdownMs","tokenizeMs","htmlBlockPassesMs","parseMarkdownToStructureTotalMs"],fr=/* @__PURE__ */new Set(["attrs","data","items","header","payload","props","rows","cells","term","definition","sourceMap"]),vr=["raw","content","code","originalCode","updatedCode"],hr=/* @__PURE__ */new WeakMap,pr=/* @__PURE__ */new WeakMap;let gr=1;function yr(){return"undefined"!=typeof performance?performance.now():Date.now()}function br(e){const n=e.stream;return n&&"function"==typeof n.stats?n.stats():null}function kr(e){if("object"!=typeof e&&"function"!=typeof e||null===e)return"";const n=e;let t=hr.get(n);return t||(t=gr++,hr.set(n,t)),String(t)}function wr(e,n,t,o={}){var l,r;const i=!1!==o.includeFinal,a={md:kr(n),customMarkdownIt:kr(t),requireClosingStrong:!0===e.requireClosingStrong,customHtmlTags:null!=(l=e.customHtmlTags)?l:[],includeSourceMap:!0===e.includeSourceMap,streamParse:null!=(r=e.streamParse)?r:"auto",validateLink:kr(e.validateLink),preTransformTokens:kr(e.preTransformTokens),postTransformTokens:kr(e.postTransformTokens),postTransformNodes:kr(e.postTransformNodes)};return i&&(a.final=!0===e.final),JSON.stringify(a)}function xr(e){let n=e.length;for(;n>0&&10===e.charCodeAt(n-1);)n-=1;const t=e.lastIndexOf("\n",n-1)+1;return e.slice(t,n).trim()}function Sr(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function Mr(e){const n=String(null!=e?e:"");return`${n.length}:${Sr(n)}`}function Cr(e,n=/* @__PURE__ */new WeakMap,t=0){if(null==e||"number"==typeof e||"boolean"==typeof e)return String(e);if("string"==typeof e)return`s:${function(e){return e.length<=8192?Mr(e):`${e.length}:${Sr(e.slice(0,8192))}:truncated`}(e)}`;if("function"==typeof e)return`fn:${kr(e)}`;if("object"!=typeof e)return typeof e;const o=e,l=n.get(o);if(l)return`cycle:${l}`;if(t>=6)return`object:${kr(o)}`;const r=kr(o);if(n.set(o,r),Array.isArray(e)){const o=e.slice(0,200);return`a:${e.length}:${o.map(e=>Cr(e,n,t+1)).join(",")}`}if("object"==typeof e){const o=e,l=Object.keys(o).sort(),r=l.slice(0,80);return`o:${l.length}:${r.map(e=>`${e}:${Cr(o[e],n,t+1)}`).join(";")}`}return typeof e}function Nr(e){return"object"==typeof e&&null!==e&&"string"==typeof e.type&&"string"==typeof e.raw}function _r(e,n=/* @__PURE__ */new WeakMap,t=0){return Array.isArray(e)?`a:${e.length}:${e.slice(0,200).map(e=>Nr(e)?Ir(e,n,t+1):_r(e,n,t+1)).join(",")}`:Nr(e)?Ir(e,n,t):Cr(e,n,t)}function Tr(e,n,t){return Object.keys(e).sort().filter(e=>"children"!==e&&!vr.includes(e)).map(o=>{const l=e[o];return"string"==typeof l?`${o}=s:${Mr(l)}`:"number"==typeof l||"boolean"==typeof l||null==l?`${o}=${String(l)}`:"function"==typeof l?`${o}=fn:${kr(l)}`:fr.has(o)&&(Array.isArray(l)||"object"==typeof l)?`${o}=${_r(l,n,t+1)}`:l&&"object"==typeof l?`${o}=object:${kr(l)}`:""}).filter(Boolean).join(";")}function Br(e){return vr.map(n=>{const t=e[n];return"string"==typeof t?`${n}=s:${Mr(t)}`:""}).filter(Boolean).join(";")}function Ir(e,n=/* @__PURE__ */new WeakMap,t=0){const o=pr.get(e);if(o)return o;const l=e,r=n.get(l);if(r)return`node-cycle:${r}`;if(t>=6)return`node:${e.type}:${kr(l)}`;const i=kr(l);n.set(l,i);const a=function(e,n,t){const o=e,l=Array.isArray(o.children)?o.children:[],r=l.length?l.slice(0,200).map(e=>Ir(e,n,t+1)).join("|"):"";return[e.type,Br(o),Tr(o,n,t),l.length,r].join(":")}(e,n,t);return pr.set(l,a),a}function Hr(e,n){return Ir(e)===Ir(n)}function $r(e,n,t){const o=yr(),l="stabilizeSignatureMs"===n?"stabilizeSignatureCallCount":"primeSignatureCallCount";try{return t()}finally{e[n]+=yr()-o,e[l]+=1,e.signatureMs=e.stabilizeSignatureMs+e.primeSignatureMs,e.signatureCallCount=e.stabilizeSignatureCallCount+e.primeSignatureCallCount}}function Rr(e,n,t){return $r(n,t,()=>Ir(e))}function Pr(e,n,t){return Rr(e,t,"stabilizeSignatureMs")===Rr(n,t,"stabilizeSignatureMs")}function Fr(e){return{reusedNodeCount:0,dirtyStartIndex:e>0?0:-1,stablePrefixNodeCount:0,dirtyTailNodeCount:e}}function Ar(e,n,t){return e<0?0:Math.max(n.length,t.length)-e}function Or(e){return!0===e.__markstreamHasCustomParserExtensions||function(e){var n;return Number(null!=(n=e.__markstreamRegisteredPluginCount)?n:0)>0}(e)}function Kr(e,n){return e.length===n.length&&e===n}function jr(e,n,t=0){if(t>=4)return null;if(e.type!==n.type)return!1;const o=e,l=n,r=Object.keys(o).filter(e=>"type"!==e&&"children"!==e).sort(),i=Object.keys(l).filter(e=>"type"!==e&&"children"!==e).sort();if(r.length!==i.length)return!1;for(let d=0;d<r.length;d++){const e=r[d];if(e!==i[d])return!1;const n=o[e],t=l[e];if(typeof n!=typeof t)return!1;if("string"!=typeof n){if("number"!=typeof n&&"boolean"!=typeof n&&null!=n)return null;if(!Object.is(n,t))return!1}else{if("string"!=typeof t)return!1;if(!Kr(n,t))return!1}}const a=Object.prototype.hasOwnProperty.call(o,"children");if(a!==Object.prototype.hasOwnProperty.call(l,"children"))return!1;if(!a)return!0;const u=o.children,s=l.children;if(!Array.isArray(u)||!Array.isArray(s))return null;if(u.length!==s.length)return!1;for(let d=0;d<u.length;d++){const e=u[d],n=s[d];if(!Nr(e)||!Nr(n))return null;const o=jr(e,n,t+1);if(null==o)return null;if(!o)return!1}return!0}function zr(e,n,t=0){if(e===n||e.type!==n.type||t>=6)return;const o=e,l=n;for(const r of["children","items","rows","cells"]){const e=o[r],n=l[r];if(!Array.isArray(e)||!Array.isArray(n))continue;const i=Math.min(e.length,n.length);for(let o=0;o<i;o++){const l=e[o],r=n[o];l!==r&&Nr(l)&&Nr(r)&&(!0===jr(l,r)?n[o]=l:zr(l,r,t+1))}}}function Lr(e,n){if(!e||!n)return!1;if(e===n)return!0;if(e.type!==n.type)return!1;const t=jr(e,n);return null!=t?t:Hr(e,n)}function Er(e,n,t){if(!e||!n)return!1;if(e===n)return!0;if(e.type!==n.type)return!1;let o=null;return $r(t,"stabilizeSignatureMs",()=>{o=jr(e,n)}),null!=o?o:Pr(e,n,t)}function Dr(e,n){const t={};for(const o of cr){const l=e[o],r=null==n?void 0:n[o];"number"==typeof l&&(t[o]=l-("number"==typeof r?r:0))}return t}function Wr(e,n){var t;const o=_(n.instanceMsgId),l=/* @__PURE__ */new Map,r=null!=(t=n.smoothStreamingEnabled)?t:A(()=>!1),i=q(n.renderContent.value);let s=[],c="",m="",f="",v=!1,h="",p=/* @__PURE__ */new WeakMap;const y=function(){let e="",n=0,t=!1,o=!1,l=!1,r=!1;function i(){e="",n=0,t=!1,o=!1,l=!1,r=!1}function a(e){let i=!1;for(let a=0;a<e.length;a++){const u=e.charCodeAt(a);if(10===u||13===u){const e=10===u&&r;r=13===u,t=!1,e||(l||(o=!1,n=0),l=!1);continue}r=!1;const s=9===u||32===u;if(s||(l=!0,o&&(i=!0)),n)if(1!==n)s||(58!==u?n=91===u?1:0:(i=!0,o=!0));else{if(t){t=!1;continue}if(92===u){t=!0;continue}93===u&&(n=2)}else 91===u&&(n=1)}return i}return(n,t)=>{if(!n||!t.startsWith(n)||t.length<=n.length)return i(),[!0,0];let o=0;e!==n&&(i(),a(n),o=n.length);const l=t.slice(n.length),r=a(l);return e=t,[r,o+l.length]}}();let b,k=0,w=0,x=yr(),S=-1,M=0;function C(e){S=Number.isInteger(e)?e:0,M+=1}function N(){b&&(clearTimeout(b),b=void 0)}function $(){N();const e=n.renderContent.value;i.value!==e&&(i.value=e),x=yr()}X([n.renderContent,n.effectiveFinal,r],([n,t,o])=>{i.value!==n&&(!o||t||function(e,n){if(!e&&n)return!0;if(n.length<=80)return!0;if(n.length<e.length||!n.startsWith(e))return!0;const t=n.slice(e.length);return!(!t||!function(e){const n=function(e){return e.includes("|")?e.replace(/^\|/,"").replace(/\|$/,"").split("|"):[]}(e);return n.length>=2&&n.every(e=>{const n=e.trim();return n.length>=1&&n.replace(/^:/,"").replace(/:$/,"").split("").every(e=>"-"===e)})}(xr(n))&&(o=n,l=xr(o),!(/^={3,}$/.test(l)||/^-{3,}$/.test(l)||t.includes("\n\n")||/(?:^|\n)(?:#{1,6}\s|[-+*]\s+|\d+[.)]\s+|>\s*|`{3,}|~{3,})/.test(t))));var o,l}(i.value,n)?$():function(){if(w+=1,b)return;const n=Math.max(0,function(e){const n=e.parseCoalesceMs;return"number"==typeof n&&Number.isFinite(n)&&n>=0?n:80}(e)-(yr()-x));n<=0?$():b=setTimeout($,n)}())},{flush:"sync",immediate:!0}),de(N);const R=A(()=>{var t,o,l,r;return T(e.customHtmlTags,null==(t=e.parseOptions)?void 0:t.customHtmlTags,(r=null!=(l=null==(o=n.customComponentsMap)?void 0:o.value)?l:{},Object.entries(r).map(([e,n])=>{const t=d(e);return null==n||!t||Ye(t)||H.has(t)||g.has(t)?"":t}).filter(Boolean)))}),P=A(()=>{const{key:e,tags:t}=B(R.value);if(!e)return o;const r=l.get(e);if(r)return r;const i=_(n.instanceMsgId,{customHtmlTags:t});return l.set(e,i),i}),F=A(()=>{const n=P.value;if(!e.customMarkdownIt)return n;const t=e.customMarkdownIt(n);return n.__markstreamHasCustomParserExtensions=!0,t.__markstreamHasCustomParserExtensions=!0,t}),O=A(()=>{var t,o;const l=null!=(t=e.parseOptions)?t:{},r=n.effectiveFinal.value,i=R.value,s=null!=r,d=i.length>0;return s||d||null==l.streamParse?a(a(u(a({},l),{streamParse:null==(o=l.streamParse)||o}),s?{final:r}:{}),d?{customHtmlTags:i}:{}):l}),K=A(()=>{var e;return new Set((null!=(e=O.value.customHtmlTags)?e:[]).map(e=>String(e).trim().toLowerCase()).filter(Boolean))}),j=A(()=>wr(O.value,F.value,e.customMarkdownIt,{includeFinal:!0})),z=A(()=>wr(O.value,F.value,e.customMarkdownIt,{includeFinal:!1}));X([j,z],([e,n],[t,o])=>{t&&(e===t&&n===o||($(),n!==o&&(s=[],f="")))},{flush:"sync"});const L=A(()=>{var t,o,l,r,d,g,b,x,M,N,_;if(null==(t=e.nodes)?void 0:t.length)return s=[],f="",C(0),fe(e.nodes.slice());const T=i.value;if(!T)return s=[],f="",C(-1),[];const B=n.debugPerformanceEnabled.value,H=B?yr():0,$=F.value,R=j.value,P=z.value;c&&R!==c&&function(e){var n,t;null==(t=null==(n=e.stream)?void 0:n.reset)||t.call(n)}($),m&&P!==m&&(s=[],f="");const A=null!=(l=null==(o=n.customComponentsMap)?void 0:o.value)?l:{},K=function(e){const n=e,t=sr.get(n);if(void 0!==t)return t;const o=function(e){return JSON.stringify(Object.entries(e).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,kr(n)]))}(e);return sr.set(n,o),o}(A);h&&K!==h&&(s=[],f="",p=/* @__PURE__ */new WeakMap);const L=Object.keys(A).length>0,E="function"==typeof O.value.postTransformNodes;E!==v&&(s=[],f="");const D=!E&&s.length>0&&T.startsWith(f)&&P===m,W=B?br($):null,V=B?{}:void 0,q=Or($),U=L&&s.some(e=>dr(e,A,p)),X=!q&&!E&&(!L||s.length>0&&!U),Y=a(u(a({},O.value),{reuseStableTopLevelNodes:X}),V?{parserMetrics:V}:{}),Z=I(T,$,Y),G=B?yr():0;if(D&&!q&&!L&&!O.value.preTransformTokens&&!O.value.postTransformTokens){const e=Math.min(s.length,Z.length);for(let n=0;n<e;n++)zr(s[n],Z[n])}const J=B?{signatureMs:0,stabilizeSignatureMs:0,primeSignatureMs:0,signatureCallCount:0,stabilizeSignatureCallCount:0,primeSignatureCallCount:0}:void 0;let Q,ee=B?Fr(Z.length):void 0,ne=0,te=0,oe=0;if(D){const n=B?yr():0,[t,o]=L?[0,0]:function(e){var n,t;const[o,l]=e.scanGlobalReferenceAppend(e.previousContent,e.content),r=e.parseOptions;return[e.previousDirtyStartIndex>0&&!0!==r.final&&!e.customMarkdownIt&&!Or(e.md)&&!o&&"function"!=typeof r.preTransformTokens&&"function"!=typeof r.postTransformTokens&&"function"!=typeof r.postTransformNodes&&0===(null!=(t=null==(n=r.customHtmlTags)?void 0:n.length)?t:0)?e.previousDirtyStartIndex:0,l]}({content:T,previousContent:f,previousDirtyStartIndex:S,parseOptions:O.value,customMarkdownIt:e.customMarkdownIt,md:$,scanGlobalReferenceAppend:y});oe=o;const l=t<=0,r=L?e=>!dr(e,A,p):void 0;if(J){const e=function(e,n,t,o={}){if(!n.length)return{nodes:e,metrics:Fr(e.length)};const l=!1!==o.reuseDirtyTail,r=function(e,n,t,o){var l;const r=Math.min(e.length,n.length);for(let i=Math.min(r,Math.max(0,null!=(l=o.scanStartIndex)?l:0));i<r;i++){const l=n[i],r=e[i];if(o.canReuseNode&&(!o.canReuseNode(l)||!o.canReuseNode(r))||!Er(l,r,t))return i}return e.length===n.length?-1:r}(e,n,t,o);if(r<0)return{nodes:n,metrics:{reusedNodeCount:e.length,dirtyStartIndex:r,stablePrefixNodeCount:e.length,dirtyTailNodeCount:0}};const i=e.slice();let a=r;for(let u=0;u<r;u++)i[u]=n[u];if(l)for(let u=r;u<e.length;u++){const l=n[u],r=e[u];l&&(!o.canReuseNode||o.canReuseNode(l)&&o.canReuseNode(r))&&Pr(l,r,t)&&(i[u]=l,a+=1)}return{nodes:i,metrics:{reusedNodeCount:a,dirtyStartIndex:r,stablePrefixNodeCount:r,dirtyTailNodeCount:Ar(r,e,n)}}}(Z,s,J,{canReuseNode:r,reuseDirtyTail:l,scanStartIndex:t});Q=e.nodes,ee=e.metrics}else{const e=function(e,n,t={}){if(!n.length)return{nodes:e,metrics:Fr(e.length)};const o=!1!==t.reuseDirtyTail,l=function(e,n,t){var o;const l=Math.min(e.length,n.length);for(let r=Math.min(l,Math.max(0,null!=(o=t.scanStartIndex)?o:0));r<l;r++){const o=n[r],l=e[r];if(t.canReuseNode&&(!t.canReuseNode(o)||!t.canReuseNode(l))||!Lr(o,l))return r}return e.length===n.length?-1:l}(e,n,t);if(l<0)return{nodes:n,metrics:{reusedNodeCount:e.length,dirtyStartIndex:l,stablePrefixNodeCount:e.length,dirtyTailNodeCount:0}};const r=e.slice();let i=l;for(let a=0;a<l;a++)r[a]=n[a];if(o)for(let a=l;a<e.length;a++){const o=n[a],l=e[a];o&&(!t.canReuseNode||t.canReuseNode(o)&&t.canReuseNode(l))&&Hr(o,l)&&(r[a]=o,i+=1)}return{nodes:r,metrics:{reusedNodeCount:i,dirtyStartIndex:l,stablePrefixNodeCount:l,dirtyTailNodeCount:Ar(l,e,n)}}}(Z,s,{canReuseNode:r,reuseDirtyTail:l,scanStartIndex:t});Q=e.nodes,ee=e.metrics}ne=B?yr()-n:0,te=l?null==(null==ee?void 0:ee.dirtyStartIndex)||ee.dirtyStartIndex<0?Q.length:ee.dirtyStartIndex:Q.length}else Q=Z,ee=Fr(Q.length);if(!0!==n.effectiveFinal.value&&(J?function(e,n,t=0){for(let o=Math.max(0,t);o<e.length;o++)$r(n,"primeSignatureMs",()=>Ir(e[o]))}(Q,J,te):function(e,n=0){for(let t=Math.max(0,n);t<e.length;t++)Ir(e[t])}(Q,te)),L)for(let e=null!=(null==ee?void 0:ee.dirtyStartIndex)&&ee.dirtyStartIndex>=0?ee.dirtyStartIndex:Q.length;e<Q.length;e++)dr(Q[e],A,p);const le=B?yr()-G:0;if(k+=1,f=T,c=R,m=P,v=E,h=K,s=Q,C(null!=(r=null==ee?void 0:ee.dirtyStartIndex)?r:0),B){const e=br($),t="number"==typeof(null==e?void 0:e.total)&&e.total>(null!=(d=null==W?void 0:W.total)?d:0);n.logPerf(t?"parse(stream)":"parse(sync)",a(a(a({rendererId:n.instanceMsgId,ms:Math.round(yr()-H),nodes:Q.length,contentLength:T.length,parseCommitCount:k,parseCoalescedCount:w,nodeReuseMs:le,referenceDefinitionScanChars:oe,signatureMs:null!=(g=null==J?void 0:J.signatureMs)?g:0,stabilizeSignatureMs:null!=(b=null==J?void 0:J.stabilizeSignatureMs)?b:0,primeSignatureMs:null!=(x=null==J?void 0:J.primeSignatureMs)?x:0,signatureCallCount:null!=(M=null==J?void 0:J.signatureCallCount)?M:0,stabilizeSignatureCallCount:null!=(N=null==J?void 0:J.stabilizeSignatureCallCount)?N:0,primeSignatureCallCount:null!=(_=null==J?void 0:J.primeSignatureCallCount)?_:0,stabilizeMs:ne},null!=ee?ee:{}),V?Object.fromEntries(mr.map(e=>{var n;return[e,null!=(n=V[e])?n:0]})):{}),e?{streamMode:e.lastMode,streamDelta:Dr(e,W),streamStats:e}:{}))}return fe(Q)});return{effectiveCustomHtmlTags:R,effectiveCustomHtmlTagsSet:K,mdBase:P,mdInstance:F,mergedParseOptions:O,getParsedNodesDirtyStartIndex:()=>S,getParsedNodesRevision:()=>M,parsedNodes:L}}function Vr(e){const{isClient:n}=e,t=q(/* @__PURE__ */new Set),o=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;function i(e){if(!n)return;const t=r.get(e);null!=t&&(window.clearTimeout(t),r.delete(e))}function a(){if(n)for(const e of r.values())window.clearTimeout(e);r.clear()}function u(){t.value=/* @__PURE__ */new Set}return{visibleNodeIndices:t,nodeVisibilityHandles:o,nodeVisibilityWatchStops:l,nodeVisibilityFallbackTimers:r,clearVisibilityFallback:i,clearAllVisibilityFallbacks:a,markNodeVisible:function(n,o=!0){var l;o&&i(n),function(n,o){if(null!=(r=null==(l=e.shouldTrackVisibleNodeIndices)?void 0:l.call(e))&&!r)return;var l,r;const i=t.value,a=i.has(n);if(o){if(a)return;const e=new Set(i);return e.add(n),void(t.value=e)}if(!a)return;const u=new Set(i);u.delete(n),t.value=u}(n,o),o&&(null==(l=e.onNodeMarkedVisible)||l.call(e,n))},resetNodeVisibleState:u,cleanupNodeVisibility:function(n){var a;if(e.shouldCleanupNodeVisibility&&!e.shouldCleanupNodeVisibility())return;for(const[e,t]of l.entries())e<n||(t(),l.delete(e));for(const[t,l]of o.entries())t<n||(l.destroy(),o.delete(t),i(t),null==(a=e.onNodeVisibilityCleaned)||a.call(e,t));for(const e of Array.from(r.keys()))e<n||i(e);if(!t.value.size)return;const u=/* @__PURE__ */new Set;for(const e of t.value)e<n&&u.add(e);t.value=u},destroyNodeVisibilityState:function(){u();for(const e of l.values())e();l.clear();for(const e of o.values())e.destroy();o.clear(),a()}}}function qr(e){const{isClient:n,virtualizationEnabled:t,listenerEnabled:o,scrollRootElement:l,resolveScrollContainer:r,scheduleFocusSync:i,onScroll:a}=e;let u=null,s=null,d=!1,c=null;const m=void 0===e.requestFrame?"function"==typeof requestAnimationFrame?requestAnimationFrame:null:e.requestFrame,f=void 0===e.cancelFrame?"function"==typeof cancelAnimationFrame?cancelAnimationFrame:null:e.cancelFrame;function v(){null!=c&&(null==f||f(c),c=null),d=!1,u&&(u(),u=null),s=null,l.value=null}function h(n){const t=e.getScrollTop?e.getScrollTop(n):n.scrollTop;return Math.max(0,Number.isFinite(t)?Math.abs(t):0)}return{cleanupScrollListener:v,setupScrollListener:function(){if(!n)return;if(!(null!=(e=null==o?void 0:o.value)?e:t.value))return void v();var e;const f=r();if(!f)return void v();if(l.value===f&&u)return;v(),s=h(f);const p=()=>{null==a||a(),t.value&&(()=>{if(d)return;d=!0;const e=()=>{if(d=!1,c=null,t.value){const e=function(e){const n=h(e),t=s;s=n;const o=Math.max(480,.75*(e.clientHeight||0));return null==t?n>o?{immediate:!0}:void 0:Math.abs(n-t)>o?{immediate:!0}:void 0}(f);e?i(e):i()}};m?c=m(e):e()})()};f.addEventListener("scroll",p,{passive:!0}),l.value=f,u=()=>{f.removeEventListener("scroll",p)}}}}function Ur(e={}){const n=q(""),t=q(""),o=q(!1),l=Fe(e),r=()=>{const e=l.getSnapshot();n.value=e.source,t.value=e.visible,o.value=e.done},i=l.subscribe(r);r();const a=A(()=>Math.max(0,n.value.length-t.value.length)),u=A(()=>0===a.value),s=A(()=>o.value&&u.value);return ye()&&de(()=>{i(),l.destroy()}),{source:n,visible:t,done:o,final:s,caughtUp:u,pendingChars:a,enqueue:e=>l.enqueue(e),finish:e=>l.finish(e),flush:()=>l.flush(),reset:(e,n)=>l.reset(e,n),pause:()=>l.pause(),resume:()=>l.resume()}}const Xr={maxCharsPerSecond:3e3,maxCommitFps:20,maxCharsPerCommit:160,catchUpLatencyMs:220,catchUpThreshold:400},Yr=/auto|scroll|overlay/i;function Zr(e){if(!e)return!1;const n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();return Yr.test(n)||Yr.test(t)}function Gr(e){const n=Math.ceil(e.scrollHeight)>Math.ceil(e.clientHeight)+1,t=Math.ceil(e.scrollWidth)>Math.ceil(e.clientWidth)+1;return n||t}const Jr=O({name:"D2BlockNodeLoading",props:{node:{type:Object,required:!0},showHeader:{type:Boolean,default:!0},estimatedPreviewHeightPx:{type:Number,default:void 0}},setup(e){const n=A(()=>{var n,t;return ze(null!=(t=Le(e.estimatedPreviewHeightPx))?t:Ee(String(null!=(n=e.node.code)?n:"")))});return()=>E("div",{class:"d2-block-container rounded-lg border overflow-hidden",style:{margin:"var(--ms-flow-diagram-y) 0",background:"var(--diagram-bg)",borderColor:"var(--diagram-border)",color:"hsl(var(--ms-foreground))",boxShadow:"var(--ms-shadow-subtle)"},"data-markstream-d2":"1","data-markstream-mode":"pending"},[e.showHeader?E("div",{class:"d2-block-header flex justify-between items-center border-b",style:{padding:"var(--ms-inset-panel-y) var(--ms-inset-panel-x)",background:"var(--diagram-header-bg)",borderColor:"var(--diagram-border)"}},[E("div",{class:"flex items-center gap-x-2"},[E("span",{class:"d2-label font-medium font-mono",style:{fontSize:"var(--ms-text-label)",color:"var(--code-action-fg)"}},"D2")]),E("div",{class:"d2-header-actions flex items-center","aria-hidden":"true"})]):null,E("div",{class:"d2-block-body",style:{minHeight:`${n.value}px`}})])}}),Qr={class:"m-0 p-0"},ei=["data-probe"],ni=/* @__PURE__ */an(/* @__PURE__ */O(u(a({},{name:"HeightEstimationProbes"}),{__name:"HeightEstimationProbes",props:{width:{},flowRoot:{type:Boolean},paragraphNode:{},listItemNode:{},listNode:{},headingNodes:{},setParagraphWrapper:{type:Function},setListItemWrapper:{type:Function},setListWrapper:{type:Function},setHeadingWrapper:{type:Function}},setup(e){const n=e;function t(e){var t,o;return null!=(o=null==(t=n.headingNodes)?void 0:t[e])?o:null}return(n,o)=>(K(),j("div",{class:"height-estimation-probes",style:se({width:`${e.width}px`}),"aria-hidden":"true"},[z("div",{ref:n=>e.setParagraphWrapper(n),class:D(["node-content",{"node-content-flow-root":e.flowRoot}]),"data-probe":"paragraph"},[W(V(ul),{node:e.paragraphNode,"index-key":"probe-paragraph"},null,8,["node"])],2),z("div",{ref:n=>e.setListItemWrapper(n),class:D(["node-content",{"node-content-flow-root":e.flowRoot}]),"data-probe":"list-item"},[z("ul",Qr,[W(V(el),{node:e.listItemNode,"index-key":"probe-list-item"},null,8,["node"])])],2),z("div",{ref:n=>e.setListWrapper(n),class:D(["node-content",{"node-content-flow-root":e.flowRoot}]),"data-probe":"list"},[W(V(nl),{node:e.listNode,"index-key":"probe-list"},null,8,["node"])],2),(K(),j(Y,null,J(6,n=>z("div",{key:`probe-heading-${n}`,ref_for:!0,ref:t=>e.setHeadingWrapper(n,t),class:D(["node-content",{"node-content-flow-root":e.flowRoot}]),"data-probe":`heading-${n}`},[W(V(Yo),{node:t(n),"index-key":`probe-heading-${n}`},null,8,["node","index-key"])],10,ei)),64))],4))}})),[["__scopeId","data-v-3e0766e2"]]),ti=O({name:"InfographicBlockNodeLoading",props:{node:{type:Object,required:!0},showHeader:{type:Boolean,default:!0},estimatedPreviewHeightPx:{type:Number,default:void 0}},setup(e){const n=A(()=>{var n,t;return Ke(null!=(t=Le(e.estimatedPreviewHeightPx))?t:je(String(null!=(n=e.node.code)?n:"")))});return()=>{var t;return E("div",{class:"infographic-block-container rounded-lg border overflow-hidden",style:{margin:"var(--ms-flow-diagram-y) 0",background:"var(--diagram-bg)",borderColor:"var(--diagram-border)",color:"hsl(var(--ms-foreground))"},"data-markstream-infographic":"1","data-markstream-mode":"pending"},[e.showHeader?E("div",{class:"infographic-block-header flex justify-between items-center border-b",style:{padding:"var(--ms-inset-panel-y) var(--ms-inset-panel-x)",background:"var(--diagram-header-bg)",borderColor:"var(--diagram-border)",minHeight:"calc(var(--ms-action-btn-icon) + var(--ms-action-btn-padding) + var(--ms-action-btn-padding) + var(--ms-inset-panel-y) + var(--ms-inset-panel-y) + 1px)"}},[E("div",{class:"flex items-center gap-x-2 overflow-hidden"},[E("span",{class:"icon-slot action-icon shrink-0",style:{display:"inline-flex",width:"var(--ms-action-btn-icon)",height:"var(--ms-action-btn-icon)"}}),E("span",{class:"infographic-label font-medium font-mono truncate",style:{fontSize:"var(--ms-text-label)",color:"hsl(var(--ms-muted-foreground))"}},"Infographic")]),E("div",{class:"infographic-header-actions flex items-center opacity-0 pointer-events-none",style:{gap:"var(--ms-gap-header-actions)"},"aria-hidden":"true"},Array.from({length:4},()=>E("span",{class:"infographic-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded",style:{width:"calc(var(--ms-action-btn-icon) + var(--ms-action-btn-padding) + var(--ms-action-btn-padding))",height:"calc(var(--ms-action-btn-icon) + var(--ms-action-btn-padding) + var(--ms-action-btn-padding))"}})))]):null,E("div",{class:"infographic-preview relative overflow-hidden block",style:{height:`${n.value}px`,minHeight:"var(--ms-size-diagram-min-height)",background:"var(--diagram-bg)"}},[E("pre",{class:"infographic-pending-source text-sm font-mono whitespace-pre-wrap",style:{position:"absolute",inset:"0",zIndex:"1",margin:"0",padding:"var(--ms-inset-panel-body)",overflow:"auto",textAlign:"left"}},String(null!=(t=e.node.code)?t:"")),E("div",{class:"absolute inset-0"},[E("div",{class:"w-full text-center flex items-center justify-center min-h-full"})])])])}}}),oi=O({name:"MermaidBlockNodeLoading",props:{node:{type:Object,required:!0},showHeader:{type:Boolean,default:!0},estimatedPreviewHeightPx:{type:Number,default:void 0}},setup(e){const n=A(()=>{var n,t;return Ae(null!=(t=Le(e.estimatedPreviewHeightPx))?t:Oe(String(null!=(n=e.node.code)?n:"")))});return()=>{var t;return E("div",{class:"mermaid-block-container rounded-lg border overflow-hidden",style:{margin:"var(--ms-flow-diagram-y) 0",borderColor:"var(--diagram-border)"},"data-markstream-mermaid":"1","data-markstream-mode":"pending"},[e.showHeader?E("div",{class:"mermaid-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)]",style:{background:"var(--diagram-header-bg)",borderColor:"var(--diagram-border)"}},[E("div",{class:"flex items-center gap-x-2 overflow-hidden"},[E("span",{class:"mermaid-label-text text-[length:var(--ms-text-label)] font-medium font-mono truncate",style:{color:"var(--code-action-fg)"}},"Mermaid")]),E("div",{class:"mermaid-header-actions flex items-center gap-[var(--ms-gap-header-actions)] opacity-0 pointer-events-none","aria-hidden":"true"},Array.from({length:4},()=>E("span",{class:"mermaid-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded"},[E("span",{class:"action-icon block"})])))]):null,E("div",{class:"mermaid-preview-area relative overflow-hidden block",style:{height:`${n.value}px`,minHeight:"var(--ms-size-diagram-min-height)",background:"var(--diagram-bg)"}},[E("pre",{class:"mermaid-source-code text-sm font-mono whitespace-pre-wrap",style:{position:"absolute",inset:"0",margin:"0",padding:"var(--ms-inset-panel-body)",overflow:"auto",textAlign:"left"}},String(null!=(t=e.node.code)?t:"")),E("div",{class:"_mermaid w-full text-center flex items-center justify-center min-h-full",style:{fontFamily:"inherit",contentVisibility:"auto",contain:"content",containIntrinsicSize:"var(--ms-size-diagram-min-height) 240px"}})])])}}}),li=O({name:"NodeRendererContent",props:["item","sourceNodes","fade","final","nestedRendererProps"],setup:e=>()=>E(pe,{name:"fade",css:!1!==e.fade,appear:!1!==e.fade&&!0!==e.final},{default:()=>{const n=e.item;return n.rendersCustomNode?E(n.component,a({key:0},n.customNodeProps),{default:()=>n.hasSlotChildren?E(di,u(a({key:0},e.nestedRendererProps),{nodes:n.node.children,indexKey:n.indexKey,batchRendering:!1,deferNodesUntilVisible:!1,renderAsFragment:!0})):n.slotContent?E(di,u(a({key:1},e.nestedRendererProps),{content:n.slotContent,final:!n.node.loading,indexKey:`${n.indexKey}-content`,smoothStreaming:!1,batchRendering:!1,deferNodesUntilVisible:!1,renderAsFragment:!0})):G("v-if",!0)}):E(n.component,a({key:1},n.nodeProps))}})}),ri={docs:{showTooltips:!0,fade:!0,batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:220,liveNodeBuffer:60,nodeVirtual:"auto"},chat:{showTooltips:!1,fade:!1,batchRendering:!0,initialRenderBatchSize:32,renderBatchSize:48,renderBatchDelay:6,renderBatchBudgetMs:8,renderBatchIdleTimeoutMs:60,deferNodesUntilVisible:!0,maxLiveNodes:0,liveNodeBuffer:0,nodeVirtual:"auto"},minimal:{showTooltips:!1,fade:!1,batchRendering:!0,initialRenderBatchSize:32,renderBatchSize:48,renderBatchDelay:6,renderBatchBudgetMs:8,renderBatchIdleTimeoutMs:60,deferNodesUntilVisible:!0,maxLiveNodes:0,liveNodeBuffer:0,nodeVirtual:"auto"}};function ii(e){if(null==e)return"";if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return String(e);try{return JSON.stringify(e)}catch(n){return String(e)}}const ai=["data-custom-id"],ui=["data-node-index","data-node-type"],si="typewriter-simple-cursor-target",di=/* @__PURE__ */an(/* @__PURE__ */O(u(a({},{name:"NodeRenderer"}),{__name:"NodeRenderer",props:{content:{},nodes:{},final:{type:Boolean},parseOptions:{},customMarkdownIt:{},debugPerformance:{type:Boolean,default:!1},customHtmlTags:{},mode:{},domMode:{},htmlPolicy:{},viewportPriority:{type:Boolean,default:void 0},viewportPriorityOptions:{},codeBlockStream:{type:Boolean,default:!0},codeBlockDarkTheme:{},codeBlockLightTheme:{},renderCodeBlocksAsPre:{type:Boolean,default:void 0},codeBlockMinWidth:{},codeBlockMaxWidth:{},codeBlockOptions:{},codeBlockProps:{},mermaidProps:{},d2Props:{},infographicProps:{},showTooltips:{type:Boolean,default:void 0},themes:{},isDark:{type:Boolean},customId:{},indexKey:{},typewriter:{type:[Boolean,String],default:!1},smoothStreaming:{type:[Boolean,String],default:"auto"},smoothStreamingOptions:{},parseCoalesceMs:{},fade:{type:Boolean,default:void 0},batchRendering:{type:Boolean,default:void 0},initialRenderBatchSize:{},renderBatchSize:{},renderBatchDelay:{},renderBatchBudgetMs:{},renderBatchIdleTimeoutMs:{},deferNodesUntilVisible:{type:Boolean,default:void 0},maxLiveNodes:{},liveNodeBuffer:{},nodeVirtual:{type:[Boolean,String],default:void 0},virtualScroll:{},renderAsFragment:{type:Boolean}},emits:["copy","copy-code","handleArtifactClick","click","mouseover","mouseout","virtual-state-change","height-change","render-settled","render-final","anchor-change"],setup(e,{expose:n,emit:t}){const o=e,l=t;function r(e){if(!("undefined"!=typeof Event&&e instanceof Event))return"string"==typeof e?(l("copy-code",e),void l("copy",e)):void l("copy",e)}function i(e){l("handleArtifactClick",e)}function d(e){l("mouseover",e)}function c(e){l("mouseout",e)}const m=Q(),f=F("markstreamNestedRendererProps",void 0);function v(e){const n=null==m?void 0:m.vnode.props;return!!n&&(Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,String(e).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)))}function h(e){var n,t;const l=o[e];return v(e)?l:null!=(t=null==(n=null==f?void 0:f.value)?void 0:n[e])?t:l}const p=ql,g=A(()=>{return"chat"===(e=h("mode"))||"minimal"===e||"docs"===e?e:"docs";var e}),y=A(()=>Yl(h("typewriter"))),b=A(()=>"off"!==y.value),k=A(()=>"minimal"===h("domMode")?"minimal":"full"),w=A(()=>!0===h("renderCodeBlocksAsPre")),x=A(()=>ri[g.value]),S=A(()=>{var e;return null!=(e=h("showTooltips"))?e:x.value.showTooltips}),M=A(()=>{var e;return null!=(e=h("fade"))?e:x.value.fade}),_=A(()=>{var e;return null!=(e=h("batchRendering"))?e:x.value.batchRendering}),T=A(()=>{var e;return null!=(e=h("initialRenderBatchSize"))?e:x.value.initialRenderBatchSize}),B=A(()=>{var e;return null!=(e=h("renderBatchSize"))?e:x.value.renderBatchSize}),I=A(()=>{var e;return null!=(e=h("renderBatchDelay"))?e:x.value.renderBatchDelay}),H=A(()=>{var e;return null!=(e=h("renderBatchBudgetMs"))?e:x.value.renderBatchBudgetMs}),R=A(()=>{var e;return null!=(e=h("renderBatchIdleTimeoutMs"))?e:x.value.renderBatchIdleTimeoutMs}),O=A(()=>{var e;return null!=(e=h("deferNodesUntilVisible"))?e:x.value.deferNodesUntilVisible}),z=A(()=>{var e;return null!=(e=h("maxLiveNodes"))?e:x.value.maxLiveNodes}),L=A(()=>{var e;return null!=(e=h("liveNodeBuffer"))?e:x.value.liveNodeBuffer}),E=A(()=>{var e;return null!=(e=h("nodeVirtual"))?e:x.value.nodeVirtual}),W={get content(){return o.content},get nodes(){return o.nodes},get final(){return o.final},get parseOptions(){return h("parseOptions")},get customMarkdownIt(){return h("customMarkdownIt")},get debugPerformance(){return o.debugPerformance},get customHtmlTags(){return h("customHtmlTags")},get mode(){return h("mode")},get domMode(){return k.value},get htmlPolicy(){return h("htmlPolicy")},get viewportPriority(){return h("viewportPriority")},get viewportPriorityOptions(){return h("viewportPriorityOptions")},get codeBlockStream(){return h("codeBlockStream")},get codeBlockDarkTheme(){return h("codeBlockDarkTheme")},get codeBlockLightTheme(){return h("codeBlockLightTheme")},get codeBlockMinWidth(){return h("codeBlockMinWidth")},get codeBlockMaxWidth(){return h("codeBlockMaxWidth")},get codeBlockOptions(){return h("codeBlockOptions")},get codeBlockProps(){return h("codeBlockProps")},get mermaidProps(){return h("mermaidProps")},get d2Props(){return h("d2Props")},get infographicProps(){return h("infographicProps")},get showTooltips(){return S.value},get themes(){return h("themes")},get isDark(){return h("isDark")},get customId(){return h("customId")},get indexKey(){return o.indexKey},get typewriter(){return h("typewriter")},get smoothStreaming(){return o.smoothStreaming},get smoothStreamingOptions(){return h("smoothStreamingOptions")},get parseCoalesceMs(){return h("parseCoalesceMs")},get fade(){return M.value},get batchRendering(){return _.value},get initialRenderBatchSize(){return T.value},get renderBatchSize(){return B.value},get renderBatchDelay(){return I.value},get renderBatchBudgetMs(){return H.value},get renderBatchIdleTimeoutMs(){return R.value},get deferNodesUntilVisible(){return O.value},get maxLiveNodes(){return z.value},get liveNodeBuffer(){return L.value},get nodeVirtual(){return E.value},get virtualScroll(){return o.virtualScroll},get renderAsFragment(){return o.renderAsFragment}};function Z(e){l("height-change",e)}function te(e){l("virtual-state-change",e)}function de(e){l("anchor-change",e)}const ce=q(),me=q(null),ve=q(null),he=q(null),pe=ge({1:null,2:null,3:null,4:null,5:null,6:null}),ye=q(!1),Se=/* @__PURE__ */new Map,Me=q(0);let Ne=!1;const _e=q(0),Te=q({paragraph:null,listItem:null,listWrapperOverhead:0,headings:{1:null,2:null,3:null,4:null,5:null,6:null}});function Be(e,n){return"string"!=typeof e?n:e.trim()||n}function Ie(e){const n=Number(e);return Number.isFinite(n)&&n>0?Math.max(1,Math.trunc(n)):640}const He=A(()=>{var e;const n=null!=(e=W.viewportPriorityOptions)?e:{},t=Be(n.rootMargin,it);return{rootMargin:t,heavyBlockMargin:Be(n.heavyBlockMargin,t),maxTargets:Ie(n.maxTargets)}}),$e=A(()=>{var e;return null!=(e=He.value.rootMargin)?e:it}),Re=A(()=>{var e;return null!=(e=He.value.maxTargets)?e:640});function Pe(){var e,n;if(!0!==(null==(e=o.virtualScroll)?void 0:e.enabled))return null;const t=null==(n=o.virtualScroll)?void 0:n.scrollRoot;return Fe("function"==typeof t?t():t)}function Fe(e){return e?"undefined"!=typeof HTMLElement&&e instanceof HTMLElement?e:"object"==typeof e&&"value"in e?Fe(e.value):"object"==typeof e&&"$el"in e?Fe(e.$el):null:null}ee(ot,He);const{isClient:De,renderAsFragment:We,debugPerformanceEnabled:Ve,resolvedShowTooltips:qe,resolvedHtmlPolicy:Ue,inheritedSmoothStreaming:Xe,ownsTypewriterCursor:Ze}=function(e){const n="undefined"!=typeof window,t=U(),o=F("markstreamHtmlPolicy",void 0),l=F("markstreamTypewriterCursor",void 0),r=F("markstreamSmoothStreaming",void 0),i=A(()=>!0===e.renderAsFragment),a=A(()=>Boolean(e.debugPerformance&&n&&"undefined"!=typeof console)),u=A(()=>{var n;if("boolean"==typeof e.showTooltips)return e.showTooltips;const o=null!=(n=t.showTooltips)?n:t["show-tooltips"];return""===o||!0===o||"true"===o||!1!==o&&"false"!==o&&void 0}),s=A(()=>{var n,t;return null!=(t=null!=(n=e.htmlPolicy)?n:null==o?void 0:o.value)?t:"safe"}),d=A(()=>!0!==(null==l?void 0:l.value));return{isClient:n,renderAsFragment:i,debugPerformanceEnabled:a,resolvedShowTooltips:u,resolvedHtmlPolicy:s,inheritedSmoothStreaming:r,inheritedTypewriterCursor:l,ownsTypewriterCursor:d}}(W),{resolveViewportRoot:Ge,resolveScrollContainer:Je,isReverseFlexScrollRoot:Qe,getNormalizedScrollTop:nn,getOffsetTopWithinRoot:tn}=function(e,n){function t(){var e,t;return null!=(t=null==(e=n.scrollRoot)?void 0:e.call(n))?t:null}function o(n){if("undefined"==typeof window)return null;const o=t();if(o)return o;const l=null!=n?n:e.value;if(!l)return null;const r=l.ownerDocument||document,i=r.scrollingElement||r.documentElement;let a=l;for(;a&&a!==r.body&&a!==i;){if(Zr(window.getComputedStyle(a))&&Gr(a))return a;a=a.parentElement}return null}function l(e){if(!n.isClient)return!1;try{const n=window.getComputedStyle(e);return!!(n.display||"").toLowerCase().includes("flex")&&(n.flexDirection||"").toLowerCase().endsWith("reverse")}catch(t){return!1}}function r(e,n,t){var o,r;if(t)return i(n);const a=e.scrollTop;if(!l(e))return a;const u=a<0?-a:a;return Math.max(0,(null!=(o=e.scrollHeight)?o:0)-(null!=(r=e.clientHeight)?r:0))-u}function i(e){var n,t,o,l,r;const i=Number(null==(n=e.scrollingElement)?void 0:n.scrollTop),a=Number(null!=(o=null==(t=e.documentElement)?void 0:t.scrollTop)?o:0),u=Number(null!=(r=null==(l=e.body)?void 0:l.scrollTop)?r:0);return Math.max(0,Number.isFinite(i)?i:0,Number.isFinite(a)?a:0,Number.isFinite(u)?u:0)}return{resolveViewportRoot:o,resolveScrollContainer:function(n){var l,r,i,a;const u=t();if(u)return u;const s=o(null!=(l=null!=n?n:e.value)?l:null);if(s)return s;const d=null!=(a=null!=(i=null==n?void 0:n.ownerDocument)?i:null==(r=e.value)?void 0:r.ownerDocument)?a:"undefined"!=typeof document?document:null;return(null==d?void 0:d.scrollingElement)||(null==d?void 0:d.documentElement)||null},isReverseFlexScrollRoot:l,getNormalizedScrollTop:r,getOffsetTopWithinRoot:function(e,n){const t=n.ownerDocument||e.ownerDocument||document;if(function(e,n){return e===n.documentElement||e===n.body||e===n.scrollingElement}(n,t))return e.getBoundingClientRect().top+i(t);const o=n.getBoundingClientRect(),l=e.getBoundingClientRect(),a=r(n,t,!1);return l.top-o.top+a}}}(ce,{isClient:De,scrollRoot:Pe});ee("markstreamShowTooltips",qe),ee("markstreamHtmlPolicy",Ue),ee("markstreamTypewriter",b),ee("markstreamFade",A(()=>!1!==W.fade)),ee("markstreamTypewriterCursor",A(()=>!0)),ee("markstreamTextStreamState",Se),ee("markstreamStreamVersion",Me),ee("markstreamParseOptions",A(()=>W.parseOptions)),ee("markstreamCustomMarkdownIt",A(()=>W.customMarkdownIt));const{smoothStreamingEnabled:on,renderContent:ln,requestedFinal:rn,effectiveFinal:an}=function(e,n){const t=Ur(u(a(a({},Xr),e.smoothStreamingOptions),{burstInitialContent:!Zl(e.typewriter)})),o=A(()=>{var t,o,l;return!1!==e.smoothStreaming&&!(null==(t=e.nodes)?void 0:t.length)&&(!0===e.smoothStreaming||!(null==(o=n.inheritedSmoothStreaming)?void 0:o.value))&&(!0===e.smoothStreaming||Zl(e.typewriter)||(null!=(l=e.maxLiveNodes)?l:0)<=0)}),l=q(!n.isClient||!0===e.smoothStreaming);be(()=>{l.value=!0});const r=A(()=>l.value&&o.value),i=A(()=>{var n;return r.value?t.visible.value:null!=(n=e.content)?n:""}),s=A(()=>{var n,t;const o=null!=(n=e.parseOptions)?n:{};return null!=(t=e.final)?t:o.final}),d=A(()=>{const e=s.value;return r.value&&null!=e?!!e&&t.caughtUp.value:e});let c=0,m=!1;function f(){c=0,m=!1}return X([()=>e.content,()=>e.nodes,r,s],([e,n,o,l])=>{if(null==n?void 0:n.length)return f(),void t.reset("");const r=null!=e?e:"";if(!o)return f(),t.reset(r),void(l&&t.finish({flush:!0}));const i=t.source.value;if(r)if(r===i);else if(r.startsWith(i)){const e=r.slice(i.length),n=t.pendingChars.value;e.length<=8?(c++,m||c>=2&&n<=8?(m=!0,t.reset(r,{prefixKnown:!0})):t.enqueue(e)):(f(),t.enqueue(e))}else f(),t.reset(r);else f(),t.reset("");l&&t.finish()},{immediate:!0}),{smoothStream:t,smoothStreamingEligible:o,smoothStreamingEnabled:r,renderContent:i,requestedFinal:s,effectiveFinal:d}}(W,{isClient:De,inheritedSmoothStreaming:Xe}),sn=!0===rn.value;ee("markstreamSmoothStreaming",on);const cn=q(!1),mn=q(!1),vn=q(!1);let hn="",pn=!1,gn=null;function yn(){De&&null!=gn&&(window.clearTimeout(gn),gn=null)}function bn(){cn.value=!1,yn()}function wn(e,n){if(!Ve.value)return;const t=function(){if(!Ve.value)return null;const e=_n(xn),n=_n(Sn),t=Math.max(Cn,n);if(e<=0&&t<=0)return null;const o={total:e,maxPerFrame:t,byLabel:(l=xn,Object.fromEntries(Array.from(l.entries()).sort((e,n)=>n[1]-e[1]||e[0].localeCompare(n[0]))))};var l;return xn.clear(),Sn.clear(),Cn=0,o}();console.info(`[markstream-vue][perf] ${e}`,t?u(a({},n),{layoutReads:t}):n)}X([()=>W.indexKey,()=>W.customId],()=>{var e,n;bn(),mn.value=!1,vn.value=!(null==(e=o.nodes)?void 0:e.length)&&!0!==rn.value&&Boolean(o.content),hn=null!=(n=ln.value)?n:"",pn=hn.length>0},{flush:"sync"}),X([()=>o.content,()=>o.nodes,rn],([e,n,t])=>{!(null==n?void 0:n.length)&&!0!==t&&Boolean(e)&&(vn.value=!0)},{flush:"sync",immediate:!0}),X([ln,()=>o.nodes,an],([e,n,t])=>{const l=null!=e?e:"";return(null==n?void 0:n.length)||!0===t?(bn(),mn.value=!1,hn=l,void(pn=!0)):(l.length>0&&(vn.value=!0),pn?(hn&&l.length>hn.length&&l.startsWith(hn)?(cn.value=!0,mn.value=!0,De&&(yn(),gn=window.setTimeout(()=>{var e;gn=null,!0===an.value||(null==(e=o.nodes)?void 0:e.length)||(pu(),cn.value=!1,bu())},1200))):(l.length<hn.length||!l.startsWith(hn))&&(bn(),mn.value=!1),void(hn=l)):(hn=l,void(pn=!0)))},{flush:"sync",immediate:!0});const xn=/* @__PURE__ */new Map,Sn=/* @__PURE__ */new Map;let Mn=!1,Cn=0;function _n(e){let n=0;for(const t of e.values())n+=t;return n}function Tn(){Cn=Math.max(Cn,_n(Sn)),Sn.clear(),Mn=!1}function Bn(e){e.maxPerFrame=Math.max(Number(e.maxPerFrame||0),Number(e.currentFrameTotal||0)),e.currentFrameTotal=0,e.frameScheduled=!1}function In(e){var n,t;Ve.value&&(xn.set(e,(null!=(n=xn.get(e))?n:0)+1),Sn.set(e,(null!=(t=Sn.get(e))?t:0)+1),function(e){const n=function(){if(!De||"undefined"==typeof window)return null;const e=window;if(e.__markstreamLayoutReadPerformance)return e.__markstreamLayoutReadPerformance;const n={total:0,maxPerFrame:0,byLabel:{}};return e.__markstreamLayoutReadPerformance=n,n}();n&&(n.total=Number(n.total||0)+1,n.byLabel[e]=Number(n.byLabel[e]||0)+1,n.currentFrameTotal=Number(n.currentFrameTotal||0)+1,n.frameScheduled||(n.frameScheduled=!0,"function"!=typeof window.requestAnimationFrame?"function"!=typeof queueMicrotask?setTimeout(()=>Bn(n),0):queueMicrotask(()=>Bn(n)):window.requestAnimationFrame(()=>Bn(n))))}(e),Mn||(Mn=!0,De&&"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(Tn):"function"!=typeof queueMicrotask?setTimeout(Tn,0):queueMicrotask(Tn)))}function $n(e,n){return In(e),n()}const Rn=W.customId?`renderer-${W.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,Pn=function(e){const n=/* @__PURE__ */new Map;return{scope:e,cache:n,clear:()=>n.clear()}}(Rn),Fn=Rn;ee(Gl,Pn);const An=en(()=>W.customId),{effectiveCustomHtmlTagsSet:On,mdInstance:Kn,mergedParseOptions:jn,parsedNodes:zn,getParsedNodesDirtyStartIndex:Ln,getParsedNodesRevision:En}=Wr(W,{instanceMsgId:Rn,renderContent:ln,effectiveFinal:an,smoothStreamingEnabled:on,debugPerformanceEnabled:Ve,customComponentsMap:An,logPerf:wn});X(zn,()=>{cn.value||Pn.clear(),Me.value+=1,Ne&&$o(Qr(zn.value.length))},{immediate:!0});const Dn=A(()=>({customId:W.customId,customHtmlTags:jn.value.customHtmlTags,parseOptions:W.parseOptions,customMarkdownIt:W.customMarkdownIt,htmlPolicy:Ue.value,viewportPriority:W.viewportPriority,viewportPriorityOptions:He.value,mode:g.value,domMode:W.domMode,codeBlockStream:W.codeBlockStream,codeBlockDarkTheme:W.codeBlockDarkTheme,codeBlockLightTheme:W.codeBlockLightTheme,renderCodeBlocksAsPre:w.value,codeBlockMinWidth:W.codeBlockMinWidth,codeBlockMaxWidth:W.codeBlockMaxWidth,codeBlockOptions:W.codeBlockOptions,codeBlockProps:W.codeBlockProps,mermaidProps:W.mermaidProps,d2Props:W.d2Props,infographicProps:W.infographicProps,showTooltips:qe.value,themes:W.themes,isDark:W.isDark,typewriter:b.value,smoothStreamingOptions:W.smoothStreamingOptions,parseCoalesceMs:W.parseCoalesceMs,fade:W.fade}));ee("markstreamNestedRendererProps",Dn);const Wn=A(()=>zn.value),Vn=A(()=>zn.value.length),qn=q(null),Un=q(null),Xn=q(null),Yn=q(null),Zn=null!=o.indexKey&&String(o.indexKey).startsWith("list-item-"),Gn=!Zn&&W.customId?Il(W.customId):null,Jn=A(()=>Gn?(Bl.value,Il(W.customId)):null),Qn=A(()=>{var e;return Boolean(!We.value&&W.customId&&!Zn&&(null==(e=Jn.value)?void 0:e.enabled))}),et=A(()=>Boolean(De&&Qn.value)),nt=A(()=>{var e;return Boolean(!We.value&&(null==(e=o.virtualScroll)?void 0:e.enabled))}),tt=A(()=>nt.value),rt=q(!1);be(()=>{rt.value=!0});const at=A(()=>Boolean(De&&nt.value));ee("markstreamHostScrollManaged",at);const ut=A(()=>Boolean(rt.value&&at.value)),dt=A(()=>et.value||at.value);X(dt,e=>{e&&Tl()},{immediate:!0});const ct=A(()=>et.value||ut.value),mt=A(()=>{var e;return dt.value&&!1!==(null==(e=Jn.value)?void 0:e.textEstimation)});function ft(){if(_e.value>0)return _e.value;const e=$n("getMeasuredContainerWidth.clientWidth",()=>{var e;return(null==(e=ce.value)?void 0:e.clientWidth)||0});return Number.isFinite(e)&&e>0?e:0}const vt=A(()=>{const e=ft();return e>0?Math.max(1,Math.round(e)):640}),ht=A(()=>{var e,n;return!(!0!==an.value||nt.value||"chat"!==g.value&&"minimal"!==g.value||v("maxLiveNodes")||v("liveNodeBuffer")||(null==(e=o.nodes)?void 0:e.length)||vn.value||!((null!=(n=W.maxLiveNodes)?n:0)<=0))}),pt=A(()=>{var e;return ht.value?50:Math.max(1,null!=(e=W.maxLiveNodes)?e:320)}),yt=A(()=>{var e;return ht.value?16:Math.max(0,null!=(e=W.liveNodeBuffer)?e:60)}),bt=A(()=>{var e;return!We.value&&!1!==W.nodeVirtual&&!((null!=(e=W.maxLiveNodes)?e:0)<=0&&!ht.value)&&(!0===W.nodeVirtual?zn.value.length>0:zn.value.length>pt.value)}),kt=A(()=>bt.value||et.value||at.value),wt=A(()=>!1!==W.viewportPriority),xt=A(()=>!!wt.value&&!ye.value);var St;St=A(()=>wt.value),ee(lt,St);const Mt=A(()=>{var e;return!(We.value||!1===W.deferNodesUntilVisible||(null!=(e=W.maxLiveNodes)?e:0)<=0||bt.value||zn.value.length>900||!1===W.viewportPriority)}),Ct=st(e=>{var n,t;return Ge(null!=(t=null!=(n=null==e?void 0:e.parentElement)?n:ce.value)?t:null)},wt),{requestFrame:Nt,cancelFrame:_t,hasIdleCallback:Tt,isTestEnv:Bt}=function(e){const n=e.isClient&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame.bind(window):null,t=e.isClient&&"function"==typeof window.cancelAnimationFrame?window.cancelAnimationFrame.bind(window):null,o=e.isClient&&"function"==typeof window.requestIdleCallback,l=function(){var e;if("undefined"==typeof globalThis||!("process"in globalThis))return;const n=null==(e=Object.getOwnPropertyDescriptor(globalThis,"process"))?void 0:e.value;return null==n?void 0:n.env}();return{requestFrame:n,cancelFrame:t,hasIdleCallback:o,isTestEnv:"test"===(null==l?void 0:l.NODE_ENV)}}({isClient:De}),It=A(()=>!0===an.value&&!nt.value),{resolvedBatchSize:Ht,resolvedInitialBatch:$t,batchingEnabled:Pt,incrementalRenderingActive:At,renderedCount:Kt,previousRenderContext:jt,adaptiveBatchSize:zt,previousBatchConfig:Lt}=function(e,n){var t;const o=A(()=>{var n;const t=Math.trunc(null!=(n=e.renderBatchSize)?n:80);return Number.isFinite(t)?Math.max(0,t):0}),l=A(()=>{var n;const t=Math.trunc(null!=(n=e.initialRenderBatchSize)?n:o.value);return Number.isFinite(t)?Math.max(0,t):o.value}),r=A(()=>!n.renderAsFragment.value&&!1!==e.batchRendering&&o.value>0&&n.isClient&&!n.isTestEnv),i=q(0),a=q({key:e.indexKey,total:0}),u=q(Math.max(1,o.value||1)),s=A(()=>{var t,o,l;return r.value&&!(null==(t=n.continuousStreaming)?void 0:t.value)&&!(null==(o=n.forceFullRenderFinalContent)?void 0:o.value)&&(null!=(l=e.maxLiveNodes)?l:0)<=0}),d=q({batchSize:o.value,initial:l.value,delay:null!=(t=e.renderBatchDelay)?t:16,enabled:s.value});return{resolvedBatchSize:o,resolvedInitialBatch:l,batchingEnabled:r,incrementalRenderingActive:s,renderedCount:i,previousRenderContext:a,adaptiveBatchSize:u,previousBatchConfig:d}}(W,{isClient:De,isTestEnv:Bt,renderAsFragment:We,forceFullRenderFinalContent:It,continuousStreaming:A(()=>mn.value&&!0!==an.value)}),Et=A(()=>{var e;return!We.value&&!1!==W.batchRendering&&Ht.value>0&&!Bt&&(null!=(e=W.maxLiveNodes)?e:0)<=0&&!It.value}),Dt=A(()=>Et.value),Wt=A(()=>dt.value||Dt.value),Vt=A(()=>{var e;return Wt.value&&!1!==(null==(e=Jn.value)?void 0:e.codeBlockEstimation)}),qt=/* @__PURE__ */new Map,Ut=/* @__PURE__ */new Map,Xt=/* @__PURE__ */new Map,Yt=/* @__PURE__ */new WeakMap;let Zt=null;const Gt=[];X(()=>zn.value.length,e=>{Gt.length>e&&(Gt.length=e)});const Jt=[],no=[];let io=[],uo=[],co=-1;const fo=P(no),ho=/* @__PURE__ */new Set,go=q(0);let yo=0;const bo=q(0),ko=A(()=>(bo.value,Array.from(qt.entries()).sort((e,n)=>e[0]-n[0]))),xo=q(null),Mo=q(null);let No,To=null,Io=0,Ho=null;function $o(e){No.markFallbackHeightPrefixDirty(e)}function Ro(e){return No.getFallbackNodeHeight(e)}function Po(e,n){return No.estimateHeightRange(e,n)}function Fo(e){return No.estimateIndexForOffset(e)}const{activeRestoreAnchor:Ao,getRelativeScrollTopWithinContainer:Ko,setRelativeScrollTopWithinContainer:jo,resolveAnchorOffset:zo,clearRestoreReconcile:Eo,scheduleRestoreReconcile:Wo,captureRestoreAnchor:Vo,restoreAnchor:Uo,getAnchorDrift:Xo}=function(e){const{isClient:n,containerRef:t,parsedNodeCount:o,requestFrame:l,cancelFrame:r,resolveScrollContainer:i,getNormalizedScrollTop:a,getOffsetTopWithinRoot:u,isReverseFlexScrollRoot:s,estimateIndexForOffset:d,estimateHeightRange:c,getFallbackNodeHeight:m,clamp:f}=e,v=q(null);let h=null,p=[];function g(){const e=i(),n=t.value;if(!e||!n)return null;const o=e.ownerDocument||n.ownerDocument||document;if(e===o.documentElement||e===o.body||e===o.scrollingElement){const e=n.getBoundingClientRect();return Math.max(0,-e.top)}return Math.max(0,a(e,o,!1)-u(n,e))}function y(e){var n;const o=i(),l=t.value;if(!o||!l)return;const r=Math.max(0,e),d=o.ownerDocument||l.ownerDocument||document,c=d.defaultView||("undefined"!=typeof window?window:null);if(o===d.documentElement||o===d.body||o===d.scrollingElement){const e=a(o,d,!0)+l.getBoundingClientRect().top;return void(null==(n=null==c?void 0:c.scrollTo)||n.call(c,0,Math.max(0,e+r)))}Ul(o,d,u(l,o)+r,{isReverseFlexScrollRoot:e=>{var n;return null!=(n=null==s?void 0:s(e))&&n},getNormalizedScrollTop:a})}function b(e){const n=o.value,t=f(e.nodeIndex,0,Math.max(0,n-1));return c(0,t)+Math.max(0,e.offsetWithinNodePx)}function k(){if(null!=h&&(null==r||r(h),h=null),n)for(const e of p)window.clearTimeout(e);p=[]}function w(e){const n=b(e),t=g();null!=t&&Math.abs(t-n)<=.5||y(n)}return{activeRestoreAnchor:v,getRelativeScrollTopWithinContainer:g,setRelativeScrollTopWithinContainer:y,resolveAnchorOffset:b,clearRestoreReconcile:k,applyRestoreAnchor:w,scheduleRestoreReconcile:function(){v.value&&n&&null==h&&(h=l?l(()=>{h=null,v.value&&w(v.value)}):null,null==h&&v.value&&w(v.value))},captureRestoreAnchor:function(){const e=g(),n=o.value;if(null==e||n<=0)return null;const t=f(d(e+1),0,n-1),l=c(0,t),r=m(t);return{nodeIndex:t,offsetWithinNodePx:f(e-l,0,Math.max(0,r-1))}},restoreAnchor:function(e){const t=o.value;if(v.value={nodeIndex:f(e.nodeIndex,0,Math.max(0,t-1)),offsetWithinNodePx:Math.max(0,e.offsetWithinNodePx)},k(),w(v.value),n)for(const n of[0,120,280,480])p.push(window.setTimeout(()=>{v.value&&w(v.value)},n))},getAnchorDrift:function(e){const n=g();return null==n?null:n-b(e)}}}({isClient:De,containerRef:ce,parsedNodeCount:Vn,requestFrame:Nt,cancelFrame:_t,resolveScrollContainer:()=>xo.value||Je(),getNormalizedScrollTop:nn,getOffsetTopWithinRoot:tn,isReverseFlexScrollRoot:Qe,estimateIndexForOffset:Fo,estimateHeightRange:Po,getFallbackNodeHeight:Ro,clamp:Yr}),{nodeHeights:Zo,heightStats:Go,heightTreeSize:Jo,heightSumTree:Qo,heightKnownTree:tl,averageNodeHeight:ol,resetHeightMeasurements:ll,pruneHeightMeasurements:il,rebuildHeightTrees:al,syncHeightTreeSize:sl,recordNodeHeight:dl,removeNodeHeights:cl,exportHeightCache:ml,importHeightCache:fl,fenwickRangeSum:vl}=function(e={}){const n=ge({}),t=ge({total:0,count:0}),o=q(0),l=q([]),r=q([]);function i(){for(const e of Object.keys(n))delete n[Number(e)];t.total=0,t.count=0,o.value=0,l.value=[],r.value=[]}function s(e,n,t){for(let o=n+1;o<e.length;o+=o&-o)e[o]+=t}function d(e,n){let t=0;for(let o=n+1;o>0;o-=o&-o)t+=e[o];return t}function c(e,n,t){if(t<=n)return 0;const o=d(e,t-1);return n<=0?o:o-d(e,n-1)}function m(e){o.value=e;const t=new Array(e+1).fill(0),i=new Array(e+1).fill(0);for(const[o,l]of Object.entries(n)){const n=Number(o),r=Number(l);!Number.isFinite(n)||n<0||n>=e||!Number.isFinite(r)||r<=0||(s(t,n,r),s(i,n,1))}l.value=t,r.value=i}function f(e){if(!Number.isInteger(e)||e<0)return!1;const i=n[e];if(!Number.isFinite(i)||i<=0)return!1;if(delete n[e],t.total=Math.max(0,t.total-i),t.count=Math.max(0,t.count-1),o.value>e){const n=l.value,t=r.value;n.length&&t.length&&(s(n,e,-i),s(t,e,-1))}return!0}const v=A(()=>t.count>0?Math.max(12,t.total/t.count):32);return{nodeHeights:n,heightStats:t,heightTreeSize:o,heightSumTree:l,heightKnownTree:r,averageNodeHeight:v,resetHeightMeasurements:i,pruneHeightMeasurements:function(e){if(e<=0)return void i();let o=0,l=0;for(const[t,r]of Object.entries(n)){const i=Number(t),a=Number(r);!Number.isFinite(i)||i<0||i>=e||!Number.isFinite(a)||a<=0?delete n[i]:(o+=a,l++)}t.total=o,t.count=l},rebuildHeightTrees:m,syncHeightTreeSize:function(e){const t=o.value;if(e===t)return;if(e<t||0===t)return void m(e);const i=l.value,a=r.value;i.length=e+1,a.length=e+1;for(let n=t;n<e;n++)i[n+1]=0,a[n+1]=0;for(let o=t;o<e;o++){const e=Number(n[o]);!Number.isFinite(e)||e<=0||(s(i,o,e),s(a,o,1))}for(let n=t+1;n<=e;n++){const e=n-(n&-n);e>=t||(i[n]+=c(i,e,t),a[n]+=c(a,e,t))}o.value=e},recordNodeHeight:function(i,d,c={}){!function(i,a,u={}){var d;if(!Number.isFinite(a)||a<=0)return!1;const c=n[i];if(c){if(!1===u.allowShrink&&a<c)return!1;if(Math.abs(a-c)<=1)return!1}if(n[i]=a,c?t.total+=a-c:(t.total+=a,t.count++),o.value>i){const e=l.value,n=r.value;if(e.length&&n.length)if(c){const n=a-c;0!==n&&s(e,i,n)}else s(e,i,a),s(n,i,1)}!1!==u.notify&&(null==(d=e.onHeightRecorded)||d.call(e,i))}(i,d,u(a({},c),{notify:!0}))},removeNodeHeight:function(n,t={}){var o;const l=f(n);return l&&!1!==t.notify&&(null==(o=e.onHeightRecorded)||o.call(e,n)),l},removeNodeHeights:function(n,t={}){var o;let l=0,r=Number.POSITIVE_INFINITY;for(const e of n){const n=Number(e);f(n)&&(l++,n<r&&(r=n))}return l>0&&!1!==t.notify&&(null==(o=e.onHeightRecorded)||o.call(e,Number.isFinite(r)?r:void 0)),l},exportHeightCache:function(){return Object.entries(n).map(([e,n])=>({index:Number(e),height:Number(n)})).filter(e=>Number.isFinite(e.index)&&e.index>=0&&Number.isFinite(e.height)&&e.height>0).sort((e,n)=>e.index-n.index)},importHeightCache:function(l,r={}){var i;if(!Array.isArray(l))return;const a=o.value;let u=!1;if("merge"!==r.mode){const e=Object.keys(n);if(e.length>0){for(const t of e)delete n[Number(t)];u=!0}}for(const e of l){const t=Number(e.index),o=Number(e.height);if(!Number.isInteger(t)||t<0)continue;if(a>0&&t>=a)continue;if(!Number.isFinite(o)||o<=0)continue;const l=n[t];l&&Math.abs(l-o)<=1||(n[t]=o,u=!0)}u&&(function(){let e=0,l=0;const r=o.value;for(const[t,o]of Object.entries(n)){const i=Number(t),a=Number(o);!Number.isFinite(i)||i<0||r>0&&i>=r||!Number.isFinite(a)||a<=0?delete n[i]:(e+=a,l++)}t.total=e,t.count=l}(),a>0&&m(a),null==(i=e.onHeightRecorded)||i.call(e))},fenwickRangeSum:c}}({onHeightRecorded:e=>{$o(null!=e?e:0),at.value&&Hu(),Ao.value&&Wo(),Mo.value&&xa(),du("node-resize")}});function hl(e){Number.isInteger(e)&&e>=0&&ho.add(e)}function gl(e){for(const n of e)hl(Number(n))}function bl(e){yo++;let n=!0;try{const t=e();return n=!1!==t,t}finally{yo--,0===yo&&n&&go.value++}}function xl(){io=[],uo=[],co=-1,ho.clear(),fo.value=no}function Sl(){xl(),bl(()=>ll()),Jt.length=0}function Cl(e){!Number.isInteger(e)||e<0||e>=zn.value.length||(Jt[e]=va(e))}function Nl(e,n,t={}){const o=Zo[e];hl(e),dl(e,n,t);const l=Zo[e];return Object.is(o,l)?(ho.delete(e),!1):(l&&l>0?Cl(e):o&&e<Jt.length&&(Jt[e]=void 0),!0)}function _l(e,n){const t=$n("getNodeLayoutHeight.content.offsetHeight",()=>n.offsetHeight);return t>0?t:$n("getNodeLayoutHeight.slot.offsetHeight",()=>{var n,t;return null!=(t=null==(n=qt.get(e))?void 0:n.offsetHeight)?t:0})}function Hl(e,n={}){"merge"!==n.mode?xl():gl(e.map(e=>e.index)),bl(()=>fl(e,n)),La()}const $l=A(()=>Mt.value&&xt.value),Rl=A(()=>dt.value||Et.value||$l.value&&zn.value.length>$t.value),Pl=A(()=>{var e;return!We.value&&!1!==W.batchRendering&&Ht.value>0&&(null!=(e=W.maxLiveNodes)?e:0)<=0}),Al=A(()=>!We.value&&sn&&!0===an.value&&!bt.value&&!nt.value&&!Qn.value&&!$l.value&&!Pl.value),Ll=A(()=>!!Ct&&$l.value),Dl=A(()=>[Ll.value,$l.value,bt.value,ye.value,Re.value,$e.value,$t.value,Boolean(Ct)].join("|")),Jl=A(()=>bt.value||at.value),{focusIndex:Ql,liveRange:er,updateLiveRange:tr}=function(e,n){const{parsedNodeCount:t,virtualizationEnabled:o,maxLiveNodesResolved:l,liveNodeBufferResolved:r,clamp:i}=n,a=null!=r?r:A(()=>{var n;return Math.max(0,null!=(n=e.liveNodeBuffer)?n:60)}),u=q(0),s=ge({start:0,end:0});return{liveNodeBufferResolved:a,focusIndex:u,liveRange:s,updateLiveRange:function(){const e=t.value;if(!o.value||0===e)return s.start=0,void(s.end=e);const n=Math.min(l.value,e),r=a.value,d=i(u.value-r,0,Math.max(0,e-n));s.start=d,s.end=Math.min(e,d+n)}}}(W,{parsedNodeCount:Vn,virtualizationEnabled:bt,maxLiveNodesResolved:pt,liveNodeBufferResolved:yt,clamp:Yr}),lr=/* @__PURE__ */new Map,rr=/* @__PURE__ */new Map,ir=/* @__PURE__ */new Map,sr=/* @__PURE__ */new Map,dr=[],cr=/* @__PURE__ */new Map;let mr=-1/0;const fr=/* @__PURE__ */new Set,vr=q(0);let hr=!1;const pr=A(()=>(vr.value,fr.size)),gr=/* @__PURE__ */new Map,yr=/* @__PURE__ */new Map,br=q(0);let kr=0;const wr=A(()=>(br.value,kr));let xr=null;const Sr=A(()=>{if(!bt.value)return zn.value.length;const e=yt.value,n=Math.max(er.end+e,$t.value),t=Math.min(zn.value.length,n);return Math.max(Kt.value,t)});function Mr(){hr||(hr=!0,queueMicrotask(()=>{hr=!1,vr.value+=1}))}function Cr(e,n,t="node-resize"){if(!De||"undefined"==typeof window)return null;const o=window.setTimeout(()=>{fr.delete(o)&&Mr();try{n()}finally{du(t)}},Math.max(0,e));return fr.add(o),Mr(),o}function Nr(e){De&&null!=e&&(fr.delete(e)&&Mr(),window.clearTimeout(e))}function _r(){if(De&&"undefined"!=typeof window)for(const e of fr)window.clearTimeout(e);fr.size&&(fr.clear(),Mr()),dr.length=0,sr.clear()}function Tr(e){me.value=e}function Br(e){ve.value=e}function Ir(e){he.value=e}const{cancelScheduledFocusSync:Hr,scheduleFocusSync:$r}=function(e){const{isClient:n,containerRef:t,virtualizationEnabled:o,requestFrame:l,cancelFrame:r,syncFocusToScroll:i}=e;let a=null;function u(){var e,n,o;return null!=(o=null==(n=null==(e=t.value)?void 0:e.ownerDocument)?void 0:n.defaultView)?o:"undefined"!=typeof window?window:null}function s(){if(!a)return;const e=u();a.viaTimeout?e?e.clearTimeout(a.id):clearTimeout(a.id):null==r||r(a.id),a=null}return{cancelScheduledFocusSync:s,scheduleFocusSync:function(e={}){if(!o.value)return;if(!n)return void i(!0);if(e.immediate)return s(),void i(!0);if(a)return;const t=()=>{a=null,i()};if(l)return void(a={id:l(t),viaTimeout:!1});const r=u(),d=r?r.setTimeout(t,16):setTimeout(t,16);a={id:d,viaTimeout:!0}}}}({isClient:De,containerRef:ce,virtualizationEnabled:bt,requestFrame:Nt,cancelFrame:_t,syncFocusToScroll:function(e=!1){var n;if(!bt.value)return;const t=xo.value||Je();if(!t)return;const o=t.ownerDocument||(null==(n=ce.value)?void 0:n.ownerDocument)||document,l=(null==o?void 0:o.defaultView)||("undefined"!=typeof window?window:null),r=t===(null==o?void 0:o.documentElement)||t===(null==o?void 0:o.body),i=zn.value.length;if(i<=0)return;if(!r&&i>0&&Qe(t)){const n=$n("syncFocusToScroll.clientHeight",()=>t.clientHeight||0),o=$n("syncFocusToScroll.scrollTop",()=>t.scrollTop),l=o<0?-o:o;return void Dr(Yr((a=Math.max(0,l)+.5*Math.max(0,n),No.estimateIndexForOffsetFromEnd(a)),0,Math.max(0,i-1)),e)}var a;const u=function(e,n,t,o){const l=ce.value;if(!l)return null;const r=o?0:$n("syncFocusToScroll.model.root.getBoundingClientRect",()=>e.getBoundingClientRect().top),i=$n("syncFocusToScroll.model.container.getBoundingClientRect",()=>l.getBoundingClientRect().top),a=Math.max(0,r-i),u=o?$n("syncFocusToScroll.model.viewport.clientHeight",()=>{var o,l,r,i;return null!=(i=null!=(r=null!=(l=null==t?void 0:t.innerHeight)?l:null==(o=n.documentElement)?void 0:o.clientHeight)?r:e.clientHeight)?i:0}):$n("syncFocusToScroll.model.root.clientHeight",()=>e.clientHeight);return Yr(Fo(a+.5*Math.max(0,u)),0,Math.max(0,zn.value.length-1))}(t,o,l,r);if(null!=u)return void Dr(u,e);const s=r?null:$n("syncFocusToScroll.root.getBoundingClientRect",()=>t.getBoundingClientRect()),d=r?0:s.top,c=r?$n("syncFocusToScroll.viewport.clientHeight",()=>{var e,n;return null!=(n=null!=(e=null==l?void 0:l.innerHeight)?e:t.clientHeight)?n:0}):s.bottom,m=ko.value;let f=null,v=null;for(const[h,p]of m){if(!p)continue;const e=$n("syncFocusToScroll.slot.getBoundingClientRect",()=>p.getBoundingClientRect());e.bottom<=d||e.top>=c||(null==f&&(f=h),v=h)}if(null==f||null==v){const e=ce.value;if(!e)return;const n=r?{top:0}:$n("syncFocusToScroll.fallback.root.getBoundingClientRect",()=>t.getBoundingClientRect()),i=$n("syncFocusToScroll.fallback.scrollTop",()=>nn(t,o,r)),a=r?(()=>{const t=$n("syncFocusToScroll.fallback.container.getBoundingClientRect",()=>e.getBoundingClientRect()),o=(r?0:n.top)-t.top;return Math.max(0,o)})():(()=>{const n=tn(e,t);return Math.max(0,i-n)})(),u=r?$n("syncFocusToScroll.fallback.viewport.clientHeight",()=>{var e,n,r,i;return null!=(i=null!=(r=null!=(n=null==l?void 0:l.innerHeight)?n:null==(e=null==o?void 0:o.documentElement)?void 0:e.clientHeight)?r:t.clientHeight)?i:0}):$n("syncFocusToScroll.fallback.root.clientHeight",()=>t.clientHeight);return void Dr(Yr(Fo(a+.5*Math.max(0,u)),0,Math.max(0,zn.value.length-1)),!0)}Dr(Math.round((f+v)/2),e)}}),{visibleNodeIndices:Rr,nodeVisibilityHandles:Pr,nodeVisibilityWatchStops:Fr,nodeVisibilityFallbackTimers:Ar,clearVisibilityFallback:Or,markNodeVisible:Kr,cleanupNodeVisibility:jr,destroyNodeVisibilityState:zr}=Vr({isClient:De,shouldTrackVisibleNodeIndices:()=>$l.value,shouldCleanupNodeVisibility:()=>bt.value,onNodeMarkedVisible:e=>{bt.value?$r():Ql.value=Yr(e,0,Math.max(0,zn.value.length-1))},onNodeVisibilityCleaned:e=>{qt.delete(e)&&cu()}}),{cleanupScrollListener:Lr,setupScrollListener:Er}=qr({isClient:De,virtualizationEnabled:bt,listenerEnabled:Jl,scrollRootElement:xo,resolveScrollContainer:Je,scheduleFocusSync:$r,onScroll:function(){const e=Mo.value;if(!e)return;const n=na();if(!n)return;if(function(e){if(eu()>=Io)return Ho=null,!1;const n=Ho;if(null==n)return!0;const t=Math.abs(e.scrollTop-n)<=2;return t||(Ho=null),t}(n))return;const t=oa(n);null!=t?(t<-32||Math.abs(Math.max(0,t)-Math.max(0,e.distanceFromBottomPx))>32)&&wa("restore"):wa("restore")},requestFrame:Nt,cancelFrame:_t,getScrollTop:e=>{var n;const t=e.ownerDocument||(null==(n=ce.value)?void 0:n.ownerDocument)||document,o=e===t.documentElement||e===t.body||e===t.scrollingElement;return $n("scrollListener.getScrollTop",()=>nn(e,t,o))}});function Dr(e,n=!1){const t=Yr(e,0,Math.max(0,zn.value.length-1));!n&&Math.abs(t-Ql.value)<=1||(Ql.value=t,tr())}function Yr(e,n,t){return Math.min(Math.max(e,n),t)}function Qr(e=zn.value.length){const n=Ln();return!Number.isInteger(n)||n<0?e:Yr(n,0,e)}function ei(e){return null==e?void 0:e.firstElementChild}function di(e,n){var t;return e?(null==(t=e.matches)?void 0:t.call(e,n))?e:e.querySelector(n):null}function ci(e,n){e<1||e>6||(pe[e]=n)}function mi(){if(!Rl.value||"undefined"==typeof ResizeObserver)return void(_e.value=0);const e=$n("updateMeasuredContainerWidth.clientWidth",()=>{var e,n;return null!=(n=null==(e=ce.value)?void 0:e.clientWidth)?n:0});_e.value=e>0?e:0}let fi=null;function vi(){null==fi||fi.disconnect(),fi=null}const hi=A(()=>w.value?to:oo);function pi(){var e;return!1!==(null==(e=W.codeBlockProps)?void 0:e.showHeader)}function gi(){var e;return!1!==(null==(e=W.codeBlockProps)?void 0:e.showCopyButton)}function yi(){var e,n;const t=null==(e=W.codeBlockProps)?void 0:e.showLineNumbers;return"boolean"==typeof t?t:!0!==(null==(n=W.codeBlockOptions)?void 0:n.disableLineNumbers)}function bi(e,n,t){var o;const l=Zo[n],r="number"==typeof l&&l>0;if(mt.value&&!r&&!function(e){return!!An.value.paragraph&&("paragraph"===e.type||"list_item"===e.type||"list"===e.type)}(e)){const n=Fl(e,t,Te.value);if(n)return n}if(Vt.value&&!r&&"code_block"===e.type){const n=function(e){if("code_block"!==e.type)return null;const n=ys(e,fs(e));return n===to?"pre":n===hi.value||n===oo?"stream-diffs":null}(e);if("stream-diffs"===n||"pre"===n)return function(e,n){if(!e||"code_block"!==e.type)return null;const t=n.rendererKind,o="pre"!==t&&!1!==n.showHeader,l="pre"===t&&!1!==n.showHeader,r=Boolean(e.diff);let i=0,u=500;if("stream-diffs"===t){const t=Kl(e,n.diffStyle),o=18,l=function(e){return e?0:16}(r);u=500,i=Math.round(t*o+l)}else{const t=Qt(n.codeBlockOptions),o=function(e,n,t){var o,l;const r=Kl(e,n.diffStyle),i=Number(n.width);if("wrap"!==t.overflow||!Number.isFinite(i)||i<=0)return r;const a=Math.max(1,.6*t.fontSize),u=Boolean(e.diff),s=u&&Ot({diffStyle:n.diffStyle});if(!u||s){const o=(u?Ol(e.raw)||[Ol(e.originalCode),Ol(e.updatedCode)].filter(Boolean).join("\n"):Ol(e.code,!0===e.loading)).split(/\r\n|\n|\r/),l=zl(i,a,o.length,t,n,!1);return o.reduce((e,n)=>e+jl(n,l,t.tabSize),0)}const d=Ol(e.originalCode).split(/\r\n|\n|\r/),c=Ol(e.updatedCode).split(/\r\n|\n|\r/);if(null==e.originalCode&&null==e.updatedCode)return r;const m=Math.max(d.length,c.length),f=zl(i,a,m,t,n,!0);let v=0;for(let h=0;h<m;h++)v+=Math.max(jl(null!=(o=d[h])?o:"",f,t.tabSize),jl(null!=(l=c[h])?l:"",f,t.tabSize));return v}(e,n,t);i=Math.round(o*t.lineHeight+t.padding+t.paddingBottom),u=t.maxHeight}const s=Math.max(1,Math.min(i,u));return a({kind:"code-block",height:Math.round(s+("pre"===t?l?37:0:o?40:0)),contentHeight:s,rendererKind:t},r&&"stream-diffs"===t?{diffInline:Ot({diffStyle:n.diffStyle})}:{})}(e,{rendererKind:n,codeBlockOptions:W.codeBlockOptions,showHeader:pi(),showLineNumbers:yi(),width:t,diffStyle:null==(o=W.codeBlockOptions)?void 0:o.diffStyle})}return null}ke(()=>{if(go.value,yo>0)return;const e=zn.value,n=En();if(!e.length||!Wt.value)return io=[],uo=[],co=-1,ho.clear(),void(fo.value=no);const t=_e.value||$n("estimatedNodeHeights.clientWidth",()=>{var e;return(null==(e=ce.value)?void 0:e.clientWidth)||0});if(!Number.isFinite(t)||t<=0)return io=[],uo=[],co=-1,ho.clear(),void(fo.value=no);const o=function(e){var n,t;const o=Qt(W.codeBlockOptions);return[Math.round(e),mt.value,Vt.value,Te.value,o.fontSize,o.lineHeight,o.fontFamily,o.padding,o.paddingBottom,o.maxHeight,o.tabSize,o.overflow,null!=(t=null==(n=W.codeBlockOptions)?void 0:n.diffStyle)?t:"split",yi(),pi(),gi(),w.value,An.value,Bl.value]}(t),l=io.length<=e.length&&(i=o,(r=uo).length===i.length&&r.every((e,n)=>Object.is(e,i[n])));var r,i;const a=l&&co===n?e.length:l?Qr(e.length):0,u=l?Array.from(ho):[];io.length=e.length;for(let s=a;s<e.length;s++)io[s]=bi(e[s],s,t);for(const s of u)s>=0&&s<e.length&&s<a&&(io[s]=bi(e[s],s,t));ho.clear(),uo=o,co=n,fo.value=io,we(fo)},{flush:"sync"});const wi=A(()=>fo.value);No=function(e){let n=!0,t=-1;const o=[0];let l="",r=-1;const i=/* @__PURE__ */new WeakMap;function a(e=0){n=!0,e<=0?t=0:(t<0||e<t)&&(t=e)}function u(n){var t;const o=e.nodeHeights[n];if(Number.isFinite(o)&&o>0)return o;const l=e.parsedNodes.value[n],r=null==l?void 0:l.type,a=Boolean(null==(t=e.hasCustomParagraphComponent)?void 0:t.call(e)),u=e.estimatedNodeHeights.value[n],s=null==u?void 0:u.height;if(!function(e,n,t){return Boolean(t&&"simple-text"===(null==n?void 0:n.kind)&&("paragraph"===e||"list_item"===e||"list"===e))}(r,u,a)&&Number.isFinite(s)&&s>0)return s;const d=function(n,t){var o;if(!n||"object"!=typeof n||!1===(null==(o=e.shouldCacheStaticFallbackHeight)?void 0:o.call(e)))return ar(n,t);const l=n,r=i.get(l);if(r&&r.width===t)return r.height;const a=ar(n,t);return i.set(l,{width:t,height:a}),a}(l,e.getContainerWidth()||640);return"heading"===r||"paragraph"===r&&d<=28&&function(e,n){if(n)return!1;const t=e.children;return!Array.isArray(t)||!t.length||t.every(or)}(l,a)?d:Math.max(e.averageNodeHeight.value,d)}function s(){var i;const s=e.parsedNodes.value.length,d=e.getPrefixCacheKeyParts().join(":"),c=o;l!==d&&(l=d,a(0));const m=e.averageNodeHeight.value;r!==m&&(r=m,a(0)),c.length>s+1&&(c.length=s+1,t>=0&&t>=c.length-1&&(n=!1));const f=c.length-1;if(!n){if(f===s)return c;t=f}const v=Math.min(t,f);c.length<s+1&&(c.length=s+1);for(let n=v;n<s;n++)c[n+1]=c[n]+(e.heightEstimationActive.value?u(n):null!=(i=e.nodeHeights[n])?i:m);return n=!1,t=s,c}function d(n){var t,o;const l=e.parsedNodes.value.length;if(l<=0)return 0;if(n<=0)return 0;const r=s();if(n>=(null!=(t=r[l])?t:0))return l-1;let i=0,a=l-1,u=l-1;for(;i<=a;){const e=i+a>>1;(null!=(o=r[e+1])?o:0)>=n?(u=e,a=e-1):i=e+1}return u}function c(n,t){var o,l;if(n>=t)return 0;if(e.heightEstimationActive.value)return function(n,t){var o,l;const r=e.parsedNodes.value.length,i=ur(Math.trunc(n),0,r),a=ur(Math.trunc(t),i,r);if(i>=a)return 0;const u=s();return(null!=(o=u[a])?o:0)-(null!=(l=u[i])?l:0)}(n,t);if(e.heightTreeSize.value!==e.parsedNodes.value.length){let l=0;for(let r=n;r<t;r++)l+=null!=(o=e.nodeHeights[r])?o:e.averageNodeHeight.value;return l}const r=e.heightSumTree.value,i=e.heightKnownTree.value;if(!r.length||!i.length){let o=0;for(let r=n;r<t;r++)o+=null!=(l=e.nodeHeights[r])?l:e.averageNodeHeight.value;return o}return e.fenwickRangeSum(r,n,t)+(t-n-e.fenwickRangeSum(i,n,t))*e.averageNodeHeight.value}function m(n){var t;if(n<=0)return 0;const o=e.parsedNodes.value;if(e.heightEstimationActive.value)return d(n);if(e.heightTreeSize.value===o.length&&e.heightSumTree.value.length&&e.heightKnownTree.value.length){const t=e.averageNodeHeight.value,l=e.heightSumTree.value,r=e.heightKnownTree.value,i=n=>n<=0?0:e.fenwickRangeSum(l,0,n)+(n-e.fenwickRangeSum(r,0,n))*t;let a=0,u=o.length-1,s=o.length-1;for(;a<=u;){const e=a+u>>1;i(e+1)>=n?(s=e,u=e-1):a=e+1}return s}let l=n;for(let r=0;r<o.length;r++){const n=null!=(t=e.nodeHeights[r])?t:e.averageNodeHeight.value;if(l<=n)return r;l-=n}return Math.max(0,o.length-1)}function f(){if(!e.heightEstimationActive.value)return 0;let n=0;const t=e.estimatedNodeHeights.value;for(let o=0;o<t.length;o++){if(!t[o])continue;const l=e.nodeHeights[o];Number.isFinite(l)&&l>0||n++}return n}return{markFallbackHeightPrefixDirty:a,getFallbackNodeHeight:u,estimateHeightRange:c,estimateIndexForOffset:m,estimateIndexForOffsetFromEnd:function(n){var t,o;const l=e.parsedNodes.value;if(!l.length)return 0;if(n<=0)return Math.max(0,l.length-1);if(e.heightEstimationActive.value){const e=null!=(t=s()[l.length])?t:0;return d(Math.max(0,e-n))}if(e.heightTreeSize.value===l.length){const e=c(0,l.length);return m(Math.max(0,e-n))}let r=n;for(let i=l.length-1;i>=0;i--){const n=null!=(o=e.nodeHeights[i])?o:e.averageNodeHeight.value;if(r<=n)return i;r-=n}return 0},getEstimatedNodeHeightCount:f,buildVirtualHeightSummary:function(n){var t;const o=e.parsedNodes.value.length;return{totalNodes:o,measuredCount:e.heightStats.count,estimatedCount:f(),averageNodeHeight:e.averageNodeHeight.value,topSpacerHeight:n.topSpacerHeight,bottomSpacerHeight:n.bottomSpacerHeight,estimatedTotalHeight:c(0,o),width:null!=(t=n.width)?t:e.getContainerWidth()}}}}({parsedNodes:zn,nodeHeights:Zo,heightStats:Go,heightTreeSize:Jo,heightSumTree:Qo,heightKnownTree:tl,averageNodeHeight:ol,heightEstimationActive:dt,estimatedNodeHeights:wi,getContainerWidth:ft,shouldCacheStaticFallbackHeight:()=>{var e;return!(null==(e=o.nodes)?void 0:e.length)},hasCustomParagraphComponent:()=>Boolean(An.value.paragraph),getPrefixCacheKeyParts:()=>{var e;const n=nr(_e.value||$n("getFallbackHeightPrefix.clientWidth",()=>{var e;return(null==(e=ce.value)?void 0:e.clientWidth)||0}));return[null==(null==(e=o.virtualScroll)?void 0:e.measurementKey)?"":String(o.virtualScroll.measurementKey),n,dt.value?1:0,Bl.value,An.value.paragraph?1:0]},fenwickRangeSum:vl}),Ne=!0,X(()=>zn.value.length,(e,n)=>{var t;$o(null!=n&&e>=n?Qr(e):0),e<=0?Sl():(e<Jo.value&&(t=e,xl(),bl(()=>il(t))),sl(e))},{immediate:!0});const xi=A(()=>{if(!bt.value)return zn.value.map((e,n)=>({node:e,index:n}));const e=zn.value.length,n=Yr(er.start,0,e),t=Yr(er.end,n,e);return zn.value.slice(n,t).map((e,t)=>({node:e,index:n+t}))}),Si=A(()=>bt.value?Po(0,Math.min(er.start,zn.value.length)):0),Mi=A(()=>{if(!bt.value)return 0;const e=zn.value.length;return Po(Math.min(er.end,e),e)});function Ci(){return No.buildVirtualHeightSummary({topSpacerHeight:Si.value,bottomSpacerHeight:Mi.value,width:Pi()})}function Ni(){const e=zn.value,n=Ci();return u(a({},n),{probe:{paragraphReady:Boolean(Te.value.paragraph),listItemReady:Boolean(Te.value.listItem),listWrapperOverhead:Te.value.listWrapperOverhead,headingReadyLevels:Object.entries(Te.value.headings).filter(([,e])=>Boolean(e)).map(([e])=>Number(e))},nodes:e.map((e,n)=>{var t,o,l,r,i,a,u,s,d;return{index:n,type:e.type,estimateKind:null!=(o=null==(t=wi.value[n])?void 0:t.kind)?o:null,rendererKind:null!=(r=null==(l=wi.value[n])?void 0:l.rendererKind)?r:null,estimatedHeight:null!=(a=null==(i=wi.value[n])?void 0:i.height)?a:null,estimatedContentHeight:null!=(s=null==(u=wi.value[n])?void 0:u.contentHeight)?s:null,measuredHeight:null!=(d=Zo[n])?d:null}})})}function _i(){return null!=o.indexKey?String(o.indexKey):nt.value?`virtual-${Bi()}`:"markdown-renderer"}function Ti(e){const n=String(e),t=`${_i()}-`;if(!n.startsWith(t))return null;const o=n.slice(t.length).match(/^(\d+)(?:$|-)/);if(!o)return null;const l=Number(o[1]);return!Number.isInteger(l)||l<0||l>=zn.value.length?null:l}function Bi(){var e,n,t;const l=null==(e=o.virtualScroll)?void 0:e.sessionKey;return String(null!=l&&""!==l?l:null!=(t=null!=(n=o.indexKey)?n:W.customId)?t:Rn)}function Ii(){var e;const n=null==(e=o.virtualScroll)?void 0:e.threadKey;return null==n||""===n?void 0:String(n)}const Hi=A(()=>{var e,n,t;return null!=(t=Ii())?t:String(null!=(n=null!=(e=o.indexKey)?e:W.customId)?n:Rn)});function $i(e){var n;return(null!=e?e:"")===(null!=(n=Ii())?n:"")}function Ri(){var e,n,t;return n=null==(e=o.virtualScroll)?void 0:e.measurementKey,t=function(e){const n=e.codeBlockProps,t=e.codeBlockOptions,o=null==t?void 0:t.parseDiffOptions;return[e.isDark?"dark":"light",e.renderCodeBlocksAsPre?"code-pre":"code-rich",!1===e.codeBlockStream?"code-static":"code-stream",ii(e.codeBlockMinWidth),ii(e.codeBlockMaxWidth),ii(null==t?void 0:t.fontSize),ii(null==t?void 0:t.lineHeight),ii(null==t?void 0:t.fontFamily),ii(null==t?void 0:t.maxHeight),ii(null==t?void 0:t.tabSize),ii(null==t?void 0:t.padding),ii(null==t?void 0:t.overflow),ii(null==t?void 0:t.disableLineNumbers),ii(null==t?void 0:t.diffStyle),ii(null==t?void 0:t.diffIndicators),ii(null==t?void 0:t.hunkSeparators),ii(null==t?void 0:t.expandUnchanged),ii(null==t?void 0:t.collapsedContextThreshold),ii(null==t?void 0:t.expansionLineCount),ii(null==o?void 0:o.context),ii(null==n?void 0:n.showHeader),ii(null==n?void 0:n.showCopyButton),ii(null==n?void 0:n.showExpandButton),ii(null==n?void 0:n.showPreviewButton),ii(null==n?void 0:n.showCollapseButton),ii(null==n?void 0:n.showFontSizeButtons),ii(null==n?void 0:n.showLineNumbers)].join("\0")}({renderCodeBlocksAsPre:w.value,isDark:W.isDark,codeBlockStream:W.codeBlockStream,codeBlockMinWidth:W.codeBlockMinWidth,codeBlockMaxWidth:W.codeBlockMaxWidth,codeBlockOptions:W.codeBlockOptions,codeBlockProps:W.codeBlockProps}),[null==n?"":String(n),t].join("\0")}function Pi(){return ft()}const Fi=A(()=>nr(Pi())),Ai=A(()=>[Ri(),Fi.value].join("\0")),Oi=A(()=>{var e;return nt.value?["virtual",null!=(e=Ii())?e:"",Bi(),Ai.value].join("\0"):o.indexKey});function Ki(){br.value+=1}function ji(e){return!(!e||!Number.isInteger(e.index)||e.index<0||e.index>=zn.value.length||e.sessionKey!==Bi()||e.threadKey!==Ii()||e.layoutEpochKey!==Ai.value)}function zi(e){const n=String(e),t=yr.get(n);return t?ji(t)?t.index:null:Ti(n)}function Li(e="async-node"){(gr.size||yr.size)&&(kr=0,gr.clear(),yr.clear(),Ki(),du(e))}const Ei=F(Ce,null),Di={reportHeight(e,n){if(!at.value)return;const t=zi(e);if(null==t)return;const o=lr.get(t);if(!o)return;const l=Number(n),r=_l(t,o);!function(e,n,t={}){bl(()=>Nl(e,n,t))}(t,Number.isFinite(l)&&l>0?Math.max(l,r||0):r)},markPending(e){if(!at.value)return;const n=Ti(e);null!=n&&function(e,n){var t;const o=yr.get(e);if(o&&ji(o))return gr.set(e,Math.max(0,null!=(t=gr.get(e))?t:0)+1),kr+=1,Ki(),void du("async-node");gr.set(e,1),kr+=1,yr.set(e,function(e){return{index:e,sessionKey:Bi(),threadKey:Ii(),layoutEpochKey:Ai.value}}(n)),Ki(),du("async-node")}(String(e),n)},markSettled(e){if(!at.value)return;const n=String(e),t=zi(e);if((null!=t||function(e){return gr.has(String(e))}(n))&&function(e){var n;const t=null!=(n=gr.get(e))?n:0;return!(t<=0||(t<=1?(gr.delete(e),yr.delete(e)):gr.set(e,t-1),kr=Math.max(0,kr-1),Ki(),1===t&&du("async-node"),0))}(n)&&null!=t){const e=lr.get(t);e&&yu(t,e)}}};function Wi(e){if(void 0!==e)return e;let n=0;for(const t of lr.values())n+=$n("getVisibleDomHeight.offsetHeight",()=>t.offsetHeight);return n}ee(Ce,{reportHeight(e,n){Di.reportHeight(e,n),null==Ei||Ei.reportHeight(e,n)},markPending(e){Di.markPending(e),null==Ei||Ei.markPending(e)},markSettled(e){Di.markSettled(e),null==Ei||Ei.markSettled(e)}});let Vi,qi=null,Ui=null;function Xi(e){return!1!==e&&null!=e&&""!==e}function Yi(){return bt.value?function(){if(!bt.value)return!0;const e=zn.value.length,n=Yr(er.start,0,e),t=Yr(er.end,n,e);if(n>=t)return!0;for(let o=n;o<t;o++){if(!qt.has(o))return!1;if(mu(o)&&!lr.has(o))return!1}return!0}():Kt.value>=Sr.value}function Zi(){return!0===an.value&&!cn.value&&0===wr.value&&0===fr.size&&0===cr.size&&null==xr&&Yi()}function Gi(){var e,n;if("manual"!==(null==(e=o.virtualScroll)?void 0:e.settleMode))return!0;if(qi===Bi()&&Vi===Ii())return!0;const t=null==(n=o.virtualScroll)?void 0:n.settledToken;return!!Xi(t)&&Ui===Pu(t)}function Ji(){return Zi()&&Gi()}function Qi(e,n){return n.totalNodes<=0?"final"===e?"final":"estimate":n.measuredCount>=n.totalNodes?"final"===e?"final":"measured":n.measuredCount>0||n.estimatedCount>0?"mixed":"estimate"}function ea(e="manual",n,t){const o=Ci(),l=function(e){return e||(!0!==an.value?zn.value.length>0?"streaming":"estimating":!Yi()||cr.size>0||null!=xr?"measuring":Ji()?"settled":"settling")}(n);return{sessionKey:Bi(),threadKey:Ii(),phase:l,nodeCount:o.totalNodes,liveRange:{start:er.start,end:er.end},renderedCount:Kt.value,measuredCount:o.measuredCount,estimatedCount:o.estimatedCount,averageNodeHeight:o.averageNodeHeight,topSpacerHeight:o.topSpacerHeight,bottomSpacerHeight:o.bottomSpacerHeight,visibleDomHeight:Wi(t),totalHeight:ta(o),width:o.width,final:!0===an.value,stable:Ji(),confidence:Qi(l,o),reason:e}}function na(){const e=xo.value||Je(),n=ce.value;if(!e||!n)return null;const t=e.ownerDocument||n.ownerDocument||document,o=e===t.documentElement||e===t.body||e===t.scrollingElement,l=$n("getScrollBox.scrollTop",()=>nn(e,t,o)),r=$n("getScrollBox.scrollHeight",()=>{var n,l,r,i,a;return o?Math.max(null!=(l=null==(n=t.documentElement)?void 0:n.scrollHeight)?l:0,null!=(i=null==(r=t.body)?void 0:r.scrollHeight)?i:0,null!=(a=e.scrollHeight)?a:0):e.scrollHeight}),i=$n("getScrollBox.clientHeight",()=>{var n;return o?(null==(n=t.documentElement)?void 0:n.clientHeight)||e.clientHeight||0:e.clientHeight});return{root:e,doc:t,isViewportRoot:o,scrollTop:l,scrollHeight:r,clientHeight:i}}function ta(e){var n;const t=zn.value.length,o=Math.max(0,Po(0,t)),l=$n("getRendererLogicalHeight.offsetHeight",()=>{var e,n;return null!=(n=null==(e=ce.value)?void 0:e.offsetHeight)?n:0}),r=Math.max(0,l>0?l:$n("getRendererLogicalHeight.scrollHeight",()=>{var e,n;return null!=(n=null==(e=ce.value)?void 0:e.scrollHeight)?n:0}));return t<=0?Math.ceil(l):bt.value?o>0?Math.max(1,Math.ceil(o),function(){let e=Si.value+Mi.value;for(const n of qt.values())n&&(e+=Math.max(0,$n("getVirtualizedDomLogicalHeight.offsetHeight",()=>n.offsetHeight||0)));return Math.ceil(Math.max(0,e))}(),function(e,n){return e<=0||n<=0?0:n<=e+Math.max(512,.05*e)?Math.ceil(n):0}(o,r)):Math.max(1,Math.ceil(r)):at.value?o>0||Go.count>0||(null!=(n=null==e?void 0:e.estimatedCount)?n:No.getEstimatedNodeHeightCount())>0?(At.value&&Kt.value,Math.max(1,Math.ceil(r),Math.ceil(o))):Math.ceil(r):Math.max(1,Math.ceil(r),Math.ceil(o))}function oa(e){const n=ce.value;if(!n)return null;const t=$n("getRendererBottomDistanceFromViewport.getBoundingClientRect",()=>n.getBoundingClientRect()),o=function(e){return e.isViewportRoot?e.clientHeight:$n("getViewportBottomInRoot.getBoundingClientRect",()=>e.root.getBoundingClientRect().bottom)}(e);return o-t.bottom}function la(e={}){const n=!1!==e.requireViewport,t=function(e=64){const n=na(),t=ce.value;if(!n||!t)return!1;const o=function(e){if(e.isViewportRoot)return{top:0,bottom:e.clientHeight};const n=$n("getVirtualViewportRect.getBoundingClientRect",()=>e.root.getBoundingClientRect());return{top:n.top,bottom:n.bottom}}(n),l=$n("isRendererNearVirtualViewport.getBoundingClientRect",()=>t.getBoundingClientRect());return l.bottom>=o.top-e&&l.top<=o.bottom+e}();if(n&&!t)return null;const o=function(){const e=na(),n=ce.value;if(!e||!n)return null;if(Math.max(0,e.scrollHeight-e.scrollTop-e.clientHeight)>64)return null;const t=oa(e);return null==t?null:t>=-8&&t<=160?{type:"bottom",distanceFromBottomPx:Math.max(0,t)}:null}();if(o)return{anchor:o,captured:!0};const l=Vo();if(l)return{anchor:{type:"node",nodeIndex:l.nodeIndex,offsetWithinNodePx:l.offsetWithinNodePx},captured:t};if(!0===e.allowFallback){const e=function(){const e=zn.value.length;return e<=0?null:{type:"node",nodeIndex:Yr(Ql.value,0,Math.max(0,e-1)),offsetWithinNodePx:0}}();return e?{anchor:e,captured:!1}:null}return null}function ra(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function ia(e,n){let t=e;for(let o=0;o<n.length;o++)t^=n.charCodeAt(o),t=Math.imul(t,16777619);return t^=31,t=Math.imul(t,16777619),t}const aa=/* @__PURE__ */new Set(["children","items","header","rows","cells","attrs","data","term","definition"]);function ua(e,n=/* @__PURE__ */new WeakSet,t=0){if(null==e||"number"==typeof e||"boolean"==typeof e)return String(e);if("string"==typeof e)return`s:${function(e){const n=e.length>8192?`${e.slice(0,8192)}...${e.length}`:e;return`${e.length}:${ra(n)}`}(e)}`;if("function"==typeof e)return"fn";if("object"!=typeof e)return typeof e;if(n.has(e))return"cycle";if(t>=6)return"max-depth";n.add(e);try{if(Array.isArray(e)){if(e.length<=160){const o=[];for(let l=0;l<e.length;l++)o.push(ua(e[l],n,t+1));return`a:${e.length}:${o.join(",")}`}const o=[],l=[],r=Math.max(0,e.length-32);let i=2166136261;for(let a=0;a<e.length;a++){const u=ua(e[a],n,t+1);i=ia(i,u),a<32&&o.push(u),a>=r&&l.push(u)}return[`a:${e.length}`,`h=${o.join(",")}`,`t=${l.join(",")}`,`all=${(i>>>0).toString(36)}`].join(":")}const o=e,l=Object.keys(o).filter(e=>{const n=o[e];return"parent"!==e&&"el"!==e&&"component"!==e&&(null==n||"string"==typeof n||"number"==typeof n||"boolean"==typeof n||aa.has(e))}).sort();return`o:${l.length}:${l.map(e=>`${e}=${ua(o[e],n,t+1)}`).join(";")}`}finally{n.delete(e)}}let sa=-1;const da=/* @__PURE__ */new Map;let ca=-1,ma="",fa=[2166136261];function va(e){var n;const t=zn.value[e],l=En();if(sa!==l&&(sa=l,da.clear()),!t)return"";if((null==(n=o.nodes)?void 0:n.length)||W.parseOptions||W.customMarkdownIt||Kn.value.__markstreamHasCustomParserExtensions||0!==Object.keys(An.value).length)return ra(ua(t));const r=da.get(e);if(void 0!==r)return r;const i=ra(ua(t));return da.set(e,i),i}function ha(e,n){let t=e;for(let o=0;o<n.length;o++)t^=n.charCodeAt(o),t=Math.imul(t,16777619);return t>>>0}function pa(){var e,n;const t=Me.value;if(ca===t)return ma;const o=zn.value.length;let l=Qr(o);(ca!==t-1||l>o||fa.length<l+1)&&(l=0),0===l?fa=[2166136261]:fa.length=l+1;for(let r=l;r<o;r++){const n=va(r);fa[r+1]=ha(null!=(e=fa[r])?e:2166136261,n)}return fa.length=o+1,ma=((null!=(n=fa[o])?n:2166136261)>>>0).toString(36),ca=t,ma}function ga(e,n={}){var t;const l=!0===n.includeHeightCache,r=null!=(t=n.includeContentHash)?t:l,i=l?function(e){const n=function(){var e,n;const t=Number(null!=(n=null==(e=o.virtualScroll)?void 0:e.heightCacheLimit)?n:5e3);return!Number.isFinite(t)||t<=0?Number.POSITIVE_INFINITY:Math.max(1,Math.trunc(t))}();if(!Number.isFinite(n)||e.length<=n)return e;const t=/* @__PURE__ */new Map,l=e=>{!e||t.size>=n||t.set(e.index,e)},r=zn.value.length,i=Yr(er.start-2*yt.value,0,r),a=Yr(er.end+2*yt.value,i,r);for(const o of e)o.index>=i&&o.index<a&&l(o);const u=Math.max(1,Math.ceil(e.length/n));for(let o=0;o<e.length&&t.size<n;o+=u)l(e[o]);for(let o=e.length-1;o>=0&&t.size<n;o-=u)l(e[o]);return Array.from(t.values()).sort((e,n)=>e.index-n.index).slice(0,n)}(ml().map(e=>{var n;const t=zn.value[e.index];return t?u(a({},e),{nodeType:String(null!=(n=t.type)?n:""),signature:va(e.index)}):null}).filter(e=>Boolean(e))):[],s=la({allowFallback:!0===n.allowAnchorFallback,requireViewport:n.requireViewport});return s||i.length||!0===n.includeEmptyState?u(a({sessionKey:e.sessionKey,threadKey:e.threadKey},s?{anchor:s.anchor,anchorCaptured:s.captured}:{anchorCaptured:!1}),{metrics:e,width:e.width,contentHash:r?pa():void 0,measurementKey:Ri()||void 0,heightCache:i.length?i:void 0}):null}function ya(e){var n,t;const o=na();if(!o)return;const l=function(e){const n=ce.value;if(!n)return null;const t=tn(n,e.root),o=zn.value.length,l=$n("getRendererBottomOffsetWithinRoot.offsetHeight",()=>n.offsetHeight||0),r=Math.max(0,l>0?l:o>0?$n("getRendererBottomOffsetWithinRoot.scrollHeight",()=>n.scrollHeight||0):0),i=ta();return t+Math.max(r,i)}(o);if(null==l)return;const r=Math.max(0,e.distanceFromBottomPx),i=Math.max(0,l-o.clientHeight-r);(function(e){Io=eu()+120,Ho=e})(i),o.isViewportRoot?null==(t=null==(n=o.doc.defaultView)?void 0:n.scrollTo)||t.call(n,0,i):Ul(o.root,o.doc,i,{isReverseFlexScrollRoot:Qe,getNormalizedScrollTop:nn})}const ba=[];function ka(){if(De)for(null!=To&&(null==_t||_t(To),To=null);ba.length;){const e=ba.pop();null!=e&&window.clearTimeout(e)}}function wa(e){const n=Boolean(Mo.value);Mo.value=null,Io=0,Ho=null,ka(),n&&e&&du(e)}function xa(){if(!Mo.value||!De)return;if(null!=To)return;const e=()=>{To=null;const e=Mo.value;e&&ya(e)};To=Nt?Nt(e):null,null==To&&e()}function Sa(e,n={}){const t=zn.value.length;return t<=0?[]:e.filter(e=>!(!Number.isInteger(e.index)||e.index<0||e.index>=t)&&!(!Number.isFinite(e.height)||e.height<=0)&&!(n.requireSignature&&!e.signature)&&!(n.requireCompatibilityMetadata&&!e.nodeType&&!e.signature)&&function(e){var n;const t=zn.value[e.index];return!(!t||e.nodeType&&e.nodeType!==String(null!=(n=t.type)?n:"")||e.signature&&e.signature!==va(e.index))}(e))}function Ma(e){const n=nr(Pi()),t=nr(e);return-1!==n&&-1!==t&&n===t}function Ca(e){var n;const t=Number(null==e?void 0:e.width);if(Number.isFinite(t)&&t>0)return t;const o=Number(null==(n=null==e?void 0:e.metrics)?void 0:n.width);return Number.isFinite(o)&&o>0?o:null}function Na(e){var n;return e.sessionKey===Bi()&&!!$i(e.threadKey)&&(null!=(n=e.measurementKey)?n:"")===Ri()&&!!Ma(Ca(e))&&!!function(e){const n=e.heightCache;return!!(null==n?void 0:n.length)&&(_a(e)?n.some(e=>Boolean(e.nodeType||e.signature)):n.some(e=>Boolean(e.signature)))}(e)}function _a(e){return Boolean(e.contentHash&&e.contentHash===pa())}function Ta(e){return!_a(e)}let Ba=null,Ia=null,Ha=null,$a=null,Ra=null,Pa=!1;function Fa(e){var n;const t=e.map(e=>{var n,t;return[e.index,Math.round(10*e.height),null!=(n=e.nodeType)?n:"",null!=(t=e.signature)?t:""].join("")}).join(""),o=nr(Pi());return[null!=(n=Ii())?n:"",Bi(),Ri(),zn.value.length,o,e.length,ra(t)].join(":")}function Aa(e=(e=>null==(e=o.virtualScroll)?void 0:e.heightCache)()){if(!at.value||!(null==e?void 0:e.length))return!1;if(zn.value.length<=0)return!1;if(!Ma(null==(n=o.virtualScroll)?void 0:n.heightCacheWidth))return!1;var n;const t=Sa(e,{requireSignature:!0});if(!t.length)return!Pa&&"undefined"!=typeof console&&p&&(Pa=!0,console.warn("[markstream-vue] virtualScroll.heightCache ignored: standalone heightCache entries must include compatible signature metadata. Use heightCache exported from virtual-state-change/render-settled, and pass heightCacheWidth from the same state.")),!1;const l=Fa(t);return l===Ba?(Ia="standalone",!0):(Hl(t,{mode:"merge"}),$o(),Ba=l,Ia="standalone",lu(),du("restore"),!0)}function Oa(){var e;const n=null==(e=o.virtualScroll)?void 0:e.restoreAnchor;return null==n||!1===n?null:!0===n?"true":String(n)}function Ka(e,n={}){var t,o,l;if(!at.value||!e)return!1;if(e.sessionKey!==Bi())return!1;if(!$i(e.threadKey))return!1;if(zn.value.length<=0)return!1;const r=Boolean(null==(t=e.heightCache)?void 0:t.length)&&!ja(),i=!e.anchor||!1===e.anchorCaptured&&!0!==n.allowUncapturedAnchor?null:e.anchor,a=!0===n.restoreAnchor&&Boolean(i)&&!ja()&&Number(Ca(e))>0;let u=!1;if((null==(o=e.heightCache)?void 0:o.length)&&Na(e)){const n=Sa(e.heightCache,{requireCompatibilityMetadata:!e.contentHash,requireSignature:Ta(e)});n.length&&(Hl(n,{mode:"merge"}),$o(),Ba=Fa(n),Ia="restore",lu(),u=!0)}if(r||a)return!1;if(!n.restoreAnchor)return u&&du("restore"),!0;if(!i)return u&&du("restore"),!0;const s=function(e,n){var t;const o=e.anchor,l=o?"bottom"===o.type?`bottom:${Math.round(o.distanceFromBottomPx)}`:`node:${o.nodeIndex}:${Math.round(o.offsetWithinNodePx)}`:"none";return[null!=(t=Ii())?t:"",Bi(),Ri(),Fi.value,n,l].join(":")}(e,null!=(l=n.restoreToken)?l:"imperative");return Ha===s?(u&&du("restore"),!0):(Ha=s,function(e){const n=()=>{if("node"===e.type)return wa(),void Uo({nodeIndex:e.nodeIndex,offsetWithinNodePx:e.offsetWithinNodePx});if(Eo(),Ao.value=null,Mo.value=e,ka(),ya(e),De)for(const e of[0,120,280,480])ba.push(window.setTimeout(()=>{const e=Mo.value;e&&ya(e)},e))};!function(e){if(!bt.value)return!1;const n=zn.value.length;return!(n<=0||(Ql.value="node"===e.type?Yr(e.nodeIndex,0,n-1):n-1,tr(),0))}(e)?n():oe(n)}(i),du("restore"),!0)}function ja(){const e=Pi();return Number.isFinite(e)&&e>0}function za(e){var n;return e.sessionKey===Bi()&&!!$i(e.threadKey)&&(zn.value.length<=0||!(!(null==(n=e.heightCache)?void 0:n.length)||ja())||!(!(e.anchor&&Number(Ca(e))>0)||ja()))}function La(){Jt.length=0;for(const e of Object.keys(Zo)){const n=Number(e);Number.isInteger(n)&&n>=0&&n<zn.value.length&&Cl(n)}}function Ea(){null!=xr&&(null==_t||_t(xr),xr=null),hu()}function Da(){return!De||Bt?Promise.resolve():new Promise(e=>{let n=!1,t=null;const o=()=>{n||(n=!0,null!=t&&window.clearTimeout(t),e())};if(Nt)return Nt(o),void(t=window.setTimeout(o,50));t=window.setTimeout(o,0)})}function Wa(e,n=Ii(),t=Ai.value){return Bi()===e&&Ii()===n&&Ai.value===t}function Va(){return s(this,arguments,function*(e={}){var n,t,l,r,i;const s=Bi(),d=Ii(),c=Ai.value,m=null!=(n=e.frames)?n:2,f=null!=(t=e.timeoutMs)?t:120,v=null!=(l=e.reason)?l:"manual",h=e.expectedSettledTokenKey,p=!0===e.flushPendingTimers,g=ea(v),y=()=>u(a({},g),{phase:g.final?"settling":g.phase,stable:!1,confidence:"final"===g.confidence?"mixed":g.confidence,reason:v}),b=()=>Wa(s,d,c)&&(null==h||tu()===h);for(let o=0;o<m;o++){if(yield oe(),!b())return y();if(yield Da(),!b())return y();bu(),Ea()}if(yield function(e){return!De||e<=0?Promise.resolve():new Promise(n=>window.setTimeout(n,e))}(f),!b())return y();if(p&&_r(),bu(),Ea(),!b())return y();const k=Zi();k&&(qi=s,Vi=d,"manual"===(null==(r=o.virtualScroll)?void 0:r.settleMode)&&null!=h&&Xi(null==(i=o.virtualScroll)?void 0:i.settledToken)&&tu()===h&&(Ui=Pu(o.virtualScroll.settledToken)));const w=b()&&k&&Gi(),x=ea(v,w?"final":void 0);return au(x,!0),x})}let qa="content",Ua=null,Xa=null,Ya=0,Za=null,Ga=null,Ja=null,Qa=null;function eu(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function nu(e){var n,t;const l=Za;if(!l)return!0;const r=null!=(t=null==(n=o.virtualScroll)?void 0:n.heightDiffThresholdPx)?t:1;return Math.abs(e.totalHeight-l.totalHeight)>r||e.sessionKey!==l.sessionKey||e.phase!==l.phase||e.stable!==l.stable||e.final!==l.final||e.threadKey!==l.threadKey||e.nodeCount!==l.nodeCount||e.measuredCount!==l.measuredCount||e.width!==l.width}function tu(e=(e=>null==(e=o.virtualScroll)?void 0:e.settledToken)()){return ii(e)}function ou(e,n){var t,l;return[e,n.sessionKey,null!=(t=n.threadKey)?t:"",Ri(),pa(),ii(null==(l=o.virtualScroll)?void 0:l.settledToken),Math.round(n.totalHeight),Math.round(n.width)].join("\0")}function lu(){Ja=null,Qa=null,Ga=null}function ru(e){const n=e.heightCache;return(null==n?void 0:n.length)?Fa(n):""}function iu(e){var n,t,o;const l=e.metrics,r=e.anchor?"bottom"===(i=e.anchor).type?`bottom:${Math.round(i.distanceFromBottomPx)}`:`node:${i.nodeIndex}:${Math.round(i.offsetWithinNodePx)}`:"none";var i;return[e.sessionKey,null!=(n=e.threadKey)?n:"",null!=(t=e.measurementKey)?t:Ri(),null!=(o=e.contentHash)?o:"",ru(e),r,e.anchorCaptured?1:0,l.liveRange.start,l.liveRange.end,l.renderedCount,l.nodeCount,Math.round(l.totalHeight),Math.round(l.width),l.phase,l.stable?1:0].join("\0")}function au(e,n=!1){if(!at.value)return;if(function(e=!1){return!e&&nt.value&&!ut.value}(n))return;const t=n||nu(e),o=function(e,n=!1){return n||e.stable||"final"===e.phase?{state:ga(e,{includeHeightCache:!0})}:{state:ga(e)}}(e,n),r=o.state,i=Boolean(r&&(t||function(e,n=!1){return!!n||iu(e)!==Ga}(r,n)));if(t&&(Z(e),Za=e,Ya=eu()),r&&i&&(te(r),r.anchor&&de(r.anchor),Ga=iu(r)),e.stable){const n=ou("settled",e);if(n!==Ja){Ja=n;const t=ga(e,{includeHeightCache:!0});t&&(te(t),Ga=iu(t)),function(e){l("render-settled",e)}(e)}}if("final"===e.phase){const n=ou("final",e);if(n!==Qa){Qa=n;const t=ga(e,{includeHeightCache:!0});t&&(te(t),Ga=iu(t)),function(e){l("render-final",e)}(e)}}}function uu(){null!=Ua&&(null==_t||_t(Ua),Ua=null),null!=Xa&&De&&(window.clearTimeout(Xa),Xa=null)}function su(){Ua=null,Xa=null;const e=eu();let n;e-mr>=120&&(mr=e,n=bu()),(cr.size>8||null==xr)&&Ea(),au(ea(qa,void 0,n))}function du(e){var n,t;if(!at.value)return;if(qa=e,null!=Ua||null!=Xa)return;const l=Math.max(0,null!=(t=null==(n=o.virtualScroll)?void 0:n.emitIntervalMs)?t:32),r=Math.max(0,l-(eu()-Ya)),i=()=>{Xa=null,Ua=Nt?Nt(su):null,null==Ua&&su()};De&&r>0?Xa=window.setTimeout(i,r):i()}function cu(){bo.value+=1}function mu(e){var n;if(At.value&&e>=Kt.value){const n=zn.value[e],t=!0===rn.value&&!0!==an.value&&e>=zn.value.length-2,o="code_block"===(null==n?void 0:n.type)||"image"===(null==n?void 0:n.type)||"mermaid"===(null==n?void 0:n.type)||"infographic"===(null==n?void 0:n.type);if(!t||o)return!1}return!$l.value||e<$t.value||!!(cn.value&&!0!==an.value&&!(null==(n=o.nodes)?void 0:n.length)&&e>=zn.value.length-yt.value)||Rr.value.has(e)}function fu(e){const n=Fr.get(e);n&&(n(),Fr.delete(e));const t=Pr.get(e);t&&(t.destroy(),Pr.delete(e)),Or(e)}function vu(e,n){let t=!1;if(n){const o=qt.get(e);if(o===n&&Ut.get(e)===Dl.value)return;qt.set(e,n),o!==n&&(t=!0)}else qt.delete(e)&&(t=!0);if(t&&cu(),n||Or(e),!Ll.value||!Ct)return fu(e),n?Ut.set(e,Dl.value):Ut.delete(e),void(n&&$l.value&&Kr(e,!0));if(!bt.value&&$l.value&&!ye.value&&Pr.size>=Re.value&&(ye.value||(ye.value=!0,p&&"undefined"!=typeof console&&console.warn("[markstream-vue] viewportPriority auto-disabled:","too-many-targets"),zr()),!Ll.value||!Ct))return fu(e),Ut.set(e,Dl.value),void(n&&Kr(e,!0));if(e<$t.value&&!bt.value)return fu(e),Ut.set(e,Dl.value),void Kr(e,!0);if(Rr.value.has(e))return fu(e),Ut.set(e,Dl.value),void Kr(e,!0);if(!n)return fu(e),void Ut.delete(e);fu(e);const o=Ct(n,{rootMargin:$e.value});if(!o)return void Ut.delete(e);Pr.set(e,o),Ut.set(e,Dl.value),Kr(e,o.isVisible.value),$l.value&&function(e){if(!De||!$l.value)return;Or(e);const n=e%17*23,t=window.setTimeout(()=>{if(Ar.delete(e),!$l.value)return;if(Rr.value.has(e))return;const n=qt.get(e);if(!n)return;const t=Je(n),o=n.ownerDocument||document,l=o.defaultView||window,r=!t||t===o.documentElement||t===o.body,i=!r&&t?$n("nodeVisibilityFallback.root.getBoundingClientRect",()=>t.getBoundingClientRect()):null,a=r?0:i.top,u=r?$n("nodeVisibilityFallback.clientHeight",()=>{var e,n;return null!=(n=null!=(e=l.innerHeight)?e:null==t?void 0:t.clientHeight)?n:0}):i.bottom,s=$n("nodeVisibilityFallback.node.getBoundingClientRect",()=>n.getBoundingClientRect());s.bottom>=a-500&&s.top<=u+500&&Kr(e,!0)},1800+n);Ar.set(e,t)}(e);let l=null;l=X(()=>o.isVisible.value,n=>{if(n){Or(e),Kr(e,!0),null==l||l(),Fr.delete(e),Pr.get(e)===o&&Pr.delete(e);try{o.destroy()}catch(t){}}},{immediate:!0}),Fr.set(e,l),bt.value&&$r()}function hu(){xr=null,bl(()=>{let e=!1;for(const[n,t]of cr)cr.delete(n),lr.get(n)===t.el&&rr.get(n)===t.version&&(e=Nl(n,t.height,{allowShrink:t.allowShrink})||e);return e})}function pu(){null!=xr&&(null==_t||_t(xr),xr=null),cr.clear()}function gu(e,n,t){var l;if(!Number.isFinite(t)||t<=0)return;if(lr.get(e)!==n)return;const r=rr.get(e);if(null==r)return;const i=zn.value[e],a=cn.value&&!0!==an.value&&!(null==(l=o.nodes)?void 0:l.length)&&e>=zn.value.length-2,u=!(!0===(null==i?void 0:i.loading)||a),s=cr.get(e),d=s?s.allowShrink&&u:u,c=s&&!d?Math.max(s.height,t):t;cr.set(e,{height:c,allowShrink:d,version:r,el:n}),null==xr&&(xr=Nt?Nt(hu):null,null==xr&&hu())}function yu(e,n){gu(e,n,_l(e,n))}function bu(){let e=0;for(const[n,t]of lr){const o=_l(n,t);e+=o,gu(n,t,o)}return e}function ku(){null==Zt||Zt.disconnect(),Zt=null,Xt.clear()}function wu(){for(;dr.length;)Nr(dr.pop())}X(ut,e=>{e&&du("content")},{flush:"post"}),n({getVirtualMetrics:ea,captureVirtualState:function(e={}){var n;return ga(ea("manual"),{includeHeightCache:!0,includeContentHash:!0,allowAnchorFallback:!0===e.allowFallbackAnchor,requireViewport:!0===e.requireViewport,includeEmptyState:null==(n=e.includeEmptyState)||n})},restoreVirtualState:function(e,n={}){const t=!0===n.restoreAnchor,o=null==n.restoreToken?"imperative":String(n.restoreToken);$a=e,Ra={restoreAnchor:t,restoreToken:o,allowUncapturedAnchor:!0===n.allowUncapturedAnchor},!Ka(e,{restoreAnchor:t,restoreToken:o,allowUncapturedAnchor:!0===n.allowUncapturedAnchor})&&za(e)||($a=null,Ra=null)},forceMeasure:function(e="manual"){return s(this,null,function*(){yield oe(),yield Da(),bu(),Ea(),yield oe();const n=ea(e);return au(n,!0),n})},settle:Va,scrollToNode:function(e,n="start"){wa(),Eo();const t=zn.value.length;if(t<=0)return;const o=Yr(e,0,t-1),l=()=>{var e;const t=zo({nodeIndex:o,offsetWithinNodePx:0}),l=Ro(o),r=na(),i=null!=(e=null==r?void 0:r.clientHeight)?e:0,a=Ko();let u=t;if("center"===n)u=t-i/2+l/2;else if("end"===n)u=t-i+l;else if("nearest"===n&&null!=a){if(t>=a&&t+l<=a+i)return;u=t<a?t:t-i+l}jo(Math.max(0,u)),$r({immediate:!0}),bt.value&&(Ql.value=o,tr())};if(bt.value)return Ql.value=o,tr(),void oe(l);l()}});const xu=/* @__PURE__ */new Set;X(()=>kt.value,e=>{if(e)ir.clear();else{ku();for(const e of sr.values())for(const n of e)Nr(n);sr.clear(),rr.clear(),wu(),pu()}},{immediate:!0}),X(an,e=>{e&&function(){if(De&&an.value&&lr.size){wu();for(const e of Zt?[80]:[80,240,640]){const n=Cr(e,()=>{for(const[e,n]of lr)n&&yu(e,n)},"final");null!=n&&dr.push(n)}}}(),du(e?"final":"content")});const Su=Xl(()=>du("content"),16),Mu=Xl(()=>du("batch"),16);X([()=>zn.value.length,()=>Kt.value],()=>{Mo.value&&xa(),Su()},{flush:"post",immediate:!0}),X([()=>er.start,()=>er.end],()=>{Mu()},{flush:"post"});const{cleanupBatchScheduler:Cu}=function(e){const{props:n,isClient:t,isTestEnv:o,parsedNodesIdentity:l,parsedNodeCount:r,desiredRenderedCount:i,datasetKey:a,batchingEnabled:u,incrementalRenderingActive:s,resolvedBatchSize:d,resolvedInitialBatch:c,renderedCount:m,adaptiveBatchSize:f,previousRenderContext:v,previousBatchConfig:h,requestFrame:p,cancelFrame:g,hasIdleCallback:y,cleanupNodeVisibility:b,onDatasetKeyChanged:k,onDatasetChanged:w}=e;let x=null,S="raf",M=null,C=0,N=!1,_=!1;const T=/* @__PURE__ */new Set,B=/* @__PURE__ */new Set;function I(){if(t){null!=x&&("raf"===S&&g?g(x):"idle"===S&&"function"==typeof window.cancelIdleCallback?window.cancelIdleCallback(x):"timeout"===S&&window.clearTimeout(x),x=null),C+=1;for(const e of T)g&&g(e);for(const e of B)window.clearTimeout(e);T.clear(),B.clear(),M=null,N=!1,_=!1}}function H(){return"undefined"!=typeof performance?performance.now():Date.now()}function $(e){!function(e){var t;if(!s.value)return;const o=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6),l=Math.max(1,d.value||1),r=Math.max(1,Math.floor(l/4));e>1.5*o?f.value=Math.max(r,Math.floor(.8*f.value)):e<.6*o&&f.value<l&&(f.value=Math.min(l,Math.ceil(1.2*f.value)))}(e),N=!1;const t=_||m.value<i.value;_=!1,t&&F()}function R(e,l={}){var r,a;if(!s.value)return;const u=i.value;if(m.value>=u)return;const d=Math.max(1,e),c=()=>{const e=H();x=null;const o=null!=M?M:d;M=null;const l=H();m.value=Math.min(u,m.value+o),b(m.value),function(e,o){if(!t)return void $(o);N=!0;const l=++C;oe().then(()=>{var t;if(l!==C)return;const r=H(),i=Math.max(o,r-e),a=()=>{l===C&&$(i)};if(p){let e=null,o=null,l=!1;const r=()=>{l||(l=!0,null!==e&&(T.delete(e),e=null),null!==o&&(B.delete(o),window.clearTimeout(o),o=null),a())};return e=p(()=>{r()}),T.add(e),o=window.setTimeout(()=>{null!==e&&g&&g(e),r()},Math.max(32,null!=(t=n.renderBatchIdleTimeoutMs)?t:120)),void B.add(o)}const u=window.setTimeout(()=>{B.delete(u),a()},0);B.add(u)})}(e,H()-l)};if(!t||l.immediate)return void c();const f=Math.max(0,null!=(r=n.renderBatchDelay)?r:16);if(M=null!=M?Math.max(M,d):d,null==x){if(!o&&y&&window.requestIdleCallback){const e=Math.max(0,null!=(a=n.renderBatchIdleTimeoutMs)?a:120);return S="idle",void(x=window.requestIdleCallback(()=>c(),{timeout:e}))}if(p&&!o)return S="raf",void(x=p(()=>{0===f?c():(S="timeout",x=window.setTimeout(()=>c(),f))}));S="timeout",x=window.setTimeout(()=>c(),f)}}function P(e,n={}){N?_=!0:null==e?F():R(e,n)}function F(){s.value&&R(u.value?Math.max(1,Math.round(f.value)):Math.max(1,d.value))}return X([l,r,a,s,d,c,()=>n.renderBatchDelay],()=>{var e;const o=r.value,l=v.value,u=a.value,p=!Object.is(u,l.key),g=o!==l.total,y=g&&o>l.total&&l.total>0&&!p,x=p||g;v.value={key:u,total:o};const S=h.value,M=null!=(e=n.renderBatchDelay)?e:16,C=S.batchSize!==d.value||S.initial!==c.value||S.delay!==M||S.enabled!==s.value;h.value={batchSize:d.value,initial:c.value,delay:M,enabled:s.value},p&&k(o),(x||C||!s.value)&&I(),(x&&!y||C)&&(f.value=Math.max(1,d.value||1)),x&&!y&&w();const N=i.value;if(!o)return m.value=0,void b(0);if(!s.value)return m.value=N,void b(m.value);const _=p||0===l.total;m.value=_||C?Math.min(N,c.value):Math.min(m.value,N);const T=Math.max(1,c.value||d.value||o);m.value<N?P(T,{immediate:!t}):b(m.value)},{immediate:!0}),X(i,(e,n)=>{s.value&&("number"==typeof n&&e<=n||e>m.value&&P())}),{cleanupBatchScheduler:I}}({props:W,isClient:De,isTestEnv:Bt,parsedNodesIdentity:Wn,parsedNodeCount:Vn,desiredRenderedCount:Sr,datasetKey:Oi,batchingEnabled:Pt,incrementalRenderingActive:At,resolvedBatchSize:Ht,resolvedInitialBatch:$t,renderedCount:Kt,adaptiveBatchSize:zt,previousRenderContext:jt,previousBatchConfig:Lt,requestFrame:Nt,cancelFrame:_t,hasIdleCallback:Tt,cleanupNodeVisibility:jr,onDatasetKeyChanged:e=>{pu(),Sl(),$o(),lu(),e>0&&al(e)},onDatasetChanged:()=>{bt.value&&$r({immediate:!0})}});X([Jl,bt,()=>ce.value,()=>Pe()],([e,n])=>{if(!e)return Lr(),void Hr();Er(),n?$r({immediate:!0}):Hr()},{flush:"post",immediate:!0});let Nu=!1;function _u(){bt.value&&De&&!Nu&&(Nu=!0,Nt?Nt(()=>{Nu=!1,$r({immediate:!0})}):queueMicrotask(()=>{Nu=!1,$r({immediate:!0})}))}X([()=>zn.value.length,()=>bt.value],([e,n])=>{n&&e&&De&&_u()},{flush:"post"}),X(dt,e=>{e&&function(){var e;if(qn.value&&Un.value&&Xn.value&&(null==(e=Yn.value)?void 0:e[1]))return;const n=fe({type:"paragraph",children:[{type:"text",content:"Probe paragraph text",raw:"Probe paragraph text"}],raw:"Probe paragraph text"}),t=fe({type:"list_item",children:[n],raw:"- Probe paragraph text"}),o=fe({type:"list",ordered:!1,items:[t],raw:"- Probe paragraph text"});qn.value=n,Un.value=t,Xn.value=o;const l={1:null,2:null,3:null,4:null,5:null,6:null};for(let r=1;r<=6;r++)l[r]=fe({type:"heading",level:r,text:"Probe heading",children:[{type:"text",content:"Probe heading",raw:"Probe heading"}],raw:`${"#".repeat(r)} Probe heading`});Yn.value=l}()},{immediate:!0}),X([()=>ce.value,Rl],()=>{if(!Rl.value)return vi(),void(_e.value=0);mi(),vi(),Rl.value&&ce.value&&"undefined"!=typeof ResizeObserver&&(fi=new ResizeObserver(()=>{mi(),dt.value&&(Ao.value&&Wo(),Mo.value&&xa(),du("resize"))}),fi.observe(ce.value))},{immediate:!0}),X([dt,vt,Ai],()=>s(null,null,function*(){if(!dt.value)return Te.value={paragraph:null,listItem:null,listWrapperOverhead:0,headings:{1:null,2:null,3:null,4:null,5:null,6:null}},void $o();yield oe(),function(){if(!dt.value||"undefined"==typeof window)return Te.value={paragraph:null,listItem:null,listWrapperOverhead:0,headings:{1:null,2:null,3:null,4:null,5:null,6:null}},void $o();const e={paragraph:null,listItem:null,listWrapperOverhead:0,headings:{1:null,2:null,3:null,4:null,5:null,6:null}},n=di(ei(me.value),".paragraph-node");e.paragraph=El(me.value,n,"pre-wrap");const t=ei(ve.value),o=null==t?void 0:t.querySelector(".paragraph-node");e.listItem=El(ve.value,o,"pre-wrap");const l=$n("readSimpleTextProbeProfile.list.offsetHeight",()=>{var e,n;return null!=(n=null==(e=he.value)?void 0:e.offsetHeight)?n:0}),r=$n("readSimpleTextProbeProfile.listItem.offsetHeight",()=>{var e,n;return null!=(n=null==(e=ve.value)?void 0:e.offsetHeight)?n:0});e.listWrapperOverhead=Math.max(0,l-r);for(let i=1;i<=6;i++){const n=di(ei(pe[i]),`h${i}`);e.headings[i]=El(pe[i],n,"pre-wrap")}Te.value=e,$o()}()}),{flush:"post",immediate:!0}),X(()=>zn.value.length,()=>{bt.value&&_u()}),X([dt,_e],()=>{$o(),bt.value&&$r({immediate:!0}),Ao.value&&Wo(),Mo.value&&xa(),du("resize")},{immediate:!1}),X(()=>$l.value,e=>{if(e)for(const[n,t]of qt)vu(n,t);else if(zr(),bt.value)$r({immediate:!0});else for(const[n,t]of qt)t&&Kr(n,!0)},{immediate:!1}),X([$e,Re,()=>Pe()],()=>{var e;null==(e=Ct.refresh)||e.call(Ct);for(const[n,t]of qt)vu(n,t)},{immediate:!1}),X([()=>W.viewportPriority,()=>zn.value.length,Re],([e,n,t])=>{if(!1!==e){if(ye.value&&(n<=200||n<=t)){ye.value=!1;for(const[e,n]of qt)vu(e,n)}}else ye.value=!1}),X(()=>Kt.value,()=>{bt.value&&$r({immediate:!0})}),X([Ql,pt,yt,()=>zn.value.length,bt],()=>{tr()},{immediate:!0});let Tu=null,Bu=!1,Iu=null;function Hu(){Tu=null,qi=null,Vi=void 0,Ui=null,lu()}function $u(){pu(),Sl(),$o(),Jt.length=0;const e=zn.value.length;e>0&&al(e),La()}function Ru(){uu(),_r(),Za=null,Ba=null,Ia=null,Ha=null,$a=null,Ra=null,Bu=!1,Hu(),Li("restore"),Eo(),wa()}function Pu(e){var n;return[null!=(n=Ii())?n:"",Bi(),Ri(),Fi.value,tu(e),zn.value.length,Math.round(Po(0,zn.value.length)),Math.round(Pi()),Go.count,Math.round(Go.total)].join(":")}function Fu(){return s(this,null,function*(){var e,n,t,l;const r=null==(e=o.virtualScroll)?void 0:e.settledToken,i=tu(r),a=Bi(),u=Ii(),s=Ai.value;if(at.value&&"manual"===(null==(n=o.virtualScroll)?void 0:n.settleMode)&&Xi(r))if(Zi()){if(Pu(r)!==Ui&&!Bu){Bu=!0;try{const e=yield Va({reason:"manual",expectedSettledTokenKey:i}),n=tu()===i;Wa(a,u,s)&&e.sessionKey===a&&e.threadKey===u&&n&&e.stable&&"final"===e.phase&&(Ui=Pu(null==(t=o.virtualScroll)?void 0:t.settledToken))}finally{Bu=!1,yield oe();const e=null==(l=o.virtualScroll)?void 0:l.settledToken,n=Xi(e)?Pu(e):"";Wa(a,u,s)&&n&&Ui!==n&&Fu()}}}else du("manual")})}X(at,(e,n)=>{if(e!==n){if(!e)return Ru(),void uu();Ru(),$u(),Iu=Ai.value,du("content")}},{flush:"post"}),X([at,Ai],([e,n])=>{e?null!=Iu?Iu!==n&&(Iu=n,function(e="resize"){pu(),Sl(),$o(),Jt.length=0;const n=zn.value.length;n>0&&al(n),La(),Ba=null,Ia=null,Ha=null,Za=null,Bu=!1,Hu(),Aa(),oe(()=>{bu(),Ao.value&&Wo(),Mo.value&&xa(),du(e)})}("resize")):Iu=n:Iu=null},{flush:"post",immediate:!0}),X([at,()=>Bi(),()=>Ii()],([e])=>{e&&(Ru(),$u(),Li("content"),du("content"))}),X([at,()=>Bi(),()=>Ii(),Ai,()=>zn.value.length],([e])=>{e&&function(e="async-node"){var n;let t=!1;for(const[o,l]of Array.from(yr.entries()))ji(l)||(kr-=Math.max(0,null!=(n=gr.get(o))?n:0),yr.delete(o),gr.delete(o),t=!0);t&&(Ki(),du(e))}("async-node")},{flush:"post"}),X([at,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.sessionKey},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.measurementKey},()=>o.indexKey,()=>Me.value],([e])=>{e&&(lu(),function(e="content"){if(!at.value)return;const n=[],t=zn.value.length,o=Qr(t),l=Jt.length-1,r=Math.max(t-1,l);for(let i=o;i<=r;i++){if(i>=t){i<=l&&void 0!==Jt[i]&&n.push(i);continue}const e=va(i),o=Jt[i];null!=o&&o!==e&&n.push(i),Jt[i]=e}if(l>=t){for(let e=t;e<=l;e++)Jt[e]=void 0;Jt.length=t}n.length&&(function(e,n={}){const t=Array.from(e,Number);gl(t);let o=0;if(bl(()=>(o=cl(t,n),o>0)),o>0)!function(e){for(const n of e)Number.isInteger(n)&&n>=0&&n<Jt.length&&(Jt[n]=void 0)}(t);else for(const l of t)ho.delete(l)}(n,{notify:!1}),$o(o),Hu(),Ao.value&&Wo(),Mo.value&&xa(),du(e))}("content"))},{flush:"post",immediate:!0}),X([at,()=>zn.value.length,()=>Bi(),()=>Ii()],([e,n,t,o],[l,r,i,a])=>{e&&l&&t===i&&o===a&&n!==r&&Hu()},{flush:"post"}),X([at,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.heightCache},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.heightCacheWidth},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.restoreState},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.measurementKey},()=>zn.value.length,()=>Bi(),_e],()=>{Aa()},{flush:"post",immediate:!0}),X(Oa,(e,n)=>{null==e&&null!=n&&(Eo(),Ao.value=null,wa(),Ha=null)},{flush:"post"}),X([at,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.restoreState},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.restoreAnchor},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.measurementKey},()=>zn.value.length,()=>Bi(),_e],e=>s(null,[e],function*([e,n]){if(!e||!n)return;yield oe();const t=Oa();Ka(n,{restoreAnchor:null!=t,restoreToken:null!=t?t:void 0})}),{flush:"post",immediate:!0}),X([at,_e,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.restoreState},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.measurementKey}],([e])=>{var n;if(!e)return;const t=null==(n=o.virtualScroll)?void 0:n.restoreState;t&&Ba&&"restore"===Ia&&(Na(t)||($u(),Ba=null,Ia=null,du("resize")))},{flush:"post"}),X([at,()=>zn.value.length,()=>Bi(),_e],e=>s(null,[e],function*([e]){var n;const t=$a,o=Ra;e&&t&&(yield oe(),!Ka(t,{restoreAnchor:!0===(null==o?void 0:o.restoreAnchor),restoreToken:null!=(n=null==o?void 0:o.restoreToken)?n:"imperative",allowUncapturedAnchor:!0===(null==o?void 0:o.allowUncapturedAnchor)})&&za(t)||($a=null,Ra=null))}),{flush:"post",immediate:!0}),X([at,an,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.settleMode},()=>Bi(),()=>Ii(),Ai,wr,pr,()=>Kt.value,Sr,()=>Go.count,()=>Go.total],([e,n,t])=>{if(!e||!0!==n||"manual"===t)return;if(!Ji())return;const o=function(){var e;const n=zn.value.length;return[null!=(e=Ii())?e:"",Bi(),Ri(),Fi.value,n,Math.round(Po(0,n)),Math.round(Pi()),Go.count,Math.round(Go.total)].join(":")}();Tu!==o&&(Tu=o,Va({reason:"final"}).then(e=>{e.stable||Tu!==o||(Tu=null)}))},{flush:"post",immediate:!0}),X([at,an,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.settleMode},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.settledToken},()=>Bi(),()=>Ii(),Ai,wr,pr,()=>Kt.value,Sr,()=>zn.value.length,()=>Go.count,()=>Go.total],()=>{Fu()},{flush:"post",immediate:!0}),X([()=>zn.value.length,bt,pt,yt,()=>er.start,()=>er.end],([e,n,t,o,l,r])=>{Ve.value&&wn("virtualization",{nodes:e,virtualization:n,maxLiveNodes:t,buffer:o,focusIndex:Ql.value,scroll:n?(()=>{const e=xo.value||Je();return e?{reverse:Qe(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:l,end:r},rendered:Kt.value})}),X([()=>W.customId],([e],n,t)=>{if(!e||Zn)return;const o=function(e,n){return e?(Ml.controllers[e]=n,()=>{Ml.controllers[e]===n&&delete Ml.controllers[e]}):()=>{}}(e,{captureRestoreAnchor:Vo,restoreAnchor:Uo,getAnchorDrift:Xo,getReport:Ni});t(()=>{o()})},{immediate:!0}),ne(()=>{!function(){if(at.value)try{bu(),Ea();const e=ea("manual");nu(e)&&(Z(e),Za=e,Ya=eu());const n=ga(e,{includeHeightCache:!0,includeContentHash:!0,allowAnchorFallback:!1,requireViewport:!0,includeEmptyState:!0});n&&(te(n),n.anchor&&de(n.anchor),Ga=iu(n))}catch(e){}}(),Cu(),zr(),yn(),ku();for(const e of sr.values())for(const n of e)Nr(n);sr.clear(),rr.clear(),Jt.length=0,wu(),pu(),vi(),Eo(),wa(),uu(),Lr(),Hr()});const Au=eo("ViewportDeferredMermaidBlockNode",le({loader:()=>s(null,null,function*(){try{return(yield import("./index10.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),Rt}}),loadingComponent:oi,delay:0}),oi),Ou=eo("ViewportDeferredInfographicBlockNode",le({loader:()=>s(null,null,function*(){try{return(yield import("./index9.js")).default}catch(e){return console.warn('[markstream-vue] Failed to load InfographicBlockNode. Showing the Infographic source fallback. To enable Infographic rendering, install "@antv/infographic" and configure setInfographicLoader with a dynamic loader.',e),ti}}),loadingComponent:ti,delay:0}),ti),Ku=eo("ViewportDeferredD2BlockNode",le({loader:()=>s(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),Rt}}),loadingComponent:Jr,delay:0}),Jr),ju={text:Ft,paragraph:ul,heading:Yo,code_block:oo,list:nl,list_item:el,blockquote:Oo,table:pl,definition_list:Lo,footnote:qo,footnote_reference:fn,footnote_anchor:Do,admonition:ki,vmr_container:wl,hardbreak:Bo,link:wo,image:gt,thematic_break:yl,math_inline:lo,math_block:ro,strong:vo,emphasis:_o,strikethrough:po,highlight:Co,insert:So,subscript:mo,superscript:so,emoji:dn,checkbox:un,checkbox_input:un,inline_code:Hn,html_inline:Nn,reference:ao,html_block:rl},zu=A(()=>_i()),Lu=A(()=>Wl(W.codeBlockProps)),Eu=A(()=>Wl(W.codeBlockProps)),Du=A(()=>u(a(a({stream:W.codeBlockStream,darkTheme:W.codeBlockDarkTheme,lightTheme:W.codeBlockLightTheme,themes:W.themes,minWidth:W.codeBlockMinWidth,maxWidth:W.codeBlockMaxWidth},"boolean"==typeof qe.value?{showTooltips:qe.value}:{}),Eu.value),{codeBlockOptions:W.codeBlockOptions})),Wu=A(()=>u(a(a({},Du.value),Lu.value),{codeBlockOptions:W.codeBlockOptions}));function Vu(e){return"boolean"==typeof e?e:void 0}const qu=A(()=>{var e,n,t,o,l,r,i;const a=W.codeBlockProps||{},u={},s=Vu(a.showLineNumbers);u.showLineNumbers=null!=s?s:!0!==(null==(e=W.codeBlockOptions)?void 0:e.disableLineNumbers),u.showHeader=null==(n=Vu(a.showHeader))||n,u.showCopyButton=null==(t=Vu(a.showCopyButton))||t;const d=null!=(o=Vu(a.showTooltips))?o:qe.value;"boolean"==typeof d&&(u.showTooltips=d),u.codeBlockOptions=W.codeBlockOptions,u.isDark=W.isDark,u.darkTheme=null!=(l=a.darkTheme)?l:W.codeBlockDarkTheme,u.lightTheme=null!=(r=a.lightTheme)?r:W.codeBlockLightTheme,u.theme=a.theme,u.themes=null!=(i=a.themes)?i:W.themes;const c=Vu(a.diffInline);void 0!==c&&(u.diffInline=c),void 0!==a.diffHideUnchangedRegions&&(u.diffHideUnchangedRegions=a.diffHideUnchangedRegions);const m=function(e){const n=Number(e);return Number.isFinite(n)&&n>0?n:void 0}(a.reservedHeightPx);return void 0!==m&&(u.reservedHeightPx=m),u}),Uu=A(()=>a({},W.mermaidProps||{})),Xu=A(()=>a({},W.d2Props||{})),Yu=A(()=>a({},W.infographicProps||{})),Zu=A(()=>({typewriter:b.value,fade:W.fade,customHtmlTags:jn.value.customHtmlTags})),Gu=A(()=>a(a({},Zu.value),"boolean"==typeof qe.value?{showTooltip:qe.value}:{})),Ju=A(()=>a(a({},Zu.value),"boolean"==typeof qe.value?{showTooltips:qe.value}:{})),Qu=A(()=>a(a({},Zu.value),"boolean"==typeof qe.value?{showTooltips:qe.value}:{})),es=A(()=>a(a({},Zu.value),"boolean"==typeof qe.value?{showTooltips:qe.value}:{}));function ns(e){return Array.isArray(e.children)&&e.children.length>0}const ts=/* @__PURE__ */new WeakMap,os=/* @__PURE__ */new WeakMap,ls=[],rs=[];let is=null,as=[];function us(e,n){var t;const o=String(null!=(t=null==e?void 0:e.code)?t:""),l=os.get(e);if(l&&l.code===o)return l.height;const r=n(o);return os.set(e,{code:o,height:r}),r}function ss(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Object.is(e[t],n[t]))return!1;return!0}const ds=A(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map;return zn.value.forEach((t,o)=>{var l;if("footnote"!==t.type)return;const r=t.id,i=null!=(l=e.get(r))?l:0;n.set(o,i),e.set(r,i+1)}),n});function cs(e,n){var t,o,l,s,m;const f=function(e,n,t){const o=dt.value?wi.value[n]:null;return[n,e.loading,o,t]}(e.node,e.index,n),v=ts.get(e.node);if(v&&ss(v.signature,f))return v.item;let h=function(e,n){var t,o;if("code_block"!==e.type)return Gt[n]=void 0,e;const l=e,r=[l.language,l.loading,l.diff,l.code,l.originalCode,l.updatedCode,l.raw,l.startLine,l.endLine,null==(t=l.sourceMap)?void 0:t.startLine,null==(o=l.sourceMap)?void 0:o.endLine],i=Gt[n];if(i&&r.every((e,n)=>e===i.signature[n]))return i.node;const u=a({},l);return Gt[n]={signature:r,node:u},u}(e.node,e.index);const p=fs(h);let g=ys(h,p);if(("html_block"===h.type||"html_inline"===h.type)&&g===ju[h.type]){const e=h,n=String(null!=(t=e.tag)?t:"").trim().toLowerCase()||C(e.content);if(n){const t=An.value[n];if(On.value.has(n)&&t)g=t,h=u(a({},e),{type:n,tag:n,content:$(e.content,n)});else if(N(null!=(o=e.content)?o:e.raw,n)){const n=String(null!=(s=null!=(l=e.content)?l:e.raw)?s:"");"html_inline"===h.type?(g=Ft,h={type:"text",content:n,raw:n}):(g=ul,h={type:"paragraph",children:[{type:"text",content:n,raw:n}],raw:n})}}}const y="code_block"===h.type&&w.value&&g===to&&!Vl(An.value,p);let b=a({},function(e,n,t){const o=null!=n?n:fs(e);if("code_block"===e.type){const n=o?Vl(An.value,o):void 0;if(t&&w.value&&!n&&t===to)return qu.value;if(t&&o&&t===n)return"mermaid"===o?hs(e):"infographic"===o?ps(e):"d2"===o||"d2lang"===o?gs(e):Wu.value;if(t&&t===An.value.code_block)return Wu.value}return"mermaid"===o?hs(e):"infographic"===o?ps(e):"d2"===o||"d2lang"===o?gs(e):"link"===e.type?Gu.value:"list"===e.type?Ju.value:"blockquote"===e.type?Qu.value:"table"===e.type?es.value:"code_block"===e.type?Du.value:Zu.value}(h,p,g));const k=dt.value?wi.value[e.index]:null;"code_block"===h.type&&"code-block"===(null==k?void 0:k.kind)&&(b=u(a({},b),y?{reservedHeightPx:k.contentHeight}:{estimatedHeightPx:k.height,estimatedContentHeightPx:k.contentHeight,estimatedDiffInline:k.diffInline})),y||"code_block"!==h.type||"mermaid"!==p||null!=Le(b.estimatedPreviewHeightPx)||(b=u(a({},b),{estimatedPreviewHeightPx:Ae(us(h,Oe))})),y||"code_block"!==h.type||"infographic"!==p||null!=Le(b.estimatedPreviewHeightPx)||(b=u(a({},b),{estimatedPreviewHeightPx:Ke(us(h,je))})),"math_block"===h.type&&(b=u(a({},b),{cacheScope:Fn}));const x=function(e,n){const t=String(e.type);return!Ye(t)&&An.value[t]===n}(h,g),S=x?kn(h,Ue.value):void 0,M=h.loading;let _=e.index;"footnote"===h.type&&g===qo&&(_=`footnote-${h.id}-${ds.value.get(e.index)}`);const T=`${zu.value}-${_}`,B=a({node:h,loading:M,"index-key":T},"reference"===h.type?{"data-markstream-reference-id":String(h.id)}:{}),I={"custom-id":W.customId,"is-dark":W.isDark},H={onCopy:r,onHandleArtifactClick:i},R={onClick:bs,onMouseover:xs,onMouseout:Ss},P={onMouseover:d,onMouseout:c},F=a(a({},null!=S?S:{}),b),A=ae(B,b,I,H),O=ae(F,B,I,H),K={node:h,sourceLoading:M,index:e.index,component:g,bindings:b,customBindings:F,nodeProps:A,customNodeProps:O,fragmentNodeProps:ae(A,R),customFragmentNodeProps:ae(O,R),minimalNodeProps:ae(A,P),rendersCustomNode:x,hasSlotChildren:ns(h),slotContent:String(null!=(m=h.content)?m:""),isCodeBlock:"code_block"===h.type,indexKey:T,vnodeKey:`${Hi.value}\0${_}\0${h.type}`};return ts.set(e.node,{signature:f,item:K}),K}const ms=A(()=>{var e,n,t,o,l;const r=is,i=function(){const e=[w.value,An.value,On.value,Ue.value,Hi.value,zu.value,Fn,hi.value,W.customId,W.isDark,qu.value,Du.value,Wu.value,Uu.value,Yu.value,Xu.value,Zu.value,Gu.value,Ju.value,Qu.value,es.value,dt.value,Bl.value,_e.value];return is&&ss(is,e)?is:(is=e,e)}(),a=r!==i;if(is=i,bt.value)return xi.value.map(e=>cs(e,i));const u=zn.value,s=u.length;let d=!1;ls.length>s&&(ls.length=s,rs.length=s,d=!0);const c=ls,m=Math.min(c.length,s);let f=a?0:m;if(!a)for(let h=0;h<m;h++){const r=u[h];if("code_block"===r.type){if((null==(e=c[h])?void 0:e.node)!==(null==(n=Gt[h])?void 0:n.node)||rs[h]!==r||!Object.is(null==(t=c[h])?void 0:t.sourceLoading,r.loading)){f=h;break}}else if((null==(o=c[h])?void 0:o.node)!==r||!Object.is(null==(l=c[h])?void 0:l.sourceLoading,r.loading)){f=h;break}}if(!d&&f===s)return as;for(let h=f;h<s;h++)c[h]=cs({node:u[h],index:h},i),rs[h]=u[h];const v=c.slice();return as=v,v});function fs(e){var n;return"code_block"===(null==e?void 0:e.type)?String(null!=(n=e.language)?n:"").trim().toLowerCase():""}function vs(e,n,t,o){var l;const r=a({},e.value);return null==Le(r.estimatedPreviewHeightPx)&&(r.estimatedPreviewHeightPx=o(us(n,t),void 0,"none"===r.maxHeight?null:null!=(l=Le(r.maxHeight))?l:void 0)),r}function hs(e){return vs(Uu,e,Oe,Ae)}function ps(e){return vs(Yu,e,je,Ke)}function gs(e){return vs(Xu,e,Ee,ze)}function ys(e,n){if(!e)return kl;const t=An.value,o=t[String(e.type)];if("code_block"===e.type){const l=null!=n?n:fs(e),r=l?Vl(t,l):void 0;if(r)return r;if(w.value)return t.code_block||to;if("mermaid"===l)return t.mermaid||Au;if("infographic"===l)return t.infographic||Ou;if("d2"===l||"d2lang"===l)return t.d2||Ku;if(o)return o;return t.code_block||hi.value}return o||ju[String(e.type)]||kl}function bs(e){const n=e.target instanceof Element?e.target.closest("[data-markstream-reference-id]"):null,t=e.currentTarget,o=n&&t instanceof Element&&t.contains(n)?n.dataset.markstreamReferenceId:void 0;l("click",e,o)}function ks(e){var n;(null==(n=e.target)?void 0:n.closest("[data-node-index]"))&&l("mouseover",e)}function ws(e){var n;(null==(n=e.target)?void 0:n.closest("[data-node-index]"))&&l("mouseout",e)}function xs(e){l("mouseover",e)}function Ss(e){l("mouseout",e)}const Ms=q(null),Cs=q(!1),Ns=q(null),_s=A(()=>!("minimal"!==W.domMode||We.value||!1!==W.fade||b.value||Cs.value||Et.value||bt.value||tt.value||Qn.value||Mt.value||0!==Object.keys(An.value).length));let Ts,Bs=null,Is=0,Hs=0,$s=0;const Rs=["code_block","admonition","table","math_block","html_block","image","thematic_break"],Ps=new Set(Rs),Fs=[".typewriter-cursor",".height-estimation-probes",...Rs.map(e=>`[data-node-type="${e}"]`),"script","style"].join(",");function As(e){if(!e||"object"!=typeof e)return!1;const n=e.type;return"string"==typeof n&&Ps.has(n)}function Os(e){var n,t;if(!e||"object"!=typeof e)return 0;const o=e,l=null!=(t=null!=(n=o.raw)?n:o.content)?t:o.code;if("string"==typeof l)return l.length;const r=o.children;if(Array.isArray(r))return r.reduce((e,n)=>e+Os(n),0);const i=o.items;return Array.isArray(i)?i.reduce((e,n)=>e+Os(n),0):0}function Ks(){Ts&&(clearTimeout(Ts),Ts=void 0)}function js(){Is+=1,null!=Bs&&(null==_t||_t(Bs),Bs=null)}function zs(){js(),Ws(),Ms.value&&(Ms.value.style.visibility="hidden")}function Ls(e){var n;if(e.nodeType!==Node.TEXT_NODE)return!1;if(!(null!=(n=e.textContent)?n:"").trim())return!1;const t=e.parentElement;return!!t&&!t.closest(Fs)}function Es(e){let n=e.lastChild;for(;n;){if(Ls(n))return n;if(n.nodeType===Node.ELEMENT_NODE){const e=n;if(!e.matches(Fs)&&e.lastChild){n=e.lastChild;continue}}for(;n&&n!==e&&!n.previousSibling;)n=n.parentNode;if(!n||n===e)break;n=n.previousSibling}return null}function Ds(){const e=ms.value;for(let n=e.length-1;n>=0;n--){const t=e[n];if(!t||As(t.node)||!mu(t.index))continue;const o=qt.get(t.index);if(!o)continue;const l=Es(o);if(l)return l}return null}function Ws(){Ns.value&&(Ns.value.classList.remove(si),Ns.value=null)}function Vs(){if("simple"!==y.value||!De||!Cs.value||!ce.value)return void Ws();const e=Ds(),n=e?function(e){var n;const t=null==(n=e.parentElement)?void 0:n.closest(".text-node");return t instanceof HTMLElement?t:e.parentElement}(e):null;n!==Ns.value&&(Ws(),n&&(n.classList.add(si),Ns.value=n))}function qs(){if("precise"!==y.value)return;if(!De||!Cs.value)return;if(null!=Bs)return;const e=Is,n=()=>{Bs=null,e===Is&&function(){var e,n;if("precise"!==y.value)return;if(!(De&&Cs.value&&ce.value&&Ms.value))return;const t=ce.value,o=Ms.value;o.style.visibility="hidden";const l=Ds();if(!l)return;let r=0,i=0,a=20,u=!1;if(null==l?void 0:l.textContent){const o=l.textContent.length,s=document.createRange();s.setStart(l,Math.max(0,o-1)),s.setEnd(l,o);const d="function"==typeof s.getClientRects?s.getClientRects():void 0,c=null!=(n=null==d?void 0:d[d.length-1])?n:null==(e=l.parentElement)?void 0:e.getBoundingClientRect();if(c){const e=$n("typewriterCursor.root.getBoundingClientRect",()=>t.getBoundingClientRect());r=c.right-e.left+t.scrollLeft,i=c.top-e.top+t.scrollTop,a=c.height||a,u=!0}s.detach()}u&&(o.style.transform=`translate(${Math.max(0,r)}px, ${Math.max(0,i)}px)`,o.style.height=`${a}px`,o.style.visibility="visible")}()};Nt?Bs=Nt(n):n()}return X([ln,()=>o.content,()=>o.nodes,()=>W.typewriter,an],()=>s(null,null,function*(){var e,n;if(!De||We.value||!Ze.value)return;if(!b.value)return void((Cs.value||Ts||null!=Bs||Ns.value||Ms.value)&&(Cs.value=!1,Ks(),zs()));if(an.value)return Cs.value=!1,Ks(),void zs();if(null==(e=o.nodes)?void 0:e.length)return Cs.value=!1,Ks(),zs(),Hs=(null!=(n=o.content)?n:"").length,void($s=ln.value.length);const t=function(){var e,n;return(null==(e=o.nodes)?void 0:e.length)?o.nodes.reduce((e,n)=>e+Os(n),0):(null!=(n=o.content)?n:"").length}(),l=function(){var e;return(null==(e=o.nodes)?void 0:e.length)?o.nodes.reduce((e,n)=>e+Os(n),0):ln.value.length}(),r=!As(zn.value[zn.value.length-1]),i=t>Hs,a=l>$s;if(!b.value||!r||!i&&!a)return b.value&&r||(Cs.value=!1,zs()),Hs=t,void($s=l);Hs=t,$s=l,Cs.value=!0,"precise"===y.value&&Ms.value&&(Ms.value.style.visibility="hidden"),Ks(),yield oe(),"simple"===y.value?Vs():(Ws(),qs()),Ts=setTimeout(()=>{Ts=void 0,Cs.value=!1},3e3)}),{flush:"post",immediate:!0}),X(Cs,e=>s(null,null,function*(){e?(yield oe(),"simple"!==y.value?(Ws(),"precise"===y.value&&qs()):Vs()):zs()}),{flush:"post"}),X(y,()=>s(null,null,function*(){if(De&&!We.value&&Ze.value&&Cs.value){if(yield oe(),"simple"===y.value)return js(),void Vs();Ws(),"precise"!==y.value?zs():qs()}}),{flush:"post"}),X([()=>Kt.value,()=>er.start,()=>er.end],()=>s(null,null,function*(){De&&!We.value&&Ze.value&&Cs.value&&(yield oe(),"simple"!==y.value?(Ws(),"precise"===y.value&&qs()):Vs())}),{flush:"post"}),ne(()=>{Ks(),js(),Ws(),Pn.clear()}),(e,n)=>{const t=xe("NodeRenderer",!0);return V(We)?(K(!0),j(Y,{key:0},J(ms.value,e=>(K(),j(Y,{key:e.vnodeKey},[e.rendersCustomNode?(K(),re(ie(e.component),ae({key:0,ref_for:!0},e.customFragmentNodeProps),{default:ue(()=>[e.hasSlotChildren?(K(),re(t,ae({key:0,ref_for:!0},Dn.value,{nodes:e.node.children,"index-key":e.indexKey,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes","index-key"])):e.slotContent?(K(),re(t,ae({key:1,ref_for:!0},Dn.value,{content:e.slotContent,final:!e.node.loading,"index-key":`${e.indexKey}-content`,"smooth-streaming":!1,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["content","final","index-key"])):G("",!0)]),_:2},1040)):(K(),re(ie(e.component),ae({key:1,ref_for:!0},e.fragmentNodeProps),null,16))],64))),128)):(K(),j("div",{key:1,ref_key:"containerRef",ref:ce,class:D(["markstream-vue markdown-renderer",[{dark:W.isDark},{virtualized:bt.value},{"virtual-scroll-coordinated":ut.value},{"stable-layout":Al.value},{"typewriter-simple-cursor":Cs.value&&"simple"===y.value}]]),"data-custom-id":W.customId,onClick:bs,onMouseover:ks,onMouseout:ws},[ct.value||bt.value?(K(),j(Y,{key:0},[ct.value?(K(),re(ni,{key:0,width:vt.value,"flow-root":bt.value||ut.value,"paragraph-node":qn.value,"list-item-node":Un.value,"list-node":Xn.value,"heading-nodes":Yn.value,"set-paragraph-wrapper":Tr,"set-list-item-wrapper":Br,"set-list-wrapper":Ir,"set-heading-wrapper":ci},null,8,["width","flow-root","paragraph-node","list-item-node","list-node","heading-nodes"])):G("",!0),bt.value?(K(),j("div",{key:1,class:"node-spacer",style:se({height:`${Si.value}px`}),"aria-hidden":"true"},null,4)):G("",!0)],64)):G("",!0),_s.value?(K(!0),j(Y,{key:1},J(ms.value,e=>(K(),j(Y,{key:e.vnodeKey},[mu(e.index)?(K(),re(ie(e.component),ae({key:0,ref_for:!0},e.minimalNodeProps),null,16)):G("",!0)],64))),128)):(K(!0),j(Y,{key:2},J(ms.value,e=>(K(),j("div",{key:e.vnodeKey,ref_for:!0,ref:n=>vu(e.index,n),class:"node-slot","data-node-index":e.index,"data-node-type":e.node.type},[V(xu).has(e.vnodeKey)||mu(e.index)?(K(),j("div",{key:0,ref_for:!0,ref:n=>function(e,n,t){var o,l;if(t?xu.add(n):xu.delete(n),t){const n=zn.value[e],o=ir.get(e);if(o&&o.el===t&&o.node===n&&o.loading===(null==n?void 0:n.loading))return}t||function(e){var n;const t=`${_i()}-${e}`;let o=!1;for(const l of Array.from(gr.keys())){const r=yr.get(l);((null==r?void 0:r.index)===e||l===t||l.startsWith(`${t}-`))&&(kr-=Math.max(0,null!=(n=gr.get(l))?n:0),gr.delete(l),yr.delete(l),o=!0)}o&&(Ki(),du("async-node"))}(e),cr.delete(e),function(e){var n;const t=(null!=(n=rr.get(e))?n:0)+1;rr.set(e,t)}(e);const r=sr.get(e);if(r){for(const e of r)Nr(e);sr.delete(e)}if(function(e){const n=Xt.get(e);n&&(null==Zt||Zt.unobserve(n),Yt.delete(n),Xt.delete(e))}(e),!t||!kt.value)return lr.delete(e),rr.delete(e),void ir.delete(e);lr.set(e,t),ir.set(e,{el:t,node:zn.value[e],loading:null==(o=zn.value[e])?void 0:o.loading});const i=()=>{yu(e,t)};queueMicrotask(i);const a=(Zt||"undefined"==typeof ResizeObserver||(Zt=new ResizeObserver(e=>{if(e.length)for(const n of e){const e=Yt.get(n.target),t=Xt.get(null!=e?e:-1);null!=e&&t&&yu(e,t)}else bu()})),Zt);if(a&&(Xt.set(e,t),Yt.set(t,e),a.observe(t)),"undefined"!=typeof window){const n="code_block"===(null==(l=zn.value[e])?void 0:l.type)?[16,80,240,800]:an.value?[80]:[];if(n.length){const t=n.map(e=>Cr(e,i,"node-resize")).filter(e=>null!=e);t.length&&sr.set(e,t)}}}(e.index,e.vnodeKey,n),class:"node-content"},[e.isCodeBlock?e.rendersCustomNode?(K(),re(ie(e.component),ae({key:1,ref_for:!0},e.customNodeProps),{default:ue(()=>[e.hasSlotChildren?(K(),re(t,ae({key:0,ref_for:!0},Dn.value,{nodes:e.node.children,"index-key":e.indexKey,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes","index-key"])):e.slotContent?(K(),re(t,ae({key:1,ref_for:!0},Dn.value,{content:e.slotContent,final:!e.node.loading,"index-key":`${e.indexKey}-content`,"smooth-streaming":!1,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["content","final","index-key"])):G("",!0)]),_:2},1040)):(K(),re(ie(e.component),ae({key:2,ref_for:!0},e.nodeProps),null,16)):(K(),re(li,{key:0,item:e,"source-nodes":o.nodes,fade:W.fade,final:V(rn),"nested-renderer-props":e.rendersCustomNode?Dn.value:void 0},null,8,["item","source-nodes","fade","final","nested-renderer-props"]))],512)):(K(),j("div",{key:1,class:"node-placeholder",style:se({height:`${Ro(e.index)}px`})},null,4))],8,ui))),128)),Cs.value&&"precise"===y.value?(K(),j("span",{key:3,ref_key:"typewriterCursorRef",ref:Ms,class:"typewriter-cursor","aria-hidden":"true"},null,512)):G("",!0),bt.value?(K(),j("div",{key:4,class:"node-spacer",style:se({height:`${Mi.value}px`}),"aria-hidden":"true"},null,4)):G("",!0)],42,ai))}}})),[["__scopeId","data-v-6e40537c"]]),ci=di;ci.install=e=>{const n=new Set(["MarkdownRender","NodeRenderer",ci.__name,ci.name].filter(e=>Boolean(e)));for(const t of n)e.component(t,di)};const mi=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:ci},Symbol.toStringTag,{value:"Module"})),fi={key:0,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"admonition-icon"},vi={key:1,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"admonition-icon"},hi={key:2,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"admonition-icon"},pi={key:3,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"admonition-icon"},gi={class:"admonition-title"},yi=["aria-expanded","aria-controls"],bi=["id"],ki=/* @__PURE__ */an(/* @__PURE__ */O({__name:"AdmonitionNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},fade:{type:Boolean},customId:{}},emits:["copy"],setup(e,{emit:n}){var t;const o=e,l=n,r=A(()=>{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)}),i=q(!!o.node.collapsible&&!(null==(t=o.node.open)||t));function a(){o.node.collapsible&&(i.value=!i.value)}const u=`admonition-${Math.random().toString(36).slice(2,9)}`;return(n,t)=>(K(),j("div",{class:D(["admonition",[`admonition-${o.node.kind}`]])},[z("div",{id:u,class:"admonition-legend"},["note"===o.node.kind||"info"===o.node.kind?(K(),j("svg",fi,[...t[1]||(t[1]=[z("circle",{cx:"12",cy:"12",r:"10"},null,-1),z("path",{d:"M12 16v-4"},null,-1),z("path",{d:"M12 8h.01"},null,-1)])])):"tip"===o.node.kind?(K(),j("svg",vi,[...t[2]||(t[2]=[z("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"},null,-1),z("path",{d:"M9 18h6"},null,-1),z("path",{d:"M10 22h4"},null,-1)])])):"warning"===o.node.kind||"caution"===o.node.kind?(K(),j("svg",hi,[...t[3]||(t[3]=[z("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"},null,-1),z("path",{d:"M12 9v4"},null,-1),z("path",{d:"M12 17h.01"},null,-1)])])):"danger"===o.node.kind||"error"===o.node.kind?(K(),j("svg",pi,[...t[4]||(t[4]=[z("polygon",{points:"7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"},null,-1),z("path",{d:"M12 8v4"},null,-1),z("path",{d:"M12 16h.01"},null,-1)])])):G("",!0),z("span",gi,L(r.value),1),o.node.collapsible?(K(),j("button",{key:4,class:"admonition-toggle","aria-expanded":!i.value,"aria-controls":`${u}-content`,onClick:a},[(K(),j("svg",{style:se({rotate:i.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...t[5]||(t[5]=[z("path",{d:"m9 18 6-6-6-6"},null,-1)])],4))],8,yi)):G("",!0)]),ce(z("div",{id:`${u}-content`,class:"admonition-content","aria-labelledby":u},[W(V(ci),{"index-key":`admonition-${e.indexKey}`,nodes:o.node.children,"custom-id":o.customId,typewriter:o.typewriter,fade:o.fade,onCopy:t[0]||(t[0]=e=>l("copy",e))},null,8,["index-key","nodes","custom-id","typewriter","fade"])],8,bi),[[me,!i.value]])],2))}}),[["__scopeId","data-v-a83480e1"]]);ki.install=e=>{e.component(ki.__name,ki)};const wi=()=>import("@terrastruct/d2");let xi=null,Si=wi,Mi=null,Ci=!1,Ni=!1,_i=0;function Ti(e){Si=e,_i++,xi=null,Mi=null,Ci=!1,Ni=!1}function Bi(e){Ti(null!=e?e:wi)}function Ii(){Ti(null)}function Hi(){return"function"==typeof Si}function $i(){return s(this,null,function*(){if(xi)return xi;const e=Si,n=_i;return e?e===wi&&Ci?null:Mi||(Mi=s(null,null,function*(){let t;try{t=yield e()}catch(o){if(e===wi)return n===_i&&e===Si&&(Ci=!0,function(e){Ni||(Ni=!0,console.warn('[markstream-vue] Optional dependency "@terrastruct/d2" is not installed. D2 blocks will render as source.',e))}(o)),null;throw o}finally{n===_i&&e===Si&&(Mi=null)}return n!==_i||e!==Si?null:t?(xi=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}(t),xi):null}),Mi):null})}let Ri=null,Pi=null,Fi=null,Ai=0;function Oi(e){Pi=null!=e?e:null,Ri=null,Fi=null,Ai++}function Ki(e){if("function"!=typeof e)throw new TypeError("enableInfographic requires a loader function");Oi(e)}function ji(){Oi()}function zi(){return"function"==typeof Pi}function Li(){return s(this,null,function*(){if(Ri)return Ri;const e=Pi,n=Ai;return e?Fi||(Fi=s(null,null,function*(){const t=yield e();if(n!==Ai||e!==Pi)return null;const o=function(e){var n,t,o;if(!e)return null;const l=null!=(n=e.default)?n:e,r="function"==typeof l&&"function"==typeof(null==(t=l.prototype)?void 0:t.render)?l:null!=(o=e.Infographic)?o:null==l?void 0:l.Infographic;return"function"==typeof r?r:null}(t);return n!==Ai||e!==Pi?null:o?(Ri=o,Ri):null}).finally(()=>{n===Ai&&e===Pi&&(Fi=null)}),Fi):null})}function Ei(e){const n=Number.parseFloat(String(null!=e?e:""));return Number.isFinite(n)?n:0}function Di(e,n){null==e||e(n)}function Wi(e,n){return e?(Di(n,"readElementBoxHeight.offsetHeight"),Math.ceil(Math.max(0,e.offsetHeight||0))):0}function Vi(e,n){const t=Wi(e,n);if(!e||"undefined"==typeof window||"function"!=typeof window.getComputedStyle)return t;Di(n,"readElementOuterHeight.getComputedStyle");const o=window.getComputedStyle(e),l=Ei(o.marginTop),r=Ei(o.marginBottom);return Math.ceil(Math.max(0,t+l+r))}function qi(e,n,t){if(!e)return 0;const o=function(e){var n;return e?(null==(n=e.matches)?void 0:n.call(e,".markstream-vue.markdown-renderer"))?e:e.querySelector(".markstream-vue.markdown-renderer"):null}(e);if(!o)return 0;const l=Number.isFinite(t)?Number(t):Vi(e,n),r=Wi(o,n);return Math.max(0,l-r)}function Ui(e){return"measured"===e||"final"===e}function Xi(e,n,t){var o,l,r;const i=null!=(r=null!=(l=null==(o=t.getKey)?void 0:o.call(t,e,n))?l:e.id)?r:n;return String(i)}function Yi(e,n,t){var o,l,r;return null!=(r=null==(o=t.getKind)?void 0:o.call(t,e,n))?r:String(null!=(l=e.kind)?l:"")}function Zi(e,n,t){var o,l;const r=null!=(l=null==(o=t.getContent)?void 0:o.call(t,e,n))?l:e.content;return"string"==typeof r?r:""}function Gi(e,n,t){var o;const l=null==(o=t.getFinal)?void 0:o.call(t,e,n);if("boolean"==typeof l)return l;const r=e.final;return"boolean"!=typeof r||r}function Ji(e,n,t){var o,l;return null!=(l=null==(o=t.getRevision)?void 0:o.call(t,e,n))?l:e.revision}function Qi(e,n,t){const o=Yi(e,n,t);return"assistant-markdown"===o||"markdown"===o||!o&&Zi(e,n,t).length>0}function ea(e,n,t){var o;const l=null==(o=t.estimateItemHeight)?void 0:o.call(t,e,n);if(Number.isFinite(l)&&l>0)return l;const r=Yi(e,n,t);return"assistant-markdown"===r||"markdown"===r?360:"system-divider"===r?44:"tool-call"===r?72:"thinking"===r?92:"error"===r?76:"user-message"===r?88:Zi(e,n,t).length>0?360:96}function na(e){const n=ge(/* @__PURE__ */new Map),t=/* @__PURE__ */new Map,o=ge(/* @__PURE__ */new Map),l=ge(/* @__PURE__ */new Map),r=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map,c=q(!1),m=[0,80,180,360,640];let f,v=0,h=null,p=[],g=0;const y=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;let k,w=!1,x=null,S=!1,M=null;function C(n){var t;!0===e.debug&&y.set(n,(null!=(t=y.get(n))?t:0)+1)}function N(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(e):(oe(e),null)}function _(e){null!=e&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}function T(){return[...Me(e.items)]}function B(){const n=Me(e.threadKey);return null==n?void 0:String(n)}function I(n,t){return Xi(n,t,e)}function H(n,t){return Qi(n,t,e)}function $(n,t){const o=I(n,t),l=B(),r=Ji(n,t,e);return[null!=l?l:"timeline",o,null==r?"":String(r)].join(":")}function R(){const n=Me(e.measurementKey);return null==n?void 0:String(n)}function P(){const n=Me(e.markdownMode);return"chat"===n||"minimal"===n||"docs"===n?n:"docs"}function F(){return!0===Me(e.renderCodeBlocksAsPre)}function A(){var e;const n=F()?"pre":"rich";return`${null!=(e=R())?e:""}${P()}${n}`}function O(n,t){if(H(n,t))return $(n,t);const o=I(n,t),l=B(),r=Ji(n,t,e);return[null!=l?l:"timeline",o,null==r?"":String(r)].join(":")}function K(e){const n=T();for(let t=0;t<n.length;t++){const o=n[t];if(I(o,t)===e)return{item:o,index:t}}return null}function j(e,n){var t;const o=K(e);if(!o||!n)return!1;if(n.sourceKey!==O(o.item,o.index))return!1;const l=H(o.item,o.index)?A():R();return(null!=(t=n.measurementKey)?t:"")===(null!=l?l:"")}function z(e){if(!j(e,t.get(e)))return 0;const o=n.get(e);return Number.isFinite(o)&&o>0?o:0}function L(e,n){var t,o;const l=K(e);return!!(l&&n&&H(l.item,l.index)&&n.sessionKey===$(l.item,l.index)&&(null!=(t=n.threadKey)?t:"")===(null!=(o=B())?o:"")&&function(e){const n=A(),t=null!=e?e:"";return t===n||t.startsWith(`${n}\0`)}(n.measurementKey))}function E(e,n){return L(e,n)}function D(e,n,t){!Number.isFinite(n)||n<=0||(l.set(e,Math.ceil(n)),r.set(e,t))}function W(e,n=o.get(e),t={}){var l;const r=t.trustImportedState?Number(null==(l=null==n?void 0:n.metrics)?void 0:l.totalHeight):function(e,n=o.get(e)){var t;if(!E(e,n))return 0;const l=Number(null==(t=null==n?void 0:n.metrics)?void 0:t.totalHeight);return Number.isFinite(l)&&l>0?Math.ceil(l):0}(e,n);return!Number.isFinite(r)||r<=0||!n?0:(D(e,Math.ceil(r),n),Math.ceil(r))}function V(e){var n;return L(e,r.get(e))?null!=(n=l.get(e))?n:0:W(e)}function U(e){return Number.isFinite(e)&&e>0?e:null}function X(){if(!S)return;S=!1,M=null;const e=k;k=void 0,e&&ae(e)}function Y(){if(null!=h&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(h),h=null,"undefined"!=typeof window)for(const e of p)window.clearTimeout(e);p=[]}function Z(o,l,r=function(e){const n=K(e);return n?function(e,n){const t=H(e,n)?A():R();return a({sourceKey:O(e,n)},null==t?{}:{measurementKey:t})}(n.item,n.index):void 0}(o)){const i=U(l);if(null==i)return;const u=n.get(o),s=r&&(m=r,!((null!=(v=null==(d=t.get(o))?void 0:d.sourceKey)?v:"")===(null!=(p=null==m?void 0:m.sourceKey)?p:"")&&(null!=(y=null==d?void 0:d.measurementKey)?y:"")===(null!=(b=null==m?void 0:m.measurementKey)?b:"")&&(null!=(w=null==d?void 0:d.widthBucket)?w:0)===(null!=(x=null==m?void 0:m.widthBucket)?x:0)));var d,m,v,p,y,b,w,x;if(null!=u&&Math.abs(u-i)<.5&&!s)return;if(c.value)return n.set(o,i),r&&t.set(o,r),e.virtualizer.setItemSize(o,i),void function(){const e=f,n=g;e&&oe(()=>{ue(n,e),null==h&&"function"==typeof requestAnimationFrame&&(h=requestAnimationFrame(()=>{h=null,ue(n,e)}))})}();const C=!1!==e.preserveScrollAnchor,_=C?re():void 0,T=Math.max(0,e.virtualizer.getTotalHeight()-e.virtualizer.getViewportHeight()-e.virtualizer.getScrollTop()),B=C&&T<=2,I=C&&T<=function(){var n;const t=Number(null!=(n=e.bottomThresholdPx)?n:48);return Number.isFinite(t)?Math.max(0,t):48}();var $;n.set(o,i),r&&t.set(o,r),e.virtualizer.setItemSize(o,i),C&&(($=B?{type:"bottom",distanceFromBottomPx:0}:I?{type:"bottom",distanceFromBottomPx:T}:_)&&(S||(k=$,S=!0,M=N(X))))}function G(e){var n;null==(n=d.get(e))||n.disconnect(),d.delete(e),s.delete(e)}function J(){if(!w)return;w=!1,x=null;const e=Array.from(b.entries());b.clear();for(const[n,t]of e)V(n)===t.logicalHeight&&ee(n,{allowMarkdownShrink:t.allowMarkdownShrink});X()}function Q(){J(),X()}function ee(n,t={}){const o=function(e){return Vi(s.get(e),C)}(n),l=z(n);let r=!1;const i=()=>{r||(r=!0,function(n,t){const o=function(){if(!0!==e.debug||0===y.size)return null;let n=0;for(const e of y.values())n+=e;const t={total:n,byLabel:Object.fromEntries(Array.from(y.entries()).sort((e,n)=>n[1]-e[1]||e[0].localeCompare(n[0])))};return y.clear(),t}();o&&console.info("[markstream-vue][virtual-adapter][perf] layout-reads",{label:n,itemKey:t,layoutReads:o})}("reconcileItemSize",n))};if(!function(e){const n=K(e);return!!n&&H(n.item,n.index)}(n))return o>0&&Z(n,o),void i();const a=V(n),u=function(e,n){return qi(s.get(e),C,n)}(n,o);if(a>0){let e=Math.max(o,a+u);return(!t.allowMarkdownShrink||c.value)&&l>0&&(e=Math.max(e,l)),e>0&&Z(n,e),void i()}const d=K(n);return d&&!Zi(d.item,d.index,e).trim()?(o>0&&Z(n,o),void i()):l>0?(o>l+1&&Z(n,o),void i()):(o>0&&Z(n,o),void i())}function ne(){const e={},n=T();for(let t=0;t<n.length;t++){const o=I(n[t],t),l=z(o);Number.isFinite(l)&&l>0&&(e[o]=l)}return e}function te(){const e={},n=T();for(let o=0;o<n.length;o++){const l=I(n[o],o),r=t.get(l);j(l,r)&&(e[l]=r)}return e}function le(){const e={};for(const[n,t]of o)e[n]=t;return e}function re(){const n=e.virtualizer.getScrollTop(),t=e.virtualizer.getViewportHeight(),o=e.virtualizer.getTotalHeight()-t-n;if(o<=2)return{type:"bottom",distanceFromBottomPx:Math.max(0,o)};const l=T();for(let a=0;a<l.length;a++){const t=I(l[a],a),o=e.virtualizer.getItemOffset(t),r=e.virtualizer.getItemSize(t);if(n>=o&&n<o+r)return{type:"item",itemKey:t,offsetWithinItemPx:n-o}}const r=e.virtualizer.getVisibleRange(),i=l[r.start];return i?{type:"item",itemKey:I(i,r.start),offsetWithinItemPx:0}:void 0}function ie(i){var a;if(!i)return n.clear(),t.clear(),o.clear(),l.clear(),void r.clear();(function(o){var l,r;if(n.clear(),t.clear(),function(e){var n,t;return(null!=(n=e.measurementKey)?n:"")===(null!=(t=R())?t:"")}(o))for(const[i,a]of Object.entries(null!=(l=o.itemHeights)?l:{})){const l=U(a),u=null==(r=o.itemSizeSources)?void 0:r[i];null!=l&&j(i,u)&&(n.set(i,l),t.set(i,u),e.virtualizer.setItemSize(i,l))}})(i),function(e){o.clear(),l.clear(),r.clear();for(const[n,t]of Object.entries(e))o.set(n,t),W(n,t,{trustImportedState:!0})}(null!=(a=i.markdownStates)?a:{})}function ae(n){if(!n)return;if("bottom"===n.type){const t=Math.max(0,e.virtualizer.getTotalHeight()-e.virtualizer.getViewportHeight()-n.distanceFromBottomPx);return void e.virtualizer.scrollToOffset(t)}const t=Math.max(0,e.virtualizer.getItemOffset(n.itemKey)+n.offsetWithinItemPx);e.virtualizer.scrollToOffset(t)}function ue(e,n){e===v&&ae(n)}function se(e){e===v&&(c.value=!1,Q(),ue(e,f),f=void 0,g=0)}function ce(){Y(),_(M),S=!1,M=null,k=void 0,_(x),w=!1,x=null,b.clear();for(const e of d.values())e.disconnect();d.clear(),s.clear(),t.clear(),l.clear(),r.clear(),i.clear()}return ye()&&de(ce),{itemHeights:n,markdownStates:o,getItemKey:I,isMarkdownItem:H,isRestoringThread:()=>c.value,measureItem:function(n,t,o){var l,r;const i=I(n,t),a=function(e){const n=e&&"$el"in e?e.$el:e;return n instanceof HTMLElement?n:null}(o),u=s.get(i);if(!a)return void G(i);if(u===a)return void ee(i);if(G(i),s.set(i,a),null==(r=(l=e.virtualizer).measureElement)||r.call(l,i,a),ee(i),"undefined"==typeof ResizeObserver)return;const c=new ResizeObserver(()=>{var n,t;a.isConnected&&(null==(t=(n=e.virtualizer).measureElement)||t.call(n,i,a),ee(i))});c.observe(a),d.set(i,c)},unobserveItem:function(e){G(e)},releaseDetached:function(){let e=0;for(const[n,t]of s)t.isConnected||(G(n),e++);return e},markdownProps:function(n,t){const l=I(n,t),r=Gi(n,t,e),a=B(),u=Zi(n,t,e),s=$(n,t),d=A(),c=P(),m=F(),f=[l,s,r?"final":"live",d,c,m,!0===e.markdownFade?"fade":"no-fade"].join(":"),v=Se(o).get(l),h=i.get(f);if(h&&h.content===u)return h.virtualScroll&&(h.virtualScroll.restoreState=E(l,v)?v:null),h;const p={enabled:!0,sessionKey:s,threadKey:a,scrollRoot:()=>e.virtualizer.getScrollElement(),restoreState:E(l,v)?v:null,restoreAnchor:!1,measurementKey:d,settleMode:"manual",settledToken:r,emitIntervalMs:96,heightDiffThresholdPx:4},g={content:u,final:r,mode:c,renderCodeBlocksAsPre:m,nodeVirtual:!!r&&"auto",maxLiveNodes:r?50:void 0,liveNodeBuffer:r?16:void 0,fade:!0===e.markdownFade,indexKey:s,virtualScroll:p,onHeightChange(e){if(e.sessionKey!==$(n,t))return;D(l,e.totalHeight,{sessionKey:e.sessionKey,threadKey:a,measurementKey:A()});const o=function(e){return"final"===e.phase||!(!0!==e.final||!Ui(e.confidence))||!!e.stable&&(Ui(e.confidence)||function(e){var n,t,o,l;const r=Number(e.nodeCount),i=Number(e.measuredCount),a=Math.max(0,Number(null!=(t=null==(n=e.liveRange)?void 0:n.start)?t:0)),u=Math.min(r,Math.max(a,Number(null!=(l=null==(o=e.liveRange)?void 0:o.end)?l:0))),s=Math.max(0,u-a);return!0===e.final&&!0===e.stable&&"mixed"===e.confidence&&r>0&&i>0&&i<r&&(s<=0||i>=s)}(e))}(e),r=Math.ceil(e.totalHeight);var i,u;i=l,u={allowMarkdownShrink:o,logicalHeight:r},b.set(i,u),w||(w=!0,x=N(J))},onVirtualStateChange(e){e.sessionKey===$(n,t)&&(o.set(l,e),p.restoreState=e,W(l,e))}};return i.set(f,g),g},captureThreadState:function(){Q();const e=R();return u(a({threadKey:B()},null==e?{}:{measurementKey:e}),{outerAnchor:re(),itemHeights:ne(),itemSizeSources:te(),markdownStates:le()})},preloadThreadState:ie,restoreThreadState:function(e){const n=++v,t=null==e?void 0:e.outerAnchor;if(Y(),c.value=Boolean(t),g=n,f=t,ie(e),!t)return c.value=!1,f=void 0,void(g=0);ue(n,t),oe(()=>{ue(n,t),"function"==typeof requestAnimationFrame&&(h=requestAnimationFrame(()=>{h=null,ue(n,t)})),"undefined"!=typeof window?m.forEach((e,o)=>{const l=window.setTimeout(()=>{ue(n,t),o===m.length-1&&se(n)},e);p.push(l)}):se(n)})},dispose:ce}}const ta=/* @__PURE__ */Symbol("markstreamLanguageIconResolver");let oa=null;function la(e){oa=null!=e?e:null}function ra(){return oa}function ia(){oa=null}function aa(){var e;try{null==(e=null==oa?void 0:oa.terminate)||e.call(oa)}catch(n){}oa=null}function ua(e){return s(this,null,function*(){const n=oa;if(n&&"function"==typeof n.setRenderOptions)try{yield n.setRenderOptions({theme:e})}catch(t){}})}function sa(e){return le(e)}const da=sa(()=>import("./index3.js")),ca=sa(()=>import("./index5.js")),ma=sa(()=>import("./index6.js")),fa=sa(()=>import("./index10.js")),va=sa(()=>import("./index9.js")),ha=sa(()=>import("./index7.js")),pa=sa(()=>import("./index4.js")),ga=sa(()=>import("./index8.js")),ya={MarkdownRender:ci,NodeRenderer:ci,AdmonitionNode:ki,BlockquoteNode:Oo,CheckboxNode:un,CodeBlockNode:da,DefinitionListNode:Lo,EmojiNode:dn,EmphasisNode:_o,FootnoteNode:qo,FootnoteReferenceNode:fn,FootnoteAnchorNode:Do,HardBreakNode:Bo,HeadingNode:Yo,HtmlBlockNode:rl,HtmlInlineNode:Nn,HighlightNode:Co,ImageNode:gt,D2BlockNode:ha,InfographicBlockNode:va,InlineCodeNode:Hn,PreCodeNode:Rt,InsertNode:So,LinkNode:wo,ListItemNode:el,ListNode:nl,MathBlockNode:ca,MathInlineNode:ma,MermaidBlockNode:fa,ParagraphNode:ul,StrikethroughNode:po,StrongNode:vo,SubscriptNode:mo,SuperscriptNode:so,TableNode:pl,TextNode:Ft,ThematicBreakNode:yl,VmrContainerNode:wl,ReferenceNode:ao,MarkstreamVirtualTimeline:ga,Tooltip:pa},ba={install(e,n){var t,o;Object.entries(ya).forEach(([n,t])=>{e.component(n,t)}),(null==n?void 0:n.iconTheme)&&Be(n.iconTheme),n&&"languageIconResolver"in n&&e.provide(ta,null!=(t=n.languageIconResolver)?t:null),(null==n?void 0:n.getLanguageIcon)&&Ie(n.getLanguageIcon),(null==n?void 0:n.mathOptions)&&R(n.mathOptions),n&&"infographicLoader"in n&&Oi(null!=(o=n.infographicLoader)?o:null),(null==n?void 0:n.defaultI18nMap)&&e.provide(Zn,n.defaultI18nMap),(null==n?void 0:n.components)&&e.provide(Ue,function(e={}){return P(Ge(e))}(n.components))}};export{Qe as $,ki as A,Oo as B,un as C,ha as D,dn as E,Do as F,an as G,Bo as H,gt as I,Rt as J,qo as K,wo as L,ta as M,tn as N,ia as O,ul as P,Ii as Q,ao as R,po as S,pl as T,ji as U,wl as V,Bi as W,Ki as X,qt as Y,ea as Z,Yo as _,da as a,$i as a0,Li as a1,qi as a2,Zi as a3,Gi as a4,Xi as a5,Yi as a6,Ji as a7,ra as a8,Xn as a9,Ur as aA,dt as aB,at as aC,Hi as aa,zt as ab,zi as ac,Qi as ad,Xt as ae,Vi as af,nn as ag,Lt as ah,At as ai,Ot as aj,ct as ak,Ut as al,Yt as am,Qt as an,Je as ao,Ti as ap,Gn as aq,Oi as ar,la as as,Un as at,ua as au,aa as av,na as aw,Jl as ax,ut as ay,nt as az,Zt as b,Gt as c,Lo as d,_o as e,fn as f,Co as g,rl as h,Nn as i,va as j,Hn as k,So as l,el as m,nl as n,ga as o,ca as p,ma as q,fa as r,vo as s,mo as t,so as u,Ft as v,yl as w,pa as x,ba as y,ci as z};
|
|
1
|
+
var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,r=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={}))l.call(n,t)&&i(e,t,n[t]);if(o)for(var t of o(n))r.call(n,t)&&i(e,t,n[t]);return e},u=(e,o)=>n(e,t(o)),s=(e,n,t)=>new Promise((o,l)=>{var r=e=>{try{a(t.next(e))}catch(n){l(n)}},i=e=>{try{a(t.throw(e))}catch(n){l(n)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);a((t=t.apply(e,n)).next())});import{normalizeCustomHtmlTagName as d,tokenizeHtml as c,sanitizeHtmlAttrs as f,sanitizeHtmlTokenAttrs as m,tokenAttrsToRecord as v,isCustomHtmlComponentTag as h,convertHtmlAttrsToProps as p,BLOCKED_HTML_TAGS as g,isHtmlTagHardBlocked as y,isHtmlTagBlocked as b,sanitizeHtmlContent as k,sanitizeImageSrc as w,shouldOpenLinkInNewTab as x,NON_STRUCTURING_HTML_TAGS as S,normalizeCustomHtmlTags as M,getHtmlTagFromContent as C,shouldRenderUnknownHtmlTagAsText as N,getMarkdown as _,mergeCustomHtmlTags as T,resolveCustomHtmlTags as B,parseMarkdownToStructure as I,EXTENDED_STANDARD_HTML_TAGS as H,stripCustomHtmlWrapper as $,setDefaultMathOptions as R}from"stream-markdown-parser";import{shallowRef as P,inject as F,computed as A,defineComponent as O,openBlock as K,createElementBlock as j,createElementVNode as z,toDisplayString as L,h as E,normalizeClass as D,createVNode as W,unref as V,ref as q,useAttrs as U,watch as X,Fragment as Y,createTextVNode as Z,createCommentVNode as G,renderList as J,getCurrentInstance as Q,provide as ee,onBeforeUnmount as ne,renderSlot as te,nextTick as oe,defineAsyncComponent as le,createBlock as re,resolveDynamicComponent as ie,mergeProps as ae,withCtx as ue,normalizeStyle as se,onScopeDispose as de,withDirectives as ce,vShow as fe,markRaw as me,normalizeProps as ve,guardReactiveProps as he,Transition as pe,reactive as ge,getCurrentScope as ye,onMounted as be,watchEffect as ke,triggerRef as we,resolveComponent as xe,toRaw as Se,toValue as Me}from"vue";import{M as Ce,n as Ne,c as _e,g as Te,s as Be,h as Ie}from"./index2.js";import{b as He}from"./workers-katexWorkerClient.js";import{createDiffMatchCache as $e,buildDiffPreviewPanes as Re,normalizeShikiLanguage as Pe,createSmoothMarkdownStream as Fe}from"markstream-core";import{d as Ae,g as Oe,b as Ke,f as je,c as ze,p as Le,e as Ee}from"./diagramHeight.js";import"./workers-mermaidWorkerClient.js";import"./workers/katexCdnWorker.js";import"./workers/mermaidCdnWorker.js";import"./utils/katex-threshold.js";import"./utils/performance-monitor.js";import"./utils/safeRaf.js";const De="__global__",We="__MARKSTREAM_VUE_CUSTOM_COMPONENTS_STORE__",Ve=(()=>{const e=globalThis;if(e[We])return e[We];const n={scopedCustomComponents:{},revision:P(0)};return e[We]=n,n})(),qe=Ve.revision,Ue=/* @__PURE__ */Symbol("markstreamCustomComponents"),Xe=/* @__PURE__ */new Set(["text","paragraph","heading","code_block","list","list_item","blockquote","table","table_row","table_cell","definition_list","definition_item","footnote","footnote_reference","footnote_anchor","admonition","hardbreak","link","image","thematic_break","math_inline","math_block","strong","emphasis","strikethrough","highlight","insert","subscript","superscript","emoji","checkbox","checkbox_input","inline_code","html_inline","html_block","reference","mermaid","infographic","d2","vmr_container"]);function Ye(e){return Xe.has(String(e).trim().toLowerCase())}function Ze(e){return e.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function Ge(e={}){const n={};for(const[t,o]of Object.entries(e))if(null!=o){n[t]=o;for(const e of/* @__PURE__ */new Set([d(t),d(Ze(t))]))!e||Ye(e)||Object.prototype.hasOwnProperty.call(n,e)||(n[e]=o)}return n}function Je(e,n){"string"==typeof e?Ve.scopedCustomComponents[e]=Ge(n||{}):Ve.scopedCustomComponents[De]=Ge(e||{}),qe.value++}function Qe(e){const n=Ge(Ve.scopedCustomComponents[De]||{});if(!e)return n;const t=Ge(Ve.scopedCustomComponents[e]||{});return n&&0!==Object.keys(n).length?t&&0!==Object.keys(t).length?a(a({},n),t):n:t}function en(e){const n=F(Ue,null);return A(()=>{var t;return qe.value,function(e,n={}){return qe.value,a(a(a({},Ge(Ve.scopedCustomComponents[De]||{})),Ge(n)),Ge(function(e){return e&&Ve.scopedCustomComponents[e]||{}}(e)))}(null==e?void 0:e(),null!=(t=null==n?void 0:n.value)?t:{})})}function nn(e){if(e===De)throw new Error("removeCustomComponents: use clearGlobalCustomComponents() to clear the global mapping");delete Ve.scopedCustomComponents[e],qe.value++}function tn(){delete Ve.scopedCustomComponents[De],qe.value++}const on=["aria-label"],ln={key:0,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",class:"checkbox-icon checkbox-unchecked"},rn={key:1,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",class:"checkbox-icon checkbox-checked"},an=(e,n)=>{const t=e.__vccOpts||e;for(const[o,l]of n)t[o]=l;return t},un=/* @__PURE__ */an(/* @__PURE__ */O({__name:"CheckboxNode",props:{node:{}},setup:e=>(n,t)=>(K(),j("span",{class:"checkbox-node",role:"img","aria-label":e.node.checked?"checked":"unchecked"},[e.node.checked?(K(),j("svg",rn,[...t[1]||(t[1]=[z("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4",fill:"currentColor"},null,-1),z("path",{d:"M9 12l2 2 4-4",stroke:"hsl(var(--ms-background))","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(K(),j("svg",ln,[...t[0]||(t[0]=[z("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4",stroke:"currentColor","stroke-width":"2"},null,-1)])]))],8,on))}),[["__scopeId","data-v-be21ab83"]]);un.install=e=>{e.component(un.__name,un)};const sn={class:"emoji-node"},dn=/* @__PURE__ */an(/* @__PURE__ */O({__name:"EmojiNode",props:{node:{}},setup:e=>(n,t)=>(K(),j("span",sn,L(e.node.name),1))}),[["__scopeId","data-v-de55dc97"]]);dn.install=e=>{e.component(dn.__name,dn)};const cn=".markdown-renderer";function fn(e,n){var t,o;if("undefined"==typeof document||"undefined"==typeof Element)return null;const l=function(e){return`[id="${e.replace(/["\\]/g,"\\$&")}"]`}(n);let r=e instanceof Element?e.closest(cn):null;for(;r;){const e=r.querySelector(l);if(e)return e;r=null!=(o=null==(t=r.parentElement)?void 0:t.closest(cn))?o:null}return document.querySelector(l)}const mn=["id"],vn=["title"],hn=/* @__PURE__ */an(/* @__PURE__ */O({__name:"FootnoteReferenceNode",props:{node:{}},setup(e){const n=e,t=`#fnref--${n.node.id}`;function o(e){if("undefined"==typeof document)return;const o=fn(e.currentTarget,`fnref--${n.node.id}`);o?o.scrollIntoView({behavior:"smooth"}):console.warn(`Element with href: ${t} not found`)}return(n,l)=>(K(),j("sup",{id:`fnref-${e.node.id}`,class:"footnote-reference",onClick:o},[z("span",{href:t,title:`查看脚注 ${e.node.id}`,class:"footnote-link cursor-pointer"},"["+L(e.node.id)+"]",9,vn)],8,mn))}}),[["__scopeId","data-v-d1baf613"]]);hn.install=e=>{e.component(hn.__name,hn)};const pn=(()=>{try{return Boolean(!1)}catch(e){}return!1})();function gn(e){pn&&console.warn(e)}function yn(e,n){return h(e,n)}function bn(e,n="safe",t){return f(e,n,t)}function kn(e){return p(e)}function wn(e){return!0===e?"":!1===e?"false":null==e?null:String(e)}function xn(e,n="safe"){const t=String(e.tag||e.type||"").trim(),o=m((l=e.attrs)?Array.isArray(l)?l.every(Array.isArray)?l.map(([e,n])=>[String(e),wn(n)]):l.filter(e=>e&&"object"==typeof e&&!Array.isArray(e)&&"name"in e).map(e=>[String(e.name),wn(e.value)]):Object.entries(l).map(([e,n])=>[e,wn(n)]):null,n,t);var l;if(!o)return;const r=kn(v(o));return Object.keys(r).length>0?r:void 0}function Sn(e,n,t=!1){const o=Object.entries(null!=n?n:{}),l=o.length>0?o.map(([e,n])=>""===n?` ${e}`:` ${e}="${n}"`).join(""):"";return t?`<${e}${l} />`:`<${e}${l}>`}function Mn(e,n){Array.isArray(n)?e.push(...n):null!=n&&e.push(n)}function Cn(e,n,t,o,l,r,i=!1){const s=yn(e,o);if(g.has(e.toLowerCase())||!s&&y(e,r))return null;if(!s&&b(e,r))return i?[Sn(e,n,!0)]:[Sn(e,n),...t,`</${e}>`];const d=f(n,r,e),c=d.key,m=null!=c&&""!==c?c:l;if(s){const n=o[e]||o[e.toLowerCase()],l=kn(d);return E(n,u(a({},l),{key:m}),t.length>0?t:void 0)}return E(e,u(a({},d),{innerHTML:void 0,key:m}),t.length>0?t:void 0)}function Nn(e,n,t="safe",o=!1){var l,r;try{if(!o&&0===Object.keys(n).length)return{ok:!0,hasCustomComponents:!1,nodes:null};const r=c(e);let i=!1;for(const e of r)if(("tag_open"===e.type||"self_closing"===e.type)&&yn(null!=(l=e.tagName)?l:"",n)){i=!0;break}const a=o||i?function(e,n,t="safe"){let o=0;const l=[],r=[];for(const i of e)if("text"===i.type)(l.length>0?l[l.length-1].children:r).push(i.content);else if("self_closing"===i.type){const e=Cn(i.tagName,i.attrs||{},[],n,"ms-html-"+o++,t,!0);Mn(l.length>0?l[l.length-1].children:r,e)}else if("tag_open"===i.type)l.push({tagName:i.tagName,children:[],attrs:i.attrs,autoKey:"ms-html-"+o++});else if("tag_close"===i.type){const e=i.tagName.toLowerCase();let o=-1;for(let n=l.length-1;n>=0;n--)if(l[n].tagName.toLowerCase()===e){o=n;break}if(-1!==o)for(;l.length>o;){const i=l.pop(),a=Cn(i.tagName,i.attrs||{},i.children,n,i.autoKey,t);l.length>0?Mn(l[l.length-1].children,a):Mn(r,a),i.tagName.toLowerCase()!==e&&l.length>o&&gn(`Auto-closing unclosed tag: <${i.tagName}>`)}else gn(`Ignoring closing tag with no matching opening tag: </${i.tagName}>`)}for(;l.length>0;){const e=l.pop(),o=Cn(e.tagName,e.attrs||{},e.children,n,e.autoKey,t);l.length>0?Mn(l[l.length-1].children,o):Mn(r,o),gn(`Auto-closing unclosed tag: <${e.tagName}>`)}return r}(r,n,t):null;return{ok:!0,hasCustomComponents:i,nodes:a}}catch(i){return r=i,pn&&console.error("Failed to parse HTML to VNodes:",r),{ok:!1,hasCustomComponents:!1,nodes:null}}}const _n=["innerHTML"],Tn=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HtmlInlineNode",props:{node:{},customId:{},htmlPolicy:{}},setup(e){const n=e,t=F("markstreamHtmlPolicy",void 0),o=A(()=>{var e,o;return null!=(o=null!=(e=n.htmlPolicy)?e:null==t?void 0:t.value)?o:"safe"}),l=en(()=>n.customId),r=O({name:"DynamicRenderer",props:{nodes:{type:Array,required:!0}},render(){return this.nodes}}),i=A(()=>{const e=n.node.content;if(!e)return{mode:"html",content:""};if("escape"===o.value)return{mode:"html",content:k(e,o.value)};if(n.node.loading&&!n.node.autoClosed)return{mode:"text",content:e};const t=!0===n.node.loading&&!0===n.node.autoClosed,r=Nn(e,l.value,o.value,t);return r.ok&&(t||r.hasCustomComponents)?{mode:"dynamic",nodes:r.nodes}:{mode:"html",content:k(e,o.value)}});return(e,t)=>"dynamic"===i.value.mode?(K(),j("span",{key:0,class:D(["html-inline-node",{"html-inline-node--loading":n.node.loading}])},[W(V(r),{nodes:i.value.nodes},null,8,["nodes"])],2)):"text"===i.value.mode?(K(),j("span",{key:1,class:D(["html-inline-node",{"html-inline-node--loading":n.node.loading}])},L(i.value.content),3)):(K(),j("span",{key:2,class:D(["html-inline-node",{"html-inline-node--loading":n.node.loading}]),innerHTML:i.value.content},null,10,_n))}}),[["__scopeId","data-v-fbbbc497"]]);function Bn(e){const n=q(e),t=P([]);let o=e,l=0;function r(){let e=0,o="";for(const n of t.value){if(!n.finished)break;o+=n.content,e++}e&&(n.value+=o,t.value=t.value.slice(e))}return{settledContent:n,segments:t,update:function(e,r,i){if(i&&e===o&&(!r||r===e||t.value.length>0))return;const s=null!=r?r:o;if(i&&s&&e.length>s.length&&e.startsWith(s)){s!==o&&(n.value=s,t.value=[]);const r=e.slice(s.length),i=performance.now(),d=t.value.at(-1);d&&(i-d.startedAt<50||t.value.length>=4)?t.value=[...t.value.slice(0,-1),u(a({},d),{content:d.content+r})]:t.value=[...t.value,{id:l++,content:r,startedAt:i,finished:!1}]}else n.value=e,t.value=[];o=e},finish:function(e,n=!1){const o=t.value.find(n=>n.id===e);o&&(o.finished=!0,n||r())},settleFinished:r}}Tn.install=e=>{e.component(Tn.__name,Tn)};const In={class:"inline-code"},Hn={key:0},$n=["onAnimationend"],Rn=/* @__PURE__ */an(/* @__PURE__ */O({__name:"InlineCodeNode",props:{node:{}},setup(e){const n=e,t=U(),o=F("markstreamFade",void 0),l=F("markstreamTextStreamState",void 0),r=A(()=>{const e=t.fade;return""===e||!0===e||"true"===e||!1!==e&&"false"!==e&&void 0}),i=A(()=>"boolean"==typeof r.value?r.value:"boolean"!=typeof(null==o?void 0:o.value)||o.value),a=A(()=>{var e;return String(null!=(e=n.node.code)?e:"")}),u=A(()=>!i.value),s=A(()=>{var e;const n=null!=(e=t["index-key"])?e:t.indexKey;return null==n||""===n?"":String(n)}),{settledContent:d,segments:c,update:f,finish:m}=Bn(n.node.code);return X([()=>n.node.code,s,i],([e])=>{const n=String(null!=e?e:""),t=s.value;f(n,t?null==l?void 0:l.get(t):void 0,i.value),t&&(null==l||l.set(t,n))},{immediate:!0}),(e,n)=>(K(),j("code",In,[u.value?(K(),j(Y,{key:0},[Z(L(a.value),1)],64)):(K(),j(Y,{key:1},[V(d)?(K(),j("span",Hn,L(V(d)),1)):G("",!0),(K(!0),j(Y,null,J(V(c),e=>(K(),j("span",{key:e.id,class:"inline-code-stream-delta",onAnimationend:n=>V(m)(e.id)},L(e.content),41,$n))),128))],64))]))}}),[["__scopeId","data-v-557cf4dd"]]);Rn.install=e=>{e.component(Rn.__name,Rn)};const Pn=q(!1),Fn=q(""),An=q("top"),On=q(null),Kn=q(null),jn=q(null),zn=q(null),Ln=q(null);let En=null,Dn=null,Wn=0;function Vn(){En&&(clearTimeout(En),En=null),Dn&&(clearTimeout(Dn),Dn=null)}let qn=!1,Un=null,Xn=!1;function Yn(e,n,t="top",o=!1,l,r){if(!e)return;const i=++Wn;Vn();const a=()=>s(null,null,function*(){var o,a;if(yield function(){return s(this,null,function*(){if(!qn&&!Xn&&"undefined"!=typeof document){null!=Un||(Un=s(null,null,function*(){const[{createApp:e,h:n},{default:t}]=yield Promise.all([import("vue"),import("./Tooltip.js")]),o=document.createElement("div");o.setAttribute("data-singleton-tooltip","1"),document.body.appendChild(o),e({setup:()=>()=>{var e;return n(t,{visible:Pn.value,"anchor-el":On.value,content:Fn.value,placement:An.value,id:Kn.value,originX:jn.value,originY:zn.value,isDark:null!=(e=Ln.value)?e:void 0})}}).mount(o),qn=!0}));try{yield Un}catch(e){qn=!1,Un=null,Xn=!0,console.warn("[markstream-vue] Failed to mount Tooltip component. Tooltips will be disabled.",e)}}})}(),qn&&i===Wn){Kn.value=`tooltip-${Date.now()}-${Math.floor(1e3*Math.random())}`,On.value=e,Fn.value=n,An.value=t,jn.value=null!=(o=null==l?void 0:l.x)?o:null,zn.value=null!=(a=null==l?void 0:l.y)?a:null,Ln.value="boolean"==typeof r?r:null,Pn.value=!0;try{e.setAttribute("aria-describedby",Kn.value)}catch(u){}}});o?a():En=setTimeout(a,80)}function Zn(e=!1){Wn+=1,Vn();const n=()=>{if(On.value&&Kn.value)try{On.value.removeAttribute("aria-describedby")}catch(e){}Pn.value=!1,On.value=null,Kn.value=null,jn.value=null,zn.value=null};e?n():Dn=setTimeout(n,120)}const Gn={"common.copy":"Copy","common.selectCopy":"全选(复制)","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.minimize":"Minimize","common.zoomIn":"Zoom in","common.zoomOut":"Zoom out","common.resetZoom":"Reset zoom","image.loadError":"Image failed to load","image.loading":"Loading image..."},Jn=/* @__PURE__ */Symbol("markstreamI18nFallback");function Qn(e){Object.assign(Gn,e)}function et(e,n){var t;return null!=(t=null==n?void 0:n[e])?t:Gn[e]}const nt=(e,n)=>{var t;return null!=(t=et(e,n))?t: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)};function tt(e,n){return{t(t){const o=et(t,n);if(e.te&&null!=o&&!e.te(t))return nt(t,n);const l=e.t(t);return l===t&&null!=o?nt(t,n):l}}}function ot(){const e=function(){var e,n,t;try{const o=Q(),l=Jn,r=null==o?void 0:o.provides,i=null==(e=null==o?void 0:o.appContext)?void 0:e.provides;return null!=(t=null!=(n=null==r?void 0:r[l])?n:null==i?void 0:i[l])?t:null}catch(o){}return null}(),n=function(){var e,n;try{const t=Q(),o=null==t?void 0:t.proxy,l=null==o?void 0:o.$t;if("function"==typeof l){const e=null==o?void 0:o.$te;return{t:l.bind(o),te:"function"==typeof e?e.bind(o):void 0}}const r=null==(n=null==(e=null==t?void 0:t.appContext)?void 0:e.config)?void 0:n.globalProperties,i=null==r?void 0:r.$t;if("function"==typeof i){const e=null==r?void 0:r.$te;return{t:i.bind(r),te:"function"==typeof e?e.bind(r):void 0}}}catch(t){}return null}();if(n)return tt(n,e);try{const n=globalThis.$vueI18nUse||null;if(n&&"function"==typeof n)try{const t=n();if(t&&"function"==typeof t.t)return tt({t:t.t.bind(t),te:"function"==typeof t.te?t.te.bind(t):void 0},e)}catch(t){}}catch(t){}return{t:n=>nt(n,e)}}const lt=/* @__PURE__ */Symbol("ViewportPriority"),rt=/* @__PURE__ */Symbol("ViewportPriorityOptions"),it=/* @__PURE__ */Symbol("OffscreenHeavyNodeDeferral"),at=A(()=>!1),ut="400px";function st(){return F(rt,void 0)}function dt(){return F(it,at)}function ct(e,n){var t,o;const l="undefined"!=typeof window&&"undefined"!=typeof document,r="boolean"==typeof n?q(n):n,i=l?null!=(t=window.requestIdleCallback)?t:e=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),16):null,a=l?null!=(o=window.cancelIdleCallback)?o:e=>window.clearTimeout(e):null,u=/* @__PURE__ */new WeakMap;let s=1;const d=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map,f=/* @__PURE__ */new Set;let m=null,v=null;function h(e){if(!e)return"viewport";let n=u.get(e);return n||(n=s++,u.set(e,n)),String(n)}function p(){if(null!=m){try{null==a||a(m)}catch(e){}m=null}}function g(e){if(e){const t=d.get(e);if(t&&!t.targets.size){try{t.io.disconnect()}catch(n){}d.delete(e)}}c.size||f.size||p()}function y(e){const n=c.get(e);if(!n)return;const t=d.get(n.bucketKey);if(!n.visible.value){n.visible.value=!0;try{n.resolve()}catch(o){}}try{null==t||t.io.unobserve(e)}catch(o){}null==t||t.targets.delete(e),c.delete(e),f.delete(e),g(n.bucketKey)}function b(){!0!==window.__MARKSTREAM_DISABLE_VIEWPORT_PRIORITY_IDLE_DRAIN__&&i&&null==m&&f.size&&(m=i(()=>{m=null;const e=f.values().next().value;e&&(f.delete(e),y(e),f.size&&b())},{timeout:1200}))}function k(n,t){if(!l)return null;if("undefined"==typeof IntersectionObserver)return null;const o=function(n,t){var o,l,r;return{root:null!=(o=null==e?void 0:e(null!=n?n:null))?o:null,rootMargin:null!=(l=null==t?void 0:t.rootMargin)?l:ut,threshold:null!=(r=null==t?void 0:t.threshold)?r:0}}(n,t),r=[h((i=o).root),i.rootMargin,i.threshold].join("\0");var i;const a=d.get(r);if(a)return{key:r,bucket:a};let u;try{u=new IntersectionObserver(e=>{for(const n of e)(n.isIntersecting||n.intersectionRatio>0)&&y(n.target)},{root:o.root,rootMargin:o.rootMargin,threshold:o.threshold})}catch(c){return null}const s={io:u,targets:/* @__PURE__ */new Map};return d.set(r,s),{key:r,bucket:s}}function w(){if(l&&r.value)for(const[n,t]of Array.from(c.entries())){const o=k(n,t.opts);if(!o){y(n);continue}if(o.key===t.bucketKey)continue;const l=t.bucketKey,r=d.get(l);try{null==r||r.io.unobserve(n)}catch(e){}null==r||r.targets.delete(n),t.bucketKey=o.key,o.bucket.targets.set(n,t),o.bucket.io.observe(n),g(l)}}X(r,e=>{if(!e){for(const e of Array.from(c.keys()))y(e);p()}},{flush:"sync"});const x=(e,n)=>{const t=q(!1);let o,i=!1;const a=new Promise(e=>{o=()=>{i||(i=!0,e())}}),u=()=>{const n=c.get(e);if(!n)return f.delete(e),void g();const t=d.get(n.bucketKey);try{null==t||t.io.unobserve(e)}catch(o){}null==t||t.targets.delete(e),c.delete(e),f.delete(e),g(n.bucketKey)};if(!l||!r.value)return t.value=!0,o(),{isVisible:t,whenVisible:a,destroy:u};const s=k(e,n);if(!s)return t.value=!0,o(),{isVisible:t,whenVisible:a,destroy:u};const m={resolve:o,visible:t,bucketKey:s.key,opts:n};return c.set(e,m),s.bucket.targets.set(e,m),s.bucket.io.observe(e),l&&null==v&&(v=window.requestAnimationFrame(()=>{v=null,w()})),!1!==(null==n?void 0:n.allowIdle)&&(f.add(e),b()),{isVisible:t,whenVisible:a,destroy:u}};return x.refresh=w,ee(lt,x),x}function ft(){var e,n;const t=F(lt,void 0);if(t)return t;const o=/* @__PURE__ */new WeakMap,l=/* @__PURE__ */new Map,r=/* @__PURE__ */new Set;let i=null;const a="undefined"!=typeof window?null!=(e=window.requestIdleCallback)?e:e=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),16):null,u="undefined"!=typeof window?null!=(n=window.cancelIdleCallback)?n:e=>window.clearTimeout(e):null,s=()=>{if(null!=i){try{null==u||u(i)}catch(e){}i=null}},d=e=>{if(!e)return;const n=l.get(e);if(n&&!n.targets.size){try{n.io.disconnect()}catch(t){}l.delete(e)}},c=e=>{const n=o.get(e);if(!n)return;const t=l.get(n.bucketKey);if(!n.visible.value){n.visible.value=!0;try{n.resolve()}catch(i){}}try{null==t||t.io.unobserve(e)}catch(i){}o.delete(e),null==t||t.targets.delete(e),r.delete(e),d(n.bucketKey),r.size||s()},f=()=>{!0!==window.__MARKSTREAM_DISABLE_VIEWPORT_PRIORITY_IDLE_DRAIN__&&a&&null==i&&r.size&&(i=a(()=>{i=null;const e=r.values().next().value;e&&(r.delete(e),c(e),r.size&&f())},{timeout:1200}))};return(e,n)=>{const t=q(!1);let i,a=!1;const u=new Promise(e=>{i=()=>{a||(a=!0,e())}}),m=()=>{const n=o.get(e);if(!n)return r.delete(e),void(r.size||s());const t=l.get(n.bucketKey);try{null==t||t.io.unobserve(e)}catch(i){}o.delete(e),null==t||t.targets.delete(e),r.delete(e),d(n.bucketKey),r.size||s()},v=(e=>{var n,t;if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return null;const o=(e=>{var n,t;return[null!=(n=null==e?void 0:e.rootMargin)?n:ut,null!=(t=null==e?void 0:e.threshold)?t:0].join("\0")})(e),r=l.get(o);if(r)return{key:o,bucket:r};const i=null!=(n=null==e?void 0:e.rootMargin)?n:ut;let a;try{a=new IntersectionObserver(e=>{for(const n of e)(n.isIntersecting||n.intersectionRatio>0)&&c(n.target)},{root:null,rootMargin:i,threshold:null!=(t=null==e?void 0:e.threshold)?t:0})}catch(s){return null}const u={io:a,targets:/* @__PURE__ */new Set};return l.set(o,u),{key:o,bucket:u}})(n);return v?(o.set(e,{resolve:i,visible:t,bucketKey:v.key}),v.bucket.targets.add(e),v.bucket.io.observe(e),!1!==(null==n?void 0:n.allowIdle)&&(r.add(e),f()),{isVisible:t,whenVisible:u,destroy:m}):(t.value=!0,i(),{isVisible:t,whenVisible:u,destroy:m})}}function mt(e,n){var t,o;const l=null!=(o=null!=(t=e.indexKey)?t:n["index-key"])?o:n.indexKey;return null==l||""===l?"":String(l)}const vt=["data-markstream-viewport-pending"],ht=["src","alt","title","loading","fetchpriority","decoding","tabindex","aria-label"],pt={key:1,class:"image-placeholder"},gt={key:1,class:"image-node__raw-text"},yt={key:2,class:"image-error"},bt=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ImageNode",props:{node:{},fallbackSrc:{default:""},lazy:{type:Boolean,default:!1},usePlaceholder:{type:Boolean,default:!0}},emits:["load","error","click"],setup(e,{emit:n}){var t,o,l;const r=e,i=n,a=q(!1),u=q(!1),d=q(!1),c=q(""),f=q("primary"),m=q(null),v=U(),h=F(Ce,null),p=ft(),g=st(),y=dt(),b=A(()=>w(r.node.src)),k=A(()=>w(r.fallbackSrc)),x=null==(l=null==(o=null==(t=Q())?void 0:t.vnode.el)?void 0:o.querySelector)?void 0:l.call(o,"img"),S="undefined"!=typeof window&&(null==x?void 0:x.getAttribute("src"))===(b.value||k.value),M=q("undefined"==typeof window||S||!y.value),C=P(null);let N="",_=null;const T=A(()=>c.value),B=A(()=>!r.lazy),I=A(()=>"undefined"!=typeof window&&y.value&&!S),H=A(()=>!I.value||M.value),$=A(()=>H.value?T.value:""),R=A(()=>{var e,n;return null!=(n=null!=(e=null==g?void 0:g.value.heavyBlockMargin)?e:null==g?void 0:g.value.rootMargin)?n:ut}),O=A(()=>!r.node.loading&&"failed"!==f.value&&c.value.length>0),E=A(()=>"failed"===f.value),W=A(()=>(u.value||!B.value||I.value)&&!a.value&&!d.value&&"failed"!==f.value&&c.value.length>0),Y=A(()=>mt(r,v));function Z(e=Y.value){e&&m.value&&(null==h||h.reportHeight(e,m.value.offsetHeight))}function J(e=Y.value){e&&oe(()=>{Z(e)})}function ee(){_&&(clearTimeout(_),_=null)}function le(){const e=Y.value;e&&N!==e&&(N&&(null==h||h.markSettled(N)),ee(),N=e,null==h||h.markPending(e),"undefined"!=typeof window&&(_=window.setTimeout(()=>{N===e&&(J(e),re())},8e3)))}function re(){return s(this,null,function*(){const e=N;e&&(ee(),N="",yield oe(),Z(e),null==h||h.markSettled(e))})}function ie(){if("primary"===f.value&&k.value&&k.value!==c.value)return f.value="fallback",c.value=k.value,a.value=!1,d.value=!1,void J();f.value="failed",d.value=!0,i("error",c.value),J()}function ae(){a.value=!0,u.value=!1,d.value=!1,i("load",T.value),J()}function ue(e){e.preventDefault(),a.value&&!d.value&&i("click",[e,T.value])}const{t:se}=ot();return X([b,k,()=>r.node.loading],()=>(a.value=!1,d.value=!1,r.node.loading?(u.value=!0,c.value=b.value,void(f.value="primary")):b.value?(c.value=b.value,void(f.value="primary")):k.value?(c.value=k.value,void(f.value="fallback")):(c.value="",f.value="failed",void(d.value=!0))),{immediate:!0}),"undefined"!=typeof window&&X([m,I],([e,n],t,o)=>{var l;if(null==(l=C.value)||l.destroy(),C.value=null,!n||M.value)return void(M.value=!0);if(!e)return void(M.value=!1);let r=!0;const i=p(e,{rootMargin:R.value,allowIdle:!1});C.value=i,M.value=i.isVisible.value,i.whenVisible.then(()=>{r&&C.value===i&&(M.value=!0)}),o(()=>{r=!1,i.destroy(),C.value===i&&(C.value=null)})},{immediate:!0}),X([O,a,d,T,()=>r.lazy,H],([e,n,t,o,l,r])=>e&&o&&!t&&r?n?(re(),void J()):l?(le(),void J()):void(n||t||le()):(re(),void J()),{flush:"post",immediate:!0}),ne(()=>{var e;null==(e=C.value)||e.destroy(),C.value=null,function(){const e=N;e&&(ee(),N="",null==h||h.markSettled(e))}()}),(n,t)=>{var o,l,i,u,s;return K(),j("span",{ref_key:"rootRef",ref:m,class:"image-node-container","data-markstream-viewport-pending":I.value&&!M.value?"true":void 0},[O.value?(K(),j("img",{key:0,src:$.value||void 0,alt:String(null!=(l=null!=(o=r.node.alt)?o:r.node.title)?l:""),title:String(null!=(u=null!=(i=r.node.title)?i:r.node.alt)?u:""),class:D(["image-node__img",{"has-placeholder":e.node.loading||W.value,"is-loading":!B.value&&!a.value,"is-loaded":B.value||a.value,"has-natural-size":a.value,"cursor-pointer":a.value}]),loading:r.lazy?"lazy":void 0,fetchpriority:B.value?"high":void 0,decoding:B.value?"sync":"async",tabindex:a.value?0:-1,"aria-label":null!=(s=r.node.alt)?s:V(se)("image.preview"),onError:ie,onLoad:ae,onClick:ue},null,42,ht)):G("",!0),!e.node.loading&&!W.value||d.value?G("",!0):(K(),j("span",pt,[r.usePlaceholder?te(n.$slots,"placeholder",{key:0,node:r.node,displaySrc:T.value,imageLoaded:a.value,hasError:d.value,fallbackSrc:r.fallbackSrc,lazy:r.lazy},()=>[t[0]||(t[0]=z("span",{class:"image-shimmer"},null,-1))],!0):(K(),j("span",gt,L(e.node.raw),1))])),E.value?(K(),j("span",yt,[te(n.$slots,"error",{node:r.node,displaySrc:T.value,imageLoaded:a.value,hasError:d.value,fallbackSrc:r.fallbackSrc,lazy:r.lazy},()=>[t[1]||(t[1]=z("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24"},[z("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)),z("span",null,L(V(se)("image.loadError")),1)],!0)])):G("",!0)],8,vt)}}}),[["__scopeId","data-v-e4e45fcb"]]);bt.install=e=>{e.component(bt.__name,bt)};const kt=le({loader:()=>Promise.resolve().then(()=>vi),suspensible:!1}),wt={key:2},xt=/* @__PURE__ */O({__name:"NodeChildRenderer",props:{node:{},components:{},customId:{},indexKey:{},fallbackToText:{type:Boolean,default:!1}},setup(e){const n=e,t=en(()=>n.customId),o=F("markstreamHtmlPolicy",void 0),l=F("markstreamNestedRendererProps",void 0),r=A(()=>{var e;return null!=(e=null==o?void 0:o.value)?e:"safe"}),i=A(()=>{var e,t;const o=null!=(e=null==l?void 0:l.value)?e:{};return u(a({},o),{customId:null!=(t=n.customId)?t:o.customId,htmlPolicy:r.value})}),s=A(()=>n.components[String(n.node.type)]),d=A(()=>Boolean(s.value&&t.value[n.node.type]&&!Ye(String(n.node.type)))),c=A(()=>d.value?xn(n.node,r.value):void 0),f=A(()=>Array.isArray(n.node.children)&&n.node.children.length>0),m=A(()=>{var e;return String(null!=(e=n.node.content)?e:"")}),v=A(()=>{var e,t;return String(null!=(t=null!=(e=n.node.content)?e:n.node.raw)?t:"")});return(n,t)=>s.value&&d.value?(K(),re(ie(s.value),ae({key:0},c.value,{node:e.node,loading:e.node.loading,"index-key":e.indexKey,"custom-id":e.customId,"is-dark":i.value.isDark,"data-markstream-reference-id":"reference"===e.node.type?String(e.node.id):void 0}),{default:ue(()=>[f.value?(K(),re(V(kt),ae({key:0},i.value,{nodes:e.node.children,"index-key":e.indexKey,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes","index-key"])):m.value?(K(),re(V(kt),ae({key:1},i.value,{content:m.value,final:!e.node.loading,"index-key":`${e.indexKey||"child"}-content`,"smooth-streaming":!1,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["content","final","index-key"])):G("",!0)]),_:1},16,["node","loading","index-key","custom-id","is-dark","data-markstream-reference-id"])):s.value?(K(),re(ie(s.value),{key:1,node:e.node,"custom-id":e.customId,"index-key":e.indexKey,"data-markstream-reference-id":"reference"===e.node.type?String(e.node.id):void 0},null,8,["node","custom-id","index-key","data-markstream-reference-id"])):e.fallbackToText?(K(),j("span",wt,L(v.value),1)):G("",!0)}}),St=["aria-busy","aria-label","data-language","data-markstream-line-numbers"],Mt={key:0,translate:"no",class:"markstream-pre__diff-code"},Ct={class:"markstream-pre__diff-pane-content"},Nt={key:0,class:"markstream-pre__diff-collapsed-icon","aria-hidden":"true"},_t={class:"markstream-pre__diff-number","aria-hidden":"true"},Tt={class:"markstream-pre__diff-content"},Bt={class:"markstream-pre__diff-content-inner"},It={key:0,translate:"no",class:"markstream-pre__code markstream-pre__code--wrapped"},Ht=["data-line-number","textContent"],$t={key:0,class:"markstream-pre__line-numbers","aria-hidden":"true"},Rt=["textContent"],Pt=["textContent"],Ft=/* @__PURE__ */O({__name:"PreCodeNode",props:{node:{},loading:{type:Boolean},showLineNumbers:{type:Boolean},diffInline:{type:Boolean},diffHideUnchangedRegions:{type:[Boolean,Object]},reservedHeightPx:{}},setup(e){const n=e,t=U(),o=$e();function l(e,n){const t=String(null!=e?e:"");return n?t:t.replace(/\r\n$|\n$|\r$/,"")}const r=A(()=>{var e,t,o;const l=String(null!=(t=null==(e=n.node)?void 0:e.language)?t:"");return String(null!=(o=String(l).split(/\s+/g)[0])?o:"").toLowerCase().replace(/[^\w-]/g,"")||"plaintext"}),i=A(()=>`language-${r.value}`),a=A(()=>{var e;return!0===n.loading||!0===(null==(e=n.node)?void 0:e.loading)}),u=A(()=>{var e;return l(null==(e=n.node)?void 0:e.code,a.value)});let s="",d=1;const c=A(()=>function(e){let n=0,t=1;e.startsWith(s)&&(n=s.length,t=d,n>0&&"\r"===e[n-1]&&"\n"===e[n]&&n++);for(let o=n;o<e.length;o++)"\n"===e[o]?t++:"\r"===e[o]&&(t++,"\n"===e[o+1]&&o++);return s=e,d=t,t}(u.value));let f="",m=[],v=0,h=0;const p=new RegExp("(?<=\\n)|(?<=\\r)(?!\\n)"),g=A(()=>function(e){const n=e.length>f.length&&e.startsWith(f),t=n?m:[],o=n?h:0;n&&(t.length=v);for(const r of e.slice(o).split(p))t.push(r);const l=e[e.length-1];return"\n"===l?(v=t.length,h=e.length,t.push("")):(v=t.length-1,h=e.length-t[t.length-1].length,"\r"===l&&t.push("")),f=e,m=t,t}(u.value)),y=A(()=>{var e;return!0===n.showLineNumbers&&!0===(null==(e=n.node)?void 0:e.diff)}),b=A(()=>{var e;if(D(t.class).split(/\s+/).includes("is-wrap"))return!0;const n=se(t.style);return"string"==typeof n?/(?:^|;)\s*white-space\s*:\s*(?:pre-wrap|break-spaces)(?:\s*!important)?\s*(?:;|$)/i.test(n):["pre-wrap","break-spaces"].includes(String(null!=(e=null==n?void 0:n.whiteSpace)?e:null==n?void 0:n["white-space"]))}),k=A(()=>y.value&&b.value);let w=0,x="";const S=A(()=>{const e=c.value;e<w&&(w=0,x="");for(let n=w+1;n<=e;n++)x+=`${x?"\n":""}${n}`;return w=e,x}),M=A(()=>y.value&&!0===n.diffInline),C=A(()=>{const e=Number(n.reservedHeightPx);if(!Number.isFinite(e)||e<=0)return;const t=`${Math.ceil(e)}px`;return a.value?{maxHeight:t,overflow:"auto"}:{height:t,minHeight:t,maxHeight:t,overflow:"auto"}});function N(e,n){const t=l(e,n);if(!t)return 0;let o=1;for(let l=0;l<t.length;l++)"\n"===t[l]?o++:"\r"===t[l]&&(o++,"\n"===t[l+1]&&l++);return o}const _=A(()=>{var e,t,l,r,i;return y.value?Re({code:null==(e=n.node)?void 0:e.code,hideUnchangedRegions:n.diffHideUnchangedRegions,inline:M.value,language:null==(t=n.node)?void 0:t.language,loading:a.value,matchCache:o,originalCode:null==(l=n.node)?void 0:l.originalCode,raw:null==(r=n.node)?void 0:r.raw,updatedCode:null==(i=n.node)?void 0:i.updatedCode}):[]}),T=A(()=>{const e=_.value;let n=1,t=!1;for(const o of e)for(const e of o.lines)"collapsed"===e.kind&&(t=!0),"number"==typeof e.number&&e.number>n&&(n=e.number);return{maxNumberedLine:n,hasCollapsed:t}}),B=A(()=>{var e,t;if(!0!==n.showLineNumbers)return;let o=y.value?1:c.value;y.value&&(o=Math.max(o,N(null==(e=n.node)?void 0:e.originalCode,a.value),N(null==(t=n.node)?void 0:t.updatedCode,a.value),T.value.maxNumberedLine));const l=`${Math.max(2,String(o).length)}ch`;return{"--markstream-pre-line-number-width":l,"--markstream-pre-diff-line-number-width":l,"--markstream-code-padding-left":"calc(var(--markstream-pre-line-number-padding-left, 2ch) + var(--markstream-pre-line-number-width, 2ch) + var(--markstream-pre-line-number-padding-right, 1ch) + var(--markstream-pre-line-number-separator-width, 2px) + var(--markstream-pre-line-number-gap-to-code, 1ch))"}}),I=A(()=>y.value&&T.value.hasCollapsed),H=A(()=>{const e=r.value;return e?`Code block: ${e}`:"Code block"}),$=q(null),R=q([]);let P=null,F=null,O=!1,E=null;function W(){if(O||"undefined"==typeof window||!y.value||M.value||!k.value)return;if(null!=P)return;const e=null!=F?F:F=import("./preCodeDiffMetrics.js");P=window.requestAnimationFrame(()=>{e.then(({measurePreCodeDiffLines:e})=>{!O&&$.value&&(R.value=e($.value,R.value))},()=>{F=null}).finally(()=>{P=null})})}function V(e){null==E||E.disconnect(),E=null,e&&y.value&&!M.value&&k.value&&"undefined"!=typeof ResizeObserver&&(E=new ResizeObserver(()=>{W()}),E.observe(e))}function Z(e,n){if(!k.value)return;const t=R.value[e];if(!t)return;const o="original"===n?t.originalHeight:t.modifiedHeight;return{"--markstream-pre-diff-synced-row-height":`${Math.ceil(t.rowHeight)}px`,"--markstream-pre-diff-content-height":`${Math.ceil(o)}px`}}return X($,e=>{V(e),W()},{flush:"post"}),X([y,M,_,k],()=>{V($.value),y.value&&!M.value&&k.value?W():R.value.length&&(R.value=[])},{flush:"post",immediate:!0}),ne(()=>{O=!0,null!=P&&(window.cancelAnimationFrame(P),P=null),null==E||E.disconnect(),E=null}),(e,t)=>{return K(),j("pre",{ref_key:"preRef",ref:$,style:se([C.value,B.value]),class:D([i.value,{"markstream-pre--line-numbers":n.showLineNumbers,"markstream-pre--diff-preview":y.value,"markstream-pre--diff-inline":M.value,"markstream-pre--diff-collapsed":I.value}]),"aria-busy":a.value,"aria-label":H.value,"data-language":r.value,"data-markstream-line-numbers":n.showLineNumbers?"1":void 0,"data-markstream-pre":"1",tabindex:"0"},[y.value?(K(),j("code",Mt,[(K(!0),j(Y,null,J(_.value,e=>(K(),j("span",{key:e.key,class:D(["markstream-pre__diff-pane",e.className])},[z("span",Ct,[(K(!0),j(Y,null,J(e.lines,(n,o)=>(K(),j("span",{key:n.key,class:D(["markstream-pre__diff-line",[`markstream-pre__diff-line--${n.kind}`,n.metadataKind?`markstream-pre__diff-line--metadata-${n.metadataKind}`:"",{"markstream-pre__diff-line--empty":n.empty,"markstream-pre__diff-line--collapsed-first":!0===n.collapsedFirst,"markstream-pre__diff-line--collapsed-last":!0===n.collapsedLast}]]),style:se(Z(o,e.key))},[t[1]||(t[1]=z("span",{class:"markstream-pre__diff-rail","aria-hidden":"true"},null,-1)),"collapsed"===n.kind?(K(),j("span",Nt,[...t[0]||(t[0]=[z("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[z("path",{d:"M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06"})],-1)])])):G("",!0),z("span",_t,L(n.number),1),z("span",Tt,[z("span",Bt,L(n.code),1)])],6))),128))])],2))),128))])):(K(),j(Y,{key:1},[!0===n.showLineNumbers&&!0!==(null==(o=n.node)?void 0:o.diff)&&b.value?(K(),j("code",It,[(K(!0),j(Y,null,J(g.value,(e,n)=>(K(),j("span",{key:n,class:"markstream-pre__logical-line","data-line-number":n+1,textContent:L(e)},null,8,Ht))),128))])):(K(),j(Y,{key:1},[n.showLineNumbers?(K(),j("span",$t,[z("span",{class:"markstream-pre__line-numbers-text",textContent:L(S.value)},null,8,Rt)])):G("",!0),z("code",{translate:"no",class:"markstream-pre__code",textContent:L(u.value)},null,8,Pt)],64))],64))],14,St);var o}}});Ft.install=e=>{e.component(Ft.__name,Ft)};const At=["onAnimationend"],Ot=/* @__PURE__ */an(/* @__PURE__ */O({__name:"TextNode",props:{node:{}},emits:["copy"],setup(e){const n=e,t=U(),o=F("markstreamFade",void 0),l=F("markstreamTextStreamState",void 0),r=A(()=>{const e=t.fade;return""===e||!0===e||"true"===e||!1!==e&&"false"!==e&&void 0}),i=A(()=>"boolean"==typeof r.value?r.value:"boolean"!=typeof(null==o?void 0:o.value)||o.value),a=A(()=>{var e;const n=null!=(e=t["index-key"])?e:t.indexKey;return null==n||""===n?"":String(n)}),{settledContent:u,segments:s,update:d,finish:c,settleFinished:f}=Bn(n.node.content),m=q(null),v=q(null),h=q([]);let p,g="",y=null,b=null,k=!1;function w(){var e;if(!h.value.length)return!1;const n=null==(e=document.getSelection)?void 0:e.call(document);if(!n||n.isCollapsed)return!1;for(let t=0;t<n.rangeCount;t++){const e=n.getRangeAt(t);if(h.value.some(n=>e.intersectsNode(n)))return!0}return!1}function x(e){const n=a.value;d(e,n?null==l?void 0:l.get(n):void 0,i.value),n&&(null==l||l.set(n,e))}X([u,m,v],function(){var e,n;const t=m.value;if(!t)return;const o=String(null!=(e=u.value)?e:""),l=v.value;return y||(y=t.firstChild,g=null!=(n=null==y?void 0:y.data)?n:""),o.startsWith(g)?!y&&o?(t.textContent=o,y=t.firstChild,void(g=o)):void(o.length>g.length&&l&&(l.appendChild(document.createTextNode(o.slice(g.length))),g=o,function(e){var n,t;if(e.childNodes.length<=4)return;if(function(e){var n;const t=null==(n=document.getSelection)?void 0:n.call(document);if(!t||0===t.rangeCount)return!1;const{anchorNode:o,focusNode:l}=t;return null!=o&&e.contains(o)||null!=l&&e.contains(l)}(e))return;let o="";for(let l=0;l<e.childNodes.length;l++)o+=null!=(t=null==(n=e.childNodes[l])?void 0:n.textContent)?t:"";e.textContent=o}(l))):(t.textContent=o,y=t.firstChild,l&&(l.textContent=""),void(g=o))},{immediate:!0}),X([()=>n.node.content,a,i],([e])=>{const n=String(null!=e?e:"");if(w())return b=n,void C();b=null,k=!1,x(n)},{immediate:!0});const S=q(u.value);function M(){if(!w())if(N(),null!=b){const e=b;b=null,k=!1,x(e),f()}else k&&(k=!1,f())}function C(){p||(p=document,p.addEventListener("selectionchange",M))}function N(){null==p||p.removeEventListener("selectionchange",M),p=void 0}return de(N),(n,t)=>(K(),j("span",{class:D([[e.node.center?"text-node-center":""],"text-node"])},[ce(z("span",{ref_key:"settledTextEl",ref:m},L(S.value),513),[[fe,""!==V(u)]]),ce(z("span",{ref_key:"settledAppendsEl",ref:v},null,512),[[fe,""!==V(u)]]),(K(!0),j(Y,null,J(V(s),e=>(K(),j("span",{key:e.id,ref_for:!0,ref_key:"streamedDeltaEls",ref:h,class:"text-node-stream-delta",onAnimationend:n=>function(e){const n=w();c(e,n),n&&(k=!0,C())}(e.id)},L(e.content),41,At))),128))],2))}}),[["__scopeId","data-v-3be01052"]]);function Kt(e){var n;if("boolean"==typeof e)return e;const t=e;if(!0===(null==t?void 0:t.expandUnchanged))return!1;const o=Number(null==(n=null==t?void 0:t.parseDiffOptions)?void 0:n.context),l=Number(null==t?void 0:t.collapsedContextThreshold);return{enabled:!0,contextLineCount:isFinite(o)&&o>=0?Math.floor(o):2,minimumLineCount:isFinite(l)&&l>=0?Math.floor(l)+1:6,revealLineCount:5}}function jt(e){return"unified"===e.diffStyle}function zt(e){var n,t;const o=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";if(o.length<3)return"";const l=o[0];if("`"!==l&&"~"!==l||o[1]!==l||o[2]!==l)return"";let r=3;for(;o[r]===l;)r+=1;return o.slice(r).trim()}function Lt(e){var n;return"diff"===(null!=(n=String(null!=e?e:"").trim().split(/\s+/,1)[0])?n:"")}function Et(e){var n;return!0===e.diff||Lt(e.language)||Lt(zt(String(null!=(n=e.raw)?n:"")))}function Dt(e,n,t){const o=function(e){const n=zt(e);if(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const o="diff"===t[0]?t.slice(1):t;for(const l of o){const e=l.includes(":")?l.slice(l.indexOf(":")+1):l;if(e&&/[./\\-]/.test(e))return e}return""}(e);return{title:o||n,caption:o?t?`Diff / ${n}`:n:""}}function Wt(e){const n=String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"");return n?n.split(/\r\n|\n|\r/):[]}Ot.install=e=>{e.component(Ot.__name,Ot)};let Vt="",qt="",Ut=null;function Xt(e,n){var t;if(Ut&&Vt===e&&qt===n)return Ut;const o=Wt(e),l=Wt(n);let r=0,i=o.length-1,a=l.length-1;for(;r<=i&&r<=a&&o[r]===l[r];)r++;for(;i>=r&&a>=r&&o[i]===l[a];)i--,a--;const u=Math.max(0,i-r+1),s=Math.max(0,a-r+1);let d;if(0===u||0===s)d={removed:u,added:s};else if((u+1)*(s+1)<=15e5){const e=/* @__PURE__ */new Map,n=new Uint32Array(s);for(let t=0;t<s;t++){const o=l[r+t];let i=e.get(o);void 0===i&&(i=e.size+1,e.set(o,i)),n[t]=i}const i=new Uint32Array(u);for(let l=0;l<u;l++)i[l]=null!=(t=e.get(o[r+l]))?t:0;const a=s+1;let c=new Uint32Array(a),f=new Uint32Array(a);for(let t=u-1;t>=0;t--){f[s]=0;for(let o=s-1;o>=0;o--)f[o]=i[t]===n[o]?c[o+1]+1:Math.max(c[o],f[o+1]);const e=c;c=f,f=e}const m=c[0];d={removed:u-m,added:s-m}}else d={removed:u,added:s};return Vt=e,qt=n,Ut=d,d}function Yt(e){var n,t,o,l,r;const i=e.isDark?"dark":"light";return void 0!==e.theme?"string"==typeof e.theme?e.theme:e.theme[i]:null!=(r=e.isDark?null!=(t=e.darkTheme)?t:null==(n=e.themes)?void 0:n[0]:null!=(l=e.lightTheme)?l:null==(o=e.themes)?void 0:o[1])?r:`vitesse-${i}`}function Zt(e,n=!1){const t=e.toLowerCase();return t?/dark|night|moon|black|dracula|mocha|frappe|macchiato|ocean|poimandres|monokai|laserwave|tokyo|rose-pine|material-theme/.test(t)&&!/light|latte|dawn|lotus/.test(t):n}function Gt(e){const n=Yt(e),t="vitesse-dark"===n||"vitesse-light"!==n&&Zt(n,!0===e.isDark);if("vitesse-dark"!==n&&"vitesse-light"!==n){const e=t?"var(--markstream-code-theme-bg, #121212)":"var(--markstream-code-theme-bg, #ffffff)";return{builtin:!1,dark:t,name:n,background:e,diffAddedLine:`color-mix(in lab, ${e} ${t?"80%":"88%"}, ${t?"#4d9375":"#1e754f"})`,diffAddedNumber:`color-mix(in lab, ${e} ${t?"85%":"91%"}, ${t?"#4d9375":"#1e754f"})`,diffRemovedLine:`color-mix(in lab, ${e} ${t?"80%":"88%"}, ${t?"#cb7676":"#ab5959"})`,diffRemovedNumber:`color-mix(in lab, ${e} ${t?"85%":"91%"}, ${t?"#cb7676":"#ab5959"})`,foreground:t?"var(--markstream-code-theme-fg, #dbd7caee)":"var(--markstream-code-theme-fg, #393a34)",lineNumber:t?"var(--markstream-code-theme-line-number, #dedcd550)":"var(--markstream-code-theme-line-number, #393a3450)"}}return t?{builtin:!0,dark:!0,name:n,background:"#121212",diffAddedLine:"color-mix(in lab, #121212 80%, #4d9375)",diffAddedNumber:"color-mix(in lab, #121212 85%, #4d9375)",diffRemovedLine:"color-mix(in lab, #121212 80%, #cb7676)",diffRemovedNumber:"color-mix(in lab, #121212 85%, #cb7676)",foreground:"#dbd7caee",lineNumber:"#dedcd550"}:{builtin:!0,dark:!1,name:n,background:"#ffffff",diffAddedLine:"color-mix(in lab, #ffffff 88%, #1e754f)",diffAddedNumber:"color-mix(in lab, #ffffff 91%, #1e754f)",diffRemovedLine:"color-mix(in lab, #ffffff 88%, #ab5959)",diffRemovedNumber:"color-mix(in lab, #ffffff 91%, #ab5959)",foreground:"#393a34",lineNumber:"#393a3450"}}const Jt=12,Qt=18;function eo(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:void 0}function no(e){var n,t,o,l,r,i;const a=null!=(n=eo(null==e?void 0:e.fontSize))?n:12,u=null!=(t=eo(null==e?void 0:e.lineHeight))?t:12===a?18:Math.max(12,Math.round(1.5*a)),s="string"==typeof(null==e?void 0:e.fontFamily)&&e.fontFamily.trim()?e.fontFamily.trim():'"SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono", "Courier New", monospace',d=null!=(o="number"==typeof(c=null==e?void 0:e.padding)&&Number.isFinite(c)&&c>=0?c:void 0)?o:8;var c;return{fontFamily:s,fontSize:a,lineHeight:u,maxHeight:null!=(l=eo(null==e?void 0:e.maxHeight))?l:500,overflow:null!=(r=null==e?void 0:e.overflow)?r:"wrap",padding:d,paddingBottom:d,scrollbarGutter:6,tabSize:null!=(i=eo(null==e?void 0:e.tabSize))?i:4}}function to(e,n,t){return O({name:e,inheritAttrs:!1,setup(e,{attrs:o,slots:l}){var r,i;const s=ft(),d=st(),c=dt(),f="undefined"!=typeof window&&1===(null==(i=null==(r=Q())?void 0:r.vnode.el)?void 0:i.nodeType),m=q("undefined"==typeof window||f||!c.value),v=P(null);let h=null;function p(e){const n=e&&"$el"in e?e.$el:e;v.value=n instanceof HTMLElement?n:null}return"undefined"!=typeof window&&X([v,c],([e,n],t,o)=>{if(null==h||h.destroy(),h=null,!n||m.value)return void(m.value=!0);if(!e)return;let l=!0;const r=s(e,{rootMargin:null==d?void 0:d.value.heavyBlockMargin,allowIdle:!1});h=r,m.value=r.isVisible.value,r.whenVisible.then(()=>{l&&h===r&&(m.value=!0)}),o(()=>{l=!1,r.destroy(),h===r&&(h=null)})},{immediate:!0}),ne(()=>{null==h||h.destroy(),h=null}),()=>E(m.value?n:t,u(a({},o),{ref:p}),l)}})}const oo=O({name:"CodeBlockNodeLoadingShell",inheritAttrs:!1,props:["node","isDark","loading","stream","codeBlockOptions","showLineNumbers","theme","darkTheme","lightTheme","isShowPreview","showHeader","showCopyButton","showExpandButton","showPreviewButton","showCollapseButton","showFontSizeButtons","enableFontSizeControl","minWidth","maxWidth","themes","showTooltips","htmlPreviewAllowScripts","htmlPreviewSandbox","customId","indexKey","estimatedHeightPx","estimatedContentHeightPx","estimatedDiffInline","diffInline","diffHideUnchangedRegions","reservedHeightPx"],emits:["click","mouseover","mouseout","copy","previewCode","handleArtifactClick"],setup(e,{attrs:n}){const t=e,o=$e();return()=>{var e,l,r,i,s,d,c,f,m,v,h,p;const g=null!=(e=t.codeBlockOptions)?e:{},y=no(g),b=Gt({darkTheme:t.darkTheme,isDark:t.isDark,lightTheme:t.lightTheme,theme:t.theme,themes:t.themes}),k=Ne(String(null!=(r=null==(l=t.node)?void 0:l.language)?r:"")),w=Et(t.node),x=Dt(String(null!=(s=null==(i=t.node)?void 0:i.raw)?s:""),_e[k]||("typescript"===k?"TypeScript":k?k.charAt(0).toUpperCase()+k.slice(1):_e[""]),w),S=w?Re({originalCode:null==(d=t.node)?void 0:d.originalCode,updatedCode:null==(c=t.node)?void 0:c.updatedCode,loading:!0,matchCache:o}).flatMap(e=>e.lines):[],M=w?{removed:S.filter(e=>"removed"===e.kind).length,added:S.filter(e=>"added"===e.kind).length}:null,C=Number(null!=(f=t.estimatedContentHeightPx)?f:t.reservedHeightPx),N=!w&&Number.isFinite(C)&&C>0?Math.min(y.maxHeight,Math.ceil(C)):void 0,_=e=>E("button",{class:`code-action-btn code-loading-action code-loading-action--${e} inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0`,"aria-hidden":"true",disabled:!0,tabindex:-1,type:"button"}),T=!1!==t.showExpandButton||!1!==t.showPreviewButton&&!1!==t.isShowPreview&&("html"===k||"svg"===k)||!1!==t.showFontSizeButtons&&!1!==t.enableFontSizeControl,B=e=>null==e?void 0:"number"==typeof e?`${e}px`:String(e),I={"--code-bg":b.background,"--code-fg":b.foreground,"--code-line-number":b.lineNumber,"--markstream-code-fallback-bg":b.background,"--markstream-code-fallback-fg":b.foreground,"--markstream-diff-added-line-fill":b.diffAddedLine,"--markstream-diff-added-number-fill":b.diffAddedNumber,"--markstream-diff-editor-bg":b.background,"--markstream-diff-metadata-bg":b.background,"--markstream-diff-metadata-fg":b.lineNumber,"--markstream-diff-removed-line-fill":b.diffRemovedLine,"--markstream-diff-removed-number-fill":b.diffRemovedNumber,"--markstream-diff-shell-bg":b.background,"--markstream-pre-resolved-theme-bg":b.background,"--markstream-pre-resolved-theme-fg":b.foreground,"--markstream-pre-resolved-theme-line-number":b.lineNumber};return E("div",u(a({},n),{class:["code-block-container rounded-lg border",{dark:!0===t.isDark,"is-dark":b.dark,"is-rendering":!1!==t.loading,"is-diff":w},n.class],style:[a(u(a({},I),{backgroundColor:b.background,color:b.foreground,minWidth:B(t.minWidth),maxWidth:B(t.maxWidth)}),w?{}:{borderColor:"var(--markstream-code-border-color, var(--code-border))"}),n.style],"data-markstream-code-block":"1","data-markstream-enhanced":"false","data-markstream-code-block-state":t.loading?"streaming":"settled","data-markstream-code-loading":"1"}),[!1===t.showHeader?null:E("div",{class:"code-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)] border-[var(--code-border)] bg-[var(--code-header-bg)] text-[var(--code-fg)]"},[E("div",{class:"code-header-main"},[E("span",{class:"icon-slot h-4 w-4 flex-shrink-0","aria-hidden":"true",innerHTML:Te(k)}),E("div",{class:"code-header-copy"},[E("div",{class:"code-header-title"},x.title),x.caption?E("div",{class:"code-header-caption"},x.caption):null])]),E("div",{class:"flex items-center gap-0.5"},[M?E("div",{class:"code-diff-stats","aria-label":`-${M.removed} +${M.added}`},[E("span",{class:"code-diff-stat removed"},`-${M.removed}`),E("span",{class:"code-diff-stat added"},`+${M.added}`)]):null,!1===t.showCopyButton?null:_("copy"),!1===t.showCollapseButton?null:_("collapse"),T?E("div",{class:"relative"},[_("more")]):null])]),E("div",{class:"code-block-shell-content",style:!1!==t.stream||!1===t.loading?void 0:{display:"none"}},[E(Ft,{node:t.node,loading:t.loading,showLineNumbers:null!=(m=t.showLineNumbers)?m:!0!==g.disableLineNumbers,diffInline:w&&Boolean(null!=(h=null!=(v=t.diffInline)?v:t.estimatedDiffInline)?h:"unified"===g.diffStyle),diffHideUnchangedRegions:w?null!=(p=t.diffHideUnchangedRegions)?p:Kt(g):void 0,reservedHeightPx:N,class:["code-pre-fallback",{"is-wrap":"wrap"===y.overflow}],style:u(a({},I),{"--markstream-code-padding-x":`${y.padding}px`,"--markstream-code-padding-y":`${y.padding}px`,"--markstream-code-tab-size":y.tabSize,"--markstream-pre-diff-line-height":`${y.lineHeight}px`,backgroundColor:b.background,color:b.foreground,fontFamily:y.fontFamily,fontSize:`${y.fontSize}px`,lineHeight:`${y.lineHeight}px`,maxHeight:`${null!=N?N:y.maxHeight}px`,overflow:"auto",paddingTop:`${y.padding}px`,paddingBottom:`${y.paddingBottom}px`,tabSize:y.tabSize,whiteSpace:"wrap"===y.overflow?"pre-wrap":"pre",overflowWrap:"wrap"===y.overflow?"anywhere":"normal"}),"data-markstream-code-loading":"1"})]),E("div",{class:"code-loading-placeholder",style:!1===t.stream&&!1!==t.loading?void 0:{display:"none"}},[E("div",{class:"loading-skeleton"},[E("div",{class:"skeleton-line"}),E("div",{class:"skeleton-line"}),E("div",{class:"skeleton-line short"})])])])}}}),lo=le({loader:()=>import("./PreCodeBlock.js"),loadingComponent:oo,delay:0,suspensible:!0}),ro=to("ViewportDeferredCodeBlockNode",le({loader:()=>s(null,null,function*(){try{return(yield import("./CodeBlockNode.js")).default}catch(e){return console.warn('[markstream-vue] Failed to load the enhanced CodeBlockNode chunk; falling back to preformatted code rendering. Enhanced code blocks require the optional "stream-diffs" peer.',e),Ft}}),loadingComponent:oo,delay:0,suspensible:!1}),oo),io=le(()=>s(null,null,function*(){var e;if("test"===(null==(e=function(){const e=Reflect.get(globalThis,"process");return null==e?void 0:e.env}())?void 0:e.NODE_ENV)&&"undefined"!=typeof window)return e=>{var n,t,o,l;return E(Ot,u(a({},e),{node:{type:"text",content:null!=(t=e.node.raw)?t:`$${null!=(n=e.node.content)?n:""}$`,raw:null!=(l=e.node.raw)?l:`$${null!=(o=e.node.content)?o:""}$`}}))};try{return yield He(),(yield import("./index6.js")).default}catch(n){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".',n)}return e=>{var n,t,o,l;return E(Ot,u(a({},e),{node:{type:"text",content:null!=(t=e.node.raw)?t:`$${null!=(n=e.node.content)?n:""}$`,raw:null!=(l=e.node.raw)?l:`$${null!=(o=e.node.content)?o:""}$`}}))}})),ao=le(()=>s(null,null,function*(){try{return yield He(),(yield import("./index5.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,o,l;return E(Ot,u(a({},e),{node:{type:"text",content:null!=(t=e.node.raw)?t:`$$${null!=(n=e.node.content)?n:""}$$`,raw:null!=(l=e.node.raw)?l:`$$${null!=(o=e.node.content)?o:""}$$`}}))}})),uo=["data-reference-id","data-markstream-reference-id"],so=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ReferenceNode",props:{node:{},messageId:{},threadId:{}},emits:["click","mouseEnter","mouseLeave"],setup:e=>(n,t)=>(K(),j("span",{class:"reference-node cursor-pointer text-xs rounded-md px-1.5 mx-0.5",role:"button",tabindex:"0","data-reference-id":e.node.id,"data-markstream-reference-id":e.node.id,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))},L(e.node.id),41,uo))}),[["__scopeId","data-v-b96c91c3"]]);so.install=e=>{e.component(so.__name,so)};const co={class:"superscript-node"},fo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"SuperscriptNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ot,inline_code:Rn,link:So,html_inline:Tn,strong:po,emphasis:Bo,footnote_reference:hn,strikethrough:yo,highlight:_o,insert:Co,subscript:vo,emoji:dn,math_inline:io,reference:so},t.value));return(t,l)=>(K(),j("sup",co,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(xt),{key:`${e.indexKey||"superscript"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"superscript"}-${l}`,"fallback-to-text":""},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-24160b22"]]);fo.install=e=>{e.component(fo.__name,fo)};const mo={class:"subscript-node"},vo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"SubscriptNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ot,inline_code:Rn,link:So,html_inline:Tn,strong:po,emphasis:Bo,footnote_reference:hn,strikethrough:yo,highlight:_o,insert:Co,superscript:fo,emoji:dn,math_inline:io,reference:so},t.value));return(t,l)=>(K(),j("sub",mo,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(xt),{key:`${e.indexKey||"subscript"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"subscript"}-${l}`,"fallback-to-text":""},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-197fa13b"]]);vo.install=e=>{e.component(vo.__name,vo)};const ho={class:"strong-node"},po=/* @__PURE__ */an(/* @__PURE__ */O({__name:"StrongNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ot,inline_code:Rn,link:So,html_inline:Tn,emphasis:Bo,strikethrough:yo,highlight:_o,insert:Co,subscript:vo,superscript:fo,emoji:dn,footnote_reference:hn,math_inline:io,reference:so},t.value));return(t,l)=>(K(),j("strong",ho,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(xt),{key:`${e.indexKey||"strong"}-${l}`,components:o.value,node:t,"index-key":`${e.indexKey||"strong"}-${l}`,"custom-id":n.customId},null,8,["components","node","index-key","custom-id"]))),128))]))}}),[["__scopeId","data-v-a8647104"]]);po.install=e=>{e.component(po.__name,po)};const go={class:"strikethrough-node"},yo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"StrikethroughNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ot,inline_code:Rn,link:So,html_inline:Tn,strong:po,emphasis:Bo,highlight:_o,insert:Co,subscript:vo,superscript:fo,emoji:dn,footnote_reference:hn,math_inline:io,reference:so},t.value));return(t,l)=>(K(),j("del",go,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(xt),{key:`${e.indexKey||"strikethrough"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"strikethrough"}-${l}`},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-b7a531fa"]]);yo.install=e=>{e.component(yo.__name,yo)};const bo=["href","title","aria-label","aria-hidden","target","rel"],ko=["aria-hidden"],wo={class:"link-text-wrapper relative inline-flex"},xo={class:"leading-[normal] link-text"},So=/* @__PURE__ */an(/* @__PURE__ */O({__name:"LinkNode",props:{node:{},indexKey:{},customId:{},showTooltip:{type:Boolean,default:!0},color:{},underlineHeight:{},underlineBottom:{},animationDuration:{},animationOpacity:{},animationTiming:{},animationIteration:{}},setup(e){const n=e,t=F("markstreamShowTooltips",void 0),o=A(()=>{const e=null==t?void 0:t.value;return"boolean"==typeof e?e:n.showTooltip}),l=A(()=>{var e,t,o,l,r;const i=void 0!==n.underlineBottom?"number"==typeof n.underlineBottom?`${n.underlineBottom}px`:String(n.underlineBottom):"-3px",a=null!=(e=n.animationOpacity)?e:.35,u=Math.max(.12,Math.min(.5*a,a)),s={"--underline-height":`${null!=(t=n.underlineHeight)?t:2}px`,"--underline-bottom":i,"--underline-opacity":String(a),"--underline-rest-opacity":String(u),"--underline-duration":`${null!=(o=n.animationDuration)?o:1.6}s`,"--underline-timing":null!=(l=n.animationTiming)?l:"ease-in-out","--underline-iteration":"number"==typeof n.animationIteration?String(n.animationIteration):null!=(r=n.animationIteration)?r:"infinite"};return n.color&&(s["--link-color"]=n.color),s}),r=en(()=>n.customId),i=A(()=>a({text:Ot,strong:po,strikethrough:yo,emphasis:Bo,image:bt,html_inline:Tn,inline_code:Rn},r.value)),u=U(),s=A(()=>{var e,t;const o=null==(e=n.node)?void 0:e.attrs;if(!o||"object"!=typeof o)return{};const l={};if(Array.isArray(o))for(const n of o)Array.isArray(n)&&n[0]&&(l[String(n[0])]=String(null!=(t=n[1])?t:""));else for(const[n,r]of Object.entries(o))n&&null!=r&&!1!==r&&(l[n]=!0===r?"":String(r));return bn(l,"safe","a")}),d=A(()=>a(a({},u),s.value)),c=A(()=>{var e,t;return bn({href:String(null!=(t=null==(e=n.node)?void 0:e.href)?t:"")},"safe","a").href}),f=A(()=>{if(!c.value)return;const e=d.value.target;return("string"==typeof e?e.trim():String(null!=e?e:"").trim())||(x(c.value)?"_blank":void 0)}),m=A(()=>{var e;return"_blank"===String(null!=(e=f.value)?e:"").trim().toLowerCase()}),v=A(()=>{if(!c.value)return;const e=d.value.rel,n=new Set(("string"==typeof e?e:String(null!=e?e:"")).split(/\s+/).filter(Boolean)),t=new Set(Array.from(n).filter(e=>"opener"!==e.toLowerCase()));return m.value&&(t.add("noopener"),t.add("noreferrer")),t.size>0?Array.from(t).join(" "):void 0}),h=A(()=>{const e=a({},d.value);return delete e.title,delete e.href,delete e.target,delete e.rel,e});function p(){o.value&&Zn()}const g=A(()=>{var e,t;const o=null==(e=n.node)?void 0:e.title;return"string"==typeof o&&o.trim().length>0?o:String(null!=(t=c.value)?t:"")});return(t,r)=>{var a,s;return e.node.loading?(K(),j("span",ae({key:1,class:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":e.node.loading?"false":"true"},V(u),{style:l.value}),[z("span",wo,[z("span",xo,[W(V(Ot),{class:"leading-[normal] link-text",node:{type:"text",content:String(null!=(a=e.node.text)?a:""),raw:String(null!=(s=e.node.text)?s:"")},"index-key":`${e.indexKey||"link-text"}-loading`},null,8,["node","index-key"])]),r[1]||(r[1]=z("span",{class:"link-loading-indicator","aria-hidden":"true"},null,-1))])],16,ko)):(K(),j("a",ae({key:0,class:"link-node",href:c.value,title:o.value?"":g.value,"aria-label":`Link: ${g.value}`,"aria-hidden":e.node.loading?"true":"false",target:f.value,rel:v.value},h.value,{style:l.value,onMouseenter:r[0]||(r[0]=e=>function(e){var t,l,r,i;if(!o.value)return;const a=e,u=null!=(null==a?void 0:a.clientX)&&null!=(null==a?void 0:a.clientY)?{x:a.clientX,y:a.clientY}:void 0,s=(null==(t=n.node)?void 0:t.title)||((null==(l=c.value)?void 0:l.includes("xn--"))&&(null==(i=null==(r=n.node)?void 0:r.text)?void 0:i.includes("://"))?n.node.text:c.value)||"";Yn(e.currentTarget,s,"top",!1,u)}(e)),onMouseleave:p}),[(K(!0),j(Y,null,J(e.node.children,(t,o)=>(K(),re(V(xt),{key:`${e.indexKey||"emphasis"}-${o}`,components:i.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"link-text"}-${o}`},null,8,["components","node","custom-id","index-key"]))),128))],16,bo))}}}),[["__scopeId","data-v-a414d325"]]);So.install=e=>{e.component(So.__name,So)};const Mo={class:"insert-node"},Co=/* @__PURE__ */an(/* @__PURE__ */O({__name:"InsertNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ot,inline_code:Rn,link:So,html_inline:Tn,strong:po,emphasis:Bo,strikethrough:yo,highlight:_o,subscript:vo,superscript:fo,emoji:dn,footnote_reference:hn,math_inline:io,reference:so},t.value));return(t,l)=>(K(),j("ins",Mo,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(xt),{key:`${e.indexKey||"insert"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"insert"}-${l}`},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-1e2c29d4"]]);Co.install=e=>{e.component(Co.__name,Co)};const No={class:"highlight-node"},_o=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HighlightNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ot,inline_code:Rn,link:So,html_inline:Tn,strong:po,emphasis:Bo,strikethrough:yo,insert:Co,subscript:vo,superscript:fo,emoji:dn,footnote_reference:hn,math_inline:io,reference:so},t.value));return(t,l)=>(K(),j("mark",No,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(xt),{key:`${e.indexKey||"highlight"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"highlight"}-${l}`},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-7a62982a"]]);_o.install=e=>{e.component(_o.__name,_o)};const To={class:"emphasis-node"},Bo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"EmphasisNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=A(()=>a({text:Ot,inline_code:Rn,link:So,html_inline:Tn,strong:po,strikethrough:yo,highlight:_o,insert:Co,subscript:vo,superscript:fo,emoji:dn,footnote_reference:hn,math_inline:io,reference:so},t.value));return(t,l)=>(K(),j("em",To,[(K(!0),j(Y,null,J(e.node.children,(t,l)=>(K(),re(V(xt),{key:`${e.indexKey||"emphasis"}-${l}`,components:o.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"emphasis"}-${l}`},null,8,["components","node","custom-id","index-key"]))),128))]))}}),[["__scopeId","data-v-2a5aafbf"]]);Bo.install=e=>{e.component(Bo.__name,Bo)};const Io={class:"hard-break"},Ho=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HardBreakNode",props:{node:{}},setup:e=>(e,n)=>(K(),j("br",Io))}),[["__scopeId","data-v-50c58f70"]]);Ho.install=e=>{e.component(Ho.__name,Ho)};const $o=/* @__PURE__ */O({__name:"SimpleInlineRenderer",props:{nodes:{},customId:{},indexKey:{}},setup(e){const n=e,t=me({checkbox:un,checkbox_input:un,emoji:dn,emphasis:Bo,hardbreak:Ho,highlight:_o,inline_code:Rn,insert:Co,link:So,reference:so,strikethrough:yo,strong:po,subscript:vo,superscript:fo,text:Ot}),o=en(()=>n.customId),l=A(()=>{const e=o.value;return Object.keys(e).length>0?a(a({},t),e):t});return(t,o)=>(K(!0),j(Y,null,J(e.nodes,(t,o)=>(K(),re(V(xt),{key:o,components:l.value,node:t,"custom-id":n.customId,"index-key":`${e.indexKey||"inline"}-${o}`},null,8,["components","node","custom-id","index-key"]))),128))}});function Ro(e){if(!e||"object"!=typeof e)return!1;const n=`|${e.type}|`;if(!"|checkbox|checkbox_input|emoji|emphasis|hardbreak|highlight|inline_code|insert|link|reference|strikethrough|strong|subscript|superscript|text|".includes(n))return!1;if(!"|emphasis|highlight|insert|link|strikethrough|strong|subscript|superscript|".includes(n))return!0;const t=e.children;return Array.isArray(t)&&t.every(Ro)}function Po(e,n=!0,t=!1){if(!e||!t&&0===e.length)return null;if(e.every(Ro))return e;if(!n||1!==e.length)return null;const o=e[0];if("paragraph"!==(null==o?void 0:o.type)||!Array.isArray(o.children))return null;const l=o.children;return(t||l.length>0)&&l.every(Ro)?l:null}function Fo(e){var n,t;if(!(null==e?void 0:e.length))return null;let o="";for(const l of e){if("text"!==(null==l?void 0:l.type)||!0===l.center)return null;o+=String(null!=(t=null!=(n=l.content)?n:l.raw)?t:"")}return o}const Ao=["cite"],Oo={key:0,dir:"auto",class:"paragraph-node"},Ko=["custom-id"],jo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"BlockquoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},fade:{type:Boolean},customId:{},showTooltips:{type:Boolean}},emits:["copy"],setup(e){const n=e,t=en(()=>n.customId),o=A(()=>Boolean(t.value.paragraph)),l=A(()=>Boolean(t.value.text)),r=A(()=>Po(n.node.children,!o.value)),i=A(()=>!1!==n.fade||l.value?null:Fo(r.value));return ee("markstreamShowTooltips",A(()=>n.showTooltips)),ee("markstreamFade",A(()=>n.fade)),(t,o)=>(K(),j("blockquote",{class:"blockquote blockquote-node",dir:"auto",cite:e.node.cite},[r.value?(K(),j("p",Oo,[null!==i.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(i.value),9,Ko)):(K(),re(V($o),{key:1,nodes:r.value,"custom-id":n.customId,"index-key":`blockquote-${n.indexKey}-paragraph`},null,8,["nodes","custom-id","index-key"]))])):(K(),re(V(mi),{key:1,"show-tooltips":n.showTooltips,"index-key":`blockquote-${n.indexKey}`,nodes:n.node.children||[],"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))},null,8,["show-tooltips","index-key","nodes","custom-id","typewriter","fade"]))],8,Ao))}}),[["__scopeId","data-v-abfecebc"]]);jo.install=e=>{e.component(jo.__name,jo)};const zo={class:"definition-list"},Lo={class:"definition-term"},Eo={class:"definition-desc"},Do=/* @__PURE__ */an(/* @__PURE__ */O({__name:"DefinitionListNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},fade:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(e,t)=>(K(),j("dl",zo,[(K(!0),j(Y,null,J(n.node.items,(o,l)=>(K(),j(Y,{key:l},[z("dt",Lo,[W(V(mi),{"index-key":`definition-term-${n.indexKey}-${l}`,nodes:o.term,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,onCopy:t[0]||(t[0]=n=>e.$emit("copy",n))},null,8,["index-key","nodes","custom-id","typewriter","fade"])]),z("dd",Eo,[W(V(mi),{"index-key":`definition-desc-${n.indexKey}-${l}`,nodes:o.definition,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,onCopy:t[1]||(t[1]=n=>e.$emit("copy",n))},null,8,["index-key","nodes","custom-id","typewriter","fade"])])],64))),128))]))}}),[["__scopeId","data-v-4e103b30"]]);Do.install=e=>{e.component(Do.__name,Do)};const Wo=["href","title"],Vo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"FootnoteAnchorNode",props:{node:{}},setup(e){const n=e;function t(e){var t;if(e.preventDefault(),"undefined"==typeof document)return;const o=fn(e.currentTarget,`fnref-${String(null!=(t=n.node.id)?t:"")}`);o&&o.scrollIntoView({behavior:"smooth",block:"center"})}return(n,o)=>(K(),j("a",{class:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${e.node.id}`,title:`返回引用 ${e.node.id}`,onClick:t}," ↩︎ ",8,Wo))}}),[["__scopeId","data-v-0dbaa45e"]]);Vo.install=e=>{e.component(Vo.__name,Vo)};const qo=["id"],Uo={class:"flex-1"},Xo=/* @__PURE__ */O({__name:"FootnoteNode",props:{node:{},indexKey:{},typewriter:{type:Boolean},fade:{type:Boolean},customId:{}},emits:["copy"],setup(e){const n=e;return(t,o)=>(K(),j("div",{id:`fnref--${e.node.id}`,class:"footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border)] pt-2"},[z("div",Uo,[W(V(mi),{"index-key":`footnote-${n.indexKey}`,nodes:n.node.children,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,onCopy:o[0]||(o[0]=e=>t.$emit("copy",e))},null,8,["index-key","nodes","custom-id","typewriter","fade"])])],8,qo))}});Xo.install=e=>{e.component(Xo.__name,Xo)};const Yo=["custom-id"],Zo=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HeadingNode",props:{node:{},customId:{},indexKey:{}},setup(e){const n=e,t=en(()=>n.customId),o=F("markstreamFade",void 0),l=A(()=>!1!==(null==o?void 0:o.value)||t.value.text?null:Fo(n.node.children)),r=A(()=>a({text:Ot,inline_code:Rn,link:So,image:bt,strong:po,emphasis:Bo,strikethrough:yo,highlight:_o,insert:Co,subscript:vo,superscript:fo,emoji:dn,checkbox:un,checkbox_input:un,footnote_reference:hn,hardbreak:Ho,math_inline:io,reference:so},t.value));return(t,o)=>(K(),re(ie(`h${e.node.level}`),ae({class:["heading-node",[`heading-${e.node.level}`]],dir:"auto"},e.node.attrs),{default:ue(()=>[null!==l.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(l.value),9,Yo)):(K(!0),j(Y,{key:1},J(e.node.children,(t,o)=>(K(),re(V(xt),{key:o,components:r.value,"custom-id":n.customId,node:t,"index-key":`${e.indexKey||"heading"}-${o}`},null,8,["components","custom-id","node","index-key"]))),128))]),_:1},16,["class"]))}}),[["__scopeId","data-v-7122dbe1"]]),Go=Zo;Go.install=e=>{e.component(Zo.__name,Zo)};const Jo={key:0,dir:"auto",class:"paragraph-node"},Qo=["custom-id"],el={dir:"auto",class:"paragraph-node"},nl=["custom-id"],tl=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ListItemNode",props:{node:{},item:{},indexKey:{},customId:{},typewriter:{type:Boolean},fade:{type:Boolean},showTooltips:{type:Boolean},value:{},isDark:{type:Boolean}},emits:["copy"],setup(e){const n=e,t=A(()=>{var e;return null!=(e=n.node)?e:n.item}),o=en(()=>n.customId),l=A(()=>Boolean(o.value.paragraph)),r=A(()=>Boolean(o.value.text)),i=A(()=>{var e;return Po(null==(e=t.value)?void 0:e.children,!l.value)}),a=A(()=>{var e;if(l.value)return null;const n=null==(e=t.value)?void 0:e.children;if(!Array.isArray(n)||n.length<2)return null;const o=n[0];if("paragraph"!==(null==o?void 0:o.type)||!Array.isArray(o.children))return null;const r=n.slice(1);if(!r.every(e=>"list"===(null==e?void 0:e.type)))return null;const i=Po([o]);return i?{paragraphChildren:i,nestedLists:r}:null});function u(){return!1===n.fade&&!r.value}const s=A(()=>u()?Fo(i.value):null),d=A(()=>{var e;return u()?Fo(null==(e=a.value)?void 0:e.paragraphChildren):null}),c=Object.freeze({}),f=A(()=>{const{value:e}=n;return"number"==typeof e&&Number.isFinite(e)?{value:e}:c});return ee("markstreamShowTooltips",A(()=>n.showTooltips)),ee("markstreamFade",A(()=>n.fade)),(e,o)=>{var l,r;return K(),j("li",ae({class:"list-item",dir:"auto"},f.value),[i.value?(K(),j("p",Jo,[null!==s.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(s.value),9,Qo)):(K(),re(V($o),{key:1,nodes:i.value,"custom-id":n.customId,"index-key":`list-item-${n.indexKey}-paragraph`},null,8,["nodes","custom-id","index-key"]))])):a.value?(K(),j(Y,{key:1},[z("p",el,[null!==d.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(d.value),9,nl)):(K(),re(V($o),{key:1,nodes:a.value.paragraphChildren,"custom-id":n.customId,"index-key":`list-item-${n.indexKey}-paragraph`},null,8,["nodes","custom-id","index-key"]))]),(K(!0),j(Y,null,J(a.value.nestedLists,(t,l)=>(K(),re(V(mi),{key:l,nodes:[t],"custom-id":n.customId,"index-key":`list-item-${n.indexKey}-nested-${l}`,"show-tooltips":n.showTooltips,typewriter:n.typewriter,fade:n.fade,"is-dark":n.isDark,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0,onCopy:o[0]||(o[0]=n=>e.$emit("copy",n))},null,8,["nodes","custom-id","index-key","show-tooltips","typewriter","fade","is-dark"]))),128))],64)):(K(),re(V(mi),{key:2,"show-tooltips":n.showTooltips,"index-key":`list-item-${n.indexKey}`,nodes:null!=(r=null==(l=t.value)?void 0:l.children)?r:[],"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,"is-dark":n.isDark,"batch-rendering":!1,onCopy:o[1]||(o[1]=n=>e.$emit("copy",n))},null,8,["show-tooltips","index-key","nodes","custom-id","typewriter","fade","is-dark"]))],16)}}}),[["__scopeId","data-v-617214f9"]]);tl.install=e=>{e.component(tl.__name,tl)};const ol=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ListNode",props:{node:{},customId:{},indexKey:{},typewriter:{type:Boolean},fade:{type:Boolean},showTooltips:{type:Boolean},isDark:{type:Boolean}},emits:["copy"],setup(e){const n=en(()=>e.customId),t=A(()=>n.value.list_item||tl);return(n,o)=>(K(),re(ie(e.node.ordered?"ol":"ul"),{class:D(["list-node",{"list-decimal":e.node.ordered,"list-disc":!e.node.ordered}])},{default:ue(()=>[(K(!0),j(Y,null,J(e.node.items,(l,r)=>{var i;return K(),re(ie(t.value),ae({key:`${e.indexKey||"list"}-${r}`},{ref_for:!0},{showTooltips:e.showTooltips},{node:l,"custom-id":e.customId,"index-key":`${e.indexKey||"list"}-${r}`,typewriter:e.typewriter,fade:e.fade,"is-dark":e.isDark,value:e.node.ordered?(null!=(i=e.node.start)?i:1)+r:void 0,onCopy:o[0]||(o[0]=e=>n.$emit("copy",e))}),null,16,["node","custom-id","index-key","typewriter","fade","is-dark","value"])}),128))]),_:1},8,["class"]))}}),[["__scopeId","data-v-99cb95e0"]]);ol.install=e=>{e.component(ol.__name,ol)};const ll={key:2,class:"html-block-node__raw"},rl=["innerHTML"],il={key:1,class:"html-block-node__placeholder"},al=/* @__PURE__ */an(/* @__PURE__ */O({__name:"HtmlBlockNode",props:{node:{},customId:{},htmlPolicy:{}},setup(e){var n;const t=e,o=F("markstreamHtmlPolicy",void 0),l=F("markstreamNestedRendererProps",void 0),r=A(()=>{var e,n;return null!=(n=null!=(e=t.htmlPolicy)?e:null==o?void 0:o.value)?n:"safe"}),i=A(()=>{var e,n;const o=null!=(e=null==l?void 0:l.value)?e:{};return u(a({},o),{customId:null!=(n=t.customId)?n:o.customId,htmlPolicy:r.value})}),d=le({loader:()=>Promise.resolve().then(()=>vi),suspensible:!1}),c=A(()=>{const e=m(t.node.attrs,r.value);if(!e)return;const n=v(e);return Object.keys(n).length>0?n:void 0}),f=A(()=>{const e=String(t.node.tag||"").trim(),n=m(t.node.attrs,r.value,e);if(!n)return;const o=v(n);return Object.keys(o).length>0?o:void 0}),h=en(()=>t.customId),p=O({name:"DynamicRenderer",props:{nodes:{type:Array,required:!0}},render(){return this.nodes}}),g=q(null);function y(e,n,t,o){if(!0!==e)return!1;const l=String(null!=n?n:"");if(!l)return!1;if(l!==String(null!=t?t:""))return!0;const r=String(null!=o?o:"").trim();return!!r&&!1===l.toLowerCase().includes(`</${r.toLowerCase()}`)}const w=q(y(t.node.loading,t.node.raw,t.node.content,t.node.tag)),x=q("undefined"==typeof window||w.value),M=q(t.node.content),C=q(0),N=q(String(null!=(n=t.node.raw)?n:"")),_=A(()=>Array.isArray(t.node.children)?t.node.children:[]);X(()=>[t.node.loading,t.node.raw,t.node.content,t.node.tag],([e,n,t,o])=>{const l=String(null!=n?n:""),r=!N.value||l.startsWith(N.value),i=y(e,n,t,o);r?i&&(w.value=!0):(w.value=i,C.value=0),i&&(x.value=!0),N.value=l},{flush:"sync"});const T=A(()=>String(t.node.tag||"div")),B=A(()=>{var e;if("details"!==T.value.trim().toLowerCase())return null;if(null==(e=t.node.attrs)?void 0:e.some(([e])=>"open"===String(e).toLowerCase()))return null;const n=_.value[0];return"html_block"===(null==n?void 0:n.type)&&"summary"===String(n.tag||"").toLowerCase()?n:null}),I=A(()=>{var e;return Fo(null==(e=B.value)?void 0:e.children)}),H=A(()=>{const e=B.value;if(!e)return;const n=m(e.attrs,r.value,"summary");if(!n)return;const t=v(n);return Object.keys(t).length>0?t:void 0}),$=A(()=>null==I.value?_.value:_.value.slice(1)),R=A(()=>{const e=T.value.trim().toLowerCase();return S.has(e)||b(e,r.value)}),E=A(()=>_.value.length>0&&!!t.node.tag&&!R.value),D=A(()=>{var e,n,o;if(E.value)return{mode:"structured"};if(!x.value)return{mode:"html",content:null!=(e=M.value)?e:""};const l=null!=(n=M.value)?n:t.node.content;if(!l)return{mode:"html",content:""};if("escape"===r.value)return{mode:"html",content:k(l,r.value)};const i=w.value||!0===t.node.loading,a=Nn(l,h.value,r.value,i);return a.ok&&(i||a.hasCustomComponents)?{mode:"dynamic",nodes:a.nodes}:i?{mode:"text",content:null!=(o=t.node.raw)?o:l}:{mode:"html",content:k(l,r.value)}}),W=ft(),U=st(),Z=dt(),J=P(null),Q=!!t.node.loading;let ee=null;return"undefined"!=typeof window?(X([()=>g.value,()=>t.node.loading,w],([e,n,o],l,r)=>{if(null==ee||ee.disconnect(),ee=null,!e||!o||!1===n||"undefined"==typeof ResizeObserver)return;const i=new ResizeObserver(e=>{var n,o;if(!w.value||!1===t.node.loading)return;const l=e[0],r=Array.isArray(null==l?void 0:l.borderBoxSize)?l.borderBoxSize[0]:null==l?void 0:l.borderBoxSize,i=null!=(o=null!=(n=null==r?void 0:r.blockSize)?n:null==l?void 0:l.contentRect.height)?o:0;i>C.value&&(C.value=i)});ee=i,i.observe(e),r(()=>i.disconnect())},{immediate:!0}),X(()=>t.node.loading,e=>s(null,null,function*(){!1!==e||!w.value||C.value<=0||(yield oe(),requestAnimationFrame(()=>{!1===t.node.loading&&(C.value=0)}))})),X([()=>g.value,()=>null==U?void 0:U.value.heavyBlockMargin,()=>null==U?void 0:U.value.rootMargin],([e],n,o)=>{var l,r,i,a;if(null==(r=null==(l=J.value)?void 0:l.destroy)||r.call(l),J.value=null,!Q)return x.value=!0,void(M.value=t.node.content);if(!e)return void(w.value||(x.value=!1));let u=!0;const s=null!=(a=null!=(i=null==U?void 0:U.value.heavyBlockMargin)?i:null==U?void 0:U.value.rootMargin)?a:ut,d=W(e,{rootMargin:s,allowIdle:!Z.value});J.value=d,x.value=x.value||d.isVisible.value,d.whenVisible.then(()=>{u&&J.value===d&&(x.value=!0)}),o(()=>{u=!1,d.destroy(),J.value===d&&(J.value=null)})},{immediate:!0}),X(()=>t.node.content,e=>{Q&&!x.value||(M.value=e)})):x.value=!0,ne(()=>{var e,n;null==ee||ee.disconnect(),ee=null,null==(n=null==(e=J.value)?void 0:e.destroy)||n.call(e),J.value=null}),(n,t)=>(K(),re(ie(E.value?T.value:"div"),ae({ref_key:"htmlRef",ref:g,class:"html-block-node",style:C.value>0?{boxSizing:"border-box",minHeight:`${C.value}px`}:void 0,"data-markstream-viewport-pending":V(Z)&&!x.value?"true":void 0},E.value?f.value:void 0),{default:ue(()=>[x.value?(K(),j(Y,{key:0},["structured"===D.value.mode?(K(),j(Y,{key:0},[null!==I.value?(K(),j(Y,{key:0},[z("summary",ve(he(H.value)),L(I.value),17),$.value.length?(K(),re(V(d),ae({key:0},i.value,{nodes:$.value,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes"])):G("",!0)],64)):(K(),re(V(d),ae({key:1},i.value,{nodes:_.value,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes"]))],64)):"dynamic"===D.value.mode?(K(),re(V(p),{key:1,nodes:D.value.nodes},null,8,["nodes"])):"text"===D.value.mode?(K(),j("pre",ll,L(D.value.content),1)):(K(),j("div",ae({key:3},c.value,{innerHTML:D.value.content}),null,16,rl))],64)):(K(),j("div",il,[te(n.$slots,"placeholder",{node:e.node},()=>[t[0]||(t[0]=z("span",{class:"html-block-node__placeholder-bar"},null,-1)),t[1]||(t[1]=z("span",{class:"html-block-node__placeholder-bar w-4/5"},null,-1)),t[2]||(t[2]=z("span",{class:"html-block-node__placeholder-bar w-2/3"},null,-1))],!0)]))]),_:3},16,["style","data-markstream-viewport-pending"]))}}),[["__scopeId","data-v-08559f85"]]);al.install=e=>{e.component(al.__name,al)};const ul={dir:"auto",class:"paragraph-node"},sl=["custom-id"],dl=/* @__PURE__ */an(/* @__PURE__ */O({__name:"ParagraphNode",props:{node:{},customId:{},indexKey:{},customHtmlTags:{},parseOptions:{},customMarkdownIt:{type:Function}},setup(e){const n=e,t=en(()=>n.customId),o=F("markstreamHtmlPolicy",void 0),l=F("markstreamFade",void 0),r=F("markstreamParseOptions",void 0),i=F("markstreamCustomMarkdownIt",void 0),s=F("markstreamNestedRendererProps",void 0),d=A(()=>{var e;return null!=(e=null==o?void 0:o.value)?e:"safe"}),c=A(()=>{var e;return null!=(e=n.parseOptions)?e:null==r?void 0:r.value}),f=A(()=>{var e;return null!=(e=n.customMarkdownIt)?e:null==i?void 0:i.value}),m=A(()=>{var e,t;return null!=(t=n.customHtmlTags)?t:null==(e=null==s?void 0:s.value)?void 0:e.customHtmlTags}),v=A(()=>{var e,t;const o=null!=(e=null==s?void 0:s.value)?e:{};return u(a({},o),{customId:null!=(t=n.customId)?t:o.customId,customHtmlTags:m.value,parseOptions:c.value,customMarkdownIt:f.value,htmlPolicy:d.value})});function h(e){var n;return"text"===e.type&&""===String(null!=(n=e.content)?n:"").trim()}const p=A(()=>n.node.children.filter(e=>!h(e))),g=A(()=>p.value.length>0&&p.value.every(e=>"image"===e.type||function(e){var n;const t=function(e){return"link"===e.type&&Array.isArray(e.children)?e.children.filter(e=>!h(e)):[]}(e);return 1===t.length&&"image"===(null==(n=t[0])?void 0:n.type)}(e))),y=A(()=>new Set(M(m.value))),b=A(()=>{if(!g.value||p.value.length<=1)return n.node.children;const e=[];for(let t=0;t<n.node.children.length;t++){const o=n.node.children[t];if(!h(o)){e.push(o);continue}const l=e.length>0,r=n.node.children.slice(t+1).some(e=>!h(e));l&&r&&e.push(u(a({},o),{content:" ",raw:" "}))}return e}),k=A(()=>!1===(null==l?void 0:l.value)&&!t.value.text),w=A(()=>k.value?Fo(b.value):null);function x(e,t){return a({node:e,"index-key":`${n.indexKey}-${t}`,"custom-id":n.customId,"custom-html-tags":m.value},"reference"===e.type?{"data-markstream-reference-id":String(e.id)}:{})}function S(e){var n,o;const l=e,r=String(l.type);if(t.value[r])return null;const i=function(e){if(!Array.isArray(e))return"";const n=[];for(const t of e){if(!t||"object"!=typeof t)return null;const e=S(t);if(null==e)return null;n.push(e)}return n.join("")}(l.children);if(null==i)return null;const a=[r,l.loading,i];switch(r){case"text":return[...a,l.content,l.center].join("");case"inline_code":return[...a,l.code].join("");case"image":return[...a,l.src,l.alt,l.title].join("");case"link":return[...a,l.href,l.title,l.text,JSON.stringify(null!=(n=l.attrs)?n:null)].join("");case"html_inline":case"html_block":return[...a,l.tag,l.content,l.autoClosed,JSON.stringify(null!=(o=l.attrs)?o:null)].join("");case"emoji":return[...a,l.name,l.markup].join("");case"checkbox":case"checkbox_input":return[...a,l.checked].join("");case"math_inline":return[...a,l.content,l.markup].join("");case"reference":case"footnote_anchor":case"footnote_reference":return[...a,l.id].join("");case"hardbreak":case"emphasis":case"strong":case"strikethrough":case"highlight":case"insert":case"subscript":case"superscript":return a.join("");default:return null}}const _=/* @__PURE__ */new Map,T=A(()=>a({inline_code:Rn,image:bt,link:So,hardbreak:Ho,emphasis:Bo,strong:po,strikethrough:yo,highlight:_o,insert:Co,subscript:vo,superscript:fo,html_inline:Tn,html_block:al,emoji:dn,checkbox:un,math_inline:io,checkbox_input:un,reference:so,footnote_anchor:Vo,footnote_reference:hn,text:Ot},t.value)),B=A(()=>{const e=b.value;if(_.size>e.length)for(const n of _.keys())n>=e.length&&_.delete(n);return e.map((e,o)=>{var l;const r=S(e),i=_.get(o),s=null!=r&&(null==i?void 0:i.sig)===r?i.child:e;null==r?_.delete(o):_.set(o,{child:s,sig:r});const c=function(e){var n,o,l,r;if("html_block"===e.type||"html_inline"===e.type){const t=String(null!=(n=e.tag)?n:"").trim().toLowerCase()||C(e.content);if(t&&!y.value.has(t)&&N(null!=(o=e.content)?o:e.raw,t)){const n=String(null!=(r=null!=(l=e.content)?l:e.raw)?r:"");return{child:{type:"text",content:n,raw:n},component:Ot,isCustomComponent:!1}}}return{child:e,component:T.value[e.type],isCustomComponent:Boolean(t.value[e.type]&&!Ye(String(e.type)))}}(s);return u(a({},c),{index:o,key:`${n.indexKey||"paragraph"}-${o}`,customAttrs:c.isCustomComponent?xn(c.child,d.value):void 0,hasSlotChildren:Array.isArray(c.child.children)&&c.child.children.length>0,slotContent:String(null!=(l=c.child.content)?l:""),originalChild:s})})});return(e,t)=>(K(),j("p",ul,[null!==w.value?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(w.value),9,sl)):(K(!0),j(Y,{key:1},J(B.value,e=>{return K(),j(Y,{key:e.key},[g.value&&h(e.originalChild)?(K(),j(Y,{key:0},[Z(L((t=e.originalChild,String(null!=(o=t.content)?o:""))),1)],64)):e.isCustomComponent?(K(),re(ie(e.component),ae({key:1,ref_for:!0},e.customAttrs,{node:e.child,loading:e.child.loading,"index-key":e.key,"custom-id":n.customId,"custom-html-tags":m.value,"is-dark":v.value.isDark}),{default:ue(()=>[e.hasSlotChildren?(K(),re(V(kt),ae({key:0,ref_for:!0},v.value,{nodes:e.child.children,"index-key":e.key,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes","index-key"])):e.slotContent?(K(),re(V(kt),ae({key:1,ref_for:!0},v.value,{content:e.slotContent,final:!e.child.loading,"index-key":`${e.key}-content`,"smooth-streaming":!1,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["content","final","index-key"])):G("",!0)]),_:2},1040,["node","loading","index-key","custom-id","custom-html-tags","is-dark"])):(K(),re(ie(e.component),ae({key:2,ref_for:!0},x(e.child,e.index)),null,16))],64);var t,o}),128))]))}}),[["__scopeId","data-v-0498f5d7"]]);dl.install=e=>{e.component(dl.__name,dl)};const cl={class:"table-node-wrapper"},fl=["aria-busy"],ml={key:0},vl=["custom-id"],hl=["aria-label","onPointerdown"],pl=["custom-id"],gl={key:0,class:"table-node__loading",role:"status","aria-live":"polite"},yl=/* @__PURE__ */an(/* @__PURE__ */O({__name:"TableNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},fade:{type:Boolean},customId:{},showTooltips:{type:Boolean}},emits:["copy"],setup(e){const n=e,t=A(()=>{var e;return null!=(e=n.node.loading)&&e}),o=A(()=>{var e;return null!=(e=n.node.rows)?e:[]}),l=q(null),r=q([]);let i=null;const a=A(()=>n.node.header.cells.length),u=A(()=>r.value.some(e=>Number.isFinite(e)&&e>0)),s=A(()=>u.value?r.value.map(e=>e>0?{width:`${e}px`}:void 0):[]);ee("markstreamShowTooltips",A(()=>n.showTooltips)),ee("markstreamFade",A(()=>n.fade));const d=en(()=>n.customId),c=A(()=>Boolean(d.value.text)),f=A(()=>Boolean(d.value.paragraph)),m=/* @__PURE__ */new WeakMap;function v(e){const t=!1===n.fade&&!c.value,o=!f.value,l=m.get(e);if((null==l?void 0:l.children)===e.children&&l.textFastPath===t&&l.paragraphFastPath===o)return l.info;const r=Po(e.children,o,!0),i={simpleChildren:r,plainText:r&&t?Fo(r):null};return m.set(e,{children:e.children,textFastPath:t,paragraphFastPath:o,info:i}),i}function h(e){if(!i)return;e.preventDefault();const n=i.startWidth+i.nextStartWidth,t=Math.min(48,Math.floor(n/2)),o=Math.max(t,Math.min(n-t,Math.round(i.startWidth+e.clientX-i.startX))),l=[...i.widths];l[i.index]=o,l[i.index+1]=n-o,r.value=l}function p(){i&&(window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),i=null)}return X(a,()=>{p(),r.value=[]}),ne(p),(a,d)=>(K(),j("div",cl,[z("table",{ref_key:"tableRef",ref:l,class:D(["table-node",{"table-node--loading":t.value}]),"aria-busy":t.value},[u.value?(K(),j("colgroup",ml,[(K(!0),j(Y,null,J(e.node.header.cells,(e,n)=>(K(),j("col",{key:n,style:se(s.value[n])},null,4))),128))])):G("",!0),z("thead",null,[z("tr",null,[(K(!0),j(Y,null,J(e.node.header.cells,(t,o)=>(K(),j("th",{key:o,dir:"auto",class:D(["right"===t.align?"text-right":"center"===t.align?"text-center":"text-left"])},[null!==v(t).plainText?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(v(t).plainText),9,vl)):v(t).simpleChildren?(K(),re(V($o),{key:1,nodes:v(t).simpleChildren,"custom-id":n.customId,"index-key":`table-th-${n.indexKey}-${o}`},null,8,["nodes","custom-id","index-key"])):(K(),re(V(mi),{key:2,nodes:t.children,"index-key":`table-th-${n.indexKey}`,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,"show-tooltips":n.showTooltips,onCopy:d[0]||(d[0]=e=>a.$emit("copy",e))},null,8,["nodes","index-key","custom-id","typewriter","fade","show-tooltips"])),o<e.node.header.cells.length-1?(K(),j("button",{key:3,type:"button",class:"table-node__resize-handle","aria-label":`Resize columns ${o+1} and ${o+2}`,onPointerdown:e=>function(e,n){if(0!==n.button)return;const t=function(){var e;const n=null==(e=l.value)?void 0:e.querySelectorAll("thead th");return Array.from(null!=n?n:[],e=>Math.round(e.getBoundingClientRect().width))}(),o=t[e],a=t[e+1];o&&a&&(n.preventDefault(),i={index:e,startX:n.clientX,startWidth:o,nextStartWidth:a,widths:t},r.value=t,window.addEventListener("pointermove",h),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p))}(o,e)},null,40,hl)):G("",!0)],2))),128))])]),z("tbody",null,[(K(!0),j(Y,null,J(o.value,(e,t)=>(K(),j("tr",{key:t},[(K(!0),j(Y,null,J(e.cells,(e,o)=>(K(),j("td",{key:o,class:D(["right"===e.align?"text-right":"center"===e.align?"text-center":"text-left"]),dir:"auto"},[null!==v(e).plainText?(K(),j("span",{key:0,class:"text-node","custom-id":n.customId},L(v(e).plainText),9,pl)):v(e).simpleChildren?(K(),re(V($o),{key:1,nodes:v(e).simpleChildren,"custom-id":n.customId,"index-key":`table-td-${n.indexKey}-${t}-${o}`},null,8,["nodes","custom-id","index-key"])):(K(),re(V(mi),{key:2,nodes:e.children,"index-key":`table-td-${n.indexKey}`,"custom-id":n.customId,typewriter:n.typewriter,fade:n.fade,"show-tooltips":n.showTooltips,onCopy:d[1]||(d[1]=e=>a.$emit("copy",e))},null,8,["nodes","index-key","custom-id","typewriter","fade","show-tooltips"]))],2))),128))]))),128))])],10,fl),W(pe,{name:"table-node-fade"},{default:ue(()=>[t.value?(K(),j("div",gl,[te(a.$slots,"loading",{isLoading:t.value},()=>[d[2]||(d[2]=z("span",{class:"table-node__spinner animate-spin","aria-hidden":"true"},null,-1)),d[3]||(d[3]=z("span",{class:"sr-only"},"Loading",-1))],!0)])):G("",!0)]),_:3})]))}}),[["__scopeId","data-v-cd7fd3ec"]]);yl.install=e=>{e.component(yl.__name,yl)};const bl={class:"hr-node"},kl=/* @__PURE__ */an({},[["render",function(e,n){return K(),j("hr",bl)}],["__scopeId","data-v-39b2349c"]]);kl.install=e=>{e.component(kl.__name,kl)};const wl={class:"unknown-node"},xl=/* @__PURE__ */O({__name:"FallbackComponent",props:{node:{}},setup:e=>(n,t)=>(K(),j("div",wl,L(e.node.raw),1))}),Sl=/* @__PURE__ */an(/* @__PURE__ */O({__name:"VmrContainerNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},fade:{type:Boolean},customId:{}},setup(e){const n=e,t=A(()=>`vmr-container vmr-container-${n.node.name}`),o=en(()=>n.customId),l=A(()=>a({text:Ot,paragraph:dl,heading:Go,inline_code:Rn,link:So,image:bt,strong:po,emphasis:Bo,strikethrough:yo,insert:Co,subscript:vo,superscript:fo,checkbox:un,checkbox_input:un,hardbreak:Ho,math_inline:io,reference:so,list:ol,math_block:ao,table:yl},o.value));return(o,r)=>(K(),j("div",ae({class:t.value},e.node.attrs),[(K(!0),j(Y,null,J(e.node.children,(t,o)=>{return K(),re(ie((r=t.type,l.value[r]||xl)),{key:`${e.indexKey||"vmr-container"}-${o}`,"custom-id":n.customId,node:t,"index-key":`${e.indexKey||"vmr-container"}-${o}`,typewriter:n.typewriter,fade:n.fade,"data-markstream-reference-id":"reference"===t.type?String(t.id):void 0},null,8,["custom-id","node","index-key","typewriter","fade","data-markstream-reference-id"]);var r}),128))],16))}}),[["__scopeId","data-v-672fe0a7"]]);Sl.install=e=>{e.component(Sl.__name,Sl)};const Ml="__MARKSTREAM_VUE_HEIGHT_ESTIMATION_EXPERIMENT__",Cl=["diff ","index ","--- ","+++ ","@@ "],Nl=(()=>{const e=globalThis;if(e[Ml])return e[Ml];const n={configs:{},controllers:{},revision:P(0),preparedCache:/* @__PURE__ */new Map,blockEstimateCache:/* @__PURE__ */new Map};return e[Ml]=n,n})();let _l=null,Tl=null,Bl=null;function Il(){return Tl||"undefined"==typeof window?null:(Bl||(Bl=import("./layout.js").then(e=>(Tl=e,Nl.revision.value++,e)).catch(()=>null)),Bl.then(()=>{}))}const Hl=Nl.revision;function $l(e){var n;return e&&null!=(n=Nl.configs[e])?n:null}function Rl(e,n){const t=Number.parseFloat(String(null!=e?e:""));return Number.isFinite(t)&&t>0?t:n}function Pl(e){return"text"===(null==e?void 0:e.type)||"emoji"===(null==e?void 0:e.type)||"hardbreak"===(null==e?void 0:e.type)}function Fl(e){var n,t,o;if(!Array.isArray(e)||0===e.length)return null;let l="";for(const r of e){if(!Pl(r))return null;"text"===r.type?l+=String(null!=(n=r.content)?n:""):"emoji"===r.type?l+=String(null!=(o=null!=(t=r.name)?t:r.raw)?o:""):"hardbreak"===r.type&&(l+="\n")}return l.length>0?l:null}function Al(e,n,t){var o,l;if(!e||!Number.isFinite(n)||n<=0||!function(){var e;if(null!=_l)return _l;if("undefined"==typeof document)return!1;try{const n=document.createElement("canvas");return _l=!!(null==(e=n.getContext)?void 0:e.call(n,"2d")),_l}catch(n){return _l=!1,!1}}())return null;const r=Tl;if(!r)return Il(),null;try{const i=Math.round(100*n)/100,a=[null!=(o=t.whiteSpace)?o:"pre-wrap",t.font,t.lineHeight,t.wrapperOverhead,t.widthAdjustment,i,e].join("\0"),u=Nl.blockEstimateCache.get(a);if(u)return Nl.blockEstimateCache.delete(a),Nl.blockEstimateCache.set(a,u),{kind:"simple-text",height:u.height,contentHeight:u.contentHeight};const s=null!=(l=t.whiteSpace)?l:"pre-wrap",d=function(e,n,t,o){const l=`${o}\0${t}\0${n}`,r=Nl.preparedCache.get(l);if(r)return Nl.preparedCache.delete(l),Nl.preparedCache.set(l,r),r.prepared;const i=e.prepare(n,t,{whiteSpace:o});for(Nl.preparedCache.set(l,{prepared:i});Nl.preparedCache.size>240;){const e=Nl.preparedCache.keys().next().value;if(!e)break;Nl.preparedCache.delete(e)}return i}(r,e,t.font,s),c=Math.max(24,i-t.widthAdjustment),f=r.layout(d,c,t.lineHeight),m=Math.max(t.lineHeight,f.height),v=Math.max(t.lineHeight,Math.round(m+t.wrapperOverhead));for(Nl.blockEstimateCache.set(a,{height:v,contentHeight:Math.round(m)});Nl.blockEstimateCache.size>4e3;){const e=Nl.blockEstimateCache.keys().next().value;if(!e)break;Nl.blockEstimateCache.delete(e)}return{kind:"simple-text",height:v,contentHeight:Math.round(m)}}catch(i){return null}}function Ol(e,n,t){var o,l;if(!t||!e||!Number.isFinite(n)||n<=0)return null;if("paragraph"===e.type){const o=Fl(e.children);return o&&t.paragraph?Al(o,n,t.paragraph):null}if("heading"===e.type){const o=Number(e.level||0),l=Fl(e.children),r=t.headings[o];return l&&r?Al(l,n,r):null}if("list_item"===e.type){const r=Array.isArray(e.children)?e.children:[];if(1!==r.length||"paragraph"!==(null==(o=r[0])?void 0:o.type)||!t.listItem)return null;const i=Fl(null==(l=r[0])?void 0:l.children);return i?Al(i,n,t.listItem):null}if("list"===e.type){const o=Array.isArray(e.items)?e.items:[];if(!o.length)return null;let l=Math.max(0,t.listWrapperOverhead);for(const e of o){const o=Ol(e,n,t);if(!o)return null;l+=o.height}return{kind:"simple-text",height:Math.max(1,Math.round(l)),contentHeight:Math.max(1,Math.round(l))}}return null}function Kl(e){if(!e)return 1;const n=String(e).split(/\r\n|\n|\r/);return Math.max(1,n.length)}function jl(e,n){const t=String(null!=e?e:"");return n?t:t.replace(/\r\n$|\n$|\r$/,"")}function zl(e,n){return e.diff?jt({diffStyle:n})?function(e){const n=jl(e.raw);if(n){const t=n.split(/\r?\n/);return null!=e.originalCode||null!=e.updatedCode?Math.max(1,t.filter(e=>!Cl.some(n=>e.startsWith(n))).length):Math.max(1,t.length)}return Kl(jl(e.originalCode))+Kl(jl(e.updatedCode))}(e):function(e){const n=e.originalCode,t=e.updatedCode;if(null!=n||null!=t)return Math.max(Kl(jl(n)),Kl(jl(t)));const o=jl(e.code).split(/\r?\n/);let l=0,r=0;for(const i of o)i.startsWith("+")&&!i.startsWith("+++")?r++:i.startsWith("-")&&!i.startsWith("---")?l++:(l++,r++);return Math.max(1,l,r)}(e):Kl(jl(e.code,!0===e.loading))}function Ll(e,n,t){return Math.max(1,Math.ceil(function(e,n){let t=0;for(const o of e)t+="\t"===o?n-t%n:o>="ᄀ"?2:1;return t}(e,t)/n))}function El(e,n,t,o,l,r){var i,a,u;const s=e/(r?2:1),d=null==(null==(i=l.codeBlockOptions)?void 0:i.padding)?n:o.padding,c=null!=(u=l.showLineNumbers)?u:!0!==(null==(a=l.codeBlockOptions)?void 0:a.disableLineNumbers),f=Math.max(2,String(Math.max(1,t)).length)*n,m=c?3*n+f+2:0;return Math.max(1,Math.floor((s-m-2*d)/n))}function Dl(e){return e?`${e.fontStyle||"normal"} ${e.fontWeight||"400"} ${e.fontSize||"16px"} ${e.fontFamily||"sans-serif"}`:""}function Wl(e,n,t="pre-wrap"){if(!e||!n||"undefined"==typeof window)return null;const o=window.getComputedStyle(n),l=e.offsetHeight,r=Rl(o.lineHeight,1.5*Rl(o.fontSize,16)),i=e.getBoundingClientRect().width,a=n.getBoundingClientRect().width;return{font:Dl(o),lineHeight:r,wrapperOverhead:Math.max(0,l-r),widthAdjustment:Math.max(0,i-a),whiteSpace:t}}const Vl=/* @__PURE__ */new Set(["node","key","ref","ctx","renderNode","indexKey","__proto__","prototype","constructor"]);function ql(e,n={}){var t;const o={},l=new Set(null!=(t=n.omit)?t:[]);if(!e||"object"!=typeof e)return o;const r=Object.getOwnPropertyDescriptors(e);for(const[i,a]of Object.entries(r))Vl.has(i)||l.has(i)||a.enumerable&&"value"in a&&(o[i]=a.value);return o}function Ul(e,n){const t=n.trim().toLowerCase();if(t)for(const o of[t,Ne(t),Pe(t),"d2lang"===t?"d2":""]){const n=o&&e[o];if(n)return n}}const Xl=!1;function Yl(e,n,t,o){var l;const r=function(e){return Math.max(0,Math.ceil(e.scrollHeight||0)-Math.ceil(e.clientHeight||0))}(e),i=function(e,n){return Number.isFinite(e)?Math.min(Math.max(0,e),n):0}(t,r);if(!o.isReverseFlexScrollRoot(e))return void(e.scrollTop=i);const a=Math.max(0,r-i),u=[-a,a];let s=u[0],d=Number.POSITIVE_INFINITY;for(const f of u){e.scrollTop=f;const t=o.getNormalizedScrollTop(e,n,!1),l=Math.abs(t-i);l<d&&(d=l,s=f)}e.scrollTop=s;const c=null!=(l=o.epsilonPx)?l:2;Math.abs(o.getNormalizedScrollTop(e,n,!1)-i)>c&&(e.scrollTop=s)}function Zl(e,n){let t=0,o=null,l=null;const r=()=>{const n=l;l=null,o=null,n&&(t=Date.now(),e(...n))};return function(...i){const a=Date.now(),u=n-(a-t);l=i,u<=0?(o&&(clearTimeout(o),o=null),t=a,l=null,e(...i)):o||(o=setTimeout(r,u))}}function Gl(e){return"simple"===e?"simple":!0===e||"true"===e||"precise"===e?"precise":"off"}function Jl(e){return"off"!==Gl(e)}const Ql=/* @__PURE__ */Symbol("MarkstreamMathBlockMinHeightCache");function er(){return F(Ql,null)}const nr=/* @__PURE__ */new Set(["text","inline_code","emoji","footnote_reference"]),tr=/* @__PURE__ */new Set(["strong","emphasis","strikethrough","highlight","insert","subscript","superscript","link"]);function or(e){const n=Number(e);return!Number.isFinite(n)||n<=0?-1:Math.round(n/32)}function lr(e,n,t,o=22){const l=String(null!=e?e:"");if(!l)return t;const r=Math.max(18,Math.floor(Math.max(320,n)/8)),i=l.split(/\r?\n/).length,a=Math.ceil(l.length/r),u=Math.max(1,i,a);return Math.max(t,Math.ceil(u*o+12))}function rr(e){var n;if(!e||"object"!=typeof e)return!1;const t=e,o=String(null!=(n=t.type)?n:"");if(nr.has(o))return!0;if(!tr.has(o))return!1;const l=t.children;return!Array.isArray(l)||!l.length||l.every(rr)}function ir(e){var n,t,o,l,r,i,a,u;if(!e||"object"!=typeof e)return"";const s=e,d=String(null!=(n=s.type)?n:"");if("text"===d)return String(null!=(o=null!=(t=s.content)?t:s.raw)?o:"");if("inline_code"===d)return String(null!=(i=null!=(r=null!=(l=s.code)?l:s.content)?r:s.raw)?i:"");if("emoji"===d)return String(null!=(u=null!=(a=s.name)?a:s.raw)?u:"");if("string"==typeof s.text)return s.text;const c=[];for(const f of["children","items","cells","rows"]){const e=s[f];if(Array.isArray(e)){const n=e.map(ir).filter(Boolean).join(" ");n&&c.push(n)}}return c.join(" ").replace(/\s+/g," ").trim()}function ar(e){if(!e||"object"!=typeof e)return!1;const n=e;return"inline_code"===n.type||["children","items","cells","rows"].some(e=>{const t=n[e];return Array.isArray(t)&&t.some(ar)})}function ur(e,n){if(!e)return 30;const t=Math.max(18,Math.floor(Math.max(320,n)/8)),o=e.split(/\r?\n/).length,l=Math.ceil(e.length/t),r=Math.max(1,o,l);return 30+26*Math.max(0,r-1)}function sr(e,n){var t,o,l,r,i,a,u,s,d,c,f,m,v,h;if(!e||"object"!=typeof e)return 32;const p=e,g=String(null!=(t=p.type)?t:""),y=Number.isFinite(n)&&n>0?n:640;switch(g){case"heading":return function(e){var n;const t=Number(null!=(n=e.level)?n:e.depth);return t>=4?20:3===t?30:2===t?32:44}(p);case"paragraph":return function(e,n){const t=String(null!=e?e:"");if(!t)return 28;const o=Math.max(18,Math.floor(Math.max(320,n)/8)),l=t.split(/\r?\n/).length,r=Math.ceil(t.length/o);return Math.max(1,l,r)<=1?28:lr(t,n,34)}(String(null!=(l=null!=(o=p.raw)?o:p.content)?l:""),y);case"list":return function(e,n){var t;const o=Array.isArray(e.items)?e.items:[];if(!o.length)return 48;const l=Math.max(48,30*o.length+12);let r=12;for(const u of o)r+=ur(ir(u)||String(null!=(t=u.raw)?t:""),n);const i=Math.max(0,r-l);if(o.length>20){const e=Math.round(2.4*o.length);return Math.round(l+Math.max(e,Math.min(i,3*o.length)))}if(i<=0)return l;const a=o.length>8?8*o.length:i;return Math.round(l+Math.min(i,a))}(p,y);case"list_item":return lr(String(null!=(i=null!=(r=p.raw)?r:p.content)?i:""),y,34);case"blockquote":return lr(String(null!=(u=null!=(a=p.raw)?a:p.content)?u:""),y,56);case"table":return function(e,n){const t=[...e.header?[e.header]:[],...Array.isArray(e.rows)?e.rows:[]];if(!t.length){const n=Array.isArray(e.children)?e.children.length:3;return Math.max(120,38*n+48)}return Math.max(120,Math.round(4+t.reduce((e,t)=>e+function(e,n){const t=Math.max(1,e.length),o=Math.max(80,(n-32)/t),l=Math.max(10,Math.floor(o/8)),r=Math.max(1,...e.map(e=>{var n;const t=ir(e)||String(null!=(n=null==e?void 0:e.raw)?n:"");return Math.ceil(t.length/l)||1}));return 54+34*Math.max(0,r-1)+(t<=3&&e.some(ar)?14:0)}(function(e){var n;return Array.isArray(null==e?void 0:e.cells)&&null!=(n=e.cells)?n:[]}(t),n),0)))}(p,y);case"code_block":{const e=String(null!=(s=p.language)?s:"").trim().toLowerCase(),n=String(null!=(c=null!=(d=p.code)?d:p.raw)?c:"");return"mermaid"===e?Ae(Oe(n)):"infographic"===e?Ke(je(n)):lr(n,y,96,20)}case"math_block":return 72;case"image":return 220;case"admonition":case"vmr_container":case"html_block":return function(e,n){var t,o,l;const r=e.match(/^\s*<details\b([^>]*)>/i);return r&&!/(?:^|\s)open(?:\s|=|$)/i.test(null!=(t=r[1])?t:"")?lr((null==(l=null==(o=e.match(/<summary\b[^>]*>([\s\S]*?)<\/summary>/i))?void 0:o[1])?void 0:l.replace(/<[^>]*>/g,"").trim())||"Details",n,28,28):lr(e,n,96)}(String(null!=(m=null!=(f=p.raw)?f:p.content)?m:""),y);case"thematic_break":return 24;default:return lr(String(null!=(h=null!=(v=p.raw)?v:p.content)?h:""),y,40)}}function dr(e,n,t){return Math.min(Math.max(e,n),t)}const cr=/* @__PURE__ */new WeakMap;function fr(e,n,t){var o;const l=e;if(t.has(l))return t.get(l);const r=String(e.type).trim().toLowerCase();if(n[r])return t.set(l,!0),!0;if("code_block"===r){const r=String(null!=(o=e.language)?o:"").trim().toLowerCase();if(r&&Ul(n,r))return t.set(l,!0),!0}const i=e;t.set(l,!1);const a=Object.values(i).some(e=>Array.isArray(e)?e.some(e=>Tr(e)&&fr(e,n,t)):Tr(e)&&fr(e,n,t));return t.set(l,a),a}const mr=["total","cacheHits","appendHits","tailHits","fullParses","chunkedParses"],vr=["tokenCloneMs","processTokensInputTokens","processTokensReusedTopLevelNodes","processTokensMs","safeMarkdownMs","tokenizeMs","htmlBlockPassesMs","parseMarkdownToStructureTotalMs"],hr=/* @__PURE__ */new Set(["attrs","data","items","header","payload","props","rows","cells","term","definition","sourceMap"]),pr=["raw","content","code","originalCode","updatedCode"],gr=/* @__PURE__ */new WeakMap,yr=/* @__PURE__ */new WeakMap;let br=1;function kr(){return"undefined"!=typeof performance?performance.now():Date.now()}function wr(e){const n=e.stream;return n&&"function"==typeof n.stats?n.stats():null}function xr(e){if("object"!=typeof e&&"function"!=typeof e||null===e)return"";const n=e;let t=gr.get(n);return t||(t=br++,gr.set(n,t)),String(t)}function Sr(e,n,t,o={}){var l,r;const i=!1!==o.includeFinal,a={md:xr(n),customMarkdownIt:xr(t),requireClosingStrong:!0===e.requireClosingStrong,customHtmlTags:null!=(l=e.customHtmlTags)?l:[],includeSourceMap:!0===e.includeSourceMap,streamParse:null!=(r=e.streamParse)?r:"auto",validateLink:xr(e.validateLink),preTransformTokens:xr(e.preTransformTokens),postTransformTokens:xr(e.postTransformTokens),postTransformNodes:xr(e.postTransformNodes)};return i&&(a.final=!0===e.final),JSON.stringify(a)}function Mr(e){let n=e.length;for(;n>0&&10===e.charCodeAt(n-1);)n-=1;const t=e.lastIndexOf("\n",n-1)+1;return e.slice(t,n).trim()}function Cr(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function Nr(e){const n=String(null!=e?e:"");return`${n.length}:${Cr(n)}`}function _r(e,n=/* @__PURE__ */new WeakMap,t=0){if(null==e||"number"==typeof e||"boolean"==typeof e)return String(e);if("string"==typeof e)return`s:${function(e){return e.length<=8192?Nr(e):`${e.length}:${Cr(e.slice(0,8192))}:truncated`}(e)}`;if("function"==typeof e)return`fn:${xr(e)}`;if("object"!=typeof e)return typeof e;const o=e,l=n.get(o);if(l)return`cycle:${l}`;if(t>=6)return`object:${xr(o)}`;const r=xr(o);if(n.set(o,r),Array.isArray(e)){const o=e.slice(0,200);return`a:${e.length}:${o.map(e=>_r(e,n,t+1)).join(",")}`}if("object"==typeof e){const o=e,l=Object.keys(o).sort(),r=l.slice(0,80);return`o:${l.length}:${r.map(e=>`${e}:${_r(o[e],n,t+1)}`).join(";")}`}return typeof e}function Tr(e){return"object"==typeof e&&null!==e&&"string"==typeof e.type&&"string"==typeof e.raw}function Br(e,n=/* @__PURE__ */new WeakMap,t=0){return Array.isArray(e)?`a:${e.length}:${e.slice(0,200).map(e=>Tr(e)?$r(e,n,t+1):Br(e,n,t+1)).join(",")}`:Tr(e)?$r(e,n,t):_r(e,n,t)}function Ir(e,n,t){return Object.keys(e).sort().filter(e=>"children"!==e&&!pr.includes(e)).map(o=>{const l=e[o];return"string"==typeof l?`${o}=s:${Nr(l)}`:"number"==typeof l||"boolean"==typeof l||null==l?`${o}=${String(l)}`:"function"==typeof l?`${o}=fn:${xr(l)}`:hr.has(o)&&(Array.isArray(l)||"object"==typeof l)?`${o}=${Br(l,n,t+1)}`:l&&"object"==typeof l?`${o}=object:${xr(l)}`:""}).filter(Boolean).join(";")}function Hr(e){return pr.map(n=>{const t=e[n];return"string"==typeof t?`${n}=s:${Nr(t)}`:""}).filter(Boolean).join(";")}function $r(e,n=/* @__PURE__ */new WeakMap,t=0){const o=yr.get(e);if(o)return o;const l=e,r=n.get(l);if(r)return`node-cycle:${r}`;if(t>=6)return`node:${e.type}:${xr(l)}`;const i=xr(l);n.set(l,i);const a=function(e,n,t){const o=e,l=Array.isArray(o.children)?o.children:[],r=l.length?l.slice(0,200).map(e=>$r(e,n,t+1)).join("|"):"";return[e.type,Hr(o),Ir(o,n,t),l.length,r].join(":")}(e,n,t);return yr.set(l,a),a}function Rr(e,n){return $r(e)===$r(n)}function Pr(e,n,t){const o=kr(),l="stabilizeSignatureMs"===n?"stabilizeSignatureCallCount":"primeSignatureCallCount";try{return t()}finally{e[n]+=kr()-o,e[l]+=1,e.signatureMs=e.stabilizeSignatureMs+e.primeSignatureMs,e.signatureCallCount=e.stabilizeSignatureCallCount+e.primeSignatureCallCount}}function Fr(e,n,t){return Pr(n,t,()=>$r(e))}function Ar(e,n,t){return Fr(e,t,"stabilizeSignatureMs")===Fr(n,t,"stabilizeSignatureMs")}function Or(e){return{reusedNodeCount:0,dirtyStartIndex:e>0?0:-1,stablePrefixNodeCount:0,dirtyTailNodeCount:e}}function Kr(e,n,t){return e<0?0:Math.max(n.length,t.length)-e}function jr(e){return!0===e.__markstreamHasCustomParserExtensions||function(e){var n;return Number(null!=(n=e.__markstreamRegisteredPluginCount)?n:0)>0}(e)}function zr(e,n){return e.length===n.length&&e===n}function Lr(e,n,t=0){if(t>=4)return null;if(e.type!==n.type)return!1;const o=e,l=n,r=Object.keys(o).filter(e=>"type"!==e&&"children"!==e).sort(),i=Object.keys(l).filter(e=>"type"!==e&&"children"!==e).sort();if(r.length!==i.length)return!1;for(let d=0;d<r.length;d++){const e=r[d];if(e!==i[d])return!1;const n=o[e],t=l[e];if(typeof n!=typeof t)return!1;if("string"!=typeof n){if("number"!=typeof n&&"boolean"!=typeof n&&null!=n)return null;if(!Object.is(n,t))return!1}else{if("string"!=typeof t)return!1;if(!zr(n,t))return!1}}const a=Object.prototype.hasOwnProperty.call(o,"children");if(a!==Object.prototype.hasOwnProperty.call(l,"children"))return!1;if(!a)return!0;const u=o.children,s=l.children;if(!Array.isArray(u)||!Array.isArray(s))return null;if(u.length!==s.length)return!1;for(let d=0;d<u.length;d++){const e=u[d],n=s[d];if(!Tr(e)||!Tr(n))return null;const o=Lr(e,n,t+1);if(null==o)return null;if(!o)return!1}return!0}function Er(e,n,t=0){if(e===n||e.type!==n.type||t>=6)return;const o=e,l=n;for(const r of["children","items","rows","cells"]){const e=o[r],n=l[r];if(!Array.isArray(e)||!Array.isArray(n))continue;const i=Math.min(e.length,n.length);for(let o=0;o<i;o++){const l=e[o],r=n[o];l!==r&&Tr(l)&&Tr(r)&&(!0===Lr(l,r)?n[o]=l:Er(l,r,t+1))}}}function Dr(e,n){if(!e||!n)return!1;if(e===n)return!0;if(e.type!==n.type)return!1;const t=Lr(e,n);return null!=t?t:Rr(e,n)}function Wr(e,n,t){if(!e||!n)return!1;if(e===n)return!0;if(e.type!==n.type)return!1;let o=null;return Pr(t,"stabilizeSignatureMs",()=>{o=Lr(e,n)}),null!=o?o:Ar(e,n,t)}function Vr(e,n){const t={};for(const o of mr){const l=e[o],r=null==n?void 0:n[o];"number"==typeof l&&(t[o]=l-("number"==typeof r?r:0))}return t}function qr(e,n){var t;const o=_(n.instanceMsgId),l=/* @__PURE__ */new Map,r=null!=(t=n.smoothStreamingEnabled)?t:A(()=>!1),i=q(n.renderContent.value);let s=[],c="",f="",m="",v=!1,h="",p=/* @__PURE__ */new WeakMap;const y=function(){let e="",n=0,t=!1,o=!1,l=!1,r=!1;function i(){e="",n=0,t=!1,o=!1,l=!1,r=!1}function a(e){let i=!1;for(let a=0;a<e.length;a++){const u=e.charCodeAt(a);if(10===u||13===u){const e=10===u&&r;r=13===u,t=!1,e||(l||(o=!1,n=0),l=!1);continue}r=!1;const s=9===u||32===u;if(s||(l=!0,o&&(i=!0)),n)if(1!==n)s||(58!==u?n=91===u?1:0:(i=!0,o=!0));else{if(t){t=!1;continue}if(92===u){t=!0;continue}93===u&&(n=2)}else 91===u&&(n=1)}return i}return(n,t)=>{if(!n||!t.startsWith(n)||t.length<=n.length)return i(),[!0,0];let o=0;e!==n&&(i(),a(n),o=n.length);const l=t.slice(n.length),r=a(l);return e=t,[r,o+l.length]}}();let b,k=0,w=0,x=kr(),S=-1,M=0;function C(e){S=Number.isInteger(e)?e:0,M+=1}function N(){b&&(clearTimeout(b),b=void 0)}function $(){N();const e=n.renderContent.value;i.value!==e&&(i.value=e),x=kr()}X([n.renderContent,n.effectiveFinal,r],([n,t,o])=>{i.value!==n&&(!o||t||function(e,n){if(!e&&n)return!0;if(n.length<=80)return!0;if(n.length<e.length||!n.startsWith(e))return!0;const t=n.slice(e.length);return!(!t||!function(e){const n=function(e){return e.includes("|")?e.replace(/^\|/,"").replace(/\|$/,"").split("|"):[]}(e);return n.length>=2&&n.every(e=>{const n=e.trim();return n.length>=1&&n.replace(/^:/,"").replace(/:$/,"").split("").every(e=>"-"===e)})}(Mr(n))&&(o=n,l=Mr(o),!(/^={3,}$/.test(l)||/^-{3,}$/.test(l)||t.includes("\n\n")||/(?:^|\n)(?:#{1,6}\s|[-+*]\s+|\d+[.)]\s+|>\s*|`{3,}|~{3,})/.test(t))));var o,l}(i.value,n)?$():function(){if(w+=1,b)return;const n=Math.max(0,function(e){const n=e.parseCoalesceMs;return"number"==typeof n&&Number.isFinite(n)&&n>=0?n:80}(e)-(kr()-x));n<=0?$():b=setTimeout($,n)}())},{flush:"sync",immediate:!0}),de(N);const R=A(()=>{var t,o,l,r;return T(e.customHtmlTags,null==(t=e.parseOptions)?void 0:t.customHtmlTags,(r=null!=(l=null==(o=n.customComponentsMap)?void 0:o.value)?l:{},Object.entries(r).map(([e,n])=>{const t=d(e);return null==n||!t||Ye(t)||H.has(t)||g.has(t)?"":t}).filter(Boolean)))}),P=A(()=>{const{key:e,tags:t}=B(R.value);if(!e)return o;const r=l.get(e);if(r)return r;const i=_(n.instanceMsgId,{customHtmlTags:t});return l.set(e,i),i}),F=A(()=>{const n=P.value;if(!e.customMarkdownIt)return n;const t=e.customMarkdownIt(n);return n.__markstreamHasCustomParserExtensions=!0,t.__markstreamHasCustomParserExtensions=!0,t}),O=A(()=>{var t,o;const l=null!=(t=e.parseOptions)?t:{},r=n.effectiveFinal.value,i=R.value,s=null!=r,d=i.length>0;return s||d||null==l.streamParse?a(a(u(a({},l),{streamParse:null==(o=l.streamParse)||o}),s?{final:r}:{}),d?{customHtmlTags:i}:{}):l}),K=A(()=>{var e;return new Set((null!=(e=O.value.customHtmlTags)?e:[]).map(e=>String(e).trim().toLowerCase()).filter(Boolean))}),j=A(()=>Sr(O.value,F.value,e.customMarkdownIt,{includeFinal:!0})),z=A(()=>Sr(O.value,F.value,e.customMarkdownIt,{includeFinal:!1}));X([j,z],([e,n],[t,o])=>{t&&(e===t&&n===o||($(),n!==o&&(s=[],m="")))},{flush:"sync"});const L=A(()=>{var t,o,l,r,d,g,b,x,M,N,_;if(null==(t=e.nodes)?void 0:t.length)return s=[],m="",C(0),me(e.nodes.slice());const T=i.value;if(!T)return s=[],m="",C(-1),[];const B=n.debugPerformanceEnabled.value,H=B?kr():0,$=F.value,R=j.value,P=z.value;c&&R!==c&&function(e){var n,t;null==(t=null==(n=e.stream)?void 0:n.reset)||t.call(n)}($),f&&P!==f&&(s=[],m="");const A=null!=(l=null==(o=n.customComponentsMap)?void 0:o.value)?l:{},K=function(e){const n=e,t=cr.get(n);if(void 0!==t)return t;const o=function(e){return JSON.stringify(Object.entries(e).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,xr(n)]))}(e);return cr.set(n,o),o}(A);h&&K!==h&&(s=[],m="",p=/* @__PURE__ */new WeakMap);const L=Object.keys(A).length>0,E="function"==typeof O.value.postTransformNodes;E!==v&&(s=[],m="");const D=!E&&s.length>0&&T.startsWith(m)&&P===f,W=B?wr($):null,V=B?{}:void 0,q=jr($),U=L&&s.some(e=>fr(e,A,p)),X=!q&&!E&&(!L||s.length>0&&!U),Y=a(u(a({},O.value),{reuseStableTopLevelNodes:X}),V?{parserMetrics:V}:{}),Z=I(T,$,Y),G=B?kr():0;if(D&&!q&&!L&&!O.value.preTransformTokens&&!O.value.postTransformTokens){const e=Math.min(s.length,Z.length);for(let n=0;n<e;n++)Er(s[n],Z[n])}const J=B?{signatureMs:0,stabilizeSignatureMs:0,primeSignatureMs:0,signatureCallCount:0,stabilizeSignatureCallCount:0,primeSignatureCallCount:0}:void 0;let Q,ee=B?Or(Z.length):void 0,ne=0,te=0,oe=0;if(D){const n=B?kr():0,[t,o]=L?[0,0]:function(e){var n,t;const[o,l]=e.scanGlobalReferenceAppend(e.previousContent,e.content),r=e.parseOptions;return[e.previousDirtyStartIndex>0&&!0!==r.final&&!e.customMarkdownIt&&!jr(e.md)&&!o&&"function"!=typeof r.preTransformTokens&&"function"!=typeof r.postTransformTokens&&"function"!=typeof r.postTransformNodes&&0===(null!=(t=null==(n=r.customHtmlTags)?void 0:n.length)?t:0)?e.previousDirtyStartIndex:0,l]}({content:T,previousContent:m,previousDirtyStartIndex:S,parseOptions:O.value,customMarkdownIt:e.customMarkdownIt,md:$,scanGlobalReferenceAppend:y});oe=o;const l=t<=0,r=L?e=>!fr(e,A,p):void 0;if(J){const e=function(e,n,t,o={}){if(!n.length)return{nodes:e,metrics:Or(e.length)};const l=!1!==o.reuseDirtyTail,r=function(e,n,t,o){var l;const r=Math.min(e.length,n.length);for(let i=Math.min(r,Math.max(0,null!=(l=o.scanStartIndex)?l:0));i<r;i++){const l=n[i],r=e[i];if(o.canReuseNode&&(!o.canReuseNode(l)||!o.canReuseNode(r))||!Wr(l,r,t))return i}return e.length===n.length?-1:r}(e,n,t,o);if(r<0)return{nodes:n,metrics:{reusedNodeCount:e.length,dirtyStartIndex:r,stablePrefixNodeCount:e.length,dirtyTailNodeCount:0}};const i=e.slice();let a=r;for(let u=0;u<r;u++)i[u]=n[u];if(l)for(let u=r;u<e.length;u++){const l=n[u],r=e[u];l&&(!o.canReuseNode||o.canReuseNode(l)&&o.canReuseNode(r))&&Ar(l,r,t)&&(i[u]=l,a+=1)}return{nodes:i,metrics:{reusedNodeCount:a,dirtyStartIndex:r,stablePrefixNodeCount:r,dirtyTailNodeCount:Kr(r,e,n)}}}(Z,s,J,{canReuseNode:r,reuseDirtyTail:l,scanStartIndex:t});Q=e.nodes,ee=e.metrics}else{const e=function(e,n,t={}){if(!n.length)return{nodes:e,metrics:Or(e.length)};const o=!1!==t.reuseDirtyTail,l=function(e,n,t){var o;const l=Math.min(e.length,n.length);for(let r=Math.min(l,Math.max(0,null!=(o=t.scanStartIndex)?o:0));r<l;r++){const o=n[r],l=e[r];if(t.canReuseNode&&(!t.canReuseNode(o)||!t.canReuseNode(l))||!Dr(o,l))return r}return e.length===n.length?-1:l}(e,n,t);if(l<0)return{nodes:n,metrics:{reusedNodeCount:e.length,dirtyStartIndex:l,stablePrefixNodeCount:e.length,dirtyTailNodeCount:0}};const r=e.slice();let i=l;for(let a=0;a<l;a++)r[a]=n[a];if(o)for(let a=l;a<e.length;a++){const o=n[a],l=e[a];o&&(!t.canReuseNode||t.canReuseNode(o)&&t.canReuseNode(l))&&Rr(o,l)&&(r[a]=o,i+=1)}return{nodes:r,metrics:{reusedNodeCount:i,dirtyStartIndex:l,stablePrefixNodeCount:l,dirtyTailNodeCount:Kr(l,e,n)}}}(Z,s,{canReuseNode:r,reuseDirtyTail:l,scanStartIndex:t});Q=e.nodes,ee=e.metrics}ne=B?kr()-n:0,te=l?null==(null==ee?void 0:ee.dirtyStartIndex)||ee.dirtyStartIndex<0?Q.length:ee.dirtyStartIndex:Q.length}else Q=Z,ee=Or(Q.length);if(!0!==n.effectiveFinal.value&&(J?function(e,n,t=0){for(let o=Math.max(0,t);o<e.length;o++)Pr(n,"primeSignatureMs",()=>$r(e[o]))}(Q,J,te):function(e,n=0){for(let t=Math.max(0,n);t<e.length;t++)$r(e[t])}(Q,te)),L)for(let e=null!=(null==ee?void 0:ee.dirtyStartIndex)&&ee.dirtyStartIndex>=0?ee.dirtyStartIndex:Q.length;e<Q.length;e++)fr(Q[e],A,p);const le=B?kr()-G:0;if(k+=1,m=T,c=R,f=P,v=E,h=K,s=Q,C(null!=(r=null==ee?void 0:ee.dirtyStartIndex)?r:0),B){const e=wr($),t="number"==typeof(null==e?void 0:e.total)&&e.total>(null!=(d=null==W?void 0:W.total)?d:0);n.logPerf(t?"parse(stream)":"parse(sync)",a(a(a({rendererId:n.instanceMsgId,ms:Math.round(kr()-H),nodes:Q.length,contentLength:T.length,parseCommitCount:k,parseCoalescedCount:w,nodeReuseMs:le,referenceDefinitionScanChars:oe,signatureMs:null!=(g=null==J?void 0:J.signatureMs)?g:0,stabilizeSignatureMs:null!=(b=null==J?void 0:J.stabilizeSignatureMs)?b:0,primeSignatureMs:null!=(x=null==J?void 0:J.primeSignatureMs)?x:0,signatureCallCount:null!=(M=null==J?void 0:J.signatureCallCount)?M:0,stabilizeSignatureCallCount:null!=(N=null==J?void 0:J.stabilizeSignatureCallCount)?N:0,primeSignatureCallCount:null!=(_=null==J?void 0:J.primeSignatureCallCount)?_:0,stabilizeMs:ne},null!=ee?ee:{}),V?Object.fromEntries(vr.map(e=>{var n;return[e,null!=(n=V[e])?n:0]})):{}),e?{streamMode:e.lastMode,streamDelta:Vr(e,W),streamStats:e}:{}))}return me(Q)});return{effectiveCustomHtmlTags:R,effectiveCustomHtmlTagsSet:K,mdBase:P,mdInstance:F,mergedParseOptions:O,getParsedNodesDirtyStartIndex:()=>S,getParsedNodesRevision:()=>M,parsedNodes:L}}function Ur(e){const{isClient:n}=e,t=q(/* @__PURE__ */new Set),o=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;function i(e){if(!n)return;const t=r.get(e);null!=t&&(window.clearTimeout(t),r.delete(e))}function a(){if(n)for(const e of r.values())window.clearTimeout(e);r.clear()}function u(){t.value=/* @__PURE__ */new Set}return{visibleNodeIndices:t,nodeVisibilityHandles:o,nodeVisibilityWatchStops:l,nodeVisibilityFallbackTimers:r,clearVisibilityFallback:i,clearAllVisibilityFallbacks:a,markNodeVisible:function(n,o=!0){var l;o&&i(n),function(n,o){if(null!=(r=null==(l=e.shouldTrackVisibleNodeIndices)?void 0:l.call(e))&&!r)return;var l,r;const i=t.value,a=i.has(n);if(o){if(a)return;const e=new Set(i);return e.add(n),void(t.value=e)}if(!a)return;const u=new Set(i);u.delete(n),t.value=u}(n,o),o&&(null==(l=e.onNodeMarkedVisible)||l.call(e,n))},resetNodeVisibleState:u,cleanupNodeVisibility:function(n){var a;if(e.shouldCleanupNodeVisibility&&!e.shouldCleanupNodeVisibility())return;for(const[e,t]of l.entries())e<n||(t(),l.delete(e));for(const[t,l]of o.entries())t<n||(l.destroy(),o.delete(t),i(t),null==(a=e.onNodeVisibilityCleaned)||a.call(e,t));for(const e of Array.from(r.keys()))e<n||i(e);if(!t.value.size)return;const u=/* @__PURE__ */new Set;for(const e of t.value)e<n&&u.add(e);t.value=u},destroyNodeVisibilityState:function(){u();for(const e of l.values())e();l.clear();for(const e of o.values())e.destroy();o.clear(),a()}}}function Xr(e){const{isClient:n,virtualizationEnabled:t,listenerEnabled:o,scrollRootElement:l,resolveScrollContainer:r,scheduleFocusSync:i,onScroll:a}=e;let u=null,s=null,d=!1,c=null;const f=void 0===e.requestFrame?"function"==typeof requestAnimationFrame?requestAnimationFrame:null:e.requestFrame,m=void 0===e.cancelFrame?"function"==typeof cancelAnimationFrame?cancelAnimationFrame:null:e.cancelFrame;function v(){null!=c&&(null==m||m(c),c=null),d=!1,u&&(u(),u=null),s=null,l.value=null}function h(n){const t=e.getScrollTop?e.getScrollTop(n):n.scrollTop;return Math.max(0,Number.isFinite(t)?Math.abs(t):0)}return{cleanupScrollListener:v,setupScrollListener:function(){if(!n)return;if(!(null!=(e=null==o?void 0:o.value)?e:t.value))return void v();var e;const m=r();if(!m)return void v();if(l.value===m&&u)return;v(),s=h(m);const p=()=>{null==a||a(),t.value&&(()=>{if(d)return;d=!0;const e=()=>{if(d=!1,c=null,t.value){const e=function(e){const n=h(e),t=s;s=n;const o=Math.max(480,.75*(e.clientHeight||0));return null==t?n>o?{immediate:!0}:void 0:Math.abs(n-t)>o?{immediate:!0}:void 0}(m);e?i(e):i()}};f?c=f(e):e()})()};m.addEventListener("scroll",p,{passive:!0}),l.value=m,u=()=>{m.removeEventListener("scroll",p)}}}}function Yr(e={}){const n=q(""),t=q(""),o=q(!1),l=Fe(e),r=()=>{const e=l.getSnapshot();n.value=e.source,t.value=e.visible,o.value=e.done},i=l.subscribe(r);r();const a=A(()=>Math.max(0,n.value.length-t.value.length)),u=A(()=>0===a.value),s=A(()=>o.value&&u.value);return ye()&&de(()=>{i(),l.destroy()}),{source:n,visible:t,done:o,final:s,caughtUp:u,pendingChars:a,enqueue:e=>l.enqueue(e),finish:e=>l.finish(e),flush:()=>l.flush(),reset:(e,n)=>l.reset(e,n),pause:()=>l.pause(),resume:()=>l.resume()}}const Zr={maxCharsPerSecond:3e3,maxCommitFps:20,maxCharsPerCommit:160,catchUpLatencyMs:220,catchUpThreshold:400},Gr=/auto|scroll|overlay/i;function Jr(e){if(!e)return!1;const n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();return Gr.test(n)||Gr.test(t)}function Qr(e){const n=Math.ceil(e.scrollHeight)>Math.ceil(e.clientHeight)+1,t=Math.ceil(e.scrollWidth)>Math.ceil(e.clientWidth)+1;return n||t}const ei=O({name:"D2BlockNodeLoading",props:{node:{type:Object,required:!0},showHeader:{type:Boolean,default:!0},estimatedPreviewHeightPx:{type:Number,default:void 0}},setup(e){const n=A(()=>{var n,t;return ze(null!=(t=Le(e.estimatedPreviewHeightPx))?t:Ee(String(null!=(n=e.node.code)?n:"")))});return()=>E("div",{class:"d2-block-container rounded-lg border overflow-hidden",style:{margin:"var(--ms-flow-diagram-y) 0",background:"var(--diagram-bg)",borderColor:"var(--diagram-border)",color:"hsl(var(--ms-foreground))",boxShadow:"var(--ms-shadow-subtle)"},"data-markstream-d2":"1","data-markstream-mode":"pending"},[e.showHeader?E("div",{class:"d2-block-header flex justify-between items-center border-b",style:{padding:"var(--ms-inset-panel-y) var(--ms-inset-panel-x)",background:"var(--diagram-header-bg)",borderColor:"var(--diagram-border)"}},[E("div",{class:"flex items-center gap-x-2"},[E("span",{class:"d2-label font-medium font-mono",style:{fontSize:"var(--ms-text-label)",color:"var(--code-action-fg)"}},"D2")]),E("div",{class:"d2-header-actions flex items-center","aria-hidden":"true"})]):null,E("div",{class:"d2-block-body",style:{minHeight:`${n.value}px`}})])}}),ni={class:"m-0 p-0"},ti=["data-probe"],oi=/* @__PURE__ */an(/* @__PURE__ */O(u(a({},{name:"HeightEstimationProbes"}),{__name:"HeightEstimationProbes",props:{width:{},flowRoot:{type:Boolean},paragraphNode:{},listItemNode:{},listNode:{},headingNodes:{},setParagraphWrapper:{type:Function},setListItemWrapper:{type:Function},setListWrapper:{type:Function},setHeadingWrapper:{type:Function}},setup(e){const n=e;function t(e){var t,o;return null!=(o=null==(t=n.headingNodes)?void 0:t[e])?o:null}return(n,o)=>(K(),j("div",{class:"height-estimation-probes",style:se({width:`${e.width}px`}),"aria-hidden":"true"},[z("div",{ref:n=>e.setParagraphWrapper(n),class:D(["node-content",{"node-content-flow-root":e.flowRoot}]),"data-probe":"paragraph"},[W(V(dl),{node:e.paragraphNode,"index-key":"probe-paragraph"},null,8,["node"])],2),z("div",{ref:n=>e.setListItemWrapper(n),class:D(["node-content",{"node-content-flow-root":e.flowRoot}]),"data-probe":"list-item"},[z("ul",ni,[W(V(tl),{node:e.listItemNode,"index-key":"probe-list-item"},null,8,["node"])])],2),z("div",{ref:n=>e.setListWrapper(n),class:D(["node-content",{"node-content-flow-root":e.flowRoot}]),"data-probe":"list"},[W(V(ol),{node:e.listNode,"index-key":"probe-list"},null,8,["node"])],2),(K(),j(Y,null,J(6,n=>z("div",{key:`probe-heading-${n}`,ref_for:!0,ref:t=>e.setHeadingWrapper(n,t),class:D(["node-content",{"node-content-flow-root":e.flowRoot}]),"data-probe":`heading-${n}`},[W(V(Go),{node:t(n),"index-key":`probe-heading-${n}`},null,8,["node","index-key"])],10,ti)),64))],4))}})),[["__scopeId","data-v-3e0766e2"]]),li=O({name:"InfographicBlockNodeLoading",props:{node:{type:Object,required:!0},showHeader:{type:Boolean,default:!0},estimatedPreviewHeightPx:{type:Number,default:void 0}},setup(e){const n=A(()=>{var n,t;return Ke(null!=(t=Le(e.estimatedPreviewHeightPx))?t:je(String(null!=(n=e.node.code)?n:"")))});return()=>{var t;return E("div",{class:"infographic-block-container rounded-lg border overflow-hidden",style:{margin:"var(--ms-flow-diagram-y) 0",background:"var(--diagram-bg)",borderColor:"var(--diagram-border)",color:"hsl(var(--ms-foreground))"},"data-markstream-infographic":"1","data-markstream-mode":"pending"},[e.showHeader?E("div",{class:"infographic-block-header flex justify-between items-center border-b",style:{padding:"var(--ms-inset-panel-y) var(--ms-inset-panel-x)",background:"var(--diagram-header-bg)",borderColor:"var(--diagram-border)",minHeight:"calc(var(--ms-action-btn-icon) + var(--ms-action-btn-padding) + var(--ms-action-btn-padding) + var(--ms-inset-panel-y) + var(--ms-inset-panel-y) + 1px)"}},[E("div",{class:"flex items-center gap-x-2 overflow-hidden"},[E("span",{class:"icon-slot action-icon shrink-0",style:{display:"inline-flex",width:"var(--ms-action-btn-icon)",height:"var(--ms-action-btn-icon)"}}),E("span",{class:"infographic-label font-medium font-mono truncate",style:{fontSize:"var(--ms-text-label)",color:"hsl(var(--ms-muted-foreground))"}},"Infographic")]),E("div",{class:"infographic-header-actions flex items-center opacity-0 pointer-events-none",style:{gap:"var(--ms-gap-header-actions)"},"aria-hidden":"true"},Array.from({length:4},()=>E("span",{class:"infographic-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded",style:{width:"calc(var(--ms-action-btn-icon) + var(--ms-action-btn-padding) + var(--ms-action-btn-padding))",height:"calc(var(--ms-action-btn-icon) + var(--ms-action-btn-padding) + var(--ms-action-btn-padding))"}})))]):null,E("div",{class:"infographic-preview relative overflow-hidden block",style:{height:`${n.value}px`,minHeight:"var(--ms-size-diagram-min-height)",background:"var(--diagram-bg)"}},[E("pre",{class:"infographic-pending-source text-sm font-mono whitespace-pre-wrap",style:{position:"absolute",inset:"0",zIndex:"1",margin:"0",padding:"var(--ms-inset-panel-body)",overflow:"auto",textAlign:"left"}},String(null!=(t=e.node.code)?t:"")),E("div",{class:"absolute inset-0"},[E("div",{class:"w-full text-center flex items-center justify-center min-h-full"})])])])}}}),ri=O({name:"MermaidBlockNodeLoading",props:{node:{type:Object,required:!0},showHeader:{type:Boolean,default:!0},estimatedPreviewHeightPx:{type:Number,default:void 0}},setup(e){const n=A(()=>{var n,t;return Ae(null!=(t=Le(e.estimatedPreviewHeightPx))?t:Oe(String(null!=(n=e.node.code)?n:"")))});return()=>{var t;return E("div",{class:"mermaid-block-container rounded-lg border overflow-hidden",style:{margin:"var(--ms-flow-diagram-y) 0",borderColor:"var(--diagram-border)"},"data-markstream-mermaid":"1","data-markstream-mode":"pending"},[e.showHeader?E("div",{class:"mermaid-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)]",style:{background:"var(--diagram-header-bg)",borderColor:"var(--diagram-border)"}},[E("div",{class:"flex items-center gap-x-2 overflow-hidden"},[E("span",{class:"mermaid-label-text text-[length:var(--ms-text-label)] font-medium font-mono truncate",style:{color:"var(--code-action-fg)"}},"Mermaid")]),E("div",{class:"mermaid-header-actions flex items-center gap-[var(--ms-gap-header-actions)] opacity-0 pointer-events-none","aria-hidden":"true"},Array.from({length:4},()=>E("span",{class:"mermaid-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded"},[E("span",{class:"action-icon block"})])))]):null,E("div",{class:"mermaid-preview-area relative overflow-hidden block",style:{height:`${n.value}px`,minHeight:"var(--ms-size-diagram-min-height)",background:"var(--diagram-bg)"}},[E("pre",{class:"mermaid-source-code text-sm font-mono whitespace-pre-wrap",style:{position:"absolute",inset:"0",margin:"0",padding:"var(--ms-inset-panel-body)",overflow:"auto",textAlign:"left"}},String(null!=(t=e.node.code)?t:"")),E("div",{class:"_mermaid w-full text-center flex items-center justify-center min-h-full",style:{fontFamily:"inherit",contentVisibility:"auto",contain:"content",containIntrinsicSize:"var(--ms-size-diagram-min-height) 240px"}})])])}}}),ii=O({name:"NodeRendererContent",props:["item","sourceNodes","fade","final","nestedRendererProps"],setup:e=>()=>E(pe,{name:"fade",css:!1!==e.fade,appear:!1!==e.fade&&!0!==e.final},{default:()=>{const n=e.item;return n.rendersCustomNode?E(n.component,a({key:0},n.customNodeProps),{default:()=>n.hasSlotChildren?E(fi,u(a({key:0},e.nestedRendererProps),{nodes:n.node.children,indexKey:n.indexKey,batchRendering:!1,deferNodesUntilVisible:!1,renderAsFragment:!0})):n.slotContent?E(fi,u(a({key:1},e.nestedRendererProps),{content:n.slotContent,final:!n.node.loading,indexKey:`${n.indexKey}-content`,smoothStreaming:!1,batchRendering:!1,deferNodesUntilVisible:!1,renderAsFragment:!0})):G("v-if",!0)}):E(n.component,a({key:1},n.nodeProps))}})}),ai={docs:{showTooltips:!0,fade:!0,batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:220,liveNodeBuffer:60,nodeVirtual:"auto"},chat:{showTooltips:!1,fade:!1,batchRendering:!0,initialRenderBatchSize:32,renderBatchSize:48,renderBatchDelay:6,renderBatchBudgetMs:8,renderBatchIdleTimeoutMs:60,deferNodesUntilVisible:!0,maxLiveNodes:0,liveNodeBuffer:0,nodeVirtual:"auto"},minimal:{showTooltips:!1,fade:!1,batchRendering:!0,initialRenderBatchSize:32,renderBatchSize:48,renderBatchDelay:6,renderBatchBudgetMs:8,renderBatchIdleTimeoutMs:60,deferNodesUntilVisible:!0,maxLiveNodes:0,liveNodeBuffer:0,nodeVirtual:"auto"}};function ui(e){if(null==e)return"";if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return String(e);try{return JSON.stringify(e)}catch(n){return String(e)}}const si=["data-custom-id"],di=["data-node-index","data-node-type"],ci="typewriter-simple-cursor-target",fi=/* @__PURE__ */an(/* @__PURE__ */O(u(a({},{name:"NodeRenderer"}),{__name:"NodeRenderer",props:{content:{},nodes:{},final:{type:Boolean},parseOptions:{},customMarkdownIt:{},debugPerformance:{type:Boolean,default:!1},customHtmlTags:{},mode:{},domMode:{},htmlPolicy:{},viewportPriority:{type:Boolean,default:void 0},viewportPriorityOptions:{},codeBlockStream:{type:Boolean,default:!0},codeBlockDarkTheme:{},codeBlockLightTheme:{},renderCodeBlocksAsPre:{type:Boolean,default:void 0},codeBlockMinWidth:{},codeBlockMaxWidth:{},codeBlockOptions:{},codeBlockProps:{},mermaidProps:{},d2Props:{},infographicProps:{},showTooltips:{type:Boolean,default:void 0},themes:{},isDark:{type:Boolean},customId:{},indexKey:{},typewriter:{type:[Boolean,String],default:!1},smoothStreaming:{type:[Boolean,String],default:"auto"},smoothStreamingOptions:{},parseCoalesceMs:{},fade:{type:Boolean,default:void 0},batchRendering:{type:Boolean,default:void 0},initialRenderBatchSize:{},renderBatchSize:{},renderBatchDelay:{},renderBatchBudgetMs:{},renderBatchIdleTimeoutMs:{},deferNodesUntilVisible:{type:Boolean,default:void 0},maxLiveNodes:{},liveNodeBuffer:{},nodeVirtual:{type:[Boolean,String],default:void 0},virtualScroll:{},renderAsFragment:{type:Boolean}},emits:["copy","copy-code","handleArtifactClick","click","mouseover","mouseout","virtual-state-change","height-change","render-settled","render-final","anchor-change"],setup(e,{expose:n,emit:t}){const o=e,l=t;function r(e){if(!("undefined"!=typeof Event&&e instanceof Event))return"string"==typeof e?(l("copy-code",e),void l("copy",e)):void l("copy",e)}function i(e){l("handleArtifactClick",e)}function d(e){l("mouseover",e)}function c(e){l("mouseout",e)}const f=Q(),m=F("markstreamNestedRendererProps",void 0);function v(e){const n=null==f?void 0:f.vnode.props;return!!n&&(Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,String(e).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)))}function h(e){var n,t;const l=o[e];return v(e)?l:null!=(t=null==(n=null==m?void 0:m.value)?void 0:n[e])?t:l}const p=Xl,g=A(()=>{return"chat"===(e=h("mode"))||"minimal"===e||"docs"===e?e:"docs";var e}),y=A(()=>Gl(h("typewriter"))),b=A(()=>"off"!==y.value),k=A(()=>"minimal"===h("domMode")?"minimal":"full"),w=A(()=>!0===h("renderCodeBlocksAsPre")),x=A(()=>ai[g.value]),S=A(()=>{var e;return null!=(e=h("showTooltips"))?e:x.value.showTooltips}),M=A(()=>{var e;return null!=(e=h("fade"))?e:x.value.fade}),_=A(()=>{var e;return null!=(e=h("batchRendering"))?e:x.value.batchRendering}),T=A(()=>{var e;return null!=(e=h("initialRenderBatchSize"))?e:x.value.initialRenderBatchSize}),B=A(()=>{var e;return null!=(e=h("renderBatchSize"))?e:x.value.renderBatchSize}),I=A(()=>{var e;return null!=(e=h("renderBatchDelay"))?e:x.value.renderBatchDelay}),H=A(()=>{var e;return null!=(e=h("renderBatchBudgetMs"))?e:x.value.renderBatchBudgetMs}),R=A(()=>{var e;return null!=(e=h("renderBatchIdleTimeoutMs"))?e:x.value.renderBatchIdleTimeoutMs}),O=A(()=>{var e;return null!=(e=h("deferNodesUntilVisible"))?e:x.value.deferNodesUntilVisible}),z=A(()=>{var e;return null!=(e=h("maxLiveNodes"))?e:x.value.maxLiveNodes}),L=A(()=>{var e;return null!=(e=h("liveNodeBuffer"))?e:x.value.liveNodeBuffer}),E=A(()=>{var e;return null!=(e=h("nodeVirtual"))?e:x.value.nodeVirtual}),W={get content(){return o.content},get nodes(){return o.nodes},get final(){return o.final},get parseOptions(){return h("parseOptions")},get customMarkdownIt(){return h("customMarkdownIt")},get debugPerformance(){return o.debugPerformance},get customHtmlTags(){return h("customHtmlTags")},get mode(){return h("mode")},get domMode(){return k.value},get htmlPolicy(){return h("htmlPolicy")},get viewportPriority(){return h("viewportPriority")},get viewportPriorityOptions(){return h("viewportPriorityOptions")},get codeBlockStream(){return h("codeBlockStream")},get codeBlockDarkTheme(){return h("codeBlockDarkTheme")},get codeBlockLightTheme(){return h("codeBlockLightTheme")},get codeBlockMinWidth(){return h("codeBlockMinWidth")},get codeBlockMaxWidth(){return h("codeBlockMaxWidth")},get codeBlockOptions(){return h("codeBlockOptions")},get codeBlockProps(){return h("codeBlockProps")},get mermaidProps(){return h("mermaidProps")},get d2Props(){return h("d2Props")},get infographicProps(){return h("infographicProps")},get showTooltips(){return S.value},get themes(){return h("themes")},get isDark(){return h("isDark")},get customId(){return h("customId")},get indexKey(){return o.indexKey},get typewriter(){return h("typewriter")},get smoothStreaming(){return o.smoothStreaming},get smoothStreamingOptions(){return h("smoothStreamingOptions")},get parseCoalesceMs(){return h("parseCoalesceMs")},get fade(){return M.value},get batchRendering(){return _.value},get initialRenderBatchSize(){return T.value},get renderBatchSize(){return B.value},get renderBatchDelay(){return I.value},get renderBatchBudgetMs(){return H.value},get renderBatchIdleTimeoutMs(){return R.value},get deferNodesUntilVisible(){return O.value},get maxLiveNodes(){return z.value},get liveNodeBuffer(){return L.value},get nodeVirtual(){return E.value},get virtualScroll(){return o.virtualScroll},get renderAsFragment(){return o.renderAsFragment}};function Z(e){l("height-change",e)}function te(e){l("virtual-state-change",e)}function de(e){l("anchor-change",e)}const ce=q(),fe=q(null),ve=q(null),he=q(null),pe=ge({1:null,2:null,3:null,4:null,5:null,6:null}),ye=q(!1),Se=/* @__PURE__ */new Map,Me=q(0);let Ne=!1;const _e=q(0),Te=q({paragraph:null,listItem:null,listWrapperOverhead:0,headings:{1:null,2:null,3:null,4:null,5:null,6:null}});function Be(e,n){return"string"!=typeof e?n:e.trim()||n}function Ie(e){const n=Number(e);return Number.isFinite(n)&&n>0?Math.max(1,Math.trunc(n)):640}const He=A(()=>{var e;const n=null!=(e=W.viewportPriorityOptions)?e:{},t=Be(n.rootMargin,ut);return{rootMargin:t,heavyBlockMargin:Be(n.heavyBlockMargin,t),maxTargets:Ie(n.maxTargets)}}),$e=A(()=>{var e;return null!=(e=He.value.rootMargin)?e:ut}),Re=A(()=>{var e;return null!=(e=He.value.maxTargets)?e:640});function Pe(){var e,n;if(!0!==(null==(e=o.virtualScroll)?void 0:e.enabled))return null;const t=null==(n=o.virtualScroll)?void 0:n.scrollRoot;return Fe("function"==typeof t?t():t)}function Fe(e){return e?"undefined"!=typeof HTMLElement&&e instanceof HTMLElement?e:"object"==typeof e&&"value"in e?Fe(e.value):"object"==typeof e&&"$el"in e?Fe(e.$el):null:null}ee(rt,He);const{isClient:De,renderAsFragment:We,debugPerformanceEnabled:Ve,resolvedShowTooltips:qe,resolvedHtmlPolicy:Ue,inheritedSmoothStreaming:Xe,ownsTypewriterCursor:Ze}=function(e){const n="undefined"!=typeof window,t=U(),o=F("markstreamHtmlPolicy",void 0),l=F("markstreamTypewriterCursor",void 0),r=F("markstreamSmoothStreaming",void 0),i=A(()=>!0===e.renderAsFragment),a=A(()=>Boolean(e.debugPerformance&&n&&"undefined"!=typeof console)),u=A(()=>{var n;if("boolean"==typeof e.showTooltips)return e.showTooltips;const o=null!=(n=t.showTooltips)?n:t["show-tooltips"];return""===o||!0===o||"true"===o||!1!==o&&"false"!==o&&void 0}),s=A(()=>{var n,t;return null!=(t=null!=(n=e.htmlPolicy)?n:null==o?void 0:o.value)?t:"safe"}),d=A(()=>!0!==(null==l?void 0:l.value));return{isClient:n,renderAsFragment:i,debugPerformanceEnabled:a,resolvedShowTooltips:u,resolvedHtmlPolicy:s,inheritedSmoothStreaming:r,inheritedTypewriterCursor:l,ownsTypewriterCursor:d}}(W),{resolveViewportRoot:Ge,resolveScrollContainer:Je,isReverseFlexScrollRoot:Qe,getNormalizedScrollTop:nn,getOffsetTopWithinRoot:tn}=function(e,n){function t(){var e,t;return null!=(t=null==(e=n.scrollRoot)?void 0:e.call(n))?t:null}function o(n){if("undefined"==typeof window)return null;const o=t();if(o)return o;const l=null!=n?n:e.value;if(!l)return null;const r=l.ownerDocument||document,i=r.scrollingElement||r.documentElement;let a=l;for(;a&&a!==r.body&&a!==i;){if(Jr(window.getComputedStyle(a))&&Qr(a))return a;a=a.parentElement}return null}function l(e){if(!n.isClient)return!1;try{const n=window.getComputedStyle(e);return!!(n.display||"").toLowerCase().includes("flex")&&(n.flexDirection||"").toLowerCase().endsWith("reverse")}catch(t){return!1}}function r(e,n,t){var o,r;if(t)return i(n);const a=e.scrollTop;if(!l(e))return a;const u=a<0?-a:a;return Math.max(0,(null!=(o=e.scrollHeight)?o:0)-(null!=(r=e.clientHeight)?r:0))-u}function i(e){var n,t,o,l,r;const i=Number(null==(n=e.scrollingElement)?void 0:n.scrollTop),a=Number(null!=(o=null==(t=e.documentElement)?void 0:t.scrollTop)?o:0),u=Number(null!=(r=null==(l=e.body)?void 0:l.scrollTop)?r:0);return Math.max(0,Number.isFinite(i)?i:0,Number.isFinite(a)?a:0,Number.isFinite(u)?u:0)}return{resolveViewportRoot:o,resolveScrollContainer:function(n){var l,r,i,a;const u=t();if(u)return u;const s=o(null!=(l=null!=n?n:e.value)?l:null);if(s)return s;const d=null!=(a=null!=(i=null==n?void 0:n.ownerDocument)?i:null==(r=e.value)?void 0:r.ownerDocument)?a:"undefined"!=typeof document?document:null;return(null==d?void 0:d.scrollingElement)||(null==d?void 0:d.documentElement)||null},isReverseFlexScrollRoot:l,getNormalizedScrollTop:r,getOffsetTopWithinRoot:function(e,n){const t=n.ownerDocument||e.ownerDocument||document;if(function(e,n){return e===n.documentElement||e===n.body||e===n.scrollingElement}(n,t))return e.getBoundingClientRect().top+i(t);const o=n.getBoundingClientRect(),l=e.getBoundingClientRect(),a=r(n,t,!1);return l.top-o.top+a}}}(ce,{isClient:De,scrollRoot:Pe});ee("markstreamShowTooltips",qe),ee("markstreamHtmlPolicy",Ue),ee("markstreamTypewriter",b),ee("markstreamFade",A(()=>!1!==W.fade)),ee("markstreamTypewriterCursor",A(()=>!0)),ee("markstreamTextStreamState",Se),ee("markstreamStreamVersion",Me),ee("markstreamParseOptions",A(()=>W.parseOptions)),ee("markstreamCustomMarkdownIt",A(()=>W.customMarkdownIt));const{smoothStreamingEnabled:on,renderContent:ln,requestedFinal:rn,effectiveFinal:an}=function(e,n){const t=Yr(u(a(a({},Zr),e.smoothStreamingOptions),{burstInitialContent:!Jl(e.typewriter)})),o=A(()=>{var t,o,l;return!1!==e.smoothStreaming&&!(null==(t=e.nodes)?void 0:t.length)&&(!0===e.smoothStreaming||!(null==(o=n.inheritedSmoothStreaming)?void 0:o.value))&&(!0===e.smoothStreaming||Jl(e.typewriter)||(null!=(l=e.maxLiveNodes)?l:0)<=0)}),l=q(!n.isClient||!0===e.smoothStreaming);be(()=>{l.value=!0});const r=A(()=>l.value&&o.value),i=A(()=>{var n;return r.value?t.visible.value:null!=(n=e.content)?n:""}),s=A(()=>{var n,t;const o=null!=(n=e.parseOptions)?n:{};return null!=(t=e.final)?t:o.final}),d=A(()=>{const e=s.value;return r.value&&null!=e?!!e&&t.caughtUp.value:e});let c=0,f=!1;function m(){c=0,f=!1}return X([()=>e.content,()=>e.nodes,r,s],([e,n,o,l])=>{if(null==n?void 0:n.length)return m(),void t.reset("");const r=null!=e?e:"";if(!o)return m(),t.reset(r),void(l&&t.finish({flush:!0}));const i=t.source.value;if(r)if(r===i);else if(r.startsWith(i)){const e=r.slice(i.length),n=t.pendingChars.value;e.length<=8?(c++,f||c>=2&&n<=8?(f=!0,t.reset(r,{prefixKnown:!0})):t.enqueue(e)):(m(),t.enqueue(e))}else m(),t.reset(r);else m(),t.reset("");l&&t.finish()},{immediate:!0}),{smoothStream:t,smoothStreamingEligible:o,smoothStreamingEnabled:r,renderContent:i,requestedFinal:s,effectiveFinal:d}}(W,{isClient:De,inheritedSmoothStreaming:Xe}),sn=!0===rn.value;ee("markstreamSmoothStreaming",on);const cn=q(!1),fn=q(!1),mn=q(!1);let vn="",pn=!1,gn=null;function yn(){De&&null!=gn&&(window.clearTimeout(gn),gn=null)}function bn(){cn.value=!1,yn()}function kn(e,n){if(!Ve.value)return;const t=function(){if(!Ve.value)return null;const e=Nn(wn),n=Nn(Sn),t=Math.max(Cn,n);if(e<=0&&t<=0)return null;const o={total:e,maxPerFrame:t,byLabel:(l=wn,Object.fromEntries(Array.from(l.entries()).sort((e,n)=>n[1]-e[1]||e[0].localeCompare(n[0]))))};var l;return wn.clear(),Sn.clear(),Cn=0,o}();console.info(`[markstream-vue][perf] ${e}`,t?u(a({},n),{layoutReads:t}):n)}X([()=>W.indexKey,()=>W.customId],()=>{var e,n;bn(),fn.value=!1,mn.value=!(null==(e=o.nodes)?void 0:e.length)&&!0!==rn.value&&Boolean(o.content),vn=null!=(n=ln.value)?n:"",pn=vn.length>0},{flush:"sync"}),X([()=>o.content,()=>o.nodes,rn],([e,n,t])=>{!(null==n?void 0:n.length)&&!0!==t&&Boolean(e)&&(mn.value=!0)},{flush:"sync",immediate:!0}),X([ln,()=>o.nodes,an],([e,n,t])=>{const l=null!=e?e:"";return(null==n?void 0:n.length)||!0===t?(bn(),fn.value=!1,vn=l,void(pn=!0)):(l.length>0&&(mn.value=!0),pn?(vn&&l.length>vn.length&&l.startsWith(vn)?(cn.value=!0,fn.value=!0,De&&(yn(),gn=window.setTimeout(()=>{var e;gn=null,!0===an.value||(null==(e=o.nodes)?void 0:e.length)||(pu(),cn.value=!1,bu())},1200))):(l.length<vn.length||!l.startsWith(vn))&&(bn(),fn.value=!1),void(vn=l)):(vn=l,void(pn=!0)))},{flush:"sync",immediate:!0});const wn=/* @__PURE__ */new Map,Sn=/* @__PURE__ */new Map;let Mn=!1,Cn=0;function Nn(e){let n=0;for(const t of e.values())n+=t;return n}function _n(){Cn=Math.max(Cn,Nn(Sn)),Sn.clear(),Mn=!1}function Bn(e){e.maxPerFrame=Math.max(Number(e.maxPerFrame||0),Number(e.currentFrameTotal||0)),e.currentFrameTotal=0,e.frameScheduled=!1}function In(e){var n,t;Ve.value&&(wn.set(e,(null!=(n=wn.get(e))?n:0)+1),Sn.set(e,(null!=(t=Sn.get(e))?t:0)+1),function(e){const n=function(){if(!De||"undefined"==typeof window)return null;const e=window;if(e.__markstreamLayoutReadPerformance)return e.__markstreamLayoutReadPerformance;const n={total:0,maxPerFrame:0,byLabel:{}};return e.__markstreamLayoutReadPerformance=n,n}();n&&(n.total=Number(n.total||0)+1,n.byLabel[e]=Number(n.byLabel[e]||0)+1,n.currentFrameTotal=Number(n.currentFrameTotal||0)+1,n.frameScheduled||(n.frameScheduled=!0,"function"!=typeof window.requestAnimationFrame?"function"!=typeof queueMicrotask?setTimeout(()=>Bn(n),0):queueMicrotask(()=>Bn(n)):window.requestAnimationFrame(()=>Bn(n))))}(e),Mn||(Mn=!0,De&&"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(_n):"function"!=typeof queueMicrotask?setTimeout(_n,0):queueMicrotask(_n)))}function Hn(e,n){return In(e),n()}const $n=W.customId?`renderer-${W.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,Pn=function(e){const n=/* @__PURE__ */new Map;return{scope:e,cache:n,clear:()=>n.clear()}}($n),Fn=$n;ee(Ql,Pn);const An=en(()=>W.customId),{effectiveCustomHtmlTagsSet:On,mdInstance:Kn,mergedParseOptions:jn,parsedNodes:zn,getParsedNodesDirtyStartIndex:Ln,getParsedNodesRevision:En}=qr(W,{instanceMsgId:$n,renderContent:ln,effectiveFinal:an,smoothStreamingEnabled:on,debugPerformanceEnabled:Ve,customComponentsMap:An,logPerf:kn});X(zn,()=>{cn.value||Pn.clear(),Me.value+=1,Ne&&$o(Vr(zn.value.length))},{immediate:!0});const Dn=A(()=>({customId:W.customId,customHtmlTags:jn.value.customHtmlTags,parseOptions:W.parseOptions,customMarkdownIt:W.customMarkdownIt,htmlPolicy:Ue.value,viewportPriority:W.viewportPriority,viewportPriorityOptions:He.value,mode:g.value,domMode:W.domMode,codeBlockStream:W.codeBlockStream,codeBlockDarkTheme:W.codeBlockDarkTheme,codeBlockLightTheme:W.codeBlockLightTheme,renderCodeBlocksAsPre:w.value,codeBlockMinWidth:W.codeBlockMinWidth,codeBlockMaxWidth:W.codeBlockMaxWidth,codeBlockOptions:W.codeBlockOptions,codeBlockProps:W.codeBlockProps,mermaidProps:W.mermaidProps,d2Props:W.d2Props,infographicProps:W.infographicProps,showTooltips:qe.value,themes:W.themes,isDark:W.isDark,typewriter:b.value,smoothStreamingOptions:W.smoothStreamingOptions,parseCoalesceMs:W.parseCoalesceMs,fade:W.fade}));ee("markstreamNestedRendererProps",Dn);const Wn=A(()=>zn.value),Vn=A(()=>zn.value.length),qn=q(null),Un=q(null),Xn=q(null),Yn=q(null),Zn=null!=o.indexKey&&String(o.indexKey).startsWith("list-item-"),Gn=!Zn&&W.customId?$l(W.customId):null,Jn=A(()=>Gn?(Hl.value,$l(W.customId)):null),Qn=A(()=>{var e;return Boolean(!We.value&&W.customId&&!Zn&&(null==(e=Jn.value)?void 0:e.enabled))}),et=A(()=>Boolean(De&&Qn.value)),nt=A(()=>{var e;return Boolean(!We.value&&(null==(e=o.virtualScroll)?void 0:e.enabled))}),tt=A(()=>nt.value),ot=q(!1);be(()=>{ot.value=!0});const lt=A(()=>Boolean(De&&nt.value));ee("markstreamHostScrollManaged",lt);const at=A(()=>Boolean(ot.value&<.value)),st=A(()=>et.value||lt.value);X(st,e=>{e&&Il()},{immediate:!0});const dt=A(()=>et.value||at.value),ft=A(()=>{var e;return st.value&&!1!==(null==(e=Jn.value)?void 0:e.textEstimation)});function mt(){if(_e.value>0)return _e.value;const e=Hn("getMeasuredContainerWidth.clientWidth",()=>{var e;return(null==(e=ce.value)?void 0:e.clientWidth)||0});return Number.isFinite(e)&&e>0?e:0}const vt=A(()=>{const e=mt();return e>0?Math.max(1,Math.round(e)):640}),ht=A(()=>{var e,n;return!(!0!==an.value||nt.value||"chat"!==g.value&&"minimal"!==g.value||v("maxLiveNodes")||v("liveNodeBuffer")||(null==(e=o.nodes)?void 0:e.length)||mn.value||!((null!=(n=W.maxLiveNodes)?n:0)<=0))}),pt=A(()=>{var e;return ht.value?50:Math.max(1,null!=(e=W.maxLiveNodes)?e:320)}),gt=A(()=>{var e;return ht.value?16:Math.max(0,null!=(e=W.liveNodeBuffer)?e:60)}),yt=A(()=>{var e;return!We.value&&!1!==W.nodeVirtual&&!((null!=(e=W.maxLiveNodes)?e:0)<=0&&!ht.value)&&(!0===W.nodeVirtual?zn.value.length>0:zn.value.length>pt.value)}),kt=A(()=>yt.value||et.value||lt.value),wt=A(()=>!1!==W.viewportPriority),xt=A(()=>!!wt.value&&!ye.value);var St;St=A(()=>wt.value),ee(it,St);const Mt=A(()=>{var e;return!(We.value||!1===W.deferNodesUntilVisible||(null!=(e=W.maxLiveNodes)?e:0)<=0||yt.value||zn.value.length>900||!1===W.viewportPriority)}),Ct=ct(e=>{var n,t;return Ge(null!=(t=null!=(n=null==e?void 0:e.parentElement)?n:ce.value)?t:null)},wt),{requestFrame:Nt,cancelFrame:_t,hasIdleCallback:Tt,isTestEnv:Bt}=function(e){const n=e.isClient&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame.bind(window):null,t=e.isClient&&"function"==typeof window.cancelAnimationFrame?window.cancelAnimationFrame.bind(window):null,o=e.isClient&&"function"==typeof window.requestIdleCallback,l=function(){var e;if("undefined"==typeof globalThis||!("process"in globalThis))return;const n=null==(e=Object.getOwnPropertyDescriptor(globalThis,"process"))?void 0:e.value;return null==n?void 0:n.env}();return{requestFrame:n,cancelFrame:t,hasIdleCallback:o,isTestEnv:"test"===(null==l?void 0:l.NODE_ENV)}}({isClient:De}),It=A(()=>!0===an.value&&!nt.value),{resolvedBatchSize:Ht,resolvedInitialBatch:$t,batchingEnabled:Rt,incrementalRenderingActive:Pt,renderedCount:At,previousRenderContext:Kt,adaptiveBatchSize:zt,previousBatchConfig:Lt}=function(e,n){var t;const o=A(()=>{var n;const t=Math.trunc(null!=(n=e.renderBatchSize)?n:80);return Number.isFinite(t)?Math.max(0,t):0}),l=A(()=>{var n;const t=Math.trunc(null!=(n=e.initialRenderBatchSize)?n:o.value);return Number.isFinite(t)?Math.max(0,t):o.value}),r=A(()=>!n.renderAsFragment.value&&!1!==e.batchRendering&&o.value>0&&n.isClient&&!n.isTestEnv),i=q(0),a=q({key:e.indexKey,total:0}),u=q(Math.max(1,o.value||1)),s=A(()=>{var t,o,l;return r.value&&!(null==(t=n.continuousStreaming)?void 0:t.value)&&!(null==(o=n.forceFullRenderFinalContent)?void 0:o.value)&&(null!=(l=e.maxLiveNodes)?l:0)<=0}),d=q({batchSize:o.value,initial:l.value,delay:null!=(t=e.renderBatchDelay)?t:16,enabled:s.value});return{resolvedBatchSize:o,resolvedInitialBatch:l,batchingEnabled:r,incrementalRenderingActive:s,renderedCount:i,previousRenderContext:a,adaptiveBatchSize:u,previousBatchConfig:d}}(W,{isClient:De,isTestEnv:Bt,renderAsFragment:We,forceFullRenderFinalContent:It,continuousStreaming:A(()=>fn.value&&!0!==an.value)}),Et=A(()=>{var e;return!We.value&&!1!==W.batchRendering&&Ht.value>0&&!Bt&&(null!=(e=W.maxLiveNodes)?e:0)<=0&&!It.value}),Dt=A(()=>Et.value),Wt=A(()=>st.value||Dt.value),Vt=A(()=>{var e;return Wt.value&&!1!==(null==(e=Jn.value)?void 0:e.codeBlockEstimation)}),qt=/* @__PURE__ */new Map,Ut=/* @__PURE__ */new Map,Xt=/* @__PURE__ */new Map,Yt=/* @__PURE__ */new WeakMap;let Zt=null;const Gt=[];X(()=>zn.value.length,e=>{Gt.length>e&&(Gt.length=e)});const Jt=[],Qt=[];let eo=[],oo=[],uo=-1;const co=P(Qt),mo=/* @__PURE__ */new Set,ho=q(0);let go=0;const bo=q(0),ko=A(()=>(bo.value,Array.from(qt.entries()).sort((e,n)=>e[0]-n[0]))),wo=q(null),xo=q(null);let Mo,No=null,To=0,Io=null;function $o(e){Mo.markFallbackHeightPrefixDirty(e)}function Ro(e){return Mo.getFallbackNodeHeight(e)}function Po(e,n){return Mo.estimateHeightRange(e,n)}function Fo(e){return Mo.estimateIndexForOffset(e)}const{activeRestoreAnchor:Ao,getRelativeScrollTopWithinContainer:Oo,setRelativeScrollTopWithinContainer:Ko,resolveAnchorOffset:zo,clearRestoreReconcile:Lo,scheduleRestoreReconcile:Eo,captureRestoreAnchor:Wo,restoreAnchor:qo,getAnchorDrift:Uo}=function(e){const{isClient:n,containerRef:t,parsedNodeCount:o,requestFrame:l,cancelFrame:r,resolveScrollContainer:i,getNormalizedScrollTop:a,getOffsetTopWithinRoot:u,isReverseFlexScrollRoot:s,estimateIndexForOffset:d,estimateHeightRange:c,getFallbackNodeHeight:f,clamp:m}=e,v=q(null);let h=null,p=[];function g(){const e=i(),n=t.value;if(!e||!n)return null;const o=e.ownerDocument||n.ownerDocument||document;if(e===o.documentElement||e===o.body||e===o.scrollingElement){const e=n.getBoundingClientRect();return Math.max(0,-e.top)}return Math.max(0,a(e,o,!1)-u(n,e))}function y(e){var n;const o=i(),l=t.value;if(!o||!l)return;const r=Math.max(0,e),d=o.ownerDocument||l.ownerDocument||document,c=d.defaultView||("undefined"!=typeof window?window:null);if(o===d.documentElement||o===d.body||o===d.scrollingElement){const e=a(o,d,!0)+l.getBoundingClientRect().top;return void(null==(n=null==c?void 0:c.scrollTo)||n.call(c,0,Math.max(0,e+r)))}Yl(o,d,u(l,o)+r,{isReverseFlexScrollRoot:e=>{var n;return null!=(n=null==s?void 0:s(e))&&n},getNormalizedScrollTop:a})}function b(e){const n=o.value,t=m(e.nodeIndex,0,Math.max(0,n-1));return c(0,t)+Math.max(0,e.offsetWithinNodePx)}function k(){if(null!=h&&(null==r||r(h),h=null),n)for(const e of p)window.clearTimeout(e);p=[]}function w(e){const n=b(e),t=g();null!=t&&Math.abs(t-n)<=.5||y(n)}return{activeRestoreAnchor:v,getRelativeScrollTopWithinContainer:g,setRelativeScrollTopWithinContainer:y,resolveAnchorOffset:b,clearRestoreReconcile:k,applyRestoreAnchor:w,scheduleRestoreReconcile:function(){v.value&&n&&null==h&&(h=l?l(()=>{h=null,v.value&&w(v.value)}):null,null==h&&v.value&&w(v.value))},captureRestoreAnchor:function(){const e=g(),n=o.value;if(null==e||n<=0)return null;const t=m(d(e+1),0,n-1),l=c(0,t),r=f(t);return{nodeIndex:t,offsetWithinNodePx:m(e-l,0,Math.max(0,r-1))}},restoreAnchor:function(e){const t=o.value;if(v.value={nodeIndex:m(e.nodeIndex,0,Math.max(0,t-1)),offsetWithinNodePx:Math.max(0,e.offsetWithinNodePx)},k(),w(v.value),n)for(const n of[0,120,280,480])p.push(window.setTimeout(()=>{v.value&&w(v.value)},n))},getAnchorDrift:function(e){const n=g();return null==n?null:n-b(e)}}}({isClient:De,containerRef:ce,parsedNodeCount:Vn,requestFrame:Nt,cancelFrame:_t,resolveScrollContainer:()=>wo.value||Je(),getNormalizedScrollTop:nn,getOffsetTopWithinRoot:tn,isReverseFlexScrollRoot:Qe,estimateIndexForOffset:Fo,estimateHeightRange:Po,getFallbackNodeHeight:Ro,clamp:Wr}),{nodeHeights:Yo,heightStats:Zo,heightTreeSize:Jo,heightSumTree:Qo,heightKnownTree:el,averageNodeHeight:nl,resetHeightMeasurements:ll,pruneHeightMeasurements:rl,rebuildHeightTrees:il,syncHeightTreeSize:ul,recordNodeHeight:sl,removeNodeHeights:cl,exportHeightCache:fl,importHeightCache:ml,fenwickRangeSum:vl}=function(e={}){const n=ge({}),t=ge({total:0,count:0}),o=q(0),l=q([]),r=q([]);function i(){for(const e of Object.keys(n))delete n[Number(e)];t.total=0,t.count=0,o.value=0,l.value=[],r.value=[]}function s(e,n,t){for(let o=n+1;o<e.length;o+=o&-o)e[o]+=t}function d(e,n){let t=0;for(let o=n+1;o>0;o-=o&-o)t+=e[o];return t}function c(e,n,t){if(t<=n)return 0;const o=d(e,t-1);return n<=0?o:o-d(e,n-1)}function f(e){o.value=e;const t=new Array(e+1).fill(0),i=new Array(e+1).fill(0);for(const[o,l]of Object.entries(n)){const n=Number(o),r=Number(l);!Number.isFinite(n)||n<0||n>=e||!Number.isFinite(r)||r<=0||(s(t,n,r),s(i,n,1))}l.value=t,r.value=i}function m(e){if(!Number.isInteger(e)||e<0)return!1;const i=n[e];if(!Number.isFinite(i)||i<=0)return!1;if(delete n[e],t.total=Math.max(0,t.total-i),t.count=Math.max(0,t.count-1),o.value>e){const n=l.value,t=r.value;n.length&&t.length&&(s(n,e,-i),s(t,e,-1))}return!0}const v=A(()=>t.count>0?Math.max(12,t.total/t.count):32);return{nodeHeights:n,heightStats:t,heightTreeSize:o,heightSumTree:l,heightKnownTree:r,averageNodeHeight:v,resetHeightMeasurements:i,pruneHeightMeasurements:function(e){if(e<=0)return void i();let o=0,l=0;for(const[t,r]of Object.entries(n)){const i=Number(t),a=Number(r);!Number.isFinite(i)||i<0||i>=e||!Number.isFinite(a)||a<=0?delete n[i]:(o+=a,l++)}t.total=o,t.count=l},rebuildHeightTrees:f,syncHeightTreeSize:function(e){const t=o.value;if(e===t)return;if(e<t||0===t)return void f(e);const i=l.value,a=r.value;i.length=e+1,a.length=e+1;for(let n=t;n<e;n++)i[n+1]=0,a[n+1]=0;for(let o=t;o<e;o++){const e=Number(n[o]);!Number.isFinite(e)||e<=0||(s(i,o,e),s(a,o,1))}for(let n=t+1;n<=e;n++){const e=n-(n&-n);e>=t||(i[n]+=c(i,e,t),a[n]+=c(a,e,t))}o.value=e},recordNodeHeight:function(i,d,c={}){!function(i,a,u={}){var d;if(!Number.isFinite(a)||a<=0)return!1;const c=n[i];if(c){if(!1===u.allowShrink&&a<c)return!1;if(Math.abs(a-c)<=1)return!1}if(n[i]=a,c?t.total+=a-c:(t.total+=a,t.count++),o.value>i){const e=l.value,n=r.value;if(e.length&&n.length)if(c){const n=a-c;0!==n&&s(e,i,n)}else s(e,i,a),s(n,i,1)}!1!==u.notify&&(null==(d=e.onHeightRecorded)||d.call(e,i))}(i,d,u(a({},c),{notify:!0}))},removeNodeHeight:function(n,t={}){var o;const l=m(n);return l&&!1!==t.notify&&(null==(o=e.onHeightRecorded)||o.call(e,n)),l},removeNodeHeights:function(n,t={}){var o;let l=0,r=Number.POSITIVE_INFINITY;for(const e of n){const n=Number(e);m(n)&&(l++,n<r&&(r=n))}return l>0&&!1!==t.notify&&(null==(o=e.onHeightRecorded)||o.call(e,Number.isFinite(r)?r:void 0)),l},exportHeightCache:function(){return Object.entries(n).map(([e,n])=>({index:Number(e),height:Number(n)})).filter(e=>Number.isFinite(e.index)&&e.index>=0&&Number.isFinite(e.height)&&e.height>0).sort((e,n)=>e.index-n.index)},importHeightCache:function(l,r={}){var i;if(!Array.isArray(l))return;const a=o.value;let u=!1;if("merge"!==r.mode){const e=Object.keys(n);if(e.length>0){for(const t of e)delete n[Number(t)];u=!0}}for(const e of l){const t=Number(e.index),o=Number(e.height);if(!Number.isInteger(t)||t<0)continue;if(a>0&&t>=a)continue;if(!Number.isFinite(o)||o<=0)continue;const l=n[t];l&&Math.abs(l-o)<=1||(n[t]=o,u=!0)}u&&(function(){let e=0,l=0;const r=o.value;for(const[t,o]of Object.entries(n)){const i=Number(t),a=Number(o);!Number.isFinite(i)||i<0||r>0&&i>=r||!Number.isFinite(a)||a<=0?delete n[i]:(e+=a,l++)}t.total=e,t.count=l}(),a>0&&f(a),null==(i=e.onHeightRecorded)||i.call(e))},fenwickRangeSum:c}}({onHeightRecorded:e=>{$o(null!=e?e:0),lt.value&&Hu(),Ao.value&&Eo(),xo.value&&xa(),du("node-resize")}});function hl(e){Number.isInteger(e)&&e>=0&&mo.add(e)}function pl(e){for(const n of e)hl(Number(n))}function gl(e){go++;let n=!0;try{const t=e();return n=!1!==t,t}finally{go--,0===go&&n&&ho.value++}}function bl(){eo=[],oo=[],uo=-1,mo.clear(),co.value=Qt}function wl(){bl(),gl(()=>ll()),Jt.length=0}function Ml(e){!Number.isInteger(e)||e<0||e>=zn.value.length||(Jt[e]=va(e))}function Cl(e,n,t={}){const o=Yo[e];hl(e),sl(e,n,t);const l=Yo[e];return Object.is(o,l)?(mo.delete(e),!1):(l&&l>0?Ml(e):o&&e<Jt.length&&(Jt[e]=void 0),!0)}function _l(e,n){const t=Hn("getNodeLayoutHeight.content.offsetHeight",()=>n.offsetHeight);return t>0?t:Hn("getNodeLayoutHeight.slot.offsetHeight",()=>{var n,t;return null!=(t=null==(n=qt.get(e))?void 0:n.offsetHeight)?t:0})}function Tl(e,n={}){"merge"!==n.mode?bl():pl(e.map(e=>e.index)),gl(()=>ml(e,n)),La()}const Bl=A(()=>Mt.value&&xt.value),Rl=A(()=>st.value||Et.value||Bl.value&&zn.value.length>$t.value),Pl=A(()=>{var e;return!We.value&&!1!==W.batchRendering&&Ht.value>0&&(null!=(e=W.maxLiveNodes)?e:0)<=0}),Fl=A(()=>!We.value&&sn&&!0===an.value&&!yt.value&&!nt.value&&!Qn.value&&!Bl.value&&!Pl.value),Al=A(()=>!!Ct&&Bl.value),Kl=A(()=>[Al.value,Bl.value,yt.value,ye.value,Re.value,$e.value,$t.value,Boolean(Ct)].join("|")),Dl=A(()=>yt.value||lt.value),{focusIndex:Vl,liveRange:er,updateLiveRange:nr}=function(e,n){const{parsedNodeCount:t,virtualizationEnabled:o,maxLiveNodesResolved:l,liveNodeBufferResolved:r,clamp:i}=n,a=null!=r?r:A(()=>{var n;return Math.max(0,null!=(n=e.liveNodeBuffer)?n:60)}),u=q(0),s=ge({start:0,end:0});return{liveNodeBufferResolved:a,focusIndex:u,liveRange:s,updateLiveRange:function(){const e=t.value;if(!o.value||0===e)return s.start=0,void(s.end=e);const n=Math.min(l.value,e),r=a.value,d=i(u.value-r,0,Math.max(0,e-n));s.start=d,s.end=Math.min(e,d+n)}}}(W,{parsedNodeCount:Vn,virtualizationEnabled:yt,maxLiveNodesResolved:pt,liveNodeBufferResolved:gt,clamp:Wr}),tr=/* @__PURE__ */new Map,lr=/* @__PURE__ */new Map,ir=/* @__PURE__ */new Map,ar=/* @__PURE__ */new Map,ur=[],cr=/* @__PURE__ */new Map;let fr=-1/0;const mr=/* @__PURE__ */new Set,vr=q(0);let hr=!1;const pr=A(()=>(vr.value,mr.size)),gr=/* @__PURE__ */new Map,yr=/* @__PURE__ */new Map,br=q(0);let kr=0;const wr=A(()=>(br.value,kr));let xr=null;const Sr=A(()=>{if(!yt.value)return zn.value.length;const e=gt.value,n=Math.max(er.end+e,$t.value),t=Math.min(zn.value.length,n);return Math.max(At.value,t)});function Mr(){hr||(hr=!0,queueMicrotask(()=>{hr=!1,vr.value+=1}))}function Cr(e,n,t="node-resize"){if(!De||"undefined"==typeof window)return null;const o=window.setTimeout(()=>{mr.delete(o)&&Mr();try{n()}finally{du(t)}},Math.max(0,e));return mr.add(o),Mr(),o}function Nr(e){De&&null!=e&&(mr.delete(e)&&Mr(),window.clearTimeout(e))}function _r(){if(De&&"undefined"!=typeof window)for(const e of mr)window.clearTimeout(e);mr.size&&(mr.clear(),Mr()),ur.length=0,ar.clear()}function Tr(e){fe.value=e}function Br(e){ve.value=e}function Ir(e){he.value=e}const{cancelScheduledFocusSync:Hr,scheduleFocusSync:$r}=function(e){const{isClient:n,containerRef:t,virtualizationEnabled:o,requestFrame:l,cancelFrame:r,syncFocusToScroll:i}=e;let a=null;function u(){var e,n,o;return null!=(o=null==(n=null==(e=t.value)?void 0:e.ownerDocument)?void 0:n.defaultView)?o:"undefined"!=typeof window?window:null}function s(){if(!a)return;const e=u();a.viaTimeout?e?e.clearTimeout(a.id):clearTimeout(a.id):null==r||r(a.id),a=null}return{cancelScheduledFocusSync:s,scheduleFocusSync:function(e={}){if(!o.value)return;if(!n)return void i(!0);if(e.immediate)return s(),void i(!0);if(a)return;const t=()=>{a=null,i()};if(l)return void(a={id:l(t),viaTimeout:!1});const r=u(),d=r?r.setTimeout(t,16):setTimeout(t,16);a={id:d,viaTimeout:!0}}}}({isClient:De,containerRef:ce,virtualizationEnabled:yt,requestFrame:Nt,cancelFrame:_t,syncFocusToScroll:function(e=!1){var n;if(!yt.value)return;const t=wo.value||Je();if(!t)return;const o=t.ownerDocument||(null==(n=ce.value)?void 0:n.ownerDocument)||document,l=(null==o?void 0:o.defaultView)||("undefined"!=typeof window?window:null),r=t===(null==o?void 0:o.documentElement)||t===(null==o?void 0:o.body),i=zn.value.length;if(i<=0)return;if(!r&&i>0&&Qe(t)){const n=Hn("syncFocusToScroll.clientHeight",()=>t.clientHeight||0),o=Hn("syncFocusToScroll.scrollTop",()=>t.scrollTop),l=o<0?-o:o;return void Dr(Wr((a=Math.max(0,l)+.5*Math.max(0,n),Mo.estimateIndexForOffsetFromEnd(a)),0,Math.max(0,i-1)),e)}var a;const u=function(e,n,t,o){const l=ce.value;if(!l)return null;const r=o?0:Hn("syncFocusToScroll.model.root.getBoundingClientRect",()=>e.getBoundingClientRect().top),i=Hn("syncFocusToScroll.model.container.getBoundingClientRect",()=>l.getBoundingClientRect().top),a=Math.max(0,r-i),u=o?Hn("syncFocusToScroll.model.viewport.clientHeight",()=>{var o,l,r,i;return null!=(i=null!=(r=null!=(l=null==t?void 0:t.innerHeight)?l:null==(o=n.documentElement)?void 0:o.clientHeight)?r:e.clientHeight)?i:0}):Hn("syncFocusToScroll.model.root.clientHeight",()=>e.clientHeight);return Wr(Fo(a+.5*Math.max(0,u)),0,Math.max(0,zn.value.length-1))}(t,o,l,r);if(null!=u)return void Dr(u,e);const s=r?null:Hn("syncFocusToScroll.root.getBoundingClientRect",()=>t.getBoundingClientRect()),d=r?0:s.top,c=r?Hn("syncFocusToScroll.viewport.clientHeight",()=>{var e,n;return null!=(n=null!=(e=null==l?void 0:l.innerHeight)?e:t.clientHeight)?n:0}):s.bottom,f=ko.value;let m=null,v=null;for(const[h,p]of f){if(!p)continue;const e=Hn("syncFocusToScroll.slot.getBoundingClientRect",()=>p.getBoundingClientRect());e.bottom<=d||e.top>=c||(null==m&&(m=h),v=h)}if(null==m||null==v){const e=ce.value;if(!e)return;const n=r?{top:0}:Hn("syncFocusToScroll.fallback.root.getBoundingClientRect",()=>t.getBoundingClientRect()),i=Hn("syncFocusToScroll.fallback.scrollTop",()=>nn(t,o,r)),a=r?(()=>{const t=Hn("syncFocusToScroll.fallback.container.getBoundingClientRect",()=>e.getBoundingClientRect()),o=(r?0:n.top)-t.top;return Math.max(0,o)})():(()=>{const n=tn(e,t);return Math.max(0,i-n)})(),u=r?Hn("syncFocusToScroll.fallback.viewport.clientHeight",()=>{var e,n,r,i;return null!=(i=null!=(r=null!=(n=null==l?void 0:l.innerHeight)?n:null==(e=null==o?void 0:o.documentElement)?void 0:e.clientHeight)?r:t.clientHeight)?i:0}):Hn("syncFocusToScroll.fallback.root.clientHeight",()=>t.clientHeight);return void Dr(Wr(Fo(a+.5*Math.max(0,u)),0,Math.max(0,zn.value.length-1)),!0)}Dr(Math.round((m+v)/2),e)}}),{visibleNodeIndices:Rr,nodeVisibilityHandles:Pr,nodeVisibilityWatchStops:Fr,nodeVisibilityFallbackTimers:Ar,clearVisibilityFallback:Or,markNodeVisible:Kr,cleanupNodeVisibility:jr,destroyNodeVisibilityState:zr}=Ur({isClient:De,shouldTrackVisibleNodeIndices:()=>Bl.value,shouldCleanupNodeVisibility:()=>yt.value,onNodeMarkedVisible:e=>{yt.value?$r():Vl.value=Wr(e,0,Math.max(0,zn.value.length-1))},onNodeVisibilityCleaned:e=>{qt.delete(e)&&cu()}}),{cleanupScrollListener:Lr,setupScrollListener:Er}=Xr({isClient:De,virtualizationEnabled:yt,listenerEnabled:Dl,scrollRootElement:wo,resolveScrollContainer:Je,scheduleFocusSync:$r,onScroll:function(){const e=xo.value;if(!e)return;const n=na();if(!n)return;if(function(e){if(eu()>=To)return Io=null,!1;const n=Io;if(null==n)return!0;const t=Math.abs(e.scrollTop-n)<=2;return t||(Io=null),t}(n))return;const t=oa(n);null!=t?(t<-32||Math.abs(Math.max(0,t)-Math.max(0,e.distanceFromBottomPx))>32)&&wa("restore"):wa("restore")},requestFrame:Nt,cancelFrame:_t,getScrollTop:e=>{var n;const t=e.ownerDocument||(null==(n=ce.value)?void 0:n.ownerDocument)||document,o=e===t.documentElement||e===t.body||e===t.scrollingElement;return Hn("scrollListener.getScrollTop",()=>nn(e,t,o))}});function Dr(e,n=!1){const t=Wr(e,0,Math.max(0,zn.value.length-1));!n&&Math.abs(t-Vl.value)<=1||(Vl.value=t,nr())}function Wr(e,n,t){return Math.min(Math.max(e,n),t)}function Vr(e=zn.value.length){const n=Ln();return!Number.isInteger(n)||n<0?e:Wr(n,0,e)}function Gr(e){return null==e?void 0:e.firstElementChild}function ni(e,n){var t;return e?(null==(t=e.matches)?void 0:t.call(e,n))?e:e.querySelector(n):null}function ti(e,n){e<1||e>6||(pe[e]=n)}function fi(){if(!Rl.value||"undefined"==typeof ResizeObserver)return void(_e.value=0);const e=Hn("updateMeasuredContainerWidth.clientWidth",()=>{var e,n;return null!=(n=null==(e=ce.value)?void 0:e.clientWidth)?n:0});_e.value=e>0?e:0}let mi=null;function vi(){null==mi||mi.disconnect(),mi=null}const hi=A(()=>w.value?lo:ro);function pi(){var e;return!1!==(null==(e=W.codeBlockProps)?void 0:e.showHeader)}function gi(){var e;return!1!==(null==(e=W.codeBlockProps)?void 0:e.showCopyButton)}function yi(){var e,n;const t=null==(e=W.codeBlockProps)?void 0:e.showLineNumbers;return"boolean"==typeof t?t:!0!==(null==(n=W.codeBlockOptions)?void 0:n.disableLineNumbers)}function bi(e,n,t){var o;const l=Yo[n],r="number"==typeof l&&l>0;if(ft.value&&!r&&!function(e){return!!An.value.paragraph&&("paragraph"===e.type||"list_item"===e.type||"list"===e.type)}(e)){const n=Ol(e,t,Te.value);if(n)return n}if(Vt.value&&!r&&"code_block"===e.type){const n=function(e){if("code_block"!==e.type)return null;const n=ys(e,ms(e));return n===lo?"pre":n===hi.value||n===ro?"stream-diffs":null}(e);if("stream-diffs"===n||"pre"===n)return function(e,n){if(!e||"code_block"!==e.type)return null;const t=n.rendererKind,o="pre"!==t&&!1!==n.showHeader,l="pre"===t&&!1!==n.showHeader,r=Boolean(e.diff);let i=0,u=500;if("stream-diffs"===t){const t=zl(e,n.diffStyle),o=18,l=function(e){return e?0:16}(r);u=500,i=Math.round(t*o+l)}else{const t=no(n.codeBlockOptions),o=function(e,n,t){var o,l;const r=zl(e,n.diffStyle),i=Number(n.width);if("wrap"!==t.overflow||!Number.isFinite(i)||i<=0)return r;const a=Math.max(1,.6*t.fontSize),u=Boolean(e.diff),s=u&&jt({diffStyle:n.diffStyle});if(!u||s){const o=(u?jl(e.raw)||[jl(e.originalCode),jl(e.updatedCode)].filter(Boolean).join("\n"):jl(e.code,!0===e.loading)).split(/\r\n|\n|\r/),l=El(i,a,o.length,t,n,!1);return o.reduce((e,n)=>e+Ll(n,l,t.tabSize),0)}const d=jl(e.originalCode).split(/\r\n|\n|\r/),c=jl(e.updatedCode).split(/\r\n|\n|\r/);if(null==e.originalCode&&null==e.updatedCode)return r;const f=Math.max(d.length,c.length),m=El(i,a,f,t,n,!0);let v=0;for(let h=0;h<f;h++)v+=Math.max(Ll(null!=(o=d[h])?o:"",m,t.tabSize),Ll(null!=(l=c[h])?l:"",m,t.tabSize));return v}(e,n,t);i=Math.round(o*t.lineHeight+t.padding+t.paddingBottom),u=t.maxHeight}const s=Math.max(1,Math.min(i,u));return a({kind:"code-block",height:Math.round(s+("pre"===t?l?37:0:o?40:0)),contentHeight:s,rendererKind:t},r&&"stream-diffs"===t?{diffInline:jt({diffStyle:n.diffStyle})}:{})}(e,{rendererKind:n,codeBlockOptions:W.codeBlockOptions,showHeader:pi(),showLineNumbers:yi(),width:t,diffStyle:null==(o=W.codeBlockOptions)?void 0:o.diffStyle})}return null}ke(()=>{if(ho.value,go>0)return;const e=zn.value,n=En();if(!e.length||!Wt.value)return eo=[],oo=[],uo=-1,mo.clear(),void(co.value=Qt);const t=_e.value||Hn("estimatedNodeHeights.clientWidth",()=>{var e;return(null==(e=ce.value)?void 0:e.clientWidth)||0});if(!Number.isFinite(t)||t<=0)return eo=[],oo=[],uo=-1,mo.clear(),void(co.value=Qt);const o=function(e){var n,t;const o=no(W.codeBlockOptions);return[Math.round(e),ft.value,Vt.value,Te.value,o.fontSize,o.lineHeight,o.fontFamily,o.padding,o.paddingBottom,o.maxHeight,o.tabSize,o.overflow,null!=(t=null==(n=W.codeBlockOptions)?void 0:n.diffStyle)?t:"split",yi(),pi(),gi(),w.value,An.value,Hl.value]}(t),l=eo.length<=e.length&&(i=o,(r=oo).length===i.length&&r.every((e,n)=>Object.is(e,i[n])));var r,i;const a=l&&uo===n?e.length:l?Vr(e.length):0,u=l?Array.from(mo):[];eo.length=e.length;for(let s=a;s<e.length;s++)eo[s]=bi(e[s],s,t);for(const s of u)s>=0&&s<e.length&&s<a&&(eo[s]=bi(e[s],s,t));mo.clear(),oo=o,uo=n,co.value=eo,we(co)},{flush:"sync"});const ki=A(()=>co.value);Mo=function(e){let n=!0,t=-1;const o=[0];let l="",r=-1;const i=/* @__PURE__ */new WeakMap;function a(e=0){n=!0,e<=0?t=0:(t<0||e<t)&&(t=e)}function u(n){var t;const o=e.nodeHeights[n];if(Number.isFinite(o)&&o>0)return o;const l=e.parsedNodes.value[n],r=null==l?void 0:l.type,a=Boolean(null==(t=e.hasCustomParagraphComponent)?void 0:t.call(e)),u=e.estimatedNodeHeights.value[n],s=null==u?void 0:u.height;if(!function(e,n,t){return Boolean(t&&"simple-text"===(null==n?void 0:n.kind)&&("paragraph"===e||"list_item"===e||"list"===e))}(r,u,a)&&Number.isFinite(s)&&s>0)return s;const d=function(n,t){var o;if(!n||"object"!=typeof n||!1===(null==(o=e.shouldCacheStaticFallbackHeight)?void 0:o.call(e)))return sr(n,t);const l=n,r=i.get(l);if(r&&r.width===t)return r.height;const a=sr(n,t);return i.set(l,{width:t,height:a}),a}(l,e.getContainerWidth()||640);return"heading"===r||"paragraph"===r&&d<=28&&function(e,n){if(n)return!1;const t=e.children;return!Array.isArray(t)||!t.length||t.every(rr)}(l,a)?d:Math.max(e.averageNodeHeight.value,d)}function s(){var i;const s=e.parsedNodes.value.length,d=e.getPrefixCacheKeyParts().join(":"),c=o;l!==d&&(l=d,a(0));const f=e.averageNodeHeight.value;r!==f&&(r=f,a(0)),c.length>s+1&&(c.length=s+1,t>=0&&t>=c.length-1&&(n=!1));const m=c.length-1;if(!n){if(m===s)return c;t=m}const v=Math.min(t,m);c.length<s+1&&(c.length=s+1);for(let n=v;n<s;n++)c[n+1]=c[n]+(e.heightEstimationActive.value?u(n):null!=(i=e.nodeHeights[n])?i:f);return n=!1,t=s,c}function d(n){var t,o;const l=e.parsedNodes.value.length;if(l<=0)return 0;if(n<=0)return 0;const r=s();if(n>=(null!=(t=r[l])?t:0))return l-1;let i=0,a=l-1,u=l-1;for(;i<=a;){const e=i+a>>1;(null!=(o=r[e+1])?o:0)>=n?(u=e,a=e-1):i=e+1}return u}function c(n,t){var o,l;if(n>=t)return 0;if(e.heightEstimationActive.value)return function(n,t){var o,l;const r=e.parsedNodes.value.length,i=dr(Math.trunc(n),0,r),a=dr(Math.trunc(t),i,r);if(i>=a)return 0;const u=s();return(null!=(o=u[a])?o:0)-(null!=(l=u[i])?l:0)}(n,t);if(e.heightTreeSize.value!==e.parsedNodes.value.length){let l=0;for(let r=n;r<t;r++)l+=null!=(o=e.nodeHeights[r])?o:e.averageNodeHeight.value;return l}const r=e.heightSumTree.value,i=e.heightKnownTree.value;if(!r.length||!i.length){let o=0;for(let r=n;r<t;r++)o+=null!=(l=e.nodeHeights[r])?l:e.averageNodeHeight.value;return o}return e.fenwickRangeSum(r,n,t)+(t-n-e.fenwickRangeSum(i,n,t))*e.averageNodeHeight.value}function f(n){var t;if(n<=0)return 0;const o=e.parsedNodes.value;if(e.heightEstimationActive.value)return d(n);if(e.heightTreeSize.value===o.length&&e.heightSumTree.value.length&&e.heightKnownTree.value.length){const t=e.averageNodeHeight.value,l=e.heightSumTree.value,r=e.heightKnownTree.value,i=n=>n<=0?0:e.fenwickRangeSum(l,0,n)+(n-e.fenwickRangeSum(r,0,n))*t;let a=0,u=o.length-1,s=o.length-1;for(;a<=u;){const e=a+u>>1;i(e+1)>=n?(s=e,u=e-1):a=e+1}return s}let l=n;for(let r=0;r<o.length;r++){const n=null!=(t=e.nodeHeights[r])?t:e.averageNodeHeight.value;if(l<=n)return r;l-=n}return Math.max(0,o.length-1)}function m(){if(!e.heightEstimationActive.value)return 0;let n=0;const t=e.estimatedNodeHeights.value;for(let o=0;o<t.length;o++){if(!t[o])continue;const l=e.nodeHeights[o];Number.isFinite(l)&&l>0||n++}return n}return{markFallbackHeightPrefixDirty:a,getFallbackNodeHeight:u,estimateHeightRange:c,estimateIndexForOffset:f,estimateIndexForOffsetFromEnd:function(n){var t,o;const l=e.parsedNodes.value;if(!l.length)return 0;if(n<=0)return Math.max(0,l.length-1);if(e.heightEstimationActive.value){const e=null!=(t=s()[l.length])?t:0;return d(Math.max(0,e-n))}if(e.heightTreeSize.value===l.length){const e=c(0,l.length);return f(Math.max(0,e-n))}let r=n;for(let i=l.length-1;i>=0;i--){const n=null!=(o=e.nodeHeights[i])?o:e.averageNodeHeight.value;if(r<=n)return i;r-=n}return 0},getEstimatedNodeHeightCount:m,buildVirtualHeightSummary:function(n){var t;const o=e.parsedNodes.value.length;return{totalNodes:o,measuredCount:e.heightStats.count,estimatedCount:m(),averageNodeHeight:e.averageNodeHeight.value,topSpacerHeight:n.topSpacerHeight,bottomSpacerHeight:n.bottomSpacerHeight,estimatedTotalHeight:c(0,o),width:null!=(t=n.width)?t:e.getContainerWidth()}}}}({parsedNodes:zn,nodeHeights:Yo,heightStats:Zo,heightTreeSize:Jo,heightSumTree:Qo,heightKnownTree:el,averageNodeHeight:nl,heightEstimationActive:st,estimatedNodeHeights:ki,getContainerWidth:mt,shouldCacheStaticFallbackHeight:()=>{var e;return!(null==(e=o.nodes)?void 0:e.length)},hasCustomParagraphComponent:()=>Boolean(An.value.paragraph),getPrefixCacheKeyParts:()=>{var e;const n=or(_e.value||Hn("getFallbackHeightPrefix.clientWidth",()=>{var e;return(null==(e=ce.value)?void 0:e.clientWidth)||0}));return[null==(null==(e=o.virtualScroll)?void 0:e.measurementKey)?"":String(o.virtualScroll.measurementKey),n,st.value?1:0,Hl.value,An.value.paragraph?1:0]},fenwickRangeSum:vl}),Ne=!0,X(()=>zn.value.length,(e,n)=>{var t;$o(null!=n&&e>=n?Vr(e):0),e<=0?wl():(e<Jo.value&&(t=e,bl(),gl(()=>rl(t))),ul(e))},{immediate:!0});const wi=A(()=>{if(!yt.value)return zn.value.map((e,n)=>({node:e,index:n}));const e=zn.value.length,n=Wr(er.start,0,e),t=Wr(er.end,n,e);return zn.value.slice(n,t).map((e,t)=>({node:e,index:n+t}))}),Si=A(()=>yt.value?Po(0,Math.min(er.start,zn.value.length)):0),Mi=A(()=>{if(!yt.value)return 0;const e=zn.value.length;return Po(Math.min(er.end,e),e)});function Ci(){return Mo.buildVirtualHeightSummary({topSpacerHeight:Si.value,bottomSpacerHeight:Mi.value,width:Pi()})}function Ni(){const e=zn.value,n=Ci();return u(a({},n),{probe:{paragraphReady:Boolean(Te.value.paragraph),listItemReady:Boolean(Te.value.listItem),listWrapperOverhead:Te.value.listWrapperOverhead,headingReadyLevels:Object.entries(Te.value.headings).filter(([,e])=>Boolean(e)).map(([e])=>Number(e))},nodes:e.map((e,n)=>{var t,o,l,r,i,a,u,s,d;return{index:n,type:e.type,estimateKind:null!=(o=null==(t=ki.value[n])?void 0:t.kind)?o:null,rendererKind:null!=(r=null==(l=ki.value[n])?void 0:l.rendererKind)?r:null,estimatedHeight:null!=(a=null==(i=ki.value[n])?void 0:i.height)?a:null,estimatedContentHeight:null!=(s=null==(u=ki.value[n])?void 0:u.contentHeight)?s:null,measuredHeight:null!=(d=Yo[n])?d:null}})})}function _i(){return null!=o.indexKey?String(o.indexKey):nt.value?`virtual-${Bi()}`:"markdown-renderer"}function Ti(e){const n=String(e),t=`${_i()}-`;if(!n.startsWith(t))return null;const o=n.slice(t.length).match(/^(\d+)(?:$|-)/);if(!o)return null;const l=Number(o[1]);return!Number.isInteger(l)||l<0||l>=zn.value.length?null:l}function Bi(){var e,n,t;const l=null==(e=o.virtualScroll)?void 0:e.sessionKey;return String(null!=l&&""!==l?l:null!=(t=null!=(n=o.indexKey)?n:W.customId)?t:$n)}function Ii(){var e;const n=null==(e=o.virtualScroll)?void 0:e.threadKey;return null==n||""===n?void 0:String(n)}const Hi=A(()=>{var e,n,t;return null!=(t=Ii())?t:String(null!=(n=null!=(e=o.indexKey)?e:W.customId)?n:$n)});function $i(e){var n;return(null!=e?e:"")===(null!=(n=Ii())?n:"")}function Ri(){var e,n,t;return n=null==(e=o.virtualScroll)?void 0:e.measurementKey,t=function(e){const n=e.codeBlockProps,t=e.codeBlockOptions,o=null==t?void 0:t.parseDiffOptions;return[e.isDark?"dark":"light",e.renderCodeBlocksAsPre?"code-pre":"code-rich",!1===e.codeBlockStream?"code-static":"code-stream",ui(e.codeBlockMinWidth),ui(e.codeBlockMaxWidth),ui(null==t?void 0:t.fontSize),ui(null==t?void 0:t.lineHeight),ui(null==t?void 0:t.fontFamily),ui(null==t?void 0:t.maxHeight),ui(null==t?void 0:t.tabSize),ui(null==t?void 0:t.padding),ui(null==t?void 0:t.overflow),ui(null==t?void 0:t.disableLineNumbers),ui(null==t?void 0:t.diffStyle),ui(null==t?void 0:t.diffIndicators),ui(null==t?void 0:t.hunkSeparators),ui(null==t?void 0:t.expandUnchanged),ui(null==t?void 0:t.collapsedContextThreshold),ui(null==t?void 0:t.expansionLineCount),ui(null==o?void 0:o.context),ui(null==n?void 0:n.showHeader),ui(null==n?void 0:n.showCopyButton),ui(null==n?void 0:n.showExpandButton),ui(null==n?void 0:n.showPreviewButton),ui(null==n?void 0:n.showCollapseButton),ui(null==n?void 0:n.showFontSizeButtons),ui(null==n?void 0:n.showLineNumbers)].join("\0")}({renderCodeBlocksAsPre:w.value,isDark:W.isDark,codeBlockStream:W.codeBlockStream,codeBlockMinWidth:W.codeBlockMinWidth,codeBlockMaxWidth:W.codeBlockMaxWidth,codeBlockOptions:W.codeBlockOptions,codeBlockProps:W.codeBlockProps}),[null==n?"":String(n),t].join("\0")}function Pi(){return mt()}const Fi=A(()=>or(Pi())),Ai=A(()=>[Ri(),Fi.value].join("\0")),Oi=A(()=>{var e;return nt.value?["virtual",null!=(e=Ii())?e:"",Bi(),Ai.value].join("\0"):o.indexKey});function Ki(){br.value+=1}function ji(e){return!(!e||!Number.isInteger(e.index)||e.index<0||e.index>=zn.value.length||e.sessionKey!==Bi()||e.threadKey!==Ii()||e.layoutEpochKey!==Ai.value)}function zi(e){const n=String(e),t=yr.get(n);return t?ji(t)?t.index:null:Ti(n)}function Li(e="async-node"){(gr.size||yr.size)&&(kr=0,gr.clear(),yr.clear(),Ki(),du(e))}const Ei=F(Ce,null),Di={reportHeight(e,n){if(!lt.value)return;const t=zi(e);if(null==t)return;const o=tr.get(t);if(!o)return;const l=Number(n),r=_l(t,o);!function(e,n,t={}){gl(()=>Cl(e,n,t))}(t,Number.isFinite(l)&&l>0?Math.max(l,r||0):r)},markPending(e){if(!lt.value)return;const n=Ti(e);null!=n&&function(e,n){var t;const o=yr.get(e);if(o&&ji(o))return gr.set(e,Math.max(0,null!=(t=gr.get(e))?t:0)+1),kr+=1,Ki(),void du("async-node");gr.set(e,1),kr+=1,yr.set(e,function(e){return{index:e,sessionKey:Bi(),threadKey:Ii(),layoutEpochKey:Ai.value}}(n)),Ki(),du("async-node")}(String(e),n)},markSettled(e){if(!lt.value)return;const n=String(e),t=zi(e);if((null!=t||function(e){return gr.has(String(e))}(n))&&function(e){var n;const t=null!=(n=gr.get(e))?n:0;return!(t<=0||(t<=1?(gr.delete(e),yr.delete(e)):gr.set(e,t-1),kr=Math.max(0,kr-1),Ki(),1===t&&du("async-node"),0))}(n)&&null!=t){const e=tr.get(t);e&&yu(t,e)}}};function Wi(e){if(void 0!==e)return e;let n=0;for(const t of tr.values())n+=Hn("getVisibleDomHeight.offsetHeight",()=>t.offsetHeight);return n}ee(Ce,{reportHeight(e,n){Di.reportHeight(e,n),null==Ei||Ei.reportHeight(e,n)},markPending(e){Di.markPending(e),null==Ei||Ei.markPending(e)},markSettled(e){Di.markSettled(e),null==Ei||Ei.markSettled(e)}});let Vi,qi=null,Ui=null;function Xi(e){return!1!==e&&null!=e&&""!==e}function Yi(){return yt.value?function(){if(!yt.value)return!0;const e=zn.value.length,n=Wr(er.start,0,e),t=Wr(er.end,n,e);if(n>=t)return!0;for(let o=n;o<t;o++){if(!qt.has(o))return!1;if(fu(o)&&!tr.has(o))return!1}return!0}():At.value>=Sr.value}function Zi(){return!0===an.value&&!cn.value&&0===wr.value&&0===mr.size&&0===cr.size&&null==xr&&Yi()}function Gi(){var e,n;if("manual"!==(null==(e=o.virtualScroll)?void 0:e.settleMode))return!0;if(qi===Bi()&&Vi===Ii())return!0;const t=null==(n=o.virtualScroll)?void 0:n.settledToken;return!!Xi(t)&&Ui===Pu(t)}function Ji(){return Zi()&&Gi()}function Qi(e,n){return n.totalNodes<=0?"final"===e?"final":"estimate":n.measuredCount>=n.totalNodes?"final"===e?"final":"measured":n.measuredCount>0||n.estimatedCount>0?"mixed":"estimate"}function ea(e="manual",n,t){const o=Ci(),l=function(e){return e||(!0!==an.value?zn.value.length>0?"streaming":"estimating":!Yi()||cr.size>0||null!=xr?"measuring":Ji()?"settled":"settling")}(n);return{sessionKey:Bi(),threadKey:Ii(),phase:l,nodeCount:o.totalNodes,liveRange:{start:er.start,end:er.end},renderedCount:At.value,measuredCount:o.measuredCount,estimatedCount:o.estimatedCount,averageNodeHeight:o.averageNodeHeight,topSpacerHeight:o.topSpacerHeight,bottomSpacerHeight:o.bottomSpacerHeight,visibleDomHeight:Wi(t),totalHeight:ta(o),width:o.width,final:!0===an.value,stable:Ji(),confidence:Qi(l,o),reason:e}}function na(){const e=wo.value||Je(),n=ce.value;if(!e||!n)return null;const t=e.ownerDocument||n.ownerDocument||document,o=e===t.documentElement||e===t.body||e===t.scrollingElement,l=Hn("getScrollBox.scrollTop",()=>nn(e,t,o)),r=Hn("getScrollBox.scrollHeight",()=>{var n,l,r,i,a;return o?Math.max(null!=(l=null==(n=t.documentElement)?void 0:n.scrollHeight)?l:0,null!=(i=null==(r=t.body)?void 0:r.scrollHeight)?i:0,null!=(a=e.scrollHeight)?a:0):e.scrollHeight}),i=Hn("getScrollBox.clientHeight",()=>{var n;return o?(null==(n=t.documentElement)?void 0:n.clientHeight)||e.clientHeight||0:e.clientHeight});return{root:e,doc:t,isViewportRoot:o,scrollTop:l,scrollHeight:r,clientHeight:i}}function ta(e){var n;const t=zn.value.length,o=Math.max(0,Po(0,t)),l=Hn("getRendererLogicalHeight.offsetHeight",()=>{var e,n;return null!=(n=null==(e=ce.value)?void 0:e.offsetHeight)?n:0}),r=Math.max(0,l>0?l:Hn("getRendererLogicalHeight.scrollHeight",()=>{var e,n;return null!=(n=null==(e=ce.value)?void 0:e.scrollHeight)?n:0}));return t<=0?Math.ceil(l):yt.value?o>0?Math.max(1,Math.ceil(o),function(){let e=Si.value+Mi.value;for(const n of qt.values())n&&(e+=Math.max(0,Hn("getVirtualizedDomLogicalHeight.offsetHeight",()=>n.offsetHeight||0)));return Math.ceil(Math.max(0,e))}(),function(e,n){return e<=0||n<=0?0:n<=e+Math.max(512,.05*e)?Math.ceil(n):0}(o,r)):Math.max(1,Math.ceil(r)):lt.value?o>0||Zo.count>0||(null!=(n=null==e?void 0:e.estimatedCount)?n:Mo.getEstimatedNodeHeightCount())>0?(Pt.value&&At.value,Math.max(1,Math.ceil(r),Math.ceil(o))):Math.ceil(r):Math.max(1,Math.ceil(r),Math.ceil(o))}function oa(e){const n=ce.value;if(!n)return null;const t=Hn("getRendererBottomDistanceFromViewport.getBoundingClientRect",()=>n.getBoundingClientRect()),o=function(e){return e.isViewportRoot?e.clientHeight:Hn("getViewportBottomInRoot.getBoundingClientRect",()=>e.root.getBoundingClientRect().bottom)}(e);return o-t.bottom}function la(e={}){const n=!1!==e.requireViewport,t=function(e=64){const n=na(),t=ce.value;if(!n||!t)return!1;const o=function(e){if(e.isViewportRoot)return{top:0,bottom:e.clientHeight};const n=Hn("getVirtualViewportRect.getBoundingClientRect",()=>e.root.getBoundingClientRect());return{top:n.top,bottom:n.bottom}}(n),l=Hn("isRendererNearVirtualViewport.getBoundingClientRect",()=>t.getBoundingClientRect());return l.bottom>=o.top-e&&l.top<=o.bottom+e}();if(n&&!t)return null;const o=function(){const e=na(),n=ce.value;if(!e||!n)return null;if(Math.max(0,e.scrollHeight-e.scrollTop-e.clientHeight)>64)return null;const t=oa(e);return null==t?null:t>=-8&&t<=160?{type:"bottom",distanceFromBottomPx:Math.max(0,t)}:null}();if(o)return{anchor:o,captured:!0};const l=Wo();if(l)return{anchor:{type:"node",nodeIndex:l.nodeIndex,offsetWithinNodePx:l.offsetWithinNodePx},captured:t};if(!0===e.allowFallback){const e=function(){const e=zn.value.length;return e<=0?null:{type:"node",nodeIndex:Wr(Vl.value,0,Math.max(0,e-1)),offsetWithinNodePx:0}}();return e?{anchor:e,captured:!1}:null}return null}function ra(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function ia(e,n){let t=e;for(let o=0;o<n.length;o++)t^=n.charCodeAt(o),t=Math.imul(t,16777619);return t^=31,t=Math.imul(t,16777619),t}const aa=/* @__PURE__ */new Set(["children","items","header","rows","cells","attrs","data","term","definition"]);function ua(e,n=/* @__PURE__ */new WeakSet,t=0){if(null==e||"number"==typeof e||"boolean"==typeof e)return String(e);if("string"==typeof e)return`s:${function(e){const n=e.length>8192?`${e.slice(0,8192)}...${e.length}`:e;return`${e.length}:${ra(n)}`}(e)}`;if("function"==typeof e)return"fn";if("object"!=typeof e)return typeof e;if(n.has(e))return"cycle";if(t>=6)return"max-depth";n.add(e);try{if(Array.isArray(e)){if(e.length<=160){const o=[];for(let l=0;l<e.length;l++)o.push(ua(e[l],n,t+1));return`a:${e.length}:${o.join(",")}`}const o=[],l=[],r=Math.max(0,e.length-32);let i=2166136261;for(let a=0;a<e.length;a++){const u=ua(e[a],n,t+1);i=ia(i,u),a<32&&o.push(u),a>=r&&l.push(u)}return[`a:${e.length}`,`h=${o.join(",")}`,`t=${l.join(",")}`,`all=${(i>>>0).toString(36)}`].join(":")}const o=e,l=Object.keys(o).filter(e=>{const n=o[e];return"parent"!==e&&"el"!==e&&"component"!==e&&(null==n||"string"==typeof n||"number"==typeof n||"boolean"==typeof n||aa.has(e))}).sort();return`o:${l.length}:${l.map(e=>`${e}=${ua(o[e],n,t+1)}`).join(";")}`}finally{n.delete(e)}}let sa=-1;const da=/* @__PURE__ */new Map;let ca=-1,fa="",ma=[2166136261];function va(e){var n;const t=zn.value[e],l=En();if(sa!==l&&(sa=l,da.clear()),!t)return"";if((null==(n=o.nodes)?void 0:n.length)||W.parseOptions||W.customMarkdownIt||Kn.value.__markstreamHasCustomParserExtensions||0!==Object.keys(An.value).length)return ra(ua(t));const r=da.get(e);if(void 0!==r)return r;const i=ra(ua(t));return da.set(e,i),i}function ha(e,n){let t=e;for(let o=0;o<n.length;o++)t^=n.charCodeAt(o),t=Math.imul(t,16777619);return t>>>0}function pa(){var e,n;const t=Me.value;if(ca===t)return fa;const o=zn.value.length;let l=Vr(o);(ca!==t-1||l>o||ma.length<l+1)&&(l=0),0===l?ma=[2166136261]:ma.length=l+1;for(let r=l;r<o;r++){const n=va(r);ma[r+1]=ha(null!=(e=ma[r])?e:2166136261,n)}return ma.length=o+1,fa=((null!=(n=ma[o])?n:2166136261)>>>0).toString(36),ca=t,fa}function ga(e,n={}){var t;const l=!0===n.includeHeightCache,r=null!=(t=n.includeContentHash)?t:l,i=l?function(e){const n=function(){var e,n;const t=Number(null!=(n=null==(e=o.virtualScroll)?void 0:e.heightCacheLimit)?n:5e3);return!Number.isFinite(t)||t<=0?Number.POSITIVE_INFINITY:Math.max(1,Math.trunc(t))}();if(!Number.isFinite(n)||e.length<=n)return e;const t=/* @__PURE__ */new Map,l=e=>{!e||t.size>=n||t.set(e.index,e)},r=zn.value.length,i=Wr(er.start-2*gt.value,0,r),a=Wr(er.end+2*gt.value,i,r);for(const o of e)o.index>=i&&o.index<a&&l(o);const u=Math.max(1,Math.ceil(e.length/n));for(let o=0;o<e.length&&t.size<n;o+=u)l(e[o]);for(let o=e.length-1;o>=0&&t.size<n;o-=u)l(e[o]);return Array.from(t.values()).sort((e,n)=>e.index-n.index).slice(0,n)}(fl().map(e=>{var n;const t=zn.value[e.index];return t?u(a({},e),{nodeType:String(null!=(n=t.type)?n:""),signature:va(e.index)}):null}).filter(e=>Boolean(e))):[],s=la({allowFallback:!0===n.allowAnchorFallback,requireViewport:n.requireViewport});return s||i.length||!0===n.includeEmptyState?u(a({sessionKey:e.sessionKey,threadKey:e.threadKey},s?{anchor:s.anchor,anchorCaptured:s.captured}:{anchorCaptured:!1}),{metrics:e,width:e.width,contentHash:r?pa():void 0,measurementKey:Ri()||void 0,heightCache:i.length?i:void 0}):null}function ya(e){var n,t;const o=na();if(!o)return;const l=function(e){const n=ce.value;if(!n)return null;const t=tn(n,e.root),o=zn.value.length,l=Hn("getRendererBottomOffsetWithinRoot.offsetHeight",()=>n.offsetHeight||0),r=Math.max(0,l>0?l:o>0?Hn("getRendererBottomOffsetWithinRoot.scrollHeight",()=>n.scrollHeight||0):0),i=ta();return t+Math.max(r,i)}(o);if(null==l)return;const r=Math.max(0,e.distanceFromBottomPx),i=Math.max(0,l-o.clientHeight-r);(function(e){To=eu()+120,Io=e})(i),o.isViewportRoot?null==(t=null==(n=o.doc.defaultView)?void 0:n.scrollTo)||t.call(n,0,i):Yl(o.root,o.doc,i,{isReverseFlexScrollRoot:Qe,getNormalizedScrollTop:nn})}const ba=[];function ka(){if(De)for(null!=No&&(null==_t||_t(No),No=null);ba.length;){const e=ba.pop();null!=e&&window.clearTimeout(e)}}function wa(e){const n=Boolean(xo.value);xo.value=null,To=0,Io=null,ka(),n&&e&&du(e)}function xa(){if(!xo.value||!De)return;if(null!=No)return;const e=()=>{No=null;const e=xo.value;e&&ya(e)};No=Nt?Nt(e):null,null==No&&e()}function Sa(e,n={}){const t=zn.value.length;return t<=0?[]:e.filter(e=>!(!Number.isInteger(e.index)||e.index<0||e.index>=t)&&!(!Number.isFinite(e.height)||e.height<=0)&&!(n.requireSignature&&!e.signature)&&!(n.requireCompatibilityMetadata&&!e.nodeType&&!e.signature)&&function(e){var n;const t=zn.value[e.index];return!(!t||e.nodeType&&e.nodeType!==String(null!=(n=t.type)?n:"")||e.signature&&e.signature!==va(e.index))}(e))}function Ma(e){const n=or(Pi()),t=or(e);return-1!==n&&-1!==t&&n===t}function Ca(e){var n;const t=Number(null==e?void 0:e.width);if(Number.isFinite(t)&&t>0)return t;const o=Number(null==(n=null==e?void 0:e.metrics)?void 0:n.width);return Number.isFinite(o)&&o>0?o:null}function Na(e){var n;return e.sessionKey===Bi()&&!!$i(e.threadKey)&&(null!=(n=e.measurementKey)?n:"")===Ri()&&!!Ma(Ca(e))&&!!function(e){const n=e.heightCache;return!!(null==n?void 0:n.length)&&(_a(e)?n.some(e=>Boolean(e.nodeType||e.signature)):n.some(e=>Boolean(e.signature)))}(e)}function _a(e){return Boolean(e.contentHash&&e.contentHash===pa())}function Ta(e){return!_a(e)}let Ba=null,Ia=null,Ha=null,$a=null,Ra=null,Pa=!1;function Fa(e){var n;const t=e.map(e=>{var n,t;return[e.index,Math.round(10*e.height),null!=(n=e.nodeType)?n:"",null!=(t=e.signature)?t:""].join("")}).join(""),o=or(Pi());return[null!=(n=Ii())?n:"",Bi(),Ri(),zn.value.length,o,e.length,ra(t)].join(":")}function Aa(e=(e=>null==(e=o.virtualScroll)?void 0:e.heightCache)()){if(!lt.value||!(null==e?void 0:e.length))return!1;if(zn.value.length<=0)return!1;if(!Ma(null==(n=o.virtualScroll)?void 0:n.heightCacheWidth))return!1;var n;const t=Sa(e,{requireSignature:!0});if(!t.length)return!Pa&&"undefined"!=typeof console&&p&&(Pa=!0,console.warn("[markstream-vue] virtualScroll.heightCache ignored: standalone heightCache entries must include compatible signature metadata. Use heightCache exported from virtual-state-change/render-settled, and pass heightCacheWidth from the same state.")),!1;const l=Fa(t);return l===Ba?(Ia="standalone",!0):(Tl(t,{mode:"merge"}),$o(),Ba=l,Ia="standalone",lu(),du("restore"),!0)}function Oa(){var e;const n=null==(e=o.virtualScroll)?void 0:e.restoreAnchor;return null==n||!1===n?null:!0===n?"true":String(n)}function Ka(e,n={}){var t,o,l;if(!lt.value||!e)return!1;if(e.sessionKey!==Bi())return!1;if(!$i(e.threadKey))return!1;if(zn.value.length<=0)return!1;const r=Boolean(null==(t=e.heightCache)?void 0:t.length)&&!ja(),i=!e.anchor||!1===e.anchorCaptured&&!0!==n.allowUncapturedAnchor?null:e.anchor,a=!0===n.restoreAnchor&&Boolean(i)&&!ja()&&Number(Ca(e))>0;let u=!1;if((null==(o=e.heightCache)?void 0:o.length)&&Na(e)){const n=Sa(e.heightCache,{requireCompatibilityMetadata:!e.contentHash,requireSignature:Ta(e)});n.length&&(Tl(n,{mode:"merge"}),$o(),Ba=Fa(n),Ia="restore",lu(),u=!0)}if(r||a)return!1;if(!n.restoreAnchor)return u&&du("restore"),!0;if(!i)return u&&du("restore"),!0;const s=function(e,n){var t;const o=e.anchor,l=o?"bottom"===o.type?`bottom:${Math.round(o.distanceFromBottomPx)}`:`node:${o.nodeIndex}:${Math.round(o.offsetWithinNodePx)}`:"none";return[null!=(t=Ii())?t:"",Bi(),Ri(),Fi.value,n,l].join(":")}(e,null!=(l=n.restoreToken)?l:"imperative");return Ha===s?(u&&du("restore"),!0):(Ha=s,function(e){const n=()=>{if("node"===e.type)return wa(),void qo({nodeIndex:e.nodeIndex,offsetWithinNodePx:e.offsetWithinNodePx});if(Lo(),Ao.value=null,xo.value=e,ka(),ya(e),De)for(const e of[0,120,280,480])ba.push(window.setTimeout(()=>{const e=xo.value;e&&ya(e)},e))};!function(e){if(!yt.value)return!1;const n=zn.value.length;return!(n<=0||(Vl.value="node"===e.type?Wr(e.nodeIndex,0,n-1):n-1,nr(),0))}(e)?n():oe(n)}(i),du("restore"),!0)}function ja(){const e=Pi();return Number.isFinite(e)&&e>0}function za(e){var n;return e.sessionKey===Bi()&&!!$i(e.threadKey)&&(zn.value.length<=0||!(!(null==(n=e.heightCache)?void 0:n.length)||ja())||!(!(e.anchor&&Number(Ca(e))>0)||ja()))}function La(){Jt.length=0;for(const e of Object.keys(Yo)){const n=Number(e);Number.isInteger(n)&&n>=0&&n<zn.value.length&&Ml(n)}}function Ea(){null!=xr&&(null==_t||_t(xr),xr=null),hu()}function Da(){return!De||Bt?Promise.resolve():new Promise(e=>{let n=!1,t=null;const o=()=>{n||(n=!0,null!=t&&window.clearTimeout(t),e())};if(Nt)return Nt(o),void(t=window.setTimeout(o,50));t=window.setTimeout(o,0)})}function Wa(e,n=Ii(),t=Ai.value){return Bi()===e&&Ii()===n&&Ai.value===t}function Va(){return s(this,arguments,function*(e={}){var n,t,l,r,i;const s=Bi(),d=Ii(),c=Ai.value,f=null!=(n=e.frames)?n:2,m=null!=(t=e.timeoutMs)?t:120,v=null!=(l=e.reason)?l:"manual",h=e.expectedSettledTokenKey,p=!0===e.flushPendingTimers,g=ea(v),y=()=>u(a({},g),{phase:g.final?"settling":g.phase,stable:!1,confidence:"final"===g.confidence?"mixed":g.confidence,reason:v}),b=()=>Wa(s,d,c)&&(null==h||tu()===h);for(let o=0;o<f;o++){if(yield oe(),!b())return y();if(yield Da(),!b())return y();bu(),Ea()}if(yield function(e){return!De||e<=0?Promise.resolve():new Promise(n=>window.setTimeout(n,e))}(m),!b())return y();if(p&&_r(),bu(),Ea(),!b())return y();const k=Zi();k&&(qi=s,Vi=d,"manual"===(null==(r=o.virtualScroll)?void 0:r.settleMode)&&null!=h&&Xi(null==(i=o.virtualScroll)?void 0:i.settledToken)&&tu()===h&&(Ui=Pu(o.virtualScroll.settledToken)));const w=b()&&k&&Gi(),x=ea(v,w?"final":void 0);return au(x,!0),x})}let qa="content",Ua=null,Xa=null,Ya=0,Za=null,Ga=null,Ja=null,Qa=null;function eu(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function nu(e){var n,t;const l=Za;if(!l)return!0;const r=null!=(t=null==(n=o.virtualScroll)?void 0:n.heightDiffThresholdPx)?t:1;return Math.abs(e.totalHeight-l.totalHeight)>r||e.sessionKey!==l.sessionKey||e.phase!==l.phase||e.stable!==l.stable||e.final!==l.final||e.threadKey!==l.threadKey||e.nodeCount!==l.nodeCount||e.measuredCount!==l.measuredCount||e.width!==l.width}function tu(e=(e=>null==(e=o.virtualScroll)?void 0:e.settledToken)()){return ui(e)}function ou(e,n){var t,l;return[e,n.sessionKey,null!=(t=n.threadKey)?t:"",Ri(),pa(),ui(null==(l=o.virtualScroll)?void 0:l.settledToken),Math.round(n.totalHeight),Math.round(n.width)].join("\0")}function lu(){Ja=null,Qa=null,Ga=null}function ru(e){const n=e.heightCache;return(null==n?void 0:n.length)?Fa(n):""}function iu(e){var n,t,o;const l=e.metrics,r=e.anchor?"bottom"===(i=e.anchor).type?`bottom:${Math.round(i.distanceFromBottomPx)}`:`node:${i.nodeIndex}:${Math.round(i.offsetWithinNodePx)}`:"none";var i;return[e.sessionKey,null!=(n=e.threadKey)?n:"",null!=(t=e.measurementKey)?t:Ri(),null!=(o=e.contentHash)?o:"",ru(e),r,e.anchorCaptured?1:0,l.liveRange.start,l.liveRange.end,l.renderedCount,l.nodeCount,Math.round(l.totalHeight),Math.round(l.width),l.phase,l.stable?1:0].join("\0")}function au(e,n=!1){if(!lt.value)return;if(function(e=!1){return!e&&nt.value&&!at.value}(n))return;const t=n||nu(e),o=function(e,n=!1){return n||e.stable||"final"===e.phase?{state:ga(e,{includeHeightCache:!0})}:{state:ga(e)}}(e,n),r=o.state,i=Boolean(r&&(t||function(e,n=!1){return!!n||iu(e)!==Ga}(r,n)));if(t&&(Z(e),Za=e,Ya=eu()),r&&i&&(te(r),r.anchor&&de(r.anchor),Ga=iu(r)),e.stable){const n=ou("settled",e);if(n!==Ja){Ja=n;const t=ga(e,{includeHeightCache:!0});t&&(te(t),Ga=iu(t)),function(e){l("render-settled",e)}(e)}}if("final"===e.phase){const n=ou("final",e);if(n!==Qa){Qa=n;const t=ga(e,{includeHeightCache:!0});t&&(te(t),Ga=iu(t)),function(e){l("render-final",e)}(e)}}}function uu(){null!=Ua&&(null==_t||_t(Ua),Ua=null),null!=Xa&&De&&(window.clearTimeout(Xa),Xa=null)}function su(){Ua=null,Xa=null;const e=eu();let n;e-fr>=120&&(fr=e,n=bu()),(cr.size>8||null==xr)&&Ea(),au(ea(qa,void 0,n))}function du(e){var n,t;if(!lt.value)return;if(qa=e,null!=Ua||null!=Xa)return;const l=Math.max(0,null!=(t=null==(n=o.virtualScroll)?void 0:n.emitIntervalMs)?t:32),r=Math.max(0,l-(eu()-Ya)),i=()=>{Xa=null,Ua=Nt?Nt(su):null,null==Ua&&su()};De&&r>0?Xa=window.setTimeout(i,r):i()}function cu(){bo.value+=1}function fu(e){var n;if(Pt.value&&e>=At.value){const n=zn.value[e],t=!0===rn.value&&!0!==an.value&&e>=zn.value.length-2,o="code_block"===(null==n?void 0:n.type)||"image"===(null==n?void 0:n.type)||"mermaid"===(null==n?void 0:n.type)||"infographic"===(null==n?void 0:n.type);if(!t||o)return!1}return!Bl.value||e<$t.value||!!(cn.value&&!0!==an.value&&!(null==(n=o.nodes)?void 0:n.length)&&e>=zn.value.length-gt.value)||Rr.value.has(e)}function mu(e){const n=Fr.get(e);n&&(n(),Fr.delete(e));const t=Pr.get(e);t&&(t.destroy(),Pr.delete(e)),Or(e)}function vu(e,n){let t=!1;if(n){const o=qt.get(e);if(o===n&&Ut.get(e)===Kl.value)return;qt.set(e,n),o!==n&&(t=!0)}else qt.delete(e)&&(t=!0);if(t&&cu(),n||Or(e),!Al.value||!Ct)return mu(e),n?Ut.set(e,Kl.value):Ut.delete(e),void(n&&Bl.value&&Kr(e,!0));if(!yt.value&&Bl.value&&!ye.value&&Pr.size>=Re.value&&(ye.value||(ye.value=!0,p&&"undefined"!=typeof console&&console.warn("[markstream-vue] viewportPriority auto-disabled:","too-many-targets"),zr()),!Al.value||!Ct))return mu(e),Ut.set(e,Kl.value),void(n&&Kr(e,!0));if(e<$t.value&&!yt.value)return mu(e),Ut.set(e,Kl.value),void Kr(e,!0);if(Rr.value.has(e))return mu(e),Ut.set(e,Kl.value),void Kr(e,!0);if(!n)return mu(e),void Ut.delete(e);mu(e);const o=Ct(n,{rootMargin:$e.value});if(!o)return void Ut.delete(e);Pr.set(e,o),Ut.set(e,Kl.value),Kr(e,o.isVisible.value),Bl.value&&function(e){if(!De||!Bl.value)return;Or(e);const n=e%17*23,t=window.setTimeout(()=>{if(Ar.delete(e),!Bl.value)return;if(Rr.value.has(e))return;const n=qt.get(e);if(!n)return;const t=Je(n),o=n.ownerDocument||document,l=o.defaultView||window,r=!t||t===o.documentElement||t===o.body,i=!r&&t?Hn("nodeVisibilityFallback.root.getBoundingClientRect",()=>t.getBoundingClientRect()):null,a=r?0:i.top,u=r?Hn("nodeVisibilityFallback.clientHeight",()=>{var e,n;return null!=(n=null!=(e=l.innerHeight)?e:null==t?void 0:t.clientHeight)?n:0}):i.bottom,s=Hn("nodeVisibilityFallback.node.getBoundingClientRect",()=>n.getBoundingClientRect());s.bottom>=a-500&&s.top<=u+500&&Kr(e,!0)},1800+n);Ar.set(e,t)}(e);let l=null;l=X(()=>o.isVisible.value,n=>{if(n){Or(e),Kr(e,!0),null==l||l(),Fr.delete(e),Pr.get(e)===o&&Pr.delete(e);try{o.destroy()}catch(t){}}},{immediate:!0}),Fr.set(e,l),yt.value&&$r()}function hu(){xr=null,gl(()=>{let e=!1;for(const[n,t]of cr)cr.delete(n),tr.get(n)===t.el&&lr.get(n)===t.version&&(e=Cl(n,t.height,{allowShrink:t.allowShrink})||e);return e})}function pu(){null!=xr&&(null==_t||_t(xr),xr=null),cr.clear()}function gu(e,n,t){var l;if(!Number.isFinite(t)||t<=0)return;if(tr.get(e)!==n)return;const r=lr.get(e);if(null==r)return;const i=zn.value[e],a=cn.value&&!0!==an.value&&!(null==(l=o.nodes)?void 0:l.length)&&e>=zn.value.length-2,u=!(!0===(null==i?void 0:i.loading)||a),s=cr.get(e),d=s?s.allowShrink&&u:u,c=s&&!d?Math.max(s.height,t):t;cr.set(e,{height:c,allowShrink:d,version:r,el:n}),null==xr&&(xr=Nt?Nt(hu):null,null==xr&&hu())}function yu(e,n){gu(e,n,_l(e,n))}function bu(){let e=0;for(const[n,t]of tr){const o=_l(n,t);e+=o,gu(n,t,o)}return e}function ku(){null==Zt||Zt.disconnect(),Zt=null,Xt.clear()}function wu(){for(;ur.length;)Nr(ur.pop())}X(at,e=>{e&&du("content")},{flush:"post"}),n({getVirtualMetrics:ea,captureVirtualState:function(e={}){var n;return ga(ea("manual"),{includeHeightCache:!0,includeContentHash:!0,allowAnchorFallback:!0===e.allowFallbackAnchor,requireViewport:!0===e.requireViewport,includeEmptyState:null==(n=e.includeEmptyState)||n})},restoreVirtualState:function(e,n={}){const t=!0===n.restoreAnchor,o=null==n.restoreToken?"imperative":String(n.restoreToken);$a=e,Ra={restoreAnchor:t,restoreToken:o,allowUncapturedAnchor:!0===n.allowUncapturedAnchor},!Ka(e,{restoreAnchor:t,restoreToken:o,allowUncapturedAnchor:!0===n.allowUncapturedAnchor})&&za(e)||($a=null,Ra=null)},forceMeasure:function(e="manual"){return s(this,null,function*(){yield oe(),yield Da(),bu(),Ea(),yield oe();const n=ea(e);return au(n,!0),n})},settle:Va,scrollToNode:function(e,n="start"){wa(),Lo();const t=zn.value.length;if(t<=0)return;const o=Wr(e,0,t-1),l=()=>{var e;const t=zo({nodeIndex:o,offsetWithinNodePx:0}),l=Ro(o),r=na(),i=null!=(e=null==r?void 0:r.clientHeight)?e:0,a=Oo();let u=t;if("center"===n)u=t-i/2+l/2;else if("end"===n)u=t-i+l;else if("nearest"===n&&null!=a){if(t>=a&&t+l<=a+i)return;u=t<a?t:t-i+l}Ko(Math.max(0,u)),$r({immediate:!0}),yt.value&&(Vl.value=o,nr())};if(yt.value)return Vl.value=o,nr(),void oe(l);l()}});const xu=/* @__PURE__ */new Set;X(()=>kt.value,e=>{if(e)ir.clear();else{ku();for(const e of ar.values())for(const n of e)Nr(n);ar.clear(),lr.clear(),wu(),pu()}},{immediate:!0}),X(an,e=>{e&&function(){if(De&&an.value&&tr.size){wu();for(const e of Zt?[80]:[80,240,640]){const n=Cr(e,()=>{for(const[e,n]of tr)n&&yu(e,n)},"final");null!=n&&ur.push(n)}}}(),du(e?"final":"content")});const Su=Zl(()=>du("content"),16),Mu=Zl(()=>du("batch"),16);X([()=>zn.value.length,()=>At.value],()=>{xo.value&&xa(),Su()},{flush:"post",immediate:!0}),X([()=>er.start,()=>er.end],()=>{Mu()},{flush:"post"});const{cleanupBatchScheduler:Cu}=function(e){const{props:n,isClient:t,isTestEnv:o,parsedNodesIdentity:l,parsedNodeCount:r,desiredRenderedCount:i,datasetKey:a,batchingEnabled:u,incrementalRenderingActive:s,resolvedBatchSize:d,resolvedInitialBatch:c,renderedCount:f,adaptiveBatchSize:m,previousRenderContext:v,previousBatchConfig:h,requestFrame:p,cancelFrame:g,hasIdleCallback:y,cleanupNodeVisibility:b,onDatasetKeyChanged:k,onDatasetChanged:w}=e;let x=null,S="raf",M=null,C=0,N=!1,_=!1;const T=/* @__PURE__ */new Set,B=/* @__PURE__ */new Set;function I(){if(t){null!=x&&("raf"===S&&g?g(x):"idle"===S&&"function"==typeof window.cancelIdleCallback?window.cancelIdleCallback(x):"timeout"===S&&window.clearTimeout(x),x=null),C+=1;for(const e of T)g&&g(e);for(const e of B)window.clearTimeout(e);T.clear(),B.clear(),M=null,N=!1,_=!1}}function H(){return"undefined"!=typeof performance?performance.now():Date.now()}function $(e){!function(e){var t;if(!s.value)return;const o=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6),l=Math.max(1,d.value||1),r=Math.max(1,Math.floor(l/4));e>1.5*o?m.value=Math.max(r,Math.floor(.8*m.value)):e<.6*o&&m.value<l&&(m.value=Math.min(l,Math.ceil(1.2*m.value)))}(e),N=!1;const t=_||f.value<i.value;_=!1,t&&F()}function R(e,l={}){var r,a;if(!s.value)return;const u=i.value;if(f.value>=u)return;const d=Math.max(1,e),c=()=>{const e=H();x=null;const o=null!=M?M:d;M=null;const l=H();f.value=Math.min(u,f.value+o),b(f.value),function(e,o){if(!t)return void $(o);N=!0;const l=++C;oe().then(()=>{var t;if(l!==C)return;const r=H(),i=Math.max(o,r-e),a=()=>{l===C&&$(i)};if(p){let e=null,o=null,l=!1;const r=()=>{l||(l=!0,null!==e&&(T.delete(e),e=null),null!==o&&(B.delete(o),window.clearTimeout(o),o=null),a())};return e=p(()=>{r()}),T.add(e),o=window.setTimeout(()=>{null!==e&&g&&g(e),r()},Math.max(32,null!=(t=n.renderBatchIdleTimeoutMs)?t:120)),void B.add(o)}const u=window.setTimeout(()=>{B.delete(u),a()},0);B.add(u)})}(e,H()-l)};if(!t||l.immediate)return void c();const m=Math.max(0,null!=(r=n.renderBatchDelay)?r:16);if(M=null!=M?Math.max(M,d):d,null!=x)return;const v="undefined"!=typeof document&&"hidden"===document.visibilityState;if(!o&&!v&&y&&window.requestIdleCallback){const e=Math.max(0,null!=(a=n.renderBatchIdleTimeoutMs)?a:120);return S="idle",void(x=window.requestIdleCallback(()=>c(),{timeout:e}))}if(p&&!o&&!v)return S="raf",void(x=p(()=>{0===m?c():(S="timeout",x=window.setTimeout(()=>c(),m))}));S="timeout",x=window.setTimeout(()=>c(),m)}function P(e,n={}){N?_=!0:null==e?F():R(e,n)}function F(){s.value&&R(u.value?Math.max(1,Math.round(m.value)):Math.max(1,d.value))}return X([l,r,a,s,d,c,()=>n.renderBatchDelay],()=>{var e;const o=r.value,l=v.value,u=a.value,p=!Object.is(u,l.key),g=o!==l.total,y=g&&o>l.total&&l.total>0&&!p,x=p||g;v.value={key:u,total:o};const S=h.value,M=null!=(e=n.renderBatchDelay)?e:16,C=S.batchSize!==d.value||S.initial!==c.value||S.delay!==M||S.enabled!==s.value;h.value={batchSize:d.value,initial:c.value,delay:M,enabled:s.value},p&&k(o),(x||C||!s.value)&&I(),(x&&!y||C)&&(m.value=Math.max(1,d.value||1)),x&&!y&&w();const N=i.value;if(!o)return f.value=0,void b(0);if(!s.value)return f.value=N,void b(f.value);const _=p||0===l.total;f.value=_||C?Math.min(N,c.value):Math.min(f.value,N);const T=Math.max(1,c.value||d.value||o);f.value<N?P(T,{immediate:!t}):b(f.value)},{immediate:!0}),X(i,(e,n)=>{s.value&&("number"==typeof n&&e<=n||e>f.value&&P())}),{cleanupBatchScheduler:I}}({props:W,isClient:De,isTestEnv:Bt,parsedNodesIdentity:Wn,parsedNodeCount:Vn,desiredRenderedCount:Sr,datasetKey:Oi,batchingEnabled:Rt,incrementalRenderingActive:Pt,resolvedBatchSize:Ht,resolvedInitialBatch:$t,renderedCount:At,adaptiveBatchSize:zt,previousRenderContext:Kt,previousBatchConfig:Lt,requestFrame:Nt,cancelFrame:_t,hasIdleCallback:Tt,cleanupNodeVisibility:jr,onDatasetKeyChanged:e=>{pu(),wl(),$o(),lu(),e>0&&il(e)},onDatasetChanged:()=>{yt.value&&$r({immediate:!0})}});X([Dl,yt,()=>ce.value,()=>Pe()],([e,n])=>{if(!e)return Lr(),void Hr();Er(),n?$r({immediate:!0}):Hr()},{flush:"post",immediate:!0});let Nu=!1;function _u(){yt.value&&De&&!Nu&&(Nu=!0,Nt?Nt(()=>{Nu=!1,$r({immediate:!0})}):queueMicrotask(()=>{Nu=!1,$r({immediate:!0})}))}X([()=>zn.value.length,()=>yt.value],([e,n])=>{n&&e&&De&&_u()},{flush:"post"}),X(st,e=>{e&&function(){var e;if(qn.value&&Un.value&&Xn.value&&(null==(e=Yn.value)?void 0:e[1]))return;const n=me({type:"paragraph",children:[{type:"text",content:"Probe paragraph text",raw:"Probe paragraph text"}],raw:"Probe paragraph text"}),t=me({type:"list_item",children:[n],raw:"- Probe paragraph text"}),o=me({type:"list",ordered:!1,items:[t],raw:"- Probe paragraph text"});qn.value=n,Un.value=t,Xn.value=o;const l={1:null,2:null,3:null,4:null,5:null,6:null};for(let r=1;r<=6;r++)l[r]=me({type:"heading",level:r,text:"Probe heading",children:[{type:"text",content:"Probe heading",raw:"Probe heading"}],raw:`${"#".repeat(r)} Probe heading`});Yn.value=l}()},{immediate:!0}),X([()=>ce.value,Rl],()=>{if(!Rl.value)return vi(),void(_e.value=0);fi(),vi(),Rl.value&&ce.value&&"undefined"!=typeof ResizeObserver&&(mi=new ResizeObserver(()=>{fi(),st.value&&(Ao.value&&Eo(),xo.value&&xa(),du("resize"))}),mi.observe(ce.value))},{immediate:!0}),X([st,vt,Ai],()=>s(null,null,function*(){if(!st.value)return Te.value={paragraph:null,listItem:null,listWrapperOverhead:0,headings:{1:null,2:null,3:null,4:null,5:null,6:null}},void $o();yield oe(),function(){if(!st.value||"undefined"==typeof window)return Te.value={paragraph:null,listItem:null,listWrapperOverhead:0,headings:{1:null,2:null,3:null,4:null,5:null,6:null}},void $o();const e={paragraph:null,listItem:null,listWrapperOverhead:0,headings:{1:null,2:null,3:null,4:null,5:null,6:null}},n=ni(Gr(fe.value),".paragraph-node");e.paragraph=Wl(fe.value,n,"pre-wrap");const t=Gr(ve.value),o=null==t?void 0:t.querySelector(".paragraph-node");e.listItem=Wl(ve.value,o,"pre-wrap");const l=Hn("readSimpleTextProbeProfile.list.offsetHeight",()=>{var e,n;return null!=(n=null==(e=he.value)?void 0:e.offsetHeight)?n:0}),r=Hn("readSimpleTextProbeProfile.listItem.offsetHeight",()=>{var e,n;return null!=(n=null==(e=ve.value)?void 0:e.offsetHeight)?n:0});e.listWrapperOverhead=Math.max(0,l-r);for(let i=1;i<=6;i++){const n=ni(Gr(pe[i]),`h${i}`);e.headings[i]=Wl(pe[i],n,"pre-wrap")}Te.value=e,$o()}()}),{flush:"post",immediate:!0}),X(()=>zn.value.length,()=>{yt.value&&_u()}),X([st,_e],()=>{$o(),yt.value&&$r({immediate:!0}),Ao.value&&Eo(),xo.value&&xa(),du("resize")},{immediate:!1}),X(()=>Bl.value,e=>{if(e)for(const[n,t]of qt)vu(n,t);else if(zr(),yt.value)$r({immediate:!0});else for(const[n,t]of qt)t&&Kr(n,!0)},{immediate:!1}),X([$e,Re,()=>Pe()],()=>{var e;null==(e=Ct.refresh)||e.call(Ct);for(const[n,t]of qt)vu(n,t)},{immediate:!1}),X([()=>W.viewportPriority,()=>zn.value.length,Re],([e,n,t])=>{if(!1!==e){if(ye.value&&(n<=200||n<=t)){ye.value=!1;for(const[e,n]of qt)vu(e,n)}}else ye.value=!1}),X(()=>At.value,()=>{yt.value&&$r({immediate:!0})}),X([Vl,pt,gt,()=>zn.value.length,yt],()=>{nr()},{immediate:!0});let Tu=null,Bu=!1,Iu=null;function Hu(){Tu=null,qi=null,Vi=void 0,Ui=null,lu()}function $u(){pu(),wl(),$o(),Jt.length=0;const e=zn.value.length;e>0&&il(e),La()}function Ru(){uu(),_r(),Za=null,Ba=null,Ia=null,Ha=null,$a=null,Ra=null,Bu=!1,Hu(),Li("restore"),Lo(),wa()}function Pu(e){var n;return[null!=(n=Ii())?n:"",Bi(),Ri(),Fi.value,tu(e),zn.value.length,Math.round(Po(0,zn.value.length)),Math.round(Pi()),Zo.count,Math.round(Zo.total)].join(":")}function Fu(){return s(this,null,function*(){var e,n,t,l;const r=null==(e=o.virtualScroll)?void 0:e.settledToken,i=tu(r),a=Bi(),u=Ii(),s=Ai.value;if(lt.value&&"manual"===(null==(n=o.virtualScroll)?void 0:n.settleMode)&&Xi(r))if(Zi()){if(Pu(r)!==Ui&&!Bu){Bu=!0;try{const e=yield Va({reason:"manual",expectedSettledTokenKey:i}),n=tu()===i;Wa(a,u,s)&&e.sessionKey===a&&e.threadKey===u&&n&&e.stable&&"final"===e.phase&&(Ui=Pu(null==(t=o.virtualScroll)?void 0:t.settledToken))}finally{Bu=!1,yield oe();const e=null==(l=o.virtualScroll)?void 0:l.settledToken,n=Xi(e)?Pu(e):"";Wa(a,u,s)&&n&&Ui!==n&&Fu()}}}else du("manual")})}X(lt,(e,n)=>{if(e!==n){if(!e)return Ru(),void uu();Ru(),$u(),Iu=Ai.value,du("content")}},{flush:"post"}),X([lt,Ai],([e,n])=>{e?null!=Iu?Iu!==n&&(Iu=n,function(e="resize"){pu(),wl(),$o(),Jt.length=0;const n=zn.value.length;n>0&&il(n),La(),Ba=null,Ia=null,Ha=null,Za=null,Bu=!1,Hu(),Aa(),oe(()=>{bu(),Ao.value&&Eo(),xo.value&&xa(),du(e)})}("resize")):Iu=n:Iu=null},{flush:"post",immediate:!0}),X([lt,()=>Bi(),()=>Ii()],([e])=>{e&&(Ru(),$u(),Li("content"),du("content"))}),X([lt,()=>Bi(),()=>Ii(),Ai,()=>zn.value.length],([e])=>{e&&function(e="async-node"){var n;let t=!1;for(const[o,l]of Array.from(yr.entries()))ji(l)||(kr-=Math.max(0,null!=(n=gr.get(o))?n:0),yr.delete(o),gr.delete(o),t=!0);t&&(Ki(),du(e))}("async-node")},{flush:"post"}),X([lt,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.sessionKey},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.measurementKey},()=>o.indexKey,()=>Me.value],([e])=>{e&&(lu(),function(e="content"){if(!lt.value)return;const n=[],t=zn.value.length,o=Vr(t),l=Jt.length-1,r=Math.max(t-1,l);for(let i=o;i<=r;i++){if(i>=t){i<=l&&void 0!==Jt[i]&&n.push(i);continue}const e=va(i),o=Jt[i];null!=o&&o!==e&&n.push(i),Jt[i]=e}if(l>=t){for(let e=t;e<=l;e++)Jt[e]=void 0;Jt.length=t}n.length&&(function(e,n={}){const t=Array.from(e,Number);pl(t);let o=0;if(gl(()=>(o=cl(t,n),o>0)),o>0)!function(e){for(const n of e)Number.isInteger(n)&&n>=0&&n<Jt.length&&(Jt[n]=void 0)}(t);else for(const l of t)mo.delete(l)}(n,{notify:!1}),$o(o),Hu(),Ao.value&&Eo(),xo.value&&xa(),du(e))}("content"))},{flush:"post",immediate:!0}),X([lt,()=>zn.value.length,()=>Bi(),()=>Ii()],([e,n,t,o],[l,r,i,a])=>{e&&l&&t===i&&o===a&&n!==r&&Hu()},{flush:"post"}),X([lt,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.heightCache},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.heightCacheWidth},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.restoreState},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.measurementKey},()=>zn.value.length,()=>Bi(),_e],()=>{Aa()},{flush:"post",immediate:!0}),X(Oa,(e,n)=>{null==e&&null!=n&&(Lo(),Ao.value=null,wa(),Ha=null)},{flush:"post"}),X([lt,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.restoreState},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.restoreAnchor},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.measurementKey},()=>zn.value.length,()=>Bi(),_e],e=>s(null,[e],function*([e,n]){if(!e||!n)return;yield oe();const t=Oa();Ka(n,{restoreAnchor:null!=t,restoreToken:null!=t?t:void 0})}),{flush:"post",immediate:!0}),X([lt,_e,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.restoreState},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.measurementKey}],([e])=>{var n;if(!e)return;const t=null==(n=o.virtualScroll)?void 0:n.restoreState;t&&Ba&&"restore"===Ia&&(Na(t)||($u(),Ba=null,Ia=null,du("resize")))},{flush:"post"}),X([lt,()=>zn.value.length,()=>Bi(),_e],e=>s(null,[e],function*([e]){var n;const t=$a,o=Ra;e&&t&&(yield oe(),!Ka(t,{restoreAnchor:!0===(null==o?void 0:o.restoreAnchor),restoreToken:null!=(n=null==o?void 0:o.restoreToken)?n:"imperative",allowUncapturedAnchor:!0===(null==o?void 0:o.allowUncapturedAnchor)})&&za(t)||($a=null,Ra=null))}),{flush:"post",immediate:!0}),X([lt,an,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.settleMode},()=>Bi(),()=>Ii(),Ai,wr,pr,()=>At.value,Sr,()=>Zo.count,()=>Zo.total],([e,n,t])=>{if(!e||!0!==n||"manual"===t)return;if(!Ji())return;const o=function(){var e;const n=zn.value.length;return[null!=(e=Ii())?e:"",Bi(),Ri(),Fi.value,n,Math.round(Po(0,n)),Math.round(Pi()),Zo.count,Math.round(Zo.total)].join(":")}();Tu!==o&&(Tu=o,Va({reason:"final"}).then(e=>{e.stable||Tu!==o||(Tu=null)}))},{flush:"post",immediate:!0}),X([lt,an,()=>{var e;return null==(e=o.virtualScroll)?void 0:e.settleMode},()=>{var e;return null==(e=o.virtualScroll)?void 0:e.settledToken},()=>Bi(),()=>Ii(),Ai,wr,pr,()=>At.value,Sr,()=>zn.value.length,()=>Zo.count,()=>Zo.total],()=>{Fu()},{flush:"post",immediate:!0}),X([()=>zn.value.length,yt,pt,gt,()=>er.start,()=>er.end],([e,n,t,o,l,r])=>{Ve.value&&kn("virtualization",{nodes:e,virtualization:n,maxLiveNodes:t,buffer:o,focusIndex:Vl.value,scroll:n?(()=>{const e=wo.value||Je();return e?{reverse:Qe(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:l,end:r},rendered:At.value})}),X([()=>W.customId],([e],n,t)=>{if(!e||Zn)return;const o=function(e,n){return e?(Nl.controllers[e]=n,()=>{Nl.controllers[e]===n&&delete Nl.controllers[e]}):()=>{}}(e,{captureRestoreAnchor:Wo,restoreAnchor:qo,getAnchorDrift:Uo,getReport:Ni});t(()=>{o()})},{immediate:!0}),ne(()=>{!function(){if(lt.value)try{bu(),Ea();const e=ea("manual");nu(e)&&(Z(e),Za=e,Ya=eu());const n=ga(e,{includeHeightCache:!0,includeContentHash:!0,allowAnchorFallback:!1,requireViewport:!0,includeEmptyState:!0});n&&(te(n),n.anchor&&de(n.anchor),Ga=iu(n))}catch(e){}}(),Cu(),zr(),yn(),ku();for(const e of ar.values())for(const n of e)Nr(n);ar.clear(),lr.clear(),Jt.length=0,wu(),pu(),vi(),Lo(),wa(),uu(),Lr(),Hr()});const Au=to("ViewportDeferredMermaidBlockNode",le({loader:()=>s(null,null,function*(){try{return(yield import("./index10.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),Ft}}),loadingComponent:ri,delay:0}),ri),Ou=to("ViewportDeferredInfographicBlockNode",le({loader:()=>s(null,null,function*(){try{return(yield import("./index8.js")).default}catch(e){return console.warn('[markstream-vue] Failed to load InfographicBlockNode. Showing the Infographic source fallback. To enable Infographic rendering, install "@antv/infographic" and configure setInfographicLoader with a dynamic loader.',e),li}}),loadingComponent:li,delay:0}),li),Ku=to("ViewportDeferredD2BlockNode",le({loader:()=>s(null,null,function*(){try{return(yield import("./index9.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),Ft}}),loadingComponent:ei,delay:0}),ei),ju={text:Ot,paragraph:dl,heading:Go,code_block:ro,list:ol,list_item:tl,blockquote:jo,table:yl,definition_list:Do,footnote:Xo,footnote_reference:hn,footnote_anchor:Vo,admonition:xi,vmr_container:Sl,hardbreak:Ho,link:So,image:bt,thematic_break:kl,math_inline:io,math_block:ao,strong:po,emphasis:Bo,strikethrough:yo,highlight:_o,insert:Co,subscript:vo,superscript:fo,emoji:dn,checkbox:un,checkbox_input:un,inline_code:Rn,html_inline:Tn,reference:so,html_block:al},zu=A(()=>_i()),Lu=A(()=>ql(W.codeBlockProps)),Eu=A(()=>ql(W.codeBlockProps)),Du=A(()=>u(a(a({stream:W.codeBlockStream,darkTheme:W.codeBlockDarkTheme,lightTheme:W.codeBlockLightTheme,themes:W.themes,minWidth:W.codeBlockMinWidth,maxWidth:W.codeBlockMaxWidth},"boolean"==typeof qe.value?{showTooltips:qe.value}:{}),Eu.value),{codeBlockOptions:W.codeBlockOptions})),Wu=A(()=>u(a(a({},Du.value),Lu.value),{codeBlockOptions:W.codeBlockOptions}));function Vu(e){return"boolean"==typeof e?e:void 0}const qu=A(()=>{var e,n,t,o,l,r,i;const a=W.codeBlockProps||{},u={},s=Vu(a.showLineNumbers);u.showLineNumbers=null!=s?s:!0!==(null==(e=W.codeBlockOptions)?void 0:e.disableLineNumbers),u.showHeader=null==(n=Vu(a.showHeader))||n,u.showCopyButton=null==(t=Vu(a.showCopyButton))||t;const d=null!=(o=Vu(a.showTooltips))?o:qe.value;"boolean"==typeof d&&(u.showTooltips=d),u.codeBlockOptions=W.codeBlockOptions,u.isDark=W.isDark,u.darkTheme=null!=(l=a.darkTheme)?l:W.codeBlockDarkTheme,u.lightTheme=null!=(r=a.lightTheme)?r:W.codeBlockLightTheme,u.theme=a.theme,u.themes=null!=(i=a.themes)?i:W.themes;const c=Vu(a.diffInline);void 0!==c&&(u.diffInline=c),void 0!==a.diffHideUnchangedRegions&&(u.diffHideUnchangedRegions=a.diffHideUnchangedRegions);const f=function(e){const n=Number(e);return Number.isFinite(n)&&n>0?n:void 0}(a.reservedHeightPx);return void 0!==f&&(u.reservedHeightPx=f),u}),Uu=A(()=>a({},W.mermaidProps||{})),Xu=A(()=>a({},W.d2Props||{})),Yu=A(()=>a({},W.infographicProps||{})),Zu=A(()=>({typewriter:b.value,fade:W.fade,customHtmlTags:jn.value.customHtmlTags})),Gu=A(()=>a(a({},Zu.value),"boolean"==typeof qe.value?{showTooltip:qe.value}:{})),Ju=A(()=>a(a({},Zu.value),"boolean"==typeof qe.value?{showTooltips:qe.value}:{})),Qu=A(()=>a(a({},Zu.value),"boolean"==typeof qe.value?{showTooltips:qe.value}:{})),es=A(()=>a(a({},Zu.value),"boolean"==typeof qe.value?{showTooltips:qe.value}:{}));function ns(e){return Array.isArray(e.children)&&e.children.length>0}const ts=/* @__PURE__ */new WeakMap,os=/* @__PURE__ */new WeakMap,ls=[],rs=[];let is=null,as=[];function us(e,n){var t;const o=String(null!=(t=null==e?void 0:e.code)?t:""),l=os.get(e);if(l&&l.code===o)return l.height;const r=n(o);return os.set(e,{code:o,height:r}),r}function ss(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Object.is(e[t],n[t]))return!1;return!0}const ds=A(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map;return zn.value.forEach((t,o)=>{var l;if("footnote"!==t.type)return;const r=t.id,i=null!=(l=e.get(r))?l:0;n.set(o,i),e.set(r,i+1)}),n});function cs(e,n){var t,o,l,s,f;const m=function(e,n,t){const o=st.value?ki.value[n]:null;return[n,e.loading,o,t]}(e.node,e.index,n),v=ts.get(e.node);if(v&&ss(v.signature,m))return v.item;let h=function(e,n){var t,o;if("code_block"!==e.type)return Gt[n]=void 0,e;const l=e,r=[l.language,l.loading,l.diff,l.code,l.originalCode,l.updatedCode,l.raw,l.startLine,l.endLine,null==(t=l.sourceMap)?void 0:t.startLine,null==(o=l.sourceMap)?void 0:o.endLine],i=Gt[n];if(i&&r.every((e,n)=>e===i.signature[n]))return i.node;const u=a({},l);return Gt[n]={signature:r,node:u},u}(e.node,e.index);const p=ms(h);let g=ys(h,p);if(("html_block"===h.type||"html_inline"===h.type)&&g===ju[h.type]){const e=h,n=String(null!=(t=e.tag)?t:"").trim().toLowerCase()||C(e.content);if(n){const t=An.value[n];if(On.value.has(n)&&t)g=t,h=u(a({},e),{type:n,tag:n,content:$(e.content,n)});else if(N(null!=(o=e.content)?o:e.raw,n)){const n=String(null!=(s=null!=(l=e.content)?l:e.raw)?s:"");"html_inline"===h.type?(g=Ot,h={type:"text",content:n,raw:n}):(g=dl,h={type:"paragraph",children:[{type:"text",content:n,raw:n}],raw:n})}}}const y="code_block"===h.type&&w.value&&g===lo&&!Ul(An.value,p);let b=a({},function(e,n,t){const o=null!=n?n:ms(e);if("code_block"===e.type){const n=o?Ul(An.value,o):void 0;if(t&&w.value&&!n&&t===lo)return qu.value;if(t&&o&&t===n)return"mermaid"===o?hs(e):"infographic"===o?ps(e):"d2"===o||"d2lang"===o?gs(e):Wu.value;if(t&&t===An.value.code_block)return Wu.value}return"mermaid"===o?hs(e):"infographic"===o?ps(e):"d2"===o||"d2lang"===o?gs(e):"link"===e.type?Gu.value:"list"===e.type?Ju.value:"blockquote"===e.type?Qu.value:"table"===e.type?es.value:"code_block"===e.type?Du.value:Zu.value}(h,p,g));const k=st.value?ki.value[e.index]:null;"code_block"===h.type&&"code-block"===(null==k?void 0:k.kind)&&(b=u(a({},b),y?{reservedHeightPx:k.contentHeight}:{estimatedHeightPx:k.height,estimatedContentHeightPx:k.contentHeight,estimatedDiffInline:k.diffInline})),y||"code_block"!==h.type||"mermaid"!==p||null!=Le(b.estimatedPreviewHeightPx)||(b=u(a({},b),{estimatedPreviewHeightPx:Ae(us(h,Oe))})),y||"code_block"!==h.type||"infographic"!==p||null!=Le(b.estimatedPreviewHeightPx)||(b=u(a({},b),{estimatedPreviewHeightPx:Ke(us(h,je))})),"math_block"===h.type&&(b=u(a({},b),{cacheScope:Fn}));const x=function(e,n){const t=String(e.type);return!Ye(t)&&An.value[t]===n}(h,g),S=x?xn(h,Ue.value):void 0,M=h.loading;let _=e.index;"footnote"===h.type&&g===Xo&&(_=`footnote-${h.id}-${ds.value.get(e.index)}`);const T=`${zu.value}-${_}`,B=a({node:h,loading:M,"index-key":T},"reference"===h.type?{"data-markstream-reference-id":String(h.id)}:{}),I={"custom-id":W.customId,"is-dark":W.isDark},H={onCopy:r,onHandleArtifactClick:i},R={onClick:bs,onMouseover:xs,onMouseout:Ss},P={onMouseover:d,onMouseout:c},F=a(a({},null!=S?S:{}),b),A=ae(B,b,I,H),O=ae(F,B,I,H),K={node:h,sourceLoading:M,index:e.index,component:g,bindings:b,customBindings:F,nodeProps:A,customNodeProps:O,fragmentNodeProps:ae(A,R),customFragmentNodeProps:ae(O,R),minimalNodeProps:ae(A,P),rendersCustomNode:x,hasSlotChildren:ns(h),slotContent:String(null!=(f=h.content)?f:""),isCodeBlock:"code_block"===h.type,indexKey:T,vnodeKey:`${Hi.value}\0${_}\0${h.type}`};return ts.set(e.node,{signature:m,item:K}),K}const fs=A(()=>{var e,n,t,o,l;const r=is,i=function(){const e=[w.value,An.value,On.value,Ue.value,Hi.value,zu.value,Fn,hi.value,W.customId,W.isDark,qu.value,Du.value,Wu.value,Uu.value,Yu.value,Xu.value,Zu.value,Gu.value,Ju.value,Qu.value,es.value,st.value,Hl.value,_e.value];return is&&ss(is,e)?is:(is=e,e)}(),a=r!==i;if(is=i,yt.value)return wi.value.map(e=>cs(e,i));const u=zn.value,s=u.length;let d=!1;ls.length>s&&(ls.length=s,rs.length=s,d=!0);const c=ls,f=Math.min(c.length,s);let m=a?0:f;if(!a)for(let h=0;h<f;h++){const r=u[h];if("code_block"===r.type){if((null==(e=c[h])?void 0:e.node)!==(null==(n=Gt[h])?void 0:n.node)||rs[h]!==r||!Object.is(null==(t=c[h])?void 0:t.sourceLoading,r.loading)){m=h;break}}else if((null==(o=c[h])?void 0:o.node)!==r||!Object.is(null==(l=c[h])?void 0:l.sourceLoading,r.loading)){m=h;break}}if(!d&&m===s)return as;for(let h=m;h<s;h++)c[h]=cs({node:u[h],index:h},i),rs[h]=u[h];const v=c.slice();return as=v,v});function ms(e){var n;return"code_block"===(null==e?void 0:e.type)?String(null!=(n=e.language)?n:"").trim().toLowerCase():""}function vs(e,n,t,o){var l;const r=a({},e.value);return null==Le(r.estimatedPreviewHeightPx)&&(r.estimatedPreviewHeightPx=o(us(n,t),void 0,"none"===r.maxHeight?null:null!=(l=Le(r.maxHeight))?l:void 0)),r}function hs(e){return vs(Uu,e,Oe,Ae)}function ps(e){return vs(Yu,e,je,Ke)}function gs(e){return vs(Xu,e,Ee,ze)}function ys(e,n){if(!e)return xl;const t=An.value,o=t[String(e.type)];if("code_block"===e.type){const l=null!=n?n:ms(e),r=l?Ul(t,l):void 0;if(r)return r;if(w.value)return t.code_block||lo;if("mermaid"===l)return t.mermaid||Au;if("infographic"===l)return t.infographic||Ou;if("d2"===l||"d2lang"===l)return t.d2||Ku;if(o)return o;return t.code_block||hi.value}return o||ju[String(e.type)]||xl}function bs(e){const n=e.target instanceof Element?e.target.closest("[data-markstream-reference-id]"):null,t=e.currentTarget,o=n&&t instanceof Element&&t.contains(n)?n.dataset.markstreamReferenceId:void 0;l("click",e,o)}function ks(e){var n;(null==(n=e.target)?void 0:n.closest("[data-node-index]"))&&l("mouseover",e)}function ws(e){var n;(null==(n=e.target)?void 0:n.closest("[data-node-index]"))&&l("mouseout",e)}function xs(e){l("mouseover",e)}function Ss(e){l("mouseout",e)}const Ms=q(null),Cs=q(!1),Ns=q(null),_s=A(()=>!("minimal"!==W.domMode||We.value||!1!==W.fade||b.value||Cs.value||Et.value||yt.value||tt.value||Qn.value||Mt.value||0!==Object.keys(An.value).length));let Ts,Bs=null,Is=0,Hs=0,$s=0;const Rs=["code_block","admonition","table","math_block","html_block","image","thematic_break"],Ps=new Set(Rs),Fs=[".typewriter-cursor",".height-estimation-probes",...Rs.map(e=>`[data-node-type="${e}"]`),"script","style"].join(",");function As(e){if(!e||"object"!=typeof e)return!1;const n=e.type;return"string"==typeof n&&Ps.has(n)}function Os(e){var n,t;if(!e||"object"!=typeof e)return 0;const o=e,l=null!=(t=null!=(n=o.raw)?n:o.content)?t:o.code;if("string"==typeof l)return l.length;const r=o.children;if(Array.isArray(r))return r.reduce((e,n)=>e+Os(n),0);const i=o.items;return Array.isArray(i)?i.reduce((e,n)=>e+Os(n),0):0}function Ks(){Ts&&(clearTimeout(Ts),Ts=void 0)}function js(){Is+=1,null!=Bs&&(null==_t||_t(Bs),Bs=null)}function zs(){js(),Ws(),Ms.value&&(Ms.value.style.visibility="hidden")}function Ls(e){var n;if(e.nodeType!==Node.TEXT_NODE)return!1;if(!(null!=(n=e.textContent)?n:"").trim())return!1;const t=e.parentElement;return!!t&&!t.closest(Fs)}function Es(e){let n=e.lastChild;for(;n;){if(Ls(n))return n;if(n.nodeType===Node.ELEMENT_NODE){const e=n;if(!e.matches(Fs)&&e.lastChild){n=e.lastChild;continue}}for(;n&&n!==e&&!n.previousSibling;)n=n.parentNode;if(!n||n===e)break;n=n.previousSibling}return null}function Ds(){const e=fs.value;for(let n=e.length-1;n>=0;n--){const t=e[n];if(!t||As(t.node)||!fu(t.index))continue;const o=qt.get(t.index);if(!o)continue;const l=Es(o);if(l)return l}return null}function Ws(){Ns.value&&(Ns.value.classList.remove(ci),Ns.value=null)}function Vs(){if("simple"!==y.value||!De||!Cs.value||!ce.value)return void Ws();const e=Ds(),n=e?function(e){var n;const t=null==(n=e.parentElement)?void 0:n.closest(".text-node");return t instanceof HTMLElement?t:e.parentElement}(e):null;n!==Ns.value&&(Ws(),n&&(n.classList.add(ci),Ns.value=n))}function qs(){if("precise"!==y.value)return;if(!De||!Cs.value)return;if(null!=Bs)return;const e=Is,n=()=>{Bs=null,e===Is&&function(){var e,n;if("precise"!==y.value)return;if(!(De&&Cs.value&&ce.value&&Ms.value))return;const t=ce.value,o=Ms.value;o.style.visibility="hidden";const l=Ds();if(!l)return;let r=0,i=0,a=20,u=!1;if(null==l?void 0:l.textContent){const o=l.textContent.length,s=document.createRange();s.setStart(l,Math.max(0,o-1)),s.setEnd(l,o);const d="function"==typeof s.getClientRects?s.getClientRects():void 0,c=null!=(n=null==d?void 0:d[d.length-1])?n:null==(e=l.parentElement)?void 0:e.getBoundingClientRect();if(c){const e=Hn("typewriterCursor.root.getBoundingClientRect",()=>t.getBoundingClientRect());r=c.right-e.left+t.scrollLeft,i=c.top-e.top+t.scrollTop,a=c.height||a,u=!0}s.detach()}u&&(o.style.transform=`translate(${Math.max(0,r)}px, ${Math.max(0,i)}px)`,o.style.height=`${a}px`,o.style.visibility="visible")}()};Nt?Bs=Nt(n):n()}return X([ln,()=>o.content,()=>o.nodes,()=>W.typewriter,an],()=>s(null,null,function*(){var e,n;if(!De||We.value||!Ze.value)return;if(!b.value)return void((Cs.value||Ts||null!=Bs||Ns.value||Ms.value)&&(Cs.value=!1,Ks(),zs()));if(an.value)return Cs.value=!1,Ks(),void zs();if(null==(e=o.nodes)?void 0:e.length)return Cs.value=!1,Ks(),zs(),Hs=(null!=(n=o.content)?n:"").length,void($s=ln.value.length);const t=function(){var e,n;return(null==(e=o.nodes)?void 0:e.length)?o.nodes.reduce((e,n)=>e+Os(n),0):(null!=(n=o.content)?n:"").length}(),l=function(){var e;return(null==(e=o.nodes)?void 0:e.length)?o.nodes.reduce((e,n)=>e+Os(n),0):ln.value.length}(),r=!As(zn.value[zn.value.length-1]),i=t>Hs,a=l>$s;if(!b.value||!r||!i&&!a)return b.value&&r||(Cs.value=!1,zs()),Hs=t,void($s=l);Hs=t,$s=l,Cs.value=!0,"precise"===y.value&&Ms.value&&(Ms.value.style.visibility="hidden"),Ks(),yield oe(),"simple"===y.value?Vs():(Ws(),qs()),Ts=setTimeout(()=>{Ts=void 0,Cs.value=!1},3e3)}),{flush:"post",immediate:!0}),X(Cs,e=>s(null,null,function*(){e?(yield oe(),"simple"!==y.value?(Ws(),"precise"===y.value&&qs()):Vs()):zs()}),{flush:"post"}),X(y,()=>s(null,null,function*(){if(De&&!We.value&&Ze.value&&Cs.value){if(yield oe(),"simple"===y.value)return js(),void Vs();Ws(),"precise"!==y.value?zs():qs()}}),{flush:"post"}),X([()=>At.value,()=>er.start,()=>er.end],()=>s(null,null,function*(){De&&!We.value&&Ze.value&&Cs.value&&(yield oe(),"simple"!==y.value?(Ws(),"precise"===y.value&&qs()):Vs())}),{flush:"post"}),ne(()=>{Ks(),js(),Ws(),Pn.clear()}),(e,n)=>{const t=xe("NodeRenderer",!0);return V(We)?(K(!0),j(Y,{key:0},J(fs.value,e=>(K(),j(Y,{key:e.vnodeKey},[e.rendersCustomNode?(K(),re(ie(e.component),ae({key:0,ref_for:!0},e.customFragmentNodeProps),{default:ue(()=>[e.hasSlotChildren?(K(),re(t,ae({key:0,ref_for:!0},Dn.value,{nodes:e.node.children,"index-key":e.indexKey,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes","index-key"])):e.slotContent?(K(),re(t,ae({key:1,ref_for:!0},Dn.value,{content:e.slotContent,final:!e.node.loading,"index-key":`${e.indexKey}-content`,"smooth-streaming":!1,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["content","final","index-key"])):G("",!0)]),_:2},1040)):(K(),re(ie(e.component),ae({key:1,ref_for:!0},e.fragmentNodeProps),null,16))],64))),128)):(K(),j("div",{key:1,ref_key:"containerRef",ref:ce,class:D(["markstream-vue markdown-renderer",[{dark:W.isDark},{virtualized:yt.value},{"virtual-scroll-coordinated":at.value},{"stable-layout":Fl.value},{"typewriter-simple-cursor":Cs.value&&"simple"===y.value}]]),"data-custom-id":W.customId,onClick:bs,onMouseover:ks,onMouseout:ws},[dt.value||yt.value?(K(),j(Y,{key:0},[dt.value?(K(),re(oi,{key:0,width:vt.value,"flow-root":yt.value||at.value,"paragraph-node":qn.value,"list-item-node":Un.value,"list-node":Xn.value,"heading-nodes":Yn.value,"set-paragraph-wrapper":Tr,"set-list-item-wrapper":Br,"set-list-wrapper":Ir,"set-heading-wrapper":ti},null,8,["width","flow-root","paragraph-node","list-item-node","list-node","heading-nodes"])):G("",!0),yt.value?(K(),j("div",{key:1,class:"node-spacer",style:se({height:`${Si.value}px`}),"aria-hidden":"true"},null,4)):G("",!0)],64)):G("",!0),_s.value?(K(!0),j(Y,{key:1},J(fs.value,e=>(K(),j(Y,{key:e.vnodeKey},[fu(e.index)?(K(),re(ie(e.component),ae({key:0,ref_for:!0},e.minimalNodeProps),null,16)):G("",!0)],64))),128)):(K(!0),j(Y,{key:2},J(fs.value,e=>(K(),j("div",{key:e.vnodeKey,ref_for:!0,ref:n=>vu(e.index,n),class:"node-slot","data-node-index":e.index,"data-node-type":e.node.type},[V(xu).has(e.vnodeKey)||fu(e.index)?(K(),j("div",{key:0,ref_for:!0,ref:n=>function(e,n,t){var o,l;if(t?xu.add(n):xu.delete(n),t){const n=zn.value[e],o=ir.get(e);if(o&&o.el===t&&o.node===n&&o.loading===(null==n?void 0:n.loading))return}t||function(e){var n;const t=`${_i()}-${e}`;let o=!1;for(const l of Array.from(gr.keys())){const r=yr.get(l);((null==r?void 0:r.index)===e||l===t||l.startsWith(`${t}-`))&&(kr-=Math.max(0,null!=(n=gr.get(l))?n:0),gr.delete(l),yr.delete(l),o=!0)}o&&(Ki(),du("async-node"))}(e),cr.delete(e),function(e){var n;const t=(null!=(n=lr.get(e))?n:0)+1;lr.set(e,t)}(e);const r=ar.get(e);if(r){for(const e of r)Nr(e);ar.delete(e)}if(function(e){const n=Xt.get(e);n&&(null==Zt||Zt.unobserve(n),Yt.delete(n),Xt.delete(e))}(e),!t||!kt.value)return tr.delete(e),lr.delete(e),void ir.delete(e);tr.set(e,t),ir.set(e,{el:t,node:zn.value[e],loading:null==(o=zn.value[e])?void 0:o.loading});const i=()=>{yu(e,t)};queueMicrotask(i);const a=(Zt||"undefined"==typeof ResizeObserver||(Zt=new ResizeObserver(e=>{if(e.length)for(const n of e){const e=Yt.get(n.target),t=Xt.get(null!=e?e:-1);null!=e&&t&&yu(e,t)}else bu()})),Zt);if(a&&(Xt.set(e,t),Yt.set(t,e),a.observe(t)),"undefined"!=typeof window){const n="code_block"===(null==(l=zn.value[e])?void 0:l.type)?[16,80,240,800]:an.value?[80]:[];if(n.length){const t=n.map(e=>Cr(e,i,"node-resize")).filter(e=>null!=e);t.length&&ar.set(e,t)}}}(e.index,e.vnodeKey,n),class:"node-content"},[e.isCodeBlock?e.rendersCustomNode?(K(),re(ie(e.component),ae({key:1,ref_for:!0},e.customNodeProps),{default:ue(()=>[e.hasSlotChildren?(K(),re(t,ae({key:0,ref_for:!0},Dn.value,{nodes:e.node.children,"index-key":e.indexKey,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["nodes","index-key"])):e.slotContent?(K(),re(t,ae({key:1,ref_for:!0},Dn.value,{content:e.slotContent,final:!e.node.loading,"index-key":`${e.indexKey}-content`,"smooth-streaming":!1,"batch-rendering":!1,"defer-nodes-until-visible":!1,"render-as-fragment":!0}),null,16,["content","final","index-key"])):G("",!0)]),_:2},1040)):(K(),re(ie(e.component),ae({key:2,ref_for:!0},e.nodeProps),null,16)):(K(),re(ii,{key:0,item:e,"source-nodes":o.nodes,fade:W.fade,final:V(rn),"nested-renderer-props":e.rendersCustomNode?Dn.value:void 0},null,8,["item","source-nodes","fade","final","nested-renderer-props"]))],512)):(K(),j("div",{key:1,class:"node-placeholder",style:se({height:`${Ro(e.index)}px`})},null,4))],8,di))),128)),Cs.value&&"precise"===y.value?(K(),j("span",{key:3,ref_key:"typewriterCursorRef",ref:Ms,class:"typewriter-cursor","aria-hidden":"true"},null,512)):G("",!0),yt.value?(K(),j("div",{key:4,class:"node-spacer",style:se({height:`${Mi.value}px`}),"aria-hidden":"true"},null,4)):G("",!0)],42,si))}}})),[["__scopeId","data-v-6e40537c"]]),mi=fi;mi.install=e=>{const n=new Set(["MarkdownRender","NodeRenderer",mi.__name,mi.name].filter(e=>Boolean(e)));for(const t of n)e.component(t,fi)};const vi=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:mi},Symbol.toStringTag,{value:"Module"})),hi={key:0,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"admonition-icon"},pi={key:1,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"admonition-icon"},gi={key:2,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"admonition-icon"},yi={key:3,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"admonition-icon"},bi={class:"admonition-title"},ki=["aria-expanded","aria-controls"],wi=["id"],xi=/* @__PURE__ */an(/* @__PURE__ */O({__name:"AdmonitionNode",props:{node:{},indexKey:{},isDark:{type:Boolean},typewriter:{type:Boolean},fade:{type:Boolean},customId:{}},emits:["copy"],setup(e,{emit:n}){var t;const o=e,l=n,r=A(()=>{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)}),i=q(!!o.node.collapsible&&!(null==(t=o.node.open)||t));function a(){o.node.collapsible&&(i.value=!i.value)}const u=`admonition-${Math.random().toString(36).slice(2,9)}`;return(n,t)=>(K(),j("div",{class:D(["admonition",[`admonition-${o.node.kind}`]])},[z("div",{id:u,class:"admonition-legend"},["note"===o.node.kind||"info"===o.node.kind?(K(),j("svg",hi,[...t[1]||(t[1]=[z("circle",{cx:"12",cy:"12",r:"10"},null,-1),z("path",{d:"M12 16v-4"},null,-1),z("path",{d:"M12 8h.01"},null,-1)])])):"tip"===o.node.kind?(K(),j("svg",pi,[...t[2]||(t[2]=[z("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"},null,-1),z("path",{d:"M9 18h6"},null,-1),z("path",{d:"M10 22h4"},null,-1)])])):"warning"===o.node.kind||"caution"===o.node.kind?(K(),j("svg",gi,[...t[3]||(t[3]=[z("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"},null,-1),z("path",{d:"M12 9v4"},null,-1),z("path",{d:"M12 17h.01"},null,-1)])])):"danger"===o.node.kind||"error"===o.node.kind?(K(),j("svg",yi,[...t[4]||(t[4]=[z("polygon",{points:"7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"},null,-1),z("path",{d:"M12 8v4"},null,-1),z("path",{d:"M12 16h.01"},null,-1)])])):G("",!0),z("span",bi,L(r.value),1),o.node.collapsible?(K(),j("button",{key:4,class:"admonition-toggle","aria-expanded":!i.value,"aria-controls":`${u}-content`,onClick:a},[(K(),j("svg",{style:se({rotate:i.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...t[5]||(t[5]=[z("path",{d:"m9 18 6-6-6-6"},null,-1)])],4))],8,ki)):G("",!0)]),ce(z("div",{id:`${u}-content`,class:"admonition-content","aria-labelledby":u},[W(V(mi),{"index-key":`admonition-${e.indexKey}`,nodes:o.node.children,"custom-id":o.customId,typewriter:o.typewriter,fade:o.fade,onCopy:t[0]||(t[0]=e=>l("copy",e))},null,8,["index-key","nodes","custom-id","typewriter","fade"])],8,wi),[[fe,!i.value]])],2))}}),[["__scopeId","data-v-a83480e1"]]);xi.install=e=>{e.component(xi.__name,xi)};const Si=()=>import("@terrastruct/d2");let Mi=null,Ci=Si,Ni=null,_i=!1,Ti=!1,Bi=0;function Ii(e){Ci=e,Bi++,Mi=null,Ni=null,_i=!1,Ti=!1}function Hi(e){Ii(null!=e?e:Si)}function $i(){Ii(null)}function Ri(){return"function"==typeof Ci}function Pi(){return s(this,null,function*(){if(Mi)return Mi;const e=Ci,n=Bi;return e?e===Si&&_i?null:Ni||(Ni=s(null,null,function*(){let t;try{t=yield e()}catch(o){if(e===Si)return n===Bi&&e===Ci&&(_i=!0,function(e){Ti||(Ti=!0,console.warn('[markstream-vue] Optional dependency "@terrastruct/d2" is not installed. D2 blocks will render as source.',e))}(o)),null;throw o}finally{n===Bi&&e===Ci&&(Ni=null)}return n!==Bi||e!==Ci?null:t?(Mi=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}(t),Mi):null}),Ni):null})}let Fi=null,Ai=null,Oi=null,Ki=0;function ji(e){Ai=null!=e?e:null,Fi=null,Oi=null,Ki++}function zi(e){if("function"!=typeof e)throw new TypeError("enableInfographic requires a loader function");ji(e)}function Li(){ji()}function Ei(){return"function"==typeof Ai}function Di(){return s(this,null,function*(){if(Fi)return Fi;const e=Ai,n=Ki;return e?Oi||(Oi=s(null,null,function*(){const t=yield e();if(n!==Ki||e!==Ai)return null;const o=function(e){var n,t,o;if(!e)return null;const l=null!=(n=e.default)?n:e,r="function"==typeof l&&"function"==typeof(null==(t=l.prototype)?void 0:t.render)?l:null!=(o=e.Infographic)?o:null==l?void 0:l.Infographic;return"function"==typeof r?r:null}(t);return n!==Ki||e!==Ai?null:o?(Fi=o,Fi):null}).finally(()=>{n===Ki&&e===Ai&&(Oi=null)}),Oi):null})}function Wi(e){const n=Number.parseFloat(String(null!=e?e:""));return Number.isFinite(n)?n:0}function Vi(e,n){null==e||e(n)}function qi(e,n){return e?(Vi(n,"readElementBoxHeight.offsetHeight"),Math.ceil(Math.max(0,e.offsetHeight||0))):0}function Ui(e,n){const t=qi(e,n);if(!e||"undefined"==typeof window||"function"!=typeof window.getComputedStyle)return t;Vi(n,"readElementOuterHeight.getComputedStyle");const o=window.getComputedStyle(e),l=Wi(o.marginTop),r=Wi(o.marginBottom);return Math.ceil(Math.max(0,t+l+r))}function Xi(e,n,t){if(!e)return 0;const o=function(e){var n;return e?(null==(n=e.matches)?void 0:n.call(e,".markstream-vue.markdown-renderer"))?e:e.querySelector(".markstream-vue.markdown-renderer"):null}(e);if(!o)return 0;const l=Number.isFinite(t)?Number(t):Ui(e,n),r=qi(o,n);return Math.max(0,l-r)}function Yi(e){return"measured"===e||"final"===e}function Zi(e,n,t){var o,l,r;const i=null!=(r=null!=(l=null==(o=t.getKey)?void 0:o.call(t,e,n))?l:e.id)?r:n;return String(i)}function Gi(e,n,t){var o,l,r;return null!=(r=null==(o=t.getKind)?void 0:o.call(t,e,n))?r:String(null!=(l=e.kind)?l:"")}function Ji(e,n,t){var o,l;const r=null!=(l=null==(o=t.getContent)?void 0:o.call(t,e,n))?l:e.content;return"string"==typeof r?r:""}function Qi(e,n,t){var o;const l=null==(o=t.getFinal)?void 0:o.call(t,e,n);if("boolean"==typeof l)return l;const r=e.final;return"boolean"!=typeof r||r}function ea(e,n,t){var o,l;return null!=(l=null==(o=t.getRevision)?void 0:o.call(t,e,n))?l:e.revision}function na(e,n,t){const o=Gi(e,n,t);return"assistant-markdown"===o||"markdown"===o||!o&&Ji(e,n,t).length>0}function ta(e,n,t){var o;const l=null==(o=t.estimateItemHeight)?void 0:o.call(t,e,n);if(Number.isFinite(l)&&l>0)return l;const r=Gi(e,n,t);return"assistant-markdown"===r||"markdown"===r?360:"system-divider"===r?44:"tool-call"===r?72:"thinking"===r?92:"error"===r?76:"user-message"===r?88:Ji(e,n,t).length>0?360:96}function oa(e){const n=ge(/* @__PURE__ */new Map),t=/* @__PURE__ */new Map,o=ge(/* @__PURE__ */new Map),l=ge(/* @__PURE__ */new Map),r=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map,c=q(!1),f=[0,80,180,360,640];let m,v=0,h=null,p=[],g=0;const y=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;let k,w=!1,x=null,S=!1,M=null;function C(n){var t;!0===e.debug&&y.set(n,(null!=(t=y.get(n))?t:0)+1)}function N(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(e):(oe(e),null)}function _(e){null!=e&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}function T(){return[...Me(e.items)]}function B(){const n=Me(e.threadKey);return null==n?void 0:String(n)}function I(n,t){return Zi(n,t,e)}function H(n,t){return na(n,t,e)}function $(n,t){const o=I(n,t),l=B(),r=ea(n,t,e);return[null!=l?l:"timeline",o,null==r?"":String(r)].join(":")}function R(){const n=Me(e.measurementKey);return null==n?void 0:String(n)}function P(){const n=Me(e.markdownMode);return"chat"===n||"minimal"===n||"docs"===n?n:"docs"}function F(){return!0===Me(e.renderCodeBlocksAsPre)}function A(){var e;const n=F()?"pre":"rich";return`${null!=(e=R())?e:""}${P()}${n}`}function O(n,t){if(H(n,t))return $(n,t);const o=I(n,t),l=B(),r=ea(n,t,e);return[null!=l?l:"timeline",o,null==r?"":String(r)].join(":")}function K(e){const n=T();for(let t=0;t<n.length;t++){const o=n[t];if(I(o,t)===e)return{item:o,index:t}}return null}function j(e,n){var t;const o=K(e);if(!o||!n)return!1;if(n.sourceKey!==O(o.item,o.index))return!1;const l=H(o.item,o.index)?A():R();return(null!=(t=n.measurementKey)?t:"")===(null!=l?l:"")}function z(e){if(!j(e,t.get(e)))return 0;const o=n.get(e);return Number.isFinite(o)&&o>0?o:0}function L(e,n){var t,o;const l=K(e);return!!(l&&n&&H(l.item,l.index)&&n.sessionKey===$(l.item,l.index)&&(null!=(t=n.threadKey)?t:"")===(null!=(o=B())?o:"")&&function(e){const n=A(),t=null!=e?e:"";return t===n||t.startsWith(`${n}\0`)}(n.measurementKey))}function E(e,n){return L(e,n)}function D(e,n,t){!Number.isFinite(n)||n<=0||(l.set(e,Math.ceil(n)),r.set(e,t))}function W(e,n=o.get(e),t={}){var l;const r=t.trustImportedState?Number(null==(l=null==n?void 0:n.metrics)?void 0:l.totalHeight):function(e,n=o.get(e)){var t;if(!E(e,n))return 0;const l=Number(null==(t=null==n?void 0:n.metrics)?void 0:t.totalHeight);return Number.isFinite(l)&&l>0?Math.ceil(l):0}(e,n);return!Number.isFinite(r)||r<=0||!n?0:(D(e,Math.ceil(r),n),Math.ceil(r))}function V(e){var n;return L(e,r.get(e))?null!=(n=l.get(e))?n:0:W(e)}function U(e){return Number.isFinite(e)&&e>0?e:null}function X(){if(!S)return;S=!1,M=null;const e=k;k=void 0,e&&ae(e)}function Y(){if(null!=h&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(h),h=null,"undefined"!=typeof window)for(const e of p)window.clearTimeout(e);p=[]}function Z(o,l,r=function(e){const n=K(e);return n?function(e,n){const t=H(e,n)?A():R();return a({sourceKey:O(e,n)},null==t?{}:{measurementKey:t})}(n.item,n.index):void 0}(o)){const i=U(l);if(null==i)return;const u=n.get(o),s=r&&(f=r,!((null!=(v=null==(d=t.get(o))?void 0:d.sourceKey)?v:"")===(null!=(p=null==f?void 0:f.sourceKey)?p:"")&&(null!=(y=null==d?void 0:d.measurementKey)?y:"")===(null!=(b=null==f?void 0:f.measurementKey)?b:"")&&(null!=(w=null==d?void 0:d.widthBucket)?w:0)===(null!=(x=null==f?void 0:f.widthBucket)?x:0)));var d,f,v,p,y,b,w,x;if(null!=u&&Math.abs(u-i)<.5&&!s)return;if(c.value)return n.set(o,i),r&&t.set(o,r),e.virtualizer.setItemSize(o,i),void function(){const e=m,n=g;e&&oe(()=>{ue(n,e),null==h&&"function"==typeof requestAnimationFrame&&(h=requestAnimationFrame(()=>{h=null,ue(n,e)}))})}();const C=!1!==e.preserveScrollAnchor,_=C?re():void 0,T=Math.max(0,e.virtualizer.getTotalHeight()-e.virtualizer.getViewportHeight()-e.virtualizer.getScrollTop()),B=C&&T<=2,I=C&&T<=function(){var n;const t=Number(null!=(n=e.bottomThresholdPx)?n:48);return Number.isFinite(t)?Math.max(0,t):48}();var $;n.set(o,i),r&&t.set(o,r),e.virtualizer.setItemSize(o,i),C&&(($=B?{type:"bottom",distanceFromBottomPx:0}:I?{type:"bottom",distanceFromBottomPx:T}:_)&&(S||(k=$,S=!0,M=N(X))))}function G(e){var n;null==(n=d.get(e))||n.disconnect(),d.delete(e),s.delete(e)}function J(){if(!w)return;w=!1,x=null;const e=Array.from(b.entries());b.clear();for(const[n,t]of e)V(n)===t.logicalHeight&&ee(n,{allowMarkdownShrink:t.allowMarkdownShrink});X()}function Q(){J(),X()}function ee(n,t={}){const o=function(e){return Ui(s.get(e),C)}(n),l=z(n);let r=!1;const i=()=>{r||(r=!0,function(n,t){const o=function(){if(!0!==e.debug||0===y.size)return null;let n=0;for(const e of y.values())n+=e;const t={total:n,byLabel:Object.fromEntries(Array.from(y.entries()).sort((e,n)=>n[1]-e[1]||e[0].localeCompare(n[0])))};return y.clear(),t}();o&&console.info("[markstream-vue][virtual-adapter][perf] layout-reads",{label:n,itemKey:t,layoutReads:o})}("reconcileItemSize",n))};if(!function(e){const n=K(e);return!!n&&H(n.item,n.index)}(n))return o>0&&Z(n,o),void i();const a=V(n),u=function(e,n){return Xi(s.get(e),C,n)}(n,o);if(a>0){let e=Math.max(o,a+u);return(!t.allowMarkdownShrink||c.value)&&l>0&&(e=Math.max(e,l)),e>0&&Z(n,e),void i()}const d=K(n);return d&&!Ji(d.item,d.index,e).trim()?(o>0&&Z(n,o),void i()):l>0?(o>l+1&&Z(n,o),void i()):(o>0&&Z(n,o),void i())}function ne(){const e={},n=T();for(let t=0;t<n.length;t++){const o=I(n[t],t),l=z(o);Number.isFinite(l)&&l>0&&(e[o]=l)}return e}function te(){const e={},n=T();for(let o=0;o<n.length;o++){const l=I(n[o],o),r=t.get(l);j(l,r)&&(e[l]=r)}return e}function le(){const e={};for(const[n,t]of o)e[n]=t;return e}function re(){const n=e.virtualizer.getScrollTop(),t=e.virtualizer.getViewportHeight(),o=e.virtualizer.getTotalHeight()-t-n;if(o<=2)return{type:"bottom",distanceFromBottomPx:Math.max(0,o)};const l=T();for(let a=0;a<l.length;a++){const t=I(l[a],a),o=e.virtualizer.getItemOffset(t),r=e.virtualizer.getItemSize(t);if(n>=o&&n<o+r)return{type:"item",itemKey:t,offsetWithinItemPx:n-o}}const r=e.virtualizer.getVisibleRange(),i=l[r.start];return i?{type:"item",itemKey:I(i,r.start),offsetWithinItemPx:0}:void 0}function ie(i){var a;if(!i)return n.clear(),t.clear(),o.clear(),l.clear(),void r.clear();(function(o){var l,r;if(n.clear(),t.clear(),function(e){var n,t;return(null!=(n=e.measurementKey)?n:"")===(null!=(t=R())?t:"")}(o))for(const[i,a]of Object.entries(null!=(l=o.itemHeights)?l:{})){const l=U(a),u=null==(r=o.itemSizeSources)?void 0:r[i];null!=l&&j(i,u)&&(n.set(i,l),t.set(i,u),e.virtualizer.setItemSize(i,l))}})(i),function(e){o.clear(),l.clear(),r.clear();for(const[n,t]of Object.entries(e))o.set(n,t),W(n,t,{trustImportedState:!0})}(null!=(a=i.markdownStates)?a:{})}function ae(n){if(!n)return;if("bottom"===n.type){const t=Math.max(0,e.virtualizer.getTotalHeight()-e.virtualizer.getViewportHeight()-n.distanceFromBottomPx);return void e.virtualizer.scrollToOffset(t)}const t=Math.max(0,e.virtualizer.getItemOffset(n.itemKey)+n.offsetWithinItemPx);e.virtualizer.scrollToOffset(t)}function ue(e,n){e===v&&ae(n)}function se(e){e===v&&(c.value=!1,Q(),ue(e,m),m=void 0,g=0)}function ce(){Y(),_(M),S=!1,M=null,k=void 0,_(x),w=!1,x=null,b.clear();for(const e of d.values())e.disconnect();d.clear(),s.clear(),t.clear(),l.clear(),r.clear(),i.clear()}return ye()&&de(ce),{itemHeights:n,markdownStates:o,getItemKey:I,isMarkdownItem:H,isRestoringThread:()=>c.value,measureItem:function(n,t,o){var l,r;const i=I(n,t),a=function(e){const n=e&&"$el"in e?e.$el:e;return n instanceof HTMLElement?n:null}(o),u=s.get(i);if(!a)return void G(i);if(u===a)return void ee(i);if(G(i),s.set(i,a),null==(r=(l=e.virtualizer).measureElement)||r.call(l,i,a),ee(i),"undefined"==typeof ResizeObserver)return;const c=new ResizeObserver(()=>{var n,t;a.isConnected&&(null==(t=(n=e.virtualizer).measureElement)||t.call(n,i,a),ee(i))});c.observe(a),d.set(i,c)},unobserveItem:function(e){G(e)},releaseDetached:function(){let e=0;for(const[n,t]of s)t.isConnected||(G(n),e++);return e},markdownProps:function(n,t){const l=I(n,t),r=Qi(n,t,e),a=B(),u=Ji(n,t,e),s=$(n,t),d=A(),c=P(),f=F(),m=[l,s,r?"final":"live",d,c,f,!0===e.markdownFade?"fade":"no-fade"].join(":"),v=Se(o).get(l),h=i.get(m);if(h&&h.content===u)return h.virtualScroll&&(h.virtualScroll.restoreState=E(l,v)?v:null),h;const p={enabled:!0,sessionKey:s,threadKey:a,scrollRoot:()=>e.virtualizer.getScrollElement(),restoreState:E(l,v)?v:null,restoreAnchor:!1,measurementKey:d,settleMode:"manual",settledToken:r,emitIntervalMs:96,heightDiffThresholdPx:4},g={content:u,final:r,mode:c,renderCodeBlocksAsPre:f,nodeVirtual:!!r&&"auto",maxLiveNodes:r?50:void 0,liveNodeBuffer:r?16:void 0,fade:!0===e.markdownFade,indexKey:s,virtualScroll:p,onHeightChange(e){if(e.sessionKey!==$(n,t))return;D(l,e.totalHeight,{sessionKey:e.sessionKey,threadKey:a,measurementKey:A()});const o=function(e){return"final"===e.phase||!(!0!==e.final||!Yi(e.confidence))||!!e.stable&&(Yi(e.confidence)||function(e){var n,t,o,l;const r=Number(e.nodeCount),i=Number(e.measuredCount),a=Math.max(0,Number(null!=(t=null==(n=e.liveRange)?void 0:n.start)?t:0)),u=Math.min(r,Math.max(a,Number(null!=(l=null==(o=e.liveRange)?void 0:o.end)?l:0))),s=Math.max(0,u-a);return!0===e.final&&!0===e.stable&&"mixed"===e.confidence&&r>0&&i>0&&i<r&&(s<=0||i>=s)}(e))}(e),r=Math.ceil(e.totalHeight);var i,u;i=l,u={allowMarkdownShrink:o,logicalHeight:r},b.set(i,u),w||(w=!0,x=N(J))},onVirtualStateChange(e){e.sessionKey===$(n,t)&&(o.set(l,e),p.restoreState=e,W(l,e))}};return i.set(m,g),g},captureThreadState:function(){Q();const e=R();return u(a({threadKey:B()},null==e?{}:{measurementKey:e}),{outerAnchor:re(),itemHeights:ne(),itemSizeSources:te(),markdownStates:le()})},preloadThreadState:ie,restoreThreadState:function(e){const n=++v,t=null==e?void 0:e.outerAnchor;if(Y(),c.value=Boolean(t),g=n,m=t,ie(e),!t)return c.value=!1,m=void 0,void(g=0);ue(n,t),oe(()=>{ue(n,t),"function"==typeof requestAnimationFrame&&(h=requestAnimationFrame(()=>{h=null,ue(n,t)})),"undefined"!=typeof window?f.forEach((e,o)=>{const l=window.setTimeout(()=>{ue(n,t),o===f.length-1&&se(n)},e);p.push(l)}):se(n)})},dispose:ce}}const la=/* @__PURE__ */Symbol("markstreamLanguageIconResolver");let ra=null;function ia(e){ra=null!=e?e:null}function aa(){return ra}function ua(){ra=null}function sa(){var e;try{null==(e=null==ra?void 0:ra.terminate)||e.call(ra)}catch(n){}ra=null}function da(e){return s(this,null,function*(){const n=ra;if(n&&"function"==typeof n.setRenderOptions)try{yield n.setRenderOptions({theme:e})}catch(t){}})}function ca(e){return le(e)}const fa=ca(()=>import("./index3.js")),ma=ca(()=>import("./index5.js")),va=ca(()=>import("./index6.js")),ha=ca(()=>import("./index10.js")),pa=ca(()=>import("./index8.js")),ga=ca(()=>import("./index9.js")),ya=ca(()=>import("./index4.js")),ba=ca(()=>import("./index7.js")),ka={MarkdownRender:mi,NodeRenderer:mi,AdmonitionNode:xi,BlockquoteNode:jo,CheckboxNode:un,CodeBlockNode:fa,DefinitionListNode:Do,EmojiNode:dn,EmphasisNode:Bo,FootnoteNode:Xo,FootnoteReferenceNode:hn,FootnoteAnchorNode:Vo,HardBreakNode:Ho,HeadingNode:Go,HtmlBlockNode:al,HtmlInlineNode:Tn,HighlightNode:_o,ImageNode:bt,D2BlockNode:ga,InfographicBlockNode:pa,InlineCodeNode:Rn,PreCodeNode:Ft,InsertNode:Co,LinkNode:So,ListItemNode:tl,ListNode:ol,MathBlockNode:ma,MathInlineNode:va,MermaidBlockNode:ha,ParagraphNode:dl,StrikethroughNode:yo,StrongNode:po,SubscriptNode:vo,SuperscriptNode:fo,TableNode:yl,TextNode:Ot,ThematicBreakNode:kl,VmrContainerNode:Sl,ReferenceNode:so,MarkstreamVirtualTimeline:ba,Tooltip:ya},wa={install(e,n){var t,o;Object.entries(ka).forEach(([n,t])=>{e.component(n,t)}),(null==n?void 0:n.iconTheme)&&Be(n.iconTheme),n&&"languageIconResolver"in n&&e.provide(la,null!=(t=n.languageIconResolver)?t:null),(null==n?void 0:n.getLanguageIcon)&&Ie(n.getLanguageIcon),(null==n?void 0:n.mathOptions)&&R(n.mathOptions),n&&"infographicLoader"in n&&ji(null!=(o=n.infographicLoader)?o:null),(null==n?void 0:n.defaultI18nMap)&&e.provide(Jn,n.defaultI18nMap),(null==n?void 0:n.components)&&e.provide(Ue,function(e={}){return P(Ge(e))}(n.components))}};export{Qe as $,xi as A,jo as B,un as C,ga as D,dn as E,Vo as F,an as G,Ho as H,bt as I,Ft as J,Xo as K,So as L,la as M,tn as N,ua as O,dl as P,$i as Q,so as R,yo as S,yl as T,Li as U,Sl as V,Hi as W,zi as X,Xt as Y,ta as Z,Go as _,fa as a,Pi as a0,Di as a1,Xi as a2,Ji as a3,Qi as a4,Zi as a5,Gi as a6,ea as a7,aa as a8,Zn as a9,Yr as aA,ft as aB,st as aC,Ri as aa,Et as ab,Ei as ac,na as ad,Zt as ae,Ui as af,nn as ag,Dt as ah,Kt as ai,jt as aj,mt as ak,Yt as al,Gt as am,no as an,Je as ao,Ii as ap,Qn as aq,ji as ar,ia as as,Yn as at,da as au,sa as av,oa as aw,er as ax,dt as ay,ot as az,Jt as b,Qt as c,Do as d,Bo as e,hn as f,_o as g,al as h,Tn as i,pa as j,Rn as k,Co as l,tl as m,ol as n,ba as o,ma as p,va as q,ha as r,po as s,vo as t,fo as u,Ot as v,kl as w,ya as x,wa as y,mi as z};
|