markstream-vue 2.0.0 → 2.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CodeBlockNode.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/tailwind.js +0 -0
- package/package.json +1 -1
package/dist/CodeBlockNode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,l=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,r=(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)&&r(e,t,l[t]);if(n)for(var t of n(l))a.call(l,t)&&r(e,t,l[t]);return e},u=(e,n)=>l(e,t(n)),d=(e,l,t)=>new Promise((n,o)=>{var a=e=>{try{i(t.next(e))}catch(l){o(l)}},r=e=>{try{i(t.throw(e))}catch(l){o(l)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,r);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{as as R,G as j,M as q,ah as I,au as A,av as V,ar as W,a8 as U,af as G,b as Y,c as J,aj as X,ae as K,a6 as Q,ab as Z,ai as ee}from"./exports.js";import{M as le,f as te,n as ne,c as oe,l as ae}from"./index2.js";import{r as re,_ as ie,a as ue}from"./PreCodeBlock.vue_vue_type_style_index_0_lang.js";import{safeRaf as de,safeCancelRaf as se}from"./utils/safeRaf.js";import{r as ve}from"./preCodeTheme.js";import{getStreamDiffsRuntime as ce}from"./streamDiffs.js";const fe={class:"html-preview-frame__header"},me={class:"html-preview-frame__title"},he={class:"html-preview-frame__label"},pe=["sandbox","srcdoc"],ge=/* @__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(),a=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>`}),r=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",fe,[g("div",me,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",he,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:r.value,referrerpolicy:"no-referrer",srcdoc:a.value},null,8,pe)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]),ye=["data-markstream-enhanced","data-markstream-enhancement-state","data-markstream-code-block-state","data-markstream-pending","data-markstream-viewport-pending"],be={class:"code-header-main"},we=["innerHTML"],ke={class:"code-header-copy"},xe={class:"code-header-title"},Se={key:0,class:"code-header-caption"},Ce=["data-markstream-host-hidden"],Me=/* @__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,a,r;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(),fe=S(le,null),me=S("markstreamHostScrollManaged",null),he=S(q,void 0),pe=v(()=>I(s,j));function Me(e,l){}const Be=C(),Pe=v(()=>{const e=null==Be?void 0:Be.vnode.props;return!(!e||!e.onPreviewCode&&!e["onPreview-code"])}),{t:He}=R(),Oe=M(null),Fe=M(null),Ne=M(!1),Ee=M(Yn(s.node.language,s.node.code,Gn())),De=v(()=>te(Ee.value)),$e=v(()=>"plaintext"===De.value?"text":De.value),Te=v(()=>"plaintext"===De.value),ze=M(!1),Le=M(!1),_e=M(!1),Re=M(!1),je=M(!1),qe=M(!1);let Ie=!1,Ae=null,Ve=null,We=null,Ue=0,Ge=!1,Ye="";const Je=M(null);let Xe=0,Ke=!1;const Qe=A(),Ze=V(),el=W(),ll=B(null),tl=M("undefined"==typeof window||!el.value),nl=null!=(o=null==(n=null==(t=C())?void 0:t.vnode.el)?void 0:n.textContent)?o:"",ol="undefined"!=typeof window&&String(null!=(a=s.node.code)?a:"").length>0&&nl.includes(String(s.node.code)),al=M(!ol);c(()=>{al.value=!0}),"undefined"!=typeof window&&P([()=>Fe.value,el],([e,l],t,n)=>{var o,a,r;if(null==(o=ll.value)||o.destroy(),ll.value=null,!l||tl.value)return void(tl.value=!0);if(!e)return void(tl.value=!1);let i=!0;const u=null!=(r=null!=(a=null==Ze?void 0:Ze.value.heavyBlockMargin)?a:null==Ze?void 0:Ze.value.rootMargin)?r:"0px",d=Qe(e,{rootMargin:u,allowIdle:!1});ll.value=d,tl.value=tl.value||d.isVisible.value,d.whenVisible.then(()=>{i&&ll.value===d&&(tl.value=!0)}).catch(()=>{}),n(()=>{i=!1,d.destroy(),ll.value===d&&(ll.value=null)})},{immediate:!0}),H(()=>{var e;Ie=!0,function(){const e=Ye;fe&&e&&(Ye="",fe.markSettled(e))}(),null==(e=ll.value)||e.destroy(),ll.value=null});let rl=null,il=null,ul=()=>{},dl=()=>{},sl=()=>{},vl=()=>{},cl=()=>null,fl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),ml=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),hl=()=>{},pl=()=>{},gl=()=>{},yl=null,bl=null,wl=null,kl=null,xl=()=>{var e;return String(null!=(e=s.node.language)?e:"plaintext")},Sl=()=>d(null,null,function*(){}),Cl=!1,Ml=null;const Bl=[],Pl=[];let Hl=null,Ol=null;const Fl=v(()=>U(s.node)),Nl=M({removed:0,added:0}),El=v(()=>`-${Nl.value.removed} +${Nl.value.added}`);function Dl(e,l){return{original:e,updated:l}}function $l(e){return String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"")}function Tl(e){var l;return String(null!=(l=null==e?void 0:e.message)?l:e).includes("no diff result available")}function zl(){if(!jn())try{const e=gl();e&&"function"==typeof e.catch&&e.catch(e=>{Tl(e)})}catch(e){Tl(e)}}const Ll=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(!Fl.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)})}),_l=v(()=>{return(void 0!==s.theme?(e=s.theme)&&"object"==typeof e&&"light"in e&&"dark"in e:!bo(s.darkTheme,s.lightTheme))?!!s.isDark:function(e){var l;const t=null!=(l=yo(e))?l:"";return Z(t,!0===s.isDark)}(wo());var e}),Rl=v(()=>(Fl.value,_l.value?"dark":"light")),jl=v(()=>Fl.value?"dark"===Rl.value:_l.value),ql=v(()=>ve({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})),Il=v(()=>Fl.value?"diff":"single"),Al=M(Il.value),Vl=M(!1),Wl=M(!1),Ul=M(!1),Gl=M(!1),Yl=M(null),Jl=M(0),Xl=M(0),Kl=M(!1);let Ql=null,Zl=!1,et=null,lt=!1;const tt=v(()=>{var e;return!!Fl.value&&"unified"===(null==(e=Ll.value)?void 0:e.diffStyle)}),nt=v(()=>G(Ll.value));function ot(e){return!0===(null==me?void 0:me.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 at=v(()=>ot(Fe.value)),rt=v(()=>!(Vl.value||!Gl.value&&Wl.value)),it=v(()=>rt.value),ut=v(()=>rt.value&&!Ul.value),dt=v(()=>!Vl.value&&!Gl.value&&rt.value),st=v(()=>Wl.value&&!Vl.value?"ready":Gl.value?"fallback":"pending"),vt=M(!1),ct=v(()=>$l(s.node.code)),ft=v(()=>Fl.value?!0===s.node.diff?s.node:u(i({},s.node),{diff:!0}):ct.value===s.node.code?s.node:u(i({},s.node),{code:ct.value}));function mt(e){const l=e.detectLanguage;"function"==typeof l&&(xl=l),Ol=e,Hl=xo();const t=e.createCodeBlockRuntime(Hl);return!!t&&(rl=t.createEditor||rl,il=t.createDiffEditor||il,ul=t.updateCode||ul,dl=t.updateDiff||dl,sl=t.finalizeCode||sl,vl=t.finalizeDiff||vl,cl=t.getEditor||cl,fl=t.getEditorView||fl,ml=t.getDiffEditorView||ml,hl=t.cleanupEditor||hl,pl=t.safeClean||t.cleanupEditor||pl,gl=t.refreshDiffPresentation||gl,Sl=t.setTheme||Sl,yl=t.whenVisualReady||null,qe.value=!0,!0)}const ht=Y,pt=J,gt=M("number"==typeof(null==(r=s.codeBlockOptions)?void 0:r.fontSize)?s.codeBlockOptions.fontSize:Number.NaN),yt=M(gt.value),bt=M(null),wt=M(null),kt=M(null),xt=M(null),St=v(()=>{const e=gt.value,l=yt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof l&&Number.isFinite(l)&&l>0}),Ct=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=yt.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:ht}),Mt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.lineHeight;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:Ct.value===ht?pt:Math.max(12,Math.round(1.5*Ct.value))}),Bt=v(()=>Mt.value),Pt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.tabSize;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:4}),Ht=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}}),Ot=v(()=>{const e=X(s.codeBlockOptions);return u(i({},e),{fontSize:Ct.value,lineHeight:Bt.value,maxHeight:Wn(),padding:Ht.value.top,paddingBottom:Ht.value.bottom,tabSize:Pt.value})}),Ft=v(()=>{const e=s.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Nt(e){if(null==e)return null;const l=Math.ceil(e);return!Number.isFinite(l)||l<=0?null:Math.min(l,Math.ceil(Wn()))}function Et(){return!Fl.value&&!1!==s.stream&&!1!==s.loading}const Dt=M(Et());function $t(){return Et()||Dt.value}const Tt=v(()=>Fl.value?null:null==Ft.value||$t()?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})(ct.value)*Bt.value+1):null),zt=v(()=>{if(Fl.value)return null;const e=Ft.value;return null==e||$t()?Nt(Tt.value):Nt(e)}),Lt=v(()=>{const e=s.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),_t=M(null);function Rt(){const e=_t.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}const jt=v(()=>{const e=Rt();return null!=e?e:!Fl.value&&Kl.value?null:rt.value||!Wl.value?zt.value:null});function qt(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 It=v(()=>{const e=Nt(Ft.value),l=Nt(Tt.value),t=$t(),n=i({},Fl.value||null==e||t?Fl.value||null==l?{}:{minHeight:`${l}px`}:{height:`${e}px`,minHeight:`${e}px`});if(n["--markstream-code-fallback-bg"]=ql.value.background,n["--markstream-code-fallback-fg"]=ql.value.foreground,ql.value.builtin&&(n["--markstream-code-theme-bg"]=ql.value.background,n["--markstream-code-theme-fg"]=ql.value.foreground,n["--markstream-code-theme-line-number"]=ql.value.lineNumber),n["--markstream-pre-line-number-top"]=`${Ht.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",Fl.value){n["--markstream-pre-diff-line-height"]=`${Bt.value}px`,n["--markstream-pre-diff-pane-bottom-padding"]=(tt.value,"0px");const e=xt.value;null!=e&&e>0&&(n.height=`${e}px`,n.minHeight=`${e}px`,n.maxHeight=`${e}px`),Object.assign(n,qt(jl.value))}return n}),At=v(()=>null!=jt.value&&(!Wl.value||null!=Rt())),Vt=v(()=>{const e=jt.value;if(null==e)return null;if(Fl.value)return Math.ceil(e);const l=Lt.value,t=Ft.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)}),Wt=v(()=>{if(Fl.value&&rt.value)return{};const e=jt.value;return At.value&&null!=e?{minHeight:`${e}px`}:{}});function Ut(){_t.value=null}function Gt(){var e,l,t,n,o,a,r,i;const u=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback"),d=ml(),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==(r=null==(a=null==d?void 0:d.getModifiedEditor)?void 0:a.call(d))?void 0:r.setScrollTop)||i.call(r,s)}function Yt(){return d(this,null,function*(){return Fl.value?(bn(),Kt(),Fn(!0),Gt(),Nn(),Ul.value=!0,yield O(),Fn(!0),yield Zt(),Fn(!0),gn(),Kt(),!!(yield function(){return d(this,null,function*(){var e;if(!Fl.value)return!0;for(let l=0;l<4;l++){const l=Kt();Fn(!0),Jt(l),Xt(l),yield O(),yield Zt();const t=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!t)return!1;if(null==l)return Ln();const n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-l)<=2)return!0}return!1})}())&&(Wl.value=!0,yield O(),Kt(),Fn(!0),gn(),Nn(),de(()=>{Ie||de(()=>{Ie||(function(){var e,l;const t=null==(e=Fe.value)?void 0:e.querySelector(".code-block-shell-content"),n=null==(l=Fe.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"))}(),En(!0))})}),En(),!0)):!(yl&&!(yield yl())||(bn(),Fn(!0),Ul.value=!0,yield O(),bn(),Fn(!0),yield Zt(),bn(),Fn(!0),Wl.value=!0,yield O(),En(),0))})}function Jt(e){var l;if(!Fl.value)return;const t=Oe.value,n=null==(l=Fe.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 a=Math.ceil(o),r=`${a}px`;xt.value=a;const i=Fe.value;i&&(i.dataset.markstreamDiffHandoffHeight=r),n.dataset.markstreamDiffHandoffHeight=r,n.style.setProperty("height",r),n.style.setProperty("min-height",r)}function Xt(e){var l,t,n;if(!Fl.value)return;const o=null==(l=Fe.value)?void 0:l.querySelector(".code-block-shell-content"),a=null==(t=Fe.value)?void 0:t.querySelector(".code-editor-layer");if(!o||!a)return;const r="number"==typeof e&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat((null==(n=Oe.value)?void 0:n.style.height)||"");if(!Number.isFinite(r)||r<=0)return;const i=`${r}px`;a.style.height=i,a.style.minHeight=i,o.style.height=i,o.style.minHeight=i}function Kt(){const e=Oe.value;if(e&&Ln(e)){Nn();const l=hn(e);if(null!=l&&l>0){const t=Math.ceil(l),n=Math.ceil(Wn()),o=Math.min(t,n),a=`${o}px`;return e.style.height=a,e.style.minHeight="0px",e.style.maxHeight=`${n}px`,e.style.overflow=t>n+1?"auto":"hidden",rt.value&&(xt.value=o,Jt(o)),Dn(),o}return Hn({preferModelDiffHeight:!0}),Jt(),Dn(),Number.parseFloat(e.style.height||"")||null}return bn()}function Qt(e,l=!1,t={}){const n=Math.ceil(e),o=Rt();if(null==o)return n;const a=!0===t.allowBelowEstimatedFloor;return n>=o||a?((l||a)&&je.value&&Ut(),n):o}function Zt(){return new Promise(e=>{let l=!1,t=null,n=null;const o=()=>{l||(l=!0,null!=n&&globalThis.clearTimeout(n),null!=t&&se(t),e())};n=globalThis.setTimeout(o,50),t=de(o)})}function en(){var e;try{const l=Oe.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 ln(){var e,l,t,n,o,a;try{const a=Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl(),r=cl(),i=null==(n=null==r?void 0:r.EditorOption)?void 0:n.fontInfo;if(a&&null!=i){const e=null==(o=a.getOption)?void 0:o.call(a,i),l=null==e?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(r){}try{const e=Oe.value;if(e){const l=null!=(a=e.querySelector(".stream-diffs-shell .stream-diffs-surface"))?a: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(r){}}}catch(r){}return null}function tn(e){var l,t;try{const n=cl(),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(a){}const n=en();if(n&&n>0)return n;const o=Number.isFinite(yt.value)&&yt.value>0?yt.value:14;return Math.max(12,Math.round(1.35*o))}function nn(){var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding;return"number"==typeof l&&Number.isFinite(l)?2*Math.max(0,l):Fl.value?24:0}function on(e){const l=$l(e);return l?l.split(/\r\n|\n|\r/):[]}function an(e){return!!Te.value||!!e&&(jn(e)||null!=yl)}function rn(){var e,l;Fl.value?Nl.value=function(e,l){const t=on(e),n=on(l);let o=0,a=t.length-1,r=n.length-1;for(;o<=a&&o<=r&&t[o]===n[o];)o++;for(;a>=o&&r>=o&&t[a]===n[r];)a--,r--;const i=Math.max(0,a-o+1),u=Math.max(0,r-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),a=new Uint32Array(e);for(let d=i-1;d>=0;d--){a[u]=0;for(let r=u-1;r>=0;r--)a[r]=t[o+d]===n[o+r]?l[r+1]+1:Math.max(l[r],a[r+1]);const e=l;l=a,a=e}const r=l[0];return{removed:i-r,added:u-r}}return{removed:i,added:u}}(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:"")):Nl.value={removed:0,added:0}}function un(){rn()}function dn(){var e;if(Number.isFinite(yt.value)&&yt.value>0&&Number.isFinite(gt.value))return yt.value;if("number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize))return gt.value=s.codeBlockOptions.fontSize,yt.value=s.codeBlockOptions.fontSize,s.codeBlockOptions.fontSize;const l=ln();return l&&l>0?(gt.value=l,yt.value=l,l):(gt.value=12,yt.value=12,12)}function sn(){const e=dn(),l=Math.min(36,e+1);yt.value=l}function vn(){const e=dn(),l=Math.max(10,e-1);yt.value=l}function cn(){dn(),Number.isFinite(gt.value)&&(yt.value=gt.value)}function fn(){var e,l,t,n,o,a,r,i,u,d,s,v,c,f;try{const m=Fl.value?ml():null,h=Fl.value?m:fl();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==(a=null==f?void 0:f.getContentHeight)?void 0:a.call(f))||0,g=Math.max(h,p);if(g>0)return Math.ceil(g);const y=(null==(u=null==(i=null==(r=null==c?void 0:c.getModel)?void 0:r.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(tn(c),tn(f)),x=nn();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 Fl.value||(Kl.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=tn(h);return Math.ceil(g*(y+1.5)+0)}catch(m){return null}}function mn(){var e,l;if(Fl.value)return!1;try{const t=null==(l=null==(e=fl())?void 0:e.getContentHeight)?void 0:l.call(e),n="number"==typeof t&&Number.isFinite(t)&&t>0;return n&&(Kl.value=!0),n}catch(t){return!1}}function hn(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 pn(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[a,r,i]=o.slice(0,3).map(Number);return.2126*a+.7152*r+.0722*i}function gn(){var e,l,t;if(yn())return;const n=ln();n&&n>0&&(bt.value=n,yt.value=n,gt.value=n);try{const n=tn(Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl());n&&n>0&&(wt.value=n)}catch(o){}try{const e=en();e&&e>0&&(wt.value=e)}catch(o){}}function yn(){return Fl.value&&it.value}function bn(){var e;if(!rt.value)return null;const l=Oe.value,t=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l||!t)return null;const n=Math.ceil(t.getBoundingClientRect().height),o=Fl.value?hn(l):null,a=Math.max(n,null!=o&&o>0?Math.ceil(o):0),r=Math.ceil(Wn()),i=Math.min(a,r);return!Number.isFinite(i)||i<=0?null:(Fl.value&&i>n&&(xt.value=i),l.style.height=`${i}px`,l.style.minHeight=`${i}px`,l.style.maxHeight=`${r}px`,l.style.overflow=a>r+1?"auto":"hidden",i)}function wn(){var e,l,t,n,o,a,r,i,u;const d=Oe.value,v=Fe.value;if(!d||!v)return;const c=d;c.style.setProperty("--markstream-diff-metadata-bg",ql.value.background),c.style.setProperty("--markstream-diff-metadata-fg",ql.value.lineNumber),c.style.setProperty("--diffs-tab-size",String(Pt.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",`${Ht.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!=(r=null!=(a=null==y?void 0:y.color)?a:null==p?void 0:p.color)?r:"").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 a=Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl(),r=cl(),i=null==(n=null==r?void 0:r.EditorOption)?void 0:n.fontInfo;if(a&&null!=i){const e=null==(o=a.getOption)?void 0:o.call(a,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&&(kt.value=C),Fl.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(qt(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(!Te.value)return!1;const n=pn(e),o=pn(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,Fl.value],([e,l,t,n])=>{n||!1===e||!1===l||Dt.value?(n||!1===e)&&Dt.value&&(Dt.value=!1):(Dt.value=!0,Ut())},{immediate:!0});let kn=0,xn=0;const Sn=/auto|scroll|overlay/i;function Cn(e,l,t){var n;if("undefined"==typeof window)return;if(Fl.value)return;if(function(e){return at.value||ot(e)}(e))return;const o=Math.ceil(l),a=Math.ceil(t)-o;if(Math.abs(a)<=1)return;const r=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 a=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;a&&a!==n.body&&a!==o;){const e=window.getComputedStyle(a),l=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(Sn.test(l)||Sn.test(t))return a;a=a.parentElement}return o}(e);if(!r)return;const i=null!=(n=e.ownerDocument)?n:document,u=r===i.body||r===i.documentElement||r===i.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,a):r.scrollTop+=a)}function Mn(){try{const e=Oe.value;if(!e)return;const l=e.getBoundingClientRect().height,t=fn();if(null!=t&&t>0){const n=Qt(t,!0,{allowBelowEstimatedFloor:!Fl.value&&je.value&&mn()}),o=Rt();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",void Cn(e,l,n)}const n=Rt();null!=n&&(e.style.minHeight=`${n}px`,e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",Cn(e,l,n))}catch(e){}}function Bn(){for(var e,l;Bl.length>0;)try{null==(l=null==(e=Bl.pop())?void 0:e.dispose)||l.call(e)}catch(t){}null!=Ae&&(se(Ae),Ae=null),null!=Ve&&(se(Ve),Ve=null),null!=We&&(se(We),We=null),Ue=0,Ge=!1}function Pn(){for(var e;Pl.length>0;)try{null==(e=Pl.pop())||e()}catch(l){}}function Hn(e=!1){Le.value||(ze.value?Mn():function(e={}){var l;try{const t=Oe.value;if(!t)return;const n=t.getBoundingClientRect().height,o=Wn(),a=Math.ceil((null==(l=t.getBoundingClientRect)?void 0:l.call(t).height)||0),r=Number.parseFloat(t.style.height||""),i=a>0?a:Number.isFinite(r)&&r>0?Math.ceil(r):0,u=Fl.value?function(){var e,l,t,n,o,a,r,i,u,d,s,v;if(jn())return null;try{const c=ml(),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==(r=null==(a=m.getModel)?void 0:a.call(m))?void 0:r.getLineCount)?void 0:i.call(r))||1,g=Math.max(h,p),y=Math.max(tn(f),tn(m)),b=nn(),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=Fl.value&&Ln(t);if(Xe>0&&(Xe--,null!=Je.value))return void Cn(t,n,$n(t,Je.value,o,{preserveScrollableOverflow:zn(t)}));if(Fl.value&&!d&&rt.value){const e=bn();if(null!=e){const l=$n(t,e,o,{allowBelowEstimatedFloor:!0});return Fn(!0),void Cn(t,n,l)}}const v=Fl.value&&!0===e.preferModelDiffHeight,c=Fl.value?hn(t):null,f=!Fl.value&&je.value&&mn(),m=Fl.value&&!1!==s.loading&&(null!=c||null!=u&&a>0&&u<a-1),h=null!=u;let p;if(Fl.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=tt.value&&null!=c||null!=c?h?Math.max(c,u):c:Fl.value&&!1!==s.loading?null!=u&&i>0&&u<i-1?u:i>0?i:null:u;else p=fn();if(Fl.value&&null!=p&&i>0&&(!1!==s.loading||!0===e.holdCurrentDiffHeight)&&(p=Math.max(p,i)),null!=p&&p>0)return void Cn(t,n,$n(t,p,o,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||m,preserveScrollableOverflow:zn(t)}));if(null!=Je.value)return void Cn(t,n,$n(t,Je.value,o,{preserveScrollableOverflow:zn(t)}));const g=Fl.value&&!1!==s.loading?a:Math.max(a,null!=u&&u>0?u:0);if(g>0)return void Cn(t,n,$n(t,g,o));const y=Rt();if(!(null==y||Fl.value&&!1!==s.loading&&d))return void Cn(t,n,$n(t,y,o));const b=Number.parseFloat(t.style.height);!Number.isNaN(b)&&b>0?Cn(t,n,$n(t,b,o)):Fl.value||Cn(t,n,$n(t,o,o))}catch(t){}}("object"==typeof e?e:{}))}function On(){kn=0,xn=0}function Fn(e=!1){var l,t,n;if(Le.value)return;const o=Oe.value;if(!o)return;const a=Fl.value?ml():fl();if(a&&"function"==typeof a.layout)try{const r=null==(l=o.getBoundingClientRect)?void 0:l.call(o),i=Math.ceil((null!=(t=null==r?void 0:r.width)?t:0)||o.clientWidth||0),u=Math.ceil((null!=(n=null==r?void 0:r.height)?n:0)||o.clientHeight||Number.parseFloat(o.style.height||"")||0);if(i>0&&u>0){if(!e&&i===kn&&u===xn)return;kn=i,xn=u,a.layout({width:i,height:u})}else On(),a.layout()}catch(r){}}function Nn(){Pn()}function En(e=!1){if(Ie||null!=Ae)return;const l=()=>{Ie||(Nn(),Hn(e),Fn())};Ae=de(()=>{Ae=null,l(),Ve=de(()=>{Ve=null,l()})}),Dn()}function Dn(e=!1){if(!Fl.value||Ie||!e&&!1===s.loading)return;if(Ge=Ge||e,Ue=Math.max(Ue,e?18:6),null!=We)return;const l=()=>{if(We=null,!Fl.value||Ie||Ue<=0||!Ge&&!1===s.loading)return Ue=0,void(Ge=!1);Ue--,Nn(),Hn({preferModelDiffHeight:!0,holdCurrentDiffHeight:Ge}),Fn(),Ue>0?We=de(l):Ge=!1};We=de(l)}function $n(e,l,t,n={}){const o=Fl.value&&!1!==s.loading?hn(e):null,a=null!=o&&o>l+1?o:l,r=Math.min(a,t),i=!0===n.allowBelowEstimatedFloor,u=Qt(r,!0===n.clearEstimatedFloor,{allowBelowEstimatedFloor:i}),d=Rt();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||a>t+1||Tn(e,u);return e.style.overflow=v?"auto":"hidden",u}function Tn(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 zn(e){var l;return Ke||Tn(e,null!=(l=Je.value)?l:0)}function Ln(e=Oe.value){return jn(e)}function _n(e=Oe.value){return jn(e)}function Rn(){var e,l;if(jn())return!0;const t=null==(l=null==(e=fl())?void 0:e.getModel)?void 0:l.call(e);return"function"==typeof(null==t?void 0:t.getValue)&&t.getValue()===ct.value}function jn(e=Oe.value){return Boolean(null==e?void 0:e.querySelector("diffs-container"))}function qn(){return!1!==s.loading||Wl.value}function In(){const e=ml();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 An(){return d(this,null,function*(){if(!Fl.value)return!0;for(let e=0;e<30;e++){if(Ie)return!1;if(jn())return yield O(),yield Zt(),!Ie&&jn();yield O(),yield Zt()}return!1})}function Vn(e,l,t){return d(this,null,function*(){try{return void(yield dl(e,l,t))}catch(n){if(!Tl(n))throw n}if(yield O(),yield Zt(),!Ie&&Fl.value)try{yield dl(e,l,t)}catch(n){if(!Tl(n))throw n}})}function Wn(){var e,l;return null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500}const Un=v(()=>s.isShowPreview&&("html"===Ee.value||"svg"===Ee.value));function Gn(){return"boolean"==typeof s.node.loading?s.node.loading:!0===s.loading}function Yn(e,l,t){return!t||function(){var e,l,t;if(!Gn())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:"")?ne(String(null!=e?e:"")):"plain"}function Jn(){return Gn()}let Xn=null,Kn=!1,Qn=0;function Zn(){Xn=null,Qn++}function eo(){return d(this,arguments,function*(e=Qn){if(!Kn){Kn=!0;try{for(;Xn&&!Ie&&!Fl.value&&e===Qn;){const e=Xn;Xn=null;try{yield Promise.resolve(ul(e.code,e.language)),yield O(),Ie||Fl.value||(Hn(!1),Fn())}catch(l){Me()}}}finally{Kn=!1,!Xn||Ie||Fl.value||eo()}}})}function lo(e,l){Xn={code:e,language:l},eo(Qn)}P(()=>[s.node.language,s.node.code,s.node.raw,s.node.loading,s.loading],([e,l,t,n,o])=>{Ee.value=Yn(e,l,"boolean"==typeof n?n:!0===o)}),P(()=>[s.node.originalCode,s.node.updatedCode,Fl.value],()=>{rn(),de(()=>un())},{immediate:!0});let to=0;P(()=>[s.node.originalCode,s.node.updatedCode,$e.value,Fl.value,s.stream],e=>d(null,[e],function*([,,,e,l]){var t,n;const o=++to;if(!e)return;if(Gn())return;if(!1===l&&!_e.value)return;if(!1!==l&&rl&&!_e.value&&Oe.value)try{yield ho(Oe.value)}catch(u){}const a=wl;if(a&&!Re.value){try{yield a}catch(u){}if(Ie||!Fl.value||o!==to)return}if(o!==to)return;const r=Dl(String(null!=(t=s.node.originalCode)?t:""),String(null!=(n=s.node.updatedCode)?n:"")),i=!1===s.loading;i&&So();try{if(yield Vn(r.original,r.updated,$e.value),Ie||!Fl.value||o!==to)return;yield O(),Fn(!0),Nn(),Hn(!1===s.loading||{preferModelDiffHeight:!0}),Fn(!0),En(!0)}catch(d){return}if(i){if(Ie||!Fl.value)return;zl(),Nn(),un(),En(),Dn(!0)}ze.value&&de(()=>Mn())})),P(()=>s.node.code,e=>d(null,null,function*(){if(Gn())return;if(!1===s.stream)return;if(Ee.value||(Ee.value=ne(xl(e))),Fl.value)return;const l=wl;if(l&&!Re.value){try{yield l}catch(t){}if(Ie||Fl.value)return}if(rl&&!_e.value&&Oe.value)try{yield ho(Oe.value)}catch(t){}lo($l(s.node.code),$e.value),ze.value&&de(()=>Mn())}));const no=v(()=>{const e=Ee.value;return e?oe[e]||e.charAt(0).toUpperCase()+e.slice(1):oe[""]||"Plain Text"}),oo=v(()=>{var e;return K(String(null!=(e=s.node.raw)?e:""),no.value,Fl.value)}),ao=v(()=>oo.value.title),ro=v(()=>oo.value.caption),io=v(()=>(ae.value,re(Ee.value||"",he))),uo=v(()=>{const e={};e["--markstream-code-layout-character-width"]=null==kt.value?"1ch":`${kt.value}px`,e["--markstream-code-fallback-bg"]=ql.value.background,e["--markstream-code-fallback-fg"]=ql.value.foreground,ql.value.builtin&&(e["--markstream-code-theme-bg"]=ql.value.background,e["--markstream-code-theme-fg"]=ql.value.foreground,e["--markstream-code-theme-line-number"]=ql.value.lineNumber),e["--markstream-diff-added-line-fill"]=ql.value.diffAddedLine,e["--markstream-diff-added-number-fill"]=ql.value.diffAddedNumber,e["--markstream-diff-editor-bg"]=ql.value.background,e["--markstream-diff-removed-line-fill"]=ql.value.diffRemovedLine,e["--markstream-diff-removed-number-fill"]=ql.value.diffRemovedNumber,e["--markstream-diff-shell-bg"]=ql.value.background,e["--markstream-pre-resolved-theme-bg"]=ql.value.background,e["--markstream-pre-resolved-theme-fg"]=ql.value.foreground,e["--markstream-pre-resolved-theme-line-number"]=ql.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),At.value&&!Fl.value&&!Le.value){const l=Vt.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)))",Fl.value||(e.borderColor="var(--markstream-code-border-color, var(--code-border))"),e}),so=v(()=>!1!==s.showTooltips);function vo(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(s.node.code)),Ne.value=!0,p("copy",s.node.code),setTimeout(()=>{Ne.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function co(){ze.value=!ze.value;const e=Fl.value?ml():fl(),l=Oe.value;e&&l&&(ze.value?(l.style.maxHeight="none",l.style.overflow="visible",Hn(!0)):(l.style.overflow="auto",Hn(!0)))}function fo(){var e,l;if(Le.value=!Le.value,Le.value){if(Ke=!1,Oe.value){const t=Math.ceil((null==(l=(e=Oe.value).getBoundingClientRect)?void 0:l.call(e).height)||0);Ke=Tn(Oe.value,t)||"auto"===Oe.value.style.overflow||"auto"===Oe.value.style.overflowY,t>0&&(Je.value=t)}}else Oe.value&&null!=Je.value&&(Oe.value.style.height=`${Je.value}px`),Xe=2,O(()=>{Le.value||Ie||(Hn(!0),Fn(!0))})}function mo(){if(!Un.value)return;const e=Ee.value;if(Pe.value){const l="html"===e?"text/html":"image/svg+xml",t="html"===e?He("artifacts.htmlPreviewTitle")||"HTML Preview":He("artifacts.svgPreviewTitle")||"SVG Preview";return void p("previewCode",{node:s.node,artifactType:l,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(vt.value=!vt.value)}function ho(e,l={}){if(!rl||Ie)return null;if(!1===s.stream&&!1!==s.loading)return null;if(Oo(),Fo())return null;if(Vl.value||Oe.value!==e)return null;if(Jn())return null;if(bl)return bl;if(_e.value&&je.value)return Promise.resolve();const t=Po(),n=Jl.value;let o=!1;_e.value=!0,function(){const e=pe.value;fe&&e&&Ye!==e&&(Ye&&fe.markSettled(Ye),Ye=e,fe.markPending(e))}();const a=d(null,null,function*(){try{yield function(e){return d(this,null,function*(){var l,t;if(!rl||Ie)return;const n=Il.value;if(lt=!1,Gl.value=!1,Yl.value=null,Re.value=!1,Wl.value=!1,Ul.value=!1,bt.value=null,wt.value=null,kt.value=null,xt.value=null,On(),function(){if(Kl.value=!1,$t())return void(_t.value=null);const e=zt.value;_t.value=je.value||null==e?null:e}(),Bn(),Pn(),function(e){e.replaceChildren()}(e),So(),Ie)return;const o=d(null,null,function*(){var l,t;if("diff"===n){!function(){if(Cl||"undefined"==typeof window)return;Cl=!0;const e=e=>{var l;Tl("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),Ml=()=>{window.removeEventListener("error",e,!0),window.removeEventListener("unhandledrejection",e,!0),Cl=!1,Ml=null}}(),pl();const n=Dl(String(null!=(l=s.node.originalCode)?l:""),String(null!=(t=s.node.updatedCode)?t:""));il?yield il(e,n.original,n.updated,$e.value):yield rl(e,s.node.code,$e.value)}else yield rl(e,ct.value,$e.value);Re.value=!0}),a=o.finally(()=>{wl===a&&(wl=null)});if(wl=a,yield function(e){return d(this,null,function*(){if(!Fl.value)return void(yield e);let l,t=!1;for(e.then(()=>{t=!0},e=>{t=!0,l=e});;){if(Ie)return;if(t){if(l)throw l;return}if(Ln()&&In())return;yield O(),yield Zt()}})}(a),Ie)return;if(Il.value!==n)return;Re.value=!0;const r=null==(l=s.codeBlockOptions)?void 0:l.fontSize;if("number"==typeof r&&Number.isFinite(r)&&r>0){const e="diff"===n?ml():fl();null==(t=null==e?void 0:e.updateOptions)||t.call(e,{fontSize:r}),gt.value=r,yt.value=r}else if(!yn()){const e=ln();e&&e>0?(gt.value=e,yt.value=e):(gt.value=12,yt.value=12)}gn(),yield ko(),ze.value||Le.value||Hn(!1),je.value=!0,Al.value=n,function(){var e,l,t,n,o;if(Bn(),Fl.value){const n=ml(),o=null==(e=null==n?void 0:n.getOriginalEditor)?void 0:e.call(n),a=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,()=>En());n&&Bl.push(n)}catch(t){}};try{const e=null==(t=null==n?void 0:n.onDidUpdateDiff)?void 0:t.call(n,()=>{En(),de(()=>un())});e&&Bl.push(e)}catch(r){}i(o,"onDidContentSizeChange"),i(a,"onDidContentSizeChange");const u=Oe.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=>{Fl.value&&qn()&&e.some(e=>l(e.target)||Array.from(e.addedNodes).some(t)||Array.from(e.removedNodes).some(l))&&(Nn(),Hn({preferModelDiffHeight:!0}),Fn(),Dn())});n.observe(u,{attributeFilter:["class"],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Bl.push({dispose:()=>n.disconnect()})}if(u&&"undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{if(!Fl.value)return;if(Fn(),!qn())return;const e=hn(u);null!=e&&(Math.ceil(u.getBoundingClientRect().height||0)<=e+1||(Nn(),Hn({preferModelDiffHeight:!0}),Fn()))});e.observe(u),Bl.push({dispose:()=>e.disconnect()})}return}const a=fl();try{const e=null==(n=null==a?void 0:a.onDidContentSizeChange)?void 0:n.call(a,()=>En());e&&Bl.push(e)}catch(r){}try{const e=null==(o=null==a?void 0:a.onDidLayoutChange)?void 0:o.call(a,()=>En());e&&Bl.push(e)}catch(r){}}(),wn(),gn(),Nn(),un(),En(),yield O();let i=null;yl&&(i=yield yl(),i&&(yield O(),yield Zt()));const u=null==i?"diff"===n?yield An():yield function(){return d(this,null,function*(){if(jn())return yield O(),yield Zt(),jn();for(let e=0;e<30;e++){if(Ie||Fl.value)return!1;const e=Oe.value,l=Rn(),t=_n(e),n=!ct.value.trim()||an(e);if(l&&t&&n&&(yield O(),yield Zt(),!Ie&&!Fl.value&&Rn()&&_n(Oe.value)&&(!ct.value.trim()||an(Oe.value))))return!0;yield O(),yield Zt()}return!1})}():i;Ie||(u?(gn(),Kt(),(yield Yt())||No()):No())})}(e),Ql=null}catch(a){const e=Po(),r=n!==Jl.value,i=!1!==l.allowStaleContentRetry&&r&&Ql!==e;if(t!==e||i)return i&&(Ql=e),o=!0,_e.value=!1,je.value=!1,Re.value=!1,void(Wl.value=!1);throw No(t),a}}).finally(()=>{bl===a&&(bl=null),function(){const e=Ye;fe&&e&&(Ye="",O(()=>{var l,t;if(!Ie){const n=null!=(t=null==(l=Fe.value)?void 0:l.offsetHeight)?t:0;n>0&&fe.reportHeight(e,n)}fe.markSettled(e)}))}(),o&&!Ie&&queueMicrotask(()=>{var e;const l=Oe.value;l&&!Ie&&(null==(e=ho(l))||e.catch(e=>{je.value=!1,Wl.value=!1,No()}))})});return bl=a,a}P(so,e=>{e||Q()}),P(()=>yt.value,(e,l)=>{var t;const n=Fl.value?ml():fl();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(null==(t=n.updateOptions)||t.call(n,{fontSize:e}),Le.value||Hn(!0))},{flush:"post",immediate:!1});let po=0;const go=P(()=>[Oe.value,Fl.value,s.stream,s.loading,qe.value,tl.value,s.node.language,s.node.raw,s.node.code,s.node.loading],e=>d(null,[e],function*([e,l,t,n,o,a]){const r=++po;if(!e)return;if(!a)return;if(Gn())return;if(Zl)return;if(!1===t&&!1!==n)return;if(!rl){if(yield function(){return d(this,null,function*(){if("undefined"==typeof window||Ie)return;if(qe.value||Vl.value)return;if(kl)return kl;const e=d(null,null,function*(){try{const e=yield ce();if(Ie)return;if(!e)return void(Vl.value=!0);mt(e)}catch(e){if(Ie)return;Vl.value=!0}}).finally(()=>{kl===e&&(kl=null)});return kl=e,e})}(),r!==po)return;if(!1===s.stream&&!1!==s.loading)return;if(Jn())return;if(!tl.value)return;if(!rl||Vl.value||_e.value||Fo()||Ie||Oe.value!==e)return}if(Jn())return;const i=ho(e);if(i){try{yield i}catch(u){je.value=!1,Wl.value=!1,No()}je.value&&Wl.value&&go()}}));function yo(e){return"string"==typeof e?e:null}function bo(e,l){if(e===l)return!0;const t=yo(e),n=yo(l);return!!t&&t===n}function wo(){return ee({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})}function ko(){return d(this,arguments,function*(e={}){So();const l=()=>{Fl.value&&zl(),de(()=>{wn(),En()})};if(e.appearanceOnly)return void l();const t=wo();if(t)try{yield Sl(t),l()}catch(n){}else l()})}function xo(){var e,l;const t=Ot.value,n=u(i({},Ll.value||{}),{wordWrap:"wrap"===t.overflow?"on":"off",overflow:t.overflow,themes:s.themes,stream:!1,MAX_HEIGHT:null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500,fontSize:Ct.value,lineHeight:Bt.value,theme:wo(),themeType:s.isDark?"dark":"light",disableLineNumbers:!b.value,disableFileHeader:!0,onThemeChange(){wn()}}),o=function(){var e;const l=null==(e=Ll.value)?void 0:e.fontFamily;return"string"==typeof l&&l.trim()?l.trim():Fl.value?function(){var e;if("undefined"==typeof window)return;const l=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l)return;return window.getComputedStyle(l).fontFamily.trim()||void 0}():void 0}();o&&(null!=n.fontFamily||(n.fontFamily=o));const a="string"==typeof n.unsafeCSS?n.unsafeCSS:"",r=`\n[data-file] [data-line],\n[data-diff] [data-line] {\n white-space: ${"wrap"===(d=t.overflow)?"pre-wrap":"pre"} !important;\n overflow-wrap: ${"wrap"===d?"anywhere":"normal"} !important;\n word-break: normal !important;\n}`;var d;return n.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }\n${r}\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${a}`.trim(),n}function So(){const e=xo();if(!Hl)return Hl=e,Hl;for(const l of Object.keys(Hl))l in e||delete Hl[l];return Object.assign(Hl,e),Hl}P(Il,(e,l)=>d(null,null,function*(){if(e===l)return;if(Gl.value||Zl)return;if(Zn(),!rl||!Oe.value)return;if(!_e.value)return;if(!1===s.stream&&!1!==s.loading)return;if(!tl.value)return;const t=bl;if(t){try{yield t}catch(n){}if(Ie||!Oe.value)return}if(Al.value!==e||!_e.value||!je.value)try{je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),yield O(),yield ho(Oe.value)}catch(o){je.value=!1,Wl.value=!1,No()}}));const Co=M(0),Mo=v(()=>String(Co.value));let Bo=!1;function Po(){var e;const l=wo();return JSON.stringify({kind:Il.value,language:$e.value,structural:Mo.value,optionsRevision:Co.value,settledContentGeneration:Xl.value,theme:null!=(e=yo(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:ht;gt.value=l,yt.value=l,bt.value=null,wt.value=null,kt.value=null}),P(()=>[s.codeBlockOptions,s.showLineNumbers],()=>{Co.value+=1,!1===s.stream&&!1!==s.loading&&(Bo=!0)},{deep:!0}),P(()=>[ct.value,s.node.originalCode,s.node.updatedCode],()=>{Jl.value+=1,Gn()||(Xl.value+=1)});const Ho=v(()=>Po());function Oo(){Gl.value&&Yl.value!==Ho.value&&(Gl.value=!1,Yl.value=null,Ql=null,et=null,_e.value=!1,je.value=!1,Re.value=!1,Wl.value=!1,Ul.value=!1)}function Fo(){return Oo(),Gl.value&&Yl.value===Ho.value}function No(e=Ho.value){Yl.value=e,Gl.value=!0,Ul.value=!1}return P(Ho,()=>d(null,null,function*(){if(Zl)return;if(!Gl.value)return;if(Yl.value===Ho.value)return;if(!rl||!Oe.value||Vl.value||Ie||!tl.value)return;if(!1===s.stream&&!1!==s.loading)return;if(Jn())return;const e=Ho.value;Zl=!0;try{if(Oo(),Gl.value)return;yield ho(Oe.value)}catch(l){je.value=!1,Wl.value=!1,No()}finally{et=e,yield O(),Zl=!1}})),P(()=>[s.codeBlockOptions,tl.value],()=>{var e,l;if(So(),!rl||!tl.value)return;const t=Fl.value?ml():fl(),n="number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize)?s.codeBlockOptions.fontSize:Number.isFinite(yt.value)?yt.value:void 0;"number"==typeof n&&Number.isFinite(n)&&n>0&&(null==(l=null==t?void 0:t.updateOptions)||l.call(t,{fontSize:n})),Hn(!1)},{deep:!0}),P(()=>[wo(),Rl.value,qe.value,_e.value,tl.value],([e],l)=>{qe.value&&je.value&&tl.value&&ko({appearanceOnly:null!=l&&bo(e,l[0])})},{flush:"post"}),P(()=>[Mo.value,qe.value,tl.value],(e,l)=>d(null,[e,l],function*([e,l,t],[n]){if(So(),!l||!t)return;if(!rl||!Oe.value)return;if(!_e.value)return;if(e===n)return;if(!1===s.stream&&!1!==s.loading)return void(Bo=!0);Bo=!1;const o=bl;if(o){try{yield o}catch(a){}if(Ie||!Oe.value)return}try{je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),Ol&&mt(Ol),yield O(),yield ho(Oe.value,{allowStaleContentRetry:!1})}catch(r){je.value=!1,Wl.value=!1,No()}}),{flush:"post"}),P(()=>[s.loading,tl.value],([e,l])=>{!1===e&&l&&Bo&&(Bo=!1,Co.value+=1)},{flush:"post"}),P(()=>[s.loading,tl.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&&Fl.value&&_e.value&&(yield O(),de(()=>{d(null,null,function*(){const e=bl;if(e)try{yield e}catch(l){}!Ie&&Fl.value&&!1!==s.loading&&(So(),zl(),En())})})),e)return;const o=void 0!==n&&!1!==n;yield O(),de(()=>{d(null,null,function*(){var e,l;try{if(o&&(yield function(){return d(this,null,function*(){if(!Gl.value)return!1;if(!rl||!Oe.value||Vl.value||Ie||!tl.value)return!1;if(et===Ho.value)return!0;Zl=!0;try{Gl.value=!1,Yl.value=null,Ql=null,_e.value=!1,je.value=!1,Re.value=!1,Wl.value=!1,Bn(),Pn(),pl(),Ol&&mt(Ol),yield O();try{yield ho(Oe.value)}catch(e){je.value=!1,Wl.value=!1,No()}}finally{yield O(),Zl=!1}return!0})}()))return void Hn(!1);if(o&&Fl.value&&_e.value&<&&Oe.value)return lt=!1,je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),yield O(),yield ho(Oe.value,{allowStaleContentRetry:!1}),void Dn(!0);if(o&&_e.value)if(Fl.value&&Oe.value){const n=bl;if(n)try{yield n}catch(t){}So();const o=Dl(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:""));if(yield Vn(o.original,o.updated,$e.value),Ie||!Fl.value)return;yield Promise.resolve(vl()),zl(),Fn(!0),Gt(),Nn(),un();const a=yield An();Ie||!a||Wl.value||(yield Yt()),En(),Dn(!0)}else Zn(),lo(ct.value,$e.value),yield new Promise(e=>{const l=()=>{Ie?e():Kn||Xn?setTimeout(l,16):e()};l()}),Ie||Fl.value||(yield Promise.resolve(sl()));o&&Fl.value?(Hn({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),Dn(!0)):Hn(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{Bn(),Pn(),hl(),null==Ml||Ml()}),(l,t)=>{var n;return Vl.value?(m(),h(ie,{key:0,style:F(It.value),node:ft.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":tt.value,"diff-hide-unchanged-regions":nt.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Ot.value,"reserved-height-px":Fl.value&&null!=(n=xt.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:Fe,style:F(uo.value),class:y(["code-block-container rounded-lg border",[{dark:s.isDark,"is-rendering":s.loading,"is-dark":jl.value,"is-diff":Fl.value,"is-plain-text":Te.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":Wl.value&&!Vl.value?"true":"false","data-markstream-enhancement-state":st.value,"data-markstream-code-block-state":Gn()?"streaming":"settled","data-markstream-pending":dt.value?"true":void 0,"data-markstream-viewport-pending":al.value&&k(el)&&!tl.value?"true":void 0},[T(ue,{"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":Le.value,"is-expanded":ze.value,"copy-text":Ne.value,"is-previewable":Un.value,"code-font-size":yt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":gt.value,"font-baseline-ready":St.value,"diff-stats":Fl.value?Nl.value:null,"diff-stats-aria-label":El.value,onToggleCollapse:fo,onDecreaseFont:vn,onResetFont:cn,onIncreaseFont:sn,onCopy:vo,onToggleExpand:co,onPreview:mo},N({"header-left":E(()=>[D(l.$slots,"header-left",{},()=>[g("div",be,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:io.value},null,8,we),g("div",ke,[g("div",xe,w(ao.value),1),ro.value?(m(),$("div",Se,w(ro.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":Le.value}])},[g("div",{ref_key:"codeEditor",ref:Oe,class:y(["code-editor-container",e.stream?"":"code-height-placeholder"]),"data-markstream-host-hidden":ut.value?"true":void 0,style:F(Wt.value)},null,14,Ce),it.value?(m(),h(ie,{key:0,style:F(It.value),node:ft.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":tt.value,"diff-hide-unchanged-regions":nt.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Ot.value,"reserved-height-px":Fl.value&&null!=(l=xt.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]]),vt.value&&!Pe.value&&Un.value&&"html"===Ee.value?(m(),h(ge,{key:0,code:s.node.code,"html-preview-allow-scripts":s.htmlPreviewAllowScripts,"html-preview-sandbox":s.htmlPreviewSandbox,"is-dark":s.isDark,"on-close":()=>vt.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,ye))}}}),[["__scopeId","data-v-5ea442c1"]]);export{Me as default};
|
|
1
|
+
var e=Object.defineProperty,l=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,r=(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)&&r(e,t,l[t]);if(n)for(var t of n(l))a.call(l,t)&&r(e,t,l[t]);return e},u=(e,n)=>l(e,t(n)),d=(e,l,t)=>new Promise((n,o)=>{var a=e=>{try{i(t.next(e))}catch(l){o(l)}},r=e=>{try{i(t.throw(e))}catch(l){o(l)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,r);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{as as R,G as j,M as q,ah as I,au as A,av as V,ar as W,a8 as U,af as G,b as Y,c as J,aj as X,ae as K,a6 as Q,ab as Z,ai as ee}from"./exports.js";import{M as le,f as te,n as ne,c as oe,l as ae}from"./index2.js";import{r as re,_ as ie,a as ue}from"./PreCodeBlock.vue_vue_type_style_index_0_lang.js";import{safeRaf as de,safeCancelRaf as se}from"./utils/safeRaf.js";import{r as ve}from"./preCodeTheme.js";import{getStreamDiffsRuntime as ce}from"./streamDiffs.js";const fe={class:"html-preview-frame__header"},me={class:"html-preview-frame__title"},he={class:"html-preview-frame__label"},pe=["sandbox","srcdoc"],ge=/* @__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(),a=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>`}),r=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",fe,[g("div",me,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",he,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:r.value,referrerpolicy:"no-referrer",srcdoc:a.value},null,8,pe)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]),ye=["data-markstream-enhanced","data-markstream-enhancement-state","data-markstream-code-block-state","data-markstream-pending","data-markstream-viewport-pending"],be={class:"code-header-main"},we=["innerHTML"],ke={class:"code-header-copy"},xe={class:"code-header-title"},Se={key:0,class:"code-header-caption"},Ce=["data-markstream-host-hidden"],Me=/* @__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,a,r;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(),fe=S(le,null),me=S("markstreamHostScrollManaged",null),he=S(q,void 0),pe=v(()=>I(s,j));function Me(e,l){}const Be=C(),Pe=v(()=>{const e=null==Be?void 0:Be.vnode.props;return!(!e||!e.onPreviewCode&&!e["onPreview-code"])}),{t:He}=R(),Oe=M(null),Fe=M(null),Ne=M(!1),Ee=M(Yn(s.node.language,s.node.code,Gn())),De=v(()=>te(Ee.value)),$e=v(()=>"plaintext"===De.value?"text":De.value),Te=v(()=>"plaintext"===De.value),ze=M(!1),Le=M(!1),_e=M(!1),Re=M(!1),je=M(!1),qe=M(!1);let Ie=!1,Ae=null,Ve=null,We=null,Ue=0,Ge=!1,Ye="";const Je=M(null);let Xe=0,Ke=!1;const Qe=A(),Ze=V(),el=W(),ll=B(null),tl=M("undefined"==typeof window||!el.value),nl=null!=(o=null==(n=null==(t=C())?void 0:t.vnode.el)?void 0:n.textContent)?o:"",ol="undefined"!=typeof window&&String(null!=(a=s.node.code)?a:"").length>0&&nl.includes(String(s.node.code)),al=M(!ol);c(()=>{al.value=!0}),"undefined"!=typeof window&&P([()=>Fe.value,el],([e,l],t,n)=>{var o,a,r;if(null==(o=ll.value)||o.destroy(),ll.value=null,!l||tl.value)return void(tl.value=!0);if(!e)return void(tl.value=!1);let i=!0;const u=null!=(r=null!=(a=null==Ze?void 0:Ze.value.heavyBlockMargin)?a:null==Ze?void 0:Ze.value.rootMargin)?r:"0px",d=Qe(e,{rootMargin:u,allowIdle:!1});ll.value=d,tl.value=tl.value||d.isVisible.value,d.whenVisible.then(()=>{i&&ll.value===d&&(tl.value=!0)}).catch(()=>{}),n(()=>{i=!1,d.destroy(),ll.value===d&&(ll.value=null)})},{immediate:!0}),H(()=>{var e;Ie=!0,function(){const e=Ye;fe&&e&&(Ye="",fe.markSettled(e))}(),null==(e=ll.value)||e.destroy(),ll.value=null});let rl=null,il=null,ul=()=>{},dl=()=>{},sl=()=>{},vl=()=>{},cl=()=>null,fl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),ml=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),hl=()=>{},pl=()=>{},gl=()=>{},yl=null,bl=null,wl=null,kl=null,xl=()=>{var e;return String(null!=(e=s.node.language)?e:"plaintext")},Sl=()=>d(null,null,function*(){}),Cl=!1,Ml=null;const Bl=[],Pl=[];let Hl=null,Ol=null;const Fl=v(()=>U(s.node)),Nl=M({removed:0,added:0}),El=v(()=>`-${Nl.value.removed} +${Nl.value.added}`);function Dl(e,l){return{original:e,updated:l}}function $l(e){return String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"")}function Tl(e){var l;return String(null!=(l=null==e?void 0:e.message)?l:e).includes("no diff result available")}function zl(){if(!jn())try{const e=gl();e&&"function"==typeof e.catch&&e.catch(e=>{Tl(e)})}catch(e){Tl(e)}}const Ll=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(!Fl.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)})}),_l=v(()=>{return(void 0!==s.theme?(e=s.theme)&&"object"==typeof e&&"light"in e&&"dark"in e:!bo(s.darkTheme,s.lightTheme))?!!s.isDark:function(e){var l;const t=null!=(l=yo(e))?l:"";return Z(t,!0===s.isDark)}(wo());var e}),Rl=v(()=>(Fl.value,_l.value?"dark":"light")),jl=v(()=>Fl.value?"dark"===Rl.value:_l.value),ql=v(()=>ve({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})),Il=v(()=>Fl.value?"diff":"single"),Al=M(Il.value),Vl=M(!1),Wl=M(!1),Ul=M(!1),Gl=M(!1),Yl=M(null),Jl=M(0),Xl=M(0),Kl=M(!1);let Ql=null,Zl=!1,et=null,lt=!1;const tt=v(()=>{var e;return!!Fl.value&&"unified"===(null==(e=Ll.value)?void 0:e.diffStyle)}),nt=v(()=>G(Ll.value));function ot(e){return!0===(null==me?void 0:me.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 at=v(()=>ot(Fe.value)),rt=v(()=>!(Vl.value||!Gl.value&&Wl.value)),it=v(()=>rt.value),ut=v(()=>rt.value&&!Ul.value),dt=v(()=>!Vl.value&&!Gl.value&&rt.value),st=v(()=>Wl.value&&!Vl.value?"ready":Gl.value?"fallback":"pending"),vt=M(!1),ct=v(()=>$l(s.node.code)),ft=v(()=>Fl.value?!0===s.node.diff?s.node:u(i({},s.node),{diff:!0}):ct.value===s.node.code?s.node:u(i({},s.node),{code:ct.value}));function mt(e){const l=e.detectLanguage;"function"==typeof l&&(xl=l),Ol=e,Hl=xo();const t=e.createCodeBlockRuntime(Hl);return!!t&&(rl=t.createEditor||rl,il=t.createDiffEditor||il,ul=t.updateCode||ul,dl=t.updateDiff||dl,sl=t.finalizeCode||sl,vl=t.finalizeDiff||vl,cl=t.getEditor||cl,fl=t.getEditorView||fl,ml=t.getDiffEditorView||ml,hl=t.cleanupEditor||hl,pl=t.safeClean||t.cleanupEditor||pl,gl=t.refreshDiffPresentation||gl,Sl=t.setTheme||Sl,yl=t.whenVisualReady||null,qe.value=!0,!0)}const ht=Y,pt=J,gt=M("number"==typeof(null==(r=s.codeBlockOptions)?void 0:r.fontSize)?s.codeBlockOptions.fontSize:Number.NaN),yt=M(gt.value),bt=M(null),wt=M(null),kt=M(null),xt=M(null),St=v(()=>{const e=gt.value,l=yt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof l&&Number.isFinite(l)&&l>0}),Ct=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=yt.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:ht}),Mt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.lineHeight;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:Ct.value===ht?pt:Math.max(12,Math.round(1.5*Ct.value))}),Bt=v(()=>Mt.value),Pt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.tabSize;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:4}),Ht=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}}),Ot=v(()=>{const e=X(s.codeBlockOptions);return u(i({},e),{fontSize:Ct.value,lineHeight:Bt.value,maxHeight:Wn(),padding:Ht.value.top,paddingBottom:Ht.value.bottom,tabSize:Pt.value})}),Ft=v(()=>{const e=s.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Nt(e){if(null==e)return null;const l=Math.ceil(e);return!Number.isFinite(l)||l<=0?null:Math.min(l,Math.ceil(Wn()))}function Et(){return!Fl.value&&!1!==s.stream&&!1!==s.loading}const Dt=M(Et());function $t(){return Et()||Dt.value}const Tt=v(()=>Fl.value?null:null==Ft.value||$t()?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})(ct.value)*Bt.value+1):null),zt=v(()=>{if(Fl.value)return null;const e=Ft.value;return null==e||$t()?Nt(Tt.value):Nt(e)}),Lt=v(()=>{const e=s.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),_t=M(null);function Rt(){const e=_t.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}const jt=v(()=>{const e=Rt();return null!=e?e:!Fl.value&&Kl.value?null:rt.value||!Wl.value?zt.value:null});function qt(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 It=v(()=>{const e=Nt(Ft.value),l=Nt(Tt.value),t=$t(),n=i({},Fl.value||null==e||t?Fl.value||null==l?{}:{minHeight:`${l}px`}:{height:`${e}px`,minHeight:`${e}px`});if(n["--markstream-code-fallback-bg"]=ql.value.background,n["--markstream-code-fallback-fg"]=ql.value.foreground,ql.value.builtin&&(n["--markstream-code-theme-bg"]=ql.value.background,n["--markstream-code-theme-fg"]=ql.value.foreground,n["--markstream-code-theme-line-number"]=ql.value.lineNumber),n["--markstream-pre-line-number-top"]=`${Ht.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",Fl.value){n["--markstream-pre-diff-line-height"]=`${Bt.value}px`,n["--markstream-pre-diff-pane-bottom-padding"]=(tt.value,"0px");const e=xt.value;null!=e&&e>0&&(n.height=`${e}px`,n.minHeight=`${e}px`,n.maxHeight=`${e}px`),Object.assign(n,qt(jl.value))}return n}),At=v(()=>null!=jt.value&&(!Wl.value||null!=Rt())),Vt=v(()=>{const e=jt.value;if(null==e)return null;if(Fl.value)return Math.ceil(e);const l=Lt.value,t=Ft.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)}),Wt=v(()=>{if(Fl.value&&rt.value)return{};const e=jt.value;return At.value&&null!=e?{minHeight:`${e}px`}:{}});function Ut(){_t.value=null}function Gt(){var e,l,t,n,o,a,r,i;const u=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback"),d=ml(),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==(r=null==(a=null==d?void 0:d.getModifiedEditor)?void 0:a.call(d))?void 0:r.setScrollTop)||i.call(r,s)}function Yt(){return d(this,null,function*(){return Fl.value?(bn(),Kt(),Fn(!0),Gt(),Nn(),Ul.value=!0,yield O(),Fn(!0),yield Zt(),Fn(!0),gn(),Kt(),!!(yield function(){return d(this,null,function*(){var e;if(!Fl.value)return!0;for(let l=0;l<4;l++){const l=Kt();Fn(!0),Jt(l),Xt(l),yield O(),yield Zt();const t=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!t)return!1;if(null==l)return Ln();const n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-l)<=2)return!0}return!1})}())&&(Wl.value=!0,yield O(),Kt(),Fn(!0),gn(),Nn(),de(()=>{Ie||de(()=>{Ie||(function(){var e,l;const t=null==(e=Fe.value)?void 0:e.querySelector(".code-block-shell-content"),n=null==(l=Fe.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"))}(),En(!0))})}),En(),!0)):!(yl&&!(yield yl())||(bn(),Fn(!0),Ul.value=!0,yield O(),bn(),Fn(!0),yield Zt(),bn(),Fn(!0),Wl.value=!0,yield O(),En(),0))})}function Jt(e){var l;if(!Fl.value)return;const t=Oe.value,n=null==(l=Fe.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 a=Math.ceil(o),r=`${a}px`;xt.value=a;const i=Fe.value;i&&(i.dataset.markstreamDiffHandoffHeight=r),n.dataset.markstreamDiffHandoffHeight=r,n.style.setProperty("height",r),n.style.setProperty("min-height",r)}function Xt(e){var l,t,n;if(!Fl.value)return;const o=null==(l=Fe.value)?void 0:l.querySelector(".code-block-shell-content"),a=null==(t=Fe.value)?void 0:t.querySelector(".code-editor-layer");if(!o||!a)return;const r="number"==typeof e&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat((null==(n=Oe.value)?void 0:n.style.height)||"");if(!Number.isFinite(r)||r<=0)return;const i=`${r}px`;a.style.height=i,a.style.minHeight=i,o.style.height=i,o.style.minHeight=i}function Kt(){const e=Oe.value;if(e&&Ln(e)){Nn();const l=hn(e);if(null!=l&&l>0){const t=Math.ceil(l),n=Math.ceil(Wn()),o=Math.min(t,n),a=`${o}px`;return e.style.height=a,e.style.minHeight="0px",e.style.maxHeight=`${n}px`,e.style.overflow=t>n+1?"auto":"hidden",rt.value&&(xt.value=o,Jt(o)),Dn(),o}return Hn({preferModelDiffHeight:!0}),Jt(),Dn(),Number.parseFloat(e.style.height||"")||null}return bn()}function Qt(e,l=!1,t={}){const n=Math.ceil(e),o=Rt();if(null==o)return n;const a=!0===t.allowBelowEstimatedFloor;return n>=o||a?((l||a)&&je.value&&Ut(),n):o}function Zt(){return new Promise(e=>{let l=!1,t=null,n=null;const o=()=>{l||(l=!0,null!=n&&globalThis.clearTimeout(n),null!=t&&se(t),e())};n=globalThis.setTimeout(o,50),t=de(o)})}function en(){var e;try{const l=Oe.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 ln(){var e,l,t,n,o,a;try{const a=Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl(),r=cl(),i=null==(n=null==r?void 0:r.EditorOption)?void 0:n.fontInfo;if(a&&null!=i){const e=null==(o=a.getOption)?void 0:o.call(a,i),l=null==e?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(r){}try{const e=Oe.value;if(e){const l=null!=(a=e.querySelector(".stream-diffs-shell .stream-diffs-surface"))?a: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(r){}}}catch(r){}return null}function tn(e){var l,t;try{const n=cl(),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(a){}const n=en();if(n&&n>0)return n;const o=Number.isFinite(yt.value)&&yt.value>0?yt.value:14;return Math.max(12,Math.round(1.35*o))}function nn(){var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding;return"number"==typeof l&&Number.isFinite(l)?2*Math.max(0,l):Fl.value?24:0}function on(e){const l=$l(e);return l?l.split(/\r\n|\n|\r/):[]}function an(e){return!!Te.value||!!e&&(jn(e)||null!=yl)}function rn(){var e,l;Fl.value?Nl.value=function(e,l){const t=on(e),n=on(l);let o=0,a=t.length-1,r=n.length-1;for(;o<=a&&o<=r&&t[o]===n[o];)o++;for(;a>=o&&r>=o&&t[a]===n[r];)a--,r--;const i=Math.max(0,a-o+1),u=Math.max(0,r-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),a=new Uint32Array(e);for(let d=i-1;d>=0;d--){a[u]=0;for(let r=u-1;r>=0;r--)a[r]=t[o+d]===n[o+r]?l[r+1]+1:Math.max(l[r],a[r+1]);const e=l;l=a,a=e}const r=l[0];return{removed:i-r,added:u-r}}return{removed:i,added:u}}(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:"")):Nl.value={removed:0,added:0}}function un(){rn()}function dn(){var e;if(Number.isFinite(yt.value)&&yt.value>0&&Number.isFinite(gt.value))return yt.value;if("number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize))return gt.value=s.codeBlockOptions.fontSize,yt.value=s.codeBlockOptions.fontSize,s.codeBlockOptions.fontSize;const l=ln();return l&&l>0?(gt.value=l,yt.value=l,l):(gt.value=12,yt.value=12,12)}function sn(){const e=dn(),l=Math.min(36,e+1);yt.value=l}function vn(){const e=dn(),l=Math.max(10,e-1);yt.value=l}function cn(){dn(),Number.isFinite(gt.value)&&(yt.value=gt.value)}function fn(){var e,l,t,n,o,a,r,i,u,d,s,v,c,f;try{const m=Fl.value?ml():null,h=Fl.value?m:fl();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==(a=null==f?void 0:f.getContentHeight)?void 0:a.call(f))||0,g=Math.max(h,p);if(g>0)return Math.ceil(g);const y=(null==(u=null==(i=null==(r=null==c?void 0:c.getModel)?void 0:r.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(tn(c),tn(f)),x=nn();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 Fl.value||(Kl.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=tn(h);return Math.ceil(g*(y+1.5)+0)}catch(m){return null}}function mn(){var e,l;if(Fl.value)return!1;try{const t=null==(l=null==(e=fl())?void 0:e.getContentHeight)?void 0:l.call(e),n="number"==typeof t&&Number.isFinite(t)&&t>0;return n&&(Kl.value=!0),n}catch(t){return!1}}function hn(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 pn(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[a,r,i]=o.slice(0,3).map(Number);return.2126*a+.7152*r+.0722*i}function gn(){var e,l,t;if(yn())return;const n=ln();n&&n>0&&(bt.value=n,yt.value=n,gt.value=n);try{const n=tn(Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl());n&&n>0&&(wt.value=n)}catch(o){}try{const e=en();e&&e>0&&(wt.value=e)}catch(o){}}function yn(){return Fl.value&&it.value}function bn(){var e;if(!rt.value)return null;const l=Oe.value,t=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l||!t)return null;const n=Math.ceil(t.getBoundingClientRect().height),o=Fl.value?hn(l):null,a=Math.max(n,null!=o&&o>0?Math.ceil(o):0),r=Math.ceil(Wn()),i=Math.min(a,r);return!Number.isFinite(i)||i<=0?null:(Fl.value&&i>n&&(xt.value=i),l.style.height=`${i}px`,l.style.minHeight=`${i}px`,l.style.maxHeight=`${r}px`,l.style.overflow=a>r+1?"auto":"hidden",i)}function wn(){var e,l,t,n,o,a,r,i,u;const d=Oe.value,v=Fe.value;if(!d||!v)return;const c=d;c.style.setProperty("--markstream-diff-metadata-bg",ql.value.background),c.style.setProperty("--markstream-diff-metadata-fg",ql.value.lineNumber),c.style.setProperty("--diffs-tab-size",String(Pt.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",`${Ht.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!=(r=null!=(a=null==y?void 0:y.color)?a:null==p?void 0:p.color)?r:"").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 a=Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl(),r=cl(),i=null==(n=null==r?void 0:r.EditorOption)?void 0:n.fontInfo;if(a&&null!=i){const e=null==(o=a.getOption)?void 0:o.call(a,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&&(kt.value=C),Fl.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(qt(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(!Te.value)return!1;const n=pn(e),o=pn(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,Fl.value],([e,l,t,n])=>{n||!1===e||!1===l||Dt.value?(n||!1===e)&&Dt.value&&(Dt.value=!1):(Dt.value=!0,Ut())},{immediate:!0});let kn=0,xn=0;const Sn=/auto|scroll|overlay/i;function Cn(e,l,t){var n;if("undefined"==typeof window)return;if(Fl.value)return;if(function(e){return at.value||ot(e)}(e))return;const o=Math.ceil(l),a=Math.ceil(t)-o;if(Math.abs(a)<=1)return;const r=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 a=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;a&&a!==n.body&&a!==o;){const e=window.getComputedStyle(a),l=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(Sn.test(l)||Sn.test(t))return a;a=a.parentElement}return o}(e);if(!r)return;const i=null!=(n=e.ownerDocument)?n:document,u=r===i.body||r===i.documentElement||r===i.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,a):r.scrollTop+=a)}function Mn(){try{const e=Oe.value;if(!e)return;const l=e.getBoundingClientRect().height,t=fn();if(null!=t&&t>0){const n=Qt(t,!0,{allowBelowEstimatedFloor:!Fl.value&&je.value&&mn()}),o=Rt();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",void Cn(e,l,n)}const n=Rt();null!=n&&(e.style.minHeight=`${n}px`,e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",Cn(e,l,n))}catch(e){}}function Bn(){for(var e,l;Bl.length>0;)try{null==(l=null==(e=Bl.pop())?void 0:e.dispose)||l.call(e)}catch(t){}null!=Ae&&(se(Ae),Ae=null),null!=Ve&&(se(Ve),Ve=null),null!=We&&(se(We),We=null),Ue=0,Ge=!1}function Pn(){for(var e;Pl.length>0;)try{null==(e=Pl.pop())||e()}catch(l){}}function Hn(e=!1){Le.value||(ze.value?Mn():function(e={}){var l;try{const t=Oe.value;if(!t)return;const n=t.getBoundingClientRect().height,o=Wn(),a=Math.ceil((null==(l=t.getBoundingClientRect)?void 0:l.call(t).height)||0),r=Number.parseFloat(t.style.height||""),i=a>0?a:Number.isFinite(r)&&r>0?Math.ceil(r):0,u=Fl.value?function(){var e,l,t,n,o,a,r,i,u,d,s,v;if(jn())return null;try{const c=ml(),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==(r=null==(a=m.getModel)?void 0:a.call(m))?void 0:r.getLineCount)?void 0:i.call(r))||1,g=Math.max(h,p),y=Math.max(tn(f),tn(m)),b=nn(),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=Fl.value&&Ln(t);if(Xe>0&&(Xe--,null!=Je.value))return void Cn(t,n,$n(t,Je.value,o,{preserveScrollableOverflow:zn(t)}));if(Fl.value&&!d&&rt.value){const e=bn();if(null!=e){const l=$n(t,e,o,{allowBelowEstimatedFloor:!0});return Fn(!0),void Cn(t,n,l)}}const v=Fl.value&&!0===e.preferModelDiffHeight,c=Fl.value?hn(t):null,f=!Fl.value&&je.value&&mn(),m=Fl.value&&!1!==s.loading&&(null!=c||null!=u&&a>0&&u<a-1),h=null!=u;let p;if(Fl.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=tt.value&&null!=c||null!=c?h?Math.max(c,u):c:Fl.value&&!1!==s.loading?null!=u&&i>0&&u<i-1?u:i>0?i:null:u;else p=fn();if(Fl.value&&null!=p&&i>0&&(!1!==s.loading||!0===e.holdCurrentDiffHeight)&&(p=Math.max(p,i)),null!=p&&p>0)return void Cn(t,n,$n(t,p,o,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||m,preserveScrollableOverflow:zn(t)}));if(null!=Je.value)return void Cn(t,n,$n(t,Je.value,o,{preserveScrollableOverflow:zn(t)}));const g=Fl.value&&!1!==s.loading?a:Math.max(a,null!=u&&u>0?u:0);if(g>0)return void Cn(t,n,$n(t,g,o));const y=Rt();if(!(null==y||Fl.value&&!1!==s.loading&&d))return void Cn(t,n,$n(t,y,o));const b=Number.parseFloat(t.style.height);!Number.isNaN(b)&&b>0?Cn(t,n,$n(t,b,o)):Fl.value||Cn(t,n,$n(t,o,o))}catch(t){}}("object"==typeof e?e:{}))}function On(){kn=0,xn=0}function Fn(e=!1){var l,t,n;if(Le.value)return;const o=Oe.value;if(!o)return;const a=Fl.value?ml():fl();if(a&&"function"==typeof a.layout)try{const r=null==(l=o.getBoundingClientRect)?void 0:l.call(o),i=Math.ceil((null!=(t=null==r?void 0:r.width)?t:0)||o.clientWidth||0),u=Math.ceil((null!=(n=null==r?void 0:r.height)?n:0)||o.clientHeight||Number.parseFloat(o.style.height||"")||0);if(i>0&&u>0){if(!e&&i===kn&&u===xn)return;kn=i,xn=u,a.layout({width:i,height:u})}else On(),a.layout()}catch(r){}}function Nn(){Pn()}function En(e=!1){if(Ie||null!=Ae)return;const l=()=>{Ie||(Nn(),Hn(e),Fn())};Ae=de(()=>{Ae=null,l(),Ve=de(()=>{Ve=null,l()})}),Dn()}function Dn(e=!1){if(!Fl.value||Ie||!e&&!1===s.loading)return;if(Ge=Ge||e,Ue=Math.max(Ue,e?18:6),null!=We)return;const l=()=>{if(We=null,!Fl.value||Ie||Ue<=0||!Ge&&!1===s.loading)return Ue=0,void(Ge=!1);Ue--,Nn(),Hn({preferModelDiffHeight:!0,holdCurrentDiffHeight:Ge}),Fn(),Ue>0?We=de(l):Ge=!1};We=de(l)}function $n(e,l,t,n={}){const o=Fl.value&&!1!==s.loading?hn(e):null,a=null!=o&&o>l+1?o:l,r=Math.min(a,t),i=!0===n.allowBelowEstimatedFloor,u=Qt(r,!0===n.clearEstimatedFloor,{allowBelowEstimatedFloor:i}),d=Rt();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||a>t+1||Tn(e,u);return e.style.overflow=v?"auto":"hidden",u}function Tn(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 zn(e){var l;return Ke||Tn(e,null!=(l=Je.value)?l:0)}function Ln(e=Oe.value){return jn(e)}function _n(e=Oe.value){return jn(e)}function Rn(){var e,l;if(jn())return!0;const t=null==(l=null==(e=fl())?void 0:e.getModel)?void 0:l.call(e);return"function"==typeof(null==t?void 0:t.getValue)&&t.getValue()===ct.value}function jn(e=Oe.value){return Boolean(null==e?void 0:e.querySelector("diffs-container"))}function qn(){return!1!==s.loading||Wl.value}function In(){const e=ml();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 An(){return d(this,null,function*(){if(!Fl.value)return!0;for(let e=0;e<30;e++){if(Ie)return!1;if(jn())return yield O(),yield Zt(),!Ie&&jn();yield O(),yield Zt()}return!1})}function Vn(e,l,t){return d(this,null,function*(){try{return void(yield dl(e,l,t))}catch(n){if(!Tl(n))throw n}if(yield O(),yield Zt(),!Ie&&Fl.value)try{yield dl(e,l,t)}catch(n){if(!Tl(n))throw n}})}function Wn(){var e,l;return null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500}const Un=v(()=>s.isShowPreview&&("html"===Ee.value||"svg"===Ee.value));function Gn(){return"boolean"==typeof s.node.loading?s.node.loading:!0===s.loading}function Yn(e,l,t){return!t||function(){var e,l,t;if(!Gn())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:"")?ne(String(null!=e?e:"")):"plain"}function Jn(){return Gn()}let Xn=null,Kn=!1,Qn=0;function Zn(){Xn=null,Qn++}function eo(){return d(this,arguments,function*(e=Qn){if(!Kn){Kn=!0;try{for(;Xn&&!Ie&&!Fl.value&&e===Qn;){const e=Xn;Xn=null;try{yield Promise.resolve(ul(e.code,e.language)),yield O(),Ie||Fl.value||(Hn(!1),Fn())}catch(l){Me()}}}finally{Kn=!1,!Xn||Ie||Fl.value||eo()}}})}function lo(e,l){Xn={code:e,language:l},eo(Qn)}P(()=>[s.node.language,s.node.code,s.node.raw,s.node.loading,s.loading],([e,l,t,n,o])=>{Ee.value=Yn(e,l,"boolean"==typeof n?n:!0===o)}),P(()=>[s.node.originalCode,s.node.updatedCode,Fl.value],()=>{rn(),de(()=>un())},{immediate:!0});let to=0;P(()=>[s.node.originalCode,s.node.updatedCode,$e.value,Fl.value,s.stream],e=>d(null,[e],function*([,,,e,l]){var t,n;const o=++to;if(!e)return;if(Gn())return;if(!1===l&&!_e.value)return;if(!1!==l&&rl&&!_e.value&&Oe.value)try{yield ho(Oe.value)}catch(u){}const a=wl;if(a&&!Re.value){try{yield a}catch(u){}if(Ie||!Fl.value||o!==to)return}if(o!==to)return;const r=Dl(String(null!=(t=s.node.originalCode)?t:""),String(null!=(n=s.node.updatedCode)?n:"")),i=!1===s.loading;i&&So();try{if(yield Vn(r.original,r.updated,$e.value),Ie||!Fl.value||o!==to)return;yield O(),Fn(!0),Nn(),Hn(!1===s.loading||{preferModelDiffHeight:!0}),Fn(!0),En(!0)}catch(d){return}if(i){if(Ie||!Fl.value)return;zl(),Nn(),un(),En(),Dn(!0)}ze.value&&de(()=>Mn())})),P(()=>s.node.code,e=>d(null,null,function*(){if(Gn())return;if(!1===s.stream)return;if(Ee.value||(Ee.value=ne(xl(e))),Fl.value)return;const l=wl;if(l&&!Re.value){try{yield l}catch(t){}if(Ie||Fl.value)return}if(rl&&!_e.value&&Oe.value)try{yield ho(Oe.value)}catch(t){}lo($l(s.node.code),$e.value),ze.value&&de(()=>Mn())}));const no=v(()=>{const e=Ee.value;return e?oe[e]||e.charAt(0).toUpperCase()+e.slice(1):oe[""]||"Plain Text"}),oo=v(()=>{var e;return K(String(null!=(e=s.node.raw)?e:""),no.value,Fl.value)}),ao=v(()=>oo.value.title),ro=v(()=>oo.value.caption),io=v(()=>(ae.value,re(Ee.value||"",he))),uo=v(()=>{const e={};e["--markstream-code-layout-character-width"]=null==kt.value?"1ch":`${kt.value}px`,e["--markstream-code-fallback-bg"]=ql.value.background,e["--markstream-code-fallback-fg"]=ql.value.foreground,ql.value.builtin&&(e["--markstream-code-theme-bg"]=ql.value.background,e["--markstream-code-theme-fg"]=ql.value.foreground,e["--markstream-code-theme-line-number"]=ql.value.lineNumber),e["--markstream-diff-added-line-fill"]=ql.value.diffAddedLine,e["--markstream-diff-added-number-fill"]=ql.value.diffAddedNumber,e["--markstream-diff-editor-bg"]=ql.value.background,e["--markstream-diff-removed-line-fill"]=ql.value.diffRemovedLine,e["--markstream-diff-removed-number-fill"]=ql.value.diffRemovedNumber,e["--markstream-diff-shell-bg"]=ql.value.background,e["--markstream-pre-resolved-theme-bg"]=ql.value.background,e["--markstream-pre-resolved-theme-fg"]=ql.value.foreground,e["--markstream-pre-resolved-theme-line-number"]=ql.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),At.value&&!Fl.value&&!Le.value){const l=Vt.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)))",Fl.value||(e.borderColor="var(--markstream-code-border-color, var(--code-border))"),e}),so=v(()=>!1!==s.showTooltips);function vo(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(s.node.code)),Ne.value=!0,p("copy",s.node.code),setTimeout(()=>{Ne.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function co(){ze.value=!ze.value;const e=Fl.value?ml():fl(),l=Oe.value;e&&l&&(ze.value?(l.style.maxHeight="none",l.style.overflow="visible",Hn(!0)):(l.style.overflow="auto",Hn(!0)))}function fo(){var e,l;if(Le.value=!Le.value,Le.value){if(Ke=!1,Oe.value){const t=Math.ceil((null==(l=(e=Oe.value).getBoundingClientRect)?void 0:l.call(e).height)||0);Ke=Tn(Oe.value,t)||"auto"===Oe.value.style.overflow||"auto"===Oe.value.style.overflowY,t>0&&(Je.value=t)}}else Oe.value&&null!=Je.value&&(Oe.value.style.height=`${Je.value}px`),Xe=2,O(()=>{Le.value||Ie||(Hn(!0),Fn(!0))})}function mo(){if(!Un.value)return;const e=Ee.value;if(Pe.value){const l="html"===e?"text/html":"image/svg+xml",t="html"===e?He("artifacts.htmlPreviewTitle")||"HTML Preview":He("artifacts.svgPreviewTitle")||"SVG Preview";return void p("previewCode",{node:s.node,artifactType:l,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(vt.value=!vt.value)}function ho(e,l={}){if(!rl||Ie)return null;if(!1===s.stream&&!1!==s.loading)return null;if(Oo(),Fo())return null;if(Vl.value||Oe.value!==e)return null;if(Jn())return null;if(bl)return bl;if(_e.value&&je.value)return Promise.resolve();const t=Po(),n=Jl.value;let o=!1;_e.value=!0,function(){const e=pe.value;fe&&e&&Ye!==e&&(Ye&&fe.markSettled(Ye),Ye=e,fe.markPending(e))}();const a=d(null,null,function*(){try{yield function(e){return d(this,null,function*(){var l,t;if(!rl||Ie)return;const n=Il.value;if(lt=!1,Gl.value=!1,Yl.value=null,Re.value=!1,Wl.value=!1,Ul.value=!1,bt.value=null,wt.value=null,kt.value=null,xt.value=null,On(),function(){if(Kl.value=!1,$t())return void(_t.value=null);const e=zt.value;_t.value=je.value||null==e?null:e}(),Bn(),Pn(),function(e){e.replaceChildren()}(e),So(),Ie)return;const o=d(null,null,function*(){var l,t;if("diff"===n){!function(){if(Cl||"undefined"==typeof window)return;Cl=!0;const e=e=>{var l;Tl("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),Ml=()=>{window.removeEventListener("error",e,!0),window.removeEventListener("unhandledrejection",e,!0),Cl=!1,Ml=null}}(),pl();const n=Dl(String(null!=(l=s.node.originalCode)?l:""),String(null!=(t=s.node.updatedCode)?t:""));il?yield il(e,n.original,n.updated,$e.value):yield rl(e,s.node.code,$e.value)}else yield rl(e,ct.value,$e.value);Re.value=!0}),a=o.finally(()=>{wl===a&&(wl=null)});if(wl=a,yield function(e){return d(this,null,function*(){if(!Fl.value)return void(yield e);let l,t=!1;for(e.then(()=>{t=!0},e=>{t=!0,l=e});;){if(Ie)return;if(t){if(l)throw l;return}if(Ln()&&In())return;yield O(),yield Zt()}})}(a),Ie)return;if(Il.value!==n)return;Re.value=!0;const r=null==(l=s.codeBlockOptions)?void 0:l.fontSize;if("number"==typeof r&&Number.isFinite(r)&&r>0){const e="diff"===n?ml():fl();null==(t=null==e?void 0:e.updateOptions)||t.call(e,{fontSize:r}),gt.value=r,yt.value=r}else if(!yn()){const e=ln();e&&e>0?(gt.value=e,yt.value=e):(gt.value=12,yt.value=12)}gn(),yield ko(),ze.value||Le.value||Hn(!1),je.value=!0,Al.value=n,function(){var e,l,t,n,o;if(Bn(),Fl.value){const n=ml(),o=null==(e=null==n?void 0:n.getOriginalEditor)?void 0:e.call(n),a=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,()=>En());n&&Bl.push(n)}catch(t){}};try{const e=null==(t=null==n?void 0:n.onDidUpdateDiff)?void 0:t.call(n,()=>{En(),de(()=>un())});e&&Bl.push(e)}catch(r){}i(o,"onDidContentSizeChange"),i(a,"onDidContentSizeChange");const u=Oe.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=>{Fl.value&&qn()&&e.some(e=>l(e.target)||Array.from(e.addedNodes).some(t)||Array.from(e.removedNodes).some(l))&&(Nn(),Hn({preferModelDiffHeight:!0}),Fn(),Dn())});n.observe(u,{attributeFilter:["class"],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Bl.push({dispose:()=>n.disconnect()})}if(u&&"undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{if(!Fl.value)return;if(Fn(),!qn())return;const e=hn(u);null!=e&&(Math.ceil(u.getBoundingClientRect().height||0)<=e+1||(Nn(),Hn({preferModelDiffHeight:!0}),Fn()))});e.observe(u),Bl.push({dispose:()=>e.disconnect()})}return}const a=fl();try{const e=null==(n=null==a?void 0:a.onDidContentSizeChange)?void 0:n.call(a,()=>En());e&&Bl.push(e)}catch(r){}try{const e=null==(o=null==a?void 0:a.onDidLayoutChange)?void 0:o.call(a,()=>En());e&&Bl.push(e)}catch(r){}}(),wn(),gn(),Nn(),un(),En(),yield O();let i=null;yl&&(i=yield yl(),i&&(yield O(),yield Zt()));const u=null==i?"diff"===n?yield An():yield function(){return d(this,null,function*(){if(jn())return yield O(),yield Zt(),jn();for(let e=0;e<30;e++){if(Ie||Fl.value)return!1;const e=Oe.value,l=Rn(),t=_n(e),n=!ct.value.trim()||an(e);if(l&&t&&n&&(yield O(),yield Zt(),!Ie&&!Fl.value&&Rn()&&_n(Oe.value)&&(!ct.value.trim()||an(Oe.value))))return!0;yield O(),yield Zt()}return!1})}():i;Ie||(u?(gn(),Kt(),(yield Yt())||No()):No())})}(e),Ql=null}catch(a){const e=Po(),r=n!==Jl.value,i=!1!==l.allowStaleContentRetry&&r&&Ql!==e;if(t!==e||i)return i&&(Ql=e),o=!0,_e.value=!1,je.value=!1,Re.value=!1,void(Wl.value=!1);throw No(t),a}}).finally(()=>{bl===a&&(bl=null),function(){const e=Ye;fe&&e&&(Ye="",O(()=>{var l,t;if(!Ie){const n=null!=(t=null==(l=Fe.value)?void 0:l.offsetHeight)?t:0;n>0&&fe.reportHeight(e,n)}fe.markSettled(e)}))}(),o&&!Ie&&queueMicrotask(()=>{var e;const l=Oe.value;l&&!Ie&&(null==(e=ho(l))||e.catch(e=>{je.value=!1,Wl.value=!1,No()}))})});return bl=a,a}P(so,e=>{e||Q()}),P(()=>yt.value,(e,l)=>{var t;const n=Fl.value?ml():fl();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(null==(t=n.updateOptions)||t.call(n,{fontSize:e}),Le.value||Hn(!0))},{flush:"post",immediate:!1});let po=0;const go=P(()=>[Oe.value,Fl.value,s.stream,s.loading,qe.value,tl.value,s.node.language,s.node.raw,s.node.code,s.node.loading],e=>d(null,[e],function*([e,l,t,n,o,a]){const r=++po;if(!e)return;if(!a)return;if(Gn())return;if(Zl)return;if(!1===t&&!1!==n)return;if(!rl){if(yield function(){return d(this,null,function*(){if("undefined"==typeof window||Ie)return;if(qe.value||Vl.value)return;if(kl)return kl;const e=d(null,null,function*(){try{const e=yield ce();if(Ie)return;if(!e)return void(Vl.value=!0);mt(e)}catch(e){if(Ie)return;Vl.value=!0}}).finally(()=>{kl===e&&(kl=null)});return kl=e,e})}(),r!==po)return;if(!1===s.stream&&!1!==s.loading)return;if(Jn())return;if(!tl.value)return;if(!rl||Vl.value||_e.value||Fo()||Ie||Oe.value!==e)return}if(Jn())return;const i=ho(e);if(i){try{yield i}catch(u){je.value=!1,Wl.value=!1,No()}je.value&&Wl.value&&go()}}));function yo(e){return"string"==typeof e?e:null}function bo(e,l){if(e===l)return!0;const t=yo(e),n=yo(l);return!!t&&t===n}function wo(){return ee({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})}function ko(){return d(this,arguments,function*(e={}){So();const l=()=>{Fl.value&&zl(),de(()=>{wn(),En()})};if(e.appearanceOnly)return void l();const t=wo();if(t)try{yield Sl(t),l()}catch(n){}else l()})}function xo(){var e,l;const t=Ot.value,n=u(i({},Ll.value||{}),{wordWrap:"wrap"===t.overflow?"on":"off",overflow:t.overflow,themes:s.themes,stream:!1,MAX_HEIGHT:null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500,fontSize:Ct.value,lineHeight:Bt.value,theme:wo(),themeType:s.isDark?"dark":"light",disableLineNumbers:!b.value,disableFileHeader:!0,onThemeChange(){wn()}}),o=function(){var e;const l=null==(e=Ll.value)?void 0:e.fontFamily;return"string"==typeof l&&l.trim()?l.trim():Fl.value?function(){var e;if("undefined"==typeof window)return;const l=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l)return;return window.getComputedStyle(l).fontFamily.trim()||void 0}():void 0}();o&&(null!=n.fontFamily||(n.fontFamily=o));const a="string"==typeof n.unsafeCSS?n.unsafeCSS:"",r=`\n[data-file] [data-line],\n[data-diff] [data-line] {\n white-space: ${"wrap"===(d=t.overflow)?"pre-wrap":"pre"} !important;\n overflow-wrap: ${"wrap"===d?"anywhere":"normal"} !important;\n word-break: normal !important;\n}`;var d;return n.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }\n${r}\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${a}`.trim(),n}function So(){const e=xo();if(!Hl)return Hl=e,Hl;for(const l of Object.keys(Hl))l in e||delete Hl[l];return Object.assign(Hl,e),Hl}P(Il,(e,l)=>d(null,null,function*(){if(e===l)return;if(Gl.value||Zl)return;if(Zn(),!rl||!Oe.value)return;if(!_e.value)return;if(!1===s.stream&&!1!==s.loading)return;if(!tl.value)return;const t=bl;if(t){try{yield t}catch(n){}if(Ie||!Oe.value)return}if(Al.value!==e||!_e.value||!je.value)try{je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),yield O(),yield ho(Oe.value)}catch(o){je.value=!1,Wl.value=!1,No()}}));const Co=M(0),Mo=v(()=>String(Co.value));let Bo=!1;function Po(){var e;const l=wo();return JSON.stringify({kind:Il.value,language:$e.value,structural:Mo.value,optionsRevision:Co.value,settledContentGeneration:Xl.value,theme:null!=(e=yo(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:ht;gt.value=l,yt.value=l,bt.value=null,wt.value=null,kt.value=null}),P(()=>[s.codeBlockOptions,s.showLineNumbers],()=>{Co.value+=1,!1===s.stream&&!1!==s.loading&&(Bo=!0)},{deep:!0}),P(()=>[ct.value,s.node.originalCode,s.node.updatedCode],()=>{Jl.value+=1,Gn()||(Xl.value+=1)});const Ho=v(()=>Po());function Oo(){Gl.value&&Yl.value!==Ho.value&&(Gl.value=!1,Yl.value=null,Ql=null,et=null,_e.value=!1,je.value=!1,Re.value=!1,Wl.value=!1,Ul.value=!1)}function Fo(){return Oo(),Gl.value&&Yl.value===Ho.value}function No(e=Ho.value){Yl.value=e,Gl.value=!0,Ul.value=!1}return P(Ho,()=>d(null,null,function*(){if(Zl)return;if(!Gl.value)return;if(Yl.value===Ho.value)return;if(!rl||!Oe.value||Vl.value||Ie||!tl.value)return;if(!1===s.stream&&!1!==s.loading)return;if(Jn())return;const e=Ho.value;Zl=!0;try{if(Oo(),Gl.value)return;yield ho(Oe.value)}catch(l){je.value=!1,Wl.value=!1,No()}finally{et=e,yield O(),Zl=!1}})),P(()=>[s.codeBlockOptions,tl.value],()=>{var e,l;if(So(),!rl||!tl.value)return;const t=Fl.value?ml():fl(),n="number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize)?s.codeBlockOptions.fontSize:Number.isFinite(yt.value)?yt.value:void 0;"number"==typeof n&&Number.isFinite(n)&&n>0&&(null==(l=null==t?void 0:t.updateOptions)||l.call(t,{fontSize:n})),Hn(!1)},{deep:!0}),P(()=>[wo(),Rl.value,qe.value,_e.value,tl.value],([e],l)=>{qe.value&&je.value&&tl.value&&ko({appearanceOnly:null!=l&&bo(e,l[0])})},{flush:"post"}),P(()=>[Mo.value,qe.value,tl.value],(e,l)=>d(null,[e,l],function*([e,l,t],[n]){if(So(),!l||!t)return;if(!rl||!Oe.value)return;if(!_e.value)return;if(e===n)return;if(!1===s.stream&&!1!==s.loading)return void(Bo=!0);Bo=!1;const o=bl;if(o){try{yield o}catch(a){}if(Ie||!Oe.value)return}try{je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),Ol&&mt(Ol),yield O(),yield ho(Oe.value,{allowStaleContentRetry:!1})}catch(r){je.value=!1,Wl.value=!1,No()}}),{flush:"post"}),P(()=>[s.loading,tl.value],([e,l])=>{!1===e&&l&&Bo&&(Bo=!1,Co.value+=1)},{flush:"post"}),P(()=>[s.loading,tl.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&&Fl.value&&_e.value&&(yield O(),de(()=>{d(null,null,function*(){const e=bl;if(e)try{yield e}catch(l){}!Ie&&Fl.value&&!1!==s.loading&&(So(),zl(),En())})})),e)return;const o=void 0!==n&&!1!==n;yield O(),de(()=>{d(null,null,function*(){var e,l;try{if(o&&(yield function(){return d(this,null,function*(){if(!Gl.value)return!1;if(!rl||!Oe.value||Vl.value||Ie||!tl.value)return!1;if(et===Ho.value)return!0;Zl=!0;try{Gl.value=!1,Yl.value=null,Ql=null,_e.value=!1,je.value=!1,Re.value=!1,Wl.value=!1,Bn(),Pn(),pl(),Ol&&mt(Ol),yield O();try{yield ho(Oe.value)}catch(e){je.value=!1,Wl.value=!1,No()}}finally{yield O(),Zl=!1}return!0})}()))return void Hn(!1);if(o&&Fl.value&&_e.value&<&&Oe.value)return lt=!1,je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),yield O(),yield ho(Oe.value,{allowStaleContentRetry:!1}),void Dn(!0);if(o&&_e.value)if(Fl.value&&Oe.value){const n=bl;if(n)try{yield n}catch(t){}So();const o=Dl(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:""));if(yield Vn(o.original,o.updated,$e.value),Ie||!Fl.value)return;yield Promise.resolve(vl()),zl(),Fn(!0),Gt(),Nn(),un();const a=yield An();Ie||!a||Wl.value||(yield Yt()),En(),Dn(!0)}else Zn(),lo(ct.value,$e.value),yield new Promise(e=>{const l=()=>{Ie?e():Kn||Xn?setTimeout(l,16):e()};l()}),Ie||Fl.value||(yield Promise.resolve(sl()));o&&Fl.value?(Hn({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),Dn(!0)):Hn(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{Bn(),Pn(),hl(),null==Ml||Ml()}),(l,t)=>{var n;return Vl.value?(m(),h(ie,{key:0,style:F(It.value),node:ft.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":tt.value,"diff-hide-unchanged-regions":nt.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Ot.value,"reserved-height-px":Fl.value&&null!=(n=xt.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:Fe,style:F(uo.value),class:y(["code-block-container rounded-lg border",[{dark:s.isDark,"is-rendering":s.loading,"is-dark":jl.value,"is-diff":Fl.value,"is-plain-text":Te.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":Wl.value&&!Vl.value?"true":"false","data-markstream-enhancement-state":st.value,"data-markstream-code-block-state":Gn()?"streaming":"settled","data-markstream-pending":dt.value?"true":void 0,"data-markstream-viewport-pending":al.value&&k(el)&&!tl.value?"true":void 0},[T(ue,{"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":Le.value,"is-expanded":ze.value,"copy-text":Ne.value,"is-previewable":Un.value,"code-font-size":yt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":gt.value,"font-baseline-ready":St.value,"diff-stats":Fl.value?Nl.value:null,"diff-stats-aria-label":El.value,onToggleCollapse:fo,onDecreaseFont:vn,onResetFont:cn,onIncreaseFont:sn,onCopy:vo,onToggleExpand:co,onPreview:mo},N({"header-left":E(()=>[D(l.$slots,"header-left",{},()=>[g("div",be,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:io.value},null,8,we),g("div",ke,[g("div",xe,w(ao.value),1),ro.value?(m(),$("div",Se,w(ro.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":Le.value}])},[g("div",{ref_key:"codeEditor",ref:Oe,class:y(["code-editor-container",e.stream?"":"code-height-placeholder"]),"data-markstream-host-hidden":ut.value?"true":void 0,style:F(Wt.value)},null,14,Ce),it.value?(m(),h(ie,{key:0,style:F(It.value),node:ft.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":tt.value,"diff-hide-unchanged-regions":nt.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Ot.value,"reserved-height-px":Fl.value&&null!=(l=xt.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]]),vt.value&&!Pe.value&&Un.value&&"html"===Ee.value?(m(),h(ge,{key:0,code:s.node.code,"html-preview-allow-scripts":s.htmlPreviewAllowScripts,"html-preview-sandbox":s.htmlPreviewSandbox,"is-dark":s.isDark,"on-close":()=>vt.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,ye))}}}),[["__scopeId","data-v-7f563cd3"]]);export{Me as default};
|