streamdown 2.3.0 → 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 +48 -1
- package/dist/chunk-BO2N2NFS.js +23 -0
- package/dist/highlighted-body-OFNGDK62.js +2 -0
- package/dist/index.d.ts +227 -12
- package/dist/index.js +1 -1
- package/dist/mermaid-GHXKKRXX.js +2 -0
- package/package.json +6 -6
- package/styles.css +1 -1
- package/dist/chunk-RLXIAIE6.js +0 -13
- package/dist/highlighted-body-B3W2YXNL.js +0 -2
- package/dist/mermaid-3ZIDBTTL.js +0 -2
package/README.md
CHANGED
|
@@ -36,6 +36,15 @@ Then, update your Tailwind `globals.css` to include the following so that Tailwi
|
|
|
36
36
|
|
|
37
37
|
The path must be relative from your CSS file to the `node_modules` folder containing `streamdown`. In a standard Next.js project where `globals.css` lives in `app/`, the default path above should work.
|
|
38
38
|
|
|
39
|
+
If you install optional Streamdown plugins, add their matching `@source` lines from the relevant plugin docs (`/docs/plugins/code`, `/docs/plugins/cjk`, `/docs/plugins/math`, `/docs/plugins/mermaid`). Only include plugin `@source` entries for packages that are actually installed.
|
|
40
|
+
|
|
41
|
+
Example:
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
@source "../node_modules/@streamdown/code/dist/*.js";
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
39
48
|
### Monorepo setup
|
|
40
49
|
|
|
41
50
|
In a monorepo (npm workspaces, Turbo, pnpm, etc.), dependencies are typically hoisted to the root `node_modules`. You need to adjust the relative path to point there:
|
|
@@ -54,7 +63,45 @@ monorepo/
|
|
|
54
63
|
@source "../../../node_modules/streamdown/dist/*.js";
|
|
55
64
|
```
|
|
56
65
|
|
|
57
|
-
Adjust the number of `../` segments based on where your CSS file lives relative to the root `node_modules`.
|
|
66
|
+
Adjust the number of `../` segments based on where your CSS file lives relative to the root `node_modules`. If you install Streamdown plugins, add their respective `@source` entries only when those packages are installed.
|
|
67
|
+
|
|
68
|
+
### CSS Custom Properties (Design Tokens)
|
|
69
|
+
|
|
70
|
+
Streamdown components are built using shadcn/ui's design system and rely on CSS custom properties for colors, border radius, and spacing. Without these variables defined, components may render with missing backgrounds, borders, or incorrect spacing.
|
|
71
|
+
|
|
72
|
+
If you are already using shadcn/ui, these variables are set up automatically. If not, add the following minimal set to your global 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
|
+
You can also use the shadcn/ui [theme generator](https://ui.shadcn.com/themes) to create a custom palette and copy the generated CSS variables directly into your project.
|
|
58
105
|
|
|
59
106
|
## Usage
|
|
60
107
|
|
|
@@ -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," ");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};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { JSX, ComponentType } from 'react';
|
|
3
|
+
import react__default, { SVGProps, JSX, ComponentType, HTMLAttributes, ComponentProps } from 'react';
|
|
4
4
|
import { MermaidConfig } from 'mermaid';
|
|
5
5
|
import { RemendOptions } from 'remend';
|
|
6
|
-
import { BundledLanguage, BundledTheme } from 'shiki';
|
|
7
|
-
export { BundledLanguage, BundledTheme } from 'shiki';
|
|
8
6
|
import { Pluggable, PluggableList } from 'unified';
|
|
9
7
|
import { Element, Parents } from 'hast';
|
|
10
8
|
import { Options as Options$1 } from 'remark-rehype';
|
|
9
|
+
import { BundledTheme, ThemeRegistrationAny, BundledLanguage } from 'shiki';
|
|
10
|
+
export { BundledLanguage, BundledTheme, ThemeRegistrationAny } from 'shiki';
|
|
11
11
|
|
|
12
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;
|
|
13
19
|
name: "animate";
|
|
14
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;
|
|
15
27
|
type: "animate";
|
|
16
28
|
}
|
|
17
29
|
interface AnimateOptions {
|
|
@@ -19,9 +31,26 @@ interface AnimateOptions {
|
|
|
19
31
|
duration?: number;
|
|
20
32
|
easing?: string;
|
|
21
33
|
sep?: "word" | "char";
|
|
34
|
+
stagger?: number;
|
|
22
35
|
}
|
|
23
36
|
declare function createAnimatePlugin(options?: AnimateOptions): AnimatePlugin;
|
|
24
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
|
+
|
|
25
54
|
interface ExtraProps {
|
|
26
55
|
node?: Element | undefined;
|
|
27
56
|
}
|
|
@@ -30,6 +59,7 @@ type UrlTransform = (url: string, key: string, node: Readonly<Element>) => strin
|
|
|
30
59
|
type Components = {
|
|
31
60
|
[Key in keyof JSX.IntrinsicElements]?: ComponentType<JSX.IntrinsicElements[Key] & ExtraProps> | keyof JSX.IntrinsicElements;
|
|
32
61
|
} & {
|
|
62
|
+
inlineCode?: ComponentType<JSX.IntrinsicElements["code"] & ExtraProps>;
|
|
33
63
|
[key: string]: ComponentType<Record<string, unknown> & ExtraProps> | keyof JSX.IntrinsicElements | undefined;
|
|
34
64
|
};
|
|
35
65
|
interface Options {
|
|
@@ -47,6 +77,7 @@ interface Options {
|
|
|
47
77
|
}
|
|
48
78
|
declare const defaultUrlTransform: UrlTransform;
|
|
49
79
|
|
|
80
|
+
type ThemeInput = BundledTheme | ThemeRegistrationAny;
|
|
50
81
|
/**
|
|
51
82
|
* A single token in a highlighted line
|
|
52
83
|
*/
|
|
@@ -73,7 +104,7 @@ interface HighlightResult {
|
|
|
73
104
|
interface HighlightOptions {
|
|
74
105
|
code: string;
|
|
75
106
|
language: BundledLanguage;
|
|
76
|
-
themes: [
|
|
107
|
+
themes: [ThemeInput, ThemeInput];
|
|
77
108
|
}
|
|
78
109
|
/**
|
|
79
110
|
* Plugin for code syntax highlighting (Shiki)
|
|
@@ -86,7 +117,7 @@ interface CodeHighlighterPlugin {
|
|
|
86
117
|
/**
|
|
87
118
|
* Get the configured themes
|
|
88
119
|
*/
|
|
89
|
-
getThemes: () => [
|
|
120
|
+
getThemes: () => [ThemeInput, ThemeInput];
|
|
90
121
|
/**
|
|
91
122
|
* Highlight code and return tokens
|
|
92
123
|
* Returns null if highlighting not ready yet (async loading)
|
|
@@ -165,6 +196,19 @@ interface CjkPlugin {
|
|
|
165
196
|
remarkPluginsBefore: Pluggable[];
|
|
166
197
|
type: "cjk";
|
|
167
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
|
+
}
|
|
168
212
|
/**
|
|
169
213
|
* Plugin configuration passed to Streamdown
|
|
170
214
|
*/
|
|
@@ -173,7 +217,41 @@ interface PluginConfig {
|
|
|
173
217
|
code?: CodeHighlighterPlugin;
|
|
174
218
|
math?: MathPlugin;
|
|
175
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;
|
|
176
253
|
}
|
|
254
|
+
declare const defaultTranslations: StreamdownTranslations;
|
|
177
255
|
|
|
178
256
|
/**
|
|
179
257
|
* Hook to check if the current block has an incomplete (unclosed) code fence.
|
|
@@ -184,8 +262,102 @@ interface PluginConfig {
|
|
|
184
262
|
*/
|
|
185
263
|
declare const useIsCodeFenceIncomplete: () => boolean;
|
|
186
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
|
+
|
|
187
323
|
declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
188
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
|
+
|
|
189
361
|
/**
|
|
190
362
|
* Normalizes indentation in HTML blocks to prevent Markdown parsers from
|
|
191
363
|
* treating indented HTML tags as code blocks (4+ spaces = code in Markdown).
|
|
@@ -198,8 +370,15 @@ declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
|
198
370
|
*/
|
|
199
371
|
declare const normalizeHtmlIndentation: (content: string) => string;
|
|
200
372
|
type ControlsConfig = boolean | {
|
|
201
|
-
table?: boolean
|
|
202
|
-
|
|
373
|
+
table?: boolean | {
|
|
374
|
+
copy?: boolean;
|
|
375
|
+
download?: boolean;
|
|
376
|
+
fullscreen?: boolean;
|
|
377
|
+
};
|
|
378
|
+
code?: boolean | {
|
|
379
|
+
copy?: boolean;
|
|
380
|
+
download?: boolean;
|
|
381
|
+
};
|
|
203
382
|
mermaid?: boolean | {
|
|
204
383
|
download?: boolean;
|
|
205
384
|
copy?: boolean;
|
|
@@ -230,13 +409,15 @@ interface MermaidOptions {
|
|
|
230
409
|
type AllowedTags = Record<string, string[]>;
|
|
231
410
|
type StreamdownProps = Options & {
|
|
232
411
|
mode?: "static" | "streaming";
|
|
412
|
+
/** Text direction for blocks. "auto" detects per-block using first strong character algorithm. */
|
|
413
|
+
dir?: "auto" | "ltr" | "rtl";
|
|
233
414
|
BlockComponent?: React.ComponentType<BlockProps>;
|
|
234
415
|
parseMarkdownIntoBlocksFn?: (markdown: string) => string[];
|
|
235
416
|
parseIncompleteMarkdown?: boolean;
|
|
236
417
|
/** Normalize HTML block indentation to prevent 4+ spaces being treated as code blocks. @default false */
|
|
237
418
|
normalizeHtmlIndentation?: boolean;
|
|
238
419
|
className?: string;
|
|
239
|
-
shikiTheme?: [
|
|
420
|
+
shikiTheme?: [ThemeInput, ThemeInput];
|
|
240
421
|
mermaid?: MermaidOptions;
|
|
241
422
|
controls?: ControlsConfig;
|
|
242
423
|
isAnimating?: boolean;
|
|
@@ -247,6 +428,34 @@ type StreamdownProps = Options & {
|
|
|
247
428
|
linkSafety?: LinkSafetyConfig;
|
|
248
429
|
/** Custom tags to allow through sanitization with their permitted attributes */
|
|
249
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;
|
|
250
459
|
};
|
|
251
460
|
declare const defaultRehypePlugins: Record<string, Pluggable>;
|
|
252
461
|
declare const defaultRemarkPlugins: Record<string, Pluggable>;
|
|
@@ -257,10 +466,12 @@ declare const carets: {
|
|
|
257
466
|
interface StreamdownContextType {
|
|
258
467
|
controls: ControlsConfig;
|
|
259
468
|
isAnimating: boolean;
|
|
469
|
+
/** Show line numbers in code blocks. @default true */
|
|
470
|
+
lineNumbers: boolean;
|
|
260
471
|
linkSafety?: LinkSafetyConfig;
|
|
261
472
|
mermaid?: MermaidOptions;
|
|
262
473
|
mode: "static" | "streaming";
|
|
263
|
-
shikiTheme: [
|
|
474
|
+
shikiTheme: [ThemeInput, ThemeInput];
|
|
264
475
|
}
|
|
265
476
|
declare const StreamdownContext: react.Context<StreamdownContextType>;
|
|
266
477
|
type BlockProps = Options & {
|
|
@@ -270,8 +481,12 @@ type BlockProps = Options & {
|
|
|
270
481
|
index: number;
|
|
271
482
|
/** Whether this block is incomplete (still being streamed) */
|
|
272
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;
|
|
273
488
|
};
|
|
274
|
-
declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
275
|
-
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, allowedTags, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
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>;
|
|
276
491
|
|
|
277
|
-
export { type AllowElement, type AllowedTags, type AnimateOptions, Block, type BlockProps, type CjkPlugin, type CodeHighlighterPlugin, type Components, type ControlsConfig, type DiagramPlugin, type ExtraProps, type HighlightOptions, type LinkSafetyConfig, type LinkSafetyModalProps, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, type UrlTransform, createAnimatePlugin, defaultRehypePlugins, defaultRemarkPlugins, defaultUrlTransform, normalizeHtmlIndentation, parseMarkdownIntoBlocks, useIsCodeFenceIncomplete };
|
|
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
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{
|
|
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';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "streamdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -36,16 +36,15 @@
|
|
|
36
36
|
"@vitejs/plugin-react": "^5.1.2",
|
|
37
37
|
"@vitest/coverage-v8": "^4.0.15",
|
|
38
38
|
"jsdom": "^27.3.0",
|
|
39
|
-
"mermaid": "^11.12.2",
|
|
40
39
|
"react-markdown": "^10.1.0",
|
|
41
40
|
"rehype-parse": "^9.0.1",
|
|
42
41
|
"rehype-stringify": "^10.0.1",
|
|
43
42
|
"shiki": "^3.19.0",
|
|
44
43
|
"tsup": "^8.5.1",
|
|
45
44
|
"vitest": "^4.0.15",
|
|
46
|
-
"@streamdown/cjk": "1.0.
|
|
47
|
-
"@streamdown/
|
|
48
|
-
"@streamdown/
|
|
45
|
+
"@streamdown/cjk": "1.0.3",
|
|
46
|
+
"@streamdown/math": "1.0.2",
|
|
47
|
+
"@streamdown/mermaid": "1.0.2"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
51
50
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -64,9 +63,10 @@
|
|
|
64
63
|
"remark-rehype": "^11.1.2",
|
|
65
64
|
"tailwind-merge": "^3.4.0",
|
|
66
65
|
"unified": "^11.0.5",
|
|
66
|
+
"mermaid": "^11.12.2",
|
|
67
67
|
"unist-util-visit": "^5.0.0",
|
|
68
68
|
"unist-util-visit-parents": "^6.0.0",
|
|
69
|
-
"remend": "1.
|
|
69
|
+
"remend": "1.3.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsup",
|
package/styles.css
CHANGED
package/dist/chunk-RLXIAIE6.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {createContext,memo,useMemo,lazy,useContext,isValidElement,useId,useTransition,useState,useEffect,cloneElement,useCallback,useRef,Suspense}from'react';import {harden}from'rehype-harden';import po from'rehype-raw';import To,{defaultSchema}from'rehype-sanitize';import Er from'remark-gfm';import Hr 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 ar from'remark-parse';import ir from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var Oo=300,Vo="300px",Ao=500;function Ge(e={}){let{immediate:t=false,debounceDelay:o=Oo,rootMargin:n=Vo,idleTimeout:s=Ao}=e,[r,i]=useState(false),c=useRef(null),a=useRef(null),l=useRef(null),m=useMemo(()=>g=>{let b=Date.now();return window.setTimeout(()=>{g({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-b))});},1)},[]),d=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(g,b)=>window.requestIdleCallback(g,b):m,[m]),p=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?g=>window.cancelIdleCallback(g):g=>{clearTimeout(g);},[]);return useEffect(()=>{if(t){i(true);return}let g=c.current;if(!g)return;a.current&&(clearTimeout(a.current),a.current=null),l.current&&(p(l.current),l.current=null);let b=()=>{a.current&&(clearTimeout(a.current),a.current=null),l.current&&(p(l.current),l.current=null);},h=w=>{l.current=d(T=>{T.timeRemaining()>0||T.didTimeout?(i(true),w.disconnect()):l.current=d(()=>{i(true),w.disconnect();},{timeout:s/2});},{timeout:s});},u=w=>{b(),a.current=window.setTimeout(()=>{var S,B;let T=w.takeRecords();(T.length===0||(B=(S=T.at(-1))==null?void 0:S.isIntersecting)!=null&&B)&&h(w);},o);},C=(w,T)=>{w.isIntersecting?u(T):b();},k=new IntersectionObserver(w=>{for(let T of w)C(T,k);},{rootMargin:n,threshold:0});return k.observe(g),()=>{a.current&&clearTimeout(a.current),l.current&&p(l.current),k.disconnect();}},[t,o,n,s,p,d]),{shouldRender:r,containerRef:c}}var Ye=/\s/,qo=/^\s+$/,_o=new Set(["code","pre","svg","math","annotation"]),Zo=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Wo=e=>e.some(t=>Zo(t)&&_o.has(t.tagName)),$o=e=>{let t=[],o="",n=false;for(let s of e){let r=Ye.test(s);r!==n&&o&&(t.push(o),o=""),o+=s,n=r;}return o&&t.push(o),t},Fo=e=>{let t=[],o="";for(let n of e)Ye.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Uo=(e,t,o,n)=>({type:"element",tagName:"span",properties:{"data-sd-animate":true,style:`--sd-animation:sd-${t};--sd-duration:${o}ms;--sd-easing:${n}`},children:[{type:"text",value:e}]}),Xo=(e,t,o)=>{let n=t.at(-1);if(!(n&&"children"in n))return;if(Wo(t))return SKIP;let s=n,r=s.children.indexOf(e);if(r===-1)return;let i=e.value;if(!i.trim())return;let a=(o.sep==="char"?Fo(i):$o(i)).map(l=>qo.test(l)?{type:"text",value:l}:Uo(l,o.animation,o.duration,o.easing));return s.children.splice(r,1,...a),r+a.length};function Q(e){var n,s,r,i;let t={animation:(n=e==null?void 0:e.animation)!=null?n:"fadeIn",duration:(s=e==null?void 0:e.duration)!=null?s:150,easing:(r=e==null?void 0:e.easing)!=null?r:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word"};return {name:"animate",type:"animate",rehypePlugin:()=>c=>{visitParents(c,"text",(a,l)=>Xo(a,l,t));}}}Q();var Re=createContext(false),Ie=()=>useContext(Re);var f=(...e)=>twMerge(clsx(e)),q=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s);};var tn=f("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"),on=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let s=o.slice(0,n).trim(),r=o.slice(n+1).trim();s&&r&&(t[s]=r);}}return t},Qe=memo(({children:e,result:t,language:o,className:n,...s})=>{let r=useMemo(()=>{let i={};return t.bg&&(i["--sdm-bg"]=t.bg),t.fg&&(i["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(i,on(t.rootStyle)),i},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:f(n,"overflow-hidden rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",...s,children:jsx("pre",{className:f(n,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:r,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:t.tokens.map((i,c)=>jsx("span",{className:tn,children:i.map((a,l)=>{let m={},d=!!a.bgColor;if(a.color&&(m["--sdm-c"]=a.color),a.bgColor&&(m["--sdm-tbg"]=a.bgColor),a.htmlStyle)for(let[p,g]of Object.entries(a.htmlStyle))p==="color"?m["--sdm-c"]=g:p==="background-color"?(m["--sdm-tbg"]=g,d=true):m[p]=g;return jsx("span",{className:f("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",d&&"bg-[var(--sdm-tbg)]",d&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:m,...a.htmlAttrs,children:a.content},l)})},c))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className);var et=({className:e,language:t,style:o,isIncomplete:n,...s})=>jsx("div",{className:f("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},...s});var Se=createContext({code:""}),de=()=>useContext(Se);var ot=({language:e})=>jsx("div",{className:"flex h-8 items-center text-muted-foreground text-xs","data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:"ml-1 font-mono lowercase",children:e})});var cn=/\n+$/,dn=lazy(()=>import('./highlighted-body-B3W2YXNL.js').then(e=>({default:e.HighlightedCodeBlockBody}))),rt=({code:e,language:t,className:o,children:n,isIncomplete:s=false,...r})=>{let i=useMemo(()=>e.replace(cn,""),[e]),c=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:i.split(`
|
|
3
|
-
`).map(a=>[{content:a,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[i]);return jsx(Se.Provider,{value:{code:e},children:jsxs(et,{isIncomplete:s,language:t,children:[jsx(ot,{language:t}),n?jsx("div",{className:"pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end",children:jsx("div",{className:"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(Qe,{className:o,language:t,result:c,...r}),children:jsx(dn,{className:o,code:i,language:t,raw:c,...r})})]})})};var J=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"})}),K=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"})}),Z=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"})}),st=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"})]}),at=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"})}),it=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"})}),me=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"})}),Ee=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"})}),lt=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"})}),ct=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 He=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:s,code:r,...i})=>{let[c,a]=useState(false),l=useRef(0),{code:m}=de(),{isAnimating:d}=useContext(R),p=r!=null?r:m,g=async()=>{var h;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(p),a(!0),e==null||e(),l.current=window.setTimeout(()=>a(!1),o));}catch(u){t==null||t(u);}};useEffect(()=>()=>{window.clearTimeout(l.current);},[]);let b=c?J:K;return jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-copy-button",disabled:d,onClick:g,title:"Copy Code",type:"button",...i,children:n!=null?n:jsx(b,{size:14})})};var mt={"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"},ut=({onDownload:e,onError:t,language:o,children:n,className:s,code:r,...i})=>{let{code:c}=de(),{isAnimating:a}=useContext(R),l=r!=null?r:c,d=`file.${o&&o in mt?mt[o]:"txt"}`,p="text/plain",g=()=>{try{q(d,l,p),e==null||e();}catch(b){t==null||t(b);}};return jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-download-button",disabled:a,onClick:g,title:"Download file",type:"button",...i,children:n!=null?n:jsx(Z,{size:14})})};var ft=()=>jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsx(st,{className:"size-4 animate-spin"})})]});var Cn=/\.[^/.]+$/,ht=({node:e,className:t,src:o,alt:n,onLoad:s,onError:r,...i})=>{let c=useRef(null),[a,l]=useState(false),[m,d]=useState(false),p=i.width!=null||i.height!=null,g=(a||p)&&!m,b=m&&!p;useEffect(()=>{let k=c.current;if(k!=null&&k.complete){let w=k.naturalWidth>0;l(w),d(!w);}},[]);let h=useCallback(k=>{l(true),d(false),s==null||s(k);},[s]),u=useCallback(k=>{l(false),d(true),r==null||r(k);},[r]),C=async()=>{if(o)try{let w=await(await fetch(o)).blob(),H=new URL(o,window.location.origin).pathname.split("/").pop()||"",S=H.split(".").pop(),B=H.includes(".")&&S!==void 0&&S.length<=4,O="";if(B)O=H;else {let E=w.type,I="png";E.includes("jpeg")||E.includes("jpg")?I="jpg":E.includes("png")?I="png":E.includes("svg")?I="svg":E.includes("gif")?I="gif":E.includes("webp")&&(I="webp"),O=`${(n||H||"image").replace(Cn,"")}.${I}`;}q(O,w,w.type);}catch(k){window.open(o,"_blank");}};return o?jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:f("max-w-full rounded-lg",b&&"hidden",t),"data-streamdown":"image",onError:u,onLoad:h,ref:c,src:o,...i}),b&&jsx("span",{className:"text-muted-foreground text-xs italic","data-streamdown":"image-fallback",children:"Image not available"}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),g&&jsx("button",{className:f("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:C,title:"Download image",type:"button",children:jsx(Z,{size:14})})]}):null};var oe=0,Mn=()=>{oe+=1,oe===1&&(document.body.style.overflow="hidden");},Tn=()=>{oe=Math.max(0,oe-1),oe===0&&(document.body.style.overflow="");},kt=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let[s,r]=useState(false),i=useCallback(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3);}catch(a){}},[e]),c=useCallback(()=>{n(),o();},[n,o]);return useEffect(()=>{if(t){Mn();let a=l=>{l.key==="Escape"&&o();};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a),Tn();}}},[t,o]),t?jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm","data-streamdown":"link-safety-modal",onClick:o,onKeyDown:a=>{a.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:"relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),role:"presentation",children:[jsx("button",{className:"absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:o,title:"Close",type:"button",children:jsx(me,{size:16})}),jsxs("div",{className:"flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center gap-2 font-semibold text-lg",children:[jsx(Ee,{size:20}),jsx("span",{children:"Open external link?"})]}),jsx("p",{className:"text-muted-foreground text-sm",children:"You're about to visit an external website."})]}),jsx("div",{className:f("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:"flex gap-2",children:[jsx("button",{className:"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:i,type:"button",children:s?jsxs(Fragment,{children:[jsx(J,{size:14}),jsx("span",{children:"Copied"})]}):jsxs(Fragment,{children:[jsx(K,{size:14}),jsx("span",{children:"Copy link"})]})}),jsxs("button",{className:"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:c,type:"button",children:[jsx(Ee,{size:14}),jsx("span",{children:"Open link"})]})]})]})}):null};var pe=createContext(null),Ct=()=>useContext(pe),Ks=()=>{var t;let e=Ct();return (t=e==null?void 0:e.code)!=null?t:null},G=()=>{var t;let e=Ct();return (t=e==null?void 0:e.mermaid)!=null?t:null};var vt=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((s,r)=>{let i="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),c=new Image;c.crossOrigin="anonymous",c.onload=()=>{let a=document.createElement("canvas"),l=c.width*o,m=c.height*o;a.width=l,a.height=m;let d=a.getContext("2d");if(!d){r(new Error("Failed to create 2D canvas context for PNG export"));return}d.drawImage(c,0,0,l,m),a.toBlob(p=>{if(!p){r(new Error("Failed to create PNG blob"));return}s(p);},"image/png");},c.onerror=()=>r(new Error("Failed to load SVG image")),c.src=i;})};var Pt=({chart:e,children:t,className:o,onDownload:n,config:s,onError:r})=>{let[i,c]=useState(false),a=useRef(null),{isAnimating:l}=useContext(R),m=G(),d=async p=>{try{if(p==="mmd"){q("diagram.mmd",e,"text/plain"),c(!1),n==null||n(p);return}if(!m){r==null||r(new Error("Mermaid plugin not available"));return}let g=m.getMermaid(s),b=e.split("").reduce((C,k)=>(C<<5)-C+k.charCodeAt(0)|0,0),h=`mermaid-${Math.abs(b)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:u}=await g.render(h,e);if(!u){r==null||r(new Error("SVG not found. Please wait for the diagram to render."));return}if(p==="svg"){q("diagram.svg",u,"image/svg+xml"),c(!1),n==null||n(p);return}if(p==="png"){let C=await vt(u);q("diagram.png",C,"image/png"),n==null||n(p),c(!1);return}}catch(g){r==null||r(g);}};return useEffect(()=>{let p=g=>{let b=g.composedPath();a.current&&!b.includes(a.current)&&c(false);};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p);}},[]),jsxs("div",{className:"relative",ref:a,children:[jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:l,onClick:()=>c(!i),title:"Download diagram",type:"button",children:t!=null?t:jsx(Z,{size:14})}),i?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]}):null]})};var re=0,On=()=>{re+=1,re===1&&(document.body.style.overflow="hidden");},Vn=()=>{re=Math.max(0,re-1),re===0&&(document.body.style.overflow="");},Lt=({chart:e,config:t,onFullscreen:o,onExit:n,className:s,...r})=>{let[i,c]=useState(false),{isAnimating:a,controls:l}=useContext(R),m=(()=>{if(typeof l=="boolean")return l;let p=l.mermaid;return p===false?false:p===true||p===void 0?true:p.panZoom!==false})(),d=()=>{c(!i);};return useEffect(()=>{if(i){On();let p=g=>{g.key==="Escape"&&c(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),Vn();}}},[i]),useEffect(()=>{i?o==null||o():n&&n();},[i,o,n]),jsxs(Fragment,{children:[jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),disabled:a,onClick:d,title:"View fullscreen",type:"button",...r,children:jsx(at,{size:14})}),i?createPortal(jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:d,onKeyDown:p=>{p.key==="Escape"&&d();},role:"button",tabIndex:0,children:[jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:d,title:"Exit fullscreen",type:"button",children:jsx(me,{size:20})}),jsx("div",{className:"flex size-full items-center justify-center p-4",onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:jsx(Nt,{chart:e,className:"size-full [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:m})})]}),document.body):null]})};var ue=e=>{var r,i;let t=[],o=[],n=e.querySelectorAll("thead th");for(let c of n)t.push(((r=c.textContent)==null?void 0:r.trim())||"");let s=e.querySelectorAll("tbody tr");for(let c of s){let a=[],l=c.querySelectorAll("td");for(let m of l)a.push(((i=m.textContent)==null?void 0:i.trim())||"");o.push(a);}return {headers:t,rows:o}},fe=e=>{let{headers:t,rows:o}=e,n=c=>{let a=false,l=false;for(let m of c){if(m==='"'){a=true,l=true;break}(m===","||m===`
|
|
4
|
-
`)&&(a=true);}return a?l?`"${c.replace(/"/g,'""')}"`:`"${c}"`:c},s=t.length>0?o.length+1:o.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(n).join(","),i+=1);for(let c of o)r[i]=c.map(n).join(","),i+=1;return r.join(`
|
|
5
|
-
`)},Rt=e=>{let{headers:t,rows:o}=e,n=c=>{let a=false;for(let m of c)if(m===" "||m===`
|
|
6
|
-
`||m==="\r"){a=true;break}if(!a)return c;let l=[];for(let m of c)m===" "?l.push("\\t"):m===`
|
|
7
|
-
`?l.push("\\n"):m==="\r"?l.push("\\r"):l.push(m);return l.join("")},s=t.length>0?o.length+1:o.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(n).join(" "),i+=1);for(let c of o)r[i]=c.map(n).join(" "),i+=1;return r.join(`
|
|
8
|
-
`)},De=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("")},se=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),s=0,r=t.map(c=>De(c));n[s]=`| ${r.join(" | ")} |`,s+=1;let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]="---";n[s]=`| ${i.join(" | ")} |`,s+=1;for(let c of o)if(c.length<t.length){let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]=l<c.length?De(c[l]):"";n[s]=`| ${a.join(" | ")} |`,s+=1;}else {let a=c.map(l=>De(l));n[s]=`| ${a.join(" | ")} |`,s+=1;}return n.join(`
|
|
9
|
-
`)};var Ht=({children:e,className:t,onCopy:o,onError:n,timeout:s=2e3})=>{let[r,i]=useState(false),[c,a]=useState(false),l=useRef(null),m=useRef(0),{isAnimating:d}=useContext(R),p=async b=>{var h,u;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.write)){n==null||n(new Error("Clipboard API not available"));return}try{let C=(u=l.current)==null?void 0:u.closest('[data-streamdown="table-wrapper"]'),k=C==null?void 0:C.querySelector("table");if(!k){n==null||n(new Error("Table not found"));return}let w=ue(k),S=({csv:fe,tsv:Rt,md:se}[b]||se)(w),B=new ClipboardItem({"text/plain":new Blob([S],{type:"text/plain"}),"text/html":new Blob([k.outerHTML],{type:"text/html"})});await navigator.clipboard.write([B]),a(!0),i(!1),o==null||o(b),m.current=window.setTimeout(()=>a(!1),s);}catch(C){n==null||n(C);}};useEffect(()=>{let b=h=>{let u=h.composedPath();l.current&&!u.includes(l.current)&&i(false);};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b),window.clearTimeout(m.current);}},[]);let g=c?J:K;return jsxs("div",{className:"relative",ref:l,children:[jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:d,onClick:()=>i(!r),title:"Copy table",type:"button",children:e!=null?e:jsx(g,{size:14})}),r?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("md"),title:"Copy table as Markdown",type:"button",children:"Markdown"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var Dt=({children:e,className:t,onDownload:o,onError:n})=>{let[s,r]=useState(false),i=useRef(null),{isAnimating:c}=useContext(R),a=l=>{var m;try{let d=(m=i.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),p=d==null?void 0:d.querySelector("table");if(!p){n==null||n(new Error("Table not found"));return}let g=ue(p),b=l==="csv"?fe(g):se(g);q(`table.${l==="csv"?"csv":"md"}`,b,l==="csv"?"text/csv":"text/markdown"),r(!1),o==null||o(l);}catch(d){n==null||n(d);}};return useEffect(()=>{let l=m=>{let d=m.composedPath();i.current&&!d.includes(i.current)&&r(false);};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l);}},[]),jsxs("div",{className:"relative",ref:i,children:[jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:()=>r(!s),title:"Download table",type:"button",children:e!=null?e:jsx(Z,{size:14})}),s?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>a("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>a("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var Vt=({children:e,className:t,showControls:o,...n})=>jsxs("div",{className:"my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2","data-streamdown":"table-wrapper",children:[o?jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(Ht,{}),jsx(Dt,{})]}):null,jsx("div",{className:"border-collapse overflow-x-auto overscroll-y-auto rounded-md border border-border bg-background",children:jsx("table",{className:f("w-full divide-y divide-border",t),"data-streamdown":"table",...n,children:e})})]});var Jn=lazy(()=>import('./mermaid-3ZIDBTTL.js').then(e=>({default:e.Mermaid}))),Kn=/language-([^\s]+)/;function ke(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,s=e.position.end,r=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)&&(s==null?void 0:s.line)===(r==null?void 0:r.line)&&(s==null?void 0:s.column)===(r==null?void 0:r.column)}function N(e,t){return e.className===t.className&&ke(e.node,t.node)}var Ve=(e,t)=>typeof e=="boolean"?e:e[t]!==false,he=(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},je=memo(({children:e,className:t,node:o,...n})=>jsx("ol",{className:f("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>N(e,t));je.displayName="MarkdownOl";var At=memo(({children:e,className:t,node:o,...n})=>jsx("li",{className:f("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ke(e.node,t.node));At.displayName="MarkdownLi";var jt=memo(({children:e,className:t,node:o,...n})=>jsx("ul",{className:f("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>N(e,t));jt.displayName="MarkdownUl";var zt=memo(({className:e,node:t,...o})=>jsx("hr",{className:f("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>N(e,t));zt.displayName="MarkdownHr";var qt=memo(({children:e,className:t,node:o,...n})=>jsx("span",{className:f("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>N(e,t));qt.displayName="MarkdownStrong";var Gn=({children:e,className:t,href:o,node:n,...s})=>{let{linkSafety:r}=useContext(R),[i,c]=useState(false),a=o==="streamdown:incomplete-link",l=useCallback(async g=>{if(!(!(r!=null&&r.enabled&&o)||a)){if(g.preventDefault(),r.onLinkCheck&&await r.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}c(true);}},[r,o,a]),m=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),d=useCallback(()=>{c(false);},[]),p={url:o!=null?o:"",isOpen:i,onClose:d,onConfirm:m};return r!=null&&r.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:f("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":a,"data-streamdown":"link",onClick:l,type:"button",children:e}),r.renderModal?r.renderModal(p):jsx(kt,{...p})]}):jsx("a",{className:f("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":a,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...s,children:e})},_t=memo(Gn,(e,t)=>N(e,t)&&e.href===t.href);_t.displayName="MarkdownA";var Zt=memo(({children:e,className:t,node:o,...n})=>jsx("h1",{className:f("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>N(e,t));Zt.displayName="MarkdownH1";var Wt=memo(({children:e,className:t,node:o,...n})=>jsx("h2",{className:f("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>N(e,t));Wt.displayName="MarkdownH2";var $t=memo(({children:e,className:t,node:o,...n})=>jsx("h3",{className:f("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>N(e,t));$t.displayName="MarkdownH3";var Ft=memo(({children:e,className:t,node:o,...n})=>jsx("h4",{className:f("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>N(e,t));Ft.displayName="MarkdownH4";var Ut=memo(({children:e,className:t,node:o,...n})=>jsx("h5",{className:f("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>N(e,t));Ut.displayName="MarkdownH5";var Xt=memo(({children:e,className:t,node:o,...n})=>jsx("h6",{className:f("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>N(e,t));Xt.displayName="MarkdownH6";var Jt=memo(({children:e,className:t,node:o,...n})=>{let{controls:s}=useContext(R),r=Ve(s,"table");return jsx(Vt,{className:t,showControls:r,...n,children:e})},(e,t)=>N(e,t));Jt.displayName="MarkdownTable";var Kt=memo(({children:e,className:t,node:o,...n})=>jsx("thead",{className:f("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>N(e,t));Kt.displayName="MarkdownThead";var Gt=memo(({children:e,className:t,node:o,...n})=>jsx("tbody",{className:f("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>N(e,t));Gt.displayName="MarkdownTbody";var Yt=memo(({children:e,className:t,node:o,...n})=>jsx("tr",{className:f("border-border",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>N(e,t));Yt.displayName="MarkdownTr";var Qt=memo(({children:e,className:t,node:o,...n})=>jsx("th",{className:f("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>N(e,t));Qt.displayName="MarkdownTh";var eo=memo(({children:e,className:t,node:o,...n})=>jsx("td",{className:f("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>N(e,t));eo.displayName="MarkdownTd";var to=memo(({children:e,className:t,node:o,...n})=>jsx("blockquote",{className:f("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>N(e,t));to.displayName="MarkdownBlockquote";var oo=memo(({children:e,className:t,node:o,...n})=>jsx("sup",{className:f("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>N(e,t));oo.displayName="MarkdownSup";var no=memo(({children:e,className:t,node:o,...n})=>jsx("sub",{className:f("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>N(e,t));no.displayName="MarkdownSub";var ro=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let r=a=>{var p,g;if(!isValidElement(a))return false;let l=Array.isArray(a.props.children)?a.props.children:[a.props.children],m=false,d=false;for(let b of l)if(b){if(typeof b=="string")b.trim()!==""&&(m=true);else if(isValidElement(b))if(((p=b.props)==null?void 0:p["data-footnote-backref"])!==void 0)d=true;else {let h=Array.isArray(b.props.children)?b.props.children:[b.props.children];for(let u of h){if(typeof u=="string"&&u.trim()!==""){m=true;break}if(isValidElement(u)&&((g=u.props)==null?void 0:g["data-footnote-backref"])===void 0){m=true;break}}}}return d&&!m},i=Array.isArray(e)?e.map(a=>{if(!isValidElement(a))return a;if(a.type===je){let m=(Array.isArray(a.props.children)?a.props.children:[a.props.children]).filter(d=>!r(d));return m.length===0?null:{...a,props:{...a.props,children:m}}}return a}):e;return (Array.isArray(i)?i.some(a=>a!==null):i!==null)?jsx("section",{className:t,...n,children:i}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>N(e,t));ro.displayName="MarkdownSection";var Yn=({node:e,className:t,children:o,...n})=>{var g;let s=!("data-block"in n),{mermaid:r,controls:i}=useContext(R),c=G(),a=Ie();if(s)return jsx("code",{className:f("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let l=t==null?void 0:t.match(Kn),m=(g=l==null?void 0:l.at(1))!=null?g:"",d="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?d=o.props.children:typeof o=="string"&&(d=o),m==="mermaid"&&c){let b=Ve(i,"mermaid"),h=he(i,"download"),u=he(i,"copy"),C=he(i,"fullscreen"),k=he(i,"panZoom"),w=b&&(h||u||C);return jsx(Suspense,{fallback:jsx(ft,{}),children:jsxs("div",{className:f("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:"flex h-8 items-center text-muted-foreground text-xs",children:jsx("span",{className:"ml-1 font-mono lowercase",children:"mermaid"})}),w?jsx("div",{className:"pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end",children:jsxs("div",{className:"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:[h?jsx(Pt,{chart:d,config:r==null?void 0:r.config}):null,u?jsx(He,{code:d}):null,C?jsx(Lt,{chart:d,config:r==null?void 0:r.config}):null]})}):null,jsx("div",{className:"rounded-md border border-border bg-background",children:jsx(Jn,{chart:d,config:r==null?void 0:r.config,showControls:k})})]})})}let p=Ve(i,"code");return jsx(rt,{className:t,code:d,isIncomplete:a,language:m,children:p?jsxs(Fragment,{children:[jsx(ut,{code:d,language:m}),jsx(He,{})]}):null})},so=memo(Yn,(e,t)=>e.className===t.className&&ke(e.node,t.node));so.displayName="MarkdownCode";var ao=memo(ht,(e,t)=>e.className===t.className&&ke(e.node,t.node));ao.displayName="MarkdownImg";var io=memo(({children:e,node:t,...o})=>{let s=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");if(s.length===1&&isValidElement(s[0])){let r=s[0].props.node,i=r==null?void 0:r.tagName;if(i==="img")return jsx(Fragment,{children:e});if(i==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{...o,children:e})},(e,t)=>N(e,t));io.displayName="MarkdownParagraph";var lo={ol:je,li:At,ul:jt,hr:zt,strong:qt,a:_t,h1:Zt,h2:Wt,h3:$t,h4:Ft,h5:Ut,h6:Xt,table:Jt,thead:Kt,tbody:Gt,tr:Yt,th:Qt,td:eo,blockquote:to,code:so,img:ao,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:oo,sub:no,p:io,section:ro};var Qn=/^[ \t]{0,3}(`{3,}|~{3,})/,er=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,ze=e=>{let t=e.split(`
|
|
10
|
-
`),o=null,n=0;for(let s of t){let r=Qn.exec(s);if(o===null){if(r){let i=r[1];o=i[0],n=i.length;}}else if(r){let i=r[1],c=i[0],a=i.length;c===o&&a>=n&&(o=null,n=0);}}return o!==null},co=e=>{let t=e.split(`
|
|
11
|
-
`);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&er.test(n))return true}return false};var mo=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var uo=[],fo={allowDangerousHtml:true},Ce=new WeakMap,_e=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,s=t.remarkPlugins,r=t.remarkRehypeOptions;if(!(n||s||r)){let d="default";return this.keyCache.set(t,d),d}let i=d=>{if(!d||d.length===0)return "";let p="";for(let g=0;g<d.length;g+=1){let b=d[g];if(g>0&&(p+=","),Array.isArray(b)){let[h,u]=b;if(typeof h=="function"){let C=Ce.get(h);C||(C=h.name,Ce.set(h,C)),p+=C;}else p+=String(h);p+=":",p+=JSON.stringify(u);}else if(typeof b=="function"){let h=Ce.get(b);h||(h=b.name,Ce.set(b,h)),p+=h;}else p+=String(b);}return p},c=i(n),a=i(s),l=r?JSON.stringify(r):"",m=`${a}::${c}::${l}`;return this.keyCache.set(t,m),m}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 s=this.cache.keys().next().value;s&&this.cache.delete(s);}this.cache.set(n,o);}clear(){this.cache.clear();}},go=new _e,Ze=e=>{let t=dr(e),o=e.children||"";return br(t.runSync(t.parse(o),o),e)},dr=e=>{let t=go.get(e);if(t)return t;let o=pr(e);return go.set(e,o),o},mr=e=>e.some(t=>Array.isArray(t)?t[0]===po:t===po),pr=e=>{let t=e.rehypePlugins||uo,o=e.remarkPlugins||uo,n=mr(t)?o:[...o,mo],s=e.remarkRehypeOptions?{...fo,...e.remarkRehypeOptions}:fo;return unified().use(ar).use(n).use(ir,s).use(t)},bo=e=>e,ur=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},fr=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let s=e.properties[n],r=urlAttributes[n];(r===null||r.includes(e.tagName))&&(e.properties[n]=(o=t(String(s||""),n,e))!=null?o:void 0);}},gr=(e,t,o,n,s,r)=>{let i=false;return n?i=!n.includes(e.tagName):s&&(i=s.includes(e.tagName)),!i&&r&&typeof t=="number"&&(i=!r(e,t,o)),i},br=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:s,skipHtml:r,unwrapDisallowed:i,urlTransform:c}=t;if(o||n||s||r||c){let l=c||bo;visit(e,(m,d,p)=>{if(m.type==="raw"&&p&&typeof d=="number")return ur(p,d,r,m.value),d;if(m.type==="element"&&(fr(m,l),gr(m,d,p,n,s,o)&&p&&typeof d=="number"))return i&&m.children?p.children.splice(d,1,...m.children):p.children.splice(d,1),d});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var yr=/\[\^[\w-]{1,200}\](?!:)/,wr=/\[\^[\w-]{1,200}\]:/;var kr=/<(\w+)[\s>]/,Cr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ho=new Map,yo=new Map,vr=e=>{let t=e.toLowerCase(),o=ho.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return ho.set(t,n),n},xr=e=>{let t=e.toLowerCase(),o=yo.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return yo.set(t,n),n},wo=(e,t)=>{if(Cr.has(t.toLowerCase()))return 0;let o=e.match(vr(t));if(!o)return 0;let n=0;for(let s of o)s.trimEnd().endsWith("/>")||(n+=1);return n},ko=(e,t)=>{let o=e.match(xr(t));return o?o.length:0},Pr=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},We=e=>{let t=yr.test(e),o=wr.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),s=[],r=[],i=false;for(let c of n){let a=c.raw,l=s.length;if(r.length>0){s[l-1]+=a;let m=r.at(-1),d=wo(a,m),p=ko(a,m);for(let g=0;g<d;g+=1)r.push(m);for(let g=0;g<p;g+=1)r.length>0&&r.at(-1)===m&&r.pop();continue}if(c.type==="html"&&c.block){let m=a.match(kr);if(m){let d=m[1],p=wo(a,d),g=ko(a,d);p>g&&r.push(d);}}if(l>0&&!i){let m=s[l-1];if(Pr(m)%2===1){s[l-1]=m+a;continue}}s.push(a),c.type!=="space"&&(i=c.type==="code");}return s};var Co=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let s=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(s,(r,i,c,a)=>{let l=c.replace(/\n\n/g,`
|
|
12
|
-
<!---->
|
|
13
|
-
`);return i+l+a});}return o};var Br=/^[ \t]*<[\w!/?-]/,Dr=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Or=e=>typeof e!="string"||e.length===0||!Br.test(e)?e:e.replace(Dr,"$1"),xo,Po,ve={...defaultSchema,protocols:{...defaultSchema.protocols,href:[...(Po=(xo=defaultSchema.protocols)==null?void 0:xo.href)!=null?Po:[],"tel"]}},Fe={raw:po,sanitize:[To,ve],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Vr={gfm:[Er,{}]},vo=Object.values(Fe),Ar=Object.values(Vr),jr={block:" \u258B",circle:" \u25CF"},zr={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0,linkSafety:{enabled:true}},R=createContext(zr),No=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:s,...r})=>{let i=typeof e=="string"&&o?Or(e):e;return jsx(Re.Provider,{value:s,children:jsx(Ze,{...r,children:i})})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete)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(s=>{var r,i;return ((r=e.components)==null?void 0:r[s])!==((i=t.components)==null?void 0:i[s])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});No.displayName="Block";var qr=["github-light","github-dark"],_r=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:n=false,components:s,rehypePlugins:r=vo,remarkPlugins:i=Ar,className:c,shikiTheme:a=qr,mermaid:l,controls:m=true,isAnimating:d=false,animated:p,BlockComponent:g=No,parseMarkdownIntoBlocksFn:b=We,caret:h,plugins:u,remend:C,linkSafety:k={enabled:true},allowedTags:w,...T})=>{let H=useId(),[S,B]=useTransition(),O=useMemo(()=>w?Object.keys(w):[],[w]),E=useMemo(()=>{if(typeof e!="string")return "";let x=t==="streaming"&&o?Hr(e,C):e;return O.length>0&&(x=Co(x,O)),x},[e,t,o,C,O]),I=useMemo(()=>b(E),[E,b]),[z,v]=useState(I);useEffect(()=>{t==="streaming"?B(()=>{v(I);}):v(I);},[I,t]);let L=t==="streaming"?z:I,ce=useMemo(()=>L.map((x,V)=>`${H}-${V}`),[L.length,H]),Pe=useMemo(()=>p?p===true?Q():Q(p):null,[p]),Ue=useMemo(()=>{var x,V;return {shikiTheme:(V=(x=u==null?void 0:u.code)==null?void 0:x.getThemes())!=null?V:a,controls:m,isAnimating:d,mode:t,mermaid:l,linkSafety:k}},[a,m,d,t,l,k,u==null?void 0:u.code]),Xe=useMemo(()=>({...lo,...s}),[s]),Je=useMemo(()=>{let x=[];return u!=null&&u.cjk&&(x=[...x,...u.cjk.remarkPluginsBefore]),x=[...x,...i],u!=null&&u.cjk&&(x=[...x,...u.cjk.remarkPluginsAfter]),u!=null&&u.math&&(x=[...x,u.math.remarkPlugin]),x},[i,u==null?void 0:u.math,u==null?void 0:u.cjk]),Ke=useMemo(()=>{var V;let x=r;if(w&&Object.keys(w).length>0&&r===vo){let Te={...ve,tagNames:[...(V=ve.tagNames)!=null?V:[],...Object.keys(w)],attributes:{...ve.attributes,...w}};x=[Fe.raw,[To,Te],Fe.harden];}return u!=null&&u.math&&(x=[...x,u.math.rehypePlugin]),Pe&&d&&(x=[...x,Pe.rehypePlugin]),x},[r,u==null?void 0:u.math,Pe,d,w]),Me=useMemo(()=>{if(!d||L.length===0)return false;let x=L.at(-1);return ze(x)||co(x)},[d,L]),Eo=useMemo(()=>h&&d&&!Me?{"--streamdown-caret":`"${jr[h]}"`}:void 0,[h,d,Me]);return t==="static"?jsx(pe.Provider,{value:u!=null?u:null,children:jsx(R.Provider,{value:Ue,children:jsx("div",{className:f("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",c),children:jsx(Ze,{components:Xe,rehypePlugins:Ke,remarkPlugins:Je,...T,children:E})})})}):jsx(pe.Provider,{value:u!=null?u:null,children:jsx(R.Provider,{value:Ue,children:jsxs("div",{className:f("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",h&&!Me?"*:last:after:inline *:last:after:align-baseline *:last:after:content-[var(--streamdown-caret)]":null,c),style:Eo,children:[L.length===0&&h&&d&&jsx("span",{}),L.map((x,V)=>{let Te=V===L.length-1,Ho=d&&Te&&ze(x);return jsx(g,{components:Xe,content:x,index:V,isIncomplete:Ho,rehypePlugins:Ke,remarkPlugins:Je,shouldNormalizeHtmlIndentation:n,shouldParseIncompleteMarkdown:o,...T},ce[V])})]})})})},(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.normalizeHtmlIndentation===t.normalizeHtmlIndentation);_r.displayName="Streamdown";var So=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:s=.1,showControls:r=true,initialZoom:i=1,fullscreen:c=false})=>{let a=useRef(null),l=useRef(null),[m,d]=useState(i),[p,g]=useState({x:0,y:0}),[b,h]=useState(false),[u,C]=useState({x:0,y:0}),[k,w]=useState({x:0,y:0}),T=useCallback(v=>{d(L=>Math.max(o,Math.min(n,L+v)));},[o,n]),H=useCallback(()=>{T(s);},[T,s]),S=useCallback(()=>{T(-s);},[T,s]),B=useCallback(()=>{d(i),g({x:0,y:0});},[i]),O=useCallback(v=>{v.preventDefault();let L=v.deltaY>0?-s:s;T(L);},[T,s]),E=useCallback(v=>{if(v.button!==0||v.isPrimary===false)return;h(true),C({x:v.clientX,y:v.clientY}),w(p);let L=v.currentTarget;L instanceof HTMLElement&&L.setPointerCapture(v.pointerId);},[p]),I=useCallback(v=>{if(!b)return;v.preventDefault();let L=v.clientX-u.x,ce=v.clientY-u.y;g({x:k.x+L,y:k.y+ce});},[b,u,k]),z=useCallback(v=>{h(false);let L=v.currentTarget;L instanceof HTMLElement&&L.releasePointerCapture(v.pointerId);},[]);return useEffect(()=>{let v=a.current;if(v)return v.addEventListener("wheel",O,{passive:false}),()=>{v.removeEventListener("wheel",O);}},[O]),useEffect(()=>{let v=l.current;if(v&&b)return document.body.style.userSelect="none",v.addEventListener("pointermove",I,{passive:false}),v.addEventListener("pointerup",z),v.addEventListener("pointercancel",z),()=>{document.body.style.userSelect="",v.removeEventListener("pointermove",I),v.removeEventListener("pointerup",z),v.removeEventListener("pointercancel",z);}},[b,I,z]),jsxs("div",{className:f("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:a,style:{cursor:b?"grabbing":"grab"},children:[r?jsxs("div",{className:f("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",c?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:"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:m>=n,onClick:H,title:"Zoom in",type:"button",children:jsx(lt,{size:16})}),jsx("button",{className:"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:m<=o,onClick:S,title:"Zoom out",type:"button",children:jsx(ct,{size:16})}),jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:B,title:"Reset zoom and pan",type:"button",children:jsx(it,{size:16})})]}):null,jsx("div",{className:f("flex-1 origin-center transition-transform duration-150 ease-out",c?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:E,ref:l,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${m})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Nt=({chart:e,className:t,config:o,fullscreen:n=false,showControls:s=true})=>{let[r,i]=useState(null),[c,a]=useState(false),[l,m]=useState(""),[d,p]=useState(""),[g,b]=useState(0),{mermaid:h}=useContext(R),u=G(),C=h==null?void 0:h.errorComponent,{shouldRender:k,containerRef:w}=Ge({immediate:n});if(useEffect(()=>{if(!k)return;if(!u){i("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{i(null),a(!0);let S=u.getMermaid(o),B=e.split("").reduce((I,z)=>(I<<5)-I+z.charCodeAt(0)|0,0),O=`mermaid-${Math.abs(B)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:E}=await S.render(O,e);m(E),p(E);}catch(S){if(!(d||l)){let B=S instanceof Error?S.message:"Failed to render Mermaid chart";i(B);}}finally{a(false);}})();},[e,o,g,k,u]),!(k||l||d))return jsx("div",{className:f("my-4 min-h-[200px]",t),ref:w});if(c&&!l&&!d)return jsx("div",{className:f("my-4 flex justify-center p-4",t),ref:w,children:jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!l&&!d){let H=()=>b(S=>S+1);return C?jsx("div",{ref:w,children:jsx(C,{chart:e,error:r,retry:H})}):jsxs("div",{className:f("rounded-md bg-red-50 p-4",t),ref:w,children:[jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),jsxs("details",{className:"mt-2",children:[jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let T=l||d;return jsx("div",{className:f("size-full",t),"data-streamdown":"mermaid",ref:w,children:jsx(So,{className:f(n?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:s,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:f("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:T},role:"img"})})})};export{Q as a,Ie as b,Qe as c,Ks as d,Nt as e,bo as f,We as g,Or as h,Fe as i,Vr as j,R as k,No as l,_r as m};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {k,d,c}from'./chunk-RLXIAIE6.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var L=({code:s,language:t,raw:e,className:n,...d$1})=>{let{shikiTheme:l}=useContext(k),o=d(),[m,i]=useState(e);return useEffect(()=>{if(!o){i(e);return}let g=o.highlight({code:s,language:t,themes:l},p=>{i(p);});g&&i(g);},[s,t,l,o,e]),jsx(c,{className:n,language:t,result:m,...d$1})};export{L as HighlightedCodeBlockBody};
|
package/dist/mermaid-3ZIDBTTL.js
DELETED