markstream-vue 1.1.3 → 1.1.5
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/index11.js +1 -1
- package/dist/index9.js +1 -1
- package/dist/tailwind.js +0 -0
- package/package.json +3 -3
package/dist/index11.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=Math.pow,i=(t,n,l)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[n]=l,u=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&i(e,n,t[n]);if(l)for(var n of l(t))r.call(t,n)&&i(e,n,t[n]);return e},s=(e,t,n)=>new Promise((l,o)=>{var r=e=>{try{i(n.next(e))}catch(t){o(t)}},a=e=>{try{i(n.throw(e))}catch(t){o(t)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,a);i((n=n.apply(e,t)).next())});import{defineComponent as c,ref as d,computed as v,useAttrs as m,inject as f,watch as h,onBeforeUnmount as g,nextTick as p,onMounted as w,onUnmounted as y,openBlock as k,createElementBlock as x,normalizeClass as b,renderSlot as M,createElementVNode as T,unref as C,toDisplayString as B,createCommentVNode as E,normalizeStyle as O,withDirectives as P,mergeProps as S,toHandlers as D,createBlock as R,Teleport as F,createVNode as $,Transition as j,withCtx as z,withModifiers as A,vShow as L}from"vue";import{ao as H,as as _,ap as N,ar as I,ag as W,a6 as X,al as Y,z as q}from"./exports.js";import{p as V,b as U,g as Z,a as K}from"./diagramHeight.js";import{e as G}from"./mermaidSequenceSemicolons.js";import{M as J}from"./index2.js";import{safeRaf as Q}from"./utils/safeRaf.js";import{c as ee,g as te,f as ne}from"./workers-mermaidWorkerClient.js";import{toSafeSvgElement as le}from"stream-markdown-parser";const oe=["data-markstream-mode","data-markstream-pending"],re={key:0,class:"mermaid-block-header flex items-center justify-between border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)]"},ae={key:0},ie={key:1,class:"flex items-center gap-x-2 overflow-hidden"},ue=["innerHTML"],se={key:2},ce={key:3,class:"mermaid-mode-toggle-group flex items-center gap-0.5"},de={class:"flex items-center gap-x-1"},ve={class:"flex items-center gap-x-1"},me={key:4},fe={key:5,class:"mermaid-header-actions flex items-center"},he=["aria-pressed"],ge={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},pe={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},we=["aria-label","disabled"],ye=["aria-label","disabled"],ke={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},xe={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},be={key:0,class:"mermaid-source-panel"},Me={class:"mermaid-source-code text-sm font-mono whitespace-pre-wrap"},Te={key:1,class:"relative"},Ce={key:0,class:"absolute top-2 right-2 z-10 rounded-lg"},Be={class:"flex items-center gap-2 backdrop-blur rounded-lg"},Ee={class:"dialog-panel mermaid-modal-panel relative w-full h-full max-w-full max-h-full rounded overflow-hidden"},Oe={class:"absolute top-6 right-6 z-50 flex items-center gap-2"},Pe="mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded",Se=/* @__PURE__ */q(/* @__PURE__ */c({__name:"MermaidBlockNode",props:{node:{},maxHeight:{default:void 0},estimatedPreviewHeightPx:{},loading:{type:Boolean,default:!0},isDark:{type:Boolean},workerTimeoutMs:{default:1400},parseTimeoutMs:{default:1800},renderTimeoutMs:{default:2500},fullRenderTimeoutMs:{default:4e3},renderDebounceMs:{default:300},contentStableDelayMs:{default:500},previewPollDelayMs:{default:800},previewPollMaxDelayMs:{default:4e3},previewPollMaxAttempts:{default:12},showHeader:{type:Boolean,default:!0},showModeToggle:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExportButton:{type:Boolean,default:!0},showFullscreenButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showZoomControls:{type:Boolean,default:!0},enableWheelZoom:{type:Boolean,default:!1},isStrict:{type:Boolean,default:!0},enableMermaidInteractions:{type:Boolean,default:!1},showTooltips:{type:Boolean,default:!0},onRenderError:{}},emits:["copy","export","openModal","toggleMode"],setup(e,{emit:l}){var o,r;const i=e,c=l,q={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style","br"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},Se=d(!1),De=d("undefined"==typeof window),Re=H(),Fe=_(),$e=v(()=>i.isStrict?"strict":"loose"),je=v(()=>({startOnLoad:!1,securityLevel:$e.value,dompurifyConfig:"strict"===$e.value?q:void 0,htmlLabels:"strict"!==$e.value&&void 0,flowchart:"strict"===$e.value?{htmlLabels:!1}:void 0}));function ze(e){if(e)try{e.replaceChildren()}catch(t){e.innerHTML=""}}function Ae(e,t,n={}){if(!e)return null;const l=function(e,t){if(!e)return null;const n=le(t);if(!n)return null;const l=function(e,t){const n=Array.from(e.childNodes),l=document.createElement("div");return l.dataset.mermaidSvgLayer="1",l.style.zIndex="1",l.appendChild(t),e.insertBefore(l,e.firstChild),n.length>0&&function(e){const t=()=>{var t;for(const n of e)null==(t=n.parentNode)||t.removeChild(n)};"function"==typeof requestAnimationFrame?requestAnimationFrame(()=>{requestAnimationFrame(t)}):setTimeout(t,32)}(n),l}(e,n);return{svg:n.outerHTML,bindTarget:l}}(e,t);return l||n.keepPreviousOnFailure||ze(e),l}let Le=null;function He(e){if(i.enableMermaidInteractions&&(null==e?void 0:e.querySelector("svg")))try{null==Le||Le(e)}catch(t){}}const{t:_e}=N();let Ne=!1,Ie=0;function We(){return s(this,null,function*(){try{const e=yield te();return Ne?null:(Se.value=!!e,e)}catch(e){throw Ne||(Se.value=!1),e}finally{Ne||(De.value=!0)}})}const Xe=d(!1),Ye=d(!1),qe=d(),Ve=d(),Ue=d(),Ze=d(),Ke=d(null),Ge=I(),Je=d(null),Qe=d("undefined"==typeof window||!Re.value),et=m(),tt=f(J,null);let nt="",lt=0,ot=0;const rt=v(()=>W(i,et));function at(){const e=rt.value;e&&(nt&&nt!==e&&(null==tt||tt.markSettled(nt),lt=0),nt=e,lt+=1,ot+=1,1===lt&&(null==tt||tt.markPending(e)))}function it(){return s(this,null,function*(){const e=nt;if(!e)return;if(lt=Math.max(0,lt-1),lt>0)return;nt="";const t=++ot;yield p(),t===ot&&(function(e=rt.value){e&&qe.value&&(null==tt||tt.reportHeight(e,qe.value.offsetHeight))}(e),null==tt||tt.markSettled(e))})}function ut(){const e=nt;e&&(nt="",lt=0,ot+=1,null==tt||tt.markSettled(e))}const st=d(),ct=v(()=>i.node.code.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"));function dt(e,t=ct.value){const n=t,l={theme:"dark"===e?"dark":"default"};"strict"===$e.value&&(l.htmlLabels=!1,l.flowchart={htmlLabels:!1});const o=`%%{init: ${JSON.stringify(l)}}%%\n`;return n.trim().startsWith("%%{")?n:o+n}function vt(){var e;return function(e){const t=function(){var e;const t=Ve.value?getComputedStyle(Ve.value).getPropertyValue("--ms-size-diagram-min-height").trim():"";return null!=(e=V(t))?e:360}(),n=An();return K(e,t,n)}(null!=(e=V(i.estimatedPreviewHeightPx))?e:U(ct.value))}function mt(){return`${vt()}px`}const ft=d(null);function ht(){var e;return!!(null==(e=Ue.value)?void 0:e.querySelector("svg"))}function gt(){return!1!==i.loading&&(ht()||!!ft.value)}const pt=d(1),wt=d(0),yt=d(0),kt=d(!1),xt=d({x:0,y:0}),bt=d(!0),Mt=d(!1),Tt=d(!1),Ct=d(null);let Bt="",Et=!1,Ot="";const Pt=d(0),St=d(!1),Dt=v(()=>{var e;return Math.max(0,null!=(e=i.renderDebounceMs)?e:300)}),Rt=v(()=>{var e;return Math.max(0,null!=(e=i.contentStableDelayMs)?e:500)}),Ft=v(()=>{var e;return Math.max(120,null!=(e=i.previewPollDelayMs)?e:800)}),$t=v(()=>{var e;return Math.max(Ft.value,null!=(e=i.previewPollMaxDelayMs)?e:4e3)}),jt=v(()=>{var e;return Math.max(1,Math.trunc(null!=(e=i.previewPollMaxAttempts)?e:12))}),zt=v(()=>!1!==i.loading);let At=null,Lt=null,Ht=null,_t=null,Nt=0;const It=null!=(o=globalThis.requestIdleCallback)?o:(e,t)=>setTimeout(()=>e({didTimeout:!0}),16),Wt=null!=(r=globalThis.cancelIdleCallback)?r:e=>clearTimeout(e);function Xt(e=Ie){return!Ne&&e===Ie}function Yt(){return Xt()&&Qe.value&&!Ye.value}function qt(){null!=Ht&&(globalThis.clearTimeout(Ht),Ht=null),null!=_t&&(Wt(_t),_t=null)}function Vt(){Ne||null==Ht&&null==_t&&(Ht=globalThis.setTimeout(()=>{Ht=null,Yt()&&(_t=It(()=>{_t=null,Yt()&&il()},{timeout:500}))},Dt.value))}function Ut(){null!=Lt&&(globalThis.clearTimeout(Lt),Lt=null)}function Zt(e=600){if("undefined"==typeof globalThis||Ne)return;const t=Math.max(0,e);Ut(),Lt=globalThis.setTimeout(()=>{if(Lt=null,!Ne){if(i.loading||Tt.value||!Yt())return void Zt(Math.min(1200,Math.max(300,1.2*t)));Vt()}},t)}const Kt=d(mt()),Gt=d(Kt.value);let Jt=null;const Qt=d(!1),en=d(!1),tn=d({}),nn=d(0);let ln=null,on=null;const rn=d(!1),an=v(()=>{var e,t;return!(Ye.value||bt.value||De.value&&!Tt.value&&!Ct.value&&(Qt.value||rn.value&&Boolean(null==(t=null==(e=Ue.value)?void 0:e.textContent)?void 0:t.trim())))}),un=d({zoom:1,translateX:0,translateY:0,containerHeight:Kt.value}),sn=v(()=>i.enableWheelZoom?{wheel:Kn}:{}),cn=v(()=>{var e,t,n,l;return{worker:null!=(e=i.workerTimeoutMs)?e:1400,parse:null!=(t=i.parseTimeoutMs)?t:1800,render:null!=(n=i.renderTimeoutMs)?n:2500,fullRender:null!=(l=i.fullRenderTimeoutMs)?l:4e3}});let dn=null,vn=null,mn=!1,fn=Ft.value,hn=null,gn=0,pn=!0,wn=0;function yn(e,t){const n=null==t?void 0:t.timeoutMs,l=null==t?void 0:t.signal;if(null==l?void 0:l.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));let o=null,r=!1,a=null;return new Promise((t,i)=>{const u=()=>{null!=o&&clearTimeout(o),a&&l&&l.removeEventListener("abort",a)};n&&n>0&&(o=globalThis.setTimeout(()=>{r||(r=!0,u(),i(new Error("Operation timed out")))},n)),l&&(a=()=>{r||(r=!0,u(),i(new DOMException("Aborted","AbortError")))},l.addEventListener("abort",a)),e().then(e=>{r||(r=!0,u(),t(e))}).catch(e=>{r||(r=!0,u(),i(e))})})}function kn(e){if("undefined"==typeof document)return;if(!Ue.value)return;if("function"==typeof i.onRenderError&&!0===i.onRenderError(e,ct.value,Ue.value))return rn.value=!0,void ul();const t=document.createElement("div");t.style.padding="var(--ms-inset-panel-body)",t.style.color="hsl(var(--ms-destructive))",t.textContent="Failed to render diagram: ";const n=document.createElement("span");n.textContent=e instanceof Error?e.message:"Unknown error",t.appendChild(n),ze(Ue.value),Ue.value.appendChild(t);const l=Ue.value?getComputedStyle(Ue.value).getPropertyValue("--ms-size-diagram-min-height").trim():"";Kt.value=l||"360px",Gt.value=Kt.value,rn.value=!0,ul()}function xn(e){const t="string"==typeof e?e:"string"==typeof(null==e?void 0:e.message)?e.message:"";return"string"==typeof t&&/timed out/i.test(t)}function bn(e){return"AbortError"===(null==e?void 0:e.name)}function Mn(e){return!xn(e)&&!bn(e)}"undefined"!=typeof window&&h([()=>qe.value,Re],([e,t])=>{var n;if(null==(n=Je.value)||n.destroy(),Je.value=null,!t||Qe.value)return void(Qe.value=!0);if(!e)return void(Qe.value=!1);const l=Ge(e,{rootMargin:null==Fe?void 0:Fe.value.heavyBlockMargin,allowIdle:!1});Je.value=l,Qe.value=l.isVisible.value,l.whenVisible.then(()=>{Qe.value=!0})},{immediate:!0}),g(()=>{var e;Ne=!0,Ie+=1,nn.value+=1,null==(e=Je.value)||e.destroy(),Je.value=null,ut(),qt()});const Tn=v(()=>!1!==i.showTooltips);function Cn(e){return!e||e.disabled}function Bn(e,t,n="top"){if(!Tn.value)return;if(Cn(e.currentTarget))return;const l=e,o=null!=(null==l?void 0:l.clientX)&&null!=(null==l?void 0:l.clientY)?{x:l.clientX,y:l.clientY}:void 0;Y(e.currentTarget,t,n,!1,o,i.isDark)}function En(){Tn.value&&X()}function On(e){if(!Tn.value)return;if(Cn(e.currentTarget))return;const t=Xe.value?_e("common.copied")||"Copied":_e("common.copy")||"Copy",n=e,l=null!=(null==n?void 0:n.clientX)&&null!=(null==n?void 0:n.clientY)?{x:n.clientX,y:n.clientY}:void 0;Y(e.currentTarget,t,"top",!1,l,i.isDark)}function Pn(e,t){const n={theme:"dark"===t?"dark":"default"};"strict"===$e.value&&(n.htmlLabels=!1,n.flowchart={htmlLabels:!1});const l=`%%{init: ${JSON.stringify(n)}}%%\n`;return e.trimStart().startsWith("%%{")?e:l+e}function Sn(){return pn&&!bt.value&&!Qt.value&&!rn.value}function Dn(e){const t=e.trim();return!(!t||t.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(t)&&t.includes(":")}function Rn(e){if("gantt"===Z(e))return function(e){var t;const n=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&n.length>0&&n.pop();n.length>0;){const e=null==(t=n[n.length-1])?void 0:t.trim();if(e&&!e.startsWith("%%")){if(Dn(e))break;n.pop()}else n.pop()}return n.some(Dn)?n.join("\n"):""}(e);const t=e.split(/\r?\n/);for(;t.length>0;){const e=t[t.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join("\n")}function Fn(e,t,n,l){return s(this,null,function*(){try{return yield yn(()=>e.render(t,n),{timeoutMs:l})}catch(o){if(!Mn(o))throw o;const a=G(n);if(a===n)throw o;try{return yield yn(()=>e.render(`${t}-retry`,a),{timeoutMs:l})}catch(r){throw o}}})}function $n(e,t,n){return s(this,null,function*(){var l;try{return yield ee(e,t,null!=(l=null==n?void 0:n.timeoutMs)?l:cn.value.worker,null==n?void 0:n.signal)}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o;const l=(null==o?void 0:o.code)||(null==o?void 0:o.name);if("WORKER_BUSY"!==l&&"WORKER_TIMEOUT"!==l&&"WORKER_INIT_ERROR"!==l&&"MERMAID_DISABLED"!==l&&"WORKER_REPLACED"!==l||(null==o?void 0:o.fallbackToRenderer))return yield function(e,t,n){return s(this,null,function*(){var l,r,a,i;const u=yield We();if(!u)return;const s=u,c=Pn(e,t);if("function"==typeof s.parse){try{yield yn(()=>s.parse(c),{timeoutMs:null!=(l=null==n?void 0:n.timeoutMs)?l:cn.value.parse,signal:null==n?void 0:n.signal})}catch(o){if(!Mn(o))throw o;const t=G(c);if(t===c)throw o;try{yield yn(()=>s.parse(t),{timeoutMs:null!=(r=null==n?void 0:n.timeoutMs)?r:cn.value.parse,signal:null==n?void 0:n.signal})}catch(v){throw o}}return!0}const d=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;try{yield yn(()=>u.render(d,c),{timeoutMs:null!=(a=null==n?void 0:n.timeoutMs)?a:cn.value.render,signal:null==n?void 0:n.signal})}catch(o){if(!Mn(o))throw o;const t=G(c);if(t===c)throw o;try{yield yn(()=>u.render(`${d}-retry`,t),{timeoutMs:null!=(i=null==n?void 0:n.timeoutMs)?i:cn.value.render,signal:null==n?void 0:n.signal})}catch(v){throw o}}return!0})}(e,t,n);throw o}})}function jn(e,t,n){return s(this,null,function*(){var l;if("gantt"===Z(e)){const l=Rn(e);if(!l.trim())return{fullOk:!1,prefixOk:!1};try{if(yield $n(l,t,n))return l===e?{fullOk:!0,prefixOk:!1}:{fullOk:!1,prefixOk:!0,prefix:l}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}}try{if(yield $n(e,t,n))return{fullOk:!0,prefixOk:!1}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}let o=Rn(e);if(o&&o.trim()&&o!==e)try{try{const r=yield ne(e,t,null!=(l=null==n?void 0:n.timeoutMs)?l:cn.value.worker,null==n?void 0:n.signal);r&&r.trim()&&(o=r)}catch(r){}if(yield $n(o,t,n))return{fullOk:!1,prefixOk:!0,prefix:o}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}})}const zn=v(()=>bt.value||Tt.value||Ye.value);function An(){if("none"===i.maxHeight)return null;if(null!=i.maxHeight){const e=Number.parseFloat(String(i.maxHeight));if(Number.isFinite(e))return e}const e=Ve.value;if(e){const t=getComputedStyle(e).getPropertyValue("--ms-size-code-max-height").trim(),n=Number.parseFloat(t);if(Number.isFinite(n))return n}return 500}function Ln(e,t){if(!Ve.value||!Ue.value)return;const n=!(null==t?void 0:t.force)&&!1!==i.loading&&ht(),l=Ue.value.querySelector("svg");if(!l)return;let o=0,r=0;const a=l.getAttribute("viewBox"),u=l.getAttribute("width"),s=l.getAttribute("height");if(a){const e=a.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),r=Number.parseFloat(e[3]))}if(o&&r||u&&s&&(o=Number.parseFloat(u),r=Number.parseFloat(s)),Number.isNaN(o)||Number.isNaN(r)||o<=0||r<=0)try{const e=l.getBBox();e&&e.width>0&&e.height>0&&(o=e.width,r=e.height)}catch(c){return void console.error("Failed to get SVG BBox:",c)}if(o>0&&r>0){const t=r/o,a=null!=e?e:Ve.value.clientWidth,u=l.getBoundingClientRect().width,s=u>0?u/Math.max(.01,pt.value):a,c=An(),d=s*t,v=null==c?d:Math.min(d,c),m=Math.max(v,vt());Gt.value=`${Math.max(d,m)}px`,n||null!=V(i.estimatedPreviewHeightPx)||(Kt.value=`${m}px`)}}const Hn=d(!1),_n=v(()=>({transform:`translate(${wt.value}px, ${yt.value}px) scale(${pt.value})`}));function Nn(e){"Escape"===e.key&&Hn.value&&Wn()}function In(){var e;if(!Ve.value||!Ze.value)return!1;if("1"===(null==(e=Ze.value.firstElementChild)?void 0:e.getAttribute("data-mermaid-modal-clone")))return!0;const t=Ve.value.cloneNode(!0);t.dataset.mermaidModalClone="1",t.classList.add("fullscreen"),t.style.height="100%",t.style.maxHeight="100%";const n=t.querySelector("._mermaid");n&&(n.style.contain="none",n.style.contentVisibility="visible");const l=t.querySelector("[data-mermaid-wrapper]");return l&&(Ke.value=l,l.style.transform=_n.value.transform),ze(Ze.value),Ze.value.appendChild(t),He(t),!0}function Wn(){if(Hn.value=!1,Ze.value&&ze(Ze.value),Ke.value=null,"undefined"!=typeof document)try{document.body.style.overflow=""}catch(e){}if("undefined"!=typeof window)try{window.removeEventListener("keydown",Nn)}catch(e){}}function Xn(){pt.value<3&&(pt.value+=.1)}function Yn(){pt.value>.5&&(pt.value-=.1)}function qn(){pt.value=1,wt.value=0,yt.value=0}function Vn(e){kt.value=!0,e instanceof MouseEvent?xt.value={x:e.clientX-wt.value,y:e.clientY-yt.value}:xt.value={x:e.touches[0].clientX-wt.value,y:e.touches[0].clientY-yt.value}}function Un(e){if(!kt.value)return;let t,n;e instanceof MouseEvent?(t=e.clientX,n=e.clientY):(t=e.touches[0].clientX,n=e.touches[0].clientY),wt.value=t-xt.value.x,yt.value=n-xt.value.y}function Zn(){kt.value=!1}function Kn(e){if(i.enableWheelZoom&&(e.ctrlKey||e.metaKey)){if(e.preventDefault(),!Ve.value)return;const t=Ve.value.getBoundingClientRect(),n=e.clientX-t.left,l=e.clientY-t.top,o=n-t.width/2,r=l-t.height/2,a=(o-wt.value)/pt.value,i=(r-yt.value)/pt.value,u=.01,s=-e.deltaY*u,c=Math.min(Math.max(pt.value+s,.5),3);c!==pt.value&&(wt.value=o-a*c,yt.value=r-i*c,pt.value=c)}}function Gn(){return s(this,null,function*(){try{const e=ct.value,t={payload:{type:"copy",text:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(c("copy",t),t.defaultPrevented)return;"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(e)),Xe.value=!0,setTimeout(()=>{Xe.value=!1},1e3)}catch(e){console.error("Failed to copy:",e)}})}function Jn(){var e;const t=null==(e=Ue.value)?void 0:e.querySelector("svg");if(!t)return void console.error("SVG element not found");const n=(new XMLSerializer).serializeToString(t),l={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:t,svgString:n};c("export",l),l.defaultPrevented||function(e,t=null){s(this,null,function*(){try{const l=null!=t?t:(new XMLSerializer).serializeToString(e),o=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(o);if("undefined"!=typeof document){const e=document.createElement("a");e.href=r,e.download=`mermaid-diagram-${Date.now()}.svg`;try{document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch(n){}URL.revokeObjectURL(r)}}catch(l){console.error("Failed to export SVG:",l)}})}(t,n)}function Qn(){var e,t;const n=null!=(t=null==(e=Ue.value)?void 0:e.querySelector("svg"))?t:null,l=n?(new XMLSerializer).serializeToString(n):null,o={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:n,svgString:l};c("openModal",o),o.defaultPrevented||function(){if(Hn.value=!0,"undefined"!=typeof document)try{document.body.style.overflow="hidden"}catch(e){}if("undefined"!=typeof window)try{window.addEventListener("keydown",Nn)}catch(e){}p(()=>{In()||p(In)})}()}function el(e){const t={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};c("toggleMode",e,t),t.defaultPrevented||tl(e)}function tl(e){return s(this,null,function*(){const t=st.value;if(!t)return Mt.value=!0,void(bt.value="source"===e);const n=t.getBoundingClientRect().height;t.style.height=`${n}px`,t.style.overflow="hidden",Mt.value=!0,bt.value="source"===e,yield p();const l=t.scrollHeight;t.style.transition="height var(--ms-duration-standard) var(--ms-ease-standard)",t.offsetHeight,t.style.height=`${l}px`;const o=()=>{t.style.transition="",t.style.height="",t.style.overflow="",t.removeEventListener("transitionend",r)};function r(){o()}t.addEventListener("transitionend",r),setTimeout(()=>o(),220)})}function nl(e=ct.value,t=(i.isDark?"dark":"light"),n=!1===i.loading){return{code:e,codeWithTheme:dt(t,e),final:n,signature:`${t}\0${e}`,theme:t}}function ll(e){return e.signature===nl().signature}function ol(){return s(this,arguments,function*(e=nl()){const l=Ie;if(!Xt(l)||!ll(e))return!1;if(Tt.value){const t=Ct.value,n=Et,o=Bt;if(!t)return!1;const r=yield t;return!(!Xt(l)||!ll(e))&&(o===e.signature?!(!r||Ot!==e.signature)||!(!e.final||!1!==i.loading||n)&&ol(e):ol(e))}if(!Ue.value){if(yield p(),!Xt(l))return!1;if(!Ue.value)return console.warn("Mermaid container not ready"),!1}return!(!Xt(l)||!ll(e))&&(Tt.value=!0,Et=e.final,Bt=e.signature,at(),Ct.value=s(null,null,function*(){var o,r,a,s;try{const c=yield We();if(!Xt(l)||!c)return!1;const d=`mermaid-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;Qt.value||en.value||null==(o=c.initialize)||o.call(c,(a=u({},je.value),s={dompurifyConfig:u({},q)},t(a,n(s))));const v=yield Fn(c,d,e.codeWithTheme,cn.value.fullRender);if(!Xt(l)||!function(e){return ll(e)||!e.final&&!1!==i.loading&&ct.value.startsWith(e.code)}(e))return en.value&&(en.value=!1),!1;if(!Ue.value)return!1;const m=Ae(Ue.value,null==v?void 0:v.svg,{keepPreviousOnFailure:!e.final||!1!==i.loading});if(!m)return en.value&&(en.value=!1),!1;const f=null!=(r=null==v?void 0:v.bindFunctions)?r:null;return Le=f,He(m.bindTarget),Qt.value||en.value||(Q(()=>Ln()),Qt.value=!0,un.value={zoom:pt.value,translateX:wt.value,translateY:yt.value,containerHeight:Kt.value}),tn.value[e.theme]={svg:m.svg,bindFunctions:f},en.value&&(en.value=!1),Ot=e.signature,ft.value=Ue.value.innerHTML,rn.value=!1,Nt=0,Ut(),!0}catch(c){if(!Xt(l)||!ll(e))return en.value&&(en.value=!1),!1;const t=xn(c),n=Nt+1;return t&&n<=3?(Nt=n,Zt(Math.min(1200,600*n))):(Nt=0,Ut(),e.final&&!1===i.loading&&console.error("Failed to render mermaid diagram:",c),e.final&&!1===i.loading&&kn(c)),!1}finally{Et=!1,Bt="",Tt.value=!1,Ct.value=null,Xt(l)&&it()}}),Ct.value)})}function rl(){return s(this,null,function*(){var e;const t=ct.value;if(!t.trim()){if(gt())return;return Ue.value&&ze(Ue.value),ft.value=null,Ot="",void(rn.value=!1)}if(!Se.value||!Yt())return;const n=nl(t);Qt.value&&n.signature===Ot&&(null==(e=Ue.value)?void 0:e.querySelector("svg"))||(yield ol(n))&&(rn.value=!1)})}function al(e,t,n,l){return s(this,null,function*(){const o=Ie;if(!Xt(o)||!Sn())return;if(!Ue.value&&(yield p(),!Xt(o)||!Ue.value))return;if(Tt.value)return;Tt.value=!0,at();const r=nl(t,n),a=s(null,null,function*(){var t;try{const a=yield We();if(!Xt(o)||!a)return!1;const u=`mermaid-partial-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,s=Rn(e),c=s&&s.trim()?s:e,d=yield Fn(a,u,Pn(c,n),cn.value.render);if(!Xt(o)||nn.value!==l||!1===i.loading||!Sn()||!ll(r))return!1;const v=null==d?void 0:d.svg;if(!Ue.value||!v)return!1;const m=Ae(Ue.value,v,{keepPreviousOnFailure:!0});return!!m&&(Le=null!=(t=null==d?void 0:d.bindFunctions)?t:null,He(m.bindTarget),Q(()=>Ln()),!1)}catch(u){return!1}finally{Ct.value===a&&(Tt.value=!1,Ct.value=null),Xt(o)&&it()}});return Ct.value=a,a})}function il(){return s(this,null,function*(){var e;if(!Yt())return;const t=Ie,n=Date.now(),l=++nn.value;at();try{ln&&ln.abort(),ln=new AbortController;const r=ln.signal,a=i.isDark?"dark":"light",u=ct.value;if(!u.trim()){if(gt())return;return Ue.value&&ze(Ue.value),ft.value=null,Ot="",void(rn.value=!1)}if(nl(u,a).signature===Ot)return;try{const e=yield jn(u,a,{signal:r,timeoutMs:cn.value.worker});if(!Xt(t))return;if(e.fullOk){if(r.aborted||nn.value!==l)return;if(!(yield ol(nl(u,a))))return;return void(Xt(t)&&nn.value===l&&(rn.value=!1))}const o=gn&&n<=gn;if(e.prefixOk&&e.prefix&&!r.aborted&&nn.value===l&&Sn()&&!o)return void(yield al(e.prefix,u,a,l))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}if(!Xt(t)||nn.value!==l)return;if(rn.value)return;const s=tn.value[a];if(s&&Ue.value){const t=Ae(Ue.value,s.svg);t&&(Le=null!=(e=s.bindFunctions)?e:null,He(t.bindTarget))}}finally{Xt(t)&&it()}})}function ul(){mn&&(mn=!1,fn=Ft.value,pn=!1,hn&&(hn.abort(),hn=null),dn&&(globalThis.clearTimeout(dn),dn=null),vn&&(Wt(vn),vn=null),gn=Date.now())}function sl(){if(ul(),qt(),ln){try{ln.abort()}catch(e){}ln=null}if(hn){try{hn.abort()}catch(e){}hn=null}Ut(),Nt=0}function cl(){null==on||on.abort(),on=null}function dl(e=Ft.value){mn&&(wn>=jt.value?ul():(dn&&globalThis.clearTimeout(dn),dn=globalThis.setTimeout(()=>{vn=It(()=>s(null,null,function*(){if(!mn)return;if(!Yt())return void ul();if(bt.value||Qt.value)return void ul();const e=i.isDark?"dark":"light",t=ct.value;if(!t.trim())return!1===i.loading?void ul():void dl(fn);if(wn++,wn>jt.value)ul();else{hn&&hn.abort(),hn=new AbortController;try{const n=yield jn(t,e,{signal:hn.signal,timeoutMs:cn.value.worker});if(n.fullOk){if((yield ol(nl(t,e)))&&Qt.value)return void ul()}else n.prefixOk&&n.prefix&&Sn()&&(yield al(n.prefix,t,e,nn.value))}catch(n){}fn=Math.min(Math.floor(1.5*fn),$t.value),dl(fn)}}),{timeout:500})},e)))}function vl(){mn||zt.value&&Se.value&&Yt()&&(bt.value||Qt.value||(mn=!0,gn=0,pn=!0,wn=0,fn=Ft.value,dl(fn)))}function ml(){return s(this,null,function*(){const e=Ie;Xt(e)&&(yield We().catch(t=>{Xt(e)&&(Se.value=!1,console.warn("[markstream-vue] Failed to initialize mermaid renderer. Call enableMermaid() to configure a loader.",t))}),Xt(e)&&(yield p(),Xt(e)&&(Mt.value||(bt.value=!Se.value),Yt()&&(zt.value?(Vt(),Pt.value=ct.value.length):bt.value||rl()))))})}return h(Ze,e=>{Hn.value&&e&&In()}),h(_n,e=>{Hn.value&&Ke.value&&(Ke.value.style.transform=e.transform)},{immediate:!0}),h(Tn,e=>{e||X()}),h(()=>ct.value,e=>{if((e.trim()||!1===i.loading)&&(Qt.value=!1,tn.value={}),!zt.value)return ul(),void(Yt()&&!bt.value&&rl());Yt()&&Vt(),!bt.value&&Se.value&&Yt()?vl():ul(),function(){if(!zt.value)return;if(!bt.value)return;if(!Se.value)return;const e=ct.value.length;e!==Pt.value&&(St.value=!0,Pt.value=e,At&&clearTimeout(At),At=setTimeout(()=>{St.value&&bt.value&&ct.value.trim()&&(St.value=!1,tl("preview"))},Rt.value))}()}),h(()=>i.isDark,()=>s(null,null,function*(){var e;if(rn.value)return;const t=i.isDark?"dark":"light",n=tn.value[t];if(n){if(Ue.value){const t=Ae(Ue.value,n.svg);t&&(Le=null!=(e=n.bindFunctions)?e:null,He(t.bindTarget))}return}const l={zoom:pt.value,translateX:wt.value,translateY:yt.value,containerHeight:Kt.value},o=1!==pt.value||0!==wt.value||0!==yt.value;en.value=!0,o&&(pt.value=1,wt.value=0,yt.value=0,yield p()),yield ol(),o&&(yield p(),pt.value=l.zoom,wt.value=l.translateX,yt.value=l.translateY,Kt.value=l.containerHeight,un.value=l)})),h(()=>bt.value,e=>s(null,null,function*(){var t;if(e)ul(),Qt.value&&(un.value={zoom:pt.value,translateX:wt.value,translateY:yt.value,containerHeight:Kt.value});else{if(rn.value)return;const e=i.isDark?"dark":"light";if(Qt.value&&tn.value[e]){if(yield p(),Ue.value){const n=tn.value[e],l=Ae(Ue.value,n.svg);l&&(Le=null!=(t=n.bindFunctions)?t:null,He(l.bindTarget))}return pt.value=un.value.zoom,wt.value=un.value.translateX,yt.value=un.value.translateY,void(Kt.value=un.value.containerHeight)}if(yield p(),!Se.value||!Yt())return;if(!zt.value)return ul(),void(yield rl());vl(),yield il()}})),h(()=>i.loading,(e,t)=>s(null,null,function*(){var n;if(e)cl();else if(!0===t){cl();const e=ct.value,t=e.trim();if(!t)return Ue.value&&ze(Ue.value),ft.value=null,Ot="",rn.value=!1,sl();if(!Yt())return void sl();const r=i.isDark?"dark":"light",u=nl(e,r);if(Qt.value&&u.signature===Ot){if(yield p(),Ue.value&&!Ue.value.querySelector("svg")&&tn.value[r]){const e=tn.value[r],t=Ae(Ue.value,e.svg);t&&(Le=null!=(n=e.bindFunctions)?n:null,He(t.bindTarget))}return Ln(void 0,{force:!0}),void sl()}const s=new AbortController;on=s;try{let e=0;for(;;)try{yield $n(t,r,{signal:s.signal,timeoutMs:cn.value.worker});break}catch(l){const t="WORKER_BUSY"===(null==l?void 0:l.code)||"WORKER_TIMEOUT"===(null==l?void 0:l.code),n="WORKER_TIMEOUT"===(null==l?void 0:l.code)?2:8;if(!t||e>=n)throw l;const o=Math.min(50*a(2,e),400);e++,yield yn(()=>new Promise(e=>setTimeout(e,o)),{signal:s.signal})}if(!(yield ol(u)))return;rn.value=!1,sl()}catch(o){if(bn(o))return;sl(),kn(o)}finally{on===s&&(on=null)}}})),h(Ve,e=>{Jt&&Jt.disconnect(),e&&(Jt=new ResizeObserver(e=>{e&&e.length>0&&!bt.value&&!Ye.value&&Q(()=>{Ln(e[0].contentRect.width)})}),Jt.observe(e))},{immediate:!0}),w(()=>{Re.value&&!Yt()||ml()}),h(()=>Se.value,e=>{Mt.value||(bt.value=!e)}),h(()=>i.maxHeight,()=>{p(()=>{Ln()})}),h([()=>i.estimatedPreviewHeightPx,()=>ct.value],()=>{Qt.value||ht()||bt.value||(Kt.value=mt(),Gt.value=Kt.value)}),h(()=>Qe.value,e=>s(null,null,function*(){e&&(De.value?(Qt.value||(zt.value?(Vt(),Pt.value=ct.value.length):rl()),i.loading||Qt.value||rl(),!bt.value&&Se.value&&zt.value&&vl()):yield ml())}),{immediate:!1}),y(()=>{At&&clearTimeout(At),qt(),Jt&&Jt.disconnect(),ln&&(ln.abort(),ln=null),cl(),ul(),Ut(),ut()}),h(()=>Ye.value,e=>s(null,null,function*(){e?(ul(),ln&&ln.abort()):Yt()&&!Qt.value&&(yield p(),zt.value?(Vt(),vl()):bt.value||rl())}),{immediate:!1}),(e,t)=>(k(),x("div",{ref_key:"blockContainer",ref:qe,class:b(["mermaid-block-container rounded-lg border overflow-hidden",[{"is-rendering":i.loading,dark:i.isDark}]]),"data-markstream-mermaid":"1","data-markstream-mode":bt.value?"fallback":Qt.value?"preview":"pending","data-markstream-pending":an.value?"true":void 0},[i.showHeader?(k(),x("div",re,[e.$slots["header-left"]?(k(),x("div",ae,[M(e.$slots,"header-left",{},void 0,!0)])):(k(),x("div",ie,[T("span",{class:"icon-slot action-icon shrink-0",innerHTML:C('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#ca9ee6" stroke-linecap="round" stroke-linejoin="round" d="M1.5 2.5c0 6 2.25 5.75 4 7 .83.67 1.17 2 1 4h3c-.17-2 .17-3.33 1-4 1.75-1.25 4-1 4-7C12 2.5 10 3 8 7 6 3 4 2.5 1.5 2.5" />\n</svg>\n')},null,8,ue),t[21]||(t[21]=T("span",{class:"mermaid-label-text text-[length:var(--ms-text-label)] font-medium font-mono truncate"},"Mermaid",-1))])),e.$slots["header-center"]?(k(),x("div",se,[M(e.$slots,"header-center",{},void 0,!0)])):i.showModeToggle&&Se.value?(k(),x("div",ce,[T("button",{class:b(["mermaid-mode-btn px-2 py-0.5 rounded transition-colors",[bt.value?"":"is-active"]]),onClick:t[0]||(t[0]=()=>el("preview")),onMouseenter:t[1]||(t[1]=e=>Bn(e,C(_e)("common.preview")||"Preview")),onFocus:t[2]||(t[2]=e=>Bn(e,C(_e)("common.preview")||"Preview")),onMouseleave:En,onBlur:En},[T("div",de,[t[22]||(t[22]=T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),T("circle",{cx:"12",cy:"12",r:"3"})])],-1)),T("span",null,B(C(_e)("common.preview")||"Preview"),1)])],34),T("button",{class:b(["mermaid-mode-btn px-2 py-0.5 rounded transition-colors",[bt.value?"is-active":""]]),onClick:t[3]||(t[3]=()=>el("source")),onMouseenter:t[4]||(t[4]=e=>Bn(e,C(_e)("common.source")||"Source")),onFocus:t[5]||(t[5]=e=>Bn(e,C(_e)("common.source")||"Source")),onMouseleave:En,onBlur:En},[T("div",ve,[t[23]||(t[23]=T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})],-1)),T("span",null,B(C(_e)("common.source")||"Source"),1)])],34)])):E("",!0),e.$slots["header-right"]?(k(),x("div",me,[M(e.$slots,"header-right",{},void 0,!0)])):(k(),x("div",fe,[i.showCollapseButton?(k(),x("button",{key:0,class:b(Pe),"aria-pressed":Ye.value,onClick:t[6]||(t[6]=e=>Ye.value=!Ye.value),onMouseenter:t[7]||(t[7]=e=>Bn(e,Ye.value?C(_e)("common.expand")||"Expand":C(_e)("common.collapse")||"Collapse")),onFocus:t[8]||(t[8]=e=>Bn(e,Ye.value?C(_e)("common.expand")||"Expand":C(_e)("common.collapse")||"Collapse")),onMouseleave:En,onBlur:En},[(k(),x("svg",{style:O({rotate:Ye.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...t[24]||(t[24]=[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,he)):E("",!0),i.showCopyButton?(k(),x("button",{key:1,class:b(Pe),onClick:Gn,onMouseenter:t[9]||(t[9]=e=>On(e)),onFocus:t[10]||(t[10]=e=>On(e)),onMouseleave:En,onBlur:En},[Xe.value?(k(),x("svg",pe,[...t[26]||(t[26]=[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(k(),x("svg",ge,[...t[25]||(t[25]=[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),T("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],32)):E("",!0),i.showExportButton&&Se.value?(k(),x("button",{key:2,class:b(`${Pe} ${zn.value?"opacity-50 cursor-not-allowed":""}`),"aria-label":C(_e)("common.export")||"Export",disabled:zn.value,onClick:Jn,onMouseenter:t[11]||(t[11]=e=>Bn(e,C(_e)("common.export")||"Export")),onFocus:t[12]||(t[12]=e=>Bn(e,C(_e)("common.export")||"Export")),onMouseleave:En,onBlur:En},[...t[27]||(t[27]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),T("path",{d:"m7 10l5 5l5-5"})])],-1)])],42,we)):E("",!0),i.showFullscreenButton&&Se.value?(k(),x("button",{key:3,class:b(`${Pe} ${zn.value?"opacity-50 cursor-not-allowed":""}`),"aria-label":Hn.value?C(_e)("common.minimize")||"Minimize":C(_e)("common.open")||"Open",disabled:zn.value,onClick:Qn,onMouseenter:t[13]||(t[13]=e=>Bn(e,Hn.value?C(_e)("common.minimize")||"Minimize":C(_e)("common.open")||"Open")),onFocus:t[14]||(t[14]=e=>Bn(e,Hn.value?C(_e)("common.minimize")||"Minimize":C(_e)("common.open")||"Open")),onMouseleave:En,onBlur:En},[Hn.value?(k(),x("svg",xe,[...t[29]||(t[29]=[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(k(),x("svg",ke,[...t[28]||(t[28]=[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])]))],42,ye)):E("",!0)]))])):E("",!0),P(T("div",{ref_key:"modeContainerRef",ref:st},[bt.value?(k(),x("div",be,[T("pre",Me,B(ct.value),1)])):(k(),x("div",Te,[i.showZoomControls?(k(),x("div",Ce,[T("div",Be,[T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Xn,onMouseenter:t[15]||(t[15]=e=>Bn(e,C(_e)("common.zoomIn")||"Zoom in")),onFocus:t[16]||(t[16]=e=>Bn(e,C(_e)("common.zoomIn")||"Zoom in")),onMouseleave:En,onBlur:En},[...t[30]||(t[30]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("circle",{cx:"11",cy:"11",r:"8"}),T("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])],32),T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Yn,onMouseenter:t[17]||(t[17]=e=>Bn(e,C(_e)("common.zoomOut")||"Zoom out")),onFocus:t[18]||(t[18]=e=>Bn(e,C(_e)("common.zoomOut")||"Zoom out")),onMouseleave:En,onBlur:En},[...t[31]||(t[31]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("circle",{cx:"11",cy:"11",r:"8"}),T("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])],32),T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] text-[length:var(--ms-text-label)] rounded transition-colors",onClick:qn,onMouseenter:t[19]||(t[19]=e=>Bn(e,C(_e)("common.resetZoom")||"Reset zoom")),onFocus:t[20]||(t[20]=e=>Bn(e,C(_e)("common.resetZoom")||"Reset zoom")),onMouseleave:En,onBlur:En},B(Math.round(100*pt.value))+"% ",33)])])):E("",!0),T("div",S({ref_key:"mermaidContainer",ref:Ve,class:"mermaid-preview-area relative overflow-hidden block transition-[height] ease-out",style:{height:Kt.value}},D(sn.value,!0),{onMousedown:Vn,onMousemove:Un,onMouseup:Zn,onMouseleave:Zn,onTouchstartPassive:Vn,onTouchmovePassive:Un,onTouchendPassive:Zn}),[T("div",{"data-mermaid-wrapper":"",class:b(["absolute inset-0 cursor-grab",{"cursor-grabbing":kt.value}]),style:O(_n.value)},[T("div",{ref_key:"mermaidContent",ref:Ue,class:"_mermaid w-full text-center flex items-center justify-center min-h-full",style:O({height:Gt.value})},null,4)],6)],16),(k(),R(F,{to:"body"},[T("div",{class:b(["markstream-vue",{dark:i.isDark}])},[$(j,{name:"mermaid-dialog",appear:""},{default:z(()=>[Hn.value?(k(),x("div",{key:0,class:"mermaid-modal-overlay fixed inset-0 z-50 flex items-center justify-center p-4",onClick:A(Wn,["self"])},[T("div",Ee,[T("div",Oe,[T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Xn},[...t[32]||(t[32]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("circle",{cx:"11",cy:"11",r:"8"}),T("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])]),T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Yn},[...t[33]||(t[33]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("circle",{cx:"11",cy:"11",r:"8"}),T("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])]),T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] text-[length:var(--ms-text-label)] rounded transition-colors",onClick:qn},B(Math.round(100*pt.value))+"% ",1),T("button",{class:"mermaid-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Wn},[...t[34]||(t[34]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"})],-1)])])]),T("div",S({ref_key:"modalContent",ref:Ze,class:"w-full h-full flex items-center justify-center p-4 overflow-hidden"},D(sn.value,!0),{onMousedown:Vn,onMousemove:Un,onMouseup:Zn,onMouseleave:Zn,onTouchstartPassive:Vn,onTouchmovePassive:Un,onTouchendPassive:Zn}),null,16)])])):E("",!0)]),_:1})],2)]))]))],512),[[L,!Ye.value]])],10,oe))}}),[["__scopeId","data-v-479b254a"]]);Se.install=e=>{e.component(Se.__name,Se)};export{Se as default};
|
|
1
|
+
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=Math.pow,i=(t,n,l)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[n]=l,u=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&i(e,n,t[n]);if(l)for(var n of l(t))r.call(t,n)&&i(e,n,t[n]);return e},s=(e,t,n)=>new Promise((l,o)=>{var r=e=>{try{i(n.next(e))}catch(t){o(t)}},a=e=>{try{i(n.throw(e))}catch(t){o(t)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,a);i((n=n.apply(e,t)).next())});import{defineComponent as c,ref as d,computed as v,useAttrs as m,inject as f,watch as h,onBeforeUnmount as g,nextTick as p,onMounted as w,onUnmounted as y,openBlock as k,createElementBlock as x,normalizeClass as b,renderSlot as M,createElementVNode as T,unref as C,toDisplayString as B,createCommentVNode as E,normalizeStyle as O,withDirectives as P,mergeProps as S,toHandlers as D,createBlock as R,Teleport as F,createVNode as j,Transition as $,withCtx as z,withModifiers as A,vShow as L}from"vue";import{ao as H,as as _,ap as N,ar as I,ag as W,a6 as X,al as Y,z as q}from"./exports.js";import{p as V,b as U,g as Z,a as K}from"./diagramHeight.js";import{e as G}from"./mermaidSequenceSemicolons.js";import{M as J}from"./index2.js";import{safeRaf as Q}from"./utils/safeRaf.js";import{c as ee,g as te,f as ne}from"./workers-mermaidWorkerClient.js";import{toSafeSvgElement as le}from"stream-markdown-parser";const oe=["data-markstream-mode","data-markstream-pending"],re={key:0,class:"mermaid-block-header flex items-center justify-between border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)]"},ae={key:0},ie={key:1,class:"flex items-center gap-x-2 overflow-hidden"},ue=["innerHTML"],se={key:2},ce={key:3,class:"mermaid-mode-toggle-group flex items-center gap-0.5"},de={class:"flex items-center gap-x-1"},ve={class:"flex items-center gap-x-1"},me={key:4},fe={key:5,class:"mermaid-header-actions flex items-center"},he=["aria-pressed"],ge={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},pe={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},we=["aria-label","disabled"],ye=["aria-label","disabled"],ke={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},xe={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},be={key:0,class:"mermaid-source-panel"},Me={class:"mermaid-source-code text-sm font-mono whitespace-pre-wrap"},Te={key:1,class:"relative"},Ce={key:0,class:"absolute top-2 right-2 z-10 rounded-lg"},Be={class:"flex items-center gap-2 backdrop-blur rounded-lg"},Ee={class:"dialog-panel mermaid-modal-panel relative w-full h-full max-w-full max-h-full rounded overflow-hidden"},Oe={class:"absolute top-6 right-6 z-50 flex items-center gap-2"},Pe="mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded",Se=/* @__PURE__ */q(/* @__PURE__ */c({__name:"MermaidBlockNode",props:{node:{},maxHeight:{default:void 0},estimatedPreviewHeightPx:{},loading:{type:Boolean,default:!0},isDark:{type:Boolean},workerTimeoutMs:{default:1400},parseTimeoutMs:{default:1800},renderTimeoutMs:{default:2500},fullRenderTimeoutMs:{default:4e3},renderDebounceMs:{default:300},contentStableDelayMs:{default:500},previewPollDelayMs:{default:800},previewPollMaxDelayMs:{default:4e3},previewPollMaxAttempts:{default:12},showHeader:{type:Boolean,default:!0},showModeToggle:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExportButton:{type:Boolean,default:!0},showFullscreenButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showZoomControls:{type:Boolean,default:!0},enableWheelZoom:{type:Boolean,default:!1},isStrict:{type:Boolean,default:!0},enableMermaidInteractions:{type:Boolean,default:!1},showTooltips:{type:Boolean,default:!0},onRenderError:{}},emits:["copy","export","openModal","toggleMode"],setup(e,{emit:l}){var o,r;const i=e,c=l,q={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style","br"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},Se=d(!1),De=d("undefined"==typeof window),Re=H(),Fe=_(),je=v(()=>i.isStrict?"strict":"loose"),$e=v(()=>({startOnLoad:!1,securityLevel:je.value,dompurifyConfig:"strict"===je.value?q:void 0,htmlLabels:"strict"!==je.value&&void 0,flowchart:"strict"===je.value?{htmlLabels:!1}:void 0}));function ze(e){if(e)try{e.replaceChildren()}catch(t){e.innerHTML=""}}function Ae(e,t,n={}){if(!e)return null;const l=function(e,t){if(!e)return null;const n=le(t);if(!n)return null;const l=function(e,t){const n=Array.from(e.childNodes),l=document.createElement("div");return l.dataset.mermaidSvgLayer="1",l.style.zIndex="1",l.appendChild(t),e.insertBefore(l,e.firstChild),n.length>0&&function(e){const t=()=>{var t;for(const n of e)null==(t=n.parentNode)||t.removeChild(n)};"function"==typeof requestAnimationFrame?requestAnimationFrame(()=>{requestAnimationFrame(t)}):setTimeout(t,32)}(n),l}(e,n);return{svg:n.outerHTML,bindTarget:l}}(e,t);return l||n.keepPreviousOnFailure||ze(e),l}let Le=null;function He(e){if(i.enableMermaidInteractions&&(null==e?void 0:e.querySelector("svg")))try{null==Le||Le(e)}catch(t){}}const{t:_e}=N();let Ne=!1,Ie=0;function We(){return s(this,null,function*(){try{const e=yield te();return Ne?null:(Se.value=!!e,e)}catch(e){throw Ne||(Se.value=!1),e}finally{Ne||(De.value=!0)}})}const Xe=d(!1),Ye=d(!1),qe=d(),Ve=d(),Ue=d(),Ze=d(),Ke=d(null),Ge=I(),Je=d(null),Qe=d("undefined"==typeof window||!Re.value),et=m(),tt=f(J,null);let nt="",lt=0,ot=0;const rt=v(()=>W(i,et));function at(){const e=rt.value;e&&(nt&&nt!==e&&(null==tt||tt.markSettled(nt),lt=0),nt=e,lt+=1,ot+=1,1===lt&&(null==tt||tt.markPending(e)))}function it(){return s(this,null,function*(){const e=nt;if(!e)return;if(lt=Math.max(0,lt-1),lt>0)return;nt="";const t=++ot;yield p(),t===ot&&(function(e=rt.value){e&&qe.value&&(null==tt||tt.reportHeight(e,qe.value.offsetHeight))}(e),null==tt||tt.markSettled(e))})}function ut(){const e=nt;e&&(nt="",lt=0,ot+=1,null==tt||tt.markSettled(e))}const st=d(),ct=v(()=>i.node.code.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"));function dt(e,t=ct.value){const n=t,l={theme:"dark"===e?"dark":"default"};"strict"===je.value&&(l.htmlLabels=!1,l.flowchart={htmlLabels:!1});const o=`%%{init: ${JSON.stringify(l)}}%%\n`;return n.trim().startsWith("%%{")?n:o+n}function vt(){var e;return function(e){const t=function(){var e;const t=Ve.value?getComputedStyle(Ve.value).getPropertyValue("--ms-size-diagram-min-height").trim():"";return null!=(e=V(t))?e:360}(),n=An();return K(e,t,n)}(null!=(e=V(i.estimatedPreviewHeightPx))?e:U(ct.value))}function mt(){return`${vt()}px`}const ft=d(null);function ht(){var e;return!!(null==(e=Ue.value)?void 0:e.querySelector("svg"))}function gt(){return!1!==i.loading&&(ht()||!!ft.value)}const pt=d(1),wt=d(0),yt=d(0),kt=d(!1),xt=d({x:0,y:0}),bt=d(!0),Mt=d(!1),Tt=d(!1),Ct=d(null);let Bt="",Et=!1,Ot="";const Pt=d(0),St=d(!1),Dt=v(()=>{var e;return Math.max(0,null!=(e=i.renderDebounceMs)?e:300)}),Rt=v(()=>{var e;return Math.max(0,null!=(e=i.contentStableDelayMs)?e:500)}),Ft=v(()=>{var e;return Math.max(120,null!=(e=i.previewPollDelayMs)?e:800)}),jt=v(()=>{var e;return Math.max(Ft.value,null!=(e=i.previewPollMaxDelayMs)?e:4e3)}),$t=v(()=>{var e;return Math.max(1,Math.trunc(null!=(e=i.previewPollMaxAttempts)?e:12))}),zt=v(()=>!1!==i.loading);let At=null,Lt=null,Ht=null,_t=null,Nt=0;const It=null!=(o=globalThis.requestIdleCallback)?o:(e,t)=>setTimeout(()=>e({didTimeout:!0}),16),Wt=null!=(r=globalThis.cancelIdleCallback)?r:e=>clearTimeout(e);function Xt(e=Ie){return!Ne&&e===Ie}function Yt(){return Xt()&&Qe.value&&!Ye.value}function qt(){null!=Ht&&(globalThis.clearTimeout(Ht),Ht=null),null!=_t&&(Wt(_t),_t=null)}function Vt(){Ne||null==Ht&&null==_t&&(Ht=globalThis.setTimeout(()=>{Ht=null,Yt()&&(_t=It(()=>{_t=null,Yt()&&il()},{timeout:500}))},Dt.value))}function Ut(){null!=Lt&&(globalThis.clearTimeout(Lt),Lt=null)}function Zt(e=600){if("undefined"==typeof globalThis||Ne)return;const t=Math.max(0,e);Ut(),Lt=globalThis.setTimeout(()=>{if(Lt=null,!Ne){if(i.loading||Tt.value||!Yt())return void Zt(Math.min(1200,Math.max(300,1.2*t)));Vt()}},t)}const Kt=d(mt()),Gt=d(Kt.value);let Jt=null;const Qt=d(!1),en=d(!1),tn=d({}),nn=d(0);let ln=null,on=null;const rn=d(!1),an=v(()=>{var e,t;return!(Ye.value||bt.value||De.value&&!Tt.value&&!Ct.value&&(Qt.value||rn.value&&Boolean(null==(t=null==(e=Ue.value)?void 0:e.textContent)?void 0:t.trim())))}),un=d({zoom:1,translateX:0,translateY:0,containerHeight:Kt.value}),sn=v(()=>i.enableWheelZoom?{wheel:Kn}:{}),cn=v(()=>{var e,t,n,l;return{worker:null!=(e=i.workerTimeoutMs)?e:1400,parse:null!=(t=i.parseTimeoutMs)?t:1800,render:null!=(n=i.renderTimeoutMs)?n:2500,fullRender:null!=(l=i.fullRenderTimeoutMs)?l:4e3}});let dn=null,vn=null,mn=!1,fn=Ft.value,hn=null,gn=0,pn=!0,wn=0;function yn(e,t){const n=null==t?void 0:t.timeoutMs,l=null==t?void 0:t.signal;if(null==l?void 0:l.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));let o=null,r=!1,a=null;return new Promise((t,i)=>{const u=()=>{null!=o&&clearTimeout(o),a&&l&&l.removeEventListener("abort",a)};n&&n>0&&(o=globalThis.setTimeout(()=>{r||(r=!0,u(),i(new Error("Operation timed out")))},n)),l&&(a=()=>{r||(r=!0,u(),i(new DOMException("Aborted","AbortError")))},l.addEventListener("abort",a)),e().then(e=>{r||(r=!0,u(),t(e))}).catch(e=>{r||(r=!0,u(),i(e))})})}function kn(e){if("undefined"==typeof document)return;if(!Ue.value)return;if("function"==typeof i.onRenderError&&!0===i.onRenderError(e,ct.value,Ue.value))return rn.value=!0,void ul();const t=document.createElement("div");t.style.padding="var(--ms-inset-panel-body)",t.style.color="hsl(var(--ms-destructive))",t.textContent="Failed to render diagram: ";const n=document.createElement("span");n.textContent=e instanceof Error?e.message:"Unknown error",t.appendChild(n),ze(Ue.value),Ue.value.appendChild(t);const l=Ue.value?getComputedStyle(Ue.value).getPropertyValue("--ms-size-diagram-min-height").trim():"";Kt.value=l||"360px",Gt.value=Kt.value,rn.value=!0,ul()}function xn(e){const t="string"==typeof e?e:"string"==typeof(null==e?void 0:e.message)?e.message:"";return"string"==typeof t&&/timed out/i.test(t)}function bn(e){return"AbortError"===(null==e?void 0:e.name)}function Mn(e){return!xn(e)&&!bn(e)}"undefined"!=typeof window&&h([()=>qe.value,Re],([e,t])=>{var n;if(null==(n=Je.value)||n.destroy(),Je.value=null,!t||Qe.value)return void(Qe.value=!0);if(!e)return void(Qe.value=!1);const l=Ge(e,{rootMargin:null==Fe?void 0:Fe.value.heavyBlockMargin,allowIdle:!1});Je.value=l,Qe.value=l.isVisible.value,l.whenVisible.then(()=>{Qe.value=!0})},{immediate:!0}),g(()=>{var e;Ne=!0,Ie+=1,nn.value+=1,null==(e=Je.value)||e.destroy(),Je.value=null,ut(),qt()});const Tn=v(()=>!1!==i.showTooltips);function Cn(e){return!e||e.disabled}function Bn(e,t,n="top"){if(!Tn.value)return;if(Cn(e.currentTarget))return;const l=e,o=null!=(null==l?void 0:l.clientX)&&null!=(null==l?void 0:l.clientY)?{x:l.clientX,y:l.clientY}:void 0;Y(e.currentTarget,t,n,!1,o,i.isDark)}function En(){Tn.value&&X()}function On(e){if(!Tn.value)return;if(Cn(e.currentTarget))return;const t=Xe.value?_e("common.copied")||"Copied":_e("common.copy")||"Copy",n=e,l=null!=(null==n?void 0:n.clientX)&&null!=(null==n?void 0:n.clientY)?{x:n.clientX,y:n.clientY}:void 0;Y(e.currentTarget,t,"top",!1,l,i.isDark)}function Pn(e,t){const n={theme:"dark"===t?"dark":"default"};"strict"===je.value&&(n.htmlLabels=!1,n.flowchart={htmlLabels:!1});const l=`%%{init: ${JSON.stringify(n)}}%%\n`;return e.trimStart().startsWith("%%{")?e:l+e}function Sn(){return pn&&!bt.value&&!Qt.value&&!rn.value}function Dn(e){const t=e.trim();return!(!t||t.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(t)&&t.includes(":")}function Rn(e){if("gantt"===Z(e))return function(e){var t;const n=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&n.length>0&&n.pop();n.length>0;){const e=null==(t=n[n.length-1])?void 0:t.trim();if(e&&!e.startsWith("%%")){if(Dn(e))break;n.pop()}else n.pop()}return n.some(Dn)?n.join("\n"):""}(e);const t=e.split(/\r?\n/);for(;t.length>0;){const e=t[t.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join("\n")}function Fn(e,t,n,l){return s(this,null,function*(){try{return yield yn(()=>e.render(t,n),{timeoutMs:l})}catch(o){if(!Mn(o))throw o;const a=G(n);if(a===n)throw o;try{return yield yn(()=>e.render(`${t}-retry`,a),{timeoutMs:l})}catch(r){throw o}}})}function jn(e,t,n){return s(this,null,function*(){var l;try{return yield ee(e,t,null!=(l=null==n?void 0:n.timeoutMs)?l:cn.value.worker,null==n?void 0:n.signal)}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o;const l=(null==o?void 0:o.code)||(null==o?void 0:o.name);if("WORKER_BUSY"!==l&&"WORKER_TIMEOUT"!==l&&"WORKER_INIT_ERROR"!==l&&"MERMAID_DISABLED"!==l&&"WORKER_REPLACED"!==l||(null==o?void 0:o.fallbackToRenderer))return yield function(e,t,n){return s(this,null,function*(){var l,r,a,i;const u=yield We();if(!u)return;const s=u,c=Pn(e,t);if("function"==typeof s.parse){try{yield yn(()=>s.parse(c),{timeoutMs:null!=(l=null==n?void 0:n.timeoutMs)?l:cn.value.parse,signal:null==n?void 0:n.signal})}catch(o){if(!Mn(o))throw o;const t=G(c);if(t===c)throw o;try{yield yn(()=>s.parse(t),{timeoutMs:null!=(r=null==n?void 0:n.timeoutMs)?r:cn.value.parse,signal:null==n?void 0:n.signal})}catch(v){throw o}}return!0}const d=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;try{yield yn(()=>u.render(d,c),{timeoutMs:null!=(a=null==n?void 0:n.timeoutMs)?a:cn.value.render,signal:null==n?void 0:n.signal})}catch(o){if(!Mn(o))throw o;const t=G(c);if(t===c)throw o;try{yield yn(()=>u.render(`${d}-retry`,t),{timeoutMs:null!=(i=null==n?void 0:n.timeoutMs)?i:cn.value.render,signal:null==n?void 0:n.signal})}catch(v){throw o}}return!0})}(e,t,n);throw o}})}function $n(e,t,n){return s(this,null,function*(){var l;if("gantt"===Z(e)){const l=Rn(e);if(!l.trim())return{fullOk:!1,prefixOk:!1};try{if(yield jn(l,t,n))return l===e?{fullOk:!0,prefixOk:!1}:{fullOk:!1,prefixOk:!0,prefix:l}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}}try{if(yield jn(e,t,n))return{fullOk:!0,prefixOk:!1}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}let o=Rn(e);if(o&&o.trim()&&o!==e)try{try{const r=yield ne(e,t,null!=(l=null==n?void 0:n.timeoutMs)?l:cn.value.worker,null==n?void 0:n.signal);r&&r.trim()&&(o=r)}catch(r){}if(yield jn(o,t,n))return{fullOk:!1,prefixOk:!0,prefix:o}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}})}const zn=v(()=>bt.value||Tt.value||Ye.value);function An(){if("none"===i.maxHeight)return null;if(null!=i.maxHeight){const e=Number.parseFloat(String(i.maxHeight));if(Number.isFinite(e))return e}const e=Ve.value;if(e){const t=getComputedStyle(e).getPropertyValue("--ms-size-code-max-height").trim(),n=Number.parseFloat(t);if(Number.isFinite(n))return n}return 500}function Ln(e,t){if(!Ve.value||!Ue.value)return;const n=!(null==t?void 0:t.force)&&!1!==i.loading&&ht(),l=Ue.value.querySelector("svg");if(!l)return;let o=0,r=0;const a=l.getAttribute("viewBox"),u=l.getAttribute("width"),s=l.getAttribute("height");if(a){const e=a.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),r=Number.parseFloat(e[3]))}if(o&&r||u&&s&&(o=Number.parseFloat(u),r=Number.parseFloat(s)),Number.isNaN(o)||Number.isNaN(r)||o<=0||r<=0)try{const e=l.getBBox();e&&e.width>0&&e.height>0&&(o=e.width,r=e.height)}catch(c){return void console.error("Failed to get SVG BBox:",c)}if(o>0&&r>0){const t=r/o,a=null!=e?e:Ve.value.clientWidth,u=l.getBoundingClientRect().width,s=u>0?u/Math.max(.01,pt.value):a,c=An(),d=s*t,v=null==c?d:Math.min(d,c),m=Math.max(v,vt());n||null!=V(i.estimatedPreviewHeightPx)||(Kt.value=`${m}px`),Gt.value=Kt.value}}const Hn=d(!1),_n=v(()=>({transform:`translate(${wt.value}px, ${yt.value}px) scale(${pt.value})`}));function Nn(e){"Escape"===e.key&&Hn.value&&Wn()}function In(){var e;if(!Ve.value||!Ze.value)return!1;if("1"===(null==(e=Ze.value.firstElementChild)?void 0:e.getAttribute("data-mermaid-modal-clone")))return!0;const t=Ve.value.cloneNode(!0);t.dataset.mermaidModalClone="1",t.classList.add("fullscreen"),t.style.height="100%",t.style.maxHeight="100%";const n=t.querySelector("._mermaid");n&&(n.style.contain="none",n.style.contentVisibility="visible");const l=t.querySelector("[data-mermaid-wrapper]");return l&&(Ke.value=l,l.style.transform=_n.value.transform),ze(Ze.value),Ze.value.appendChild(t),He(t),!0}function Wn(){if(Hn.value=!1,Ze.value&&ze(Ze.value),Ke.value=null,"undefined"!=typeof document)try{document.body.style.overflow=""}catch(e){}if("undefined"!=typeof window)try{window.removeEventListener("keydown",Nn)}catch(e){}}function Xn(){pt.value<3&&(pt.value+=.1)}function Yn(){pt.value>.5&&(pt.value-=.1)}function qn(){pt.value=1,wt.value=0,yt.value=0}function Vn(e){kt.value=!0,e instanceof MouseEvent?xt.value={x:e.clientX-wt.value,y:e.clientY-yt.value}:xt.value={x:e.touches[0].clientX-wt.value,y:e.touches[0].clientY-yt.value}}function Un(e){if(!kt.value)return;let t,n;e instanceof MouseEvent?(t=e.clientX,n=e.clientY):(t=e.touches[0].clientX,n=e.touches[0].clientY),wt.value=t-xt.value.x,yt.value=n-xt.value.y}function Zn(){kt.value=!1}function Kn(e){if(i.enableWheelZoom&&(e.ctrlKey||e.metaKey)){if(e.preventDefault(),!Ve.value)return;const t=Ve.value.getBoundingClientRect(),n=e.clientX-t.left,l=e.clientY-t.top,o=n-t.width/2,r=l-t.height/2,a=(o-wt.value)/pt.value,i=(r-yt.value)/pt.value,u=.01,s=-e.deltaY*u,c=Math.min(Math.max(pt.value+s,.5),3);c!==pt.value&&(wt.value=o-a*c,yt.value=r-i*c,pt.value=c)}}function Gn(){return s(this,null,function*(){try{const e=ct.value,t={payload:{type:"copy",text:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(c("copy",t),t.defaultPrevented)return;"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(e)),Xe.value=!0,setTimeout(()=>{Xe.value=!1},1e3)}catch(e){console.error("Failed to copy:",e)}})}function Jn(){var e;const t=null==(e=Ue.value)?void 0:e.querySelector("svg");if(!t)return void console.error("SVG element not found");const n=(new XMLSerializer).serializeToString(t),l={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:t,svgString:n};c("export",l),l.defaultPrevented||function(e,t=null){s(this,null,function*(){try{const l=null!=t?t:(new XMLSerializer).serializeToString(e),o=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(o);if("undefined"!=typeof document){const e=document.createElement("a");e.href=r,e.download=`mermaid-diagram-${Date.now()}.svg`;try{document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch(n){}URL.revokeObjectURL(r)}}catch(l){console.error("Failed to export SVG:",l)}})}(t,n)}function Qn(){var e,t;const n=null!=(t=null==(e=Ue.value)?void 0:e.querySelector("svg"))?t:null,l=n?(new XMLSerializer).serializeToString(n):null,o={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:n,svgString:l};c("openModal",o),o.defaultPrevented||function(){if(Hn.value=!0,"undefined"!=typeof document)try{document.body.style.overflow="hidden"}catch(e){}if("undefined"!=typeof window)try{window.addEventListener("keydown",Nn)}catch(e){}p(()=>{In()||p(In)})}()}function el(e){const t={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};c("toggleMode",e,t),t.defaultPrevented||tl(e)}function tl(e){return s(this,null,function*(){const t=st.value;if(!t)return Mt.value=!0,void(bt.value="source"===e);const n=t.getBoundingClientRect().height;t.style.height=`${n}px`,t.style.overflow="hidden",Mt.value=!0,bt.value="source"===e,yield p();const l=t.scrollHeight;t.style.transition="height var(--ms-duration-standard) var(--ms-ease-standard)",t.offsetHeight,t.style.height=`${l}px`;const o=()=>{t.style.transition="",t.style.height="",t.style.overflow="",t.removeEventListener("transitionend",r)};function r(){o()}t.addEventListener("transitionend",r),setTimeout(()=>o(),220)})}function nl(e=ct.value,t=(i.isDark?"dark":"light"),n=!1===i.loading){return{code:e,codeWithTheme:dt(t,e),final:n,signature:`${t}\0${e}`,theme:t}}function ll(e){return e.signature===nl().signature}function ol(){return s(this,arguments,function*(e=nl()){const l=Ie;if(!Xt(l)||!ll(e))return!1;if(Tt.value){const t=Ct.value,n=Et,o=Bt;if(!t)return!1;const r=yield t;return!(!Xt(l)||!ll(e))&&(o===e.signature?!(!r||Ot!==e.signature)||!(!e.final||!1!==i.loading||n)&&ol(e):ol(e))}if(!Ue.value){if(yield p(),!Xt(l))return!1;if(!Ue.value)return console.warn("Mermaid container not ready"),!1}return!(!Xt(l)||!ll(e))&&(Tt.value=!0,Et=e.final,Bt=e.signature,at(),Ct.value=s(null,null,function*(){var o,r,a,s;try{const c=yield We();if(!Xt(l)||!c)return!1;const d=`mermaid-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;Qt.value||en.value||null==(o=c.initialize)||o.call(c,(a=u({},$e.value),s={dompurifyConfig:u({},q)},t(a,n(s))));const v=yield Fn(c,d,e.codeWithTheme,cn.value.fullRender);if(!Xt(l)||!function(e){return ll(e)||!e.final&&!1!==i.loading&&ct.value.startsWith(e.code)}(e))return en.value&&(en.value=!1),!1;if(!Ue.value)return!1;const m=Ae(Ue.value,null==v?void 0:v.svg,{keepPreviousOnFailure:!e.final||!1!==i.loading});if(!m)return en.value&&(en.value=!1),!1;const f=null!=(r=null==v?void 0:v.bindFunctions)?r:null;return Le=f,He(m.bindTarget),Q(()=>Ln()),Qt.value||en.value||(Qt.value=!0,un.value={zoom:pt.value,translateX:wt.value,translateY:yt.value,containerHeight:Kt.value}),tn.value[e.theme]={svg:m.svg,bindFunctions:f},en.value&&(en.value=!1),Ot=e.signature,ft.value=Ue.value.innerHTML,rn.value=!1,Nt=0,Ut(),!0}catch(c){if(!Xt(l)||!ll(e))return en.value&&(en.value=!1),!1;const t=xn(c),n=Nt+1;return t&&n<=3?(Nt=n,Zt(Math.min(1200,600*n))):(Nt=0,Ut(),e.final&&!1===i.loading&&console.error("Failed to render mermaid diagram:",c),e.final&&!1===i.loading&&kn(c)),!1}finally{Et=!1,Bt="",Tt.value=!1,Ct.value=null,Xt(l)&&it()}}),Ct.value)})}function rl(){return s(this,null,function*(){var e;const t=ct.value;if(!t.trim()){if(gt())return;return Ue.value&&ze(Ue.value),ft.value=null,Ot="",void(rn.value=!1)}if(!Se.value||!Yt())return;const n=nl(t);Qt.value&&n.signature===Ot&&(null==(e=Ue.value)?void 0:e.querySelector("svg"))||(yield ol(n))&&(rn.value=!1)})}function al(e,t,n,l){return s(this,null,function*(){const o=Ie;if(!Xt(o)||!Sn())return;if(!Ue.value&&(yield p(),!Xt(o)||!Ue.value))return;if(Tt.value)return;Tt.value=!0,at();const r=nl(t,n),a=s(null,null,function*(){var t;try{const a=yield We();if(!Xt(o)||!a)return!1;const u=`mermaid-partial-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,s=Rn(e),c=s&&s.trim()?s:e,d=yield Fn(a,u,Pn(c,n),cn.value.render);if(!Xt(o)||nn.value!==l||!1===i.loading||!Sn()||!ll(r))return!1;const v=null==d?void 0:d.svg;if(!Ue.value||!v)return!1;const m=Ae(Ue.value,v,{keepPreviousOnFailure:!0});return!!m&&(Le=null!=(t=null==d?void 0:d.bindFunctions)?t:null,He(m.bindTarget),Q(()=>Ln()),!1)}catch(u){return!1}finally{Ct.value===a&&(Tt.value=!1,Ct.value=null),Xt(o)&&it()}});return Ct.value=a,a})}function il(){return s(this,null,function*(){var e;if(!Yt())return;const t=Ie,n=Date.now(),l=++nn.value;at();try{ln&&ln.abort(),ln=new AbortController;const r=ln.signal,a=i.isDark?"dark":"light",u=ct.value;if(!u.trim()){if(gt())return;return Ue.value&&ze(Ue.value),ft.value=null,Ot="",void(rn.value=!1)}if(nl(u,a).signature===Ot)return;try{const e=yield $n(u,a,{signal:r,timeoutMs:cn.value.worker});if(!Xt(t))return;if(e.fullOk){if(r.aborted||nn.value!==l)return;if(!(yield ol(nl(u,a))))return;return void(Xt(t)&&nn.value===l&&(rn.value=!1))}const o=gn&&n<=gn;if(e.prefixOk&&e.prefix&&!r.aborted&&nn.value===l&&Sn()&&!o)return void(yield al(e.prefix,u,a,l))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}if(!Xt(t)||nn.value!==l)return;if(rn.value)return;const s=tn.value[a];if(s&&Ue.value){const t=Ae(Ue.value,s.svg);t&&(Le=null!=(e=s.bindFunctions)?e:null,He(t.bindTarget))}}finally{Xt(t)&&it()}})}function ul(){mn&&(mn=!1,fn=Ft.value,pn=!1,hn&&(hn.abort(),hn=null),dn&&(globalThis.clearTimeout(dn),dn=null),vn&&(Wt(vn),vn=null),gn=Date.now())}function sl(){if(ul(),qt(),ln){try{ln.abort()}catch(e){}ln=null}if(hn){try{hn.abort()}catch(e){}hn=null}Ut(),Nt=0}function cl(){null==on||on.abort(),on=null}function dl(e=Ft.value){mn&&(wn>=$t.value?ul():(dn&&globalThis.clearTimeout(dn),dn=globalThis.setTimeout(()=>{vn=It(()=>s(null,null,function*(){if(!mn)return;if(!Yt())return void ul();if(bt.value||Qt.value)return void ul();const e=i.isDark?"dark":"light",t=ct.value;if(!t.trim())return!1===i.loading?void ul():void dl(fn);if(wn++,wn>$t.value)ul();else{hn&&hn.abort(),hn=new AbortController;try{const n=yield $n(t,e,{signal:hn.signal,timeoutMs:cn.value.worker});if(n.fullOk){if((yield ol(nl(t,e)))&&Qt.value)return void ul()}else n.prefixOk&&n.prefix&&Sn()&&(yield al(n.prefix,t,e,nn.value))}catch(n){}fn=Math.min(Math.floor(1.5*fn),jt.value),dl(fn)}}),{timeout:500})},e)))}function vl(){mn||zt.value&&Se.value&&Yt()&&(bt.value||Qt.value||(mn=!0,gn=0,pn=!0,wn=0,fn=Ft.value,dl(fn)))}function ml(){return s(this,null,function*(){const e=Ie;Xt(e)&&(yield We().catch(t=>{Xt(e)&&(Se.value=!1,console.warn("[markstream-vue] Failed to initialize mermaid renderer. Call enableMermaid() to configure a loader.",t))}),Xt(e)&&(yield p(),Xt(e)&&(Mt.value||(bt.value=!Se.value),Yt()&&(zt.value?(Vt(),Pt.value=ct.value.length):bt.value||rl()))))})}return h(Ze,e=>{Hn.value&&e&&In()}),h(_n,e=>{Hn.value&&Ke.value&&(Ke.value.style.transform=e.transform)},{immediate:!0}),h(Tn,e=>{e||X()}),h(()=>ct.value,e=>{if((e.trim()||!1===i.loading)&&(Qt.value=!1,tn.value={}),!zt.value)return ul(),void(Yt()&&!bt.value&&rl());Yt()&&Vt(),!bt.value&&Se.value&&Yt()?vl():ul(),function(){if(!zt.value)return;if(!bt.value)return;if(!Se.value)return;const e=ct.value.length;e!==Pt.value&&(St.value=!0,Pt.value=e,At&&clearTimeout(At),At=setTimeout(()=>{St.value&&bt.value&&ct.value.trim()&&(St.value=!1,tl("preview"))},Rt.value))}()}),h(()=>i.isDark,()=>s(null,null,function*(){var e;if(rn.value)return;const t=i.isDark?"dark":"light",n=tn.value[t];if(n){if(Ue.value){const t=Ae(Ue.value,n.svg);t&&(Le=null!=(e=n.bindFunctions)?e:null,He(t.bindTarget))}return}const l={zoom:pt.value,translateX:wt.value,translateY:yt.value,containerHeight:Kt.value},o=1!==pt.value||0!==wt.value||0!==yt.value;en.value=!0,o&&(pt.value=1,wt.value=0,yt.value=0,yield p()),yield ol(),o&&(yield p(),pt.value=l.zoom,wt.value=l.translateX,yt.value=l.translateY,Kt.value=l.containerHeight,un.value=l)})),h(()=>bt.value,e=>s(null,null,function*(){var t;if(e)ul(),Qt.value&&(un.value={zoom:pt.value,translateX:wt.value,translateY:yt.value,containerHeight:Kt.value});else{if(rn.value)return;const e=i.isDark?"dark":"light";if(Qt.value&&tn.value[e]){if(yield p(),Ue.value){const n=tn.value[e],l=Ae(Ue.value,n.svg);l&&(Le=null!=(t=n.bindFunctions)?t:null,He(l.bindTarget))}return pt.value=un.value.zoom,wt.value=un.value.translateX,yt.value=un.value.translateY,void(Kt.value=un.value.containerHeight)}if(yield p(),!Se.value||!Yt())return;if(!zt.value)return ul(),void(yield rl());vl(),yield il()}})),h(()=>i.loading,(e,t)=>s(null,null,function*(){var n;if(e)cl();else if(!0===t){cl();const e=ct.value,t=e.trim();if(!t)return Ue.value&&ze(Ue.value),ft.value=null,Ot="",rn.value=!1,sl();if(!Yt())return void sl();const r=i.isDark?"dark":"light",u=nl(e,r);if(Qt.value&&u.signature===Ot){if(yield p(),Ue.value&&!Ue.value.querySelector("svg")&&tn.value[r]){const e=tn.value[r],t=Ae(Ue.value,e.svg);t&&(Le=null!=(n=e.bindFunctions)?n:null,He(t.bindTarget))}return Ln(void 0,{force:!0}),void sl()}const s=new AbortController;on=s;try{let e=0;for(;;)try{yield jn(t,r,{signal:s.signal,timeoutMs:cn.value.worker});break}catch(l){const t="WORKER_BUSY"===(null==l?void 0:l.code)||"WORKER_TIMEOUT"===(null==l?void 0:l.code),n="WORKER_TIMEOUT"===(null==l?void 0:l.code)?2:8;if(!t||e>=n)throw l;const o=Math.min(50*a(2,e),400);e++,yield yn(()=>new Promise(e=>setTimeout(e,o)),{signal:s.signal})}if(!(yield ol(u)))return;rn.value=!1,sl()}catch(o){if(bn(o))return;sl(),kn(o)}finally{on===s&&(on=null)}}})),h(Ve,e=>{Jt&&Jt.disconnect(),e&&(Jt=new ResizeObserver(e=>{e&&e.length>0&&!bt.value&&!Ye.value&&Q(()=>{Ln(e[0].contentRect.width)})}),Jt.observe(e))},{immediate:!0}),w(()=>{Re.value&&!Yt()||ml()}),h(()=>Se.value,e=>{Mt.value||(bt.value=!e)}),h(()=>i.maxHeight,()=>{p(()=>{Ln()})}),h([()=>i.estimatedPreviewHeightPx,()=>ct.value],()=>{Qt.value||ht()||bt.value||(Kt.value=mt(),Gt.value=Kt.value)}),h(()=>Qe.value,e=>s(null,null,function*(){e&&(De.value?(Qt.value||(zt.value?(Vt(),Pt.value=ct.value.length):rl()),i.loading||Qt.value||rl(),!bt.value&&Se.value&&zt.value&&vl()):yield ml())}),{immediate:!1}),y(()=>{At&&clearTimeout(At),qt(),Jt&&Jt.disconnect(),ln&&(ln.abort(),ln=null),cl(),ul(),Ut(),ut()}),h(()=>Ye.value,e=>s(null,null,function*(){e?(ul(),ln&&ln.abort()):Yt()&&!Qt.value&&(yield p(),zt.value?(Vt(),vl()):bt.value||rl())}),{immediate:!1}),(e,t)=>(k(),x("div",{ref_key:"blockContainer",ref:qe,class:b(["mermaid-block-container rounded-lg border overflow-hidden",[{"is-rendering":i.loading,dark:i.isDark}]]),"data-markstream-mermaid":"1","data-markstream-mode":bt.value?"fallback":Qt.value?"preview":"pending","data-markstream-pending":an.value?"true":void 0},[i.showHeader?(k(),x("div",re,[e.$slots["header-left"]?(k(),x("div",ae,[M(e.$slots,"header-left",{},void 0,!0)])):(k(),x("div",ie,[T("span",{class:"icon-slot action-icon shrink-0",innerHTML:C('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#ca9ee6" stroke-linecap="round" stroke-linejoin="round" d="M1.5 2.5c0 6 2.25 5.75 4 7 .83.67 1.17 2 1 4h3c-.17-2 .17-3.33 1-4 1.75-1.25 4-1 4-7C12 2.5 10 3 8 7 6 3 4 2.5 1.5 2.5" />\n</svg>\n')},null,8,ue),t[21]||(t[21]=T("span",{class:"mermaid-label-text text-[length:var(--ms-text-label)] font-medium font-mono truncate"},"Mermaid",-1))])),e.$slots["header-center"]?(k(),x("div",se,[M(e.$slots,"header-center",{},void 0,!0)])):i.showModeToggle&&Se.value?(k(),x("div",ce,[T("button",{class:b(["mermaid-mode-btn px-2 py-0.5 rounded transition-colors",[bt.value?"":"is-active"]]),onClick:t[0]||(t[0]=()=>el("preview")),onMouseenter:t[1]||(t[1]=e=>Bn(e,C(_e)("common.preview")||"Preview")),onFocus:t[2]||(t[2]=e=>Bn(e,C(_e)("common.preview")||"Preview")),onMouseleave:En,onBlur:En},[T("div",de,[t[22]||(t[22]=T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),T("circle",{cx:"12",cy:"12",r:"3"})])],-1)),T("span",null,B(C(_e)("common.preview")||"Preview"),1)])],34),T("button",{class:b(["mermaid-mode-btn px-2 py-0.5 rounded transition-colors",[bt.value?"is-active":""]]),onClick:t[3]||(t[3]=()=>el("source")),onMouseenter:t[4]||(t[4]=e=>Bn(e,C(_e)("common.source")||"Source")),onFocus:t[5]||(t[5]=e=>Bn(e,C(_e)("common.source")||"Source")),onMouseleave:En,onBlur:En},[T("div",ve,[t[23]||(t[23]=T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})],-1)),T("span",null,B(C(_e)("common.source")||"Source"),1)])],34)])):E("",!0),e.$slots["header-right"]?(k(),x("div",me,[M(e.$slots,"header-right",{},void 0,!0)])):(k(),x("div",fe,[i.showCollapseButton?(k(),x("button",{key:0,class:b(Pe),"aria-pressed":Ye.value,onClick:t[6]||(t[6]=e=>Ye.value=!Ye.value),onMouseenter:t[7]||(t[7]=e=>Bn(e,Ye.value?C(_e)("common.expand")||"Expand":C(_e)("common.collapse")||"Collapse")),onFocus:t[8]||(t[8]=e=>Bn(e,Ye.value?C(_e)("common.expand")||"Expand":C(_e)("common.collapse")||"Collapse")),onMouseleave:En,onBlur:En},[(k(),x("svg",{style:O({rotate:Ye.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...t[24]||(t[24]=[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,he)):E("",!0),i.showCopyButton?(k(),x("button",{key:1,class:b(Pe),onClick:Gn,onMouseenter:t[9]||(t[9]=e=>On(e)),onFocus:t[10]||(t[10]=e=>On(e)),onMouseleave:En,onBlur:En},[Xe.value?(k(),x("svg",pe,[...t[26]||(t[26]=[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(k(),x("svg",ge,[...t[25]||(t[25]=[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),T("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],32)):E("",!0),i.showExportButton&&Se.value?(k(),x("button",{key:2,class:b(`${Pe} ${zn.value?"opacity-50 cursor-not-allowed":""}`),"aria-label":C(_e)("common.export")||"Export",disabled:zn.value,onClick:Jn,onMouseenter:t[11]||(t[11]=e=>Bn(e,C(_e)("common.export")||"Export")),onFocus:t[12]||(t[12]=e=>Bn(e,C(_e)("common.export")||"Export")),onMouseleave:En,onBlur:En},[...t[27]||(t[27]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),T("path",{d:"m7 10l5 5l5-5"})])],-1)])],42,we)):E("",!0),i.showFullscreenButton&&Se.value?(k(),x("button",{key:3,class:b(`${Pe} ${zn.value?"opacity-50 cursor-not-allowed":""}`),"aria-label":Hn.value?C(_e)("common.minimize")||"Minimize":C(_e)("common.open")||"Open",disabled:zn.value,onClick:Qn,onMouseenter:t[13]||(t[13]=e=>Bn(e,Hn.value?C(_e)("common.minimize")||"Minimize":C(_e)("common.open")||"Open")),onFocus:t[14]||(t[14]=e=>Bn(e,Hn.value?C(_e)("common.minimize")||"Minimize":C(_e)("common.open")||"Open")),onMouseleave:En,onBlur:En},[Hn.value?(k(),x("svg",xe,[...t[29]||(t[29]=[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(k(),x("svg",ke,[...t[28]||(t[28]=[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])]))],42,ye)):E("",!0)]))])):E("",!0),P(T("div",{ref_key:"modeContainerRef",ref:st},[bt.value?(k(),x("div",be,[T("pre",Me,B(ct.value),1)])):(k(),x("div",Te,[i.showZoomControls?(k(),x("div",Ce,[T("div",Be,[T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Xn,onMouseenter:t[15]||(t[15]=e=>Bn(e,C(_e)("common.zoomIn")||"Zoom in")),onFocus:t[16]||(t[16]=e=>Bn(e,C(_e)("common.zoomIn")||"Zoom in")),onMouseleave:En,onBlur:En},[...t[30]||(t[30]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("circle",{cx:"11",cy:"11",r:"8"}),T("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])],32),T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Yn,onMouseenter:t[17]||(t[17]=e=>Bn(e,C(_e)("common.zoomOut")||"Zoom out")),onFocus:t[18]||(t[18]=e=>Bn(e,C(_e)("common.zoomOut")||"Zoom out")),onMouseleave:En,onBlur:En},[...t[31]||(t[31]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("circle",{cx:"11",cy:"11",r:"8"}),T("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])],32),T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] text-[length:var(--ms-text-label)] rounded transition-colors",onClick:qn,onMouseenter:t[19]||(t[19]=e=>Bn(e,C(_e)("common.resetZoom")||"Reset zoom")),onFocus:t[20]||(t[20]=e=>Bn(e,C(_e)("common.resetZoom")||"Reset zoom")),onMouseleave:En,onBlur:En},B(Math.round(100*pt.value))+"% ",33)])])):E("",!0),T("div",S({ref_key:"mermaidContainer",ref:Ve,class:"mermaid-preview-area relative overflow-hidden block transition-[height] ease-out",style:{height:Kt.value}},D(sn.value,!0),{onMousedown:Vn,onMousemove:Un,onMouseup:Zn,onMouseleave:Zn,onTouchstartPassive:Vn,onTouchmovePassive:Un,onTouchendPassive:Zn}),[T("div",{"data-mermaid-wrapper":"",class:b(["absolute inset-0 cursor-grab",{"cursor-grabbing":kt.value}]),style:O(_n.value)},[T("div",{ref_key:"mermaidContent",ref:Ue,class:"_mermaid w-full text-center flex items-center justify-center min-h-full",style:O({height:Gt.value})},null,4)],6)],16),(k(),R(F,{to:"body"},[T("div",{class:b(["markstream-vue",{dark:i.isDark}])},[j($,{name:"mermaid-dialog",appear:""},{default:z(()=>[Hn.value?(k(),x("div",{key:0,class:"mermaid-modal-overlay fixed inset-0 z-50 flex items-center justify-center p-4",onClick:A(Wn,["self"])},[T("div",Ee,[T("div",Oe,[T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Xn},[...t[32]||(t[32]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("circle",{cx:"11",cy:"11",r:"8"}),T("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])]),T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Yn},[...t[33]||(t[33]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[T("circle",{cx:"11",cy:"11",r:"8"}),T("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])]),T("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] text-[length:var(--ms-text-label)] rounded transition-colors",onClick:qn},B(Math.round(100*pt.value))+"% ",1),T("button",{class:"mermaid-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Wn},[...t[34]||(t[34]=[T("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[T("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"})],-1)])])]),T("div",S({ref_key:"modalContent",ref:Ze,class:"w-full h-full flex items-center justify-center p-4 overflow-hidden"},D(sn.value,!0),{onMousedown:Vn,onMousemove:Un,onMouseup:Zn,onMouseleave:Zn,onTouchstartPassive:Vn,onTouchmovePassive:Un,onTouchendPassive:Zn}),null,16)])])):E("",!0)]),_:1})],2)]))]))],512),[[L,!Ye.value]])],10,oe))}}),[["__scopeId","data-v-73c385f8"]]);Se.install=e=>{e.component(Se.__name,Se)};export{Se as default};
|
package/dist/index9.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,l=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,i=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&l(e,n,t[n]);if(r)for(var n of r(t))a.call(t,n)&&l(e,n,t[n]);return e},u=(e,r)=>t(e,n(r)),s=(e,t,n)=>l(e,"symbol"!=typeof t?t+"":t,n);import{defineComponent as c,ref as d,reactive as m,provide as f,computed as v,shallowRef as h,watch as g,nextTick as y,onMounted as k,onUpdated as p,onBeforeUnmount as b,openBlock as w,createElementBlock as M,normalizeClass as S,createElementVNode as x,normalizeStyle as B,Fragment as K,renderList as T,renderSlot as F,mergeProps as H,createBlock as q,unref as R,resolveDynamicComponent as N,toDisplayString as C,createCommentVNode as A,createTextVNode as P}from"vue";import{y as _,aa as j,a4 as I,X as z,a3 as O,a2 as $,a1 as L,a5 as E,ab as D,a0 as V,z as W}from"./exports.js";const Y=["data-markstream-item-key","data-markstream-item-kind"],X={key:0,class:"markstream-virtual-timeline__status"},G=.5,J=/* @__PURE__ */W(/* @__PURE__ */c(u(i({},{name:"MarkstreamVirtualTimeline"}),{__name:"MarkstreamVirtualTimeline",props:{items:{},threadKey:{},layoutRevision:{},getKey:{},getKind:{},getContent:{},getFinal:{},getRevision:{},estimateItemHeight:{},overscan:{default:4},overscanPx:{default:1200},stickToBottom:{type:[Boolean,String],default:"auto"},measurementKey:{},markdownMode:{default:"docs"},markdownCodeRenderer:{},initialThreadState:{},markdownFade:{type:Boolean,default:!1},restoreMaxLoadingMs:{type:[Number,Boolean],default:!1},debug:{type:Boolean}},emits:["height-change","virtual-state-change","range-change","thread-state-change"],setup(e,{expose:t,emit:n}){const r=e,o=n;function a(e){o("thread-state-change",e)}function l(e){return"measured"===e||"final"===e}function c(e){return!0===(null==e?void 0:e.stable)&&function(e){var t,n,r,o;if(!e)return!1;const a=Number(e.nodeCount),l=Number(e.measuredCount),i=Math.max(0,Number(null!=(n=null==(t=e.liveRange)?void 0:t.start)?n:0)),u=Math.min(a,Math.max(i,Number(null!=(o=null==(r=e.liveRange)?void 0:r.end)?o:0))),s=Math.max(0,u-i);return!0===e.final&&"mixed"===e.confidence&&a>0&&l>0&&l<a&&(s<=0||l>=s)}(e)}const W=/* @__PURE__ */new Map;function J(e){var t;!0===r.debug&&W.set(e,(null!=(t=W.get(e))?t:0)+1)}const Q=d(null),U=d(0),Z=d(0),ee=d(0),te=d(!0),ne=d(!0),re=m(/* @__PURE__ */new Map),oe=/* @__PURE__ */new Map,ae=/* @__PURE__ */new Map,le=/* @__PURE__ */new Map,ie=/* @__PURE__ */new Map,ue=/* @__PURE__ */new Set,se=m(/* @__PURE__ */new Map),ce=m(/* @__PURE__ */new Map),de=/* @__PURE__ */new Map,me=/* @__PURE__ */new Map,fe=/* @__PURE__ */new Map,ve=/* @__PURE__ */new Map,he=d(!1),ge=d(!0),ye=d(!0);f("markstreamHostScrollManaged",ye);const ke=[0,80,180,360,640];let pe,be,we=null,Me=null,Se=0,xe=null,Be=[],Ke=null,Te=null,Fe=-1,He=0,qe=null,Re=!1,Ne=!1,Ce=null,Ae=0,Pe=0,_e={top:0,bottom:0},je=!1;const Ie=v(()=>null==r.threadKey?void 0:String(r.threadKey));let ze=Ie.value;function Oe(e){return"chat"===e||"minimal"===e||"docs"===e?e:"docs"}const $e=v(()=>Oe(r.markdownMode)),Le=v(()=>function(e,t=Oe(r.markdownMode)){return"pre"===e||"shiki"===e||"monaco"===e?e:"docs"===t?"monaco":"pre"}(r.markdownCodeRenderer,$e.value)),Ee=v(()=>[null==r.measurementKey?"":String(r.measurementKey),ee.value].join(":")),De=v(()=>`${Ee.value}${$e.value}${Le.value}`);class Ve{constructor(e){s(this,"tree"),s(this,"total"),this.tree=Array.from({length:e.length+1},()=>0),this.total=0,e.forEach((e,t)=>this.add(t,e))}add(e,t){if(Number.isFinite(t)&&0!==t){this.total+=t;for(let n=e+1;n<this.tree.length;n+=n&-n)this.tree[n]+=t}}prefixSum(e){let t=Math.max(0,Math.min(e,this.tree.length-1)),n=0;for(;t>0;)n+=this.tree[t],t-=t&-t;return n}lowerBound(e,t="gte"){const n=this.tree.length-1;if(n<=0)return 0;if(e<=0)return 0;if(e>=this.total)return n-1;let r=0,o=1;for(;o<<1<this.tree.length;)o<<=1;let a=0;for(;o>0;o>>=1){const n=r+o;if(n<this.tree.length){const o=a+this.tree[n];("gt"===t?o<=e:o<e)&&(r=n,a=o)}}return Math.min(r,n-1)}}const We=h([]),Ye=/* @__PURE__ */new Map,Xe=h(new Ve([])),Ge=d(0);let Je=[];const Qe=v(()=>(Ge.value,{records:We.value,totalHeight:Xe.value.total}));function Ue(){var e;const t=[],n=[],o=function(){var e;return null!=(e=Ie.value)?e:"timeline"}();Ye.clear();for(let a=0;a<r.items.length;a++){const l=r.items[a],s=lt(l,a),c={item:l,index:a,key:s,kind:I(l,a,r),markdown:j(l,a,r)};let d=bt(c);null==d&&(d=null!=(e=Je[a])?e:z(l,a,r));const m=u(i({},c),{renderKey:`${o}:${s}`,offset:0,size:d,component:null==l?void 0:l.component});t.push(m),n.push(d),Ye.has(s)||Ye.set(s,m)}We.value=t,Xe.value=new Ve(n),Je=[],Ge.value+=1}function Ze(e){return Ge.value,Xe.value.prefixSum(e.index)}function et(e){return u(i({},e),{offset:Ze(e)})}function tt(e,t){const n=Ye.get(e);if(!n)return;const r=Math.ceil(t),o=r-n.size;0!==o&&(n.size=r,Xe.value.add(n.index,o),Ge.value+=1)}function nt(e,t="gte"){return Ge.value,Xe.value.lowerBound(e,t)}const rt=v(()=>{var e;return Math.max(0,null!=(e=r.overscan)?e:4)}),ot=v(()=>{var e;const t=Math.max(0,null!=(e=r.overscanPx)?e:1200);return ge.value?t:Math.min(t,160)}),at=v(()=>{var e,t,n;const r=Qe.value.records;if(0===r.length)return{start:0,end:0,records:[],topSpacerHeight:0,bottomSpacerHeight:0};const o=rt.value,a=ot.value,l=At(),i=l+Math.max(1,Z.value);let u=nt(Math.max(0,l-a),"gt"),s=nt(Math.min(Qe.value.totalHeight,i+a))+1;u=Math.max(0,u-o),s=Math.min(r.length,Math.max(s+o,u+1));const c=r.slice(u,s).map(et),d=c[0],m=c[c.length-1],f=null!=(e=null==d?void 0:d.offset)?e:0,v=null!=(t=null==m?void 0:m.offset)?t:0;return{start:u,end:s,records:c,topSpacerHeight:f,bottomSpacerHeight:Math.max(0,Qe.value.totalHeight-(v+(null!=(n=null==m?void 0:m.size)?n:0)))}});function lt(e,t){return O(e,t,r)}const it=/* @__PURE__ */new WeakMap;let ut=1;function st(e){if("object"!=typeof e&&"function"!=typeof e||null===e)return String(null!=e?e:"");const t=e;let n=it.get(t);return n||(n=ut++,it.set(t,n)),String(n)}function ct(e,t,n){var o;if(n)return"";const a="string"==typeof(null==e?void 0:e.text)?e.text:"string"==typeof(null==e?void 0:e.message)?e.message:"string"==typeof(null==e?void 0:e.label)?e.label:String(null!=(o=L(e,t,r))?o:"");return a?`${a.length}:${function(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}(a)}`:""}function dt(e,t){if("function"!=typeof r.estimateItemHeight)return"";const n=r.estimateItemHeight(e,t);if(!Number.isFinite(n)||n<=0)return"";const o=Math.ceil(n);return Je[t]=o,String(o)}function mt(e){var t;return null!=(t=r.items[e.index])?t:e.item}function ft(e){return e.item}function vt(e){var t;const n=mt(e);return null!=(t=null==n?void 0:n.component)?t:e.component}function ht(e,t=Ie.value){const n=ft(e),o=E(n,e.index,r);return[null!=t?t:"timeline",e.key,null==o?"":String(o)].join(":")}function gt(e,t=Ie.value){if(e.markdown)return ht(e,t);const n=ft(e),o=E(n,e.index,r);return[null!=t?t:"timeline",e.key,null==o?"":String(o)].join(":")}function yt(e){return{sourceKey:gt(e),measurementKey:e.markdown?De.value:Ee.value,widthBucket:ee.value}}function kt(e,t){var n,r,o,a,l,i;return(null!=(n=null==e?void 0:e.sourceKey)?n:"")===(null!=(r=null==t?void 0:t.sourceKey)?r:"")&&(null!=(o=null==e?void 0:e.measurementKey)?o:"")===(null!=(a=null==t?void 0:t.measurementKey)?a:"")&&(null!=(l=null==e?void 0:e.widthBucket)?l:0)===(null!=(i=null==t?void 0:t.widthBucket)?i:0)}function pt(e,t,n=Ie.value){var r;return!(!e||!t)&&t.sourceKey===gt(e,n)&&t.measurementKey===(e.markdown?De.value:Ee.value)&&(null!=(r=t.widthBucket)?r:0)===ee.value}function bt(e,t=Ie.value){const n=re.get(e.key);return pt(e,oe.get(e.key),t)&&Number.isFinite(n)&&n>0?n:null}function wt(e){return Qe.value,Ye.get(e)}function Mt(e,t){var n,r;return!!(e&&e.markdown&&t)&&t.sessionKey===ht(e)&&(null!=(n=t.threadKey)?n:"")===(null!=(r=Ie.value)?r:"")&&!!function(e){const t=De.value,n=null!=e?e:"";return n===t||n.startsWith(`${t}\0`)}(t.measurementKey)}function St(e,t){return Mt(e,t)}function xt(e,t,n){!Number.isFinite(t)||t<=0||(ce.set(e,Math.ceil(t)),de.set(e,n))}function Bt(e,t=se.get(e)){const n=function(e,t=se.get(e)){var n;if(!St(wt(e),t))return 0;const r=Number(null==(n=null==t?void 0:t.metrics)?void 0:n.totalHeight);return Number.isFinite(r)&&r>0?Math.ceil(r):0}(e,t);return n>0&&xt(e,n,t),n}function Kt(e){var t;return Mt(wt(e),de.get(e))?null!=(t=ce.get(e))?t:0:Bt(e)}function Tt(e){return e===Se&&He===e&&!ge.value}function Ft(){if(null!=xe&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(xe),xe=null,null!=Ke&&"undefined"!=typeof window&&window.clearTimeout(Ke),Ke=null,"undefined"!=typeof window)for(const e of Be)window.clearTimeout(e);Be=[]}function Ht(){var e;return Math.max(0,Z.value||(null==(e=Q.value)?void 0:e.clientHeight)||0)}function qt(){const e=Q.value;if(!e||"function"!=typeof getComputedStyle)return void(_e={top:0,bottom:0});const t=getComputedStyle(e),n=Number.parseFloat(t.paddingTop)||0,r=Number.parseFloat(t.paddingBottom)||0;_e={top:n,bottom:r}}function Rt(){return _e.top}function Nt(){const e=_e;return Math.max(0,Qe.value.totalHeight+e.top+e.bottom)}function Ct(){var e,t;return Math.max(Nt(),null!=(t=null==(e=Q.value)?void 0:e.scrollHeight)?t:0)}function At(){return Math.max(0,U.value-Rt())}function Pt(){return Math.max(0,Ct()-Ht())}function _t(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(t,Pt())):0}function jt(){return Math.max(0,Pt()-U.value)}function It(){const e=jt();ne.value=e<=2,!0!==r.stickToBottom?!1!==r.stickToBottom?te.value=e<=48:te.value=!1:te.value=!0}function zt(){var e,t;const n=null!=(t=null==(e=Q.value)?void 0:e.clientWidth)?t:0;ee.value=Number.isFinite(n)&&n>0?32*Math.round(n/32):0}function Ot(e={}){const t=Q.value;t&&(U.value=Math.max(0,t.scrollTop||0),Z.value=t.clientHeight||0),zt(),It(),(!0===e.remember||!1!==e.remember&&!he.value)&&vn()}function $t(e,t={}){const n=_t(e),o=Q.value;if(U.value=n,o&&(Z.value=o.clientHeight||Z.value||0,!1!==t.writeDom&&Math.abs((o.scrollTop||0)-n)>G)){const e={target:n,preserveBottomPin:!1!==r.stickToBottom&&Math.abs(Pt()-n)<=2};Me=ge.value?e:null,o.scrollTop=n,e.target=Math.max(0,o.scrollTop||0)}zt(),!1!==t.updatePinned&&It(),(!0===t.remember||!1!==t.remember&&!he.value)&&vn()}function Lt(){if(!ge.value){Me=null;const e=Q.value,t=qe;return e&&null!=t&&Math.abs((e.scrollTop||0)-t)>G&&(e.scrollTop=t),void pn(He,be)}const e=Q.value,t=Me,n=Math.max(0,(null==e?void 0:e.scrollTop)||0);return e&&t&&Math.abs(n-t.target)<=G&&t.preserveBottomPin&&!1!==r.stickToBottom||e&&ne.value&&"auto"===r.stickToBottom&&(Math.abs(Pt()-n)<=2||n>=U.value-G)||!0===r.stickToBottom?(te.value=!0,ne.value=!0,void $t(Pt(),{writeDom:!0,remember:!1})):(Me=null,void Ot())}function Et(e){$t(e,{writeDom:!0,remember:!0})}function Dt(){Et(Pt())}function Vt(e,t){const n=ae.get(e);if(!Number.isFinite(n)||null==n||n<=0)return 0;const r=le.get(e);return t&&r&&!Wt(r,t)?0:Math.ceil(n)}function Wt(e,t){var n,r,o,a;return e.sourceKey===t.sourceKey&&(0===(null!=(n=t.widthBucket)?n:0)||0===(null!=(r=e.widthBucket)?r:0)||(null!=(o=t.widthBucket)?o:0)===(null!=(a=e.widthBucket)?a:0))&&(Yt(t.measurementKey)||Yt(e.measurementKey)||t.measurementKey===e.measurementKey)}function Yt(e){return":0"===e||!0===(null==e?void 0:e.startsWith(":0"))}function Xt(e){ae.delete(e),le.delete(e),ie.delete(e),ue.delete(e)}function Gt(e,t,n,o={}){if(!Number.isFinite(t)||t<=0)return;const a=re.get(e),l=n&&!kt(oe.get(e),n),i=!0===o.releaseRestoredFloor;!function(e,t){if(!t)return;const n=le.get(e);n&&!Wt(n,t)&&(ae.delete(e),le.delete(e),ie.delete(e),ue.delete(e))}(e,n),i&&Xt(e);const u=Vt(e,n),s=u>0?u:Math.ceil(t);if(null!=a&&Math.abs(a-s)<=1&&!l)return void(i&&(Ge.value+=1));if(!1===o.updateLayout)return n&&oe.set(e,n),re.set(e,s),void gn(o.rememberThreadKey);if(he.value)return n&&oe.set(e,n),re.set(e,s),tt(e,s),void function(e=He,t=be){t&&y(()=>{pn(e,t),null==xe&&"function"==typeof requestAnimationFrame&&(xe=requestAnimationFrame(()=>{xe=null,pn(e,t)}))})}();const c=(d=mn(),m=jt(),!0===r.stickToBottom?{type:"bottom",distanceFromBottomPx:0}:"auto"===r.stickToBottom&&te.value?{type:"bottom",distanceFromBottomPx:ne.value?0:Math.max(0,m)}:d);var d,m;n&&oe.set(e,n),re.set(e,s),tt(e,s),gn(o.rememberThreadKey),function(e){if(!Jt.scheduled)return Jt.anchor=e,Jt.scheduled=!0,void(Jt.raf=en(nn));!Jt.anchor&&e&&(Jt.anchor=e)}(c)}g([()=>function(){const e=r.layoutRevision;return null!=e?["explicit",String(e),r.items.length].join(""):r.items.map((e,t)=>{var n;const o=lt(e,t),a=j(e,t,r);return[o,I(e,t,r),a?1:0,null!=(n=E(e,t,r))?n:"",dt(e,t),ct(e,t,a),(l=null==e?void 0:e.component,l?"string"==typeof l?`s:${l}`:`o:${st(l)}`:"")].join("");var l}).join("\0")}(),Ee,De,Ie,()=>st(r.estimateItemHeight),()=>st(r.getKey),()=>st(r.getKind),()=>st(r.getContent),()=>st(r.getFinal),()=>st(r.getRevision)],()=>Ue(),{immediate:!0,flush:"sync"});const Jt={scheduled:!1,raf:null,anchor:void 0},Qt=/* @__PURE__ */new Map;let Ut=!1,Zt=null;function en(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(e):(y(e),null)}function tn(e){null!=e&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}function nn(){if(!Jt.scheduled)return;Jt.scheduled=!1,Jt.raf=null;const e=Jt.anchor;Jt.anchor=void 0;const t="bottom"===(null==e?void 0:e.type)&&e.distanceFromBottomPx<=2&&ne.value;e&&kn(e);const n=Q.value,r=!n||Math.abs((n.scrollTop||0)-U.value)<=G;t&&!r||Ot({remember:!1})}function rn(){var e,t;if(!Ut)return;Ut=!1,Zt=null;const n=Array.from(Qt.entries());Qt.clear();for(const[r,o]of n){if(ce.get(r)!==o.logicalHeight)continue;const n=Ye.get(r);if(!n)continue;const a=(null!=(e=o.threadKey)?e:"")===(null!=(t=Ie.value)?t:"");ln(n,{allowMarkdownShrink:o.allowMarkdownShrink,allowRestoredFloorShrink:o.allowRestoredFloorShrink,markdownLogicalHeight:o.logicalHeight,rememberThreadKey:o.threadKey,source:o.itemSizeSource,updateLayout:a})}nn()}function on(){rn(),nn()}function an(e){var t;null==(t=fe.get(e))||t.disconnect(),fe.delete(e),me.delete(e)}function ln(e,t={}){var n,o,a;const l=(s=e.key,D(me.get(s),J));var s;const c=null!=(n=t.source)?n:yt(e);let d=!1;const m=()=>{d||(d=!0,function(e,t){const n=function(){if(!0!==r.debug||0===W.size)return null;let e=0;for(const n of W.values())e+=n;const t={total:e,byLabel:Object.fromEntries(Array.from(W.entries()).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])))};return W.clear(),t}();n&&console.info("[markstream-vue][timeline][perf] layout-reads",{label:e,itemKey:t,layoutReads:n})}("reconcileRecordSize",e.key))};if(!e.markdown)return l>0&&Gt(e.key,l,c,t),void m();const f=kt(oe.get(e.key),c)&&null!=(o=re.get(e.key))?o:0,v=null!=(a=t.markdownLogicalHeight)?a:Kt(e.key),h=function(e,t){return V(me.get(e),J,t)}(e.key,l);if(v>0){let n=Math.max(l,v+h);(!t.allowMarkdownShrink||he.value)&&f>0&&(n=Math.max(n,f));const o=Vt(e.key,c),a=o>0&&n>o+1&&(!$(mt(e),e.index,r)||!0===t.allowRestoredFloorShrink);return e.markdown&&o>0&&(!0===t.allowRestoredFloorShrink||a)?he.value?ue.add(e.key):t=u(i({},t),{releaseRestoredFloor:!0}):t.allowMarkdownShrink&&!he.value&&(o<=0||t.allowRestoredFloorShrink&&function(e,t,n){const r=ie.get(e);return!Number.isFinite(r)||null==r||r<=0||t+Math.max(0,n-r)<n-1}(e.key,v,o))&&Xt(e.key),n>0&&Gt(e.key,n,c,t),void m()}return String(L(mt(e),e.index,r)).trim()?f>0?(l>f+1&&Gt(e.key,l,c,t),void m()):(l>0&&Gt(e.key,l,c,t),void m()):(l>0&&(Xt(e.key),Gt(e.key,l,c,t)),void m())}function un(e){return t=>{!function(e,t){const n=function(e){const t=e&&"$el"in e?e.$el:e;return t instanceof HTMLElement?t:null}(t),r=me.get(e.key);if(!n)return void an(e.key);if(r===n)return void ln(e);if(an(e.key),me.set(e.key,n),ln(e),"undefined"==typeof ResizeObserver)return;const o=new ResizeObserver(()=>{ln(e)});o.observe(n),fe.set(e.key,o)}(e,t)}}function sn(e){const t=mt(e),n=$(t,e.index,r),a=se.get(e.key),s=$e.value,d=Le.value,m={enabled:!0,sessionKey:ht(e),threadKey:Ie.value,scrollRoot:()=>Q.value,restoreState:St(e,a)?a:null,restoreAnchor:!1,measurementKey:De.value,settleMode:"manual",settledToken:n,emitIntervalMs:96,heightDiffThresholdPx:4};return u(i({content:L(t,e.index,r),final:n,mode:s,codeRenderer:d},n?{nodeVirtual:"auto",maxLiveNodes:50,liveNodeBuffer:16}:{}),{fade:!0===r.markdownFade,indexKey:ht(e),virtualScroll:m,onHeightChange(t){if(t.sessionKey!==ht(e))return;xt(e.key,t.totalHeight,{sessionKey:t.sessionKey,threadKey:Ie.value,measurementKey:De.value});const n=function(e){return"final"===e.phase||!(!0!==e.final||!l(e.confidence))||!!e.stable&&(l(e.confidence)||c(e))}(t),r=function(e){return"final"===e.phase||!!e.stable&&(l(e.confidence)||c(e))}(t),a=Math.ceil(t.totalHeight);var i;!function(e,t){Qt.set(e.key,t),Ut||(Ut=!0,Zt=en(rn))}(e,{allowMarkdownShrink:n,allowRestoredFloorShrink:r,itemSizeSource:yt(e),logicalHeight:a,threadKey:Ie.value}),i={itemKey:e.key,metrics:t},o("height-change",i)},onVirtualStateChange(t){var n;t.sessionKey===ht(e)&&(se.set(e.key,t),Bt(e.key,t),gn(),n={itemKey:e.key,state:t},o("virtual-state-change",n))}})}function cn(e){return{item:mt(e),index:e.index,itemKey:e.key,kind:e.kind,measureRef:un(e),markdownProps:sn(e)}}function dn(e){var t;const n=null!=(t=mt(e))?t:{};return"string"==typeof n.text?n.text:"string"==typeof n.message?n.message:"string"==typeof n.label?n.label:L(n,e.index,r)}function mn(){const e=jt();if(e<=2)return{type:"bottom",distanceFromBottomPx:Math.max(0,e)};const t=At(),n=nt(t,"gt"),r=Qe.value.records[n];if(r){const e=Ze(r);if(t>=e&&t<e+r.size)return{type:"item",itemKey:r.key,offsetWithinItemPx:t-e}}const o=at.value.records[0];return o?{type:"item",itemKey:o.key,offsetWithinItemPx:0}:void 0}function fn(e=Ie.value){on();const t={},n={};for(const r of Qe.value.records){const o=bt(r,e),a=oe.get(r.key);null!=o&&pt(r,a,e)&&(t[r.key]=o,n[r.key]=a)}return{threadKey:e,measurementKey:Ee.value,widthBucket:ee.value,outerAnchor:mn(),itemHeights:t,itemSizeSources:n,markdownStates:Object.fromEntries(se.entries())}}function vn(e=Ie.value){if(!e)return;const t=fn(e);return ve.set(e,t),e===Ie.value&&(Ce=t),a(t),t}function hn(){const e=pe;return null!=Te&&"undefined"!=typeof window&&window.clearTimeout(Te),Te=null,pe=void 0,e?vn(e):void 0}function gn(e=Ie.value){e&&(pe=e,null==Te&&("undefined"!=typeof window?Te=window.setTimeout(()=>{Te=null,hn()},80):hn()))}function yn(e){if(!e)return null;if("bottom"===e.type)return(ge.value?Ct():Nt())-Ht()-Math.max(0,e.distanceFromBottomPx);const t=wt(e.itemKey);return t?Rt()+Ze(t)+Math.max(0,e.offsetWithinItemPx):null}function kn(e,t={}){const n=yn(e);return null!=n&&($t(n,{writeDom:!0,remember:!0===t.remember}),!0)}function pn(e,t){if(e===Se){if(t){const e=kn(t,{remember:!1});qe=e?U.value:null}Ot({remember:!1})}}function bn(e,t){const n=e.getBoundingClientRect();return n.width>0&&n.height>0&&n.bottom>t.top&&n.top<t.bottom}function wn(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.bottom>r.top&&n.top<r.bottom}function Mn(e){if(e.closest(".code-editor-container.is-hidden"))return!1;let t=e;for(;t;){const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility||Number.parseFloat(e.opacity||"1")<=.01)return!1;t=t.parentElement}const n=e.getBoundingClientRect();return n.width>0&&n.height>0}function Sn(e){if(!e)return!1;if(e.classList.contains("is-fading-out"))return!1;const t=window.getComputedStyle(e);if("none"===t.display||Number.parseFloat(t.opacity||"1")<=.01)return!1;const n=e.getBoundingClientRect();return n.width>0&&n.height>0}function xn(e){return Array.from(e.querySelectorAll(['[data-markstream-pending="true"]','[data-markstream-mermaid][data-markstream-mode="pending"]','.mermaid-block-container[data-markstream-mode="pending"]','[data-markstream-code-loading="1"]'].join(","))).some(e=>!e.matches('[data-markstream-code-block="1"]')||!Sn(e.querySelector("pre.code-pre-fallback")))}function Bn(e){var t;if(e.querySelector(":scope > .node-placeholder"))return!1;const n=e.querySelector(":scope > .node-content");return!!n&&(!xn(n)&&(!!function(e){const t=Array.from(e.querySelectorAll("[data-markstream-math]"));return!t.length||t.every(e=>{const t=e.dataset.markstreamMode;return!("true"===e.dataset.markstreamPending||"loading"===t||"katex"!==t&&"fallback"!==t)})}(n)&&("code_block"===(null!=(t=e.dataset.nodeType)?t:"")?function(e){if(e.querySelector('[data-markstream-code-loading="1"]'))return!1;const t=e.querySelector('[data-markstream-code-block="1"]');if(t){const e="true"===t.dataset.markstreamEnhanced,r=Sn(t.querySelector("pre.code-pre-fallback"));return e||r||(n=t,Array.from(n.querySelectorAll(".monaco-editor, .monaco-diff-editor")).some(Mn))}var n;return function(e){var t,n;const r=e.querySelector("[data-markstream-mermaid], .mermaid-block-container");if(r){if("true"===r.dataset.markstreamPending)return!1;const e=r.dataset.markstreamMode;return"preview"===e?Boolean(r.querySelector("svg")||r.querySelector('[data-mermaid-svg-layer="1"] svg')):"fallback"===e&&Boolean(null==(n=null==(t=r.querySelector(".mermaid-source-code"))?void 0:t.textContent)?void 0:n.trim())}const o=e.querySelector("[data-markstream-infographic], .infographic-block-container");if(o)return"true"!==o.dataset.markstreamPending;const a=e.querySelector("[data-markstream-d2], .d2-block-container");return a?"true"!==a.dataset.markstreamPending:Boolean(e.querySelector('pre[data-markstream-pre="1"]'))}(e)}(n):function(e){var t;return(null!=(t=e.textContent)?t:"").trim().length>0||Boolean(e.querySelector(["hr","br","table","blockquote","img","svg","canvas","input","button","select","textarea","[role]","[aria-label]","[data-markstream-math]","[data-markstream-mermaid]","[data-markstream-infographic]","[data-markstream-d2]",'[data-markstream-pre="1"]'].join(",")))}(n))))}function Kn(e,t){var n;if(!e.markdown)return!0;const o=L(mt(e),e.index,r);if(!String(null!=o?o:"").trim())return!0;if(t.querySelector("[data-node-index]"))return!0;const a=t.querySelector(".markdown-renderer"),l=null!=a?a:t;return!xn(l)&&(!!(null!=(n=l.textContent)?n:"").trim()||Boolean(l.querySelector(["hr","br","table","blockquote","img","svg","canvas","input","button","[role]","[aria-label]","[data-markstream-math]","[data-markstream-mermaid]","[data-markstream-infographic]","[data-markstream-d2]",'[data-markstream-pre="1"]','[data-markstream-code-block="1"]'].join(","))))}function Tn(e,t,n){if(!e.markdown)return!0;const o=L(mt(e),e.index,r);if(!String(null!=o?o:"").trim())return!0;const a=n.getBoundingClientRect(),l=Array.from(t.querySelectorAll("[data-node-index]")).filter(e=>bn(e,a));if(l.length>0)return l.every(e=>Bn(e));const i=t.querySelector(".markdown-renderer"),u=null!=i?i:t;return u.querySelector("[data-node-index], .node-placeholder")?!!function(e,t,n,r){if(!Fn(e))return!1;const o=n.getBoundingClientRect(),a=t.getBoundingClientRect();return o.width>0&&o.height>0&&o.bottom<=r.top+1&&a.bottom>r.top}(e,t,u,a)&&Kn(e,t):Kn(e,t)}function Fn(e){const t=oe.get(e.key);return Vt(e.key,t)>0}function Hn(e,t){var n,o,a,i;if(!e.markdown)return!0;if(!Re&&!Ne)return!0;if(Fn(e))return!0;const u=L(mt(e),e.index,r);if(!String(null!=u?u:"").trim())return!0;if(!t.querySelector(".markdown-renderer"))return!1;const s=se.get(e.key);if(!St(e,s))return!1;const d=null==s?void 0:s.metrics,m=Number(null!=(n=null==d?void 0:d.totalHeight)?n:0);if(!Number.isFinite(m)||m<=0)return!1;const f=Number(null!=(o=null==d?void 0:d.measuredCount)?o:0),v=Number(null!=(a=null==d?void 0:d.estimatedCount)?a:0),h=Number(null!=(i=null==d?void 0:d.nodeCount)?i:0),g=h<=0||f>=h&&v<=0,y=l(null==d?void 0:d.confidence),k=c(d),p=!0===(null==d?void 0:d.stable)||y||k;return Ne?!0===(null==d?void 0:d.final)&&(g&&y||k):p||!0===(null==d?void 0:d.final)}function qn(){const e=Q.value;if(!e)return!1;const t=yn(be);if(null!=t&&Math.abs((e.scrollTop||0)-_t(t))>G)return!1;const n=at.value.records;if(!n.length)return 0===Qe.value.records.length;const r=new Map(Array.from(e.querySelectorAll("[data-markstream-item-key]")).map(e=>{var t;return[null!=(t=e.dataset.markstreamItemKey)?t:"",e]})),o=[];for(const i of n){const t=r.get(i.key);t&&wn(t,e)&&o.push({record:i,el:t})}if(!o.length)return!1;for(const{record:i,el:u}of o){if(u.offsetHeight+1<i.size)return!1;if(!Tn(i,u,e))return!1;if(!Hn(i,u))return!1}const a=e.getBoundingClientRect();if(Array.from(e.querySelectorAll(['[data-markstream-pending="true"]','[data-markstream-mermaid][data-markstream-mode="pending"]','.mermaid-block-container[data-markstream-mode="pending"]','[data-markstream-code-loading="1"]'].join(","))).some(e=>!(!bn(e,a)||e.matches('[data-markstream-code-block="1"]')&&Sn(e.querySelector("pre.code-pre-fallback")))))return!1;const l=Array.from(e.querySelectorAll("[data-node-index]")).filter(e=>bn(e,a));for(const i of l)if(!Bn(i))return!1;return!0}function Rn(){const e=Q.value;if(!e)return"";const t=e.getBoundingClientRect(),n=new Map(Array.from(e.querySelectorAll("[data-markstream-item-key]")).map(e=>{var t;return[null!=(t=e.dataset.markstreamItemKey)?t:"",e]})),r=at.value.records.map(e=>{var t,r,o,a,l,i,u,s,c;const d=n.get(e.key),m=null==d?void 0:d.querySelector(".markdown-renderer"),f=null==(t=se.get(e.key))?void 0:t.metrics;return[e.key,e.size,null!=(r=null==d?void 0:d.offsetHeight)?r:0,null!=(o=null==d?void 0:d.scrollHeight)?o:0,null!=(a=null==m?void 0:m.offsetHeight)?a:0,null!=(l=null==m?void 0:m.scrollHeight)?l:0,f?Math.round(Number(f.totalHeight||0)):"",null!=(i=null==f?void 0:f.measuredCount)?i:"",null!=(u=null==f?void 0:f.estimatedCount)?u:"",null!=(s=null==f?void 0:f.nodeCount)?s:"",!0===(null==f?void 0:f.final)?1:0,!0===(null==f?void 0:f.stable)?1:0,null!=(c=null==f?void 0:f.confidence)?c:""].join(":")}).join("|"),o=Array.from(e.querySelectorAll("[data-node-index]")).filter(e=>bn(e,t)).map(e=>{var t,n,r,o,a;const l=e.getBoundingClientRect(),i=e.querySelector(":scope > .node-content"),u=null==i?void 0:i.querySelector('[data-markstream-code-block="1"]'),s=null==i?void 0:i.querySelector("pre.code-pre-fallback"),c=null==i?void 0:i.querySelector(".monaco-editor, .monaco-diff-editor");return[null!=(t=e.dataset.nodeIndex)?t:"",null!=(n=e.dataset.nodeType)?n:"",Math.round(l.height),null!=(r=null==i?void 0:i.offsetHeight)?r:0,null!=(o=null==i?void 0:i.scrollHeight)?o:0,null!=(a=null==u?void 0:u.dataset.markstreamEnhanced)?a:"",u?Math.round(u.getBoundingClientRect().height):0,s?Math.round(s.getBoundingClientRect().height):0,c?Math.round(c.getBoundingClientRect().height):0].join(":")}).join("|");return[Math.round(e.scrollTop||0),Math.round(e.scrollHeight||0),Math.round(Qe.value.totalHeight||0),r,o].join("\n")}function Nn(){return"undefined"!=typeof performance?performance.now():Date.now()}function Cn(){return Ne?24:2}function An(e){Tt(e)&&Ae!==e&&(Ae=e,function(e){return t=this,n=function*(){const t=Nn();let n=0,r="";for(let o=0;o<40;o++){if(yield y(),yield new Promise(e=>{"function"!=typeof requestAnimationFrame?e():requestAnimationFrame(()=>e())}),!Tt(e))return!1;pn(e,be);const o=Nn(),a=qn(),l=a?Rn():"";if(a&&l===r&&l){if(n+=1,n>=Cn()&&o-t>=96)return!0}else n=0,r=l}return!1},new Promise((e,r)=>{var o=e=>{try{l(n.next(e))}catch(t){r(t)}},a=e=>{try{l(n.throw(e))}catch(t){r(t)}},l=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,a);l((n=n.apply(t,null)).next())});var t,n}(e).then(t=>{if(Ae===e&&(Ae=0),Tt(e))return t?void zn(e):function(){if(Fe<0)return!1;const e=function(){if(!1===r.restoreMaxLoadingMs)return Number.POSITIVE_INFINITY;const e=Number(r.restoreMaxLoadingMs);return Number.isFinite(e)&&e>0?e:Number.POSITIVE_INFINITY}();return Number.isFinite(e)&&Nn()-Fe>=e}()?(!0===r.debug&&import.meta,void zn(e)):(function(e){Pe!==e&&(Pe=e,!0===r.debug&&import.meta)}(e),void function(e){Tt(e)&&"undefined"!=typeof window&&(null!=Ke&&window.clearTimeout(Ke),Ke=window.setTimeout(()=>{Ke=null,Tt(e)&&An(e)},120))}(e))}))}function Pn(){ge.value=!0,Fe=-1,Ae=0,Pe=0,Re=!1,Ne=!1,null!=Ke&&"undefined"!=typeof window&&window.clearTimeout(Ke),Ke=null}function _n(){je=!0}function jn(e){var t,n;const r=[];if(!function(e){var t,n;return!!e&&(null!=(t=e.measurementKey)?t:"")===Ee.value&&(null!=(n=e.widthBucket)?n:0)===ee.value}(e))return r;for(const[o,a]of Object.entries(null!=(t=null==e?void 0:e.itemHeights)?t:{})){if(!Number.isFinite(a)||a<=0)continue;const t=wt(o),l=null==(n=null==e?void 0:e.itemSizeSources)?void 0:n[o];pt(t,l)&&r.push([o,Math.ceil(a),l])}return r}function In(e){var t;for(const[n,r]of Object.entries(null!=(t=null==e?void 0:e.markdownStates)?t:{}))if(St(wt(n),r))return!0;return!1}function zn(e){if(e!==Se)return;rn();const t=new Set(ue);Ft(),pn(e,be),he.value=!1,Fe=-1,be=void 0,qe=null,He=0;for(const n of Qe.value.records)n.markdown&&!t.has(n.key)||Xt(n.key);for(const n of t){const e=Ye.get(n);e?ln(e,{allowMarkdownShrink:!0,allowRestoredFloorShrink:!0,markdownLogicalHeight:Kt(e.key),source:yt(e),updateLayout:!0}):Xt(n)}ue.clear(),nn(),Ot({remember:!1}),Pn(),_n()}function On(e,t={}){var n;const o=++Se;Me=null,(null==e?void 0:e.widthBucket)&&0===ee.value&&(ee.value=e.widthBucket);const a=null==e?void 0:e.outerAnchor,l=function(e){return Boolean((null==e?void 0:e.outerAnchor)||jn(e).length>0||In(e))}(e),i=In(e),u=!(!je&&!0!==t.threadSwitch||l),s=l||u,c=null!=a?a:s?function(){if(!1!==r.stickToBottom)return{type:"bottom",distanceFromBottomPx:0};const e=Qe.value.records[0];return e?{type:"item",itemKey:e.key,offsetWithinItemPx:0}:void 0}():void 0;Ft(),Ae=0,Pe=0,ge.value=!s,he.value=s&&Boolean(c),He=o,be=c,Re=s&&i,Ne=s&&u,Fe=he.value?Nn():-1,$n(),re.clear(),oe.clear(),ae.clear(),le.clear(),ie.clear(),ue.clear(),se.clear(),ce.clear(),de.clear();for(const[r,m,f]of jn(e)){const e=Math.ceil(m);oe.set(r,f),re.set(r,e),ae.set(r,e),le.set(r,f)}for(const[r,m]of Object.entries(null!=(n=null==e?void 0:e.markdownStates)?n:{})){se.set(r,m);const e=Bt(r,m);e>0&&ie.set(r,e)}Ue(),!0===r.stickToBottom?(te.value=!0,ne.value=!0):!1===r.stickToBottom?(te.value=!1,ne.value=!1):(te.value="bottom"===(null==c?void 0:c.type),ne.value="bottom"===(null==c?void 0:c.type)&&c.distanceFromBottomPx<=2);const d=yn(c);return qe=null==d?null:_t(d),null!=d&&$t(d,{writeDom:!0,remember:!1,updatePinned:!1}),Ce=(null==e?void 0:e.threadKey)===Ie.value?e:null,s?c?void y(()=>{pn(o,c),"undefined"!=typeof window?(ke.forEach(e=>{const t=window.setTimeout(()=>{pn(o,c)},e);Be.push(t)}),An(o)):zn(o)}):(he.value=!1,be=void 0,qe=null,He=0,Ot({remember:!1}),Pn(),void _n()):(he.value=!1,be=void 0,qe=null,He=0,Ot({remember:!1}),Pn(),_n(),void(!1!==r.stickToBottom&&(te.value=!0,ne.value=!0,y(()=>{he.value||Dt()}))))}function $n(){for(const e of fe.values())e.disconnect();fe.clear(),me.clear()}return g(Ie,(e,t)=>{const n=null!=ze?ze:t,o=Boolean(n&&n!==e);o&&function(e){var t;on(),(null==(t=hn())?void 0:t.threadKey)!==e&&((null==Ce?void 0:Ce.threadKey)===e?(ve.set(e,Ce),a(Ce)):ve.has(e)||vn(e))}(n),ze=e,On(function(e){return(e?ve.get(e):null)||function(e){var t;const n=r.initialThreadState;return n?(null!=(t=n.threadKey)?t:"")!==(null!=e?e:"")?null:n:null}(e)}(e),{threadSwitch:o})},{immediate:!0,flush:"sync"}),g(()=>at.value.records.map(e=>e.key).join("\0"),()=>{var e;e={start:at.value.start,end:at.value.end},o("range-change",e)},{immediate:!0}),g(()=>[r.items.length,Qe.value.totalHeight],()=>{he.value||!1!==r.stickToBottom&&("auto"!==r.stickToBottom||ne.value)&&y(()=>{he.value||!1!==r.stickToBottom&&("auto"!==r.stickToBottom||ne.value)&&Dt()})},{flush:"post"}),k(()=>{qt(),zt(),be?(pn(He,be),Ot({remember:!1}),vn()):!1===r.stickToBottom?(Ot({remember:!1}),vn()):(te.value=!0,$t(Pt(),{writeDom:!0,remember:!1,updatePinned:!1}),Ot({remember:!1}),vn()),Q.value&&"undefined"!=typeof ResizeObserver&&(we=new ResizeObserver(()=>{qt(),Ot()}),we.observe(Q.value))}),p(()=>{ge.value||An(He)}),b(()=>{hn()||vn(),Ft(),Me=null,null!=Te&&"undefined"!=typeof window&&window.clearTimeout(Te),Te=null,pe=void 0,tn(Jt.raf),Jt.scheduled=!1,Jt.raf=null,Jt.anchor=void 0,tn(Zt),Ut=!1,Zt=null,Qt.clear(),$n(),oe.clear(),ae.clear(),le.clear(),ie.clear(),ue.clear(),ce.clear(),de.clear(),null==we||we.disconnect(),we=null}),t({captureThreadState:function(){return fn(Ie.value)},restoreThreadState:On,scrollToBottom:Dt,scrollToIndex:function(e,t="start"){const n=Qe.value.records[e];if(!n)return;let r=Rt()+Ze(n);"center"===t?r-=(Z.value-n.size)/2:"end"===t&&(r-=Z.value-n.size),Et(r)},scrollToOffset:Et,getItemSize:e=>{var t;const n=wt(e);return n&&null!=(t=bt(n))?t:void 0},getTotalHeight:()=>Qe.value.totalHeight,getVisibleRange:()=>({start:at.value.start,end:at.value.end})}),(e,t)=>(w(),M("div",{ref_key:"scrollRoot",ref:Q,class:S(["markstream-virtual-timeline",{"is-restoring-thread":!ge.value}]),"data-markstream-virtual-timeline":"1","data-testid":"markstream-virtual-timeline",onScroll:Lt},[x("div",{class:"markstream-virtual-timeline__spacer",style:B({height:`${at.value.topSpacerHeight}px`}),"aria-hidden":"true"},null,4),(w(!0),M(K,null,T(at.value.records,t=>(w(),M("div",{key:t.renderKey,class:S(["markstream-virtual-timeline__item",{"is-restored-height-floor":Fn(t)}]),"data-markstream-item-key":t.key,"data-markstream-item-kind":t.kind,style:B({minHeight:`${t.size}px`,"--markstream-virtual-item-size":`${t.size}px`})},[F(e.$slots,"default",H({ref_for:!0},cn(t)),()=>{var e,n;return[t.markdown?(w(),q(R(_),H({key:0,ref_for:!0},sn(t)),null,16)):vt(t)?(w(),q(N(vt(t)),{key:1,ref_for:!0,ref:un(t),item:mt(t)},null,8,["item"])):(w(),M("div",{key:2,ref_for:!0,ref:un(t),class:S(["markstream-virtual-timeline__default-item",`markstream-virtual-timeline__default-item--${t.kind||"item"}`])},["tool-call"===t.kind&&(null==(e=mt(t))?void 0:e.status)?(w(),M("span",X,C(null==(n=mt(t))?void 0:n.status),1)):A("",!0),P(" "+C(dn(t)),1)],2))]},!0)],14,Y))),128)),x("div",{class:"markstream-virtual-timeline__spacer",style:B({height:`${at.value.bottomSpacerHeight}px`}),"aria-hidden":"true"},null,4),ge.value?A("",!0):(w(),M("div",{key:0,class:"markstream-virtual-timeline__restore-loading",style:B({height:`${Math.max(1,Ht())}px`,transform:`translateY(${U.value}px)`}),"aria-live":"polite","aria-busy":"true"},[F(e.$slots,"restore-loading",{threadKey:Ie.value,visibleRecords:at.value.records},()=>[t[0]||(t[0]=x("div",{class:"markstream-virtual-timeline__restore-loading-card"},[x("span",{class:"markstream-virtual-timeline__restore-spinner","aria-hidden":"true"}),x("span",null,"Loading thread…")],-1))],!0)],4))],34))}})),[["__scopeId","data-v-1303f06e"]]),Q=J;Q.install=e=>{var t,n;const r=null!=(n=null!=(t=Q.__name)?t:Q.name)?n:"MarkstreamVirtualTimeline";e.component(r,J)};export{Q as default};
|
|
1
|
+
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,l=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,i=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&l(e,n,t[n]);if(r)for(var n of r(t))a.call(t,n)&&l(e,n,t[n]);return e},u=(e,r)=>t(e,n(r)),s=(e,t,n)=>l(e,"symbol"!=typeof t?t+"":t,n);import{defineComponent as c,ref as d,reactive as m,provide as f,computed as v,shallowRef as h,watch as g,nextTick as y,onMounted as k,onUpdated as p,onBeforeUnmount as b,openBlock as w,createElementBlock as M,normalizeClass as S,createElementVNode as x,normalizeStyle as B,Fragment as K,renderList as T,renderSlot as F,mergeProps as H,createBlock as q,unref as R,resolveDynamicComponent as N,toDisplayString as C,createCommentVNode as A,createTextVNode as P}from"vue";import{y as _,aa as j,a4 as I,X as z,a3 as O,a2 as $,a1 as L,a5 as E,ab as D,a0 as V,z as W}from"./exports.js";const Y=["data-markstream-item-key","data-markstream-item-kind"],X={key:0,class:"markstream-virtual-timeline__status"},G=.5,J=/* @__PURE__ */W(/* @__PURE__ */c(u(i({},{name:"MarkstreamVirtualTimeline"}),{__name:"MarkstreamVirtualTimeline",props:{items:{},threadKey:{},layoutRevision:{},getKey:{},getKind:{},getContent:{},getFinal:{},getRevision:{},estimateItemHeight:{},overscan:{default:4},overscanPx:{default:1200},stickToBottom:{type:[Boolean,String],default:"auto"},measurementKey:{},markdownMode:{default:"docs"},markdownCodeRenderer:{},initialThreadState:{},markdownFade:{type:Boolean,default:!1},restoreMaxLoadingMs:{type:[Number,Boolean],default:!1},debug:{type:Boolean}},emits:["height-change","virtual-state-change","range-change","thread-state-change"],setup(e,{expose:t,emit:n}){const r=e,o=n;function a(e){o("thread-state-change",e)}function l(e){return"measured"===e||"final"===e}function c(e){return!0===(null==e?void 0:e.stable)&&function(e){var t,n,r,o;if(!e)return!1;const a=Number(e.nodeCount),l=Number(e.measuredCount),i=Math.max(0,Number(null!=(n=null==(t=e.liveRange)?void 0:t.start)?n:0)),u=Math.min(a,Math.max(i,Number(null!=(o=null==(r=e.liveRange)?void 0:r.end)?o:0))),s=Math.max(0,u-i);return!0===e.final&&"mixed"===e.confidence&&a>0&&l>0&&l<a&&(s<=0||l>=s)}(e)}const W=/* @__PURE__ */new Map;function J(e){var t;!0===r.debug&&W.set(e,(null!=(t=W.get(e))?t:0)+1)}const Q=d(null),U=d(0),Z=d(0),ee=d(0),te=d(!0),ne=d(!0),re=m(/* @__PURE__ */new Map),oe=/* @__PURE__ */new Map,ae=/* @__PURE__ */new Map,le=/* @__PURE__ */new Map,ie=/* @__PURE__ */new Map,ue=/* @__PURE__ */new Set,se=m(/* @__PURE__ */new Map),ce=m(/* @__PURE__ */new Map),de=/* @__PURE__ */new Map,me=/* @__PURE__ */new Map,fe=/* @__PURE__ */new Map,ve=/* @__PURE__ */new Map,he=d(!1),ge=d(!0),ye=d(!0);f("markstreamHostScrollManaged",ye);const ke=[0,80,180,360,640];let pe,be,we=null,Me=null,Se=0,xe=null,Be=[],Ke=null,Te=null,Fe=-1,He=0,qe=null,Re=!1,Ne=!1,Ce=null,Ae=0,Pe=0,_e={top:0,bottom:0},je=!1;const Ie=v(()=>null==r.threadKey?void 0:String(r.threadKey));let ze=Ie.value;function Oe(e){return"chat"===e||"minimal"===e||"docs"===e?e:"docs"}const $e=v(()=>Oe(r.markdownMode)),Le=v(()=>function(e,t=Oe(r.markdownMode)){return"pre"===e||"shiki"===e||"monaco"===e?e:"docs"===t?"monaco":"pre"}(r.markdownCodeRenderer,$e.value)),Ee=v(()=>[null==r.measurementKey?"":String(r.measurementKey),ee.value].join(":")),De=v(()=>`${Ee.value}${$e.value}${Le.value}`);class Ve{constructor(e){s(this,"tree"),s(this,"total"),this.tree=Array.from({length:e.length+1},()=>0),this.total=0,e.forEach((e,t)=>this.add(t,e))}add(e,t){if(Number.isFinite(t)&&0!==t){this.total+=t;for(let n=e+1;n<this.tree.length;n+=n&-n)this.tree[n]+=t}}prefixSum(e){let t=Math.max(0,Math.min(e,this.tree.length-1)),n=0;for(;t>0;)n+=this.tree[t],t-=t&-t;return n}lowerBound(e,t="gte"){const n=this.tree.length-1;if(n<=0)return 0;if(e<=0)return 0;if(e>=this.total)return n-1;let r=0,o=1;for(;o<<1<this.tree.length;)o<<=1;let a=0;for(;o>0;o>>=1){const n=r+o;if(n<this.tree.length){const o=a+this.tree[n];("gt"===t?o<=e:o<e)&&(r=n,a=o)}}return Math.min(r,n-1)}}const We=h([]),Ye=/* @__PURE__ */new Map,Xe=h(new Ve([])),Ge=d(0);let Je=[];const Qe=v(()=>(Ge.value,{records:We.value,totalHeight:Xe.value.total}));function Ue(){var e;const t=[],n=[],o=function(){var e;return null!=(e=Ie.value)?e:"timeline"}();Ye.clear();for(let a=0;a<r.items.length;a++){const l=r.items[a],s=lt(l,a),c={item:l,index:a,key:s,kind:I(l,a,r),markdown:j(l,a,r)};let d=bt(c);null==d&&(d=null!=(e=Je[a])?e:z(l,a,r));const m=u(i({},c),{renderKey:`${o}:${s}`,offset:0,size:d,component:null==l?void 0:l.component});t.push(m),n.push(d),Ye.has(s)||Ye.set(s,m)}We.value=t,Xe.value=new Ve(n),Je=[],Ge.value+=1}function Ze(e){return Ge.value,Xe.value.prefixSum(e.index)}function et(e){return u(i({},e),{offset:Ze(e)})}function tt(e,t){const n=Ye.get(e);if(!n)return;const r=Math.ceil(t),o=r-n.size;0!==o&&(n.size=r,Xe.value.add(n.index,o),Ge.value+=1)}function nt(e,t="gte"){return Ge.value,Xe.value.lowerBound(e,t)}const rt=v(()=>{var e;return Math.max(0,null!=(e=r.overscan)?e:4)}),ot=v(()=>{var e;const t=Math.max(0,null!=(e=r.overscanPx)?e:1200);return ge.value?t:Math.min(t,160)}),at=v(()=>{var e,t,n;const r=Qe.value.records;if(0===r.length)return{start:0,end:0,records:[],topSpacerHeight:0,bottomSpacerHeight:0};const o=rt.value,a=ot.value,l=At(),i=l+Math.max(1,Z.value);let u=nt(Math.max(0,l-a),"gt"),s=nt(Math.min(Qe.value.totalHeight,i+a))+1;u=Math.max(0,u-o),s=Math.min(r.length,Math.max(s+o,u+1));const c=r.slice(u,s).map(et),d=c[0],m=c[c.length-1],f=null!=(e=null==d?void 0:d.offset)?e:0,v=null!=(t=null==m?void 0:m.offset)?t:0;return{start:u,end:s,records:c,topSpacerHeight:f,bottomSpacerHeight:Math.max(0,Qe.value.totalHeight-(v+(null!=(n=null==m?void 0:m.size)?n:0)))}});function lt(e,t){return O(e,t,r)}const it=/* @__PURE__ */new WeakMap;let ut=1;function st(e){if("object"!=typeof e&&"function"!=typeof e||null===e)return String(null!=e?e:"");const t=e;let n=it.get(t);return n||(n=ut++,it.set(t,n)),String(n)}function ct(e,t,n){var o;if(n)return"";const a="string"==typeof(null==e?void 0:e.text)?e.text:"string"==typeof(null==e?void 0:e.message)?e.message:"string"==typeof(null==e?void 0:e.label)?e.label:String(null!=(o=L(e,t,r))?o:"");return a?`${a.length}:${function(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}(a)}`:""}function dt(e,t){if("function"!=typeof r.estimateItemHeight)return"";const n=r.estimateItemHeight(e,t);if(!Number.isFinite(n)||n<=0)return"";const o=Math.ceil(n);return Je[t]=o,String(o)}function mt(e){var t;return null!=(t=r.items[e.index])?t:e.item}function ft(e){return e.item}function vt(e){var t;const n=mt(e);return null!=(t=null==n?void 0:n.component)?t:e.component}function ht(e,t=Ie.value){const n=ft(e),o=E(n,e.index,r);return[null!=t?t:"timeline",e.key,null==o?"":String(o)].join(":")}function gt(e,t=Ie.value){if(e.markdown)return ht(e,t);const n=ft(e),o=E(n,e.index,r);return[null!=t?t:"timeline",e.key,null==o?"":String(o)].join(":")}function yt(e){return{sourceKey:gt(e),measurementKey:e.markdown?De.value:Ee.value,widthBucket:ee.value}}function kt(e,t){var n,r,o,a,l,i;return(null!=(n=null==e?void 0:e.sourceKey)?n:"")===(null!=(r=null==t?void 0:t.sourceKey)?r:"")&&(null!=(o=null==e?void 0:e.measurementKey)?o:"")===(null!=(a=null==t?void 0:t.measurementKey)?a:"")&&(null!=(l=null==e?void 0:e.widthBucket)?l:0)===(null!=(i=null==t?void 0:t.widthBucket)?i:0)}function pt(e,t,n=Ie.value){var r;return!(!e||!t)&&t.sourceKey===gt(e,n)&&t.measurementKey===(e.markdown?De.value:Ee.value)&&(null!=(r=t.widthBucket)?r:0)===ee.value}function bt(e,t=Ie.value){const n=re.get(e.key);return pt(e,oe.get(e.key),t)&&Number.isFinite(n)&&n>0?n:null}function wt(e){return Qe.value,Ye.get(e)}function Mt(e,t){var n,r;return!!(e&&e.markdown&&t)&&t.sessionKey===ht(e)&&(null!=(n=t.threadKey)?n:"")===(null!=(r=Ie.value)?r:"")&&!!function(e){const t=De.value,n=null!=e?e:"";return n===t||n.startsWith(`${t}\0`)}(t.measurementKey)}function St(e,t){return Mt(e,t)}function xt(e,t,n){!Number.isFinite(t)||t<=0||(ce.set(e,Math.ceil(t)),de.set(e,n))}function Bt(e,t=se.get(e)){const n=function(e,t=se.get(e)){var n;if(!St(wt(e),t))return 0;const r=Number(null==(n=null==t?void 0:t.metrics)?void 0:n.totalHeight);return Number.isFinite(r)&&r>0?Math.ceil(r):0}(e,t);return n>0&&xt(e,n,t),n}function Kt(e){var t;return Mt(wt(e),de.get(e))?null!=(t=ce.get(e))?t:0:Bt(e)}function Tt(e){return e===Se&&He===e&&!ge.value}function Ft(){if(null!=xe&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(xe),xe=null,null!=Ke&&"undefined"!=typeof window&&window.clearTimeout(Ke),Ke=null,"undefined"!=typeof window)for(const e of Be)window.clearTimeout(e);Be=[]}function Ht(){var e;return Math.max(0,Z.value||(null==(e=Q.value)?void 0:e.clientHeight)||0)}function qt(){const e=Q.value;if(!e||"function"!=typeof getComputedStyle)return void(_e={top:0,bottom:0});const t=getComputedStyle(e),n=Number.parseFloat(t.paddingTop)||0,r=Number.parseFloat(t.paddingBottom)||0;_e={top:n,bottom:r}}function Rt(){return _e.top}function Nt(){const e=_e;return Math.max(0,Qe.value.totalHeight+e.top+e.bottom)}function Ct(){var e,t;return Math.max(Nt(),null!=(t=null==(e=Q.value)?void 0:e.scrollHeight)?t:0)}function At(){return Math.max(0,U.value-Rt())}function Pt(){return Math.max(0,Ct()-Ht())}function _t(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(t,Pt())):0}function jt(){return Math.max(0,Pt()-U.value)}function It(){const e=jt();ne.value=e<=2,!0!==r.stickToBottom?!1!==r.stickToBottom?te.value=e<=48:te.value=!1:te.value=!0}function zt(){var e,t;const n=null!=(t=null==(e=Q.value)?void 0:e.clientWidth)?t:0;ee.value=Number.isFinite(n)&&n>0?32*Math.round(n/32):0}function Ot(e={}){const t=Q.value;t&&(U.value=Math.max(0,t.scrollTop||0),Z.value=t.clientHeight||0),zt(),It(),(!0===e.remember||!1!==e.remember&&!he.value)&&gn()}function $t(e,t={}){const n=_t(e),o=Q.value;if(U.value=n,o&&(Z.value=o.clientHeight||Z.value||0,!1!==t.writeDom&&Math.abs((o.scrollTop||0)-n)>G)){const e={target:n,preserveBottomPin:!1!==r.stickToBottom&&Math.abs(Pt()-n)<=2};Me=ge.value?e:null,o.scrollTop=n,e.target=Math.max(0,o.scrollTop||0)}zt(),!1!==t.updatePinned&&It(),(!0===t.remember||!1!==t.remember&&!he.value)&&vn()}function Lt(){if(!ge.value){Me=null;const e=Q.value,t=qe;return e&&null!=t&&Math.abs((e.scrollTop||0)-t)>G&&(e.scrollTop=t),void pn(He,be)}const e=Q.value,t=Me,n=Math.max(0,(null==e?void 0:e.scrollTop)||0);return e&&t&&Math.abs(n-t.target)<=G&&t.preserveBottomPin&&!1!==r.stickToBottom||e&&ne.value&&"auto"===r.stickToBottom&&(Math.abs(Pt()-n)<=2||n>=U.value-G)||!0===r.stickToBottom?(te.value=!0,ne.value=!0,void $t(Pt(),{writeDom:!0,remember:!1})):(Me=null,void Ot())}function Et(e){$t(e,{writeDom:!0,remember:!0})}function Dt(){Et(Pt())}function Vt(e,t){const n=ae.get(e);if(!Number.isFinite(n)||null==n||n<=0)return 0;const r=le.get(e);return t&&r&&!Wt(r,t)?0:Math.ceil(n)}function Wt(e,t){var n,r,o,a;return e.sourceKey===t.sourceKey&&(0===(null!=(n=t.widthBucket)?n:0)||0===(null!=(r=e.widthBucket)?r:0)||(null!=(o=t.widthBucket)?o:0)===(null!=(a=e.widthBucket)?a:0))&&(Yt(t.measurementKey)||Yt(e.measurementKey)||t.measurementKey===e.measurementKey)}function Yt(e){return":0"===e||!0===(null==e?void 0:e.startsWith(":0"))}function Xt(e){ae.delete(e),le.delete(e),ie.delete(e),ue.delete(e)}function Gt(e,t,n,o={}){if(!Number.isFinite(t)||t<=0)return;const a=re.get(e),l=n&&!kt(oe.get(e),n),i=!0===o.releaseRestoredFloor;!function(e,t){if(!t)return;const n=le.get(e);n&&!Wt(n,t)&&(ae.delete(e),le.delete(e),ie.delete(e),ue.delete(e))}(e,n),i&&Xt(e);const u=Vt(e,n),s=u>0?u:Math.ceil(t);if(null!=a&&Math.abs(a-s)<=1&&!l)return void(i&&(Ge.value+=1));if(!1===o.updateLayout)return n&&oe.set(e,n),re.set(e,s),void gn(o.rememberThreadKey);if(he.value)return n&&oe.set(e,n),re.set(e,s),tt(e,s),void function(e=He,t=be){t&&y(()=>{pn(e,t),null==xe&&"function"==typeof requestAnimationFrame&&(xe=requestAnimationFrame(()=>{xe=null,pn(e,t)}))})}();const c=(d=mn(),m=jt(),!0===r.stickToBottom?{type:"bottom",distanceFromBottomPx:0}:"auto"===r.stickToBottom&&te.value?{type:"bottom",distanceFromBottomPx:ne.value?0:Math.max(0,m)}:d);var d,m;n&&oe.set(e,n),re.set(e,s),tt(e,s),gn(o.rememberThreadKey),function(e){if(!Jt.scheduled)return Jt.anchor=e,Jt.scheduled=!0,void(Jt.raf=en(nn));!Jt.anchor&&e&&(Jt.anchor=e)}(c)}g([()=>function(){const e=r.layoutRevision;return null!=e?["explicit",String(e),r.items.length].join(""):r.items.map((e,t)=>{var n;const o=lt(e,t),a=j(e,t,r);return[o,I(e,t,r),a?1:0,null!=(n=E(e,t,r))?n:"",dt(e,t),ct(e,t,a),(l=null==e?void 0:e.component,l?"string"==typeof l?`s:${l}`:`o:${st(l)}`:"")].join("");var l}).join("\0")}(),Ee,De,Ie,()=>st(r.estimateItemHeight),()=>st(r.getKey),()=>st(r.getKind),()=>st(r.getContent),()=>st(r.getFinal),()=>st(r.getRevision)],()=>Ue(),{immediate:!0,flush:"sync"});const Jt={scheduled:!1,raf:null,anchor:void 0},Qt=/* @__PURE__ */new Map;let Ut=!1,Zt=null;function en(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(e):(y(e),null)}function tn(e){null!=e&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}function nn(){if(!Jt.scheduled)return;Jt.scheduled=!1,Jt.raf=null;const e=Jt.anchor;Jt.anchor=void 0;const t="bottom"===(null==e?void 0:e.type)&&e.distanceFromBottomPx<=2&&ne.value;e&&kn(e);const n=Q.value,r=!n||Math.abs((n.scrollTop||0)-U.value)<=G;t&&!r||Ot({remember:!1})}function rn(){var e,t;if(!Ut)return;Ut=!1,Zt=null;const n=Array.from(Qt.entries());Qt.clear();for(const[r,o]of n){if(ce.get(r)!==o.logicalHeight)continue;const n=Ye.get(r);if(!n)continue;const a=(null!=(e=o.threadKey)?e:"")===(null!=(t=Ie.value)?t:"");ln(n,{allowMarkdownShrink:o.allowMarkdownShrink,allowRestoredFloorShrink:o.allowRestoredFloorShrink,markdownLogicalHeight:o.logicalHeight,rememberThreadKey:o.threadKey,source:o.itemSizeSource,updateLayout:a})}nn()}function on(){rn(),nn()}function an(e){var t;null==(t=fe.get(e))||t.disconnect(),fe.delete(e),me.delete(e)}function ln(e,t={}){var n,o,a;const l=(s=e.key,D(me.get(s),J));var s;const c=null!=(n=t.source)?n:yt(e);let d=!1;const m=()=>{d||(d=!0,function(e,t){const n=function(){if(!0!==r.debug||0===W.size)return null;let e=0;for(const n of W.values())e+=n;const t={total:e,byLabel:Object.fromEntries(Array.from(W.entries()).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])))};return W.clear(),t}();n&&console.info("[markstream-vue][timeline][perf] layout-reads",{label:e,itemKey:t,layoutReads:n})}("reconcileRecordSize",e.key))};if(!e.markdown)return l>0&&Gt(e.key,l,c,t),void m();const f=kt(oe.get(e.key),c)&&null!=(o=re.get(e.key))?o:0,v=null!=(a=t.markdownLogicalHeight)?a:Kt(e.key),h=function(e,t){return V(me.get(e),J,t)}(e.key,l);if(v>0){let n=Math.max(l,v+h);(!t.allowMarkdownShrink||he.value)&&f>0&&(n=Math.max(n,f));const o=Vt(e.key,c),a=o>0&&n>o+1&&(!$(mt(e),e.index,r)||!0===t.allowRestoredFloorShrink);return e.markdown&&o>0&&(!0===t.allowRestoredFloorShrink||a)?he.value?ue.add(e.key):t=u(i({},t),{releaseRestoredFloor:!0}):t.allowMarkdownShrink&&!he.value&&(o<=0||t.allowRestoredFloorShrink&&function(e,t,n){const r=ie.get(e);return!Number.isFinite(r)||null==r||r<=0||t+Math.max(0,n-r)<n-1}(e.key,v,o))&&Xt(e.key),n>0&&Gt(e.key,n,c,t),void m()}return String(L(mt(e),e.index,r)).trim()?f>0?(l>f+1&&Gt(e.key,l,c,t),void m()):(l>0&&Gt(e.key,l,c,t),void m()):(l>0&&(Xt(e.key),Gt(e.key,l,c,t)),void m())}function un(e){return t=>{!function(e,t){const n=function(e){const t=e&&"$el"in e?e.$el:e;return t instanceof HTMLElement?t:null}(t),r=me.get(e.key);if(!n)return void an(e.key);if(r===n)return void ln(e);if(an(e.key),me.set(e.key,n),ln(e),"undefined"==typeof ResizeObserver)return;const o=new ResizeObserver(()=>{ln(e)});o.observe(n),fe.set(e.key,o)}(e,t)}}function sn(e){const t=mt(e),n=$(t,e.index,r),a=se.get(e.key),s=$e.value,d=Le.value,m={enabled:!0,sessionKey:ht(e),threadKey:Ie.value,scrollRoot:()=>Q.value,restoreState:St(e,a)?a:null,restoreAnchor:!1,measurementKey:De.value,settleMode:"manual",settledToken:n,emitIntervalMs:96,heightDiffThresholdPx:4};return u(i({content:L(t,e.index,r),final:n,mode:s,codeRenderer:d},n?{nodeVirtual:"auto",maxLiveNodes:50,liveNodeBuffer:16}:{}),{fade:!0===r.markdownFade,indexKey:ht(e),virtualScroll:m,onHeightChange(t){if(t.sessionKey!==ht(e))return;xt(e.key,t.totalHeight,{sessionKey:t.sessionKey,threadKey:Ie.value,measurementKey:De.value});const n=function(e){return"final"===e.phase||!(!0!==e.final||!l(e.confidence))||!!e.stable&&(l(e.confidence)||c(e))}(t),r=function(e){return"final"===e.phase||!!e.stable&&(l(e.confidence)||c(e))}(t),a=Math.ceil(t.totalHeight);var i;!function(e,t){Qt.set(e.key,t),Ut||(Ut=!0,Zt=en(rn))}(e,{allowMarkdownShrink:n,allowRestoredFloorShrink:r,itemSizeSource:yt(e),logicalHeight:a,threadKey:Ie.value}),i={itemKey:e.key,metrics:t},o("height-change",i)},onVirtualStateChange(t){var n;t.sessionKey===ht(e)&&(se.set(e.key,t),Bt(e.key,t),gn(),n={itemKey:e.key,state:t},o("virtual-state-change",n))}})}function cn(e){return{item:mt(e),index:e.index,itemKey:e.key,kind:e.kind,measureRef:un(e),markdownProps:sn(e)}}function dn(e){var t;const n=null!=(t=mt(e))?t:{};return"string"==typeof n.text?n.text:"string"==typeof n.message?n.message:"string"==typeof n.label?n.label:L(n,e.index,r)}function mn(){const e=jt();if(e<=2)return{type:"bottom",distanceFromBottomPx:Math.max(0,e)};const t=At(),n=nt(t,"gt"),r=Qe.value.records[n];if(r){const e=Ze(r);if(t>=e&&t<e+r.size)return{type:"item",itemKey:r.key,offsetWithinItemPx:t-e}}const o=at.value.records[0];return o?{type:"item",itemKey:o.key,offsetWithinItemPx:0}:void 0}function fn(e=Ie.value){on();const t={},n={};for(const r of Qe.value.records){const o=bt(r,e),a=oe.get(r.key);null!=o&&pt(r,a,e)&&(t[r.key]=o,n[r.key]=a)}return{threadKey:e,measurementKey:Ee.value,widthBucket:ee.value,outerAnchor:mn(),itemHeights:t,itemSizeSources:n,markdownStates:Object.fromEntries(se.entries())}}function vn(e=Ie.value){if(!e)return;const t=fn(e);return ve.set(e,t),e===Ie.value&&(Ce=t),a(t),t}function hn(){const e=pe;return null!=Te&&"undefined"!=typeof window&&window.clearTimeout(Te),Te=null,pe=void 0,e?vn(e):void 0}function gn(e=Ie.value){e&&(pe=e,null==Te&&("undefined"!=typeof window?Te=window.setTimeout(()=>{Te=null,hn()},80):hn()))}function yn(e){if(!e)return null;if("bottom"===e.type)return(ge.value?Ct():Nt())-Ht()-Math.max(0,e.distanceFromBottomPx);const t=wt(e.itemKey);return t?Rt()+Ze(t)+Math.max(0,e.offsetWithinItemPx):null}function kn(e,t={}){const n=yn(e);return null!=n&&($t(n,{writeDom:!0,remember:!0===t.remember}),!0)}function pn(e,t){if(e===Se){if(t){const e=kn(t,{remember:!1});qe=e?U.value:null}Ot({remember:!1})}}function bn(e,t){const n=e.getBoundingClientRect();return n.width>0&&n.height>0&&n.bottom>t.top&&n.top<t.bottom}function wn(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.bottom>r.top&&n.top<r.bottom}function Mn(e){if(e.closest(".code-editor-container.is-hidden"))return!1;let t=e;for(;t;){const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility||Number.parseFloat(e.opacity||"1")<=.01)return!1;t=t.parentElement}const n=e.getBoundingClientRect();return n.width>0&&n.height>0}function Sn(e){if(!e)return!1;if(e.classList.contains("is-fading-out"))return!1;const t=window.getComputedStyle(e);if("none"===t.display||Number.parseFloat(t.opacity||"1")<=.01)return!1;const n=e.getBoundingClientRect();return n.width>0&&n.height>0}function xn(e){return Array.from(e.querySelectorAll(['[data-markstream-pending="true"]','[data-markstream-mermaid][data-markstream-mode="pending"]','.mermaid-block-container[data-markstream-mode="pending"]','[data-markstream-code-loading="1"]'].join(","))).some(e=>!e.matches('[data-markstream-code-block="1"]')||!Sn(e.querySelector("pre.code-pre-fallback")))}function Bn(e){var t;if(e.querySelector(":scope > .node-placeholder"))return!1;const n=e.querySelector(":scope > .node-content");return!!n&&(!xn(n)&&(!!function(e){const t=Array.from(e.querySelectorAll("[data-markstream-math]"));return!t.length||t.every(e=>{const t=e.dataset.markstreamMode;return!("true"===e.dataset.markstreamPending||"loading"===t||"katex"!==t&&"fallback"!==t)})}(n)&&("code_block"===(null!=(t=e.dataset.nodeType)?t:"")?function(e){if(e.querySelector('[data-markstream-code-loading="1"]'))return!1;const t=e.querySelector('[data-markstream-code-block="1"]');if(t){const e="true"===t.dataset.markstreamEnhanced,r=Sn(t.querySelector("pre.code-pre-fallback"));return e||r||(n=t,Array.from(n.querySelectorAll(".monaco-editor, .monaco-diff-editor")).some(Mn))}var n;return function(e){var t,n;const r=e.querySelector("[data-markstream-mermaid], .mermaid-block-container");if(r){if("true"===r.dataset.markstreamPending)return!1;const e=r.dataset.markstreamMode;return"preview"===e?Boolean(r.querySelector("svg")||r.querySelector('[data-mermaid-svg-layer="1"] svg')):"fallback"===e&&Boolean(null==(n=null==(t=r.querySelector(".mermaid-source-code"))?void 0:t.textContent)?void 0:n.trim())}const o=e.querySelector("[data-markstream-infographic], .infographic-block-container");if(o)return"true"!==o.dataset.markstreamPending;const a=e.querySelector("[data-markstream-d2], .d2-block-container");return a?"true"!==a.dataset.markstreamPending:Boolean(e.querySelector('pre[data-markstream-pre="1"]'))}(e)}(n):function(e){var t;return(null!=(t=e.textContent)?t:"").trim().length>0||Boolean(e.querySelector(["hr","br","table","blockquote","img","svg","canvas","input","button","select","textarea","[role]","[aria-label]","[data-markstream-math]","[data-markstream-mermaid]","[data-markstream-infographic]","[data-markstream-d2]",'[data-markstream-pre="1"]'].join(",")))}(n))))}function Kn(e,t){var n;if(!e.markdown)return!0;const o=L(mt(e),e.index,r);if(!String(null!=o?o:"").trim())return!0;if(t.querySelector("[data-node-index]"))return!0;const a=t.querySelector(".markdown-renderer"),l=null!=a?a:t;return!xn(l)&&(!!(null!=(n=l.textContent)?n:"").trim()||Boolean(l.querySelector(["hr","br","table","blockquote","img","svg","canvas","input","button","[role]","[aria-label]","[data-markstream-math]","[data-markstream-mermaid]","[data-markstream-infographic]","[data-markstream-d2]",'[data-markstream-pre="1"]','[data-markstream-code-block="1"]'].join(","))))}function Tn(e,t,n){if(!e.markdown)return!0;const o=L(mt(e),e.index,r);if(!String(null!=o?o:"").trim())return!0;const a=n.getBoundingClientRect(),l=Array.from(t.querySelectorAll("[data-node-index]")).filter(e=>bn(e,a));if(l.length>0)return l.every(e=>Bn(e));const i=t.querySelector(".markdown-renderer"),u=null!=i?i:t;return u.querySelector("[data-node-index], .node-placeholder")?!!function(e,t,n,r){if(!Fn(e))return!1;const o=n.getBoundingClientRect(),a=t.getBoundingClientRect();return o.width>0&&o.height>0&&o.bottom<=r.top+1&&a.bottom>r.top}(e,t,u,a)&&Kn(e,t):Kn(e,t)}function Fn(e){const t=oe.get(e.key);return Vt(e.key,t)>0}function Hn(e,t){var n,o,a,i;if(!e.markdown)return!0;if(!Re&&!Ne)return!0;if(Fn(e))return!0;const u=L(mt(e),e.index,r);if(!String(null!=u?u:"").trim())return!0;if(!t.querySelector(".markdown-renderer"))return!1;const s=se.get(e.key);if(!St(e,s))return!1;const d=null==s?void 0:s.metrics,m=Number(null!=(n=null==d?void 0:d.totalHeight)?n:0);if(!Number.isFinite(m)||m<=0)return!1;const f=Number(null!=(o=null==d?void 0:d.measuredCount)?o:0),v=Number(null!=(a=null==d?void 0:d.estimatedCount)?a:0),h=Number(null!=(i=null==d?void 0:d.nodeCount)?i:0),g=h<=0||f>=h&&v<=0,y=l(null==d?void 0:d.confidence),k=c(d),p=!0===(null==d?void 0:d.stable)||y||k;return Ne?!0===(null==d?void 0:d.final)&&(g&&y||k):p||!0===(null==d?void 0:d.final)}function qn(){const e=Q.value;if(!e)return!1;const t=yn(be);if(null!=t&&Math.abs((e.scrollTop||0)-_t(t))>G)return!1;const n=at.value.records;if(!n.length)return 0===Qe.value.records.length;const r=new Map(Array.from(e.querySelectorAll("[data-markstream-item-key]")).map(e=>{var t;return[null!=(t=e.dataset.markstreamItemKey)?t:"",e]})),o=[];for(const i of n){const t=r.get(i.key);t&&wn(t,e)&&o.push({record:i,el:t})}if(!o.length)return!1;for(const{record:i,el:u}of o){if(u.offsetHeight+1<i.size)return!1;if(!Tn(i,u,e))return!1;if(!Hn(i,u))return!1}const a=e.getBoundingClientRect();if(Array.from(e.querySelectorAll(['[data-markstream-pending="true"]','[data-markstream-mermaid][data-markstream-mode="pending"]','.mermaid-block-container[data-markstream-mode="pending"]','[data-markstream-code-loading="1"]'].join(","))).some(e=>!(!bn(e,a)||e.matches('[data-markstream-code-block="1"]')&&Sn(e.querySelector("pre.code-pre-fallback")))))return!1;const l=Array.from(e.querySelectorAll("[data-node-index]")).filter(e=>bn(e,a));for(const i of l)if(!Bn(i))return!1;return!0}function Rn(){const e=Q.value;if(!e)return"";const t=e.getBoundingClientRect(),n=new Map(Array.from(e.querySelectorAll("[data-markstream-item-key]")).map(e=>{var t;return[null!=(t=e.dataset.markstreamItemKey)?t:"",e]})),r=at.value.records.map(e=>{var t,r,o,a,l,i,u,s,c;const d=n.get(e.key),m=null==d?void 0:d.querySelector(".markdown-renderer"),f=null==(t=se.get(e.key))?void 0:t.metrics;return[e.key,e.size,null!=(r=null==d?void 0:d.offsetHeight)?r:0,null!=(o=null==d?void 0:d.scrollHeight)?o:0,null!=(a=null==m?void 0:m.offsetHeight)?a:0,null!=(l=null==m?void 0:m.scrollHeight)?l:0,f?Math.round(Number(f.totalHeight||0)):"",null!=(i=null==f?void 0:f.measuredCount)?i:"",null!=(u=null==f?void 0:f.estimatedCount)?u:"",null!=(s=null==f?void 0:f.nodeCount)?s:"",!0===(null==f?void 0:f.final)?1:0,!0===(null==f?void 0:f.stable)?1:0,null!=(c=null==f?void 0:f.confidence)?c:""].join(":")}).join("|"),o=Array.from(e.querySelectorAll("[data-node-index]")).filter(e=>bn(e,t)).map(e=>{var t,n,r,o,a;const l=e.getBoundingClientRect(),i=e.querySelector(":scope > .node-content"),u=null==i?void 0:i.querySelector('[data-markstream-code-block="1"]'),s=null==i?void 0:i.querySelector("pre.code-pre-fallback"),c=null==i?void 0:i.querySelector(".monaco-editor, .monaco-diff-editor");return[null!=(t=e.dataset.nodeIndex)?t:"",null!=(n=e.dataset.nodeType)?n:"",Math.round(l.height),null!=(r=null==i?void 0:i.offsetHeight)?r:0,null!=(o=null==i?void 0:i.scrollHeight)?o:0,null!=(a=null==u?void 0:u.dataset.markstreamEnhanced)?a:"",u?Math.round(u.getBoundingClientRect().height):0,s?Math.round(s.getBoundingClientRect().height):0,c?Math.round(c.getBoundingClientRect().height):0].join(":")}).join("|");return[Math.round(e.scrollTop||0),Math.round(e.scrollHeight||0),Math.round(Qe.value.totalHeight||0),r,o].join("\n")}function Nn(){return"undefined"!=typeof performance?performance.now():Date.now()}function Cn(){return Ne?24:2}function An(e){Tt(e)&&Ae!==e&&(Ae=e,function(e){return t=this,n=function*(){const t=Nn();let n=0,r="";for(let o=0;o<40;o++){if(yield y(),yield new Promise(e=>{"function"!=typeof requestAnimationFrame?e():requestAnimationFrame(()=>e())}),!Tt(e))return!1;pn(e,be);const o=Nn(),a=qn(),l=a?Rn():"";if(a&&l===r&&l){if(n+=1,n>=Cn()&&o-t>=96)return!0}else n=0,r=l}return!1},new Promise((e,r)=>{var o=e=>{try{l(n.next(e))}catch(t){r(t)}},a=e=>{try{l(n.throw(e))}catch(t){r(t)}},l=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,a);l((n=n.apply(t,null)).next())});var t,n}(e).then(t=>{if(Ae===e&&(Ae=0),Tt(e))return t?void zn(e):function(){if(Fe<0)return!1;const e=function(){if(!1===r.restoreMaxLoadingMs)return Number.POSITIVE_INFINITY;const e=Number(r.restoreMaxLoadingMs);return Number.isFinite(e)&&e>0?e:Number.POSITIVE_INFINITY}();return Number.isFinite(e)&&Nn()-Fe>=e}()?(!0===r.debug&&import.meta,void zn(e)):(function(e){Pe!==e&&(Pe=e,!0===r.debug&&import.meta)}(e),void function(e){Tt(e)&&"undefined"!=typeof window&&(null!=Ke&&window.clearTimeout(Ke),Ke=window.setTimeout(()=>{Ke=null,Tt(e)&&An(e)},120))}(e))}))}function Pn(){ge.value=!0,Fe=-1,Ae=0,Pe=0,Re=!1,Ne=!1,null!=Ke&&"undefined"!=typeof window&&window.clearTimeout(Ke),Ke=null}function _n(){je=!0}function jn(e){var t,n;const r=[];if(!function(e){var t,n;return!!e&&(null!=(t=e.measurementKey)?t:"")===Ee.value&&(null!=(n=e.widthBucket)?n:0)===ee.value}(e))return r;for(const[o,a]of Object.entries(null!=(t=null==e?void 0:e.itemHeights)?t:{})){if(!Number.isFinite(a)||a<=0)continue;const t=wt(o),l=null==(n=null==e?void 0:e.itemSizeSources)?void 0:n[o];pt(t,l)&&r.push([o,Math.ceil(a),l])}return r}function In(e){var t;for(const[n,r]of Object.entries(null!=(t=null==e?void 0:e.markdownStates)?t:{}))if(St(wt(n),r))return!0;return!1}function zn(e){if(e!==Se)return;rn();const t=new Set(ue);Ft(),pn(e,be),he.value=!1,Fe=-1,be=void 0,qe=null,He=0;for(const n of Qe.value.records)n.markdown&&!t.has(n.key)||Xt(n.key);for(const n of t){const e=Ye.get(n);e?ln(e,{allowMarkdownShrink:!0,allowRestoredFloorShrink:!0,markdownLogicalHeight:Kt(e.key),source:yt(e),updateLayout:!0}):Xt(n)}ue.clear(),nn(),Ot({remember:!1}),Pn(),_n()}function On(e,t={}){var n;const o=++Se;Me=null,(null==e?void 0:e.widthBucket)&&0===ee.value&&(ee.value=e.widthBucket);const a=null==e?void 0:e.outerAnchor,l=function(e){return Boolean((null==e?void 0:e.outerAnchor)||jn(e).length>0||In(e))}(e),i=In(e),u=!(!je&&!0!==t.threadSwitch||l),s=l||u,c=null!=a?a:s?function(){if(!1!==r.stickToBottom)return{type:"bottom",distanceFromBottomPx:0};const e=Qe.value.records[0];return e?{type:"item",itemKey:e.key,offsetWithinItemPx:0}:void 0}():void 0;Ft(),Ae=0,Pe=0,ge.value=!s,he.value=s&&Boolean(c),He=o,be=c,Re=s&&i,Ne=s&&u,Fe=he.value?Nn():-1,$n(),re.clear(),oe.clear(),ae.clear(),le.clear(),ie.clear(),ue.clear(),se.clear(),ce.clear(),de.clear();for(const[r,m,f]of jn(e)){const e=Math.ceil(m);oe.set(r,f),re.set(r,e),ae.set(r,e),le.set(r,f)}for(const[r,m]of Object.entries(null!=(n=null==e?void 0:e.markdownStates)?n:{})){se.set(r,m);const e=Bt(r,m);e>0&&ie.set(r,e)}Ue(),!0===r.stickToBottom?(te.value=!0,ne.value=!0):!1===r.stickToBottom?(te.value=!1,ne.value=!1):(te.value="bottom"===(null==c?void 0:c.type),ne.value="bottom"===(null==c?void 0:c.type)&&c.distanceFromBottomPx<=2);const d=yn(c);return qe=null==d?null:_t(d),null!=d&&$t(d,{writeDom:!0,remember:!1,updatePinned:!1}),Ce=(null==e?void 0:e.threadKey)===Ie.value?e:null,s?c?void y(()=>{pn(o,c),"undefined"!=typeof window?(ke.forEach(e=>{const t=window.setTimeout(()=>{pn(o,c)},e);Be.push(t)}),An(o)):zn(o)}):(he.value=!1,be=void 0,qe=null,He=0,Ot({remember:!1}),Pn(),void _n()):(he.value=!1,be=void 0,qe=null,He=0,Ot({remember:!1}),Pn(),_n(),void(!1!==r.stickToBottom&&(te.value=!0,ne.value=!0,y(()=>{he.value||Dt()}))))}function $n(){for(const e of fe.values())e.disconnect();fe.clear(),me.clear()}return g(Ie,(e,t)=>{const n=null!=ze?ze:t,o=Boolean(n&&n!==e);o&&function(e){var t;on(),(null==(t=hn())?void 0:t.threadKey)!==e&&((null==Ce?void 0:Ce.threadKey)===e?(ve.set(e,Ce),a(Ce)):ve.has(e)||vn(e))}(n),ze=e,On(function(e){return(e?ve.get(e):null)||function(e){var t;const n=r.initialThreadState;return n?(null!=(t=n.threadKey)?t:"")!==(null!=e?e:"")?null:n:null}(e)}(e),{threadSwitch:o})},{immediate:!0,flush:"sync"}),g(()=>at.value.records.map(e=>e.key).join("\0"),()=>{var e;e={start:at.value.start,end:at.value.end},o("range-change",e)},{immediate:!0}),g(()=>[r.items.length,Qe.value.totalHeight],()=>{he.value||!1!==r.stickToBottom&&("auto"!==r.stickToBottom||ne.value)&&y(()=>{he.value||!1!==r.stickToBottom&&("auto"!==r.stickToBottom||ne.value)&&Dt()})},{flush:"post"}),k(()=>{qt(),zt(),be?(pn(He,be),Ot({remember:!1}),vn()):!1===r.stickToBottom?(Ot({remember:!1}),vn()):(te.value=!0,$t(Pt(),{writeDom:!0,remember:!1,updatePinned:!1}),Ot({remember:!1}),vn()),Q.value&&"undefined"!=typeof ResizeObserver&&(we=new ResizeObserver(()=>{qt(),Ot()}),we.observe(Q.value))}),p(()=>{ge.value||An(He)}),b(()=>{hn()||vn(),Ft(),Me=null,null!=Te&&"undefined"!=typeof window&&window.clearTimeout(Te),Te=null,pe=void 0,tn(Jt.raf),Jt.scheduled=!1,Jt.raf=null,Jt.anchor=void 0,tn(Zt),Ut=!1,Zt=null,Qt.clear(),$n(),oe.clear(),ae.clear(),le.clear(),ie.clear(),ue.clear(),ce.clear(),de.clear(),null==we||we.disconnect(),we=null}),t({captureThreadState:function(){return fn(Ie.value)},restoreThreadState:On,scrollToBottom:Dt,scrollToIndex:function(e,t="start"){const n=Qe.value.records[e];if(!n)return;let r=Rt()+Ze(n);"center"===t?r-=(Z.value-n.size)/2:"end"===t&&(r-=Z.value-n.size),Et(r)},scrollToOffset:Et,getItemSize:e=>{var t;const n=wt(e);return n&&null!=(t=bt(n))?t:void 0},getTotalHeight:()=>Qe.value.totalHeight,getVisibleRange:()=>({start:at.value.start,end:at.value.end})}),(e,t)=>(w(),M("div",{ref_key:"scrollRoot",ref:Q,class:S(["markstream-virtual-timeline",{"is-restoring-thread":!ge.value}]),"data-markstream-virtual-timeline":"1","data-testid":"markstream-virtual-timeline",onScroll:Lt},[x("div",{class:"markstream-virtual-timeline__spacer",style:B({height:`${at.value.topSpacerHeight}px`}),"aria-hidden":"true"},null,4),(w(!0),M(K,null,T(at.value.records,t=>(w(),M("div",{key:t.renderKey,class:S(["markstream-virtual-timeline__item",{"is-restored-height-floor":Fn(t)}]),"data-markstream-item-key":t.key,"data-markstream-item-kind":t.kind,style:B({minHeight:`${t.size}px`,"--markstream-virtual-item-size":`${t.size}px`})},[F(e.$slots,"default",H({ref_for:!0},cn(t)),()=>{var e,n;return[t.markdown?(w(),q(R(_),H({key:0,ref_for:!0},sn(t)),null,16)):vt(t)?(w(),q(N(vt(t)),{key:1,ref_for:!0,ref:un(t),item:mt(t)},null,8,["item"])):(w(),M("div",{key:2,ref_for:!0,ref:un(t),class:S(["markstream-virtual-timeline__default-item",`markstream-virtual-timeline__default-item--${t.kind||"item"}`])},["tool-call"===t.kind&&(null==(e=mt(t))?void 0:e.status)?(w(),M("span",X,C(null==(n=mt(t))?void 0:n.status),1)):A("",!0),P(" "+C(dn(t)),1)],2))]},!0)],14,Y))),128)),x("div",{class:"markstream-virtual-timeline__spacer",style:B({height:`${at.value.bottomSpacerHeight}px`}),"aria-hidden":"true"},null,4),ge.value?A("",!0):(w(),M("div",{key:0,class:"markstream-virtual-timeline__restore-loading",style:B({height:`${Math.max(1,Ht())}px`,transform:`translateY(${U.value}px)`}),"aria-live":"polite","aria-busy":"true"},[F(e.$slots,"restore-loading",{threadKey:Ie.value,visibleRecords:at.value.records},()=>[t[0]||(t[0]=x("div",{class:"markstream-virtual-timeline__restore-loading-card"},[x("span",{class:"markstream-virtual-timeline__restore-spinner","aria-hidden":"true"}),x("span",null,"Loading thread…")],-1))],!0)],4))],34))}})),[["__scopeId","data-v-f06d8eb5"]]),Q=J;Q.install=e=>{var t,n;const r=null!=(n=null!=(t=Q.__name)?t:Q.name)?n:"MarkstreamVirtualTimeline";e.component(r,J)};export{Q as default};
|
package/dist/tailwind.js
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markstream-vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.5",
|
|
5
5
|
"description": "Vue/Nuxt streaming Markdown renderer for AI chat, LLM token streams, SSE/WebSocket output, incomplete Markdown, long documents, Mermaid, KaTeX, Shiki, and Monaco.",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|
|
@@ -146,8 +146,8 @@
|
|
|
146
146
|
"dependencies": {
|
|
147
147
|
"@chenglou/pretext": "^0.0.8",
|
|
148
148
|
"@floating-ui/dom": "^1.8.0",
|
|
149
|
-
"
|
|
150
|
-
"
|
|
149
|
+
"markstream-core": "1.1.5",
|
|
150
|
+
"stream-markdown-parser": "1.2.7"
|
|
151
151
|
},
|
|
152
152
|
"devDependencies": {
|
|
153
153
|
"@antfu/eslint-config": "^5.4.1",
|