markstream-vue 1.0.1-beta.1 → 1.0.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,7 @@ Looking for other frameworks?
24
24
 
25
25
  ## 1.0 stability scope
26
26
 
27
- `markstream-vue@1.0` is scoped to the Vue 3 renderer package. The stable surface is `MarkdownRender`, streaming content rendering, pre-parsed node rendering, the safe HTML policy, optional Mermaid / KaTeX / Monaco / D2 / Infographic integrations, CSS exports, worker client subpaths, and SSR imports for Vite / Nuxt / VitePress.
27
+ `markstream-vue@1.0` is scoped to the Vue 3 renderer package. The stable surface is `MarkdownRender`, streaming content rendering, pre-parsed node rendering, the safe HTML policy, optional Mermaid / KaTeX / Monaco / D2 / Infographic integrations, virtual-scroll coordination, CSS exports, worker client subpaths, and SSR imports for Vite / Nuxt / VitePress.
28
28
 
29
29
  Experimental surfaces are the cross-framework adapters, repository skills/prompts, low-level worker entrypoints beyond documented clients, and internal performance/debug props such as `indexKey`, `renderAsFragment`, `debugPerformance`, batch budget internals, and height-estimation experiments.
30
30
 
@@ -377,6 +377,7 @@ Pick one mode per surface: virtualization for best scrollback and steady memory
377
377
  - `parse-options`: reuse parser hooks (e.g., `preTransformTokens`, `requireClosingStrong`) on the component.
378
378
  - `final`: marks end-of-stream; disables mid-state loading parsing and forces unfinished constructs to settle.
379
379
  - `custom-html-tags`: extend streaming HTML allowlist for custom tags and emit them as custom nodes for `setCustomComponents` (e.g., `['thinking']`).
380
+ Declared custom nodes keep `content`/`raw` close to the original tag payload, while `children` remains the Markdown-rendered form for rich text.
380
381
  - `setCustomComponents(customId?, mapping)`: register inline Vue components for custom tags/markers (scoped by `custom-id` when provided).
381
382
 
382
383
  Example: map Markdown placeholders to Vue components (scoped)
