streamdown 1.1.10 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -56,6 +56,7 @@ Streamdown supports Mermaid diagrams using the `mermaid` language identifier:
56
56
 
57
57
  ```tsx
58
58
  import { Streamdown } from 'streamdown';
59
+ import type { MermaidConfig } from 'mermaid';
59
60
 
60
61
  export default function Page() {
61
62
  const markdown = `
@@ -84,7 +85,20 @@ sequenceDiagram
84
85
  \`\`\`
85
86
  `;
86
87
 
87
- return <Streamdown>{markdown}</Streamdown>;
88
+ // Optional: Customize Mermaid theme and colors
89
+ const mermaidConfig: MermaidConfig = {
90
+ theme: 'dark',
91
+ themeVariables: {
92
+ primaryColor: '#ff0000',
93
+ primaryTextColor: '#fff'
94
+ }
95
+ };
96
+
97
+ return (
98
+ <Streamdown mermaidConfig={mermaidConfig}>
99
+ {markdown}
100
+ </Streamdown>
101
+ );
88
102
  }
89
103
  ```
90
104
 
@@ -150,7 +164,9 @@ Streamdown accepts all the same props as react-markdown, plus additional streami
150
164
  | `allowedImagePrefixes` | `array` | `['*']` | Allowed image URL prefixes |
151
165
  | `allowedLinkPrefixes` | `array` | `['*']` | Allowed link URL prefixes |
152
166
  | `defaultOrigin` | `string` | - | Default origin to use for relative URLs in links and images |
153
- | `shikiTheme` | `BundledTheme` (from Shiki) | `github-light` | The theme to use for code blocks |
167
+ | `shikiTheme` | `[BundledTheme, BundledTheme]` | `['github-light', 'github-dark']` | The light and dark themes to use for code blocks |
168
+ | `mermaidConfig` | `MermaidConfig` | - | Custom configuration for Mermaid diagrams (theme, colors, etc.) |
169
+ | `controls` | `boolean \| { table?: boolean, code?: boolean, mermaid?: boolean }` | `true` | Control visibility of copy/download buttons |
154
170
 
155
171
  ## Architecture
156
172
 
package/dist/index.cjs CHANGED
@@ -1,8 +1,15 @@
1
- "use strict";"use client";var re=Object.create;var B=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var r in t)B(e,r,{get:t[r],enumerable:!0})},_=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oe(t))!ie.call(e,o)&&o!==r&&B(e,o,{get:()=>t[o],enumerable:!(n=ne(t,o))||n.enumerable});return e};var v=(e,t,r)=>(r=e!=null?re(se(e)):{},_(t||!e||!e.__esModule?B(r,"default",{value:e,enumerable:!0}):r,e)),le=e=>_(B({},"__esModule",{value:!0}),e);var ze={};ae(ze,{ShikiThemeContext:()=>I,Streamdown:()=>ee});module.exports=le(ze);var b=require("react"),J=v(require("react-markdown"),1),Q=v(require("rehype-katex"),1),Y=v(require("remark-gfm"),1),Z=v(require("remark-math"),1),xe=require("katex/dist/katex.min.css"),L=v(require("harden-react-markdown"),1);var G=require("react");var C=require("lucide-react"),h=require("react"),S=require("shiki"),W=require("shiki/engine/javascript");var R=require("clsx"),E=require("tailwind-merge"),i=(...e)=>(0,E.twMerge)((0,R.clsx)(e));var f=require("react/jsx-runtime"),de=/<pre(\s|>)/,z=(0,h.createContext)({code:""}),N=class{constructor(){this.lightHighlighter=null;this.darkHighlighter=null;this.lightTheme=null;this.darkTheme=null;this.loadedLanguages=new Set;this.initializationPromise=null}async ensureHighlightersInitialized(t,r){var m,u;let[n,o]=t,s=(0,W.createJavaScriptRegexEngine)({forgiving:!0}),a=!this.lightHighlighter||this.lightTheme!==n,c=!this.darkHighlighter||this.darkTheme!==o;(a||c)&&this.loadedLanguages.clear();let l=!this.loadedLanguages.has(r);if(a?(this.lightHighlighter=await(0,S.createHighlighter)({themes:[n],langs:[r],engine:s}),this.lightTheme=n,this.loadedLanguages.add(r)):l&&await((m=this.lightHighlighter)==null?void 0:m.loadLanguage(r)),c){let p=l?[...this.loadedLanguages,r]:Array.from(this.loadedLanguages);this.darkHighlighter=await(0,S.createHighlighter)({themes:[o],langs:p.length>0?p:[r],engine:s}),this.darkTheme=o}else l&&await((u=this.darkHighlighter)==null?void 0:u.loadLanguage(r));l&&this.loadedLanguages.add(r)}async highlightCode(t,r,n,o){var u,p;this.initializationPromise&&await this.initializationPromise,this.initializationPromise=this.ensureHighlightersInitialized(n,r),await this.initializationPromise,this.initializationPromise=null;let s=g=>o?g.replace(de,`<pre class="${o}"$1`):g,[a,c]=n,l=(u=this.lightHighlighter)==null?void 0:u.codeToHtml(t,{lang:r,theme:a}),m=(p=this.darkHighlighter)==null?void 0:p.codeToHtml(t,{lang:r,theme:c});return[D(s(l)),D(s(m))]}},ce=new N;async function me(e,t,r,n){return ce.highlightCode(e,t,r,n)}function D(e){return e.replace(/(<pre[^>]*)(style="[^"]*background[^";]*;?[^"]*")([^>]*>)/g,"$1$3")}var O=({code:e,language:t,className:r,children:n,preClassName:o,...s})=>{let[a,c]=(0,h.useState)(""),[l,m]=(0,h.useState)(""),u=(0,h.useRef)(!1),[p,g]=(0,h.useContext)(I);return(0,h.useEffect)(()=>(u.current=!0,me(e,t,[p,g],o).then(([w,y])=>{u.current&&(c(w),m(y))}),()=>{u.current=!1}),[e,t,p,g,o]),(0,f.jsx)(z.Provider,{value:{code:e},children:(0,f.jsxs)("div",{className:"my-4 w-full overflow-hidden rounded-xl border","data-code-block-container":!0,"data-language":t,children:[(0,f.jsxs)("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":!0,"data-language":t,children:[(0,f.jsx)("span",{className:"ml-1 font-mono lowercase",children:t}),(0,f.jsx)("div",{children:n})]}),(0,f.jsx)("div",{className:"w-full",children:(0,f.jsxs)("div",{className:"min-w-full",children:[(0,f.jsx)("div",{className:i("overflow-x-auto dark:hidden",r),dangerouslySetInnerHTML:{__html:a},"data-code-block":!0,"data-language":t,...s}),(0,f.jsx)("div",{className:i("hidden overflow-x-auto dark:block",r),dangerouslySetInnerHTML:{__html:l},"data-code-block":!0,"data-language":t,...s})]})})]})})},H=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:o,code:s,...a})=>{let[c,l]=(0,h.useState)(!1),m=(0,h.useRef)(0),u=(0,h.useContext)(z).code,p=s!=null?s:u,g=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(p),l(!0),e==null||e(),m.current=window.setTimeout(()=>l(!1),r))}catch(M){t==null||t(M)}};(0,h.useEffect)(()=>()=>{window.clearTimeout(m.current)},[]);let w=c?C.CheckIcon:C.CopyIcon;return(0,f.jsx)("button",{className:i("text-muted-foreground","p-1 transition-all",o),onClick:g,type:"button",...a,children:n!=null?n:(0,f.jsx)(w,{size:14})})};var $=require("react");var k=require("react/jsx-runtime"),U=!1,ue=async()=>{if(!U){let r=(await import("mermaid")).default;return r.initialize({startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0}),U=!0,r}return(await import("mermaid")).default},q=({chart:e,className:t})=>{let[r,n]=(0,$.useState)(null),[o,s]=(0,$.useState)(!0),[a,c]=(0,$.useState)(""),[l,m]=(0,$.useState)("");if((0,$.useEffect)(()=>{(async()=>{try{n(null),s(!0);let g=await ue(),w=e.split("").reduce((A,te)=>(A<<5)-A+te.charCodeAt(0)|0,0),y=`mermaid-${Math.abs(w)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:M}=await g.render(y,e);c(M),m(M)}catch(g){if(!(l||a)){let w=g instanceof Error?g.message:"Failed to render Mermaid chart";n(w)}}finally{s(!1)}})()},[e]),o&&!a&&!l)return(0,k.jsx)("div",{className:i("my-4 flex justify-center p-4",t),children:(0,k.jsxs)("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[(0,k.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),(0,k.jsx)("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!a&&!l)return(0,k.jsxs)("div",{className:i("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[(0,k.jsxs)("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),(0,k.jsxs)("details",{className:"mt-2",children:[(0,k.jsx)("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),(0,k.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let u=a||l;return(0,k.jsx)("div",{"aria-label":"Mermaid chart",className:i("my-4 flex justify-center",t),dangerouslySetInnerHTML:{__html:u},role:"img"})};var d=require("react/jsx-runtime"),he=/language-([^\s]+)/,ge=({node:e,className:t,children:r,...n})=>{var l,m,u;if(((l=e==null?void 0:e.position)==null?void 0:l.start.line)===((m=e==null?void 0:e.position)==null?void 0:m.end.line))return(0,d.jsx)("code",{className:i("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let s=t==null?void 0:t.match(he),a=(u=s==null?void 0:s.at(1))!=null?u:"",c="";return(0,G.isValidElement)(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?c=r.props.children:typeof r=="string"&&(c=r),a==="mermaid"?(0,d.jsxs)("div",{className:i("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[(0,d.jsx)("div",{className:"flex items-center justify-end",children:(0,d.jsx)(H,{code:c})}),(0,d.jsx)(q,{chart:c})]}):(0,d.jsx)(O,{className:i("overflow-x-auto border-t",t),code:c,"data-language":a,"data-streamdown":"code-block",language:a,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:(0,d.jsx)(H,{})})},V={ol:({node:e,children:t,className:r,...n})=>(0,d.jsx)("ol",{className:i("ml-4 list-outside list-decimal whitespace-normal",r),"data-streamdown":"ordered-list",...n,children:t}),li:({node:e,children:t,className:r,...n})=>(0,d.jsx)("li",{className:i("py-1",r),"data-streamdown":"list-item",...n,children:t}),ul:({node:e,children:t,className:r,...n})=>(0,d.jsx)("ul",{className:i("ml-4 list-outside list-disc whitespace-normal",r),"data-streamdown":"unordered-list",...n,children:t}),hr:({node:e,className:t,...r})=>(0,d.jsx)("hr",{className:i("my-6 border-border",t),"data-streamdown":"horizontal-rule",...r}),strong:({node:e,children:t,className:r,...n})=>(0,d.jsx)("span",{className:i("font-semibold",r),"data-streamdown":"strong",...n,children:t}),a:({node:e,children:t,className:r,href:n,...o})=>{let s=n==="streamdown:incomplete-link";return(0,d.jsx)("a",{className:i("font-medium text-primary underline",r),"data-incomplete":s,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...o,children:t})},h1:({node:e,children:t,className:r,...n})=>(0,d.jsx)("h1",{className:i("mt-6 mb-2 font-semibold text-3xl",r),"data-streamdown":"heading-1",...n,children:t}),h2:({node:e,children:t,className:r,...n})=>(0,d.jsx)("h2",{className:i("mt-6 mb-2 font-semibold text-2xl",r),"data-streamdown":"heading-2",...n,children:t}),h3:({node:e,children:t,className:r,...n})=>(0,d.jsx)("h3",{className:i("mt-6 mb-2 font-semibold text-xl",r),"data-streamdown":"heading-3",...n,children:t}),h4:({node:e,children:t,className:r,...n})=>(0,d.jsx)("h4",{className:i("mt-6 mb-2 font-semibold text-lg",r),"data-streamdown":"heading-4",...n,children:t}),h5:({node:e,children:t,className:r,...n})=>(0,d.jsx)("h5",{className:i("mt-6 mb-2 font-semibold text-base",r),"data-streamdown":"heading-5",...n,children:t}),h6:({node:e,children:t,className:r,...n})=>(0,d.jsx)("h6",{className:i("mt-6 mb-2 font-semibold text-sm",r),"data-streamdown":"heading-6",...n,children:t}),table:({node:e,children:t,className:r,...n})=>(0,d.jsx)("div",{className:"my-4 overflow-x-auto","data-streamdown":"table-wrapper",children:(0,d.jsx)("table",{className:i("w-full border-collapse border border-border",r),"data-streamdown":"table",...n,children:t})}),thead:({node:e,children:t,className:r,...n})=>(0,d.jsx)("thead",{className:i("bg-muted/80",r),"data-streamdown":"table-header",...n,children:t}),tbody:({node:e,children:t,className:r,...n})=>(0,d.jsx)("tbody",{className:i("divide-y bg-muted/40 divide-border",r),"data-streamdown":"table-body",...n,children:t}),tr:({node:e,children:t,className:r,...n})=>(0,d.jsx)("tr",{className:i("border-border border-b",r),"data-streamdown":"table-row",...n,children:t}),th:({node:e,children:t,className:r,...n})=>(0,d.jsx)("th",{className:i("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",r),"data-streamdown":"table-header-cell",...n,children:t}),td:({node:e,children:t,className:r,...n})=>(0,d.jsx)("td",{className:i("px-4 py-2 text-sm",r),"data-streamdown":"table-cell",...n,children:t}),blockquote:({node:e,children:t,className:r,...n})=>(0,d.jsx)("blockquote",{className:i("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",r),"data-streamdown":"blockquote",...n,children:t}),code:ge,pre:({children:e})=>e,sup:({node:e,children:t,className:r,...n})=>(0,d.jsx)("sup",{className:i("text-sm",r),"data-streamdown":"superscript",...n,children:t}),sub:({node:e,children:t,className:r,...n})=>(0,d.jsx)("sub",{className:i("text-sm",r),"data-streamdown":"subscript",...n,children:t})};var F=require("marked"),K=e=>{let r=F.marked.use({gfm:!0}).lexer(e).map(o=>o.raw),n=[];for(let o=0;o<r.length;o++){let s=r[o];if(s.trim()==="$$"&&n.length>0){let a=n.at(-1),c=a.trimStart().startsWith("$$"),l=(a.match(/\$\$/g)||[]).length;if(c&&l%2===1){n[n.length-1]=a+s;continue}}if(n.length>0&&s.trimEnd().endsWith("$$")){let a=n.at(-1),c=a.trimStart().startsWith("$$"),l=(a.match(/\$\$/g)||[]).length,m=(s.match(/\$\$/g)||[]).length;if(c&&l%2===1&&!s.trimStart().startsWith("$$")&&m===1){n[n.length-1]=a+s;continue}}n.push(s)}return n};var pe=/(!?\[)([^\]]*?)$/,fe=/(\*\*)([^*]*?)$/,ke=/(__)([^_]*?)$/,be=/(\*\*\*)([^*]*?)$/,we=/(\*)([^*]*?)$/,ye=/(_)([^_]*?)$/,ve=/(`)([^`]*?)$/,$e=/(~~)([^~]*?)$/,P=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
2
- `)},Me=e=>{let t=e.match(pe);if(t){if(t[1].startsWith("!")){let n=e.lastIndexOf(t[1]);return e.substring(0,n)}return`${e}](streamdown:incomplete-link)`}return e},Te=e=>{if(P(e))return e;let t=e.match(fe);if(t){let r=t[2];if(!r||/^[\s_~*`]*$/.test(r))return e;if((e.match(/\*\*/g)||[]).length%2===1)return`${e}**`}return e},Be=e=>{let t=e.match(ke);if(t){let r=t[2];if(!r||/^[\s_~*`]*$/.test(r))return e;if((e.match(/__/g)||[]).length%2===1)return`${e}__`}return e},Ce=e=>e.split("").reduce((t,r,n)=>{if(r==="*"){let o=e[n-1],s=e[n+1];if(o==="\\")return t;let a=n;for(let l=n-1;l>=0;l--){if(e[l]===`
3
- `){a=l+1;break}if(l===0){a=0;break}}if(e.substring(a,n).trim()===""&&(s===" "||s===" "))return t;if(o!=="*"&&s!=="*")return t+1}return t},0),Ie=e=>{if(P(e))return e;if(e.match(we)){let r=-1;for(let s=0;s<e.length;s++)if(e[s]==="*"&&e[s-1]!=="*"&&e[s+1]!=="*"){r=s;break}if(r===-1)return e;let n=e.substring(r+1);if(!n||/^[\s_~*`]*$/.test(n))return e;if(Ce(e)%2===1)return`${e}*`}return e},j=(e,t)=>{let r=!1,n=!1;for(let o=0;o<e.length&&o<t;o++){if(e[o]==="\\"&&e[o+1]==="$"){o++;continue}e[o]==="$"&&(e[o+1]==="$"?(n=!n,o++,r=!1):n||(r=!r))}return r||n},Pe=e=>e.split("").reduce((t,r,n)=>{if(r==="_"){let o=e[n-1],s=e[n+1];if(o==="\\"||j(e,n))return t;if(o!=="_"&&s!=="_")return t+1}return t},0),Se=e=>{if(P(e))return e;if(e.match(ye)){let r=-1;for(let s=0;s<e.length;s++)if(e[s]==="_"&&e[s-1]!=="_"&&e[s+1]!=="_"&&!j(e,s)){r=s;break}if(r===-1)return e;let n=e.substring(r+1);if(!n||/^[\s_~*`]*$/.test(n))return e;if(Pe(e)%2===1)return`${e}_`}return e},Ne=(e,t)=>{let r=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",o=t>1&&e.substring(t-2,t+1)==="```";return r||n||o},He=e=>{let t=0;for(let r=0;r<e.length;r++)e[r]==="`"&&!Ne(e,r)&&t++;return t},Le=e=>{if(e.match(/^```[^`\n]*```?$/)&&!e.includes(`
4
- `))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let r=(e.match(/```/g)||[]).length,n=r%2===1;if(r>0&&r%2===0&&e.includes(`
5
- `)||(e.endsWith("```\n")||e.endsWith("```"))&&r%2===0)return e;let o=e.match(ve);if(o&&!n){let s=o[2];if(!s||/^[\s_~*`]*$/.test(s))return e;if(He(e)%2===1)return`${e}\``}return e},Ae=e=>{let t=e.match($e);if(t){let r=t[2];if(!r||/^[\s_~*`]*$/.test(r))return e;if((e.match(/~~/g)||[]).length%2===1)return`${e}~~`}return e};var _e=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let r=e.indexOf("$$");return r!==-1&&e.indexOf(`
6
- `,r)!==-1&&!e.endsWith(`
1
+ "use strict";"use client";var Xe=Object.create;var q=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ge=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var o in t)q(e,o,{get:t[o],enumerable:!0})},G=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fe(t))!Ve.call(e,r)&&r!==o&&q(e,r,{get:()=>t[r],enumerable:!(s=Je(t,r))||s.enumerable});return e};var I=(e,t,o)=>(o=e!=null?Xe(Ge(e)):{},G(t||!e||!e.__esModule?q(o,"default",{value:e,enumerable:!0}):o,e)),Qe=e=>G(q({},"__esModule",{value:!0}),e);var Lt={};Ke(Lt,{ControlsContext:()=>A,MermaidConfigContext:()=>_,ShikiThemeContext:()=>D,Streamdown:()=>Ue});module.exports=Qe(Lt);var v=require("react"),qe=I(require("react-markdown"),1),De=I(require("rehype-katex"),1),Ee=I(require("rehype-raw"),1),_e=I(require("remark-gfm"),1),Oe=I(require("remark-math"),1),Kt=require("katex/dist/katex.min.css"),F=I(require("harden-react-markdown"),1);var g=require("react");var x=require("lucide-react"),w=require("react"),R=require("shiki"),Z=require("shiki/engine/javascript");var V=require("clsx"),K=require("tailwind-merge"),d=(...e)=>(0,K.twMerge)((0,V.clsx)(e)),H=(e,t,o)=>{let s=typeof t=="string"?new Blob([t],{type:o}):t,r=URL.createObjectURL(s),n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)};var y=require("react/jsx-runtime"),Ye=/<pre(\s|>)/,U=(0,w.createContext)({code:""}),W=class{constructor(){this.lightHighlighter=null;this.darkHighlighter=null;this.lightTheme=null;this.darkTheme=null;this.loadedLanguages=new Set;this.initializationPromise=null}isLanguageSupported(t){return Object.hasOwn(R.bundledLanguages,t)}getFallbackLanguage(){return"text"}async ensureHighlightersInitialized(t,o){var p,f;let[s,r]=t,n=(0,Z.createJavaScriptRegexEngine)({forgiving:!0}),a=!this.lightHighlighter||this.lightTheme!==s,l=!this.darkHighlighter||this.darkTheme!==r;(a||l)&&this.loadedLanguages.clear();let i=this.isLanguageSupported(o),m=!this.loadedLanguages.has(o)&&i;if(a?(this.lightHighlighter=await(0,R.createHighlighter)({themes:[s],langs:i?[o]:[],engine:n}),this.lightTheme=s,i&&this.loadedLanguages.add(o)):m&&await((p=this.lightHighlighter)==null?void 0:p.loadLanguage(o)),l){let h=m?[...this.loadedLanguages].concat(i?[o]:[]):Array.from(this.loadedLanguages);this.darkHighlighter=await(0,R.createHighlighter)({themes:[r],langs:h.length>0?h:i?[o]:[],engine:n}),this.darkTheme=r}else m&&await((f=this.darkHighlighter)==null?void 0:f.loadLanguage(o));m&&this.loadedLanguages.add(o)}async highlightCode(t,o,s,r){var f,h;this.initializationPromise&&await this.initializationPromise,this.initializationPromise=this.ensureHighlightersInitialized(s,o),await this.initializationPromise,this.initializationPromise=null;let[n,a]=s,l=this.isLanguageSupported(o)?o:this.getFallbackLanguage(),i=(f=this.lightHighlighter)==null?void 0:f.codeToHtml(t,{lang:l,theme:n}),m=(h=this.darkHighlighter)==null?void 0:h.codeToHtml(t,{lang:l,theme:a}),p=u=>r?u.replace(Ye,`<pre class="${r}"$1`):u;return[Q(p(i)),Q(p(m))]}},Ze=new W,Q=e=>e.replace(/(<pre[^>]*)(style="[^"]*background[^";]*;?[^"]*")([^>]*>)/g,"$1$3"),ee=({code:e,language:t,className:o,children:s,preClassName:r,...n})=>{let[a,l]=(0,w.useState)(""),[i,m]=(0,w.useState)(""),p=(0,w.useRef)(!1),[f,h]=(0,w.useContext)(D);return(0,w.useEffect)(()=>(p.current=!0,Ze.highlightCode(e,t,[f,h],r).then(([u,b])=>{p.current&&(l(u),m(b))}),()=>{p.current=!1}),[e,t,f,h,r]),(0,y.jsx)(U.Provider,{value:{code:e},children:(0,y.jsxs)("div",{className:"my-4 w-full overflow-hidden rounded-xl border","data-code-block-container":!0,"data-language":t,children:[(0,y.jsxs)("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":!0,"data-language":t,children:[(0,y.jsx)("span",{className:"ml-1 font-mono lowercase",children:t}),(0,y.jsx)("div",{className:"flex items-center gap-2",children:s})]}),(0,y.jsx)("div",{className:"w-full",children:(0,y.jsxs)("div",{className:"min-w-full",children:[(0,y.jsx)("div",{className:d("overflow-x-auto dark:hidden",o),dangerouslySetInnerHTML:{__html:a},"data-code-block":!0,"data-language":t,...n}),(0,y.jsx)("div",{className:d("hidden overflow-x-auto dark:block",o),dangerouslySetInnerHTML:{__html:i},"data-code-block":!0,"data-language":t,...n})]})})]})})},Y={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},z=({onDownload:e,onError:t,language:o,children:s,className:r,code:n,...a})=>{let l=(0,w.useContext)(U).code,i=n!=null?n:l,p=`file.${o&&o in Y?Y[o]:"txt"}`,f="text/plain",h=()=>{try{H(p,i,f),e==null||e()}catch(u){t==null||t(u)}};return(0,y.jsx)("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground",r),onClick:h,title:"Download file",type:"button",...a,children:s!=null?s:(0,y.jsx)(x.DownloadIcon,{size:14})})},X=({onCopy:e,onError:t,timeout:o=2e3,children:s,className:r,code:n,...a})=>{let[l,i]=(0,w.useState)(!1),m=(0,w.useRef)(0),p=(0,w.useContext)(U).code,f=n!=null?n:p,h=async()=>{var b;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{l||(await navigator.clipboard.writeText(f),i(!0),e==null||e(),m.current=window.setTimeout(()=>i(!1),o))}catch(T){t==null||t(T)}};(0,w.useEffect)(()=>()=>{window.clearTimeout(m.current)},[]);let u=l?x.CheckIcon:x.CopyIcon;return(0,y.jsx)("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground",r),onClick:h,type:"button",...a,children:s!=null?s:(0,y.jsx)(u,{size:14})})};var te=require("lucide-react");var B=require("react/jsx-runtime"),oe=({node:e,className:t,src:o,alt:s,...r})=>{let n=async()=>{var a;if(o)try{let i=await(await fetch(o)).blob(),p=new URL(o,window.location.origin).pathname.split("/").pop()||"",f=p.includes(".")&&((a=p.split(".").pop())==null?void 0:a.length)<=4,h="";if(f)h=p;else{let u=i.type,b="png";u.includes("jpeg")||u.includes("jpg")?b="jpg":u.includes("png")?b="png":u.includes("svg")?b="svg":u.includes("gif")?b="gif":u.includes("webp")&&(b="webp"),h=`${(s||p||"image").replace(/\.[^/.]+$/,"")}.${b}`}H(h,i,i.type)}catch(l){console.error("Failed to download image:",l)}};return o?(0,B.jsxs)("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[(0,B.jsx)("img",{alt:s,className:d("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...r}),(0,B.jsx)("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),(0,B.jsx)("button",{className:d("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:n,title:"Download image",type:"button",children:(0,B.jsx)(te.DownloadIcon,{size:14})})]}):null};var L=require("react");var M=require("react/jsx-runtime"),et=async e=>{let o={...{startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0},...e},r=(await import("mermaid")).default;return r.initialize(o),r},se=({chart:e,className:t,config:o})=>{let[s,r]=(0,L.useState)(null),[n,a]=(0,L.useState)(!0),[l,i]=(0,L.useState)(""),[m,p]=(0,L.useState)("");if((0,L.useEffect)(()=>{(async()=>{try{r(null),a(!0);let u=await et(o),b=e.split("").reduce(($,ze)=>($<<5)-$+ze.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(b)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:P}=await u.render(T,e);i(P),p(P)}catch(u){if(!(m||l)){let b=u instanceof Error?u.message:"Failed to render Mermaid chart";r(b)}}finally{a(!1)}})()},[e,o]),n&&!l&&!m)return(0,M.jsx)("div",{className:d("my-4 flex justify-center p-4",t),children:(0,M.jsxs)("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[(0,M.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),(0,M.jsx)("span",{className:"text-sm",children:"Loading diagram..."})]})});if(s&&!l&&!m)return(0,M.jsxs)("div",{className:d("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[(0,M.jsxs)("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",s]}),(0,M.jsxs)("details",{className:"mt-2",children:[(0,M.jsx)("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),(0,M.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let f=l||m;return(0,M.jsx)("div",{"aria-label":"Mermaid chart",className:d("my-4 flex justify-center",t),dangerouslySetInnerHTML:{__html:f},role:"img"})};var j=require("lucide-react"),N=require("react");var C=require("react/jsx-runtime");function ne(e){var n,a;let t=[],o=[],s=e.querySelectorAll("thead th");for(let l of s)t.push(((n=l.textContent)==null?void 0:n.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],m=l.querySelectorAll("td");for(let p of m)i.push(((a=p.textContent)==null?void 0:a.trim())||"");o.push(i)}return{headers:t,rows:o}}function re(e){let{headers:t,rows:o}=e,s=n=>n.includes(",")||n.includes('"')||n.includes(`
2
+ `)?`"${n.replace(/"/g,'""')}"`:n,r=[];t.length>0&&r.push(t.map(s).join(","));for(let n of o)r.push(n.map(s).join(","));return r.join(`
3
+ `)}function ae(e){let{headers:t,rows:o}=e;if(t.length===0)return"";let s=[],r=t.map(n=>n.replace(/\|/g,"\\|"));s.push(`| ${r.join(" | ")} |`),s.push(`| ${t.map(()=>"---").join(" | ")} |`);for(let n of o){let a=[...n];for(;a.length<t.length;)a.push("");let l=a.map(i=>i.replace(/\|/g,"\\|"));s.push(`| ${l.join(" | ")} |`)}return s.join(`
4
+ `)}var ie=({children:e,className:t,onCopy:o,onError:s,timeout:r=2e3,format:n="markdown"})=>{let[a,l]=(0,N.useState)(!1),i=(0,N.useRef)(0),m=async f=>{var h;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.write)){s==null||s(new Error("Clipboard API not available"));return}try{if(!a){let b=f.currentTarget.closest('[data-streamdown="table-wrapper"]'),T=b==null?void 0:b.querySelector("table");if(!T){s==null||s(new Error("Table not found"));return}let P=ne(T),$=new ClipboardItem({"text/plain":n==="markdown"?ae(P):re(P),"text/html":new Blob([T.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),l(!0),o==null||o(),i.current=window.setTimeout(()=>l(!1),r)}}catch(u){s==null||s(u)}};(0,N.useEffect)(()=>()=>{window.clearTimeout(i.current)},[]);let p=a?j.CheckIcon:j.CopyIcon;return(0,C.jsx)("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground",t),onClick:m,title:`Copy table as ${n}`,type:"button",children:e!=null?e:(0,C.jsx)(p,{size:14})})};var le=({children:e,className:t,onDownload:o,onError:s})=>{let[r,n]=(0,N.useState)(!1),a=(0,N.useRef)(null),l=i=>{var m;try{let p=(m=a.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),f=p==null?void 0:p.querySelector("table");if(!f){s==null||s(new Error("Table not found"));return}let h=ne(f),u=i==="csv"?re(h):ae(h);H(`table.${i==="csv"?"csv":"md"}`,u,i==="csv"?"text/csv":"text/markdown"),n(!1),o==null||o(i)}catch(p){s==null||s(p)}};return(0,N.useEffect)(()=>{let i=m=>{a.current&&!a.current.contains(m.target)&&n(!1)};return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]),(0,C.jsxs)("div",{className:"relative",ref:a,children:[(0,C.jsx)("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground",t),onClick:()=>n(!r),title:"Download table",type:"button",children:e!=null?e:(0,C.jsx)(j.DownloadIcon,{size:14})}),r&&(0,C.jsxs)("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] rounded-md border border-border bg-background shadow-lg",children:[(0,C.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),type:"button",children:"CSV"}),(0,C.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};var c=require("react/jsx-runtime"),tt=/language-([^\s]+)/;function E(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&(t!=null&&t.position)))return!1;let o=e.position.start,s=t.position.start,r=e.position.end,n=t.position.end;return(o==null?void 0:o.line)===(s==null?void 0:s.line)&&(o==null?void 0:o.column)===(s==null?void 0:s.column)&&(r==null?void 0:r.line)===(n==null?void 0:n.line)&&(r==null?void 0:r.column)===(n==null?void 0:n.column)}function k(e,t){return e.className===t.className&&E(e.node,t.node)}var J=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,de=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("ol",{className:d("ml-4 list-outside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>k(e,t));de.displayName="MarkdownOl";var ce=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("li",{className:d("py-1",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&E(e.node,t.node));ce.displayName="MarkdownLi";var me=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("ul",{className:d("ml-4 list-outside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>k(e,t));me.displayName="MarkdownUl";var pe=(0,g.memo)(({className:e,...t})=>(0,c.jsx)("hr",{className:d("my-6 border-border",e),"data-streamdown":"horizontal-rule",...t}),(e,t)=>k(e,t));pe.displayName="MarkdownHr";var ue=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("span",{className:d("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>k(e,t));ue.displayName="MarkdownStrong";var ge=(0,g.memo)(({children:e,className:t,href:o,...s})=>{let r=o==="streamdown:incomplete-link";return(0,c.jsx)("a",{className:d("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...s,children:e})},(e,t)=>k(e,t)&&e.href===t.href);ge.displayName="MarkdownA";var he=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("h1",{className:d("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>k(e,t));he.displayName="MarkdownH1";var fe=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("h2",{className:d("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>k(e,t));fe.displayName="MarkdownH2";var be=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("h3",{className:d("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>k(e,t));be.displayName="MarkdownH3";var ke=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("h4",{className:d("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>k(e,t));ke.displayName="MarkdownH4";var we=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("h5",{className:d("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>k(e,t));we.displayName="MarkdownH5";var ye=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("h6",{className:d("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>k(e,t));ye.displayName="MarkdownH6";var ve=(0,g.memo)(({children:e,className:t,...o})=>{let s=(0,g.useContext)(A),r=J(s,"table");return(0,c.jsxs)("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[r&&(0,c.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,c.jsx)(ie,{}),(0,c.jsx)(le,{})]}),(0,c.jsx)("div",{className:"overflow-x-auto",children:(0,c.jsx)("table",{className:d("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]})},(e,t)=>k(e,t));ve.displayName="MarkdownTable";var Me=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("thead",{className:d("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>k(e,t));Me.displayName="MarkdownThead";var Te=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("tbody",{className:d("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>k(e,t));Te.displayName="MarkdownTbody";var Ce=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("tr",{className:d("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>k(e,t));Ce.displayName="MarkdownTr";var Ne=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("th",{className:d("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>k(e,t));Ne.displayName="MarkdownTh";var Pe=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("td",{className:d("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>k(e,t));Pe.displayName="MarkdownTd";var Ie=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("blockquote",{className:d("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>k(e,t));Ie.displayName="MarkdownBlockquote";var Be=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("sup",{className:d("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>k(e,t));Be.displayName="MarkdownSup";var Le=(0,g.memo)(({children:e,className:t,...o})=>(0,c.jsx)("sub",{className:d("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>k(e,t));Le.displayName="MarkdownSub";var ot=({node:e,className:t,children:o,...s})=>{var f,h,u;let r=((f=e==null?void 0:e.position)==null?void 0:f.start.line)===((h=e==null?void 0:e.position)==null?void 0:h.end.line),n=(0,g.useContext)(_),a=(0,g.useContext)(A);if(r)return(0,c.jsx)("code",{className:d("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...s,children:o});let l=t==null?void 0:t.match(tt),i=(u=l==null?void 0:l.at(1))!=null?u:"",m="";if((0,g.isValidElement)(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?m=o.props.children:typeof o=="string"&&(m=o),i==="mermaid"){let b=J(a,"mermaid");return(0,c.jsxs)("div",{className:d("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[b&&(0,c.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,c.jsx)(z,{code:m,language:i}),(0,c.jsx)(X,{code:m})]}),(0,c.jsx)(se,{chart:m,config:n})]})}let p=J(a,"code");return(0,c.jsx)(ee,{className:d("overflow-x-auto border-t",t),code:m,"data-language":i,"data-streamdown":"code-block",language:i,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:p&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(z,{code:m,language:i}),(0,c.jsx)(X,{})]})})},Se=(0,g.memo)(ot,(e,t)=>e.className===t.className&&E(e.node,t.node));Se.displayName="MarkdownCode";var $e=(0,g.memo)(oe,(e,t)=>e.className===t.className&&E(e.node,t.node));$e.displayName="MarkdownImg";var He={ol:de,li:ce,ul:me,hr:pe,strong:ue,a:ge,h1:he,h2:fe,h3:be,h4:ke,h5:we,h6:ye,table:ve,thead:Me,tbody:Te,tr:Ce,th:Ne,td:Pe,blockquote:Ie,code:Se,img:$e,pre:({children:e})=>e,sup:Be,sub:Le};var xe=require("marked"),je=e=>{let o=xe.Lexer.lex(e,{gfm:!0}).map(r=>r.raw),s=[];for(let r of o){if(r.trim()==="$$"&&s.length>0){let n=s.at(-1);if(!n)continue;let a=n.trimStart().startsWith("$$"),l=(n.match(/\$\$/g)||[]).length;if(a&&l%2===1){s[s.length-1]=n+r;continue}}if(s.length>0&&r.trimEnd().endsWith("$$")){let n=s.at(-1);if(!n)continue;let a=n.trimStart().startsWith("$$"),l=(n.match(/\$\$/g)||[]).length,i=(r.match(/\$\$/g)||[]).length;if(a&&l%2===1&&!r.trimStart().startsWith("$$")&&i===1){s[s.length-1]=n+r;continue}}s.push(r)}return s};var st=/(!?\[)([^\]]*?)$/,nt=/(\*\*)([^*]*?)$/,rt=/(__)([^_]*?)$/,at=/(\*\*\*)([^*]*?)$/,it=/(\*)([^*]*?)$/,lt=/(_)([^_]*?)$/,dt=/(`)([^`]*?)$/,ct=/(~~)([^~]*?)$/,O=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
5
+ `)},mt=e=>{let t=e.match(st);if(t){if(t[1].startsWith("!")){let s=e.lastIndexOf(t[1]);return e.substring(0,s)}return`${e}](streamdown:incomplete-link)`}return e},pt=e=>{if(O(e))return e;let t=e.match(nt);if(t){let o=t[2];if(!o||/^[\s_~*`]*$/.test(o))return e;let s=e.lastIndexOf(t[1]),n=e.substring(0,s).lastIndexOf(`
6
+ `),a=n===-1?0:n+1,l=e.substring(a,s);if(/^[\s]*[-*+][\s]+$/.test(l)&&o.includes(`
7
+ `))return e;if((e.match(/\*\*/g)||[]).length%2===1)return`${e}**`}return e},ut=e=>{let t=e.match(rt);if(t){let o=t[2];if(!o||/^[\s_~*`]*$/.test(o))return e;let s=e.lastIndexOf(t[1]),n=e.substring(0,s).lastIndexOf(`
8
+ `),a=n===-1?0:n+1,l=e.substring(a,s);if(/^[\s]*[-*+][\s]+$/.test(l)&&o.includes(`
9
+ `))return e;if((e.match(/__/g)||[]).length%2===1)return`${e}__`}return e},gt=e=>e.split("").reduce((t,o,s)=>{if(o==="*"){let r=e[s-1],n=e[s+1];if(r==="\\")return t;let a=s;for(let i=s-1;i>=0;i--){if(e[i]===`
10
+ `){a=i+1;break}if(i===0){a=0;break}}if(e.substring(a,s).trim()===""&&(n===" "||n===" "))return t;if(r!=="*"&&n!=="*")return t+1}return t},0),ht=e=>{if(O(e))return e;if(e.match(it)){let o=-1;for(let n=0;n<e.length;n++)if(e[n]==="*"&&e[n-1]!=="*"&&e[n+1]!=="*"){o=n;break}if(o===-1)return e;let s=e.substring(o+1);if(!s||/^[\s_~*`]*$/.test(s))return e;if(gt(e)%2===1)return`${e}*`}return e},Re=(e,t)=>{let o=!1,s=!1;for(let r=0;r<e.length&&r<t;r++){if(e[r]==="\\"&&e[r+1]==="$"){r++;continue}e[r]==="$"&&(e[r+1]==="$"?(s=!s,r++,o=!1):s||(o=!o))}return o||s},ft=e=>e.split("").reduce((t,o,s)=>{if(o==="_"){let r=e[s-1],n=e[s+1];if(r==="\\"||Re(e,s)||r&&n&&/[\p{L}\p{N}_]/u.test(r)&&/[\p{L}\p{N}_]/u.test(n))return t;if(r!=="_"&&n!=="_")return t+1}return t},0),bt=e=>{if(O(e))return e;if(e.match(lt)){let o=-1;for(let n=0;n<e.length;n++)if(e[n]==="_"&&e[n-1]!=="_"&&e[n+1]!=="_"&&e[n-1]!=="\\"&&!Re(e,n)){let a=n>0?e[n-1]:"",l=n<e.length-1?e[n+1]:"";if(a&&l&&/[\p{L}\p{N}_]/u.test(a)&&/[\p{L}\p{N}_]/u.test(l))continue;o=n;break}if(o===-1)return e;let s=e.substring(o+1);if(!s||/^[\s_~*`]*$/.test(s))return e;if(ft(e)%2===1){let n=e.match(/\n+$/);return n?`${e.slice(0,-n[0].length)}_${n[0]}`:`${e}_`}}return e},kt=(e,t)=>{let o=e.substring(t,t+3)==="```",s=t>0&&e.substring(t-1,t+2)==="```",r=t>1&&e.substring(t-2,t+1)==="```";return o||s||r},wt=e=>{let t=0;for(let o=0;o<e.length;o++)e[o]==="`"&&!kt(e,o)&&t++;return t},yt=e=>{if(e.match(/^```[^`\n]*```?$/)&&!e.includes(`
11
+ `))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let o=(e.match(/```/g)||[]).length,s=o%2===1;if(o>0&&o%2===0&&e.includes(`
12
+ `)||(e.endsWith("```\n")||e.endsWith("```"))&&o%2===0)return e;let r=e.match(dt);if(r&&!s){let n=r[2];if(!n||/^[\s_~*`]*$/.test(n))return e;if(wt(e)%2===1)return`${e}\``}return e},vt=e=>{let t=e.match(ct);if(t){let o=t[2];if(!o||/^[\s_~*`]*$/.test(o))return e;if((e.match(/~~/g)||[]).length%2===1)return`${e}~~`}return e};var Mt=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let o=e.indexOf("$$");return o!==-1&&e.indexOf(`
13
+ `,o)!==-1&&!e.endsWith(`
7
14
  `)?`${e}
8
- $$`:`${e}$$`},Re=e=>{let t=0,r=e.match(/\*+/g)||[];for(let n of r){let o=n.length;o>=3&&(t+=Math.floor(o/3))}return t},Ee=e=>{if(P(e)||/^\*{4,}$/.test(e))return e;let t=e.match(be);if(t){let r=t[2];if(!r||/^[\s_~*`]*$/.test(r))return e;if(Re(e)%2===1)return`${e}***`}return e},X=e=>{if(!e||typeof e!="string")return e;let t=e,r=Me(t);return r.endsWith("](streamdown:incomplete-link)")?r:(t=r,t=Ee(t),t=Te(t),t=Be(t),t=Ie(t),t=Se(t),t=Le(t),t=Ae(t),t=_e(t),t)};var T=require("react/jsx-runtime"),De=L.default.default||L.default,We=De(J.default),I=(0,b.createContext)(["github-light","github-dark"]),x=(0,b.memo)(({content:e,shouldParseIncompleteMarkdown:t,...r})=>{let n=(0,b.useMemo)(()=>typeof e=="string"&&t?X(e.trim()):e,[e,t]);return(0,T.jsx)(We,{...r,children:n})},(e,t)=>e.content===t.content);x.displayName="Block";var ee=(0,b.memo)(({children:e,allowedImagePrefixes:t,allowedLinkPrefixes:r,defaultOrigin:n,parseIncompleteMarkdown:o=!0,components:s,rehypePlugins:a,remarkPlugins:c,className:l,shikiTheme:m=["github-light","github-dark"],...u})=>{let p=(0,b.useId)(),g=(0,b.useMemo)(()=>K(typeof e=="string"?e:""),[e]),w=(0,b.useMemo)(()=>()=>(0,Q.default)({errorColor:"var(--color-muted-foreground)"}),[]);return(0,T.jsx)(I.Provider,{value:m,children:(0,T.jsx)("div",{className:i("space-y-4",l),...u,children:g.map((y,M)=>(0,T.jsx)(x,{allowedImagePrefixes:t!=null?t:["*"],allowedLinkPrefixes:r!=null?r:["*"],components:{...V,...s},content:y,defaultOrigin:n,rehypePlugins:[w,...a!=null?a:[]],remarkPlugins:[Y.default,[Z.default,{singleDollarTextMath:!1}],...c!=null?c:[]],shouldParseIncompleteMarkdown:o},`${p}-block_${M}`))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme);ee.displayName="Streamdown";0&&(module.exports={ShikiThemeContext,Streamdown});
15
+ $$`:`${e}$$`},Tt=e=>{let t=0,o=e.match(/\*+/g)||[];for(let s of o){let r=s.length;r>=3&&(t+=Math.floor(r/3))}return t},Ct=e=>{if(O(e)||/^\*{4,}$/.test(e))return e;let t=e.match(at);if(t){let o=t[2];if(!o||/^[\s_~*`]*$/.test(o))return e;if(Tt(e)%2===1)return`${e}***`}return e},Ae=e=>{if(!e||typeof e!="string")return e;let t=e,o=mt(t);return o.endsWith("](streamdown:incomplete-link)")?o:(t=o,t=Ct(t),t=pt(t),t=ut(t),t=ht(t),t=bt(t),t=yt(t),t=vt(t),t=Mt(t),t)};var S=require("react/jsx-runtime"),Nt=F.default.default||F.default,Pt=Nt(qe.default),D=(0,v.createContext)(["github-light","github-dark"]),_=(0,v.createContext)(void 0),A=(0,v.createContext)(!0),It={singleDollarTextMath:!1},Bt={},We=(0,v.memo)(({content:e,shouldParseIncompleteMarkdown:t,...o})=>{let s=(0,v.useMemo)(()=>typeof e=="string"&&t?Ae(e.trim()):e,[e,t]);return(0,S.jsx)(Pt,{...o,children:s})},(e,t)=>e.content===t.content);We.displayName="Block";var Ue=(0,v.memo)(({children:e,allowedImagePrefixes:t=["*"],allowedLinkPrefixes:o=["*"],defaultOrigin:s,parseIncompleteMarkdown:r=!0,components:n,rehypePlugins:a,remarkPlugins:l,className:i,shikiTheme:m=["github-light","github-dark"],mermaidConfig:p,controls:f=!0,...h})=>{let u=(0,v.useId)(),b=(0,v.useMemo)(()=>je(typeof e=="string"?e:""),[e]),T=(0,v.useMemo)(()=>()=>(0,De.default)({errorColor:"var(--color-muted-foreground)"}),[]);return(0,S.jsx)(D.Provider,{value:m,children:(0,S.jsx)(_.Provider,{value:p,children:(0,S.jsx)(A.Provider,{value:f,children:(0,S.jsx)("div",{className:d("space-y-4",i),...h,children:b.map((P,$)=>(0,S.jsx)(We,{allowedImagePrefixes:t,allowedLinkPrefixes:o,components:{...He,...n},content:P,defaultOrigin:s,rehypePlugins:[Ee.default,T,...a!=null?a:[]],remarkPlugins:[[_e.default,Bt],[Oe.default,It],...l!=null?l:[]],shouldParseIncompleteMarkdown:r},`${u}-block_${$}`))})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme);Ue.displayName="Streamdown";0&&(module.exports={ControlsContext,MermaidConfigContext,ShikiThemeContext,Streamdown});
package/dist/index.d.cts CHANGED
@@ -2,18 +2,29 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { Options } from 'react-markdown';
4
4
  import { BundledTheme } from 'shiki';
5
+ import { MermaidConfig } from 'mermaid';
6
+ export { MermaidConfig } from 'mermaid';
5
7
 
6
8
  type HardenReactMarkdownProps = Options & {
7
9
  defaultOrigin?: string;
8
10
  allowedLinkPrefixes?: string[];
9
11
  allowedImagePrefixes?: string[];
10
12
  };
13
+ type ControlsConfig = boolean | {
14
+ table?: boolean;
15
+ code?: boolean;
16
+ mermaid?: boolean;
17
+ };
11
18
  type StreamdownProps = HardenReactMarkdownProps & {
12
19
  parseIncompleteMarkdown?: boolean;
13
20
  className?: string;
14
21
  shikiTheme?: [BundledTheme, BundledTheme];
22
+ mermaidConfig?: MermaidConfig;
23
+ controls?: ControlsConfig;
15
24
  };
16
25
  declare const ShikiThemeContext: react.Context<[BundledTheme, BundledTheme]>;
17
- declare const Streamdown: react.MemoExoticComponent<({ children, allowedImagePrefixes, allowedLinkPrefixes, defaultOrigin, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
26
+ declare const MermaidConfigContext: react.Context<MermaidConfig | undefined>;
27
+ declare const ControlsContext: react.Context<ControlsConfig>;
28
+ declare const Streamdown: react.MemoExoticComponent<({ children, allowedImagePrefixes, allowedLinkPrefixes, defaultOrigin, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaidConfig, controls, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
18
29
 
19
- export { ShikiThemeContext, Streamdown, type StreamdownProps };
30
+ export { type ControlsConfig, ControlsContext, MermaidConfigContext, ShikiThemeContext, Streamdown, type StreamdownProps };
package/dist/index.d.ts CHANGED
@@ -2,18 +2,29 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { Options } from 'react-markdown';
4
4
  import { BundledTheme } from 'shiki';
5
+ import { MermaidConfig } from 'mermaid';
6
+ export { MermaidConfig } from 'mermaid';
5
7
 
6
8
  type HardenReactMarkdownProps = Options & {
7
9
  defaultOrigin?: string;
8
10
  allowedLinkPrefixes?: string[];
9
11
  allowedImagePrefixes?: string[];
10
12
  };
13
+ type ControlsConfig = boolean | {
14
+ table?: boolean;
15
+ code?: boolean;
16
+ mermaid?: boolean;
17
+ };
11
18
  type StreamdownProps = HardenReactMarkdownProps & {
12
19
  parseIncompleteMarkdown?: boolean;
13
20
  className?: string;
14
21
  shikiTheme?: [BundledTheme, BundledTheme];
22
+ mermaidConfig?: MermaidConfig;
23
+ controls?: ControlsConfig;
15
24
  };
16
25
  declare const ShikiThemeContext: react.Context<[BundledTheme, BundledTheme]>;
17
- declare const Streamdown: react.MemoExoticComponent<({ children, allowedImagePrefixes, allowedLinkPrefixes, defaultOrigin, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
26
+ declare const MermaidConfigContext: react.Context<MermaidConfig | undefined>;
27
+ declare const ControlsContext: react.Context<ControlsConfig>;
28
+ declare const Streamdown: react.MemoExoticComponent<({ children, allowedImagePrefixes, allowedLinkPrefixes, defaultOrigin, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaidConfig, controls, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
18
29
 
19
- export { ShikiThemeContext, Streamdown, type StreamdownProps };
30
+ export { type ControlsConfig, ControlsContext, MermaidConfigContext, ShikiThemeContext, Streamdown, type StreamdownProps };
package/dist/index.js CHANGED
@@ -1,8 +1,15 @@
1
- "use client";import{createContext as Le,memo as F,useId as Ae,useMemo as S}from"react";import _e from"react-markdown";import Re from"rehype-katex";import Ee from"remark-gfm";import De from"remark-math";import"katex/dist/katex.min.css";import V from"harden-react-markdown";import{isValidElement as se}from"react";import{CheckIcon as Q,CopyIcon as Y}from"lucide-react";import{createContext as Z,useContext as A,useEffect as _,useRef as R,useState as B}from"react";import{createHighlighter as H}from"shiki";import{createJavaScriptRegexEngine as x}from"shiki/engine/javascript";import{clsx as X}from"clsx";import{twMerge as J}from"tailwind-merge";var i=(...e)=>J(X(e));import{jsx as k,jsxs as T}from"react/jsx-runtime";var ee=/<pre(\s|>)/,E=Z({code:""}),C=class{constructor(){this.lightHighlighter=null;this.darkHighlighter=null;this.lightTheme=null;this.darkTheme=null;this.loadedLanguages=new Set;this.initializationPromise=null}async ensureHighlightersInitialized(t,r){var m,u;let[n,s]=t,o=x({forgiving:!0}),a=!this.lightHighlighter||this.lightTheme!==n,c=!this.darkHighlighter||this.darkTheme!==s;(a||c)&&this.loadedLanguages.clear();let l=!this.loadedLanguages.has(r);if(a?(this.lightHighlighter=await H({themes:[n],langs:[r],engine:o}),this.lightTheme=n,this.loadedLanguages.add(r)):l&&await((m=this.lightHighlighter)==null?void 0:m.loadLanguage(r)),c){let g=l?[...this.loadedLanguages,r]:Array.from(this.loadedLanguages);this.darkHighlighter=await H({themes:[s],langs:g.length>0?g:[r],engine:o}),this.darkTheme=s}else l&&await((u=this.darkHighlighter)==null?void 0:u.loadLanguage(r));l&&this.loadedLanguages.add(r)}async highlightCode(t,r,n,s){var u,g;this.initializationPromise&&await this.initializationPromise,this.initializationPromise=this.ensureHighlightersInitialized(n,r),await this.initializationPromise,this.initializationPromise=null;let o=h=>s?h.replace(ee,`<pre class="${s}"$1`):h,[a,c]=n,l=(u=this.lightHighlighter)==null?void 0:u.codeToHtml(t,{lang:r,theme:a}),m=(g=this.darkHighlighter)==null?void 0:g.codeToHtml(t,{lang:r,theme:c});return[L(o(l)),L(o(m))]}},te=new C;async function re(e,t,r,n){return te.highlightCode(e,t,r,n)}function L(e){return e.replace(/(<pre[^>]*)(style="[^"]*background[^";]*;?[^"]*")([^>]*>)/g,"$1$3")}var D=({code:e,language:t,className:r,children:n,preClassName:s,...o})=>{let[a,c]=B(""),[l,m]=B(""),u=R(!1),[g,h]=A(P);return _(()=>(u.current=!0,re(e,t,[g,h],s).then(([p,f])=>{u.current&&(c(p),m(f))}),()=>{u.current=!1}),[e,t,g,h,s]),k(E.Provider,{value:{code:e},children:T("div",{className:"my-4 w-full overflow-hidden rounded-xl border","data-code-block-container":!0,"data-language":t,children:[T("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":!0,"data-language":t,children:[k("span",{className:"ml-1 font-mono lowercase",children:t}),k("div",{children:n})]}),k("div",{className:"w-full",children:T("div",{className:"min-w-full",children:[k("div",{className:i("overflow-x-auto dark:hidden",r),dangerouslySetInnerHTML:{__html:a},"data-code-block":!0,"data-language":t,...o}),k("div",{className:i("hidden overflow-x-auto dark:block",r),dangerouslySetInnerHTML:{__html:l},"data-code-block":!0,"data-language":t,...o})]})})]})})},I=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:s,code:o,...a})=>{let[c,l]=B(!1),m=R(0),u=A(E).code,g=o!=null?o:u,h=async()=>{var f;if(typeof window=="undefined"||!((f=navigator==null?void 0:navigator.clipboard)!=null&&f.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(g),l(!0),e==null||e(),m.current=window.setTimeout(()=>l(!1),r))}catch(b){t==null||t(b)}};_(()=>()=>{window.clearTimeout(m.current)},[]);let p=c?Q:Y;return k("button",{className:i("text-muted-foreground","p-1 transition-all",s),onClick:h,type:"button",...a,children:n!=null?n:k(p,{size:14})})};import{useEffect as ne,useState as y}from"react";import{jsx as w,jsxs as v}from"react/jsx-runtime";var W=!1,oe=async()=>{if(!W){let r=(await import("mermaid")).default;return r.initialize({startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0}),W=!0,r}return(await import("mermaid")).default},z=({chart:e,className:t})=>{let[r,n]=y(null),[s,o]=y(!0),[a,c]=y(""),[l,m]=y("");if(ne(()=>{(async()=>{try{n(null),o(!0);let h=await oe(),p=e.split("").reduce((N,j)=>(N<<5)-N+j.charCodeAt(0)|0,0),f=`mermaid-${Math.abs(p)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:b}=await h.render(f,e);c(b),m(b)}catch(h){if(!(l||a)){let p=h instanceof Error?h.message:"Failed to render Mermaid chart";n(p)}}finally{o(!1)}})()},[e]),s&&!a&&!l)return w("div",{className:i("my-4 flex justify-center p-4",t),children:v("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[w("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),w("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!a&&!l)return v("div",{className:i("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[v("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),v("details",{className:"mt-2",children:[w("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),w("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let u=a||l;return w("div",{"aria-label":"Mermaid chart",className:i("my-4 flex justify-center",t),dangerouslySetInnerHTML:{__html:u},role:"img"})};import{jsx as d,jsxs as le}from"react/jsx-runtime";var ie=/language-([^\s]+)/,ae=({node:e,className:t,children:r,...n})=>{var l,m,u;if(((l=e==null?void 0:e.position)==null?void 0:l.start.line)===((m=e==null?void 0:e.position)==null?void 0:m.end.line))return d("code",{className:i("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let o=t==null?void 0:t.match(ie),a=(u=o==null?void 0:o.at(1))!=null?u:"",c="";return se(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?c=r.props.children:typeof r=="string"&&(c=r),a==="mermaid"?le("div",{className:i("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[d("div",{className:"flex items-center justify-end",children:d(I,{code:c})}),d(z,{chart:c})]}):d(D,{className:i("overflow-x-auto border-t",t),code:c,"data-language":a,"data-streamdown":"code-block",language:a,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d(I,{})})},O={ol:({node:e,children:t,className:r,...n})=>d("ol",{className:i("ml-4 list-outside list-decimal whitespace-normal",r),"data-streamdown":"ordered-list",...n,children:t}),li:({node:e,children:t,className:r,...n})=>d("li",{className:i("py-1",r),"data-streamdown":"list-item",...n,children:t}),ul:({node:e,children:t,className:r,...n})=>d("ul",{className:i("ml-4 list-outside list-disc whitespace-normal",r),"data-streamdown":"unordered-list",...n,children:t}),hr:({node:e,className:t,...r})=>d("hr",{className:i("my-6 border-border",t),"data-streamdown":"horizontal-rule",...r}),strong:({node:e,children:t,className:r,...n})=>d("span",{className:i("font-semibold",r),"data-streamdown":"strong",...n,children:t}),a:({node:e,children:t,className:r,href:n,...s})=>{let o=n==="streamdown:incomplete-link";return d("a",{className:i("font-medium text-primary underline",r),"data-incomplete":o,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...s,children:t})},h1:({node:e,children:t,className:r,...n})=>d("h1",{className:i("mt-6 mb-2 font-semibold text-3xl",r),"data-streamdown":"heading-1",...n,children:t}),h2:({node:e,children:t,className:r,...n})=>d("h2",{className:i("mt-6 mb-2 font-semibold text-2xl",r),"data-streamdown":"heading-2",...n,children:t}),h3:({node:e,children:t,className:r,...n})=>d("h3",{className:i("mt-6 mb-2 font-semibold text-xl",r),"data-streamdown":"heading-3",...n,children:t}),h4:({node:e,children:t,className:r,...n})=>d("h4",{className:i("mt-6 mb-2 font-semibold text-lg",r),"data-streamdown":"heading-4",...n,children:t}),h5:({node:e,children:t,className:r,...n})=>d("h5",{className:i("mt-6 mb-2 font-semibold text-base",r),"data-streamdown":"heading-5",...n,children:t}),h6:({node:e,children:t,className:r,...n})=>d("h6",{className:i("mt-6 mb-2 font-semibold text-sm",r),"data-streamdown":"heading-6",...n,children:t}),table:({node:e,children:t,className:r,...n})=>d("div",{className:"my-4 overflow-x-auto","data-streamdown":"table-wrapper",children:d("table",{className:i("w-full border-collapse border border-border",r),"data-streamdown":"table",...n,children:t})}),thead:({node:e,children:t,className:r,...n})=>d("thead",{className:i("bg-muted/80",r),"data-streamdown":"table-header",...n,children:t}),tbody:({node:e,children:t,className:r,...n})=>d("tbody",{className:i("divide-y bg-muted/40 divide-border",r),"data-streamdown":"table-body",...n,children:t}),tr:({node:e,children:t,className:r,...n})=>d("tr",{className:i("border-border border-b",r),"data-streamdown":"table-row",...n,children:t}),th:({node:e,children:t,className:r,...n})=>d("th",{className:i("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",r),"data-streamdown":"table-header-cell",...n,children:t}),td:({node:e,children:t,className:r,...n})=>d("td",{className:i("px-4 py-2 text-sm",r),"data-streamdown":"table-cell",...n,children:t}),blockquote:({node:e,children:t,className:r,...n})=>d("blockquote",{className:i("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",r),"data-streamdown":"blockquote",...n,children:t}),code:ae,pre:({children:e})=>e,sup:({node:e,children:t,className:r,...n})=>d("sup",{className:i("text-sm",r),"data-streamdown":"superscript",...n,children:t}),sub:({node:e,children:t,className:r,...n})=>d("sub",{className:i("text-sm",r),"data-streamdown":"subscript",...n,children:t})};import{marked as de}from"marked";var U=e=>{let r=de.use({gfm:!0}).lexer(e).map(s=>s.raw),n=[];for(let s=0;s<r.length;s++){let o=r[s];if(o.trim()==="$$"&&n.length>0){let a=n.at(-1),c=a.trimStart().startsWith("$$"),l=(a.match(/\$\$/g)||[]).length;if(c&&l%2===1){n[n.length-1]=a+o;continue}}if(n.length>0&&o.trimEnd().endsWith("$$")){let a=n.at(-1),c=a.trimStart().startsWith("$$"),l=(a.match(/\$\$/g)||[]).length,m=(o.match(/\$\$/g)||[]).length;if(c&&l%2===1&&!o.trimStart().startsWith("$$")&&m===1){n[n.length-1]=a+o;continue}}n.push(o)}return n};var ce=/(!?\[)([^\]]*?)$/,me=/(\*\*)([^*]*?)$/,ue=/(__)([^_]*?)$/,he=/(\*\*\*)([^*]*?)$/,ge=/(\*)([^*]*?)$/,pe=/(_)([^_]*?)$/,fe=/(`)([^`]*?)$/,ke=/(~~)([^~]*?)$/,$=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
2
- `)},be=e=>{let t=e.match(ce);if(t){if(t[1].startsWith("!")){let n=e.lastIndexOf(t[1]);return e.substring(0,n)}return`${e}](streamdown:incomplete-link)`}return e},we=e=>{if($(e))return e;let t=e.match(me);if(t){let r=t[2];if(!r||/^[\s_~*`]*$/.test(r))return e;if((e.match(/\*\*/g)||[]).length%2===1)return`${e}**`}return e},ye=e=>{let t=e.match(ue);if(t){let r=t[2];if(!r||/^[\s_~*`]*$/.test(r))return e;if((e.match(/__/g)||[]).length%2===1)return`${e}__`}return e},ve=e=>e.split("").reduce((t,r,n)=>{if(r==="*"){let s=e[n-1],o=e[n+1];if(s==="\\")return t;let a=n;for(let l=n-1;l>=0;l--){if(e[l]===`
3
- `){a=l+1;break}if(l===0){a=0;break}}if(e.substring(a,n).trim()===""&&(o===" "||o===" "))return t;if(s!=="*"&&o!=="*")return t+1}return t},0),$e=e=>{if($(e))return e;if(e.match(ge)){let r=-1;for(let o=0;o<e.length;o++)if(e[o]==="*"&&e[o-1]!=="*"&&e[o+1]!=="*"){r=o;break}if(r===-1)return e;let n=e.substring(r+1);if(!n||/^[\s_~*`]*$/.test(n))return e;if(ve(e)%2===1)return`${e}*`}return e},q=(e,t)=>{let r=!1,n=!1;for(let s=0;s<e.length&&s<t;s++){if(e[s]==="\\"&&e[s+1]==="$"){s++;continue}e[s]==="$"&&(e[s+1]==="$"?(n=!n,s++,r=!1):n||(r=!r))}return r||n},Me=e=>e.split("").reduce((t,r,n)=>{if(r==="_"){let s=e[n-1],o=e[n+1];if(s==="\\"||q(e,n))return t;if(s!=="_"&&o!=="_")return t+1}return t},0),Te=e=>{if($(e))return e;if(e.match(pe)){let r=-1;for(let o=0;o<e.length;o++)if(e[o]==="_"&&e[o-1]!=="_"&&e[o+1]!=="_"&&!q(e,o)){r=o;break}if(r===-1)return e;let n=e.substring(r+1);if(!n||/^[\s_~*`]*$/.test(n))return e;if(Me(e)%2===1)return`${e}_`}return e},Be=(e,t)=>{let r=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",s=t>1&&e.substring(t-2,t+1)==="```";return r||n||s},Ce=e=>{let t=0;for(let r=0;r<e.length;r++)e[r]==="`"&&!Be(e,r)&&t++;return t},Ie=e=>{if(e.match(/^```[^`\n]*```?$/)&&!e.includes(`
4
- `))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let r=(e.match(/```/g)||[]).length,n=r%2===1;if(r>0&&r%2===0&&e.includes(`
5
- `)||(e.endsWith("```\n")||e.endsWith("```"))&&r%2===0)return e;let s=e.match(fe);if(s&&!n){let o=s[2];if(!o||/^[\s_~*`]*$/.test(o))return e;if(Ce(e)%2===1)return`${e}\``}return e},Pe=e=>{let t=e.match(ke);if(t){let r=t[2];if(!r||/^[\s_~*`]*$/.test(r))return e;if((e.match(/~~/g)||[]).length%2===1)return`${e}~~`}return e};var Se=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let r=e.indexOf("$$");return r!==-1&&e.indexOf(`
6
- `,r)!==-1&&!e.endsWith(`
1
+ "use client";import{createContext as J,memo as De,useId as $t,useMemo as X}from"react";import Ht from"react-markdown";import xt from"rehype-katex";import jt from"rehype-raw";import Rt from"remark-gfm";import At from"remark-math";import"katex/dist/katex.min.css";import qe from"harden-react-markdown";import{isValidElement as nt,memo as b,useContext as W}from"react";import{CheckIcon as Ue,CopyIcon as ze,DownloadIcon as Xe}from"lucide-react";import{createContext as Je,useContext as q,useEffect as K,useRef as Q,useState as R}from"react";import{bundledLanguages as Fe,createHighlighter as F}from"shiki";import{createJavaScriptRegexEngine as Ge}from"shiki/engine/javascript";import{clsx as Oe}from"clsx";import{twMerge as We}from"tailwind-merge";var d=(...e)=>We(Oe(e)),T=(e,t,o)=>{let s=typeof t=="string"?new Blob([t],{type:o}):t,r=URL.createObjectURL(s),n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)};import{jsx as y,jsxs as j}from"react/jsx-runtime";var Ve=/<pre(\s|>)/,D=Je({code:""}),A=class{constructor(){this.lightHighlighter=null;this.darkHighlighter=null;this.lightTheme=null;this.darkTheme=null;this.loadedLanguages=new Set;this.initializationPromise=null}isLanguageSupported(t){return Object.hasOwn(Fe,t)}getFallbackLanguage(){return"text"}async ensureHighlightersInitialized(t,o){var m,h;let[s,r]=t,n=Ge({forgiving:!0}),a=!this.lightHighlighter||this.lightTheme!==s,l=!this.darkHighlighter||this.darkTheme!==r;(a||l)&&this.loadedLanguages.clear();let i=this.isLanguageSupported(o),c=!this.loadedLanguages.has(o)&&i;if(a?(this.lightHighlighter=await F({themes:[s],langs:i?[o]:[],engine:n}),this.lightTheme=s,i&&this.loadedLanguages.add(o)):c&&await((m=this.lightHighlighter)==null?void 0:m.loadLanguage(o)),l){let g=c?[...this.loadedLanguages].concat(i?[o]:[]):Array.from(this.loadedLanguages);this.darkHighlighter=await F({themes:[r],langs:g.length>0?g:i?[o]:[],engine:n}),this.darkTheme=r}else c&&await((h=this.darkHighlighter)==null?void 0:h.loadLanguage(o));c&&this.loadedLanguages.add(o)}async highlightCode(t,o,s,r){var h,g;this.initializationPromise&&await this.initializationPromise,this.initializationPromise=this.ensureHighlightersInitialized(s,o),await this.initializationPromise,this.initializationPromise=null;let[n,a]=s,l=this.isLanguageSupported(o)?o:this.getFallbackLanguage(),i=(h=this.lightHighlighter)==null?void 0:h.codeToHtml(t,{lang:l,theme:n}),c=(g=this.darkHighlighter)==null?void 0:g.codeToHtml(t,{lang:l,theme:a}),m=u=>r?u.replace(Ve,`<pre class="${r}"$1`):u;return[G(m(i)),G(m(c))]}},Ke=new A,G=e=>e.replace(/(<pre[^>]*)(style="[^"]*background[^";]*;?[^"]*")([^>]*>)/g,"$1$3"),Y=({code:e,language:t,className:o,children:s,preClassName:r,...n})=>{let[a,l]=R(""),[i,c]=R(""),m=Q(!1),[h,g]=q(O);return K(()=>(m.current=!0,Ke.highlightCode(e,t,[h,g],r).then(([u,f])=>{m.current&&(l(u),c(f))}),()=>{m.current=!1}),[e,t,h,g,r]),y(D.Provider,{value:{code:e},children:j("div",{className:"my-4 w-full overflow-hidden rounded-xl border","data-code-block-container":!0,"data-language":t,children:[j("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":!0,"data-language":t,children:[y("span",{className:"ml-1 font-mono lowercase",children:t}),y("div",{className:"flex items-center gap-2",children:s})]}),y("div",{className:"w-full",children:j("div",{className:"min-w-full",children:[y("div",{className:d("overflow-x-auto dark:hidden",o),dangerouslySetInnerHTML:{__html:a},"data-code-block":!0,"data-language":t,...n}),y("div",{className:d("hidden overflow-x-auto dark:block",o),dangerouslySetInnerHTML:{__html:i},"data-code-block":!0,"data-language":t,...n})]})})]})})},V={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},E=({onDownload:e,onError:t,language:o,children:s,className:r,code:n,...a})=>{let l=q(D).code,i=n!=null?n:l,m=`file.${o&&o in V?V[o]:"txt"}`,h="text/plain",g=()=>{try{T(m,i,h),e==null||e()}catch(u){t==null||t(u)}};return y("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground",r),onClick:g,title:"Download file",type:"button",...a,children:s!=null?s:y(Xe,{size:14})})},_=({onCopy:e,onError:t,timeout:o=2e3,children:s,className:r,code:n,...a})=>{let[l,i]=R(!1),c=Q(0),m=q(D).code,h=n!=null?n:m,g=async()=>{var f;if(typeof window=="undefined"||!((f=navigator==null?void 0:navigator.clipboard)!=null&&f.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{l||(await navigator.clipboard.writeText(h),i(!0),e==null||e(),c.current=window.setTimeout(()=>i(!1),o))}catch(w){t==null||t(w)}};K(()=>()=>{window.clearTimeout(c.current)},[]);let u=l?Ue:ze;return y("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground",r),onClick:g,type:"button",...a,children:s!=null?s:y(u,{size:14})})};import{DownloadIcon as Qe}from"lucide-react";import{jsx as B,jsxs as Ye}from"react/jsx-runtime";var Z=({node:e,className:t,src:o,alt:s,...r})=>{let n=async()=>{var a;if(o)try{let i=await(await fetch(o)).blob(),m=new URL(o,window.location.origin).pathname.split("/").pop()||"",h=m.includes(".")&&((a=m.split(".").pop())==null?void 0:a.length)<=4,g="";if(h)g=m;else{let u=i.type,f="png";u.includes("jpeg")||u.includes("jpg")?f="jpg":u.includes("png")?f="png":u.includes("svg")?f="svg":u.includes("gif")?f="gif":u.includes("webp")&&(f="webp"),g=`${(s||m||"image").replace(/\.[^/.]+$/,"")}.${f}`}T(g,i,i.type)}catch(l){console.error("Failed to download image:",l)}};return o?Ye("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[B("img",{alt:s,className:d("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...r}),B("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),B("button",{className:d("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:n,title:"Download image",type:"button",children:B(Qe,{size:14})})]}):null};import{useEffect as Ze,useState as L}from"react";import{jsx as C,jsxs as S}from"react/jsx-runtime";var et=async e=>{let o={...{startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0},...e},r=(await import("mermaid")).default;return r.initialize(o),r},ee=({chart:e,className:t,config:o})=>{let[s,r]=L(null),[n,a]=L(!0),[l,i]=L(""),[c,m]=L("");if(Ze(()=>{(async()=>{try{r(null),a(!0);let u=await et(o),f=e.split("").reduce((M,_e)=>(M<<5)-M+_e.charCodeAt(0)|0,0),w=`mermaid-${Math.abs(f)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:v}=await u.render(w,e);i(v),m(v)}catch(u){if(!(c||l)){let f=u instanceof Error?u.message:"Failed to render Mermaid chart";r(f)}}finally{a(!1)}})()},[e,o]),n&&!l&&!c)return C("div",{className:d("my-4 flex justify-center p-4",t),children:S("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[C("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),C("span",{className:"text-sm",children:"Loading diagram..."})]})});if(s&&!l&&!c)return S("div",{className:d("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[S("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",s]}),S("details",{className:"mt-2",children:[C("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),C("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let h=l||c;return C("div",{"aria-label":"Mermaid chart",className:d("my-4 flex justify-center",t),dangerouslySetInnerHTML:{__html:h},role:"img"})};import{CheckIcon as tt,CopyIcon as ot,DownloadIcon as st}from"lucide-react";import{useEffect as oe,useRef as se,useState as ne}from"react";import{jsx as N,jsxs as te}from"react/jsx-runtime";function re(e){var n,a;let t=[],o=[],s=e.querySelectorAll("thead th");for(let l of s)t.push(((n=l.textContent)==null?void 0:n.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],c=l.querySelectorAll("td");for(let m of c)i.push(((a=m.textContent)==null?void 0:a.trim())||"");o.push(i)}return{headers:t,rows:o}}function ae(e){let{headers:t,rows:o}=e,s=n=>n.includes(",")||n.includes('"')||n.includes(`
2
+ `)?`"${n.replace(/"/g,'""')}"`:n,r=[];t.length>0&&r.push(t.map(s).join(","));for(let n of o)r.push(n.map(s).join(","));return r.join(`
3
+ `)}function ie(e){let{headers:t,rows:o}=e;if(t.length===0)return"";let s=[],r=t.map(n=>n.replace(/\|/g,"\\|"));s.push(`| ${r.join(" | ")} |`),s.push(`| ${t.map(()=>"---").join(" | ")} |`);for(let n of o){let a=[...n];for(;a.length<t.length;)a.push("");let l=a.map(i=>i.replace(/\|/g,"\\|"));s.push(`| ${l.join(" | ")} |`)}return s.join(`
4
+ `)}var le=({children:e,className:t,onCopy:o,onError:s,timeout:r=2e3,format:n="markdown"})=>{let[a,l]=ne(!1),i=se(0),c=async h=>{var g;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.write)){s==null||s(new Error("Clipboard API not available"));return}try{if(!a){let f=h.currentTarget.closest('[data-streamdown="table-wrapper"]'),w=f==null?void 0:f.querySelector("table");if(!w){s==null||s(new Error("Table not found"));return}let v=re(w),M=new ClipboardItem({"text/plain":n==="markdown"?ie(v):ae(v),"text/html":new Blob([w.outerHTML],{type:"text/html"})});await navigator.clipboard.write([M]),l(!0),o==null||o(),i.current=window.setTimeout(()=>l(!1),r)}}catch(u){s==null||s(u)}};oe(()=>()=>{window.clearTimeout(i.current)},[]);let m=a?tt:ot;return N("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground",t),onClick:c,title:`Copy table as ${n}`,type:"button",children:e!=null?e:N(m,{size:14})})};var de=({children:e,className:t,onDownload:o,onError:s})=>{let[r,n]=ne(!1),a=se(null),l=i=>{var c;try{let m=(c=a.current)==null?void 0:c.closest('[data-streamdown="table-wrapper"]'),h=m==null?void 0:m.querySelector("table");if(!h){s==null||s(new Error("Table not found"));return}let g=re(h),u=i==="csv"?ae(g):ie(g);T(`table.${i==="csv"?"csv":"md"}`,u,i==="csv"?"text/csv":"text/markdown"),n(!1),o==null||o(i)}catch(m){s==null||s(m)}};return oe(()=>{let i=c=>{a.current&&!a.current.contains(c.target)&&n(!1)};return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]),te("div",{className:"relative",ref:a,children:[N("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground",t),onClick:()=>n(!r),title:"Download table",type:"button",children:e!=null?e:N(st,{size:14})}),r&&te("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] rounded-md border border-border bg-background shadow-lg",children:[N("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),type:"button",children:"CSV"}),N("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};import{Fragment as it,jsx as p,jsxs as I}from"react/jsx-runtime";var rt=/language-([^\s]+)/;function $(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&(t!=null&&t.position)))return!1;let o=e.position.start,s=t.position.start,r=e.position.end,n=t.position.end;return(o==null?void 0:o.line)===(s==null?void 0:s.line)&&(o==null?void 0:o.column)===(s==null?void 0:s.column)&&(r==null?void 0:r.line)===(n==null?void 0:n.line)&&(r==null?void 0:r.column)===(n==null?void 0:n.column)}function k(e,t){return e.className===t.className&&$(e.node,t.node)}var U=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,ce=b(({children:e,className:t,...o})=>p("ol",{className:d("ml-4 list-outside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>k(e,t));ce.displayName="MarkdownOl";var me=b(({children:e,className:t,...o})=>p("li",{className:d("py-1",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&$(e.node,t.node));me.displayName="MarkdownLi";var pe=b(({children:e,className:t,...o})=>p("ul",{className:d("ml-4 list-outside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>k(e,t));pe.displayName="MarkdownUl";var ue=b(({className:e,...t})=>p("hr",{className:d("my-6 border-border",e),"data-streamdown":"horizontal-rule",...t}),(e,t)=>k(e,t));ue.displayName="MarkdownHr";var ge=b(({children:e,className:t,...o})=>p("span",{className:d("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>k(e,t));ge.displayName="MarkdownStrong";var he=b(({children:e,className:t,href:o,...s})=>{let r=o==="streamdown:incomplete-link";return p("a",{className:d("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...s,children:e})},(e,t)=>k(e,t)&&e.href===t.href);he.displayName="MarkdownA";var fe=b(({children:e,className:t,...o})=>p("h1",{className:d("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>k(e,t));fe.displayName="MarkdownH1";var be=b(({children:e,className:t,...o})=>p("h2",{className:d("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>k(e,t));be.displayName="MarkdownH2";var ke=b(({children:e,className:t,...o})=>p("h3",{className:d("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>k(e,t));ke.displayName="MarkdownH3";var we=b(({children:e,className:t,...o})=>p("h4",{className:d("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>k(e,t));we.displayName="MarkdownH4";var ye=b(({children:e,className:t,...o})=>p("h5",{className:d("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>k(e,t));ye.displayName="MarkdownH5";var ve=b(({children:e,className:t,...o})=>p("h6",{className:d("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>k(e,t));ve.displayName="MarkdownH6";var Me=b(({children:e,className:t,...o})=>{let s=W(H),r=U(s,"table");return I("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[r&&I("div",{className:"flex items-center justify-end gap-1",children:[p(le,{}),p(de,{})]}),p("div",{className:"overflow-x-auto",children:p("table",{className:d("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]})},(e,t)=>k(e,t));Me.displayName="MarkdownTable";var Te=b(({children:e,className:t,...o})=>p("thead",{className:d("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>k(e,t));Te.displayName="MarkdownThead";var Ce=b(({children:e,className:t,...o})=>p("tbody",{className:d("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>k(e,t));Ce.displayName="MarkdownTbody";var Ne=b(({children:e,className:t,...o})=>p("tr",{className:d("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>k(e,t));Ne.displayName="MarkdownTr";var Pe=b(({children:e,className:t,...o})=>p("th",{className:d("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>k(e,t));Pe.displayName="MarkdownTh";var Ie=b(({children:e,className:t,...o})=>p("td",{className:d("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>k(e,t));Ie.displayName="MarkdownTd";var Be=b(({children:e,className:t,...o})=>p("blockquote",{className:d("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>k(e,t));Be.displayName="MarkdownBlockquote";var Le=b(({children:e,className:t,...o})=>p("sup",{className:d("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>k(e,t));Le.displayName="MarkdownSup";var Se=b(({children:e,className:t,...o})=>p("sub",{className:d("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>k(e,t));Se.displayName="MarkdownSub";var at=({node:e,className:t,children:o,...s})=>{var h,g,u;let r=((h=e==null?void 0:e.position)==null?void 0:h.start.line)===((g=e==null?void 0:e.position)==null?void 0:g.end.line),n=W(z),a=W(H);if(r)return p("code",{className:d("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...s,children:o});let l=t==null?void 0:t.match(rt),i=(u=l==null?void 0:l.at(1))!=null?u:"",c="";if(nt(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?c=o.props.children:typeof o=="string"&&(c=o),i==="mermaid"){let f=U(a,"mermaid");return I("div",{className:d("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[f&&I("div",{className:"flex items-center justify-end gap-2",children:[p(E,{code:c,language:i}),p(_,{code:c})]}),p(ee,{chart:c,config:n})]})}let m=U(a,"code");return p(Y,{className:d("overflow-x-auto border-t",t),code:c,"data-language":i,"data-streamdown":"code-block",language:i,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:m&&I(it,{children:[p(E,{code:c,language:i}),p(_,{})]})})},$e=b(at,(e,t)=>e.className===t.className&&$(e.node,t.node));$e.displayName="MarkdownCode";var He=b(Z,(e,t)=>e.className===t.className&&$(e.node,t.node));He.displayName="MarkdownImg";var xe={ol:ce,li:me,ul:pe,hr:ue,strong:ge,a:he,h1:fe,h2:be,h3:ke,h4:we,h5:ye,h6:ve,table:Me,thead:Te,tbody:Ce,tr:Ne,th:Pe,td:Ie,blockquote:Be,code:$e,img:He,pre:({children:e})=>e,sup:Le,sub:Se};import{Lexer as lt}from"marked";var je=e=>{let o=lt.lex(e,{gfm:!0}).map(r=>r.raw),s=[];for(let r of o){if(r.trim()==="$$"&&s.length>0){let n=s.at(-1);if(!n)continue;let a=n.trimStart().startsWith("$$"),l=(n.match(/\$\$/g)||[]).length;if(a&&l%2===1){s[s.length-1]=n+r;continue}}if(s.length>0&&r.trimEnd().endsWith("$$")){let n=s.at(-1);if(!n)continue;let a=n.trimStart().startsWith("$$"),l=(n.match(/\$\$/g)||[]).length,i=(r.match(/\$\$/g)||[]).length;if(a&&l%2===1&&!r.trimStart().startsWith("$$")&&i===1){s[s.length-1]=n+r;continue}}s.push(r)}return s};var dt=/(!?\[)([^\]]*?)$/,ct=/(\*\*)([^*]*?)$/,mt=/(__)([^_]*?)$/,pt=/(\*\*\*)([^*]*?)$/,ut=/(\*)([^*]*?)$/,gt=/(_)([^_]*?)$/,ht=/(`)([^`]*?)$/,ft=/(~~)([^~]*?)$/,x=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
5
+ `)},bt=e=>{let t=e.match(dt);if(t){if(t[1].startsWith("!")){let s=e.lastIndexOf(t[1]);return e.substring(0,s)}return`${e}](streamdown:incomplete-link)`}return e},kt=e=>{if(x(e))return e;let t=e.match(ct);if(t){let o=t[2];if(!o||/^[\s_~*`]*$/.test(o))return e;let s=e.lastIndexOf(t[1]),n=e.substring(0,s).lastIndexOf(`
6
+ `),a=n===-1?0:n+1,l=e.substring(a,s);if(/^[\s]*[-*+][\s]+$/.test(l)&&o.includes(`
7
+ `))return e;if((e.match(/\*\*/g)||[]).length%2===1)return`${e}**`}return e},wt=e=>{let t=e.match(mt);if(t){let o=t[2];if(!o||/^[\s_~*`]*$/.test(o))return e;let s=e.lastIndexOf(t[1]),n=e.substring(0,s).lastIndexOf(`
8
+ `),a=n===-1?0:n+1,l=e.substring(a,s);if(/^[\s]*[-*+][\s]+$/.test(l)&&o.includes(`
9
+ `))return e;if((e.match(/__/g)||[]).length%2===1)return`${e}__`}return e},yt=e=>e.split("").reduce((t,o,s)=>{if(o==="*"){let r=e[s-1],n=e[s+1];if(r==="\\")return t;let a=s;for(let i=s-1;i>=0;i--){if(e[i]===`
10
+ `){a=i+1;break}if(i===0){a=0;break}}if(e.substring(a,s).trim()===""&&(n===" "||n===" "))return t;if(r!=="*"&&n!=="*")return t+1}return t},0),vt=e=>{if(x(e))return e;if(e.match(ut)){let o=-1;for(let n=0;n<e.length;n++)if(e[n]==="*"&&e[n-1]!=="*"&&e[n+1]!=="*"){o=n;break}if(o===-1)return e;let s=e.substring(o+1);if(!s||/^[\s_~*`]*$/.test(s))return e;if(yt(e)%2===1)return`${e}*`}return e},Re=(e,t)=>{let o=!1,s=!1;for(let r=0;r<e.length&&r<t;r++){if(e[r]==="\\"&&e[r+1]==="$"){r++;continue}e[r]==="$"&&(e[r+1]==="$"?(s=!s,r++,o=!1):s||(o=!o))}return o||s},Mt=e=>e.split("").reduce((t,o,s)=>{if(o==="_"){let r=e[s-1],n=e[s+1];if(r==="\\"||Re(e,s)||r&&n&&/[\p{L}\p{N}_]/u.test(r)&&/[\p{L}\p{N}_]/u.test(n))return t;if(r!=="_"&&n!=="_")return t+1}return t},0),Tt=e=>{if(x(e))return e;if(e.match(gt)){let o=-1;for(let n=0;n<e.length;n++)if(e[n]==="_"&&e[n-1]!=="_"&&e[n+1]!=="_"&&e[n-1]!=="\\"&&!Re(e,n)){let a=n>0?e[n-1]:"",l=n<e.length-1?e[n+1]:"";if(a&&l&&/[\p{L}\p{N}_]/u.test(a)&&/[\p{L}\p{N}_]/u.test(l))continue;o=n;break}if(o===-1)return e;let s=e.substring(o+1);if(!s||/^[\s_~*`]*$/.test(s))return e;if(Mt(e)%2===1){let n=e.match(/\n+$/);return n?`${e.slice(0,-n[0].length)}_${n[0]}`:`${e}_`}}return e},Ct=(e,t)=>{let o=e.substring(t,t+3)==="```",s=t>0&&e.substring(t-1,t+2)==="```",r=t>1&&e.substring(t-2,t+1)==="```";return o||s||r},Nt=e=>{let t=0;for(let o=0;o<e.length;o++)e[o]==="`"&&!Ct(e,o)&&t++;return t},Pt=e=>{if(e.match(/^```[^`\n]*```?$/)&&!e.includes(`
11
+ `))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let o=(e.match(/```/g)||[]).length,s=o%2===1;if(o>0&&o%2===0&&e.includes(`
12
+ `)||(e.endsWith("```\n")||e.endsWith("```"))&&o%2===0)return e;let r=e.match(ht);if(r&&!s){let n=r[2];if(!n||/^[\s_~*`]*$/.test(n))return e;if(Nt(e)%2===1)return`${e}\``}return e},It=e=>{let t=e.match(ft);if(t){let o=t[2];if(!o||/^[\s_~*`]*$/.test(o))return e;if((e.match(/~~/g)||[]).length%2===1)return`${e}~~`}return e};var Bt=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let o=e.indexOf("$$");return o!==-1&&e.indexOf(`
13
+ `,o)!==-1&&!e.endsWith(`
7
14
  `)?`${e}
8
- $$`:`${e}$$`},Ne=e=>{let t=0,r=e.match(/\*+/g)||[];for(let n of r){let s=n.length;s>=3&&(t+=Math.floor(s/3))}return t},He=e=>{if($(e)||/^\*{4,}$/.test(e))return e;let t=e.match(he);if(t){let r=t[2];if(!r||/^[\s_~*`]*$/.test(r))return e;if(Ne(e)%2===1)return`${e}***`}return e},G=e=>{if(!e||typeof e!="string")return e;let t=e,r=be(t);return r.endsWith("](streamdown:incomplete-link)")?r:(t=r,t=He(t),t=we(t),t=ye(t),t=$e(t),t=Te(t),t=Ie(t),t=Pe(t),t=Se(t),t)};import{jsx as M}from"react/jsx-runtime";var We=V.default||V,ze=We(_e),P=Le(["github-light","github-dark"]),K=F(({content:e,shouldParseIncompleteMarkdown:t,...r})=>{let n=S(()=>typeof e=="string"&&t?G(e.trim()):e,[e,t]);return M(ze,{...r,children:n})},(e,t)=>e.content===t.content);K.displayName="Block";var Oe=F(({children:e,allowedImagePrefixes:t,allowedLinkPrefixes:r,defaultOrigin:n,parseIncompleteMarkdown:s=!0,components:o,rehypePlugins:a,remarkPlugins:c,className:l,shikiTheme:m=["github-light","github-dark"],...u})=>{let g=Ae(),h=S(()=>U(typeof e=="string"?e:""),[e]),p=S(()=>()=>Re({errorColor:"var(--color-muted-foreground)"}),[]);return M(P.Provider,{value:m,children:M("div",{className:i("space-y-4",l),...u,children:h.map((f,b)=>M(K,{allowedImagePrefixes:t!=null?t:["*"],allowedLinkPrefixes:r!=null?r:["*"],components:{...O,...o},content:f,defaultOrigin:n,rehypePlugins:[p,...a!=null?a:[]],remarkPlugins:[Ee,[De,{singleDollarTextMath:!1}],...c!=null?c:[]],shouldParseIncompleteMarkdown:s},`${g}-block_${b}`))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme);Oe.displayName="Streamdown";export{P as ShikiThemeContext,Oe as Streamdown};
15
+ $$`:`${e}$$`},Lt=e=>{let t=0,o=e.match(/\*+/g)||[];for(let s of o){let r=s.length;r>=3&&(t+=Math.floor(r/3))}return t},St=e=>{if(x(e)||/^\*{4,}$/.test(e))return e;let t=e.match(pt);if(t){let o=t[2];if(!o||/^[\s_~*`]*$/.test(o))return e;if(Lt(e)%2===1)return`${e}***`}return e},Ae=e=>{if(!e||typeof e!="string")return e;let t=e,o=bt(t);return o.endsWith("](streamdown:incomplete-link)")?o:(t=o,t=St(t),t=kt(t),t=wt(t),t=vt(t),t=Tt(t),t=Pt(t),t=It(t),t=Bt(t),t)};import{jsx as P}from"react/jsx-runtime";var qt=qe.default||qe,Dt=qt(Ht),O=J(["github-light","github-dark"]),z=J(void 0),H=J(!0),Et={singleDollarTextMath:!1},_t={},Ee=De(({content:e,shouldParseIncompleteMarkdown:t,...o})=>{let s=X(()=>typeof e=="string"&&t?Ae(e.trim()):e,[e,t]);return P(Dt,{...o,children:s})},(e,t)=>e.content===t.content);Ee.displayName="Block";var Ot=De(({children:e,allowedImagePrefixes:t=["*"],allowedLinkPrefixes:o=["*"],defaultOrigin:s,parseIncompleteMarkdown:r=!0,components:n,rehypePlugins:a,remarkPlugins:l,className:i,shikiTheme:c=["github-light","github-dark"],mermaidConfig:m,controls:h=!0,...g})=>{let u=$t(),f=X(()=>je(typeof e=="string"?e:""),[e]),w=X(()=>()=>xt({errorColor:"var(--color-muted-foreground)"}),[]);return P(O.Provider,{value:c,children:P(z.Provider,{value:m,children:P(H.Provider,{value:h,children:P("div",{className:d("space-y-4",i),...g,children:f.map((v,M)=>P(Ee,{allowedImagePrefixes:t,allowedLinkPrefixes:o,components:{...xe,...n},content:v,defaultOrigin:s,rehypePlugins:[jt,w,...a!=null?a:[]],remarkPlugins:[[Rt,_t],[At,Et],...l!=null?l:[]],shouldParseIncompleteMarkdown:r},`${u}-block_${M}`))})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme);Ot.displayName="Streamdown";export{H as ControlsContext,z as MermaidConfigContext,O as ShikiThemeContext,Ot as Streamdown};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamdown",
3
- "version": "1.1.10",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -47,9 +47,10 @@
47
47
  "katex": "^0.16.22",
48
48
  "lucide-react": "^0.542.0",
49
49
  "marked": "^16.2.1",
50
- "mermaid": "^11.10.1",
50
+ "mermaid": "^11.11.0",
51
51
  "react-markdown": "^10.1.0",
52
52
  "rehype-katex": "^7.0.1",
53
+ "rehype-raw": "^7.0.0",
53
54
  "remark-gfm": "^4.0.1",
54
55
  "remark-math": "^6.0.0",
55
56
  "shiki": "^3.12.2",