markstream-vue 1.0.1 → 1.0.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(n,t,l)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l,a=(e,n)=>{for(var t in n||(n={}))o.call(n,t)&&r(e,t,n[t]);if(l)for(var t of l(n))i.call(n,t)&&r(e,t,n[t]);return e},u=(e,l)=>n(e,t(l)),d=(e,n,t)=>new Promise((l,o)=>{var i=e=>{try{a(t.next(e))}catch(n){o(n)}},r=e=>{try{a(t.throw(e))}catch(n){o(n)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);a((t=t.apply(e,n)).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 g,normalizeClass as y,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 W,b as A,h as j,A 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 ne}from"./monaco.js";const te={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 n=e,t=void 0!==import.meta&&Boolean(!1);let l=null;const{t:o}=D(),i=c(()=>{const e=n.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${n.isDark?"#020617":"#ffffff"};\n color: ${n.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=n.htmlPreviewSandbox,o=n.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!t||"undefined"==typeof console||l===e)return;const n=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);n.has("allow-scripts")&&n.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 t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",a)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",a)}),(e,t)=>(m(),p(h,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:n.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:t[2]||(t[2]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})},[g("div",{class:"html-preview-frame",onClick:t[1]||(t[1]=w(()=>{},["stop"]))},[g("div",te,[g("div",le,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",oe,b(n.title||S(o)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:t[0]||(t[0]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})}," × ")]),g("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","data-markstream-pending"],he={class:"code-header-main"},ge=["innerHTML"],ye={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:{},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:n}){var t;const l=e,o=n,i=k(),r=x(U,null),s=x("markstreamHostScrollManaged",null),v=c(()=>W(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(),te=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=A(),Te=M(null),We=M("undefined"==typeof window);"undefined"!=typeof window&&P(()=>le.value,e=>{var n;if(null==(n=Te.value)||n.destroy(),Te.value=null,!e)return void(We.value=!1);const t=De(e,{rootMargin:"400px"});Te.value=t,We.value=t.isVisible.value,t.whenVisible.then(()=>{We.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 Ae=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*(){}),en=!1;const nn=[],tn=[];let ln=null;function on(e){var n;return"diff"===(null!=(n=String(null!=e?e:"").trim().split(/\s+/,1)[0])?n:"")}const rn=c(()=>{var e;return!0===l.node.diff||on(l.node.language)||on(Zt(String(null!=(e=l.node.raw)?e:"")))}),an=M({removed:0,added:0}),un=c(()=>`-${an.value.removed} +${an.value.added}`),dn=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5}),sn=Object.freeze(u(a({},dn),{enabled:!1,revealLineCount:0}));function cn(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return u(a(a({},dn),t),{enabled:null==(n=t.enabled)||n})}return a({},dn)}function vn(e,n){return{original:String(null!=e?e:""),updated:String(null!=n?n:"")}}function fn(e,n){const t=String(null!=e?e:"");return n?t:t.replace(/\r\n$|\n$|\r$/,"")}function mn(e){var n;return String(null!=(n=null==e?void 0:e.message)?n:e).includes("no diff result available")}function pn(){try{const e=Ye();e&&"function"==typeof e.catch&&e.catch(e=>{mn(e)})}catch(e){mn(e)}}const hn=c(()=>{var e,n,t,o;const i=l.monacoOptions?a({},l.monacoOptions):{};if(!rn.value)return i;const r=void 0===i.diffHideUnchangedRegions?a({},dn):cn(i.diffHideUnchangedRegions),d=void 0===i.hideUnchangedRegions?void 0:cn(i.hideUnchangedRegions),s=!1!==l.stream&&!1!==l.loading,c=s?a({},sn):r,v=s?a({},sn):d,f=function(e){return void 0!==e.diffWordWrap?e.diffWordWrap:"off"}(i),m=a({},null!=(e=i.experimental)?e:{}),p=null!=(n=i.diffUnchangedRegionStyle)?n:"line-info",h={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,diffWordWrap:f,renderSideBySide:null==(t=i.renderSideBySide)||t,diffHideUnchangedRegions:c,useInlineViewWhenSpaceIsLimited:null!=(o=i.useInlineViewWhenSpaceIsLimited)&&o,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:p,diffHunkActionsOnHover:!1,experimental:m};return u(a(u(a(a({},h),i),{experimental:m}),void 0===v?{}:{hideUnchangedRegions:v}),{diffHideUnchangedRegions:c,diffWordWrap:f})}),gn=c(()=>rn.value?"diff":"single"),yn=M(gn.value),wn=M(!1),bn=M(!1),Sn=M(!1),kn=M(!1),xn=M(!1);let Cn=null;const Mn=c(()=>{var e,n,t;if(rn.value){const t=null==(e=hn.value)?void 0:e.diffWordWrap;if("inherit"===t){const e=null==(n=l.monacoOptions)?void 0:n.wordWrap;return null==e||"off"!==String(e)}return"on"===t}const o=null==(t=l.monacoOptions)?void 0:t.wordWrap;return null==o||"off"!==String(o)}),Pn=c(()=>{var e,n,t,l,o,i;if(!rn.value)return!1;if(!1===(null==(e=hn.value)?void 0:e.renderSideBySide))return!0;if(!0!==(null==(n=hn.value)?void 0:n.useInlineViewWhenSpaceIsLimited))return!1;const r=null==(t=hn.value)?void 0:t.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 Bn(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 En=c(()=>Bn(le.value)),On=c(()=>!wn.value&&(!!Sn.value||(rn.value||En.value||!K())&&!bn.value)),Ln=c(()=>On.value||kn.value),Fn=c(()=>On.value&&!kn.value),Hn=c(()=>!wn.value&&!Sn.value&&(On.value||kn.value||xn.value)),Nn=M(!1),zn=c(()=>fn(l.node.code,!0===l.node.loading)),$n=c(()=>rn.value?!0===l.node.diff?l.node:u(a({},l.node),{diff:!0}):zn.value===l.node.code?l.node:u(a({},l.node),{code:zn.value}));"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield ne();if(Fe)return;if(!e)return void(wn.value=!0);const n=e.useMonaco,t=e.detectLanguage;if("function"==typeof t&&(Qe=t),"function"==typeof n){const e=hl();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");ln=bl();const t=n(ln);Ae=t.createEditor||Ae,je=t.createDiffEditor||je,Ie=t.updateCode||Ie,qe=t.updateDiff||qe,Ue=t.getEditor||Ue,Ve=t.getEditorView||Ve,Ge=t.getDiffEditorView||Ge,Je=t.cleanupEditor||Je,Xe=t.safeClean||t.cleanupEditor||Xe,Ye=t.refreshDiffPresentation||Ye,Ze=t.setTheme||Ze,Le.value=!0,!Fe&&te.value&&(yield cl(te.value))}}catch(e){if(Fe)return;wn.value=!0}});const Rn=M("number"==typeof(null==(t=l.monacoOptions)?void 0:t.fontSize)?l.monacoOptions.fontSize:Number.NaN),_n=M(Rn.value),Dn=M(null),Tn=M(null),Wn=c(()=>{const e=Rn.value,n=_n.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),An=c(()=>{var e;const n=Dn.value;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const o=_n.value;return"number"==typeof o&&Number.isFinite(o)&&o>0?o:12}),jn=c(()=>{var e;const n=Tn.value;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:12===An.value?18:Math.max(12,Math.round(1.5*An.value))}),In=c(()=>jn.value);function qn(e){const n=String(null!=e?e:"");return n?Math.max(1,n.split(/\r\n|\n|\r/).length):1}function Un(e){return e.startsWith("-")&&!e.startsWith("---")}function Vn(e){return e.startsWith("+")&&!e.startsWith("+++")}const Gn=c(()=>Pn.value?function(){var e,n,t;const o=String(null!=(e=l.node.code)?e:"").split(/\r\n|\n|\r/);if(o.some(e=>Un(e)||Vn(e)))return Math.max(1,o.length);const i=String(null!=(n=l.node.originalCode)?n:"").split(/\r\n|\n|\r/),r=String(null!=(t=l.node.updatedCode)?t:"").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 n=String(null!=(e=l.node.code)?e:"").split(/\r\n|\n|\r/);if(!n.some(e=>Un(e)||Vn(e))&&(null!=l.node.originalCode||null!=l.node.updatedCode))return Math.max(qn(l.node.originalCode),qn(l.node.updatedCode));let t=0,o=0;for(const l of n)Un(l)?t++:(Vn(l)||t++,o++);return Math.max(1,t,o)}()),Jn=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:4}),Xn=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.padding;return{top:"number"==typeof(null==n?void 0:n.top)&&Number.isFinite(n.top)&&n.top>0?n.top:0,bottom:"number"==typeof(null==n?void 0:n.bottom)&&Number.isFinite(n.bottom)&&n.bottom>0?n.bottom:0}}),Yn=c(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Kn(e){if(null==e)return null;const n=Math.ceil(e);return!Number.isFinite(n)||n<=0?null:Math.min(n,Math.ceil(Yt()))}const Qn=c(()=>rn.value?Math.ceil(Gn.value*In.value):null!=Yn.value?null:Math.ceil((e=>{const n=String(null!=e?e:"");return n?Math.max(1,n.split(/\r\n|\n|\r/).length):1})(zn.value)*(jn.value+xe)+1)),Zn=c(()=>{if(rn.value){const e=Qn.value,n=it();return Kn(null!=n&&null!=e?Math.max(e,n):null!=n?n:e)}const e=Yn.value;return Kn(null!=e?e:Qn.value)}),et=c(()=>{const e=l.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),nt=M(null),tt=M(null);function lt(){const e=nt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function ot(){return rn.value&&!1!==l.stream&&(!1!==l.loading||On.value||kn.value||xn.value)}function it(){if(!ot())return null;const e=tt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function rt(e){if(!ot()||null==e)return;const n=Math.min(Math.ceil(e),Math.ceil(Yt()));if(!Number.isFinite(n)||n<=0)return;const t=it();tt.value=null==t?n:Math.max(t,n)}const at=c(()=>{const e=lt();return null!=e?e:On.value||!bn.value?Zn.value:null}),ut=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontFamily,t=Kn(Yn.value),o=Kn(Qn.value),i=a(a({fontSize:`${An.value}px`,lineHeight:`${In.value}px`,tabSize:Jn.value,boxSizing:"border-box",maxHeight:`${Yt()}px`,overflow:"auto",paddingTop:`${Xn.value.top}px`,paddingBottom:`${Xn.value.bottom}px`},rn.value?function(e){if(null==e)return{};const n=Math.ceil(e),t=Math.ceil(Yt()),l=Math.min(n,t);return n>=t?{height:`${l}px`,minHeight:`${l}px`}:{minHeight:`${n}px`}}(Zn.value):null!=t?{height:`${t}px`,minHeight:`${t}px`}:null!=o?{minHeight:`${o}px`}:{}),"string"==typeof n&&n.trim()?{"--markstream-code-font-family":n.trim()}:{});return i["--markstream-pre-line-number-top"]=`${Xn.value.top}px`,i["--markstream-code-padding-left"]="62px",i["--markstream-pre-line-number-width"]="36px",i["--markstream-pre-line-number-gap"]="0px",rn.value&&(i["--markstream-pre-diff-line-height"]=`${In.value}px`),i}),dt=c(()=>null!=at.value&&(!bn.value||null!=lt())),st=c(()=>{const e=at.value;if(null==e)return null;if(rn.value)return Math.ceil(e);const n=et.value,t=Yn.value;if(null==n||null==t)return Math.ceil(e);const l=Math.max(0,Math.ceil(n)-Math.ceil(t));return Math.ceil(e+l)}),ct=c(()=>{if(rn.value&&On.value)return;const e=at.value;return dt.value&&null!=e?{minHeight:`${e}px`}:void 0});function vt(){null!=Cn&&"undefined"!=typeof window&&window.clearTimeout(Cn),Cn=null}function ft(){if(!rn.value)return!1;if(!Oe.value||!bn.value)return!1;if(kn.value||xn.value)return!1;const e=te.value;return!!e&&Ot(e)}function mt(e,n=!1,t={}){const l=Math.ceil(e),o=lt();if(null==o)return l;const i=!0===t.allowBelowEstimatedFloor||ft();return l>=o||i?((n||i)&&Oe.value&&(nt.value=null),l):o}function pt(){return new Promise(e=>{Q(()=>e())})}function ht(){try{const e=te.value;if(!e)return null;const n=e.querySelector(".view-lines .view-line");if(n){const e=Math.ceil(n.getBoundingClientRect().height);if(e>0)return e}}catch(e){}return null}function gt(){var e,n,t,l,o;try{const i=rn.value?null!=(t=null==(n=null==(e=Ge())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t: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),n=null==e?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n}}catch(i){}try{const e=te.value;if(e){const n=e.querySelector(".view-lines .view-line");if(n)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(n).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(i){}}}catch(i){}return null}function yt(e){var n,t;try{const l=Ue(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.lineHeight;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof n&&n>0)return n}}catch(i){}const l=ht();if(l&&l>0)return l;const o=Number.isFinite(_n.value)&&_n.value>0?_n.value:14;return Math.max(12,Math.round(1.35*o))}function wt(e){var n,t,l;try{const l=Ue(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.padding;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o),l="number"==typeof(null==n?void 0:n.top)?n.top:0,i="number"==typeof(null==n?void 0:n.bottom)?n.bottom:0;if(l>0||i>0)return l+i}}catch(a){}const o=null==(l=hn.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:rn.value?24:0}function bt(e,n){return"number"!=typeof e||"number"!=typeof n||e<1||n<e?0:n-e+1}function St(e){if(!e)return[];const n=e.split(/\r?\n/);return 1===n.length&&""===n[0]?[]:n}function kt(){var e,n;rn.value?an.value=function(e,n){const t=St(e),l=St(n);let o=0,i=t.length-1,r=l.length-1;for(;o<=i&&o<=r&&t[o]===l[o];)o++;for(;i>=o&&r>=o&&t[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!=(n=l.node.updatedCode)?n:"")):an.value={removed:0,added:0}}function xt(){var e;if(rn.value)try{const n=Ge(),t=null==(e=null==n?void 0:n.getLineChanges)?void 0:e.call(n);if(!Array.isArray(t))return void kt();let l=0,o=0;for(const e of t)l+=bt(e.originalStartLineNumber,e.originalEndLineNumber),o+=bt(e.modifiedStartLineNumber,e.modifiedEndLineNumber);an.value={removed:l,added:o}}catch(n){kt()}else an.value={removed:0,added:0}}function Ct(){var e;if(Number.isFinite(_n.value)&&_n.value>0&&Number.isFinite(Rn.value))return _n.value;const n=gt();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(Rn.value=l.monacoOptions.fontSize,_n.value=l.monacoOptions.fontSize,_n.value):n&&n>0?(Rn.value=n,_n.value=n,n):(Rn.value=12,_n.value=12,12)}function Mt(){const e=Ct(),n=Math.min(36,e+1);_n.value=n}function Pt(){const e=Ct(),n=Math.max(10,e-1);_n.value=n}function Bt(){Ct(),Number.isFinite(Rn.value)&&(_n.value=Rn.value)}function Et(){var e,n,t,l,o,i,r,a,u,d,s,c,v,f;try{const m=rn.value?Ge():null,p=rn.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==(n=m.getModifiedEditor)?void 0:n.call(m);null==(t=null==v?void 0:v.layout)||t.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,g=Math.max(p,h);if(g>0)return Math.ceil(g+1);const y=(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(y,w),S=Math.max(yt(v),yt(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 g=1;h&&"function"==typeof h.getLineCount&&(g=h.getLineCount());const y=yt(p);return Math.ceil(g*(y+xe)+0+1)}catch(m){return null}}function Ot(e){if("undefined"==typeof window)return!1;const n=e.getBoundingClientRect();if(n.width<=0||n.height<=0)return!1;const t=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const l of Array.from(t)){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 t=l.getBoundingClientRect();if(!(t.width<=0||t.height<=0||t.bottom<=n.top||t.top>=n.bottom))return!0}return!1}function Lt(e){var n;const t=String(null!=e?e:"").trim(),l=null==(n=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:n[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=t.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 Ft(){var e;const n=null==(e=te.value)?void 0:e.parentElement;return n instanceof HTMLElement?n:null}function Ht(e,n){var t;null==n||!Number.isFinite(n)||n<=0||null==(t=Ft())||t.style.setProperty(e,`${n}px`)}function Nt(){var e,n,t;if(zt())return;const l=gt();l&&l>0&&(Dn.value=l,_n.value=l,Rn.value=l);try{const l=yt(rn.value?null!=(t=null==(n=null==(e=Ge())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t:Ge():Ve());l&&l>0&&(Tn.value=l)}catch(o){}try{const e=ht();e&&e>0&&(Tn.value=e)}catch(o){}}function zt(){return rn.value&&Ln.value}function $t(){var e,n,t,l,o,i,r,a;const u=te.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 g=String(null!=(e=null==m?void 0:m.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),y=String(null!=(n=null==m?void 0:m.getPropertyValue("--vscode-editor-background"))?n:"").trim(),w=String(null!=(l=null!=(t=null==m?void 0:m.getPropertyValue("--vscode-editor-selectionBackground"))?t:null==m?void 0:m.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),b=g||String(null!=(i=null!=(o=null==h?void 0:h.color)?o:null==m?void 0:m.color)?i:"").trim(),S=y||String(null!=(a=null!=(r=null==p?void 0:p.backgroundColor)?r:null==m?void 0:m.backgroundColor)?a:"").trim();return rn.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,n,t){if(!Me.value)return!1;const l=Lt(e),o=Lt(n);return t?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 Rt=0,_t=0;const Dt=/auto|scroll|overlay/i;function Tt(e,n,t){var l;if("undefined"==typeof window)return;if(rn.value)return;if(function(e){return En.value||Bn(e)}(e))return;const o=Math.ceil(n),i=Math.ceil(t)-o;if(Math.abs(i)<=1)return;const r=function(e){var n,t;if("undefined"==typeof window)return null;const l=null!=(n=null==e?void 0:e.ownerDocument)?n:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(Dt.test(n)||Dt.test(t))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 Wt(){try{const e=te.value;if(!e)return;const n=e.getBoundingClientRect().height,t=Et();if(null!=t&&t>0){const l=mt(t,!0),o=lt();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",void Tt(e,n,l)}const l=lt();null!=l&&(e.style.minHeight=`${l}px`,e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",Tt(e,n,l))}catch(e){}}function At(){for(var e,n;nn.length>0;)try{null==(n=null==(e=nn.pop())?void 0:e.dispose)||n.call(e)}catch(t){}null!=He&&(Z(He),He=null)}function jt(){for(var e;tn.length>0;)try{null==(e=tn.pop())||e()}catch(n){}}function It(e=!1){Be.value||(Pe.value?Wt():function(){var e;try{const n=te.value;if(!n)return;const t=n.getBoundingClientRect().height,l=Yt(),o=Math.ceil((null==(e=n.getBoundingClientRect)?void 0:e.call(n).height)||0),i=rn.value?function(){var e,n,t,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==(n=null==u?void 0:u.getModifiedEditor)?void 0:n.call(u);if(!d||!s)return null;const c=(null==(o=null==(l=null==(t=d.getModel)?void 0:t.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(yt(d),yt(s)),p=Math.max(wt(d),wt(s));return Math.ceil(f*(m+xe)+p+0+1)}catch(u){return null}}():null,r=rn.value&&Ot(n),a=r&&Oe.value&&bn.value&&!kn.value&&!xn.value;if(r||($e.value=null),_e>0&&(_e--,null!=ze.value))return void Tt(n,t,Jt(n,ze.value,l,{allowBelowEstimatedFloor:a}));const u=rn.value?function(e){var n,t;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 n of Array.from(e.querySelectorAll(i.join(",")))){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();t.height<=0||t.bottom<=l.top||(r=Math.max(r,t.bottom-l.top))}if(r>0)return Math.ceil(r);const a=e.querySelector(".monaco-diff-editor"),u=null!=(t=null==(n=null==a?void 0:a.getBoundingClientRect)?void 0:n.call(a).height)?t:0;return u>0?Math.ceil(u+1):null}catch(l){return null}}(n):null,d=rn.value?r?u:null!=i?Math.max(null!=u?u:0,i):u:Et();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=Jt(n,e?$e.value:i?o:d,l,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:a});return r&&u<l-1&&($e.value=u,Re=Date.now()+160),void Tt(n,t,u)}if(null!=ze.value)return void Tt(n,t,Jt(n,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=Jt(n,e?$e.value:i?o:s,l,{allowBelowEstimatedFloor:a});return r&&u<l-1&&($e.value=u,Re=Date.now()+160),void Tt(n,t,u)}const c=lt();if(null!=c)return void Tt(n,t,Jt(n,c,l,{allowBelowEstimatedFloor:a}));const v=Number.parseFloat(n.style.height);!Number.isNaN(v)&&v>0?Tt(n,t,Jt(n,v,l,{allowBelowEstimatedFloor:a})):rn.value||Tt(n,t,Jt(n,l,l))}catch(n){}}())}function qt(){Rt=0,_t=0}function Ut(e=!1){var n,t,l;const o=te.value;if(!o)return;const i=rn.value?Ge():Ve();if(i&&"function"==typeof i.layout)try{const r=null==(n=o.getBoundingClientRect)?void 0:n.call(o),a=Math.ceil((null!=(t=null==r?void 0:r.width)?t: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===Rt&&u===_t)return;Rt=a,_t=u,i.layout({width:a,height:u})}else qt(),i.layout()}catch(r){}}function Vt(){if(!rn.value)return void jt();const e=te.value;if(!e)return void jt();const n=e.querySelector(".monaco-diff-editor");if(!n||n.classList.contains("side-by-side"))return void jt();const t=Array.from(n.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(n.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(t.length,l.length);for(let i=0;i<o;i++){const e=l[i],n=e.querySelector("a"),t=e.querySelector(".center > div:first-child"),o=e.querySelector(".center");if(!n||!t||!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=n.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(),n.click(),Q(()=>Gt())},s=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),n.click(),Q(()=>Gt()))};r.addEventListener("mousedown",u),r.addEventListener("click",d),r.addEventListener("keydown",s),o.appendChild(r),tn.push(()=>{r.removeEventListener("mousedown",u),r.removeEventListener("click",d),r.removeEventListener("keydown",s),r.parentElement===o&&o.removeChild(r)})}}function Gt(e=!1){null==He&&(He=Q(()=>{He=null,Q(()=>{Vt(),It(e),Ut()})}))}function Jt(e,n,t,l={}){rt(n);const o=it(),i=null!=o?Math.max(n,o):n,r=Math.min(i,t),a=!0===l.allowBelowEstimatedFloor||ft(),u=mt(r,!0===l.clearEstimatedFloor,{allowBelowEstimatedFloor:a}),d=lt();if(e.style.minHeight=null==d||a?"0px":`${Math.min(d,Math.ceil(t))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(t)}px`,rn.value)e.style.overflow="hidden";else{const n=i>t+1;e.style.overflow=n?"auto":"hidden"}return u}function Xt(e,n,t){return d(this,null,function*(){try{return void(yield qe(e,n,t))}catch(l){if(!mn(l))throw l}if(yield E(),yield pt(),!Fe&&rn.value)try{yield qe(e,n,t)}catch(l){if(!mn(l))throw l}})}function Yt(){var e,n;const t=null!=(n=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t)return t;const o=String(t).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}const Kt=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,rn.value],()=>{kt(),Q(()=>xt())},{immediate:!0}),P(()=>[rn.value,l.stream,l.loading,On.value,kn.value,xn.value,Qn.value],()=>{ot()?rt(Qn.value):tt.value=null},{immediate:!0}),P(()=>[l.node.originalCode,l.node.updatedCode,Ce.value,rn.value],e=>d(null,[e],function*([e,n,t,o]){if(!1===l.stream||!o)return;if(Ae&&!Ee.value&&te.value)try{yield cl(te.value)}catch(a){}const i=vn(String(null!=e?e:""),String(null!=n?n:"")),r=!1===l.loading;r&&Sl();try{yield Xt(i.original,i.updated,Ce.value),Ut(!0)}catch(u){return}if(r){if(Fe||!rn.value)return;pn(),Vt(),xt(),Gt()}Pe.value&&Q(()=>Wt())})),P(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(ie.value||(ie.value=V(Qe(e))),!rn.value)){if(Ae&&!Ee.value&&te.value)try{yield cl(te.value)}catch(n){}Ie(fn(e,!0===l.node.loading),Ce.value),Pe.value&&Q(()=>Wt())}}));const Qt=c(()=>{const e=ie.value;return e?J[e]||e.charAt(0).toUpperCase()+e.slice(1):J[""]||"Plain Text"});function Zt(e){var n,t;const l=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";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 el=c(()=>{var e;return function(e){const n=Zt(e);if(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const l="diff"===t[0]?t.slice(1):t;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:""))}),nl=c(()=>el.value||Qt.value),tl=c(()=>el.value?rn.value?`Diff / ${Qt.value}`:Qt.value:""),ll=c(()=>(X.value,Y(ie.value||""))),ol=c(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(l.minWidth),o=n(l.maxWidth);if(t&&(e.minWidth=t),o&&(e.maxWidth=o),dt.value&&!rn.value){const n=st.value;null!=n&&(e.minHeight=`${n}px`)}return rn.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}),il=c(()=>!1!==l.showTooltips);function rl(){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 al(e){if(Pe.value=!Pe.value,e&&il.value){const n=function(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}(e);if(n){const e=Pe.value?T("common.collapse")||"Collapse":T("common.expand")||"Expand";q(n,e,"top",!1,void 0,l.isDark)}}const n=rn.value?Ge():Ve(),t=te.value;n&&t&&(Pe.value?(sl(!0),t.style.maxHeight="none",t.style.overflow="visible",It(!0)):(sl(!1),t.style.overflow=rn.value?"hidden":"auto",It(!0)))}function ul(){var e,n,t;if(Be.value=!Be.value,Be.value){if(te.value){const t=Math.ceil((null==(n=(e=te.value).getBoundingClientRect)?void 0:n.call(e).height)||0);t>0&&(ze.value=t)}sl(!1)}else{Pe.value&&sl(!0),te.value&&null!=ze.value&&(te.value.style.height=`${ze.value}px`);const e=rn.value?Ge():Ve();try{null==(t=null==e?void 0:e.layout)||t.call(e)}catch(l){}_e=2,Q(()=>{It(!0)})}}function dl(){if(!Kt.value)return;const e=ie.value;if(w.value){const n="html"===e?"text/html":"image/svg+xml",t="html"===e?T("artifacts.htmlPreviewTitle")||"HTML Preview":T("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:n,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(Nn.value=!Nn.value)}function sl(e){var n,t;try{if(rn.value){const t=Ge();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}else{const n=Ve();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}}catch(l){}}function cl(e){if(!Ae||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 n=d(null,null,function*(){yield function(e){return d(this,null,function*(){var n;if("undefined"==typeof window)return yield e();try{const t=null==(n=window.Element)?void 0:n.prototype,l=null==t?void 0:t.addEventListener;if(!t||!l)return yield e();const o=function(){const e=window,n=e[ke];if(n)return n;const t={depth:0,original:null};return e[ke]=t,t}();0===o.depth&&(o.original=l,t.addEventListener=function(e,n,t){var i;const r=null!=(i=o.original)?i:l;return"touchstart"===e&&function(e,n){if(!e)return!1;const t=e;return!("function"!=typeof t.closest||!t.closest(".monaco-editor, .monaco-diff-editor")||n&&"object"==typeof n&&"passive"in n)}(this,t)?r.call(this,e,n,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}}(t)):r.call(this,e,n,t)}),o.depth++;try{return yield e()}finally{o.depth=Math.max(0,o.depth-1),0===o.depth&&o.original&&t.addEventListener!==o.original&&(t.addEventListener=o.original,o.original=null)}}catch(t){return yield e()}})}(()=>function(e){return d(this,null,function*(){var n,t,o;if(!Ae||Fe)return;if(Sn.value=!1,bn.value=!1,kn.value=!1,xn.value=!1,vt(),Dn.value=null,Tn.value=null,function(){const e=Ft();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"))}(),qt(),function(){const e=Zn.value;nt.value=Oe.value||null==e?null:e}(),At(),jt(),function(e){e.replaceChildren()}(e),Fe)return;if(rn.value){!function(){if(en||"undefined"==typeof window)return;en=!0;const e=e=>{var n;mn("reason"in e?e.reason:null!=(n=e.error)?n:e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener("error",e,!0),window.addEventListener("unhandledrejection",e,!0)}(),Xe();const o=vn(String(null!=(n=l.node.originalCode)?n:""),String(null!=(t=l.node.updatedCode)?t:""));je?yield je(e,o.original,o.updated,Ce.value):yield Ae(e,l.node.code,Ce.value)}else yield Ae(e,zn.value,Ce.value);if(Fe)return;const i=rn.value?Ge():Ve();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),Rn.value=l.monacoOptions.fontSize,_n.value=l.monacoOptions.fontSize;else if(!zt()){const e=gt();e&&e>0?(Rn.value=e,_n.value=e):(Rn.value=12,_n.value=12)}Nt(),Pe.value||Be.value||It(!1),yield function(){return d(this,null,function*(){null!=lt()&&(Vt(),It(!1),yield E(),yield pt(),Vt(),It(!1),yield pt(),Vt(),It(!1))})}(),Fe||(Oe.value=!0,function(){var e,n,t,l,o;if(At(),rn.value){const l=Ge(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),i=null==(n=null==l?void 0:l.getModifiedEditor)?void 0:n.call(l),a=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const l=t.call(e,()=>Gt());l&&nn.push(l)}catch(t){}};try{const e=null==(t=null==l?void 0:l.onDidUpdateDiff)?void 0:t.call(l,()=>{Gt(),Q(()=>xt())});e&&nn.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,()=>Gt());e&&nn.push(e)}catch(r){}try{const e=null==(o=null==i?void 0:i.onDidLayoutChange)?void 0:o.call(i,()=>Gt());e&&nn.push(e)}catch(r){}}(),$t(),Nt(),Vt(),xt(),Gt(),yield function(){return d(this,null,function*(){Vt(),It(!1),yield E(),yield pt(),Vt(),It(!1),yield pt(),Vt(),It(!1)})}(),yield function(){return d(this,null,function*(){var e;if(rn.value){for(let t=0;t<8;t++){if(Fe)return;const l=te.value,o=Ge();let i=!1;try{const n=null==(e=null==o?void 0:o.getLineChanges)?void 0:e.call(o);i=Array.isArray(n)}catch(n){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 pt(),Fe)return;try{pn(),Vt(),xt(),Gt()}catch(n){}return}if(t>=1&&!r)return;yield E(),yield pt()}if(!Fe)try{pn(),Vt(),xt(),Gt()}catch(n){}}})}(),Fe||(Nt(),function(){if(!rn.value)return;const e=te.value;if(!e)return;const n=e.querySelector(".monaco-diff-editor");function t(e,n,t,l){const o=e.querySelector(n);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,Ht(t,d)):u&&(d=u.getBoundingClientRect().width,Ht(t,d)),r){const e=r.getBoundingClientRect();if(e.width>=20&&e.width<=64&&Ht("--stream-monaco-line-number-width",e.width),null!=d){const n=d-(e.right-i.left);Number.isFinite(n)&&n>=0&&n<=32&&(Ht(l,n),Ht("--stream-monaco-line-number-gap-to-code",n))}}}n&&(t(n,".editor.original","--stream-monaco-original-scrollable-left","--stream-monaco-original-line-number-gap-to-code"),t(n,".editor.modified","--stream-monaco-modified-scrollable-left","--stream-monaco-modified-line-number-gap-to-code"))}(),yield E(),function(){var e;if(!rn.value||!On.value)return;const n=te.value,t=null==(e=le.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!n||!t)return;const l=Math.ceil(t.getBoundingClientRect().height);!Number.isFinite(l)||l<=0||(n.style.height=`${l}px`,n.style.minHeight=`${l}px`)}(),yield pt(),yield function(){return d(this,null,function*(){if(rn.value){if(kn.value=!0,xn.value=!1,bn.value=!0,yield E(),yield pt(),!Fe){if(Ut(!0),xn.value=!0,vt(),"undefined"==typeof window)return kn.value=!1,void(xn.value=!1);Cn=window.setTimeout(()=>{Cn=null,kn.value=!1,xn.value=!1,Q(()=>{Nt(),Vt(),Gt()})},120)}}else bn.value=!0})}()))})}(e))}).finally(()=>{Ke===n&&(Ke=null),function(){const e=Ne;r&&e&&(Ne="",E(()=>{var n,t;if(!Fe){const l=null!=(t=null==(n=le.value)?void 0:n.offsetHeight)?t:0;l>0&&r.reportHeight(e,l)}r.markSettled(e)}))}()});return Ke=n,n}P(il,e=>{e||j()}),P(()=>_n.value,(e,n)=>{const t=rn.value?Ge():Ve();t&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(t.updateOptions({fontSize:e}),Be.value||It(!0))},{flush:"post",immediate:!1});const vl=P(()=>[te.value,rn.value,l.stream,l.loading,Le.value,We.value],e=>d(null,[e],function*([e,n,t,l,o,i]){if(!e||!Ae)return;if(!i)return;if(!1===t&&!1!==l)return;const r=cl(e);if(r){try{yield r}catch(a){Oe.value=!1,bn.value=!1,Sn.value=!0}vl()}}));function fl(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function ml(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function pl(e,n){if(e===n)return!0;const t=ml(e),l=ml(n);return!!t&&t===l}function hl(){var e;const n=function(){if(void 0!==l.theme){const e=l.theme;return fl(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),t=null==(e=hn.value)?void 0:e.theme,o=null!=n?n:t;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=ml(o),a=i.map(e=>ml(e)).filter(e=>!!e);if(!r||a.includes(r))return o;const u=ml(t);return null!=t&&u&&a.includes(u)?t:i[0]}P(gn,(e,n)=>d(null,null,function*(){if(e===n)return;if(yn.value=e,!Ae||!te.value)return;if(!Ee.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!We.value)return;const t=Ke;if(t){try{yield t}catch(o){}if(Fe||!te.value)return}try{Oe.value=!1,bn.value=!1,Ee.value=!1,At(),jt(),Xe(),yield E(),yield cl(te.value)}catch(i){Oe.value=!1,bn.value=!1,Sn.value=!0}}));const gl=c(()=>(void 0!==l.theme?!fl(l.theme):pl(l.darkTheme,l.lightTheme))?function(e){var n,t;if(e&&"object"==typeof e&&(null==(n=e.colors)?void 0:n["editor.background"])){const n=Lt(e.colors["editor.background"]);if(null!=n)return n<128}const o=(null!=(t=ml(e))?t:"").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}(hl()):!!l.isDark),yl=c(()=>{var e;if(!rn.value)return gl.value?"dark":"light";const n=null==(e=hn.value)?void 0:e.diffAppearance;return"light"===n||"dark"===n?n:gl.value?"dark":"light"}),wl=c(()=>rn.value?"dark"===yl.value:gl.value);function bl(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:l.themes},hn.value||{}),{theme:hl()}),rn.value?{diffAppearance:yl.value}:{}),{onThemeChange(){$t()}})}function Sl(){const e=bl();if(!ln)return ln=e,ln;for(const n of Object.keys(ln))n in e||delete ln[n];return Object.assign(ln,e),ln}const kl=c(()=>{var e,n,t,o,i,r,u,d,s,c,v,f,m,p,h;return JSON.stringify({diffLineStyle:null!=(n=null==(e=hn.value)?void 0:e.diffLineStyle)?n:"background",diffUnchangedRegionStyle:null!=(o=null==(t=hn.value)?void 0:t.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:void 0===(null==(i=l.monacoOptions)?void 0:i.diffHideUnchangedRegions)?a({},dn):cn(l.monacoOptions.diffHideUnchangedRegions),renderSideBySide:null==(u=null==(r=hn.value)?void 0:r.renderSideBySide)||u,useInlineViewWhenSpaceIsLimited:null!=(s=null==(d=hn.value)?void 0:d.useInlineViewWhenSpaceIsLimited)&&s,enableSplitViewResizing:null==(v=null==(c=hn.value)?void 0:c.enableSplitViewResizing)||v,ignoreTrimWhitespace:null==(m=null==(f=hn.value)?void 0:f.ignoreTrimWhitespace)||m,originalEditable:null!=(h=null==(p=hn.value)?void 0:p.originalEditable)&&h})});return P(()=>[l.monacoOptions,We.value],()=>{var e,n;if(Sl(),!Ae||!We.value)return;const t=rn.value?Ge():Ve(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(_n.value)?_n.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(n=null==t?void 0:t.updateOptions)||n.call(t,{fontSize:o})),It(!1)},{deep:!0}),P(()=>[hl(),yl.value,Le.value,Ee.value,We.value],([e],n)=>{Le.value&&Ee.value&&We.value&&function(e={}){if(e.appearanceOnly)return;Sl();const n=hl(),t=()=>{rn.value&&pn(),Q(()=>{$t(),Gt()})};n?function(e,n){const t=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 t=fe.get(e);if(t)return t;try{const n=JSON.stringify(e);if(n)return fe.set(e,n),n}catch(n){}const l="__theme_"+ ++me;return fe.set(e,l),l}return String(e)}(n);return t?(ve=e,ae||ce!==t?ae?(se===t||ue===t||(de=n,se=t),ae):(de=n,se=t,ae=d(null,null,function*(){for(;se&&null!=de;){const t=de,l=se;if(de=null,se=null,ce!==l)try{ue=l,yield(null!=ve?ve:e)(t),ce=l}catch(n){}}}).finally(()=>{ae=null,ue=null}),ae):Promise.resolve()):Promise.resolve()}(Ze,n).then(t).catch(e=>{}):t()}({appearanceOnly:null!=n&&pl(e,n[0])})},{flush:"post"}),P(()=>[kl.value,Le.value,We.value],(e,n)=>d(null,[e,n],function*([e,n,t],[o]){if(Sl(),!n||!t)return;if(!Ae||!te.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||!te.value)return}try{Oe.value=!1,bn.value=!1,Ee.value=!1,At(),jt(),Xe(),yield E(),yield cl(te.value)}catch(a){Oe.value=!1,bn.value=!1,Sn.value=!0}}),{flush:"post"}),P(()=>[l.loading,We.value],(e,n)=>d(null,[e,n],function*([e,n],t){if(!n)return;const o=null==t?void 0:t[0];if(!1===o&&!1!==e&&rn.value&&Ee.value&&(yield E(),Q(()=>{d(null,null,function*(){const e=Ke;if(e)try{yield e}catch(n){}!Fe&&rn.value&&!1!==l.loading&&(Sl(),pn(),Gt())})})),e)return;const i=void 0!==o&&!1!==o;yield E(),Q(()=>{d(null,null,function*(){var e,n;try{if(i&&Ee.value)if(rn.value&&te.value){const o=Ke;if(o)try{yield o}catch(t){}Sl();const i=vn(String(null!=(e=l.node.originalCode)?e:""),String(null!=(n=l.node.updatedCode)?n:""));if(yield Xt(i.original,i.updated,Ce.value),Fe||!rn.value)return;pn(),Ut(!0),Vt(),xt(),Gt()}else Ie(zn.value,Ce.value);It(!1)}catch(o){}})})}),{immediate:!0,flush:"post"}),f(()=>{vt(),At(),jt(),Je()}),(n,t)=>wn.value?(m(),p(S(I),{key:0,node:$n.value,loading:l.loading},null,8,["node","loading"])):(m(),O("div",{key:1,ref_key:"container",ref:le,style:L(ol.value),class:y(["code-block-container rounded-lg border",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":wl.value,"is-diff":rn.value,"is-plain-text":Me.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":bn.value&&!wn.value?"true":"false","data-markstream-pending":Hn.value?"true":void 0},[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":Kt.value,"code-font-size":_n.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":Rn.value,"font-baseline-ready":Wn.value,"diff-stats":rn.value?an.value:null,"diff-stats-aria-label":un.value,onToggleCollapse:ul,onDecreaseFont:Pt,onResetFont:Bt,onIncreaseFont:Mt,onCopy:rl,onToggleExpand:al,onPreview:dl},H({"header-left":N(()=>[_(n.$slots,"header-left",{},()=>[g("div",he,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:ll.value},null,8,ge),g("div",ye,[g("div",we,b(nl.value),1),tl.value?(m(),O("div",be,b(tl.value),1)):$("",!0)])])],!0)]),loading:N(()=>[_(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:N(()=>[z(g("div",Se,[g("div",{ref_key:"codeEditor",ref:te,class:y(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":Fn.value}]]),style:L(ct.value)},null,6),Ln.value?(m(),p(S(I),{key:0,class:y(["code-pre-fallback",{"is-wrap":Mn.value,"is-fading-out":xn.value}]),style:L(ut.value),node:$n.value,"show-line-numbers":!0,"diff-inline":Pn.value},null,8,["class","style","node","diff-inline"])):$("",!0)],512),[[R,!(Be.value||!e.stream&&e.loading)]]),Nn.value&&!w.value&&Kt.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":()=>Nn.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):$("",!0)]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:N(()=>[_(n.$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-b5776a3f"]]);export{Ce as default};
1
+ var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(n,t,l)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l,a=(e,n)=>{for(var t in n||(n={}))o.call(n,t)&&r(e,t,n[t]);if(l)for(var t of l(n))i.call(n,t)&&r(e,t,n[t]);return e},u=(e,l)=>n(e,t(l)),d=(e,n,t)=>new Promise((l,o)=>{var i=e=>{try{a(t.next(e))}catch(n){o(n)}},r=e=>{try{a(t.throw(e))}catch(n){o(n)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);a((t=t.apply(e,n)).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 g,normalizeClass as y,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 D}from"vue";import{ap as T,y as W,ah as _,ar as A,a9 as j,z as I,am as q}from"./exports.js";import{M as U,e as V,n 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 ne}from"./monaco.js";const te={class:"html-preview-frame__header"},le={class:"html-preview-frame__title"},oe={class:"html-preview-frame__label"},ie=["sandbox","srcdoc"],re=/* @__PURE__ */W(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const n=e,t=void 0!==import.meta&&Boolean(!1);let l=null;const{t:o}=T(),i=c(()=>{const e=n.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${n.isDark?"#020617":"#ffffff"};\n color: ${n.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=n.htmlPreviewSandbox,o=n.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!t||"undefined"==typeof console||l===e)return;const n=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);n.has("allow-scripts")&&n.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 t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",a)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",a)}),(e,t)=>(m(),p(h,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:n.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:t[2]||(t[2]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})},[g("div",{class:"html-preview-frame",onClick:t[1]||(t[1]=w(()=>{},["stop"]))},[g("div",te,[g("div",le,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",oe,b(n.title||S(o)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:t[0]||(t[0]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})}," × ")]),g("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","data-markstream-pending"],he={class:"code-header-main"},ge=["innerHTML"],ye={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__ */W(/* @__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:{},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:n}){var t;const l=e,o=n,i=k(),r=x(U,null),s=x("markstreamHostScrollManaged",null),v=c(()=>_(l,i));const h=C(),w=c(()=>{const e=null==h?void 0:h.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:W}=T(),te=M(null),le=M(null),oe=M(!1),ie=M(nl(l.node.language,l.node.code,el())),Ce=c(()=>V(ie.value)),Me=c(()=>"plaintext"===Ce.value),Pe=M(!1),Be=M(!1),Ee=M(!1),Oe=M(!1),Le=M(!1),Fe=M(!1);let He=!1,Ne=null,ze="";const $e=M(null),Re=M(null);let De=0,Te=0;const We=A(),_e=M(null),Ae=M("undefined"==typeof window);"undefined"!=typeof window&&P(()=>le.value,e=>{var n;if(null==(n=_e.value)||n.destroy(),_e.value=null,!e)return void(Ae.value=!1);const t=We(e,{rootMargin:"400px"});_e.value=t,Ae.value=t.isVisible.value,t.whenVisible.then(()=>{Ae.value=!0})},{immediate:!0}),B(()=>{var e;He=!0,function(){const e=ze;r&&e&&(ze="",r.markSettled(e))}(),null==(e=_e.value)||e.destroy(),_e.value=null});let je=null,Ie=null,qe=()=>{},Ue=()=>{},Ve=()=>null,Ge=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Je=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Xe=()=>{},Ye=()=>{},Ke=()=>{},Qe=null,Ze=null,en=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},nn=()=>d(null,null,function*(){}),tn=!1;const ln=[],on=[];let rn=null;function an(e){var n;return"diff"===(null!=(n=String(null!=e?e:"").trim().split(/\s+/,1)[0])?n:"")}const un=c(()=>{var e;return!0===l.node.diff||an(l.node.language)||an(ol(String(null!=(e=l.node.raw)?e:"")))}),dn=M({removed:0,added:0}),sn=c(()=>`-${dn.value.removed} +${dn.value.added}`),cn=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5}),vn=Object.freeze(u(a({},cn),{enabled:!1,revealLineCount:0}));function fn(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return u(a(a({},cn),t),{enabled:null==(n=t.enabled)||n})}return a({},cn)}function mn(e,n){return{original:pn(e,!1),updated:pn(n,!1)}}function pn(e,n){const t=String(null!=e?e:"");return n?t:t.replace(/\r\n$|\n$|\r$/,"")}function hn(e){var n;return String(null!=(n=null==e?void 0:e.message)?n:e).includes("no diff result available")}function gn(){try{const e=Ke();e&&"function"==typeof e.catch&&e.catch(e=>{hn(e)})}catch(e){hn(e)}}const yn=c(()=>{var e,n,t,o;const i=l.monacoOptions?a({},l.monacoOptions):{};if(!un.value)return i;const r=void 0===i.diffHideUnchangedRegions?a({},cn):fn(i.diffHideUnchangedRegions),d=void 0===i.hideUnchangedRegions?void 0:fn(i.hideUnchangedRegions),s=!1!==l.stream&&!1!==l.loading,c=s?a({},vn):r,v=s?a({},vn):d,f=function(e){return void 0!==e.diffWordWrap?e.diffWordWrap:"off"}(i),m=a({},null!=(e=i.experimental)?e:{}),p=null!=(n=i.diffUnchangedRegionStyle)?n:"line-info",h={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,diffWordWrap:f,renderSideBySide:null==(t=i.renderSideBySide)||t,diffHideUnchangedRegions:c,useInlineViewWhenSpaceIsLimited:null!=(o=i.useInlineViewWhenSpaceIsLimited)&&o,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:p,diffHunkActionsOnHover:!1,experimental:m};return u(a(u(a(a({},h),i),{experimental:m}),void 0===v?{}:{hideUnchangedRegions:v}),{diffHideUnchangedRegions:c,diffWordWrap:f})}),wn=c(()=>un.value?"diff":"single"),bn=M(wn.value),Sn=M(!1),kn=M(!1),xn=M(!1),Cn=M(!1),Mn=M(!1);let Pn=null;const Bn=c(()=>{var e,n,t;if(un.value){const t=null==(e=yn.value)?void 0:e.diffWordWrap;if("inherit"===t){const e=null==(n=l.monacoOptions)?void 0:n.wordWrap;return null==e||"off"!==String(e)}return"on"===t}const o=null==(t=l.monacoOptions)?void 0:t.wordWrap;return null==o||"off"!==String(o)}),En=c(()=>{var e,n,t,l,o,i;if(!un.value)return!1;if(!1===(null==(e=yn.value)?void 0:e.renderSideBySide))return!0;if(!0!==(null==(n=yn.value)?void 0:n.useInlineViewWhenSpaceIsLimited))return!1;const r=null==(t=yn.value)?void 0:t.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 On(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 Ln=c(()=>On(le.value)),Fn=c(()=>!Sn.value&&(!!xn.value||(un.value||Ln.value||!K())&&!kn.value)),Hn=c(()=>Fn.value||Cn.value),Nn=c(()=>Fn.value&&!Cn.value),zn=c(()=>!Sn.value&&!xn.value&&(Fn.value||Cn.value||Mn.value)),$n=M(!1),Rn=c(()=>pn(l.node.code,!0===l.node.loading)),Dn=c(()=>un.value?!0===l.node.diff?l.node:u(a({},l.node),{diff:!0}):Rn.value===l.node.code?l.node:u(a({},l.node),{code:Rn.value}));"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield ne();if(He)return;if(!e)return void(Sn.value=!0);const n=e.useMonaco,t=e.detectLanguage;if("function"==typeof t&&(en=t),"function"==typeof n){const e=Sl();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");rn=Ml();const t=n(rn);je=t.createEditor||je,Ie=t.createDiffEditor||Ie,qe=t.updateCode||qe,Ue=t.updateDiff||Ue,Ve=t.getEditor||Ve,Ge=t.getEditorView||Ge,Je=t.getDiffEditorView||Je,Xe=t.cleanupEditor||Xe,Ye=t.safeClean||t.cleanupEditor||Ye,Ke=t.refreshDiffPresentation||Ke,nn=t.setTheme||nn,Fe.value=!0,!He&&te.value&&(yield hl(te.value))}}catch(e){if(He)return;Sn.value=!0}});const Tn=M("number"==typeof(null==(t=l.monacoOptions)?void 0:t.fontSize)?l.monacoOptions.fontSize:Number.NaN),Wn=M(Tn.value),_n=M(null),An=M(null),jn=c(()=>{const e=Tn.value,n=Wn.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),In=c(()=>{var e;const n=_n.value;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const o=Wn.value;return"number"==typeof o&&Number.isFinite(o)&&o>0?o:12}),qn=c(()=>{var e;const n=An.value;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:12===In.value?18:Math.max(12,Math.round(1.5*In.value))}),Un=c(()=>qn.value);function Vn(e){const n=String(null!=e?e:"");return n?Math.max(1,n.split(/\r\n|\n|\r/).length):1}function Gn(e){return e.startsWith("-")&&!e.startsWith("---")}function Jn(e){return e.startsWith("+")&&!e.startsWith("+++")}const Xn=c(()=>En.value?function(){var e,n,t;const o=String(null!=(e=l.node.code)?e:"").split(/\r\n|\n|\r/);if(o.some(e=>Gn(e)||Jn(e)))return Math.max(1,o.length);const i=String(null!=(n=l.node.originalCode)?n:"").split(/\r\n|\n|\r/),r=String(null!=(t=l.node.updatedCode)?t:"").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 n=String(null!=(e=l.node.code)?e:"").split(/\r\n|\n|\r/);if(!n.some(e=>Gn(e)||Jn(e))&&(null!=l.node.originalCode||null!=l.node.updatedCode))return Math.max(Vn(l.node.originalCode),Vn(l.node.updatedCode));let t=0,o=0;for(const l of n)Gn(l)?t++:(Jn(l)||t++,o++);return Math.max(1,t,o)}()),Yn=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:4}),Kn=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.padding;return{top:"number"==typeof(null==n?void 0:n.top)&&Number.isFinite(n.top)&&n.top>0?n.top:0,bottom:"number"==typeof(null==n?void 0:n.bottom)&&Number.isFinite(n.bottom)&&n.bottom>0?n.bottom:0}}),Qn=c(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Zn(e){if(null==e)return null;const n=Math.ceil(e);return!Number.isFinite(n)||n<=0?null:Math.min(n,Math.ceil(Qt()))}const et=c(()=>un.value?Math.ceil(Xn.value*Un.value):null!=Qn.value?null:Math.ceil((e=>{const n=String(null!=e?e:"");return n?Math.max(1,n.split(/\r\n|\n|\r/).length):1})(Rn.value)*(qn.value+xe)+1)),nt=c(()=>{if(un.value){const e=et.value,n=at();return Zn(null!=n&&null!=e?Math.max(e,n):null!=n?n:e)}const e=Qn.value;return Zn(null!=e?e:et.value)}),tt=c(()=>{const e=l.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),lt=M(null),ot=M(null);function it(){const e=lt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function rt(){return un.value&&!1!==l.stream&&(!1!==l.loading||Fn.value||Cn.value||Mn.value)}function at(){if(!rt())return null;const e=ot.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function ut(e){if(!rt()||null==e)return;const n=Math.min(Math.ceil(e),Math.ceil(Qt()));if(!Number.isFinite(n)||n<=0)return;const t=at();ot.value=null==t?n:Math.max(t,n)}const dt=c(()=>{const e=it();return null!=e?e:Fn.value||!kn.value?nt.value:null}),st=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontFamily,t=Zn(Qn.value),o=Zn(et.value),i=a(a({fontSize:`${In.value}px`,lineHeight:`${Un.value}px`,tabSize:Yn.value,boxSizing:"border-box",maxHeight:`${Qt()}px`,overflow:"auto",paddingTop:`${Kn.value.top}px`,paddingBottom:`${Kn.value.bottom}px`},un.value?function(e){if(null==e)return{};const n=Math.ceil(e),t=Math.ceil(Qt()),l=Math.min(n,t);return n>=t?{height:`${l}px`,minHeight:`${l}px`}:{minHeight:`${n}px`}}(nt.value):null!=t?{height:`${t}px`,minHeight:`${t}px`}:null!=o?{minHeight:`${o}px`}:{}),"string"==typeof n&&n.trim()?{"--markstream-code-font-family":n.trim()}:{});return i["--markstream-pre-line-number-top"]=`${Kn.value.top}px`,i["--markstream-code-padding-left"]="62px",i["--markstream-pre-line-number-width"]="36px",i["--markstream-pre-line-number-gap"]="0px",un.value&&(i["--markstream-pre-diff-line-height"]=`${Un.value}px`),i}),ct=c(()=>null!=dt.value&&(!kn.value||null!=it())),vt=c(()=>{const e=dt.value;if(null==e)return null;if(un.value)return Math.ceil(e);const n=tt.value,t=Qn.value;if(null==n||null==t)return Math.ceil(e);const l=Math.max(0,Math.ceil(n)-Math.ceil(t));return Math.ceil(e+l)}),ft=c(()=>{if(un.value&&Fn.value)return;const e=dt.value;return ct.value&&null!=e?{minHeight:`${e}px`}:void 0});function mt(){null!=Pn&&"undefined"!=typeof window&&window.clearTimeout(Pn),Pn=null}function pt(){if(!un.value)return!1;if(!Le.value||!kn.value)return!1;if(Cn.value||Mn.value)return!1;const e=te.value;return!!e&&Ft(e)}function ht(e,n=!1,t={}){const l=Math.ceil(e),o=it();if(null==o)return l;const i=!0===t.allowBelowEstimatedFloor||pt();return l>=o||i?((n||i)&&Le.value&&(lt.value=null),l):o}function gt(){return new Promise(e=>{Q(()=>e())})}function yt(){try{const e=te.value;if(!e)return null;const n=e.querySelector(".view-lines .view-line");if(n){const e=Math.ceil(n.getBoundingClientRect().height);if(e>0)return e}}catch(e){}return null}function wt(){var e,n,t,l,o;try{const i=un.value?null!=(t=null==(n=null==(e=Je())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t:Je():Ge(),r=Ve(),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),n=null==e?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n}}catch(i){}try{const e=te.value;if(e){const n=e.querySelector(".view-lines .view-line");if(n)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(n).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(i){}}}catch(i){}return null}function bt(e){var n,t;try{const l=Ve(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.lineHeight;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof n&&n>0)return n}}catch(i){}const l=yt();if(l&&l>0)return l;const o=Number.isFinite(Wn.value)&&Wn.value>0?Wn.value:14;return Math.max(12,Math.round(1.35*o))}function St(e){var n,t,l;try{const l=Ve(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.padding;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o),l="number"==typeof(null==n?void 0:n.top)?n.top:0,i="number"==typeof(null==n?void 0:n.bottom)?n.bottom:0;if(l>0||i>0)return l+i}}catch(a){}const o=null==(l=yn.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:un.value?24:0}function kt(e,n){return"number"!=typeof e||"number"!=typeof n||e<1||n<e?0:n-e+1}function xt(e){if(!e)return[];const n=e.split(/\r?\n/);return 1===n.length&&""===n[0]?[]:n}function Ct(){var e,n;un.value?dn.value=function(e,n){const t=xt(e),l=xt(n);let o=0,i=t.length-1,r=l.length-1;for(;o<=i&&o<=r&&t[o]===l[o];)o++;for(;i>=o&&r>=o&&t[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!=(n=l.node.updatedCode)?n:"")):dn.value={removed:0,added:0}}function Mt(){var e;if(un.value)try{const n=Je(),t=null==(e=null==n?void 0:n.getLineChanges)?void 0:e.call(n);if(!Array.isArray(t))return void Ct();let l=0,o=0;for(const e of t)l+=kt(e.originalStartLineNumber,e.originalEndLineNumber),o+=kt(e.modifiedStartLineNumber,e.modifiedEndLineNumber);dn.value={removed:l,added:o}}catch(n){Ct()}else dn.value={removed:0,added:0}}function Pt(){var e;if(Number.isFinite(Wn.value)&&Wn.value>0&&Number.isFinite(Tn.value))return Wn.value;const n=wt();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(Tn.value=l.monacoOptions.fontSize,Wn.value=l.monacoOptions.fontSize,Wn.value):n&&n>0?(Tn.value=n,Wn.value=n,n):(Tn.value=12,Wn.value=12,12)}function Bt(){const e=Pt(),n=Math.min(36,e+1);Wn.value=n}function Et(){const e=Pt(),n=Math.max(10,e-1);Wn.value=n}function Ot(){Pt(),Number.isFinite(Tn.value)&&(Wn.value=Tn.value)}function Lt(){var e,n,t,l,o,i,r,a,u,d,s,c,v,f;try{const m=un.value?Je():null,p=un.value?m:Ge();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==(n=m.getModifiedEditor)?void 0:n.call(m);null==(t=null==v?void 0:v.layout)||t.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,g=Math.max(p,h);if(g>0)return Math.ceil(g+1);const y=(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(y,w),S=Math.max(bt(v),bt(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 g=1;h&&"function"==typeof h.getLineCount&&(g=h.getLineCount());const y=bt(p);return Math.ceil(g*(y+xe)+0+1)}catch(m){return null}}function Ft(e){if("undefined"==typeof window)return!1;const n=e.getBoundingClientRect();if(n.width<=0||n.height<=0)return!1;const t=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const l of Array.from(t)){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 t=l.getBoundingClientRect();if(!(t.width<=0||t.height<=0||t.bottom<=n.top||t.top>=n.bottom))return!0}return!1}function Ht(e){var n;const t=String(null!=e?e:"").trim(),l=null==(n=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:n[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=t.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 Nt(){var e;const n=null==(e=te.value)?void 0:e.parentElement;return n instanceof HTMLElement?n:null}function zt(e,n){var t;null==n||!Number.isFinite(n)||n<=0||null==(t=Nt())||t.style.setProperty(e,`${n}px`)}function $t(){var e,n,t;if(Rt())return;const l=wt();l&&l>0&&(_n.value=l,Wn.value=l,Tn.value=l);try{const l=bt(un.value?null!=(t=null==(n=null==(e=Je())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t:Je():Ge());l&&l>0&&(An.value=l)}catch(o){}try{const e=yt();e&&e>0&&(An.value=e)}catch(o){}}function Rt(){return un.value&&Hn.value}function Dt(){var e,n,t,l,o,i,r,a;const u=te.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 g=String(null!=(e=null==m?void 0:m.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),y=String(null!=(n=null==m?void 0:m.getPropertyValue("--vscode-editor-background"))?n:"").trim(),w=String(null!=(l=null!=(t=null==m?void 0:m.getPropertyValue("--vscode-editor-selectionBackground"))?t:null==m?void 0:m.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),b=g||String(null!=(i=null!=(o=null==h?void 0:h.color)?o:null==m?void 0:m.color)?i:"").trim(),S=y||String(null!=(a=null!=(r=null==p?void 0:p.backgroundColor)?r:null==m?void 0:m.backgroundColor)?a:"").trim();return un.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,n,t){if(!Me.value)return!1;const l=Ht(e),o=Ht(n);return t?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 Tt=0,Wt=0;const _t=/auto|scroll|overlay/i;function At(e,n,t){var l;if("undefined"==typeof window)return;if(un.value)return;if(function(e){return Ln.value||On(e)}(e))return;const o=Math.ceil(n),i=Math.ceil(t)-o;if(Math.abs(i)<=1)return;const r=function(e){var n,t;if("undefined"==typeof window)return null;const l=null!=(n=null==e?void 0:e.ownerDocument)?n:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(_t.test(n)||_t.test(t))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=te.value;if(!e)return;const n=e.getBoundingClientRect().height,t=Lt();if(null!=t&&t>0){const l=ht(t,!0),o=it();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,n,l)}const l=it();null!=l&&(e.style.minHeight=`${l}px`,e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",At(e,n,l))}catch(e){}}function It(){for(var e,n;ln.length>0;)try{null==(n=null==(e=ln.pop())?void 0:e.dispose)||n.call(e)}catch(t){}null!=Ne&&(Z(Ne),Ne=null)}function qt(){for(var e;on.length>0;)try{null==(e=on.pop())||e()}catch(n){}}function Ut(e=!1){Be.value||(Pe.value?jt():function(){var e;try{const n=te.value;if(!n)return;const t=n.getBoundingClientRect().height,l=Qt(),o=Math.ceil((null==(e=n.getBoundingClientRect)?void 0:e.call(n).height)||0),i=un.value?function(){var e,n,t,l,o,i,r,a;try{const u=Je(),d=null==(e=null==u?void 0:u.getOriginalEditor)?void 0:e.call(u),s=null==(n=null==u?void 0:u.getModifiedEditor)?void 0:n.call(u);if(!d||!s)return null;const c=(null==(o=null==(l=null==(t=d.getModel)?void 0:t.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(bt(d),bt(s)),p=Math.max(St(d),St(s));return Math.ceil(f*(m+xe)+p+0+1)}catch(u){return null}}():null,r=un.value&&Ft(n),a=r&&Le.value&&kn.value&&!Cn.value&&!Mn.value;if(r||(Re.value=null),Te>0&&(Te--,null!=$e.value))return void At(n,t,Yt(n,$e.value,l,{allowBelowEstimatedFloor:a}));const u=un.value?function(e){var n,t;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 n of Array.from(e.querySelectorAll(i.join(",")))){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();t.height<=0||t.bottom<=l.top||(r=Math.max(r,t.bottom-l.top))}if(r>0)return Math.ceil(r);const a=e.querySelector(".monaco-diff-editor"),u=null!=(t=null==(n=null==a?void 0:a.getBoundingClientRect)?void 0:n.call(a).height)?t:0;return u>0?Math.ceil(u+1):null}catch(l){return null}}(n):null,d=un.value?r?u:null!=i?Math.max(null!=u?u:0,i):u:Lt();if(null!=d&&d>0){const e=null!=Re.value&&Date.now()<De&&d>=l-1,i=r&&o>0&&o<l-1&&d>=l-1,u=Yt(n,e?Re.value:i?o:d,l,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:a});return r&&u<l-1&&(Re.value=u,De=Date.now()+160),void At(n,t,u)}if(null!=$e.value)return void At(n,t,Yt(n,$e.value,l,{allowBelowEstimatedFloor:a}));const s=r?o:Math.max(o,null!=i&&i>0?i:0);if(s>0){const e=null!=Re.value&&Date.now()<De&&s>=l-1,i=r&&o>0&&o<l-1&&s>=l-1,u=Yt(n,e?Re.value:i?o:s,l,{allowBelowEstimatedFloor:a});return r&&u<l-1&&(Re.value=u,De=Date.now()+160),void At(n,t,u)}const c=it();if(null!=c)return void At(n,t,Yt(n,c,l,{allowBelowEstimatedFloor:a}));const v=Number.parseFloat(n.style.height);!Number.isNaN(v)&&v>0?At(n,t,Yt(n,v,l,{allowBelowEstimatedFloor:a})):un.value||At(n,t,Yt(n,l,l))}catch(n){}}())}function Vt(){Tt=0,Wt=0}function Gt(e=!1){var n,t,l;const o=te.value;if(!o)return;const i=un.value?Je():Ge();if(i&&"function"==typeof i.layout)try{const r=null==(n=o.getBoundingClientRect)?void 0:n.call(o),a=Math.ceil((null!=(t=null==r?void 0:r.width)?t: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===Tt&&u===Wt)return;Tt=a,Wt=u,i.layout({width:a,height:u})}else Vt(),i.layout()}catch(r){}}function Jt(){if(!un.value)return void qt();const e=te.value;if(!e)return void qt();const n=e.querySelector(".monaco-diff-editor");if(!n||n.classList.contains("side-by-side"))return void qt();const t=Array.from(n.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(n.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(t.length,l.length);for(let i=0;i<o;i++){const e=l[i],n=e.querySelector("a"),t=e.querySelector(".center > div:first-child"),o=e.querySelector(".center");if(!n||!t||!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=n.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(),n.click(),Q(()=>Xt())},s=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),n.click(),Q(()=>Xt()))};r.addEventListener("mousedown",u),r.addEventListener("click",d),r.addEventListener("keydown",s),o.appendChild(r),on.push(()=>{r.removeEventListener("mousedown",u),r.removeEventListener("click",d),r.removeEventListener("keydown",s),r.parentElement===o&&o.removeChild(r)})}}function Xt(e=!1){null==Ne&&(Ne=Q(()=>{Ne=null,Q(()=>{Jt(),Ut(e),Gt()})}))}function Yt(e,n,t,l={}){ut(n);const o=at(),i=null!=o?Math.max(n,o):n,r=Math.min(i,t),a=!0===l.allowBelowEstimatedFloor||pt(),u=ht(r,!0===l.clearEstimatedFloor,{allowBelowEstimatedFloor:a}),d=it();if(e.style.minHeight=null==d||a?"0px":`${Math.min(d,Math.ceil(t))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(t)}px`,un.value)e.style.overflow="hidden";else{const n=i>t+1;e.style.overflow=n?"auto":"hidden"}return u}function Kt(e,n,t){return d(this,null,function*(){try{return void(yield Ue(e,n,t))}catch(l){if(!hn(l))throw l}if(yield E(),yield gt(),!He&&un.value)try{yield Ue(e,n,t)}catch(l){if(!hn(l))throw l}})}function Qt(){var e,n;const t=null!=(n=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t)return t;const o=String(t).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}const Zt=c(()=>l.isShowPreview&&("html"===ie.value||"svg"===ie.value));function el(){return"boolean"==typeof l.node.loading?l.node.loading:!0===l.loading}function nl(e,n,t){return t&&!String(null!=n?n:"")?"plain":G(String(null!=e?e:""))}function tl(){var e,n,t,o;return!(!el()||(un.value?String(null!=(e=l.node.originalCode)?e:"")||String(null!=(n=l.node.updatedCode)?n:"")||String(null!=(t=l.node.code)?t:""):String(null!=(o=l.node.code)?o:"")))}P(()=>[l.node.language,l.node.code,l.node.loading,l.loading],([e,n,t,l])=>{ie.value=nl(e,n,"boolean"==typeof t?t:!0===l)}),P(()=>[l.node.originalCode,l.node.updatedCode,un.value],()=>{Ct(),Q(()=>Mt())},{immediate:!0}),P(()=>[un.value,l.stream,l.loading,Fn.value,Cn.value,Mn.value,et.value],()=>{rt()?ut(et.value):ot.value=null},{immediate:!0}),P(()=>[l.node.originalCode,l.node.updatedCode,Ce.value,un.value],e=>d(null,[e],function*([,,,e]){var n,t;if(!1===l.stream||!e)return;if(je&&!Ee.value&&te.value)try{yield hl(te.value)}catch(a){}const o=Ze;if(o&&!Oe.value){try{yield o}catch(a){}if(He||!un.value)return}const i=mn(String(null!=(n=l.node.originalCode)?n:""),String(null!=(t=l.node.updatedCode)?t:"")),r=!1===l.loading;r&&Pl();try{yield Kt(i.original,i.updated,Ce.value),Gt(!0)}catch(u){return}if(r){if(He||!un.value)return;gn(),Jt(),Mt(),Xt()}Pe.value&&Q(()=>jt())})),P(()=>l.node.code,e=>d(null,null,function*(){if(!1===l.stream)return;if(ie.value||(ie.value=G(en(e))),un.value)return;const n=Ze;if(n&&!Oe.value){try{yield n}catch(t){}if(He||un.value)return}if(je&&!Ee.value&&te.value)try{yield hl(te.value)}catch(t){}qe(pn(l.node.code,!0===l.node.loading),Ce.value),Pe.value&&Q(()=>jt())}));const ll=c(()=>{const e=ie.value;return e?J[e]||e.charAt(0).toUpperCase()+e.slice(1):J[""]||"Plain Text"});function ol(e){var n,t;const l=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";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 il=c(()=>{var e;return function(e){const n=ol(e);if(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const l="diff"===t[0]?t.slice(1):t;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:""))}),rl=c(()=>il.value||ll.value),al=c(()=>il.value?un.value?`Diff / ${ll.value}`:ll.value:""),ul=c(()=>(X.value,Y(ie.value||""))),dl=c(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(l.minWidth),o=n(l.maxWidth);if(t&&(e.minWidth=t),o&&(e.maxWidth=o),ct.value&&!un.value){const n=vt.value;null!=n&&(e.minHeight=`${n}px`)}return un.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}),sl=c(()=>!1!==l.showTooltips);function cl(){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 vl(e){if(Pe.value=!Pe.value,e&&sl.value){const n=function(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}(e);if(n){const e=Pe.value?W("common.collapse")||"Collapse":W("common.expand")||"Expand";q(n,e,"top",!1,void 0,l.isDark)}}const n=un.value?Je():Ge(),t=te.value;n&&t&&(Pe.value?(pl(!0),t.style.maxHeight="none",t.style.overflow="visible",Ut(!0)):(pl(!1),t.style.overflow=un.value?"hidden":"auto",Ut(!0)))}function fl(){var e,n,t;if(Be.value=!Be.value,Be.value){if(te.value){const t=Math.ceil((null==(n=(e=te.value).getBoundingClientRect)?void 0:n.call(e).height)||0);t>0&&($e.value=t)}pl(!1)}else{Pe.value&&pl(!0),te.value&&null!=$e.value&&(te.value.style.height=`${$e.value}px`);const e=un.value?Je():Ge();try{null==(t=null==e?void 0:e.layout)||t.call(e)}catch(l){}Te=2,Q(()=>{Ut(!0)})}}function ml(){if(!Zt.value)return;const e=ie.value;if(w.value){const n="html"===e?"text/html":"image/svg+xml",t="html"===e?W("artifacts.htmlPreviewTitle")||"HTML Preview":W("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:n,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&($n.value=!$n.value)}function pl(e){var n,t;try{if(un.value){const t=Je();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}else{const n=Ge();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}}catch(l){}}function hl(e){if(!je||He)return null;if(tl())return null;if(Qe)return Qe;if(Ee.value&&Le.value)return Promise.resolve();Ee.value=!0,function(){const e=v.value;r&&e&&ze!==e&&(ze&&r.markSettled(ze),ze=e,r.markPending(e))}();const n=d(null,null,function*(){yield function(e){return d(this,null,function*(){var n;if("undefined"==typeof window)return yield e();try{const t=null==(n=window.Element)?void 0:n.prototype,l=null==t?void 0:t.addEventListener;if(!t||!l)return yield e();const o=function(){const e=window,n=e[ke];if(n)return n;const t={depth:0,original:null};return e[ke]=t,t}();0===o.depth&&(o.original=l,t.addEventListener=function(e,n,t){var i;const r=null!=(i=o.original)?i:l;return"touchstart"===e&&function(e,n){if(!e)return!1;const t=e;return!("function"!=typeof t.closest||!t.closest(".monaco-editor, .monaco-diff-editor")||n&&"object"==typeof n&&"passive"in n)}(this,t)?r.call(this,e,n,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}}(t)):r.call(this,e,n,t)}),o.depth++;try{return yield e()}finally{o.depth=Math.max(0,o.depth-1),0===o.depth&&o.original&&t.addEventListener!==o.original&&(t.addEventListener=o.original,o.original=null)}}catch(t){return yield e()}})}(()=>function(e){return d(this,null,function*(){var n;if(!je||He)return;if(xn.value=!1,Oe.value=!1,kn.value=!1,Cn.value=!1,Mn.value=!1,mt(),_n.value=null,An.value=null,function(){const e=Nt();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"))}(),Vt(),function(){const e=nt.value;lt.value=Le.value||null==e?null:e}(),It(),qt(),function(e){e.replaceChildren()}(e),He)return;const t=d(null,null,function*(){var n,t;if(un.value){!function(){if(tn||"undefined"==typeof window)return;tn=!0;const e=e=>{var n;hn("reason"in e?e.reason:null!=(n=e.error)?n:e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener("error",e,!0),window.addEventListener("unhandledrejection",e,!0)}(),Ye();const o=mn(String(null!=(n=l.node.originalCode)?n:""),String(null!=(t=l.node.updatedCode)?t:""));Ie?yield Ie(e,o.original,o.updated,Ce.value):yield je(e,l.node.code,Ce.value)}else yield je(e,Rn.value,Ce.value);Oe.value=!0}),o=t.finally(()=>{Ze===o&&(Ze=null)});if(Ze=o,yield o,He)return;const i=un.value?Je():Ge();if("number"==typeof(null==(n=l.monacoOptions)?void 0:n.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),Tn.value=l.monacoOptions.fontSize,Wn.value=l.monacoOptions.fontSize;else if(!Rt()){const e=wt();e&&e>0?(Tn.value=e,Wn.value=e):(Tn.value=12,Wn.value=12)}$t(),Pe.value||Be.value||Ut(!1),yield function(){return d(this,null,function*(){null!=it()&&(Jt(),Ut(!1),yield E(),yield gt(),Jt(),Ut(!1),yield gt(),Jt(),Ut(!1))})}(),He||(Le.value=!0,function(){var e,n,t,l,o;if(It(),un.value){const l=Je(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),i=null==(n=null==l?void 0:l.getModifiedEditor)?void 0:n.call(l),a=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const l=t.call(e,()=>Xt());l&&ln.push(l)}catch(t){}};try{const e=null==(t=null==l?void 0:l.onDidUpdateDiff)?void 0:t.call(l,()=>{Xt(),Q(()=>Mt())});e&&ln.push(e)}catch(r){}return a(o,"onDidContentSizeChange"),a(i,"onDidContentSizeChange"),a(o,"onDidLayoutChange"),void a(i,"onDidLayoutChange")}const i=Ge();try{const e=null==(l=null==i?void 0:i.onDidContentSizeChange)?void 0:l.call(i,()=>Xt());e&&ln.push(e)}catch(r){}try{const e=null==(o=null==i?void 0:i.onDidLayoutChange)?void 0:o.call(i,()=>Xt());e&&ln.push(e)}catch(r){}}(),Dt(),$t(),Jt(),Mt(),Xt(),yield function(){return d(this,null,function*(){Jt(),Ut(!1),yield E(),yield gt(),Jt(),Ut(!1),yield gt(),Jt(),Ut(!1)})}(),yield function(){return d(this,null,function*(){var e;if(un.value){for(let t=0;t<8;t++){if(He)return;const l=te.value,o=Je();let i=!1;try{const n=null==(e=null==o?void 0:o.getLineChanges)?void 0:e.call(o);i=Array.isArray(n)}catch(n){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 gt(),He)return;try{gn(),Jt(),Mt(),Xt()}catch(n){}return}if(t>=1&&!r)return;yield E(),yield gt()}if(!He)try{gn(),Jt(),Mt(),Xt()}catch(n){}}})}(),He||($t(),function(){if(!un.value)return;const e=te.value;if(!e)return;const n=e.querySelector(".monaco-diff-editor");function t(e,n,t,l){const o=e.querySelector(n);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,zt(t,d)):u&&(d=u.getBoundingClientRect().width,zt(t,d)),r){const e=r.getBoundingClientRect();if(e.width>=20&&e.width<=64&&zt("--stream-monaco-line-number-width",e.width),null!=d){const n=d-(e.right-i.left);Number.isFinite(n)&&n>=0&&n<=32&&(zt(l,n),zt("--stream-monaco-line-number-gap-to-code",n))}}}n&&(t(n,".editor.original","--stream-monaco-original-scrollable-left","--stream-monaco-original-line-number-gap-to-code"),t(n,".editor.modified","--stream-monaco-modified-scrollable-left","--stream-monaco-modified-line-number-gap-to-code"))}(),yield E(),function(){var e;if(!un.value||!Fn.value)return;const n=te.value,t=null==(e=le.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!n||!t)return;const l=Math.ceil(t.getBoundingClientRect().height);!Number.isFinite(l)||l<=0||(n.style.height=`${l}px`,n.style.minHeight=`${l}px`)}(),yield gt(),yield function(){return d(this,null,function*(){if(un.value){if(Cn.value=!0,Mn.value=!1,kn.value=!0,yield E(),yield gt(),!He){if(Gt(!0),Mn.value=!0,mt(),"undefined"==typeof window)return Cn.value=!1,void(Mn.value=!1);Pn=window.setTimeout(()=>{Pn=null,Cn.value=!1,Mn.value=!1,Q(()=>{$t(),Jt(),Xt()})},120)}}else kn.value=!0})}()))})}(e))}).finally(()=>{Qe===n&&(Qe=null),function(){const e=ze;r&&e&&(ze="",E(()=>{var n,t;if(!He){const l=null!=(t=null==(n=le.value)?void 0:n.offsetHeight)?t:0;l>0&&r.reportHeight(e,l)}r.markSettled(e)}))}()});return Qe=n,n}P(sl,e=>{e||j()}),P(()=>Wn.value,(e,n)=>{const t=un.value?Je():Ge();t&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(t.updateOptions({fontSize:e}),Be.value||Ut(!0))},{flush:"post",immediate:!1});const gl=P(()=>[te.value,un.value,l.stream,l.loading,Fe.value,Ae.value,l.node.code,l.node.loading],e=>d(null,[e],function*([e,n,t,l,o,i]){if(!e||!je)return;if(!i)return;if(!1===t&&!1!==l)return;if(tl())return;const r=hl(e);if(r){try{yield r}catch(a){Le.value=!1,kn.value=!1,xn.value=!0}gl()}}));function yl(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function wl(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function bl(e,n){if(e===n)return!0;const t=wl(e),l=wl(n);return!!t&&t===l}function Sl(){var e;const n=function(){if(void 0!==l.theme){const e=l.theme;return yl(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),t=null==(e=yn.value)?void 0:e.theme,o=null!=n?n:t;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=wl(o),a=i.map(e=>wl(e)).filter(e=>!!e);if(!r||a.includes(r))return o;const u=wl(t);return null!=t&&u&&a.includes(u)?t:i[0]}P(wn,(e,n)=>d(null,null,function*(){if(e===n)return;if(bn.value=e,!je||!te.value)return;if(!Ee.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Ae.value)return;const t=Qe;if(t){try{yield t}catch(o){}if(He||!te.value)return}try{Le.value=!1,kn.value=!1,Ee.value=!1,Oe.value=!1,It(),qt(),Ye(),yield E(),yield hl(te.value)}catch(i){Le.value=!1,kn.value=!1,xn.value=!0}}));const kl=c(()=>(void 0!==l.theme?!yl(l.theme):bl(l.darkTheme,l.lightTheme))?function(e){var n,t;if(e&&"object"==typeof e&&(null==(n=e.colors)?void 0:n["editor.background"])){const n=Ht(e.colors["editor.background"]);if(null!=n)return n<128}const o=(null!=(t=wl(e))?t:"").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}(Sl()):!!l.isDark),xl=c(()=>{var e;if(!un.value)return kl.value?"dark":"light";const n=null==(e=yn.value)?void 0:e.diffAppearance;return"light"===n||"dark"===n?n:kl.value?"dark":"light"}),Cl=c(()=>un.value?"dark"===xl.value:kl.value);function Ml(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:l.themes},yn.value||{}),{theme:Sl()}),un.value?{diffAppearance:xl.value}:{}),{onThemeChange(){Dt()}})}function Pl(){const e=Ml();if(!rn)return rn=e,rn;for(const n of Object.keys(rn))n in e||delete rn[n];return Object.assign(rn,e),rn}const Bl=c(()=>{var e,n,t,o,i,r,u,d,s,c,v,f,m,p,h;return JSON.stringify({diffLineStyle:null!=(n=null==(e=yn.value)?void 0:e.diffLineStyle)?n:"background",diffUnchangedRegionStyle:null!=(o=null==(t=yn.value)?void 0:t.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:void 0===(null==(i=l.monacoOptions)?void 0:i.diffHideUnchangedRegions)?a({},cn):fn(l.monacoOptions.diffHideUnchangedRegions),renderSideBySide:null==(u=null==(r=yn.value)?void 0:r.renderSideBySide)||u,useInlineViewWhenSpaceIsLimited:null!=(s=null==(d=yn.value)?void 0:d.useInlineViewWhenSpaceIsLimited)&&s,enableSplitViewResizing:null==(v=null==(c=yn.value)?void 0:c.enableSplitViewResizing)||v,ignoreTrimWhitespace:null==(m=null==(f=yn.value)?void 0:f.ignoreTrimWhitespace)||m,originalEditable:null!=(h=null==(p=yn.value)?void 0:p.originalEditable)&&h})});return P(()=>[l.monacoOptions,Ae.value],()=>{var e,n;if(Pl(),!je||!Ae.value)return;const t=un.value?Je():Ge(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(Wn.value)?Wn.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(n=null==t?void 0:t.updateOptions)||n.call(t,{fontSize:o})),Ut(!1)},{deep:!0}),P(()=>[Sl(),xl.value,Fe.value,Ee.value,Ae.value],([e],n)=>{Fe.value&&Ee.value&&Ae.value&&function(e={}){if(e.appearanceOnly)return;Pl();const n=Sl(),t=()=>{un.value&&gn(),Q(()=>{Dt(),Xt()})};n?function(e,n){const t=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 t=fe.get(e);if(t)return t;try{const n=JSON.stringify(e);if(n)return fe.set(e,n),n}catch(n){}const l="__theme_"+ ++me;return fe.set(e,l),l}return String(e)}(n);return t?(ve=e,ae||ce!==t?ae?(se===t||ue===t||(de=n,se=t),ae):(de=n,se=t,ae=d(null,null,function*(){for(;se&&null!=de;){const t=de,l=se;if(de=null,se=null,ce!==l)try{ue=l,yield(null!=ve?ve:e)(t),ce=l}catch(n){}}}).finally(()=>{ae=null,ue=null}),ae):Promise.resolve()):Promise.resolve()}(nn,n).then(t).catch(e=>{}):t()}({appearanceOnly:null!=n&&bl(e,n[0])})},{flush:"post"}),P(()=>[Bl.value,Fe.value,Ae.value],(e,n)=>d(null,[e,n],function*([e,n,t],[o]){if(Pl(),!n||!t)return;if(!je||!te.value)return;if(!Ee.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=Qe;if(i){try{yield i}catch(r){}if(He||!te.value)return}try{Le.value=!1,kn.value=!1,Ee.value=!1,Oe.value=!1,It(),qt(),Ye(),yield E(),yield hl(te.value)}catch(a){Le.value=!1,kn.value=!1,xn.value=!0}}),{flush:"post"}),P(()=>[l.loading,Ae.value],(e,n)=>d(null,[e,n],function*([e,n],t){if(!n)return;const o=null==t?void 0:t[0];if(!1===o&&!1!==e&&un.value&&Ee.value&&(yield E(),Q(()=>{d(null,null,function*(){const e=Qe;if(e)try{yield e}catch(n){}!He&&un.value&&!1!==l.loading&&(Pl(),gn(),Xt())})})),e)return;const i=void 0!==o&&!1!==o;yield E(),Q(()=>{d(null,null,function*(){var e,n;try{if(i&&Ee.value)if(un.value&&te.value){const o=Qe;if(o)try{yield o}catch(t){}Pl();const i=mn(String(null!=(e=l.node.originalCode)?e:""),String(null!=(n=l.node.updatedCode)?n:""));if(yield Kt(i.original,i.updated,Ce.value),He||!un.value)return;gn(),Gt(!0),Jt(),Mt(),Xt()}else qe(Rn.value,Ce.value);Ut(!1)}catch(o){}})})}),{immediate:!0,flush:"post"}),f(()=>{mt(),It(),qt(),Xe()}),(n,t)=>Sn.value?(m(),p(S(I),{key:0,node:Dn.value,loading:l.loading},null,8,["node","loading"])):(m(),O("div",{key:1,ref_key:"container",ref:le,style:L(dl.value),class:y(["code-block-container rounded-lg border",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":Cl.value,"is-diff":un.value,"is-plain-text":Me.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":kn.value&&!Sn.value?"true":"false","data-markstream-pending":zn.value?"true":void 0},[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":Zt.value,"code-font-size":Wn.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":Tn.value,"font-baseline-ready":jn.value,"diff-stats":un.value?dn.value:null,"diff-stats-aria-label":sn.value,onToggleCollapse:fl,onDecreaseFont:Et,onResetFont:Ot,onIncreaseFont:Bt,onCopy:cl,onToggleExpand:vl,onPreview:ml},H({"header-left":N(()=>[D(n.$slots,"header-left",{},()=>[g("div",he,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:ul.value},null,8,ge),g("div",ye,[g("div",we,b(rl.value),1),al.value?(m(),O("div",be,b(al.value),1)):$("",!0)])])],!0)]),loading:N(()=>[D(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:N(()=>[z(g("div",Se,[g("div",{ref_key:"codeEditor",ref:te,class:y(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":Nn.value}]]),style:L(ft.value)},null,6),Hn.value?(m(),p(S(I),{key:0,class:y(["code-pre-fallback",{"is-wrap":Bn.value,"is-fading-out":Mn.value}]),style:L(st.value),node:Dn.value,"show-line-numbers":!0,"diff-inline":En.value},null,8,["class","style","node","diff-inline"])):$("",!0)],512),[[R,!(Be.value||!e.stream&&e.loading)]]),$n.value&&!w.value&&Zt.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":()=>$n.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):$("",!0)]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:N(()=>[D(n.$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-454daf15"]]);export{Ce as default};
@@ -1 +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 _};
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{ap as x,am as b,a9 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 _};
package/dist/Tooltip.js CHANGED
@@ -1 +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};
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{y 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};