package/README.zh-CN.md CHANGED
@@ -363,6 +363,7 @@ function addChunk(chunk: string) {
363
363
  - `parse-options`:在组件上复用解析钩子(如 `preTransformTokens`、`requireClosingStrong`)。
364
364
  - `final`:标记“最终态/流结束”,关闭中间态 loading 解析并强制收敛未闭合结构。
365
365
  - `custom-html-tags`:扩展流式 HTML 白名单并将这些标签输出为自定义节点,便于 `setCustomComponents` 直接映射(如 `['thinking']`)。
366
+ 声明过的自定义节点会尽量让 `content`/`raw` 保留原始标签 payload,`children` 则仍作为富文本场景下的 Markdown 渲染结果。
366
367
  - `setCustomComponents(customId?, mapping)`:为自定义标签/标记注册内嵌 Vue 组件(传 `custom-id` 可限定作用域)。
367
368
 
368
369
  示例:将 Markdown 占位符映射到 Vue 组件(作用域)
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(t,n,l)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[n]=l,a=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&r(e,n,t[n]);if(l)for(var n of l(t))i.call(t,n)&&r(e,n,t[n]);return e},u=(e,l)=>t(e,n(l)),d=(e,t,n)=>new Promise((l,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},r=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);a((n=n.apply(e,t)).next())});import{defineComponent as s,computed as c,onMounted as v,onUnmounted as f,openBlock as m,createBlock as p,Teleport as h,createElementVNode as y,normalizeClass as g,withModifiers as b,toDisplayString as w,unref as k,getCurrentInstance as S,ref as C,watch as x,onBeforeUnmount as P,nextTick as O,createElementBlock as M,normalizeStyle as E,createVNode as L,createSlots as B,withCtx as H,withDirectives as z,createCommentVNode as N,vShow as F,renderSlot as D}from"vue";import{b as T,_,n as R,r as $,a as A,j,l as I,k as W,m as U,h as q,o as V,q as G,s as J,t as X}from"./exports.js";import{safeRaf as Y,safeCancelRaf as K}from"./utils/safeRaf.js";const Q={class:"html-preview-frame__header"},Z={class:"html-preview-frame__title"},ee={class:"html-preview-frame__label"},te=["sandbox","srcdoc"],ne=/* @__PURE__ */_(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const t=e,n=void 0!==import.meta&&Boolean(!1);let l=null;const{t:o}=T(),i=c(()=>{const e=t.code||"",n=e.trim().toLowerCase();return n.startsWith("<!doctype")||n.startsWith("<html")||n.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: ${t.isDark?"#020617":"#ffffff"};\n color: ${t.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=c(()=>{return e=t.htmlPreviewSandbox,o=t.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!n||"undefined"==typeof console||l===e)return;const t=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);t.has("allow-scripts")&&t.has("allow-same-origin")&&(l=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 a(e){var n;"Escape"!==e.key&&"Esc"!==e.key||null==(n=t.onClose)||n.call(t)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",a)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",a)}),(e,n)=>(m(),p(h,{to:"body"},[y("div",{class:g(["markstream-vue",{dark:t.isDark}])},[y("div",{class:"html-preview-frame__backdrop",onClick:n[2]||(n[2]=e=>{var n;return null==(n=t.onClose)?void 0:n.call(t)})},[y("div",{class:"html-preview-frame",onClick:n[1]||(n[1]=b(()=>{},["stop"]))},[y("div",Q,[y("div",Z,[n[3]||(n[3]=y("span",{class:"html-preview-frame__dot"},null,-1)),y("span",ee,w(t.title||k(o)("common.preview")||"Preview"),1)]),y("button",{type:"button",class:"html-preview-frame__close",onClick:n[0]||(n[0]=e=>{var n;return null==(n=t.onClose)?void 0:n.call(t)})}," × ")]),y("iframe",{class:"html-preview-frame__iframe",sandbox:r.value,referrerpolicy:"no-referrer",srcdoc:i.value},null,8,te)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]);let le=null,oe=null,ie=null,re=null,ae=null,ue=null;const de=/* @__PURE__ */new WeakMap;let se=0;const ce=["data-markstream-enhanced"],ve={class:"code-header-main"},fe=["innerHTML"],me={class:"code-header-copy"},pe={class:"code-header-title"},he={key:0,class:"code-header-caption"},ye={class:"code-editor-layer"},ge="__markstreamMonacoPassiveTouchState__",be=/* @__PURE__ */_(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:t}){var n;const l=e,o=t;const i=S(),r=c(()=>{const e=null==i?void 0:i.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:s}=T(),v=C(null),h=C(null),b=C(!1),_=C(R(l.node.language)),Q=c(()=>$(_.value)),Z=c(()=>"plaintext"===Q.value),ee=C(!1),te=C(!1),be=C(!1),we=C(!1),ke=C(!1);let Se=!1,Ce=null;const xe=C(null),Pe=C(null);let Oe=0,Me=0;const Ee=A(),Le=C(null),Be=C("undefined"==typeof window);"undefined"!=typeof window&&x(()=>h.value,e=>{var t;if(null==(t=Le.value)||t.destroy(),Le.value=null,!e)return void(Be.value=!1);const n=Ee(e,{rootMargin:"400px"});Le.value=n,Be.value=n.isVisible.value,n.whenVisible.then(()=>{Be.value=!0})},{immediate:!0}),P(()=>{var e;Se=!0,null==(e=Le.value)||e.destroy(),Le.value=null});let He=null,ze=null,Ne=()=>{},Fe=()=>{},De=()=>null,Te=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),_e=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Re=()=>{},$e=()=>{},Ae=()=>{},je=null,Ie=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},We=()=>d(null,null,function*(){});const Ue=[],qe=[];let Ve=null;const Ge=c(()=>l.node.diff),Je=C({removed:0,added:0}),Xe=c(()=>`-${Je.value.removed} +${Je.value.added}`),Ye=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5}),Ke=Object.freeze(u(a({},Ye),{enabled:!1,revealLineCount:0}));function Qe(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return u(a(a({},Ye),n),{enabled:null==(t=n.enabled)||t})}return a({},Ye)}function Ze(e,t){return{original:String(null!=e?e:""),updated:String(null!=t?t:"")}}const et=c(()=>{var e,t,n;const o=l.monacoOptions?a({},l.monacoOptions):{};if(!Ge.value)return o;const i=void 0===o.diffHideUnchangedRegions?a({},Ye):Qe(o.diffHideUnchangedRegions),r=void 0===o.hideUnchangedRegions?void 0:Qe(o.hideUnchangedRegions),d=!1!==l.stream&&!1!==l.loading,s=d?a({},Ke):i,c=d?a({},Ke):r,v=a({},null!=(e=o.experimental)?e:{}),f=null!=(t=o.diffUnchangedRegionStyle)?t:"line-info",m={maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:s,useInlineViewWhenSpaceIsLimited:null!=(n=o.useInlineViewWhenSpaceIsLimited)&&n,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:f,diffHunkActionsOnHover:!1,experimental:v};return u(a(u(a(a({},m),o),{experimental:v}),void 0===c?{}:{hideUnchangedRegions:c}),{diffHideUnchangedRegions:s})}),tt=c(()=>Ge.value?"diff":"single"),nt=C(tt.value),lt=C(!1),ot=C(!1),it=C(!1),rt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.wordWrap;return null==t||"off"!==String(t)}),at=c(()=>!(lt.value||!it.value&&(X()||ot.value))),ut=C(!1);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield j();if(Se)return;if(!e)return void(lt.value=!0);const t=e.useMonaco,n=e.detectLanguage;if("function"==typeof n&&(Ie=n),"function"==typeof t){const e=mn();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");Ve=gn();const n=t(Ve);He=n.createEditor||He,ze=n.createDiffEditor||ze,Ne=n.updateCode||Ne,Fe=n.updateDiff||Fe,De=n.getEditor||De,Te=n.getEditorView||Te,_e=n.getDiffEditorView||_e,Re=n.cleanupEditor||Re,$e=n.safeClean||n.cleanupEditor||$e,Ae=n.refreshDiffPresentation||Ae,We=n.setTheme||We,ke.value=!0,!Se&&v.value&&(yield dn(v.value))}}catch(e){if(Se)return;lt.value=!0}});const dt=C("number"==typeof(null==(n=l.monacoOptions)?void 0:n.fontSize)?l.monacoOptions.fontSize:Number.NaN),st=C(dt.value),ct=c(()=>{const e=dt.value,t=st.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof t&&Number.isFinite(t)&&t>0}),vt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const n=st.value;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:14}),ft=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:Math.max(12,Math.round(1.35*vt.value))}),mt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:4}),pt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.padding;return{top:"number"==typeof(null==t?void 0:t.top)&&Number.isFinite(t.top)&&t.top>0?t.top:0,bottom:"number"==typeof(null==t?void 0:t.bottom)&&Number.isFinite(t.bottom)&&t.bottom>0?t.bottom:0}}),ht=c(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),yt=c(()=>{const e=l.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),gt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.fontFamily;return a(a({fontSize:`${vt.value}px`,lineHeight:`${ft.value}px`,tabSize:mt.value,boxSizing:"border-box",maxHeight:`${Jt()}px`,overflow:"auto",paddingTop:`${pt.value.top}px`,paddingBottom:`${pt.value.bottom}px`},null!=ht.value?{height:`${ht.value}px`,minHeight:`${ht.value}px`}:{}),"string"==typeof t&&t.trim()?{"--markstream-code-font-family":t.trim()}:{})}),bt=c(()=>null!=ht.value&&(!ot.value||null!=St())),wt=c(()=>{if(bt.value)return{minHeight:`${ht.value}px`}}),kt=C(null);function St(){const e=kt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function Ct(e,t=!1){const n=Math.ceil(e),l=St();return null==l?n:n>=l?(t&&we.value&&(kt.value=null),n):l}function xt(){return new Promise(e=>{Y(()=>e())})}function Pt(){var e,t,n,l,o;try{const i=Ge.value?null!=(n=null==(t=null==(e=_e())?void 0:e.getModifiedEditor)?void 0:t.call(e))?n:_e():Te(),r=De(),a=null==(l=null==r?void 0:r.EditorOption)?void 0:l.fontInfo;if(i&&null!=a){const e=null==(o=i.getOption)?void 0:o.call(i,a),t=null==e?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t}}catch(i){}try{const e=v.value;if(e){const t=e.querySelector(".view-lines .view-line");if(t)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(t).fontSize,n=e&&e.match(/^(\d+(?:\.\d+)?)/);if(n)return Number.parseFloat(n[1])}}catch(i){}}}catch(i){}return null}function Ot(e){var t,n;try{const l=De(),o=null==(t=null==l?void 0:l.EditorOption)?void 0:t.lineHeight;if(null!=o){const t=null==(n=null==e?void 0:e.getOption)?void 0:n.call(e,o);if("number"==typeof t&&t>0)return t}}catch(i){}const l=function(){try{const e=v.value;if(!e)return null;const t=e.querySelector(".view-lines .view-line");if(t){const e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch(i){}return null}();if(l&&l>0)return l;const o=Number.isFinite(st.value)&&st.value>0?st.value:14;return Math.max(12,Math.round(1.35*o))}function Mt(e){var t,n,l;try{const l=De(),o=null==(t=null==l?void 0:l.EditorOption)?void 0:t.padding;if(null!=o){const t=null==(n=null==e?void 0:e.getOption)?void 0:n.call(e,o),l="number"==typeof(null==t?void 0:t.top)?t.top:0,i="number"==typeof(null==t?void 0:t.bottom)?t.bottom:0;if(l>0||i>0)return l+i}}catch(a){}const o=null==(l=et.value)?void 0:l.padding,i="number"==typeof(null==o?void 0:o.top)?o.top:0,r="number"==typeof(null==o?void 0:o.bottom)?o.bottom:0;return i>0||r>0?i+r:Ge.value?24:0}function Et(e,t){return"number"!=typeof e||"number"!=typeof t||e<1||t<e?0:t-e+1}function Lt(e){if(!e)return[];const t=e.split(/\r?\n/);return 1===t.length&&""===t[0]?[]:t}function Bt(){var e,t;Ge.value?Je.value=function(e,t){const n=Lt(e),l=Lt(t);let o=0,i=n.length-1,r=l.length-1;for(;o<=i&&o<=r&&n[o]===l[o];)o++;for(;i>=o&&r>=o&&n[i]===l[r];)i--,r--;return{removed:Math.max(0,i-o+1),added:Math.max(0,r-o+1)}}(String(null!=(e=l.node.originalCode)?e:""),String(null!=(t=l.node.updatedCode)?t:"")):Je.value={removed:0,added:0}}function Ht(){var e;if(Ge.value)try{const t=_e(),n=null==(e=null==t?void 0:t.getLineChanges)?void 0:e.call(t);if(!Array.isArray(n))return void Bt();let l=0,o=0;for(const e of n)l+=Et(e.originalStartLineNumber,e.originalEndLineNumber),o+=Et(e.modifiedStartLineNumber,e.modifiedEndLineNumber);Je.value={removed:l,added:o}}catch(t){Bt()}else Je.value={removed:0,added:0}}function zt(){var e;if(Number.isFinite(st.value)&&st.value>0&&Number.isFinite(dt.value))return st.value;const t=Pt();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(dt.value=l.monacoOptions.fontSize,st.value=l.monacoOptions.fontSize,st.value):t&&t>0?(dt.value=t,st.value=t,t):(dt.value=12,st.value=12,12)}function Nt(){const e=zt(),t=Math.min(36,e+1);st.value=t}function Ft(){const e=zt(),t=Math.max(10,e-1);st.value=t}function Dt(){zt(),Number.isFinite(dt.value)&&(st.value=dt.value)}function Tt(){var e,t,n,l,o,i,r,a,u,d,s,c,v,f;try{const m=Ge.value?_e():null,p=Ge.value?m:Te();if(!p)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const v=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(t=m.getModifiedEditor)?void 0:t.call(m);null==(n=null==v?void 0:v.layout)||n.call(v),null==(l=null==f?void 0:f.layout)||l.call(f);const p=(null==(o=null==v?void 0:v.getContentHeight)?void 0:o.call(v))||0,h=(null==(i=null==f?void 0:f.getContentHeight)?void 0:i.call(f))||0,y=Math.max(p,h);if(y>0)return Math.ceil(y+1);const g=(null==(u=null==(a=null==(r=null==v?void 0:v.getModel)?void 0:r.call(v))?void 0:a.getLineCount)?void 0:u.call(a))||1,b=(null==(c=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:c.call(s))||1,w=Math.max(g,b),k=Math.max(Ot(v),Ot(f));return Math.ceil(w*(k+1.5)+0+1)}if(null==p?void 0:p.getContentHeight){null==(v=null==p?void 0:p.layout)||v.call(p);const e=p.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==p?void 0:p.getModel)?void 0:f.call(p);let y=1;h&&"function"==typeof h.getLineCount&&(y=h.getLineCount());const g=Ot(p);return Math.ceil(y*(g+1.5)+0+1)}catch(m){return null}}function _t(e){var t;const n=String(null!=e?e:"").trim(),l=null==(t=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:t[1];if(l){const e=3===l.length?l.split("").map(e=>`${e}${e}`).join(""):l;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=n.match(/\d+(?:\.\d+)?/g);if(!o||o.length<3)return null;const[i,r,a]=o.slice(0,3).map(Number);return.2126*i+.7152*r+.0722*a}function Rt(){var e,t,n,l,o,i,r,a;const u=v.value,d=h.value;if(!u||!d)return;const s=u,c=u.querySelector(".monaco-editor")||u,f=c.querySelector(".monaco-editor-background")||c,m=c.querySelector(".view-lines")||c;let p=null,y=null,g=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(c),y=f===c?p:window.getComputedStyle(f),g=m===c?p:window.getComputedStyle(m))}catch(x){p=null,y=null,g=null}const b=String(null!=(e=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),w=String(null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?t:"").trim(),k=String(null!=(l=null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?n:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),S=b||String(null!=(i=null!=(o=null==g?void 0:g.color)?o:null==p?void 0:p.color)?i:"").trim(),C=w||String(null!=(a=null!=(r=null==y?void 0:y.backgroundColor)?r:null==p?void 0:p.backgroundColor)?a:"").trim();return Ge.value?(S?(d.style.setProperty("--markstream-diff-editor-fg",S),s.style.setProperty("--vscode-editor-foreground",S),s.style.setProperty("--stream-monaco-editor-fg",S)):(d.style.removeProperty("--markstream-diff-editor-fg"),s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--stream-monaco-editor-fg")),C?(d.style.setProperty("--markstream-diff-editor-bg",C),d.style.setProperty("--markstream-diff-panel-bg",C),d.style.setProperty("--markstream-diff-panel-bg-soft",C),d.style.setProperty("--markstream-diff-panel-bg-strong",C),s.style.setProperty("--vscode-editor-background",C),s.style.setProperty("--stream-monaco-editor-bg",C),s.style.setProperty("--stream-monaco-fixed-editor-bg",C),s.style.setProperty("--stream-monaco-panel-bg",C),s.style.setProperty("--stream-monaco-panel-bg-soft",C),s.style.setProperty("--stream-monaco-panel-bg-strong",C),s.style.backgroundColor=C):(d.style.removeProperty("--markstream-diff-editor-bg"),d.style.removeProperty("--markstream-diff-panel-bg"),d.style.removeProperty("--markstream-diff-panel-bg-soft"),d.style.removeProperty("--markstream-diff-panel-bg-strong"),s.style.removeProperty("--vscode-editor-background"),s.style.removeProperty("--stream-monaco-editor-bg"),s.style.removeProperty("--stream-monaco-fixed-editor-bg"),s.style.removeProperty("--stream-monaco-panel-bg"),s.style.removeProperty("--stream-monaco-panel-bg-soft"),s.style.removeProperty("--stream-monaco-panel-bg-strong"),s.style.backgroundColor=""),void(k?s.style.setProperty("--vscode-editor-selectionBackground",k):s.style.removeProperty("--vscode-editor-selectionBackground"))):function(e,t,n){if(!Z.value)return!1;const l=_t(e),o=_t(t);return n?null!=l&&l>170||null!=o&&o<110:null!=l&&l<85||null!=o&&o>190}(C,S,d.classList.contains("is-dark"))?(s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--vscode-editor-background"),void s.style.removeProperty("--vscode-editor-selectionBackground")):(S&&s.style.setProperty("--vscode-editor-foreground",S),C&&s.style.setProperty("--vscode-editor-background",C),void(k&&s.style.setProperty("--vscode-editor-selectionBackground",k)))}const $t=/auto|scroll|overlay/i;function At(e,t,n){var l;if("undefined"==typeof window)return;if(Ge.value)return;const o=Math.ceil(t),i=Math.ceil(n)-o;if(!i)return;const r=function(e){var t,n;if("undefined"==typeof window)return null;const l=null!=(t=null==e?void 0:e.ownerDocument)?t:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(n=null==e?void 0:e.parentElement)?n:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),t=(e.overflowY||"").toLowerCase(),n=(e.overflow||"").toLowerCase();if($t.test(t)||$t.test(n))return i;i=i.parentElement}return o}(e);if(!r)return;const a=null!=(l=e.ownerDocument)?l:document,u=r===a.body||r===a.documentElement||r===a.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,i):r.scrollTop+=i)}function jt(){try{const e=v.value;if(!e)return;const t=e.getBoundingClientRect().height,n=Tt();if(null!=n&&n>0){const l=Ct(n,!0),o=St();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",void At(e,t,l)}const l=St();null!=l&&(e.style.minHeight=`${l}px`,e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",At(e,t,l))}catch(e){}}function It(){for(var e,t;Ue.length>0;)try{null==(t=null==(e=Ue.pop())?void 0:e.dispose)||t.call(e)}catch(n){}null!=Ce&&(K(Ce),Ce=null)}function Wt(){for(var e;qe.length>0;)try{null==(e=qe.pop())||e()}catch(t){}}function Ut(e=!1){te.value||(ee.value?jt():function(){var e;try{const t=v.value;if(!t)return;const n=t.getBoundingClientRect().height,l=Jt(),o=Math.ceil((null==(e=t.getBoundingClientRect)?void 0:e.call(t).height)||0),i=Ge.value?function(){var e,t,n,l,o,i,r,a;try{const u=_e(),d=null==(e=null==u?void 0:u.getOriginalEditor)?void 0:e.call(u),s=null==(t=null==u?void 0:u.getModifiedEditor)?void 0:t.call(u);if(!d||!s)return null;const c=(null==(o=null==(l=null==(n=d.getModel)?void 0:n.call(d))?void 0:l.getLineCount)?void 0:o.call(l))||1,v=(null==(a=null==(r=null==(i=s.getModel)?void 0:i.call(s))?void 0:r.getLineCount)?void 0:a.call(r))||1,f=Math.max(c,v),m=Math.max(Ot(d),Ot(s)),p=Math.max(Mt(d),Mt(s));return Math.ceil(f*(m+1.5)+p+0+1)}catch(u){return null}}():null,r=Ge.value&&function(e){if("undefined"==typeof window)return!1;const t=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const n of Array.from(t)){if(!(n instanceof HTMLElement))continue;const e=window.getComputedStyle(n);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const t=n.getBoundingClientRect();if(!(t.width<=0||t.height<=0))return!0}return!1}(t);if(r||(Pe.value=null),Me>0&&(Me--,null!=xe.value))return void At(t,n,Gt(t,xe.value,l));const a=Ge.value?function(e){var t,n;if("undefined"==typeof window)return null;try{const l=e.getBoundingClientRect();if(l.height<=0)return null;const o=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let i=0;for(const t of Array.from(e.querySelectorAll(o.join(",")))){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const n=t.getBoundingClientRect();n.height<=0||n.bottom<=l.top||(i=Math.max(i,n.bottom-l.top))}if(i>0)return Math.ceil(i+1);const r=e.querySelector(".monaco-diff-editor"),a=null!=(n=null==(t=null==r?void 0:r.getBoundingClientRect)?void 0:t.call(r).height)?n:0;return a>0?Math.ceil(a+1):null}catch(l){return null}}(t):null,u=Ge.value?r?a:Math.max(null!=a?a:0,null!=i?i:0)||null:Tt();if(null!=u&&u>0){const e=null!=Pe.value&&Date.now()<Oe&&u>=l-1,i=r&&o>0&&o<l-1&&u>=l-1,a=Gt(t,e?Pe.value:i?o:u,l,{clearEstimatedFloor:!0});return r&&a<l-1&&(Pe.value=a,Oe=Date.now()+160),void At(t,n,a)}if(null!=xe.value)return void At(t,n,Gt(t,xe.value,l));const d=r?o:Math.max(o,null!=i&&i>0?i:0);if(d>0){const e=null!=Pe.value&&Date.now()<Oe&&d>=l-1,i=r&&o>0&&o<l-1&&d>=l-1,a=Gt(t,e?Pe.value:i?o:d,l);return r&&a<l-1&&(Pe.value=a,Oe=Date.now()+160),void At(t,n,a)}const s=St();if(null!=s)return void At(t,n,Gt(t,s,l));const c=Number.parseFloat(t.style.height);!Number.isNaN(c)&&c>0?At(t,n,Gt(t,c,l)):Ge.value||At(t,n,Gt(t,l,l))}catch(t){}}())}function qt(){if(!Ge.value)return void Wt();const e=v.value;if(!e)return void Wt();const t=e.querySelector(".monaco-diff-editor");if(!t||t.classList.contains("side-by-side"))return void Wt();const n=Array.from(t.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(t.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(n.length,l.length);for(let i=0;i<o;i++){const e=l[i],t=e.querySelector("a"),n=e.querySelector(".center > div:first-child"),o=e.querySelector(".center");if(!t||!n||!o)continue;if(o.querySelector(".markstream-inline-fold-proxy"))continue;const r=document.createElement("button");r.type="button",r.className="markstream-inline-fold-proxy",r.dataset.markstreamInlineFoldProxy="true";const a=t.getAttribute("title")||"Show Unchanged Region";r.title=a,r.setAttribute("aria-label",a);const u=e=>{e.preventDefault(),e.stopPropagation()},d=e=>{e.preventDefault(),e.stopPropagation(),t.click(),Y(()=>Vt())},s=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),t.click(),Y(()=>Vt()))};r.addEventListener("mousedown",u),r.addEventListener("click",d),r.addEventListener("keydown",s),o.appendChild(r),qe.push(()=>{r.removeEventListener("mousedown",u),r.removeEventListener("click",d),r.removeEventListener("keydown",s),r.parentElement===o&&o.removeChild(r)})}}function Vt(e=!1){null==Ce&&(Ce=Y(()=>{Ce=null,Y(()=>{qt(),Ut(e)})}))}function Gt(e,t,n,l={}){const o=Ct(Math.min(t,n),!0===l.clearEstimatedFloor),i=St();if(e.style.minHeight=null!=i?`${Math.min(i,Math.ceil(n))}px`:"0px",e.style.height=`${o}px`,e.style.maxHeight=`${Math.ceil(n)}px`,Ge.value)e.style.overflow="hidden";else{const l=t>n+1;e.style.overflow=l?"auto":"hidden"}return o}function Jt(){var e,t;const n=null!=(t=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?t:500;if("number"==typeof n)return n;const o=String(n).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}const Xt=c(()=>l.isShowPreview&&("html"===_.value||"svg"===_.value));x(()=>l.node.language,e=>{_.value=R(e)}),x(()=>[l.node.originalCode,l.node.updatedCode,Ge.value],()=>{Bt(),Y(()=>Ht())},{immediate:!0}),x(()=>[l.node.originalCode,l.node.updatedCode,Q.value,Ge.value],e=>d(null,[e],function*([e,t,n,o]){if(!1===l.stream||!o)return;if(He&&!be.value&&v.value)try{yield dn(v.value)}catch(a){}const i=Ze(String(null!=e?e:""),String(null!=t?t:"")),r=!1===l.loading;if(r&&bn(),yield Fe(i.original,i.updated,Q.value),r){if(Se||!Ge.value)return;Ae(),qt(),Ht(),Vt()}ee.value&&Y(()=>jt())})),x(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(_.value||(_.value=R(Ie(e))),!Ge.value)){if(He&&!be.value&&v.value)try{yield dn(v.value)}catch(t){}Ne(e,Q.value),ee.value&&Y(()=>jt())}}));const Yt=c(()=>{const e=_.value;return e?I[e]||e.charAt(0).toUpperCase()+e.slice(1):I[""]||"Plain Text"});const Kt=c(()=>{var e;return function(e){const t=function(e){var t,n;const l=null!=(n=null==(t=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:t.trim())?n:"";if(l.length<3)return"";const o=l[0];if("`"!==o&&"~"!==o||l[1]!==o||l[2]!==o)return"";let i=3;for(;l[i]===o;)i+=1;return l.slice(i).trim()}(e);if(!t)return"";const n=t.split(/\s+/).filter(Boolean);if(!n.length)return"";const l="diff"===n[0]?n.slice(1):n;for(const o of l){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(String(null!=(e=l.node.raw)?e:""))}),Qt=c(()=>Kt.value||Yt.value),Zt=c(()=>Kt.value?Ge.value?`Diff / ${Yt.value}`:Yt.value:""),en=c(()=>(W.value,U(_.value||""))),tn=c(()=>{var e;const t={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},o=n(l.minWidth),i=n(l.maxWidth);return o&&(t.minWidth=o),i&&(t.maxWidth=i),bt.value&&(t.minHeight=`${null!=(e=yt.value)?e:ht.value}px`),Ge.value||(t.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))",t.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg))",t.borderColor="var(--markstream-code-border-color)"),t}),nn=c(()=>!1!==l.showTooltips);function ln(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(l.node.code)),b.value=!0,o("copy",l.node.code),setTimeout(()=>{b.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function on(e){if(ee.value=!ee.value,e&&nn.value){const t=function(e){const t=e.currentTarget||e.target;return!t||t.disabled?null:t}(e);if(t){const e=ee.value?s("common.collapse")||"Collapse":s("common.expand")||"Expand";J(t,e,"top",!1,void 0,l.isDark)}}const t=Ge.value?_e():Te(),n=v.value;t&&n&&(ee.value?(un(!0),n.style.maxHeight="none",n.style.overflow="visible",Ut(!0)):(un(!1),n.style.overflow=Ge.value?"hidden":"auto",Ut(!0)))}function rn(){var e,t,n;if(te.value=!te.value,te.value){if(v.value){const n=Math.ceil((null==(t=(e=v.value).getBoundingClientRect)?void 0:t.call(e).height)||0);n>0&&(xe.value=n)}un(!1)}else{ee.value&&un(!0),v.value&&null!=xe.value&&(v.value.style.height=`${xe.value}px`);const e=Ge.value?_e():Te();try{null==(n=null==e?void 0:e.layout)||n.call(e)}catch(l){}Me=2,Y(()=>{Ut(!0)})}}function an(){if(!Xt.value)return;const e=_.value;if(r.value){const t="html"===e?"text/html":"image/svg+xml",n="html"===e?s("artifacts.htmlPreviewTitle")||"HTML Preview":s("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:t,artifactTitle:n,id:`temp-${e}-${Date.now()}`})}"html"===e&&(ut.value=!ut.value)}function un(e){var t,n;try{if(Ge.value){const n=_e();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}else{const t=Te();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}}catch(l){}}function dn(e){if(!He||Se)return null;if(je)return je;if(be.value&&we.value)return Promise.resolve();be.value=!0;const t=d(null,null,function*(){yield function(e){return d(this,null,function*(){var t;if("undefined"==typeof window)return yield e();try{const n=null==(t=window.Element)?void 0:t.prototype,l=null==n?void 0:n.addEventListener;if(!n||!l)return yield e();const o=function(){const e=window,t=e[ge];if(t)return t;const n={depth:0,original:null};return e[ge]=n,n}();0===o.depth&&(o.original=l,n.addEventListener=function(e,t,n){var i;const r=null!=(i=o.original)?i:l;return"touchstart"===e&&function(e,t){if(!e)return!1;const n=e;return!("function"!=typeof n.closest||!n.closest(".monaco-editor, .monaco-diff-editor")||t&&"object"==typeof t&&"passive"in t)}(this,n)?r.call(this,e,t,function(e){return null==e?{passive:!0}:"boolean"==typeof e?{capture:e,passive:!0}:"object"==typeof e?"passive"in e?e:u(a({},e),{passive:!0}):{passive:!0}}(n)):r.call(this,e,t,n)}),o.depth++;try{return yield e()}finally{o.depth=Math.max(0,o.depth-1),0===o.depth&&o.original&&n.addEventListener!==o.original&&(n.addEventListener=o.original,o.original=null)}}catch(n){return yield e()}})}(()=>function(e){return d(this,null,function*(){var t,n,o;if(!He||Se)return;if(it.value=!1,ot.value=!1,function(){const e=ht.value;kt.value=we.value||null==e?null:e}(),It(),Wt(),function(e){e.replaceChildren()}(e),Se)return;if(Ge.value){$e();const o=Ze(String(null!=(t=l.node.originalCode)?t:""),String(null!=(n=l.node.updatedCode)?n:""));ze?yield ze(e,o.original,o.updated,Q.value):yield He(e,l.node.code,Q.value)}else yield He(e,l.node.code,Q.value);if(Se)return;const i=Ge.value?_e():Te();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),dt.value=l.monacoOptions.fontSize,st.value=l.monacoOptions.fontSize;else{const e=Pt();e&&e>0?(dt.value=e,st.value=e):(dt.value=12,st.value=12)}ee.value||te.value||Ut(!1),yield function(){return d(this,null,function*(){null!=St()&&(qt(),Ut(!1),yield O(),yield xt(),qt(),Ut(!1),yield xt(),qt(),Ut(!1))})}(),Se||(we.value=!0,function(){var e,t,n,l,o;if(It(),Ge.value){const l=_e(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),i=null==(t=null==l?void 0:l.getModifiedEditor)?void 0:t.call(l),a=(e,t)=>{try{const n=null==e?void 0:e[t];if("function"!=typeof n)return;const l=n.call(e,()=>Vt());l&&Ue.push(l)}catch(n){}};try{const e=null==(n=null==l?void 0:l.onDidUpdateDiff)?void 0:n.call(l,()=>{Vt(),Y(()=>Ht())});e&&Ue.push(e)}catch(r){}return a(o,"onDidContentSizeChange"),a(i,"onDidContentSizeChange"),a(o,"onDidLayoutChange"),void a(i,"onDidLayoutChange")}const i=Te();try{const e=null==(l=null==i?void 0:i.onDidContentSizeChange)?void 0:l.call(i,()=>Vt());e&&Ue.push(e)}catch(r){}try{const e=null==(o=null==i?void 0:i.onDidLayoutChange)?void 0:o.call(i,()=>Vt());e&&Ue.push(e)}catch(r){}}(),Rt(),qt(),Ht(),Vt(),yield function(){return d(this,null,function*(){qt(),Ut(!1),yield O(),yield xt(),qt(),Ut(!1),yield xt(),qt(),Ut(!1)})}(),Se||(ot.value=!0))})}(e))}).finally(()=>{je===t&&(je=null)});return je=t,t}x(nn,e=>{e||q()}),x(()=>st.value,(e,t)=>{const n=Ge.value?_e():Te();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(n.updateOptions({fontSize:e}),te.value||Ut(!0))},{flush:"post",immediate:!1});const sn=x(()=>[v.value,Ge.value,l.stream,l.loading,ke.value,Be.value],e=>d(null,[e],function*([e,t,n,l,o,i]){if(!e||!He)return;if(!i)return;if(!1===n&&!1!==l)return;const r=dn(e);if(r){try{yield r}catch(a){we.value=!1,ot.value=!1,it.value=!0}sn()}}));function cn(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function vn(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function fn(e,t){if(e===t)return!0;const n=vn(e),l=vn(t);return!!n&&n===l}function mn(){var e;const t=function(){if(void 0!==l.theme){const e=l.theme;return cn(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),n=null==(e=et.value)?void 0:e.theme,o=null!=t?t:n;if(null!=o&&"object"==typeof o)return o;const i=Array.isArray(l.themes)?l.themes:[];if(!i.length||null==o)return o;const r=vn(o),a=i.map(e=>vn(e)).filter(e=>!!e);if(!r||a.includes(r))return o;const u=vn(n);return null!=n&&u&&a.includes(u)?n:i[0]}x(tt,(e,t)=>d(null,null,function*(){if(e===t)return;if(nt.value=e,!He||!v.value)return;if(!be.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Be.value)return;const n=je;if(n){try{yield n}catch(o){}if(Se||!v.value)return}try{we.value=!1,ot.value=!1,be.value=!1,It(),Wt(),$e(),yield O(),yield dn(v.value)}catch(i){we.value=!1,ot.value=!1,it.value=!0}}));const pn=c(()=>(void 0!==l.theme?!cn(l.theme):fn(l.darkTheme,l.lightTheme))?function(e){var t,n;if(e&&"object"==typeof e&&(null==(t=e.colors)?void 0:t["editor.background"])){const t=_t(e.colors["editor.background"]);if(null!=t)return t<128}const o=(null!=(n=vn(e))?n:"").toLowerCase();return o?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):!!l.isDark}(mn()):!!l.isDark),hn=c(()=>{var e;if(!Ge.value)return pn.value?"dark":"light";const t=null==(e=et.value)?void 0:e.diffAppearance;return"light"===t||"dark"===t?t:pn.value?"dark":"light"}),yn=c(()=>Ge.value?"dark"===hn.value:pn.value);function gn(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:l.themes},et.value||{}),{theme:mn()}),Ge.value?{diffAppearance:hn.value}:{}),{onThemeChange(){Rt()}})}function bn(){const e=gn();if(!Ve)return Ve=e,Ve;for(const t of Object.keys(Ve))t in e||delete Ve[t];return Object.assign(Ve,e),Ve}const wn=c(()=>{var e,t,n,o,i,r,u,d,s,c,v,f,m,p,h;return JSON.stringify({diffLineStyle:null!=(t=null==(e=et.value)?void 0:e.diffLineStyle)?t:"background",diffUnchangedRegionStyle:null!=(o=null==(n=et.value)?void 0:n.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:void 0===(null==(i=l.monacoOptions)?void 0:i.diffHideUnchangedRegions)?a({},Ye):Qe(l.monacoOptions.diffHideUnchangedRegions),renderSideBySide:null==(u=null==(r=et.value)?void 0:r.renderSideBySide)||u,useInlineViewWhenSpaceIsLimited:null==(s=null==(d=et.value)?void 0:d.useInlineViewWhenSpaceIsLimited)||s,enableSplitViewResizing:null==(v=null==(c=et.value)?void 0:c.enableSplitViewResizing)||v,ignoreTrimWhitespace:null==(m=null==(f=et.value)?void 0:f.ignoreTrimWhitespace)||m,originalEditable:null!=(h=null==(p=et.value)?void 0:p.originalEditable)&&h})});return x(()=>[l.monacoOptions,Be.value],()=>{var e,t;if(bn(),!He||!Be.value)return;const n=Ge.value?_e():Te(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(st.value)?st.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(t=null==n?void 0:n.updateOptions)||t.call(n,{fontSize:o})),Ut(!1)},{deep:!0}),x(()=>[mn(),hn.value,ke.value,be.value,Be.value],([e],t)=>{ke.value&&be.value&&Be.value&&function(e={}){if(e.appearanceOnly)return;bn();const t=mn(),n=()=>{Ge.value&&Ae(),Y(()=>{Rt(),Vt()})};t?function(e,t){const n=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&"name"in e)return String(e.name);if("object"==typeof e){const n=de.get(e);if(n)return n;try{const t=JSON.stringify(e);if(t)return de.set(e,t),t}catch(t){}const l="__theme_"+ ++se;return de.set(e,l),l}return String(e)}(t);return n?(ue=e,le||ae!==n?le?(re===n||oe===n||(ie=t,re=n),le):(ie=t,re=n,le=d(null,null,function*(){for(;re&&null!=ie;){const n=ie,l=re;if(ie=null,re=null,ae!==l)try{oe=l,yield(null!=ue?ue:e)(n),ae=l}catch(t){}}}).finally(()=>{le=null,oe=null}),le):Promise.resolve()):Promise.resolve()}(We,t).then(n).catch(e=>{}):n()}({appearanceOnly:null!=t&&fn(e,t[0])})},{flush:"post"}),x(()=>[wn.value,ke.value,Be.value],(e,t)=>d(null,[e,t],function*([e,t,n],[o]){if(bn(),!t||!n)return;if(!He||!v.value)return;if(!be.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=je;if(i){try{yield i}catch(r){}if(Se||!v.value)return}try{we.value=!1,ot.value=!1,be.value=!1,It(),Wt(),$e(),yield O(),yield dn(v.value)}catch(a){we.value=!1,ot.value=!1,it.value=!0}}),{flush:"post"}),x(()=>[l.loading,Be.value],(e,t)=>d(null,[e,t],function*([e,t],n){if(!t)return;if(e)return;const o=null==n?void 0:n[0],i=void 0!==o&&!1!==o;yield O(),Y(()=>{d(null,null,function*(){var e;try{if(i&&be.value)if(Ge.value&&v.value){const e=je;if(e)try{yield e}catch(t){}if(bn(),we.value=!1,ot.value=!1,be.value=!1,It(),Wt(),$e(),yield O(),yield dn(v.value),Se||!Ge.value)return;Ae(),qt(),Ht()}else Ne(String(null!=(e=l.node.code)?e:""),Q.value);Ut(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{It(),Wt(),Re()}),(t,n)=>lt.value?(m(),p(k(V),{key:0,node:l.node,loading:l.loading},null,8,["node","loading"])):(m(),M("div",{key:1,ref_key:"container",ref:h,style:E(tn.value),class:g(["code-block-container rounded-lg border",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":yn.value,"is-diff":Ge.value,"is-plain-text":Z.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":ot.value&&!lt.value?"true":"false"},[L(G,{"show-header":l.showHeader,"show-collapse-button":l.showCollapseButton,"show-font-size-buttons":l.showFontSizeButtons,"enable-font-size-control":l.enableFontSizeControl,"show-copy-button":l.showCopyButton,"show-expand-button":l.showExpandButton,"show-preview-button":l.showPreviewButton,"show-tooltips":l.showTooltips,"is-dark":l.isDark,loading:l.loading,stream:e.stream,"is-collapsed":te.value,"is-expanded":ee.value,"copy-text":b.value,"is-previewable":Xt.value,"code-font-size":st.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":dt.value,"font-baseline-ready":ct.value,"diff-stats":Ge.value?Je.value:null,"diff-stats-aria-label":Xe.value,onToggleCollapse:rn,onDecreaseFont:Ft,onResetFont:Dt,onIncreaseFont:Nt,onCopy:ln,onToggleExpand:on,onPreview:an},B({"header-left":H(()=>[D(t.$slots,"header-left",{},()=>[y("div",ve,[y("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:en.value},null,8,fe),y("div",me,[y("div",pe,w(Qt.value),1),Zt.value?(m(),M("div",he,w(Zt.value),1)):N("",!0)])])],!0)]),loading:H(()=>[D(t.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[n[0]||(n[0]=y("div",{class:"loading-skeleton"},[y("div",{class:"skeleton-line"}),y("div",{class:"skeleton-line"}),y("div",{class:"skeleton-line short"})],-1))],!0)]),default:H(()=>[z(y("div",ye,[y("div",{ref_key:"codeEditor",ref:v,class:g(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":at.value}]]),style:E(wt.value)},null,6),at.value?(m(),p(k(V),{key:0,class:g(["code-pre-fallback",{"is-wrap":rt.value}]),style:E(gt.value),node:l.node},null,8,["class","style","node"])):N("",!0)],512),[[F,!(te.value||!e.stream&&e.loading)]]),ut.value&&!r.value&&Xt.value&&"html"===_.value?(m(),p(ne,{key:0,code:l.node.code,"html-preview-allow-scripts":l.htmlPreviewAllowScripts,"html-preview-sandbox":l.htmlPreviewSandbox,"is-dark":l.isDark,"on-close":()=>ut.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):N("",!0)]),_:2},[t.$slots["header-right"]?{name:"header-right",fn:H(()=>[D(t.$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,ce))}}),[["__scopeId","data-v-c1313629"]]);export{be as default};
1
+ var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(t,n,l)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[n]=l,a=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&r(e,n,t[n]);if(l)for(var n of l(t))i.call(t,n)&&r(e,n,t[n]);return e},u=(e,l)=>t(e,n(l)),d=(e,t,n)=>new Promise((l,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},r=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);a((n=n.apply(e,t)).next())});import{defineComponent as s,computed as c,onMounted as v,onUnmounted as f,openBlock as m,createBlock as p,Teleport as h,createElementVNode as y,normalizeClass as g,withModifiers as w,toDisplayString as b,unref as S,useAttrs as k,inject as x,getCurrentInstance as C,ref as M,watch as P,onBeforeUnmount as B,nextTick as E,createElementBlock as O,normalizeStyle as L,createVNode as F,createSlots as H,withCtx as N,withDirectives as z,createCommentVNode as $,vShow as R,renderSlot as _}from"vue";import{u as D,_ as T,r as A,b as W,h as j,z as I,s as q}from"./exports.js";import{M as U,n as V,e as G,c as J,l as X,g as Y,i as K}from"./index2.js";import{safeRaf as Q,safeCancelRaf as Z}from"./utils/safeRaf.js";import{_ as ee}from"./CodeBlockShell.vue_vue_type_style_index_0_lang.js";import{getUseMonaco as te}from"./monaco.js";const ne={class:"html-preview-frame__header"},le={class:"html-preview-frame__title"},oe={class:"html-preview-frame__label"},ie=["sandbox","srcdoc"],re=/* @__PURE__ */T(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const t=e,n=void 0!==import.meta&&Boolean(!1);let l=null;const{t:o}=D(),i=c(()=>{const e=t.code||"",n=e.trim().toLowerCase();return n.startsWith("<!doctype")||n.startsWith("<html")||n.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: ${t.isDark?"#020617":"#ffffff"};\n color: ${t.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=c(()=>{return e=t.htmlPreviewSandbox,o=t.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!n||"undefined"==typeof console||l===e)return;const t=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);t.has("allow-scripts")&&t.has("allow-same-origin")&&(l=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 a(e){var n;"Escape"!==e.key&&"Esc"!==e.key||null==(n=t.onClose)||n.call(t)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",a)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",a)}),(e,n)=>(m(),p(h,{to:"body"},[y("div",{class:g(["markstream-vue",{dark:t.isDark}])},[y("div",{class:"html-preview-frame__backdrop",onClick:n[2]||(n[2]=e=>{var n;return null==(n=t.onClose)?void 0:n.call(t)})},[y("div",{class:"html-preview-frame",onClick:n[1]||(n[1]=w(()=>{},["stop"]))},[y("div",ne,[y("div",le,[n[3]||(n[3]=y("span",{class:"html-preview-frame__dot"},null,-1)),y("span",oe,b(t.title||S(o)("common.preview")||"Preview"),1)]),y("button",{type:"button",class:"html-preview-frame__close",onClick:n[0]||(n[0]=e=>{var n;return null==(n=t.onClose)?void 0:n.call(t)})}," × ")]),y("iframe",{class:"html-preview-frame__iframe",sandbox:r.value,referrerpolicy:"no-referrer",srcdoc:i.value},null,8,ie)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]);let ae=null,ue=null,de=null,se=null,ce=null,ve=null;const fe=/* @__PURE__ */new WeakMap;let me=0;const pe=["data-markstream-enhanced"],he={class:"code-header-main"},ye=["innerHTML"],ge={class:"code-header-copy"},we={class:"code-header-title"},be={key:0,class:"code-header-caption"},Se={class:"code-editor-layer"},ke="__markstreamMonacoPassiveTouchState__",xe=1.5,Ce=/* @__PURE__ */T(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:t}){var n;const l=e,o=t,i=k(),r=x(U,null),s=x("markstreamHostScrollManaged",null),v=c(()=>A(l,i));const h=C(),w=c(()=>{const e=null==h?void 0:h.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:T}=D(),ne=M(null),le=M(null),oe=M(!1),ie=M(V(l.node.language)),Ce=c(()=>G(ie.value)),Me=c(()=>"plaintext"===Ce.value),Pe=M(!1),Be=M(!1),Ee=M(!1),Oe=M(!1),Le=M(!1);let Fe=!1,He=null,Ne="";const ze=M(null),$e=M(null);let Re=0,_e=0;const De=W(),Te=M(null),Ae=M("undefined"==typeof window);"undefined"!=typeof window&&P(()=>le.value,e=>{var t;if(null==(t=Te.value)||t.destroy(),Te.value=null,!e)return void(Ae.value=!1);const n=De(e,{rootMargin:"400px"});Te.value=n,Ae.value=n.isVisible.value,n.whenVisible.then(()=>{Ae.value=!0})},{immediate:!0}),B(()=>{var e;Fe=!0,function(){const e=Ne;r&&e&&(Ne="",r.markSettled(e))}(),null==(e=Te.value)||e.destroy(),Te.value=null});let We=null,je=null,Ie=()=>{},qe=()=>{},Ue=()=>null,Ve=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Ge=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Je=()=>{},Xe=()=>{},Ye=()=>{},Ke=null,Qe=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},Ze=()=>d(null,null,function*(){}),et=!1;const tt=[],nt=[];let lt=null;function ot(e){var t;return"diff"===(null!=(t=String(null!=e?e:"").trim().split(/\s+/,1)[0])?t:"")}const it=c(()=>{var e;return!0===l.node.diff||ot(l.node.language)||ot(Yn(String(null!=(e=l.node.raw)?e:"")))}),rt=M({removed:0,added:0}),at=c(()=>`-${rt.value.removed} +${rt.value.added}`),ut=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5}),dt=Object.freeze(u(a({},ut),{enabled:!1,revealLineCount:0}));function st(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return u(a(a({},ut),n),{enabled:null==(t=n.enabled)||t})}return a({},ut)}function ct(e,t){return{original:String(null!=e?e:""),updated:String(null!=t?t:"")}}function vt(e){var t;return String(null!=(t=null==e?void 0:e.message)?t:e).includes("no diff result available")}function ft(){try{const e=Ye();e&&"function"==typeof e.catch&&e.catch(e=>{vt(e)})}catch(e){vt(e)}}const mt=c(()=>{var e,t,n,o;const i=l.monacoOptions?a({},l.monacoOptions):{};if(!it.value)return i;const r=void 0===i.diffHideUnchangedRegions?a({},ut):st(i.diffHideUnchangedRegions),d=void 0===i.hideUnchangedRegions?void 0:st(i.hideUnchangedRegions),s=!1!==l.stream&&!1!==l.loading,c=s?a({},dt):r,v=s?a({},dt):d,f=a({},null!=(e=i.experimental)?e:{}),m=null!=(t=i.diffUnchangedRegionStyle)?t:"line-info",p={maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,minimap:{enabled:!1},renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,renderSideBySide:null==(n=i.renderSideBySide)||n,diffHideUnchangedRegions:c,useInlineViewWhenSpaceIsLimited:null!=(o=i.useInlineViewWhenSpaceIsLimited)&&o,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:m,diffHunkActionsOnHover:!1,experimental:f};return u(a(u(a(a({},p),i),{experimental:f}),void 0===v?{}:{hideUnchangedRegions:v}),{diffHideUnchangedRegions:c})}),pt=c(()=>it.value?"diff":"single"),ht=M(pt.value),yt=M(!1),gt=M(!1),wt=M(!1),bt=M(!1),St=M(!1);let kt=null;const xt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.wordWrap;return null==t||"off"!==String(t)}),Ct=c(()=>{var e,t,n,l,o,i;if(!it.value)return!1;if(!1===(null==(e=mt.value)?void 0:e.renderSideBySide))return!0;if(!0!==(null==(t=mt.value)?void 0:t.useInlineViewWhenSpaceIsLimited))return!1;const r=null==(n=mt.value)?void 0:n.renderSideBySideInlineBreakpoint,a="number"==typeof r&&Number.isFinite(r)?r:900,u=(null==(o=null==(l=le.value)?void 0:l.getBoundingClientRect)?void 0:o.call(l).width)||(null==(i=le.value)?void 0:i.clientWidth)||("undefined"==typeof window?0:window.innerWidth);return u>0&&u<=a});function Mt(e){return!0===(null==s?void 0:s.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 Pt=c(()=>Mt(le.value)),Bt=c(()=>!yt.value&&(!!wt.value||(it.value||Pt.value||!K())&&!gt.value)),Et=c(()=>Bt.value||bt.value),Ot=c(()=>Bt.value&&!bt.value),Lt=M(!1),Ft=c(()=>it.value&&!0!==l.node.diff?u(a({},l.node),{diff:!0}):l.node);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield te();if(Fe)return;if(!e)return void(yt.value=!0);const t=e.useMonaco,n=e.detectLanguage;if("function"==typeof n&&(Qe=n),"function"==typeof t){const e=fl();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");lt=yl();const n=t(lt);We=n.createEditor||We,je=n.createDiffEditor||je,Ie=n.updateCode||Ie,qe=n.updateDiff||qe,Ue=n.getEditor||Ue,Ve=n.getEditorView||Ve,Ge=n.getDiffEditorView||Ge,Je=n.cleanupEditor||Je,Xe=n.safeClean||n.cleanupEditor||Xe,Ye=n.refreshDiffPresentation||Ye,Ze=n.setTheme||Ze,Le.value=!0,!Fe&&ne.value&&(yield ul(ne.value))}}catch(e){if(Fe)return;yt.value=!0}});const Ht=M("number"==typeof(null==(n=l.monacoOptions)?void 0:n.fontSize)?l.monacoOptions.fontSize:Number.NaN),Nt=M(Ht.value),zt=M(null),$t=M(null),Rt=c(()=>{const e=Ht.value,t=Nt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof t&&Number.isFinite(t)&&t>0}),_t=c(()=>{var e;const t=zt.value;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const n=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const o=Nt.value;return"number"==typeof o&&Number.isFinite(o)&&o>0?o:12}),Dt=c(()=>{var e;const t=$t.value;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const n=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:12===_t.value?18:Math.max(12,Math.round(1.5*_t.value))}),Tt=c(()=>Dt.value);function At(e){const t=String(null!=e?e:"");return t?Math.max(1,t.split(/\r\n|\n|\r/).length):1}function Wt(e){return e.startsWith("-")&&!e.startsWith("---")}function jt(e){return e.startsWith("+")&&!e.startsWith("+++")}const It=c(()=>Ct.value?function(){var e,t,n;const o=String(null!=(e=l.node.code)?e:"").split(/\r\n|\n|\r/);if(o.some(e=>Wt(e)||jt(e)))return Math.max(1,o.length);const i=String(null!=(t=l.node.originalCode)?t:"").split(/\r\n|\n|\r/),r=String(null!=(n=l.node.updatedCode)?n:"").split(/\r\n|\n|\r/);let a=0,u=i.length-1,d=r.length-1;for(;a<=u&&a<=d&&i[a]===r[a];)a++;let s=0;for(;u>=a&&d>=a&&i[u]===r[d];)s++,u--,d--;const c=Math.max(0,u-a+1),v=Math.max(0,d-a+1);return Math.max(1,a+c+v+s)}():function(){var e;const t=String(null!=(e=l.node.code)?e:"").split(/\r\n|\n|\r/);if(!t.some(e=>Wt(e)||jt(e))&&(null!=l.node.originalCode||null!=l.node.updatedCode))return Math.max(At(l.node.originalCode),At(l.node.updatedCode));let n=0,o=0;for(const l of t)Wt(l)?n++:(jt(l)||n++,o++);return Math.max(1,n,o)}()),qt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:4}),Ut=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.padding;return{top:"number"==typeof(null==t?void 0:t.top)&&Number.isFinite(t.top)&&t.top>0?t.top:0,bottom:"number"==typeof(null==t?void 0:t.bottom)&&Number.isFinite(t.bottom)&&t.bottom>0?t.bottom:0}}),Vt=c(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Gt(e){if(null==e)return null;const t=Math.ceil(e);return!Number.isFinite(t)||t<=0?null:Math.min(t,Math.ceil(Gn()))}const Jt=c(()=>it.value?Math.ceil(It.value*Tt.value):null!=Vt.value?null:Math.ceil((e=>{const t=String(null!=e?e:"");return t?Math.max(1,t.split(/\r\n|\n|\r/).length):1})(l.node.code)*(Dt.value+xe)+1)),Xt=c(()=>{if(it.value){const e=Jt.value,t=tn();return Gt(null!=t&&null!=e?Math.max(e,t):null!=t?t:e)}const e=Vt.value;return Gt(null!=e?e:Jt.value)}),Yt=c(()=>{const e=l.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),Kt=M(null),Qt=M(null);function Zt(){const e=Kt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function en(){return it.value&&!1!==l.stream&&(!1!==l.loading||Bt.value||bt.value||St.value)}function tn(){if(!en())return null;const e=Qt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function nn(e){if(!en()||null==e)return;const t=Math.min(Math.ceil(e),Math.ceil(Gn()));if(!Number.isFinite(t)||t<=0)return;const n=tn();Qt.value=null==n?t:Math.max(n,t)}const ln=c(()=>{const e=Zt();return null!=e?e:Bt.value||!gt.value?Xt.value:null}),on=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.fontFamily,n=Gt(Vt.value),o=Gt(Jt.value),i=a(a({fontSize:`${_t.value}px`,lineHeight:`${Tt.value}px`,tabSize:qt.value,boxSizing:"border-box",maxHeight:`${Gn()}px`,overflow:"auto",paddingTop:`${Ut.value.top}px`,paddingBottom:`${Ut.value.bottom}px`},it.value?function(e){if(null==e)return{};const t=Math.ceil(e),n=Math.ceil(Gn()),l=Math.min(t,n);return t>=n?{height:`${l}px`,minHeight:`${l}px`}:{minHeight:`${t}px`}}(Xt.value):null!=n?{height:`${n}px`,minHeight:`${n}px`}:null!=o?{minHeight:`${o}px`}:{}),"string"==typeof t&&t.trim()?{"--markstream-code-font-family":t.trim()}:{});return i["--markstream-pre-line-number-top"]=`${Ut.value.top}px`,i["--markstream-code-padding-left"]="62px",i["--markstream-pre-line-number-width"]="36px",i["--markstream-pre-line-number-gap"]="0px",it.value&&(i["--markstream-pre-diff-line-height"]=`${Tt.value}px`),i}),rn=c(()=>null!=ln.value&&(!gt.value||null!=Zt())),an=c(()=>{const e=ln.value;if(null==e)return null;if(it.value)return Math.ceil(e);const t=Yt.value,n=Vt.value;if(null==t||null==n)return Math.ceil(e);const l=Math.max(0,Math.ceil(t)-Math.ceil(n));return Math.ceil(e+l)}),un=c(()=>{if(it.value&&Bt.value)return;const e=ln.value;return rn.value&&null!=e?{minHeight:`${e}px`}:void 0});function dn(){null!=kt&&"undefined"!=typeof window&&window.clearTimeout(kt),kt=null}function sn(){if(!it.value)return!1;if(!Oe.value||!gt.value)return!1;if(bt.value||St.value)return!1;const e=ne.value;return!!e&&Pn(e)}function cn(e,t=!1,n={}){const l=Math.ceil(e),o=Zt();if(null==o)return l;const i=!0===n.allowBelowEstimatedFloor||sn();return l>=o||i?((t||i)&&Oe.value&&(Kt.value=null),l):o}function vn(){return new Promise(e=>{Q(()=>e())})}function fn(){try{const e=ne.value;if(!e)return null;const t=e.querySelector(".view-lines .view-line");if(t){const e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch(e){}return null}function mn(){var e,t,n,l,o;try{const i=it.value?null!=(n=null==(t=null==(e=Ge())?void 0:e.getModifiedEditor)?void 0:t.call(e))?n:Ge():Ve(),r=Ue(),a=null==(l=null==r?void 0:r.EditorOption)?void 0:l.fontInfo;if(i&&null!=a){const e=null==(o=i.getOption)?void 0:o.call(i,a),t=null==e?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t}}catch(i){}try{const e=ne.value;if(e){const t=e.querySelector(".view-lines .view-line");if(t)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(t).fontSize,n=e&&e.match(/^(\d+(?:\.\d+)?)/);if(n)return Number.parseFloat(n[1])}}catch(i){}}}catch(i){}return null}function pn(e){var t,n;try{const l=Ue(),o=null==(t=null==l?void 0:l.EditorOption)?void 0:t.lineHeight;if(null!=o){const t=null==(n=null==e?void 0:e.getOption)?void 0:n.call(e,o);if("number"==typeof t&&t>0)return t}}catch(i){}const l=fn();if(l&&l>0)return l;const o=Number.isFinite(Nt.value)&&Nt.value>0?Nt.value:14;return Math.max(12,Math.round(1.35*o))}function hn(e){var t,n,l;try{const l=Ue(),o=null==(t=null==l?void 0:l.EditorOption)?void 0:t.padding;if(null!=o){const t=null==(n=null==e?void 0:e.getOption)?void 0:n.call(e,o),l="number"==typeof(null==t?void 0:t.top)?t.top:0,i="number"==typeof(null==t?void 0:t.bottom)?t.bottom:0;if(l>0||i>0)return l+i}}catch(a){}const o=null==(l=mt.value)?void 0:l.padding,i="number"==typeof(null==o?void 0:o.top)?o.top:0,r="number"==typeof(null==o?void 0:o.bottom)?o.bottom:0;return i>0||r>0?i+r:it.value?24:0}function yn(e,t){return"number"!=typeof e||"number"!=typeof t||e<1||t<e?0:t-e+1}function gn(e){if(!e)return[];const t=e.split(/\r?\n/);return 1===t.length&&""===t[0]?[]:t}function wn(){var e,t;it.value?rt.value=function(e,t){const n=gn(e),l=gn(t);let o=0,i=n.length-1,r=l.length-1;for(;o<=i&&o<=r&&n[o]===l[o];)o++;for(;i>=o&&r>=o&&n[i]===l[r];)i--,r--;return{removed:Math.max(0,i-o+1),added:Math.max(0,r-o+1)}}(String(null!=(e=l.node.originalCode)?e:""),String(null!=(t=l.node.updatedCode)?t:"")):rt.value={removed:0,added:0}}function bn(){var e;if(it.value)try{const t=Ge(),n=null==(e=null==t?void 0:t.getLineChanges)?void 0:e.call(t);if(!Array.isArray(n))return void wn();let l=0,o=0;for(const e of n)l+=yn(e.originalStartLineNumber,e.originalEndLineNumber),o+=yn(e.modifiedStartLineNumber,e.modifiedEndLineNumber);rt.value={removed:l,added:o}}catch(t){wn()}else rt.value={removed:0,added:0}}function Sn(){var e;if(Number.isFinite(Nt.value)&&Nt.value>0&&Number.isFinite(Ht.value))return Nt.value;const t=mn();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(Ht.value=l.monacoOptions.fontSize,Nt.value=l.monacoOptions.fontSize,Nt.value):t&&t>0?(Ht.value=t,Nt.value=t,t):(Ht.value=12,Nt.value=12,12)}function kn(){const e=Sn(),t=Math.min(36,e+1);Nt.value=t}function xn(){const e=Sn(),t=Math.max(10,e-1);Nt.value=t}function Cn(){Sn(),Number.isFinite(Ht.value)&&(Nt.value=Ht.value)}function Mn(){var e,t,n,l,o,i,r,a,u,d,s,c,v,f;try{const m=it.value?Ge():null,p=it.value?m:Ve();if(!p)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const v=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(t=m.getModifiedEditor)?void 0:t.call(m);null==(n=null==v?void 0:v.layout)||n.call(v),null==(l=null==f?void 0:f.layout)||l.call(f);const p=(null==(o=null==v?void 0:v.getContentHeight)?void 0:o.call(v))||0,h=(null==(i=null==f?void 0:f.getContentHeight)?void 0:i.call(f))||0,y=Math.max(p,h);if(y>0)return Math.ceil(y+1);const g=(null==(u=null==(a=null==(r=null==v?void 0:v.getModel)?void 0:r.call(v))?void 0:a.getLineCount)?void 0:u.call(a))||1,w=(null==(c=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:c.call(s))||1,b=Math.max(g,w),S=Math.max(pn(v),pn(f));return Math.ceil(b*(S+xe)+0+1)}if(null==p?void 0:p.getContentHeight){null==(v=null==p?void 0:p.layout)||v.call(p);const e=p.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==p?void 0:p.getModel)?void 0:f.call(p);let y=1;h&&"function"==typeof h.getLineCount&&(y=h.getLineCount());const g=pn(p);return Math.ceil(y*(g+xe)+0+1)}catch(m){return null}}function Pn(e){if("undefined"==typeof window)return!1;const t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return!1;const n=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const l of Array.from(n)){if(!(l instanceof HTMLElement))continue;const e=window.getComputedStyle(l);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const n=l.getBoundingClientRect();if(!(n.width<=0||n.height<=0||n.bottom<=t.top||n.top>=t.bottom))return!0}return!1}function Bn(e){var t;const n=String(null!=e?e:"").trim(),l=null==(t=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:t[1];if(l){const e=3===l.length?l.split("").map(e=>`${e}${e}`).join(""):l;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=n.match(/\d+(?:\.\d+)?/g);if(!o||o.length<3)return null;const[i,r,a]=o.slice(0,3).map(Number);return.2126*i+.7152*r+.0722*a}function En(){var e;const t=null==(e=ne.value)?void 0:e.parentElement;return t instanceof HTMLElement?t:null}function On(e,t){var n;null==t||!Number.isFinite(t)||t<=0||null==(n=En())||n.style.setProperty(e,`${t}px`)}function Ln(){var e,t,n;if(Fn())return;const l=mn();l&&l>0&&(zt.value=l,Nt.value=l,Ht.value=l);try{const l=pn(it.value?null!=(n=null==(t=null==(e=Ge())?void 0:e.getModifiedEditor)?void 0:t.call(e))?n:Ge():Ve());l&&l>0&&($t.value=l)}catch(o){}try{const e=fn();e&&e>0&&($t.value=e)}catch(o){}}function Fn(){return it.value&&Et.value}function Hn(){var e,t,n,l,o,i,r,a;const u=ne.value,d=le.value;if(!u||!d)return;const s=u,c=u.querySelector(".monaco-editor")||u,v=c.querySelector(".monaco-editor-background")||c,f=c.querySelector(".view-lines")||c;let m=null,p=null,h=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(m=window.getComputedStyle(c),p=v===c?m:window.getComputedStyle(v),h=f===c?m:window.getComputedStyle(f))}catch(k){m=null,p=null,h=null}const y=String(null!=(e=null==m?void 0:m.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),g=String(null!=(t=null==m?void 0:m.getPropertyValue("--vscode-editor-background"))?t:"").trim(),w=String(null!=(l=null!=(n=null==m?void 0:m.getPropertyValue("--vscode-editor-selectionBackground"))?n:null==m?void 0:m.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),b=y||String(null!=(i=null!=(o=null==h?void 0:h.color)?o:null==m?void 0:m.color)?i:"").trim(),S=g||String(null!=(a=null!=(r=null==p?void 0:p.backgroundColor)?r:null==m?void 0:m.backgroundColor)?a:"").trim();return it.value?(b?(d.style.setProperty("--markstream-diff-editor-fg",b),s.style.setProperty("--vscode-editor-foreground",b),s.style.setProperty("--stream-monaco-editor-fg",b)):(d.style.removeProperty("--markstream-diff-editor-fg"),s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--stream-monaco-editor-fg")),S?(d.style.setProperty("--markstream-diff-editor-bg",S),d.style.setProperty("--markstream-diff-panel-bg",S),d.style.setProperty("--markstream-diff-panel-bg-soft",S),d.style.setProperty("--markstream-diff-panel-bg-strong",S),s.style.setProperty("--vscode-editor-background",S),s.style.setProperty("--stream-monaco-editor-bg",S),s.style.setProperty("--stream-monaco-fixed-editor-bg",S),s.style.setProperty("--stream-monaco-panel-bg",S),s.style.setProperty("--stream-monaco-panel-bg-soft",S),s.style.setProperty("--stream-monaco-panel-bg-strong",S),s.style.backgroundColor=S):(d.style.removeProperty("--markstream-diff-editor-bg"),d.style.removeProperty("--markstream-diff-panel-bg"),d.style.removeProperty("--markstream-diff-panel-bg-soft"),d.style.removeProperty("--markstream-diff-panel-bg-strong"),s.style.removeProperty("--vscode-editor-background"),s.style.removeProperty("--stream-monaco-editor-bg"),s.style.removeProperty("--stream-monaco-fixed-editor-bg"),s.style.removeProperty("--stream-monaco-panel-bg"),s.style.removeProperty("--stream-monaco-panel-bg-soft"),s.style.removeProperty("--stream-monaco-panel-bg-strong"),s.style.backgroundColor=""),void(w?s.style.setProperty("--vscode-editor-selectionBackground",w):s.style.removeProperty("--vscode-editor-selectionBackground"))):function(e,t,n){if(!Me.value)return!1;const l=Bn(e),o=Bn(t);return n?null!=l&&l>170||null!=o&&o<110:null!=l&&l<85||null!=o&&o>190}(S,b,d.classList.contains("is-dark"))?(s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--vscode-editor-background"),void s.style.removeProperty("--vscode-editor-selectionBackground")):(b&&s.style.setProperty("--vscode-editor-foreground",b),S&&s.style.setProperty("--vscode-editor-background",S),void(w&&s.style.setProperty("--vscode-editor-selectionBackground",w)))}let Nn=0,zn=0;const $n=/auto|scroll|overlay/i;function Rn(e,t,n){var l;if("undefined"==typeof window)return;if(it.value)return;if(function(e){return Pt.value||Mt(e)}(e))return;const o=Math.ceil(t),i=Math.ceil(n)-o;if(Math.abs(i)<=1)return;const r=function(e){var t,n;if("undefined"==typeof window)return null;const l=null!=(t=null==e?void 0:e.ownerDocument)?t:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(n=null==e?void 0:e.parentElement)?n:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),t=(e.overflowY||"").toLowerCase(),n=(e.overflow||"").toLowerCase();if($n.test(t)||$n.test(n))return i;i=i.parentElement}return o}(e);if(!r)return;const a=null!=(l=e.ownerDocument)?l:document,u=r===a.body||r===a.documentElement||r===a.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,i):r.scrollTop+=i)}function _n(){try{const e=ne.value;if(!e)return;const t=e.getBoundingClientRect().height,n=Mn();if(null!=n&&n>0){const l=cn(n,!0),o=Zt();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",void Rn(e,t,l)}const l=Zt();null!=l&&(e.style.minHeight=`${l}px`,e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",Rn(e,t,l))}catch(e){}}function Dn(){for(var e,t;tt.length>0;)try{null==(t=null==(e=tt.pop())?void 0:e.dispose)||t.call(e)}catch(n){}null!=He&&(Z(He),He=null)}function Tn(){for(var e;nt.length>0;)try{null==(e=nt.pop())||e()}catch(t){}}function An(e=!1){Be.value||(Pe.value?_n():function(){var e;try{const t=ne.value;if(!t)return;const n=t.getBoundingClientRect().height,l=Gn(),o=Math.ceil((null==(e=t.getBoundingClientRect)?void 0:e.call(t).height)||0),i=it.value?function(){var e,t,n,l,o,i,r,a;try{const u=Ge(),d=null==(e=null==u?void 0:u.getOriginalEditor)?void 0:e.call(u),s=null==(t=null==u?void 0:u.getModifiedEditor)?void 0:t.call(u);if(!d||!s)return null;const c=(null==(o=null==(l=null==(n=d.getModel)?void 0:n.call(d))?void 0:l.getLineCount)?void 0:o.call(l))||1,v=(null==(a=null==(r=null==(i=s.getModel)?void 0:i.call(s))?void 0:r.getLineCount)?void 0:a.call(r))||1,f=Math.max(c,v),m=Math.max(pn(d),pn(s)),p=Math.max(hn(d),hn(s));return Math.ceil(f*(m+xe)+p+0+1)}catch(u){return null}}():null,r=it.value&&Pn(t),a=r&&Oe.value&&gt.value&&!bt.value&&!St.value;if(r||($e.value=null),_e>0&&(_e--,null!=ze.value))return void Rn(t,n,Un(t,ze.value,l,{allowBelowEstimatedFloor:a}));const u=it.value?function(e){var t,n;if("undefined"==typeof window)return null;try{const l=e.getBoundingClientRect(),o=window.getComputedStyle(e);if("none"===o.display||"hidden"===o.visibility)return null;const i=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let r=0;for(const t of Array.from(e.querySelectorAll(i.join(",")))){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const n=t.getBoundingClientRect();n.height<=0||n.bottom<=l.top||(r=Math.max(r,n.bottom-l.top))}if(r>0)return Math.ceil(r);const a=e.querySelector(".monaco-diff-editor"),u=null!=(n=null==(t=null==a?void 0:a.getBoundingClientRect)?void 0:t.call(a).height)?n:0;return u>0?Math.ceil(u+1):null}catch(l){return null}}(t):null,d=it.value?r?u:null!=i?Math.max(null!=u?u:0,i):u:Mn();if(null!=d&&d>0){const e=null!=$e.value&&Date.now()<Re&&d>=l-1,i=r&&o>0&&o<l-1&&d>=l-1,u=Un(t,e?$e.value:i?o:d,l,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:a});return r&&u<l-1&&($e.value=u,Re=Date.now()+160),void Rn(t,n,u)}if(null!=ze.value)return void Rn(t,n,Un(t,ze.value,l,{allowBelowEstimatedFloor:a}));const s=r?o:Math.max(o,null!=i&&i>0?i:0);if(s>0){const e=null!=$e.value&&Date.now()<Re&&s>=l-1,i=r&&o>0&&o<l-1&&s>=l-1,u=Un(t,e?$e.value:i?o:s,l,{allowBelowEstimatedFloor:a});return r&&u<l-1&&($e.value=u,Re=Date.now()+160),void Rn(t,n,u)}const c=Zt();if(null!=c)return void Rn(t,n,Un(t,c,l,{allowBelowEstimatedFloor:a}));const v=Number.parseFloat(t.style.height);!Number.isNaN(v)&&v>0?Rn(t,n,Un(t,v,l,{allowBelowEstimatedFloor:a})):it.value||Rn(t,n,Un(t,l,l))}catch(t){}}())}function Wn(){Nn=0,zn=0}function jn(e=!1){var t,n,l;const o=ne.value;if(!o)return;const i=it.value?Ge():Ve();if(i&&"function"==typeof i.layout)try{const r=null==(t=o.getBoundingClientRect)?void 0:t.call(o),a=Math.ceil((null!=(n=null==r?void 0:r.width)?n:0)||o.clientWidth||0),u=Math.ceil((null!=(l=null==r?void 0:r.height)?l:0)||o.clientHeight||Number.parseFloat(o.style.height||"")||0);if(a>0&&u>0){if(!e&&a===Nn&&u===zn)return;Nn=a,zn=u,i.layout({width:a,height:u})}else Wn(),i.layout()}catch(r){}}function In(){if(!it.value)return void Tn();const e=ne.value;if(!e)return void Tn();const t=e.querySelector(".monaco-diff-editor");if(!t||t.classList.contains("side-by-side"))return void Tn();const n=Array.from(t.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(t.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(n.length,l.length);for(let i=0;i<o;i++){const e=l[i],t=e.querySelector("a"),n=e.querySelector(".center > div:first-child"),o=e.querySelector(".center");if(!t||!n||!o)continue;if(o.querySelector(".markstream-inline-fold-proxy"))continue;const r=document.createElement("button");r.type="button",r.className="markstream-inline-fold-proxy",r.dataset.markstreamInlineFoldProxy="true";const a=t.getAttribute("title")||"Show Unchanged Region";r.title=a,r.setAttribute("aria-label",a);const u=e=>{e.preventDefault(),e.stopPropagation()},d=e=>{e.preventDefault(),e.stopPropagation(),t.click(),Q(()=>qn())},s=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),t.click(),Q(()=>qn()))};r.addEventListener("mousedown",u),r.addEventListener("click",d),r.addEventListener("keydown",s),o.appendChild(r),nt.push(()=>{r.removeEventListener("mousedown",u),r.removeEventListener("click",d),r.removeEventListener("keydown",s),r.parentElement===o&&o.removeChild(r)})}}function qn(e=!1){null==He&&(He=Q(()=>{He=null,Q(()=>{In(),An(e),jn()})}))}function Un(e,t,n,l={}){nn(t);const o=tn(),i=null!=o?Math.max(t,o):t,r=Math.min(i,n),a=!0===l.allowBelowEstimatedFloor||sn(),u=cn(r,!0===l.clearEstimatedFloor,{allowBelowEstimatedFloor:a}),d=Zt();if(e.style.minHeight=null==d||a?"0px":`${Math.min(d,Math.ceil(n))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(n)}px`,it.value)e.style.overflow="hidden";else{const t=i>n+1;e.style.overflow=t?"auto":"hidden"}return u}function Vn(e,t,n){return d(this,null,function*(){try{return void(yield qe(e,t,n))}catch(l){if(!vt(l))throw l}if(yield E(),yield vn(),!Fe&&it.value)try{yield qe(e,t,n)}catch(l){if(!vt(l))throw l}})}function Gn(){var e,t;const n=null!=(t=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?t:500;if("number"==typeof n)return n;const o=String(n).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}const Jn=c(()=>l.isShowPreview&&("html"===ie.value||"svg"===ie.value));P(()=>l.node.language,e=>{ie.value=V(e)}),P(()=>[l.node.originalCode,l.node.updatedCode,it.value],()=>{wn(),Q(()=>bn())},{immediate:!0}),P(()=>[it.value,l.stream,l.loading,Bt.value,bt.value,St.value,Jt.value],()=>{en()?nn(Jt.value):Qt.value=null},{immediate:!0}),P(()=>[l.node.originalCode,l.node.updatedCode,Ce.value,it.value],e=>d(null,[e],function*([e,t,n,o]){if(!1===l.stream||!o)return;if(We&&!Ee.value&&ne.value)try{yield ul(ne.value)}catch(a){}const i=ct(String(null!=e?e:""),String(null!=t?t:"")),r=!1===l.loading;r&&gl();try{yield Vn(i.original,i.updated,Ce.value),jn(!0)}catch(u){return}if(r){if(Fe||!it.value)return;ft(),In(),bn(),qn()}Pe.value&&Q(()=>_n())})),P(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(ie.value||(ie.value=V(Qe(e))),!it.value)){if(We&&!Ee.value&&ne.value)try{yield ul(ne.value)}catch(t){}Ie(e,Ce.value),Pe.value&&Q(()=>_n())}}));const Xn=c(()=>{const e=ie.value;return e?J[e]||e.charAt(0).toUpperCase()+e.slice(1):J[""]||"Plain Text"});function Yn(e){var t,n;const l=null!=(n=null==(t=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:t.trim())?n:"";if(l.length<3)return"";const o=l[0];if("`"!==o&&"~"!==o||l[1]!==o||l[2]!==o)return"";let i=3;for(;l[i]===o;)i+=1;return l.slice(i).trim()}const Kn=c(()=>{var e;return function(e){const t=Yn(e);if(!t)return"";const n=t.split(/\s+/).filter(Boolean);if(!n.length)return"";const l="diff"===n[0]?n.slice(1):n;for(const o of l){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(String(null!=(e=l.node.raw)?e:""))}),Qn=c(()=>Kn.value||Xn.value),Zn=c(()=>Kn.value?it.value?`Diff / ${Xn.value}`:Xn.value:""),el=c(()=>(X.value,Y(ie.value||""))),tl=c(()=>{const e={},t=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},n=t(l.minWidth),o=t(l.maxWidth);if(n&&(e.minWidth=n),o&&(e.maxWidth=o),rn.value&&!it.value){const t=an.value;null!=t&&(e.minHeight=`${t}px`)}return it.value||(e.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))",e.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg))",e.borderColor="var(--markstream-code-border-color)"),e}),nl=c(()=>!1!==l.showTooltips);function ll(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(l.node.code)),oe.value=!0,o("copy",l.node.code),setTimeout(()=>{oe.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function ol(e){if(Pe.value=!Pe.value,e&&nl.value){const t=function(e){const t=e.currentTarget||e.target;return!t||t.disabled?null:t}(e);if(t){const e=Pe.value?T("common.collapse")||"Collapse":T("common.expand")||"Expand";q(t,e,"top",!1,void 0,l.isDark)}}const t=it.value?Ge():Ve(),n=ne.value;t&&n&&(Pe.value?(al(!0),n.style.maxHeight="none",n.style.overflow="visible",An(!0)):(al(!1),n.style.overflow=it.value?"hidden":"auto",An(!0)))}function il(){var e,t,n;if(Be.value=!Be.value,Be.value){if(ne.value){const n=Math.ceil((null==(t=(e=ne.value).getBoundingClientRect)?void 0:t.call(e).height)||0);n>0&&(ze.value=n)}al(!1)}else{Pe.value&&al(!0),ne.value&&null!=ze.value&&(ne.value.style.height=`${ze.value}px`);const e=it.value?Ge():Ve();try{null==(n=null==e?void 0:e.layout)||n.call(e)}catch(l){}_e=2,Q(()=>{An(!0)})}}function rl(){if(!Jn.value)return;const e=ie.value;if(w.value){const t="html"===e?"text/html":"image/svg+xml",n="html"===e?T("artifacts.htmlPreviewTitle")||"HTML Preview":T("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:t,artifactTitle:n,id:`temp-${e}-${Date.now()}`})}"html"===e&&(Lt.value=!Lt.value)}function al(e){var t,n;try{if(it.value){const n=Ge();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}else{const t=Ve();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}}catch(l){}}function ul(e){if(!We||Fe)return null;if(Ke)return Ke;if(Ee.value&&Oe.value)return Promise.resolve();Ee.value=!0,function(){const e=v.value;r&&e&&Ne!==e&&(Ne&&r.markSettled(Ne),Ne=e,r.markPending(e))}();const t=d(null,null,function*(){yield function(e){return d(this,null,function*(){var t;if("undefined"==typeof window)return yield e();try{const n=null==(t=window.Element)?void 0:t.prototype,l=null==n?void 0:n.addEventListener;if(!n||!l)return yield e();const o=function(){const e=window,t=e[ke];if(t)return t;const n={depth:0,original:null};return e[ke]=n,n}();0===o.depth&&(o.original=l,n.addEventListener=function(e,t,n){var i;const r=null!=(i=o.original)?i:l;return"touchstart"===e&&function(e,t){if(!e)return!1;const n=e;return!("function"!=typeof n.closest||!n.closest(".monaco-editor, .monaco-diff-editor")||t&&"object"==typeof t&&"passive"in t)}(this,n)?r.call(this,e,t,function(e){return null==e?{passive:!0}:"boolean"==typeof e?{capture:e,passive:!0}:"object"==typeof e?"passive"in e?e:u(a({},e),{passive:!0}):{passive:!0}}(n)):r.call(this,e,t,n)}),o.depth++;try{return yield e()}finally{o.depth=Math.max(0,o.depth-1),0===o.depth&&o.original&&n.addEventListener!==o.original&&(n.addEventListener=o.original,o.original=null)}}catch(n){return yield e()}})}(()=>function(e){return d(this,null,function*(){var t,n,o;if(!We||Fe)return;if(wt.value=!1,gt.value=!1,bt.value=!1,St.value=!1,dn(),zt.value=null,$t.value=null,function(){const e=En();e&&(e.style.removeProperty("--stream-monaco-line-number-left"),e.style.removeProperty("--stream-monaco-line-number-width"),e.style.removeProperty("--stream-monaco-line-number-gap-to-code"),e.style.removeProperty("--stream-monaco-original-line-number-gap-to-code"),e.style.removeProperty("--stream-monaco-modified-line-number-gap-to-code"),e.style.removeProperty("--stream-monaco-original-scrollable-left"),e.style.removeProperty("--stream-monaco-modified-scrollable-left"))}(),Wn(),function(){const e=Xt.value;Kt.value=Oe.value||null==e?null:e}(),Dn(),Tn(),function(e){e.replaceChildren()}(e),Fe)return;if(it.value){!function(){if(et||"undefined"==typeof window)return;et=!0;const e=e=>{var t;vt("reason"in e?e.reason:null!=(t=e.error)?t:e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener("error",e,!0),window.addEventListener("unhandledrejection",e,!0)}(),Xe();const o=ct(String(null!=(t=l.node.originalCode)?t:""),String(null!=(n=l.node.updatedCode)?n:""));je?yield je(e,o.original,o.updated,Ce.value):yield We(e,l.node.code,Ce.value)}else yield We(e,l.node.code,Ce.value);if(Fe)return;const i=it.value?Ge():Ve();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),Ht.value=l.monacoOptions.fontSize,Nt.value=l.monacoOptions.fontSize;else if(!Fn()){const e=mn();e&&e>0?(Ht.value=e,Nt.value=e):(Ht.value=12,Nt.value=12)}Ln(),Pe.value||Be.value||An(!1),yield function(){return d(this,null,function*(){null!=Zt()&&(In(),An(!1),yield E(),yield vn(),In(),An(!1),yield vn(),In(),An(!1))})}(),Fe||(Oe.value=!0,function(){var e,t,n,l,o;if(Dn(),it.value){const l=Ge(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),i=null==(t=null==l?void 0:l.getModifiedEditor)?void 0:t.call(l),a=(e,t)=>{try{const n=null==e?void 0:e[t];if("function"!=typeof n)return;const l=n.call(e,()=>qn());l&&tt.push(l)}catch(n){}};try{const e=null==(n=null==l?void 0:l.onDidUpdateDiff)?void 0:n.call(l,()=>{qn(),Q(()=>bn())});e&&tt.push(e)}catch(r){}return a(o,"onDidContentSizeChange"),a(i,"onDidContentSizeChange"),a(o,"onDidLayoutChange"),void a(i,"onDidLayoutChange")}const i=Ve();try{const e=null==(l=null==i?void 0:i.onDidContentSizeChange)?void 0:l.call(i,()=>qn());e&&tt.push(e)}catch(r){}try{const e=null==(o=null==i?void 0:i.onDidLayoutChange)?void 0:o.call(i,()=>qn());e&&tt.push(e)}catch(r){}}(),Hn(),Ln(),In(),bn(),qn(),yield function(){return d(this,null,function*(){In(),An(!1),yield E(),yield vn(),In(),An(!1),yield vn(),In(),An(!1)})}(),yield function(){return d(this,null,function*(){var e;if(it.value){for(let n=0;n<8;n++){if(Fe)return;const l=ne.value,o=Ge();let i=!1;try{const t=null==(e=null==o?void 0:o.getLineChanges)?void 0:e.call(o);i=Array.isArray(t)}catch(t){i=!1}const r=Boolean(null==l?void 0:l.querySelector(".monaco-diff-editor")),a=Boolean(null==l?void 0:l.querySelector(".monaco-diff-editor .view-lines .view-line"));if(r&&a&&i){if(yield E(),yield vn(),Fe)return;try{ft(),In(),bn(),qn()}catch(t){}return}if(n>=1&&!r)return;yield E(),yield vn()}if(!Fe)try{ft(),In(),bn(),qn()}catch(t){}}})}(),Fe||(Ln(),function(){if(!it.value)return;const e=ne.value;if(!e)return;const t=e.querySelector(".monaco-diff-editor");function n(e,t,n,l){const o=e.querySelector(t);if(!o)return;const i=o.getBoundingClientRect();if(i.width<=0)return;const r=o.querySelector(".line-numbers"),a=o.querySelector(".view-lines .view-line"),u=o.querySelector(".margin");let d=null;if(a?(d=a.getBoundingClientRect().left-i.left,On(n,d)):u&&(d=u.getBoundingClientRect().width,On(n,d)),r){const e=r.getBoundingClientRect();if(e.width>=20&&e.width<=64&&On("--stream-monaco-line-number-width",e.width),null!=d){const t=d-(e.right-i.left);Number.isFinite(t)&&t>=0&&t<=32&&(On(l,t),On("--stream-monaco-line-number-gap-to-code",t))}}}t&&(n(t,".editor.original","--stream-monaco-original-scrollable-left","--stream-monaco-original-line-number-gap-to-code"),n(t,".editor.modified","--stream-monaco-modified-scrollable-left","--stream-monaco-modified-line-number-gap-to-code"))}(),yield E(),function(){var e;if(!it.value||!Bt.value)return;const t=ne.value,n=null==(e=le.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!t||!n)return;const l=Math.ceil(n.getBoundingClientRect().height);!Number.isFinite(l)||l<=0||(t.style.height=`${l}px`,t.style.minHeight=`${l}px`)}(),yield vn(),yield function(){return d(this,null,function*(){if(it.value){if(bt.value=!0,St.value=!1,gt.value=!0,yield E(),yield vn(),!Fe){if(jn(!0),St.value=!0,dn(),"undefined"==typeof window)return bt.value=!1,void(St.value=!1);kt=window.setTimeout(()=>{kt=null,bt.value=!1,St.value=!1,Q(()=>{Ln(),In(),qn()})},120)}}else gt.value=!0})}()))})}(e))}).finally(()=>{Ke===t&&(Ke=null),function(){const e=Ne;r&&e&&(Ne="",E(()=>{var t,n;if(!Fe){const l=null!=(n=null==(t=le.value)?void 0:t.offsetHeight)?n:0;l>0&&r.reportHeight(e,l)}r.markSettled(e)}))}()});return Ke=t,t}P(nl,e=>{e||j()}),P(()=>Nt.value,(e,t)=>{const n=it.value?Ge():Ve();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(n.updateOptions({fontSize:e}),Be.value||An(!0))},{flush:"post",immediate:!1});const dl=P(()=>[ne.value,it.value,l.stream,l.loading,Le.value,Ae.value],e=>d(null,[e],function*([e,t,n,l,o,i]){if(!e||!We)return;if(!i)return;if(!1===n&&!1!==l)return;const r=ul(e);if(r){try{yield r}catch(a){Oe.value=!1,gt.value=!1,wt.value=!0}dl()}}));function sl(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function cl(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function vl(e,t){if(e===t)return!0;const n=cl(e),l=cl(t);return!!n&&n===l}function fl(){var e;const t=function(){if(void 0!==l.theme){const e=l.theme;return sl(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),n=null==(e=mt.value)?void 0:e.theme,o=null!=t?t:n;if(null!=o&&"object"==typeof o)return o;const i=Array.isArray(l.themes)?l.themes:[];if(!i.length||null==o)return o;const r=cl(o),a=i.map(e=>cl(e)).filter(e=>!!e);if(!r||a.includes(r))return o;const u=cl(n);return null!=n&&u&&a.includes(u)?n:i[0]}P(pt,(e,t)=>d(null,null,function*(){if(e===t)return;if(ht.value=e,!We||!ne.value)return;if(!Ee.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Ae.value)return;const n=Ke;if(n){try{yield n}catch(o){}if(Fe||!ne.value)return}try{Oe.value=!1,gt.value=!1,Ee.value=!1,Dn(),Tn(),Xe(),yield E(),yield ul(ne.value)}catch(i){Oe.value=!1,gt.value=!1,wt.value=!0}}));const ml=c(()=>(void 0!==l.theme?!sl(l.theme):vl(l.darkTheme,l.lightTheme))?function(e){var t,n;if(e&&"object"==typeof e&&(null==(t=e.colors)?void 0:t["editor.background"])){const t=Bn(e.colors["editor.background"]);if(null!=t)return t<128}const o=(null!=(n=cl(e))?n:"").toLowerCase();return o?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):!!l.isDark}(fl()):!!l.isDark),pl=c(()=>{var e;if(!it.value)return ml.value?"dark":"light";const t=null==(e=mt.value)?void 0:e.diffAppearance;return"light"===t||"dark"===t?t:ml.value?"dark":"light"}),hl=c(()=>it.value?"dark"===pl.value:ml.value);function yl(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:l.themes},mt.value||{}),{theme:fl()}),it.value?{diffAppearance:pl.value}:{}),{onThemeChange(){Hn()}})}function gl(){const e=yl();if(!lt)return lt=e,lt;for(const t of Object.keys(lt))t in e||delete lt[t];return Object.assign(lt,e),lt}const wl=c(()=>{var e,t,n,o,i,r,u,d,s,c,v,f,m,p,h;return JSON.stringify({diffLineStyle:null!=(t=null==(e=mt.value)?void 0:e.diffLineStyle)?t:"background",diffUnchangedRegionStyle:null!=(o=null==(n=mt.value)?void 0:n.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:void 0===(null==(i=l.monacoOptions)?void 0:i.diffHideUnchangedRegions)?a({},ut):st(l.monacoOptions.diffHideUnchangedRegions),renderSideBySide:null==(u=null==(r=mt.value)?void 0:r.renderSideBySide)||u,useInlineViewWhenSpaceIsLimited:null!=(s=null==(d=mt.value)?void 0:d.useInlineViewWhenSpaceIsLimited)&&s,enableSplitViewResizing:null==(v=null==(c=mt.value)?void 0:c.enableSplitViewResizing)||v,ignoreTrimWhitespace:null==(m=null==(f=mt.value)?void 0:f.ignoreTrimWhitespace)||m,originalEditable:null!=(h=null==(p=mt.value)?void 0:p.originalEditable)&&h})});return P(()=>[l.monacoOptions,Ae.value],()=>{var e,t;if(gl(),!We||!Ae.value)return;const n=it.value?Ge():Ve(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(Nt.value)?Nt.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(t=null==n?void 0:n.updateOptions)||t.call(n,{fontSize:o})),An(!1)},{deep:!0}),P(()=>[fl(),pl.value,Le.value,Ee.value,Ae.value],([e],t)=>{Le.value&&Ee.value&&Ae.value&&function(e={}){if(e.appearanceOnly)return;gl();const t=fl(),n=()=>{it.value&&ft(),Q(()=>{Hn(),qn()})};t?function(e,t){const n=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&"name"in e)return String(e.name);if("object"==typeof e){const n=fe.get(e);if(n)return n;try{const t=JSON.stringify(e);if(t)return fe.set(e,t),t}catch(t){}const l="__theme_"+ ++me;return fe.set(e,l),l}return String(e)}(t);return n?(ve=e,ae||ce!==n?ae?(se===n||ue===n||(de=t,se=n),ae):(de=t,se=n,ae=d(null,null,function*(){for(;se&&null!=de;){const n=de,l=se;if(de=null,se=null,ce!==l)try{ue=l,yield(null!=ve?ve:e)(n),ce=l}catch(t){}}}).finally(()=>{ae=null,ue=null}),ae):Promise.resolve()):Promise.resolve()}(Ze,t).then(n).catch(e=>{}):n()}({appearanceOnly:null!=t&&vl(e,t[0])})},{flush:"post"}),P(()=>[wl.value,Le.value,Ae.value],(e,t)=>d(null,[e,t],function*([e,t,n],[o]){if(gl(),!t||!n)return;if(!We||!ne.value)return;if(!Ee.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=Ke;if(i){try{yield i}catch(r){}if(Fe||!ne.value)return}try{Oe.value=!1,gt.value=!1,Ee.value=!1,Dn(),Tn(),Xe(),yield E(),yield ul(ne.value)}catch(a){Oe.value=!1,gt.value=!1,wt.value=!0}}),{flush:"post"}),P(()=>[l.loading,Ae.value],(e,t)=>d(null,[e,t],function*([e,t],n){if(!t)return;const o=null==n?void 0:n[0];if(!1===o&&!1!==e&&it.value&&Ee.value&&(yield E(),Q(()=>{d(null,null,function*(){const e=Ke;if(e)try{yield e}catch(t){}!Fe&&it.value&&!1!==l.loading&&(gl(),ft(),qn())})})),e)return;const i=void 0!==o&&!1!==o;yield E(),Q(()=>{d(null,null,function*(){var e,t,n;try{if(i&&Ee.value)if(it.value&&ne.value){const n=Ke;if(n)try{yield n}catch(o){}gl();const i=ct(String(null!=(e=l.node.originalCode)?e:""),String(null!=(t=l.node.updatedCode)?t:""));if(yield Vn(i.original,i.updated,Ce.value),Fe||!it.value)return;ft(),jn(!0),In(),bn(),qn()}else Ie(String(null!=(n=l.node.code)?n:""),Ce.value);An(!1)}catch(r){}})})}),{immediate:!0,flush:"post"}),f(()=>{dn(),Dn(),Tn(),Je()}),(t,n)=>yt.value?(m(),p(S(I),{key:0,node:Ft.value,loading:l.loading},null,8,["node","loading"])):(m(),O("div",{key:1,ref_key:"container",ref:le,style:L(tl.value),class:g(["code-block-container rounded-lg border",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":hl.value,"is-diff":it.value,"is-plain-text":Me.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":gt.value&&!yt.value?"true":"false"},[F(ee,{"show-header":l.showHeader,"show-collapse-button":l.showCollapseButton,"show-font-size-buttons":l.showFontSizeButtons,"enable-font-size-control":l.enableFontSizeControl,"show-copy-button":l.showCopyButton,"show-expand-button":l.showExpandButton,"show-preview-button":l.showPreviewButton,"show-tooltips":l.showTooltips,"is-dark":l.isDark,loading:l.loading,stream:e.stream,"is-collapsed":Be.value,"is-expanded":Pe.value,"copy-text":oe.value,"is-previewable":Jn.value,"code-font-size":Nt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":Ht.value,"font-baseline-ready":Rt.value,"diff-stats":it.value?rt.value:null,"diff-stats-aria-label":at.value,onToggleCollapse:il,onDecreaseFont:xn,onResetFont:Cn,onIncreaseFont:kn,onCopy:ll,onToggleExpand:ol,onPreview:rl},H({"header-left":N(()=>[_(t.$slots,"header-left",{},()=>[y("div",he,[y("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:el.value},null,8,ye),y("div",ge,[y("div",we,b(Qn.value),1),Zn.value?(m(),O("div",be,b(Zn.value),1)):$("",!0)])])],!0)]),loading:N(()=>[_(t.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[n[0]||(n[0]=y("div",{class:"loading-skeleton"},[y("div",{class:"skeleton-line"}),y("div",{class:"skeleton-line"}),y("div",{class:"skeleton-line short"})],-1))],!0)]),default:N(()=>[z(y("div",Se,[y("div",{ref_key:"codeEditor",ref:ne,class:g(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":Ot.value}]]),style:L(un.value)},null,6),Et.value?(m(),p(S(I),{key:0,class:g(["code-pre-fallback",{"is-wrap":xt.value,"is-fading-out":St.value}]),style:L(on.value),node:Ft.value,"show-line-numbers":!0,"diff-inline":Ct.value},null,8,["class","style","node","diff-inline"])):$("",!0)],512),[[R,!(Be.value||!e.stream&&e.loading)]]),Lt.value&&!w.value&&Jn.value&&"html"===ie.value?(m(),p(re,{key:0,code:l.node.code,"html-preview-allow-scripts":l.htmlPreviewAllowScripts,"html-preview-sandbox":l.htmlPreviewSandbox,"is-dark":l.isDark,"on-close":()=>Lt.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):$("",!0)]),_:2},[t.$slots["header-right"]?{name:"header-right",fn:N(()=>[_(t.$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,pe))}}),[["__scopeId","data-v-ec2b9e40"]]);export{Ce as default};
@@ -0,0 +1 @@
1
+ import{defineComponent as e,ref as o,computed as t,openBlock as n,createElementBlock as a,Fragment as r,renderSlot as i,createElementVNode as l,toDisplayString as s,createCommentVNode as d,unref as c,normalizeStyle as u,withModifiers as p,createStaticVNode as v,createVNode as h,Transition as m,withCtx as w,withDirectives as g,vShow as f}from"vue";import{u as x,s as b,h as y}from"./exports.js";const k={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)]"},B={class:"flex items-center gap-0.5"},C=["aria-label"],F={class:"code-diff-stat removed"},M={class:"code-diff-stat added"},S=["aria-label"],z={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},j={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},E=["aria-pressed"],T={key:3,class:"relative"},L=["aria-expanded"],P=["disabled"],_=["disabled"],R=["disabled"],$={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},H={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},A={class:"code-block-shell-content"},D={class:"code-loading-placeholder"},N={class:"sr-only","aria-live":"polite",role:"status"},V=/* @__PURE__ */e({__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:V}){const q=e,G=V,I=o(!1),J=o(null),K=o(null);function O(){I.value=!I.value,I.value&&document.addEventListener("click",Q,{once:!0,capture:!0})}function Q(e){var o,t;const n=e.target;(null==(o=J.value)?void 0:o.contains(n))||(null==(t=K.value)?void 0:t.contains(n))?document.addEventListener("click",Q,{once:!0,capture:!0}):I.value=!1}const U=t(()=>q.showFontSizeButtons&&q.enableFontSizeControl||q.showExpandButton||q.isPreviewable&&q.showPreviewButton),{t:W}=x(),X=t(()=>!1!==q.showTooltips);function Y(e,o){X.value&&b(e.currentTarget,o,"top",!1,void 0,q.isDark)}function Z(){X.value&&y()}function ee(e){Y(e,q.copyText?W("common.copied")||"Copied":W("common.copy")||"Copy")}const oe=t(()=>{var e,o;return!!Number.isFinite(q.codeFontSize)&&(null!=(e=q.codeFontSize)?e:0)<=(null!=(o=q.codeFontMin)?o:0)}),te=t(()=>!q.fontBaselineReady||q.codeFontSize===q.defaultCodeFontSize),ne=t(()=>{var e,o;return!!Number.isFinite(q.codeFontSize)&&(null!=(e=q.codeFontSize)?e:0)>=(null!=(o=q.codeFontMax)?o:100)});return(o,t)=>(n(),a(r,null,[q.showHeader?(n(),a("div",k,[i(o.$slots,"header-left"),i(o.$slots,"header-right",{},()=>[l("div",B,[e.diffStats?(n(),a("div",{key:0,class:"code-diff-stats","aria-label":e.diffStatsAriaLabel},[l("span",F,"-"+s(e.diffStats.removed),1),l("span",M,"+"+s(e.diffStats.added),1)],8,C)):d("",!0),q.showCopyButton?(n(),a("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?c(W)("common.copied")||"Copied":c(W)("common.copy")||"Copy",onClick:t[0]||(t[0]=e=>G("copy")),onMouseenter:t[1]||(t[1]=e=>ee(e)),onFocus:t[2]||(t[2]=e=>ee(e)),onMouseleave:Z,onBlur:Z},[e.copyText?(n(),a("svg",j,[...t[14]||(t[14]=[l("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(n(),a("svg",z,[...t[13]||(t[13]=[l("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[l("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),l("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,S)):d("",!0),q.showCollapseButton?(n(),a("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:t[3]||(t[3]=e=>G("toggleCollapse")),onMouseenter:t[4]||(t[4]=o=>Y(o,e.isCollapsed?c(W)("common.expand")||"Expand":c(W)("common.collapse")||"Collapse")),onFocus:t[5]||(t[5]=o=>Y(o,e.isCollapsed?c(W)("common.expand")||"Expand":c(W)("common.collapse")||"Collapse")),onMouseleave:Z,onBlur:Z},[(n(),a("svg",{style:u({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"},[...t[15]||(t[15]=[l("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,E)):d("",!0),U.value?(n(),a("div",T,[l("button",{ref_key:"moreBtnRef",ref:K,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":I.value,"aria-haspopup":"true",onClick:p(O,["stop"]),onMouseenter:t[6]||(t[6]=e=>Y(e,c(W)("common.more")||"More")),onFocus:t[7]||(t[7]=e=>Y(e,c(W)("common.more")||"More")),onMouseleave:Z,onBlur:Z},[...t[16]||(t[16]=[v('<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,L),h(m,{name:"code-menu"},{default:w(()=>[I.value?(n(),a("div",{key:0,ref_key:"moreMenuRef",ref:J,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"},[q.showFontSizeButtons&&q.enableFontSizeControl?(n(),a(r,{key:0},[l("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:oe.value,onClick:t[8]||(t[8]=e=>G("decreaseFont"))},[t[17]||(t[17]=l("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[l("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)),l("span",null,s(c(W)("common.fontSmaller")||"Font size −"),1)],8,P),l("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:te.value,onClick:t[9]||(t[9]=e=>G("resetFont"))},[t[18]||(t[18]=l("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[l("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[l("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),l("path",{d:"M3 3v5h5"})])],-1)),l("span",null,s(c(W)("common.fontReset")||"Font size reset"),1)],8,_),l("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:ne.value,onClick:t[10]||(t[10]=e=>G("increaseFont"))},[t[19]||(t[19]=l("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[l("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)),l("span",null,s(c(W)("common.fontLarger")||"Font size +"),1)],8,R)],64)):d("",!0),q.showExpandButton?(n(),a("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:t[11]||(t[11]=e=>{G("toggleExpand",e),I.value=!1})},[e.isExpanded?(n(),a("svg",$,[...t[20]||(t[20]=[l("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)])])):(n(),a("svg",H,[...t[21]||(t[21]=[l("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)])])),l("span",null,s(e.isExpanded?c(W)("common.collapse")||"Collapse":c(W)("common.expand")||"Expand"),1)])):d("",!0),e.isPreviewable&&q.showPreviewButton?(n(),a("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:t[12]||(t[12]=e=>{G("preview"),I.value=!1})},[t[22]||(t[22]=l("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[l("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[l("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"}),l("circle",{cx:"12",cy:"12",r:"3"})])],-1)),l("span",null,s(c(W)("common.preview")||"Preview"),1)])):d("",!0)],512)):d("",!0)]),_:1})])):d("",!0)])])])):d("",!0),g(l("div",A,[i(o.$slots,"default")],512),[[f,!(e.isCollapsed||!e.stream&&e.loading)]]),g(l("div",D,[i(o.$slots,"loading",{},()=>[t[23]||(t[23]=l("div",{class:"loading-skeleton"},[l("div",{class:"skeleton-line"}),l("div",{class:"skeleton-line"}),l("div",{class:"skeleton-line short"})],-1))])],512),[[f,!e.stream&&e.loading]]),l("span",N,s(e.copyText?c(W)("common.copied")||"Copied":""),1)],64))}});export{V as _};
@@ -0,0 +1 @@
1
+ var e=(e,l,t)=>new Promise((n,a)=>{var i=e=>{try{r(t.next(e))}catch(l){a(l)}},o=e=>{try{r(t.throw(e))}catch(l){a(l)}},r=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,o);r((t=t.apply(e,l)).next())});import{defineComponent as l,ref as t,watch as n,nextTick as a,onBeforeUnmount as i,openBlock as o,createBlock as r,Teleport as u,createElementVNode as s,normalizeClass as v,createVNode as c,Transition as p,withCtx as f,withDirectives as d,normalizeStyle as h,createTextVNode as m,toDisplayString as y,vShow as x}from"vue";import{_ as b}from"./exports.js";const g=["id"],E=["data-placement"],w=/* @__PURE__ */b(/* @__PURE__ */l({__name:"Tooltip",props:{visible:{type:Boolean},anchorEl:{},content:{},placement:{},offset:{},originX:{},originY:{},id:{},isDark:{type:[Boolean,null]}},setup(l){var b;const w=l,M=t(null),$=t(null),_=t({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),k=t({}),B=t(null!=(b=w.placement)?b:"top"),P=t(!1);let X=null,Y=null,C=null,D=null,R=null,N=0;function j(){return D?Promise.resolve(D):(R||(R=import("@floating-ui/dom").then(e=>(D=e,e)).catch(e=>{throw R=null,e})),R)}function I(){X&&(X(),X=null),Y=null,C=null}function T(l){return e(this,null,function*(){const e=w.anchorEl,t=M.value;if(!w.visible||!e||!t)return;if(Y===e&&C===t)return;const{autoUpdate:n}=yield j();l()&&w.visible&&w.anchorEl===e&&M.value===t&&(I(),Y=e,C=t,X=n(e,t,()=>{U().catch(()=>{q()})}))})}function U(){return e(this,null,function*(){var e,l;const t=w.anchorEl,n=M.value;if(!w.visible||!t||!n)return!1;const{arrow:a,computePosition:i,flip:o,offset:r,shift:u}=yield j();if(!w.visible||w.anchorEl!==t||M.value!==n)return!1;const s=[r(null!=(e=w.offset)?e:6),o(),u({padding:6}),...$.value?[a({element:$.value,padding:4})]:[]],{x:v,y:c,placement:p,middlewareData:f}=yield i(t,n,{placement:null!=(l=w.placement)?l:"top",middleware:s,strategy:"fixed"});if(!w.visible||w.anchorEl!==t||M.value!==n)return!1;if(_.value.transform=`translate3d(${Math.round(v)}px, ${Math.round(c)}px, 0)`,_.value.left="0px",_.value.top="0px",B.value=p,f.arrow&&$.value){const{x:e,y:l}=f.arrow,t={top:"bottom",bottom:"top",left:"right",right:"left"}[p.split("-")[0]];k.value={left:null!=e?`${e}px`:"",top:null!=l?`${l}px`:"",[t]:"-3px"}}return!0})}function q(){var e,l;const t=w.anchorEl,n=M.value;if(!t||!n)return!1;const a=t.getBoundingClientRect(),i=n.getBoundingClientRect(),o=null!=(e=w.offset)?e:6,r=null!=(l=w.placement)?l:"top";let u=a.left,s=a.top;return"bottom"===r?s=a.bottom+o:"left"===r?u=a.left-i.width-o:"right"===r?u=a.right+o:s=a.top-i.height-o,_.value.transform=`translate3d(${Math.round(Math.max(0,u))}px, ${Math.round(Math.max(0,s))}px, 0)`,_.value.left="0px",_.value.top="0px",B.value=r,k.value={},!0}n(()=>w.visible,l=>e(null,null,function*(){const e=++N;if(l){if(P.value=!1,yield a(),e!==N||!w.visible)return;if(w.anchorEl&&M.value)try{const l=w.anchorEl,t=M.value,n=l.getBoundingClientRect();if(!(yield U())||e!==N||!w.visible||w.anchorEl!==l||M.value!==t)return;const i=_.value.transform;if(null!=w.originX&&null!=w.originY){const l=Math.abs(Number(w.originX)-n.left),t=Math.abs(Number(w.originY)-n.top);if(Math.hypot(l,t)>120){if(_.value.transform=`translate3d(${Math.round(w.originX)}px, ${Math.round(w.originY)}px, 0)`,yield a(),e!==N||!w.visible)return;if(P.value=!0,yield a(),e!==N||!w.visible)return;_.value.transform=i}else P.value=!0}else P.value=!0;yield T(()=>e===N)}catch(t){if(e!==N||!w.visible)return;if(P.value=q(),w.anchorEl&&M.value)try{yield T(()=>e===N)}catch(n){}}else P.value=!0}else P.value=!1,I()}));let z=0;return n([()=>w.anchorEl,()=>w.placement,()=>w.content],()=>e(null,null,function*(){const e=++z;if(w.visible&&w.anchorEl&&M.value){if(yield a(),e!==z||!w.visible||!w.anchorEl||!M.value)return;try{const l=yield U();if(e!==z||!w.visible||!w.anchorEl||!M.value)return;l||q()}catch(l){q()}yield T(()=>e===z)}})),i(()=>{N+=1,I()}),(e,t)=>(o(),r(u,{to:"body"},[s("div",{class:v(["markstream-vue",{dark:l.isDark}])},[c(p,{name:"tooltip",appear:""},{default:f(()=>[d(s("div",{id:w.id,ref_key:"tooltip",ref:M,style:h({position:"fixed",left:_.value.left,top:_.value.top,transform:_.value.transform,visibility:P.value?"visible":"hidden",pointerEvents:P.value?void 0:"none"}),class:"tooltip-element",role:"tooltip"},[m(y(l.content)+" ",1),s("div",{ref_key:"arrowEl",ref:$,class:"tooltip-arrow","data-placement":B.value,style:h(k.value)},null,12,E)],12,g),[[x,l.visible]])]),_:1})],2)]))}}),[["__scopeId","data-v-c606ee4c"]]);export{w as default};