markstream-vue 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/README.zh-CN.md +21 -0
- package/dist/CodeBlockNode.js +1 -1
- package/dist/exports.js +1 -1
- package/dist/extended.js +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1635 -98
- package/dist/index.js +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/index2.js +1 -1
- package/dist/index3.js +1 -1
- package/dist/index4.js +1 -1
- package/dist/index5.js +1 -1
- package/dist/index6.js +1 -1
- package/dist/tailwind.ts +0 -0
- package/package.json +2 -1
- package/dist/languageIconExtended.js +0 -1
- package/dist/types/components/AdmonitionNode/AdmonitionNode.vue.d.ts +0 -26
- package/dist/types/components/AdmonitionNode/index.d.ts +0 -2
- package/dist/types/components/BlockquoteNode/BlockquoteNode.vue.d.ts +0 -23
- package/dist/types/components/BlockquoteNode/index.d.ts +0 -2
- package/dist/types/components/CheckboxNode/CheckboxNode.vue.d.ts +0 -9
- package/dist/types/components/CheckboxNode/index.d.ts +0 -2
- package/dist/types/components/CodeBlockNode/CodeBlockNode.vue.d.ts +0 -55
- package/dist/types/components/CodeBlockNode/HtmlPreviewFrame.vue.d.ts +0 -8
- package/dist/types/components/CodeBlockNode/index.d.ts +0 -2
- package/dist/types/components/CodeBlockNode/monaco.d.ts +0 -57
- package/dist/types/components/CodeBlockNode/monacoThemeScheduler.d.ts +0 -4
- package/dist/types/components/D2BlockNode/D2BlockNode.vue.d.ts +0 -16
- package/dist/types/components/D2BlockNode/d2.d.ts +0 -6
- package/dist/types/components/D2BlockNode/index.d.ts +0 -2
- package/dist/types/components/DefinitionListNode/DefinitionListNode.vue.d.ts +0 -29
- package/dist/types/components/DefinitionListNode/index.d.ts +0 -2
- package/dist/types/components/EmojiNode/EmojiNode.vue.d.ts +0 -10
- package/dist/types/components/EmojiNode/index.d.ts +0 -2
- package/dist/types/components/EmphasisNode/EmphasisNode.vue.d.ts +0 -16
- package/dist/types/components/EmphasisNode/index.d.ts +0 -2
- package/dist/types/components/FootnoteAnchorNode/FootnoteAnchorNode.vue.d.ts +0 -9
- package/dist/types/components/FootnoteAnchorNode/index.d.ts +0 -2
- package/dist/types/components/FootnoteNode/FootnoteNode.vue.d.ts +0 -21
- package/dist/types/components/FootnoteNode/index.d.ts +0 -2
- package/dist/types/components/FootnoteReferenceNode/FootnoteReferenceNode.vue.d.ts +0 -10
- package/dist/types/components/FootnoteReferenceNode/index.d.ts +0 -2
- package/dist/types/components/HardBreakNode/HardBreakNode.vue.d.ts +0 -9
- package/dist/types/components/HardBreakNode/index.d.ts +0 -2
- package/dist/types/components/HeadingNode/HeadingNode.vue.d.ts +0 -19
- package/dist/types/components/HeadingNode/index.d.ts +0 -2
- package/dist/types/components/HighlightNode/HighlightNode.vue.d.ts +0 -16
- package/dist/types/components/HighlightNode/index.d.ts +0 -2
- package/dist/types/components/HtmlBlockNode/HtmlBlockNode.vue.d.ts +0 -39
- package/dist/types/components/HtmlBlockNode/index.d.ts +0 -2
- package/dist/types/components/HtmlInlineNode/HtmlInlineNode.vue.d.ts +0 -12
- package/dist/types/components/HtmlInlineNode/index.d.ts +0 -2
- package/dist/types/components/ImageNode/ImageNode.vue.d.ts +0 -59
- package/dist/types/components/ImageNode/index.d.ts +0 -2
- package/dist/types/components/InfographicBlockNode/InfographicBlockNode.vue.d.ts +0 -46
- package/dist/types/components/InfographicBlockNode/index.d.ts +0 -2
- package/dist/types/components/InfographicBlockNode/infographic.d.ts +0 -3
- package/dist/types/components/InlineCodeNode/InlineCodeNode.vue.d.ts +0 -9
- package/dist/types/components/InlineCodeNode/index.d.ts +0 -2
- package/dist/types/components/InsertNode/InsertNode.vue.d.ts +0 -16
- package/dist/types/components/InsertNode/index.d.ts +0 -2
- package/dist/types/components/LinkNode/LinkNode.vue.d.ts +0 -5
- package/dist/types/components/LinkNode/index.d.ts +0 -2
- package/dist/types/components/ListItemNode/ListItemNode.vue.d.ts +0 -30
- package/dist/types/components/ListItemNode/index.d.ts +0 -2
- package/dist/types/components/ListNode/ListNode.vue.d.ts +0 -29
- package/dist/types/components/ListNode/index.d.ts +0 -2
- package/dist/types/components/MarkdownCodeBlockNode/MarkdownCodeBlockNode.vue.d.ts +0 -90
- package/dist/types/components/MarkdownCodeBlockNode/index.d.ts +0 -2
- package/dist/types/components/MathBlockNode/MathBlockNode.vue.d.ts +0 -5
- package/dist/types/components/MathBlockNode/index.d.ts +0 -2
- package/dist/types/components/MathInlineNode/MathInlineNode.vue.d.ts +0 -24
- package/dist/types/components/MathInlineNode/index.d.ts +0 -2
- package/dist/types/components/MathInlineNode/katex.d.ts +0 -7
- package/dist/types/components/MermaidBlockNode/MermaidBlockNode.vue.d.ts +0 -62
- package/dist/types/components/MermaidBlockNode/index.d.ts +0 -2
- package/dist/types/components/MermaidBlockNode/mermaid.d.ts +0 -6
- package/dist/types/components/NodeRenderer/FallbackComponent.vue.d.ts +0 -7
- package/dist/types/components/NodeRenderer/NodeRenderer.vue.d.ts +0 -34
- package/dist/types/components/NodeRenderer/asyncComponent.d.ts +0 -32
- package/dist/types/components/NodeRenderer/index.d.ts +0 -2
- package/dist/types/components/NodeRenderer/preloadMonaco.d.ts +0 -1
- package/dist/types/components/ParagraphNode/ParagraphNode.vue.d.ts +0 -17
- package/dist/types/components/ParagraphNode/index.d.ts +0 -2
- package/dist/types/components/PreCodeNode/PreCodeNode.vue.d.ts +0 -3
- package/dist/types/components/PreCodeNode/index.d.ts +0 -2
- package/dist/types/components/ReferenceNode/ReferenceNode.vue.d.ts +0 -19
- package/dist/types/components/ReferenceNode/index.d.ts +0 -2
- package/dist/types/components/StrikethroughNode/StrikethroughNode.vue.d.ts +0 -16
- package/dist/types/components/StrikethroughNode/index.d.ts +0 -2
- package/dist/types/components/StrongNode/StrongNode.vue.d.ts +0 -16
- package/dist/types/components/StrongNode/index.d.ts +0 -2
- package/dist/types/components/SubscriptNode/SubscriptNode.vue.d.ts +0 -16
- package/dist/types/components/SubscriptNode/index.d.ts +0 -2
- package/dist/types/components/SuperscriptNode/SuperscriptNode.vue.d.ts +0 -16
- package/dist/types/components/SuperscriptNode/index.d.ts +0 -2
- package/dist/types/components/TableNode/TableNode.vue.d.ts +0 -52
- package/dist/types/components/TableNode/index.d.ts +0 -2
- package/dist/types/components/TextNode/TextNode.vue.d.ts +0 -14
- package/dist/types/components/TextNode/index.d.ts +0 -2
- package/dist/types/components/ThematicBreakNode/ThematicBreakNode.vue.d.ts +0 -2
- package/dist/types/components/ThematicBreakNode/index.d.ts +0 -2
- package/dist/types/components/Tooltip/Tooltip.vue.d.ts +0 -15
- package/dist/types/components/Tooltip/index.d.ts +0 -2
- package/dist/types/components/VmrContainerNode/VmrContainerNode.vue.d.ts +0 -20
- package/dist/types/components/VmrContainerNode/index.d.ts +0 -2
- package/dist/types/components/__tests__/htmlNodes.integration.test.d.ts +0 -4
- package/dist/types/composables/rendererContext.d.ts +0 -19
- package/dist/types/composables/useKatexReady.d.ts +0 -1
- package/dist/types/composables/useSafeI18n.d.ts +0 -10
- package/dist/types/composables/useSingletonTooltip.d.ts +0 -11
- package/dist/types/composables/viewportPriority.d.ts +0 -21
- package/dist/types/exports.d.ts +0 -381
- package/dist/types/internal/heightEstimationExperiment.d.ts +0 -84
- package/dist/types/types/component-props.d.ts +0 -305
- package/dist/types/types/index.d.ts +0 -272
- package/dist/types/types/node-renderer-props.d.ts +0 -81
- package/dist/types/utils/__tests__/htmlRenderer.test.d.ts +0 -4
- package/dist/types/utils/htmlRenderer.d.ts +0 -20
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/katex-threshold.d.ts +0 -20
- package/dist/types/utils/languageIcon.d.ts +0 -8
- package/dist/types/utils/languageIconExtended.d.ts +0 -1
- package/dist/types/utils/nodeComponents.d.ts +0 -20
- package/dist/types/utils/performance-monitor.d.ts +0 -121
- package/dist/types/utils/safeRaf.d.ts +0 -2
- package/dist/types/workers/katexCdnWorker.d.ts +0 -52
- package/dist/types/workers/katexRenderer.worker.d.ts +0 -0
- package/dist/types/workers/katexWorkerClient.d.ts +0 -48
- package/dist/types/workers/mermaidCdnWorker.d.ts +0 -35
- package/dist/types/workers/mermaidParser.worker.d.ts +0 -1
- package/dist/types/workers/mermaidWorkerClient.d.ts +0 -21
package/README.md
CHANGED
|
@@ -158,6 +158,27 @@ Renderer CSS is scoped under an internal `.markstream-vue` container to minimize
|
|
|
158
158
|
|
|
159
159
|
For dark theme variables, either add a `.dark` class on an ancestor, or pass `:is-dark="true"` to `MarkdownRender` to scope dark mode to the renderer.
|
|
160
160
|
|
|
161
|
+
Prefer the unified code-block `theme` prop for new integrations. When you render through `MarkdownRender`, pass it via `code-block-props`:
|
|
162
|
+
|
|
163
|
+
```vue
|
|
164
|
+
<MarkdownRender
|
|
165
|
+
:is-dark="isDark"
|
|
166
|
+
:code-block-props="{ theme: { light: 'vitesse-light', dark: 'vitesse-dark' } }"
|
|
167
|
+
:content="doc"
|
|
168
|
+
/>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Language icons use the built-in `material` theme by default. Advanced integrations can inspect or switch icon themes with the exported helpers, or set an initial theme with `app.use(VueRendererMarkdown, { iconTheme })`:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { getRegisteredThemes, setIconTheme } from 'markstream-vue'
|
|
175
|
+
|
|
176
|
+
console.log(getRegisteredThemes()) // ['material']
|
|
177
|
+
setIconTheme('material')
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Use `registerIconTheme()` if you want to add your own icon pack.
|
|
181
|
+
|
|
161
182
|
Enable heavy peers only when needed:
|
|
162
183
|
|
|
163
184
|
```ts
|
package/README.zh-CN.md
CHANGED
|
@@ -159,6 +159,27 @@ createApp({
|
|
|
159
159
|
|
|
160
160
|
暗色变量可以通过给祖先节点加 `.dark`,或直接给 `MarkdownRender` 传入 `:is-dark="true"`(仅对渲染器生效)。
|
|
161
161
|
|
|
162
|
+
新的接入建议优先使用统一代码块 `theme` prop。如果你是通过 `MarkdownRender` 统一下发,可以放到 `code-block-props`:
|
|
163
|
+
|
|
164
|
+
```vue
|
|
165
|
+
<MarkdownRender
|
|
166
|
+
:is-dark="isDark"
|
|
167
|
+
:code-block-props="{ theme: { light: 'vitesse-light', dark: 'vitesse-dark' } }"
|
|
168
|
+
:content="doc"
|
|
169
|
+
/>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
语言图标默认使用内置的 `material` theme。进阶接入可以用导出的 helper 查看或切换 icon theme,也可以在 `app.use(VueRendererMarkdown, { iconTheme })` 时指定初始主题:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { getRegisteredThemes, setIconTheme } from 'markstream-vue'
|
|
176
|
+
|
|
177
|
+
console.log(getRegisteredThemes()) // ['material']
|
|
178
|
+
setIconTheme('material')
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
如果你需要接自己的图标包,可以继续使用 `registerIconTheme()` 注册。
|
|
182
|
+
|
|
162
183
|
按需启用重型依赖:
|
|
163
184
|
|
|
164
185
|
```ts
|
package/dist/CodeBlockNode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,a=(e,n)=>{for(var t in n||(n={}))l.call(n,t)&&r(e,t,n[t]);if(o)for(var t of o(n))i.call(n,t)&&r(e,t,n[t]);return e},u=(e,o)=>n(e,t(o)),d=(e,n,t)=>new Promise((o,l)=>{var i=e=>{try{a(t.next(e))}catch(n){l(n)}},r=e=>{try{a(t.throw(e))}catch(n){l(n)}},a=e=>e.done?o(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 k,getCurrentInstance as x,ref as C,watch as S,onBeforeUnmount as M,nextTick as B,createElementBlock as O,normalizeStyle as E,renderSlot as L,createCommentVNode as P,Fragment as H,withDirectives as D,vShow as N}from"vue";import{b as F,_,n as z,k as T,u as R,l as j,c as $,m as A,o as U,p as W,h as q,q as V,e as I,v as X}from"./exports.js";const Y={class:"markstream-vue"},G={class:"html-preview-frame__header"},J={class:"html-preview-frame__title"},K={class:"html-preview-frame__label"},Q=["srcdoc"],Z=/* @__PURE__ */_(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},onClose:{type:Function},title:{}},setup(e){const n=e,{t}=F(),o=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>`});function l(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",l)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",l)}),(e,l)=>(m(),p(h,{to:"body"},[g("div",Y,[g("div",{class:y(["html-preview-frame__backdrop",{"html-preview-frame__backdrop--dark":n.isDark}]),onClick:l[2]||(l[2]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})},[g("div",{class:y(["html-preview-frame",{"html-preview-frame--dark":n.isDark}]),onClick:l[1]||(l[1]=w(()=>{},["stop"]))},[g("div",G,[g("div",J,[l[3]||(l[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",K,b(n.title||k(t)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:y(["html-preview-frame__close",{"html-preview-frame__close--dark":n.isDark}]),onClick:l[0]||(l[0]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})}," × ",2)]),g("iframe",{class:"html-preview-frame__iframe",sandbox:"allow-scripts allow-same-origin",srcdoc:o.value},null,8,Q)],2)],2)])]))}}),[["__scopeId","data-v-296dd89d"]]);let ee=null,ne=null,te=null,oe=null,le=null,ie=null;const re=/* @__PURE__ */new WeakMap;let ae=0;const ue=["data-markstream-enhanced"],de={class:"code-header-main"},se=["innerHTML"],ce={class:"code-header-copy"},ve={class:"code-header-title"},fe={key:0,class:"code-header-caption"},me={class:"code-header-actions"},pe=["aria-label"],he={class:"code-diff-stat removed"},ge={class:"code-diff-stat added"},ye=["aria-pressed"],we=["disabled"],be=["disabled"],ke=["disabled"],xe=["aria-label"],Ce={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"},Se={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"},Me=["aria-pressed"],Be={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"},Oe={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"},Ee=["aria-label"],Le={class:"code-editor-layer"},Pe={class:"sr-only","aria-live":"polite",role:"status"},He="__markstreamMonacoPassiveTouch__",De=/* @__PURE__ */_(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:n}){var t;const o=e,l=n;const i=x(),r=c(()=>{const e=null==i?void 0:i.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:s}=F(),v=C(null),h=C(null),w=C(!1),_=C(z(o.node.language)),Y=c(()=>T(_.value)),G=c(()=>"plaintext"===Y.value),J=C(!1),K=C(!1),Q=C(!1),De=C(!1),Ne=C(!1);let Fe=!1,_e=null;const ze=C(null);let Te=0;const Re=R(),je=C(null),$e=C("undefined"==typeof window);"undefined"!=typeof window&&S(()=>h.value,e=>{var n;if(null==(n=je.value)||n.destroy(),je.value=null,!e)return void($e.value=!1);const t=Re(e,{rootMargin:"400px"});je.value=t,$e.value=t.isVisible.value,t.whenVisible.then(()=>{$e.value=!0})},{immediate:!0}),M(()=>{var e;Fe=!0,null==(e=je.value)||e.destroy(),je.value=null});let Ae=null,Ue=null,We=()=>{},qe=()=>{},Ve=()=>null,Ie=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Xe=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Ye=()=>{},Ge=()=>{},Je=()=>{},Ke=null,Qe=()=>{var e;return String(null!=(e=o.node.language)?e:"plaintext")},Ze=()=>d(null,null,function*(){});const en=[],nn=[];let tn=null;const on=c(()=>o.node.diff),ln=C({removed:0,added:0}),rn=c(()=>`-${ln.value.removed} +${ln.value.added}`),an=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function un(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return u(a(a({},an),t),{enabled:null==(n=t.enabled)||n})}return a({},an)}const dn=c(()=>{var e;const n=o.monacoOptions?a({},o.monacoOptions):{};if(!on.value)return n;const t=void 0===n.diffHideUnchangedRegions?a({},an):un(n.diffHideUnchangedRegions),l=void 0===n.hideUnchangedRegions?void 0:un(n.hideUnchangedRegions),i=null!=(e=n.diffUnchangedRegionStyle)?e:"line-info";return u(a(a(a({},{maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:12,lineNumbersMinChars:2,glyphMargin:!1,fontSize:13,lineHeight:30,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,padding:{top:10,bottom:"line-info"===i||"line-info-basic"===i||"metadata"===i?22:14},diffHideUnchangedRegions:t,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:i,diffHunkActionsOnHover:!0,diffHunkHoverHideDelayMs:160}),n),void 0===l?{}:{hideUnchangedRegions:l}),{diffHideUnchangedRegions:t})}),sn=c(()=>on.value?"diff":"single"),cn=C(sn.value),vn=C(!1),fn=c(()=>{var e;const n=null==(e=o.monacoOptions)?void 0:e.wordWrap;return null==n||"off"!==String(n)}),mn=c(()=>!vn.value&&!De.value),pn=C(!1);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield j();if(Fe)return;if(!e)return void(vn.value=!0);const n=e.useMonaco,t=e.detectLanguage;if("function"==typeof t&&(Qe=t),"function"==typeof n){const e=vt();if(e&&o.themes&&Array.isArray(o.themes)&&!o.themes.includes(e))throw new Error("Preferred theme not in provided themes array");tn=ht();const t=n(tn);Ae=t.createEditor||Ae,Ue=t.createDiffEditor||Ue,We=t.updateCode||We,qe=t.updateDiff||qe,Ve=t.getEditor||Ve,Ie=t.getEditorView||Ie,Xe=t.getDiffEditorView||Xe,Ye=t.cleanupEditor||Ye,Ge=t.safeClean||t.cleanupEditor||Ge,Je=t.refreshDiffPresentation||Je,Ze=t.setTheme||Ze,Ne.value=!0,!Fe&&v.value&&(yield dt(v.value))}}catch(e){if(Fe)return;vn.value=!0}});const hn=C("number"==typeof(null==(t=o.monacoOptions)?void 0:t.fontSize)?o.monacoOptions.fontSize:Number.NaN),gn=C(hn.value),yn=c(()=>{const e=hn.value,n=gn.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),wn=c(()=>{var e;const n=null==(e=o.monacoOptions)?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=gn.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:12}),bn=c(()=>{var e;const n=null==(e=o.monacoOptions)?void 0:e.lineHeight;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:Math.round(1.5*wn.value)}),kn=c(()=>{var e;const n=null==(e=o.monacoOptions)?void 0:e.tabSize;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:4}),xn=c(()=>{const e=o.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}),Cn=c(()=>{var e;const n=null==(e=o.monacoOptions)?void 0:e.fontFamily;return a(a({fontSize:`${wn.value}px`,lineHeight:`${bn.value}px`,tabSize:kn.value},null!=xn.value?{minHeight:`${xn.value}px`}:{}),"string"==typeof n&&n.trim()?{"--markstream-code-font-family":n.trim()}:{})}),Sn=c(()=>null!=xn.value&&!De.value),Mn=c(()=>{if(Sn.value)return{minHeight:`${xn.value}px`}}),Bn=c(()=>{if(null!=xn.value)return{minHeight:`${xn.value}px`}});function On(){var e,n,t,o,l;try{const i=on.value?null!=(t=null==(n=null==(e=Xe())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t:Xe():Ie(),r=Ve(),a=null==(o=null==r?void 0:r.EditorOption)?void 0:o.fontInfo;if(i&&null!=a){const e=null==(l=i.getOption)?void 0:l.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=v.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 En(e){var n,t;try{const o=Ve(),l=null==(n=null==o?void 0:o.EditorOption)?void 0:n.lineHeight;if(null!=l){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,l);if("number"==typeof n&&n>0)return n}}catch(i){}const o=function(){try{const e=v.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(i){}return null}();if(o&&o>0)return o;const l=Number.isFinite(gn.value)&&gn.value>0?gn.value:12;return Math.max(12,Math.round(1.35*l))}function Ln(e,n){return"number"!=typeof e||"number"!=typeof n||e<1||n<e?0:n-e+1}function Pn(e){if(!e)return[];const n=e.split(/\r?\n/);return 1===n.length&&""===n[0]?[]:n}function Hn(){var e,n;on.value?ln.value=function(e,n){const t=Pn(e),o=Pn(n);let l=0,i=t.length-1,r=o.length-1;for(;l<=i&&l<=r&&t[l]===o[l];)l++;for(;i>=l&&r>=l&&t[i]===o[r];)i--,r--;return{removed:Math.max(0,i-l+1),added:Math.max(0,r-l+1)}}(String(null!=(e=o.node.originalCode)?e:""),String(null!=(n=o.node.updatedCode)?n:"")):ln.value={removed:0,added:0}}function Dn(){var e;if(on.value)try{const n=Xe(),t=null==(e=null==n?void 0:n.getLineChanges)?void 0:e.call(n);if(!Array.isArray(t))return void Hn();let o=0,l=0;for(const e of t)o+=Ln(e.originalStartLineNumber,e.originalEndLineNumber),l+=Ln(e.modifiedStartLineNumber,e.modifiedEndLineNumber);ln.value={removed:o,added:l}}catch(n){Hn()}else ln.value={removed:0,added:0}}function Nn(){var e;if(Number.isFinite(gn.value)&&gn.value>0&&Number.isFinite(hn.value))return gn.value;const n=On();return"number"==typeof(null==(e=o.monacoOptions)?void 0:e.fontSize)?(hn.value=o.monacoOptions.fontSize,gn.value=o.monacoOptions.fontSize,gn.value):n&&n>0?(hn.value=n,gn.value=n,n):(hn.value=12,gn.value=12,12)}function Fn(){var e,n,t,o,l,i,r,a,u,d,s,c,v,f;try{const m=on.value?Xe():null,p=on.value?m:Ie();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==(o=null==f?void 0:f.layout)||o.call(f);const p=(null==(l=null==v?void 0:v.getContentHeight)?void 0:l.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),k=Math.max(En(v),En(f));return Math.ceil(b*(k+1.5)+0+1)}if(null==p?void 0:p.getContentHeight){null==(v=null==p?void 0:p.layout)||v.call(p);const e=p.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==p?void 0:p.getModel)?void 0:f.call(p);let g=1;h&&"function"==typeof h.getLineCount&&(g=h.getLineCount());const y=En(p);return Math.ceil(g*(y+1.5)+0+1)}catch(m){return null}}function _n(e){const n=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!n||n.length<3)return null;const[t,o,l]=n.slice(0,3).map(Number);return.2126*t+.7152*o+.0722*l}function zn(){var e,n,t,o,l,i,r,a;const u=v.value,d=h.value;if(!u||!d)return;if(on.value)return d.style.removeProperty("--vscode-editor-foreground"),d.style.removeProperty("--vscode-editor-background"),void d.style.removeProperty("--vscode-editor-selectionBackground");const s=u.querySelector(".monaco-editor")||u,c=s.querySelector(".monaco-editor-background")||s,f=s.querySelector(".view-lines")||s;let m=null,p=null,g=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(m=window.getComputedStyle(s),p=c===s?m:window.getComputedStyle(c),g=f===s?m:window.getComputedStyle(f))}catch(C){m=null,p=null,g=null}const y=String(null!=(e=null==m?void 0:m.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),w=String(null!=(n=null==m?void 0:m.getPropertyValue("--vscode-editor-background"))?n:"").trim(),b=String(null!=(o=null!=(t=null==m?void 0:m.getPropertyValue("--vscode-editor-selectionBackground"))?t:null==m?void 0:m.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?o:"").trim(),k=y||String(null!=(i=null!=(l=null==g?void 0:g.color)?l:null==m?void 0:m.color)?i:"").trim(),x=w||String(null!=(a=null!=(r=null==p?void 0:p.backgroundColor)?r:null==m?void 0:m.backgroundColor)?a:"").trim();if(function(e,n,t){if(!G.value)return!1;const o=_n(e),l=_n(n);return t?null!=o&&o>170||null!=l&&l<110:null!=o&&o<85||null!=l&&l>190}(x,k,d.classList.contains("is-dark")))return d.style.removeProperty("--vscode-editor-foreground"),d.style.removeProperty("--vscode-editor-background"),void d.style.removeProperty("--vscode-editor-selectionBackground");k&&d.style.setProperty("--vscode-editor-foreground",k),x&&d.style.setProperty("--vscode-editor-background",x),b&&d.style.setProperty("--vscode-editor-selectionBackground",b)}const Tn=/auto|scroll|overlay/i;function Rn(e,n,t){var o;if("undefined"==typeof window)return;const l=Math.ceil(n),i=Math.ceil(t)-l;if(!i)return;const r=function(e){var n,t;if("undefined"==typeof window)return null;const o=null!=(n=null==e?void 0:e.ownerDocument)?n:document,l=o.scrollingElement||o.documentElement||o.body;let i=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;i&&i!==o.body&&i!==l;){const e=window.getComputedStyle(i),n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(Tn.test(n)||Tn.test(t))return i;i=i.parentElement}return l}(e);if(!r)return;const a=null!=(o=e.ownerDocument)?o: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 jn(){try{const e=v.value;if(!e)return;const n=e.getBoundingClientRect().height,t=Fn();if(null!=t&&t>0){const o=Math.ceil(t);e.style.minHeight="0px",e.style.height=`${o}px`,e.style.maxHeight="none",e.style.overflow="visible",Rn(e,n,o)}}catch(e){}}function $n(){for(var e,n;en.length>0;)try{null==(n=null==(e=en.pop())?void 0:e.dispose)||n.call(e)}catch(t){}null!=_e&&(X(_e),_e=null)}function An(){for(var e;nn.length>0;)try{null==(e=nn.pop())||e()}catch(n){}}function Un(){if(An(),!on.value)return;const e=v.value;if(!e)return;const n=e.querySelector(".monaco-diff-editor");if(!n||n.classList.contains("side-by-side"))return;const t=Array.from(n.querySelectorAll(".editor.original .diff-hidden-lines")),o=Array.from(n.querySelectorAll(".editor.modified .diff-hidden-lines")),l=Math.min(t.length,o.length);for(let i=0;i<l;i++){const e=t[i],n=o[i].querySelector("a"),l=e.querySelector(".center > div:first-child");if(!n||!l)continue;const r=document.createElement("button");r.type="button",r.className="markstream-inline-fold-proxy";const a=n.getAttribute("title")||"Show Unchanged Region";r.title=a,r.setAttribute("aria-label",a);const u=n.querySelector(".codicon"),d=document.createElement("span");d.className=(null==u?void 0:u.className)||"codicon codicon-unfold",r.append(d);const s=e=>{e.preventDefault(),e.stopPropagation()},c=e=>{e.preventDefault(),e.stopPropagation(),n.click()},v=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),n.click())};r.addEventListener("mousedown",s),r.addEventListener("click",c),r.addEventListener("keydown",v),l.replaceChildren(r),nn.push(()=>{r.removeEventListener("mousedown",s),r.removeEventListener("click",c),r.removeEventListener("keydown",v),l.contains(r)&&l.replaceChildren()})}}function Wn(){null==_e&&(_e=$(()=>{_e=null,$(()=>{Un(),K.value||(J.value?jn():Vn())})}))}function qn(e,n,t){const o=Math.min(n,t),l=n>t+1;return e.style.minHeight="0px",e.style.height=`${Math.ceil(o)}px`,e.style.maxHeight=`${Math.ceil(t)}px`,e.style.overflow=l?"auto":"hidden",Math.ceil(o)}function Vn(){var e;try{const n=v.value;if(!n)return;const t=n.getBoundingClientRect().height,l=function(){var e,n;const t=null!=(n=null==(e=o.monacoOptions)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t)return t;const l=String(t).match(/^(\d+(?:\.\d+)?)/);return l?Number.parseFloat(l[1]):500}();if(Te>0&&(Te--,null!=ze.value))return void Rn(n,t,qn(n,ze.value,l));const i=Fn();if(null!=i&&i>0)return void Rn(n,t,qn(n,i,l));if(null!=ze.value)return void Rn(n,t,qn(n,ze.value,l));const r=Math.ceil((null==(e=n.getBoundingClientRect)?void 0:e.call(n).height)||0);if(r>0)return void Rn(n,t,qn(n,r,l));const a=Number.parseFloat(n.style.height);!Number.isNaN(a)&&a>0?Rn(n,t,qn(n,a,l)):Rn(n,t,qn(n,l,l))}catch(n){}}const In=c(()=>o.isShowPreview&&("html"===_.value||"svg"===_.value));S(()=>o.node.language,e=>{_.value=z(e)}),S(()=>[o.node.originalCode,o.node.updatedCode,on.value],()=>{Hn(),$(()=>Dn())},{immediate:!0}),S(()=>[o.node.originalCode,o.node.updatedCode,Y.value,on.value],e=>d(null,[e],function*([e,n,t,l]){if(!1!==o.stream&&l){if(Ae&&!Q.value&&v.value)try{yield dt(v.value)}catch(i){}qe(String(null!=e?e:""),String(null!=n?n:""),Y.value),J.value&&$(()=>jn())}})),S(()=>o.node.code,e=>d(null,null,function*(){if(!1!==o.stream&&(_.value||(_.value=z(Qe(e))),!on.value)){if(Ae&&!Q.value&&v.value)try{yield dt(v.value)}catch(n){}We(e,Y.value),J.value&&$(()=>jn())}}));const Xn=c(()=>{const e=_.value;return e?A[e]||e.charAt(0).toUpperCase()+e.slice(1):A[""]||"Plain Text"});const Yn=c(()=>{var e;return function(e){const n=function(e){var n,t;const o=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";if(o.length<3)return"";const l=o[0];if("`"!==l&&"~"!==l||o[1]!==l||o[2]!==l)return"";let i=3;for(;o[i]===l;)i+=1;return o.slice(i).trim()}(e);if(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const o="diff"===t[0]?t.slice(1):t;for(const l of o){const e=l.includes(":")?l.slice(l.indexOf(":")+1):l;if(e&&/[./\\-]/.test(e))return e}return""}(String(null!=(e=o.node.raw)?e:""))}),Gn=c(()=>Yn.value||Xn.value),Jn=c(()=>Yn.value?on.value?`Diff / ${Xn.value}`:Xn.value:""),Kn=c(()=>(U.value,W(_.value||""))),Qn=c(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(o.minWidth),l=n(o.maxWidth);return t&&(e.minWidth=t),l&&(e.maxWidth=l),on.value?(e.color="var(--markstream-diff-shell-fg)",e.borderColor="var(--markstream-diff-shell-border)"):(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}),Zn=c(()=>{if(!on.value)return{color:"var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))",backgroundColor:"var(--vscode-editor-background, var(--markstream-code-fallback-bg))"}}),et=c(()=>!1!==o.showTooltips);function nt(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(o.node.code)),w.value=!0,l("copy",o.node.code),setTimeout(()=>{w.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function tt(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}function ot(e,n,t="top"){if(!et.value)return;const l=tt(e);if(!l)return;const i=e,r=null!=(null==i?void 0:i.clientX)&&null!=(null==i?void 0:i.clientY)?{x:i.clientX,y:i.clientY}:void 0;I(l,n,t,!1,r,o.isDark)}function lt(){et.value&&q()}function it(e){if(!et.value)return;const n=tt(e);if(!n)return;const t=w.value?s("common.copied")||"Copied":s("common.copy")||"Copy",l=e,i=null!=(null==l?void 0:l.clientX)&&null!=(null==l?void 0:l.clientY)?{x:l.clientX,y:l.clientY}:void 0;I(n,t,"top",!1,i,o.isDark)}function rt(){var e,n,t;if(K.value=!K.value,K.value){if(v.value){const t=Math.ceil((null==(n=(e=v.value).getBoundingClientRect)?void 0:n.call(e).height)||0);t>0&&(ze.value=t)}ut(!1)}else{J.value&&ut(!0),v.value&&null!=ze.value&&(v.value.style.height=`${ze.value}px`);const e=on.value?Xe():Ie();try{null==(t=null==e?void 0:e.layout)||t.call(e)}catch(o){}Te=2,$(()=>{J.value?jn():Vn()})}}function at(){if(!In.value)return;const e=_.value;if(r.value){const n="html"===e?"text/html":"image/svg+xml",t="html"===e?s("artifacts.htmlPreviewTitle")||"HTML Preview":s("artifacts.svgPreviewTitle")||"SVG Preview";return void l("previewCode",{node:o.node,artifactType:n,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(pn.value=!pn.value)}function ut(e){var n,t;try{if(on.value){const t=Xe();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}else{const n=Ie();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}}catch(o){}}function dt(e){if(!Ae||Fe)return null;if(function(){var e;try{const n=window;if(n[He])return;const t=null==(e=window.Element)?void 0:e.prototype,o=null==t?void 0:t.addEventListener;if(!t||!o)return;t.addEventListener=function(e,n,t){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)?o.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)):o.call(this,e,n,t)},n[He]=!0}catch(n){}}(),Ke)return Ke;if(Q.value&&De.value)return Promise.resolve();Q.value=!0;const n=d(null,null,function*(){yield function(e){return d(this,null,function*(){var n,t,l;if(!Ae||Fe)return;if($n(),An(),function(e){e.replaceChildren()}(e),Fe)return;if(on.value?(Ge(),Ue?yield Ue(e,String(null!=(n=o.node.originalCode)?n:""),String(null!=(t=o.node.updatedCode)?t:""),Y.value):yield Ae(e,o.node.code,Y.value)):yield Ae(e,o.node.code,Y.value),Fe)return;const i=on.value?Xe():Ie();if("number"==typeof(null==(l=o.monacoOptions)?void 0:l.fontSize))null==i||i.updateOptions({fontSize:o.monacoOptions.fontSize,automaticLayout:!1}),hn.value=o.monacoOptions.fontSize,gn.value=o.monacoOptions.fontSize;else{const e=On();e&&e>0?(hn.value=e,gn.value=e):(hn.value=12,gn.value=12)}if(J.value||K.value||Vn(),!1===o.loading){if(yield B(),Fe)return;$(()=>{Fe||(J.value&&!K.value?jn():K.value||Vn())})}yield B(),Fe||(De.value=!0,function(){var e,n,t,o,l;if($n(),on.value){const o=Xe(),l=null==(e=null==o?void 0:o.getOriginalEditor)?void 0:e.call(o),r=null==(n=null==o?void 0:o.getModifiedEditor)?void 0:n.call(o),a=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const o=t.call(e,()=>Wn());o&&en.push(o)}catch(t){}};try{const e=null==(t=null==o?void 0:o.onDidUpdateDiff)?void 0:t.call(o,()=>{Wn(),$(()=>Dn())});e&&en.push(e)}catch(i){}a(l,"onDidContentSizeChange"),a(r,"onDidContentSizeChange"),a(l,"onDidLayoutChange"),a(r,"onDidLayoutChange")}else{const e=Ie();try{const n=null==(o=null==e?void 0:e.onDidContentSizeChange)?void 0:o.call(e,()=>Wn());n&&en.push(n)}catch(i){}try{const n=null==(l=null==e?void 0:e.onDidLayoutChange)?void 0:l.call(e,()=>Wn());n&&en.push(n)}catch(i){}}}(),zn(),Un(),Dn(),Wn())})}(e)}).finally(()=>{Ke===n&&(Ke=null)});return Ke=n,n}S(et,e=>{e||q()}),S(()=>gn.value,(e,n)=>{const t=on.value?Xe():Ie();t&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(t.updateOptions({fontSize:e}),J.value&&!K.value&&jn())},{flush:"post",immediate:!1});const st=S(()=>[v.value,on.value,o.stream,o.loading,Ne.value,$e.value],e=>d(null,[e],function*([e,n,t,o,l,i]){if(!e||!Ae)return;if(!i)return;if(!1===t&&!1!==o)return;const r=dt(e);if(r){try{yield r}catch(a){De.value=!1}st()}}));function ct(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function vt(){var e;const n=o.isDark?o.darkTheme:o.lightTheme,t=null==(e=dn.value)?void 0:e.theme,l=null!=n?n:t,i=Array.isArray(o.themes)?o.themes:[];if(!i.length||null==l)return l;const r=ct(l),a=i.map(e=>ct(e)).filter(e=>!!e);if(!r||a.includes(r))return l;const u=ct(t);return null!=t&&u&&a.includes(u)?t:i[0]}S(sn,(e,n)=>d(null,null,function*(){if(e===n)return;if(cn.value=e,!Ae||!v.value)return;if(!Q.value)return;if(!1===o.stream&&!1!==o.loading)return;if(!$e.value)return;const t=Ke;if(t){try{yield t}catch(l){}if(Fe||!v.value)return}try{De.value=!1,Q.value=!1,$n(),An(),Ge(),yield B(),yield dt(v.value)}catch(i){De.value=!1}}));const ft=c(()=>function(e){var n;const t=(null!=(n=ct(e))?n:"").toLowerCase();return t?["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=>t.includes(e))&&!["light","latte","dawn","lotus"].some(e=>t.includes(e)):!!o.isDark}(vt())),mt=c(()=>{var e;if(!on.value)return ft.value?"dark":"light";const n=null==(e=dn.value)?void 0:e.diffAppearance;return"light"===n||"dark"===n?n:o.isDark?"dark":"light"}),pt=c(()=>on.value?"dark"===mt.value:ft.value);function ht(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:o.themes},dn.value||{}),{theme:vt()}),on.value?{diffAppearance:mt.value}:{}),{onThemeChange(){zn()}})}function gt(){const e=ht();if(!tn)return tn=e,tn;for(const n of Object.keys(tn))n in e||delete tn[n];return Object.assign(tn,e),tn}const yt=c(()=>{var e,n,t,o,l,i,r,a,u,d,s,c,v,f;return JSON.stringify({diffLineStyle:null!=(n=null==(e=dn.value)?void 0:e.diffLineStyle)?n:"background",diffUnchangedRegionStyle:null!=(o=null==(t=dn.value)?void 0:t.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:null==(i=null==(l=dn.value)?void 0:l.diffHideUnchangedRegions)||i,renderSideBySide:null==(a=null==(r=dn.value)?void 0:r.renderSideBySide)||a,enableSplitViewResizing:null==(d=null==(u=dn.value)?void 0:u.enableSplitViewResizing)||d,ignoreTrimWhitespace:null==(c=null==(s=dn.value)?void 0:s.ignoreTrimWhitespace)||c,originalEditable:null!=(f=null==(v=dn.value)?void 0:v.originalEditable)&&f})});S(()=>[o.monacoOptions,$e.value],()=>{var e,n;if(gt(),!Ae||!$e.value)return;const t=on.value?Xe():Ie(),l="number"==typeof(null==(e=o.monacoOptions)?void 0:e.fontSize)?o.monacoOptions.fontSize:Number.isFinite(gn.value)?gn.value:void 0;"number"==typeof l&&Number.isFinite(l)&&l>0&&(null==(n=null==t?void 0:t.updateOptions)||n.call(t,{fontSize:l})),J.value&&!K.value?jn():K.value||Vn()},{deep:!0}),S(()=>[vt(),mt.value,Ne.value,Q.value,$e.value],()=>{Ne.value&&Q.value&&$e.value&&function(){gt();const e=vt(),n=()=>{on.value&&Je(),$(()=>{zn(),Wn()})};e?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=re.get(e);if(t)return t;try{const n=JSON.stringify(e);if(n)return re.set(e,n),n}catch(n){}const o="__theme_"+ ++ae;return re.set(e,o),o}return String(e)}(n);return t?(ie=e,ee||le!==t?ee?(oe===t||ne===t||(te=n,oe=t),ee):(te=n,oe=t,ee=d(null,null,function*(){for(;oe&&null!=te;){const t=te,o=oe;if(te=null,oe=null,le!==o)try{ne=o,yield(null!=ie?ie:e)(t),le=o}catch(n){}}}).finally(()=>{ee=null,ne=null}),ee):Promise.resolve()):Promise.resolve()}(Ze,e).then(n).catch(e=>{}):n()}()},{flush:"post"}),S(()=>[yt.value,Ne.value,$e.value],(e,n)=>d(null,[e,n],function*([e,n,t],[l]){if(gt(),!n||!t)return;if(!Ae||!v.value)return;if(!Q.value)return;if(e===l)return;if(!1===o.stream&&!1!==o.loading)return;const i=Ke;if(i){try{yield i}catch(r){}if(Fe||!v.value)return}try{De.value=!1,Q.value=!1,$n(),An(),Ge(),yield B(),yield dt(v.value)}catch(a){De.value=!1}}),{flush:"post"});const wt=S(()=>[o.loading,$e.value],(e,n)=>d(null,[e,n],function*([e,n],t){if(!n)return;if(e)return;const l=null==t?void 0:t[0],i=void 0!==l&&!1!==l;yield B(),$(()=>{d(null,null,function*(){var e;try{if(i&&Q.value)if(on.value&&v.value){const e=Ke;if(e)try{yield e}catch(n){}De.value=!1,Q.value=!1,$n(),An(),Ge(),v.value.replaceChildren(),yield B(),yield dt(v.value)}else We(String(null!=(e=o.node.code)?e:""),Y.value);K.value||(J.value?jn():Vn()),wt()}catch(t){}})})}),{immediate:!0,flush:"post"});return f(()=>{$n(),An(),Ye()}),(n,t)=>vn.value?(m(),p(k(V),{key:0,node:o.node,loading:o.loading},null,8,["node","loading"])):(m(),O("div",{key:1,ref_key:"container",ref:h,style:E(Qn.value),class:y(["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",[{"is-rendering":o.loading,"is-dark":pt.value,"is-diff":on.value,"is-plain-text":G.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":De.value&&!vn.value?"true":"false"},[o.showHeader?(m(),O("div",{key:0,class:"code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:E(Zn.value)},[L(n.$slots,"header-left",{},()=>[g("div",de,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:Kn.value},null,8,se),g("div",ce,[g("div",ve,b(Gn.value),1),Jn.value?(m(),O("div",fe,b(Jn.value),1)):P("",!0)])])],!0),L(n.$slots,"header-right",{},()=>[g("div",me,[on.value?(m(),O("div",{key:0,class:"code-diff-stats","aria-label":rn.value},[g("span",he,"-"+b(ln.value.removed),1),g("span",ge,"+"+b(ln.value.added),1)],8,pe)):P("",!0),o.showCollapseButton?(m(),O("button",{key:1,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":K.value,onClick:rt,onMouseenter:t[0]||(t[0]=e=>ot(e,K.value?k(s)("common.expand")||"Expand":k(s)("common.collapse")||"Collapse")),onFocus:t[1]||(t[1]=e=>ot(e,K.value?k(s)("common.expand")||"Expand":k(s)("common.collapse")||"Collapse")),onMouseleave:lt,onBlur:lt},[(m(),O("svg",{style:E({rotate:K.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"},[...t[18]||(t[18]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,ye)):P("",!0),o.showFontSizeButtons&&o.enableFontSizeControl?(m(),O(H,{key:2},[g("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!!Number.isFinite(gn.value)&&gn.value<=10,onClick:t[2]||(t[2]=e=>function(){const e=Nn(),n=Math.max(10,e-1);gn.value=n}()),onMouseenter:t[3]||(t[3]=e=>ot(e,k(s)("common.decrease")||"Decrease")),onFocus:t[4]||(t[4]=e=>ot(e,k(s)("common.decrease")||"Decrease")),onMouseleave:lt,onBlur:lt},[...t[19]||(t[19]=[g("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"},[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)])],40,we),g("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!yn.value||gn.value===hn.value,onClick:t[5]||(t[5]=e=>(Nn(),void(Number.isFinite(hn.value)&&(gn.value=hn.value)))),onMouseenter:t[6]||(t[6]=e=>ot(e,k(s)("common.reset")||"Reset")),onFocus:t[7]||(t[7]=e=>ot(e,k(s)("common.reset")||"Reset")),onMouseleave:lt,onBlur:lt},[...t[20]||(t[20]=[g("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"},[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),g("path",{d:"M3 3v5h5"})])],-1)])],40,be),g("button",{type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:!!Number.isFinite(gn.value)&&gn.value>=36,onClick:t[8]||(t[8]=e=>function(){const e=Nn(),n=Math.min(36,e+1);gn.value=n}()),onMouseenter:t[9]||(t[9]=e=>ot(e,k(s)("common.increase")||"Increase")),onFocus:t[10]||(t[10]=e=>ot(e,k(s)("common.increase")||"Increase")),onMouseleave:lt,onBlur:lt},[...t[21]||(t[21]=[g("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"},[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)])],40,ke)],64)):P("",!0),o.showCopyButton?(m(),O("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":w.value?k(s)("common.copied")||"Copied":k(s)("common.copy")||"Copy",onClick:nt,onMouseenter:t[11]||(t[11]=e=>it(e)),onFocus:t[12]||(t[12]=e=>it(e)),onMouseleave:lt,onBlur:lt},[w.value?(m(),O("svg",Se,[...t[23]||(t[23]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(m(),O("svg",Ce,[...t[22]||(t[22]=[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),g("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,xe)):P("",!0),o.showExpandButton?(m(),O("button",{key:4,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":J.value,onClick:t[13]||(t[13]=e=>function(e){if(J.value=!J.value,e&&et.value){const n=tt(e);if(n){const e=J.value?s("common.collapse")||"Collapse":s("common.expand")||"Expand";I(n,e,"top",!1,void 0,o.isDark)}}const n=on.value?Xe():Ie(),t=v.value;n&&t&&(J.value?(ut(!0),t.style.maxHeight="none",t.style.overflow="visible",jn()):(ut(!1),t.style.overflow="auto",Vn()))}(e)),onMouseenter:t[14]||(t[14]=e=>ot(e,J.value?k(s)("common.collapse")||"Collapse":k(s)("common.expand")||"Expand")),onFocus:t[15]||(t[15]=e=>ot(e,J.value?k(s)("common.collapse")||"Collapse":k(s)("common.expand")||"Expand")),onMouseleave:lt,onBlur:lt},[J.value?(m(),O("svg",Be,[...t[24]||(t[24]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(m(),O("svg",Oe,[...t[25]||(t[25]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])]))],40,Me)):P("",!0),In.value&&o.showPreviewButton?(m(),O("button",{key:5,type:"button",class:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":k(s)("common.preview")||"Preview",onClick:at,onMouseenter:t[16]||(t[16]=e=>ot(e,k(s)("common.preview")||"Preview")),onFocus:t[17]||(t[17]=e=>ot(e,k(s)("common.preview")||"Preview")),onMouseleave:lt,onBlur:lt},[...t[26]||(t[26]=[g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24"},[g("g",{fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"},[g("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"}),g("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,Ee)):P("",!0)])],!0)],4)):P("",!0),D(g("div",Le,[g("div",{ref_key:"codeEditor",ref:v,class:y(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":mn.value}]]),style:E(Mn.value)},null,6),mn.value?(m(),p(k(V),{key:0,class:y(["code-pre-fallback",{"is-wrap":fn.value}]),style:E(Cn.value),node:o.node},null,8,["class","style","node"])):P("",!0)],512),[[N,!(K.value||!e.stream&&e.loading)]]),pn.value&&!r.value&&In.value&&"html"===_.value?(m(),p(Z,{key:1,code:o.node.code,"is-dark":o.isDark,"on-close":()=>pn.value=!1},null,8,["code","is-dark","on-close"])):P("",!0),D(g("div",{class:"code-loading-placeholder",style:E(Bn.value)},[L(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[27]||(t[27]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)],4),[[N,!e.stream&&e.loading]]),g("span",Pe,b(w.value?k(s)("common.copied")||"Copied":""),1)],14,ue))}}),[["__scopeId","data-v-1a55f98f"]]);export{De as default};
|
|
1
|
+
var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,a=(n,t,l)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l,r=(e,n)=>{for(var t in n||(n={}))o.call(n,t)&&a(e,t,n[t]);if(l)for(var t of l(n))i.call(n,t)&&a(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{r(t.next(e))}catch(n){o(n)}},a=e=>{try{r(t.throw(e))}catch(n){o(n)}},r=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,a);r((t=t.apply(e,n)).next())});import{defineComponent as s,computed as c,onMounted as v,onUnmounted as f,openBlock as p,createBlock as m,Teleport as h,createElementVNode as g,normalizeClass as y,withModifiers as w,toDisplayString as b,unref as k,getCurrentInstance as S,ref as C,watch as x,onBeforeUnmount as O,nextTick as E,createElementBlock as L,normalizeStyle as M,createVNode as P,createSlots as B,withCtx as H,withDirectives as z,createCommentVNode as N,vShow as D,renderSlot as _}from"vue";import{b as T,_ as F,n as R,k as $,u as j,l as A,c as U,m as W,o as q,p as V,h as I,q as G,v as J,e as X,w as Y}from"./exports.js";const K={class:"html-preview-frame__header"},Q={class:"html-preview-frame__title"},Z={class:"html-preview-frame__label"},ee=["srcdoc"],ne=/* @__PURE__ */F(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},onClose:{type:Function},title:{}},setup(e){const n=e,{t}=T(),l=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>`});function o(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",o)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",o)}),(e,o)=>(p(),m(h,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:n.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:o[2]||(o[2]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})},[g("div",{class:"html-preview-frame",onClick:o[1]||(o[1]=w(()=>{},["stop"]))},[g("div",K,[g("div",Q,[o[3]||(o[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",Z,b(n.title||k(t)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:o[0]||(o[0]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})}," × ")]),g("iframe",{class:"html-preview-frame__iframe",sandbox:"allow-scripts allow-same-origin",srcdoc:l.value},null,8,ee)])])],2)]))}}),[["__scopeId","data-v-fd3f9c21"]]);let te=null,le=null,oe=null,ie=null,ae=null,re=null;const ue=/* @__PURE__ */new WeakMap;let de=0;const se=["data-markstream-enhanced"],ce={class:"code-header-main"},ve=["innerHTML"],fe={class:"code-header-copy"},pe={class:"code-header-title"},me={key:0,class:"code-header-caption"},he={class:"code-editor-layer"},ge="__markstreamMonacoPassiveTouch__",ye=/* @__PURE__ */F(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:n}){var t;const l=e,o=n;const i=S(),a=c(()=>{const e=null==i?void 0:i.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:s}=T(),v=C(null),h=C(null),w=C(!1),F=C(R(l.node.language)),K=c(()=>$(F.value)),Q=c(()=>"plaintext"===K.value),Z=C(!1),ee=C(!1),ye=C(!1),we=C(!1),be=C(!1);let ke=!1,Se=null;const Ce=C(null);let xe=0;const Oe=j(),Ee=C(null),Le=C("undefined"==typeof window);"undefined"!=typeof window&&x(()=>h.value,e=>{var n;if(null==(n=Ee.value)||n.destroy(),Ee.value=null,!e)return void(Le.value=!1);const t=Oe(e,{rootMargin:"400px"});Ee.value=t,Le.value=t.isVisible.value,t.whenVisible.then(()=>{Le.value=!0})},{immediate:!0}),O(()=>{var e;ke=!0,null==(e=Ee.value)||e.destroy(),Ee.value=null});let Me=null,Pe=null,Be=()=>{},He=()=>{},ze=()=>null,Ne=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),De=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),_e=()=>{},Te=()=>{},Fe=()=>{},Re=null,$e=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},je=()=>d(null,null,function*(){});const Ae=[],Ue=[];let We=null;const qe=c(()=>l.node.diff),Ve=C({removed:0,added:0}),Ie=c(()=>`-${Ve.value.removed} +${Ve.value.added}`),Ge=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Je(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return u(r(r({},Ge),t),{enabled:null==(n=t.enabled)||n})}return r({},Ge)}const Xe=c(()=>{var e;const n=l.monacoOptions?r({},l.monacoOptions):{};if(!qe.value)return n;const t=void 0===n.diffHideUnchangedRegions?r({},Ge):Je(n.diffHideUnchangedRegions),o=void 0===n.hideUnchangedRegions?void 0:Je(n.hideUnchangedRegions),i=null!=(e=n.diffUnchangedRegionStyle)?e:"line-info";return u(r(r(r({},{maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:t,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:i,diffHunkActionsOnHover:!1}),n),void 0===o?{}:{hideUnchangedRegions:o}),{diffHideUnchangedRegions:t})}),Ye=c(()=>qe.value?"diff":"single"),Ke=C(Ye.value),Qe=C(!1),Ze=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.wordWrap;return null==n||"off"!==String(n)}),en=c(()=>!Qe.value&&!we.value),nn=C(!1);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield A();if(ke)return;if(!e)return void(Qe.value=!0);const n=e.useMonaco,t=e.detectLanguage;if("function"==typeof t&&($e=t),"function"==typeof n){const e=Qn();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");We=tt();const t=n(We);Me=t.createEditor||Me,Pe=t.createDiffEditor||Pe,Be=t.updateCode||Be,He=t.updateDiff||He,ze=t.getEditor||ze,Ne=t.getEditorView||Ne,De=t.getDiffEditorView||De,_e=t.cleanupEditor||_e,Te=t.safeClean||t.cleanupEditor||Te,Fe=t.refreshDiffPresentation||Fe,je=t.setTheme||je,be.value=!0,!ke&&v.value&&(yield Jn(v.value))}}catch(e){if(ke)return;Qe.value=!0}});const tn=C("number"==typeof(null==(t=l.monacoOptions)?void 0:t.fontSize)?l.monacoOptions.fontSize:Number.NaN),ln=C(tn.value),on=c(()=>{const e=tn.value,n=ln.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),an=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=ln.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:12}),rn=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:Math.round(1.5*an.value)}),un=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:4}),dn=c(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}),sn=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontFamily;return r(r({fontSize:`${an.value}px`,lineHeight:`${rn.value}px`,tabSize:un.value},null!=dn.value?{minHeight:`${dn.value}px`}:{}),"string"==typeof n&&n.trim()?{"--markstream-code-font-family":n.trim()}:{})}),cn=c(()=>null!=dn.value&&!we.value),vn=c(()=>{if(cn.value)return{minHeight:`${dn.value}px`}});function fn(){var e,n,t,l,o;try{const i=qe.value?null!=(t=null==(n=null==(e=De())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t:De():Ne(),a=ze(),r=null==(l=null==a?void 0:a.EditorOption)?void 0:l.fontInfo;if(i&&null!=r){const e=null==(o=i.getOption)?void 0:o.call(i,r),n=null==e?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n}}catch(i){}try{const e=v.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 pn(e){var n,t;try{const l=ze(),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=function(){try{const e=v.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(i){}return null}();if(l&&l>0)return l;const o=Number.isFinite(ln.value)&&ln.value>0?ln.value:14;return Math.max(12,Math.round(1.35*o))}function mn(e,n){return"number"!=typeof e||"number"!=typeof n||e<1||n<e?0:n-e+1}function hn(e){if(!e)return[];const n=e.split(/\r?\n/);return 1===n.length&&""===n[0]?[]:n}function gn(){var e,n;qe.value?Ve.value=function(e,n){const t=hn(e),l=hn(n);let o=0,i=t.length-1,a=l.length-1;for(;o<=i&&o<=a&&t[o]===l[o];)o++;for(;i>=o&&a>=o&&t[i]===l[a];)i--,a--;return{removed:Math.max(0,i-o+1),added:Math.max(0,a-o+1)}}(String(null!=(e=l.node.originalCode)?e:""),String(null!=(n=l.node.updatedCode)?n:"")):Ve.value={removed:0,added:0}}function yn(){var e;if(qe.value)try{const n=De(),t=null==(e=null==n?void 0:n.getLineChanges)?void 0:e.call(n);if(!Array.isArray(t))return void gn();let l=0,o=0;for(const e of t)l+=mn(e.originalStartLineNumber,e.originalEndLineNumber),o+=mn(e.modifiedStartLineNumber,e.modifiedEndLineNumber);Ve.value={removed:l,added:o}}catch(n){gn()}else Ve.value={removed:0,added:0}}function wn(){var e;if(Number.isFinite(ln.value)&&ln.value>0&&Number.isFinite(tn.value))return ln.value;const n=fn();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(tn.value=l.monacoOptions.fontSize,ln.value=l.monacoOptions.fontSize,ln.value):n&&n>0?(tn.value=n,ln.value=n,n):(tn.value=12,ln.value=12,12)}function bn(){const e=wn(),n=Math.min(36,e+1);ln.value=n}function kn(){const e=wn(),n=Math.max(10,e-1);ln.value=n}function Sn(){wn(),Number.isFinite(tn.value)&&(ln.value=tn.value)}function Cn(){var e,n,t,l,o,i,a,r,u,d,s,c,v,f;try{const p=qe.value?De():null,m=qe.value?p:Ne();if(!m)return null;if((null==p?void 0:p.getOriginalEditor)&&(null==p?void 0:p.getModifiedEditor)){const v=null==(e=p.getOriginalEditor)?void 0:e.call(p),f=null==(n=p.getModifiedEditor)?void 0:n.call(p);null==(t=null==v?void 0:v.layout)||t.call(v),null==(l=null==f?void 0:f.layout)||l.call(f);const m=(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(m,h);if(g>0)return Math.ceil(g+1);const y=(null==(u=null==(r=null==(a=null==v?void 0:v.getModel)?void 0:a.call(v))?void 0:r.getLineCount)?void 0:u.call(r))||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),k=Math.max(pn(v),pn(f));return Math.ceil(b*(k+1.5)+0+1)}if(null==m?void 0:m.getContentHeight){null==(v=null==m?void 0:m.layout)||v.call(m);const e=m.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==m?void 0:m.getModel)?void 0:f.call(m);let g=1;h&&"function"==typeof h.getLineCount&&(g=h.getLineCount());const y=pn(m);return Math.ceil(g*(y+1.5)+0+1)}catch(p){return null}}function xn(e){const n=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!n||n.length<3)return null;const[t,l,o]=n.slice(0,3).map(Number);return.2126*t+.7152*l+.0722*o}function On(){var e,n,t,l,o,i,a,r;const u=v.value,d=h.value;if(!u||!d)return;const s=u;if(qe.value)return s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--vscode-editor-background"),void s.style.removeProperty("--vscode-editor-selectionBackground");const c=u.querySelector(".monaco-editor")||u,f=c.querySelector(".monaco-editor-background")||c,p=c.querySelector(".view-lines")||c;let m=null,g=null,y=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(m=window.getComputedStyle(c),g=f===c?m:window.getComputedStyle(f),y=p===c?m:window.getComputedStyle(p))}catch(x){m=null,g=null,y=null}const w=String(null!=(e=null==m?void 0:m.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),b=String(null!=(n=null==m?void 0:m.getPropertyValue("--vscode-editor-background"))?n:"").trim(),k=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(),S=w||String(null!=(i=null!=(o=null==y?void 0:y.color)?o:null==m?void 0:m.color)?i:"").trim(),C=b||String(null!=(r=null!=(a=null==g?void 0:g.backgroundColor)?a:null==m?void 0:m.backgroundColor)?r:"").trim();if(function(e,n,t){if(!Q.value)return!1;const l=xn(e),o=xn(n);return t?null!=l&&l>170||null!=o&&o<110:null!=l&&l<85||null!=o&&o>190}(C,S,d.classList.contains("is-dark")))return s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--vscode-editor-background"),void s.style.removeProperty("--vscode-editor-selectionBackground");S&&s.style.setProperty("--vscode-editor-foreground",S),C&&s.style.setProperty("--vscode-editor-background",C),k&&s.style.setProperty("--vscode-editor-selectionBackground",k)}c(()=>{if(null!=dn.value)return{minHeight:`${dn.value}px`}});const En=/auto|scroll|overlay/i;function Ln(e,n,t){var l;if("undefined"==typeof window)return;const o=Math.ceil(n),i=Math.ceil(t)-o;if(!i)return;const a=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(En.test(n)||En.test(t))return i;i=i.parentElement}return o}(e);if(!a)return;const r=null!=(l=e.ownerDocument)?l:document,u=a===r.body||a===r.documentElement||a===r.scrollingElement,d=u?0:a.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,i):a.scrollTop+=i)}function Mn(){try{const e=v.value;if(!e)return;const n=e.getBoundingClientRect().height,t=Cn();if(null!=t&&t>0){const l=Math.ceil(t);e.style.minHeight="0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",Ln(e,n,l)}}catch(e){}}function Pn(){for(var e,n;Ae.length>0;)try{null==(n=null==(e=Ae.pop())?void 0:e.dispose)||n.call(e)}catch(t){}null!=Se&&(Y(Se),Se=null)}function Bn(){for(var e;Ue.length>0;)try{null==(e=Ue.pop())||e()}catch(n){}}function Hn(){if(Bn(),!qe.value)return;const e=v.value;if(!e)return;const n=e.querySelector(".monaco-diff-editor");if(!n||n.classList.contains("side-by-side"))return;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=t[i],n=l[i].querySelector("a"),o=e.querySelector(".center > div:first-child");if(!n||!o)continue;const a=document.createElement("button");a.type="button",a.className="markstream-inline-fold-proxy";const r=n.getAttribute("title")||"Show Unchanged Region";a.title=r,a.setAttribute("aria-label",r);const u=n.querySelector(".codicon"),d=document.createElement("span");d.className=(null==u?void 0:u.className)||"codicon codicon-unfold",a.append(d);const s=e=>{e.preventDefault(),e.stopPropagation()},c=e=>{e.preventDefault(),e.stopPropagation(),n.click()},v=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),n.click())};a.addEventListener("mousedown",s),a.addEventListener("click",c),a.addEventListener("keydown",v),o.replaceChildren(a),Ue.push(()=>{a.removeEventListener("mousedown",s),a.removeEventListener("click",c),a.removeEventListener("keydown",v),o.contains(a)&&o.replaceChildren()})}}function zn(){null==Se&&(Se=U(()=>{Se=null,U(()=>{Hn(),ee.value||(Z.value?Mn():Dn())})}))}function Nn(e,n,t){const l=Math.min(n,t),o=n>t+1;return e.style.minHeight="0px",e.style.height=`${Math.ceil(l)}px`,e.style.maxHeight=`${Math.ceil(t)}px`,e.style.overflow=o?"auto":"hidden",Math.ceil(l)}function Dn(){var e;try{const n=v.value;if(!n)return;const t=n.getBoundingClientRect().height,o=function(){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}();if(xe>0&&(xe--,null!=Ce.value))return void Ln(n,t,Nn(n,Ce.value,o));const i=Cn();if(null!=i&&i>0)return void Ln(n,t,Nn(n,i,o));if(null!=Ce.value)return void Ln(n,t,Nn(n,Ce.value,o));const a=Math.ceil((null==(e=n.getBoundingClientRect)?void 0:e.call(n).height)||0);if(a>0)return void Ln(n,t,Nn(n,a,o));const r=Number.parseFloat(n.style.height);!Number.isNaN(r)&&r>0?Ln(n,t,Nn(n,r,o)):Ln(n,t,Nn(n,o,o))}catch(n){}}const _n=c(()=>l.isShowPreview&&("html"===F.value||"svg"===F.value));x(()=>l.node.language,e=>{F.value=R(e)}),x(()=>[l.node.originalCode,l.node.updatedCode,qe.value],()=>{gn(),U(()=>yn())},{immediate:!0}),x(()=>[l.node.originalCode,l.node.updatedCode,K.value,qe.value],e=>d(null,[e],function*([e,n,t,o]){if(!1!==l.stream&&o){if(Me&&!ye.value&&v.value)try{yield Jn(v.value)}catch(i){}He(String(null!=e?e:""),String(null!=n?n:""),K.value),Z.value&&U(()=>Mn())}})),x(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(F.value||(F.value=R($e(e))),!qe.value)){if(Me&&!ye.value&&v.value)try{yield Jn(v.value)}catch(n){}Be(e,K.value),Z.value&&U(()=>Mn())}}));const Tn=c(()=>{const e=F.value;return e?W[e]||e.charAt(0).toUpperCase()+e.slice(1):W[""]||"Plain Text"});const Fn=c(()=>{var e;return function(e){const n=function(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()}(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:""))}),Rn=c(()=>Fn.value||Tn.value),$n=c(()=>Fn.value?qe.value?`Diff / ${Tn.value}`:Tn.value:""),jn=c(()=>(q.value,V(F.value||""))),An=c(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(l.minWidth),o=n(l.maxWidth);return t&&(e.minWidth=t),o&&(e.maxWidth=o),qe.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});c(()=>{});const Un=c(()=>!1!==l.showTooltips);function Wn(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(l.node.code)),w.value=!0,o("copy",l.node.code),setTimeout(()=>{w.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function qn(e){if(Z.value=!Z.value,e&&Un.value){const n=function(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}(e);if(n){const e=Z.value?s("common.collapse")||"Collapse":s("common.expand")||"Expand";X(n,e,"top",!1,void 0,l.isDark)}}const n=qe.value?De():Ne(),t=v.value;n&&t&&(Z.value?(Gn(!0),t.style.maxHeight="none",t.style.overflow="visible",Mn()):(Gn(!1),t.style.overflow="auto",Dn()))}function Vn(){var e,n,t;if(ee.value=!ee.value,ee.value){if(v.value){const t=Math.ceil((null==(n=(e=v.value).getBoundingClientRect)?void 0:n.call(e).height)||0);t>0&&(Ce.value=t)}Gn(!1)}else{Z.value&&Gn(!0),v.value&&null!=Ce.value&&(v.value.style.height=`${Ce.value}px`);const e=qe.value?De():Ne();try{null==(t=null==e?void 0:e.layout)||t.call(e)}catch(l){}xe=2,U(()=>{Z.value?Mn():Dn()})}}function In(){if(!_n.value)return;const e=F.value;if(a.value){const n="html"===e?"text/html":"image/svg+xml",t="html"===e?s("artifacts.htmlPreviewTitle")||"HTML Preview":s("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 Gn(e){var n,t;try{if(qe.value){const t=De();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}else{const n=Ne();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}}catch(l){}}function Jn(e){if(!Me||ke)return null;if(function(){var e;try{const n=window;if(n[ge])return;const t=null==(e=window.Element)?void 0:e.prototype,l=null==t?void 0:t.addEventListener;if(!t||!l)return;t.addEventListener=function(e,n,t){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)?l.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(r({},e),{passive:!0}):{passive:!0}}(t)):l.call(this,e,n,t)},n[ge]=!0}catch(n){}}(),Re)return Re;if(ye.value&&we.value)return Promise.resolve();ye.value=!0;const n=d(null,null,function*(){yield function(e){return d(this,null,function*(){var n,t,o;if(!Me||ke)return;if(Pn(),Bn(),function(e){e.replaceChildren()}(e),ke)return;if(qe.value?(Te(),Pe?yield Pe(e,String(null!=(n=l.node.originalCode)?n:""),String(null!=(t=l.node.updatedCode)?t:""),K.value):yield Me(e,l.node.code,K.value)):yield Me(e,l.node.code,K.value),ke)return;const i=qe.value?De():Ne();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),tn.value=l.monacoOptions.fontSize,ln.value=l.monacoOptions.fontSize;else{const e=fn();e&&e>0?(tn.value=e,ln.value=e):(tn.value=12,ln.value=12)}if(Z.value||ee.value||Dn(),!1===l.loading){if(yield E(),ke)return;U(()=>{ke||(Z.value&&!ee.value?Mn():ee.value||Dn())})}yield E(),ke||(we.value=!0,function(){var e,n,t,l,o;if(Pn(),qe.value){const l=De(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),a=null==(n=null==l?void 0:l.getModifiedEditor)?void 0:n.call(l),r=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const l=t.call(e,()=>zn());l&&Ae.push(l)}catch(t){}};try{const e=null==(t=null==l?void 0:l.onDidUpdateDiff)?void 0:t.call(l,()=>{zn(),U(()=>yn())});e&&Ae.push(e)}catch(i){}r(o,"onDidContentSizeChange"),r(a,"onDidContentSizeChange"),r(o,"onDidLayoutChange"),r(a,"onDidLayoutChange")}else{const e=Ne();try{const n=null==(l=null==e?void 0:e.onDidContentSizeChange)?void 0:l.call(e,()=>zn());n&&Ae.push(n)}catch(i){}try{const n=null==(o=null==e?void 0:e.onDidLayoutChange)?void 0:o.call(e,()=>zn());n&&Ae.push(n)}catch(i){}}}(),On(),Hn(),yn(),zn())})}(e)}).finally(()=>{Re===n&&(Re=null)});return Re=n,n}x(Un,e=>{e||I()}),x(()=>ln.value,(e,n)=>{const t=qe.value?De():Ne();t&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(t.updateOptions({fontSize:e}),Z.value&&!ee.value&&Mn())},{flush:"post",immediate:!1});const Xn=x(()=>[v.value,qe.value,l.stream,l.loading,be.value,Le.value],e=>d(null,[e],function*([e,n,t,l,o,i]){if(!e||!Me)return;if(!i)return;if(!1===t&&!1!==l)return;const a=Jn(e);if(a){try{yield a}catch(r){we.value=!1}Xn()}}));function Yn(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function Kn(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function Qn(){var e;const n=function(){if(void 0!==l.theme){const e=l.theme;return Yn(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),t=null==(e=Xe.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 a=Kn(o),r=i.map(e=>Kn(e)).filter(e=>!!e);if(!a||r.includes(a))return o;const u=Kn(t);return null!=t&&u&&r.includes(u)?t:i[0]}x(Ye,(e,n)=>d(null,null,function*(){if(e===n)return;if(Ke.value=e,!Me||!v.value)return;if(!ye.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Le.value)return;const t=Re;if(t){try{yield t}catch(o){}if(ke||!v.value)return}try{we.value=!1,ye.value=!1,Pn(),Bn(),Te(),yield E(),yield Jn(v.value)}catch(i){we.value=!1}}));const Zn=c(()=>void 0===l.theme||Yn(l.theme)?!!l.isDark:function(e){var n,t;if(e&&"object"==typeof e&&(null==(n=e.colors)?void 0:n["editor.background"])){const n=xn(e.colors["editor.background"]);if(null!=n)return n<128}const o=(null!=(t=Kn(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}(Qn())),et=c(()=>{var e;if(!qe.value)return Zn.value?"dark":"light";const n=null==(e=Xe.value)?void 0:e.diffAppearance;return"light"===n||"dark"===n?n:Zn.value?"dark":"light"}),nt=c(()=>qe.value?"dark"===et.value:Zn.value);function tt(){return u(r(u(r({wordWrap:"on",wrappingIndent:"same",themes:l.themes},Xe.value||{}),{theme:Qn()}),qe.value?{diffAppearance:et.value}:{}),{onThemeChange(){On()}})}function lt(){const e=tt();if(!We)return We=e,We;for(const n of Object.keys(We))n in e||delete We[n];return Object.assign(We,e),We}const ot=c(()=>{var e,n,t,l,o,i,a,r,u,d,s,c,v,f;return JSON.stringify({diffLineStyle:null!=(n=null==(e=Xe.value)?void 0:e.diffLineStyle)?n:"background",diffUnchangedRegionStyle:null!=(l=null==(t=Xe.value)?void 0:t.diffUnchangedRegionStyle)?l:"line-info",diffHideUnchangedRegions:null==(i=null==(o=Xe.value)?void 0:o.diffHideUnchangedRegions)||i,renderSideBySide:null==(r=null==(a=Xe.value)?void 0:a.renderSideBySide)||r,enableSplitViewResizing:null==(d=null==(u=Xe.value)?void 0:u.enableSplitViewResizing)||d,ignoreTrimWhitespace:null==(c=null==(s=Xe.value)?void 0:s.ignoreTrimWhitespace)||c,originalEditable:null!=(f=null==(v=Xe.value)?void 0:v.originalEditable)&&f})});x(()=>[l.monacoOptions,Le.value],()=>{var e,n;if(lt(),!Me||!Le.value)return;const t=qe.value?De():Ne(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(ln.value)?ln.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(n=null==t?void 0:t.updateOptions)||n.call(t,{fontSize:o})),Z.value&&!ee.value?Mn():ee.value||Dn()},{deep:!0}),x(()=>[Qn(),et.value,be.value,ye.value,Le.value],()=>{be.value&&ye.value&&Le.value&&function(){lt();const e=Qn(),n=()=>{qe.value&&Fe(),U(()=>{On(),zn()})};e?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=ue.get(e);if(t)return t;try{const n=JSON.stringify(e);if(n)return ue.set(e,n),n}catch(n){}const l="__theme_"+ ++de;return ue.set(e,l),l}return String(e)}(n);return t?(re=e,te||ae!==t?te?(ie===t||le===t||(oe=n,ie=t),te):(oe=n,ie=t,te=d(null,null,function*(){for(;ie&&null!=oe;){const t=oe,l=ie;if(oe=null,ie=null,ae!==l)try{le=l,yield(null!=re?re:e)(t),ae=l}catch(n){}}}).finally(()=>{te=null,le=null}),te):Promise.resolve()):Promise.resolve()}(je,e).then(n).catch(e=>{}):n()}()},{flush:"post"}),x(()=>[ot.value,be.value,Le.value],(e,n)=>d(null,[e,n],function*([e,n,t],[o]){if(lt(),!n||!t)return;if(!Me||!v.value)return;if(!ye.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=Re;if(i){try{yield i}catch(a){}if(ke||!v.value)return}try{we.value=!1,ye.value=!1,Pn(),Bn(),Te(),yield E(),yield Jn(v.value)}catch(r){we.value=!1}}),{flush:"post"});const it=x(()=>[l.loading,Le.value],(e,n)=>d(null,[e,n],function*([e,n],t){if(!n)return;if(e)return;const o=null==t?void 0:t[0],i=void 0!==o&&!1!==o;yield E(),U(()=>{d(null,null,function*(){var e;try{if(i&&ye.value)if(qe.value&&v.value){const e=Re;if(e)try{yield e}catch(n){}we.value=!1,ye.value=!1,Pn(),Bn(),Te(),v.value.replaceChildren(),yield E(),yield Jn(v.value)}else Be(String(null!=(e=l.node.code)?e:""),K.value);ee.value||(Z.value?Mn():Dn()),it()}catch(t){}})})}),{immediate:!0,flush:"post"});return f(()=>{Pn(),Bn(),_e()}),(n,t)=>Qe.value?(p(),m(k(G),{key:0,node:l.node,loading:l.loading},null,8,["node","loading"])):(p(),L("div",{key:1,ref_key:"container",ref:h,style:M(An.value),class:y(["code-block-container rounded-lg border overflow-hidden",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":nt.value,"is-diff":qe.value,"is-plain-text":Q.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":we.value&&!Qe.value?"true":"false"},[P(J,{"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":ee.value,"is-expanded":Z.value,"copy-text":w.value,"is-previewable":_n.value,"code-font-size":ln.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":tn.value,"font-baseline-ready":on.value,"diff-stats":qe.value?Ve.value:null,"diff-stats-aria-label":Ie.value,onToggleCollapse:Vn,onDecreaseFont:kn,onResetFont:Sn,onIncreaseFont:bn,onCopy:Wn,onToggleExpand:qn,onPreview:In},B({"header-left":H(()=>[_(n.$slots,"header-left",{},()=>[g("div",ce,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:jn.value},null,8,ve),g("div",fe,[g("div",pe,b(Rn.value),1),$n.value?(p(),L("div",me,b($n.value),1)):N("",!0)])])],!0)]),loading:H(()=>[_(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:H(()=>[z(g("div",he,[g("div",{ref_key:"codeEditor",ref:v,class:y(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":en.value}]]),style:M(vn.value)},null,6),en.value?(p(),m(k(G),{key:0,class:y(["code-pre-fallback",{"is-wrap":Ze.value}]),style:M(sn.value),node:l.node},null,8,["class","style","node"])):N("",!0)],512),[[D,!(ee.value||!e.stream&&e.loading)]]),nn.value&&!a.value&&_n.value&&"html"===F.value?(p(),m(ne,{key:0,code:l.node.code,"is-dark":l.isDark,"on-close":()=>nn.value=!1},null,8,["code","is-dark","on-close"])):N("",!0)]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:H(()=>[_(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,se))}}),[["__scopeId","data-v-21de71db"]]);export{ye as default};
|