markstream-vue 2.0.2-beta.0 → 2.0.4

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.
@@ -1 +1 @@
1
- var e=Object.defineProperty,l=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(l,t,n)=>t in l?e(l,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[t]=n,i=(e,l)=>{for(var t in l||(l={}))o.call(l,t)&&a(e,t,l[t]);if(n)for(var t of n(l))r.call(l,t)&&a(e,t,l[t]);return e},u=(e,n)=>l(e,t(n)),d=(e,l,t)=>new Promise((n,o)=>{var r=e=>{try{i(t.next(e))}catch(l){o(l)}},a=e=>{try{i(t.throw(e))}catch(l){o(l)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);i((t=t.apply(e,l)).next())});import{defineComponent as s,computed as v,onMounted as c,onUnmounted as f,openBlock as m,createBlock as h,Teleport as p,createElementVNode as g,normalizeClass as y,withModifiers as b,toDisplayString as w,unref as k,useAttrs as x,inject as S,getCurrentInstance as C,ref as M,shallowRef as B,watch as P,onBeforeUnmount as H,nextTick as O,normalizeStyle as F,createSlots as N,withCtx as E,renderSlot as D,createElementBlock as $,createVNode as T,withDirectives as z,createCommentVNode as L,vShow as _}from"vue";import{ax as R,G as j,M as q,aj as I,az as A,aA as V,aw as W,aa as U,ah as G,b as Y,c as J,al as X,ag as K,a8 as Q,ad as Z,ak as ee,as as le,a7 as te}from"./exports.js";import{M as ne,f as oe,n as re,c as ae,l as ie}from"./index2.js";import{r as ue,_ as de,a as se}from"./PreCodeBlock.vue_vue_type_style_index_0_lang.js";import{safeRaf as ve,safeCancelRaf as ce}from"./utils/safeRaf.js";import{r as fe}from"./preCodeTheme.js";import{getStreamDiffsRuntime as me}from"./streamDiffs.js";const he={class:"html-preview-frame__header"},pe={class:"html-preview-frame__title"},ge={class:"html-preview-frame__label"},ye=["sandbox","srcdoc"],be=/* @__PURE__ */j(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const l=e,t=void 0!==import.meta&&Boolean(!1);let n=null;const{t:o}=R(),r=v(()=>{const e=l.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${l.isDark?"#020617":"#ffffff"};\n color: ${l.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),a=v(()=>{return e=l.htmlPreviewSandbox,o=l.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!t||"undefined"==typeof console||n===e)return;const l=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);l.has("allow-scripts")&&l.has("allow-same-origin")&&(n=e,console.warn("[markstream-vue] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))}(e),e):void 0!==e?"":!0===o?"allow-scripts":"";var e,o});function i(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=l.onClose)||t.call(l)}return c(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",i)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",i)}),(e,t)=>(m(),h(p,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:l.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:t[2]||(t[2]=e=>{var t;return null==(t=l.onClose)?void 0:t.call(l)})},[g("div",{class:"html-preview-frame",onClick:t[1]||(t[1]=b(()=>{},["stop"]))},[g("div",he,[g("div",pe,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",ge,w(l.title||k(o)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:t[0]||(t[0]=e=>{var t;return null==(t=l.onClose)?void 0:t.call(l)})}," × ")]),g("iframe",{class:"html-preview-frame__iframe",sandbox:a.value,referrerpolicy:"no-referrer",srcdoc:r.value},null,8,ye)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]),we=["data-markstream-enhanced","data-markstream-enhancement-state","data-markstream-code-block-state","data-markstream-pending","data-markstream-viewport-pending"],ke={class:"code-header-main"},xe=["innerHTML"],Se={class:"code-header-copy"},Ce={class:"code-header-title"},Me={key:0,class:"code-header-caption"},Be=["data-markstream-host-hidden"],Pe=/* @__PURE__ */j(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},codeBlockOptions:{},showLineNumbers:{type:Boolean,default:void 0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{},estimatedDiffInline:{type:Boolean}},emits:["previewCode","copy"],setup(e,{emit:l}){var t,n,o,r,a;const s=e,p=l,b=v(()=>{var e,l;return null!=(l=s.showLineNumbers)?l:!0!==(null==(e=s.codeBlockOptions)?void 0:e.disableLineNumbers)}),j=x(),he=S(ne,null),pe=S("markstreamHostScrollManaged",null),ge=S(q,void 0),ye=v(()=>I(s,j));function Pe(e,l){}const He=C(),Oe=v(()=>{const e=null==He?void 0:He.vnode.props;return!(!e||!e.onPreviewCode&&!e["onPreview-code"])}),{t:Fe}=R(),Ne=M(null),Ee=M(null),De=M(!1),$e=M(Kn(s.node.language,s.node.code,Xn())),Te=v(()=>oe($e.value)),ze=v(()=>"plaintext"===Te.value?"text":Te.value),Le=v(()=>"plaintext"===Te.value),_e=M(!1),Re=M(!1),je=M(!1),qe=M(!1),Ie=M(!1),Ae=M(!1);let Ve=!1,We=!1,Ue=null,Ge=null,Ye=null,Je=0,Xe=!1,Ke="";const Qe=M(null);let Ze=0,el=!1;const ll=A(),tl=V(),nl=W(),ol=B(null),rl=M("undefined"==typeof window||!nl.value),al=null!=(o=null==(n=null==(t=C())?void 0:t.vnode.el)?void 0:n.textContent)?o:"",il="undefined"!=typeof window&&String(null!=(r=s.node.code)?r:"").length>0&&al.includes(String(s.node.code)),ul=M(!il);c(()=>{ul.value=!0}),"undefined"!=typeof window&&P([()=>Ee.value,nl],([e,l],t,n)=>{var o,r,a;if(null==(o=ol.value)||o.destroy(),ol.value=null,!l||rl.value)return void(rl.value=!0);if(!e)return void(rl.value=!1);let i=!0;const u=null!=(a=null!=(r=null==tl?void 0:tl.value.heavyBlockMargin)?r:null==tl?void 0:tl.value.rootMargin)?a:"0px",d=ll(e,{rootMargin:u,allowIdle:!1});ol.value=d,rl.value=rl.value||d.isVisible.value,d.whenVisible.then(()=>{i&&ol.value===d&&(rl.value=!0)}).catch(()=>{}),n(()=>{i=!1,d.destroy(),ol.value===d&&(ol.value=null)})},{immediate:!0}),H(()=>{var e;Ve=!0,function(){const e=Ke;he&&e&&(Ke="",he.markSettled(e))}(),null==(e=ol.value)||e.destroy(),ol.value=null});let dl=null,sl=null,vl=()=>{},cl=()=>{},fl=()=>{},ml=()=>{},hl=()=>null,pl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),gl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),yl=()=>{},bl=()=>{},wl=()=>{},kl=null,xl=null,Sl=null,Cl=null,Ml=()=>{var e;return String(null!=(e=s.node.language)?e:"plaintext")},Bl=()=>d(null,null,function*(){}),Pl=!1,Hl=null;const Ol=[],Fl=[];let Nl=null,El=null;const Dl=v(()=>U(s.node)),$l=M({removed:0,added:0}),Tl=v(()=>`-${$l.value.removed} +${$l.value.added}`);function zl(e,l){return{original:e,updated:l}}function Ll(e){return String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"")}function _l(e){var l;return String(null!=(l=null==e?void 0:e.message)?l:e).includes("no diff result available")}function Rl(){if(!An())try{const e=wl();e&&"function"==typeof e.catch&&e.catch(e=>{_l(e)})}catch(e){_l(e)}}const jl=v(()=>{const e=i({},s.codeBlockOptions||{});for(const n of["theme","themes","themeType","language","languages","stream","disableFileHeader","onThemeChange","renderCustomHeader","renderHeaderMetadata","renderHeaderPrefix","maxHeight","padding","tabSize"])delete e[n];if(!Dl.value)return e;const l=e.parseDiffOptions&&"object"==typeof e.parseDiffOptions?e.parseDiffOptions:{},t={diffStyle:"split",expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:"line-info",parseDiffOptions:{context:2}};return u(i(i({},t),e),{parseDiffOptions:i(i({},t.parseDiffOptions),l)})}),ql=v(()=>{return(void 0!==s.theme?(e=s.theme)&&"object"==typeof e&&"light"in e&&"dark"in e:!xo(s.darkTheme,s.lightTheme))?!!s.isDark:function(e){var l;const t=null!=(l=ko(e))?l:"";return Z(t,!0===s.isDark)}(So());var e}),Il=v(()=>(Dl.value,ql.value?"dark":"light")),Al=v(()=>Dl.value?"dark"===Il.value:ql.value),Vl=v(()=>fe({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})),Wl=v(()=>Dl.value?"diff":"single"),Ul=M(Wl.value),Gl=M(!1),Yl=M(!1),Jl=M(!1),Xl=M(!1),Kl=M(null),Ql=M(0),Zl=M(0),et=M(!1);let lt=null,tt=!1,nt=null,ot=!1;const rt=v(()=>{var e;return!!Dl.value&&"unified"===(null==(e=jl.value)?void 0:e.diffStyle)}),at=v(()=>G(jl.value));function it(e){return!0===(null==pe?void 0:pe.value)||!!e&&(!!e.closest('[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline')||Boolean(e.closest(".vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]")))}const ut=v(()=>it(Ee.value)),dt=v(()=>!(Gl.value||!Xl.value&&Yl.value)),st=v(()=>dt.value),vt=v(()=>dt.value&&!Jl.value),ct=v(()=>!Gl.value&&!Xl.value&&dt.value),ft=v(()=>Yl.value&&!Gl.value?"ready":Xl.value?"fallback":"pending"),mt=M(!1),ht=v(()=>Ll(s.node.code)),pt=v(()=>Dl.value?!0===s.node.diff?s.node:u(i({},s.node),{diff:!0}):ht.value===s.node.code?s.node:u(i({},s.node),{code:ht.value}));function gt(e){const l=e.detectLanguage;"function"==typeof l&&(Ml=l),El=e,Nl=Bo();const t=e.createCodeBlockRuntime(Nl);return!!t&&(dl=t.createEditor||dl,sl=t.createDiffEditor||sl,vl=t.updateCode||vl,cl=t.updateDiff||cl,fl=t.finalizeCode||fl,ml=t.finalizeDiff||ml,hl=t.getEditor||hl,pl=t.getEditorView||pl,gl=t.getDiffEditorView||gl,yl=t.cleanupEditor||yl,bl=t.safeClean||t.cleanupEditor||bl,wl=t.refreshDiffPresentation||wl,Bl=t.setTheme||Bl,kl=t.whenVisualReady||null,Ae.value=!0,!0)}const yt=Y,bt=J,wt=M("number"==typeof(null==(a=s.codeBlockOptions)?void 0:a.fontSize)?s.codeBlockOptions.fontSize:Number.NaN),kt=M(wt.value),xt=M(null),St=M(null),Ct=M(null),Mt=M(null),Bt=v(()=>{const e=wt.value,l=kt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof l&&Number.isFinite(l)&&l>0}),Pt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l;const t=kt.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:yt}),Ht=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.lineHeight;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:Pt.value===yt?bt:Math.max(12,Math.round(1.5*Pt.value))}),Ot=v(()=>Ht.value),Ft=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.tabSize;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:4}),Nt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding,t="number"==typeof l&&Number.isFinite(l)&&l>=0?l:8;return{top:t,bottom:t}}),Et=v(()=>{const e=X(s.codeBlockOptions);return u(i({},e),{fontSize:Pt.value,lineHeight:Ot.value,maxHeight:Yn(),padding:Nt.value.top,paddingBottom:Nt.value.bottom,tabSize:Ft.value})}),Dt=v(()=>{const e=s.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function $t(e){if(null==e)return null;const l=Math.ceil(e);return!Number.isFinite(l)||l<=0?null:Math.min(l,Math.ceil(Yn()))}function Tt(){return!Dl.value&&!1!==s.stream&&!1!==s.loading}const zt=M(Tt());function Lt(){return Tt()||zt.value}const _t=v(()=>Dl.value?null:null==Dt.value||Lt()?Math.ceil((e=>{const l=String(null!=e?e:"");if(!l)return 1;let t=1;for(let n=0;n<l.length;n++)"\n"===l[n]?t++:"\r"===l[n]&&(t++,"\n"===l[n+1]&&n++);return t})(ht.value)*Ot.value+1):null),Rt=v(()=>{if(Dl.value)return null;const e=Dt.value;return null==e||Lt()?$t(_t.value):$t(e)}),jt=v(()=>{const e=s.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),qt=M(null);function It(){const e=qt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}const At=v(()=>{const e=It();return null!=e?e:!Dl.value&&et.value?null:dt.value||!Yl.value?Rt.value:null});function Vt(e){const l=e?"hsl(152 42% 60%)":"var(--diff-added-fg)",t=e?"hsl(0 58% 58%)":"var(--diff-removed-fg)",n=e?"color-mix(in lab, #121212 80%, #4d9375)":"color-mix(in lab, #ffffff 88%, #1e754f)",o=e?"color-mix(in lab, #121212 80%, #cb7676)":"color-mix(in lab, #ffffff 88%, #ab5959)";return{"--markstream-diff-line-number-bg":e?"hsl(0 0% 7% / 0.98)":"hsl(var(--ms-muted) / 0.45)","--markstream-diff-added-fg":l,"--markstream-diff-removed-fg":t,"--markstream-diff-added-line":n,"--markstream-diff-removed-line":o,"--markstream-diff-added-line-fill":n,"--markstream-diff-added-number-fill":e?"color-mix(in lab, #121212 85%, #4d9375)":"color-mix(in lab, #ffffff 91%, #1e754f)","--markstream-diff-removed-line-fill":o,"--markstream-diff-removed-number-fill":e?"color-mix(in lab, #121212 85%, #cb7676)":"color-mix(in lab, #ffffff 91%, #ab5959)","--markstream-diff-added-gutter":`linear-gradient(90deg, ${l} 0 4px, transparent 4px 100%)`,"--markstream-diff-removed-gutter":`linear-gradient(90deg, ${t} 0 4px, transparent 4px 100%)`,"--markstream-diff-added-inline":e?"hsl(152 42% 60% / 0.28)":"var(--diff-added-inline-bg)","--markstream-diff-removed-inline":e?"hsl(0 58% 58% / 0.28)":"var(--diff-removed-inline-bg)"}}const Wt=v(()=>{const e=$t(Dt.value),l=$t(_t.value),t=Lt(),n=i({},Dl.value||null==e||t?Dl.value||null==l?{}:{minHeight:`${l}px`}:{height:`${e}px`,minHeight:`${e}px`});if(n["--markstream-code-fallback-bg"]=Vl.value.background,n["--markstream-code-fallback-fg"]=Vl.value.foreground,Vl.value.builtin&&(n["--markstream-code-theme-bg"]=Vl.value.background,n["--markstream-code-theme-fg"]=Vl.value.foreground,n["--markstream-code-theme-line-number"]=Vl.value.lineNumber),n["--markstream-pre-line-number-top"]=`${Nt.value.top}px`,n["--markstream-pre-line-number-left"]="0px",n["--markstream-pre-line-number-padding-left"]="2ch",n["--markstream-pre-line-number-padding-right"]="1ch",n["--markstream-pre-line-number-separator-width"]="2px",Dl.value){n["--markstream-pre-diff-line-height"]=`${Ot.value}px`,n["--markstream-pre-diff-pane-bottom-padding"]=(rt.value,"0px");const e=Mt.value;null!=e&&e>0&&(n.height=`${e}px`,n.minHeight=`${e}px`,n.maxHeight=`${e}px`),Object.assign(n,Vt(Al.value))}return n}),Ut=v(()=>null!=At.value&&(!Yl.value||null!=It())),Gt=v(()=>{const e=At.value;if(null==e)return null;if(Dl.value)return Math.ceil(e);const l=jt.value,t=Dt.value;if(null==l||null==t)return Math.ceil(e);const n=Math.max(0,Math.ceil(l)-Math.ceil(t));return Math.ceil(e+n)}),Yt=v(()=>{if(Dl.value&&dt.value)return{};const e=At.value;return Ut.value&&null!=e?{minHeight:`${e}px`}:{}});function Jt(){qt.value=null}function Xt(){var e,l,t,n,o,r,a,i;const u=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback"),d=gl(),s=null!=(l=null==u?void 0:u.scrollTop)?l:0;null==(o=null==(n=null==(t=null==d?void 0:d.getOriginalEditor)?void 0:t.call(d))?void 0:n.setScrollTop)||o.call(n,s),null==(i=null==(a=null==(r=null==d?void 0:d.getModifiedEditor)?void 0:r.call(d))?void 0:a.setScrollTop)||i.call(a,s)}function Kt(){return d(this,null,function*(){return Dl.value?(xn(),en(),Dn(!0),Xt(),$n(),Jl.value=!0,yield O(),Dn(!0),yield tn(),Dn(!0),wn(),en(),!!(yield function(){return d(this,null,function*(){var e;if(!Dl.value)return!0;for(let l=0;l<4;l++){const l=en();Dn(!0),Qt(l),Zt(l),yield O(),yield tn();const t=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!t)return!1;if(null==l)return jn();const n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-l)<=2)return!0}return!1})}())&&(Yl.value=!0,yield O(),en(),Dn(!0),wn(),$n(),ve(()=>{Ve||ve(()=>{Ve||(function(){var e,l;const t=null==(e=Ee.value)?void 0:e.querySelector(".code-block-shell-content"),n=null==(l=Ee.value)?void 0:l.querySelector(".code-editor-layer");t&&n&&(n.style.removeProperty("height"),n.style.removeProperty("min-height"),t.style.removeProperty("height"),t.style.removeProperty("min-height"))}(),Tn(!0))})}),Tn(),!0)):!(kl&&!(yield kl())||(xn(),Dn(!0),Jl.value=!0,yield O(),xn(),Dn(!0),yield tn(),xn(),Dn(!0),Yl.value=!0,yield O(),Tn(),0))})}function Qt(e){var l;if(!Dl.value)return;const t=Ne.value,n=null==(l=Ee.value)?void 0:l.querySelector("pre.code-pre-fallback");if(!t||!n)return;const o=null!=e?e:Number.parseFloat(t.style.height||"");if(!Number.isFinite(o)||o<=0)return;const r=Math.ceil(o),a=`${r}px`;Mt.value=r;const i=Ee.value;i&&(i.dataset.markstreamDiffHandoffHeight=a),n.dataset.markstreamDiffHandoffHeight=a,n.style.setProperty("height",a),n.style.setProperty("min-height",a)}function Zt(e){var l,t,n;if(!Dl.value)return;const o=null==(l=Ee.value)?void 0:l.querySelector(".code-block-shell-content"),r=null==(t=Ee.value)?void 0:t.querySelector(".code-editor-layer");if(!o||!r)return;const a="number"==typeof e&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat((null==(n=Ne.value)?void 0:n.style.height)||"");if(!Number.isFinite(a)||a<=0)return;const i=`${a}px`;r.style.height=i,r.style.minHeight=i,o.style.height=i,o.style.minHeight=i}function en(){const e=Ne.value;if(e&&jn(e)){$n();const l=yn(e);if(null!=l&&l>0){const t=Math.ceil(l),n=Math.ceil(Yn()),o=Math.min(t,n),r=`${o}px`;return e.style.height=r,e.style.minHeight="0px",e.style.maxHeight=`${n}px`,e.style.overflow=t>n+1?"auto":"hidden",dt.value&&(Mt.value=o,Qt(o)),zn(),o}return Nn({preferModelDiffHeight:!0}),Qt(),zn(),Number.parseFloat(e.style.height||"")||null}return xn()}function ln(e,l=!1,t={}){const n=Math.ceil(e),o=It();if(null==o)return n;const r=!0===t.allowBelowEstimatedFloor;return n>=o||r?((l||r)&&Ie.value&&Jt(),n):o}function tn(){return new Promise(e=>{let l=!1,t=null,n=null;const o=()=>{l||(l=!0,null!=n&&globalThis.clearTimeout(n),null!=t&&ce(t),e())};n=globalThis.setTimeout(o,50),t=ve(o)})}function nn(){var e;try{const l=Ne.value;if(!l)return null;const t=null!=(e=l.querySelector(".stream-diffs-shell .stream-diffs-surface"))?e:l.querySelector(".stream-diffs-shell");if(t){const e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch(l){}return null}function on(){var e,l,t,n,o,r;try{const r=Dl.value?null!=(t=null==(l=null==(e=gl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:gl():pl(),a=hl(),i=null==(n=null==a?void 0:a.EditorOption)?void 0:n.fontInfo;if(r&&null!=i){const e=null==(o=r.getOption)?void 0:o.call(r,i),l=null==e?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(a){}try{const e=Ne.value;if(e){const l=null!=(r=e.querySelector(".stream-diffs-shell .stream-diffs-surface"))?r:e.querySelector(".stream-diffs-shell");if(l)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(l).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(a){}}}catch(a){}return null}function rn(e){var l,t;try{const n=hl(),o=null==(l=null==n?void 0:n.EditorOption)?void 0:l.lineHeight;if(null!=o){const l=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof l&&l>0)return l}}catch(r){}const n=nn();if(n&&n>0)return n;const o=Number.isFinite(kt.value)&&kt.value>0?kt.value:14;return Math.max(12,Math.round(1.35*o))}function an(){var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding;return"number"==typeof l&&Number.isFinite(l)?2*Math.max(0,l):Dl.value?24:0}function un(e){const l=Ll(e);return l?l.split(/\r\n|\n|\r/):[]}function dn(e){return!!Le.value||!!e&&(An(e)||null!=kl)}function sn(){var e,l;Dl.value?$l.value=function(e,l){const t=un(e),n=un(l);let o=0,r=t.length-1,a=n.length-1;for(;o<=r&&o<=a&&t[o]===n[o];)o++;for(;r>=o&&a>=o&&t[r]===n[a];)r--,a--;const i=Math.max(0,r-o+1),u=Math.max(0,a-o+1);if(0===i||0===u)return{removed:i,added:u};if((i+1)*(u+1)<=15e5){const e=u+1;let l=new Uint32Array(e),r=new Uint32Array(e);for(let d=i-1;d>=0;d--){r[u]=0;for(let a=u-1;a>=0;a--)r[a]=t[o+d]===n[o+a]?l[a+1]+1:Math.max(l[a],r[a+1]);const e=l;l=r,r=e}const a=l[0];return{removed:i-a,added:u-a}}return{removed:i,added:u}}(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:"")):$l.value={removed:0,added:0}}function vn(){sn()}function cn(){var e;if(Number.isFinite(kt.value)&&kt.value>0&&Number.isFinite(wt.value))return kt.value;if("number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize))return wt.value=s.codeBlockOptions.fontSize,kt.value=s.codeBlockOptions.fontSize,s.codeBlockOptions.fontSize;const l=on();return l&&l>0?(wt.value=l,kt.value=l,l):(wt.value=12,kt.value=12,12)}function fn(){const e=cn(),l=Math.min(36,e+1);kt.value=l}function mn(){const e=cn(),l=Math.max(10,e-1);kt.value=l}function hn(){cn(),Number.isFinite(wt.value)&&(kt.value=wt.value)}function pn(){var e,l,t,n,o,r,a,i,u,d,s,v,c,f;try{const m=Dl.value?gl():null,h=Dl.value?m:pl();if(!h)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const c=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(l=m.getModifiedEditor)?void 0:l.call(m);null==(t=null==c?void 0:c.layout)||t.call(c),null==(n=null==f?void 0:f.layout)||n.call(f);const h=(null==(o=null==c?void 0:c.getContentHeight)?void 0:o.call(c))||0,p=(null==(r=null==f?void 0:f.getContentHeight)?void 0:r.call(f))||0,g=Math.max(h,p);if(g>0)return Math.ceil(g);const y=(null==(u=null==(i=null==(a=null==c?void 0:c.getModel)?void 0:a.call(c))?void 0:i.getLineCount)?void 0:u.call(i))||1,b=(null==(v=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:v.call(s))||1,w=Math.max(y,b),k=Math.max(rn(c),rn(f)),x=an();return Math.ceil(w*k+x+0)}if(null==h?void 0:h.getContentHeight){null==(c=null==h?void 0:h.layout)||c.call(h);const e=h.getContentHeight();if(e>0)return Dl.value||(et.value=!0),Math.ceil(e)}const p=null==(f=null==h?void 0:h.getModel)?void 0:f.call(h);let g=1;p&&"function"==typeof p.getLineCount&&(g=p.getLineCount());const y=rn(h);return Math.ceil(g*(y+1.5)+0)}catch(m){return null}}function gn(){var e,l;if(Dl.value)return!1;try{const t=null==(l=null==(e=pl())?void 0:e.getContentHeight)?void 0:l.call(e),n="number"==typeof t&&Number.isFinite(t)&&t>0;return n&&(et.value=!0),n}catch(t){return!1}}function yn(e){if("undefined"==typeof window)return null;try{if("none"===window.getComputedStyle(e).display)return null;const l=e.querySelector("diffs-container");if(l instanceof HTMLElement){const e=l.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}const t=e.querySelector(".stream-diffs-shell");if(t){const e=t.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}return null}catch(l){return null}}function bn(e){var l;const t=String(null!=e?e:"").trim(),n=null==(l=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:l[1];if(n){const e=3===n.length?n.split("").map(e=>`${e}${e}`).join(""):n;return.2126*Number.parseInt(e.slice(0,2),16)+.7152*Number.parseInt(e.slice(2,4),16)+.0722*Number.parseInt(e.slice(4,6),16)}const o=t.match(/\d+(?:\.\d+)?/g);if(!o||o.length<3)return null;const[r,a,i]=o.slice(0,3).map(Number);return.2126*r+.7152*a+.0722*i}function wn(){var e,l,t;if(kn())return;const n=on();n&&n>0&&(xt.value=n,kt.value=n,wt.value=n);try{const n=rn(Dl.value?null!=(t=null==(l=null==(e=gl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:gl():pl());n&&n>0&&(St.value=n)}catch(o){}try{const e=nn();e&&e>0&&(St.value=e)}catch(o){}}function kn(){return Dl.value&&st.value}function xn(){var e;if(!dt.value)return null;const l=Ne.value,t=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l||!t)return null;const n=Math.ceil(t.getBoundingClientRect().height),o=Dl.value?yn(l):null,r=Math.max(n,null!=o&&o>0?Math.ceil(o):0),a=Math.ceil(Yn()),i=Math.min(r,a);return!Number.isFinite(i)||i<=0?null:(Dl.value&&i>n&&(Mt.value=i),l.style.height=`${i}px`,l.style.minHeight=`${i}px`,l.style.maxHeight=`${a}px`,l.style.overflow=r>a+1?"auto":"hidden",i)}function Sn(){var e,l,t,n,o,r,a,i,u;const d=Ne.value,v=Ee.value;if(!d||!v)return;const c=d;c.style.setProperty("--markstream-diff-metadata-bg",Vl.value.background),c.style.setProperty("--markstream-diff-metadata-fg",Vl.value.lineNumber),c.style.setProperty("--diffs-tab-size",String(Ft.value)),c.style.setProperty("--diffs-scrollbar-gutter-override","0px"),"number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.padding)?c.style.setProperty("--diffs-gap-block",`${Nt.value.top}px`):c.style.removeProperty("--diffs-gap-block");const f=d.querySelector(".stream-diffs-shell")||d,m=f,h=f;let p=null,g=null,y=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(f),g=m===f?p:window.getComputedStyle(m),y=h===f?p:window.getComputedStyle(h))}catch(M){p=null,g=null,y=null}const b=String(null!=(l=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?l:"").trim(),w=String(null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?t:"").trim(),k=String(null!=(o=null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?n:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?o:"").trim(),x=b||String(null!=(a=null!=(r=null==y?void 0:y.color)?r:null==p?void 0:p.color)?a:"").trim(),S=w||String(null!=(u=null!=(i=null==g?void 0:g.backgroundColor)?i:null==p?void 0:p.backgroundColor)?u:"").trim(),C=function(){var e,l,t,n,o;try{const r=Dl.value?null!=(t=null==(l=null==(e=gl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:gl():pl(),a=hl(),i=null==(n=null==a?void 0:a.EditorOption)?void 0:n.fontInfo;if(r&&null!=i){const e=null==(o=r.getOption)?void 0:o.call(r,i),l=null==e?void 0:e.typicalHalfwidthCharacterWidth;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(M){}return null}();if(null!=C&&(Ct.value=C),Dl.value){const e=(e,l)=>{l?(v.style.setProperty(e,l),c.style.setProperty(e,l)):(v.style.removeProperty(e),c.style.removeProperty(e))};for(const[l,t]of Object.entries(Vt(v.classList.contains("is-dark"))))e(l,t);return x?(v.style.setProperty("--markstream-diff-editor-fg",x),c.style.setProperty("--vscode-editor-foreground",x)):(v.style.removeProperty("--markstream-diff-editor-fg"),c.style.removeProperty("--vscode-editor-foreground")),S?(v.style.setProperty("--markstream-diff-editor-bg",S),v.style.setProperty("--markstream-diff-panel-bg",S),v.style.setProperty("--markstream-diff-panel-bg-soft",S),v.style.setProperty("--markstream-diff-panel-bg-strong",S),c.style.setProperty("--vscode-editor-background",S),c.style.backgroundColor=S):(v.style.removeProperty("--markstream-diff-editor-bg"),v.style.removeProperty("--markstream-diff-panel-bg"),v.style.removeProperty("--markstream-diff-panel-bg-soft"),v.style.removeProperty("--markstream-diff-panel-bg-strong"),c.style.removeProperty("--vscode-editor-background"),c.style.backgroundColor=""),void(k?c.style.setProperty("--vscode-editor-selectionBackground",k):c.style.removeProperty("--vscode-editor-selectionBackground"))}if(function(e,l,t){if(!Le.value)return!1;const n=bn(e),o=bn(l);return t?null!=n&&n>170||null!=o&&o<110:null!=n&&n<85||null!=o&&o>190}(S,x,v.classList.contains("is-dark")))return c.style.removeProperty("--vscode-editor-foreground"),c.style.removeProperty("--vscode-editor-background"),void c.style.removeProperty("--vscode-editor-selectionBackground");x&&c.style.setProperty("--vscode-editor-foreground",x),S&&c.style.setProperty("--vscode-editor-background",S),k&&c.style.setProperty("--vscode-editor-selectionBackground",k)}P(()=>[s.stream,s.loading,s.node.loading,Dl.value],([e,l,t,n])=>{n||!1===e||!1===l||zt.value?(n||!1===e)&&zt.value&&(zt.value=!1):(zt.value=!0,Jt())},{immediate:!0});let Cn=0,Mn=0;const Bn=/auto|scroll|overlay/i;function Pn(e,l,t){var n;if("undefined"==typeof window)return;if(Dl.value)return;if(function(e){return ut.value||it(e)}(e))return;const o=Math.ceil(l),r=Math.ceil(t)-o;if(Math.abs(r)<=1)return;const a=function(e){var l,t;if("undefined"==typeof window)return null;const n=null!=(l=null==e?void 0:e.ownerDocument)?l:document,o=n.scrollingElement||n.documentElement||n.body;let r=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;r&&r!==n.body&&r!==o;){const e=window.getComputedStyle(r),l=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(Bn.test(l)||Bn.test(t))return r;r=r.parentElement}return o}(e);if(!a)return;const i=null!=(n=e.ownerDocument)?n:document,u=a===i.body||a===i.documentElement||a===i.scrollingElement,d=u?0:a.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,r):a.scrollTop+=r)}function Hn(){try{const e=Ne.value;if(!e)return;const l=e.getBoundingClientRect().height,t=pn();if(null!=t&&t>0){const n=ln(t,!0,{allowBelowEstimatedFloor:!Dl.value&&Ie.value&&gn()}),o=It();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",void Pn(e,l,n)}const n=It();null!=n&&(e.style.minHeight=`${n}px`,e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",Pn(e,l,n))}catch(e){}}function On(){for(var e,l;Ol.length>0;)try{null==(l=null==(e=Ol.pop())?void 0:e.dispose)||l.call(e)}catch(t){}null!=Ue&&(ce(Ue),Ue=null),null!=Ge&&(ce(Ge),Ge=null),null!=Ye&&(ce(Ye),Ye=null),Je=0,Xe=!1}function Fn(){for(var e;Fl.length>0;)try{null==(e=Fl.pop())||e()}catch(l){}}function Nn(e=!1){Re.value||(_e.value?Hn():function(e={}){var l;try{const t=Ne.value;if(!t)return;const n=t.getBoundingClientRect().height,o=Yn(),r=Math.ceil((null==(l=t.getBoundingClientRect)?void 0:l.call(t).height)||0),a=Number.parseFloat(t.style.height||""),i=r>0?r:Number.isFinite(a)&&a>0?Math.ceil(a):0,u=Dl.value?function(){var e,l,t,n,o,r,a,i,u,d,s,v;if(An())return null;try{const c=gl(),f=null==(e=null==c?void 0:c.getOriginalEditor)?void 0:e.call(c),m=null==(l=null==c?void 0:c.getModifiedEditor)?void 0:l.call(c);if(!f||!m)return null;const h=(null==(o=null==(n=null==(t=f.getModel)?void 0:t.call(f))?void 0:n.getLineCount)?void 0:o.call(n))||1,p=(null==(i=null==(a=null==(r=m.getModel)?void 0:r.call(m))?void 0:a.getLineCount)?void 0:i.call(a))||1,g=Math.max(h,p),y=Math.max(rn(f),rn(m)),b=an(),w=Math.max(null!=(d=null==(u=f.getContentHeight)?void 0:u.call(f))?d:0,null!=(v=null==(s=m.getContentHeight)?void 0:s.call(m))?v:0);return Math.ceil(Math.max(w,g*y+b+0))}catch(c){return null}}():null,d=Dl.value&&jn(t);if(Ze>0&&(Ze--,null!=Qe.value))return void Pn(t,n,Ln(t,Qe.value,o,{preserveScrollableOverflow:Rn(t)}));if(Dl.value&&!d&&dt.value){const e=xn();if(null!=e){const l=Ln(t,e,o,{allowBelowEstimatedFloor:!0});return Dn(!0),void Pn(t,n,l)}}const v=Dl.value&&!0===e.preferModelDiffHeight,c=Dl.value?yn(t):null,f=!Dl.value&&Ie.value&&gn(),m=Dl.value&&!1!==s.loading&&(null!=c||null!=u&&r>0&&u<r-1),h=null!=u;let p;if(Dl.value)if(v){const e=null!=u&&!1===s.loading&&i>0&&u<i-1;p=!1===s.loading&&null!=c?null==u?c:Math.max(c,u):e?u:null!=c&&null!=u?Math.max(c,u,!1!==s.loading?i:0):Math.max(null!=c?c:0,null!=u?u:0,!1!==s.loading?i:0)||null}else p=rt.value&&null!=c||null!=c?h?Math.max(c,u):c:Dl.value&&!1!==s.loading?null!=u&&i>0&&u<i-1?u:i>0?i:null:u;else p=pn();if(Dl.value&&null!=p&&i>0&&(!1!==s.loading||!0===e.holdCurrentDiffHeight)&&(p=Math.max(p,i)),null!=p&&p>0)return void Pn(t,n,Ln(t,p,o,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||m,preserveScrollableOverflow:Rn(t)}));if(null!=Qe.value)return void Pn(t,n,Ln(t,Qe.value,o,{preserveScrollableOverflow:Rn(t)}));const g=Dl.value&&!1!==s.loading?r:Math.max(r,null!=u&&u>0?u:0);if(g>0)return void Pn(t,n,Ln(t,g,o));const y=It();if(!(null==y||Dl.value&&!1!==s.loading&&d))return void Pn(t,n,Ln(t,y,o));const b=Number.parseFloat(t.style.height);!Number.isNaN(b)&&b>0?Pn(t,n,Ln(t,b,o)):Dl.value||Pn(t,n,Ln(t,o,o))}catch(t){}}("object"==typeof e?e:{}))}function En(){Cn=0,Mn=0}function Dn(e=!1){var l,t,n;if(Re.value)return;const o=Ne.value;if(!o)return;const r=Dl.value?gl():pl();if(r&&"function"==typeof r.layout)try{const a=null==(l=o.getBoundingClientRect)?void 0:l.call(o),i=Math.ceil((null!=(t=null==a?void 0:a.width)?t:0)||o.clientWidth||0),u=Math.ceil((null!=(n=null==a?void 0:a.height)?n:0)||o.clientHeight||Number.parseFloat(o.style.height||"")||0);if(i>0&&u>0){if(!e&&i===Cn&&u===Mn)return;Cn=i,Mn=u,r.layout({width:i,height:u})}else En(),r.layout()}catch(a){}}function $n(){Fn()}function Tn(e=!1){if(Ve||null!=Ue)return;const l=()=>{Ve||($n(),Nn(e),Dn())};Ue=ve(()=>{Ue=null,l(),Ge=ve(()=>{Ge=null,l()})}),zn()}function zn(e=!1){if(!Dl.value||Ve||!e&&!1===s.loading)return;if(Xe=Xe||e,Je=Math.max(Je,e?18:6),null!=Ye)return;const l=()=>{if(Ye=null,!Dl.value||Ve||Je<=0||!Xe&&!1===s.loading)return Je=0,void(Xe=!1);Je--,$n(),Nn({preferModelDiffHeight:!0,holdCurrentDiffHeight:Xe}),Dn(),Je>0?Ye=ve(l):Xe=!1};Ye=ve(l)}function Ln(e,l,t,n={}){const o=Dl.value&&!1!==s.loading?yn(e):null,r=null!=o&&o>l+1?o:l,a=Math.min(r,t),i=!0===n.allowBelowEstimatedFloor,u=ln(a,!0===n.clearEstimatedFloor,{allowBelowEstimatedFloor:i}),d=It();e.style.minHeight=null==d||i?"0px":`${Math.min(d,Math.ceil(t))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(t)}px`;const v=!0===n.preserveScrollableOverflow||r>t+1||_n(e,u);return e.style.overflow=v?"auto":"hidden",u}function _n(e,l=0){var t;const n=Math.ceil((null==(t=e.getBoundingClientRect)?void 0:t.call(e).height)||0),o=Math.max(l,e.clientHeight||0,n);return o>0&&e.scrollHeight>o+1}function Rn(e){var l;return el||_n(e,null!=(l=Qe.value)?l:0)}function jn(e=Ne.value){return An(e)}function qn(e=Ne.value){return An(e)}function In(){var e,l;if(An())return!0;const t=null==(l=null==(e=pl())?void 0:e.getModel)?void 0:l.call(e);return"function"==typeof(null==t?void 0:t.getValue)&&t.getValue()===ht.value}function An(e=Ne.value){return Boolean(null==e?void 0:e.querySelector("diffs-container"))}function Vn(){return!1!==s.loading||Yl.value}function Wn(){const e=gl();return Boolean("function"==typeof(null==e?void 0:e.getOriginalEditor)||"function"==typeof(null==e?void 0:e.getModifiedEditor)||"function"==typeof(null==e?void 0:e.getLineChanges))}function Un(){return d(this,null,function*(){if(!Dl.value)return!0;for(let e=0;e<30;e++){if(Ve)return!1;if(An())return yield O(),yield tn(),!Ve&&An();yield O(),yield tn()}return!1})}function Gn(e,l,t){return d(this,null,function*(){try{return void(yield cl(e,l,t))}catch(n){if(!_l(n))throw n}if(yield O(),yield tn(),!Ve&&Dl.value)try{yield cl(e,l,t)}catch(n){if(!_l(n))throw n}})}function Yn(){var e,l;return null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500}const Jn=v(()=>s.isShowPreview&&("html"===$e.value||"svg"===$e.value));function Xn(){return"boolean"==typeof s.node.loading?s.node.loading:!0===s.loading}function Kn(e,l,t){return!t||function(){var e,l,t;if(!Xn())return!0;const n=String(null!=(e=s.node.raw)?e:""),o=null!=(t=null==(l=n.split(/\r\n|\n|\r/,1)[0])?void 0:l.trimStart())?t:"";return!/^(?:`{3,}|~{3,})/.test(o)||/\r\n|\n|\r/.test(n)}()&&String(null!=l?l:"")?re(String(null!=e?e:"")):"plain"}function Qn(){return Xn()}let Zn=null,eo=!1,lo=0;function to(){Zn=null,lo++}function no(){return d(this,arguments,function*(e=lo){if(!eo){eo=!0;try{for(;Zn&&!Ve&&!Dl.value&&e===lo;){const e=Zn;Zn=null;try{yield Promise.resolve(vl(e.code,e.language)),yield O(),Ve||Dl.value||(Nn(!1),Dn())}catch(l){Pe()}}}finally{eo=!1,!Zn||Ve||Dl.value||no()}}})}function oo(e,l){Zn={code:e,language:l},no(lo)}P(()=>[s.node.language,s.node.code,s.node.raw,s.node.loading,s.loading],([e,l,t,n,o])=>{$e.value=Kn(e,l,"boolean"==typeof n?n:!0===o)}),P(()=>[s.node.originalCode,s.node.updatedCode,Dl.value],()=>{sn(),ve(()=>vn())},{immediate:!0});let ro=0;P(()=>[s.node.originalCode,s.node.updatedCode,ze.value,Dl.value,s.stream],e=>d(null,[e],function*([,,,e,l]){var t,n;const o=++ro;if(!e)return;if(Xn())return;if(!1===l&&!je.value)return;if(!1!==l&&dl&&!je.value&&Ne.value)try{yield yo(Ne.value)}catch(u){}const r=Sl;if(r&&!qe.value){try{yield r}catch(u){}if(Ve||!Dl.value||o!==ro)return}if(o!==ro)return;const a=zl(String(null!=(t=s.node.originalCode)?t:""),String(null!=(n=s.node.updatedCode)?n:"")),i=!1===s.loading;i&&Po();try{if(yield Gn(a.original,a.updated,ze.value),Ve||!Dl.value||o!==ro)return;yield O(),Dn(!0),$n(),Nn(!1===s.loading||{preferModelDiffHeight:!0}),Dn(!0),Tn(!0)}catch(d){return}if(i){if(Ve||!Dl.value)return;Rl(),$n(),vn(),Tn(),zn(!0)}_e.value&&ve(()=>Hn())})),P(()=>s.node.code,e=>d(null,null,function*(){if(Xn())return;if(!1===s.stream)return;if($e.value||($e.value=re(Ml(e))),Dl.value)return;const l=Sl;if(l&&!qe.value){try{yield l}catch(t){}if(Ve||Dl.value)return}if(dl&&!je.value&&Ne.value)try{yield yo(Ne.value)}catch(t){}oo(Ll(s.node.code),ze.value),_e.value&&ve(()=>Hn())}));const ao=v(()=>{const e=$e.value;return e?ae[e]||e.charAt(0).toUpperCase()+e.slice(1):ae[""]||"Plain Text"}),io=v(()=>{var e;return K(String(null!=(e=s.node.raw)?e:""),ao.value,Dl.value)}),uo=v(()=>io.value.title),so=v(()=>io.value.caption),vo=v(()=>(ie.value,ue($e.value||"",ge))),co=v(()=>{const e={};e["--markstream-code-layout-character-width"]=null==Ct.value?"1ch":`${Ct.value}px`,e["--markstream-code-fallback-bg"]=Vl.value.background,e["--markstream-code-fallback-fg"]=Vl.value.foreground,Vl.value.builtin&&(e["--markstream-code-theme-bg"]=Vl.value.background,e["--markstream-code-theme-fg"]=Vl.value.foreground,e["--markstream-code-theme-line-number"]=Vl.value.lineNumber),e["--markstream-diff-added-line-fill"]=Vl.value.diffAddedLine,e["--markstream-diff-added-number-fill"]=Vl.value.diffAddedNumber,e["--markstream-diff-editor-bg"]=Vl.value.background,e["--markstream-diff-removed-line-fill"]=Vl.value.diffRemovedLine,e["--markstream-diff-removed-number-fill"]=Vl.value.diffRemovedNumber,e["--markstream-diff-shell-bg"]=Vl.value.background,e["--markstream-pre-resolved-theme-bg"]=Vl.value.background,e["--markstream-pre-resolved-theme-fg"]=Vl.value.foreground,e["--markstream-pre-resolved-theme-line-number"]=Vl.value.lineNumber;const l=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=l(s.minWidth),n=l(s.maxWidth);if(t&&(e.minWidth=t),n&&(e.maxWidth=n),Ut.value&&!Dl.value&&!Re.value){const l=Gt.value;null!=l&&(e.minHeight=`${l}px`)}return e.color="var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))",e.backgroundColor="var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))",Dl.value||(e.borderColor="var(--markstream-code-border-color, var(--code-border))"),e}),fo=v(()=>!1!==s.showTooltips);function mo(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(s.node.code)),De.value=!0,p("copy",s.node.code),setTimeout(()=>{De.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function ho(){_e.value=!_e.value;const e=Dl.value?gl():pl(),l=Ne.value;e&&l&&(_e.value?(l.style.maxHeight="none",l.style.overflow="visible",Nn(!0)):(l.style.overflow="auto",Nn(!0)))}function po(){var e,l;if(Re.value=!Re.value,Re.value){if(el=!1,Ne.value){const t=Math.ceil((null==(l=(e=Ne.value).getBoundingClientRect)?void 0:l.call(e).height)||0);el=_n(Ne.value,t)||"auto"===Ne.value.style.overflow||"auto"===Ne.value.style.overflowY,t>0&&(Qe.value=t)}}else Ne.value&&null!=Qe.value&&(Ne.value.style.height=`${Qe.value}px`),Ze=2,O(()=>{Re.value||Ve||(Nn(!0),Dn(!0))})}function go(){if(!Jn.value)return;const e=$e.value;if(Oe.value){const l="html"===e?"text/html":"image/svg+xml",t="html"===e?Fe("artifacts.htmlPreviewTitle")||"HTML Preview":Fe("artifacts.svgPreviewTitle")||"SVG Preview";return void p("previewCode",{node:s.node,artifactType:l,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(mt.value=!mt.value)}function yo(e,l={}){if(!dl||Ve)return null;if(!1===s.stream&&!1!==s.loading)return null;if(Do(),$o())return null;if(Gl.value||Ne.value!==e)return null;if(Qn())return null;if(xl)return xl;if(je.value&&Ie.value)return Promise.resolve();const t=No(),n=Ql.value;let o=!1;je.value=!0,function(){const e=ye.value;he&&e&&Ke!==e&&(Ke&&he.markSettled(Ke),Ke=e,he.markPending(e))}();const r=d(null,null,function*(){try{yield function(e){return d(this,null,function*(){var l,t;if(!dl||Ve)return;We=!1;const n=Wl.value;if(ot=!1,Xl.value=!1,Kl.value=null,qe.value=!1,Yl.value=!1,Jl.value=!1,xt.value=null,St.value=null,Ct.value=null,Mt.value=null,En(),function(){if(et.value=!1,Lt())return void(qt.value=null);const e=Rt.value;qt.value=Ie.value||null==e?null:e}(),On(),Fn(),function(e){e.replaceChildren()}(e),Po(),yield le(Mo()),Ve)return;const o=d(null,null,function*(){var l,t;if("diff"===n){!function(){if(Pl||"undefined"==typeof window)return;Pl=!0;const e=e=>{var l;_l("reason"in e?e.reason:null!=(l=e.error)?l:e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener("error",e,!0),window.addEventListener("unhandledrejection",e,!0),Hl=()=>{window.removeEventListener("error",e,!0),window.removeEventListener("unhandledrejection",e,!0),Pl=!1,Hl=null}}(),bl();const n=zl(String(null!=(l=s.node.originalCode)?l:""),String(null!=(t=s.node.updatedCode)?t:""));sl?yield sl(e,n.original,n.updated,ze.value):yield dl(e,s.node.code,ze.value)}else yield dl(e,ht.value,ze.value);qe.value=!0}),r=o.finally(()=>{Sl===r&&(Sl=null)});if(Sl=r,yield function(e){return d(this,null,function*(){if(!Dl.value)return void(yield e);let l,t=!1;for(e.then(()=>{t=!0},e=>{t=!0,l=e});;){if(Ve)return;if(t){if(l)throw l;return}if(jn()&&Wn())return;yield O(),yield tn()}})}(r),Ve)return;if(Wl.value!==n)return;qe.value=!0;const a=null==(l=s.codeBlockOptions)?void 0:l.fontSize;if("number"==typeof a&&Number.isFinite(a)&&a>0){const e="diff"===n?gl():pl();null==(t=null==e?void 0:e.updateOptions)||t.call(e,{fontSize:a}),wt.value=a,kt.value=a}else if(!kn()){const e=on();e&&e>0?(wt.value=e,kt.value=e):(wt.value=12,kt.value=12)}for(wn();We;)if(We=!1,yield Co(),Ve)return;_e.value||Re.value||Nn(!1),Ie.value=!0,Ul.value=n,function(){var e,l,t,n,o;if(On(),Dl.value){const n=gl(),o=null==(e=null==n?void 0:n.getOriginalEditor)?void 0:e.call(n),r=null==(l=null==n?void 0:n.getModifiedEditor)?void 0:l.call(n),i=(e,l)=>{try{const t=null==e?void 0:e[l];if("function"!=typeof t)return;const n=t.call(e,()=>Tn());n&&Ol.push(n)}catch(t){}};try{const e=null==(t=null==n?void 0:n.onDidUpdateDiff)?void 0:t.call(n,()=>{Tn(),ve(()=>vn())});e&&Ol.push(e)}catch(a){}i(o,"onDidContentSizeChange"),i(r,"onDidContentSizeChange");const u=Ne.value;if(u&&"undefined"!=typeof MutationObserver){const e=["diffs-container",".stream-diffs-shell",".stream-diffs-surface"].join(","),l=l=>{var t;const n=l instanceof HTMLElement?l:l.parentElement;return Boolean(null==(t=null==n?void 0:n.closest)?void 0:t.call(n,e))},t=l=>{var t,n;const o=l instanceof HTMLElement?l:l.parentElement;return Boolean((null==(t=null==o?void 0:o.closest)?void 0:t.call(o,e))||(null==(n=null==o?void 0:o.querySelector)?void 0:n.call(o,e)))},n=new MutationObserver(e=>{Dl.value&&Vn()&&e.some(e=>l(e.target)||Array.from(e.addedNodes).some(t)||Array.from(e.removedNodes).some(l))&&($n(),Nn({preferModelDiffHeight:!0}),Dn(),zn())});n.observe(u,{attributeFilter:["class"],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Ol.push({dispose:()=>n.disconnect()})}if(u&&"undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{if(!Dl.value)return;if(Dn(),!Vn())return;const e=yn(u);null!=e&&(Math.ceil(u.getBoundingClientRect().height||0)<=e+1||($n(),Nn({preferModelDiffHeight:!0}),Dn()))});e.observe(u),Ol.push({dispose:()=>e.disconnect()})}return}const r=pl();try{const e=null==(n=null==r?void 0:r.onDidContentSizeChange)?void 0:n.call(r,()=>Tn());e&&Ol.push(e)}catch(a){}try{const e=null==(o=null==r?void 0:r.onDidLayoutChange)?void 0:o.call(r,()=>Tn());e&&Ol.push(e)}catch(a){}}(),Sn(),wn(),$n(),vn(),Tn(),yield O();let i=null;kl&&(i=yield kl(),i&&(yield O(),yield tn()));const u=null==i?"diff"===n?yield Un():yield function(){return d(this,null,function*(){if(An())return yield O(),yield tn(),An();for(let e=0;e<30;e++){if(Ve||Dl.value)return!1;const e=Ne.value,l=In(),t=qn(e),n=!ht.value.trim()||dn(e);if(l&&t&&n&&(yield O(),yield tn(),!Ve&&!Dl.value&&In()&&qn(Ne.value)&&(!ht.value.trim()||dn(Ne.value))))return!0;yield O(),yield tn()}return!1})}():i;Ve||(u?(wn(),en(),(yield Kt())||To()):To())})}(e),lt=null}catch(r){const e=No(),a=n!==Ql.value,i=!1!==l.allowStaleContentRetry&&a&&lt!==e;if(t!==e||i)return i&&(lt=e),o=!0,je.value=!1,Ie.value=!1,qe.value=!1,void(Yl.value=!1);throw To(t),r}}).finally(()=>{xl===r&&(xl=null),function(){const e=Ke;he&&e&&(Ke="",O(()=>{var l,t;if(!Ve){const n=null!=(t=null==(l=Ee.value)?void 0:l.offsetHeight)?t:0;n>0&&he.reportHeight(e,n)}he.markSettled(e)}))}(),o&&!Ve&&queueMicrotask(()=>{var e;const l=Ne.value;l&&!Ve&&(null==(e=yo(l))||e.catch(e=>{Ie.value=!1,Yl.value=!1,To()}))})});return xl=r,r}P(fo,e=>{e||Q()}),P(()=>kt.value,(e,l)=>{var t;const n=Dl.value?gl():pl();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(null==(t=n.updateOptions)||t.call(n,{fontSize:e}),Re.value||Nn(!0))},{flush:"post",immediate:!1});let bo=0;const wo=P(()=>[Ne.value,Dl.value,s.stream,s.loading,Ae.value,rl.value,s.node.language,s.node.raw,s.node.code,s.node.loading],e=>d(null,[e],function*([e,l,t,n,o,r]){const a=++bo;if(!e)return;if(!r)return;if(Xn())return;if(tt)return;if(!1===t&&!1!==n)return;if(!dl){if(yield function(){return d(this,null,function*(){if("undefined"==typeof window||Ve)return;if(Ae.value||Gl.value)return;if(Cl)return Cl;const e=d(null,null,function*(){try{const e=yield me();if(Ve)return;if(!e)return void(Gl.value=!0);gt(e)}catch(e){if(Ve)return;Gl.value=!0}}).finally(()=>{Cl===e&&(Cl=null)});return Cl=e,e})}(),a!==bo)return;if(!1===s.stream&&!1!==s.loading)return;if(Qn())return;if(!rl.value)return;if(!dl||Gl.value||je.value||$o()||Ve||Ne.value!==e)return}if(Qn())return;const i=yo(e);if(i){try{yield i}catch(u){Ie.value=!1,Yl.value=!1,To()}Ie.value&&Yl.value&&wo()}}));function ko(e){return"string"==typeof e?e:null}function xo(e,l){if(e===l)return!0;const t=ko(e),n=ko(l);return!!t&&t===n}function So(){return ee({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})}function Co(){return d(this,arguments,function*(e={}){Po();const l=()=>{Dl.value&&Rl(),ve(()=>{Sn(),Tn()})};if(e.appearanceOnly)return void l();const t=So();if(t)try{yield le(Mo()),yield Bl(t),l()}catch(n){}else l()})}function Mo(){const e=s.themes;return e&&"string"==typeof e[0]&&"string"==typeof e[1]?{dark:e[0],light:e[1]}:So()}function Bo(){var e,l,t,n,o;const r=Et.value,a=u(i({},jl.value||{}),{wordWrap:"wrap"===r.overflow?"on":"off",overflow:r.overflow,themes:s.themes,stream:!1,MAX_HEIGHT:null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500,fontSize:Pt.value,lineHeight:Ot.value,theme:So(),themeType:s.isDark?"dark":"light",disableLineNumbers:!b.value,disableFileHeader:!0,workerManager:null!=(o=null!=(n=null==(t=jl.value)?void 0:t.workerManager)?n:te())?o:void 0,onThemeChange(){Sn()}}),d=function(){var e;const l=null==(e=jl.value)?void 0:e.fontFamily;return"string"==typeof l&&l.trim()?l.trim():Dl.value?function(){var e;if("undefined"==typeof window)return;const l=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l)return;return window.getComputedStyle(l).fontFamily.trim()||void 0}():void 0}();d&&(null!=a.fontFamily||(a.fontFamily=d));const v="string"==typeof a.unsafeCSS?a.unsafeCSS:"",c=`\n[data-file] [data-line],\n[data-diff] [data-line] {\n white-space: ${"wrap"===(f=r.overflow)?"pre-wrap":"pre"} !important;\n overflow-wrap: ${"wrap"===f?"anywhere":"normal"} !important;\n word-break: normal !important;\n}`;var f;return a.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }\n${c}\n\n[data-no-newline],\n[data-gutter-buffer="metadata"] {\n --diffs-computed-decoration-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-computed-diff-line-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-computed-selected-line-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-line-bg: var(--markstream-diff-metadata-bg) !important;\n color: var(--markstream-diff-metadata-fg) !important;\n background-color: var(--markstream-diff-metadata-bg) !important;\n}\n${v}`.trim(),a}function Po(){const e=Bo();if(!Nl)return Nl=e,Nl;for(const l of Object.keys(Nl))l in e||delete Nl[l];return Object.assign(Nl,e),Nl}P(Wl,(e,l)=>d(null,null,function*(){if(e===l)return;if(Xl.value||tt)return;if(to(),!dl||!Ne.value)return;if(!je.value)return;if(!1===s.stream&&!1!==s.loading)return;if(!rl.value)return;const t=xl;if(t){try{yield t}catch(n){}if(Ve||!Ne.value)return}if(Ul.value!==e||!je.value||!Ie.value)try{Ie.value=!1,Yl.value=!1,je.value=!1,qe.value=!1,On(),Fn(),bl(),yield O(),yield yo(Ne.value)}catch(o){Ie.value=!1,Yl.value=!1,To()}}));const Ho=M(0),Oo=v(()=>String(Ho.value));let Fo=!1;function No(){var e;const l=So();return JSON.stringify({kind:Wl.value,language:ze.value,structural:Oo.value,optionsRevision:Ho.value,settledContentGeneration:Zl.value,theme:null!=(e=ko(l))?e:null==l?null:"custom",isDark:s.isDark})}P(()=>{var e;return null==(e=s.codeBlockOptions)?void 0:e.fontSize},e=>{const l="number"==typeof e&&Number.isFinite(e)&&e>0?e:yt;wt.value=l,kt.value=l,xt.value=null,St.value=null,Ct.value=null}),P(()=>[s.codeBlockOptions,s.showLineNumbers],()=>{Ho.value+=1,!1===s.stream&&!1!==s.loading&&(Fo=!0)},{deep:!0}),P(()=>[ht.value,s.node.originalCode,s.node.updatedCode],()=>{Ql.value+=1,Xn()||(Zl.value+=1)});const Eo=v(()=>No());function Do(){Xl.value&&Kl.value!==Eo.value&&(Xl.value=!1,Kl.value=null,lt=null,nt=null,je.value=!1,Ie.value=!1,qe.value=!1,Yl.value=!1,Jl.value=!1)}function $o(){return Do(),Xl.value&&Kl.value===Eo.value}function To(e=Eo.value){Kl.value=e,Xl.value=!0,Jl.value=!1}return P(Eo,()=>d(null,null,function*(){if(tt)return;if(!Xl.value)return;if(Kl.value===Eo.value)return;if(!dl||!Ne.value||Gl.value||Ve||!rl.value)return;if(!1===s.stream&&!1!==s.loading)return;if(Qn())return;const e=Eo.value;tt=!0;try{if(Do(),Xl.value)return;yield yo(Ne.value)}catch(l){Ie.value=!1,Yl.value=!1,To()}finally{nt=e,yield O(),tt=!1}})),P(()=>[s.codeBlockOptions,rl.value],()=>{var e,l;if(Po(),!dl||!rl.value)return;const t=Dl.value?gl():pl(),n="number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize)?s.codeBlockOptions.fontSize:Number.isFinite(kt.value)?kt.value:void 0;"number"==typeof n&&Number.isFinite(n)&&n>0&&(null==(l=null==t?void 0:t.updateOptions)||l.call(t,{fontSize:n})),Nn(!1)},{deep:!0}),P(()=>[So(),Il.value,Ae.value,je.value,rl.value],([e,l],t)=>{if(!Ae.value||!rl.value)return;const n=null!=t&&xo(e,t[0]),o=null!=t&&l!==t[1];Ie.value?(We=!1,Co({appearanceOnly:n})):n&&!o||(We=!0)},{flush:"post"}),P(()=>[Oo.value,Ae.value,rl.value],(e,l)=>d(null,[e,l],function*([e,l,t],[n]){if(Po(),!l||!t)return;if(!dl||!Ne.value)return;if(!je.value)return;if(e===n)return;if(!1===s.stream&&!1!==s.loading)return void(Fo=!0);Fo=!1;const o=xl;if(o){try{yield o}catch(r){}if(Ve||!Ne.value)return}try{Ie.value=!1,Yl.value=!1,je.value=!1,qe.value=!1,On(),Fn(),bl(),El&&gt(El),yield O(),yield yo(Ne.value,{allowStaleContentRetry:!1})}catch(a){Ie.value=!1,Yl.value=!1,To()}}),{flush:"post"}),P(()=>[s.loading,rl.value],([e,l])=>{!1===e&&l&&Fo&&(Fo=!1,Ho.value+=1)},{flush:"post"}),P(()=>[s.loading,rl.value],(e,l)=>d(null,[e,l],function*([e,l],t){if(!l)return;const n=null==t?void 0:t[0];if(!1===n&&!1!==e&&Dl.value&&je.value&&(yield O(),ve(()=>{d(null,null,function*(){const e=xl;if(e)try{yield e}catch(l){}!Ve&&Dl.value&&!1!==s.loading&&(Po(),Rl(),Tn())})})),e)return;const o=void 0!==n&&!1!==n;yield O(),ve(()=>{d(null,null,function*(){var e,l;try{if(o&&(yield function(){return d(this,null,function*(){if(!Xl.value)return!1;if(!dl||!Ne.value||Gl.value||Ve||!rl.value)return!1;if(nt===Eo.value)return!0;tt=!0;try{Xl.value=!1,Kl.value=null,lt=null,je.value=!1,Ie.value=!1,qe.value=!1,Yl.value=!1,On(),Fn(),bl(),El&&gt(El),yield O();try{yield yo(Ne.value)}catch(e){Ie.value=!1,Yl.value=!1,To()}}finally{yield O(),tt=!1}return!0})}()))return void Nn(!1);if(o&&Dl.value&&je.value&&ot&&Ne.value)return ot=!1,Ie.value=!1,Yl.value=!1,je.value=!1,qe.value=!1,On(),Fn(),bl(),yield O(),yield yo(Ne.value,{allowStaleContentRetry:!1}),void zn(!0);if(o&&je.value)if(Dl.value&&Ne.value){const n=xl;if(n)try{yield n}catch(t){}Po();const o=zl(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:""));if(yield Gn(o.original,o.updated,ze.value),Ve||!Dl.value)return;yield Promise.resolve(ml()),Rl(),Dn(!0),Xt(),$n(),vn();const r=yield Un();Ve||!r||Yl.value||(yield Kt()),Tn(),zn(!0)}else to(),oo(ht.value,ze.value),yield new Promise(e=>{const l=()=>{Ve?e():eo||Zn?setTimeout(l,16):e()};l()}),Ve||Dl.value||(yield Promise.resolve(fl()));o&&Dl.value?(Nn({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),zn(!0)):Nn(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{On(),Fn(),yl(),null==Hl||Hl()}),(l,t)=>{var n;return Gl.value?(m(),h(de,{key:0,style:F(Wt.value),node:pt.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":rt.value,"diff-hide-unchanged-regions":at.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Et.value,"reserved-height-px":Dl.value&&null!=(n=Mt.value)?n:void 0,"is-dark":s.isDark,theme:s.theme,"dark-theme":s.darkTheme,"light-theme":s.lightTheme,themes:s.themes,"show-header":s.showHeader,"show-copy-button":s.showCopyButton,"show-tooltips":s.showTooltips},N({_:2},[l.$slots["header-left"]?{name:"header-left",fn:E(()=>[D(l.$slots,"header-left",{},void 0,!0)]),key:"0"}:void 0,l.$slots["header-right"]?{name:"header-right",fn:E(()=>[D(l.$slots,"header-right",{},void 0,!0)]),key:"1"}:void 0]),1032,["style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","code-block-options","resolved-visual-options","reserved-height-px","is-dark","theme","dark-theme","light-theme","themes","show-header","show-copy-button","show-tooltips"])):(m(),$("div",{key:1,ref_key:"container",ref:Ee,style:F(co.value),class:y(["code-block-container rounded-lg border",[{dark:s.isDark,"is-rendering":s.loading,"is-dark":Al.value,"is-diff":Dl.value,"is-plain-text":Le.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":Yl.value&&!Gl.value?"true":"false","data-markstream-enhancement-state":ft.value,"data-markstream-code-block-state":Xn()?"streaming":"settled","data-markstream-pending":ct.value?"true":void 0,"data-markstream-viewport-pending":ul.value&&k(nl)&&!rl.value?"true":void 0},[T(se,{"show-header":s.showHeader,"show-collapse-button":s.showCollapseButton,"show-font-size-buttons":s.showFontSizeButtons,"enable-font-size-control":s.enableFontSizeControl,"show-copy-button":s.showCopyButton,"show-expand-button":s.showExpandButton,"show-preview-button":s.showPreviewButton,"show-tooltips":s.showTooltips,"is-dark":s.isDark,loading:s.loading,stream:e.stream,"is-collapsed":Re.value,"is-expanded":_e.value,"copy-text":De.value,"is-previewable":Jn.value,"code-font-size":kt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":wt.value,"font-baseline-ready":Bt.value,"diff-stats":Dl.value?$l.value:null,"diff-stats-aria-label":Tl.value,onToggleCollapse:po,onDecreaseFont:mn,onResetFont:hn,onIncreaseFont:fn,onCopy:mo,onToggleExpand:ho,onPreview:go},N({"header-left":E(()=>[D(l.$slots,"header-left",{},()=>[g("div",ke,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:vo.value},null,8,xe),g("div",Se,[g("div",Ce,w(uo.value),1),so.value?(m(),$("div",Me,w(so.value),1)):L("",!0)])])],!0)]),loading:E(()=>[D(l.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:E(()=>{var l;return[z(g("div",{class:y(["code-editor-layer",{"code-editor-layer--collapsed":Re.value}])},[g("div",{ref_key:"codeEditor",ref:Ne,class:y(["code-editor-container",e.stream?"":"code-height-placeholder"]),"data-markstream-host-hidden":vt.value?"true":void 0,style:F(Yt.value)},null,14,Be),st.value?(m(),h(de,{key:0,style:F(Wt.value),node:pt.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":rt.value,"diff-hide-unchanged-regions":at.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Et.value,"reserved-height-px":Dl.value&&null!=(l=Mt.value)?l:void 0,"is-dark":s.isDark,theme:s.theme,"dark-theme":s.darkTheme,"light-theme":s.lightTheme,themes:s.themes,"show-toolbar":!1},null,8,["style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","code-block-options","resolved-visual-options","reserved-height-px","is-dark","theme","dark-theme","light-theme","themes"])):L("",!0)],2),[[_,!!e.stream||!e.loading]]),mt.value&&!Oe.value&&Jn.value&&"html"===$e.value?(m(),h(be,{key:0,code:s.node.code,"html-preview-allow-scripts":s.htmlPreviewAllowScripts,"html-preview-sandbox":s.htmlPreviewSandbox,"is-dark":s.isDark,"on-close":()=>mt.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):L("",!0)]}),_:2},[l.$slots["header-right"]?{name:"header-right",fn:E(()=>[D(l.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready","diff-stats","diff-stats-aria-label"])],14,we))}}}),[["__scopeId","data-v-8d8d96fe"]]);export{Pe as default};
1
+ var e=Object.defineProperty,l=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(l,t,n)=>t in l?e(l,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[t]=n,i=(e,l)=>{for(var t in l||(l={}))o.call(l,t)&&a(e,t,l[t]);if(n)for(var t of n(l))r.call(l,t)&&a(e,t,l[t]);return e},u=(e,n)=>l(e,t(n)),d=(e,l,t)=>new Promise((n,o)=>{var r=e=>{try{i(t.next(e))}catch(l){o(l)}},a=e=>{try{i(t.throw(e))}catch(l){o(l)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);i((t=t.apply(e,l)).next())});import{defineComponent as s,computed as v,onMounted as c,onUnmounted as f,openBlock as m,createBlock as h,Teleport as p,createElementVNode as g,normalizeClass as y,withModifiers as b,toDisplayString as w,unref as k,useAttrs as x,inject as S,getCurrentInstance as C,ref as M,shallowRef as B,watch as P,onBeforeUnmount as H,nextTick as O,normalizeStyle as F,createSlots as N,withCtx as E,renderSlot as D,createElementBlock as $,createVNode as T,withDirectives as z,createCommentVNode as L,vShow as _}from"vue";import{ax as R,G as j,M as q,aj as I,az as A,aA as V,aw as W,aa as U,ah as G,b as Y,c as J,al as X,ag as K,a8 as Q,ad as Z,ak as ee,as as le,a7 as te}from"./exports.js";import{M as ne,f as oe,n as re,c as ae,l as ie}from"./index2.js";import{r as ue,_ as de,a as se}from"./PreCodeBlock.vue_vue_type_style_index_0_lang.js";import{safeRaf as ve,safeCancelRaf as ce}from"./utils/safeRaf.js";import{r as fe}from"./preCodeTheme.js";import{getStreamDiffsRuntime as me}from"./streamDiffs.js";const he={class:"html-preview-frame__header"},pe={class:"html-preview-frame__title"},ge={class:"html-preview-frame__label"},ye=["sandbox","srcdoc"],be=/* @__PURE__ */j(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const l=e,t=void 0!==import.meta&&Boolean(!1);let n=null;const{t:o}=R(),r=v(()=>{const e=l.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${l.isDark?"#020617":"#ffffff"};\n color: ${l.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),a=v(()=>{return e=l.htmlPreviewSandbox,o=l.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!t||"undefined"==typeof console||n===e)return;const l=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);l.has("allow-scripts")&&l.has("allow-same-origin")&&(n=e,console.warn("[markstream-vue] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))}(e),e):void 0!==e?"":!0===o?"allow-scripts":"";var e,o});function i(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=l.onClose)||t.call(l)}return c(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",i)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",i)}),(e,t)=>(m(),h(p,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:l.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:t[2]||(t[2]=e=>{var t;return null==(t=l.onClose)?void 0:t.call(l)})},[g("div",{class:"html-preview-frame",onClick:t[1]||(t[1]=b(()=>{},["stop"]))},[g("div",he,[g("div",pe,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",ge,w(l.title||k(o)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:t[0]||(t[0]=e=>{var t;return null==(t=l.onClose)?void 0:t.call(l)})}," × ")]),g("iframe",{class:"html-preview-frame__iframe",sandbox:a.value,referrerpolicy:"no-referrer",srcdoc:r.value},null,8,ye)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]),we=["data-markstream-enhanced","data-markstream-enhancement-state","data-markstream-code-block-state","data-markstream-pending","data-markstream-viewport-pending"],ke={class:"code-header-main"},xe=["innerHTML"],Se={class:"code-header-copy"},Ce={class:"code-header-title"},Me={key:0,class:"code-header-caption"},Be=["data-markstream-host-hidden"],Pe=/* @__PURE__ */j(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},codeBlockOptions:{},showLineNumbers:{type:Boolean,default:void 0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{},estimatedDiffInline:{type:Boolean}},emits:["previewCode","copy"],setup(e,{emit:l}){var t,n,o,r,a;const s=e,p=l,b=v(()=>{var e,l;return null!=(l=s.showLineNumbers)?l:!0!==(null==(e=s.codeBlockOptions)?void 0:e.disableLineNumbers)}),j=x(),he=S(ne,null),pe=S("markstreamHostScrollManaged",null),ge=S(q,void 0),ye=v(()=>I(s,j));function Pe(e,l){}const He=C(),Oe=v(()=>{const e=null==He?void 0:He.vnode.props;return!(!e||!e.onPreviewCode&&!e["onPreview-code"])}),{t:Fe}=R(),Ne=M(null),Ee=M(null),De=M(!1),$e=M(Kn(s.node.language,s.node.code,Xn())),Te=v(()=>oe($e.value)),ze=v(()=>"plaintext"===Te.value?"text":Te.value),Le=v(()=>"plaintext"===Te.value),_e=M(!1),Re=M(!1),je=M(!1),qe=M(!1),Ie=M(!1),Ae=M(!1);let Ve=!1,We=!1,Ue=null,Ge=null,Ye=null,Je=0,Xe=!1,Ke="";const Qe=M(null);let Ze=0,el=!1;const ll=A(),tl=V(),nl=W(),ol=B(null),rl=M("undefined"==typeof window||!nl.value),al=null!=(o=null==(n=null==(t=C())?void 0:t.vnode.el)?void 0:n.textContent)?o:"",il="undefined"!=typeof window&&String(null!=(r=s.node.code)?r:"").length>0&&al.includes(String(s.node.code)),ul=M(!il);c(()=>{ul.value=!0}),"undefined"!=typeof window&&P([()=>Ee.value,nl],([e,l],t,n)=>{var o,r,a;if(null==(o=ol.value)||o.destroy(),ol.value=null,!l||rl.value)return void(rl.value=!0);if(!e)return void(rl.value=!1);let i=!0;const u=null!=(a=null!=(r=null==tl?void 0:tl.value.heavyBlockMargin)?r:null==tl?void 0:tl.value.rootMargin)?a:"0px",d=ll(e,{rootMargin:u,allowIdle:!1});ol.value=d,rl.value=rl.value||d.isVisible.value,d.whenVisible.then(()=>{i&&ol.value===d&&(rl.value=!0)}).catch(()=>{}),n(()=>{i=!1,d.destroy(),ol.value===d&&(ol.value=null)})},{immediate:!0}),H(()=>{var e;Ve=!0,function(){const e=Ke;he&&e&&(Ke="",he.markSettled(e))}(),null==(e=ol.value)||e.destroy(),ol.value=null});let dl=null,sl=null,vl=()=>{},cl=()=>{},fl=()=>{},ml=()=>{},hl=()=>null,pl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),gl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),yl=()=>{},bl=()=>{},wl=()=>{},kl=null,xl=null,Sl=null,Cl=null,Ml=()=>{var e;return String(null!=(e=s.node.language)?e:"plaintext")},Bl=()=>d(null,null,function*(){}),Pl=!1,Hl=null;const Ol=[],Fl=[];let Nl=null,El=null;const Dl=v(()=>U(s.node)),$l=M({removed:0,added:0}),Tl=v(()=>`-${$l.value.removed} +${$l.value.added}`);function zl(e,l){return{original:e,updated:l}}function Ll(e){return String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"")}function _l(e){var l;return String(null!=(l=null==e?void 0:e.message)?l:e).includes("no diff result available")}function Rl(){if(!An())try{const e=wl();e&&"function"==typeof e.catch&&e.catch(e=>{_l(e)})}catch(e){_l(e)}}const jl=v(()=>{const e=i({},s.codeBlockOptions||{});for(const n of["theme","themes","themeType","language","languages","stream","disableFileHeader","onThemeChange","renderCustomHeader","renderHeaderMetadata","renderHeaderPrefix","maxHeight","padding","tabSize"])delete e[n];if(!Dl.value)return e;const l=e.parseDiffOptions&&"object"==typeof e.parseDiffOptions?e.parseDiffOptions:{},t={diffStyle:"split",expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:"line-info",parseDiffOptions:{context:2}};return u(i(i({},t),e),{parseDiffOptions:i(i({},t.parseDiffOptions),l)})}),ql=v(()=>{return(void 0!==s.theme?(e=s.theme)&&"object"==typeof e&&"light"in e&&"dark"in e:!xo(s.darkTheme,s.lightTheme))?!!s.isDark:function(e){var l;const t=null!=(l=ko(e))?l:"";return Z(t,!0===s.isDark)}(So());var e}),Il=v(()=>(Dl.value,ql.value?"dark":"light")),Al=v(()=>Dl.value?"dark"===Il.value:ql.value),Vl=v(()=>fe({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})),Wl=v(()=>Dl.value?"diff":"single"),Ul=M(Wl.value),Gl=M(!1),Yl=M(!1),Jl=M(!1),Xl=M(!1),Kl=M(null),Ql=M(0),Zl=M(0),et=M(!1);let lt=null,tt=!1,nt=null,ot=!1;const rt=v(()=>{var e;return!!Dl.value&&"unified"===(null==(e=jl.value)?void 0:e.diffStyle)}),at=v(()=>G(jl.value));function it(e){return!0===(null==pe?void 0:pe.value)||!!e&&(!!e.closest('[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline')||Boolean(e.closest(".vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]")))}const ut=v(()=>it(Ee.value)),dt=v(()=>!(Gl.value||!Xl.value&&Yl.value)),st=v(()=>dt.value),vt=v(()=>dt.value&&!Jl.value),ct=v(()=>!Gl.value&&!Xl.value&&dt.value),ft=v(()=>Yl.value&&!Gl.value?"ready":Xl.value?"fallback":"pending"),mt=M(!1),ht=v(()=>Ll(s.node.code)),pt=v(()=>Dl.value?!0===s.node.diff?s.node:u(i({},s.node),{diff:!0}):ht.value===s.node.code?s.node:u(i({},s.node),{code:ht.value}));function gt(e){const l=e.detectLanguage;"function"==typeof l&&(Ml=l),El=e,Nl=Bo();const t=e.createCodeBlockRuntime(Nl);return!!t&&(dl=t.createEditor||dl,sl=t.createDiffEditor||sl,vl=t.updateCode||vl,cl=t.updateDiff||cl,fl=t.finalizeCode||fl,ml=t.finalizeDiff||ml,hl=t.getEditor||hl,pl=t.getEditorView||pl,gl=t.getDiffEditorView||gl,yl=t.cleanupEditor||yl,bl=t.safeClean||t.cleanupEditor||bl,wl=t.refreshDiffPresentation||wl,Bl=t.setTheme||Bl,kl=t.whenVisualReady||null,Ae.value=!0,!0)}const yt=Y,bt=J,wt=M("number"==typeof(null==(a=s.codeBlockOptions)?void 0:a.fontSize)?s.codeBlockOptions.fontSize:Number.NaN),kt=M(wt.value),xt=M(null),St=M(null),Ct=M(null),Mt=M(null),Bt=v(()=>{const e=wt.value,l=kt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof l&&Number.isFinite(l)&&l>0}),Pt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l;const t=kt.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:yt}),Ht=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.lineHeight;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:Pt.value===yt?bt:Math.max(12,Math.round(1.5*Pt.value))}),Ot=v(()=>Ht.value),Ft=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.tabSize;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:4}),Nt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding,t="number"==typeof l&&Number.isFinite(l)&&l>=0?l:8;return{top:t,bottom:t}}),Et=v(()=>{const e=X(s.codeBlockOptions);return u(i({},e),{fontSize:Pt.value,lineHeight:Ot.value,maxHeight:Yn(),padding:Nt.value.top,paddingBottom:Nt.value.bottom,tabSize:Ft.value})}),Dt=v(()=>{const e=s.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function $t(e){if(null==e)return null;const l=Math.ceil(e);return!Number.isFinite(l)||l<=0?null:Math.min(l,Math.ceil(Yn()))}function Tt(){return!Dl.value&&!1!==s.stream&&!1!==s.loading}const zt=M(Tt());function Lt(){return Tt()||zt.value}const _t=v(()=>Dl.value?null:null==Dt.value||Lt()?Math.ceil((e=>{const l=String(null!=e?e:"");if(!l)return 1;let t=1;for(let n=0;n<l.length;n++)"\n"===l[n]?t++:"\r"===l[n]&&(t++,"\n"===l[n+1]&&n++);return t})(ht.value)*Ot.value+1):null),Rt=v(()=>{if(Dl.value)return null;const e=Dt.value;return null==e||Lt()?$t(_t.value):$t(e)}),jt=v(()=>{const e=s.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),qt=M(null);function It(){const e=qt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}const At=v(()=>{const e=It();return null!=e?e:!Dl.value&&et.value?null:dt.value||!Yl.value?Rt.value:null});function Vt(e){const l=e?"hsl(152 42% 60%)":"var(--diff-added-fg)",t=e?"hsl(0 58% 58%)":"var(--diff-removed-fg)",n=e?"color-mix(in lab, #121212 80%, #4d9375)":"color-mix(in lab, #ffffff 88%, #1e754f)",o=e?"color-mix(in lab, #121212 80%, #cb7676)":"color-mix(in lab, #ffffff 88%, #ab5959)";return{"--markstream-diff-line-number-bg":e?"hsl(0 0% 7% / 0.98)":"hsl(var(--ms-muted) / 0.45)","--markstream-diff-added-fg":l,"--markstream-diff-removed-fg":t,"--markstream-diff-added-line":n,"--markstream-diff-removed-line":o,"--markstream-diff-added-line-fill":n,"--markstream-diff-added-number-fill":e?"color-mix(in lab, #121212 85%, #4d9375)":"color-mix(in lab, #ffffff 91%, #1e754f)","--markstream-diff-removed-line-fill":o,"--markstream-diff-removed-number-fill":e?"color-mix(in lab, #121212 85%, #cb7676)":"color-mix(in lab, #ffffff 91%, #ab5959)","--markstream-diff-added-gutter":`linear-gradient(90deg, ${l} 0 4px, transparent 4px 100%)`,"--markstream-diff-removed-gutter":`linear-gradient(90deg, ${t} 0 4px, transparent 4px 100%)`,"--markstream-diff-added-inline":e?"hsl(152 42% 60% / 0.28)":"var(--diff-added-inline-bg)","--markstream-diff-removed-inline":e?"hsl(0 58% 58% / 0.28)":"var(--diff-removed-inline-bg)"}}const Wt=v(()=>{const e=$t(Dt.value),l=$t(_t.value),t=Lt(),n=i({},Dl.value||null==e||t?Dl.value||null==l?{}:{minHeight:`${l}px`}:{height:`${e}px`,minHeight:`${e}px`});if(n["--markstream-code-fallback-bg"]=Vl.value.background,n["--markstream-code-fallback-fg"]=Vl.value.foreground,Vl.value.builtin&&(n["--markstream-code-theme-bg"]=Vl.value.background,n["--markstream-code-theme-fg"]=Vl.value.foreground,n["--markstream-code-theme-line-number"]=Vl.value.lineNumber),n["--markstream-pre-line-number-top"]=`${Nt.value.top}px`,n["--markstream-pre-line-number-left"]="0px",n["--markstream-pre-line-number-padding-left"]="2ch",n["--markstream-pre-line-number-padding-right"]="1ch",n["--markstream-pre-line-number-separator-width"]="2px",Dl.value){n["--markstream-pre-diff-line-height"]=`${Ot.value}px`,n["--markstream-pre-diff-pane-bottom-padding"]=(rt.value,"0px");const e=Mt.value;null!=e&&e>0&&(n.height=`${e}px`,n.minHeight=`${e}px`,n.maxHeight=`${e}px`),Object.assign(n,Vt(Al.value))}return n}),Ut=v(()=>null!=At.value&&(!Yl.value||null!=It())),Gt=v(()=>{const e=At.value;if(null==e)return null;if(Dl.value)return Math.ceil(e);const l=jt.value,t=Dt.value;if(null==l||null==t)return Math.ceil(e);const n=Math.max(0,Math.ceil(l)-Math.ceil(t));return Math.ceil(e+n)}),Yt=v(()=>{if(Dl.value&&dt.value)return{};const e=At.value;return Ut.value&&null!=e?{minHeight:`${e}px`}:{}});function Jt(){qt.value=null}function Xt(){var e,l,t,n,o,r,a,i;const u=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback"),d=gl(),s=null!=(l=null==u?void 0:u.scrollTop)?l:0;null==(o=null==(n=null==(t=null==d?void 0:d.getOriginalEditor)?void 0:t.call(d))?void 0:n.setScrollTop)||o.call(n,s),null==(i=null==(a=null==(r=null==d?void 0:d.getModifiedEditor)?void 0:r.call(d))?void 0:a.setScrollTop)||i.call(a,s)}function Kt(){return d(this,null,function*(){return Dl.value?(xn(),en(),Dn(!0),Xt(),$n(),Jl.value=!0,yield O(),Dn(!0),yield tn(),Dn(!0),wn(),en(),!!(yield function(){return d(this,null,function*(){var e;if(!Dl.value)return!0;for(let l=0;l<4;l++){const l=en();Dn(!0),Qt(l),Zt(l),yield O(),yield tn();const t=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!t)return!1;if(null==l)return jn();const n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-l)<=2)return!0}return!1})}())&&(Yl.value=!0,yield O(),en(),Dn(!0),wn(),$n(),ve(()=>{Ve||ve(()=>{Ve||(function(){var e,l;const t=null==(e=Ee.value)?void 0:e.querySelector(".code-block-shell-content"),n=null==(l=Ee.value)?void 0:l.querySelector(".code-editor-layer");t&&n&&(n.style.removeProperty("height"),n.style.removeProperty("min-height"),t.style.removeProperty("height"),t.style.removeProperty("min-height"))}(),Tn(!0))})}),Tn(),!0)):!(kl&&!(yield kl())||(xn(),Dn(!0),Jl.value=!0,yield O(),xn(),Dn(!0),yield tn(),xn(),Dn(!0),Yl.value=!0,yield O(),Tn(),0))})}function Qt(e){var l;if(!Dl.value)return;const t=Ne.value,n=null==(l=Ee.value)?void 0:l.querySelector("pre.code-pre-fallback");if(!t||!n)return;const o=null!=e?e:Number.parseFloat(t.style.height||"");if(!Number.isFinite(o)||o<=0)return;const r=Math.ceil(o),a=`${r}px`;Mt.value=r;const i=Ee.value;i&&(i.dataset.markstreamDiffHandoffHeight=a),n.dataset.markstreamDiffHandoffHeight=a,n.style.setProperty("height",a),n.style.setProperty("min-height",a)}function Zt(e){var l,t,n;if(!Dl.value)return;const o=null==(l=Ee.value)?void 0:l.querySelector(".code-block-shell-content"),r=null==(t=Ee.value)?void 0:t.querySelector(".code-editor-layer");if(!o||!r)return;const a="number"==typeof e&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat((null==(n=Ne.value)?void 0:n.style.height)||"");if(!Number.isFinite(a)||a<=0)return;const i=`${a}px`;r.style.height=i,r.style.minHeight=i,o.style.height=i,o.style.minHeight=i}function en(){const e=Ne.value;if(e&&jn(e)){$n();const l=yn(e);if(null!=l&&l>0){const t=Math.ceil(l),n=Math.ceil(Yn()),o=Math.min(t,n),r=`${o}px`;return e.style.height=r,e.style.minHeight="0px",e.style.maxHeight=`${n}px`,e.style.overflow=t>n+1?"auto":"hidden",dt.value&&(Mt.value=o,Qt(o)),zn(),o}return Nn({preferModelDiffHeight:!0}),Qt(),zn(),Number.parseFloat(e.style.height||"")||null}return xn()}function ln(e,l=!1,t={}){const n=Math.ceil(e),o=It();if(null==o)return n;const r=!0===t.allowBelowEstimatedFloor;return n>=o||r?((l||r)&&Ie.value&&Jt(),n):o}function tn(){return new Promise(e=>{let l=!1,t=null,n=null;const o=()=>{l||(l=!0,null!=n&&globalThis.clearTimeout(n),null!=t&&ce(t),e())};n=globalThis.setTimeout(o,50),t=ve(o)})}function nn(){var e;try{const l=Ne.value;if(!l)return null;const t=null!=(e=l.querySelector(".stream-diffs-shell .stream-diffs-surface"))?e:l.querySelector(".stream-diffs-shell");if(t){const e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch(l){}return null}function on(){var e,l,t,n,o,r;try{const r=Dl.value?null!=(t=null==(l=null==(e=gl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:gl():pl(),a=hl(),i=null==(n=null==a?void 0:a.EditorOption)?void 0:n.fontInfo;if(r&&null!=i){const e=null==(o=r.getOption)?void 0:o.call(r,i),l=null==e?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(a){}try{const e=Ne.value;if(e){const l=null!=(r=e.querySelector(".stream-diffs-shell .stream-diffs-surface"))?r:e.querySelector(".stream-diffs-shell");if(l)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(l).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(a){}}}catch(a){}return null}function rn(e){var l,t;try{const n=hl(),o=null==(l=null==n?void 0:n.EditorOption)?void 0:l.lineHeight;if(null!=o){const l=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof l&&l>0)return l}}catch(r){}const n=nn();if(n&&n>0)return n;const o=Number.isFinite(kt.value)&&kt.value>0?kt.value:14;return Math.max(12,Math.round(1.35*o))}function an(){var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding;return"number"==typeof l&&Number.isFinite(l)?2*Math.max(0,l):Dl.value?24:0}function un(e){const l=Ll(e);return l?l.split(/\r\n|\n|\r/):[]}function dn(e){return!!Le.value||!!e&&(An(e)||null!=kl)}function sn(){var e,l;Dl.value?$l.value=function(e,l){const t=un(e),n=un(l);let o=0,r=t.length-1,a=n.length-1;for(;o<=r&&o<=a&&t[o]===n[o];)o++;for(;r>=o&&a>=o&&t[r]===n[a];)r--,a--;const i=Math.max(0,r-o+1),u=Math.max(0,a-o+1);if(0===i||0===u)return{removed:i,added:u};if((i+1)*(u+1)<=15e5){const e=u+1;let l=new Uint32Array(e),r=new Uint32Array(e);for(let d=i-1;d>=0;d--){r[u]=0;for(let a=u-1;a>=0;a--)r[a]=t[o+d]===n[o+a]?l[a+1]+1:Math.max(l[a],r[a+1]);const e=l;l=r,r=e}const a=l[0];return{removed:i-a,added:u-a}}return{removed:i,added:u}}(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:"")):$l.value={removed:0,added:0}}function vn(){sn()}function cn(){var e;if(Number.isFinite(kt.value)&&kt.value>0&&Number.isFinite(wt.value))return kt.value;if("number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize))return wt.value=s.codeBlockOptions.fontSize,kt.value=s.codeBlockOptions.fontSize,s.codeBlockOptions.fontSize;const l=on();return l&&l>0?(wt.value=l,kt.value=l,l):(wt.value=12,kt.value=12,12)}function fn(){const e=cn(),l=Math.min(36,e+1);kt.value=l}function mn(){const e=cn(),l=Math.max(10,e-1);kt.value=l}function hn(){cn(),Number.isFinite(wt.value)&&(kt.value=wt.value)}function pn(){var e,l,t,n,o,r,a,i,u,d,s,v,c,f;try{const m=Dl.value?gl():null,h=Dl.value?m:pl();if(!h)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const c=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(l=m.getModifiedEditor)?void 0:l.call(m);null==(t=null==c?void 0:c.layout)||t.call(c),null==(n=null==f?void 0:f.layout)||n.call(f);const h=(null==(o=null==c?void 0:c.getContentHeight)?void 0:o.call(c))||0,p=(null==(r=null==f?void 0:f.getContentHeight)?void 0:r.call(f))||0,g=Math.max(h,p);if(g>0)return Math.ceil(g);const y=(null==(u=null==(i=null==(a=null==c?void 0:c.getModel)?void 0:a.call(c))?void 0:i.getLineCount)?void 0:u.call(i))||1,b=(null==(v=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:v.call(s))||1,w=Math.max(y,b),k=Math.max(rn(c),rn(f)),x=an();return Math.ceil(w*k+x+0)}if(null==h?void 0:h.getContentHeight){null==(c=null==h?void 0:h.layout)||c.call(h);const e=h.getContentHeight();if(e>0)return Dl.value||(et.value=!0),Math.ceil(e)}const p=null==(f=null==h?void 0:h.getModel)?void 0:f.call(h);let g=1;p&&"function"==typeof p.getLineCount&&(g=p.getLineCount());const y=rn(h);return Math.ceil(g*(y+1.5)+0)}catch(m){return null}}function gn(){var e,l;if(Dl.value)return!1;try{const t=null==(l=null==(e=pl())?void 0:e.getContentHeight)?void 0:l.call(e),n="number"==typeof t&&Number.isFinite(t)&&t>0;return n&&(et.value=!0),n}catch(t){return!1}}function yn(e){if("undefined"==typeof window)return null;try{if("none"===window.getComputedStyle(e).display)return null;const l=e.querySelector("diffs-container");if(l instanceof HTMLElement){const e=l.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}const t=e.querySelector(".stream-diffs-shell");if(t){const e=t.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}return null}catch(l){return null}}function bn(e){var l;const t=String(null!=e?e:"").trim(),n=null==(l=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:l[1];if(n){const e=3===n.length?n.split("").map(e=>`${e}${e}`).join(""):n;return.2126*Number.parseInt(e.slice(0,2),16)+.7152*Number.parseInt(e.slice(2,4),16)+.0722*Number.parseInt(e.slice(4,6),16)}const o=t.match(/\d+(?:\.\d+)?/g);if(!o||o.length<3)return null;const[r,a,i]=o.slice(0,3).map(Number);return.2126*r+.7152*a+.0722*i}function wn(){var e,l,t;if(kn())return;const n=on();n&&n>0&&(xt.value=n,kt.value=n,wt.value=n);try{const n=rn(Dl.value?null!=(t=null==(l=null==(e=gl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:gl():pl());n&&n>0&&(St.value=n)}catch(o){}try{const e=nn();e&&e>0&&(St.value=e)}catch(o){}}function kn(){return Dl.value&&st.value}function xn(){var e;if(!dt.value)return null;const l=Ne.value,t=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l||!t)return null;const n=Math.ceil(t.getBoundingClientRect().height),o=Dl.value?yn(l):null,r=Math.max(n,null!=o&&o>0?Math.ceil(o):0),a=Math.ceil(Yn()),i=Math.min(r,a);return!Number.isFinite(i)||i<=0?null:(Dl.value&&i>n&&(Mt.value=i),l.style.height=`${i}px`,l.style.minHeight=`${i}px`,l.style.maxHeight=`${a}px`,l.style.overflow=r>a+1?"auto":"hidden",i)}function Sn(){var e,l,t,n,o,r,a,i,u;const d=Ne.value,v=Ee.value;if(!d||!v)return;const c=d;c.style.setProperty("--markstream-diff-metadata-bg",Vl.value.background),c.style.setProperty("--markstream-diff-metadata-fg",Vl.value.lineNumber),c.style.setProperty("--diffs-tab-size",String(Ft.value)),c.style.setProperty("--diffs-scrollbar-gutter-override","0px"),"number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.padding)?c.style.setProperty("--diffs-gap-block",`${Nt.value.top}px`):c.style.removeProperty("--diffs-gap-block");const f=d.querySelector(".stream-diffs-shell")||d,m=f,h=f;let p=null,g=null,y=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(f),g=m===f?p:window.getComputedStyle(m),y=h===f?p:window.getComputedStyle(h))}catch(M){p=null,g=null,y=null}const b=String(null!=(l=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?l:"").trim(),w=String(null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?t:"").trim(),k=String(null!=(o=null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?n:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?o:"").trim(),x=b||String(null!=(a=null!=(r=null==y?void 0:y.color)?r:null==p?void 0:p.color)?a:"").trim(),S=w||String(null!=(u=null!=(i=null==g?void 0:g.backgroundColor)?i:null==p?void 0:p.backgroundColor)?u:"").trim(),C=function(){var e,l,t,n,o;try{const r=Dl.value?null!=(t=null==(l=null==(e=gl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:gl():pl(),a=hl(),i=null==(n=null==a?void 0:a.EditorOption)?void 0:n.fontInfo;if(r&&null!=i){const e=null==(o=r.getOption)?void 0:o.call(r,i),l=null==e?void 0:e.typicalHalfwidthCharacterWidth;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(M){}return null}();if(null!=C&&(Ct.value=C),Dl.value){const e=(e,l)=>{l?(v.style.setProperty(e,l),c.style.setProperty(e,l)):(v.style.removeProperty(e),c.style.removeProperty(e))};for(const[l,t]of Object.entries(Vt(v.classList.contains("is-dark"))))e(l,t);return x?(v.style.setProperty("--markstream-diff-editor-fg",x),c.style.setProperty("--vscode-editor-foreground",x)):(v.style.removeProperty("--markstream-diff-editor-fg"),c.style.removeProperty("--vscode-editor-foreground")),S?(v.style.setProperty("--markstream-diff-editor-bg",S),v.style.setProperty("--markstream-diff-panel-bg",S),v.style.setProperty("--markstream-diff-panel-bg-soft",S),v.style.setProperty("--markstream-diff-panel-bg-strong",S),c.style.setProperty("--vscode-editor-background",S),c.style.backgroundColor=S):(v.style.removeProperty("--markstream-diff-editor-bg"),v.style.removeProperty("--markstream-diff-panel-bg"),v.style.removeProperty("--markstream-diff-panel-bg-soft"),v.style.removeProperty("--markstream-diff-panel-bg-strong"),c.style.removeProperty("--vscode-editor-background"),c.style.backgroundColor=""),void(k?c.style.setProperty("--vscode-editor-selectionBackground",k):c.style.removeProperty("--vscode-editor-selectionBackground"))}if(function(e,l,t){if(!Le.value)return!1;const n=bn(e),o=bn(l);return t?null!=n&&n>170||null!=o&&o<110:null!=n&&n<85||null!=o&&o>190}(S,x,v.classList.contains("is-dark")))return c.style.removeProperty("--vscode-editor-foreground"),c.style.removeProperty("--vscode-editor-background"),void c.style.removeProperty("--vscode-editor-selectionBackground");x&&c.style.setProperty("--vscode-editor-foreground",x),S&&c.style.setProperty("--vscode-editor-background",S),k&&c.style.setProperty("--vscode-editor-selectionBackground",k)}P(()=>[s.stream,s.loading,s.node.loading,Dl.value],([e,l,t,n])=>{n||!1===e||!1===l||zt.value?(n||!1===e)&&zt.value&&(zt.value=!1):(zt.value=!0,Jt())},{immediate:!0});let Cn=0,Mn=0;const Bn=/auto|scroll|overlay/i;function Pn(e,l,t){var n;if("undefined"==typeof window)return;if(Dl.value)return;if(function(e){return ut.value||it(e)}(e))return;const o=Math.ceil(l),r=Math.ceil(t)-o;if(Math.abs(r)<=1)return;const a=function(e){var l,t;if("undefined"==typeof window)return null;const n=null!=(l=null==e?void 0:e.ownerDocument)?l:document,o=n.scrollingElement||n.documentElement||n.body;let r=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;r&&r!==n.body&&r!==o;){const e=window.getComputedStyle(r),l=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(Bn.test(l)||Bn.test(t))return r;r=r.parentElement}return o}(e);if(!a)return;const i=null!=(n=e.ownerDocument)?n:document,u=a===i.body||a===i.documentElement||a===i.scrollingElement,d=u?0:a.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,r):a.scrollTop+=r)}function Hn(){try{const e=Ne.value;if(!e)return;const l=e.getBoundingClientRect().height,t=pn();if(null!=t&&t>0){const n=ln(t,!0,{allowBelowEstimatedFloor:!Dl.value&&Ie.value&&gn()}),o=It();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",void Pn(e,l,n)}const n=It();null!=n&&(e.style.minHeight=`${n}px`,e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",Pn(e,l,n))}catch(e){}}function On(){for(var e,l;Ol.length>0;)try{null==(l=null==(e=Ol.pop())?void 0:e.dispose)||l.call(e)}catch(t){}null!=Ue&&(ce(Ue),Ue=null),null!=Ge&&(ce(Ge),Ge=null),null!=Ye&&(ce(Ye),Ye=null),Je=0,Xe=!1}function Fn(){for(var e;Fl.length>0;)try{null==(e=Fl.pop())||e()}catch(l){}}function Nn(e=!1){Re.value||(_e.value?Hn():function(e={}){var l;try{const t=Ne.value;if(!t)return;const n=t.getBoundingClientRect().height,o=Yn(),r=Math.ceil((null==(l=t.getBoundingClientRect)?void 0:l.call(t).height)||0),a=Number.parseFloat(t.style.height||""),i=r>0?r:Number.isFinite(a)&&a>0?Math.ceil(a):0,u=Dl.value?function(){var e,l,t,n,o,r,a,i,u,d,s,v;if(An())return null;try{const c=gl(),f=null==(e=null==c?void 0:c.getOriginalEditor)?void 0:e.call(c),m=null==(l=null==c?void 0:c.getModifiedEditor)?void 0:l.call(c);if(!f||!m)return null;const h=(null==(o=null==(n=null==(t=f.getModel)?void 0:t.call(f))?void 0:n.getLineCount)?void 0:o.call(n))||1,p=(null==(i=null==(a=null==(r=m.getModel)?void 0:r.call(m))?void 0:a.getLineCount)?void 0:i.call(a))||1,g=Math.max(h,p),y=Math.max(rn(f),rn(m)),b=an(),w=Math.max(null!=(d=null==(u=f.getContentHeight)?void 0:u.call(f))?d:0,null!=(v=null==(s=m.getContentHeight)?void 0:s.call(m))?v:0);return Math.ceil(Math.max(w,g*y+b+0))}catch(c){return null}}():null,d=Dl.value&&jn(t);if(Ze>0&&(Ze--,null!=Qe.value))return void Pn(t,n,Ln(t,Qe.value,o,{preserveScrollableOverflow:Rn(t)}));if(Dl.value&&!d&&dt.value){const e=xn();if(null!=e){const l=Ln(t,e,o,{allowBelowEstimatedFloor:!0});return Dn(!0),void Pn(t,n,l)}}const v=Dl.value&&!0===e.preferModelDiffHeight,c=Dl.value?yn(t):null,f=!Dl.value&&Ie.value&&gn(),m=Dl.value&&!1!==s.loading&&(null!=c||null!=u&&r>0&&u<r-1),h=null!=u;let p;if(Dl.value)if(v){const e=null!=u&&!1===s.loading&&i>0&&u<i-1;p=!1===s.loading&&null!=c?null==u?c:Math.max(c,u):e?u:null!=c&&null!=u?Math.max(c,u,!1!==s.loading?i:0):Math.max(null!=c?c:0,null!=u?u:0,!1!==s.loading?i:0)||null}else p=rt.value&&null!=c||null!=c?h?Math.max(c,u):c:Dl.value&&!1!==s.loading?null!=u&&i>0&&u<i-1?u:i>0?i:null:u;else p=pn();if(Dl.value&&null!=p&&i>0&&(!1!==s.loading||!0===e.holdCurrentDiffHeight)&&(p=Math.max(p,i)),null!=p&&p>0)return void Pn(t,n,Ln(t,p,o,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||m,preserveScrollableOverflow:Rn(t)}));if(null!=Qe.value)return void Pn(t,n,Ln(t,Qe.value,o,{preserveScrollableOverflow:Rn(t)}));const g=Dl.value&&!1!==s.loading?r:Math.max(r,null!=u&&u>0?u:0);if(g>0)return void Pn(t,n,Ln(t,g,o));const y=It();if(!(null==y||Dl.value&&!1!==s.loading&&d))return void Pn(t,n,Ln(t,y,o));const b=Number.parseFloat(t.style.height);!Number.isNaN(b)&&b>0?Pn(t,n,Ln(t,b,o)):Dl.value||Pn(t,n,Ln(t,o,o))}catch(t){}}("object"==typeof e?e:{}))}function En(){Cn=0,Mn=0}function Dn(e=!1){var l,t,n;if(Re.value)return;const o=Ne.value;if(!o)return;const r=Dl.value?gl():pl();if(r&&"function"==typeof r.layout)try{const a=null==(l=o.getBoundingClientRect)?void 0:l.call(o),i=Math.ceil((null!=(t=null==a?void 0:a.width)?t:0)||o.clientWidth||0),u=Math.ceil((null!=(n=null==a?void 0:a.height)?n:0)||o.clientHeight||Number.parseFloat(o.style.height||"")||0);if(i>0&&u>0){if(!e&&i===Cn&&u===Mn)return;Cn=i,Mn=u,r.layout({width:i,height:u})}else En(),r.layout()}catch(a){}}function $n(){Fn()}function Tn(e=!1){if(Ve||null!=Ue)return;const l=()=>{Ve||($n(),Nn(e),Dn())};Ue=ve(()=>{Ue=null,l(),Ge=ve(()=>{Ge=null,l()})}),zn()}function zn(e=!1){if(!Dl.value||Ve||!e&&!1===s.loading)return;if(Xe=Xe||e,Je=Math.max(Je,e?18:6),null!=Ye)return;const l=()=>{if(Ye=null,!Dl.value||Ve||Je<=0||!Xe&&!1===s.loading)return Je=0,void(Xe=!1);Je--,$n(),Nn({preferModelDiffHeight:!0,holdCurrentDiffHeight:Xe}),Dn(),Je>0?Ye=ve(l):Xe=!1};Ye=ve(l)}function Ln(e,l,t,n={}){const o=Dl.value&&!1!==s.loading?yn(e):null,r=null!=o&&o>l+1?o:l,a=Math.min(r,t),i=!0===n.allowBelowEstimatedFloor,u=ln(a,!0===n.clearEstimatedFloor,{allowBelowEstimatedFloor:i}),d=It();e.style.minHeight=null==d||i?"0px":`${Math.min(d,Math.ceil(t))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(t)}px`;const v=!0===n.preserveScrollableOverflow||r>t+1||_n(e,u);return e.style.overflow=v?"auto":"hidden",u}function _n(e,l=0){var t;const n=Math.ceil((null==(t=e.getBoundingClientRect)?void 0:t.call(e).height)||0),o=Math.max(l,e.clientHeight||0,n);return o>0&&e.scrollHeight>o+1}function Rn(e){var l;return el||_n(e,null!=(l=Qe.value)?l:0)}function jn(e=Ne.value){return An(e)}function qn(e=Ne.value){return An(e)}function In(){var e,l;if(An())return!0;const t=null==(l=null==(e=pl())?void 0:e.getModel)?void 0:l.call(e);return"function"==typeof(null==t?void 0:t.getValue)&&t.getValue()===ht.value}function An(e=Ne.value){return Boolean(null==e?void 0:e.querySelector("diffs-container"))}function Vn(){return!1!==s.loading||Yl.value}function Wn(){const e=gl();return Boolean("function"==typeof(null==e?void 0:e.getOriginalEditor)||"function"==typeof(null==e?void 0:e.getModifiedEditor)||"function"==typeof(null==e?void 0:e.getLineChanges))}function Un(){return d(this,null,function*(){if(!Dl.value)return!0;for(let e=0;e<30;e++){if(Ve)return!1;if(An())return yield O(),yield tn(),!Ve&&An();yield O(),yield tn()}return!1})}function Gn(e,l,t){return d(this,null,function*(){try{return void(yield cl(e,l,t))}catch(n){if(!_l(n))throw n}if(yield O(),yield tn(),!Ve&&Dl.value)try{yield cl(e,l,t)}catch(n){if(!_l(n))throw n}})}function Yn(){var e,l;return null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500}const Jn=v(()=>s.isShowPreview&&("html"===$e.value||"svg"===$e.value));function Xn(){return"boolean"==typeof s.node.loading?s.node.loading:!0===s.loading}function Kn(e,l,t){return!t||function(){var e,l,t;if(!Xn())return!0;const n=String(null!=(e=s.node.raw)?e:""),o=null!=(t=null==(l=n.split(/\r\n|\n|\r/,1)[0])?void 0:l.trimStart())?t:"";return!/^(?:`{3,}|~{3,})/.test(o)||/\r\n|\n|\r/.test(n)}()&&String(null!=l?l:"")?re(String(null!=e?e:"")):"plain"}function Qn(){return Xn()}let Zn=null,eo=!1,lo=0;function to(){Zn=null,lo++}function no(){return d(this,arguments,function*(e=lo){if(!eo){eo=!0;try{for(;Zn&&!Ve&&!Dl.value&&e===lo;){const e=Zn;Zn=null;try{yield Promise.resolve(vl(e.code,e.language)),yield O(),Ve||Dl.value||(Nn(!1),Dn())}catch(l){Pe()}}}finally{eo=!1,!Zn||Ve||Dl.value||no()}}})}function oo(e,l){Zn={code:e,language:l},no(lo)}P(()=>[s.node.language,s.node.code,s.node.raw,s.node.loading,s.loading],([e,l,t,n,o])=>{$e.value=Kn(e,l,"boolean"==typeof n?n:!0===o)}),P(()=>[s.node.originalCode,s.node.updatedCode,Dl.value],()=>{sn(),ve(()=>vn())},{immediate:!0});let ro=0;P(()=>[s.node.originalCode,s.node.updatedCode,ze.value,Dl.value,s.stream],e=>d(null,[e],function*([,,,e,l]){var t,n;const o=++ro;if(!e)return;if(Xn())return;if(!1===l&&!je.value)return;if(!1!==l&&dl&&!je.value&&Ne.value)try{yield yo(Ne.value)}catch(u){}const r=Sl;if(r&&!qe.value){try{yield r}catch(u){}if(Ve||!Dl.value||o!==ro)return}if(o!==ro)return;const a=zl(String(null!=(t=s.node.originalCode)?t:""),String(null!=(n=s.node.updatedCode)?n:"")),i=!1===s.loading;i&&Po();try{if(yield Gn(a.original,a.updated,ze.value),Ve||!Dl.value||o!==ro)return;yield O(),Dn(!0),$n(),Nn(!1===s.loading||{preferModelDiffHeight:!0}),Dn(!0),Tn(!0)}catch(d){return}if(i){if(Ve||!Dl.value)return;Rl(),$n(),vn(),Tn(),zn(!0)}_e.value&&ve(()=>Hn())})),P(()=>s.node.code,e=>d(null,null,function*(){if(Xn())return;if(!1===s.stream)return;if($e.value||($e.value=re(Ml(e))),Dl.value)return;const l=Sl;if(l&&!qe.value){try{yield l}catch(t){}if(Ve||Dl.value)return}if(dl&&!je.value&&Ne.value)try{yield yo(Ne.value)}catch(t){}oo(Ll(s.node.code),ze.value),_e.value&&ve(()=>Hn())}));const ao=v(()=>{const e=$e.value;return e?ae[e]||e.charAt(0).toUpperCase()+e.slice(1):ae[""]||"Plain Text"}),io=v(()=>{var e;return K(String(null!=(e=s.node.raw)?e:""),ao.value,Dl.value)}),uo=v(()=>io.value.title),so=v(()=>io.value.caption),vo=v(()=>(ie.value,ue($e.value||"",ge))),co=v(()=>{const e={};e["--markstream-code-layout-character-width"]=null==Ct.value?"1ch":`${Ct.value}px`,e["--markstream-code-fallback-bg"]=Vl.value.background,e["--markstream-code-fallback-fg"]=Vl.value.foreground,Vl.value.builtin&&(e["--markstream-code-theme-bg"]=Vl.value.background,e["--markstream-code-theme-fg"]=Vl.value.foreground,e["--markstream-code-theme-line-number"]=Vl.value.lineNumber),e["--markstream-diff-added-line-fill"]=Vl.value.diffAddedLine,e["--markstream-diff-added-number-fill"]=Vl.value.diffAddedNumber,e["--markstream-diff-editor-bg"]=Vl.value.background,e["--markstream-diff-removed-line-fill"]=Vl.value.diffRemovedLine,e["--markstream-diff-removed-number-fill"]=Vl.value.diffRemovedNumber,e["--markstream-diff-shell-bg"]=Vl.value.background,e["--markstream-pre-resolved-theme-bg"]=Vl.value.background,e["--markstream-pre-resolved-theme-fg"]=Vl.value.foreground,e["--markstream-pre-resolved-theme-line-number"]=Vl.value.lineNumber;const l=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=l(s.minWidth),n=l(s.maxWidth);if(t&&(e.minWidth=t),n&&(e.maxWidth=n),Ut.value&&!Dl.value&&!Re.value){const l=Gt.value;null!=l&&(e.minHeight=`${l}px`)}return e.color="var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))",e.backgroundColor="var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))",Dl.value||(e.borderColor="var(--markstream-code-border-color, var(--code-border))"),e}),fo=v(()=>!1!==s.showTooltips);function mo(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(s.node.code)),De.value=!0,p("copy",s.node.code),setTimeout(()=>{De.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function ho(){_e.value=!_e.value;const e=Dl.value?gl():pl(),l=Ne.value;e&&l&&(_e.value?(l.style.maxHeight="none",l.style.overflow="visible",Nn(!0)):(l.style.overflow="auto",Nn(!0)))}function po(){var e,l;if(Re.value=!Re.value,Re.value){if(el=!1,Ne.value){const t=Math.ceil((null==(l=(e=Ne.value).getBoundingClientRect)?void 0:l.call(e).height)||0);el=_n(Ne.value,t)||"auto"===Ne.value.style.overflow||"auto"===Ne.value.style.overflowY,t>0&&(Qe.value=t)}}else Ne.value&&null!=Qe.value&&(Ne.value.style.height=`${Qe.value}px`),Ze=2,O(()=>{Re.value||Ve||(Nn(!0),Dn(!0))})}function go(){if(!Jn.value)return;const e=$e.value;if(Oe.value){const l="html"===e?"text/html":"image/svg+xml",t="html"===e?Fe("artifacts.htmlPreviewTitle")||"HTML Preview":Fe("artifacts.svgPreviewTitle")||"SVG Preview";return void p("previewCode",{node:s.node,artifactType:l,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(mt.value=!mt.value)}function yo(e,l={}){if(!dl||Ve)return null;if(!1===s.stream&&!1!==s.loading)return null;if(Do(),$o())return null;if(Gl.value||Ne.value!==e)return null;if(Qn())return null;if(xl)return xl;if(je.value&&Ie.value)return Promise.resolve();const t=No(),n=Ql.value;let o=!1;je.value=!0,function(){const e=ye.value;he&&e&&Ke!==e&&(Ke&&he.markSettled(Ke),Ke=e,he.markPending(e))}();const r=d(null,null,function*(){try{yield function(e){return d(this,null,function*(){var l,t;if(!dl||Ve)return;We=!1;const n=Wl.value;if(ot=!1,Xl.value=!1,Kl.value=null,qe.value=!1,Yl.value=!1,Jl.value=!1,xt.value=null,St.value=null,Ct.value=null,Mt.value=null,En(),function(){if(et.value=!1,Lt())return void(qt.value=null);const e=Rt.value;qt.value=Ie.value||null==e?null:e}(),On(),Fn(),function(e){e.replaceChildren()}(e),Po(),yield le(Mo()),Ve)return;const o=d(null,null,function*(){var l,t;if("diff"===n){!function(){if(Pl||"undefined"==typeof window)return;Pl=!0;const e=e=>{var l;_l("reason"in e?e.reason:null!=(l=e.error)?l:e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener("error",e,!0),window.addEventListener("unhandledrejection",e,!0),Hl=()=>{window.removeEventListener("error",e,!0),window.removeEventListener("unhandledrejection",e,!0),Pl=!1,Hl=null}}(),bl();const n=zl(String(null!=(l=s.node.originalCode)?l:""),String(null!=(t=s.node.updatedCode)?t:""));sl?yield sl(e,n.original,n.updated,ze.value):yield dl(e,s.node.code,ze.value)}else yield dl(e,ht.value,ze.value);qe.value=!0}),r=o.finally(()=>{Sl===r&&(Sl=null)});if(Sl=r,yield function(e){return d(this,null,function*(){if(!Dl.value)return void(yield e);let l,t=!1;for(e.then(()=>{t=!0},e=>{t=!0,l=e});;){if(Ve)return;if(t){if(l)throw l;return}if(jn()&&Wn())return;yield O(),yield tn()}})}(r),Ve)return;if(Wl.value!==n)return;qe.value=!0;const a=null==(l=s.codeBlockOptions)?void 0:l.fontSize;if("number"==typeof a&&Number.isFinite(a)&&a>0){const e="diff"===n?gl():pl();null==(t=null==e?void 0:e.updateOptions)||t.call(e,{fontSize:a}),wt.value=a,kt.value=a}else if(!kn()){const e=on();e&&e>0?(wt.value=e,kt.value=e):(wt.value=12,kt.value=12)}for(wn();We;)if(We=!1,yield Co(),Ve)return;_e.value||Re.value||Nn(!1),Ie.value=!0,Ul.value=n,function(){var e,l,t,n,o;if(On(),Dl.value){const n=gl(),o=null==(e=null==n?void 0:n.getOriginalEditor)?void 0:e.call(n),r=null==(l=null==n?void 0:n.getModifiedEditor)?void 0:l.call(n),i=(e,l)=>{try{const t=null==e?void 0:e[l];if("function"!=typeof t)return;const n=t.call(e,()=>Tn());n&&Ol.push(n)}catch(t){}};try{const e=null==(t=null==n?void 0:n.onDidUpdateDiff)?void 0:t.call(n,()=>{Tn(),ve(()=>vn())});e&&Ol.push(e)}catch(a){}i(o,"onDidContentSizeChange"),i(r,"onDidContentSizeChange");const u=Ne.value;if(u&&"undefined"!=typeof MutationObserver){const e=["diffs-container",".stream-diffs-shell",".stream-diffs-surface"].join(","),l=l=>{var t;const n=l instanceof HTMLElement?l:l.parentElement;return Boolean(null==(t=null==n?void 0:n.closest)?void 0:t.call(n,e))},t=l=>{var t,n;const o=l instanceof HTMLElement?l:l.parentElement;return Boolean((null==(t=null==o?void 0:o.closest)?void 0:t.call(o,e))||(null==(n=null==o?void 0:o.querySelector)?void 0:n.call(o,e)))},n=new MutationObserver(e=>{Dl.value&&Vn()&&e.some(e=>l(e.target)||Array.from(e.addedNodes).some(t)||Array.from(e.removedNodes).some(l))&&($n(),Nn({preferModelDiffHeight:!0}),Dn(),zn())});n.observe(u,{attributeFilter:["class"],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Ol.push({dispose:()=>n.disconnect()})}if(u&&"undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{if(!Dl.value)return;if(Dn(),!Vn())return;const e=yn(u);null!=e&&(Math.ceil(u.getBoundingClientRect().height||0)<=e+1||($n(),Nn({preferModelDiffHeight:!0}),Dn()))});e.observe(u),Ol.push({dispose:()=>e.disconnect()})}return}const r=pl();try{const e=null==(n=null==r?void 0:r.onDidContentSizeChange)?void 0:n.call(r,()=>Tn());e&&Ol.push(e)}catch(a){}try{const e=null==(o=null==r?void 0:r.onDidLayoutChange)?void 0:o.call(r,()=>Tn());e&&Ol.push(e)}catch(a){}}(),Sn(),wn(),$n(),vn(),Tn(),yield O();let i=null;kl&&(i=yield kl(),i&&(yield O(),yield tn()));const u=null==i?"diff"===n?yield Un():yield function(){return d(this,null,function*(){if(An())return yield O(),yield tn(),An();for(let e=0;e<30;e++){if(Ve||Dl.value)return!1;const e=Ne.value,l=In(),t=qn(e),n=!ht.value.trim()||dn(e);if(l&&t&&n&&(yield O(),yield tn(),!Ve&&!Dl.value&&In()&&qn(Ne.value)&&(!ht.value.trim()||dn(Ne.value))))return!0;yield O(),yield tn()}return!1})}():i;Ve||(u?(wn(),en(),(yield Kt())||To()):To())})}(e),lt=null}catch(r){const e=No(),a=n!==Ql.value,i=!1!==l.allowStaleContentRetry&&a&&lt!==e;if(t!==e||i)return i&&(lt=e),o=!0,je.value=!1,Ie.value=!1,qe.value=!1,void(Yl.value=!1);throw To(t),r}}).finally(()=>{xl===r&&(xl=null),function(){const e=Ke;he&&e&&(Ke="",O(()=>{var l,t;if(!Ve){const n=null!=(t=null==(l=Ee.value)?void 0:l.offsetHeight)?t:0;n>0&&he.reportHeight(e,n)}he.markSettled(e)}))}(),o&&!Ve&&queueMicrotask(()=>{var e;const l=Ne.value;l&&!Ve&&(null==(e=yo(l))||e.catch(e=>{Ie.value=!1,Yl.value=!1,To()}))})});return xl=r,r}P(fo,e=>{e||Q()}),P(()=>kt.value,(e,l)=>{var t;const n=Dl.value?gl():pl();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(null==(t=n.updateOptions)||t.call(n,{fontSize:e}),Re.value||Nn(!0))},{flush:"post",immediate:!1});let bo=0;const wo=P(()=>[Ne.value,Dl.value,s.stream,s.loading,Ae.value,rl.value,s.node.language,s.node.raw,s.node.code,s.node.loading],e=>d(null,[e],function*([e,l,t,n,o,r]){const a=++bo;if(!e)return;if(!r)return;if(Xn())return;if(tt)return;if(!1===t&&!1!==n)return;if(!dl){if(yield function(){return d(this,null,function*(){if("undefined"==typeof window||Ve)return;if(Ae.value||Gl.value)return;if(Cl)return Cl;const e=d(null,null,function*(){try{const e=yield me();if(Ve)return;if(!e)return void(Gl.value=!0);gt(e)}catch(e){if(Ve)return;Gl.value=!0}}).finally(()=>{Cl===e&&(Cl=null)});return Cl=e,e})}(),a!==bo)return;if(!1===s.stream&&!1!==s.loading)return;if(Qn())return;if(!rl.value)return;if(!dl||Gl.value||je.value||$o()||Ve||Ne.value!==e)return}if(Qn())return;const i=yo(e);if(i){try{yield i}catch(u){Ie.value=!1,Yl.value=!1,To()}Ie.value&&Yl.value&&wo()}}));function ko(e){return"string"==typeof e?e:null}function xo(e,l){if(e===l)return!0;const t=ko(e),n=ko(l);return!!t&&t===n}function So(){return ee({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})}function Co(){return d(this,arguments,function*(e={}){Po();const l=()=>{Dl.value&&Rl(),ve(()=>{Sn(),Tn()})};if(e.appearanceOnly)return void l();const t=So();if(t)try{yield le(Mo()),yield Bl(t),l()}catch(n){}else l()})}function Mo(){const e=s.themes;return e&&"string"==typeof e[0]&&"string"==typeof e[1]?{dark:e[0],light:e[1]}:So()}function Bo(){var e,l,t,n,o;const r=Et.value,a=u(i({},jl.value||{}),{wordWrap:"wrap"===r.overflow?"on":"off",overflow:r.overflow,themes:s.themes,stream:!1,MAX_HEIGHT:null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500,fontSize:Pt.value,lineHeight:Ot.value,theme:So(),themeType:s.isDark?"dark":"light",disableLineNumbers:!b.value,disableFileHeader:!0,workerManager:null!=(o=null!=(n=null==(t=jl.value)?void 0:t.workerManager)?n:te())?o:void 0,onThemeChange(){Sn()}}),d=function(){var e;const l=null==(e=jl.value)?void 0:e.fontFamily;return"string"==typeof l&&l.trim()?l.trim():Dl.value?function(){var e;if("undefined"==typeof window)return;const l=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l)return;return window.getComputedStyle(l).fontFamily.trim()||void 0}():void 0}();d&&(null!=a.fontFamily||(a.fontFamily=d));const v="string"==typeof a.unsafeCSS?a.unsafeCSS:"",c=`\n[data-file] [data-line],\n[data-diff] [data-line] {\n white-space: ${"wrap"===(f=r.overflow)?"pre-wrap":"pre"} !important;\n overflow-wrap: ${"wrap"===f?"anywhere":"normal"} !important;\n word-break: normal !important;\n}`;var f;return a.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }\n${c}\n\n[data-no-newline],\n[data-gutter-buffer="metadata"] {\n --diffs-computed-decoration-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-computed-diff-line-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-computed-selected-line-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-line-bg: var(--markstream-diff-metadata-bg) !important;\n color: var(--markstream-diff-metadata-fg) !important;\n background-color: var(--markstream-diff-metadata-bg) !important;\n}\n${v}`.trim(),a}function Po(){const e=Bo();if(!Nl)return Nl=e,Nl;for(const l of Object.keys(Nl))l in e||delete Nl[l];return Object.assign(Nl,e),Nl}P(Wl,(e,l)=>d(null,null,function*(){if(e===l)return;if(Xl.value||tt)return;if(to(),!dl||!Ne.value)return;if(!je.value)return;if(!1===s.stream&&!1!==s.loading)return;if(!rl.value)return;const t=xl;if(t){try{yield t}catch(n){}if(Ve||!Ne.value)return}if(Ul.value!==e||!je.value||!Ie.value)try{Ie.value=!1,Yl.value=!1,je.value=!1,qe.value=!1,On(),Fn(),bl(),yield O(),yield yo(Ne.value)}catch(o){Ie.value=!1,Yl.value=!1,To()}}));const Ho=M(0),Oo=v(()=>String(Ho.value));let Fo=!1;function No(){var e;const l=So();return JSON.stringify({kind:Wl.value,language:ze.value,structural:Oo.value,optionsRevision:Ho.value,settledContentGeneration:Zl.value,theme:null!=(e=ko(l))?e:null==l?null:"custom",isDark:s.isDark})}P(()=>{var e;return null==(e=s.codeBlockOptions)?void 0:e.fontSize},e=>{const l="number"==typeof e&&Number.isFinite(e)&&e>0?e:yt;wt.value=l,kt.value=l,xt.value=null,St.value=null,Ct.value=null}),P(()=>[s.codeBlockOptions,s.showLineNumbers],()=>{Ho.value+=1,!1===s.stream&&!1!==s.loading&&(Fo=!0)},{deep:!0}),P(()=>[ht.value,s.node.originalCode,s.node.updatedCode],()=>{Ql.value+=1,Xn()||(Zl.value+=1)});const Eo=v(()=>No());function Do(){Xl.value&&Kl.value!==Eo.value&&(Xl.value=!1,Kl.value=null,lt=null,nt=null,je.value=!1,Ie.value=!1,qe.value=!1,Yl.value=!1,Jl.value=!1)}function $o(){return Do(),Xl.value&&Kl.value===Eo.value}function To(e=Eo.value){Kl.value=e,Xl.value=!0,Jl.value=!1}return P(Eo,()=>d(null,null,function*(){if(tt)return;if(!Xl.value)return;if(Kl.value===Eo.value)return;if(!dl||!Ne.value||Gl.value||Ve||!rl.value)return;if(!1===s.stream&&!1!==s.loading)return;if(Qn())return;const e=Eo.value;tt=!0;try{if(Do(),Xl.value)return;yield yo(Ne.value)}catch(l){Ie.value=!1,Yl.value=!1,To()}finally{nt=e,yield O(),tt=!1}})),P(()=>[s.codeBlockOptions,rl.value],()=>{var e,l;if(Po(),!dl||!rl.value)return;const t=Dl.value?gl():pl(),n="number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize)?s.codeBlockOptions.fontSize:Number.isFinite(kt.value)?kt.value:void 0;"number"==typeof n&&Number.isFinite(n)&&n>0&&(null==(l=null==t?void 0:t.updateOptions)||l.call(t,{fontSize:n})),Nn(!1)},{deep:!0}),P(()=>[So(),Il.value,Ae.value,je.value,rl.value],([e,l],t)=>{if(!Ae.value||!rl.value)return;const n=null!=t&&xo(e,t[0]),o=null!=t&&l!==t[1];Ie.value?(We=!1,Co({appearanceOnly:n})):n&&!o||(We=!0)},{flush:"post"}),P(()=>[Oo.value,Ae.value,rl.value],(e,l)=>d(null,[e,l],function*([e,l,t],[n]){if(Po(),!l||!t)return;if(!dl||!Ne.value)return;if(!je.value)return;if(e===n)return;if(!1===s.stream&&!1!==s.loading)return void(Fo=!0);Fo=!1;const o=xl;if(o){try{yield o}catch(r){}if(Ve||!Ne.value)return}try{Ie.value=!1,Yl.value=!1,je.value=!1,qe.value=!1,On(),Fn(),bl(),El&&gt(El),yield O(),yield yo(Ne.value,{allowStaleContentRetry:!1})}catch(a){Ie.value=!1,Yl.value=!1,To()}}),{flush:"post"}),P(()=>[s.loading,rl.value],([e,l])=>{!1===e&&l&&Fo&&(Fo=!1,Ho.value+=1)},{flush:"post"}),P(()=>[s.loading,rl.value],(e,l)=>d(null,[e,l],function*([e,l],t){if(!l)return;const n=null==t?void 0:t[0];if(!1===n&&!1!==e&&Dl.value&&je.value&&(yield O(),ve(()=>{d(null,null,function*(){const e=xl;if(e)try{yield e}catch(l){}!Ve&&Dl.value&&!1!==s.loading&&(Po(),Rl(),Tn())})})),e)return;const o=void 0!==n&&!1!==n;yield O(),ve(()=>{d(null,null,function*(){var e,l;try{if(o&&(yield function(){return d(this,null,function*(){if(!Xl.value)return!1;if(!dl||!Ne.value||Gl.value||Ve||!rl.value)return!1;if(nt===Eo.value)return!0;tt=!0;try{Xl.value=!1,Kl.value=null,lt=null,je.value=!1,Ie.value=!1,qe.value=!1,Yl.value=!1,On(),Fn(),bl(),El&&gt(El),yield O();try{yield yo(Ne.value)}catch(e){Ie.value=!1,Yl.value=!1,To()}}finally{yield O(),tt=!1}return!0})}()))return void Nn(!1);if(o&&Dl.value&&je.value&&ot&&Ne.value)return ot=!1,Ie.value=!1,Yl.value=!1,je.value=!1,qe.value=!1,On(),Fn(),bl(),yield O(),yield yo(Ne.value,{allowStaleContentRetry:!1}),void zn(!0);if(o&&je.value)if(Dl.value&&Ne.value){const n=xl;if(n)try{yield n}catch(t){}Po();const o=zl(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:""));if(yield Gn(o.original,o.updated,ze.value),Ve||!Dl.value)return;yield Promise.resolve(ml()),Rl(),Dn(!0),Xt(),$n(),vn();const r=yield Un();Ve||!r||Yl.value||(yield Kt()),Tn(),zn(!0)}else to(),oo(ht.value,ze.value),yield new Promise(e=>{const l=()=>{Ve?e():eo||Zn?setTimeout(l,16):e()};l()}),Ve||Dl.value||(yield Promise.resolve(fl()));o&&Dl.value?(Nn({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),zn(!0)):Nn(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{On(),Fn(),yl(),null==Hl||Hl()}),(l,t)=>{var n;return Gl.value?(m(),h(de,{key:0,style:F(Wt.value),node:pt.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":rt.value,"diff-hide-unchanged-regions":at.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Et.value,"reserved-height-px":Dl.value&&null!=(n=Mt.value)?n:void 0,"is-dark":s.isDark,theme:s.theme,"dark-theme":s.darkTheme,"light-theme":s.lightTheme,themes:s.themes,"show-header":s.showHeader,"show-copy-button":s.showCopyButton,"show-tooltips":s.showTooltips},N({_:2},[l.$slots["header-left"]?{name:"header-left",fn:E(()=>[D(l.$slots,"header-left",{},void 0,!0)]),key:"0"}:void 0,l.$slots["header-right"]?{name:"header-right",fn:E(()=>[D(l.$slots,"header-right",{},void 0,!0)]),key:"1"}:void 0]),1032,["style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","code-block-options","resolved-visual-options","reserved-height-px","is-dark","theme","dark-theme","light-theme","themes","show-header","show-copy-button","show-tooltips"])):(m(),$("div",{key:1,ref_key:"container",ref:Ee,style:F(co.value),class:y(["code-block-container rounded-lg border",[{dark:s.isDark,"is-rendering":s.loading,"is-dark":Al.value,"is-diff":Dl.value,"is-plain-text":Le.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":Yl.value&&!Gl.value?"true":"false","data-markstream-enhancement-state":ft.value,"data-markstream-code-block-state":Xn()?"streaming":"settled","data-markstream-pending":ct.value?"true":void 0,"data-markstream-viewport-pending":ul.value&&k(nl)&&!rl.value?"true":void 0},[T(se,{"show-header":s.showHeader,"show-collapse-button":s.showCollapseButton,"show-font-size-buttons":s.showFontSizeButtons,"enable-font-size-control":s.enableFontSizeControl,"show-copy-button":s.showCopyButton,"show-expand-button":s.showExpandButton,"show-preview-button":s.showPreviewButton,"show-tooltips":s.showTooltips,"is-dark":s.isDark,loading:s.loading,stream:e.stream,"is-collapsed":Re.value,"is-expanded":_e.value,"copy-text":De.value,"is-previewable":Jn.value,"code-font-size":kt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":wt.value,"font-baseline-ready":Bt.value,"diff-stats":Dl.value?$l.value:null,"diff-stats-aria-label":Tl.value,onToggleCollapse:po,onDecreaseFont:mn,onResetFont:hn,onIncreaseFont:fn,onCopy:mo,onToggleExpand:ho,onPreview:go},N({"header-left":E(()=>[D(l.$slots,"header-left",{},()=>[g("div",ke,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:vo.value},null,8,xe),g("div",Se,[g("div",Ce,w(uo.value),1),so.value?(m(),$("div",Me,w(so.value),1)):L("",!0)])])],!0)]),loading:E(()=>[D(l.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:E(()=>{var l;return[z(g("div",{class:y(["code-editor-layer",{"code-editor-layer--collapsed":Re.value}])},[g("div",{ref_key:"codeEditor",ref:Ne,class:y(["code-editor-container",e.stream?"":"code-height-placeholder"]),"data-markstream-host-hidden":vt.value?"true":void 0,style:F(Yt.value)},null,14,Be),st.value?(m(),h(de,{key:0,style:F(Wt.value),node:pt.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":rt.value,"diff-hide-unchanged-regions":at.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Et.value,"reserved-height-px":Dl.value&&null!=(l=Mt.value)?l:void 0,"is-dark":s.isDark,theme:s.theme,"dark-theme":s.darkTheme,"light-theme":s.lightTheme,themes:s.themes,"show-toolbar":!1},null,8,["style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","code-block-options","resolved-visual-options","reserved-height-px","is-dark","theme","dark-theme","light-theme","themes"])):L("",!0)],2),[[_,!!e.stream||!e.loading]]),mt.value&&!Oe.value&&Jn.value&&"html"===$e.value?(m(),h(be,{key:0,code:s.node.code,"html-preview-allow-scripts":s.htmlPreviewAllowScripts,"html-preview-sandbox":s.htmlPreviewSandbox,"is-dark":s.isDark,"on-close":()=>mt.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):L("",!0)]}),_:2},[l.$slots["header-right"]?{name:"header-right",fn:E(()=>[D(l.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready","diff-stats","diff-stats-aria-label"])],14,we))}}}),[["__scopeId","data-v-4e4a9920"]]);export{Pe as default};