import{e as rt,f as B,r as M,g as q,h as Et,y as ut,o as F,j as ke,z as g,c as D,s as Ee,a as u,t as Ye,l as $e,F as $t,x as G,k as Qe,v as Ze,n as oe,A as Nt,q as zt,B as Tt,m as Dt,p as ye}from"./index-WOIPm_2l.js";import{J as st,n as ct,D as Ne,U as Ht,o as jt,q as et,F as Lt,f as tt,Y as nt,a as Yt,O as Vt}from"./MessageList-DFdDzCzJ.js";import{e as ae}from"./safeRaf-DvJDa2y1.js";import"./toast-CbgsPrO_.js";var qt=Object.defineProperty,Wt=Object.defineProperties,It=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,lt=(p,m,k)=>m in p?qt(p,m,{enumerable:!0,configurable:!0,writable:!0,value:k}):p[m]=k,ze=(p,m)=>{for(var k in m||(m={}))At.call(m,k)&&lt(p,k,m[k]);if(ot)for(var k of ot(m))Rt.call(m,k)&&lt(p,k,m[k]);return p},it=(p,m)=>Wt(p,It(m)),Y=(p,m,k)=>new Promise((l,W)=>{var $=d=>{try{f(k.next(d))}catch(U){W(U)}},b=d=>{try{f(k.throw(d))}catch(U){W(U)}},f=d=>d.done?l(d.value):Promise.resolve(d.value).then($,b);f((k=k.apply(p,m)).next())});const Ut={class:"markstream-vue"},Xt={class:"html-preview-frame__header"},Jt={class:"html-preview-frame__title"},Gt={class:"html-preview-frame__label"},Kt=["srcdoc"],Qt=st(rt({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},onClose:{type:Function},title:{}},setup(p){const m=p,{t:k}=ct(),l=B(()=>{const $=m.code||"",b=$.trim().toLowerCase();return b.startsWith("<!doctype")||b.startsWith("<html")||b.startsWith("<body")?$:`<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style>
      html, body {
        margin: 0;
        padding: 0;
        height: 100%;
        background-color: ${m.isDark?"#020617":"#ffffff"};
        color: ${m.isDark?"#e5e7eb":"#020617"};
      }
      body {
        font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;
      }
    </style>
  </head>
  <body>
    ${$}
  </body>
</html>`});function W($){var b;$.key!=="Escape"&&$.key!=="Esc"||(b=m.onClose)==null||b.call(m)}return zt(()=>{typeof window<"u"&&window.addEventListener("keydown",W)}),ut(()=>{typeof window<"u"&&window.removeEventListener("keydown",W)}),($,b)=>(F(),ke(Dt,{to:"body"},[u("div",Ut,[u("div",{class:oe(["html-preview-frame__backdrop",{"html-preview-frame__backdrop--dark":m.isDark}]),onClick:b[2]||(b[2]=f=>{var d;return(d=m.onClose)==null?void 0:d.call(m)})},[u("div",{class:oe(["html-preview-frame",{"html-preview-frame--dark":m.isDark}]),onClick:b[1]||(b[1]=Tt(()=>{},["stop"]))},[u("div",Xt,[u("div",Jt,[b[3]||(b[3]=u("span",{class:"html-preview-frame__dot"},null,-1)),u("span",Gt,Ye(m.title||g(k)("common.preview")||"Preview"),1)]),u("button",{type:"button",class:oe(["html-preview-frame__close",{"html-preview-frame__close--dark":m.isDark}]),onClick:b[0]||(b[0]=f=>{var d;return(d=m.onClose)==null?void 0:d.call(m)})}," × ",2)]),u("iframe",{class:"html-preview-frame__iframe",sandbox:"allow-scripts allow-same-origin",srcdoc:l.value},null,8,Kt)],2)],2)])]))}}),[["__scopeId","data-v-296dd89d"]]);let te=null,Te=null,re=null,ne=null,De=null,He=null;const je=new WeakMap;let Zt=0;const en={key:0,class:"code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:{color:"var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))","background-color":"var(--vscode-editor-background, var(--markstream-code-fallback-bg))"}},tn={class:"flex items-center gap-x-2 flex-1 overflow-hidden"},nn=["innerHTML"],on={class:"text-sm font-medium font-mono truncate"},ln={class:"flex items-center gap-x-2"},an=["aria-pressed"],rn=["disabled"],un=["disabled"],sn=["disabled"],cn=["aria-label"],dn={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},vn={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},mn=["aria-pressed"],fn={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},pn={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},hn=["aria-label"],wn={class:"code-editor-layer"},gn={class:"code-loading-placeholder"},yn={class:"sr-only","aria-live":"polite",role:"status"},at="__markstreamMonacoPassiveTouch__",Le=st(rt({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},customId:{}},emits:["previewCode","copy"],setup(p,{emit:m}){var k;const l=p,W=m;typeof window<"u"&&(function(){var t;try{const e=window;if(e[at])return;const n=(t=window.Element)==null?void 0:t.prototype,o=n==null?void 0:n.addEventListener;if(!n||!o)return;n.addEventListener=function(i,a,c){return i==="touchstart"&&(function(r,y){if(!r)return!1;const s=r;return!(typeof s.closest!="function"||!s.closest(".monaco-editor, .monaco-diff-editor")||y&&typeof y=="object"&&"passive"in y)})(this,c)?o.call(this,i,a,(function(r){return r==null?{passive:!0}:typeof r=="boolean"?{capture:r,passive:!0}:typeof r=="object"?"passive"in r?r:it(ze({},r),{passive:!0}):{passive:!0}})(c)):o.call(this,i,a,c)},e[at]=!0}catch{}})();const $=Nt(),b=B(()=>{const t=$==null?void 0:$.vnode.props;return!(!t||!t.onPreviewCode&&!t.onPreviewCode)}),{t:f}=ct(),d=M(null),U=M(null),K=M(!1),H=M(Ne(l.node.language)),le=B(()=>Ht(H.value)),S=M(!1),O=M(!1),ue=M(!1),Q=M(!1),se=M(!1),X=M(null);let be=0;const dt=jt(),ie=M(null),I=M(typeof window>"u");typeof window<"u"&&q(()=>U.value,t=>{var e;if((e=ie.value)==null||e.destroy(),ie.value=null,!t)return void(I.value=!1);const n=dt(t,{rootMargin:"400px"});ie.value=n,I.value=n.isVisible.value,n.whenVisible.then(()=>{I.value=!0})},{immediate:!0}),Et(()=>{var t;(t=ie.value)==null||t.destroy(),ie.value=null});let j=null,ce=null,xe=()=>{},Me=()=>{},de=()=>null,L=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),T=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Ce=()=>{},ve=()=>{},Z=null,Ve=()=>{var t;return String((t=l.node.language)!=null?t:"plaintext")},Be=()=>Y(null,null,function*(){});const P=B(()=>l.node.diff),qe=B(()=>P.value?"diff":"single"),vt=M(qe.value),me=M(!1),mt=B(()=>{var t;const e=(t=l.monacoOptions)==null?void 0:t.wordWrap;return e==null||String(e)!=="off"}),We=B(()=>typeof window<"u"&&!me.value&&!Q.value),fe=M(!1);typeof window<"u"&&Y(null,null,function*(){try{const t=yield Vt();if(!t)return void(me.value=!0);const e=t.useMonaco,n=t.detectLanguage;if(typeof n=="function"&&(Ve=n),typeof e=="function"){const o=Je();if(o&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(o))throw new Error("Preferred theme not in provided themes array");const i=e(it(ze({wordWrap:"on",wrappingIndent:"same",themes:l.themes,theme:o},l.monacoOptions||{}),{onThemeChange(){Fe()}}));j=i.createEditor||j,ce=i.createDiffEditor||ce,xe=i.updateCode||xe,Me=i.updateDiff||Me,de=i.getEditor||de,L=i.getEditorView||L,T=i.getDiffEditorView||T,Ce=i.cleanupEditor||Ce,ve=i.safeClean||i.cleanupEditor||ve,Be=i.setTheme||Be,se.value=!0,d.value&&(yield he(d.value))}}catch{me.value=!0}});const N=M(typeof((k=l.monacoOptions)==null?void 0:k.fontSize)=="number"?l.monacoOptions.fontSize:Number.NaN),h=M(N.value),ft=B(()=>{const t=N.value,e=h.value;return typeof t=="number"&&Number.isFinite(t)&&t>0&&typeof e=="number"&&Number.isFinite(e)&&e>0}),Ie=B(()=>{var t;const e=(t=l.monacoOptions)==null?void 0:t.fontSize;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;const n=h.value;return typeof n=="number"&&Number.isFinite(n)&&n>0?n:12}),pt=B(()=>{var t;const e=(t=l.monacoOptions)==null?void 0:t.lineHeight;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:Math.round(1.5*Ie.value)}),ht=B(()=>{var t;const e=(t=l.monacoOptions)==null?void 0:t.tabSize;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:4}),wt=B(()=>{var t;const e=(t=l.monacoOptions)==null?void 0:t.fontFamily;return ze({fontSize:`${Ie.value}px`,lineHeight:`${pt.value}px`,tabSize:ht.value},typeof e=="string"&&e.trim()?{"--markstream-code-font-family":e.trim()}:{})});function Ae(){var t,e,n,o,i;try{const a=P.value?(n=(e=(t=T())==null?void 0:t.getModifiedEditor)==null?void 0:e.call(t))!=null?n:T():L(),c=de(),r=(o=c==null?void 0:c.EditorOption)==null?void 0:o.fontInfo;if(a&&r!=null){const y=(i=a.getOption)==null?void 0:i.call(a,r),s=y==null?void 0:y.fontSize;if(typeof s=="number"&&Number.isFinite(s)&&s>0)return s}}catch{}try{const a=d.value;if(a){const c=a.querySelector(".view-lines .view-line");if(c)try{if(typeof window<"u"&&typeof window.getComputedStyle=="function"){const r=window.getComputedStyle(c).fontSize,y=r&&r.match(/^(\d+(?:\.\d+)?)/);if(y)return Number.parseFloat(y[1])}}catch{}}}catch{}return null}function Se(t){var e,n;try{const a=de(),c=(e=a==null?void 0:a.EditorOption)==null?void 0:e.lineHeight;if(c!=null){const r=(n=t==null?void 0:t.getOption)==null?void 0:n.call(t,c);if(typeof r=="number"&&r>0)return r}}catch{}const o=(function(){try{const a=d.value;if(!a)return null;const c=a.querySelector(".view-lines .view-line");if(c){const r=Math.ceil(c.getBoundingClientRect().height);if(r>0)return r}}catch{}return null})();if(o&&o>0)return o;const i=Number.isFinite(h.value)&&h.value>0?h.value:12;return Math.max(12,Math.round(1.35*i))}function Oe(){var t;if(Number.isFinite(h.value)&&h.value>0&&Number.isFinite(N.value))return h.value;const e=Ae();return typeof((t=l.monacoOptions)==null?void 0:t.fontSize)=="number"?(N.value=l.monacoOptions.fontSize,h.value=l.monacoOptions.fontSize,h.value):e&&e>0?(N.value=e,h.value=e,e):(N.value=12,h.value=12,12)}function Re(){var t,e,n,o,i,a,c,r,y,s,v,V,A,x;try{const w=P.value?T():L();if(!w)return null;if(P.value&&(w!=null&&w.getOriginalEditor)&&(w!=null&&w.getModifiedEditor)){const C=(t=w.getOriginalEditor)==null?void 0:t.call(w),E=(e=w.getModifiedEditor)==null?void 0:e.call(w);(n=C==null?void 0:C.layout)==null||n.call(C),(o=E==null?void 0:E.layout)==null||o.call(E);const ge=((i=C==null?void 0:C.getContentHeight)==null?void 0:i.call(C))||0,Ge=((a=E==null?void 0:E.getContentHeight)==null?void 0:a.call(E))||0,Ke=Math.max(ge,Ge);if(Ke>0)return Math.ceil(Ke+1);const Ot=((y=(r=(c=C==null?void 0:C.getModel)==null?void 0:c.call(C))==null?void 0:r.getLineCount)==null?void 0:y.call(r))||1,Ft=((V=(v=(s=E==null?void 0:E.getModel)==null?void 0:s.call(E))==null?void 0:v.getLineCount)==null?void 0:V.call(v))||1,_t=Math.max(Ot,Ft),Pt=Math.max(Se(C),Se(E));return Math.ceil(_t*(Pt+1.5)+0+1)}if(w!=null&&w.getContentHeight){(A=w==null?void 0:w.layout)==null||A.call(w);const C=w.getContentHeight();if(C>0)return Math.ceil(C+1)}const R=(x=w==null?void 0:w.getModel)==null?void 0:x.call(w);let we=1;R&&typeof R.getLineCount=="function"&&(we=R.getLineCount());const Pe=Se(w);return Math.ceil(we*(Pe+1.5)+0+1)}catch{return null}}function Fe(){var t,e,n,o,i,a,c,r;const y=d.value,s=U.value;if(!y||!s)return;const v=y.querySelector(".monaco-editor")||y,V=v.querySelector(".monaco-editor-background")||v,A=v.querySelector(".view-lines")||v;let x=null,w=null,R=null;try{typeof window<"u"&&typeof window.getComputedStyle=="function"&&(x=window.getComputedStyle(v),w=V===v?x:window.getComputedStyle(V),R=A===v?x:window.getComputedStyle(A))}catch{x=null,w=null,R=null}const we=String((t=x==null?void 0:x.getPropertyValue("--vscode-editor-foreground"))!=null?t:"").trim(),Pe=String((e=x==null?void 0:x.getPropertyValue("--vscode-editor-background"))!=null?e:"").trim(),C=String((o=(n=x==null?void 0:x.getPropertyValue("--vscode-editor-selectionBackground"))!=null?n:x==null?void 0:x.getPropertyValue("--vscode-editor-hoverHighlightBackground"))!=null?o:"").trim(),E=we||String((a=(i=R==null?void 0:R.color)!=null?i:x==null?void 0:x.color)!=null?a:"").trim(),ge=Pe||String((r=(c=w==null?void 0:w.backgroundColor)!=null?c:x==null?void 0:x.backgroundColor)!=null?r:"").trim();E&&s.style.setProperty("--vscode-editor-foreground",E),ge&&s.style.setProperty("--vscode-editor-background",ge),C&&s.style.setProperty("--vscode-editor-selectionBackground",C)}function J(){try{const t=d.value;if(!t)return;const e=t.getBoundingClientRect(),n=window.scrollY+e.top,o=Re();if(o!=null&&o>0){const i=e.height;t.style.height=`${Math.ceil(o)}px`,t.style.maxHeight="none";const a=Math.ceil(o)-i;a!==0&&n<window.scrollY&&window.scrollBy(0,a)}}catch{}}function ee(){var t;try{const e=d.value;if(!e)return;const n=e.getBoundingClientRect(),o=window.scrollY+n.top,i=n.height,a=(function(){var s,v;const V=(v=(s=l.monacoOptions)==null?void 0:s.MAX_HEIGHT)!=null?v:500;if(typeof V=="number")return V;const A=String(V).match(/^(\d+(?:\.\d+)?)/);return A?Number.parseFloat(A[1]):500})();if(be>0&&(be--,X.value!=null)){const s=Math.min(X.value,a);e.style.height=`${Math.ceil(s)}px`,e.style.maxHeight=`${Math.ceil(a)}px`,e.style.overflow="auto";const v=Math.ceil(s)-i;return void(v!==0&&o<window.scrollY&&window.scrollBy(0,v))}const c=Re();if(c!=null&&c>0){const s=Math.min(c,a);e.style.height=`${Math.ceil(s)}px`,e.style.maxHeight=`${Math.ceil(a)}px`,e.style.overflow="auto";const v=Math.ceil(s)-i;return void(v!==0&&o<window.scrollY&&window.scrollBy(0,v))}if(X.value!=null){const s=Math.min(X.value,a);e.style.height=`${Math.ceil(s)}px`,e.style.maxHeight=`${Math.ceil(a)}px`,e.style.overflow="auto";const v=Math.ceil(s)-i;return void(v!==0&&o<window.scrollY&&window.scrollBy(0,v))}const r=Math.ceil(((t=e.getBoundingClientRect)==null?void 0:t.call(e).height)||0);if(r>0){const s=Math.min(r,a);e.style.height=`${Math.ceil(s)}px`,e.style.maxHeight=`${Math.ceil(a)}px`,e.style.overflow="auto";const v=Math.ceil(s)-i;return void(v!==0&&o<window.scrollY&&window.scrollBy(0,v))}const y=Number.parseFloat(e.style.height);if(!Number.isNaN(y)&&y>0){const s=Math.ceil(Math.min(y,a));e.style.height=`${s}px`;const v=s-i;v!==0&&o<window.scrollY&&window.scrollBy(0,v)}else{const s=Math.ceil(a);e.style.height=`${s}px`;const v=s-i;v!==0&&o<window.scrollY&&window.scrollBy(0,v)}e.style.maxHeight=`${Math.ceil(a)}px`,e.style.overflow="auto"}catch{}}const _e=B(()=>l.isShowPreview&&(H.value==="html"||H.value==="svg"));q(()=>l.node.language,t=>{H.value=Ne(t)}),q(()=>l.node.code,t=>Y(null,null,function*(){var e,n;if(l.stream!==!1){if(H.value||(H.value=Ne(Ve(t))),j&&!ue.value&&d.value)try{yield he(d.value)}catch{}P.value?Me(String((e=l.node.originalCode)!=null?e:""),String((n=l.node.updatedCode)!=null?n:""),le.value):xe(t,le.value),S.value&&ae(()=>J())}}));const gt=B(()=>{const t=H.value;return t?et[t]||t.charAt(0).toUpperCase()+t.slice(1):et[""]}),yt=B(()=>Lt(H.value||"")),kt=B(()=>{const t={},e=i=>{if(i!=null)return typeof i=="number"?`${i}px`:String(i)},n=e(l.minWidth),o=e(l.maxWidth);return n&&(t.minWidth=n),o&&(t.maxWidth=o),t});function bt(){return Y(this,null,function*(){try{typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function"&&(yield navigator.clipboard.writeText(l.node.code)),K.value=!0,W("copy",l.node.code),setTimeout(()=>{K.value=!1},1e3)}catch(t){console.error("复制失败:",t)}})}function Ue(t){return!t||t.disabled}function z(t,e,n="top"){if(Ue(t.currentTarget))return;const o=t,i=(o==null?void 0:o.clientX)!=null&&(o==null?void 0:o.clientY)!=null?{x:o.clientX,y:o.clientY}:void 0;nt(t.currentTarget,e,n,!1,i,l.isDark)}function _(){Yt()}function Xe(t){if(Ue(t.currentTarget))return;const e=K.value?f("common.copied")||"Copied":f("common.copy")||"Copy",n=t,o=(n==null?void 0:n.clientX)!=null&&(n==null?void 0:n.clientY)!=null?{x:n.clientX,y:n.clientY}:void 0;nt(t.currentTarget,e,"top",!1,o,l.isDark)}function xt(){S.value=!S.value;const t=P.value?T():L(),e=d.value;t&&e&&(S.value?(pe(!0),e.style.maxHeight="none",e.style.overflow="visible",J()):(pe(!1),e.style.overflow="auto",ee()))}function Mt(){var t,e,n;if(O.value=!O.value,O.value){if(d.value){const o=Math.ceil(((e=(t=d.value).getBoundingClientRect)==null?void 0:e.call(t).height)||0);o>0&&(X.value=o)}pe(!1)}else{S.value&&pe(!0),d.value&&X.value!=null&&(d.value.style.height=`${X.value}px`);const o=P.value?T():L();try{(n=o==null?void 0:o.layout)==null||n.call(o)}catch{}be=2,ae(()=>{S.value?J():ee()})}}function Ct(){if(!_e.value)return;const t=H.value;if(b.value){const e=t==="html"?"text/html":"image/svg+xml",n=t==="html"?f("artifacts.htmlPreviewTitle")||"HTML Preview":f("artifacts.svgPreviewTitle")||"SVG Preview";return void W("previewCode",{node:l.node,artifactType:e,artifactTitle:n,id:`temp-${t}-${Date.now()}`})}t==="html"&&(fe.value=!fe.value)}function pe(t){var e,n;try{if(P.value){const o=T();(e=o==null?void 0:o.updateOptions)==null||e.call(o,{automaticLayout:t})}else{const o=L();(n=o==null?void 0:o.updateOptions)==null||n.call(o,{automaticLayout:t})}}catch{}}function he(t){return j?Z||(ue.value=!0,Z=Y(null,null,function*(){yield(function(n){return Y(this,null,function*(){var o,i,a;if(!j)return;P.value?(ve(),ce?yield ce(n,String((o=l.node.originalCode)!=null?o:""),String((i=l.node.updatedCode)!=null?i:""),le.value):yield j(n,l.node.code,le.value)):yield j(n,l.node.code,le.value);const c=P.value?T():L();if(typeof((a=l.monacoOptions)==null?void 0:a.fontSize)=="number")c==null||c.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),N.value=l.monacoOptions.fontSize,h.value=l.monacoOptions.fontSize;else{const r=Ae();r&&r>0?(N.value=r,h.value=r):(N.value=12,h.value=12)}S.value||O.value||ee(),l.loading===!1&&(yield ye(),ae(()=>{S.value&&!O.value?J():O.value||ee()})),yield ye(),Q.value=!0,Fe()})})(t)}).finally(()=>{Z=null}),Z):null}q(()=>h.value,(t,e)=>{const n=P.value?T():L();n&&typeof t=="number"&&Number.isFinite(t)&&t>0&&(n.updateOptions({fontSize:t}),S.value&&!O.value&&J())},{flush:"post",immediate:!1});const Bt=q(()=>[d.value,P.value,l.stream,l.loading,se.value,I.value],t=>Y(null,[t],function*([e,n,o,i,a,c]){if(!e||!j||!c||o===!1&&i!==!1)return;const r=he(e);if(r){try{yield r}catch{Q.value=!1}Bt()}}));function Je(){return l.isDark?l.darkTheme:l.lightTheme}q(qe,(t,e)=>Y(null,null,function*(){if(t!==e&&(vt.value=t,j&&d.value&&ue.value&&(l.stream!==!1||l.loading===!1)&&I.value))try{Q.value=!1,ue.value=!1,Z=null,ve(),yield ye(),yield he(d.value)}catch{Q.value=!1}})),q(()=>[l.isDark,l.darkTheme,l.lightTheme,se.value],()=>{se.value&&(function(){const t=Je();t&&(function(e,n){const o=(function(i){if(i==null)return null;if(typeof i=="string")return i;if(typeof i=="object"&&i&&"name"in i)return String(i.name);if(typeof i=="object"){const a=je.get(i);if(a)return a;try{const r=JSON.stringify(i);if(r)return je.set(i,r),r}catch{}const c="__theme_"+ ++Zt;return je.set(i,c),c}return String(i)})(n);return o?(He=e,te||De!==o?te?(ne===o||Te===o||(re=n,ne=o),te):(re=n,ne=o,te=Y(null,null,function*(){for(;ne&&re!=null;){const i=re,a=ne;if(re=null,ne=null,De!==a)try{Te=a,yield(He??e)(i),De=a}catch{}}}).finally(()=>{te=null,Te=null}),te):Promise.resolve()):Promise.resolve()})(Be,t).then(()=>{Q.value&&ae(()=>Fe())})})()}),q(()=>[l.monacoOptions,I.value],()=>{var t,e;if(!j||!I.value)return;const n=P.value?T():L(),o=typeof((t=l.monacoOptions)==null?void 0:t.fontSize)=="number"?l.monacoOptions.fontSize:Number.isFinite(h.value)?h.value:void 0;typeof o=="number"&&Number.isFinite(o)&&o>0&&((e=n==null?void 0:n.updateOptions)==null||e.call(n,{fontSize:o})),S.value&&!O.value?J():O.value||ee()},{deep:!0});const St=q(()=>[l.loading,I.value],t=>Y(null,[t],function*([e,n]){n&&(e||(yield ye(),ae(()=>{O.value||(S.value?J():ee()),St()})))}),{immediate:!0,flush:"post"});return ut(()=>{Ce()}),(t,e)=>me.value?(F(),ke(g(tt),{key:0,node:p.node,loading:l.loading},null,8,["node","loading"])):(F(),D("div",{key:1,ref_key:"container",ref:U,style:$e(kt.value),class:oe(["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",[l.isDark?"border-gray-700/30 bg-gray-900":"border-gray-200 bg-white",{"is-rendering":l.loading,"is-dark":l.isDark}]])},[l.showHeader?(F(),D("div",en,[Ee(t.$slots,"header-left",{},()=>[u("div",tn,[u("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:yt.value},null,8,nn),u("span",on,Ye(gt.value),1)])],!0),Ee(t.$slots,"header-right",{},()=>[u("div",ln,[u("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":O.value,onClick:Mt,onMouseenter:e[0]||(e[0]=n=>z(n,O.value?g(f)("common.expand")||"Expand":g(f)("common.collapse")||"Collapse")),onFocus:e[1]||(e[1]=n=>z(n,O.value?g(f)("common.expand")||"Expand":g(f)("common.collapse")||"Collapse")),onMouseleave:_,onBlur:_},[(F(),D("svg",{style:$e({rotate:O.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[...e[17]||(e[17]=[u("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,an),l.showFontSizeButtons&&l.enableFontSizeControl?(F(),D($t,{key:0},[u("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!!Number.isFinite(h.value)&&h.value<=10,onClick:e[2]||(e[2]=n=>(function(){const o=Oe(),i=Math.max(10,o-1);h.value=i})()),onMouseenter:e[3]||(e[3]=n=>z(n,g(f)("common.decrease")||"Decrease")),onFocus:e[4]||(e[4]=n=>z(n,g(f)("common.decrease")||"Decrease")),onMouseleave:_,onBlur:_},[...e[18]||(e[18]=[u("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[u("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)])],40,rn),u("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!ft.value||h.value===N.value,onClick:e[5]||(e[5]=n=>(Oe(),void(Number.isFinite(N.value)&&(h.value=N.value)))),onMouseenter:e[6]||(e[6]=n=>z(n,g(f)("common.reset")||"Reset")),onFocus:e[7]||(e[7]=n=>z(n,g(f)("common.reset")||"Reset")),onMouseleave:_,onBlur:_},[...e[19]||(e[19]=[u("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[u("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[u("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),u("path",{d:"M3 3v5h5"})])],-1)])],40,un),u("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!!Number.isFinite(h.value)&&h.value>=36,onClick:e[8]||(e[8]=n=>(function(){const o=Oe(),i=Math.min(36,o+1);h.value=i})()),onMouseenter:e[9]||(e[9]=n=>z(n,g(f)("common.increase")||"Increase")),onFocus:e[10]||(e[10]=n=>z(n,g(f)("common.increase")||"Increase")),onMouseleave:_,onBlur:_},[...e[20]||(e[20]=[u("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[u("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)])],40,sn)],64)):G("",!0),l.showCopyButton?(F(),D("button",{key:1,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":K.value?g(f)("common.copied")||"Copied":g(f)("common.copy")||"Copy",onClick:bt,onMouseenter:e[11]||(e[11]=n=>Xe(n)),onFocus:e[12]||(e[12]=n=>Xe(n)),onMouseleave:_,onBlur:_},[K.value?(F(),D("svg",vn,[...e[22]||(e[22]=[u("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(F(),D("svg",dn,[...e[21]||(e[21]=[u("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[u("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),u("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,cn)):G("",!0),l.showExpandButton?(F(),D("button",{key:2,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":S.value,onClick:xt,onMouseenter:e[13]||(e[13]=n=>z(n,S.value?g(f)("common.collapse")||"Collapse":g(f)("common.expand")||"Expand")),onFocus:e[14]||(e[14]=n=>z(n,S.value?g(f)("common.collapse")||"Collapse":g(f)("common.expand")||"Expand")),onMouseleave:_,onBlur:_},[S.value?(F(),D("svg",fn,[...e[23]||(e[23]=[u("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)])])):(F(),D("svg",pn,[...e[24]||(e[24]=[u("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)])]))],40,mn)):G("",!0),_e.value&&l.showPreviewButton?(F(),D("button",{key:3,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":g(f)("common.preview")||"Preview",onClick:Ct,onMouseenter:e[15]||(e[15]=n=>z(n,g(f)("common.preview")||"Preview")),onFocus:e[16]||(e[16]=n=>z(n,g(f)("common.preview")||"Preview")),onMouseleave:_,onBlur:_},[...e[25]||(e[25]=[u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24"},[u("g",{fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"},[u("path",{d:"M23.628 7.41c-.12-1.172-.08-3.583-.9-4.233c-1.921-1.51-6.143-1.11-8.815-1.19c-3.481-.15-7.193.14-10.625.24a.34.34 0 0 0 0 .67c3.472-.05 7.074-.29 10.575-.09c2.471.15 6.653-.14 8.254 1.16c.4.33.41 2.732.49 3.582a42 42 0 0 1 .08 9.005a13.8 13.8 0 0 1-.45 3.001c-2.42 1.4-19.69 2.381-20.72.55a21 21 0 0 1-.65-4.632a41.5 41.5 0 0 1 .12-7.964c.08 0 7.334.33 12.586.24c2.331 0 4.682-.13 6.764-.21a.33.33 0 0 0 0-.66c-7.714-.16-12.897-.43-19.31.05c.11-1.38.48-3.922.38-4.002a.3.3 0 0 0-.42 0c-.37.41-.29 1.77-.36 2.251s-.14 1.07-.2 1.6a45 45 0 0 0-.36 8.645a21.8 21.8 0 0 0 .66 5.002c1.46 2.702 17.248 1.461 20.95.43c1.45-.4 1.69-.8 1.871-1.95c.575-3.809.602-7.68.08-11.496"}),u("path",{d:"M4.528 5.237a.84.84 0 0 0-.21-1c-.77-.41-1.71.39-1 1.1a.83.83 0 0 0 1.21-.1m2.632-.25c.14-.14.19-.84-.2-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.2-.09m2.88 0a.83.83 0 0 0-.21-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.21-.09m-4.29 8.735c0 .08.23 2.471.31 2.561a.371.371 0 0 0 .63-.14c0-.09 0 0 .15-1.72a10 10 0 0 0-.11-2.232a5.3 5.3 0 0 1-.26-1.37a.3.3 0 0 0-.54-.24a6.8 6.8 0 0 0-.2 2.33c-1.281-.38-1.121.13-1.131-.42a15 15 0 0 0-.19-1.93c-.16-.17-.36-.17-.51.14a20 20 0 0 0-.43 3.471c.04.773.18 1.536.42 2.272c.26.4.7.22.7-.1c0-.09-.16-.09 0-1.862c.06-1.18-.23-.3 1.16-.76m5.033-2.552c.32-.07.41-.28.39-.37c0-.55-3.322-.34-3.462-.24s-.2.18-.18.28s0 .11 0 .16a3.8 3.8 0 0 0 1.591.361v.82a15 15 0 0 0-.13 3.132c0 .2-.09.94.17 1.16a.34.34 0 0 0 .48 0c.125-.35.196-.718.21-1.09a8 8 0 0 0 .14-3.232c0-.13.05-.7-.1-.89a8 8 0 0 0 .89-.09m5.544-.181a.69.69 0 0 0-.89-.44a2.8 2.8 0 0 0-1.252 1.001a2.3 2.3 0 0 0-.41-.83a1 1 0 0 0-1.6.27a7 7 0 0 0-.35 2.07c0 .571 0 2.642.06 2.762c.14 1.09 1 .51.63.13a17.6 17.6 0 0 1 .38-3.962c.32-1.18.32.2.39.51s.11 1.081.73 1.081s.48-.93 1.401-1.78q.075 1.345 0 2.69a15 15 0 0 0 0 1.811a.34.34 0 0 0 .68 0q.112-.861.11-1.73a16.7 16.7 0 0 0 .12-3.582m1.441-.201c-.05.16-.3 3.002-.31 3.202a6.3 6.3 0 0 0 .21 1.741c.33 1 1.21 1.07 2.291.82a3.7 3.7 0 0 0 1.14-.23c.21-.22.10-.59-.41-.64q-.817.096-1.64.07c-.44-.07-.34 0-.67-4.442q.015-.185 0-.37a.316.316 0 0 0-.23-.38a.316.316 0 0 0-.38.23"})])],-1)])],40,hn)):G("",!0)])],!0)])):G("",!0),Qe(u("div",wn,[u("div",{ref_key:"codeEditor",ref:d,class:oe(["code-editor-container",[p.stream?"":"code-height-placeholder",{"is-hidden":We.value}]])},null,2),We.value?(F(),ke(g(tt),{key:0,class:oe(["code-pre-fallback",{"is-wrap":mt.value}]),style:$e(wt.value),node:p.node},null,8,["class","style","node"])):G("",!0)],512),[[Ze,!(O.value||!p.stream&&p.loading)]]),fe.value&&!b.value&&_e.value&&H.value==="html"?(F(),ke(Qt,{key:1,code:p.node.code,"is-dark":l.isDark,"on-close":()=>fe.value=!1},null,8,["code","is-dark","on-close"])):G("",!0),Qe(u("div",gn,[Ee(t.$slots,"loading",{loading:p.loading,stream:p.stream},()=>[e[26]||(e[26]=u("div",{class:"loading-skeleton"},[u("div",{class:"skeleton-line"}),u("div",{class:"skeleton-line"}),u("div",{class:"skeleton-line short"})],-1))],!0)],512),[[Ze,!p.stream&&p.loading]]),u("span",yn,Ye(K.value?g(f)("common.copied")||"Copied":""),1)],6))}}),[["__scopeId","data-v-bf41db7f"]]);Le.install=p=>{p.component(Le.__name,Le)};export{Le as default};
