markstream-react 0.0.48 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Tooltip-3iGNq_AM.js → Tooltip-DOyIMYde.js} +132 -133
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/markstream-react.css +1 -1
- package/dist/next.d.ts +18 -0
- package/dist/next.js +1 -1
- package/dist/server.d.ts +18 -0
- package/dist/tailwind.ts +1 -1
- package/dist/types/components/DefinitionListNode/DefinitionListNode.d.ts +1 -1
- package/dist/types/components/ListNode/ListNode.d.ts +1 -1
- package/dist/types/components/TableNode/TableNode.d.ts +1 -1
- package/dist/types/context/smoothStreaming.d.ts +1 -0
- package/dist/types/context/streamState.d.ts +24 -0
- package/dist/types/hooks/useSmoothMarkdownStream.d.ts +20 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types/node-component.d.ts +2 -0
- package/dist/types/types.d.ts +17 -1
- package/dist/types/utils/streamingTextState.d.ts +2 -23
- package/package.json +6 -4
|
@@ -1,198 +1,197 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useMemo as o,useState as i,
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useMemo as o,useState as i,createContext as l,useContext as a,useRef as c,useEffect as s,useCallback as d,useSyncExternalStore as u,useLayoutEffect as m}from"react";import{sanitizeHtmlTokenAttrs as h,NON_STRUCTURING_HTML_TAGS as f,isHtmlTagBlocked as p,sanitizeHtmlContent as g,BLOCKED_HTML_TAGS as w,isHtmlTagHardBlocked as v,convertHtmlAttrsToProps as y,sanitizeHtmlAttrs as x,getHtmlTagFromContent as k,stripCustomHtmlWrapper as b,shouldRenderUnknownHtmlTagAsText as C,mergeCustomHtmlTags as M,getMarkdown as N,parseMarkdownToStructure as B}from"stream-markdown-parser";import{i as S,n as L,f as T,d as E,b as D,l as $,j as P,C as A,D as R,a as H,t as _,q as W,E as I,k as F,F as j,G as O,H as z,y as V,z as K,A as X,h as U,u as q,v as Y,x as Z,B as G,m as J,o as Q}from"./customHtmlTag-BRT4eqd8.js";import{createSmoothMarkdownStream as ee,resolveStreamingTextUpdate as te}from"markstream-core";import{createPortal as ne}from"react-dom";import{autoUpdate as re,computePosition as oe,offset as ie,flip as le,shift as ae}from"@floating-ui/dom";const ce={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"};function se(n){const{node:r,ctx:l,renderNode:a,indexKey:c,isDark:s}=n,d=String(r.kind||"note"),u=o(()=>r.title&&String(r.title).trim().length?String(r.title):d.charAt(0).toUpperCase()+d.slice(1),[d,r.title]),[m,h]=i(()=>{var e;return!!r.collapsible&&!(null==(e=r.open)||e)}),f=o(()=>`admonition-${Math.random().toString(36).slice(2,9)}`,[]);/* @__PURE__ */
|
|
2
2
|
return e("div",{className:`admonition admonition-${d}${s?" is-dark":""}`,"data-index-key":c,children:[
|
|
3
|
-
/* @__PURE__ */e("div",{id:
|
|
4
|
-
/* @__PURE__ */t("span",{className:"admonition-title",children:u}),r.collapsible&&/* @__PURE__ */t("button",{type:"button",className:"admonition-toggle","aria-expanded":!m,"aria-controls":`${
|
|
5
|
-
return t(
|
|
6
|
-
return t("span",{className:"checkbox-node",children:/* @__PURE__ */t("input",{type:"checkbox",checked:Boolean(n.checked),disabled:!0,className:"checkbox-input",readOnly:!0})})}const
|
|
3
|
+
/* @__PURE__ */e("div",{id:f,className:"admonition-header",children:[ce[d]&&/* @__PURE__ */t("span",{className:"admonition-icon",children:ce[d]}),
|
|
4
|
+
/* @__PURE__ */t("span",{className:"admonition-title",children:u}),r.collapsible&&/* @__PURE__ */t("button",{type:"button",className:"admonition-toggle","aria-expanded":!m,"aria-controls":`${f}-content`,title:m?"Expand":"Collapse",onClick:()=>h(e=>!e),children:/* @__PURE__ */t("span",{children:m?"▶":"▼"})})]}),!m&&/* @__PURE__ */t("div",{id:`${f}-content`,className:"admonition-content","aria-labelledby":f,children:l&&a?S(r.children,l,String(null!=c?c:f),a):null})]})}const de=l(!1),ue=l(null);function me(){return a(ue)}const he=l(null);function fe(e,t){var n,r;const o="undefined"!=typeof window&&"undefined"!=typeof document,i=o?null!=(n=window.requestIdleCallback)?n:e=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),16):null,l=o?null!=(r=window.cancelIdleCallback)?r:e=>window.clearTimeout(e):null;let a=null,c=null;const s=/* @__PURE__ */new Map,d=/* @__PURE__ */new Set;let u=null;const m=()=>{if(!s.size){try{null==a||a.disconnect()}catch{}a=null,c=null,d.size||(()=>{if(null!=u){try{null==l||l(u)}catch{}u=null}})()}},h=e=>{const t=s.get(e);if(t){t.state.current=!0;try{t.resolve()}catch{}try{null==a||a.unobserve(e)}catch{}s.delete(e),d.delete(e),m()}},f=()=>{i&&null==u&&d.size&&(u=i(()=>{u=null;const e=d.values().next().value;e&&(d.delete(e),h(e),d.size&&f())},{timeout:1200}))};return(n,r)=>{var i,l;const u={current:!1};let p,g=!1;const w=new Promise(e=>{p=()=>{g||(g=!0,e())}}),v=()=>{if(s.has(n)){s.delete(n);try{null==a||a.unobserve(n)}catch{}}d.delete(n),m()};if(!o||!t())return u.current=!0,p(),{isVisible:()=>!0,whenVisible:w,destroy:v};const y=((t,n)=>{if(!o)return null;if("undefined"==typeof IntersectionObserver)return null;const r=((t,n)=>{var r;return{root:null!=(r=e())?r:null,rootMargin:t,threshold:n}})(t,n);if(a&&(l=r,(i=c)&&i.root===l.root&&i.rootMargin===l.rootMargin&&i.threshold===l.threshold))return a;var i,l;if(a)try{a.disconnect()}catch{}a=new IntersectionObserver(e=>{for(const t of e)(t.isIntersecting||t.intersectionRatio>0)&&h(t.target)},{root:r.root,rootMargin:r.rootMargin,threshold:r.threshold}),c=r;for(const e of s.keys())a.observe(e);return a})(null!=(i=null==r?void 0:r.rootMargin)?i:"300px",null!=(l=null==r?void 0:r.threshold)?l:0);return y?(s.set(n,{resolve:p,state:u}),y.observe(n),d.add(n),f(),{isVisible:()=>u.current,whenVisible:w,destroy:v}):(u.current=!0,p(),{isVisible:()=>!0,whenVisible:w,destroy:v})}}const pe=fe(()=>null,()=>!0);function ge({getRoot:e,enabled:n=!0,children:r}){const i=c(n);i.current=n;const l=c(e);l.current=e;const a=o(()=>fe(()=>{var e,t;return null!=(t=null==(e=l.current)?void 0:e.call(l))?t:null},()=>i.current),[]);/* @__PURE__ */
|
|
5
|
+
return t(he.Provider,{value:a,children:r})}function we(){var e;return null!=(e=a(he))?e:pe}function ve(e={}){const t=c(null);t.current||(t.current=ee(e));const n=t.current,[r,l]=i(()=>n.getSnapshot());return s(()=>{const e=n.subscribe(()=>{l(n.getSnapshot())});return n.resume(),l(n.getSnapshot()),()=>{e(),n.pause()}},[n]),o(()=>({...r,enqueue:n.enqueue,finish:n.finish,flush:n.flush,reset:n.reset,pause:n.pause,resume:n.resume,getSnapshot:n.getSnapshot}),[n,r])}function ye(e){const{node:n}=e;/* @__PURE__ */
|
|
6
|
+
return t("span",{className:"checkbox-node",children:/* @__PURE__ */t("input",{type:"checkbox",checked:Boolean(n.checked),disabled:!0,className:"checkbox-input",readOnly:!0})})}const xe={"common.copy":"Copy","common.copied":"Copied","common.decrease":"Decrease","common.reset":"Reset","common.increase":"Increase","common.expand":"Expand","common.collapse":"Collapse","common.preview":"Preview","common.source":"Source","common.export":"Export","common.open":"Open","common.close":"Close","common.zoomIn":"Zoom in","common.zoomOut":"Zoom out","common.resetZoom":"Reset zoom","image.loadError":"Image failed to load","image.loading":"Loading image..."};function ke(e){Object.assign(xe,e)}function be(){return{t:e=>{var t;return null!=(t=xe[e])?t:function(e){return(e.split(".").pop()||e).replace(/[_-]/g," ").replace(/([A-Z])/g," $1").replace(/\s+/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}(e)}}}let Ce=null,Me=null,Ne=null,Be=null,Se=null,Le=null;function Te(){Be&&(clearTimeout(Be),Be=null),Se&&(clearTimeout(Se),Se=null)}async function Ee(e){if(!Ce||!Me)return;const{x:t,y:n}=await oe(Me,Ce,{placement:e,middleware:[ie(8),le(),ae({padding:8})],strategy:"fixed"});Ce.style.transform=`translate3d(${Math.round(t)}px, ${Math.round(n)}px, 0)`}function De(e,t,n="top",r=!1,o,i){if(!e||"undefined"==typeof document)return;if(Ce||"undefined"==typeof document||(Ce=document.createElement("div"),Ce.className="ms-tooltip",Ce.setAttribute("role","tooltip"),Ce.dataset.visible="false",Ce.style.position="fixed",Ce.style.left="0px",Ce.style.top="0px",Ce.style.transform="translate3d(0,0,0)",document.body.appendChild(Ce)),!Ce)return;Te();const l=async()=>{if(Ce){Me=e,Ce.textContent=t,Ce.dataset.placement=n,Ce.dataset.dark=function(e){if("boolean"==typeof e)return e;if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0}catch{}if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{}return!1}(i)?"true":"false",Ce.dataset.visible="false",Le=`tooltip-${Date.now()}-${Math.random().toString(36).slice(2)}`,Ce.id=Le;try{e.setAttribute("aria-describedby",Le)}catch{}await Ee(n),Ce.dataset.visible="true",null==Ne||Ne(),Ne=re(e,Ce,()=>{Ee(n)})}};r?l():Be=setTimeout(l,80)}function $e(e=!1){if(!Ce)return;Te();const t=()=>{if(Ce){if(Ce.dataset.visible="false",Me&&Le)try{Me.removeAttribute("aria-describedby")}catch{}Me=null,Le=null,Ne&&(Ne(),Ne=null)}};e?t():Se=setTimeout(t,120)}const Pe=void 0!==import.meta&&Boolean(!1);let Ae=null;function Re(n){const{t:r}=be(),i=o(()=>{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>`},[n.code,n.isDark]),l=o(()=>{return e=n.htmlPreviewSandbox,t=n.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!Pe||"undefined"==typeof console||Ae===e)return;const t=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);t.has("allow-scripts")&&t.has("allow-same-origin")&&(Ae=e,console.warn("[markstream-react] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))}(e),e):void 0!==e?"":!0===t?"allow-scripts":"";var e,t},[n.htmlPreviewAllowScripts,n.htmlPreviewSandbox]);return s(()=>{const e=e=>{var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)};return"undefined"!=typeof window&&window.addEventListener("keydown",e),()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",e)}},[n]),"undefined"==typeof document?null:ne(
|
|
7
7
|
/* @__PURE__ */t("div",{className:"html-preview-frame__backdrop"+(n.isDark?" html-preview-frame__backdrop--dark":""),onClick:()=>{var e;return null==(e=n.onClose)?void 0:e.call(n)},children:/* @__PURE__ */e("div",{className:"html-preview-frame"+(n.isDark?" html-preview-frame--dark":""),onClick:e=>e.stopPropagation(),children:[
|
|
8
8
|
/* @__PURE__ */e("div",{className:"html-preview-frame__header",children:[
|
|
9
9
|
/* @__PURE__ */e("div",{className:"html-preview-frame__title",children:[
|
|
10
10
|
/* @__PURE__ */t("span",{className:"html-preview-frame__dot"}),
|
|
11
11
|
/* @__PURE__ */t("span",{className:"html-preview-frame__label",children:n.title||`HTML ${r("common.preview")}`})]}),
|
|
12
12
|
/* @__PURE__ */t("button",{type:"button",className:"html-preview-frame__close"+(n.isDark?" html-preview-frame__close--dark":""),onClick:()=>{var e;return null==(e=n.onClose)?void 0:e.call(n)},children:"×"})]}),
|
|
13
|
-
/* @__PURE__ */t("iframe",{className:"html-preview-frame__iframe",sandbox:l,referrerPolicy:"no-referrer",src:"about:blank",srcDoc:i,title:n.title||"Preview"})]})}),document.body)}let
|
|
14
|
-
return t("pre",{className:`language-${r}`,"aria-busy":!0===(null==e?void 0:e.loading),"aria-label":i,"data-language":r,tabIndex:0,children:/* @__PURE__ */t("code",{translate:"no",children:String(null!=(n=null==e?void 0:e.code)?n:"")})})}const Je={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0},Qe=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function et(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return{...Qe,...n,enabled:null==(t=n.enabled)||t}}return{...Qe}}function tt(e,t){var n;const r=t?{...t}:{};if(!e)return r;const o=void 0===r.diffHideUnchangedRegions?{...Qe}:et(r.diffHideUnchangedRegions),i=void 0===r.hideUnchangedRegions?void 0:et(r.hideUnchangedRegions),l=null!=(n=r.diffUnchangedRegionStyle)?n:"line-info";return{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"===l||"line-info-basic"===l||"metadata"===l?22:14},diffHideUnchangedRegions:o,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:l,diffHunkActionsOnHover:!0,diffHunkHoverHideDelayMs:160,...r,...void 0===i?{}:{hideUnchangedRegions:i},diffHideUnchangedRegions:o}}function nt(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function rt(e){const t=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!t||t.length<3)return null;const[n,r,o]=t.slice(0,3).map(Number);return.2126*n+.7152*r+.0722*o}function ot(r){var l;const c={...Je,...r},{node:u,isDark:m,loading:h,stream:p,isShowPreview:f,enableFontSizeControl:g,darkTheme:w,lightTheme:v,monacoOptions:y,themes:x,minWidth:k,maxWidth:b,showHeader:C,showCopyButton:M,showExpandButton:N,showPreviewButton:B,showCollapseButton:L,showFontSizeButtons:P,showTooltips:A}=c,R=a(null),H=a(null),W=a(null),I=a(null),_=a(null),F=a(null),j=a(null),O=a(0),z=a(null),V=a(null),K=me(),X=a(y),U=a(null),q=a(null),[Y,Z]=i(!1),[G,J]=i(()=>"undefined"==typeof window),[Q,ee]=i(!1),[te,ne]=i(!1),[re,oe]=i(!1),[ie,le]=i(()=>u.language||"plaintext"),[ae,ce]=i(()=>S(u.language)),[se,de]=i(!1),[ue,he]=i(!1),[pe,fe]=i(!1),[we,ve]=i(!1),[ye,xe]=i(0),{t:ke}=ge(),be=o(()=>tt(Boolean(u.diff),y),[y,u.diff]),[Ce,Me]=i(()=>{var e;const t=Number(null==(e=tt(Boolean(u.diff),y))?void 0:e.fontSize);return Number.isFinite(t)&&t>0?t:14}),[Le,Se]=i(Ce),Ee=o(()=>!1!==A,[A]),De=d(()=>{var e,t;const n=null!=(t=null==(e=X.current)?void 0:e.MAX_HEIGHT)?t:500;if("number"==typeof n&&Number.isFinite(n))return Math.max(80,n);const r=String(n).match(/^(\d+(?:\.\d+)?)/),o=r?Number.parseFloat(r[1]):500;return Number.isFinite(o)?Math.max(80,o):500},[]),$e=d(e=>{var t,n,r,o;if(Y)return;const i=R.current,l=W.current;if(!i||!l)return;const a="diff"===F.current?null==(t=l.getDiffEditorView)?void 0:t.call(l):null==(n=l.getEditorView)?void 0:n.call(l);if(!a)return;const c=De();try{null==(r=a.updateOptions)||r.call(a,{automaticLayout:e})}catch{}e?(i.style.minHeight="0px",i.style.maxHeight="none",i.style.overflow="visible"):(i.style.minHeight="0px",i.style.maxHeight=`${Math.ceil(c)}px`,i.style.overflow="auto");try{const t=Number((()=>{if("function"==typeof a.getContentHeight)return a.getContentHeight();if("diff"===F.current&&"function"==typeof a.getModifiedEditor){const e=a.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}})());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,c);i.style.height=`${Math.ceil(Math.max(1,n))}px`}null==(o=a.layout)||o.call(a)}catch{}},[De,Y]);s(()=>T(()=>{xe(e=>e+1)}),[]),s(()=>{ce(S(u.language))},[u.language]);const Ae=a(u);Ae.current=u;const Re=d(()=>{var e;O.current+=1;try{null==(e=I.current)||e.call(I)}catch{}_.current=null,F.current=null,j.current=null,oe(!1),ne(!1)},[]),He=d(()=>{var e,t,n,r,o,i;const l=R.current,a=H.current;if(!l||!a)return;if(u.diff)return a.style.removeProperty("--vscode-editor-foreground"),a.style.removeProperty("--vscode-editor-background"),void a.style.removeProperty("--vscode-editor-selectionBackground");const c=null!=(e=l.querySelector(".monaco-editor"))?e:l;try{const e="undefined"!=typeof window&&window.getComputedStyle?window.getComputedStyle(c):null,l=String(null!=(t=null==e?void 0:e.getPropertyValue("--vscode-editor-foreground"))?t:"").trim()||String(null!=(n=null==e?void 0:e.color)?n:"").trim(),s=String(null!=(r=null==e?void 0:e.getPropertyValue("--vscode-editor-background"))?r:"").trim()||String(null!=(o=null==e?void 0:e.backgroundColor)?o:"").trim(),d=String(null!=(i=null==e?void 0:e.getPropertyValue("--vscode-editor-selectionBackground"))?i:"").trim();if(function(e,t,n,r){if(!n)return!1;const o=rt(e),i=rt(t);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(s,l,"plaintext"===E(String(u.language||ae||ie||"plaintext")),a.classList.contains("is-dark")))return a.style.removeProperty("--vscode-editor-foreground"),a.style.removeProperty("--vscode-editor-background"),void a.style.removeProperty("--vscode-editor-selectionBackground");l&&a.style.setProperty("--vscode-editor-foreground",l),s&&a.style.setProperty("--vscode-editor-background",s),d&&a.style.setProperty("--vscode-editor-selectionBackground",d)}catch{}},[ae,ie,u.diff,u.language]),We=o(()=>m?w:v,[w,m,v]),Ie=d(()=>{var e;const t=null==be?void 0:be.theme,n=null!=(e=null!=We?We:t)?e:Ve,r=Array.isArray(x)?x:[];if(!r.length||null==n)return n;const o=nt(n),i=r.map(e=>nt(e)).filter(e=>!!e);if(!o||i.includes(o))return n;const l=nt(t);return null!=t&&l&&i.includes(l)?t:r[0]},[We,be,x]),_e=o(()=>Ie(),[Ie]),Fe=o(()=>function(e,t){var n;const r=(null!=(n=nt(e))?n:"").toLowerCase();return r?["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=>r.includes(e))&&!["light","latte","dawn","lotus"].some(e=>r.includes(e)):t}(_e,Boolean(m)),[m,_e]),je=o(()=>{if(!u.diff)return Fe?"dark":"light";const e=null==be?void 0:be.diffAppearance;return"light"===e||"dark"===e?e:m?"dark":"light"},[m,u.diff,Fe,be]),Oe=o(()=>u.diff?"dark"===je:Fe,[je,u.diff,Fe]),qe=d(()=>({wordWrap:"on",wrappingIndent:"same",themes:x,...be||{},theme:_e,...u.diff?{diffAppearance:je}:{},onThemeChange(){He()}}),[je,u.diff,_e,be,He,x]),Ye=d(()=>{const e=qe(),t=U.current;if(!t)return U.current=e,e;for(const n of Object.keys(t))n in e||delete t[n];return Object.assign(t,e),t},[qe]),Qe=o(()=>{var e,t,n,r,o,i,l;return JSON.stringify({diffLineStyle:null!=(e=null==be?void 0:be.diffLineStyle)?e:"background",diffUnchangedRegionStyle:null!=(t=null==be?void 0:be.diffUnchangedRegionStyle)?t:"line-info",diffHideUnchangedRegions:null==(n=null==be?void 0:be.diffHideUnchangedRegions)||n,renderSideBySide:null==(r=null==be?void 0:be.renderSideBySide)||r,enableSplitViewResizing:null==(o=null==be?void 0:be.enableSplitViewResizing)||o,ignoreTrimWhitespace:null==(i=null==be?void 0:be.ignoreTrimWhitespace)||i,originalEditable:null!=(l=null==be?void 0:be.originalEditable)&&l})},[be]);s(()=>{X.current=be,Ye()},[be,Ye]),s(()=>()=>{var e,t,n;O.current+=1,null==(e=I.current)||e.call(I),I.current=null,_.current=null,F.current=null,j.current=null,z.current=null,null==(n=null==(t=V.current)?void 0:t.destroy)||n.call(t),V.current=null},[]),s(()=>{var e,t;if("undefined"==typeof window)return;if(G)return;const n=H.current;if(!n)return;null==(t=null==(e=V.current)?void 0:e.destroy)||t.call(e);const r=K(n,{rootMargin:"400px"});return V.current=r,r.isVisible()&&J(!0),r.whenVisible.then(()=>J(!0)),()=>{r.destroy(),V.current===r&&(V.current=null)}},[K,G]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:W.current?(Ye(),()=>{e=!1}):((async()=>{try{const n=await Pe();if(!e)return;if(!n)return void Z(!0);const r=n.useMonaco,o=n.detectLanguage;if("function"==typeof o&&(z.current=o),"function"!=typeof r)return void Z(!0);const i=r(Ye());W.current=i,"function"==typeof(t=i.setTheme)&&(Xe=t,null!=Ve&&null!=Ke&&ze(Ve,Xe).then(()=>Ze()).catch(()=>{})),I.current="function"==typeof i.safeClean?()=>i.safeClean():"function"==typeof i.cleanupEditor?()=>i.cleanupEditor():null,ee(!0)}catch{e&&Z(!0)}var t})(),()=>{e=!1})},[Ye]),s(()=>{var e;if(!u.language&&!ae&&z.current)try{const t=z.current(String(null!=(e=u.code)?e:""));t&&le(t)}catch{}},[ae,u.code,u.language]);const et=o(()=>String(u.language||ae||ie||"plaintext"),[ae,ie,u.language]),ot=o(()=>S(et),[et]),it=o(()=>E(ot),[ot]),lt=o(()=>"plaintext"===it,[it]),at=o(()=>D(ot),[ot,ye]),ct=o(()=>!!f&&("html"===ot||"svg"===ot),[ot,f]),st=o(()=>{const e=ot;return e?$[e]||e.charAt(0).toUpperCase()+e.slice(1):$[""]||"Plain Text"},[ot]),dt=o(()=>{var e,t,n;return u.diff?null!=(t=null!=(e=u.updatedCode)?e:u.code)?t:"":null!=(n=u.code)?n:""},[u.code,u.diff,u.updatedCode]),ut=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t={},n=e(k),r=e(b);return n&&(t.minWidth=n),r&&(t.maxWidth=r),u.diff?(t.color="var(--markstream-diff-shell-fg)",t.borderColor="var(--markstream-diff-shell-border)"):(t.color=`var(--vscode-editor-foreground, ${Oe?"#e5e7eb":"#111827"})`,t.backgroundColor=`var(--vscode-editor-background, ${Oe?"#111827":"#ffffff"})`,t.borderColor=Oe?"rgb(55 65 81 / 0.3)":"rgb(229 231 235)"),t},[b,k,u.diff,Oe]),mt=o(()=>{if(!u.diff)return{color:`var(--vscode-editor-foreground, ${Oe?"#e5e7eb":"#111827"})`,backgroundColor:`var(--vscode-editor-background, ${Oe?"#111827":"#ffffff"})`}},[u.diff,Oe]),ht=!1===p&&h;s(()=>{if(Y)return;if(!Q)return;if(!te||!G)return;const e=W.current;Ye();const t=()=>{var t;u.diff&&(null==(t=null==e?void 0:e.refreshDiffPresentation)||t.call(e)),He(),pe||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>$e(ue)):null)&&$e(ue)};(null==e?void 0:e.setTheme)&&_e?ze(_e,e.setTheme).then(t).catch(()=>{}):t()},[$e,pe,te,je,ue,Q,u.diff,_e,He,Ye,Y,G]),s(()=>{var e;if("undefined"!=typeof window)return e=()=>{He()},Ue.add(e),()=>{Ue.delete(e)}},[He]);const pt=d(async()=>{var e,t;if(Y)return null;if(!G)return null;if(pe)return null;if(ht)return null;const n=W.current,r=R.current;if(!n||!r||!n.createEditor)return null;Ye();const o=Ae.current,i=o.diff?"diff":"single",l=j.current,a="diff"===i?Boolean(null==(e=n.getDiffEditorView)?void 0:e.call(n)):Boolean(null==(t=n.getEditorView)?void 0:t.call(n));if(F.current===i&&l===r&&a)return null;if(_.current)return _.current;O.current+=1;const c=O.current;ne(!0);const s=(async()=>{var e,t,i,l,a,s,d,u,m,h;try{null==(e=I.current)||e.call(I),F.current=null,j.current=null,oe(!1);const p=it;if(o.diff?"function"==typeof n.createDiffEditor?(F.current="diff",await n.createDiffEditor(r,String(null!=(t=o.originalCode)?t:""),String(null!=(i=o.updatedCode)?i:""),p)):(F.current="single",await n.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),p)):(F.current="single",await n.createEditor(r,String(null!=(s=o.code)?s:""),p)),j.current=r,O.current!==c)return;const f=Number(null==(d=X.current)?void 0:d.fontSize);if(Number.isFinite(f)&&f>0){Me(f),Se(f);try{const e="diff"===F.current?null==(u=n.getDiffEditorView)?void 0:u.call(n):null==(m=n.getEditorView)?void 0:m.call(n);null==(h=null==e?void 0:e.updateOptions)||h.call(e,{fontSize:f,automaticLayout:!1})}catch{}}He(),ue||pe||$e(!1),oe(!0)}catch{O.current===c&&Z(!0)}})().finally(()=>{_.current===s&&(_.current=null)});return _.current=s,s},[$e,pe,ue,it,ht,He,Ye,Y,G]);s(()=>{Ye();const e=q.current;if(q.current=Qe,!u.diff)return;if(Y)return;if(!Q||!G||!te)return;if(pe||ht)return;if(e===Qe)return;let t=!1;return(async()=>{if(Re(),!t)try{await pt()}catch{}})(),()=>{t=!0}},[pe,te,pt,Q,Qe,u.diff,Re,ht,Ye,Y,G]),s(()=>{Y||Q&&G&&(pe||ht?Re():pt())},[pe,pt,Q,Re,ht,Y,G]),s(()=>{var e;if(Y)return;if(!Q)return;if(!G)return;if(pe)return;if(ht)return;const t=W.current;if(!t)return;const n=String(null!=(e=u.code)?e:"");(async()=>{var e,r;let o=ae;if(!o&&z.current)try{o=S(z.current(n)),o&&ce(o)}catch{}const i=E(o||ot);if(t.createEditor&&R.current){try{await Promise.resolve(pt())}catch{}const e=_.current;if(e)try{await e}catch{}}try{u.diff&&t.updateDiff?await Promise.resolve(t.updateDiff(String(null!=(e=u.originalCode)?e:""),String(null!=(r=u.updatedCode)?r:""),i)):t.updateCode&&await Promise.resolve(t.updateCode(n,i))}catch{}ue&&$e(!0)})()},[$e,ot,ae,pe,te,pt,ue,Q,u.code,u.diff,u.originalCode,u.updatedCode,ht,Y,G]),s(()=>{if(Y)return;if(!Q)return;if(!G)return;if(pe)return;if(ht)return;if(!ue&&h)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>$e(ue)):null;return null==e&&$e(ue),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[$e,pe,ue,h,Q,ht,Y,G]),s(()=>{var e,t,n;if(!g)return;if(Y)return;const r=W.current;if(r){try{const o="diff"===F.current?null==(e=r.getDiffEditorView)?void 0:e.call(r):null==(t=r.getEditorView)?void 0:t.call(r);null==(n=null==o?void 0:o.updateOptions)||n.call(o,{fontSize:Le})}catch{}$e(ue)}},[$e,g,ue,Le,u.diff,Y]),s(()=>{Ee||Be(!0)},[Ee]);const ft=d((e,t)=>{if(!Ee)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ne(n,t,"top",!1,0,Oe))},[Oe,Ee]),gt=d(()=>{Ee&&Be()},[Ee]),wt=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(String(dt)),de(!0),null==(e=c.onCopy)||e.call(c,String(dt)),setTimeout(()=>de(!1),1e3)}catch{}},[c,dt]),vt=d(()=>{if(!ct)return;const e="html"===ot?"text/html":"image/svg+xml",t="html"===ot?ke("artifacts.htmlPreviewTitle")||"HTML Preview":ke("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof c.onPreviewCode?"html"===ot&&ve(e=>!e):c.onPreviewCode({node:u,artifactType:e,artifactTitle:t,id:`temp-${ot}-${Date.now()}`})},[ot,ct,u,c,ke]);return Y?/* @__PURE__ */t(Ge,{node:u}):/* @__PURE__ */e("div",{ref:H,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",Oe?"border-gray-700/30 bg-gray-900":"border-gray-200 bg-white",h?"is-rendering":"",Oe?"is-dark":"",u.diff?"is-diff":"",lt?"is-plain-text":""].join(" "),style:ut,children:[C&&/* @__PURE__ */e("div",{className:"code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:mt,children:[
|
|
13
|
+
/* @__PURE__ */t("iframe",{className:"html-preview-frame__iframe",sandbox:l,referrerPolicy:"no-referrer",src:"about:blank",srcDoc:i,title:n.title||"Preview"})]})}),document.body)}let He=!1,_e=null,We=!1;async function Ie(){if(_e)return _e;if(We)return null;try{return _e=await import("stream-monaco"),await async function(e){if(He)return;He=!0;const t=null==globalThis?void 0:globalThis.MonacoEnvironment;(!t||"function"!=typeof t.getWorker&&"function"!=typeof t.getWorkerUrl)&&(null==e?void 0:e.preloadMonacoWorkers)&&await e.preloadMonacoWorkers()}(_e),_e}catch{return We=!0,null}}let Fe=null,je=!1,Oe=null,ze=null,Ve=null,Ke=null,Xe=null;const Ue=/* @__PURE__ */new WeakMap;let qe=0;function Ye(e,t){const n=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&e&&"name"in e)return String(e.name);if("object"==typeof e){const t=Ue.get(e);if(t)return t;try{const t=JSON.stringify(e);if(t)return Ue.set(e,t),t}catch{}const n="__theme_"+ ++qe;return Ue.set(e,n),n}return String(e)}(e);return n?(Fe!==t&&(Fe=t),je||Xe!==n?!Oe||Ke!==n&&ze!==n?(Ve=e,Ke=n,Oe||(je=!0,Oe=(async()=>{for(;null!=Ve&&null!=Ke;){const e=Ve,t=Ke;if(Ve=null,Ke=null,Xe===t)continue;const n=Fe;if(!n)break;try{ze=t,await Promise.resolve(n(e)),Xe=t}catch{}}})().finally(()=>{je=!1,Oe=null,ze=null}),Oe)):Oe:Promise.resolve()):Promise.resolve()}let Ze=null,Ge=null,Je=null;const Qe=/* @__PURE__ */new Set,et=/* @__PURE__ */new WeakMap;let tt=0;function nt(){for(const e of Array.from(Qe))try{e()}catch{}}function rt({node:e}){var n;const r=o(()=>function(e){var t;return String(null!=(t=String(null!=e?e:"").split(/\s+/g)[0])?t:"").toLowerCase().replace(/[^\w-]/g,"")||"plaintext"}(null==e?void 0:e.language),[e]),i=r?`Code block: ${r}`:"Code block";/* @__PURE__ */
|
|
14
|
+
return t("pre",{className:`language-${r}`,"aria-busy":!0===(null==e?void 0:e.loading),"aria-label":i,"data-language":r,tabIndex:0,children:/* @__PURE__ */t("code",{translate:"no",children:String(null!=(n=null==e?void 0:e.code)?n:"")})})}const ot={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0},it=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function lt(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return{...it,...n,enabled:null==(t=n.enabled)||t}}return{...it}}function at(e,t){var n;const r=t?{...t}:{};if(!e)return r;const o=void 0===r.diffHideUnchangedRegions?{...it}:lt(r.diffHideUnchangedRegions),i=void 0===r.hideUnchangedRegions?void 0:lt(r.hideUnchangedRegions),l=null!=(n=r.diffUnchangedRegionStyle)?n:"line-info";return{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"===l||"line-info-basic"===l||"metadata"===l?22:14},diffHideUnchangedRegions:o,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:l,diffHunkActionsOnHover:!0,diffHunkHoverHideDelayMs:160,...r,...void 0===i?{}:{hideUnchangedRegions:i},diffHideUnchangedRegions:o}}function ct(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function st(e){const t=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!t||t.length<3)return null;const[n,r,o]=t.slice(0,3).map(Number);return.2126*n+.7152*r+.0722*o}function dt(r){var l;const a={...ot,...r},{node:u,isDark:m,loading:h,stream:f,isShowPreview:p,enableFontSizeControl:g,darkTheme:w,lightTheme:v,monacoOptions:y,themes:x,minWidth:k,maxWidth:b,showHeader:C,showCopyButton:M,showExpandButton:N,showPreviewButton:B,showCollapseButton:S,showFontSizeButtons:P,showTooltips:A}=a,R=c(null),H=c(null),_=c(null),W=c(null),I=c(null),F=c(null),j=c(null),O=c(0),z=c(null),V=c(null),K=we(),X=c(y),U=c(null),q=c(null),[Y,Z]=i(!1),[G,J]=i(()=>"undefined"==typeof window),[Q,ee]=i(!1),[te,ne]=i(!1),[re,oe]=i(!1),[ie,le]=i(()=>u.language||"plaintext"),[ae,ce]=i(()=>L(u.language)),[se,de]=i(!1),[ue,me]=i(!1),[he,fe]=i(!1),[pe,ge]=i(!1),[ve,ye]=i(0),{t:xe}=be(),ke=o(()=>at(Boolean(u.diff),y),[y,u.diff]),[Ce,Me]=i(()=>{var e;const t=Number(null==(e=at(Boolean(u.diff),y))?void 0:e.fontSize);return Number.isFinite(t)&&t>0?t:14}),[Ne,Be]=i(Ce),Se=o(()=>!1!==A,[A]),Le=d(()=>{var e,t;const n=null!=(t=null==(e=X.current)?void 0:e.MAX_HEIGHT)?t:500;if("number"==typeof n&&Number.isFinite(n))return Math.max(80,n);const r=String(n).match(/^(\d+(?:\.\d+)?)/),o=r?Number.parseFloat(r[1]):500;return Number.isFinite(o)?Math.max(80,o):500},[]),Te=d(e=>{var t,n,r,o;if(Y)return;const i=R.current,l=_.current;if(!i||!l)return;const a="diff"===F.current?null==(t=l.getDiffEditorView)?void 0:t.call(l):null==(n=l.getEditorView)?void 0:n.call(l);if(!a)return;const c=Le();try{null==(r=a.updateOptions)||r.call(a,{automaticLayout:e})}catch{}e?(i.style.minHeight="0px",i.style.maxHeight="none",i.style.overflow="visible"):(i.style.minHeight="0px",i.style.maxHeight=`${Math.ceil(c)}px`,i.style.overflow="auto");try{const t=Number((()=>{if("function"==typeof a.getContentHeight)return a.getContentHeight();if("diff"===F.current&&"function"==typeof a.getModifiedEditor){const e=a.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}})());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,c);i.style.height=`${Math.ceil(Math.max(1,n))}px`}null==(o=a.layout)||o.call(a)}catch{}},[Le,Y]);s(()=>T(()=>{ye(e=>e+1)}),[]),s(()=>{ce(L(u.language))},[u.language]);const Ee=c(u);Ee.current=u;const Pe=d(()=>{var e;O.current+=1;try{null==(e=W.current)||e.call(W)}catch{}I.current=null,F.current=null,j.current=null,oe(!1),ne(!1)},[]),Ae=d(()=>{var e,t,n,r,o,i;const l=R.current,a=H.current;if(!l||!a)return;if(u.diff)return a.style.removeProperty("--vscode-editor-foreground"),a.style.removeProperty("--vscode-editor-background"),void a.style.removeProperty("--vscode-editor-selectionBackground");const c=null!=(e=l.querySelector(".monaco-editor"))?e:l;try{const e="undefined"!=typeof window&&window.getComputedStyle?window.getComputedStyle(c):null,l=String(null!=(t=null==e?void 0:e.getPropertyValue("--vscode-editor-foreground"))?t:"").trim()||String(null!=(n=null==e?void 0:e.color)?n:"").trim(),s=String(null!=(r=null==e?void 0:e.getPropertyValue("--vscode-editor-background"))?r:"").trim()||String(null!=(o=null==e?void 0:e.backgroundColor)?o:"").trim(),d=String(null!=(i=null==e?void 0:e.getPropertyValue("--vscode-editor-selectionBackground"))?i:"").trim();if(function(e,t,n,r){if(!n)return!1;const o=st(e),i=st(t);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(s,l,"plaintext"===E(String(u.language||ae||ie||"plaintext")),a.classList.contains("is-dark")))return a.style.removeProperty("--vscode-editor-foreground"),a.style.removeProperty("--vscode-editor-background"),void a.style.removeProperty("--vscode-editor-selectionBackground");l&&a.style.setProperty("--vscode-editor-foreground",l),s&&a.style.setProperty("--vscode-editor-background",s),d&&a.style.setProperty("--vscode-editor-selectionBackground",d)}catch{}},[ae,ie,u.diff,u.language]),He=o(()=>m?w:v,[w,m,v]),_e=d(()=>{var e;const t=null==ke?void 0:ke.theme,n=null!=(e=null!=He?He:t)?e:Ze,r=Array.isArray(x)?x:[];if(!r.length||null==n)return n;const o=ct(n),i=r.map(e=>ct(e)).filter(e=>!!e);if(!o||i.includes(o))return n;const l=ct(t);return null!=t&&l&&i.includes(l)?t:r[0]},[He,ke,x]),We=o(()=>_e(),[_e]),Fe=o(()=>function(e,t){var n;const r=(null!=(n=ct(e))?n:"").toLowerCase();return r?["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=>r.includes(e))&&!["light","latte","dawn","lotus"].some(e=>r.includes(e)):t}(We,Boolean(m)),[m,We]),je=o(()=>{if(!u.diff)return Fe?"dark":"light";const e=null==ke?void 0:ke.diffAppearance;return"light"===e||"dark"===e?e:m?"dark":"light"},[m,u.diff,Fe,ke]),Oe=o(()=>u.diff?"dark"===je:Fe,[je,u.diff,Fe]),ze=d(()=>({wordWrap:"on",wrappingIndent:"same",themes:x,...ke||{},theme:We,...u.diff?{diffAppearance:je}:{},onThemeChange(){Ae()}}),[je,u.diff,We,ke,Ae,x]),Ve=d(()=>{const e=ze(),t=U.current;if(!t)return U.current=e,e;for(const n of Object.keys(t))n in e||delete t[n];return Object.assign(t,e),t},[ze]),Ke=o(()=>{var e,t,n,r,o,i,l;return JSON.stringify({diffLineStyle:null!=(e=null==ke?void 0:ke.diffLineStyle)?e:"background",diffUnchangedRegionStyle:null!=(t=null==ke?void 0:ke.diffUnchangedRegionStyle)?t:"line-info",diffHideUnchangedRegions:null==(n=null==ke?void 0:ke.diffHideUnchangedRegions)||n,renderSideBySide:null==(r=null==ke?void 0:ke.renderSideBySide)||r,enableSplitViewResizing:null==(o=null==ke?void 0:ke.enableSplitViewResizing)||o,ignoreTrimWhitespace:null==(i=null==ke?void 0:ke.ignoreTrimWhitespace)||i,originalEditable:null!=(l=null==ke?void 0:ke.originalEditable)&&l})},[ke]);s(()=>{X.current=ke,Ve()},[ke,Ve]),s(()=>()=>{var e,t,n;O.current+=1,null==(e=W.current)||e.call(W),W.current=null,I.current=null,F.current=null,j.current=null,z.current=null,null==(n=null==(t=V.current)?void 0:t.destroy)||n.call(t),V.current=null},[]),s(()=>{var e,t;if("undefined"==typeof window)return;if(G)return;const n=H.current;if(!n)return;null==(t=null==(e=V.current)?void 0:e.destroy)||t.call(e);const r=K(n,{rootMargin:"400px"});return V.current=r,r.isVisible()&&J(!0),r.whenVisible.then(()=>J(!0)),()=>{r.destroy(),V.current===r&&(V.current=null)}},[K,G]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:_.current?(Ve(),()=>{e=!1}):((async()=>{try{const n=await Ie();if(!e)return;if(!n)return void Z(!0);const r=n.useMonaco,o=n.detectLanguage;if("function"==typeof o&&(z.current=o),"function"!=typeof r)return void Z(!0);const i=r(Ve());_.current=i,"function"==typeof(t=i.setTheme)&&(Je=t,null!=Ze&&null!=Ge&&Ye(Ze,Je).then(()=>nt()).catch(()=>{})),W.current="function"==typeof i.safeClean?()=>i.safeClean():"function"==typeof i.cleanupEditor?()=>i.cleanupEditor():null,ee(!0)}catch{e&&Z(!0)}var t})(),()=>{e=!1})},[Ve]),s(()=>{var e;if(!u.language&&!ae&&z.current)try{const t=z.current(String(null!=(e=u.code)?e:""));t&&le(t)}catch{}},[ae,u.code,u.language]);const Xe=o(()=>String(u.language||ae||ie||"plaintext"),[ae,ie,u.language]),Ue=o(()=>L(Xe),[Xe]),qe=o(()=>E(Ue),[Ue]),et=o(()=>"plaintext"===qe,[qe]),tt=o(()=>D(Ue),[Ue,ve]),it=o(()=>!!p&&("html"===Ue||"svg"===Ue),[Ue,p]),lt=o(()=>{const e=Ue;return e?$[e]||e.charAt(0).toUpperCase()+e.slice(1):$[""]||"Plain Text"},[Ue]),dt=o(()=>{var e,t,n;return u.diff?null!=(t=null!=(e=u.updatedCode)?e:u.code)?t:"":null!=(n=u.code)?n:""},[u.code,u.diff,u.updatedCode]),ut=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t={},n=e(k),r=e(b);return n&&(t.minWidth=n),r&&(t.maxWidth=r),u.diff?(t.color="var(--markstream-diff-shell-fg)",t.borderColor="var(--markstream-diff-shell-border)"):(t.color=`var(--vscode-editor-foreground, ${Oe?"#e5e7eb":"#111827"})`,t.backgroundColor=`var(--vscode-editor-background, ${Oe?"#111827":"#ffffff"})`,t.borderColor=Oe?"rgb(55 65 81 / 0.3)":"rgb(229 231 235)"),t},[b,k,u.diff,Oe]),mt=o(()=>{if(!u.diff)return{color:`var(--vscode-editor-foreground, ${Oe?"#e5e7eb":"#111827"})`,backgroundColor:`var(--vscode-editor-background, ${Oe?"#111827":"#ffffff"})`}},[u.diff,Oe]),ht=!1===f&&h;s(()=>{if(Y)return;if(!Q)return;if(!te||!G)return;const e=_.current;Ve();const t=()=>{var t;u.diff&&(null==(t=null==e?void 0:e.refreshDiffPresentation)||t.call(e)),Ae(),he||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>Te(ue)):null)&&Te(ue)};(null==e?void 0:e.setTheme)&&We?Ye(We,e.setTheme).then(t).catch(()=>{}):t()},[Te,he,te,je,ue,Q,u.diff,We,Ae,Ve,Y,G]),s(()=>{var e;if("undefined"!=typeof window)return e=()=>{Ae()},Qe.add(e),()=>{Qe.delete(e)}},[Ae]);const ft=d(async()=>{var e,t;if(Y)return null;if(!G)return null;if(he)return null;if(ht)return null;const n=_.current,r=R.current;if(!n||!r||!n.createEditor)return null;Ve();const o=Ee.current,i=o.diff?"diff":"single",l=j.current,a="diff"===i?Boolean(null==(e=n.getDiffEditorView)?void 0:e.call(n)):Boolean(null==(t=n.getEditorView)?void 0:t.call(n));if(F.current===i&&l===r&&a)return null;if(I.current)return I.current;O.current+=1;const c=O.current;ne(!0);const s=(async()=>{var e,t,i,l,a,s,d,u,m,h;try{null==(e=W.current)||e.call(W),F.current=null,j.current=null,oe(!1);const f=qe;if(o.diff?"function"==typeof n.createDiffEditor?(F.current="diff",await n.createDiffEditor(r,String(null!=(t=o.originalCode)?t:""),String(null!=(i=o.updatedCode)?i:""),f)):(F.current="single",await n.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),f)):(F.current="single",await n.createEditor(r,String(null!=(s=o.code)?s:""),f)),j.current=r,O.current!==c)return;const p=Number(null==(d=X.current)?void 0:d.fontSize);if(Number.isFinite(p)&&p>0){Me(p),Be(p);try{const e="diff"===F.current?null==(u=n.getDiffEditorView)?void 0:u.call(n):null==(m=n.getEditorView)?void 0:m.call(n);null==(h=null==e?void 0:e.updateOptions)||h.call(e,{fontSize:p,automaticLayout:!1})}catch{}}Ae(),ue||he||Te(!1),oe(!0)}catch{O.current===c&&Z(!0)}})().finally(()=>{I.current===s&&(I.current=null)});return I.current=s,s},[Te,he,ue,qe,ht,Ae,Ve,Y,G]);s(()=>{Ve();const e=q.current;if(q.current=Ke,!u.diff)return;if(Y)return;if(!Q||!G||!te)return;if(he||ht)return;if(e===Ke)return;let t=!1;return(async()=>{if(Pe(),!t)try{await ft()}catch{}})(),()=>{t=!0}},[he,te,ft,Q,Ke,u.diff,Pe,ht,Ve,Y,G]),s(()=>{Y||Q&&G&&(he||ht?Pe():ft())},[he,ft,Q,Pe,ht,Y,G]),s(()=>{var e;if(Y)return;if(!Q)return;if(!G)return;if(he)return;if(ht)return;const t=_.current;if(!t)return;const n=String(null!=(e=u.code)?e:"");(async()=>{var e,r;let o=ae;if(!o&&z.current)try{o=L(z.current(n)),o&&ce(o)}catch{}const i=E(o||Ue);if(t.createEditor&&R.current){try{await Promise.resolve(ft())}catch{}const e=I.current;if(e)try{await e}catch{}}try{u.diff&&t.updateDiff?await Promise.resolve(t.updateDiff(String(null!=(e=u.originalCode)?e:""),String(null!=(r=u.updatedCode)?r:""),i)):t.updateCode&&await Promise.resolve(t.updateCode(n,i))}catch{}ue&&Te(!0)})()},[Te,Ue,ae,he,te,ft,ue,Q,u.code,u.diff,u.originalCode,u.updatedCode,ht,Y,G]),s(()=>{if(Y)return;if(!Q)return;if(!G)return;if(he)return;if(ht)return;if(!ue&&h)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>Te(ue)):null;return null==e&&Te(ue),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[Te,he,ue,h,Q,ht,Y,G]),s(()=>{var e,t,n;if(!g)return;if(Y)return;const r=_.current;if(r){try{const o="diff"===F.current?null==(e=r.getDiffEditorView)?void 0:e.call(r):null==(t=r.getEditorView)?void 0:t.call(r);null==(n=null==o?void 0:o.updateOptions)||n.call(o,{fontSize:Ne})}catch{}Te(ue)}},[Te,g,ue,Ne,u.diff,Y]),s(()=>{Se||$e(!0)},[Se]);const pt=d((e,t)=>{if(!Se)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),De(n,t,"top",!1,0,Oe))},[Oe,Se]),gt=d(()=>{Se&&$e()},[Se]),wt=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(String(dt)),de(!0),null==(e=a.onCopy)||e.call(a,String(dt)),setTimeout(()=>de(!1),1e3)}catch{}},[a,dt]),vt=d(()=>{if(!it)return;const e="html"===Ue?"text/html":"image/svg+xml",t="html"===Ue?xe("artifacts.htmlPreviewTitle")||"HTML Preview":xe("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof a.onPreviewCode?"html"===Ue&&ge(e=>!e):a.onPreviewCode({node:u,artifactType:e,artifactTitle:t,id:`temp-${Ue}-${Date.now()}`})},[Ue,it,u,a,xe]);return Y?/* @__PURE__ */t(rt,{node:u}):/* @__PURE__ */e("div",{ref:H,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",Oe?"border-gray-700/30 bg-gray-900":"border-gray-200 bg-white",h?"is-rendering":"",Oe?"is-dark":"",u.diff?"is-diff":"",et?"is-plain-text":""].join(" "),style:ut,children:[C&&/* @__PURE__ */e("div",{className:"code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:mt,children:[
|
|
15
15
|
/* @__PURE__ */e("div",{className:"flex items-center space-x-2 flex-1 overflow-hidden",children:[
|
|
16
|
-
/* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:
|
|
17
|
-
/* @__PURE__ */t("span",{className:"text-sm font-medium font-mono truncate",children:
|
|
18
|
-
/* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[
|
|
19
|
-
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:
|
|
20
|
-
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:
|
|
16
|
+
/* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:tt}}),
|
|
17
|
+
/* @__PURE__ */t("span",{className:"text-sm font-medium font-mono truncate",children:lt})]}),
|
|
18
|
+
/* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[S&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":he,onClick:()=>fe(e=>!e),onMouseEnter:e=>pt(e,he?xe("common.expand")||"Expand":xe("common.collapse")||"Collapse"),onFocus:e=>pt(e,he?xe("common.expand")||"Expand":xe("common.collapse")||"Collapse"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",{style:{rotate:he?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),P&&g&&/* @__PURE__ */e(n,{children:[
|
|
19
|
+
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Ne<=10,onClick:()=>Be(e=>Math.max(10,e-1)),onMouseEnter:e=>pt(e,xe("common.decrease")||"Decrease"),onFocus:e=>pt(e,xe("common.decrease")||"Decrease"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
|
|
20
|
+
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Ne===Ce,onClick:()=>Be(Ce),onMouseEnter:e=>pt(e,xe("common.reset")||"Reset"),onFocus:e=>pt(e,xe("common.reset")||"Reset"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
21
21
|
/* @__PURE__ */t("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),
|
|
22
22
|
/* @__PURE__ */t("path",{d:"M3 3v5h5"})]})})}),
|
|
23
|
-
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:
|
|
23
|
+
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Ne>=36,onClick:()=>Be(e=>Math.min(36,e+1)),onMouseEnter:e=>pt(e,xe("common.increase")||"Increase"),onFocus:e=>pt(e,xe("common.increase")||"Increase"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),M&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":se?xe("common.copied")||"Copied":xe("common.copy")||"Copy",onClick:wt,onMouseEnter:e=>pt(e,se?xe("common.copied")||"Copied":xe("common.copy")||"Copy"),onFocus:e=>pt(e,se?xe("common.copied")||"Copied":xe("common.copy")||"Copy"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",se?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
24
24
|
/* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
25
|
-
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),N&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":ue,onClick:e=>{
|
|
25
|
+
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),N&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":ue,onClick:e=>{me(e=>!e),pt(e,ue?xe("common.expand")||"Expand":xe("common.collapse")||"Collapse")},onMouseEnter:e=>pt(e,ue?xe("common.collapse")||"Collapse":xe("common.expand")||"Expand"),onFocus:e=>pt(e,ue?xe("common.collapse")||"Collapse":xe("common.expand")||"Expand"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",ue?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),it&&B&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":xe("common.preview")||"Preview",onClick:vt,onMouseEnter:e=>pt(e,xe("common.preview")||"Preview"),onFocus:e=>pt(e,xe("common.preview")||"Preview"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",children:/* @__PURE__ */e("g",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",children:[
|
|
26
26
|
/* @__PURE__ */t("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"}),
|
|
27
27
|
/* @__PURE__ */t("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"})]})})})]})]}),
|
|
28
|
-
/* @__PURE__ */e("div",{className:`code-block-body${
|
|
29
|
-
/* @__PURE__ */t("div",{ref:R,className:"code-editor-container"+(
|
|
28
|
+
/* @__PURE__ */e("div",{className:`code-block-body${he?" code-block-body--collapsed":""}${ue?" code-block-body--expanded":""}`,children:[!he&&(!!f||!h)&&(Y?/* @__PURE__ */t(rt,{node:u}):/* @__PURE__ */e("div",{className:"code-editor-layer",children:[
|
|
29
|
+
/* @__PURE__ */t("div",{ref:R,className:"code-editor-container"+(f?"":" code-height-placeholder"),style:{visibility:re?"visible":"hidden"},"aria-hidden":!re}),!re&&/* @__PURE__ */t("div",{className:"code-editor-fallback-surface",children:/* @__PURE__ */t("pre",{className:"code-fallback-plain m-0","aria-busy":h,"aria-label":`Code block: ${lt}`,tabIndex:0,children:/* @__PURE__ */t("code",{translate:"no",children:String(dt)})})})]})),!f&&h&&/* @__PURE__ */t("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
|
|
30
30
|
/* @__PURE__ */t("div",{className:"skeleton-line"}),
|
|
31
31
|
/* @__PURE__ */t("div",{className:"skeleton-line"}),
|
|
32
|
-
/* @__PURE__ */t("div",{className:"skeleton-line short"})]})})]}),
|
|
33
|
-
/* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:se?
|
|
32
|
+
/* @__PURE__ */t("div",{className:"skeleton-line short"})]})})]}),pe&&!a.onPreviewCode&&it&&"html"===Ue&&/* @__PURE__ */t(Re,{code:String(null!=(l=u.code)?l:""),htmlPreviewAllowScripts:a.htmlPreviewAllowScripts,htmlPreviewSandbox:a.htmlPreviewSandbox,isDark:m,onClose:()=>ge(!1)}),
|
|
33
|
+
/* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:se?xe("common.copied")||"Copied":""})]})}function ut(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=ut(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function mt(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=ut(e))&&(r&&(r+=" "),r+=t);return r}const ht=()=>import("@terrastruct/d2");let ft=null,pt=ht;function gt(e){pt=e,ft=null}function wt(e){gt(null!=e?e:ht)}function vt(){gt(null)}function yt(){return"function"==typeof pt}async function xt(){if(ft)return ft;const e=pt;if(!e)return null;let t;try{t=await e()}catch(n){if(e===ht)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw n}return t?(ft=function(e){var t;if(!e)return e;if(e.D2&&"function"==typeof e.D2)return e.D2;if(e.default&&e.default.D2&&"function"==typeof e.default.D2)return e.default.D2;const n=null!=(t=e.default)?t:e;return"function"==typeof n?n:(null==n?void 0:n.D2)&&"function"==typeof n.D2?n.D2:n}(t),ft):null}const kt={maxHeight:"500px",loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},bt={N1:"#E5E7EB",N2:"#CBD5E1",N3:"#94A3B8",N4:"#64748B",N5:"#475569",N6:"#334155",N7:"#0B1220",B1:"#60A5FA",B2:"#3B82F6",B3:"#2563EB",B4:"#1D4ED8",B5:"#1E40AF",B6:"#111827",AA2:"#22D3EE",AA4:"#0EA5E9",AA5:"#0284C7",AB4:"#FBBF24",AB5:"#F59E0B"},Ct=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],Mt=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Nt(e){if(!e)return"";const t=e.trim();return Mt.test(t)?t:""}function Bt(r){var l,a;const u={...kt,...r},{t:m}=be(),[h,f]=i(!1),[p,g]=i(!1),[w,v]=i(!1),[y,x]=i(!1),[k,b]=i(null),[C,M]=i(""),[N,B]=i(null),[S,L]=i(!1),[T,E]=i(()=>"undefined"==typeof window),D=c(0),$=c(null),P=c(!1),A=c(!1),R=c(0),H=c(null),_=c(!1),W=c(null),I=c(null),F=c(null),j=c(null),O=c(!1),z=c(()=>{}),V=we(),K=null!=(a=null==(l=u.node)?void 0:l.code)?a:"",X=w||!y||!C,U=!!C,q=o(()=>{if(u.maxHeight)return{maxHeight:"number"==typeof u.maxHeight?`${u.maxHeight}px`:String(u.maxHeight)}},[u.maxHeight]),Y=o(()=>{if(X&&N)return{minHeight:`${N}px`}},[N,X]);s(()=>{O.current=S},[S]),s(()=>{const e=W.current;if(!e)return;const t=V(e,{rootMargin:"160px"});return I.current=t,t.isVisible()&&E(!0),t.whenVisible.then(()=>E(!0)),()=>{t.destroy(),I.current=null}},[V]);const Z=d(()=>{const e=F.current;if(!e)return;const t=e.getBoundingClientRect().height;t>0&&B(e=>e!==t?t:e)},[]),G=d((e=!1)=>{if(P.current||"undefined"==typeof window)return;if(A.current)return;if(!T)return;if(O.current)return void(_.current=!0);const t=Math.max(120,Number(u.progressiveIntervalMs)||0),n=Date.now()-R.current;if(!e&&n<t)return _.current=!0,void(null==H.current&&(H.current=window.setTimeout(()=>{H.current=null,_.current&&(_.current=!1,G(!0))},Math.max(0,t-n))));P.current=!0;const r=()=>{P.current=!1,R.current=Date.now(),z.current()};"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,0)},[u.progressiveIntervalMs,T]),J=d(async()=>{if($.current)return $.current;const e=await xt();if(!e)return null;if("function"==typeof e){const t=new e;return t&&"function"==typeof t.compile?$.current=t:"function"==typeof e.compile&&($.current=e),$.current}return(null==e?void 0:e.D2)&&"function"==typeof e.D2?($.current=new e.D2,$.current):("function"==typeof e.compile&&($.current=e),$.current)},[]),Q=d(async()=>{var e,t,n,r,o;if("undefined"==typeof window||A.current)return;if(!T)return;if(u.loading&&!u.progressiveRender)return;if(!K)return M(""),void b(null);const i=++D.current;L(!0),b(null);try{const l=await J();if(!l)return x(!1),v(!0),M(""),void b("D2 is not available.");if("function"!=typeof l.compile||"function"!=typeof l.render)throw new Error("D2 instance is missing compile/render methods.");x(!0);const a=await l.compile(K);if(i!==D.current)return;const c=null!=(e=null==a?void 0:a.diagram)?e:a,s=null!=(n=null!=(t=null==a?void 0:a.renderOptions)?t:null==a?void 0:a.options)?n:{},d=null!=(r=u.themeId)?r:s.themeID,m=null!=(o=u.darkThemeId)?o:s.darkThemeID,h={...s};if(h.themeID=u.isDark&&null!=m?m:d,h.darkThemeID=null,h.darkThemeOverrides=null,u.isDark){const e=s.themeOverrides&&"object"==typeof s.themeOverrides?s.themeOverrides:null;h.themeOverrides={...bt,...e||{}}}const f=await l.render(c,h);if(i!==D.current)return;const p=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(f);if(!p)throw new Error("D2 render returned empty output.");const g=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return"";if(!e)return"";const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),n=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!n||"svg"!==n.nodeName.toLowerCase())return"";const r=n;return function(e){const t=/* @__PURE__ */new Set(["script"]),n=[e,...Array.from(e.querySelectorAll("*"))];for(const r of n){if(t.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&t.value){const n=t.value;if(Ct.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=Nt(t.value);if(!n){r.removeAttribute(e);continue}n!==t.value&&r.setAttribute(e,n)}}}}}(r),r.classList.add("markstream-d2-root-svg"),r.outerHTML}(p);M(g||""),u.loading&&v(!1),b(null)}catch(l){if(i!==D.current)return;const e=(null==l?void 0:l.message)?String(l.message):"D2 render failed.";u.loading||b(e),e.includes("@terrastruct/d2")&&(x(!1),v(!0))}finally{i===D.current&&(L(!1),_.current&&(_.current=!1,G()))}},[K,J,u.darkThemeId,u.isDark,u.loading,u.progressiveRender,u.themeId,G,T]);s(()=>{z.current=Q},[Q]);const ee=d(async()=>{var e;try{(null==(e=null==navigator?void 0:navigator.clipboard)?void 0:e.writeText)&&await navigator.clipboard.writeText(K),f(!0),setTimeout(()=>f(!1),1e3)}catch{}},[K]),te=d(()=>{if(C)try{const e=new Blob([C],{type:"image/svg+xml;charset=utf-8"}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error("Failed to export SVG:",e)}},[C]),ne=d((e,t)=>{var n;(n=e.currentTarget)&&!n.disabled&&De(e.currentTarget,t,"top",!1,(e.clientX,e.clientY),u.isDark)},[u.isDark]),re=d(()=>{$e()},[]);return s(()=>{G()},[K,u.loading,u.isDark,G]),s(()=>{u.loading||G(!0)},[u.loading,G]),s(()=>{const e=requestAnimationFrame(()=>Z());return()=>cancelAnimationFrame(e)},[X,C,K,Z]),s(()=>{A.current=!1,G();const e=requestAnimationFrame(()=>Z());if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{Z()});j.current=e,F.current&&e.observe(F.current)}return()=>{var t;A.current=!0,null!=H.current&&(clearTimeout(H.current),H.current=null),null==(t=j.current)||t.disconnect(),j.current=null,cancelAnimationFrame(e)}},[G,Z]),/* @__PURE__ */e("div",{ref:W,className:mt("d2-block my-4 rounded-lg border overflow-hidden shadow-sm",u.isDark?"border-gray-700/30 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900"),children:[u.showHeader&&/* @__PURE__ */e("div",{className:"d2-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:{color:"var(--vscode-editor-foreground)",backgroundColor:"var(--vscode-editor-background)"},children:[
|
|
34
34
|
/* @__PURE__ */t("div",{className:"flex items-center gap-x-2",children:/* @__PURE__ */t("span",{className:"text-sm font-medium font-mono",children:"D2"})}),
|
|
35
|
-
/* @__PURE__ */e("div",{className:"flex items-center gap-x-2",children:[u.showModeToggle&&/* @__PURE__ */e("div",{className:
|
|
36
|
-
/* @__PURE__ */t("button",{type:"button",className:
|
|
37
|
-
/* @__PURE__ */t("button",{type:"button",className:
|
|
35
|
+
/* @__PURE__ */e("div",{className:"flex items-center gap-x-2",children:[u.showModeToggle&&/* @__PURE__ */e("div",{className:mt("flex items-center gap-x-1 rounded-md p-0.5",u.isDark?"bg-gray-700":"bg-gray-100"),children:[
|
|
36
|
+
/* @__PURE__ */t("button",{type:"button",className:mt("mode-btn px-2 py-1 text-xs rounded",!w&&"is-active"),onClick:()=>v(!1),onMouseEnter:e=>ne(e,m("common.preview")||"Preview"),onFocus:e=>ne(e,m("common.preview")||"Preview"),onMouseLeave:re,onBlur:re,children:m("common.preview")||"Preview"}),
|
|
37
|
+
/* @__PURE__ */t("button",{type:"button",className:mt("mode-btn px-2 py-1 text-xs rounded",w&&"is-active"),onClick:()=>v(!0),onMouseEnter:e=>ne(e,m("common.source")||"Source"),onFocus:e=>ne(e,m("common.source")||"Source"),onMouseLeave:re,onBlur:re,children:m("common.source")||"Source"})]}),u.showCopyButton&&/* @__PURE__ */t("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":h?m("common.copied")||"Copied":m("common.copy")||"Copy",onClick:ee,onMouseEnter:e=>ne(e,h?m("common.copied")||"Copied":m("common.copy")||"Copy"),onFocus:e=>ne(e,h?m("common.copied")||"Copied":m("common.copy")||"Copy"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("svg",h?{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
38
38
|
/* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
39
|
-
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),u.showExportButton&&C&&/* @__PURE__ */t("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":m("common.export")||"Export",onClick:te,onMouseEnter:e=>ne(e,m("common.export")||"Export"),onFocus:e=>ne(e,m("common.export")||"Export"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 3v12m0-12l-4 4m4-4l4 4M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"})})}),u.showCollapseButton&&/* @__PURE__ */t("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":
|
|
39
|
+
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),u.showExportButton&&C&&/* @__PURE__ */t("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":m("common.export")||"Export",onClick:te,onMouseEnter:e=>ne(e,m("common.export")||"Export"),onFocus:e=>ne(e,m("common.export")||"Export"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 3v12m0-12l-4 4m4-4l4 4M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"})})}),u.showCollapseButton&&/* @__PURE__ */t("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":p,onClick:()=>g(e=>!e),onMouseEnter:e=>ne(e,p?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onFocus:e=>ne(e,p?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("svg",{style:{transform:`rotate(${p?0:90}deg)`},xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})})]})]}),!p&&/* @__PURE__ */t("div",{ref:F,className:"d2-block-body",style:Y,children:u.loading&&!U?/* @__PURE__ */e("div",{className:"d2-source px-4 py-4",children:[
|
|
40
40
|
/* @__PURE__ */t("pre",{className:"d2-code",children:/* @__PURE__ */t("code",{children:K})}),k&&/* @__PURE__ */t("p",{className:"d2-error mt-2 text-xs",children:k})]}):/* @__PURE__ */t(n,{children:/* @__PURE__ */e("div",X?{className:"d2-source px-4 py-4",children:[
|
|
41
41
|
/* @__PURE__ */t("pre",{className:"d2-code",children:/* @__PURE__ */t("code",{children:K})}),k&&/* @__PURE__ */t("p",{className:"d2-error mt-2 text-xs",children:k})]}:{className:"d2-render",style:q,children:[
|
|
42
|
-
/* @__PURE__ */t("div",{className:"d2-svg",dangerouslySetInnerHTML:{__html:C}}),k&&/* @__PURE__ */t("p",{className:"d2-error px-4 pb-3 text-xs",children:k})]})})})]})}function
|
|
42
|
+
/* @__PURE__ */t("div",{className:"d2-svg",dangerouslySetInnerHTML:{__html:C}}),k&&/* @__PURE__ */t("p",{className:"d2-error px-4 pb-3 text-xs",children:k})]})})})]})}function St(n){const{node:r,ctx:o,renderNode:i,indexKey:l}=n,a=Array.isArray(r.items)?r.items:[];/* @__PURE__ */
|
|
43
43
|
return t("dl",{className:"definition-list","data-index-key":l,children:a.map((n,r)=>/* @__PURE__ */e("div",{className:"mb-4",children:[
|
|
44
44
|
/* @__PURE__ */t("dt",{className:"definition-term font-semibold",children:o&&i?P(n.term,o,`${String(null!=l?l:"definition")}-term-${r}`,i):null}),
|
|
45
|
-
/* @__PURE__ */t("dd",{className:"definition-desc ml-4",children:o&&i?P(n.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function
|
|
46
|
-
return t("span",{className:"emoji-node",children:null!=(n=r.name)?n:r.markup})}function
|
|
47
|
-
return t("em",{className:"emphasis-node",children:e.children})}function
|
|
48
|
-
return t("a",{className:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${n.id}`,title:`返回引用 ${n.id}`,onClick:r,children:"↩︎"})}function
|
|
49
|
-
return t("div",{id:`fnref--${n.id}`,className:"footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2",children:/* @__PURE__ */t("div",{className:"flex-1",children:r&&o?
|
|
50
|
-
return t("sup",{id:`fnref-${r.id}`,className:"footnote-reference",onClick:a,children:/* @__PURE__ */e("span",{...l,title:`查看脚注 ${r.id}`,className:"footnote-link cursor-pointer",children:["[",r.id,"]"]})})}function
|
|
51
|
-
return t("br",{className:"hard-break"})}function
|
|
52
|
-
return t(c,{dir:"auto",className:
|
|
53
|
-
return t("mark",{className:"highlight-node",children:e.children})}function
|
|
45
|
+
/* @__PURE__ */t("dd",{className:"definition-desc ml-4",children:o&&i?P(n.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function Lt(e){var n;const{node:r}=e;/* @__PURE__ */
|
|
46
|
+
return t("span",{className:"emoji-node",children:null!=(n=r.name)?n:r.markup})}function Tt(e){/* @__PURE__ */
|
|
47
|
+
return t("em",{className:"emphasis-node",children:e.children})}function Et(e){const{node:n}=e,r=d(e=>{var t;if(e.preventDefault(),"undefined"==typeof document)return;const r=document.getElementById(`fnref-${String(null!=(t=n.id)?t:"")}`);r&&r.scrollIntoView({behavior:"smooth"})},[n.id]);/* @__PURE__ */
|
|
48
|
+
return t("a",{className:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${n.id}`,title:`返回引用 ${n.id}`,onClick:r,children:"↩︎"})}function Dt(e){const{node:n,ctx:r,renderNode:o,indexKey:i}=e;/* @__PURE__ */
|
|
49
|
+
return t("div",{id:`fnref--${n.id}`,className:"footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2",children:/* @__PURE__ */t("div",{className:"flex-1",children:r&&o?S(n.children,r,String(null!=i?i:`footnote-${n.id}`),o):null})})}function $t(n){const{node:r}=n,i=o(()=>`#fnref--${r.id}`,[r.id]),l=o(()=>({href:i}),[i]),a=d(e=>{if(e.preventDefault(),"undefined"==typeof document)return;const t=document.querySelector(i);t&&t.scrollIntoView({behavior:"smooth"})},[i]);/* @__PURE__ */
|
|
50
|
+
return t("sup",{id:`fnref-${r.id}`,className:"footnote-reference",onClick:a,children:/* @__PURE__ */e("span",{...l,title:`查看脚注 ${r.id}`,className:"footnote-link cursor-pointer",children:["[",r.id,"]"]})})}function Pt(e){/* @__PURE__ */
|
|
51
|
+
return t("br",{className:"hard-break"})}function At(e){const{node:n,ctx:r,renderNode:o,indexKey:i,children:l}=e,a=Math.min(6,Math.max(1,Number(n.level)||1)),c=`h${a}`,s=null==n?void 0:n.attrs,{class:d,className:u,style:m,...h}=null!=s?s:{};/* @__PURE__ */
|
|
52
|
+
return t(c,{dir:"auto",className:mt("heading-node font-semibold",`heading-${a}`,d,u),..."object"==typeof m&&null!=m?{style:m}:{},...h,children:null!=l?l:r&&o?S(n.children,r,String(null!=i?i:`heading-${a}`),o):null})}function Rt(e){/* @__PURE__ */
|
|
53
|
+
return t("mark",{className:"highlight-node",children:e.children})}function Ht(l){var a,d,m;const{node:w,placeholder:v,customId:y}=l,x=null!=(m=null!=(d=l.htmlPolicy)?d:null==(a=l.ctx)?void 0:a.htmlPolicy)?m:"safe",k=we(),[b,C]=i(null),M=c(null),[N,B]=i(()=>"undefined"==typeof window),[L,T]=i(w.content),E=Boolean(w.loading),D=u(A,R,R),$=o(()=>{var e;return null!=(e=l.customComponents)?e:H(y)},[y,l.customComponents,D]);s(()=>{var e;if("undefined"==typeof window)return void B(!0);if(null==(e=M.current)||e.destroy(),M.current=null,!E)return B(!0),void T(w.content);if(!b)return void B(!1);const t=k(b,{rootMargin:"400px"});return M.current=t,t.isVisible()&&B(!0),t.whenVisible.then(()=>B(!0)).catch(()=>{}),()=>{t.destroy(),M.current=null}},[b,E,w.content,k]),s(()=>()=>{var e;null==(e=M.current)||e.destroy(),M.current=null},[]),s(()=>{E&&!N||T(w.content)},[E,w.content,N]);const P=o(()=>{var e;const t=_(h(null!=(e=w.attrs)?e:void 0,x));return t?W(t):void 0},[x,w.attrs]),j=o(()=>{var e;return String(null!=(e=w.tag)?e:"").trim()},[w.tag]),O=o(()=>{var e;const t=_(h(null!=(e=w.attrs)?e:void 0,x,j));return t?W(t):void 0},[x,w.attrs,j]),z=o(()=>Array.isArray(w.children)?w.children:[],[w.children]),V=z.length>0&&!!j&&!f.has(j.toLowerCase())&&!p(j,x)&&!!l.ctx&&!!l.renderNode,K=o(()=>function(e){const t={...e||{}},n="string"==typeof t.className?t.className.trim():"";return t.className=n?`html-block-node ${n}`:"html-block-node",t}(O),[O]),X=o(()=>{var e;return"escape"!==x&&I(null!=(e=w.content)?e:"",$)},[$,x,w.content]),U=o(()=>X&&w.content?F(w.content,$,x):null,[$,x,w.content,X]),q=o(()=>g(null!=L?L:"",x),[x,L]),Y=o(()=>{var e;return V&&l.ctx&&l.renderNode?S(z,l.ctx,`${String(null!=(e=l.indexKey)?e:"html-block")}-structured`,l.renderNode):null},[V,l.ctx,l.indexKey,l.renderNode,z]),Z=/* @__PURE__ */t("div",{className:"html-block-node__placeholder",children:null!=v?v:/* @__PURE__ */e(n,{children:[
|
|
54
54
|
/* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar"}),
|
|
55
55
|
/* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-4/5"}),
|
|
56
|
-
/* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return V?r.createElement(j,{...K,ref:C},N?Y:Z):/* @__PURE__ */t("div",{ref:C,className:"html-block-node",...P,children:N?X&&U?/* @__PURE__ */t(n,{children:U}):/* @__PURE__ */t("div",{dangerouslySetInnerHTML:{__html:q}}):Z})}const
|
|
56
|
+
/* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return V?r.createElement(j,{...K,ref:C},N?Y:Z):/* @__PURE__ */t("div",{ref:C,className:"html-block-node",...P,children:N?X&&U?/* @__PURE__ */t(n,{children:U}):/* @__PURE__ */t("div",{dangerouslySetInnerHTML:{__html:q}}):Z})}const _t=(()=>{try{return Boolean(!1)}catch{}return!1})();function Wt(e){_t&&console.warn(e)}function It(e,t,n=!1){const r=Object.entries(null!=t?t:{}),o=r.length>0?r.map(([e,t])=>""===t?` ${e}`:` ${e}="${t}"`).join(""):"";return n?`<${e}${o} />`:`<${e}${o}>`}function Ft(e,t){Array.isArray(t)?e.push(...t):null!=t&&e.push(t)}function jt(e,t,n,o,i,l){const a=O(e,o);if(w.has(e.toLowerCase())||!a&&v(e,l))return null;if(!a&&p(e,l))return[It(e,t),...n,`</${e}>`];const c=z(t,l,e),s=c.key,d=null!=s&&""!==s?s:i;if(a){const t=o[e]||o[e.toLowerCase()],i=function(e){return y(e)}(c);return r.createElement(t,{...i,key:d},...n)}return r.createElement(e,{...W(c),key:d},...n)}function Ot(e){var n,o,l;const{node:a,customId:d}=e,u=null!=(l=null!=(o=e.htmlPolicy)?o:null==(n=e.ctx)?void 0:n.htmlPolicy)?l:"safe",m=c(null),[h,f]=i(!1);s(()=>{f(!0)},[]);const y=H(d),x=r.useMemo(()=>{var e;return g(null!=(e=a.content)?e:"",u)},[u,a.content]),k=r.useMemo(()=>{const e=a.content;if(!e)return{mode:"html",content:""};if("escape"===u)return{mode:"html",content:e};if(!I(e,y))return{mode:"html",content:e};const t=function(e,t,n="safe"){if(!e)return[];try{const r=function(e,t,n="safe"){let r=0;const o=[],i=[];for(const l of e)if("text"===l.type){if(o.length>0&&o[o.length-1].hardBlocked)continue;(o.length>0?o[o.length-1].children:i).push(l.content)}else if("self_closing"===l.type){const e=O(l.tagName,t);if(w.has(l.tagName.toLowerCase())||!e&&v(l.tagName,n))continue;if(!e&&p(l.tagName,n)){(o.length>0?o[o.length-1].children:i).push(It(l.tagName,l.attrs||{},!0));continue}const a=jt(l.tagName,l.attrs||{},[],t,"ms-html-"+r++,n);Ft(o.length>0?o[o.length-1].children:i,a)}else if("tag_open"===l.type){const e=o.length>0&&o[o.length-1].hardBlocked,r=O(l.tagName,t);o.push({tagName:l.tagName,children:[],attrs:l.attrs,customComponent:r,hardBlocked:e||w.has(l.tagName.toLowerCase())||!r&&v(l.tagName,n),softBlocked:!e&&!r&&p(l.tagName,n)})}else if("tag_close"===l.type){const e=l.tagName.toLowerCase();let a=-1;for(let t=o.length-1;t>=0;t--)if(o[t].tagName.toLowerCase()===e){a=t;break}if(-1!==a)for(;o.length>a;){const l=o.pop();let c;c=l.hardBlocked?null:l.softBlocked?[It(l.tagName,l.attrs||{}),...l.children,`</${l.tagName}>`]:jt(l.tagName,l.attrs||{},l.children,t,"ms-html-"+r++,n),o.length>0?Ft(o[o.length-1].children,c):Ft(i,c),l.tagName.toLowerCase()!==e&&o.length>a&&Wt(`Auto-closing unclosed tag: <${l.tagName}>`)}else Wt(`Ignoring closing tag with no matching opening tag: </${l.tagName}>`)}for(;o.length>0;){const e=o.pop();let l;l=e.hardBlocked?null:e.softBlocked?[It(e.tagName,e.attrs||{}),...e.children,`</${e.tagName}>`]:jt(e.tagName,e.attrs||{},e.children,t,"ms-html-"+r++,n),Ft(i,l),Wt(`Auto-closing unclosed tag: <${e.tagName}>`)}return i}(j(e),t,n);return r}catch(o){return r=o,_t&&console.error("Failed to parse HTML to React nodes:",r),null}var r}(e,y,u);return null===t?{mode:"html",content:e}:{mode:"dynamic",nodes:t}},[y,u,a.content]);return s(()=>{if(!h||!m.current||"html"!==k.mode)return;const e=m.current;e.innerHTML="";const t=document.createElement("template");t.innerHTML=x,e.appendChild(t.content.cloneNode(!0))},[k.mode,h,x]),a.loading&&!a.autoClosed?/* @__PURE__ */t("span",{className:"html-inline-node html-inline-node--loading",children:a.content}):"dynamic"===k.mode?/* @__PURE__ */t("span",{className:"html-inline-node",style:{display:"inline"},children:k.nodes}):/* @__PURE__ */t("span",{ref:m,className:"html-inline-node",style:{display:"inline"}})}const zt={fallbackSrc:"",lazy:!0,usePlaceholder:!0};function Vt(r){var o,l,a,c,d,u;const m={...zt,...r},[h,f]=i(!1),[p,g]=i(!1),[w,v]=i(!1),y=p&&m.fallbackSrc?m.fallbackSrc:m.node.src;s(()=>{f(!1),g(!1)},[y]),s(()=>{v(!1)},[m.node.src]);return m.node.loading||p?p?m.node.loading||m.fallbackSrc?null:/* @__PURE__ */e("span",{className:"image-node__error",children:[
|
|
57
57
|
/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24","aria-hidden":"true",children:/* @__PURE__ */t("path",{fill:"currentColor",d:"M2 2h20v10h-2V4H4v9.586l5-5L14.414 14L13 15.414l-4-4l-5 5V20h8v2H2zm13.547 5a1 1 0 1 0 0 2a1 1 0 0 0 0-2m-3 1a3 3 0 1 1 6 0a3 3 0 0 1-6 0m3.625 6.757L19 17.586l2.828-2.829l1.415 1.415L20.414 19l2.829 2.828l-1.415 1.415L19 20.414l-2.828 2.829l-1.415-1.415L17.586 19l-2.829-2.828z"})}),
|
|
58
58
|
/* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:"Image failed to load"})]}):/* @__PURE__ */t("span",{className:"image-node__placeholder",children:m.usePlaceholder?/* @__PURE__ */e(n,{children:[
|
|
59
59
|
/* @__PURE__ */t("span",{className:"image-node__spinner","aria-hidden":"true"}),
|
|
60
|
-
/* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:"Loading image..."})]}):/* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:null!=(u=m.node.raw)?u:"Loading image…"})},"placeholder"):/* @__PURE__ */t("img",{src:y,alt:String(null!=(l=null!=(o=m.node.alt)?o:m.node.title)?l:""),title:String(null!=(c=null!=(a=m.node.title)?a:m.node.alt)?c:""),className:"image-node__img"+(h?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:h?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;m.fallbackSrc&&!w?(v(!0),g(!0)):(g(!0),null==(e=m.onError)||e.call(m,m.node.src))},onLoad:()=>{var e;
|
|
60
|
+
/* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:"Loading image..."})]}):/* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:null!=(u=m.node.raw)?u:"Loading image…"})},"placeholder"):/* @__PURE__ */t("img",{src:y,alt:String(null!=(l=null!=(o=m.node.alt)?o:m.node.title)?l:""),title:String(null!=(c=null!=(a=m.node.title)?a:m.node.alt)?c:""),className:"image-node__img"+(h?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:h?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;m.fallbackSrc&&!w?(v(!0),g(!0)):(g(!0),null==(e=m.onError)||e.call(m,m.node.src))},onLoad:()=>{var e;f(!0),g(!1),null==(e=m.onLoad)||e.call(m,y)},onClick:e=>{var t;e.preventDefault(),h&&!p&&(null==(t=m.onClick)||t.call(m,[e,y]))}},"image")}let Kt=null,Xt=null;const Ut=/* @__PURE__ */t("svg",{width:"1em",height:"1em",viewBox:"0 0 291 300",fill:"none",className:"w-4 h-4 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",children:/* @__PURE__ */e("g",{children:[
|
|
61
61
|
/* @__PURE__ */t("path",{d:"M140.904 239.376C128.83 239.683 119.675 239.299 115.448 243.843C110.902 248.07 111.288 257.227 110.979 269.302C111.118 274.675 111.118 279.478 111.472 283.52C111.662 285.638 111.95 287.547 112.406 289.224C112.411 289.243 112.416 289.259 112.422 289.28C112.462 289.419 112.496 289.558 112.539 289.691C113.168 291.787 114.088 293.491 115.446 294.758C116.662 296.064 118.283 296.963 120.264 297.69C120.36 297.614 120.464 297.646 120.555 297.675C120.56 297.68 120.56 297.68 120.566 297.68C120.848 297.768 121.142 297.846 121.443 297.923C121.454 297.923 121.464 297.928 121.478 297.934C122.875 298.272 124.424 298.507 126.11 298.678C126.326 298.696 126.542 298.718 126.763 298.739C130.79 299.086 135.558 299.088 140.904 299.222C152.974 298.912 162.128 299.302 166.36 294.758C170.904 290.526 170.515 281.371 170.824 269.302C170.515 257.227 170.907 248.07 166.36 243.843C162.131 239.299 152.974 239.683 140.904 239.376Z",fill:"#FF6376"}),
|
|
62
62
|
/* @__PURE__ */t("path",{d:"M21.2155 128.398C12.6555 128.616 6.16484 128.339 3.16751 131.56C-0.0538222 134.56 0.218178 141.054 -0.000488281 149.608C0.218178 158.168 -0.0538222 164.659 3.16751 167.656C6.16484 170.878 12.6555 170.606 21.2155 170.824C25.0262 170.726 28.4288 170.726 31.2955 170.475C32.7968 170.342 34.1488 170.136 35.3382 169.814C35.3542 169.811 35.3648 169.806 35.3782 169.803C35.4768 169.774 35.5755 169.747 35.6688 169.718C37.1568 169.272 38.3648 168.622 39.2635 167.656C40.1915 166.795 40.8262 165.646 41.2715 164.243C41.2875 164.174 41.3115 164.102 41.3328 164.035C41.3328 164.035 41.3355 164.032 41.3355 164.027C41.3968 163.827 41.4529 163.622 41.5062 163.406C41.5062 163.398 41.5115 163.392 41.5142 163.382C41.7542 162.392 41.9222 161.294 42.0422 160.096C42.0555 159.944 42.0715 159.792 42.0848 159.635C42.3328 156.779 42.3328 153.398 42.4262 149.608C42.2075 141.054 42.4848 134.56 39.2635 131.56C36.2635 128.339 29.7728 128.616 21.2155 128.398Z",fill:"#FFCCCC"}),
|
|
63
63
|
/* @__PURE__ */t("path",{d:"M81.0595 184.171C70.8568 184.433 63.1208 184.102 59.5475 187.942C55.7075 191.518 56.0328 199.254 55.7742 209.454C56.0328 219.657 55.7075 227.393 59.5475 230.963C63.1208 234.803 70.8568 234.478 81.0595 234.739C85.6008 234.622 89.6595 234.622 93.0728 234.323C94.8648 234.163 96.4755 233.921 97.8942 233.534C97.9102 233.529 97.9235 233.526 97.9422 233.521C98.0568 233.486 98.1742 233.457 98.2888 233.422C100.06 232.889 101.5 232.113 102.569 230.963C103.676 229.937 104.433 228.566 104.964 226.894C104.985 226.811 105.012 226.726 105.036 226.646C105.041 226.643 105.041 226.643 105.041 226.638C105.116 226.401 105.18 226.153 105.244 225.897C105.244 225.889 105.249 225.881 105.254 225.867C105.54 224.689 105.74 223.379 105.881 221.953C105.9 221.771 105.916 221.59 105.934 221.403C106.228 218.001 106.228 213.969 106.342 209.454C106.081 199.254 106.412 191.518 102.572 187.942C98.9955 184.102 91.2568 184.433 81.0595 184.171Z",fill:"#FF939F"}),
|
|
64
64
|
/* @__PURE__ */t("path",{d:"M260.591 151.87C215.652 151.87 203.02 164.523 203.02 209.462H198.476C198.476 164.523 185.836 151.881 140.895 151.881V147.337C185.836 147.337 198.487 134.705 198.487 89.7659H203.02C203.02 134.705 215.652 147.337 260.591 147.337V151.87ZM286.052 124.158C281.82 119.614 272.66 120.001 260.591 119.689C248.521 119.385 239.361 119.771 235.129 115.227C230.585 110.995 230.983 101.846 230.671 89.7659C230.513 83.7312 230.535 78.4272 230.023 74.1019C229.513 69.7659 228.481 66.4219 226.209 64.3046C221.967 59.7606 212.817 60.1472 200.748 59.8459C188.681 60.1472 179.519 59.7606 175.287 64.3046C170.753 68.5366 171.129 77.6966 170.828 89.7659C170.516 101.835 170.9 110.995 166.356 115.227C162.124 119.771 152.985 119.374 140.905 119.689C138.873 119.739 136.924 119.771 135.071 119.811C119.313 118.697 106.337 112.318 106.337 89.7659C106.212 84.6699 106.233 80.1792 105.807 76.5206C105.367 72.8726 104.492 70.0379 102.575 68.2566C99.0013 64.4112 91.2573 64.7446 81.0653 64.4832C70.86 64.7446 63.1186 64.4112 59.5533 68.2566C55.708 71.8299 56.0306 79.5632 55.7693 89.7659C56.0306 99.9686 55.708 107.702 59.5533 111.278C63.1186 115.113 70.86 114.79 81.0653 115.049C103.617 115.049 109.996 128.035 111.1 143.803C111.068 145.659 111.028 147.587 110.975 149.619C111.121 154.987 111.121 159.79 111.476 163.835C111.663 165.95 111.945 167.857 112.404 169.534C112.412 169.555 112.412 169.566 112.423 169.598C112.465 169.734 112.497 169.867 112.537 170.003C113.164 172.099 114.092 173.809 115.447 175.07C116.665 176.371 118.281 177.278 120.271 177.905C120.364 177.934 120.46 177.955 120.564 177.987C120.855 178.081 121.145 178.153 121.439 178.238C121.46 178.238 121.471 178.238 121.479 178.249C122.876 178.582 124.42 178.822 126.108 178.987C126.327 179.009 126.545 179.03 126.764 179.051C130.788 179.395 135.559 179.395 140.905 179.529C152.975 179.843 162.124 179.457 166.356 184.001C170.9 188.233 170.516 197.371 170.828 209.451C171.129 221.529 170.743 230.681 175.287 234.91C179.519 239.454 188.681 239.07 200.748 239.371C206.127 239.235 210.921 239.235 214.975 238.881C217.079 238.694 218.985 238.403 220.676 237.955C220.695 237.945 220.705 237.934 220.727 237.934C220.873 237.891 220.999 237.859 221.135 237.819C223.228 237.193 224.937 236.265 226.209 234.91C227.511 233.691 228.409 232.065 229.044 230.097C229.065 230.003 229.095 229.899 229.127 229.803V229.793C229.22 229.513 229.295 229.222 229.367 228.918C229.367 228.897 229.377 228.897 229.377 228.878C229.721 227.481 229.951 225.937 230.127 224.249C230.137 224.03 230.169 223.811 230.191 223.593C230.535 219.571 230.535 214.798 230.671 209.451C230.972 197.371 230.585 188.233 235.129 184.001C239.361 179.457 248.511 179.843 260.591 179.529C272.66 179.227 281.82 179.614 286.052 175.07C290.596 170.838 290.209 161.689 290.511 149.619C290.209 137.539 290.596 128.379 286.052 124.158Z",fill:"#FF356A"}),
|
|
65
|
-
/* @__PURE__ */t("path",{d:"M112.405 49.848C112.411 49.8694 112.416 49.8827 112.421 49.904C112.461 50.0427 112.499 50.1814 112.539 50.3147C113.171 52.4134 114.088 54.1147 115.448 55.384C116.661 56.6907 118.283 57.5894 120.264 58.2134C120.36 58.24 120.464 58.2694 120.555 58.3014C120.56 58.3067 120.56 58.3067 120.565 58.3067C120.848 58.3947 121.141 58.4694 121.443 58.5467C121.453 58.5467 121.464 58.552 121.48 58.5574C122.875 58.896 124.424 59.1334 126.112 59.3014C126.325 59.3227 126.541 59.3414 126.763 59.3627C130.789 59.712 135.56 59.712 140.904 59.8454C152.973 59.5387 162.128 59.928 166.36 55.384C170.907 51.152 170.515 41.9947 170.824 29.9254C170.517 17.8507 170.907 8.69602 166.363 4.46935C162.131 -0.0746511 152.973 0.309349 140.904 1.52588e-05C128.829 0.309349 119.675 -0.0746511 115.448 4.46935C110.904 8.69602 111.288 17.8507 110.979 29.9254C111.117 35.3014 111.117 40.1014 111.472 44.144C111.661 46.2614 111.949 48.1707 112.405 49.848Z",fill:"#FF6376"})]})}),
|
|
65
|
+
/* @__PURE__ */t("path",{d:"M112.405 49.848C112.411 49.8694 112.416 49.8827 112.421 49.904C112.461 50.0427 112.499 50.1814 112.539 50.3147C113.171 52.4134 114.088 54.1147 115.448 55.384C116.661 56.6907 118.283 57.5894 120.264 58.2134C120.36 58.24 120.464 58.2694 120.555 58.3014C120.56 58.3067 120.56 58.3067 120.565 58.3067C120.848 58.3947 121.141 58.4694 121.443 58.5467C121.453 58.5467 121.464 58.552 121.48 58.5574C122.875 58.896 124.424 59.1334 126.112 59.3014C126.325 59.3227 126.541 59.3414 126.763 59.3627C130.789 59.712 135.56 59.712 140.904 59.8454C152.973 59.5387 162.128 59.928 166.36 55.384C170.907 51.152 170.515 41.9947 170.824 29.9254C170.517 17.8507 170.907 8.69602 166.363 4.46935C162.131 -0.0746511 152.973 0.309349 140.904 1.52588e-05C128.829 0.309349 119.675 -0.0746511 115.448 4.46935C110.904 8.69602 111.288 17.8507 110.979 29.9254C111.117 35.3014 111.117 40.1014 111.472 44.144C111.661 46.2614 111.949 48.1707 112.405 49.848Z",fill:"#FF6376"})]})}),qt={maxHeight:"500px",loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function Yt(r){var l;const a={...qt,...r},{t:u}=be(),[m,h]=i(!1),[f,p]=i(!1),[g,w]=i(!1),[v,y]=i(!1),[x,k]=i(()=>"undefined"==typeof window),b=a.node.code,C=o(()=>a.maxHeight&&"none"!==a.maxHeight?V(a.maxHeight):null,[a.maxHeight]),M=o(()=>{var e;return K(null!=(e=V(a.estimatedPreviewHeightPx))?e:X(b),void 0,C)},[b,C,a.estimatedPreviewHeightPx]),[N,B]=i(`${M}px`),[S,L]=i(!1),[T,E]=i(1),[D,$]=i({x:0,y:0}),[P,A]=i(!1),R=c(null),H=c(null),_=c(null),W=c(null),I=c(null),F=c({x:0,y:0}),j=c(null),O=we(),z=d(e=>{if(!a.maxHeight||"none"===a.maxHeight)return`${Math.max(e,M)}px`;const t=Number.parseFloat(String(a.maxHeight));return Number.isFinite(t)?`${Math.max(Math.min(e,t),M)}px`:`${Math.max(e,M)}px`},[M,a.maxHeight]),U=d(()=>{const e=R.current;if(!e)return;const t=e.scrollHeight;t>0&&B(z(t))},[z]);s(()=>{g||f||B(e=>{const t=V(e);return null!=t&&t>=M?e:`${M}px`})},[M,f,g]);const q=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(b)),h(!0),null==(t=a.onCopy)||t.call(a,b),setTimeout(()=>h(!1),1e3)}catch{}},[b,a]),Y=d(async()=>{var e,t;if(!x)return;if(!R.current)return;const n=R.current;try{const r=await async function(){return Xt||Kt||(Kt=import("@antv/infographic").then(e=>{const t=e&&e.default?e.default:e;let n=t;return"function"==typeof t&&t.prototype&&t.prototype.render?n=t:e.Infographic?n=e.Infographic:t&&t.Infographic&&(n=t.Infographic),Xt=n,n}).catch(e=>(console.warn("Failed to load @antv/infographic",e),null)),Kt)}();if(!r)return void console.warn("Infographic library failed to load.");j.current&&(null==(t=(e=j.current).destroy)||t.call(e),j.current=null),n.innerHTML="";const o=new r({container:n,width:"100%",height:"100%"});j.current=o,o.render(b),L(!0),setTimeout(()=>{U()},0)}catch(r){console.error("Failed to render infographic:",r),L(!1),n.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${r instanceof Error?r.message:"Unknown error"}</div>`}},[b,U,x]);s(()=>{const e=H.current;if(!e)return;const t=O(e,{rootMargin:"160px"});return _.current=t,t.isVisible()&&k(!0),t.whenVisible.then(()=>k(!0)),()=>{t.destroy(),_.current=null}},[O]),s(()=>{!x||g||f||Y()},[b,f,Y,g,x]),s(()=>()=>{var e,t;j.current&&(null==(t=(e=j.current).destroy)||t.call(e),j.current=null)},[]);const Z=d(()=>{y(!1),W.current&&(W.current.innerHTML=""),I.current=null,document.body.style.overflow=""},[]),G=d(()=>{y(!0),document.body.style.overflow="hidden"},[]);s(()=>{if(!v)return;const e=e=>{"Escape"===e.key&&Z()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v,Z]),s(()=>{v&&setTimeout(()=>{if(R.current&&W.current){W.current.innerHTML="";const e=document.createElement("div");Object.assign(e.style,{transition:"transform 0.1s ease",transformOrigin:"center center",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"});const t=R.current.cloneNode(!0);t.classList.add("fullscreen"),t.style.height="auto",e.appendChild(t),W.current.appendChild(e),I.current=e,e.style.transform=`translate(${D.x}px, ${D.y}px) scale(${T})`}},0)},[v]),s(()=>{v&&I.current&&(I.current.style.transform=`translate(${D.x}px, ${D.y}px) scale(${T})`)},[v,D,T]);const J=d(()=>{var e;const t=null==(e=R.current)?void 0:e.querySelector("svg");if(!t)return;const n=(new XMLSerializer).serializeToString(t),r=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`infographic-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)},[]),Q=e=>{A(!0);const t="touches"in e?e.touches[0].clientX:e.clientX,n="touches"in e?e.touches[0].clientY:e.clientY;F.current={x:t-D.x,y:n-D.y}},ee=e=>{if(!P)return;const t="touches"in e?e.touches[0].clientX:e.clientX,n="touches"in e?e.touches[0].clientY:e.clientY;$({x:t-F.current.x,y:n-F.current.y})},te=()=>A(!1),re=a.isDark?"p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",oe=g||f;/* @__PURE__ */
|
|
66
66
|
return e(n,{children:[
|
|
67
|
-
/* @__PURE__ */e("div",{ref:H,"data-markstream-infographic":"1","data-markstream-mode":g?"source":
|
|
68
|
-
/* @__PURE__ */e("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[
|
|
69
|
-
/* @__PURE__ */t("span",{className:
|
|
70
|
-
/* @__PURE__ */t("button",{className:
|
|
67
|
+
/* @__PURE__ */e("div",{ref:H,"data-markstream-infographic":"1","data-markstream-mode":g?"source":S?"preview":"pending",className:mt("my-4 rounded-lg border overflow-hidden shadow-sm",a.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":a.loading}),children:[a.showHeader&&/* @__PURE__ */e("div",{className:mt("flex justify-between items-center px-4 py-2.5 border-b",a.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"),children:[
|
|
68
|
+
/* @__PURE__ */e("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[Ut,
|
|
69
|
+
/* @__PURE__ */t("span",{className:mt("text-sm font-medium font-mono truncate",a.isDark?"text-gray-400":"text-gray-600"),children:"Infographic"})]}),a.showModeToggle&&/* @__PURE__ */e("div",{className:mt("flex items-center gap-x-1 rounded-md p-0.5",a.isDark?"bg-gray-700":"bg-gray-100"),children:[
|
|
70
|
+
/* @__PURE__ */t("button",{className:mt("px-2.5 py-1 text-xs rounded transition-colors",g?a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"),onClick:()=>w(!1),onMouseEnter:e=>De(e.currentTarget,u("common.preview")||"Preview","top",!1,0,a.isDark),onMouseLeave:()=>$e(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
|
|
71
71
|
/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
72
72
|
/* @__PURE__ */t("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),
|
|
73
73
|
/* @__PURE__ */t("circle",{cx:"12",cy:"12",r:"3"})]})}),
|
|
74
74
|
/* @__PURE__ */t("span",{children:u("common.preview")||"Preview"})]})}),
|
|
75
|
-
/* @__PURE__ */t("button",{className:
|
|
75
|
+
/* @__PURE__ */t("button",{className:mt("px-2.5 py-1 text-xs rounded transition-colors",g?a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),onClick:()=>w(!0),onMouseEnter:e=>De(e.currentTarget,u("common.source")||"Source","top",!1,0,a.isDark),onMouseLeave:()=>$e(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
|
|
76
76
|
/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})}),
|
|
77
77
|
/* @__PURE__ */t("span",{children:u("common.source")||"Source"})]})})]}),
|
|
78
|
-
/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
|
|
78
|
+
/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[a.showCollapseButton&&/* @__PURE__ */t("button",{className:re,onClick:()=>p(!f),onMouseEnter:e=>De(e.currentTarget,f?u("common.expand")||"Expand":u("common.collapse")||"Collapse","top",!1,0,a.isDark),onMouseLeave:()=>$e(),children:/* @__PURE__ */t("svg",{style:{rotate:f?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),a.showCopyButton&&/* @__PURE__ */t("button",{className:re,onClick:q,onMouseEnter:e=>De(e.currentTarget,m?u("common.copied")||"Copied":u("common.copy")||"Copy","top",!1,0,a.isDark),onMouseLeave:()=>$e(),children:/* @__PURE__ */t("svg",m?{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
79
79
|
/* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
80
|
-
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),
|
|
80
|
+
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),a.showExportButton&&/* @__PURE__ */t("button",{className:mt(re,oe&&"opacity-50 cursor-not-allowed"),disabled:oe,onClick:J,onMouseEnter:e=>De(e.currentTarget,u("common.export")||"Export","top",!1,0,a.isDark),onMouseLeave:()=>$e(),children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
81
81
|
/* @__PURE__ */t("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
|
|
82
|
-
/* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),
|
|
83
|
-
/* @__PURE__ */t("button",{className:
|
|
84
|
-
/* @__PURE__ */t("button",{className:
|
|
85
|
-
/* @__PURE__ */e("button",{className:
|
|
86
|
-
/* @__PURE__ */t("div",{className:
|
|
87
|
-
/* @__PURE__ */t("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:Z,role:"dialog","aria-modal":"true",children:/* @__PURE__ */e("div",{className:
|
|
82
|
+
/* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),a.showFullscreenButton&&/* @__PURE__ */t("button",{className:mt(re,oe&&"opacity-50 cursor-not-allowed"),disabled:oe,onClick:G,onMouseEnter:e=>De(e.currentTarget,v?u("common.minimize")||"Minimize":u("common.open")||"Open","top",!1,0,a.isDark),onMouseLeave:()=>$e(),children:/* @__PURE__ */t("svg",v?{xmlns:"http://www.w3.org/2000/svg",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),!f&&/* @__PURE__ */t("div",{children:g?/* @__PURE__ */t("div",{className:mt("p-4",a.isDark?"bg-gray-900":"bg-gray-50"),children:/* @__PURE__ */t("pre",{className:mt("text-sm font-mono whitespace-pre-wrap",a.isDark?"text-gray-300":"text-gray-700"),children:b})}):/* @__PURE__ */e("div",{className:"relative",children:[a.showZoomControls&&/* @__PURE__ */t("div",{className:"absolute top-2 right-2 z-10 rounded-lg",children:/* @__PURE__ */e("div",{className:"flex items-center gap-2 backdrop-blur rounded-lg",children:[
|
|
83
|
+
/* @__PURE__ */t("button",{className:mt("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.min(T+.1,3)),children:"+"}),
|
|
84
|
+
/* @__PURE__ */t("button",{className:mt("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.max(T-.1,.5)),children:"-"}),
|
|
85
|
+
/* @__PURE__ */e("button",{className:mt("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{E(1),$({x:0,y:0})},children:[Math.round(100*T),"%"]})]})}),
|
|
86
|
+
/* @__PURE__ */t("div",{className:mt("infographic-preview min-h-[360px] relative transition-all duration-100 overflow-hidden block",a.isDark?"bg-gray-900":"bg-gray-50"),style:{height:N,maxHeight:null!=(l=a.maxHeight)?l:void 0},onMouseDown:Q,onMouseMove:ee,onMouseUp:te,onMouseLeave:te,onTouchStart:Q,onTouchMove:ee,onTouchEnd:te,children:/* @__PURE__ */t("div",{className:mt("absolute inset-0 cursor-grab",P&&"cursor-grabbing"),style:{transform:`translate(${D.x}px, ${D.y}px) scale(${T})`},children:/* @__PURE__ */t("div",{ref:R,className:"w-full text-center flex items-center justify-center min-h-full"})})})]})})]}),v&&"undefined"!=typeof document&&ne(
|
|
87
|
+
/* @__PURE__ */t("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:Z,role:"dialog","aria-modal":"true",children:/* @__PURE__ */e("div",{className:mt("dialog-panel relative w-full h-full max-w-full max-h-full rounded shadow-lg overflow-hidden",a.isDark?"bg-gray-900":"bg-white"),onClick:e=>e.stopPropagation(),children:[
|
|
88
88
|
/* @__PURE__ */e("div",{className:"absolute top-6 right-6 z-50 flex items-center gap-2",children:[
|
|
89
|
-
/* @__PURE__ */t("button",{className:
|
|
90
|
-
/* @__PURE__ */t("button",{className:
|
|
91
|
-
/* @__PURE__ */e("button",{className:
|
|
92
|
-
/* @__PURE__ */t("button",{className:
|
|
93
|
-
/* @__PURE__ */t("div",{ref:
|
|
94
|
-
return t("ins",{className:"insert-node",children:e.children})}function
|
|
95
|
-
/* @__PURE__ */t("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */t(
|
|
96
|
-
/* @__PURE__ */t("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */t("a",{className:"link-node",href:
|
|
97
|
-
return t("li",{className:"list-item pl-1.5 my-2",dir:"auto",value:null==i?void 0:i,children:null!=a?a:r&&o?
|
|
98
|
-
return t(a,{className:
|
|
99
|
-
return t(s,{node:e,value:r.ordered?(null!=(a=r.start)?a:1)+n:void 0,ctx:o,renderNode:i,indexKey:`${String(null!=l?l:"list")}-${n}`,customId:null==o?void 0:o.customId,isDark:null==o?void 0:o.isDark,typewriter:null==o?void 0:o.typewriter},`${String(null!=l?l:"list")}-${n}`)})})}let
|
|
89
|
+
/* @__PURE__ */t("button",{className:mt("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.min(T+.1,3)),children:"+"}),
|
|
90
|
+
/* @__PURE__ */t("button",{className:mt("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.max(T-.1,.5)),children:"-"}),
|
|
91
|
+
/* @__PURE__ */e("button",{className:mt("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{E(1),$({x:0,y:0})},children:[Math.round(100*T),"%"]}),
|
|
92
|
+
/* @__PURE__ */t("button",{className:mt("inline-flex items-center justify-center p-2 rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:Z,children:"X"})]}),
|
|
93
|
+
/* @__PURE__ */t("div",{ref:W,className:mt("w-full h-full flex items-center justify-center p-4 overflow-hidden",!P&&"cursor-grab",P&&"cursor-grabbing"),onMouseDown:Q,onMouseMove:ee,onMouseUp:te,onMouseLeave:te,onTouchStart:Q,onTouchMove:ee,onTouchEnd:te})]})}),document.body)]})}function Zt(r){var o,l;const{node:a,children:d,ctx:u,indexKey:m,fade:h}=r,f=String(null!=(o=a.code)?o:""),p=null==(l=null!=h?h:null==u?void 0:u.fade)||l,g=null==m||""===m?"":String(m),[w,v]=i(f),[y,x]=i(""),[k,b]=i(0),C=me(),M=c(void 0),N=c({settledContent:f,streamedDelta:""}),B=(e,t)=>{N.current={settledContent:e,streamedDelta:t},v(e),x(t)},S=()=>{const{settledContent:e,streamedDelta:t}=N.current;return e+t};return s(()=>{var e,t;const n=null!=(e=null==C?void 0:C.getStreamRenderVersion())?e:null==u?void 0:u.streamRenderVersion,r=n!==M.current;if(null!=d)return B("",""),void(M.current=n);const o=null!=(t=null==C?void 0:C.textStreamState)?t:null==u?void 0:u.textStreamState,i=N.current,l=g?null==o?void 0:o.get(g):void 0,a=te({nextContent:f,persistedContent:l,currentState:i,typewriterEnabled:p,streamRenderVersionChanged:r});B(a.settledContent,a.streamedDelta),a.appended&&b(e=>e+1),g&&(null==o||o.set(g,f)),M.current=n},[d,f,C,null==u?void 0:u.textStreamState,null==u?void 0:u.streamRenderVersion,g,p]),s(()=>{if(p)return;const e=S();B(e,"")},[p]),/* @__PURE__ */t("code",{className:"inline-code inline text-[85%] px-1 py-0.5 rounded font-mono bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full",children:d||/* @__PURE__ */e(n,{children:[w?/* @__PURE__ */t("span",{children:w}):null,y?/* @__PURE__ */t("span",{className:mt("text-node-stream-delta",k%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"),onAnimationEnd:()=>{N.current.streamedDelta&&B(S(),"")},children:y}):null]})})}function Gt(e){/* @__PURE__ */
|
|
94
|
+
return t("ins",{className:"insert-node",children:e.children})}function Jt(n){var r,o;const{node:l,children:a,ctx:d,indexKey:u,fade:m}=n,h=String(null!=(r=l.content)?r:""),f=null==(o=null!=m?m:null==d?void 0:d.fade)||o,p=null==u||""===u?"":String(u),[g,w]=i(h),[v,y]=i(""),[x,k]=i(0),b=me(),C=c(void 0),M=c({settledContent:h,streamedDelta:""}),N=(e,t)=>{M.current={settledContent:e,streamedDelta:t},w(e),y(t)},B=()=>{const{settledContent:e,streamedDelta:t}=M.current;return e+t};return s(()=>{var e,t;const n=null!=(e=null==b?void 0:b.getStreamRenderVersion())?e:null==d?void 0:d.streamRenderVersion,r=n!==C.current;if(null!=a)return N("",""),void(C.current=n);const o=null!=(t=null==b?void 0:b.textStreamState)?t:null==d?void 0:d.textStreamState,i=M.current,l=p?null==o?void 0:o.get(p):void 0,c=te({nextContent:h,persistedContent:l,currentState:i,typewriterEnabled:f,streamRenderVersionChanged:r});N(c.settledContent,c.streamedDelta),c.appended&&k(e=>e+1),p&&(null==o||o.set(p,h)),C.current=n},[a,h,b,null==d?void 0:d.textStreamState,null==d?void 0:d.streamRenderVersion,p,f]),s(()=>{if(f)return;const e=B();N(e,"")},[f]),null!=a?/* @__PURE__ */t("span",{className:mt("text-node whitespace-pre-wrap break-words",l.center&&"text-node-center"),children:a}):/* @__PURE__ */e("span",{className:mt("text-node whitespace-pre-wrap break-words",l.center&&"text-node-center"),children:[g?/* @__PURE__ */t("span",{children:g}):null,v?/* @__PURE__ */t("span",{className:mt("text-node-stream-delta",x%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"),onAnimationEnd:()=>{M.current.streamedDelta&&N(B(),"")},children:v}):null]})}function Qt(n){var r,i,l;const{node:a,ctx:c,renderNode:s,indexKey:u}=n,m=!1!==n.showTooltip,h=null!=(r=n.isDark)?r:null==c?void 0:c.isDark,f=o(()=>{var e,t,r,o,i,l;const a=void 0!==n.underlineBottom?"number"==typeof n.underlineBottom?`${n.underlineBottom}px`:String(n.underlineBottom):"-3px",c=null!=(e=n.animationOpacity)?e:.35,s=Math.max(.12,Math.min(.5*c,c));return{"--link-color":null!=(t=n.color)?t:"#0366d6","--underline-height":`${null!=(r=n.underlineHeight)?r:2}px`,"--underline-bottom":a,"--underline-opacity":String(c),"--underline-rest-opacity":String(s),"--underline-duration":`${null!=(o=n.animationDuration)?o:1.6}s`,"--underline-timing":null!=(i=n.animationTiming)?i:"ease-in-out","--underline-iteration":"number"==typeof n.animationIteration?String(n.animationIteration):null!=(l=n.animationIteration)?l:"infinite"}},[n.animationDuration,n.animationIteration,n.animationOpacity,n.animationTiming,n.color,n.underlineBottom,n.underlineHeight]),p=o(()=>{var e;return x({href:String(null!=(e=a.href)?e:"")}).href},[a.href]),g="string"==typeof a.title&&a.title.trim().length>0?a.title:String(null!=p?p:""),w=d(e=>{m&&De(e.currentTarget,String(a.title||p||a.text||""),"top",!1,(e.clientX,e.clientY),h)},[h,a.text,a.title,p,m]),v=d(()=>{m&&$e()},[m]);return a.loading?/* @__PURE__ */t("span",{className:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":"false",style:f,children:/* @__PURE__ */e("span",{className:"link-text-wrapper relative inline-flex",children:[
|
|
95
|
+
/* @__PURE__ */t("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */t(Jt,{node:{type:"text",content:String(null!=(i=a.text)?i:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-loading`,typewriter:n.typewriter})}),
|
|
96
|
+
/* @__PURE__ */t("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */t("a",{className:"link-node",href:p,title:m?"":g,"aria-label":`Link: ${g}`,target:"_blank",rel:"noopener noreferrer",style:f,onMouseEnter:w,onMouseLeave:v,children:c&&s?S(a.children,c,String(null!=u?u:"link"),s):/* @__PURE__ */t(Jt,{node:{type:"text",content:String(null!=(l=a.text)?l:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-fallback`,typewriter:n.typewriter})})}function en(e){const{node:n,ctx:r,renderNode:o,value:i,indexKey:l,children:a}=e;/* @__PURE__ */
|
|
97
|
+
return t("li",{className:"list-item pl-1.5 my-2",dir:"auto",value:null==i?void 0:i,children:null!=a?a:r&&o?S(n.children,r,String(null!=l?l:"list-item"),o):null})}function tn(e){var n;const{node:r,ctx:o,renderNode:i,indexKey:l}=e,a=r.ordered?"ol":"ul",c=r.ordered&&r.start?r.start:void 0,s=o&&H(o.customId).list_item||en;/* @__PURE__ */
|
|
98
|
+
return t(a,{className:mt("list-node my-5 pl-[calc(13/8*1em)]",r.ordered?"list-decimal":"list-disc max-lg:my-[calc(4/3*1em)] max-lg:pl-[calc(14/9*1em)]"),start:c,children:null==(n=r.items)?void 0:n.map((e,n)=>{var a;/* @__PURE__ */
|
|
99
|
+
return t(s,{node:e,value:r.ordered?(null!=(a=r.start)?a:1)+n:void 0,ctx:o,renderNode:i,indexKey:`${String(null!=l?l:"list")}-${n}`,customId:null==o?void 0:o.customId,isDark:null==o?void 0:o.isDark,typewriter:null==o?void 0:o.typewriter},`${String(null!=l?l:"list")}-${n}`)})})}let nn=null,rn=null,on=!1;const ln=/* @__PURE__ */new Map,an=/* @__PURE__ */new Map;let cn=5;const sn=/* @__PURE__ */new Set;function dn(){if(ln.size<cn&&sn.size){const e=Array.from(sn);sn.clear();for(const t of e)try{t()}catch{}}}function un(e){nn=e,rn=null,nn.onmessage=e=>{const{id:t,html:n,error:r}=e.data,o=ln.get(t);if(o)if(ln.delete(t),clearTimeout(o.timeoutId),dn(),r)o.reject(new Error(r));else{const{content:t,displayMode:r}=e.data;if(t){const e=`${r?"d":"i"}:${t}`;if(an.set(e,n),an.size>200){const e=an.keys().next().value;an.delete(e)}}o.resolve(n)}},nn.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[t,n]of ln.entries())clearTimeout(n.timeoutId),n.reject(new Error(`Worker error: ${e.message}`));ln.clear(),dn()}}function mn(){var e;nn&&(null==(e=nn.terminate)||e.call(nn)),nn=null,rn=null}function hn(e){on=!!e,nn&&nn.postMessage({type:"init",debug:on})}const fn="WORKER_BUSY";async function pn(e,t=!0,n=2e3,r){performance.now();const o=U(e);if(rn)return Promise.reject(rn);const i=`${t?"d":"i"}:${o}`,l=an.get(i);if(l)return Promise.resolve(l);const a=nn||(rn=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),rn.name="WORKER_INIT_ERROR",rn.code="WORKER_INIT_ERROR",null);if(!a)return Promise.reject(rn);if(ln.size>=cn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=fn,e.busy=!0,e.inFlight=ln.size,e.max=cn,Promise.reject(e)}return new Promise((e,i)=>{if(null==r?void 0:r.aborted){const e=new Error("Aborted");return e.name="AbortError",void i(e)}const l=Math.random().toString(36).slice(2),c=setTimeout(()=>{ln.delete(l);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",i(e),dn()},n),s=()=>{},d=()=>{ln.delete(l),clearTimeout(c),sn.delete(s);const e=new Error("Aborted");e.name="AbortError",i(e),dn()};r&&r.addEventListener("abort",d,{once:!0}),ln.set(l,{resolve:t=>{r&&r.removeEventListener("abort",d),e(t)},reject:e=>{r&&r.removeEventListener("abort",d),i(e)},timeoutId:c});try{a.postMessage({id:l,content:o,displayMode:t,debug:on})}catch(u){ln.delete(l),clearTimeout(c),r&&r.removeEventListener("abort",d),i(u),dn()}})}function gn(e,t,n){const r=`${t?"d":"i"}:${U(e)}`;if(an.set(r,n),an.size>200){const e=an.keys().next().value;an.delete(e)}}function wn(){an.clear()}function vn(e){cn=Math.max(1,Math.floor(e)),dn()}function yn(e=1500,t){return ln.size<cn?Promise.resolve():new Promise((n,r)=>{if(null==t?void 0:t.aborted){const e=new Error("Aborted");return e.name="AbortError",void r(e)}let o=null;function i(){sn.delete(l),null!=o&&clearTimeout(o),t&&t.removeEventListener("abort",a)}function l(){i(),n()}function a(){i();const e=new Error("Aborted");e.name="AbortError",r(e)}o=e>0?setTimeout(()=>{i(),r(new Error("Timeout waiting for worker slot"))},e):null,t&&t.addEventListener("abort",a,{once:!0}),sn.add(l)})}const xn={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function kn(e){null!=e.timeout&&(xn.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(xn.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(xn.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(xn.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function bn(){return{...xn}}async function Cn(e,t=!0,n={}){var r,o,i,l;const a=null!=(r=n.timeout)?r:xn.timeout,c=null!=(o=n.waitTimeout)?o:xn.waitTimeout,s=null!=(i=n.backoffMs)?i:xn.backoffMs,d=null!=(l=n.maxRetries)?l:xn.maxRetries,u=Number.isFinite(d)?Math.max(0,Math.min(Math.floor(d),8)):xn.maxRetries,m=n.signal;let h=0;for(;;){if(null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}try{return await pn(e,t,a,m)}catch(f){if((null==f?void 0:f.code)!==fn||h>=u)throw f;if(h++,await yn(c,m).catch(()=>{}),null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}s>0&&await new Promise(e=>setTimeout(e,s*h))}}}let Mn=null,Nn=!1;async function Bn(){if(Mn)return Mn;if(Nn)return null;try{return Mn=await import("katex"),await import("katex/contrib/mhchem"),Mn}catch{return Nn=!0,null}}function Sn({node:e}){const n=c(null),r=c(null),o=c(null),l=we(),[a,d]=i(!0),[u,m]=i(()=>"undefined"==typeof window),h=c(0);return s(()=>{const e=n.current;if(!e)return;const t=l(e,{rootMargin:"400px"});return o.current=t,t.isVisible()&&m(!0),t.whenVisible.then(()=>m(!0)),()=>{t.destroy(),o.current=null}},[l]),s(()=>{var t;const n=U(null!=(t=e.content)?t:"");if(!n)return r.current&&(r.current.innerHTML=""),void d(!1);if(!u)return void d(!0);let o=!1;const i=new AbortController,l=++h.current;return Cn(n,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:i.signal}).then(e=>{o||l!==h.current||(r.current&&(r.current.innerHTML=e),d(!1))}).catch(async t=>{if(o||l!==h.current)return;if(!r.current)return;const i=(null==t?void 0:t.code)||(null==t?void 0:t.name);if("WORKER_INIT_ERROR"===i||(null==t?void 0:t.fallbackToRenderer)||i===fn||"WORKER_TIMEOUT"===i){const t=await Bn();if(t)try{const i=t.renderToString(n,{throwOnError:e.loading,displayMode:!0});return void(!o&&l===h.current&&r.current&&(r.current.innerHTML=i,d(!1),gn(n,!0,i)))}catch{}}e.loading||(r.current.textContent=e.raw,d(!1))}),()=>{o=!0,i.abort()}},[e.content,e.loading,e.raw,u]),/* @__PURE__ */t("div",{ref:n,className:"math-block text-center overflow-x-auto relative min-h-[40px]",children:/* @__PURE__ */t("div",{ref:r,className:a?"math-rendering":void 0})})}function Ln({node:n}){const r=c(null),o=c(null),l=c(null),a=we(),[d,u]=i(!0),[m,h]=i(()=>"undefined"==typeof window),f=c(0);return s(()=>{const e=r.current;if(!e)return;const t=a(e,{rootMargin:"400px"});return l.current=t,t.isVisible()&&h(!0),t.whenVisible.then(()=>h(!0)),()=>{t.destroy(),l.current=null}},[a]),s(()=>{var e;const t=U(null!=(e=n.content)?e:"");if(!t)return o.current&&(o.current.innerHTML=""),void u(!1);if(!m)return void u(!0);let r=!1;const i=new AbortController,l=++f.current,a="$$"===n.markup;return Cn(t,a,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||l!==f.current||o.current&&(o.current.innerHTML=e,u(!1))}).catch(async e=>{if(r||l!==f.current)return;if(!o.current)return;const i=(null==e?void 0:e.code)||(null==e?void 0:e.name);if("WORKER_INIT_ERROR"===i||(null==e?void 0:e.fallbackToRenderer)||i===fn||"WORKER_TIMEOUT"===i){const e=await Bn();if(e)try{const i=e.renderToString(t,{throwOnError:n.loading,displayMode:a});return void(!r&&l===f.current&&o.current&&(o.current.innerHTML=i,u(!1),gn(t,a,i)))}catch{}}n.loading||(o.current.textContent=n.raw,u(!1))}),()=>{r=!0,i.abort()}},[n.content,n.loading,n.raw,n.markup,m]),/* @__PURE__ */e("span",{ref:r,className:"math-inline-wrapper",children:[
|
|
100
100
|
/* @__PURE__ */t("span",{ref:o,className:"math-inline"+(d?" math-inline--hidden":"")}),d&&/* @__PURE__ */e("span",{className:"math-inline__loading",role:"status","aria-live":"polite",children:[
|
|
101
101
|
/* @__PURE__ */t("span",{className:"math-inline__spinner","aria-hidden":"true"}),
|
|
102
|
-
/* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function Mn(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let Nn=null,Bn=null;const Ln=/* @__PURE__ */new Map;let Sn=5,Tn=!1;function En(e){Tn=!!e}function Dn(e){Number.isFinite(e)&&e>0&&(Sn=Math.floor(e))}function $n(){return{inFlight:Ln.size,max:Sn}}const Pn="WORKER_BUSY";function An(e){Nn=e,Bn=null;const t=e;Nn.onmessage=e=>{if(Nn!==t)return;const{id:n,ok:r,result:o,error:i}=e.data,l=Ln.get(n);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},Nn.onerror=e=>{var n,r;if(Nn===t)if(0!==Ln.size){try{Tn?console.error("[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e)}catch{}for(const[t,n]of Ln.entries())n.reject(new Error(`Worker error: ${e.message}`));Ln.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},Nn.onmessageerror=e=>{var n,r;if(Nn===t)if(0!==Ln.size){try{Tn?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,t]of Ln.entries())t.reject(new Error("Worker messageerror"));Ln.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function Rn(){var e;if(Nn)try{for(const[e,t]of Ln.entries())t.reject(new Error("Worker cleared"));Ln.clear(),null==(e=Nn.terminate)||e.call(Nn)}catch{}Nn=null,Bn=null}function Hn(e,t,n=1400){if(Bn)return Promise.reject(Bn);const r=Nn||(Bn=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Bn.name="WORKER_INIT_ERROR",Bn.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(Bn);if(Ln.size>=Sn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Pn,e.inFlight=Ln.size,e.max=Sn,Promise.reject(e)}return new Promise((o,i)=>{const l=Math.random().toString(36).slice(2);let a=!1,c=null;const s=()=>{a||(a=!0,null!=c&&clearTimeout(c),Ln.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};Ln.set(l,d);try{r.postMessage({id:l,action:e,payload:t})}catch(u){return Ln.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const t=Ln.get(l);null==t||t.reject(e)},n)})}async function Wn(e,t,n=1400){return Hn("canParse",{code:e,theme:t},n)}async function In(e,t,n=2400){return Hn("findPrefix",{code:e,theme:t},n)}function _n(){var e;null==(e=null==Nn?void 0:Nn.terminate)||e.call(Nn),Nn=null,Bn=null,Ln.clear()}let Fn=null,jn=!1,On=null,zn=null;function Vn(e,t){var n;if(!e||!t)return;const r=function(e){var t,n;return`${String(null!=(t=null==e?void 0:e.securityLevel)?t:"strict")}|htmlLabels:${!1===(null==(n=null==e?void 0:e.flowchart)?void 0:n.htmlLabels)?"0":"1"}`}(t);if(On!==r)try{"function"==typeof e.initialize?e.initialize(t):(null==(n=e.mermaidAPI)?void 0:n.initialize)&&e.mermaidAPI.initialize(t),On=r}catch{}}const Kn="undefined"!=typeof window?m:s,Xn={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},Un=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],qn=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Yn(e){if(!e)return"";const t=e.trim();return qn.test(t)?t:""}function Zn(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function Gn(e,t,n){if(!e)return"";if(n)return function(e,t){if(!e)return"";Zn(e);const n=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return null;if(!e)return null;const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),n=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!n||"svg"!==n.nodeName.toLowerCase())return null;const r=n;return function(e){const t=/* @__PURE__ */new Set(["script"]),n=[e,...Array.from(e.querySelectorAll("*"))];for(const r of n){if(t.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&t.value){const n=t.value;if(Un.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=Yn(t.value);if(!n){r.removeAttribute(e);continue}n!==t.value&&r.setAttribute(e,n)}}}}}(r),r}(t);return n?(e.appendChild(n),e.innerHTML):""}(e,t);if(Zn(e),t)try{e.insertAdjacentHTML("afterbegin",t)}catch{e.innerHTML=t}return e.innerHTML}function Jn(e){if(!e||"undefined"==typeof DOMParser)return!e;const t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!t||"svg"!==t.nodeName.toLowerCase())return!0;const n=t.getAttribute("viewBox");if(n){const e=n.trim().split(/[\s,]+/);if(4===e.length){const t=Number.parseFloat(e[2]||""),n=Number.parseFloat(e[3]||"");if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0)return!0}}const r=[t,...Array.from(t.querySelectorAll("*"))];for(const o of r)for(const e of Array.from(o.attributes)){if(/\bNaN\b/i.test(e.value))return!0;if("style"===e.name&&/max-width:\s*0(?:px)?/i.test(e.value))return!0}return!1}const Qn={maxHeight:"500px",loading:!0,workerTimeoutMs:1400,parseTimeoutMs:1800,renderTimeoutMs:2500,fullRenderTimeoutMs:4e3,renderDebounceMs:300,contentStableDelayMs:500,previewPollDelayMs:800,previewPollMaxDelayMs:4e3,previewPollMaxAttempts:12,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showFullscreenButton:!0,showCollapseButton:!0,showZoomControls:!0,enableWheelZoom:!1,isStrict:!0};function er(r){var l,c,u,h,p,f,g,w,v,y;const x={...Qn,...r},{t:k}=ge(),b=o(()=>D("mermaid"),[]),C=null!=(c=null==(l=x.node)?void 0:l.code)?c:"",M=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),N=null!=(u=x.workerTimeoutMs)?u:Qn.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:Qn.parseTimeoutMs,L=null!=(p=x.renderTimeoutMs)?p:Qn.renderTimeoutMs,S=null!=(f=x.fullRenderTimeoutMs)?f:Qn.fullRenderTimeoutMs,T=Math.max(0,null!=(g=x.renderDebounceMs)?g:Qn.renderDebounceMs),E=o(()=>x.maxHeight&&"none"!==x.maxHeight?q(x.maxHeight):null,[x.maxHeight]),$=o(()=>{var e;return Y(null!=(e=q(x.estimatedPreviewHeightPx))?e:Z(M),void 0,E)},[M,E,x.estimatedPreviewHeightPx]),[P,A]=i(!1),[R,H]=i(!1),[W,I]=i(!1),[_,F]=i(!1),[j,O]=i(1),[z,V]=i({x:0,y:0}),[K,X]=i(!1),[U,G]=i(!1),[J,Q]=i(!1),[te,ne]=i(null),[re,oe]=i(!1),[ie,le]=i(`${$}px`),[ae,ce]=i("undefined"==typeof window),se=a(null),de=a(null),ue=a(null),he=a(null),pe=a(null),fe=a(null),we=a(null),ve=a({x:0,y:0}),ye=a(0),xe=a({}),ke=a(""),be=a(!1),Ce=a(null),Me=a(!1),Le=a({zoom:1,translateX:0,translateY:0,containerHeight:ie||"360px"}),Se=me(),Te=Boolean(null!=(v=null==(w=x.node)?void 0:w.loading)?v:x.loading),Ee=x.isDark?"dark":"light",De=Boolean(x.isStrict),$e=o(()=>De?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:Xn,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[De]);s(()=>{Me.current=J},[J]),s(()=>{R||W||le(e=>{const t=q(e);return null!=t&&t>=$?e:`${$}px`})},[$,W,R]),s(()=>{xe.current={}},[Ee,M,De]),s(()=>{let e=!1;return(async()=>{const t=await async function(e){if(Fn)return Vn(Fn,e),Fn;if(zn){const t=await zn;return t&&Vn(t,e),t}if(jn)return null;try{jn=!0,zn=(async()=>{try{const t=await import("mermaid"),n=(null==t?void 0:t.default)||t;if(Fn=(null==n?void 0:n.default)?n.default:(null==n?void 0:n.mermaidAPI)?n:(null==n?void 0:n.mermaid)?n.mermaid:n,!Fn)throw new Error("Mermaid module did not export expected API");return Vn(Fn,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),Fn}catch(t){return console.warn("[markstream-react] Failed to load mermaid:",t),null}finally{zn=null}})();const t=await zn;return t&&Vn(t,e),t}catch{return null}}($e);e||(se.current=t,A(Boolean(t)),be.current||H(!t))})(),()=>{e=!0}},[$e]),s(()=>{const e=de.current;if(!e)return;const t=Se(e,{rootMargin:"400px"});return Ce.current=t,t.isVisible()&&ce(!0),t.whenVisible.then(()=>ce(!0)),()=>{t.destroy(),Ce.current=null}},[Se]),s(()=>{if("undefined"==typeof document)return;if(!re)return;const e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[re]);const Pe=d(()=>E,[E]),Ae=d(e=>{const t=de.current,n=he.current;if(!t||!n)return;const r=n.querySelector("svg");if(!r)return;let o=0,i=0;const l=r.getAttribute("viewBox");if(l){const e=l.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),i=Number.parseFloat(e[3]))}if(o&&i||!r.hasAttribute("width")||!r.hasAttribute("height")||(o=Number.parseFloat(r.getAttribute("width")||"0"),i=Number.parseFloat(r.getAttribute("height")||"0")),!o||!i||Number.isNaN(o)||Number.isNaN(i))try{const e=r.getBBox();o=e.width,i=e.height}catch{return}if(!(o>0&&i>0))return;const a=(null!=e?e:t.clientWidth)*(i/o),c=Number.isFinite(a)&&a>0?a:i,s=Pe(),d=null==s?c:Math.min(c,s);le(`${"none"===x.maxHeight?d:Math.max(d,$)}px`)},[$,x.maxHeight,Pe]);s(()=>{if(!de.current||"undefined"==typeof ResizeObserver)return;if(R||W)return;const e=new ResizeObserver(e=>{if(!e.length)return;const t=e[0].contentRect.width;Mn(()=>Ae(t))});return e.observe(de.current),()=>e.disconnect()},[W,R,Ae]),s(()=>{R||W||Ae()},[W,x.maxHeight,R,Ae]),s(()=>()=>{_n()},[]),m(()=>{!R&&he.current&&xe.current[Ee]&&(Gn(he.current,xe.current[Ee],De),Mn(()=>Ae()))},[R,De,Ee,Ae]);const Re=d(async(e,t,n)=>{var r;if(!se.current||!he.current)return!1;G(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=rr(e,t),l=await ar(()=>se.current.render(o,i),{timeoutMs:S,signal:n});if(!(null==l?void 0:l.svg)||Jn(l.svg))return!1;const a=Gn(he.current,l.svg,De);return null==(r=l.bindFunctions)||r.call(l,he.current),Ae(),xe.current[t]=a,Q(!0),ne(null),!0}catch(o){if(!Te){if("function"==typeof x.onRenderError&&he.current&&!0===x.onRenderError(o,M,he.current))return!1;ne(o instanceof Error?o.message:String(o))}return!1}finally{G(!1)}},[S,Te,De,Ae]),He=d(async(e,t,n)=>{var r;if(se.current&&he.current){G(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=rr(lr(e)||e,t),l=await ar(()=>se.current.render(o,i),{timeoutMs:L,signal:n});(null==l?void 0:l.svg)&&!Jn(l.svg)&&(Gn(he.current,l.svg,De),null==(r=l.bindFunctions)||r.call(l,he.current),Ae())}catch{}finally{G(!1)}}},[L,Te,De,Ae]),We=d(async(e,t)=>{if(!e.trim())return Zn(he.current),Q(!1),void(ke.current="");const n=e.replace(/\s+/g,"");if(n===ke.current&&Me.current)return;const r=++ye.current;if("gantt"===or(e)){const i=lr(e);if(!i.trim())return;try{if(await nr(i,Ee,{workerTimeout:N,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;i===e?await Re(e,Ee,t)&&(ke.current=n):await He(i,Ee,t)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await nr(e,Ee,{workerTimeout:N,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;return void(await Re(e,Ee,t)&&(ke.current=n))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}try{const n=await async function(e,t,n){try{const r=await In(e,t,n.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return lr(e)}(e,Ee,{workerTimeout:N,signal:t});if(!n||(null==t?void 0:t.aborted)||ye.current!==r)return;await He(n,Ee,t)}catch{}},[B,Re,He,Ee,N]),Ie=d(()=>ae&&!R&&!W,[W,R,ae]);s(()=>{if(!Ie())return;if(!se.current)return;const e=new AbortController,t=window.setTimeout(()=>{!e.signal.aborted&&Ie()&&We(M,e.signal)},T);return()=>{e.abort(),window.clearTimeout(t)}},[M,Ie,P,We,T]);const _e=d((e,t)=>{e.clientX,e.clientY,Ne(e.currentTarget,t,"top",!1,0,x.isDark)},[x.isDark]),Fe=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(M)),F(!0),null==(t=x.onCopy)||t.call(x,M),setTimeout(()=>F(!1),1e3)}catch{}},[M,x]),je=d(()=>{var e,t,n;const r=null!=(t=null==(e=he.current)?void 0:e.querySelector("svg"))?t:null;if(!r)return;const o=cr(r),i={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(n=x.onExport)||n.call(x,i),i.defaultPrevented||function(e,t){const n=null!=t?t:cr(e),r=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`mermaid-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}(r,o)},[x]),Oe=d(()=>{we.current=null,Zn(fe.current)},[]),ze=d(()=>{oe(!1),Oe()},[Oe]),Ve=d(()=>{var e,t,n;const r=null!=(t=null==(e=he.current)?void 0:e.querySelector("svg"))?t:null,o=r?cr(r):null,i={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(n=x.onOpenModal)||n.call(x,i),i.defaultPrevented||oe(!0)},[x]);s(()=>{if(!re)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&ze()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[ze,re]),Kn(()=>{if(!re)return;const e=fe.current,t=de.current;if(!e||!t)return;const n=`translate(${z.x}px, ${z.y}px) scale(${j})`,r=t.cloneNode(!0);r.classList.add("fullscreen"),r.style.height="100%",r.style.maxHeight="100%";const o=r.querySelector("[data-mermaid-wrapper]");o&&(we.current=o,o.style.transform=n),Zn(e),e.appendChild(r)},[re]),s(()=>{re&&we.current&&(we.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${j})`)},[re,z.x,z.y,j]);const Ke=R||U||W,Xe=o(()=>x.isDark?"mermaid-action-btn p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"mermaid-action-btn p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",[x.isDark]),Ue=d(e=>{var t;const n={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(null==(t=x.onToggleMode)||t.call(x,e,n),!n.defaultPrevented)if(be.current=!0,"preview"===e){H(!1);const e=Le.current;O(e.zoom),V({x:e.translateX,y:e.translateY}),le(e.containerHeight)}else Le.current={zoom:j,translateX:z.x,translateY:z.y,containerHeight:ie},H(!0)},[M,ie,We,x,Ee,z.x,z.y,Ae,j]),qe=d(e=>{if(!1===x.enableWheelZoom)return;if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=de.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-z.x,o=e.clientY-n.top-z.y,i=.01*-e.deltaY,l=tr(j+i,.5,3);if(l===j)return;const a=l/j;V({x:z.x-r*(a-1),y:z.y-o*(a-1)}),O(l)},[z,j]),Ye=d((e,t)=>{X(!0),ve.current={x:e-z.x,y:t-z.y}},[z.x,z.y]),Ze=d((e,t)=>{K&&V({x:e-ve.current.x,y:t-ve.current.y})},[K]),Ge=d(()=>{X(!1)},[]),Je=/* @__PURE__ */e("div",{className:"relative",children:[x.showZoomControls&&/* @__PURE__ */t("div",{className:"absolute top-2 right-2 z-10 rounded-lg",children:/* @__PURE__ */e("div",{className:"flex items-center gap-2 backdrop-blur rounded-lg",children:[
|
|
103
|
-
/* @__PURE__ */t("button",{type:"button",className:
|
|
104
|
-
/* @__PURE__ */t("button",{type:"button",className:
|
|
105
|
-
/* @__PURE__ */e("button",{type:"button",className:
|
|
106
|
-
/* @__PURE__ */e("div",{ref:de,className:
|
|
107
|
-
/* @__PURE__ */t("div",{ref:ue,"data-mermaid-wrapper":!0,className:
|
|
102
|
+
/* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function Tn(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let En=null,Dn=null;const $n=/* @__PURE__ */new Map;let Pn=5,An=!1;function Rn(e){An=!!e}function Hn(e){Number.isFinite(e)&&e>0&&(Pn=Math.floor(e))}function _n(){return{inFlight:$n.size,max:Pn}}const Wn="WORKER_BUSY";function In(e){En=e,Dn=null;const t=e;En.onmessage=e=>{if(En!==t)return;const{id:n,ok:r,result:o,error:i}=e.data,l=$n.get(n);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},En.onerror=e=>{var n,r;if(En===t)if(0!==$n.size){try{An?console.error("[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e)}catch{}for(const[t,n]of $n.entries())n.reject(new Error(`Worker error: ${e.message}`));$n.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},En.onmessageerror=e=>{var n,r;if(En===t)if(0!==$n.size){try{An?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,t]of $n.entries())t.reject(new Error("Worker messageerror"));$n.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function Fn(){var e;if(En)try{for(const[e,t]of $n.entries())t.reject(new Error("Worker cleared"));$n.clear(),null==(e=En.terminate)||e.call(En)}catch{}En=null,Dn=null}function jn(e,t,n=1400){if(Dn)return Promise.reject(Dn);const r=En||(Dn=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Dn.name="WORKER_INIT_ERROR",Dn.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(Dn);if($n.size>=Pn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Wn,e.inFlight=$n.size,e.max=Pn,Promise.reject(e)}return new Promise((o,i)=>{const l=Math.random().toString(36).slice(2);let a=!1,c=null;const s=()=>{a||(a=!0,null!=c&&clearTimeout(c),$n.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};$n.set(l,d);try{r.postMessage({id:l,action:e,payload:t})}catch(u){return $n.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const t=$n.get(l);null==t||t.reject(e)},n)})}async function On(e,t,n=1400){return jn("canParse",{code:e,theme:t},n)}async function zn(e,t,n=2400){return jn("findPrefix",{code:e,theme:t},n)}function Vn(){var e;null==(e=null==En?void 0:En.terminate)||e.call(En),En=null,Dn=null,$n.clear()}let Kn=null,Xn=!1,Un=null,qn=null;function Yn(e,t){var n;if(!e||!t)return;const r=function(e){var t,n;return`${String(null!=(t=null==e?void 0:e.securityLevel)?t:"strict")}|htmlLabels:${!1===(null==(n=null==e?void 0:e.flowchart)?void 0:n.htmlLabels)?"0":"1"}`}(t);if(Un!==r)try{"function"==typeof e.initialize?e.initialize(t):(null==(n=e.mermaidAPI)?void 0:n.initialize)&&e.mermaidAPI.initialize(t),Un=r}catch{}}const Zn="undefined"!=typeof window?m:s,Gn={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},Jn=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],Qn=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function er(e){if(!e)return"";const t=e.trim();return Qn.test(t)?t:""}function tr(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function nr(e,t,n){if(!e)return"";if(n)return function(e,t){if(!e)return"";tr(e);const n=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return null;if(!e)return null;const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),n=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!n||"svg"!==n.nodeName.toLowerCase())return null;const r=n;return function(e){const t=/* @__PURE__ */new Set(["script"]),n=[e,...Array.from(e.querySelectorAll("*"))];for(const r of n){if(t.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&t.value){const n=t.value;if(Jn.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=er(t.value);if(!n){r.removeAttribute(e);continue}n!==t.value&&r.setAttribute(e,n)}}}}}(r),r}(t);return n?(e.appendChild(n),e.innerHTML):""}(e,t);if(tr(e),t)try{e.insertAdjacentHTML("afterbegin",t)}catch{e.innerHTML=t}return e.innerHTML}function rr(e){if(!e||"undefined"==typeof DOMParser)return!e;const t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!t||"svg"!==t.nodeName.toLowerCase())return!0;const n=t.getAttribute("viewBox");if(n){const e=n.trim().split(/[\s,]+/);if(4===e.length){const t=Number.parseFloat(e[2]||""),n=Number.parseFloat(e[3]||"");if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0)return!0}}const r=[t,...Array.from(t.querySelectorAll("*"))];for(const o of r)for(const e of Array.from(o.attributes)){if(/\bNaN\b/i.test(e.value))return!0;if("style"===e.name&&/max-width:\s*0(?:px)?/i.test(e.value))return!0}return!1}const or={maxHeight:"500px",loading:!0,workerTimeoutMs:1400,parseTimeoutMs:1800,renderTimeoutMs:2500,fullRenderTimeoutMs:4e3,renderDebounceMs:300,contentStableDelayMs:500,previewPollDelayMs:800,previewPollMaxDelayMs:4e3,previewPollMaxAttempts:12,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showFullscreenButton:!0,showCollapseButton:!0,showZoomControls:!0,enableWheelZoom:!1,isStrict:!0};function ir(r){var l,a,u,h,f,p,g,w,v,y;const x={...or,...r},{t:k}=be(),b=o(()=>D("mermaid"),[]),C=null!=(a=null==(l=x.node)?void 0:l.code)?a:"",M=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),N=null!=(u=x.workerTimeoutMs)?u:or.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:or.parseTimeoutMs,S=null!=(f=x.renderTimeoutMs)?f:or.renderTimeoutMs,L=null!=(p=x.fullRenderTimeoutMs)?p:or.fullRenderTimeoutMs,T=Math.max(0,null!=(g=x.renderDebounceMs)?g:or.renderDebounceMs),E=o(()=>x.maxHeight&&"none"!==x.maxHeight?q(x.maxHeight):null,[x.maxHeight]),$=o(()=>{var e;return Y(null!=(e=q(x.estimatedPreviewHeightPx))?e:Z(M),void 0,E)},[M,E,x.estimatedPreviewHeightPx]),[P,A]=i(!1),[R,H]=i(!1),[_,W]=i(!1),[I,F]=i(!1),[j,O]=i(1),[z,V]=i({x:0,y:0}),[K,X]=i(!1),[U,G]=i(!1),[J,Q]=i(!1),[ee,te]=i(null),[re,oe]=i(!1),[ie,le]=i(`${$}px`),[ae,ce]=i("undefined"==typeof window),se=c(null),de=c(null),ue=c(null),me=c(null),he=c(null),fe=c(null),pe=c(null),ge=c({x:0,y:0}),ve=c(0),ye=c({}),xe=c(""),ke=c(!1),Ce=c(null),Me=c(!1),Ne=c({zoom:1,translateX:0,translateY:0,containerHeight:ie||"360px"}),Be=we(),Se=Boolean(null!=(v=null==(w=x.node)?void 0:w.loading)?v:x.loading),Le=x.isDark?"dark":"light",Te=Boolean(x.isStrict),Ee=o(()=>Te?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:Gn,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[Te]);s(()=>{Me.current=J},[J]),s(()=>{R||_||le(e=>{const t=q(e);return null!=t&&t>=$?e:`${$}px`})},[$,_,R]),s(()=>{ye.current={}},[Le,M,Te]),s(()=>{let e=!1;return(async()=>{const t=await async function(e){if(Kn)return Yn(Kn,e),Kn;if(qn){const t=await qn;return t&&Yn(t,e),t}if(Xn)return null;try{Xn=!0,qn=(async()=>{try{const t=await import("mermaid"),n=(null==t?void 0:t.default)||t;if(Kn=(null==n?void 0:n.default)?n.default:(null==n?void 0:n.mermaidAPI)?n:(null==n?void 0:n.mermaid)?n.mermaid:n,!Kn)throw new Error("Mermaid module did not export expected API");return Yn(Kn,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),Kn}catch(t){return console.warn("[markstream-react] Failed to load mermaid:",t),null}finally{qn=null}})();const t=await qn;return t&&Yn(t,e),t}catch{return null}}(Ee);e||(se.current=t,A(Boolean(t)),ke.current||H(!t))})(),()=>{e=!0}},[Ee]),s(()=>{const e=de.current;if(!e)return;const t=Be(e,{rootMargin:"400px"});return Ce.current=t,t.isVisible()&&ce(!0),t.whenVisible.then(()=>ce(!0)),()=>{t.destroy(),Ce.current=null}},[Be]),s(()=>{if("undefined"==typeof document)return;if(!re)return;const e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[re]);const Pe=d(()=>E,[E]),Ae=d(e=>{const t=de.current,n=me.current;if(!t||!n)return;const r=n.querySelector("svg");if(!r)return;let o=0,i=0;const l=r.getAttribute("viewBox");if(l){const e=l.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),i=Number.parseFloat(e[3]))}if(o&&i||!r.hasAttribute("width")||!r.hasAttribute("height")||(o=Number.parseFloat(r.getAttribute("width")||"0"),i=Number.parseFloat(r.getAttribute("height")||"0")),!o||!i||Number.isNaN(o)||Number.isNaN(i))try{const e=r.getBBox();o=e.width,i=e.height}catch{return}if(!(o>0&&i>0))return;const a=(null!=e?e:t.clientWidth)*(i/o),c=Number.isFinite(a)&&a>0?a:i,s=Pe(),d=null==s?c:Math.min(c,s);le(`${"none"===x.maxHeight?d:Math.max(d,$)}px`)},[$,x.maxHeight,Pe]);s(()=>{if(!de.current||"undefined"==typeof ResizeObserver)return;if(R||_)return;const e=new ResizeObserver(e=>{if(!e.length)return;const t=e[0].contentRect.width;Tn(()=>Ae(t))});return e.observe(de.current),()=>e.disconnect()},[_,R,Ae]),s(()=>{R||_||Ae()},[_,x.maxHeight,R,Ae]),s(()=>()=>{Vn()},[]),m(()=>{!R&&me.current&&ye.current[Le]&&(nr(me.current,ye.current[Le],Te),Tn(()=>Ae()))},[R,Te,Le,Ae]);const Re=d(async(e,t,n)=>{var r;if(!se.current||!me.current)return!1;G(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=cr(e,t),l=await mr(()=>se.current.render(o,i),{timeoutMs:L,signal:n});if(!(null==l?void 0:l.svg)||rr(l.svg))return!1;const a=nr(me.current,l.svg,Te);return null==(r=l.bindFunctions)||r.call(l,me.current),Ae(),ye.current[t]=a,Q(!0),te(null),!0}catch(o){if(!Se){if("function"==typeof x.onRenderError&&me.current&&!0===x.onRenderError(o,M,me.current))return!1;te(o instanceof Error?o.message:String(o))}return!1}finally{G(!1)}},[L,Se,Te,Ae]),He=d(async(e,t,n)=>{var r;if(se.current&&me.current){G(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=cr(ur(e)||e,t),l=await mr(()=>se.current.render(o,i),{timeoutMs:S,signal:n});(null==l?void 0:l.svg)&&!rr(l.svg)&&(nr(me.current,l.svg,Te),null==(r=l.bindFunctions)||r.call(l,me.current),Ae())}catch{}finally{G(!1)}}},[S,Se,Te,Ae]),_e=d(async(e,t)=>{if(!e.trim())return tr(me.current),Q(!1),void(xe.current="");const n=e.replace(/\s+/g,"");if(n===xe.current&&Me.current)return;const r=++ve.current;if("gantt"===sr(e)){const i=ur(e);if(!i.trim())return;try{if(await ar(i,Le,{workerTimeout:N,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ve.current!==r)return;i===e?await Re(e,Le,t)&&(xe.current=n):await He(i,Le,t)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await ar(e,Le,{workerTimeout:N,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ve.current!==r)return;return void(await Re(e,Le,t)&&(xe.current=n))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}try{const n=await async function(e,t,n){try{const r=await zn(e,t,n.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return ur(e)}(e,Le,{workerTimeout:N,signal:t});if(!n||(null==t?void 0:t.aborted)||ve.current!==r)return;await He(n,Le,t)}catch{}},[B,Re,He,Le,N]),We=d(()=>ae&&!R&&!_,[_,R,ae]);s(()=>{if(!We())return;if(!se.current)return;const e=new AbortController,t=window.setTimeout(()=>{!e.signal.aborted&&We()&&_e(M,e.signal)},T);return()=>{e.abort(),window.clearTimeout(t)}},[M,We,P,_e,T]);const Ie=d((e,t)=>{e.clientX,e.clientY,De(e.currentTarget,t,"top",!1,0,x.isDark)},[x.isDark]),Fe=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(M)),F(!0),null==(t=x.onCopy)||t.call(x,M),setTimeout(()=>F(!1),1e3)}catch{}},[M,x]),je=d(()=>{var e,t,n;const r=null!=(t=null==(e=me.current)?void 0:e.querySelector("svg"))?t:null;if(!r)return;const o=hr(r),i={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(n=x.onExport)||n.call(x,i),i.defaultPrevented||function(e,t){const n=null!=t?t:hr(e),r=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`mermaid-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}(r,o)},[x]),Oe=d(()=>{pe.current=null,tr(fe.current)},[]),ze=d(()=>{oe(!1),Oe()},[Oe]),Ve=d(()=>{var e,t,n;const r=null!=(t=null==(e=me.current)?void 0:e.querySelector("svg"))?t:null,o=r?hr(r):null,i={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(n=x.onOpenModal)||n.call(x,i),i.defaultPrevented||oe(!0)},[x]);s(()=>{if(!re)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&ze()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[ze,re]),Zn(()=>{if(!re)return;const e=fe.current,t=de.current;if(!e||!t)return;const n=`translate(${z.x}px, ${z.y}px) scale(${j})`,r=t.cloneNode(!0);r.classList.add("fullscreen"),r.style.height="100%",r.style.maxHeight="100%";const o=r.querySelector("[data-mermaid-wrapper]");o&&(pe.current=o,o.style.transform=n),tr(e),e.appendChild(r)},[re]),s(()=>{re&&pe.current&&(pe.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${j})`)},[re,z.x,z.y,j]);const Ke=R||U||_,Xe=o(()=>x.isDark?"mermaid-action-btn p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"mermaid-action-btn p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",[x.isDark]),Ue=d(e=>{var t;const n={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(null==(t=x.onToggleMode)||t.call(x,e,n),!n.defaultPrevented)if(ke.current=!0,"preview"===e){H(!1);const e=Ne.current;O(e.zoom),V({x:e.translateX,y:e.translateY}),le(e.containerHeight)}else Ne.current={zoom:j,translateX:z.x,translateY:z.y,containerHeight:ie},H(!0)},[M,ie,_e,x,Le,z.x,z.y,Ae,j]),qe=d(e=>{if(!1===x.enableWheelZoom)return;if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=de.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-z.x,o=e.clientY-n.top-z.y,i=.01*-e.deltaY,l=lr(j+i,.5,3);if(l===j)return;const a=l/j;V({x:z.x-r*(a-1),y:z.y-o*(a-1)}),O(l)},[z,j]),Ye=d((e,t)=>{X(!0),ge.current={x:e-z.x,y:t-z.y}},[z.x,z.y]),Ze=d((e,t)=>{K&&V({x:e-ge.current.x,y:t-ge.current.y})},[K]),Ge=d(()=>{X(!1)},[]),Je=/* @__PURE__ */e("div",{className:"relative",children:[x.showZoomControls&&/* @__PURE__ */t("div",{className:"absolute top-2 right-2 z-10 rounded-lg",children:/* @__PURE__ */e("div",{className:"flex items-center gap-2 backdrop-blur rounded-lg",children:[
|
|
103
|
+
/* @__PURE__ */t("button",{type:"button",className:mt("p-2 text-xs rounded transition-colors",x.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onMouseEnter:e=>Ie(e,k("common.zoomIn")),onMouseLeave:()=>$e(),onClick:()=>O(lr(j+.1,.5,3)),children:"+"}),
|
|
104
|
+
/* @__PURE__ */t("button",{type:"button",className:mt("p-2 text-xs rounded transition-colors",x.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onMouseEnter:e=>Ie(e,k("common.zoomOut")),onMouseLeave:()=>$e(),onClick:()=>O(lr(j-.1,.5,3)),children:"−"}),
|
|
105
|
+
/* @__PURE__ */e("button",{type:"button",className:mt("p-2 text-xs rounded transition-colors",x.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onMouseEnter:e=>Ie(e,k("common.resetZoom")),onMouseLeave:()=>$e(),onClick:()=>{O(1),V({x:0,y:0})},children:[Math.round(100*j),"%"]})]})}),
|
|
106
|
+
/* @__PURE__ */e("div",{ref:de,className:mt("min-h-[360px] relative overflow-hidden block transition-[height] duration-150 ease-out",x.isDark?"bg-gray-900":"bg-gray-50"),style:{height:ie,maxHeight:null!=(y=x.maxHeight)?y:void 0},onWheel:qe,onMouseDown:e=>{0===e.button&&(e.preventDefault(),Ye(e.clientX,e.clientY))},onMouseMove:e=>Ze(e.clientX,e.clientY),onMouseUp:Ge,onMouseLeave:Ge,onTouchStart:e=>{const t=e.touches[0];t&&Ye(t.clientX,t.clientY)},onTouchMove:e=>{const t=e.touches[0];t&&Ze(t.clientX,t.clientY)},onTouchEnd:Ge,children:[
|
|
107
|
+
/* @__PURE__ */t("div",{ref:ue,"data-mermaid-wrapper":!0,className:mt("absolute inset-0 cursor-grab",{"cursor-grabbing":K}),style:{transform:`translate(${z.x}px, ${z.y}px) scale(${j})`},children:/* @__PURE__ */t("div",{ref:me,className:"_mermaid w-full text-center flex items-center justify-center min-h-full"})}),(U||Se)&&/* @__PURE__ */e("div",{className:"mermaid-loading",children:[
|
|
108
108
|
/* @__PURE__ */t("span",{className:"mermaid-spinner"}),
|
|
109
|
-
/* @__PURE__ */t("span",{children:"Rendering diagram…"})]})]})]}),Qe=x.showHeader&&/* @__PURE__ */e("div",{className:
|
|
109
|
+
/* @__PURE__ */t("span",{children:"Rendering diagram…"})]})]})]}),Qe=x.showHeader&&/* @__PURE__ */e("div",{className:mt("mermaid-block-header flex justify-between items-center px-4 py-2.5 border-b",x.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"),children:[
|
|
110
110
|
/* @__PURE__ */e("div",{className:"flex items-center space-x-2 overflow-hidden",children:[
|
|
111
111
|
/* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:b}}),
|
|
112
|
-
/* @__PURE__ */t("span",{className:
|
|
113
|
-
/* @__PURE__ */t("button",{type:"button",className:
|
|
112
|
+
/* @__PURE__ */t("span",{className:mt("text-sm font-medium font-mono truncate",x.isDark?"text-gray-400":"text-gray-600"),children:"Mermaid"})]}),x.showModeToggle&&P&&/* @__PURE__ */e("div",{className:mt("flex items-center space-x-1 rounded-md p-0.5",x.isDark?"bg-gray-700":"bg-gray-100"),children:[
|
|
113
|
+
/* @__PURE__ */t("button",{type:"button",className:mt("px-2.5 py-1 text-xs rounded transition-colors",R?x.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":x.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"),onClick:()=>Ue("preview"),onMouseEnter:e=>Ie(e,k("common.preview")),onFocus:e=>Ie(e,k("common.preview")),onMouseLeave:()=>$e(),onBlur:()=>$e(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
|
|
114
114
|
/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
115
115
|
/* @__PURE__ */t("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),
|
|
116
116
|
/* @__PURE__ */t("circle",{cx:"12",cy:"12",r:"3"})]})}),
|
|
117
117
|
/* @__PURE__ */t("span",{children:k("common.preview")})]})}),
|
|
118
|
-
/* @__PURE__ */t("button",{type:"button",className:
|
|
118
|
+
/* @__PURE__ */t("button",{type:"button",className:mt("px-2.5 py-1 text-xs rounded transition-colors",R?x.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":x.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),onClick:()=>Ue("source"),onMouseEnter:e=>Ie(e,k("common.source")),onFocus:e=>Ie(e,k("common.source")),onMouseLeave:()=>$e(),onBlur:()=>$e(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
|
|
119
119
|
/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})}),
|
|
120
120
|
/* @__PURE__ */t("span",{children:k("common.source")})]})})]}),
|
|
121
|
-
/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[x.showCollapseButton&&/* @__PURE__ */t("button",{type:"button",className:Xe,"aria-pressed":
|
|
121
|
+
/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[x.showCollapseButton&&/* @__PURE__ */t("button",{type:"button",className:Xe,"aria-pressed":_,onClick:()=>W(e=>!e),onMouseEnter:e=>Ie(e,k(_?"common.expand":"common.collapse")),onFocus:e=>Ie(e,k(_?"common.expand":"common.collapse")),onMouseLeave:()=>$e(),onBlur:()=>$e(),children:/* @__PURE__ */t("svg",{style:{rotate:_?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),x.showCopyButton&&/* @__PURE__ */t("button",{type:"button",className:Xe,onClick:Fe,onMouseEnter:e=>Ie(e,k(I?"common.copied":"common.copy")),onFocus:e=>Ie(e,k(I?"common.copied":"common.copy")),onMouseLeave:()=>$e(),onBlur:()=>$e(),children:/* @__PURE__ */t("svg",I?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
122
122
|
/* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
123
|
-
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),x.showExportButton&&P&&/* @__PURE__ */t("button",{type:"button",className:
|
|
123
|
+
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),x.showExportButton&&P&&/* @__PURE__ */t("button",{type:"button",className:mt(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:je,onMouseEnter:e=>Ie(e,k("common.export")),onFocus:e=>Ie(e,k("common.export")),onMouseLeave:()=>$e(),onBlur:()=>$e(),children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
124
124
|
/* @__PURE__ */t("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
|
|
125
|
-
/* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&P&&/* @__PURE__ */t("button",{type:"button",className:
|
|
125
|
+
/* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&P&&/* @__PURE__ */t("button",{type:"button",className:mt(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:re?ze:Ve,onMouseEnter:e=>Ie(e,k(re?"common.minimize":"common.open")),onFocus:e=>Ie(e,k(re?"common.minimize":"common.open")),onMouseLeave:()=>$e(),onBlur:()=>$e(),children:/* @__PURE__ */t("svg",re?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),et=/* @__PURE__ */e("div",{children:[R?/* @__PURE__ */t("div",{className:mt("p-4",x.isDark?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-700"),children:/* @__PURE__ */t("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:M})}):Je,ee&&/* @__PURE__ */t("div",{className:"mermaid-error",children:ee})]});/* @__PURE__ */
|
|
126
126
|
return e(n,{children:[
|
|
127
|
-
/* @__PURE__ */e("div",{"data-markstream-mermaid":"1","data-markstream-mode":R?"source":J?"preview":"pending",className:
|
|
128
|
-
/* @__PURE__ */t("div",{ref:
|
|
129
|
-
/* @__PURE__ */t("div",{className:"mermaid-modal-overlay",onClick:()=>ze(),children:/* @__PURE__ */e("div",{className:
|
|
127
|
+
/* @__PURE__ */e("div",{"data-markstream-mermaid":"1","data-markstream-mode":R?"source":J?"preview":"pending",className:mt("my-4 rounded-lg border overflow-hidden shadow-sm mermaid-block",x.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":Se}),children:[Qe,
|
|
128
|
+
/* @__PURE__ */t("div",{ref:he,style:{display:_?"none":""},children:et})]}),re&&"undefined"!=typeof document&&ne(
|
|
129
|
+
/* @__PURE__ */t("div",{className:"mermaid-modal-overlay",onClick:()=>ze(),children:/* @__PURE__ */e("div",{className:mt("mermaid-modal-panel",{"is-dark":x.isDark}),role:"dialog","aria-modal":"true",onClick:e=>e.stopPropagation(),children:[
|
|
130
130
|
/* @__PURE__ */e("div",{className:"mermaid-modal-header",children:[
|
|
131
131
|
/* @__PURE__ */t("span",{className:"mermaid-modal-title",children:`Mermaid ${k("common.preview")}`}),
|
|
132
132
|
/* @__PURE__ */t("button",{type:"button",className:"mermaid-modal-close",onClick:ze,children:k("common.close")})]}),
|
|
133
|
-
/* @__PURE__ */t("div",{className:"mermaid-modal-body",children:/* @__PURE__ */t("div",{ref:fe,className:"mermaid-modal-content"})})]})}),document.body)]})}function
|
|
134
|
-
return e("div",{className:"unknown-node text-sm text-gray-500 italic",children:["Unsupported node type:"," ",String(null==n?void 0:n.type)]})}function
|
|
135
|
-
return t("p",{dir:"auto",className:"paragraph-node",children:d});const u=null!=(o=l.children)?o:[],m=null!=(i=a.customComponents)?i:H(a.customId),h=[],
|
|
136
|
-
/* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:
|
|
137
|
-
/* @__PURE__ */t(r.Fragment,{children:c(e,`${String(null!=s?s:"paragraph")}-block-${n}`,a)},`${String(null!=s?s:"paragraph")}-block-${n}`))):
|
|
138
|
-
return t("span",{className:"reference-node cursor-pointer bg-[hsl(var(--muted))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]",role:"button",tabIndex:0,onClick:r,onMouseEnter:t=>{var r;null==(r=e.onMouseEnter)||r.call(e,t,n.id,e.messageId,e.threadId)},onMouseLeave:t=>{var r;null==(r=e.onMouseLeave)||r.call(e,t,n.id,e.messageId,e.threadId)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||r(e)},children:n.id})}function
|
|
139
|
-
return t("s",{className:"strikethrough-node",children:e.children})}function
|
|
140
|
-
return t("strong",{className:"strong-node",children:e.children})}function
|
|
141
|
-
return t("sub",{className:"subscript-node",children:e.children})}function
|
|
142
|
-
return t("sup",{className:"superscript-node",children:e.children})}function
|
|
143
|
-
/* @__PURE__ */e("table",{ref:m,className:
|
|
144
|
-
/* @__PURE__ */t("thead",{className:"border-[var(--table-border,#cbd5e1)]",children:/* @__PURE__ */t("tr",{className:"border-b",children:s.map((n,r)=>/* @__PURE__ */e("th",{className:
|
|
133
|
+
/* @__PURE__ */t("div",{className:"mermaid-modal-body",children:/* @__PURE__ */t("div",{ref:fe,className:"mermaid-modal-content"})})]})}),document.body)]})}function lr(e,t,n){return Math.min(Math.max(e,t),n)}async function ar(e,t,n){try{if(await On(e,t,n.workerTimeout))return!0}catch(l){if("AbortError"===(null==l?void 0:l.name))throw l}if(!n.mermaid)throw new Error("Mermaid not available");const r=cr(e,t),o=n.mermaid;if("function"==typeof o.parse)return await mr(()=>o.parse(r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0;const i=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await mr(()=>o.render(i,r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0}function cr(e,t){return e.trimStart().startsWith("%%{")?e:`%%{init: {"theme": "${"dark"===t?"dark":"default"}"}}%%\n${e}`}function sr(e){var t;for(const n of e.split(/\r?\n/)){const e=n.trim();if(!e||e.startsWith("%%"))continue;const r=e.match(/^([A-Z][\w-]*)\b/i);return(null==(t=null==r?void 0:r[1])?void 0:t.toLowerCase())||""}return""}function dr(e){const t=e.trim();return!(!t||t.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(t)&&t.includes(":")}function ur(e){if("gantt"===sr(e))return function(e){var t;const n=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&n.length>0&&n.pop();n.length>0;){const e=null==(t=n[n.length-1])?void 0:t.trim();if(e&&!e.startsWith("%%")){if(dr(e))break;n.pop()}else n.pop()}return n.some(dr)?n.join("\n"):""}(e);const t=e.split("\n");for(;t.length>0;){const e=t[t.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join("\n")}async function mr(e,t={}){const{timeoutMs:n,signal:r}=t;return(null==r?void 0:r.aborted)?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((t,o)=>{let i=!1,l=null;function a(){i||(i=!0,c(),o(new DOMException("Aborted","AbortError")))}function c(){null!=l&&clearTimeout(l),r&&r.removeEventListener("abort",a)}r&&r.addEventListener("abort",a,{once:!0}),n&&n>0&&(l=setTimeout(()=>{i||(i=!0,c(),o(new Error("Operation timed out")))},n)),e().then(e=>{i||(i=!0,c(),t(e))}).catch(e=>{i||(i=!0,c(),o(e))})})}function hr(e){return(new XMLSerializer).serializeToString(e)}function fr(t){const{node:n}=t;/* @__PURE__ */
|
|
134
|
+
return e("div",{className:"unknown-node text-sm text-gray-500 italic",children:["Unsupported node type:"," ",String(null==n?void 0:n.type)]})}function pr(e){var t;return"text"===(null==e?void 0:e.type)&&""===String(null!=(t=null==e?void 0:e.content)?t:"").trim()}function gr(e,n,o,i){const l=e.filter(e=>!pr(e)),a=l.length>0&&l.every(e=>"image"===e.type||function(e){var t;const n=function(e){return"link"===(null==e?void 0:e.type)&&Array.isArray(null==e?void 0:e.children)?e.children.filter(e=>!pr(e)):[]}(e);return 1===n.length&&"image"===(null==(t=n[0])?void 0:t.type)}(e));if(!a||l.length<=1)return S(e,o,i,n);const c=[];for(let t=0;t<e.length;t++){const n=e[t];if(!pr(n)){c.push(n);continue}const r=c.length>0,o=e.slice(t+1).some(e=>!pr(e));r&&o&&c.push({...n,content:" ",raw:" "})}return c.map((e,l)=>{var c;return a&&pr(e)?/* @__PURE__ */t(r.Fragment,{children:String(null!=(c=null==e?void 0:e.content)?c:"")},`${i}-${l}`):n(e,`${i}-${l}`,o)})}function wr(e){var o,i;const{node:l,ctx:a,renderNode:c,indexKey:s,children:d}=e;if(!a||!c)/* @__PURE__ */
|
|
135
|
+
return t("p",{dir:"auto",className:"paragraph-node",children:d});const u=null!=(o=l.children)?o:[],m=null!=(i=a.customComponents)?i:H(a.customId),h=[],f=[],p=()=>{if(!f.length)return;const e=h.length;h.push(
|
|
136
|
+
/* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:gr(f.slice(),c,a,`${String(null!=s?s:"paragraph")}-${e}`)},`${String(null!=s?s:"paragraph")}-inline-${e}`)),f.length=0};return u.forEach((e,n)=>{G.has(e.type)||J(e,m,a.customHtmlTags)?(p(),h.push(
|
|
137
|
+
/* @__PURE__ */t(r.Fragment,{children:c(e,`${String(null!=s?s:"paragraph")}-block-${n}`,a)},`${String(null!=s?s:"paragraph")}-block-${n}`))):f.push(e)}),p(),h.length?/* @__PURE__ */t(n,{children:h}):/* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:gr(u,c,a,String(null!=s?s:"paragraph"))})}function vr(e){const{node:n}=e,r=d(t=>{var r;null==(r=e.onClick)||r.call(e,t,n.id,e.messageId,e.threadId)},[n.id,e]);/* @__PURE__ */
|
|
138
|
+
return t("span",{className:"reference-node cursor-pointer bg-[hsl(var(--muted))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]",role:"button",tabIndex:0,onClick:r,onMouseEnter:t=>{var r;null==(r=e.onMouseEnter)||r.call(e,t,n.id,e.messageId,e.threadId)},onMouseLeave:t=>{var r;null==(r=e.onMouseLeave)||r.call(e,t,n.id,e.messageId,e.threadId)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||r(e)},children:n.id})}function yr(e){/* @__PURE__ */
|
|
139
|
+
return t("s",{className:"strikethrough-node",children:e.children})}function xr(e){/* @__PURE__ */
|
|
140
|
+
return t("strong",{className:"strong-node",children:e.children})}function kr(e){/* @__PURE__ */
|
|
141
|
+
return t("sub",{className:"subscript-node",children:e.children})}function br(e){/* @__PURE__ */
|
|
142
|
+
return t("sup",{className:"superscript-node",children:e.children})}function Cr(n){var o;const{node:i,ctx:l,renderNode:a,indexKey:c}=n,s=Array.isArray(null==(o=null==i?void 0:i.header)?void 0:o.cells)?i.header.cells:[],d=Boolean(null==i?void 0:i.loading),u=Array.isArray(null==i?void 0:i.rows)?i.rows:[],m=r.useRef(null),h=r.useRef(null),f=r.useRef(null),[p,g]=r.useState([]),w=e=>"right"===e?"text-right":"center"===e?"text-center":"text-left",v=()=>{const e=f.current;e&&(window.removeEventListener("pointermove",e.move),window.removeEventListener("pointerup",e.stop),window.removeEventListener("pointercancel",e.stop),f.current=null),h.current=null};return r.useEffect(()=>(v(),g([]),v),[s.length]),/* @__PURE__ */e("div",{className:"table-node-wrapper","data-index-key":c,children:[
|
|
143
|
+
/* @__PURE__ */e("table",{ref:m,className:mt("my-8 text-sm table-node",d&&"table-node--loading"),"aria-busy":d,children:[p.length>0&&/* @__PURE__ */t("colgroup",{children:s.map((e,n)=>/* @__PURE__ */t("col",{style:p[n]>0?{width:`${p[n]}px`}:void 0},`col-${n}`))}),
|
|
144
|
+
/* @__PURE__ */t("thead",{className:"border-[var(--table-border,#cbd5e1)]",children:/* @__PURE__ */t("tr",{className:"border-b",children:s.map((n,r)=>/* @__PURE__ */e("th",{className:mt("font-semibold p-[calc(4/7*1em)]",w(n.align)),dir:"auto",children:[l&&a?P(n.children,l,`${String(null!=c?c:"table")}-th-${r}`,a):null,r<s.length-1&&/* @__PURE__ */t("button",{type:"button",className:"table-node__resize-handle","aria-label":`Resize columns ${r+1} and ${r+2}`,onPointerDown:e=>((e,t)=>{if(0!==t.button)return;const n=(()=>{var e;const t=null==(e=m.current)?void 0:e.querySelectorAll("thead th");return Array.from(null!=t?t:[],e=>Math.round(e.getBoundingClientRect().width))})(),r=n[e],o=n[e+1];if(!r||!o)return;t.preventDefault(),v(),h.current={index:e,startX:t.clientX,startWidth:r,nextStartWidth:o,widths:n},g(n);const i=e=>{const t=h.current;if(!t)return;e.preventDefault();const n=t.startWidth+t.nextStartWidth,r=Math.min(48,Math.floor(n/2)),o=Math.max(r,Math.min(n-r,Math.round(t.startWidth+e.clientX-t.startX))),i=[...t.widths];i[t.index]=o,i[t.index+1]=n-o,g(i)},l=()=>{v()};f.current={move:i,stop:l},window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)})(r,e)})]},`header-${r}`))})}),
|
|
145
145
|
/* @__PURE__ */t("tbody",{children:u.map((e,n)=>{var r;/* @__PURE__ */
|
|
146
|
-
return t("tr",{className:
|
|
146
|
+
return t("tr",{className:mt("border-[var(--table-border,#cbd5e1)]",n<u.length-1&&"border-b"),children:null==(r=e.cells)?void 0:r.map((e,r)=>/* @__PURE__ */t("td",{className:mt("p-[calc(4/7*1em)]",w(e.align)),dir:"auto",children:l&&a?P(e.children,l,`${String(null!=c?c:"table")}-row-${n}-${r}`,a):null},`cell-${n}-${r}`))},`row-${n}`)})})]}),d&&/* @__PURE__ */e("div",{className:"table-node__loading",role:"status","aria-live":"polite",children:[
|
|
147
147
|
/* @__PURE__ */t("span",{className:"table-node__spinner","aria-hidden":"true"}),
|
|
148
|
-
/* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function
|
|
149
|
-
return t("hr",{className:"hr-node thematic-break"})}function
|
|
150
|
-
return t("div",{className:c,...s,children:i&&l&&Array.isArray(n.children)?n.children.map((e,n)=>/* @__PURE__ */t(r.Fragment,{children:l(e,`${String(null!=a?a:"vmr-container")}-${n}`,i)},`${String(null!=a?a:"vmr-container")}-${n}`)):null})}function
|
|
151
|
-
return t(
|
|
152
|
-
return t(
|
|
153
|
-
return t(
|
|
154
|
-
return t(
|
|
155
|
-
return t(
|
|
156
|
-
return t(
|
|
157
|
-
return t(
|
|
158
|
-
return t(
|
|
159
|
-
return t(
|
|
160
|
-
return t(
|
|
161
|
-
return t(
|
|
162
|
-
return t(
|
|
163
|
-
return t(
|
|
164
|
-
return t(
|
|
165
|
-
return t(
|
|
166
|
-
return t(
|
|
167
|
-
return t(
|
|
168
|
-
return t(
|
|
169
|
-
return t(
|
|
170
|
-
return t(
|
|
171
|
-
return t(
|
|
172
|
-
return t(
|
|
173
|
-
return t(
|
|
174
|
-
return t(
|
|
175
|
-
return t(
|
|
176
|
-
return t(
|
|
177
|
-
return t(
|
|
178
|
-
return t(
|
|
179
|
-
return t(
|
|
180
|
-
return t(
|
|
181
|
-
return t(
|
|
182
|
-
return t(
|
|
183
|
-
return t(
|
|
184
|
-
return e("div",{ref:u,className:`markstream-react markdown-renderer${n.isDark?" dark":""}${
|
|
185
|
-
return t(
|
|
186
|
-
return t("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,children:null!=m?m:s&&d?/* @__PURE__ */t(Br,{nodes:c.children||[],indexKey:`blockquote-${String(null!=u?u:"blockquote")}`,customId:s.customId,isDark:s.isDark,typewriter:s.typewriter,viewportPriority:!0,codeBlockStream:s.codeBlockStream,renderCodeBlocksAsPre:s.renderCodeBlocksAsPre,codeBlockProps:s.codeBlockProps,themes:null==(n=s.codeBlockThemes)?void 0:n.themes,codeBlockDarkTheme:null==(r=s.codeBlockThemes)?void 0:r.darkTheme,codeBlockLightTheme:null==(o=s.codeBlockThemes)?void 0:o.lightTheme,codeBlockMonacoOptions:null==(i=s.codeBlockThemes)?void 0:i.monacoOptions,codeBlockMinWidth:null==(l=s.codeBlockThemes)?void 0:l.minWidth,codeBlockMaxWidth:null==(a=s.codeBlockThemes)?void 0:a.maxWidth,htmlPolicy:s.htmlPolicy,showTooltips:s.showTooltips,onCopy:s.events.onCopy,onHandleArtifactClick:s.events.onHandleArtifactClick}):null})}function Sr(r){const l={loading:!0,stream:!0,darkTheme:"vitesse-dark",lightTheme:"vitesse-light",isDark:!1,isShowPreview:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0,...r},c=o(()=>{var e;return String(null!=(e=l.node.language)?e:"")},[l.node.language]),u=o(()=>function(e){var t;const[n]=String(null!=e?e:"").split(":");return(null!=(t=null==n?void 0:n.trim().toLowerCase())?t:"")||"plaintext"}(c),[c]),m=o(()=>S(c),[c]),[h,p]=i(0);s(()=>T(()=>{p(e=>e+1)}),[]);const f=o(()=>{const e=$[m]||m;return e?e.charAt(0).toUpperCase()+e.slice(1):"Text"},[m]),g=o(()=>D(m),[m,h]),{t:w}=ge(),v=o(()=>!!l.isShowPreview&&("html"===m||"svg"===m),[m,l.isShowPreview]),y=o(()=>{const e={},t=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},n=t(l.minWidth),r=t(l.maxWidth);return n&&(e.minWidth=n),r&&(e.maxWidth=r),e},[l.maxWidth,l.minWidth]),[x,k]=i(!1),[b,C]=i(!1),[M,N]=i(!1),[B,L]=i(""),[E,P]=i(!1),[A,R]=i(14),[H,W]=i(A),I=o(()=>!1!==l.showTooltips,[l.showTooltips]),_=a(null),F=a(null),j=a(null),O=a(null),z=a(null),V=a(!1),K=a(null),X=me(),[U,q]=i(()=>"undefined"==typeof window),Y=d(()=>l.isDark?l.darkTheme:l.lightTheme,[l.darkTheme,l.isDark,l.lightTheme]),Z=d(e=>{if(!e)return L(""),void P(!1);var t;L(`<pre class="shiki shiki-fallback"><code>${t=e,t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`),P(!1)},[]),G=d(()=>{L(""),P(!0)},[]),J=d(async()=>{if(!z.current&&!V.current){V.current=!0;try{const e=await import("stream-markdown");z.current=e.createShikiStreamRenderer}catch{}}},[]),Q=d(async()=>{if(U)if(await J(),F.current&&j.current)if(!O.current&&z.current&&(O.current=z.current(j.current,{theme:Y(),themes:l.themes}),P(!0)),O.current)if(!1===l.stream&&l.loading)Z(l.node.code);else{Z(l.node.code);try{await O.current.updateCode(l.node.code,u),G()}catch{}}else Z(l.node.code);else Z(l.node.code);else Z(l.node.code)},[G,J,Y,u,l.loading,l.node.code,l.stream,l.themes,Z,U]);s(()=>{const e=_.current;if(!e)return;const t=X(e,{rootMargin:"400px"});return K.current=t,t.isVisible()&&q(!0),t.whenVisible.then(()=>q(!0)),()=>{t.destroy(),K.current=null}},[X]),s(()=>(Q(),()=>{var e;null==(e=O.current)||e.dispose(),O.current=null}),[Q]),s(()=>{O.current&&U&&O.current.setTheme(Y())},[Y,U]),s(()=>{U?O.current&&(!1===l.stream&&l.loading||(Z(l.node.code),Promise.resolve(O.current.updateCode(l.node.code,u)).then(()=>G()).catch(()=>{}))):Z(l.node.code)},[G,u,l.loading,l.node.code,l.stream,Z,U]),s(()=>{I||Be(!0)},[I]);const ee=d((e,t)=>{if(!I)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ne(n,t,"top",!1,0,l.isDark))},[l.isDark,I]),te=d(()=>{I&&Be()},[I]),ne=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(l.node.code),k(!0),null==(e=l.onCopy)||e.call(l,l.node.code),setTimeout(()=>k(!1),1e3)}catch{}},[l]),re=d(()=>{var e;if(!v)return;const t="html"===u?"text/html":"image/svg+xml",n="html"===u?"HTML Preview":"SVG Preview";null==(e=l.onPreviewCode)||e.call(l,{type:t,content:l.node.code,title:n})},[v,u,l]),oe=o(()=>({fontSize:`${H}px`}),[H]);return s(()=>{R(14),W(14)},[]),/* @__PURE__ */e("div",{ref:_,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",l.isDark?"border-gray-700/30 bg-gray-900 is-dark":"border-gray-200 bg-white"].join(" "),style:y,children:[l.showHeader&&/* @__PURE__ */e("div",{className:"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)",backgroundColor:"var(--vscode-editor-background)"},children:[
|
|
148
|
+
/* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function Mr(){/* @__PURE__ */
|
|
149
|
+
return t("hr",{className:"hr-node thematic-break"})}function Nr(e){const{node:n,ctx:i,renderNode:l,indexKey:a}=e,c=`vmr-container vmr-container-${n.name}`,s=o(()=>{if(n.attrs)return Array.isArray(n.attrs)?_(n.attrs):n.attrs},[n.attrs]);/* @__PURE__ */
|
|
150
|
+
return t("div",{className:c,...s,children:i&&l&&Array.isArray(n.children)?n.children.map((e,n)=>/* @__PURE__ */t(r.Fragment,{children:l(e,`${String(null!=a?a:"vmr-container")}-${n}`,i)},`${String(null!=a?a:"vmr-container")}-${n}`)):null})}function Br(e,t,n,o){return r.createElement(e,{key:n,node:t,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade})}function Sr(e,n,o){var i,l,a,c,s,d,u,m,h;const f=null!=(i=o.customComponents)?i:H(o.customId),p="code_block"===e.type?null:f[e.type];if(p)return r.createElement(p,{key:n,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade});if("html_block"===e.type||"html_inline"===e.type){const i=Q(e,f,o.customHtmlTags),h=String(null!=(l=e.tag)?l:"").trim().toLowerCase()||k(e.content),p=null!=(a=null==i?void 0:i.tag)?a:h;if(p){const l=null!=(c=null==i?void 0:i.component)?c:f[p],a=null!=(d=null==i?void 0:i.isWhitelisted)?d:(null!=(s=o.customHtmlTags)?s:[]).some(e=>e.toLowerCase()===p);if(a&&l){const t={...e,type:p,tag:p,content:b(e.content,p)};return r.createElement(l,{key:n,node:t,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade})}const h=String(null!=(m=null!=(u=e.content)?u:e.raw)?m:"");if(!a&&C(h,p))return"html_inline"===e.type?/* @__PURE__ */t(Jt,{node:{type:"text",content:h,raw:h},ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n):/* @__PURE__ */t(wr,{node:{type:"paragraph",children:[{type:"text",content:h,raw:h}],raw:h},ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n)}}switch(e.type){case"text":/* @__PURE__ */
|
|
151
|
+
return t(Jt,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"text_special":/* @__PURE__ */
|
|
152
|
+
return t(Jt,{node:{type:"text",content:null!=(h=e.content)?h:"",center:e.center},ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"paragraph":/* @__PURE__ */
|
|
153
|
+
return t(wr,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"heading":/* @__PURE__ */
|
|
154
|
+
return t(At,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"blockquote":/* @__PURE__ */
|
|
155
|
+
return t(Ar,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"list":/* @__PURE__ */
|
|
156
|
+
return t(tn,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"list_item":/* @__PURE__ */
|
|
157
|
+
return t(en,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"table":/* @__PURE__ */
|
|
158
|
+
return t(Cr,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"definition_list":/* @__PURE__ */
|
|
159
|
+
return t(St,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"footnote":/* @__PURE__ */
|
|
160
|
+
return t(Dt,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"footnote_reference":/* @__PURE__ */
|
|
161
|
+
return t($t,{node:e},n);case"footnote_anchor":/* @__PURE__ */
|
|
162
|
+
return t(Et,{node:e},n);case"admonition":/* @__PURE__ */
|
|
163
|
+
return t(se,{node:e,ctx:o,renderNode:Sr,indexKey:n,isDark:o.isDark,typewriter:o.typewriter,fade:o.fade},n);case"hardbreak":/* @__PURE__ */
|
|
164
|
+
return t(Pt,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"link":/* @__PURE__ */
|
|
165
|
+
return t(Qt,{node:e,ctx:o,renderNode:Sr,indexKey:n,isDark:o.isDark,showTooltip:"boolean"==typeof o.showTooltips?o.showTooltips:void 0,typewriter:o.typewriter,fade:o.fade},n);case"image":/* @__PURE__ */
|
|
166
|
+
return t(Vt,{node:e},n);case"inline_code":/* @__PURE__ */
|
|
167
|
+
return t(Zt,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"code_block":return function(e,n,o,i){var l,a,c,s;const d=function(e){const t=String((null==e?void 0:e.language)||"").trim();if(!t)return"";const[n]=t.split(/\s+/),[r]=n.split(":");return r.toLowerCase()}(e),u=L(d),m=d?i[d]:null;if("mermaid"===u){const l=function(e,t){var n,r;const o={...t.mermaidProps||{}};return null==q(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=Y(Z(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=q(o.maxHeight))?r:void 0)),o}(e,o),a=m||i.mermaid;if(a)return r.createElement(a,{key:n,node:e,isDark:o.isDark,...l});if(!o.renderCodeBlocksAsPre)/* @__PURE__ */
|
|
168
|
+
return t(ir,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...l},n)}if("infographic"===u){const l=function(e,t){var n,r;const o={...t.infographicProps||{}};return null==V(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=K(X(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=V(o.maxHeight))?r:void 0)),o}(e,o),a=m||i.infographic;return a?r.createElement(a,{key:n,node:e,isDark:o.isDark,...l}):/* @__PURE__ */t(Yt,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...l},n)}if("d2"===u||"d2lang"===u){const l=m||i.d2;return l?r.createElement(l,{key:n,node:e,isDark:o.isDark,...o.d2Props||{}}):/* @__PURE__ */t(Bt,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...o.d2Props||{}},n)}if(m)return Br(m,e,n,o);const h=i.code_block;return h?Br(h,e,n,o):o.renderCodeBlocksAsPre||"mermaid"===u?/* @__PURE__ */t(rt,{node:e},n):/* @__PURE__ */t(dt,{node:e,loading:Boolean(e.loading),stream:o.codeBlockStream,monacoOptions:null==(l=o.codeBlockThemes)?void 0:l.monacoOptions,themes:null==(a=o.codeBlockThemes)?void 0:a.themes,minWidth:null==(c=o.codeBlockThemes)?void 0:c.minWidth,maxWidth:null==(s=o.codeBlockThemes)?void 0:s.maxWidth,isDark:o.isDark,onCopy:o.events.onCopy,...o.codeBlockProps||{}},n)}(e,n,o,f);case"strong":/* @__PURE__ */
|
|
169
|
+
return t(xr,{node:e,children:S(e.children,o,`${String(n)}-strong`,Sr)},n);case"emphasis":/* @__PURE__ */
|
|
170
|
+
return t(Tt,{node:e,children:S(e.children,o,`${String(n)}-em`,Sr)},n);case"strikethrough":/* @__PURE__ */
|
|
171
|
+
return t(yr,{node:e,children:S(e.children,o,`${String(n)}-strike`,Sr)},n);case"highlight":/* @__PURE__ */
|
|
172
|
+
return t(Rt,{node:e,children:S(e.children,o,`${String(n)}-highlight`,Sr)},n);case"insert":/* @__PURE__ */
|
|
173
|
+
return t(Gt,{node:e,children:S(e.children,o,`${String(n)}-insert`,Sr)},n);case"subscript":/* @__PURE__ */
|
|
174
|
+
return t(kr,{node:e,children:S(e.children,o,`${String(n)}-sub`,Sr)},n);case"superscript":/* @__PURE__ */
|
|
175
|
+
return t(br,{node:e,children:S(e.children,o,`${String(n)}-sup`,Sr)},n);case"checkbox":case"checkbox_input":/* @__PURE__ */
|
|
176
|
+
return t(ye,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"emoji":/* @__PURE__ */
|
|
177
|
+
return t(Lt,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"thematic_break":/* @__PURE__ */
|
|
178
|
+
return t(Mr,{},n);case"math_inline":/* @__PURE__ */
|
|
179
|
+
return t(Ln,{node:e},n);case"math_block":/* @__PURE__ */
|
|
180
|
+
return t(Sn,{node:e},n);case"reference":/* @__PURE__ */
|
|
181
|
+
return t(vr,{node:e,ctx:o,typewriter:o.typewriter,fade:o.fade},n);case"html_block":case"html_inline":return"html_block"===e.type?/* @__PURE__ */t(Ht,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade,customId:o.customId},n):/* @__PURE__ */t(Ot,{node:e,ctx:o,typewriter:o.typewriter,fade:o.fade,customId:o.customId},n);case"vmr_container":/* @__PURE__ */
|
|
182
|
+
return t(Nr,{node:e,ctx:o,renderNode:Sr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"label_open":case"label_close":return null;default:/* @__PURE__ */
|
|
183
|
+
return t(fr,{node:e},n)}}const Lr={codeBlockStream:!0,typewriter:!1,fade:!0,smoothStreaming:"auto",batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:320,liveNodeBuffer:60},Tr=N();function Er(e,t){if(e.type!==t.type)return!1;if(e.raw!==t.raw)return!1;if("code_block"===e.type||"code_block"===t.type){if(e.loading!==t.loading)return!1;if(e.diff!==t.diff)return!1}return!0}const Dr=r.memo(({node:e,nodeKey:t,renderCtx:n})=>Sr(e,t,n),(e,t)=>e.node===t.node&&e.renderCtx===t.renderCtx&&e.nodeKey===t.nodeKey),$r=r.memo(({props:n,parsedNodes:r,renderCtx:l,indexPrefix:a,containerRef:u,showTypewriterCursor:m,typewriterCursorRef:h})=>{var f,p,g,w,v,y,x;const k=we(),b="undefined"!=typeof window,C="undefined"!=typeof window&&"function"==typeof window.requestIdleCallback,M=Math.max(0,Math.trunc(null!=(f=n.renderBatchSize)?f:80)),N=Math.max(0,Math.trunc(null!=(p=n.initialRenderBatchSize)?p:M||r.length)),B=!1!==n.batchRendering&&M>0&&b,S=Math.max(0,null!=(g=n.liveNodeBuffer)?g:60),L=Math.max(1,null!=(w=n.maxLiveNodes)?w:320),T=(null!=(v=n.maxLiveNodes)?v:0)>0&&r.length>L,E=!1!==n.viewportPriority,D=B&&(null!=(y=n.maxLiveNodes)?y:0)<=0,$=o(()=>{var e;return!1!==n.deferNodesUntilVisible&&!((null!=(e=n.maxLiveNodes)?e:0)<=0)&&!T&&!(r.length>900)&&E},[r.length,n.deferNodesUntilVisible,n.maxLiveNodes,E,T]),[P,A]=i(()=>D?Math.min(r.length,N):r.length),R=c(P);s(()=>{R.current=P},[P]);const H=D?P:r.length,[_,W]=i(0),[I,F]=i({start:0,end:r.length}),j=c(/* @__PURE__ */new Map),[O,z]=i(0),V=c({}),K=c(/* @__PURE__ */new Map),X=c(/* @__PURE__ */new Map),U=c(/* @__PURE__ */new Map),q=c(/* @__PURE__ */new Map),Y=c(/* @__PURE__ */new Set),Z=c(P),G=c(null),J=c(null),Q=c(null),ee=c(!1),te=c(null),ne=c(Math.max(1,M||1)),re=c(r.length),oe=c({key:n.indexKey,total:r.length}),ie=c({batchSize:M,initial:N,delay:null!=(x=n.renderBatchDelay)?x:16,enabled:D}),le=$||T,ae=o(()=>{const e=j.current;if(!e.size)return 32;let t=0;for(const n of e.values())t+=n;return Math.max(16,t/e.size)},[O]),ce=o(()=>{if(!T)return r.map((e,t)=>({node:e,index:t}));const e=r.length,t=Math.max(0,Math.min(I.start,e)),n=Math.max(t,Math.min(I.end,e));return r.slice(t,n).map((e,n)=>({node:e,index:t+n}))},[r,I,T]),se=o(()=>{if(!T)return r.length;const e=Math.max(I.end+S,N),t=Math.min(r.length,e);return Math.max(P,t)},[r.length,T,I.end,S,N,P]);re.current=se;const de=d((e,t)=>{var n;if(e>=t)return 0;const r=j.current;let o=0;for(let i=e;i<t;i++)o+=null!=(n=r.get(i))?n:ae;return o},[ae]),ue=T?de(0,Math.min(I.start,r.length)):0,me=T?de(Math.min(I.end,r.length),r.length):0,he=d(()=>{null!=G.current&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(G.current),G.current=null),null!=J.current&&(window.clearTimeout(J.current),J.current=null),null!=Q.current&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(Q.current),Q.current=null),ee.current=!1,te.current=null},[]),fe=d(e=>{var t;if(!D)return;const r=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6),o=Math.max(1,M||1),i=Math.max(1,Math.floor(o/4));e>1.2*r?ne.current=Math.max(i,Math.floor(.7*ne.current)):e<.5*r&&ne.current<o&&(ne.current=Math.min(o,Math.ceil(1.2*ne.current)))},[D,n.renderBatchBudgetMs,M]),pe=d((e,t={})=>{var r,o;if(!D)return;const i=re.current;if(R.current>=i)return;const l=Math.max(1,e),a=e=>{const t="undefined"!=typeof performance?performance.now():Date.now();A(t=>{const n=Math.min(re.current,t+Math.max(1,e));return R.current=n,n});const n="undefined"!=typeof performance?performance.now():Date.now();fe(n-t)},c=()=>{const e=Math.max(1,Math.round(ne.current));pe(e)},s=e=>{var t;G.current=null,J.current=null,Q.current=null,ee.current=!1;const r=te.current;if(te.current=null,a(null!=r?r:l),R.current>=re.current)return;if(!e)return void c();const o=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6);for(;R.current<re.current&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)a(Math.max(1,Math.round(ne.current)));R.current<re.current&&c()};if(!b||t.immediate)return void s();const d=Math.max(0,null!=(r=n.renderBatchDelay)?r:16);if(te.current=null!=te.current?Math.max(te.current,l):l,!ee.current){if(ee.current=!0,C){const e=Math.max(0,null!=(o=n.renderBatchIdleTimeoutMs)?o:120);return void(Q.current=window.requestIdleCallback(e=>s(e),{timeout:e}))}"function"==typeof requestAnimationFrame?G.current=requestAnimationFrame(()=>{0!==d?J.current=window.setTimeout(()=>s(),d):s()}):J.current=window.setTimeout(()=>s(),d)}},[fe,C,D,b,n.renderBatchDelay,n.renderBatchBudgetMs,n.renderBatchIdleTimeoutMs]);s(()=>{var e;const t=n.indexKey,o=r.length,i=oe.current,l=void 0!==t?t!==i.key:o!==i.total;oe.current={key:t,total:o};const a=ie.current,c=null!=(e=n.renderBatchDelay)?e:16,s=a.batchSize!==M||a.initial!==N||a.delay!==c||a.enabled!==D;if(ie.current={batchSize:M,initial:N,delay:c,enabled:D},(l||s||!D)&&he(),(l||s)&&(ne.current=Math.max(1,M||1),Y.current.clear()),!o)return R.current=0,void A(0);const d=re.current;if(!D)return R.current=d,void A(d);if(l||s){const e=Math.min(d,N);return R.current=e,A(e),void(e<d&&pe(Math.max(1,N),{immediate:!b}))}const u=Math.min(R.current,d);u!==R.current&&(R.current=u,A(u)),R.current<d&&pe(Math.max(1,M||1))},[he,D,b,r.length,n.indexKey,n.renderBatchDelay,M,N,pe]),s(()=>{if(!T)return void F({start:0,end:r.length});const e=r.length;if(!e)return void F({start:0,end:0});const t=Math.max(0,Math.min(_,e-1));let n=Math.max(0,t-S),o=Math.min(e,t+S+1);const i=o-n;if(i>L){const e=i-L;n+=Math.ceil(e/2),o-=Math.floor(e/2)}else if(i<L){const t=L-i;n=Math.max(0,n-Math.ceil(t/2)),o=Math.min(e,o+Math.floor(t/2))}F({start:n,end:o})},[_,S,L,r.length,T]),s(()=>()=>{he();for(const e of K.current.values())e.destroy();K.current.clear()},[he]);const ge=d(e=>{for(const[t,n]of K.current.entries())t>=e&&(n.destroy(),K.current.delete(t),delete V.current[t],X.current.delete(t),U.current.delete(t),q.current.delete(t))},[]);s(()=>{ge(H)},[ge,H]),s(()=>{const e=r.length;let t=!1;for(const n of Array.from(j.current.keys()))n>=e&&(j.current.delete(n),t=!0);t&&z(e=>e+1);for(const n of Object.keys(V.current))Number(n)>=e&&delete V.current[n];for(const n of Array.from(Y.current))n>=e&&Y.current.delete(n)},[r.length]);const ve=d((e,t)=>{$&&t&&(V.current[e]=!0),t&&T&&W(t=>e>t?e:t)},[$,T]),ye=d(e=>{const t=K.current.get(e);t&&(t.destroy(),K.current.delete(e))},[]),xe=d((e,t)=>{const n=X.current;if(t?n.set(e,t):n.delete(e),!le||!t)return ye(e),$&&!t&&delete V.current[e],void(t&&ve(e,!0));if(e<N&&!T)return ye(e),void ve(e,!0);ye(e);const r=k(t,{rootMargin:"400px"});K.current.set(e,r),r.isVisible()&&ve(e,!0),r.whenVisible.then(()=>ve(e,!0)).catch(()=>{})},[$,ye,ve,k,N,le,T]),ke=d(e=>{const t=U.current.get(e);if(t)return t;const n=t=>xe(e,t);return U.current.set(e,n),n},[xe]),be=d((e,t)=>{if(!t)return void(j.current.has(e)&&(j.current.delete(e),z(e=>e+1)));const n=()=>{const n=t.offsetHeight;n&&j.current.get(e)!==n&&(j.current.set(e,n),z(e=>e+1))};"function"==typeof queueMicrotask?queueMicrotask(n):Promise.resolve().then(n)},[]),Ce=d(e=>{const t=q.current.get(e);if(t)return t;const n=t=>be(e,t);return q.current.set(e,n),n},[be]),Me=d(e=>!(D&&e>=R.current)&&(!$||e<N||!0===V.current[e]),[$,D,N]),Ne=d(e=>t=>{if(!e)return;const n=t.target;(null==n?void 0:n.closest("[data-node-index]"))&&e(t)},[]);s(()=>{for(const[e,t]of X.current.entries())t&&xe(e,t)},[xe]),s(()=>{T&&P>Z.current&&W(P-1),Z.current=P},[P,T]);const Be=T?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${ue}px`},"aria-hidden":"true"}):null,Se=T?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${me}px`},"aria-hidden":"true"}):null;/* @__PURE__ */
|
|
184
|
+
return e("div",{ref:u,className:`markstream-react markdown-renderer${n.isDark?" dark":""}${T?" virtualized":""}`,"data-custom-id":n.customId,onClick:n.onClick,onMouseOver:Ne(n.onMouseOver),onMouseOut:Ne(n.onMouseOut),children:[Be,ce.map(({node:e,index:r})=>{var o;const i=Me(r),c=null!=(o=j.current.get(r))?o:ae,s=!1!==n.fade&&"code_block"!==e.type&&!Y.current.has(r)&&i;return s&&Y.current.add(r),/* @__PURE__ */t("div",{ref:ke(r),className:"node-slot","data-node-index":r,"data-node-type":e.type,children:/* @__PURE__ */t("div",i?{ref:Ce(r),className:"node-content"+(s?" fade-node typewriter-node":""),children:/* @__PURE__ */t(Dr,{node:e,nodeKey:`${a}-${r}`,renderCtx:l})}:{className:"node-placeholder",style:{height:`${c}px`}})},`${a}-${r}`)}),Se,m&&/* @__PURE__ */t("span",{ref:h,className:"typewriter-cursor","aria-hidden":"true"})]})},function(e,t){if(e.renderCtx!==t.renderCtx)return!1;if(e.indexPrefix!==t.indexPrefix)return!1;if(e.containerRef!==t.containerRef)return!1;if(e.showTypewriterCursor!==t.showTypewriterCursor)return!1;const n=e.parsedNodes,r=t.parsedNodes;if(n===r)return!0;if(n.length!==r.length)return!1;for(let l=0;l<n.length;l++)if(n[l]!==r[l])return!1;const o=e.props,i=t.props;return o.isDark===i.isDark&&o.typewriter===i.typewriter&&o.fade===i.fade&&o.batchRendering===i.batchRendering&&o.initialRenderBatchSize===i.initialRenderBatchSize&&o.renderBatchSize===i.renderBatchSize&&o.renderBatchDelay===i.renderBatchDelay&&o.renderBatchBudgetMs===i.renderBatchBudgetMs&&o.renderBatchIdleTimeoutMs===i.renderBatchIdleTimeoutMs&&o.deferNodesUntilVisible===i.deferNodesUntilVisible&&o.maxLiveNodes===i.maxLiveNodes&&o.liveNodeBuffer===i.liveNodeBuffer&&o.viewportPriority===i.viewportPriority&&o.indexKey===i.indexKey&&o.onClick===i.onClick&&o.onMouseOver===i.onMouseOver&&o.onMouseOut===i.onMouseOut}),Pr=e=>{var n,l;const a={...Lr,...e},m=c(null),h=c(null),f=c(/* @__PURE__ */new Map),p=c(0),g=c(null),w=ve(a.smoothStreamingOptions),v=r.useContext(de),[y,x]=i(()=>!0===a.smoothStreaming);s(()=>{x(!0)},[]);const k=Array.isArray(a.nodes)&&a.nodes.length>0,b=o(()=>{var e;return!1!==a.smoothStreaming&&!k&&(!0===a.smoothStreaming||!v)&&(!0===a.smoothStreaming||!0===a.typewriter||(null!=(e=a.maxLiveNodes)?e:0)<=0)},[k,v,a.maxLiveNodes,a.smoothStreaming,a.typewriter]),C=y&&b,S=C?w.visible:null!=(n=a.content)?n:"",T=o(()=>{var e,t;const n=null!=(e=a.parseOptions)?e:{};return null!=(t=a.final)?t:n.final},[a.final,a.parseOptions]),E=null!=(l=a.content)?l:"",D=k||w.source===E,$=o(()=>C&&null!=T?Boolean(T&&D&&w.caughtUp):T,[T,D,w.caughtUp,C]),P=c(null),[_,W]=i(!1),I=c(void 0),F=c(0),j=o(()=>/* @__PURE__ */new Set(["code_block","admonition","table","math_block","html_block","image"]),[]),O=d(e=>{if(!e||"object"!=typeof e)return!1;const t=e.type;return"string"==typeof t&&j.has(t)},[j]),z=d(e=>{var t,n;if(!e||"object"!=typeof e)return 0;const r=e,o=null!=(n=null!=(t=r.raw)?t:r.content)?n:r.code;if("string"==typeof o)return o.length;const i=r.children;if(Array.isArray(i))return i.reduce((e,t)=>e+z(t),0);const l=r.items;return Array.isArray(l)?l.reduce((e,t)=>e+z(t),0):0},[]),V=d(()=>{var e;return(null==(e=a.nodes)?void 0:e.length)?a.nodes.reduce((e,t)=>e+z(t),0):S.length},[a.nodes,S,z]),K=d(()=>{I.current&&(clearTimeout(I.current),I.current=void 0)},[]),X=d(e=>{const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){var t;if(!(null!=(t=e.textContent)?t:"").trim())return NodeFilter.FILTER_REJECT;const n=e.parentElement;return n?n.closest('.typewriter-cursor, .height-estimation-probes, [data-node-type="code_block"], [data-node-type="admonition"], [data-node-type="table"], [data-node-type="math_block"], [data-node-type="html_block"], [data-node-type="image"], script, style')?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let n=null,r=t.nextNode();for(;r;)n=r,r=t.nextNode();return n},[]),U=d(()=>{var e,t;if("undefined"==typeof window||!_||!m.current||!P.current)return;const n=m.current,r=P.current,o=X(n),i=n.getBoundingClientRect();let l=0,a=0,c=20;if(null==o?void 0:o.textContent){const r=document.createRange(),s=o.textContent.length;r.setStart(o,Math.max(0,s-1)),r.setEnd(o,s);const d="function"==typeof r.getClientRects?r.getClientRects():void 0,u=null!=(t=null==d?void 0:d[d.length-1])?t:null==(e=o.parentElement)?void 0:e.getBoundingClientRect();u&&(l=u.right-i.left+n.scrollLeft,a=u.top-i.top+n.scrollTop,c=u.height||c),r.detach()}r.style.transform=`translate(${Math.max(0,l)}px, ${Math.max(0,a)}px)`,r.style.height=`${c}px`},[_,m,X]);s(()=>{_&&requestAnimationFrame(()=>{U()})},[_,U]),s(()=>()=>{K()},[K]);const q=k?a.nodes:S;g.current!==q&&(p.current+=1,g.current=q);const Y=u(A,R,R),Z=o(()=>H(a.customId),[a.customId,Y]),G=o(()=>a.customId?`renderer-${a.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[a.customId]),J=o(()=>{var e,t;const n=null!=(t=(null!=(e=a.parseOptions)?e:{}).customHtmlTags)?t:[];return M(a.customHtmlTags,Array.isArray(n)?n:[])},[a.customId,a.customHtmlTags,a.parseOptions,Y]),Q=o(()=>{const e=J;return e&&0!==e.length?N(G,{customHtmlTags:e}):N(G)},[G,J]),ee=o(()=>{const e=Q;return a.customMarkdownIt?a.customMarkdownIt(e):e},[Q,a.customMarkdownIt]),te=o(()=>{var e;const t=null!=(e=a.parseOptions)?e:{},n=$,r=null!=n,o=J.length>0;return r||o?{...t,...r?{final:n}:{},...o?{customHtmlTags:J}:{}}:t},[J,$,a.parseOptions]),ne=o(()=>{const e=Boolean(a.debugPerformance)&&"undefined"!=typeof console&&"undefined"!=typeof performance,t=e?performance.now():0;let n=[];return k?n=a.nodes.map(e=>({...e})):S&&(n=B(S,null!=ee?ee:Tr,te)),e&&console.info("[markstream-react][perf] parse(sync)",{ms:Math.round(performance.now()-t),nodes:n.length,contentLength:S.length}),n},[a.debugPerformance,S,k,a.nodes,te,ee,a.customId,Y,J]),re=d(()=>{const e=ne[ne.length-1];return!O(e)},[ne,O]);s(()=>{if("undefined"==typeof window||k)return;const e=V(),t=re();return!1===a.typewriter||!t||e<=F.current?(!1!==a.typewriter&&t||W(!1),void(F.current=e)):(F.current=e,W(!0),K(),requestAnimationFrame(()=>{U()}),I.current=setTimeout(()=>{W(!1)},3e3),()=>{K()})},[S,a.nodes,a.typewriter,ne.length,k,V,re,K,U]);const oe=c([]),ie=function(e,t){if(!t.length)return e;const n=new Array(e.length);let r=e.length===t.length;for(let o=0;o<e.length;o++){const i=o<t.length?t[o]:null;i&&Er(i,e[o])?n[o]=i:(n[o]=e[o],r=!1)}return r?t:n}(ne,oe.current);oe.current=ie,s(()=>{var e;if(k)return void w.reset("");const t=null!=(e=a.content)?e:"";if(!C)return w.reset(t),void(T&&w.finish({flush:!0}));const n=w.getSnapshot().source;t?t===n||(t.startsWith(n)?w.enqueue(t.slice(n.length)):w.reset(t)):w.reset(""),T&&w.finish()},[k,a.content,T,C]),s(()=>{var e,t;if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;if(!ie.some(e=>{var t;return"code_block"===(null==e?void 0:e.type)&&"mermaid"!==L(String(null!=(t=null==e?void 0:e.language)?t:""))}))return;const n=null!=(e=window.requestIdleCallback)?e:(e,t)=>{var n;return window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),null!=(n=null==t?void 0:t.timeout)?n:600)},r=null!=(t=window.cancelIdleCallback)?t:e=>window.clearTimeout(e),o=n(()=>{Ie()},{timeout:900});return()=>r(o)},[ie,a.renderCodeBlocksAsPre]),s(()=>{if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;const e=a.isDark?a.codeBlockDarkTheme:a.codeBlockLightTheme,t="string"==typeof e?e:"object"==typeof e&&e&&"name"in e?String(e.name):null;t&&h.current!==t&&(h.current=t,function(e){if(null==e)return;const t=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&e&&"name"in e)return String(e.name);if("object"==typeof e){const t=et.get(e);if(t)return t;try{const t=JSON.stringify(e);if(t)return et.set(e,t),t}catch{}const n="__theme_"+ ++tt;return et.set(e,n),n}return String(e)}(e);t&&Ge!==t&&(Ze=e,Ge=t,Je&&Ye(Ze,Je).then(()=>nt()).catch(()=>{}))}(e))},[a.codeBlockDarkTheme,a.codeBlockLightTheme,a.isDark,a.renderCodeBlocksAsPre]);const le=o(()=>null!=a.indexKey?String(a.indexKey):"markdown-renderer",[a.indexKey]),ae=o(()=>({..."boolean"==typeof a.showTooltips?{showTooltips:a.showTooltips}:{},...a.codeBlockProps||{}}),[a.codeBlockProps,a.showTooltips]),ce=o(()=>({...a.mermaidProps||{}}),[a.mermaidProps]),se=o(()=>({...a.d2Props||{}}),[a.d2Props]),me=o(()=>({...a.infographicProps||{}}),[a.infographicProps]),he=o(()=>{var e;return{customId:a.customId,isDark:a.isDark,indexKey:le,typewriter:a.typewriter,fade:a.fade,textStreamState:f.current,streamRenderVersion:p.current,customComponents:Z,customHtmlTags:J,htmlPolicy:null!=(e=a.htmlPolicy)?e:"safe",showTooltips:a.showTooltips,renderCodeBlocksAsPre:a.renderCodeBlocksAsPre,codeBlockStream:a.codeBlockStream,codeBlockProps:ae,mermaidProps:ce,d2Props:se,infographicProps:me,codeBlockThemes:{themes:a.themes,monacoOptions:a.codeBlockMonacoOptions,minWidth:a.codeBlockMinWidth,maxWidth:a.codeBlockMaxWidth},events:{onCopy:a.onCopy,onHandleArtifactClick:a.onHandleArtifactClick}}},[a.customId,a.isDark,le,a.typewriter,a.fade,a.showTooltips,a.htmlPolicy,a.renderCodeBlocksAsPre,a.codeBlockStream,J,ae,ce,se,me,a.themes,a.codeBlockMonacoOptions,a.codeBlockMinWidth,a.codeBlockMaxWidth,a.onCopy,a.onHandleArtifactClick,Z]);he.streamRenderVersion=p.current,he.textStreamState=f.current;const fe=c(null);return fe.current||(fe.current={textStreamState:f.current,getStreamRenderVersion:()=>p.current}),/* @__PURE__ */t(ue.Provider,{value:fe.current,children:/* @__PURE__ */t(de.Provider,{value:C,children:/* @__PURE__ */t(ge,{getRoot:()=>m.current,enabled:!1!==a.viewportPriority,children:/* @__PURE__ */t($r,{props:a,parsedNodes:ie,renderCtx:he,indexPrefix:le,containerRef:m,showTypewriterCursor:_,typewriterCursorRef:P})})})})};function Ar(e){var n,r,o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;/* @__PURE__ */
|
|
185
|
+
return t("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,children:null!=m?m:s&&d?/* @__PURE__ */t(Pr,{nodes:c.children||[],indexKey:`blockquote-${String(null!=u?u:"blockquote")}`,customId:s.customId,isDark:s.isDark,typewriter:s.typewriter,viewportPriority:!0,codeBlockStream:s.codeBlockStream,renderCodeBlocksAsPre:s.renderCodeBlocksAsPre,codeBlockProps:s.codeBlockProps,themes:null==(n=s.codeBlockThemes)?void 0:n.themes,codeBlockDarkTheme:null==(r=s.codeBlockThemes)?void 0:r.darkTheme,codeBlockLightTheme:null==(o=s.codeBlockThemes)?void 0:o.lightTheme,codeBlockMonacoOptions:null==(i=s.codeBlockThemes)?void 0:i.monacoOptions,codeBlockMinWidth:null==(l=s.codeBlockThemes)?void 0:l.minWidth,codeBlockMaxWidth:null==(a=s.codeBlockThemes)?void 0:a.maxWidth,htmlPolicy:s.htmlPolicy,showTooltips:s.showTooltips,onCopy:s.events.onCopy,onHandleArtifactClick:s.events.onHandleArtifactClick}):null})}function Rr(r){const l={loading:!0,stream:!0,darkTheme:"vitesse-dark",lightTheme:"vitesse-light",isDark:!1,isShowPreview:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0,...r},a=o(()=>{var e;return String(null!=(e=l.node.language)?e:"")},[l.node.language]),u=o(()=>function(e){var t;const[n]=String(null!=e?e:"").split(":");return(null!=(t=null==n?void 0:n.trim().toLowerCase())?t:"")||"plaintext"}(a),[a]),m=o(()=>L(a),[a]),[h,f]=i(0);s(()=>T(()=>{f(e=>e+1)}),[]);const p=o(()=>{const e=$[m]||m;return e?e.charAt(0).toUpperCase()+e.slice(1):"Text"},[m]),g=o(()=>D(m),[m,h]),{t:w}=be(),v=o(()=>!!l.isShowPreview&&("html"===m||"svg"===m),[m,l.isShowPreview]),y=o(()=>{const e={},t=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},n=t(l.minWidth),r=t(l.maxWidth);return n&&(e.minWidth=n),r&&(e.maxWidth=r),e},[l.maxWidth,l.minWidth]),[x,k]=i(!1),[b,C]=i(!1),[M,N]=i(!1),[B,S]=i(""),[E,P]=i(!1),[A,R]=i(14),[H,_]=i(A),W=o(()=>!1!==l.showTooltips,[l.showTooltips]),I=c(null),F=c(null),j=c(null),O=c(null),z=c(null),V=c(!1),K=c(null),X=we(),[U,q]=i(()=>"undefined"==typeof window),Y=d(()=>l.isDark?l.darkTheme:l.lightTheme,[l.darkTheme,l.isDark,l.lightTheme]),Z=d(e=>{if(!e)return S(""),void P(!1);var t;S(`<pre class="shiki shiki-fallback"><code>${t=e,t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`),P(!1)},[]),G=d(()=>{S(""),P(!0)},[]),J=d(async()=>{if(!z.current&&!V.current){V.current=!0;try{const e=await import("stream-markdown");z.current=e.createShikiStreamRenderer}catch{}}},[]),Q=d(async()=>{if(U)if(await J(),F.current&&j.current)if(!O.current&&z.current&&(O.current=z.current(j.current,{theme:Y(),themes:l.themes}),P(!0)),O.current)if(!1===l.stream&&l.loading)Z(l.node.code);else{Z(l.node.code);try{await O.current.updateCode(l.node.code,u),G()}catch{}}else Z(l.node.code);else Z(l.node.code);else Z(l.node.code)},[G,J,Y,u,l.loading,l.node.code,l.stream,l.themes,Z,U]);s(()=>{const e=I.current;if(!e)return;const t=X(e,{rootMargin:"400px"});return K.current=t,t.isVisible()&&q(!0),t.whenVisible.then(()=>q(!0)),()=>{t.destroy(),K.current=null}},[X]),s(()=>(Q(),()=>{var e;null==(e=O.current)||e.dispose(),O.current=null}),[Q]),s(()=>{O.current&&U&&O.current.setTheme(Y())},[Y,U]),s(()=>{U?O.current&&(!1===l.stream&&l.loading||(Z(l.node.code),Promise.resolve(O.current.updateCode(l.node.code,u)).then(()=>G()).catch(()=>{}))):Z(l.node.code)},[G,u,l.loading,l.node.code,l.stream,Z,U]),s(()=>{W||$e(!0)},[W]);const ee=d((e,t)=>{if(!W)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),De(n,t,"top",!1,0,l.isDark))},[l.isDark,W]),te=d(()=>{W&&$e()},[W]),ne=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(l.node.code),k(!0),null==(e=l.onCopy)||e.call(l,l.node.code),setTimeout(()=>k(!1),1e3)}catch{}},[l]),re=d(()=>{var e;if(!v)return;const t="html"===u?"text/html":"image/svg+xml",n="html"===u?"HTML Preview":"SVG Preview";null==(e=l.onPreviewCode)||e.call(l,{type:t,content:l.node.code,title:n})},[v,u,l]),oe=o(()=>({fontSize:`${H}px`}),[H]);return s(()=>{R(14),_(14)},[]),/* @__PURE__ */e("div",{ref:I,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",l.isDark?"border-gray-700/30 bg-gray-900 is-dark":"border-gray-200 bg-white"].join(" "),style:y,children:[l.showHeader&&/* @__PURE__ */e("div",{className:"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)",backgroundColor:"var(--vscode-editor-background)"},children:[
|
|
187
186
|
/* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[
|
|
188
187
|
/* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:g}}),
|
|
189
|
-
/* @__PURE__ */t("span",{className:"text-sm font-medium font-mono",children:
|
|
188
|
+
/* @__PURE__ */t("span",{className:"text-sm font-medium font-mono",children:p})]}),
|
|
190
189
|
/* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[l.showCollapseButton&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":M,onClick:()=>N(e=>!e),onMouseEnter:e=>ee(e,M?w("common.expand")||"Expand":w("common.collapse")||"Collapse"),onFocus:e=>ee(e,M?w("common.expand")||"Expand":w("common.collapse")||"Collapse"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("svg",{style:{rotate:M?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),l.showFontSizeButtons&&l.enableFontSizeControl&&/* @__PURE__ */e(n,{children:[
|
|
191
|
-
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:H<=10,onClick:()=>
|
|
192
|
-
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:H===A,onClick:()=>
|
|
190
|
+
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:H<=10,onClick:()=>_(e=>Math.max(10,e-1)),onMouseEnter:e=>ee(e,w("common.decrease")||"Decrease"),onFocus:e=>ee(e,w("common.decrease")||"Decrease"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
|
|
191
|
+
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:H===A,onClick:()=>_(A),onMouseEnter:e=>ee(e,w("common.reset")||"Reset"),onFocus:e=>ee(e,w("common.reset")||"Reset"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
193
192
|
/* @__PURE__ */t("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),
|
|
194
193
|
/* @__PURE__ */t("path",{d:"M3 3v5h5"})]})})}),
|
|
195
|
-
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:H>=36,onClick:()=>
|
|
194
|
+
/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:H>=36,onClick:()=>_(e=>Math.min(36,e+1)),onMouseEnter:e=>ee(e,w("common.increase")||"Increase"),onFocus:e=>ee(e,w("common.increase")||"Increase"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),l.showCopyButton&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":x?w("common.copied")||"Copied":w("common.copy")||"Copy",onClick:ne,onMouseEnter:e=>ee(e,x?w("common.copied")||"Copied":w("common.copy")||"Copy"),onFocus:e=>ee(e,x?w("common.copied")||"Copied":w("common.copy")||"Copy"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("svg",x?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
196
195
|
/* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
197
196
|
/* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),l.showExpandButton&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":b,onClick:e=>{C(e=>!e),ee(e,b?w("common.expand")||"Expand":w("common.collapse")||"Collapse")},onMouseEnter:e=>ee(e,b?w("common.collapse")||"Collapse":w("common.expand")||"Expand"),onFocus:e=>ee(e,b?w("common.collapse")||"Collapse":w("common.expand")||"Expand"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("svg",b?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),v&&l.showPreviewButton&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":w("common.preview")||"Preview",onClick:re,onMouseEnter:e=>ee(e,w("common.preview")||"Preview"),onFocus:e=>ee(e,w("common.preview")||"Preview"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
198
197
|
/* @__PURE__ */t("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),
|
|
@@ -201,5 +200,5 @@ return t("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,childr
|
|
|
201
200
|
/* @__PURE__ */t("div",{className:"skeleton-line"}),
|
|
202
201
|
/* @__PURE__ */t("div",{className:"skeleton-line"}),
|
|
203
202
|
/* @__PURE__ */t("div",{className:"skeleton-line short"})]})}),
|
|
204
|
-
/* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:x?w("common.copied")||"Copied":""})]})}function
|
|
205
|
-
/* @__PURE__ */t("div",{id:null!=(n=e.id)?n:void 0,ref:r,style:d,className:["ms-tooltip z-[9999] inline-block text-base py-2 px-3 rounded-md shadow-md whitespace-nowrap pointer-events-none border tooltip-element",m?"bg-gray-900 text-white border-gray-700 is-dark":"bg-white text-gray-900 border-gray-200"].join(" "),role:"tooltip",children:e.content}),document.body):null}export{
|
|
203
|
+
/* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:x?w("common.copied")||"Copied":""})]})}function Hr(e){var n;const r=c(null),[l,a]=i(!1),[d,u]=i({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),m=o(()=>function(e){if("boolean"==typeof e)return e;if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0}catch{}if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{}return!1}(e.isDark),[e.isDark]);return s(()=>{if(!e.visible)return void a(!1);if(!e.anchorEl||!r.current)return void a(!0);let t=null,n=!1;const o=async()=>{var t,o;if(!e.anchorEl||!r.current)return;const{x:i,y:l}=await oe(e.anchorEl,r.current,{placement:null!=(t=e.placement)?t:"top",middleware:[ie(null!=(o=e.offset)?o:8),le(),ae({padding:8})],strategy:"fixed"});n||u({position:"fixed",left:"0px",top:"0px",transform:`translate3d(${Math.round(i)}px, ${Math.round(l)}px, 0)`})};return o().then(()=>{n||a(!0)}),t=re(e.anchorEl,r.current,o),()=>{n=!0,null==t||t()}},[e.anchorEl,e.offset,e.placement,e.visible,l]),"undefined"==typeof document?null:e.visible&&l?ne(
|
|
204
|
+
/* @__PURE__ */t("div",{id:null!=(n=e.id)?n:void 0,ref:r,style:d,className:["ms-tooltip z-[9999] inline-block text-base py-2 px-3 rounded-md shadow-md whitespace-nowrap pointer-events-none border tooltip-element",m?"bg-gray-900 text-white border-gray-700 is-dark":"bg-white text-gray-900 border-gray-200"].join(" "),role:"tooltip",children:e.content}),document.body):null}export{yt as $,se as A,Ar as B,ye as C,Bt as D,Lt as E,fr as F,Hr as G,Pt as H,Vt as I,On as J,wn as K,Qt as L,Wn as M,Pr as N,mn as O,wr as P,Fn as Q,vr as R,yr as S,Cr as T,vt as U,Nr as V,fn as W,wt as X,zn as Y,bn as Z,_n as _,dt as a,pn as a0,Cn as a1,Sr as a2,gt as a3,ke as a4,kn as a5,gn as a6,vn as a7,un as a8,hn as a9,In as aa,Rn as ab,Hn as ac,Vn as ad,be as ae,ve as af,yn as ag,xt as ah,St as b,Tt as c,Et as d,Dt as e,$t as f,At as g,Rt as h,Ht as i,Ot as j,Re as k,Yt as l,Zt as m,Gt as n,en as o,tn as p,Rr as q,Sn as r,Ln as s,ir as t,rt as u,xr as v,kr as w,br as x,Jt as y,Mr as z};
|