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