@supermanzm/streamdown 2.5.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 ADDED
@@ -0,0 +1,148 @@
1
+ ```markdown
2
+ # Streamdown
3
+
4
+ `react-markdown` 的即插即用替代品,专为 AI 驱动的流式输出设计。
5
+
6
+ [![npm 版本](https://img.shields.io/npm/v/streamdown)](https://www.npmjs.com/package/streamdown)
7
+
8
+ ## 概述
9
+
10
+ 格式化 Markdown 很简单,但在对它进行分词和流式传输时,会出现新的挑战。Streamdown 专为处理 AI 模型流式传输 Markdown 内容的独特需求而构建,即使面对不完整或未终止的 Markdown 块,也能提供流畅的格式化。
11
+
12
+ Streamdown 为 [AI Elements Message](https://ai-sdk.dev/elements/components/message) 组件提供支持,但也可以作为独立包安装,用于您自己的流式传输需求。
13
+
14
+ ## 特性
15
+
16
+ - 🚀 **即插即用替代品** - 可直接替换 `react-markdown`
17
+ - 🔄 **流式优化** - 优雅地处理不完整的 Markdown
18
+ - 🎨 **未终止块解析** - 结合 `remend` 构建,提供更好的流式质量
19
+ - 📊 **GitHub Flavored Markdown** - 支持表格、任务列表和删除线
20
+ - 🔢 **数学公式渲染** - 通过 KaTeX 渲染 LaTeX 公式
21
+ - 📈 **Mermaid 图表** - 将 Mermaid 图表作为代码块渲染,并提供渲染按钮
22
+ - 🎯 **代码语法高亮** - 使用 Shiki 提供美观的代码块
23
+ - 🛡️ **安全优先** - 使用 `rehype-harden` 构建,实现安全渲染
24
+ - ⚡ **性能优化** - 采用 Memoized 渲染,实现高效更新
25
+
26
+ ## 安装
27
+
28
+ ```bash
29
+ npm i streamdown
30
+ ```
31
+
32
+ 然后,更新您的 Tailwind `globals.css` 文件,加入以下内容,以便 Tailwind 能够检测到 Streamdown 使用的工具类。
33
+
34
+ ```css
35
+ @source "../node_modules/streamdown/dist/*.js";
36
+ ```
37
+
38
+ 路径必须是相对于您的 CSS 文件到包含 `streamdown` 的 `node_modules` 文件夹的相对路径。在标准的 Next.js 项目中(`globals.css` 位于 `app/` 目录),上面的默认路径应该可以正常工作。
39
+
40
+ 如果您安装了 Streamdown 的可选插件,请从相关插件文档(`/docs/plugins/code`、`/docs/plugins/cjk`、`/docs/plugins/math`、`/docs/plugins/mermaid`)中添加对应的 `@source` 行。只为实际安装的包添加插件 `@source` 条目。
41
+
42
+ 示例:
43
+
44
+ ```css
45
+ @source "../node_modules/@streamdown/code/dist/*.js";
46
+ ```
47
+
48
+ ### Monorepo 设置
49
+
50
+ 在 monorepo(npm workspaces、Turbo、pnpm 等)中,依赖通常会被提升(hoisted)到根目录的 `node_modules`。您需要调整相对路径指向那里:
51
+
52
+ ```
53
+ monorepo/
54
+ ├── node_modules/streamdown/ ← 提升到这里
55
+ ├── apps/
56
+ │ └── web/
57
+ │ └── app/
58
+ │ └── globals.css ← 您的 CSS 文件
59
+ ```
60
+
61
+ ```css
62
+ /* apps/web/app/globals.css → 向上 3 级到达根 node_modules */
63
+ @source "../../../node_modules/streamdown/dist/*.js";
64
+ ```
65
+
66
+ 根据您的 CSS 文件相对于根 `node_modules` 的位置,调整 `../` 的数量。如果安装了 Streamdown 插件,仅在实际安装这些包时添加对应的 `@source` 条目。
67
+
68
+ ### CSS 自定义属性(设计令牌)
69
+
70
+ Streamdown 组件基于 shadcn/ui 的设计系统构建,依赖 CSS 自定义属性来处理颜色、圆角和间距。如果未定义这些变量,组件可能会出现背景缺失、边框缺失或间距错误的问题。
71
+
72
+ 如果您已经在使用 shadcn/ui,这些变量会自动设置。如果没有,请将以下最小配置添加到您的全局 CSS 中:
73
+
74
+ ```css
75
+ :root {
76
+ --background: oklch(1 0 0);
77
+ --foreground: oklch(0.145 0 0);
78
+ --card: oklch(1 0 0);
79
+ --card-foreground: oklch(0.145 0 0);
80
+ --muted: oklch(0.97 0 0);
81
+ --muted-foreground: oklch(0.556 0 0);
82
+ --border: oklch(0.922 0 0);
83
+ --input: oklch(0.922 0 0);
84
+ --primary: oklch(0.205 0 0);
85
+ --primary-foreground: oklch(0.985 0 0);
86
+ --radius: 0.625rem;
87
+ }
88
+
89
+ .dark {
90
+ --background: oklch(0.145 0 0);
91
+ --foreground: oklch(0.985 0 0);
92
+ --card: oklch(0.205 0 0);
93
+ --card-foreground: oklch(0.985 0 0);
94
+ --muted: oklch(0.269 0 0);
95
+ --muted-foreground: oklch(0.708 0 0);
96
+ --border: oklch(0.269 0 0);
97
+ --input: oklch(0.269 0 0);
98
+ --primary: oklch(0.985 0 0);
99
+ --primary-foreground: oklch(0.205 0 0);
100
+ --radius: 0.625rem;
101
+ }
102
+ ```
103
+
104
+ 您也可以使用 shadcn/ui 的[主题生成器](https://ui.shadcn.com/themes)创建自定义配色,并将生成的 CSS 变量直接复制到您的项目中。
105
+
106
+ ## 使用方法
107
+
108
+ 以下是在 React 应用中使用 Streamdown 结合 AI SDK 的示例:
109
+
110
+ ```tsx
111
+ import { useChat } from "@ai-sdk/react";
112
+ import { Streamdown } from "streamdown";
113
+ import { code } from "@streamdown/code";
114
+ import { mermaid } from "@streamdown/mermaid";
115
+ import { math } from "@streamdown/math";
116
+ import { cjk } from "@streamdown/cjk";
117
+ import "katex/dist/katex.min.css";
118
+ import "streamdown/styles.css";
119
+
120
+ export default function Chat() {
121
+ const { messages, status } = useChat();
122
+
123
+ return (
124
+ <div>
125
+ {messages.map(message => (
126
+ <div key={message.id}>
127
+ {message.role === 'user' ? 'User: ' : 'AI: '}
128
+ {message.parts.map((part, index) =>
129
+ part.type === 'text' ? (
130
+ <Streamdown
131
+ key={index}
132
+ animated
133
+ plugins={{ code, mermaid, math, cjk }}
134
+ isAnimating={status === 'streaming'}
135
+ >
136
+ {part.text}
137
+ </Streamdown>
138
+ ) : null,
139
+ )}
140
+ </div>
141
+ ))}
142
+ </div>
143
+ );
144
+ }
145
+ ```
146
+
147
+ 更多信息请参阅[文档](https://streamdown.ai/docs)。
148
+ ```
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import {createContext,memo,useContext,useMemo,lazy,isValidElement,useId,useTransition,useRef,useEffect,useState,cloneElement,createElement,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Yo from'rehype-raw';import kn,{defaultSchema}from'rehype-sanitize';import $s from'remark-gfm';import Ws from'remend';import {visitParents,SKIP}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import gs from'remark-parse';import bs from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var Bn=300,An="300px",On=500;function Rt(e={}){let{immediate:t=false,debounceDelay:o=Bn,rootMargin:n=An,idleTimeout:r=On}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),d=useRef(null),c=useMemo(()=>u=>{let f=Date.now();return window.setTimeout(()=>{u({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-f))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(u,f)=>window.requestIdleCallback(u,f):c,[c]),m=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?u=>window.cancelIdleCallback(u):u=>{clearTimeout(u);},[]);return useEffect(()=>{if(t){a(true);return}let u=l.current;if(!u)return;i.current&&(clearTimeout(i.current),i.current=null),d.current&&(m(d.current),d.current=null);let f=()=>{i.current&&(clearTimeout(i.current),i.current=null),d.current&&(m(d.current),d.current=null);},h=v=>{d.current=p(w=>{w.timeRemaining()>0||w.didTimeout?(a(true),v.disconnect()):d.current=p(()=>{a(true),v.disconnect();},{timeout:r/2});},{timeout:r});},b=v=>{f(),i.current=window.setTimeout(()=>{var M,H;let w=v.takeRecords();(w.length===0||(H=(M=w.at(-1))==null?void 0:M.isIntersecting)!=null&&H)&&h(v);},o);},g=(v,w)=>{v.isIntersecting?b(w):f();},T=new IntersectionObserver(v=>{for(let w of v)g(w,T);},{rootMargin:n,threshold:0});return T.observe(u),()=>{i.current&&clearTimeout(i.current),d.current&&m(d.current),T.disconnect();}},[t,o,n,r,m,p]),{shouldRender:s,containerRef:l}}var St=/\s/,Fn=/^\s+$/,zn=new Set(["code","pre","svg","math","annotation"]),_n=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",qn=e=>e.some(t=>_n(t)&&zn.has(t.tagName)),$n=e=>{let t=[],o="",n=false;for(let r of e){let s=St.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},Wn=e=>{let t=[],o="";for(let n of e)St.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Zn=(e,t,o,n,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;return s&&(a+=`;--sd-delay:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},Xn=(e,t,o,n,r)=>{let s=t.at(-1);if(!(s&&"children"in s))return;if(qn(t))return SKIP;let a=s,l=a.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let d=o.sep==="char"?Wn(i):$n(i),c=n.prevContentLength,p=d.map(m=>{let u=r.count;if(r.count+=m.length,Fn.test(m))return {type:"text",value:m};let f=c>0&&u<c,h=f?0:r.newIndex++*o.stagger;return Zn(m,o.animation,o.duration,o.easing,f,h)});return a.children.splice(l,1,...p),l+p.length},Jn=0;function be(e){var s,a,l,i,d;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(d=e==null?void 0:e.stagger)!=null?d:40},o={prevContentLength:0,lastRenderCharCount:0},n=Jn++,r=()=>c=>{let p={count:0,newIndex:0};visitParents(c,"text",(m,u)=>Xn(m,u,t,o,p)),o.lastRenderCharCount=p.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setPrevContentLength(c){o.prevContentLength=c;},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c}}}be();var et=createContext(false),tt=()=>useContext(et);var he=(...e)=>twMerge(clsx(e)),Gn=(e,t)=>{if(!e||!t)return t;let o=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(o)?n:`${e}:${n}`).join(" ")},Dt=e=>e?(...t)=>Gn(e,twMerge(clsx(t))):he,W=(e,t,o)=>{let n=typeof t=="string"&&o.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([n+t],{type:o}):t,s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s);};var Ee=createContext(he),y=()=>useContext(Ee);var tr=he("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),or=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),s=o.slice(n+1).trim();r&&s&&(t[r]=s);}}return t},At=memo(({children:e,result:t,language:o,className:n,startLine:r,lineNumbers:s=true,...a})=>{let l=y(),i=useMemo(()=>l(tr),[l]),d=useMemo(()=>{let c={};return t.bg&&(c["--sdm-bg"]=t.bg),t.fg&&(c["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(c,or(t.rootStyle)),c},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:l(n,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",...a,children:jsx("pre",{className:l(n,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:d,children:jsx("code",{className:s?l("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&r&&r>1?{counterReset:`line ${r-1}`}:void 0,children:t.tokens.map((c,p)=>jsx("span",{className:s?i:void 0,children:c.length===0||c.length===1&&c[0].content===""?`
3
+ `:c.map((m,u)=>{let f={},h=!!m.bgColor;if(m.color&&(f["--sdm-c"]=m.color),m.bgColor&&(f["--sdm-tbg"]=m.bgColor),m.htmlStyle)for(let[b,g]of Object.entries(m.htmlStyle))b==="color"?f["--sdm-c"]=g:b==="background-color"?(f["--sdm-tbg"]=g,h=true):f[b]=g;return jsx("span",{className:l("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",h&&"bg-[var(--sdm-tbg)]",h&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:f,...m.htmlAttrs,children:m.content},u)})},p))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var ot=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=y();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var nt=createContext({code:""}),He=()=>useContext(nt);var rt=({language:e})=>{let t=y();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var lr=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
+ `;)t--;return e.slice(0,t)},cr=lazy(()=>import('./highlighted-body-OFNGDK62.js').then(e=>({default:e.HighlightedCodeBlockBody}))),st=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=y(),d=useMemo(()=>lr(e),[e]),c=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
5
+ `).map(p=>[{content:p,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(nt.Provider,{value:{code:e},children:jsxs(ot,{isIncomplete:r,language:t,children:[jsx(rt,{language:t}),n?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,jsx(Suspense,{fallback:jsx(At,{className:o,language:t,lineNumbers:a,result:c,startLine:s,...l}),children:jsx(cr,{className:o,code:d,language:t,lineNumbers:a,raw:c,startLine:s,...l})})]})})};var jt=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),Ft=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),zt=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),_t=e=>jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),qt=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),$t=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Wt=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Zt=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),Xt=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Jt=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var we={CheckIcon:jt,CopyIcon:Ft,DownloadIcon:zt,ExternalLinkIcon:Zt,Loader2Icon:_t,Maximize2Icon:qt,RotateCcwIcon:$t,XIcon:Wt,ZoomInIcon:Xt,ZoomOutIcon:Jt},Ut=createContext(we),fr=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},at=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...we,...e}:we);fr(o.current,e)||(o.current=e,n.current=e?{...we,...e}:we);let r=n.current;return jsx(Ut.Provider,{value:r,children:t})},L=()=>useContext(Ut);var De={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},Be=createContext(De),D=()=>useContext(Be);var Ae=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=y(),[i,d]=useState(false),c=useRef(0),{code:p}=He(),{isAnimating:m}=useContext(R),u=D(),f=s!=null?s:p,h=async()=>{var T;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(f),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),o));}catch(v){t==null||t(v);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let b=L(),g=i?b.CheckIcon:b.CopyIcon;return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:m,onClick:h,title:u.copyCode,type:"button",...a,children:n!=null?n:jsx(g,{size:14})})};var Yt={"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"},it=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=y(),{code:i}=He(),{isAnimating:d}=useContext(R),c=D(),p=L(),m=s!=null?s:i,f=`file.${o&&o in Yt?Yt[o]:"txt"}`,h="text/plain",b=()=>{try{W(f,m,h),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:d,onClick:b,title:c.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var Oe=()=>{let{Loader2Icon:e}=L(),t=y();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var Mr=/\.[^/.]+$/,oo=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,...a})=>{let{DownloadIcon:l}=L(),i=y(),d=useRef(null),[c,p]=useState(false),[m,u]=useState(false),f=D(),h=a.width!=null||a.height!=null,b=(c||h)&&!m,g=m&&!h;useEffect(()=>{let P=d.current;if(P!=null&&P.complete){let M=P.naturalWidth>0;p(M),u(!M);}},[]);let T=useCallback(P=>{p(true),u(false),r==null||r(P);},[r]),v=useCallback(P=>{p(false),u(true),s==null||s(P);},[s]),w=async()=>{if(o)try{let M=await(await fetch(o)).blob(),S=new URL(o,window.location.origin).pathname.split("/").pop()||"",F=S.split(".").pop(),j=S.includes(".")&&F!==void 0&&F.length<=4,z="";if(j)z=S;else {let B=M.type,_="png";B.includes("jpeg")||B.includes("jpg")?_="jpg":B.includes("png")?_="png":B.includes("svg")?_="svg":B.includes("gif")?_="gif":B.includes("webp")&&(_="webp"),z=`${(n||S||"image").replace(Mr,"")}.${_}`;}W(z,M,M.type);}catch(P){window.open(o,"_blank");}};return o?jsxs("div",{className:i("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:i("max-w-full rounded-lg",g&&"hidden",t),"data-streamdown":"image",onError:v,onLoad:T,ref:d,src:o,...a}),g&&jsx("span",{className:i("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:f.imageNotAvailable}),jsx("div",{className:i("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),b&&jsx("button",{className:i("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:w,title:f.downloadImage,type:"button",children:jsx(l,{size:14})})]}):null};var ke=0,le=()=>{ke+=1,ke===1&&(document.body.style.overflow="hidden");},ce=()=>{ke=Math.max(0,ke-1),ke===0&&(document.body.style.overflow="");};var so=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=L(),i=y(),[d,c]=useState(false),p=D(),m=useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3);}catch(f){}},[e]),u=useCallback(()=>{n(),o();},[n,o]);return useEffect(()=>{if(t){le();let f=h=>{h.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),ce();}}},[t,o]),t?jsx("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:f=>{f.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:i("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[jsx("button",{className:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:p.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i("flex flex-col gap-2"),children:[jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:i("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i("flex gap-2"),children:[jsx("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:m,type:"button",children:d?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:u,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:p.openLink})]})]})]})}):null};var Ve=createContext(null),ct=()=>useContext(Ve),Li=()=>{var t;let e=ct();return (t=e==null?void 0:e.code)!=null?t:null},de=()=>{var t;let e=ct();return (t=e==null?void 0:e.mermaid)!=null?t:null};var ao=e=>{var o;let t=ct();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var io=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let i=document.createElement("canvas"),d=l.width*o,c=l.height*o;i.width=d,i.height=c;let p=i.getContext("2d");if(!p){s(new Error("Failed to create 2D canvas context for PNG export"));return}p.drawImage(l,0,0,d,c),i.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=a;})};var co=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=y(),[l,i]=useState(false),d=useRef(null),{isAnimating:c}=useContext(R),p=L(),m=de(),u=D(),f=async h=>{try{if(h==="mmd"){W("diagram.mmd",e,"text/plain"),i(!1),n==null||n(h);return}if(!m){s==null||s(new Error("Mermaid plugin not available"));return}let b=m.getMermaid(r),g=e.split("").reduce((w,P)=>(w<<5)-w+P.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:v}=await b.render(T,e);if(!v){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(h==="svg"){W("diagram.svg",v,"image/svg+xml"),i(!1),n==null||n(h);return}if(h==="png"){let w=await io(v);W("diagram.png",w,"image/png"),n==null||n(h),i(!1);return}}catch(b){s==null||s(b);}};return useEffect(()=>{let h=b=>{let g=b.composedPath();d.current&&!g.includes(d.current)&&i(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[]),jsxs("div",{className:a("relative"),ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:c,onClick:()=>i(!l),title:u.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("svg"),title:u.downloadDiagramAsSvg,type:"button",children:u.mermaidFormatSvg}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("png"),title:u.downloadDiagramAsPng,type:"button",children:u.mermaidFormatPng}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("mmd"),title:u.downloadDiagramAsMmd,type:"button",children:u.mermaidFormatMmd})]}):null]})};var fo=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=L(),i=y(),[d,c]=useState(false),{isAnimating:p,controls:m}=useContext(R),u=D(),f=(()=>{if(typeof m=="boolean")return m;let b=m.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),h=()=>{c(!d);};return useEffect(()=>{if(d){le();let b=g=>{g.key==="Escape"&&c(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),ce();}}},[d]),useEffect(()=>{d?o==null||o():n&&n();},[d,o,n]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:h,title:u.viewFullscreen,type:"button",...s,children:jsx(a,{size:14})}),d?createPortal(jsxs("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:h,onKeyDown:b=>{b.key==="Escape"&&h();},role:"button",tabIndex:0,children:[jsx("button",{className:i("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:u.exitFullscreen,type:"button",children:jsx(l,{size:20})}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(po,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:f})})]}),document.body):null]})};var ue=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let l of n)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],d=l.querySelectorAll("td");for(let c of d)i.push(((a=c.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},ne=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,d=false;for(let c of l){if(c==='"'){i=true,d=true;break}(c===","||c===`
6
+ `)&&(i=true);}return i?d?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let l of o)s[a]=l.map(n).join(","),a+=1;return s.join(`
7
+ `)},dt=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let c of l)if(c===" "||c===`
8
+ `||c==="\r"){i=true;break}if(!i)return l;let d=[];for(let c of l)c===" "?d.push("\\t"):c===`
9
+ `?d.push("\\n"):c==="\r"?d.push("\\r"):d.push(c);return d.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let l of o)s[a]=l.map(n).join(" "),a+=1;return s.join(`
10
+ `)},je=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):o.push(n);return o.join("")},re=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(l=>je(l));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let d=0;d<t.length;d+=1)i[d]=d<l.length?je(l[d]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(d=>je(d));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
11
+ `)};var Te=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=y(),[a,l]=useState(false),[i,d]=useState(false),c=useRef(null),p=useRef(0),{isAnimating:m}=useContext(R),u=D(),f=async g=>{var T,v;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.write)){n==null||n(new Error("Clipboard API not available"));return}try{let w=(v=c.current)==null?void 0:v.closest('[data-streamdown="table-wrapper"]'),P=w==null?void 0:w.querySelector("table");if(!P){n==null||n(new Error("Table not found"));return}let M=ue(P),F=({csv:ne,tsv:dt,md:re}[g]||re)(M),j=new ClipboardItem({"text/plain":new Blob([F],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([j]),d(!0),l(!1),o==null||o(g),p.current=window.setTimeout(()=>d(!1),r);}catch(w){n==null||n(w);}};useEffect(()=>{let g=T=>{let v=T.composedPath();c.current&&!v.includes(c.current)&&l(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g),window.clearTimeout(p.current);}},[]);let h=L(),b=i?h.CheckIcon:h.CopyIcon;return jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>l(!a),title:u.copyTable,type:"button",children:e!=null?e:jsx(b,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("md"),title:u.copyTableAsMarkdown,type:"button",children:u.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("csv"),title:u.copyTableAsCsv,type:"button",children:u.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("tsv"),title:u.copyTableAsTsv,type:"button",children:u.tableFormatTsv})]}):null]})};var Wr=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=y(),{isAnimating:l}=useContext(R),i=D(),d=L(),c=p=>{try{let u=p.currentTarget.closest('[data-streamdown="table-wrapper"]'),f=u==null?void 0:u.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let h=ue(f),b="",g="",T="";switch(r){case "csv":b=ne(h),g="text/csv",T="csv";break;case "markdown":b=re(h),g="text/markdown",T="md";break;default:b=ne(h),g="text/csv",T="csv";}W(`${s||"table"}.${T}`,b,g),o==null||o();}catch(m){n==null||n(m);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:c,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})})},Pe=({children:e,className:t,onDownload:o,onError:n})=>{let r=y(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(R),d=D(),c=L(),p=m=>{var u;try{let f=(u=l.current)==null?void 0:u.closest('[data-streamdown="table-wrapper"]'),h=f==null?void 0:f.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let b=ue(h),g=m==="csv"?ne(b):re(b);W(`table.${m==="csv"?"csv":"md"}`,g,m==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(m);}catch(f){n==null||n(f);}};return useEffect(()=>{let m=u=>{let f=u.composedPath();l.current&&!f.includes(l.current)&&a(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>a(!s),title:d.downloadTable,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("csv"),title:d.downloadTableAsCsv,type:"button",children:d.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("markdown"),title:d.downloadTableAsMarkdown,type:"button",children:d.tableFormatMarkdown})]}):null]})};var Co=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=L(),a=y(),[l,i]=useState(false),{isAnimating:d}=useContext(R),c=D(),p=()=>{i(true);},m=()=>{i(false);};return useEffect(()=>{if(l){le();let u=f=>{f.key==="Escape"&&i(false);};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u),ce();}}},[l]),jsxs(Fragment,{children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:d,onClick:p,title:c.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":c.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:m,onKeyDown:u=>{u.key==="Escape"&&m();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:u=>u.stopPropagation(),onKeyDown:u=>u.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(Te,{}):null,n?jsx(Pe,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:m,title:c.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var vo=({children:e,className:t,showControls:o,showCopy:n=true,showDownload:r=true,showFullscreen:s=true,...a})=>{let l=y(),i=o&&n,d=o&&r,c=o&&s,p=i||d||c;return jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[p?jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[i?jsx(Te,{}):null,d?jsx(Pe,{}):null,c?jsx(Co,{showCopy:i,showDownload:d,children:e}):null]}):null,jsx("div",{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:jsx("table",{className:l("w-full divide-y divide-border",t),"data-streamdown":"table",...a,children:e})})]})};var es=/startLine=(\d+)/,ts=/\bnoLineNumbers\b/,os=lazy(()=>import('./mermaid-GHXKKRXX.js').then(e=>({default:e.Mermaid}))),ns=/language-([^\s]+)/;function qe(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function E(e,t){return e.className===t.className&&qe(e.node,t.node)}var ft=(e,t)=>typeof e=="boolean"?e:e[t]!==false,pt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},To=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},Fe=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},bt=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>E(e,t));bt.displayName="MarkdownOl";var Po=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("li",{className:r("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e})},(e,t)=>e.className===t.className&&qe(e.node,t.node));Po.displayName="MarkdownLi";var Mo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>E(e,t));Mo.displayName="MarkdownUl";var Io=memo(({className:e,node:t,...o})=>{let n=y();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>E(e,t));Io.displayName="MarkdownHr";var No=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>E(e,t));No.displayName="MarkdownStrong";var rs=({children:e,className:t,href:o,node:n,...r})=>{let s=y(),{linkSafety:a}=useContext(R),[l,i]=useState(false),d=o==="streamdown:incomplete-link",c=useCallback(async f=>{if(!(!(a!=null&&a.enabled&&o)||d)){if(f.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,d]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),m=useCallback(()=>{i(false);},[]),u={url:o!=null?o:"",isOpen:l,onClose:m,onConfirm:p};return a!=null&&a.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",onClick:c,type:"button",children:e}),a.renderModal?a.renderModal(u):jsx(so,{...u})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},Lo=memo(rs,(e,t)=>E(e,t)&&e.href===t.href);Lo.displayName="MarkdownA";var Ro=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>E(e,t));Ro.displayName="MarkdownH1";var So=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>E(e,t));So.displayName="MarkdownH2";var Eo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>E(e,t));Eo.displayName="MarkdownH3";var Ho=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>E(e,t));Ho.displayName="MarkdownH4";var Do=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>E(e,t));Do.displayName="MarkdownH5";var Bo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>E(e,t));Bo.displayName="MarkdownH6";var Ao=memo(({children:e,className:t,node:o,...n})=>{let{controls:r}=useContext(R),s=ft(r,"table"),a=pt(r,"copy"),l=pt(r,"download"),i=pt(r,"fullscreen");return jsx(vo,{className:t,showControls:s,showCopy:a,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>E(e,t));Ao.displayName="MarkdownTable";var Oo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>E(e,t));Oo.displayName="MarkdownThead";var Vo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>E(e,t));Vo.displayName="MarkdownTbody";var jo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>E(e,t));jo.displayName="MarkdownTr";var Fo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>E(e,t));Fo.displayName="MarkdownTh";var zo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>E(e,t));zo.displayName="MarkdownTd";var _o=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>E(e,t));_o.displayName="MarkdownBlockquote";var qo=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>E(e,t));qo.displayName="MarkdownSup";var $o=memo(({children:e,className:t,node:o,...n})=>{let r=y();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>E(e,t));$o.displayName="MarkdownSub";var Wo=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var m,u;if(!isValidElement(i))return false;let d=Array.isArray(i.props.children)?i.props.children:[i.props.children],c=false,p=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(c=true);else if(isValidElement(f))if(((m=f.props)==null?void 0:m["data-footnote-backref"])!==void 0)p=true;else {let h=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let b of h){if(typeof b=="string"&&b.trim()!==""){c=true;break}if(isValidElement(b)&&((u=b.props)==null?void 0:u["data-footnote-backref"])===void 0){c=true;break}}}}return p&&!c},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===bt){let c=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(p=>!s(p));return c.length===0?null:{...i,props:{...i.props,children:c}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>E(e,t));Wo.displayName="MarkdownSection";var ss=({node:e,className:t,children:o,...n})=>{var S,F;let r=y(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(R),d=de(),c=tt(),p=t==null?void 0:t.match(ns),m=(S=p==null?void 0:p.at(1))!=null?S:"",u=ao(m);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let f=(F=e==null?void 0:e.properties)==null?void 0:F.metastring,h=f==null?void 0:f.match(es),b=h?Number.parseInt(h[1],10):void 0,g=b!==void 0&&b>=1?b:void 0,v=!(f?ts.test(f):false)&&i!==false,w="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?w=o.props.children:typeof o=="string"&&(w=o),u){let j=u.component;return jsx(Suspense,{fallback:jsx(Oe,{}),children:jsx(j,{code:w,isIncomplete:c,language:m,meta:f})})}if(m==="mermaid"&&d){let j=ft(l,"mermaid"),z=Fe(l,"download"),B=Fe(l,"copy"),_=Fe(l,"fullscreen"),Q=Fe(l,"panZoom"),U=j&&(z||B||_);return jsx(Suspense,{fallback:jsx(Oe,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),U?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[z?jsx(co,{chart:w,config:a==null?void 0:a.config}):null,B?jsx(Ae,{code:w}):null,_?jsx(fo,{chart:w,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(os,{chart:w,config:a==null?void 0:a.config,showControls:Q})})]})})}let P=ft(l,"code"),M=To(l,"download"),H=To(l,"copy");return jsx(st,{className:t,code:w,isIncomplete:c,language:m,lineNumbers:v,startLine:g,children:P?jsxs(Fragment,{children:[M?jsx(it,{code:w,language:m}):null,H?jsx(Ae,{}):null]}):null})},Zo=memo(ss,(e,t)=>e.className===t.className&&qe(e.node,t.node));Zo.displayName="MarkdownCode";var Xo=memo(oo,(e,t)=>e.className===t.className&&qe(e.node,t.node));Xo.displayName="MarkdownImg";var Jo=memo(({children:e,node:t,...o})=>{let r=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(r.length===1&&isValidElement(r[0])){let s=r[0].props.node,a=s==null?void 0:s.tagName;if(a==="img")return jsx(Fragment,{children:e});if(a==="code"&&"data-block"in r[0].props)return jsx(Fragment,{children:e})}return jsx("p",{...o,children:e})},(e,t)=>E(e,t));Jo.displayName="MarkdownParagraph";var Ko={ol:bt,li:Po,ul:Mo,hr:Io,strong:No,a:Lo,h1:Ro,h2:So,h3:Eo,h4:Ho,h5:Do,h6:Bo,table:Ao,thead:Oo,tbody:Vo,tr:jo,th:Fo,td:zo,blockquote:_o,code:Zo,img:Xo,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:qo,sub:$o,p:Jo,section:Wo};var as=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,is=/\p{L}/u;function $e(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(as.test(o))return "rtl";if(is.test(o))return "ltr"}return "ltr"}var ls=/^[ \t]{0,3}(`{3,}|~{3,})/,cs=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,ht=e=>{let t=e.split(`
12
+ `),o=null,n=0;for(let r of t){let s=ls.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null},Uo=e=>{let t=e.split(`
13
+ `);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&cs.test(n))return true}return false};var Go=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var Qo=[],en={allowDangerousHtml:true},We=new WeakMap,wt=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let p="default";return this.keyCache.set(t,p),p}let a=p=>{if(!p||p.length===0)return "";let m="";for(let u=0;u<p.length;u+=1){let f=p[u];if(u>0&&(m+=","),Array.isArray(f)){let[h,b]=f;if(typeof h=="function"){let g=We.get(h);g||(g=h.name,We.set(h,g)),m+=g;}else m+=String(h);m+=":",m+=JSON.stringify(b);}else if(typeof f=="function"){let h=We.get(f);h||(h=f.name,We.set(f,h)),m+=h;}else m+=String(f);}return m},l=a(n),i=a(r),d=s?JSON.stringify(s):"",c=`${i}::${l}::${d}`;return this.keyCache.set(t,c),c}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},tn=new wt,Ct=e=>{let t=ws(e),o=e.children||"",n=t.runSync(t.parse(o),o);return Ps(n,e)},ws=e=>{let t=tn.get(e);if(t)return t;let o=ks(e);return tn.set(e,o),o},Cs=e=>e.some(t=>Array.isArray(t)?t[0]===Yo:t===Yo),ks=e=>{let t=e.rehypePlugins||Qo,o=e.remarkPlugins||Qo,n=Cs(t)?o:[...o,Go],r=e.remarkRehypeOptions?{...en,...e.remarkRehypeOptions}:en;return unified().use(gs).use(n).use(bs,r).use(t)},on=e=>e,vs=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},xs=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],s=urlAttributes[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},Ts=(e,t,o,n,r,s)=>{let a=false;return n?a=!n.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,o)),a},Ps=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let d=l||on;visit(e,(c,p,m)=>{if(c.type==="raw"&&m&&typeof p=="number")return vs(m,p,s,c.value),p;if(c.type==="element"&&(xs(c,d),Ts(c,p,m,n,r,o)&&m&&typeof p=="number"))return a&&c.children?m.children.splice(p,1,...c.children):m.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Is=/\[\^[\w-]{1,200}\](?!:)/,Ns=/\[\^[\w-]{1,200}\]:/;var Ls=/<(\w+)[\s>]/,Rs=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),nn=new Map,rn=new Map,Ss=e=>{let t=e.toLowerCase(),o=nn.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return nn.set(t,n),n},Es=e=>{let t=e.toLowerCase(),o=rn.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return rn.set(t,n),n},sn=(e,t)=>{if(Rs.has(t.toLowerCase()))return 0;let o=e.match(Ss(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},an=(e,t)=>{let o=e.match(Es(t));return o?o.length:0},Hs=e=>{let t=0;for(let o=0;o<e.length-1;o+=1)e[o]==="$"&&e[o+1]==="$"&&(t+=1,o+=1);return t},kt=e=>{let t=Is.test(e),o=Ns.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],s=[],a=false;for(let l of n){let i=l.raw,d=r.length;if(s.length>0){r[d-1]+=i;let c=s.at(-1),p=sn(i,c),m=an(i,c);for(let u=0;u<p;u+=1)s.push(c);for(let u=0;u<m;u+=1)s.length>0&&s.at(-1)===c&&s.pop();continue}if(l.type==="html"&&l.block){let c=i.match(Ls);if(c){let p=c[1],m=sn(i,p),u=an(i,p);m>u&&s.push(p);}}if(d>0&&!a){let c=r[d-1];if(Hs(c)%2===1){r[d-1]=c+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r};var ln=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{if(!l.includes(`
14
+
15
+ `))return a+l+i;let d=l.replace(/\n\n/g,`
16
+ <!---->
17
+ `),c=(d.startsWith(`
18
+ `)?"":`
19
+ `)+d+(d.endsWith(`
20
+ `)?"":`
21
+ `);return `${a}${c}${i}
22
+
23
+ `});}return o};var Ds=/([\\`*_~[\]|])/g,Bs=e=>e.replace(Ds,"\\$1"),cn=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let d=Bs(l).replace(/\n\n/g,"&#10;&#10;");return a+d+i});}return o};var dn=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(dn).join(""):"",mn=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{if(o.has(n.tagName.toLowerCase())){let r=dn(n);n.children=r?[{type:"text",value:r}]:[];}});};var un=()=>e=>{visit(e,"code",t=>{var o,n;t.meta&&(t.data=(o=t.data)!=null?o:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta});});};var Zs=/^[ \t]*<[\w!/?-]/,Xs=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Js=e=>typeof e!="string"||e.length===0||!Zs.test(e)?e:e.replace(Xs,"$1"),bn,hn,yn,wn,Ze={...defaultSchema,protocols:{...defaultSchema.protocols,href:[...(hn=(bn=defaultSchema.protocols)==null?void 0:bn.href)!=null?hn:[],"tel"]},attributes:{...defaultSchema.attributes,code:[...(wn=(yn=defaultSchema.attributes)==null?void 0:yn.code)!=null?wn:[],"metastring"]}},xt={raw:Yo,sanitize:[kn,Ze],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Ks={gfm:[$s,{}],codeMeta:un},gn=Object.values(xt),Us=Object.values(Ks),Gs={block:" \u258B",circle:" \u25CF"},vn=["github-light","github-dark"],xn={enabled:true},Ys={shikiTheme:vn,controls:true,isAnimating:false,lineNumbers:true,mode:"streaming",mermaid:void 0,linkSafety:xn},R=createContext(Ys),Tn=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{if(a){let c=a.getLastRenderCharCount();a.setPrevContentLength(c);}let i=typeof e=="string"&&o?Js(e):e,d=jsx(Ct,{...l,children:i});return jsx(et.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:d}):d})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Tn.displayName="Block";var Qs=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=gn,remarkPlugins:l=Us,className:i,shikiTheme:d=vn,mermaid:c,controls:p=true,isAnimating:m=false,animated:u,BlockComponent:f=Tn,parseMarkdownIntoBlocksFn:h=kt,caret:b,plugins:g,remend:T,linkSafety:v=xn,lineNumbers:w=true,allowedTags:P,literalTagContent:M,translations:H,icons:S,prefix:F,onAnimationStart:j,onAnimationEnd:z,...B})=>{let _=useId(),[Q,U]=useTransition(),x=useMemo(()=>Dt(F),[F]),q=useRef(null),X=useRef(j),Re=useRef(z);X.current=j,Re.current=z,useEffect(()=>{var A,K,ee;if(t==="static")return;let k=q.current;if(q.current=m,k===null){m&&((A=X.current)==null||A.call(X));return}m&&!k?(K=X.current)==null||K.call(X):!m&&k&&((ee=Re.current)==null||ee.call(Re));},[m,t]);let Je=useMemo(()=>P?Object.keys(P):[],[P]),Se=useMemo(()=>{if(typeof e!="string")return "";let k=t==="streaming"&&n?Ws(e,T):e;return M&&M.length>0&&(k=cn(k,M)),Je.length>0&&(k=ln(k,Je)),k},[e,t,n,T,Je,M]),fe=useMemo(()=>h(Se),[Se,h]),[Ln,Tt]=useState(fe);useEffect(()=>{t==="streaming"&&!ge?U(()=>{Tt(fe);}):Tt(fe);},[fe,t]);let J=t==="streaming"?Ln:fe,Ke=useMemo(()=>o==="auto"?J.map($e):void 0,[J,o]),Rn=useMemo(()=>J.map((k,A)=>`${_}-${A}`),[J.length,_]),Ue=useMemo(()=>u===true?"true":u?JSON.stringify(u):"",[u]),ge=useMemo(()=>Ue?Ue==="true"?be():be(u):null,[Ue]),Pt=useMemo(()=>{var k,A;return {shikiTheme:(A=(k=g==null?void 0:g.code)==null?void 0:k.getThemes())!=null?A:d,controls:p,isAnimating:m,lineNumbers:w,mode:t,mermaid:c,linkSafety:v}},[d,p,m,w,t,c,v,g==null?void 0:g.code]),Sn=useMemo(()=>H?JSON.stringify(H):"",[H]),Mt=useMemo(()=>({...De,...H}),[Sn]),It=useMemo(()=>{let{inlineCode:k,...A}=s!=null?s:{},K={...Ko,...A};if(k){let ee=K.code;K.code=ie=>"data-block"in ie?ee?createElement(ee,ie):null:createElement(k,ie);}return K},[s]),Nt=useMemo(()=>{let k=[];return g!=null&&g.cjk&&(k=[...k,...g.cjk.remarkPluginsBefore]),k=[...k,...l],g!=null&&g.cjk&&(k=[...k,...g.cjk.remarkPluginsAfter]),g!=null&&g.math&&(k=[...k,g.math.remarkPlugin]),k},[l,g==null?void 0:g.math,g==null?void 0:g.cjk]),Lt=useMemo(()=>{var A;let k=a;if(P&&Object.keys(P).length>0&&a===gn){let K={...Ze,tagNames:[...(A=Ze.tagNames)!=null?A:[],...Object.keys(P)],attributes:{...Ze.attributes,...P}};k=[xt.raw,[kn,K],xt.harden];}return M&&M.length>0&&(k=[...k,[mn,M]]),g!=null&&g.math&&(k=[...k,g.math.rehypePlugin]),ge&&m&&(k=[...k,ge.rehypePlugin]),k},[a,g==null?void 0:g.math,ge,m,P,M]),Ge=useMemo(()=>{if(!m||J.length===0)return false;let k=J.at(-1);return ht(k)||Uo(k)},[m,J]),En=useMemo(()=>b&&m&&!Ge?{"--streamdown-caret":`"${Gs[b]}"`}:void 0,[b,m,Ge]);return t==="static"?jsx(Be.Provider,{value:Mt,children:jsx(Ve.Provider,{value:g!=null?g:null,children:jsx(R.Provider,{value:Pt,children:jsx(at,{icons:S,children:jsx(Ee.Provider,{value:x,children:jsx("div",{className:x("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?$e(Se):o,children:jsx(Ct,{components:It,rehypePlugins:Lt,remarkPlugins:Nt,...B,children:Se})})})})})})}):jsx(Be.Provider,{value:Mt,children:jsx(Ve.Provider,{value:g!=null?g:null,children:jsx(R.Provider,{value:Pt,children:jsx(at,{icons:S,children:jsx(Ee.Provider,{value:x,children:jsxs("div",{className:x("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",b&&!Ge?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),style:En,children:[J.length===0&&b&&m&&jsx("span",{}),J.map((k,A)=>{var ie;let K=A===J.length-1,ee=m&&K&&ht(k);return jsx(f,{animatePlugin:ge,components:It,content:k,dir:(ie=Ke==null?void 0:Ke[A])!=null?ie:o!=="auto"?o:void 0,index:A,isIncomplete:ee,rehypePlugins:Lt,remarkPlugins:Nt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...B},Rn[A])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Qs.displayName="Streamdown";var Nn=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:r=.1,showControls:s=true,initialZoom:a=1,fullscreen:l=false})=>{let{RotateCcwIcon:i,ZoomInIcon:d,ZoomOutIcon:c}=L(),p=y(),m=useRef(null),u=useRef(null),[f,h]=useState(a),[b,g]=useState({x:0,y:0}),[T,v]=useState(false),[w,P]=useState({x:0,y:0}),[M,H]=useState({x:0,y:0}),S=useCallback(x=>{h(q=>Math.max(o,Math.min(n,q+x)));},[o,n]),F=useCallback(()=>{S(r);},[S,r]),j=useCallback(()=>{S(-r);},[S,r]),z=useCallback(()=>{h(a),g({x:0,y:0});},[a]),B=useCallback(x=>{x.preventDefault();let q=x.deltaY>0?-r:r;S(q);},[S,r]),_=useCallback(x=>{if(x.button!==0||x.isPrimary===false)return;v(true),P({x:x.clientX,y:x.clientY}),H(b);let q=x.currentTarget;q instanceof HTMLElement&&q.setPointerCapture(x.pointerId);},[b]),Q=useCallback(x=>{if(!T)return;x.preventDefault();let q=x.clientX-w.x,X=x.clientY-w.y;g({x:M.x+q,y:M.y+X});},[T,w,M]),U=useCallback(x=>{v(false);let q=x.currentTarget;q instanceof HTMLElement&&q.releasePointerCapture(x.pointerId);},[]);return useEffect(()=>{let x=m.current;if(x)return x.addEventListener("wheel",B,{passive:false}),()=>{x.removeEventListener("wheel",B);}},[B]),useEffect(()=>{let x=u.current;if(x&&T)return document.body.style.userSelect="none",x.addEventListener("pointermove",Q,{passive:false}),x.addEventListener("pointerup",U),x.addEventListener("pointercancel",U),()=>{document.body.style.userSelect="",x.removeEventListener("pointermove",Q),x.removeEventListener("pointerup",U),x.removeEventListener("pointercancel",U);}},[T,Q,U]),jsxs("div",{className:p("relative flex flex-col",l?"h-full w-full":"min-h-28 w-full",t),ref:m,style:{cursor:T?"grabbing":"grab"},children:[s?jsxs("div",{className:p("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",l?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:f>=n,onClick:F,title:"Zoom in",type:"button",children:jsx(d,{size:16})}),jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:f<=o,onClick:j,title:"Zoom out",type:"button",children:jsx(c,{size:16})}),jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:z,title:"Reset zoom and pan",type:"button",children:jsx(i,{size:16})})]}):null,jsx("div",{className:p("flex-1 origin-center transition-transform duration-150 ease-out",l?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:_,ref:u,role:"application",style:{transform:`translate(${b.x}px, ${b.y}px) scale(${f})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var po=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=y(),[a,l]=useState(null),[i,d]=useState(false),[c,p]=useState(""),[m,u]=useState(""),[f,h]=useState(0),{mermaid:b}=useContext(R),g=de(),T=b==null?void 0:b.errorComponent,{shouldRender:v,containerRef:w}=Rt({immediate:n});if(useEffect(()=>{if(!v)return;if(!g){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),d(!0);let H=g.getMermaid(o),S=e.split("").reduce((z,B)=>(z<<5)-z+B.charCodeAt(0)|0,0),F=`mermaid-${Math.abs(S)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:j}=await H.render(F,e);p(j),u(j);}catch(H){if(!(m||c)){let S=H instanceof Error?H.message:"Failed to render Mermaid chart";l(S);}}finally{d(false);}})();},[e,o,f,v,g]),!(v||c||m))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:w});if(i&&!c&&!m)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:w,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(a&&!c&&!m){let M=()=>h(H=>H+1);return T?jsx("div",{ref:w,children:jsx(T,{chart:e,error:a,retry:M})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:w,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let P=c||m;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:w,children:jsx(Nn,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:P},role:"img"})})})};export{R as A,Tn as B,Qs as C,be as a,tt as b,At as c,ot as d,rt as e,Li as f,st as g,De as h,Ae as i,it as j,Oe as k,po as l,ue as m,ne as n,dt as o,je as p,re as q,Te as r,Wr as s,Pe as t,$e as u,on as v,kt as w,Js as x,xt as y,Ks as z};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import {A,f,c}from'./chunk-BO2N2NFS.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var R=({code:s,language:e,raw:t,className:h,startLine:d,lineNumbers:m,...p})=>{let{shikiTheme:l}=useContext(A),o=f(),[a,i]=useState(t);return useEffect(()=>{if(!o){i(t);return}let r=o.highlight({code:s,language:e,themes:l},c=>{i(c);});r&&i(r);},[s,e,l,o,t]),jsx(c,{className:h,language:e,lineNumbers:m,result:a,startLine:d,...p})};export{R as HighlightedCodeBlockBody};
@@ -0,0 +1,492 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import react__default, { SVGProps, JSX, ComponentType, HTMLAttributes, ComponentProps } from 'react';
4
+ import { MermaidConfig } from 'mermaid';
5
+ import { RemendOptions } from 'remend';
6
+ import { Pluggable, PluggableList } from 'unified';
7
+ import { Element, Parents } from 'hast';
8
+ import { Options as Options$1 } from 'remark-rehype';
9
+ import { BundledTheme, ThemeRegistrationAny, BundledLanguage } from 'shiki';
10
+ export { BundledLanguage, BundledTheme, ThemeRegistrationAny } from 'shiki';
11
+
12
+ interface AnimatePlugin {
13
+ /**
14
+ * Returns the total HAST text node character count from the last
15
+ * rehype run, then resets to 0. Use this value as the argument to
16
+ * setPrevContentLength on the next render.
17
+ */
18
+ getLastRenderCharCount: () => number;
19
+ name: "animate";
20
+ rehypePlugin: Pluggable;
21
+ /**
22
+ * Set the number of HAST text characters from a previous render.
23
+ * Characters up to this count will get duration=0ms, preventing
24
+ * re-animation of already-visible content during streaming updates.
25
+ */
26
+ setPrevContentLength: (length: number) => void;
27
+ type: "animate";
28
+ }
29
+ interface AnimateOptions {
30
+ animation?: "fadeIn" | "blurIn" | "slideUp" | (string & {});
31
+ duration?: number;
32
+ easing?: string;
33
+ sep?: "word" | "char";
34
+ stagger?: number;
35
+ }
36
+ declare function createAnimatePlugin(options?: AnimateOptions): AnimatePlugin;
37
+
38
+ type IconComponent = React.ComponentType<SVGProps<SVGSVGElement> & {
39
+ size?: number;
40
+ }>;
41
+ interface IconMap {
42
+ CheckIcon: IconComponent;
43
+ CopyIcon: IconComponent;
44
+ DownloadIcon: IconComponent;
45
+ ExternalLinkIcon: IconComponent;
46
+ Loader2Icon: IconComponent;
47
+ Maximize2Icon: IconComponent;
48
+ RotateCcwIcon: IconComponent;
49
+ XIcon: IconComponent;
50
+ ZoomInIcon: IconComponent;
51
+ ZoomOutIcon: IconComponent;
52
+ }
53
+
54
+ interface ExtraProps {
55
+ node?: Element | undefined;
56
+ }
57
+ type AllowElement = (element: Readonly<Element>, index: number, parent: Readonly<Parents> | undefined) => boolean | null | undefined;
58
+ type UrlTransform = (url: string, key: string, node: Readonly<Element>) => string | null | undefined;
59
+ type Components = {
60
+ [Key in keyof JSX.IntrinsicElements]?: ComponentType<JSX.IntrinsicElements[Key] & ExtraProps> | keyof JSX.IntrinsicElements;
61
+ } & {
62
+ inlineCode?: ComponentType<JSX.IntrinsicElements["code"] & ExtraProps>;
63
+ [key: string]: ComponentType<Record<string, unknown> & ExtraProps> | keyof JSX.IntrinsicElements | undefined;
64
+ };
65
+ interface Options {
66
+ allowElement?: AllowElement;
67
+ allowedElements?: readonly string[];
68
+ children?: string;
69
+ components?: Components;
70
+ disallowedElements?: readonly string[];
71
+ rehypePlugins?: PluggableList;
72
+ remarkPlugins?: PluggableList;
73
+ remarkRehypeOptions?: Readonly<Options$1>;
74
+ skipHtml?: boolean;
75
+ unwrapDisallowed?: boolean;
76
+ urlTransform?: UrlTransform;
77
+ }
78
+ declare const defaultUrlTransform: UrlTransform;
79
+
80
+ type ThemeInput = BundledTheme | ThemeRegistrationAny;
81
+ /**
82
+ * A single token in a highlighted line
83
+ */
84
+ interface HighlightToken {
85
+ bgColor?: string;
86
+ color?: string;
87
+ content: string;
88
+ htmlAttrs?: Record<string, string>;
89
+ htmlStyle?: Record<string, string>;
90
+ offset?: number;
91
+ }
92
+ /**
93
+ * Result from code highlighting (compatible with shiki's TokensResult)
94
+ */
95
+ interface HighlightResult {
96
+ bg?: string;
97
+ fg?: string;
98
+ rootStyle?: string | false;
99
+ tokens: HighlightToken[][];
100
+ }
101
+ /**
102
+ * Options for highlighting code
103
+ */
104
+ interface HighlightOptions {
105
+ code: string;
106
+ language: BundledLanguage;
107
+ themes: [ThemeInput, ThemeInput];
108
+ }
109
+ /**
110
+ * Plugin for code syntax highlighting (Shiki)
111
+ */
112
+ interface CodeHighlighterPlugin {
113
+ /**
114
+ * Get list of supported languages
115
+ */
116
+ getSupportedLanguages: () => BundledLanguage[];
117
+ /**
118
+ * Get the configured themes
119
+ */
120
+ getThemes: () => [ThemeInput, ThemeInput];
121
+ /**
122
+ * Highlight code and return tokens
123
+ * Returns null if highlighting not ready yet (async loading)
124
+ * Use callback for async result
125
+ */
126
+ highlight: (options: HighlightOptions, callback?: (result: HighlightResult) => void) => HighlightResult | null;
127
+ name: "shiki";
128
+ /**
129
+ * Check if language is supported
130
+ */
131
+ supportsLanguage: (language: BundledLanguage) => boolean;
132
+ type: "code-highlighter";
133
+ }
134
+ /**
135
+ * Mermaid instance interface
136
+ */
137
+ interface MermaidInstance {
138
+ initialize: (config: MermaidConfig) => void;
139
+ render: (id: string, source: string) => Promise<{
140
+ svg: string;
141
+ }>;
142
+ }
143
+ /**
144
+ * Plugin for diagram rendering (Mermaid)
145
+ */
146
+ interface DiagramPlugin {
147
+ /**
148
+ * Get the mermaid instance (initialized with optional config)
149
+ */
150
+ getMermaid: (config?: MermaidConfig) => MermaidInstance;
151
+ /**
152
+ * Language identifier for code blocks
153
+ */
154
+ language: string;
155
+ name: "mermaid";
156
+ type: "diagram";
157
+ }
158
+ /**
159
+ * Plugin for math rendering (KaTeX)
160
+ */
161
+ interface MathPlugin {
162
+ /**
163
+ * Get CSS styles for math rendering (injected into head)
164
+ */
165
+ getStyles?: () => string;
166
+ name: "katex";
167
+ /**
168
+ * Get rehype plugin for rendering math
169
+ */
170
+ rehypePlugin: Pluggable;
171
+ /**
172
+ * Get remark plugin for parsing math syntax
173
+ */
174
+ remarkPlugin: Pluggable;
175
+ type: "math";
176
+ }
177
+ /**
178
+ * Plugin for CJK text handling
179
+ */
180
+ interface CjkPlugin {
181
+ name: "cjk";
182
+ /**
183
+ * @deprecated Use remarkPluginsBefore and remarkPluginsAfter instead
184
+ * All remark plugins (for backwards compatibility)
185
+ */
186
+ remarkPlugins: Pluggable[];
187
+ /**
188
+ * Remark plugins that must run AFTER remarkGfm
189
+ * (e.g., autolink boundary splitting, strikethrough enhancements)
190
+ */
191
+ remarkPluginsAfter: Pluggable[];
192
+ /**
193
+ * Remark plugins that must run BEFORE remarkGfm
194
+ * (e.g., remark-cjk-friendly which modifies emphasis handling)
195
+ */
196
+ remarkPluginsBefore: Pluggable[];
197
+ type: "cjk";
198
+ }
199
+ interface CustomRendererProps {
200
+ code: string;
201
+ isIncomplete: boolean;
202
+ language: string;
203
+ /** Raw metastring from the code fence (everything after the language identifier).
204
+ * e.g. ```rust {1} title="foo" → meta = '{1} title="foo"'
205
+ * Undefined when no metastring is present. */
206
+ meta?: string;
207
+ }
208
+ interface CustomRenderer {
209
+ component: react__default.ComponentType<CustomRendererProps>;
210
+ language: string | string[];
211
+ }
212
+ /**
213
+ * Plugin configuration passed to Streamdown
214
+ */
215
+ interface PluginConfig {
216
+ cjk?: CjkPlugin;
217
+ code?: CodeHighlighterPlugin;
218
+ math?: MathPlugin;
219
+ mermaid?: DiagramPlugin;
220
+ renderers?: CustomRenderer[];
221
+ }
222
+
223
+ interface StreamdownTranslations {
224
+ close: string;
225
+ copied: string;
226
+ copyCode: string;
227
+ copyLink: string;
228
+ copyTable: string;
229
+ copyTableAsCsv: string;
230
+ copyTableAsMarkdown: string;
231
+ copyTableAsTsv: string;
232
+ downloadDiagram: string;
233
+ downloadDiagramAsMmd: string;
234
+ downloadDiagramAsPng: string;
235
+ downloadDiagramAsSvg: string;
236
+ downloadFile: string;
237
+ downloadImage: string;
238
+ downloadTable: string;
239
+ downloadTableAsCsv: string;
240
+ downloadTableAsMarkdown: string;
241
+ exitFullscreen: string;
242
+ externalLinkWarning: string;
243
+ imageNotAvailable: string;
244
+ mermaidFormatMmd: string;
245
+ mermaidFormatPng: string;
246
+ mermaidFormatSvg: string;
247
+ openExternalLink: string;
248
+ openLink: string;
249
+ tableFormatCsv: string;
250
+ tableFormatMarkdown: string;
251
+ tableFormatTsv: string;
252
+ viewFullscreen: string;
253
+ }
254
+ declare const defaultTranslations: StreamdownTranslations;
255
+
256
+ /**
257
+ * Hook to check if the current block has an incomplete (unclosed) code fence.
258
+ *
259
+ * Returns `true` when the code fence in this block is still being streamed.
260
+ * Useful for deferring expensive renders (syntax highlighting, Mermaid diagrams)
261
+ * until the code block is complete.
262
+ */
263
+ declare const useIsCodeFenceIncomplete: () => boolean;
264
+
265
+ type CodeBlockProps = HTMLAttributes<HTMLDivElement> & {
266
+ code: string;
267
+ language: string;
268
+ /** Whether the code block is still being streamed (incomplete) */
269
+ isIncomplete?: boolean;
270
+ /** Custom starting line number for line numbering (default: 1) */
271
+ startLine?: number;
272
+ /** Show line numbers in code blocks. @default true */
273
+ lineNumbers?: boolean;
274
+ };
275
+ declare const CodeBlock: ({ code, language, className, children, isIncomplete, startLine, lineNumbers, ...rest }: CodeBlockProps) => react_jsx_runtime.JSX.Element;
276
+
277
+ type CodeBlockContainerProps = ComponentProps<"div"> & {
278
+ language: string;
279
+ /** Whether the code block is still being streamed (incomplete) */
280
+ isIncomplete?: boolean;
281
+ };
282
+ declare const CodeBlockContainer: ({ className, language, style, isIncomplete, ...props }: CodeBlockContainerProps) => react_jsx_runtime.JSX.Element;
283
+
284
+ type CodeBlockCopyButtonProps = ComponentProps<"button"> & {
285
+ onCopy?: () => void;
286
+ onError?: (error: Error) => void;
287
+ timeout?: number;
288
+ };
289
+ declare const CodeBlockCopyButton: ({ onCopy, onError, timeout, children, className, code: propCode, ...props }: CodeBlockCopyButtonProps & {
290
+ code?: string;
291
+ }) => react_jsx_runtime.JSX.Element;
292
+
293
+ type CodeBlockDownloadButtonProps = ComponentProps<"button"> & {
294
+ onDownload?: () => void;
295
+ onError?: (error: Error) => void;
296
+ };
297
+ declare const CodeBlockDownloadButton: ({ onDownload, onError, language, children, className, code: propCode, ...props }: CodeBlockDownloadButtonProps & {
298
+ code?: string;
299
+ language?: string;
300
+ }) => react_jsx_runtime.JSX.Element;
301
+
302
+ interface CodeBlockHeaderProps {
303
+ language: string;
304
+ }
305
+ declare const CodeBlockHeader: ({ language }: CodeBlockHeaderProps) => react_jsx_runtime.JSX.Element;
306
+
307
+ declare const CodeBlockSkeleton: () => react_jsx_runtime.JSX.Element;
308
+
309
+ /**
310
+ * Detect text direction using the "first strong character" algorithm.
311
+ * Strips common markdown syntax then finds the first Unicode letter
312
+ * with strong directionality.
313
+ *
314
+ * Note: markdown stripping is best-effort — nested formatting,
315
+ * multi-line fenced code blocks, and raw HTML are not fully handled.
316
+ * This is acceptable since the algorithm only needs to reach the first
317
+ * strong character, which is almost always in plain prose.
318
+ *
319
+ * @returns "rtl" if first strong char is RTL, "ltr" otherwise
320
+ */
321
+ declare function detectTextDirection(text: string): "ltr" | "rtl";
322
+
323
+ declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
324
+
325
+ interface TableCopyDropdownProps {
326
+ children?: React.ReactNode;
327
+ className?: string;
328
+ onCopy?: (format: "csv" | "tsv" | "md") => void;
329
+ onError?: (error: Error) => void;
330
+ timeout?: number;
331
+ }
332
+ declare const TableCopyDropdown: ({ children, className, onCopy, onError, timeout, }: TableCopyDropdownProps) => react_jsx_runtime.JSX.Element;
333
+
334
+ interface TableDownloadButtonProps {
335
+ children?: React.ReactNode;
336
+ className?: string;
337
+ filename?: string;
338
+ format?: "csv" | "markdown";
339
+ onDownload?: () => void;
340
+ onError?: (error: Error) => void;
341
+ }
342
+ declare const TableDownloadButton: ({ children, className, onDownload, onError, format, filename, }: TableDownloadButtonProps) => react_jsx_runtime.JSX.Element;
343
+ interface TableDownloadDropdownProps {
344
+ children?: React.ReactNode;
345
+ className?: string;
346
+ onDownload?: (format: "csv" | "markdown") => void;
347
+ onError?: (error: Error) => void;
348
+ }
349
+ declare const TableDownloadDropdown: ({ children, className, onDownload, onError, }: TableDownloadDropdownProps) => react_jsx_runtime.JSX.Element;
350
+
351
+ interface TableData {
352
+ headers: string[];
353
+ rows: string[][];
354
+ }
355
+ declare const extractTableDataFromElement: (tableElement: HTMLElement) => TableData;
356
+ declare const tableDataToCSV: (data: TableData) => string;
357
+ declare const tableDataToTSV: (data: TableData) => string;
358
+ declare const escapeMarkdownTableCell: (cell: string) => string;
359
+ declare const tableDataToMarkdown: (data: TableData) => string;
360
+
361
+ /**
362
+ * Normalizes indentation in HTML blocks to prevent Markdown parsers from
363
+ * treating indented HTML tags as code blocks (4+ spaces = code in Markdown).
364
+ *
365
+ * Useful when rendering AI-generated HTML content with nested tags that
366
+ * are indented for readability.
367
+ *
368
+ * @param content - The raw HTML/Markdown string to normalize
369
+ * @returns The normalized string with reduced indentation before HTML tags
370
+ */
371
+ declare const normalizeHtmlIndentation: (content: string) => string;
372
+ type ControlsConfig = boolean | {
373
+ table?: boolean | {
374
+ copy?: boolean;
375
+ download?: boolean;
376
+ fullscreen?: boolean;
377
+ };
378
+ code?: boolean | {
379
+ copy?: boolean;
380
+ download?: boolean;
381
+ };
382
+ mermaid?: boolean | {
383
+ download?: boolean;
384
+ copy?: boolean;
385
+ fullscreen?: boolean;
386
+ panZoom?: boolean;
387
+ };
388
+ };
389
+ interface LinkSafetyModalProps {
390
+ isOpen: boolean;
391
+ onClose: () => void;
392
+ onConfirm: () => void;
393
+ url: string;
394
+ }
395
+ interface LinkSafetyConfig {
396
+ enabled: boolean;
397
+ onLinkCheck?: (url: string) => Promise<boolean> | boolean;
398
+ renderModal?: (props: LinkSafetyModalProps) => React.ReactNode;
399
+ }
400
+ interface MermaidErrorComponentProps {
401
+ chart: string;
402
+ error: string;
403
+ retry: () => void;
404
+ }
405
+ interface MermaidOptions {
406
+ config?: MermaidConfig;
407
+ errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
408
+ }
409
+ type AllowedTags = Record<string, string[]>;
410
+ type StreamdownProps = Options & {
411
+ mode?: "static" | "streaming";
412
+ /** Text direction for blocks. "auto" detects per-block using first strong character algorithm. */
413
+ dir?: "auto" | "ltr" | "rtl";
414
+ BlockComponent?: React.ComponentType<BlockProps>;
415
+ parseMarkdownIntoBlocksFn?: (markdown: string) => string[];
416
+ parseIncompleteMarkdown?: boolean;
417
+ /** Normalize HTML block indentation to prevent 4+ spaces being treated as code blocks. @default false */
418
+ normalizeHtmlIndentation?: boolean;
419
+ className?: string;
420
+ shikiTheme?: [ThemeInput, ThemeInput];
421
+ mermaid?: MermaidOptions;
422
+ controls?: ControlsConfig;
423
+ isAnimating?: boolean;
424
+ animated?: boolean | AnimateOptions;
425
+ caret?: keyof typeof carets;
426
+ plugins?: PluginConfig;
427
+ remend?: RemendOptions;
428
+ linkSafety?: LinkSafetyConfig;
429
+ /** Custom tags to allow through sanitization with their permitted attributes */
430
+ allowedTags?: AllowedTags;
431
+ /**
432
+ * Tags whose children should be treated as plain text (no markdown parsing).
433
+ * Useful for mention/entity tags in AI UIs where child content is a data
434
+ * label rather than prose. Requires the tag to also be listed in `allowedTags`.
435
+ *
436
+ * @example
437
+ * ```tsx
438
+ * <Streamdown
439
+ * allowedTags={{ mention: ['user_id'] }}
440
+ * literalTagContent={['mention']}
441
+ * >
442
+ * {`<mention user_id="123">@_some_username_</mention>`}
443
+ * </Streamdown>
444
+ * ```
445
+ */
446
+ literalTagContent?: string[];
447
+ /** Override UI strings for i18n / custom labels */
448
+ translations?: Partial<StreamdownTranslations>;
449
+ /** Custom icons to override the default icons used in controls */
450
+ icons?: Partial<IconMap>;
451
+ /** Tailwind CSS prefix to prepend to all utility classes (e.g. `"tw"` produces `tw:flex` instead of `flex`). Enables Tailwind v4's `prefix()` support. Note: user-supplied `className` values are also prefixed. */
452
+ prefix?: string;
453
+ /** Show line numbers in code blocks. @default true */
454
+ lineNumbers?: boolean;
455
+ /** Called when isAnimating transitions from false to true. Suppressed in mode="static". */
456
+ onAnimationStart?: () => void;
457
+ /** Called when isAnimating transitions from true to false. Suppressed in mode="static". */
458
+ onAnimationEnd?: () => void;
459
+ };
460
+ declare const defaultRehypePlugins: Record<string, Pluggable>;
461
+ declare const defaultRemarkPlugins: Record<string, Pluggable>;
462
+ declare const carets: {
463
+ block: string;
464
+ circle: string;
465
+ };
466
+ interface StreamdownContextType {
467
+ controls: ControlsConfig;
468
+ isAnimating: boolean;
469
+ /** Show line numbers in code blocks. @default true */
470
+ lineNumbers: boolean;
471
+ linkSafety?: LinkSafetyConfig;
472
+ mermaid?: MermaidOptions;
473
+ mode: "static" | "streaming";
474
+ shikiTheme: [ThemeInput, ThemeInput];
475
+ }
476
+ declare const StreamdownContext: react.Context<StreamdownContextType>;
477
+ type BlockProps = Options & {
478
+ content: string;
479
+ shouldParseIncompleteMarkdown: boolean;
480
+ shouldNormalizeHtmlIndentation: boolean;
481
+ index: number;
482
+ /** Whether this block is incomplete (still being streamed) */
483
+ isIncomplete: boolean;
484
+ /** Resolved text direction for this block */
485
+ dir?: "ltr" | "rtl";
486
+ /** Animate plugin instance for tracking previous content length */
487
+ animatePlugin?: AnimatePlugin | null;
488
+ };
489
+ declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, dir, animatePlugin: animatePluginProp, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
490
+ declare const Streamdown: react.MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, lineNumbers, allowedTags, literalTagContent, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
491
+
492
+ export { type AllowElement, type AllowedTags, type AnimateOptions, Block, type BlockProps, type CjkPlugin, CodeBlock, CodeBlockContainer, CodeBlockCopyButton, CodeBlockDownloadButton, CodeBlockHeader, CodeBlockSkeleton, type CodeHighlighterPlugin, type Components, type ControlsConfig, type CustomRenderer, type CustomRendererProps, type DiagramPlugin, type ExtraProps, type HighlightOptions, type IconMap, type LinkSafetyConfig, type LinkSafetyModalProps, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, type StreamdownTranslations, TableCopyDropdown, type TableCopyDropdownProps, type TableData, TableDownloadButton, type TableDownloadButtonProps, TableDownloadDropdown, type TableDownloadDropdownProps, type ThemeInput, type UrlTransform, createAnimatePlugin, defaultRehypePlugins, defaultRemarkPlugins, defaultTranslations, defaultUrlTransform, detectTextDirection, escapeMarkdownTableCell, extractTableDataFromElement, normalizeHtmlIndentation, parseMarkdownIntoBlocks, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, useIsCodeFenceIncomplete };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{B as Block,g as CodeBlock,d as CodeBlockContainer,i as CodeBlockCopyButton,j as CodeBlockDownloadButton,e as CodeBlockHeader,k as CodeBlockSkeleton,C as Streamdown,A as StreamdownContext,r as TableCopyDropdown,s as TableDownloadButton,t as TableDownloadDropdown,a as createAnimatePlugin,y as defaultRehypePlugins,z as defaultRemarkPlugins,h as defaultTranslations,v as defaultUrlTransform,u as detectTextDirection,p as escapeMarkdownTableCell,m as extractTableDataFromElement,x as normalizeHtmlIndentation,w as parseMarkdownIntoBlocks,n as tableDataToCSV,q as tableDataToMarkdown,o as tableDataToTSV,b as useIsCodeFenceIncomplete}from'./chunk-BO2N2NFS.js';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{l as Mermaid}from'./chunk-BO2N2NFS.js';
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@supermanzm/streamdown",
3
+ "version": "2.5.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./styles.css": "./styles.css"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "styles.css",
18
+ "README.md"
19
+ ],
20
+ "homepage": "https://streamdown.ai",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/vercel/streamdown.git",
24
+ "directory": "packages/streamdown"
25
+ },
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "postbuild": "node scripts/postbuild.js",
29
+ "test": "vitest run",
30
+ "test:ui": "vitest --ui run",
31
+ "test:coverage": "vitest --coverage run",
32
+ "bench": "vitest bench --run > results.txt",
33
+ "bench:ui": "vitest bench --ui --run",
34
+ "size": "node scripts/bundle-size.js"
35
+ },
36
+ "author": "Hayden Bleasel <hayden.bleasel@vercel.com>",
37
+ "license": "Apache-2.0",
38
+ "description": "A drop-in replacement for react-markdown, designed for AI-powered streaming.",
39
+ "devDependencies": {
40
+ "@supermanzm/streamdown-cjk": "workspace:*",
41
+ "@supermanzm/streamdown-math": "workspace:*",
42
+ "@supermanzm/streamdown-mermaid": "workspace:*",
43
+ "@testing-library/jest-dom": "^6.9.1",
44
+ "@testing-library/react": "^16.3.0",
45
+ "@types/hast": "^3.0.4",
46
+ "@types/react": "^19.2.7",
47
+ "@types/react-dom": "^19.2.3",
48
+ "react-dom": "^19.2.3",
49
+ "@vitejs/plugin-react": "^5.1.2",
50
+ "@vitest/coverage-v8": "^4.0.15",
51
+ "jsdom": "^27.3.0",
52
+ "react-markdown": "^10.1.0",
53
+ "rehype-parse": "^9.0.1",
54
+ "rehype-stringify": "^10.0.1",
55
+ "shiki": "^3.19.0",
56
+ "tsup": "^8.5.1",
57
+ "vitest": "^4.0.15"
58
+ },
59
+ "peerDependencies": {
60
+ "react": "^18.0.0 || ^19.0.0",
61
+ "react-dom": "^18.0.0 || ^19.0.0"
62
+ },
63
+ "dependencies": {
64
+ "clsx": "^2.1.1",
65
+ "hast-util-to-jsx-runtime": "^2.3.6",
66
+ "html-url-attributes": "^3.0.1",
67
+ "marked": "^17.0.1",
68
+ "rehype-harden": "^1.1.8",
69
+ "rehype-raw": "^7.0.0",
70
+ "rehype-sanitize": "^6.0.0",
71
+ "remark-gfm": "^4.0.1",
72
+ "remark-parse": "^11.0.0",
73
+ "remark-rehype": "^11.1.2",
74
+ "remend": "workspace:*",
75
+ "tailwind-merge": "^3.4.0",
76
+ "unified": "^11.0.5",
77
+ "mermaid": "^11.12.2",
78
+ "unist-util-visit": "^5.0.0",
79
+ "unist-util-visit-parents": "^6.0.0"
80
+ }
81
+ }
package/styles.css ADDED
@@ -0,0 +1,35 @@
1
+ @keyframes sd-fadeIn {
2
+ from {
3
+ opacity: 0;
4
+ }
5
+ to {
6
+ opacity: 1;
7
+ }
8
+ }
9
+
10
+ @keyframes sd-blurIn {
11
+ from {
12
+ opacity: 0;
13
+ filter: blur(4px);
14
+ }
15
+ to {
16
+ opacity: 1;
17
+ filter: blur(0);
18
+ }
19
+ }
20
+
21
+ @keyframes sd-slideUp {
22
+ from {
23
+ opacity: 0;
24
+ transform: translateY(4px);
25
+ }
26
+ to {
27
+ opacity: 1;
28
+ transform: translateY(0);
29
+ }
30
+ }
31
+
32
+ [data-sd-animate] {
33
+ animation: var(--sd-animation, sd-fadeIn) var(--sd-duration, 150ms)
34
+ var(--sd-easing, ease) var(--sd-delay, 0ms) both;
35
+ }