markstream-vue 2.0.0-beta.2 → 2.0.0
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/README.md +9 -8
- package/dist/CodeBlockNode.js +1 -1
- package/dist/exports.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/index5.js +1 -1
- package/dist/index6.js +1 -1
- package/dist/index8.js +1 -1
- package/dist/tailwind.js +0 -0
- package/package.json +4 -3
package/dist/index8.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 S,normalizeClass as M,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 A,toDisplayString as N,createCommentVNode as C,createTextVNode as P}from"vue";import{z as _,aa as j,a4 as I,X as z,a3 as O,a2 as $,a1 as L,a5 as E,ac as D,a0 as V,G as W}from"./exports.js";const Y=["data-markstream-item-key","data-markstream-item-kind"],G={key:0,class:"markstream-virtual-timeline__status"},X=.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"},renderCodeBlocksAsPre:{type:Boolean},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,Se=null,Me=0,xe=null,Be=[],Ke=null,Te=null,Fe=-1,He=0,qe=null,Re=!1,Ae=!1,Ne=null,Ce=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;const Oe=v(()=>{return"chat"===(e=r.markdownMode)||"minimal"===e||"docs"===e?e:"docs";var e}),$e=v(()=>!0===r.renderCodeBlocksAsPre),Le=v(()=>[null==r.measurementKey?"":String(r.measurementKey),ee.value].join(":")),Ee=v(()=>{const e=$e.value?"pre":"rich";return`${Le.value}${Oe.value}${e}`});class De{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 Ve=h([]),We=/* @__PURE__ */new Map,Ye=h(new De([])),Ge=d(0);let Xe=[];const Je=v(()=>(Ge.value,{records:Ve.value,totalHeight:Ye.value.total}));function Qe(){var e;const t=[],n=[],o=function(){var e;return null!=(e=Ie.value)?e:"timeline"}();We.clear();for(let a=0;a<r.items.length;a++){const l=r.items[a],s=at(l,a),c={item:l,index:a,key:s,kind:I(l,a,r),markdown:j(l,a,r)};let d=pt(c);null==d&&(d=null!=(e=Xe[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),We.has(s)||We.set(s,m)}Ve.value=t,Ye.value=new De(n),Xe=[],Ge.value+=1}function Ue(e){return Ge.value,Ye.value.prefixSum(e.index)}function Ze(e){return u(i({},e),{offset:Ue(e)})}function et(e,t){const n=We.get(e);if(!n)return;const r=Math.ceil(t),o=r-n.size;0!==o&&(n.size=r,Ye.value.add(n.index,o),Ge.value+=1)}function tt(e,t="gte"){return Ge.value,Ye.value.lowerBound(e,t)}const nt=v(()=>{var e;return Math.max(0,null!=(e=r.overscan)?e:4)}),rt=v(()=>{var e;const t=Math.max(0,null!=(e=r.overscanPx)?e:1200);return ge.value?t:Math.min(t,160)}),ot=v(()=>{var e,t,n;const r=Je.value.records;if(0===r.length)return{start:0,end:0,records:[],topSpacerHeight:0,bottomSpacerHeight:0};const o=nt.value,a=rt.value,l=Nt(),i=l+Math.max(1,Z.value);let u=tt(Math.max(0,l-a),"gt"),s=tt(Math.min(Je.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(Ze),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,Je.value.totalHeight-(v+(null!=(n=null==m?void 0:m.size)?n:0)))}});function at(e,t){return O(e,t,r)}const lt=/* @__PURE__ */new WeakMap;let it=1;function ut(e){if("object"!=typeof e&&"function"!=typeof e||null===e)return String(null!=e?e:"");const t=e;let n=lt.get(t);return n||(n=it++,lt.set(t,n)),String(n)}function st(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 ct(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 Xe[t]=o,String(o)}function dt(e){var t;return null!=(t=r.items[e.index])?t:e.item}function mt(e){return e.item}function ft(e){var t;const n=dt(e);return null!=(t=null==n?void 0:n.component)?t:e.component}function vt(e,t=Ie.value){const n=mt(e),o=E(n,e.index,r);return[null!=t?t:"timeline",e.key,null==o?"":String(o)].join(":")}function ht(e,t=Ie.value){if(e.markdown)return vt(e,t);const n=mt(e),o=E(n,e.index,r);return[null!=t?t:"timeline",e.key,null==o?"":String(o)].join(":")}function gt(e){return{sourceKey:ht(e),measurementKey:e.markdown?Ee.value:Le.value,widthBucket:ee.value}}function yt(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 kt(e,t,n=Ie.value){var r;return!(!e||!t)&&t.sourceKey===ht(e,n)&&t.measurementKey===(e.markdown?Ee.value:Le.value)&&(null!=(r=t.widthBucket)?r:0)===ee.value}function pt(e,t=Ie.value){const n=re.get(e.key);return kt(e,oe.get(e.key),t)&&Number.isFinite(n)&&n>0?n:null}function bt(e){return Je.value,We.get(e)}function wt(e,t){var n,r;return!!(e&&e.markdown&&t)&&t.sessionKey===vt(e)&&(null!=(n=t.threadKey)?n:"")===(null!=(r=Ie.value)?r:"")&&!!function(e){const t=Ee.value,n=null!=e?e:"";return n===t||n.startsWith(`${t}\0`)}(t.measurementKey)}function St(e,t){return wt(e,t)}function Mt(e,t,n){!Number.isFinite(t)||t<=0||(ce.set(e,Math.ceil(t)),de.set(e,n))}function xt(e,t=se.get(e)){const n=function(e,t=se.get(e)){var n;if(!St(bt(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&&Mt(e,n,t),n}function Bt(e){var t;return wt(bt(e),de.get(e))?null!=(t=ce.get(e))?t:0:xt(e)}function Kt(e){return e===Me&&He===e&&!ge.value}function Tt(){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 Ft(){var e;return Math.max(0,Z.value||(null==(e=Q.value)?void 0:e.clientHeight)||0)}function Ht(){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 qt(){return _e.top}function Rt(){const e=_e;return Math.max(0,Je.value.totalHeight+e.top+e.bottom)}function At(){var e,t;return Math.max(Rt(),null!=(t=null==(e=Q.value)?void 0:e.scrollHeight)?t:0)}function Nt(){return Math.max(0,U.value-qt())}function Ct(){return Math.max(0,At()-Ft())}function Pt(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(t,Ct())):0}function _t(){return Math.max(0,Ct()-U.value)}function jt(){const e=_t();ne.value=e<=2,!0!==r.stickToBottom?!1!==r.stickToBottom?te.value=e<=48:te.value=!1:te.value=!0}function It(){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 zt(e={}){const t=Q.value;t&&(U.value=Math.max(0,t.scrollTop||0),Z.value=t.clientHeight||0),It(),jt(),(!0===e.remember||!1!==e.remember&&!he.value)&&fn()}function Ot(e,t={}){const n=Pt(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)>X)){const e={target:n,preserveBottomPin:!1!==r.stickToBottom&&Math.abs(Ct()-n)<=2};Se=ge.value?e:null,o.scrollTop=n,e.target=Math.max(0,o.scrollTop||0)}It(),!1!==t.updatePinned&&jt(),(!0===t.remember||!1!==t.remember&&!he.value)&&fn()}function $t(){if(!ge.value){Se=null;const e=Q.value,t=qe;return e&&null!=t&&Math.abs((e.scrollTop||0)-t)>X&&(e.scrollTop=t),void kn(He,be)}const e=Q.value,t=Se,n=Math.max(0,(null==e?void 0:e.scrollTop)||0);return e&&t&&Math.abs(n-t.target)<=X&&t.preserveBottomPin&&!1!==r.stickToBottom||e&&ne.value&&"auto"===r.stickToBottom&&(Math.abs(Ct()-n)<=2||n>=U.value-X)||!0===r.stickToBottom?(te.value=!0,ne.value=!0,void Ot(Ct(),{writeDom:!0,remember:!1})):(Se=null,void zt())}function Lt(e){Ot(e,{writeDom:!0,remember:!0})}function Et(){Lt(Ct())}function Dt(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&&!Vt(r,t)?0:Math.ceil(n)}function Vt(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))&&(Wt(t.measurementKey)||Wt(e.measurementKey)||t.measurementKey===e.measurementKey)}function Wt(e){return":0"===e||!0===(null==e?void 0:e.startsWith(":0"))}function Yt(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&&!yt(oe.get(e),n),i=!0===o.releaseRestoredFloor;!function(e,t){if(!t)return;const n=le.get(e);n&&!Vt(n,t)&&(ae.delete(e),le.delete(e),ie.delete(e),ue.delete(e))}(e,n),i&&Yt(e);const u=Dt(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 hn(o.rememberThreadKey);if(he.value)return n&&oe.set(e,n),re.set(e,s),et(e,s),void function(e=He,t=be){t&&y(()=>{kn(e,t),null==xe&&"function"==typeof requestAnimationFrame&&(xe=requestAnimationFrame(()=>{xe=null,kn(e,t)}))})}();const c=(d=dn(),m=_t(),!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),et(e,s),hn(o.rememberThreadKey),function(e){if(!Xt.scheduled)return Xt.anchor=e,Xt.scheduled=!0,void(Xt.raf=Zt(tn));!Xt.anchor&&e&&(Xt.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=at(e,t),a=j(e,t,r);return[o,I(e,t,r),a?1:0,null!=(n=E(e,t,r))?n:"",ct(e,t),st(e,t,a),(l=null==e?void 0:e.component,l?"string"==typeof l?`s:${l}`:`o:${ut(l)}`:"")].join("");var l}).join("\0")}(),Le,Ee,Ie,()=>ut(r.estimateItemHeight),()=>ut(r.getKey),()=>ut(r.getKind),()=>ut(r.getContent),()=>ut(r.getFinal),()=>ut(r.getRevision)],()=>Qe(),{immediate:!0,flush:"sync"});const Xt={scheduled:!1,raf:null,anchor:void 0},Jt=/* @__PURE__ */new Map;let Qt=!1,Ut=null;function Zt(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(e):(y(e),null)}function en(e){null!=e&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}function tn(){if(!Xt.scheduled)return;Xt.scheduled=!1,Xt.raf=null;const e=Xt.anchor;Xt.anchor=void 0;const t="bottom"===(null==e?void 0:e.type)&&e.distanceFromBottomPx<=2&&ne.value;e&&yn(e);const n=Q.value,r=!n||Math.abs((n.scrollTop||0)-U.value)<=X;t&&!r||zt({remember:!1})}function nn(){var e,t;if(!Qt)return;Qt=!1,Ut=null;const n=Array.from(Jt.entries());Jt.clear();for(const[r,o]of n){if(ce.get(r)!==o.logicalHeight)continue;const n=We.get(r);if(!n)continue;const a=(null!=(e=o.threadKey)?e:"")===(null!=(t=Ie.value)?t:"");an(n,{allowMarkdownShrink:o.allowMarkdownShrink,allowRestoredFloorShrink:o.allowRestoredFloorShrink,markdownLogicalHeight:o.logicalHeight,rememberThreadKey:o.threadKey,source:o.itemSizeSource,updateLayout:a})}tn()}function rn(){nn(),tn()}function on(e){var t;null==(t=fe.get(e))||t.disconnect(),fe.delete(e),me.delete(e)}function an(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:gt(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=yt(oe.get(e.key),c)&&null!=(o=re.get(e.key))?o:0,v=null!=(a=t.markdownLogicalHeight)?a:Bt(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=Dt(e.key,c),a=o>0&&n>o+1&&(!$(dt(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))&&Yt(e.key),n>0&&Gt(e.key,n,c,t),void m()}return String(L(dt(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&&(Yt(e.key),Gt(e.key,l,c,t)),void m())}function ln(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 on(e.key);if(r===n)return void an(e);if(on(e.key),me.set(e.key,n),an(e),"undefined"==typeof ResizeObserver)return;const o=new ResizeObserver(()=>{an(e)});o.observe(n),fe.set(e.key,o)}(e,t)}}function un(e){const t=dt(e),n=$(t,e.index,r),a=se.get(e.key),s=Oe.value,d={enabled:!0,sessionKey:vt(e),threadKey:Ie.value,scrollRoot:()=>Q.value,restoreState:St(e,a)?a:null,restoreAnchor:!1,measurementKey:Ee.value,settleMode:"manual",settledToken:n,emitIntervalMs:96,heightDiffThresholdPx:4};return u(i({content:L(t,e.index,r),final:n,mode:s,renderCodeBlocksAsPre:$e.value},n?{nodeVirtual:"auto",maxLiveNodes:50,liveNodeBuffer:16}:{}),{fade:!0===r.markdownFade,indexKey:vt(e),virtualScroll:d,onHeightChange(t){if(t.sessionKey!==vt(e))return;Mt(e.key,t.totalHeight,{sessionKey:t.sessionKey,threadKey:Ie.value,measurementKey:Ee.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){Jt.set(e.key,t),Qt||(Qt=!0,Ut=Zt(nn))}(e,{allowMarkdownShrink:n,allowRestoredFloorShrink:r,itemSizeSource:gt(e),logicalHeight:a,threadKey:Ie.value}),i={itemKey:e.key,metrics:t},o("height-change",i)},onVirtualStateChange(t){var n;t.sessionKey===vt(e)&&(se.set(e.key,t),xt(e.key,t),hn(),n={itemKey:e.key,state:t},o("virtual-state-change",n))}})}function sn(e){return{item:dt(e),index:e.index,itemKey:e.key,kind:e.kind,measureRef:ln(e),markdownProps:un(e)}}function cn(e){var t;const n=null!=(t=dt(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 dn(){const e=_t();if(e<=2)return{type:"bottom",distanceFromBottomPx:Math.max(0,e)};const t=Nt(),n=tt(t,"gt"),r=Je.value.records[n];if(r){const e=Ue(r);if(t>=e&&t<e+r.size)return{type:"item",itemKey:r.key,offsetWithinItemPx:t-e}}const o=ot.value.records[0];return o?{type:"item",itemKey:o.key,offsetWithinItemPx:0}:void 0}function mn(e=Ie.value){rn();const t={},n={};for(const r of Je.value.records){const o=pt(r,e),a=oe.get(r.key);null!=o&&kt(r,a,e)&&(t[r.key]=o,n[r.key]=a)}return{threadKey:e,measurementKey:Le.value,widthBucket:ee.value,outerAnchor:dn(),itemHeights:t,itemSizeSources:n,markdownStates:Object.fromEntries(se.entries())}}function fn(e=Ie.value){if(!e)return;const t=mn(e);return ve.set(e,t),e===Ie.value&&(Ne=t),a(t),t}function vn(){const e=pe;return null!=Te&&"undefined"!=typeof window&&window.clearTimeout(Te),Te=null,pe=void 0,e?fn(e):void 0}function hn(e=Ie.value){e&&(pe=e,null==Te&&("undefined"!=typeof window?Te=window.setTimeout(()=>{Te=null,vn()},80):vn()))}function gn(e){if(!e)return null;if("bottom"===e.type)return(ge.value?At():Rt())-Ft()-Math.max(0,e.distanceFromBottomPx);const t=bt(e.itemKey);return t?qt()+Ue(t)+Math.max(0,e.offsetWithinItemPx):null}function yn(e,t={}){const n=gn(e);return null!=n&&(Ot(n,{writeDom:!0,remember:!0===t.remember}),!0)}function kn(e,t){if(e===Me){if(t){const e=yn(t,{remember:!1});qe=e?U.value:null}zt({remember:!1})}}function pn(e,t){const n=e.getBoundingClientRect();return n.width>0&&n.height>0&&n.bottom>t.top&&n.top<t.bottom}function bn(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.bottom>r.top&&n.top<r.bottom}function wn(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 Mn(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 xn(e){var t;if(e.querySelector(":scope > .node-placeholder"))return!1;const n=e.querySelector(":scope > .node-content");return!!n&&(!Mn(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("diffs-container, .stream-diffs-shell, .stream-diffs-surface")).some(wn))}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 Bn(e,t){var n;if(!e.markdown)return!0;const o=L(dt(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!Mn(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 Kn(e,t,n){if(!e.markdown)return!0;const o=L(dt(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=>pn(e,a));if(l.length>0)return l.every(e=>xn(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(!Tn(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)&&Bn(e,t):Bn(e,t)}function Tn(e){const t=oe.get(e.key);return Dt(e.key,t)>0}function Fn(e,t){var n,o,a,i;if(!e.markdown)return!0;if(!Re&&!Ae)return!0;if(Tn(e))return!0;const u=L(dt(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 Ae?!0===(null==d?void 0:d.final)&&(g&&y||k):p||!0===(null==d?void 0:d.final)}function Hn(){const e=Q.value;if(!e)return!1;const t=gn(be);if(null!=t&&Math.abs((e.scrollTop||0)-Pt(t))>X)return!1;const n=ot.value.records;if(!n.length)return 0===Je.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&&bn(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(!Kn(i,u,e))return!1;if(!Fn(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=>!(!pn(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=>pn(e,a));for(const i of l)if(!xn(i))return!1;return!0}function qn(){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=ot.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=>pn(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("diffs-container, .stream-diffs-shell");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(Je.value.totalHeight||0),r,o].join("\n")}function Rn(){return"undefined"!=typeof performance?performance.now():Date.now()}function An(){return Ae?24:2}function Nn(e){Kt(e)&&Ce!==e&&(Ce=e,function(e){return t=this,n=function*(){const t=Rn();let n=0,r="";for(let o=0;o<40;o++){if(yield y(),yield new Promise(e=>{"function"!=typeof requestAnimationFrame?e():requestAnimationFrame(()=>e())}),!Kt(e))return!1;kn(e,be);const o=Rn(),a=Hn(),l=a?qn():"";if(a&&l===r&&l){if(n+=1,n>=An()&&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(Ce===e&&(Ce=0),Kt(e))return t?void In(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)&&Rn()-Fe>=e}()?(!0===r.debug&&import.meta,void In(e)):(function(e){Pe!==e&&(Pe=e,!0===r.debug&&import.meta)}(e),void function(e){Kt(e)&&"undefined"!=typeof window&&(null!=Ke&&window.clearTimeout(Ke),Ke=window.setTimeout(()=>{Ke=null,Kt(e)&&Nn(e)},120))}(e))}))}function Cn(){ge.value=!0,Fe=-1,Ce=0,Pe=0,Re=!1,Ae=!1,null!=Ke&&"undefined"!=typeof window&&window.clearTimeout(Ke),Ke=null}function Pn(){je=!0}function _n(e){var t,n;const r=[];if(!function(e){var t,n;return!!e&&(null!=(t=e.measurementKey)?t:"")===Le.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=bt(o),l=null==(n=null==e?void 0:e.itemSizeSources)?void 0:n[o];kt(t,l)&&r.push([o,Math.ceil(a),l])}return r}function jn(e){var t;for(const[n,r]of Object.entries(null!=(t=null==e?void 0:e.markdownStates)?t:{}))if(St(bt(n),r))return!0;return!1}function In(e){if(e!==Me)return;nn();const t=new Set(ue);Tt(),kn(e,be),he.value=!1,Fe=-1,be=void 0,qe=null,He=0;for(const n of Je.value.records)n.markdown&&!t.has(n.key)||Yt(n.key);for(const n of t){const e=We.get(n);e?an(e,{allowMarkdownShrink:!0,allowRestoredFloorShrink:!0,markdownLogicalHeight:Bt(e.key),source:gt(e),updateLayout:!0}):Yt(n)}ue.clear(),tn(),zt({remember:!1}),Cn(),Pn()}function zn(e,t={}){var n;const o=++Me;Se=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)||_n(e).length>0||jn(e))}(e),i=jn(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=Je.value.records[0];return e?{type:"item",itemKey:e.key,offsetWithinItemPx:0}:void 0}():void 0;Tt(),Ce=0,Pe=0,ge.value=!s,he.value=s&&Boolean(c),He=o,be=c,Re=s&&i,Ae=s&&u,Fe=he.value?Rn():-1,On(),re.clear(),oe.clear(),ae.clear(),le.clear(),ie.clear(),ue.clear(),se.clear(),ce.clear(),de.clear();for(const[r,m,f]of _n(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=xt(r,m);e>0&&ie.set(r,e)}Qe(),!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=gn(c);return qe=null==d?null:Pt(d),null!=d&&Ot(d,{writeDom:!0,remember:!1,updatePinned:!1}),Ne=(null==e?void 0:e.threadKey)===Ie.value?e:null,s?c?void y(()=>{kn(o,c),"undefined"!=typeof window?(ke.forEach(e=>{const t=window.setTimeout(()=>{kn(o,c)},e);Be.push(t)}),Nn(o)):In(o)}):(he.value=!1,be=void 0,qe=null,He=0,zt({remember:!1}),Cn(),void Pn()):(he.value=!1,be=void 0,qe=null,He=0,zt({remember:!1}),Cn(),Pn(),void(!1!==r.stickToBottom&&(te.value=!0,ne.value=!0,y(()=>{he.value||Et()}))))}function On(){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;rn(),(null==(t=vn())?void 0:t.threadKey)!==e&&((null==Ne?void 0:Ne.threadKey)===e?(ve.set(e,Ne),a(Ne)):ve.has(e)||fn(e))}(n),ze=e,zn(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(()=>ot.value.records.map(e=>e.key).join("\0"),()=>{var e;e={start:ot.value.start,end:ot.value.end},o("range-change",e)},{immediate:!0}),g(()=>[r.items.length,Je.value.totalHeight],()=>{he.value||!1!==r.stickToBottom&&("auto"!==r.stickToBottom||ne.value)&&y(()=>{he.value||!1!==r.stickToBottom&&("auto"!==r.stickToBottom||ne.value)&&Et()})},{flush:"post"}),k(()=>{Ht(),It(),be?(kn(He,be),zt({remember:!1}),fn()):!1===r.stickToBottom?(zt({remember:!1}),fn()):(te.value=!0,Ot(Ct(),{writeDom:!0,remember:!1,updatePinned:!1}),zt({remember:!1}),fn()),Q.value&&"undefined"!=typeof ResizeObserver&&(we=new ResizeObserver(()=>{Ht(),zt()}),we.observe(Q.value))}),p(()=>{ge.value||Nn(He)}),b(()=>{vn()||fn(),Tt(),Se=null,null!=Te&&"undefined"!=typeof window&&window.clearTimeout(Te),Te=null,pe=void 0,en(Xt.raf),Xt.scheduled=!1,Xt.raf=null,Xt.anchor=void 0,en(Ut),Qt=!1,Ut=null,Jt.clear(),On(),oe.clear(),ae.clear(),le.clear(),ie.clear(),ue.clear(),ce.clear(),de.clear(),null==we||we.disconnect(),we=null}),t({captureThreadState:function(){return mn(Ie.value)},restoreThreadState:zn,scrollToBottom:Et,scrollToIndex:function(e,t="start"){const n=Je.value.records[e];if(!n)return;let r=qt()+Ue(n);"center"===t?r-=(Z.value-n.size)/2:"end"===t&&(r-=Z.value-n.size),Lt(r)},scrollToOffset:Lt,getItemSize:e=>{var t;const n=bt(e);return n&&null!=(t=pt(n))?t:void 0},getTotalHeight:()=>Je.value.totalHeight,getVisibleRange:()=>({start:ot.value.start,end:ot.value.end})}),(e,t)=>(w(),S("div",{ref_key:"scrollRoot",ref:Q,class:M(["markstream-virtual-timeline",{"is-restoring-thread":!ge.value}]),"data-markstream-virtual-timeline":"1","data-testid":"markstream-virtual-timeline",onScroll:$t},[x("div",{class:"markstream-virtual-timeline__spacer",style:B({height:`${ot.value.topSpacerHeight}px`}),"aria-hidden":"true"},null,4),(w(!0),S(K,null,T(ot.value.records,t=>(w(),S("div",{key:t.renderKey,class:M(["markstream-virtual-timeline__item",{"is-restored-height-floor":Tn(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},sn(t)),()=>{var e,n;return[t.markdown?(w(),q(R(_),H({key:0,ref_for:!0},un(t)),null,16)):ft(t)?(w(),q(A(ft(t)),{key:1,ref_for:!0,ref:ln(t),item:dt(t)},null,8,["item"])):(w(),S("div",{key:2,ref_for:!0,ref:ln(t),class:M(["markstream-virtual-timeline__default-item",`markstream-virtual-timeline__default-item--${t.kind||"item"}`])},["tool-call"===t.kind&&(null==(e=dt(t))?void 0:e.status)?(w(),S("span",G,N(null==(n=dt(t))?void 0:n.status),1)):C("",!0),P(" "+N(cn(t)),1)],2))]},!0)],14,Y))),128)),x("div",{class:"markstream-virtual-timeline__spacer",style:B({height:`${ot.value.bottomSpacerHeight}px`}),"aria-hidden":"true"},null,4),ge.value?C("",!0):(w(),S("div",{key:0,class:"markstream-virtual-timeline__restore-loading",style:B({height:`${Math.max(1,Ft())}px`,transform:`translateY(${U.value}px)`}),"aria-live":"polite","aria-busy":"true"},[F(e.$slots,"restore-loading",{threadKey:Ie.value,visibleRecords:ot.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-574ad3d2"]]),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 S,normalizeClass as M,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 A,toDisplayString as N,createCommentVNode as C,createTextVNode as P}from"vue";import{z as _,aa as j,a4 as I,X as z,a3 as O,a2 as $,a1 as L,a5 as E,ac as D,a0 as V,G as W}from"./exports.js";const Y=["data-markstream-item-key","data-markstream-item-kind"],G={key:0,class:"markstream-virtual-timeline__status"},X=.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"},renderCodeBlocksAsPre:{type:Boolean},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,Se=null,Me=0,xe=null,Be=[],Ke=null,Te=null,Fe=-1,He=0,qe=null,Re=!1,Ae=!1,Ne=null,Ce=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;const Oe=v(()=>{return"chat"===(e=r.markdownMode)||"minimal"===e||"docs"===e?e:"docs";var e}),$e=v(()=>!0===r.renderCodeBlocksAsPre),Le=v(()=>[null==r.measurementKey?"":String(r.measurementKey),ee.value].join(":")),Ee=v(()=>{const e=$e.value?"pre":"rich";return`${Le.value}${Oe.value}${e}`});class De{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 Ve=h([]),We=/* @__PURE__ */new Map,Ye=h(new De([])),Ge=d(0);let Xe=[];const Je=v(()=>(Ge.value,{records:Ve.value,totalHeight:Ye.value.total}));function Qe(){var e;const t=[],n=[],o=function(){var e;return null!=(e=Ie.value)?e:"timeline"}();We.clear();for(let a=0;a<r.items.length;a++){const l=r.items[a],s=at(l,a),c={item:l,index:a,key:s,kind:I(l,a,r),markdown:j(l,a,r)};let d=pt(c);null==d&&(d=null!=(e=Xe[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),We.has(s)||We.set(s,m)}Ve.value=t,Ye.value=new De(n),Xe=[],Ge.value+=1}function Ue(e){return Ge.value,Ye.value.prefixSum(e.index)}function Ze(e){return u(i({},e),{offset:Ue(e)})}function et(e,t){const n=We.get(e);if(!n)return;const r=Math.ceil(t),o=r-n.size;0!==o&&(n.size=r,Ye.value.add(n.index,o),Ge.value+=1)}function tt(e,t="gte"){return Ge.value,Ye.value.lowerBound(e,t)}const nt=v(()=>{var e;return Math.max(0,null!=(e=r.overscan)?e:4)}),rt=v(()=>{var e;const t=Math.max(0,null!=(e=r.overscanPx)?e:1200);return ge.value?t:Math.min(t,160)}),ot=v(()=>{var e,t,n;const r=Je.value.records;if(0===r.length)return{start:0,end:0,records:[],topSpacerHeight:0,bottomSpacerHeight:0};const o=nt.value,a=rt.value,l=Nt(),i=l+Math.max(1,Z.value);let u=tt(Math.max(0,l-a),"gt"),s=tt(Math.min(Je.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(Ze),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,Je.value.totalHeight-(v+(null!=(n=null==m?void 0:m.size)?n:0)))}});function at(e,t){return O(e,t,r)}const lt=/* @__PURE__ */new WeakMap;let it=1;function ut(e){if("object"!=typeof e&&"function"!=typeof e||null===e)return String(null!=e?e:"");const t=e;let n=lt.get(t);return n||(n=it++,lt.set(t,n)),String(n)}function st(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 ct(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 Xe[t]=o,String(o)}function dt(e){var t;return null!=(t=r.items[e.index])?t:e.item}function mt(e){return e.item}function ft(e){var t;const n=dt(e);return null!=(t=null==n?void 0:n.component)?t:e.component}function vt(e,t=Ie.value){const n=mt(e),o=E(n,e.index,r);return[null!=t?t:"timeline",e.key,null==o?"":String(o)].join(":")}function ht(e,t=Ie.value){if(e.markdown)return vt(e,t);const n=mt(e),o=E(n,e.index,r);return[null!=t?t:"timeline",e.key,null==o?"":String(o)].join(":")}function gt(e){return{sourceKey:ht(e),measurementKey:e.markdown?Ee.value:Le.value,widthBucket:ee.value}}function yt(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 kt(e,t,n=Ie.value){var r;return!(!e||!t)&&t.sourceKey===ht(e,n)&&t.measurementKey===(e.markdown?Ee.value:Le.value)&&(null!=(r=t.widthBucket)?r:0)===ee.value}function pt(e,t=Ie.value){const n=re.get(e.key);return kt(e,oe.get(e.key),t)&&Number.isFinite(n)&&n>0?n:null}function bt(e){return Je.value,We.get(e)}function wt(e,t){var n,r;return!!(e&&e.markdown&&t)&&t.sessionKey===vt(e)&&(null!=(n=t.threadKey)?n:"")===(null!=(r=Ie.value)?r:"")&&!!function(e){const t=Ee.value,n=null!=e?e:"";return n===t||n.startsWith(`${t}\0`)}(t.measurementKey)}function St(e,t){return wt(e,t)}function Mt(e,t,n){!Number.isFinite(t)||t<=0||(ce.set(e,Math.ceil(t)),de.set(e,n))}function xt(e,t=se.get(e)){const n=function(e,t=se.get(e)){var n;if(!St(bt(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&&Mt(e,n,t),n}function Bt(e){var t;return wt(bt(e),de.get(e))?null!=(t=ce.get(e))?t:0:xt(e)}function Kt(e){return e===Me&&He===e&&!ge.value}function Tt(){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 Ft(){var e;return Math.max(0,Z.value||(null==(e=Q.value)?void 0:e.clientHeight)||0)}function Ht(){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 qt(){return _e.top}function Rt(){const e=_e;return Math.max(0,Je.value.totalHeight+e.top+e.bottom)}function At(){var e,t;return Math.max(Rt(),null!=(t=null==(e=Q.value)?void 0:e.scrollHeight)?t:0)}function Nt(){return Math.max(0,U.value-qt())}function Ct(){return Math.max(0,At()-Ft())}function Pt(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(t,Ct())):0}function _t(){return Math.max(0,Ct()-U.value)}function jt(){const e=_t();ne.value=e<=2,!0!==r.stickToBottom?!1!==r.stickToBottom?te.value=e<=48:te.value=!1:te.value=!0}function It(){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 zt(e={}){const t=Q.value;t&&(U.value=Math.max(0,t.scrollTop||0),Z.value=t.clientHeight||0),It(),jt(),(!0===e.remember||!1!==e.remember&&!he.value)&&hn()}function Ot(e,t={}){const n=Pt(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)>X)){const e={target:n,preserveBottomPin:!1!==r.stickToBottom&&Math.abs(Ct()-n)<=2};Se=ge.value?e:null,o.scrollTop=n,e.target=Math.max(0,o.scrollTop||0)}It(),!1!==t.updatePinned&&jt(),(!0===t.remember||!1!==t.remember&&!he.value)&&fn()}function $t(){if(!ge.value){Se=null;const e=Q.value,t=qe;return e&&null!=t&&Math.abs((e.scrollTop||0)-t)>X&&(e.scrollTop=t),void kn(He,be)}const e=Q.value,t=Se,n=Math.max(0,(null==e?void 0:e.scrollTop)||0);return e&&t&&Math.abs(n-t.target)<=X&&t.preserveBottomPin&&!1!==r.stickToBottom||e&&ne.value&&"auto"===r.stickToBottom&&(Math.abs(Ct()-n)<=2||n>=U.value-X)||!0===r.stickToBottom?(te.value=!0,ne.value=!0,void Ot(Ct(),{writeDom:!0,remember:!1})):(Se=null,void zt())}function Lt(e){Ot(e,{writeDom:!0,remember:!0})}function Et(){Lt(Ct())}function Dt(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&&!Vt(r,t)?0:Math.ceil(n)}function Vt(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))&&(Wt(t.measurementKey)||Wt(e.measurementKey)||t.measurementKey===e.measurementKey)}function Wt(e){return":0"===e||!0===(null==e?void 0:e.startsWith(":0"))}function Yt(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&&!yt(oe.get(e),n),i=!0===o.releaseRestoredFloor;!function(e,t){if(!t)return;const n=le.get(e);n&&!Vt(n,t)&&(ae.delete(e),le.delete(e),ie.delete(e),ue.delete(e))}(e,n),i&&Yt(e);const u=Dt(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 hn(o.rememberThreadKey);if(he.value)return n&&oe.set(e,n),re.set(e,s),et(e,s),void function(e=He,t=be){t&&y(()=>{kn(e,t),null==xe&&"function"==typeof requestAnimationFrame&&(xe=requestAnimationFrame(()=>{xe=null,kn(e,t)}))})}();const c=(d=dn(),m=_t(),!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),et(e,s),hn(o.rememberThreadKey),function(e){if(!Xt.scheduled)return Xt.anchor=e,Xt.scheduled=!0,void(Xt.raf=Zt(tn));!Xt.anchor&&e&&(Xt.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=at(e,t),a=j(e,t,r);return[o,I(e,t,r),a?1:0,null!=(n=E(e,t,r))?n:"",ct(e,t),st(e,t,a),(l=null==e?void 0:e.component,l?"string"==typeof l?`s:${l}`:`o:${ut(l)}`:"")].join("");var l}).join("\0")}(),Le,Ee,Ie,()=>ut(r.estimateItemHeight),()=>ut(r.getKey),()=>ut(r.getKind),()=>ut(r.getContent),()=>ut(r.getFinal),()=>ut(r.getRevision)],()=>Qe(),{immediate:!0,flush:"sync"});const Xt={scheduled:!1,raf:null,anchor:void 0},Jt=/* @__PURE__ */new Map;let Qt=!1,Ut=null;function Zt(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(e):(y(e),null)}function en(e){null!=e&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}function tn(){if(!Xt.scheduled)return;Xt.scheduled=!1,Xt.raf=null;const e=Xt.anchor;Xt.anchor=void 0;const t="bottom"===(null==e?void 0:e.type)&&e.distanceFromBottomPx<=2&&ne.value;e&&yn(e);const n=Q.value,r=!n||Math.abs((n.scrollTop||0)-U.value)<=X;t&&!r||zt({remember:!1})}function nn(){var e,t;if(!Qt)return;Qt=!1,Ut=null;const n=Array.from(Jt.entries());Jt.clear();for(const[r,o]of n){if(ce.get(r)!==o.logicalHeight)continue;const n=We.get(r);if(!n)continue;const a=(null!=(e=o.threadKey)?e:"")===(null!=(t=Ie.value)?t:"");an(n,{allowMarkdownShrink:o.allowMarkdownShrink,allowRestoredFloorShrink:o.allowRestoredFloorShrink,markdownLogicalHeight:o.logicalHeight,rememberThreadKey:o.threadKey,source:o.itemSizeSource,updateLayout:a})}tn()}function rn(){nn(),tn()}function on(e){var t;null==(t=fe.get(e))||t.disconnect(),fe.delete(e),me.delete(e)}function an(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:gt(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=yt(oe.get(e.key),c)&&null!=(o=re.get(e.key))?o:0,v=null!=(a=t.markdownLogicalHeight)?a:Bt(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=Dt(e.key,c),a=o>0&&n>o+1&&(!$(dt(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))&&Yt(e.key),n>0&&Gt(e.key,n,c,t),void m()}return String(L(dt(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&&(Yt(e.key),Gt(e.key,l,c,t)),void m())}function ln(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 on(e.key);if(r===n)return void an(e);if(on(e.key),me.set(e.key,n),an(e),"undefined"==typeof ResizeObserver)return;const o=new ResizeObserver(()=>{an(e)});o.observe(n),fe.set(e.key,o)}(e,t)}}function un(e){const t=dt(e),n=$(t,e.index,r),a=se.get(e.key),s=Oe.value,d={enabled:!0,sessionKey:vt(e),threadKey:Ie.value,scrollRoot:()=>Q.value,restoreState:St(e,a)?a:null,restoreAnchor:!1,measurementKey:Ee.value,settleMode:"manual",settledToken:n,emitIntervalMs:96,heightDiffThresholdPx:4};return u(i({content:L(t,e.index,r),final:n,mode:s,renderCodeBlocksAsPre:$e.value},n?{nodeVirtual:"auto",maxLiveNodes:50,liveNodeBuffer:16}:{}),{fade:!0===r.markdownFade,indexKey:vt(e),virtualScroll:d,onHeightChange(t){if(t.sessionKey!==vt(e))return;Mt(e.key,t.totalHeight,{sessionKey:t.sessionKey,threadKey:Ie.value,measurementKey:Ee.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){Jt.set(e.key,t),Qt||(Qt=!0,Ut=Zt(nn))}(e,{allowMarkdownShrink:n,allowRestoredFloorShrink:r,itemSizeSource:gt(e),logicalHeight:a,threadKey:Ie.value}),i={itemKey:e.key,metrics:t},o("height-change",i)},onVirtualStateChange(t){var n;t.sessionKey===vt(e)&&(se.set(e.key,t),xt(e.key,t),hn(),n={itemKey:e.key,state:t},o("virtual-state-change",n))}})}function sn(e){return{item:dt(e),index:e.index,itemKey:e.key,kind:e.kind,measureRef:ln(e),markdownProps:un(e)}}function cn(e){var t;const n=null!=(t=dt(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 dn(){const e=_t();if(e<=2)return{type:"bottom",distanceFromBottomPx:Math.max(0,e)};const t=Nt(),n=tt(t,"gt"),r=Je.value.records[n];if(r){const e=Ue(r);if(t>=e&&t<e+r.size)return{type:"item",itemKey:r.key,offsetWithinItemPx:t-e}}const o=ot.value.records[0];return o?{type:"item",itemKey:o.key,offsetWithinItemPx:0}:void 0}function mn(e=Ie.value){rn();const t={},n={};for(const r of Je.value.records){const o=pt(r,e),a=oe.get(r.key);null!=o&&kt(r,a,e)&&(t[r.key]=o,n[r.key]=a)}return{threadKey:e,measurementKey:Le.value,widthBucket:ee.value,outerAnchor:dn(),itemHeights:t,itemSizeSources:n,markdownStates:Object.fromEntries(se.entries())}}function fn(e=Ie.value){if(!e)return;const t=mn(e);return ve.set(e,t),e===Ie.value&&(Ne=t),a(t),t}function vn(){const e=pe;return null!=Te&&"undefined"!=typeof window&&window.clearTimeout(Te),Te=null,pe=void 0,e?fn(e):void 0}function hn(e=Ie.value){e&&(pe=e,null==Te&&("undefined"!=typeof window?Te=window.setTimeout(()=>{Te=null,vn()},80):vn()))}function gn(e){if(!e)return null;if("bottom"===e.type)return(ge.value?At():Rt())-Ft()-Math.max(0,e.distanceFromBottomPx);const t=bt(e.itemKey);return t?qt()+Ue(t)+Math.max(0,e.offsetWithinItemPx):null}function yn(e,t={}){const n=gn(e);return null!=n&&(Ot(n,{writeDom:!0,remember:!0===t.remember}),!0)}function kn(e,t){if(e===Me){if(t){const e=yn(t,{remember:!1});qe=e?U.value:null}zt({remember:!1})}}function pn(e,t){const n=e.getBoundingClientRect();return n.width>0&&n.height>0&&n.bottom>t.top&&n.top<t.bottom}function bn(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.bottom>r.top&&n.top<r.bottom}function wn(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 Mn(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 xn(e){var t;if(e.querySelector(":scope > .node-placeholder"))return!1;const n=e.querySelector(":scope > .node-content");return!!n&&(!Mn(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("diffs-container, .stream-diffs-shell, .stream-diffs-surface")).some(wn))}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 Bn(e,t){var n;if(!e.markdown)return!0;const o=L(dt(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!Mn(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 Kn(e,t,n){if(!e.markdown)return!0;const o=L(dt(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=>pn(e,a));if(l.length>0)return l.every(e=>xn(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(!Tn(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)&&Bn(e,t):Bn(e,t)}function Tn(e){const t=oe.get(e.key);return Dt(e.key,t)>0}function Fn(e,t){var n,o,a,i;if(!e.markdown)return!0;if(!Re&&!Ae)return!0;if(Tn(e))return!0;const u=L(dt(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 Ae?!0===(null==d?void 0:d.final)&&(g&&y||k):p||!0===(null==d?void 0:d.final)}function Hn(){const e=Q.value;if(!e)return!1;const t=gn(be);if(null!=t&&Math.abs((e.scrollTop||0)-Pt(t))>X)return!1;const n=ot.value.records;if(!n.length)return 0===Je.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&&bn(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(!Kn(i,u,e))return!1;if(!Fn(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=>!(!pn(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=>pn(e,a));for(const i of l)if(!xn(i))return!1;return!0}function qn(){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=ot.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=>pn(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("diffs-container, .stream-diffs-shell");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(Je.value.totalHeight||0),r,o].join("\n")}function Rn(){return"undefined"!=typeof performance?performance.now():Date.now()}function An(){return Ae?24:2}function Nn(e){Kt(e)&&Ce!==e&&(Ce=e,function(e){return t=this,n=function*(){const t=Rn();let n=0,r="";for(let o=0;o<40;o++){if(yield y(),yield new Promise(e=>{"function"!=typeof requestAnimationFrame?e():requestAnimationFrame(()=>e())}),!Kt(e))return!1;kn(e,be);const o=Rn(),a=Hn(),l=a?qn():"";if(a&&l===r&&l){if(n+=1,n>=An()&&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(Ce===e&&(Ce=0),Kt(e))return t?void In(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)&&Rn()-Fe>=e}()?(!0===r.debug&&import.meta,void In(e)):(function(e){Pe!==e&&(Pe=e,!0===r.debug&&import.meta)}(e),void function(e){Kt(e)&&"undefined"!=typeof window&&(null!=Ke&&window.clearTimeout(Ke),Ke=window.setTimeout(()=>{Ke=null,Kt(e)&&Nn(e)},120))}(e))}))}function Cn(){ge.value=!0,Fe=-1,Ce=0,Pe=0,Re=!1,Ae=!1,null!=Ke&&"undefined"!=typeof window&&window.clearTimeout(Ke),Ke=null}function Pn(){je=!0}function _n(e){var t,n;const r=[];if(!function(e){var t,n;return!!e&&(null!=(t=e.measurementKey)?t:"")===Le.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=bt(o),l=null==(n=null==e?void 0:e.itemSizeSources)?void 0:n[o];kt(t,l)&&r.push([o,Math.ceil(a),l])}return r}function jn(e){var t;for(const[n,r]of Object.entries(null!=(t=null==e?void 0:e.markdownStates)?t:{}))if(St(bt(n),r))return!0;return!1}function In(e){if(e!==Me)return;nn();const t=new Set(ue);Tt(),kn(e,be),he.value=!1,Fe=-1,be=void 0,qe=null,He=0;for(const n of Je.value.records)n.markdown&&!t.has(n.key)||Yt(n.key);for(const n of t){const e=We.get(n);e?an(e,{allowMarkdownShrink:!0,allowRestoredFloorShrink:!0,markdownLogicalHeight:Bt(e.key),source:gt(e),updateLayout:!0}):Yt(n)}ue.clear(),tn(),zt({remember:!1}),Cn(),Pn()}function zn(e,t={}){var n;const o=++Me;Se=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)||_n(e).length>0||jn(e))}(e),i=jn(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=Je.value.records[0];return e?{type:"item",itemKey:e.key,offsetWithinItemPx:0}:void 0}():void 0;Tt(),Ce=0,Pe=0,ge.value=!s,he.value=s&&Boolean(c),He=o,be=c,Re=s&&i,Ae=s&&u,Fe=he.value?Rn():-1,On(),re.clear(),oe.clear(),ae.clear(),le.clear(),ie.clear(),ue.clear(),se.clear(),ce.clear(),de.clear();for(const[r,m,f]of _n(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=xt(r,m);e>0&&ie.set(r,e)}Qe(),!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=gn(c);return qe=null==d?null:Pt(d),null!=d&&Ot(d,{writeDom:!0,remember:!1,updatePinned:!1}),Ne=(null==e?void 0:e.threadKey)===Ie.value?e:null,s?c?void y(()=>{kn(o,c),"undefined"!=typeof window?(ke.forEach(e=>{const t=window.setTimeout(()=>{kn(o,c)},e);Be.push(t)}),Nn(o)):In(o)}):(he.value=!1,be=void 0,qe=null,He=0,zt({remember:!1}),Cn(),void Pn()):(he.value=!1,be=void 0,qe=null,He=0,zt({remember:!1}),Cn(),Pn(),void(!1!==r.stickToBottom&&(te.value=!0,ne.value=!0,y(()=>{he.value||Et()}))))}function On(){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;rn(),(null==(t=vn())?void 0:t.threadKey)!==e&&((null==Ne?void 0:Ne.threadKey)===e?(ve.set(e,Ne),a(Ne)):ve.has(e)||fn(e))}(n),ze=e,zn(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(()=>ot.value.records.map(e=>e.key).join("\0"),()=>{var e;e={start:ot.value.start,end:ot.value.end},o("range-change",e)},{immediate:!0}),g(()=>[r.items.length,Je.value.totalHeight],()=>{he.value||!1!==r.stickToBottom&&("auto"!==r.stickToBottom||ne.value)&&y(()=>{he.value||!1!==r.stickToBottom&&("auto"!==r.stickToBottom||ne.value)&&Et()})},{flush:"post"}),k(()=>{Ht(),It(),be?(kn(He,be),zt({remember:!1}),fn()):!1===r.stickToBottom?(zt({remember:!1}),fn()):(te.value=!0,Ot(Ct(),{writeDom:!0,remember:!1,updatePinned:!1}),zt({remember:!1}),fn()),Q.value&&"undefined"!=typeof ResizeObserver&&(we=new ResizeObserver(()=>{Ht(),zt()}),we.observe(Q.value))}),p(()=>{ge.value||Nn(He)}),b(()=>{vn()||fn(),Tt(),Se=null,null!=Te&&"undefined"!=typeof window&&window.clearTimeout(Te),Te=null,pe=void 0,en(Xt.raf),Xt.scheduled=!1,Xt.raf=null,Xt.anchor=void 0,en(Ut),Qt=!1,Ut=null,Jt.clear(),On(),oe.clear(),ae.clear(),le.clear(),ie.clear(),ue.clear(),ce.clear(),de.clear(),null==we||we.disconnect(),we=null}),t({captureThreadState:function(){return mn(Ie.value)},restoreThreadState:zn,scrollToBottom:Et,scrollToIndex:function(e,t="start"){const n=Je.value.records[e];if(!n)return;let r=qt()+Ue(n);"center"===t?r-=(Z.value-n.size)/2:"end"===t&&(r-=Z.value-n.size),Lt(r)},scrollToOffset:Lt,getItemSize:e=>{var t;const n=bt(e);return n&&null!=(t=pt(n))?t:void 0},getTotalHeight:()=>Je.value.totalHeight,getVisibleRange:()=>({start:ot.value.start,end:ot.value.end})}),(e,t)=>(w(),S("div",{ref_key:"scrollRoot",ref:Q,class:M(["markstream-virtual-timeline",{"is-restoring-thread":!ge.value}]),"data-markstream-virtual-timeline":"1","data-testid":"markstream-virtual-timeline",onScroll:$t},[x("div",{class:"markstream-virtual-timeline__spacer",style:B({height:`${ot.value.topSpacerHeight}px`}),"aria-hidden":"true"},null,4),(w(!0),S(K,null,T(ot.value.records,t=>(w(),S("div",{key:t.renderKey,class:M(["markstream-virtual-timeline__item",{"is-restored-height-floor":Tn(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},sn(t)),()=>{var e,n;return[t.markdown?(w(),q(R(_),H({key:0,ref_for:!0},un(t)),null,16)):ft(t)?(w(),q(A(ft(t)),{key:1,ref_for:!0,ref:ln(t),item:dt(t)},null,8,["item"])):(w(),S("div",{key:2,ref_for:!0,ref:ln(t),class:M(["markstream-virtual-timeline__default-item",`markstream-virtual-timeline__default-item--${t.kind||"item"}`])},["tool-call"===t.kind&&(null==(e=dt(t))?void 0:e.status)?(w(),S("span",G,N(null==(n=dt(t))?void 0:n.status),1)):C("",!0),P(" "+N(cn(t)),1)],2))]},!0)],14,Y))),128)),x("div",{class:"markstream-virtual-timeline__spacer",style:B({height:`${ot.value.bottomSpacerHeight}px`}),"aria-hidden":"true"},null,4),ge.value?C("",!0):(w(),S("div",{key:0,class:"markstream-virtual-timeline__restore-loading",style:B({height:`${Math.max(1,Ft())}px`,transform:`translateY(${U.value}px)`}),"aria-live":"polite","aria-busy":"true"},[F(e.$slots,"restore-loading",{threadKey:Ie.value,visibleRecords:ot.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-adb4b0ba"]]),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": "2.0.0
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"description": "Vue/Nuxt streaming Markdown renderer for AI chat, LLM token streams, SSE/WebSocket output, incomplete Markdown, long documents, Mermaid, KaTeX, and stream-diffs powered code blocks.",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|
|
@@ -137,8 +137,8 @@
|
|
|
137
137
|
"dependencies": {
|
|
138
138
|
"@chenglou/pretext": "^0.0.8",
|
|
139
139
|
"@floating-ui/dom": "^1.8.0",
|
|
140
|
-
"
|
|
141
|
-
"
|
|
140
|
+
"markstream-core": "2.0.0",
|
|
141
|
+
"stream-markdown-parser": "1.2.8"
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
144
|
"@antfu/eslint-config": "^5.4.1",
|
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
"lz-string": "^1.5.0",
|
|
162
162
|
"markdown-it-emoji": "^3.1.0",
|
|
163
163
|
"material-icon-theme": "^5.37.0",
|
|
164
|
+
"octane": "^0.1.21",
|
|
164
165
|
"picocolors": "^1.1.1",
|
|
165
166
|
"playwright-core": "^1.62.0",
|
|
166
167
|
"postcss-cli": "^11.0.1",
|