streamdown-prism 2.1.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 +113 -0
- package/dist/chunk-N537QM36.js +12 -0
- package/dist/chunk-NJFWWDMZ.cjs +12 -0
- package/dist/code-block-7PYKXEZZ.cjs +3 -0
- package/dist/code-block-SIO7R2CF.js +3 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +245 -0
- package/dist/index.d.ts +245 -0
- package/dist/index.js +2 -0
- package/dist/mermaid-L67ZEL4M.js +2 -0
- package/dist/mermaid-ROHDMRLI.cjs +2 -0
- package/package.json +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Streamdown-Prism
|
|
2
|
+
|
|
3
|
+
A minimal fork of [streamdown](https://github.com/vercel/streamdown) that uses **Prism** instead of **Shiki** for code syntax highlighting.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/streamdown-prism)
|
|
6
|
+
|
|
7
|
+
## Why This Fork?
|
|
8
|
+
|
|
9
|
+
The original streamdown package uses Shiki for syntax highlighting, which:
|
|
10
|
+
- Requires async loading of language grammars
|
|
11
|
+
- Has a larger bundle size due to TextMate grammars
|
|
12
|
+
- Loads themes and languages from a CDN
|
|
13
|
+
|
|
14
|
+
This fork replaces Shiki with [prism-react-renderer](https://github.com/FormidableLabs/prism-react-renderer), providing:
|
|
15
|
+
- **Synchronous highlighting** - No async loading, instant rendering
|
|
16
|
+
- **Smaller bundle** - Prism's grammars are more lightweight
|
|
17
|
+
- **No CDN dependency** - Everything is bundled locally
|
|
18
|
+
- **Simpler setup** - No need to configure theme/language loading
|
|
19
|
+
|
|
20
|
+
## Differences from Original
|
|
21
|
+
|
|
22
|
+
| Feature | streamdown (original) | streamdown-prism (this fork) |
|
|
23
|
+
|---------|----------------------|------------------------------|
|
|
24
|
+
| Highlighter | Shiki | Prism |
|
|
25
|
+
| Loading | Async (CDN) | Sync (bundled) |
|
|
26
|
+
| Languages | 100+ via CDN | ~30 built-in |
|
|
27
|
+
| Themes | Many via CDN | github-light, github-dark, oneDark |
|
|
28
|
+
|
|
29
|
+
### Not Included
|
|
30
|
+
|
|
31
|
+
This fork does not include the optional plugin packages from the original monorepo:
|
|
32
|
+
- `@streamdown/math` - LaTeX/KaTeX rendering
|
|
33
|
+
- `@streamdown/cjk` - CJK text support
|
|
34
|
+
- `@streamdown/mermaid` - Mermaid diagrams (built-in mermaid support still works)
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm i streamdown-prism
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then, update your Tailwind `globals.css` to include the following:
|
|
43
|
+
|
|
44
|
+
```css
|
|
45
|
+
@source "../node_modules/streamdown-prism/dist/*.js";
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Make sure the path matches the location of the `node_modules` folder in your project.
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { useChat } from "@ai-sdk/react";
|
|
54
|
+
import { Streamdown, prism } from "streamdown-prism";
|
|
55
|
+
|
|
56
|
+
export default function Chat() {
|
|
57
|
+
const { messages, status } = useChat();
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div>
|
|
61
|
+
{messages.map(message => (
|
|
62
|
+
<div key={message.id}>
|
|
63
|
+
{message.role === 'user' ? 'User: ' : 'AI: '}
|
|
64
|
+
{message.parts.map((part, index) =>
|
|
65
|
+
part.type === 'text' ? (
|
|
66
|
+
<Streamdown
|
|
67
|
+
key={index}
|
|
68
|
+
plugins={{ code: prism }}
|
|
69
|
+
isAnimating={status === 'streaming'}
|
|
70
|
+
>
|
|
71
|
+
{part.text}
|
|
72
|
+
</Streamdown>
|
|
73
|
+
) : null,
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
))}
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Supported Languages
|
|
83
|
+
|
|
84
|
+
The built-in Prism plugin supports these languages:
|
|
85
|
+
- javascript, typescript, jsx, tsx
|
|
86
|
+
- python, java, go, rust, ruby, php, swift, kotlin, scala
|
|
87
|
+
- c, cpp, csharp, objectivec
|
|
88
|
+
- sql, bash/shell, json, yaml, xml, html, css
|
|
89
|
+
- markdown, graphql, diff, r
|
|
90
|
+
|
|
91
|
+
Language aliases like `js`, `ts`, `py`, `sh` are also supported.
|
|
92
|
+
|
|
93
|
+
### Custom Themes
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import { createPrismPlugin } from "streamdown-prism";
|
|
97
|
+
|
|
98
|
+
const customPrism = createPrismPlugin({
|
|
99
|
+
themes: ["github-light", "oneDark"], // [light theme, dark theme]
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
<Streamdown plugins={{ code: customPrism }}>
|
|
103
|
+
{content}
|
|
104
|
+
</Streamdown>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Credits
|
|
108
|
+
|
|
109
|
+
This is a fork of [streamdown](https://github.com/vercel/streamdown) by [Vercel](https://vercel.com). All credit for the core streaming markdown functionality goes to the original authors.
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
Apache-2.0 (same as original)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {createContext,lazy,memo,useContext,isValidElement,useId,useTransition,useMemo,useState,useEffect,useCallback,Suspense,useRef}from'react';import {harden}from'rehype-harden';import Jt from'rehype-raw';import ro,{defaultSchema}from'rehype-sanitize';import Dn from'remark-gfm';import jn from'remend';import {jsx,Fragment,jsxs}from'react/jsx-runtime';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import mn from'remark-parse';import pn from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';import {Prism}from'prism-react-renderer';var go=300,bo="300px",ho=500;function $e(e={}){let{immediate:t=false,debounceDelay:o=go,rootMargin:n=bo,idleTimeout:l=ho}=e,[s,d]=useState(false),c=useRef(null),r=useRef(null),a=useRef(null),p=useMemo(()=>f=>{let i=Date.now();return window.setTimeout(()=>{f({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-i))});},1)},[]),u=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(f,i)=>window.requestIdleCallback(f,i):p,[p]),m=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?f=>window.cancelIdleCallback(f):f=>{clearTimeout(f);},[]);return useEffect(()=>{if(t){d(true);return}let f=c.current;if(!f)return;r.current&&(clearTimeout(r.current),r.current=null),a.current&&(m(a.current),a.current=null);let i=()=>{r.current&&(clearTimeout(r.current),r.current=null),a.current&&(m(a.current),a.current=null);},b=C=>{a.current=u(x=>{x.timeRemaining()>0||x.didTimeout?(d(true),C.disconnect()):a.current=u(()=>{d(true),C.disconnect();},{timeout:l/2});},{timeout:l});},y=C=>{i(),r.current=window.setTimeout(()=>{var H,I;let x=C.takeRecords();(x.length===0||(I=(H=x.at(-1))==null?void 0:H.isIntersecting)!=null&&I)&&b(C);},o);},w=(C,x)=>{C.isIntersecting?y(x):i();},v=new IntersectionObserver(C=>{for(let x of C)w(x,v);},{rootMargin:n,threshold:0});return v.observe(f),()=>{r.current&&clearTimeout(r.current),a.current&&m(a.current),v.disconnect();}},[t,o,n,l,m,u]),{shouldRender:s,containerRef:c}}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"})}),F=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"})}),$=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"})}),Ze=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"})]}),We=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"})}),_e=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"})}),re=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"})}),xe=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"})}),Xe=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"})}),Ue=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"})});var g=(...e)=>twMerge(clsx(e)),q=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,l=URL.createObjectURL(n),s=document.createElement("a");s.href=l,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(l);};var xo=createContext({code:""}),se=()=>useContext(xo);var Pe=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:l,code:s,...d})=>{let[c,r]=useState(false),a=useRef(0),{code:p}=se(),{isAnimating:u}=useContext(S),m=s!=null?s:p,f=async()=>{var b;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(m),r(!0),e==null||e(),a.current=window.setTimeout(()=>r(!1),o));}catch(y){t==null||t(y);}};useEffect(()=>()=>{window.clearTimeout(a.current);},[]);let i=c?J:F;return jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:"Copy Code",type:"button",...d,children:n!=null?n:jsx(i,{size:14})})};var Fe={"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"},Ke=({onDownload:e,onError:t,language:o,children:n,className:l,code:s,...d})=>{let{code:c}=se(),{isAnimating:r}=useContext(S),a=s!=null?s:c,u=`file.${o&&o in Fe?Fe[o]:"txt"}`,m="text/plain",f=()=>{try{q(u,a,m),e==null||e();}catch(i){t==null||t(i);}};return jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),"data-streamdown":"code-block-download-button",disabled:r,onClick:f,title:"Download file",type:"button",...d,children:n!=null?n:jsx($,{size:14})})};var Le=()=>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(Ze,{className:"size-4 animate-spin"})})]});var Ro=/\.[^/.]+$/,Ye=({node:e,className:t,src:o,alt:n,...l})=>{let s=async()=>{if(o)try{let c=await(await fetch(o)).blob(),a=new URL(o,window.location.origin).pathname.split("/").pop()||"",p=a.split(".").pop(),u=a.includes(".")&&p!==void 0&&p.length<=4,m="";if(u)m=a;else {let f=c.type,i="png";f.includes("jpeg")||f.includes("jpg")?i="jpg":f.includes("png")?i="png":f.includes("svg")?i="svg":f.includes("gif")?i="gif":f.includes("webp")&&(i="webp"),m=`${(n||a||"image").replace(Ro,"")}.${i}`;}q(m,c,c.type);}catch(d){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:g("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...l}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsx("button",{className:g("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:s,title:"Download image",type:"button",children:jsx($,{size:14})})]}):null};var Q=0,Do=()=>{Q+=1,Q===1&&(document.body.style.overflow="hidden");},jo=()=>{Q=Math.max(0,Q-1),Q===0&&(document.body.style.overflow="");},tt=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let[l,s]=useState(false),d=useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3);}catch(r){}},[e]),c=useCallback(()=>{n(),o();},[n,o]);return useEffect(()=>{if(t){Do();let r=a=>{a.key==="Escape"&&o();};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r),jo();}}},[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:r=>{r.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:r=>r.stopPropagation(),onKeyDown:r=>r.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(re,{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(xe,{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:g("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:d,type:"button",children:l?jsxs(Fragment,{children:[jsx(J,{size:14}),jsx("span",{children:"Copied"})]}):jsxs(Fragment,{children:[jsx(F,{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(xe,{size:14}),jsx("span",{children:"Open link"})]})]})]})}):null};var ie=createContext(null),ot=()=>useContext(ie),Tr=()=>{var t;let e=ot();return (t=e==null?void 0:e.code)!=null?t:null},G=()=>{var t;let e=ot();return (t=e==null?void 0:e.mermaid)!=null?t:null};var nt=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((l,s)=>{let d="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),c=new Image;c.crossOrigin="anonymous",c.onload=()=>{let r=document.createElement("canvas"),a=c.width*o,p=c.height*o;r.width=a,r.height=p;let u=r.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(c,0,0,a,p),r.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}l(m);},"image/png");},c.onerror=()=>s(new Error("Failed to load SVG image")),c.src=d;})};var st=({chart:e,children:t,className:o,onDownload:n,config:l,onError:s})=>{let[d,c]=useState(false),r=useRef(null),{isAnimating:a}=useContext(S),p=G(),u=async m=>{try{if(m==="mmd"){q("diagram.mmd",e,"text/plain"),c(!1),n==null||n(m);return}if(!p){s==null||s(new Error("Mermaid plugin not available"));return}let f=p.getMermaid(l),i=e.split("").reduce((w,v)=>(w<<5)-w+v.charCodeAt(0)|0,0),b=`mermaid-${Math.abs(i)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await f.render(b,e);if(!y){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){q("diagram.svg",y,"image/svg+xml"),c(!1),n==null||n(m);return}if(m==="png"){let w=await nt(y);q("diagram.png",w,"image/png"),n==null||n(m),c(!1);return}}catch(f){s==null||s(f);}};return useEffect(()=>{let m=f=>{let i=f.composedPath();r.current&&!i.includes(r.current)&&c(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),jsxs("div",{className:"relative",ref:r,children:[jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:a,onClick:()=>c(!d),title:"Download diagram",type:"button",children:t!=null?t:jsx($,{size:14})}),d?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:()=>u("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:()=>u("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:()=>u("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]}):null]})};var te=0,Wo=()=>{te+=1,te===1&&(document.body.style.overflow="hidden");},_o=()=>{te=Math.max(0,te-1),te===0&&(document.body.style.overflow="");},ct=({chart:e,config:t,onFullscreen:o,onExit:n,className:l,...s})=>{let[d,c]=useState(false),{isAnimating:r,controls:a}=useContext(S),p=(()=>{if(typeof a=="boolean")return a;let m=a.mermaid;return m===false?false:m===true||m===void 0?true:m.panZoom!==false})(),u=()=>{c(!d);};return useEffect(()=>{if(d){Wo();let m=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),_o();}}},[d]),useEffect(()=>{d?o==null||o():n&&n();},[d,o,n]),jsxs(Fragment,{children:[jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),disabled:r,onClick:u,title:"View fullscreen",type:"button",...s,children:jsx(We,{size:14})}),d?jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:u,onKeyDown:m=>{m.key==="Escape"&&u();},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:u,title:"Exit fullscreen",type:"button",children:jsx(re,{size:20})}),jsx("div",{className:"flex size-full items-center justify-center p-4",onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:jsx(lt,{chart:e,className:"size-full [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:p})})]}):null]})};var le=e=>{var s,d;let t=[],o=[],n=e.querySelectorAll("thead th");for(let c of n)t.push(((s=c.textContent)==null?void 0:s.trim())||"");let l=e.querySelectorAll("tbody tr");for(let c of l){let r=[],a=c.querySelectorAll("td");for(let p of a)r.push(((d=p.textContent)==null?void 0:d.trim())||"");o.push(r);}return {headers:t,rows:o}},ce=e=>{let{headers:t,rows:o}=e,n=c=>{let r=false,a=false;for(let p of c){if(p==='"'){r=true,a=true;break}(p===","||p===`
|
|
3
|
+
`)&&(r=true);}return r?a?`"${c.replace(/"/g,'""')}"`:`"${c}"`:c},l=t.length>0?o.length+1:o.length,s=new Array(l),d=0;t.length>0&&(s[d]=t.map(n).join(","),d+=1);for(let c of o)s[d]=c.map(n).join(","),d+=1;return s.join(`
|
|
4
|
+
`)},dt=e=>{let{headers:t,rows:o}=e,n=c=>{let r=false;for(let p of c)if(p===" "||p===`
|
|
5
|
+
`||p==="\r"){r=true;break}if(!r)return c;let a=[];for(let p of c)p===" "?a.push("\\t"):p===`
|
|
6
|
+
`?a.push("\\n"):p==="\r"?a.push("\\r"):a.push(p);return a.join("")},l=t.length>0?o.length+1:o.length,s=new Array(l),d=0;t.length>0&&(s[d]=t.map(n).join(" "),d+=1);for(let c of o)s[d]=c.map(n).join(" "),d+=1;return s.join(`
|
|
7
|
+
`)},Te=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("")},mt=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),l=0,s=t.map(c=>Te(c));n[l]=`| ${s.join(" | ")} |`,l+=1;let d=new Array(t.length);for(let c=0;c<t.length;c+=1)d[c]="---";n[l]=`| ${d.join(" | ")} |`,l+=1;for(let c of o)if(c.length<t.length){let r=new Array(t.length);for(let a=0;a<t.length;a+=1)r[a]=a<c.length?Te(c[a]):"";n[l]=`| ${r.join(" | ")} |`,l+=1;}else {let r=c.map(a=>Te(a));n[l]=`| ${r.join(" | ")} |`,l+=1;}return n.join(`
|
|
8
|
+
`)};var gt=({children:e,className:t,onCopy:o,onError:n,timeout:l=2e3})=>{let[s,d]=useState(false),[c,r]=useState(false),a=useRef(null),p=useRef(0),{isAnimating:u}=useContext(S),m=async i=>{var b,y;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.write)){n==null||n(new Error("Clipboard API not available"));return}try{let w=(y=a.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"]'),v=w==null?void 0:w.querySelector("table");if(!v){n==null||n(new Error("Table not found"));return}let C=le(v),x=i==="csv"?ce(C):dt(C),O=new ClipboardItem({"text/plain":new Blob([x],{type:"text/plain"}),"text/html":new Blob([v.outerHTML],{type:"text/html"})});await navigator.clipboard.write([O]),r(!0),d(!1),o==null||o(i),p.current=window.setTimeout(()=>r(!1),l);}catch(w){n==null||n(w);}};useEffect(()=>{let i=b=>{let y=b.composedPath();a.current&&!y.includes(a.current)&&d(false);};return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i),window.clearTimeout(p.current);}},[]);let f=c?J:F;return jsxs("div",{className:"relative",ref:a,children:[jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>d(!s),title:"Copy table",type:"button",children:e!=null?e:jsx(f,{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:()=>m("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:()=>m("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var ht=({children:e,className:t,onDownload:o,onError:n})=>{let[l,s]=useState(false),d=useRef(null),{isAnimating:c}=useContext(S),r=a=>{var p;try{let u=(p=d.current)==null?void 0:p.closest('[data-streamdown="table-wrapper"]'),m=u==null?void 0:u.querySelector("table");if(!m){n==null||n(new Error("Table not found"));return}let f=le(m),i=a==="csv"?ce(f):mt(f);q(`table.${a==="csv"?"csv":"md"}`,i,a==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(a);}catch(u){n==null||n(u);}};return useEffect(()=>{let a=p=>{let u=p.composedPath();d.current&&!u.includes(d.current)&&s(false);};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a);}},[]),jsxs("div",{className:"relative",ref:d,children:[jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:()=>s(!l),title:"Download table",type:"button",children:e!=null?e:jsx($,{size:14})}),l?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:()=>r("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:()=>r("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var wt=({children:e,className:t,showControls:o,...n})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o?jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(gt,{}),jsx(ht,{})]}):null,jsx("div",{className:"overflow-x-auto overscroll-y-auto",children:jsx("table",{className:g("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});var en=lazy(()=>import('./code-block-SIO7R2CF.js').then(e=>({default:e.CodeBlock}))),tn=lazy(()=>import('./mermaid-L67ZEL4M.js').then(e=>({default:e.Mermaid}))),on=/language-([^\s]+)/;function be(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,l=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)&&(l==null?void 0:l.line)===(s==null?void 0:s.line)&&(l==null?void 0:l.column)===(s==null?void 0:s.column)}function L(e,t){return e.className===t.className&&be(e.node,t.node)}var Se=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ue=(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},He=memo(({children:e,className:t,node:o,...n})=>jsx("ol",{className:g("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>L(e,t));He.displayName="MarkdownOl";var Ct=memo(({children:e,className:t,node:o,...n})=>jsx("li",{className:g("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&be(e.node,t.node));Ct.displayName="MarkdownLi";var xt=memo(({children:e,className:t,node:o,...n})=>jsx("ul",{className:g("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>L(e,t));xt.displayName="MarkdownUl";var Pt=memo(({className:e,node:t,...o})=>jsx("hr",{className:g("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>L(e,t));Pt.displayName="MarkdownHr";var Mt=memo(({children:e,className:t,node:o,...n})=>jsx("span",{className:g("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>L(e,t));Mt.displayName="MarkdownStrong";var nn=({children:e,className:t,href:o,node:n,...l})=>{let{linkSafety:s}=useContext(S),[d,c]=useState(false),r=o==="streamdown:incomplete-link",a=useCallback(async f=>{if(!(!(s!=null&&s.enabled&&o)||r)){if(f.preventDefault(),s.onLinkCheck&&await s.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}c(true);}},[s,o,r]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{c(false);},[]),m={url:o!=null?o:"",isOpen:d,onClose:u,onConfirm:p};return s!=null&&s.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:g("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",onClick:a,type:"button",children:e}),s.renderModal?s.renderModal(m):jsx(tt,{...m})]}):jsx("a",{className:g("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...l,children:e})},Lt=memo(nn,(e,t)=>L(e,t)&&e.href===t.href);Lt.displayName="MarkdownA";var Tt=memo(({children:e,className:t,node:o,...n})=>jsx("h1",{className:g("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>L(e,t));Tt.displayName="MarkdownH1";var Nt=memo(({children:e,className:t,node:o,...n})=>jsx("h2",{className:g("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>L(e,t));Nt.displayName="MarkdownH2";var St=memo(({children:e,className:t,node:o,...n})=>jsx("h3",{className:g("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>L(e,t));St.displayName="MarkdownH3";var Rt=memo(({children:e,className:t,node:o,...n})=>jsx("h4",{className:g("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>L(e,t));Rt.displayName="MarkdownH4";var Ht=memo(({children:e,className:t,node:o,...n})=>jsx("h5",{className:g("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>L(e,t));Ht.displayName="MarkdownH5";var It=memo(({children:e,className:t,node:o,...n})=>jsx("h6",{className:g("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>L(e,t));It.displayName="MarkdownH6";var Et=memo(({children:e,className:t,node:o,...n})=>{let{controls:l}=useContext(S),s=Se(l,"table");return jsx(wt,{className:t,showControls:s,...n,children:e})},(e,t)=>L(e,t));Et.displayName="MarkdownTable";var Dt=memo(({children:e,className:t,node:o,...n})=>jsx("thead",{className:g("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>L(e,t));Dt.displayName="MarkdownThead";var jt=memo(({children:e,className:t,node:o,...n})=>jsx("tbody",{className:g("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>L(e,t));jt.displayName="MarkdownTbody";var Vt=memo(({children:e,className:t,node:o,...n})=>jsx("tr",{className:g("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>L(e,t));Vt.displayName="MarkdownTr";var Ot=memo(({children:e,className:t,node:o,...n})=>jsx("th",{className:g("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>L(e,t));Ot.displayName="MarkdownTh";var Bt=memo(({children:e,className:t,node:o,...n})=>jsx("td",{className:g("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>L(e,t));Bt.displayName="MarkdownTd";var At=memo(({children:e,className:t,node:o,...n})=>jsx("blockquote",{className:g("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>L(e,t));At.displayName="MarkdownBlockquote";var qt=memo(({children:e,className:t,node:o,...n})=>jsx("sup",{className:g("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>L(e,t));qt.displayName="MarkdownSup";var zt=memo(({children:e,className:t,node:o,...n})=>jsx("sub",{className:g("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>L(e,t));zt.displayName="MarkdownSub";var $t=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=r=>{var m,f;if(!isValidElement(r))return false;let a=Array.isArray(r.props.children)?r.props.children:[r.props.children],p=false,u=false;for(let i of a)if(i){if(typeof i=="string")i.trim()!==""&&(p=true);else if(isValidElement(i))if(((m=i.props)==null?void 0:m["data-footnote-backref"])!==void 0)u=true;else {let b=Array.isArray(i.props.children)?i.props.children:[i.props.children];for(let y of b){if(typeof y=="string"&&y.trim()!==""){p=true;break}if(isValidElement(y)&&((f=y.props)==null?void 0:f["data-footnote-backref"])===void 0){p=true;break}}}}return u&&!p},d=Array.isArray(e)?e.map(r=>{if(!isValidElement(r))return r;if(r.type===He){let p=(Array.isArray(r.props.children)?r.props.children:[r.props.children]).filter(u=>!s(u));return p.length===0?null:{...r,props:{...r.props,children:p}}}return r}):e;return (Array.isArray(d)?d.some(r=>r!==null):d!==null)?jsx("section",{className:t,...n,children:d}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>L(e,t));$t.displayName="MarkdownSection";var rn=({node:e,className:t,children:o,...n})=>{var m,f,i;let l=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((f=e==null?void 0:e.position)==null?void 0:f.end.line),{mermaid:s,controls:d}=useContext(S),c=G();if(l)return jsx("code",{className:g("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let r=t==null?void 0:t.match(on),a=(i=r==null?void 0:r.at(1))!=null?i:"",p="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?p=o.props.children:typeof o=="string"&&(p=o),a==="mermaid"&&c){let b=Se(d,"mermaid"),y=ue(d,"download"),w=ue(d,"copy"),v=ue(d,"fullscreen"),C=ue(d,"panZoom"),x=b&&(y||w||v);return jsx(Suspense,{fallback:jsx(Le,{}),children:jsxs("div",{className:g("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[x?jsxs("div",{className:"flex items-center justify-end gap-2",children:[y?jsx(st,{chart:p,config:s==null?void 0:s.config}):null,w?jsx(Pe,{code:p}):null,v?jsx(ct,{chart:p,config:s==null?void 0:s.config}):null]}):null,jsx(tn,{chart:p,config:s==null?void 0:s.config,showControls:C})]})})}let u=Se(d,"code");return jsx(Suspense,{fallback:jsx(Le,{}),children:jsx(en,{className:g("overflow-x-auto border-border border-t",t),code:p,language:a,children:u?jsxs(Fragment,{children:[jsx(Ke,{code:p,language:a}),jsx(Pe,{})]}):null})})},Zt=memo(rn,(e,t)=>e.className===t.className&&be(e.node,t.node));Zt.displayName="MarkdownCode";var Wt=memo(Ye,(e,t)=>e.className===t.className&&be(e.node,t.node));Wt.displayName="MarkdownImg";var _t=memo(({children:e,className:t,node:o,...n})=>{var d,c;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,a=r==null?void 0:r.tagName;if(a==="img")return jsx(Fragment,{children:e});if(a==="code"&&((d=r==null?void 0:r.position)==null?void 0:d.start.line)!==((c=r==null?void 0:r.position)==null?void 0:c.end.line))return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>L(e,t));_t.displayName="MarkdownParagraph";var Xt={ol:He,li:Ct,ul:xt,hr:Pt,strong:Mt,a:Lt,h1:Tt,h2:Nt,h3:St,h4:Rt,h5:Ht,h6:It,table:Et,thead:Dt,tbody:jt,tr:Vt,th:Ot,td:Bt,blockquote:At,code:Zt,img:Wt,pre:({children:e})=>e,sup:qt,sub:zt,p:_t,section:$t};var Ut=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var Ft=[],Gt={allowDangerousHtml:true},he=new WeakMap,Ie=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,l=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||l||s)){let u="default";return this.keyCache.set(t,u),u}let d=u=>{if(!u||u.length===0)return "";let m="";for(let f=0;f<u.length;f+=1){let i=u[f];if(f>0&&(m+=","),Array.isArray(i)){let[b,y]=i;if(typeof b=="function"){let w=he.get(b);w||(w=b.name,he.set(b,w)),m+=w;}else m+=String(b);m+=":",m+=JSON.stringify(y);}else if(typeof i=="function"){let b=he.get(i);b||(b=i.name,he.set(i,b)),m+=b;}else m+=String(i);}return m},c=d(n),r=d(l),a=s?JSON.stringify(s):"",p=`${r}::${c}::${a}`;return this.keyCache.set(t,p),p}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 l=this.cache.keys().next().value;l&&this.cache.delete(l);}this.cache.set(n,o);}clear(){this.cache.clear();}},Kt=new Ie,Ee=e=>{let t=fn(e),o=e.children||"";return hn(t.runSync(t.parse(o),o),e)},fn=e=>{let t=Kt.get(e);if(t)return t;let o=bn(e);return Kt.set(e,o),o},gn=e=>e.some(t=>Array.isArray(t)?t[0]===Jt:t===Jt),bn=e=>{let t=e.rehypePlugins||Ft,o=e.remarkPlugins||Ft,n=gn(t)?o:[...o,Ut],l=e.remarkRehypeOptions?{...Gt,...e.remarkRehypeOptions}:Gt;return unified().use(mn).use(n).use(pn,l).use(t)},hn=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var wn=/\[\^[\w-]{1,200}\](?!:)/,kn=/\[\^[\w-]{1,200}\]:/,vn=/<\/(\w+)>/,Cn=/<(\w+)[\s>]/,xn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),De=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
|
+
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},Pn=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
10
|
+
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},je=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},Ve=e=>{let t=wn.test(e),o=kn.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),l=[],s=[],d=false;for(let c of n){let r=c.raw,a=l.length;if(s.length>0){if(l[a-1]+=r,c.type==="html"){let u=r.match(vn);if(u){let m=u[1];s.at(-1)===m&&s.pop();}}continue}if(c.type==="html"&&c.block){let u=r.match(Cn);if(u){let m=u[1];!r.includes(`</${m}>`)&&!xn.has(m.toLowerCase())&&s.push(m);}}if(r.trim()==="$$"&&a>0&&!d){let u=l[a-1],m=De(u),f=je(u);if(m&&f%2===1){l[a-1]=u+r;continue}}if(a>0&&Pn(r)&&!d){let u=l[a-1],m=De(u),f=je(u),i=je(r);if(m&&f%2===1&&!De(r)&&i===1){l[a-1]=u+r;continue}}l.push(r),c.type!=="space"&&(d=c.type==="code");}return l};var Ae=["javascript","typescript","jsx","tsx","python","java","sql","bash","json","css","html","xml","c","cpp","csharp","go","rust","ruby","php","swift","kotlin","scala","yaml","markdown","graphql","diff","objectivec","r","plain","markup"],Yt={js:"javascript",ts:"typescript",py:"python",sh:"bash",shell:"bash",text:"plain",plaintext:"plain",cs:"csharp","c++":"cpp","c#":"csharp",yml:"yaml",md:"markdown",gql:"graphql",objc:"objectivec"};function Qt(e){if(!e)return "plain";let t=e.toLowerCase().trim();return Yt[t]?Yt[t]:Ae.includes(t)?t:"plain"}var ye={"github-light":{fg:"#24292e",bg:"#ffffff",keyword:"#d73a49",string:"#032f62",number:"#005cc5",comment:"#6a737d",function:"#6f42c1",operator:"#d73a49",punctuation:"#24292e",className:"#6f42c1",builtin:"#005cc5"},"github-dark":{fg:"#c9d1d9",bg:"#0d1117",keyword:"#ff7b72",string:"#a5d6ff",number:"#79c0ff",comment:"#8b949e",function:"#d2a8ff",operator:"#ff7b72",punctuation:"#c9d1d9",className:"#d2a8ff",builtin:"#79c0ff"},oneDark:{fg:"#abb2bf",bg:"#282c34",keyword:"#c678dd",string:"#98c379",number:"#d19a66",comment:"#5c6370",function:"#61afef",operator:"#56b6c2",punctuation:"#abb2bf",className:"#e5c07b",builtin:"#e06c75"}},Be=new Map;function Mn(e,t,o){let n=e.slice(0,100),l=e.length>100?e.slice(-100):"";return `${t}:${o[0]}:${o[1]}:${e.length}:${n}:${l}`}function eo(e,t){let n={keyword:"keyword",string:"string",number:"number",comment:"comment",function:"function","function-variable":"function",operator:"operator",punctuation:"punctuation","class-name":"className",builtin:"builtin",boolean:"keyword",property:"function",tag:"keyword","attr-name":"function","attr-value":"string",selector:"keyword"}[e];return n&&t[n]?t[n]:t.fg}function to(e={}){var o;let t=(o=e.themes)!=null?o:["github-light","github-dark"];return {name:"prism",type:"code-highlighter",supportsLanguage(n){let l=Qt(n);return Ae.includes(l)},getSupportedLanguages(){return [...Ae]},getThemes(){return t},highlight({code:n,language:l,themes:s},d){var u,m;let c=Mn(n,l,s);if(Be.has(c))return Be.get(c);let r=Qt(l),a=(u=ye[s[0]])!=null?u:ye["github-light"],p=(m=ye[s[1]])!=null?m:ye["github-dark"];try{let f=Prism.languages[r]||Prism.languages.plain,i=Prism.tokenize(n,f),b=n.split(`
|
|
11
|
+
`),y=[],w=0;for(let C of b){let x=[],O=C,H=0;for(;H<O.length;){let I=!1,T=O.slice(H);for(let V of i){let D=typeof V=="string"?V:V.content,R=typeof D=="string"?D:String(D);if(T.startsWith(R)||R.includes(T.slice(0,Math.min(T.length,R.length)))){let k=typeof V=="string"?"plain":V.type||"plain",E=eo(k,a),_=eo(k,p);if(T.slice(0,Math.min(T.length,R.length-(R.indexOf(T.charAt(0))>=0,0))).length>0){x.push({content:T.length<=R.length?T:T.slice(0,R.length),color:E,bgColor:"transparent",htmlStyle:{"--code-dark":_,"--code-dark-bg":p.bg}}),H+=T.length<=R.length?T.length:R.length,I=!0;break}}}if(!I){x.push({content:T,color:a.fg,bgColor:"transparent",htmlStyle:{"--code-dark":p.fg,"--code-dark-bg":p.bg}});break}}x.length===0&&x.push({content:C,color:a.fg,bgColor:"transparent",htmlStyle:{"--code-dark":p.fg,"--code-dark-bg":p.bg}}),y.push(x),w+=C.length+1;}let v={bg:a.bg,fg:a.fg,tokens:y};return Be.set(c,v),d&&d(v),v}catch(f){return console.error("[Streamdown Prism] Failed to highlight code:",f),{bg:a.bg,fg:a.fg,tokens:n.split(`
|
|
12
|
+
`).map(b=>[{content:b,color:a.fg,bgColor:"transparent",htmlStyle:{"--code-dark":p.fg,"--code-dark-bg":p.bg}}])}}}}}var Ln=to();var ze={raw:Jt,sanitize:[ro,{}],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Vn={gfm:[Dn,{}]},oo=Object.values(ze),On=Object.values(Vn),Bn={block:" \u258B",circle:" \u25CF"},An={theme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0,linkSafety:{enabled:true}},S=createContext(An),so=memo(({content:e,shouldParseIncompleteMarkdown:t,index:o,...n})=>jsx(Ee,{...n,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)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(l=>{var s,d;return ((s=e.components)==null?void 0:s[l])!==((d=t.components)==null?void 0:d[l])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});so.displayName="Block";var qn=["github-light","github-dark"],zn=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=true,components:n,rehypePlugins:l=oo,remarkPlugins:s=On,className:d,theme:c=qn,mermaid:r,controls:a=true,isAnimating:p=false,BlockComponent:u=so,parseMarkdownIntoBlocksFn:m=Ve,caret:f,plugins:i,remend:b,linkSafety:y={enabled:true},allowedTags:w,...v})=>{let C=useId(),[x,O]=useTransition(),H=useMemo(()=>typeof e!="string"?"":t==="streaming"&&o?jn(e,b):e,[e,t,o,b]),I=useMemo(()=>m(H),[H,m]),[T,V]=useState(I);useEffect(()=>{t==="streaming"?O(()=>{V(I);}):V(I);},[I,t]);let D=t==="streaming"?T:I,R=useMemo(()=>D.map((N,A)=>`${C}-${A}`),[D.length,C]),k=useMemo(()=>{var N,A;return {theme:(A=(N=i==null?void 0:i.code)==null?void 0:N.getThemes())!=null?A:c,controls:a,isAnimating:p,mode:t,mermaid:r,linkSafety:y}},[c,a,p,t,r,y,i==null?void 0:i.code]),E=useMemo(()=>({...Xt,...n}),[n]),_=useMemo(()=>{let N=[];return i!=null&&i.cjk&&(N=[...N,...i.cjk.remarkPluginsBefore]),N=[...N,...s],i!=null&&i.cjk&&(N=[...N,...i.cjk.remarkPluginsAfter]),i!=null&&i.math&&(N=[...N,i.math.remarkPlugin]),N},[s,i==null?void 0:i.math,i==null?void 0:i.cjk]),ke=useMemo(()=>{var A;let N=l;if(w&&Object.keys(w).length>0&&l===oo){let po={...defaultSchema,tagNames:[...(A=defaultSchema.tagNames)!=null?A:[],...Object.keys(w)],attributes:{...defaultSchema.attributes,...w}};N=[ze.raw,[ro,po],ze.harden];}return i!=null&&i.math&&(N=[...N,i.math.rehypePlugin]),N},[l,i==null?void 0:i.math,w]),mo=useMemo(()=>f&&p?{"--streamdown-caret":`"${Bn[f]}"`}:void 0,[f,p]);return t==="static"?jsx(ie.Provider,{value:i!=null?i:null,children:jsx(S.Provider,{value:k,children:jsx("div",{className:g("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",d),children:jsx(Ee,{components:E,rehypePlugins:ke,remarkPlugins:_,...v,children:e})})})}):jsx(ie.Provider,{value:i!=null?i:null,children:jsx(S.Provider,{value:k,children:jsxs("div",{className:g("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",f?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,d),style:mo,children:[D.length===0&&f&&p&&jsx("span",{}),D.map((N,A)=>jsx(u,{components:E,content:N,index:A,rehypePlugins:ke,remarkPlugins:_,shouldParseIncompleteMarkdown:o,...v},R[A]))]})})})},(e,t)=>e.children===t.children&&e.theme===t.theme&&e.isAnimating===t.isAnimating&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety);zn.displayName="Streamdown";var co=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:l=.1,showControls:s=true,initialZoom:d=1,fullscreen:c=false})=>{let r=useRef(null),a=useRef(null),[p,u]=useState(d),[m,f]=useState({x:0,y:0}),[i,b]=useState(false),[y,w]=useState({x:0,y:0}),[v,C]=useState({x:0,y:0}),x=useCallback(k=>{u(E=>Math.max(o,Math.min(n,E+k)));},[o,n]),O=useCallback(()=>{x(l);},[x,l]),H=useCallback(()=>{x(-l);},[x,l]),I=useCallback(()=>{u(d),f({x:0,y:0});},[d]),T=useCallback(k=>{k.preventDefault();let E=k.deltaY>0?-l:l;x(E);},[x,l]),V=useCallback(k=>{if(k.button!==0||k.isPrimary===false)return;b(true),w({x:k.clientX,y:k.clientY}),C(m);let E=k.currentTarget;E instanceof HTMLElement&&E.setPointerCapture(k.pointerId);},[m]),D=useCallback(k=>{if(!i)return;k.preventDefault();let E=k.clientX-y.x,_=k.clientY-y.y;f({x:v.x+E,y:v.y+_});},[i,y,v]),R=useCallback(k=>{b(false);let E=k.currentTarget;E instanceof HTMLElement&&E.releasePointerCapture(k.pointerId);},[]);return useEffect(()=>{let k=r.current;if(k)return k.addEventListener("wheel",T,{passive:false}),()=>{k.removeEventListener("wheel",T);}},[T]),useEffect(()=>{let k=a.current;if(k&&i)return document.body.style.userSelect="none",k.addEventListener("pointermove",D,{passive:false}),k.addEventListener("pointerup",R),k.addEventListener("pointercancel",R),()=>{document.body.style.userSelect="",k.removeEventListener("pointermove",D),k.removeEventListener("pointerup",R),k.removeEventListener("pointercancel",R);}},[i,D,R]),jsxs("div",{className:g("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:r,style:{cursor:i?"grabbing":"grab"},children:[s?jsxs("div",{className:g("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm 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:p>=n,onClick:O,title:"Zoom in",type:"button",children:jsx(Xe,{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:p<=o,onClick:H,title:"Zoom out",type:"button",children:jsx(Ue,{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:I,title:"Reset zoom and pan",type:"button",children:jsx(_e,{size:16})})]}):null,jsx("div",{className:g("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:V,ref:a,role:"application",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${p})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var lt=({chart:e,className:t,config:o,fullscreen:n=false,showControls:l=true})=>{let[s,d]=useState(null),[c,r]=useState(false),[a,p]=useState(""),[u,m]=useState(""),[f,i]=useState(0),{mermaid:b}=useContext(S),y=G(),w=b==null?void 0:b.errorComponent,{shouldRender:v,containerRef:C}=$e({immediate:n});if(useEffect(()=>{if(!v)return;if(!y){d("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{d(null),r(!0);let H=y.getMermaid(o),I=e.split("").reduce((D,R)=>(D<<5)-D+R.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(I)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:V}=await H.render(T,e);p(V),m(V);}catch(H){if(!(u||a)){let I=H instanceof Error?H.message:"Failed to render Mermaid chart";d(I);}}finally{r(false);}})();},[e,o,f,v,y]),!(v||a||u))return jsx("div",{className:g("my-4 min-h-[200px]",t),ref:C});if(c&&!a&&!u)return jsx("div",{className:g("my-4 flex justify-center p-4",t),ref:C,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(s&&!a&&!u){let O=()=>i(H=>H+1);return w?jsx("div",{ref:C,children:jsx(w,{chart:e,error:s,retry:O})}):jsxs("div",{className:g("rounded-lg border border-red-200 bg-red-50 p-4",t),ref:C,children:[jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",s]}),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 x=a||u;return jsx("div",{className:g("size-full",t),"data-streamdown":"mermaid",ref:C,children:jsx(co,{className:g(n?"size-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:l,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:g("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:x},role:"img"})})})};export{g as a,xo as b,Tr as c,lt as d,Ve as e,to as f,Ln as g,ze as h,Vn as i,S as j,so as k,zn as l};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var react=require('react'),rehypeHarden=require('rehype-harden'),Jt=require('rehype-raw'),ro=require('rehype-sanitize'),Dn=require('remark-gfm'),jn=require('remend'),jsxRuntime=require('react/jsx-runtime'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),hastUtilToJsxRuntime=require('hast-util-to-jsx-runtime'),mn=require('remark-parse'),pn=require('remark-rehype'),unified=require('unified'),unistUtilVisit=require('unist-util-visit'),marked=require('marked'),prismReactRenderer=require('prism-react-renderer');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Jt__default=/*#__PURE__*/_interopDefault(Jt);var ro__default=/*#__PURE__*/_interopDefault(ro);var Dn__default=/*#__PURE__*/_interopDefault(Dn);var jn__default=/*#__PURE__*/_interopDefault(jn);var mn__default=/*#__PURE__*/_interopDefault(mn);var pn__default=/*#__PURE__*/_interopDefault(pn);var go=300,bo="300px",ho=500;function $e(e={}){let{immediate:t=false,debounceDelay:o=go,rootMargin:n=bo,idleTimeout:l=ho}=e,[s,d]=react.useState(false),c=react.useRef(null),r=react.useRef(null),a=react.useRef(null),p=react.useMemo(()=>f=>{let i=Date.now();return window.setTimeout(()=>{f({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-i))});},1)},[]),u=react.useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(f,i)=>window.requestIdleCallback(f,i):p,[p]),m=react.useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?f=>window.cancelIdleCallback(f):f=>{clearTimeout(f);},[]);return react.useEffect(()=>{if(t){d(true);return}let f=c.current;if(!f)return;r.current&&(clearTimeout(r.current),r.current=null),a.current&&(m(a.current),a.current=null);let i=()=>{r.current&&(clearTimeout(r.current),r.current=null),a.current&&(m(a.current),a.current=null);},b=C=>{a.current=u(x=>{x.timeRemaining()>0||x.didTimeout?(d(true),C.disconnect()):a.current=u(()=>{d(true),C.disconnect();},{timeout:l/2});},{timeout:l});},y=C=>{i(),r.current=window.setTimeout(()=>{var H,I;let x=C.takeRecords();(x.length===0||(I=(H=x.at(-1))==null?void 0:H.isIntersecting)!=null&&I)&&b(C);},o);},w=(C,x)=>{C.isIntersecting?y(x):i();},v=new IntersectionObserver(C=>{for(let x of C)w(x,v);},{rootMargin:n,threshold:0});return v.observe(f),()=>{r.current&&clearTimeout(r.current),a.current&&m(a.current),v.disconnect();}},[t,o,n,l,m,u]),{shouldRender:s,containerRef:c}}var J=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),F=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),$=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),Ze=e=>jsxRuntime.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsxRuntime.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),We=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),_e=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),re=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),xe=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),Xe=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),Ue=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})});var g=(...e)=>tailwindMerge.twMerge(clsx.clsx(e)),q=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,l=URL.createObjectURL(n),s=document.createElement("a");s.href=l,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(l);};var xo=react.createContext({code:""}),se=()=>react.useContext(xo);var Pe=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:l,code:s,...d})=>{let[c,r]=react.useState(false),a=react.useRef(0),{code:p}=se(),{isAnimating:u}=react.useContext(S),m=s!=null?s:p,f=async()=>{var b;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(m),r(!0),e==null||e(),a.current=window.setTimeout(()=>r(!1),o));}catch(y){t==null||t(y);}};react.useEffect(()=>()=>{window.clearTimeout(a.current);},[]);let i=c?J:F;return jsxRuntime.jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:"Copy Code",type:"button",...d,children:n!=null?n:jsxRuntime.jsx(i,{size:14})})};var Fe={"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"},Ke=({onDownload:e,onError:t,language:o,children:n,className:l,code:s,...d})=>{let{code:c}=se(),{isAnimating:r}=react.useContext(S),a=s!=null?s:c,u=`file.${o&&o in Fe?Fe[o]:"txt"}`,m="text/plain",f=()=>{try{q(u,a,m),e==null||e();}catch(i){t==null||t(i);}};return jsxRuntime.jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),"data-streamdown":"code-block-download-button",disabled:r,onClick:f,title:"Download file",type:"button",...d,children:n!=null?n:jsxRuntime.jsx($,{size:14})})};var Le=()=>jsxRuntime.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsxRuntime.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsxRuntime.jsx(Ze,{className:"size-4 animate-spin"})})]});var Ro=/\.[^/.]+$/,Ye=({node:e,className:t,src:o,alt:n,...l})=>{let s=async()=>{if(o)try{let c=await(await fetch(o)).blob(),a=new URL(o,window.location.origin).pathname.split("/").pop()||"",p=a.split(".").pop(),u=a.includes(".")&&p!==void 0&&p.length<=4,m="";if(u)m=a;else {let f=c.type,i="png";f.includes("jpeg")||f.includes("jpg")?i="jpg":f.includes("png")?i="png":f.includes("svg")?i="svg":f.includes("gif")?i="gif":f.includes("webp")&&(i="webp"),m=`${(n||a||"image").replace(Ro,"")}.${i}`;}q(m,c,c.type);}catch(d){window.open(o,"_blank");}};return o?jsxRuntime.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntime.jsx("img",{alt:n,className:g("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...l}),jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntime.jsx("button",{className:g("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:s,title:"Download image",type:"button",children:jsxRuntime.jsx($,{size:14})})]}):null};var Q=0,Do=()=>{Q+=1,Q===1&&(document.body.style.overflow="hidden");},jo=()=>{Q=Math.max(0,Q-1),Q===0&&(document.body.style.overflow="");},tt=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let[l,s]=react.useState(false),d=react.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3);}catch(r){}},[e]),c=react.useCallback(()=>{n(),o();},[n,o]);return react.useEffect(()=>{if(t){Do();let r=a=>{a.key==="Escape"&&o();};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r),jo();}}},[t,o]),t?jsxRuntime.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:r=>{r.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxRuntime.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:r=>r.stopPropagation(),onKeyDown:r=>r.stopPropagation(),role:"presentation",children:[jsxRuntime.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:jsxRuntime.jsx(re,{size:16})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-semibold text-lg",children:[jsxRuntime.jsx(xe,{size:20}),jsxRuntime.jsx("span",{children:"Open external link?"})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:"You're about to visit an external website."})]}),jsxRuntime.jsx("div",{className:g("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.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:d,type:"button",children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(J,{size:14}),jsxRuntime.jsx("span",{children:"Copied"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(F,{size:14}),jsxRuntime.jsx("span",{children:"Copy link"})]})}),jsxRuntime.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:[jsxRuntime.jsx(xe,{size:14}),jsxRuntime.jsx("span",{children:"Open link"})]})]})]})}):null};var ie=react.createContext(null),ot=()=>react.useContext(ie),Tr=()=>{var t;let e=ot();return (t=e==null?void 0:e.code)!=null?t:null},G=()=>{var t;let e=ot();return (t=e==null?void 0:e.mermaid)!=null?t:null};var nt=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((l,s)=>{let d="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),c=new Image;c.crossOrigin="anonymous",c.onload=()=>{let r=document.createElement("canvas"),a=c.width*o,p=c.height*o;r.width=a,r.height=p;let u=r.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(c,0,0,a,p),r.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}l(m);},"image/png");},c.onerror=()=>s(new Error("Failed to load SVG image")),c.src=d;})};var st=({chart:e,children:t,className:o,onDownload:n,config:l,onError:s})=>{let[d,c]=react.useState(false),r=react.useRef(null),{isAnimating:a}=react.useContext(S),p=G(),u=async m=>{try{if(m==="mmd"){q("diagram.mmd",e,"text/plain"),c(!1),n==null||n(m);return}if(!p){s==null||s(new Error("Mermaid plugin not available"));return}let f=p.getMermaid(l),i=e.split("").reduce((w,v)=>(w<<5)-w+v.charCodeAt(0)|0,0),b=`mermaid-${Math.abs(i)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await f.render(b,e);if(!y){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){q("diagram.svg",y,"image/svg+xml"),c(!1),n==null||n(m);return}if(m==="png"){let w=await nt(y);q("diagram.png",w,"image/png"),n==null||n(m),c(!1);return}}catch(f){s==null||s(f);}};return react.useEffect(()=>{let m=f=>{let i=f.composedPath();r.current&&!i.includes(r.current)&&c(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:r,children:[jsxRuntime.jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:a,onClick:()=>c(!d),title:"Download diagram",type:"button",children:t!=null?t:jsxRuntime.jsx($,{size:14})}),d?jsxRuntime.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:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]}):null]})};var te=0,Wo=()=>{te+=1,te===1&&(document.body.style.overflow="hidden");},_o=()=>{te=Math.max(0,te-1),te===0&&(document.body.style.overflow="");},ct=({chart:e,config:t,onFullscreen:o,onExit:n,className:l,...s})=>{let[d,c]=react.useState(false),{isAnimating:r,controls:a}=react.useContext(S),p=(()=>{if(typeof a=="boolean")return a;let m=a.mermaid;return m===false?false:m===true||m===void 0?true:m.panZoom!==false})(),u=()=>{c(!d);};return react.useEffect(()=>{if(d){Wo();let m=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),_o();}}},[d]),react.useEffect(()=>{d?o==null||o():n&&n();},[d,o,n]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),disabled:r,onClick:u,title:"View fullscreen",type:"button",...s,children:jsxRuntime.jsx(We,{size:14})}),d?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:u,onKeyDown:m=>{m.key==="Escape"&&u();},role:"button",tabIndex:0,children:[jsxRuntime.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:u,title:"Exit fullscreen",type:"button",children:jsxRuntime.jsx(re,{size:20})}),jsxRuntime.jsx("div",{className:"flex size-full items-center justify-center p-4",onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:jsxRuntime.jsx(lt,{chart:e,className:"size-full [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:p})})]}):null]})};var le=e=>{var s,d;let t=[],o=[],n=e.querySelectorAll("thead th");for(let c of n)t.push(((s=c.textContent)==null?void 0:s.trim())||"");let l=e.querySelectorAll("tbody tr");for(let c of l){let r=[],a=c.querySelectorAll("td");for(let p of a)r.push(((d=p.textContent)==null?void 0:d.trim())||"");o.push(r);}return {headers:t,rows:o}},ce=e=>{let{headers:t,rows:o}=e,n=c=>{let r=false,a=false;for(let p of c){if(p==='"'){r=true,a=true;break}(p===","||p===`
|
|
3
|
+
`)&&(r=true);}return r?a?`"${c.replace(/"/g,'""')}"`:`"${c}"`:c},l=t.length>0?o.length+1:o.length,s=new Array(l),d=0;t.length>0&&(s[d]=t.map(n).join(","),d+=1);for(let c of o)s[d]=c.map(n).join(","),d+=1;return s.join(`
|
|
4
|
+
`)},dt=e=>{let{headers:t,rows:o}=e,n=c=>{let r=false;for(let p of c)if(p===" "||p===`
|
|
5
|
+
`||p==="\r"){r=true;break}if(!r)return c;let a=[];for(let p of c)p===" "?a.push("\\t"):p===`
|
|
6
|
+
`?a.push("\\n"):p==="\r"?a.push("\\r"):a.push(p);return a.join("")},l=t.length>0?o.length+1:o.length,s=new Array(l),d=0;t.length>0&&(s[d]=t.map(n).join(" "),d+=1);for(let c of o)s[d]=c.map(n).join(" "),d+=1;return s.join(`
|
|
7
|
+
`)},Te=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("")},mt=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),l=0,s=t.map(c=>Te(c));n[l]=`| ${s.join(" | ")} |`,l+=1;let d=new Array(t.length);for(let c=0;c<t.length;c+=1)d[c]="---";n[l]=`| ${d.join(" | ")} |`,l+=1;for(let c of o)if(c.length<t.length){let r=new Array(t.length);for(let a=0;a<t.length;a+=1)r[a]=a<c.length?Te(c[a]):"";n[l]=`| ${r.join(" | ")} |`,l+=1;}else {let r=c.map(a=>Te(a));n[l]=`| ${r.join(" | ")} |`,l+=1;}return n.join(`
|
|
8
|
+
`)};var gt=({children:e,className:t,onCopy:o,onError:n,timeout:l=2e3})=>{let[s,d]=react.useState(false),[c,r]=react.useState(false),a=react.useRef(null),p=react.useRef(0),{isAnimating:u}=react.useContext(S),m=async i=>{var b,y;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.write)){n==null||n(new Error("Clipboard API not available"));return}try{let w=(y=a.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"]'),v=w==null?void 0:w.querySelector("table");if(!v){n==null||n(new Error("Table not found"));return}let C=le(v),x=i==="csv"?ce(C):dt(C),O=new ClipboardItem({"text/plain":new Blob([x],{type:"text/plain"}),"text/html":new Blob([v.outerHTML],{type:"text/html"})});await navigator.clipboard.write([O]),r(!0),d(!1),o==null||o(i),p.current=window.setTimeout(()=>r(!1),l);}catch(w){n==null||n(w);}};react.useEffect(()=>{let i=b=>{let y=b.composedPath();a.current&&!y.includes(a.current)&&d(false);};return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i),window.clearTimeout(p.current);}},[]);let f=c?J:F;return jsxRuntime.jsxs("div",{className:"relative",ref:a,children:[jsxRuntime.jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>d(!s),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(f,{size:14})}),s?jsxRuntime.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:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var ht=({children:e,className:t,onDownload:o,onError:n})=>{let[l,s]=react.useState(false),d=react.useRef(null),{isAnimating:c}=react.useContext(S),r=a=>{var p;try{let u=(p=d.current)==null?void 0:p.closest('[data-streamdown="table-wrapper"]'),m=u==null?void 0:u.querySelector("table");if(!m){n==null||n(new Error("Table not found"));return}let f=le(m),i=a==="csv"?ce(f):mt(f);q(`table.${a==="csv"?"csv":"md"}`,i,a==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(a);}catch(u){n==null||n(u);}};return react.useEffect(()=>{let a=p=>{let u=p.composedPath();d.current&&!u.includes(d.current)&&s(false);};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:d,children:[jsxRuntime.jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:()=>s(!l),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx($,{size:14})}),l?jsxRuntime.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:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>r("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>r("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var wt=({children:e,className:t,showControls:o,...n})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(gt,{}),jsxRuntime.jsx(ht,{})]}):null,jsxRuntime.jsx("div",{className:"overflow-x-auto overscroll-y-auto",children:jsxRuntime.jsx("table",{className:g("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});var en=react.lazy(()=>import('./code-block-7PYKXEZZ.cjs').then(e=>({default:e.CodeBlock}))),tn=react.lazy(()=>import('./mermaid-ROHDMRLI.cjs').then(e=>({default:e.Mermaid}))),on=/language-([^\s]+)/;function be(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,l=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)&&(l==null?void 0:l.line)===(s==null?void 0:s.line)&&(l==null?void 0:l.column)===(s==null?void 0:s.column)}function L(e,t){return e.className===t.className&&be(e.node,t.node)}var Se=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ue=(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},He=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("ol",{className:g("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>L(e,t));He.displayName="MarkdownOl";var Ct=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("li",{className:g("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&be(e.node,t.node));Ct.displayName="MarkdownLi";var xt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("ul",{className:g("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>L(e,t));xt.displayName="MarkdownUl";var Pt=react.memo(({className:e,node:t,...o})=>jsxRuntime.jsx("hr",{className:g("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>L(e,t));Pt.displayName="MarkdownHr";var Mt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("span",{className:g("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>L(e,t));Mt.displayName="MarkdownStrong";var nn=({children:e,className:t,href:o,node:n,...l})=>{let{linkSafety:s}=react.useContext(S),[d,c]=react.useState(false),r=o==="streamdown:incomplete-link",a=react.useCallback(async f=>{if(!(!(s!=null&&s.enabled&&o)||r)){if(f.preventDefault(),s.onLinkCheck&&await s.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}c(true);}},[s,o,r]),p=react.useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=react.useCallback(()=>{c(false);},[]),m={url:o!=null?o:"",isOpen:d,onClose:u,onConfirm:p};return s!=null&&s.enabled&&o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:g("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",onClick:a,type:"button",children:e}),s.renderModal?s.renderModal(m):jsxRuntime.jsx(tt,{...m})]}):jsxRuntime.jsx("a",{className:g("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...l,children:e})},Lt=react.memo(nn,(e,t)=>L(e,t)&&e.href===t.href);Lt.displayName="MarkdownA";var Tt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h1",{className:g("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>L(e,t));Tt.displayName="MarkdownH1";var Nt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h2",{className:g("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>L(e,t));Nt.displayName="MarkdownH2";var St=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h3",{className:g("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>L(e,t));St.displayName="MarkdownH3";var Rt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h4",{className:g("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>L(e,t));Rt.displayName="MarkdownH4";var Ht=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h5",{className:g("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>L(e,t));Ht.displayName="MarkdownH5";var It=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h6",{className:g("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>L(e,t));It.displayName="MarkdownH6";var Et=react.memo(({children:e,className:t,node:o,...n})=>{let{controls:l}=react.useContext(S),s=Se(l,"table");return jsxRuntime.jsx(wt,{className:t,showControls:s,...n,children:e})},(e,t)=>L(e,t));Et.displayName="MarkdownTable";var Dt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("thead",{className:g("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>L(e,t));Dt.displayName="MarkdownThead";var jt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("tbody",{className:g("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>L(e,t));jt.displayName="MarkdownTbody";var Vt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("tr",{className:g("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>L(e,t));Vt.displayName="MarkdownTr";var Ot=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("th",{className:g("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>L(e,t));Ot.displayName="MarkdownTh";var Bt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("td",{className:g("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>L(e,t));Bt.displayName="MarkdownTd";var At=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("blockquote",{className:g("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>L(e,t));At.displayName="MarkdownBlockquote";var qt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("sup",{className:g("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>L(e,t));qt.displayName="MarkdownSup";var zt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("sub",{className:g("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>L(e,t));zt.displayName="MarkdownSub";var $t=react.memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=r=>{var m,f;if(!react.isValidElement(r))return false;let a=Array.isArray(r.props.children)?r.props.children:[r.props.children],p=false,u=false;for(let i of a)if(i){if(typeof i=="string")i.trim()!==""&&(p=true);else if(react.isValidElement(i))if(((m=i.props)==null?void 0:m["data-footnote-backref"])!==void 0)u=true;else {let b=Array.isArray(i.props.children)?i.props.children:[i.props.children];for(let y of b){if(typeof y=="string"&&y.trim()!==""){p=true;break}if(react.isValidElement(y)&&((f=y.props)==null?void 0:f["data-footnote-backref"])===void 0){p=true;break}}}}return u&&!p},d=Array.isArray(e)?e.map(r=>{if(!react.isValidElement(r))return r;if(r.type===He){let p=(Array.isArray(r.props.children)?r.props.children:[r.props.children]).filter(u=>!s(u));return p.length===0?null:{...r,props:{...r.props,children:p}}}return r}):e;return (Array.isArray(d)?d.some(r=>r!==null):d!==null)?jsxRuntime.jsx("section",{className:t,...n,children:d}):null}return jsxRuntime.jsx("section",{className:t,...n,children:e})},(e,t)=>L(e,t));$t.displayName="MarkdownSection";var rn=({node:e,className:t,children:o,...n})=>{var m,f,i;let l=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((f=e==null?void 0:e.position)==null?void 0:f.end.line),{mermaid:s,controls:d}=react.useContext(S),c=G();if(l)return jsxRuntime.jsx("code",{className:g("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let r=t==null?void 0:t.match(on),a=(i=r==null?void 0:r.at(1))!=null?i:"",p="";if(react.isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?p=o.props.children:typeof o=="string"&&(p=o),a==="mermaid"&&c){let b=Se(d,"mermaid"),y=ue(d,"download"),w=ue(d,"copy"),v=ue(d,"fullscreen"),C=ue(d,"panZoom"),x=b&&(y||w||v);return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(Le,{}),children:jsxRuntime.jsxs("div",{className:g("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[x?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y?jsxRuntime.jsx(st,{chart:p,config:s==null?void 0:s.config}):null,w?jsxRuntime.jsx(Pe,{code:p}):null,v?jsxRuntime.jsx(ct,{chart:p,config:s==null?void 0:s.config}):null]}):null,jsxRuntime.jsx(tn,{chart:p,config:s==null?void 0:s.config,showControls:C})]})})}let u=Se(d,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(Le,{}),children:jsxRuntime.jsx(en,{className:g("overflow-x-auto border-border border-t",t),code:p,language:a,children:u?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ke,{code:p,language:a}),jsxRuntime.jsx(Pe,{})]}):null})})},Zt=react.memo(rn,(e,t)=>e.className===t.className&&be(e.node,t.node));Zt.displayName="MarkdownCode";var Wt=react.memo(Ye,(e,t)=>e.className===t.className&&be(e.node,t.node));Wt.displayName="MarkdownImg";var _t=react.memo(({children:e,className:t,node:o,...n})=>{var d,c;let s=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");if(s.length===1&&react.isValidElement(s[0])){let r=s[0].props.node,a=r==null?void 0:r.tagName;if(a==="img")return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e});if(a==="code"&&((d=r==null?void 0:r.position)==null?void 0:d.start.line)!==((c=r==null?void 0:r.position)==null?void 0:c.end.line))return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}return jsxRuntime.jsx("p",{className:t,...n,children:e})},(e,t)=>L(e,t));_t.displayName="MarkdownParagraph";var Xt={ol:He,li:Ct,ul:xt,hr:Pt,strong:Mt,a:Lt,h1:Tt,h2:Nt,h3:St,h4:Rt,h5:Ht,h6:It,table:Et,thead:Dt,tbody:jt,tr:Vt,th:Ot,td:Bt,blockquote:At,code:Zt,img:Wt,pre:({children:e})=>e,sup:qt,sub:zt,p:_t,section:$t};var Ut=()=>e=>{unistUtilVisit.visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var Ft=[],Gt={allowDangerousHtml:true},he=new WeakMap,Ie=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,l=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||l||s)){let u="default";return this.keyCache.set(t,u),u}let d=u=>{if(!u||u.length===0)return "";let m="";for(let f=0;f<u.length;f+=1){let i=u[f];if(f>0&&(m+=","),Array.isArray(i)){let[b,y]=i;if(typeof b=="function"){let w=he.get(b);w||(w=b.name,he.set(b,w)),m+=w;}else m+=String(b);m+=":",m+=JSON.stringify(y);}else if(typeof i=="function"){let b=he.get(i);b||(b=i.name,he.set(i,b)),m+=b;}else m+=String(i);}return m},c=d(n),r=d(l),a=s?JSON.stringify(s):"",p=`${r}::${c}::${a}`;return this.keyCache.set(t,p),p}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 l=this.cache.keys().next().value;l&&this.cache.delete(l);}this.cache.set(n,o);}clear(){this.cache.clear();}},Kt=new Ie,Ee=e=>{let t=fn(e),o=e.children||"";return hn(t.runSync(t.parse(o),o),e)},fn=e=>{let t=Kt.get(e);if(t)return t;let o=bn(e);return Kt.set(e,o),o},gn=e=>e.some(t=>Array.isArray(t)?t[0]===Jt__default.default:t===Jt__default.default),bn=e=>{let t=e.rehypePlugins||Ft,o=e.remarkPlugins||Ft,n=gn(t)?o:[...o,Ut],l=e.remarkRehypeOptions?{...Gt,...e.remarkRehypeOptions}:Gt;return unified.unified().use(mn__default.default).use(n).use(pn__default.default,l).use(t)},hn=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var wn=/\[\^[\w-]{1,200}\](?!:)/,kn=/\[\^[\w-]{1,200}\]:/,vn=/<\/(\w+)>/,Cn=/<(\w+)[\s>]/,xn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),De=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
|
+
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},Pn=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
10
|
+
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},je=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},Ve=e=>{let t=wn.test(e),o=kn.test(e);if(t||o)return [e];let n=marked.Lexer.lex(e,{gfm:true}),l=[],s=[],d=false;for(let c of n){let r=c.raw,a=l.length;if(s.length>0){if(l[a-1]+=r,c.type==="html"){let u=r.match(vn);if(u){let m=u[1];s.at(-1)===m&&s.pop();}}continue}if(c.type==="html"&&c.block){let u=r.match(Cn);if(u){let m=u[1];!r.includes(`</${m}>`)&&!xn.has(m.toLowerCase())&&s.push(m);}}if(r.trim()==="$$"&&a>0&&!d){let u=l[a-1],m=De(u),f=je(u);if(m&&f%2===1){l[a-1]=u+r;continue}}if(a>0&&Pn(r)&&!d){let u=l[a-1],m=De(u),f=je(u),i=je(r);if(m&&f%2===1&&!De(r)&&i===1){l[a-1]=u+r;continue}}l.push(r),c.type!=="space"&&(d=c.type==="code");}return l};var Ae=["javascript","typescript","jsx","tsx","python","java","sql","bash","json","css","html","xml","c","cpp","csharp","go","rust","ruby","php","swift","kotlin","scala","yaml","markdown","graphql","diff","objectivec","r","plain","markup"],Yt={js:"javascript",ts:"typescript",py:"python",sh:"bash",shell:"bash",text:"plain",plaintext:"plain",cs:"csharp","c++":"cpp","c#":"csharp",yml:"yaml",md:"markdown",gql:"graphql",objc:"objectivec"};function Qt(e){if(!e)return "plain";let t=e.toLowerCase().trim();return Yt[t]?Yt[t]:Ae.includes(t)?t:"plain"}var ye={"github-light":{fg:"#24292e",bg:"#ffffff",keyword:"#d73a49",string:"#032f62",number:"#005cc5",comment:"#6a737d",function:"#6f42c1",operator:"#d73a49",punctuation:"#24292e",className:"#6f42c1",builtin:"#005cc5"},"github-dark":{fg:"#c9d1d9",bg:"#0d1117",keyword:"#ff7b72",string:"#a5d6ff",number:"#79c0ff",comment:"#8b949e",function:"#d2a8ff",operator:"#ff7b72",punctuation:"#c9d1d9",className:"#d2a8ff",builtin:"#79c0ff"},oneDark:{fg:"#abb2bf",bg:"#282c34",keyword:"#c678dd",string:"#98c379",number:"#d19a66",comment:"#5c6370",function:"#61afef",operator:"#56b6c2",punctuation:"#abb2bf",className:"#e5c07b",builtin:"#e06c75"}},Be=new Map;function Mn(e,t,o){let n=e.slice(0,100),l=e.length>100?e.slice(-100):"";return `${t}:${o[0]}:${o[1]}:${e.length}:${n}:${l}`}function eo(e,t){let n={keyword:"keyword",string:"string",number:"number",comment:"comment",function:"function","function-variable":"function",operator:"operator",punctuation:"punctuation","class-name":"className",builtin:"builtin",boolean:"keyword",property:"function",tag:"keyword","attr-name":"function","attr-value":"string",selector:"keyword"}[e];return n&&t[n]?t[n]:t.fg}function to(e={}){var o;let t=(o=e.themes)!=null?o:["github-light","github-dark"];return {name:"prism",type:"code-highlighter",supportsLanguage(n){let l=Qt(n);return Ae.includes(l)},getSupportedLanguages(){return [...Ae]},getThemes(){return t},highlight({code:n,language:l,themes:s},d){var u,m;let c=Mn(n,l,s);if(Be.has(c))return Be.get(c);let r=Qt(l),a=(u=ye[s[0]])!=null?u:ye["github-light"],p=(m=ye[s[1]])!=null?m:ye["github-dark"];try{let f=prismReactRenderer.Prism.languages[r]||prismReactRenderer.Prism.languages.plain,i=prismReactRenderer.Prism.tokenize(n,f),b=n.split(`
|
|
11
|
+
`),y=[],w=0;for(let C of b){let x=[],O=C,H=0;for(;H<O.length;){let I=!1,T=O.slice(H);for(let V of i){let D=typeof V=="string"?V:V.content,R=typeof D=="string"?D:String(D);if(T.startsWith(R)||R.includes(T.slice(0,Math.min(T.length,R.length)))){let k=typeof V=="string"?"plain":V.type||"plain",E=eo(k,a),_=eo(k,p);if(T.slice(0,Math.min(T.length,R.length-(R.indexOf(T.charAt(0))>=0,0))).length>0){x.push({content:T.length<=R.length?T:T.slice(0,R.length),color:E,bgColor:"transparent",htmlStyle:{"--code-dark":_,"--code-dark-bg":p.bg}}),H+=T.length<=R.length?T.length:R.length,I=!0;break}}}if(!I){x.push({content:T,color:a.fg,bgColor:"transparent",htmlStyle:{"--code-dark":p.fg,"--code-dark-bg":p.bg}});break}}x.length===0&&x.push({content:C,color:a.fg,bgColor:"transparent",htmlStyle:{"--code-dark":p.fg,"--code-dark-bg":p.bg}}),y.push(x),w+=C.length+1;}let v={bg:a.bg,fg:a.fg,tokens:y};return Be.set(c,v),d&&d(v),v}catch(f){return console.error("[Streamdown Prism] Failed to highlight code:",f),{bg:a.bg,fg:a.fg,tokens:n.split(`
|
|
12
|
+
`).map(b=>[{content:b,color:a.fg,bgColor:"transparent",htmlStyle:{"--code-dark":p.fg,"--code-dark-bg":p.bg}}])}}}}}var Ln=to();var ze={raw:Jt__default.default,sanitize:[ro__default.default,{}],harden:[rehypeHarden.harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Vn={gfm:[Dn__default.default,{}]},oo=Object.values(ze),On=Object.values(Vn),Bn={block:" \u258B",circle:" \u25CF"},An={theme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0,linkSafety:{enabled:true}},S=react.createContext(An),so=react.memo(({content:e,shouldParseIncompleteMarkdown:t,index:o,...n})=>jsxRuntime.jsx(Ee,{...n,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)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(l=>{var s,d;return ((s=e.components)==null?void 0:s[l])!==((d=t.components)==null?void 0:d[l])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});so.displayName="Block";var qn=["github-light","github-dark"],zn=react.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=true,components:n,rehypePlugins:l=oo,remarkPlugins:s=On,className:d,theme:c=qn,mermaid:r,controls:a=true,isAnimating:p=false,BlockComponent:u=so,parseMarkdownIntoBlocksFn:m=Ve,caret:f,plugins:i,remend:b,linkSafety:y={enabled:true},allowedTags:w,...v})=>{let C=react.useId(),[x,O]=react.useTransition(),H=react.useMemo(()=>typeof e!="string"?"":t==="streaming"&&o?jn__default.default(e,b):e,[e,t,o,b]),I=react.useMemo(()=>m(H),[H,m]),[T,V]=react.useState(I);react.useEffect(()=>{t==="streaming"?O(()=>{V(I);}):V(I);},[I,t]);let D=t==="streaming"?T:I,R=react.useMemo(()=>D.map((N,A)=>`${C}-${A}`),[D.length,C]),k=react.useMemo(()=>{var N,A;return {theme:(A=(N=i==null?void 0:i.code)==null?void 0:N.getThemes())!=null?A:c,controls:a,isAnimating:p,mode:t,mermaid:r,linkSafety:y}},[c,a,p,t,r,y,i==null?void 0:i.code]),E=react.useMemo(()=>({...Xt,...n}),[n]),_=react.useMemo(()=>{let N=[];return i!=null&&i.cjk&&(N=[...N,...i.cjk.remarkPluginsBefore]),N=[...N,...s],i!=null&&i.cjk&&(N=[...N,...i.cjk.remarkPluginsAfter]),i!=null&&i.math&&(N=[...N,i.math.remarkPlugin]),N},[s,i==null?void 0:i.math,i==null?void 0:i.cjk]),ke=react.useMemo(()=>{var A;let N=l;if(w&&Object.keys(w).length>0&&l===oo){let po={...ro.defaultSchema,tagNames:[...(A=ro.defaultSchema.tagNames)!=null?A:[],...Object.keys(w)],attributes:{...ro.defaultSchema.attributes,...w}};N=[ze.raw,[ro__default.default,po],ze.harden];}return i!=null&&i.math&&(N=[...N,i.math.rehypePlugin]),N},[l,i==null?void 0:i.math,w]),mo=react.useMemo(()=>f&&p?{"--streamdown-caret":`"${Bn[f]}"`}:void 0,[f,p]);return t==="static"?jsxRuntime.jsx(ie.Provider,{value:i!=null?i:null,children:jsxRuntime.jsx(S.Provider,{value:k,children:jsxRuntime.jsx("div",{className:g("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",d),children:jsxRuntime.jsx(Ee,{components:E,rehypePlugins:ke,remarkPlugins:_,...v,children:e})})})}):jsxRuntime.jsx(ie.Provider,{value:i!=null?i:null,children:jsxRuntime.jsx(S.Provider,{value:k,children:jsxRuntime.jsxs("div",{className:g("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",f?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,d),style:mo,children:[D.length===0&&f&&p&&jsxRuntime.jsx("span",{}),D.map((N,A)=>jsxRuntime.jsx(u,{components:E,content:N,index:A,rehypePlugins:ke,remarkPlugins:_,shouldParseIncompleteMarkdown:o,...v},R[A]))]})})})},(e,t)=>e.children===t.children&&e.theme===t.theme&&e.isAnimating===t.isAnimating&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety);zn.displayName="Streamdown";var co=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:l=.1,showControls:s=true,initialZoom:d=1,fullscreen:c=false})=>{let r=react.useRef(null),a=react.useRef(null),[p,u]=react.useState(d),[m,f]=react.useState({x:0,y:0}),[i,b]=react.useState(false),[y,w]=react.useState({x:0,y:0}),[v,C]=react.useState({x:0,y:0}),x=react.useCallback(k=>{u(E=>Math.max(o,Math.min(n,E+k)));},[o,n]),O=react.useCallback(()=>{x(l);},[x,l]),H=react.useCallback(()=>{x(-l);},[x,l]),I=react.useCallback(()=>{u(d),f({x:0,y:0});},[d]),T=react.useCallback(k=>{k.preventDefault();let E=k.deltaY>0?-l:l;x(E);},[x,l]),V=react.useCallback(k=>{if(k.button!==0||k.isPrimary===false)return;b(true),w({x:k.clientX,y:k.clientY}),C(m);let E=k.currentTarget;E instanceof HTMLElement&&E.setPointerCapture(k.pointerId);},[m]),D=react.useCallback(k=>{if(!i)return;k.preventDefault();let E=k.clientX-y.x,_=k.clientY-y.y;f({x:v.x+E,y:v.y+_});},[i,y,v]),R=react.useCallback(k=>{b(false);let E=k.currentTarget;E instanceof HTMLElement&&E.releasePointerCapture(k.pointerId);},[]);return react.useEffect(()=>{let k=r.current;if(k)return k.addEventListener("wheel",T,{passive:false}),()=>{k.removeEventListener("wheel",T);}},[T]),react.useEffect(()=>{let k=a.current;if(k&&i)return document.body.style.userSelect="none",k.addEventListener("pointermove",D,{passive:false}),k.addEventListener("pointerup",R),k.addEventListener("pointercancel",R),()=>{document.body.style.userSelect="",k.removeEventListener("pointermove",D),k.removeEventListener("pointerup",R),k.removeEventListener("pointercancel",R);}},[i,D,R]),jsxRuntime.jsxs("div",{className:g("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:r,style:{cursor:i?"grabbing":"grab"},children:[s?jsxRuntime.jsxs("div",{className:g("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",c?"bottom-4 left-4":"bottom-2 left-2"),children:[jsxRuntime.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:p>=n,onClick:O,title:"Zoom in",type:"button",children:jsxRuntime.jsx(Xe,{size:16})}),jsxRuntime.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:p<=o,onClick:H,title:"Zoom out",type:"button",children:jsxRuntime.jsx(Ue,{size:16})}),jsxRuntime.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:I,title:"Reset zoom and pan",type:"button",children:jsxRuntime.jsx(_e,{size:16})})]}):null,jsxRuntime.jsx("div",{className:g("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:V,ref:a,role:"application",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${p})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var lt=({chart:e,className:t,config:o,fullscreen:n=false,showControls:l=true})=>{let[s,d]=react.useState(null),[c,r]=react.useState(false),[a,p]=react.useState(""),[u,m]=react.useState(""),[f,i]=react.useState(0),{mermaid:b}=react.useContext(S),y=G(),w=b==null?void 0:b.errorComponent,{shouldRender:v,containerRef:C}=$e({immediate:n});if(react.useEffect(()=>{if(!v)return;if(!y){d("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{d(null),r(!0);let H=y.getMermaid(o),I=e.split("").reduce((D,R)=>(D<<5)-D+R.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(I)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:V}=await H.render(T,e);p(V),m(V);}catch(H){if(!(u||a)){let I=H instanceof Error?H.message:"Failed to render Mermaid chart";d(I);}}finally{r(false);}})();},[e,o,f,v,y]),!(v||a||u))return jsxRuntime.jsx("div",{className:g("my-4 min-h-[200px]",t),ref:C});if(c&&!a&&!u)return jsxRuntime.jsx("div",{className:g("my-4 flex justify-center p-4",t),ref:C,children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsxRuntime.jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(s&&!a&&!u){let O=()=>i(H=>H+1);return w?jsxRuntime.jsx("div",{ref:C,children:jsxRuntime.jsx(w,{chart:e,error:s,retry:O})}):jsxRuntime.jsxs("div",{className:g("rounded-lg border border-red-200 bg-red-50 p-4",t),ref:C,children:[jsxRuntime.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",s]}),jsxRuntime.jsxs("details",{className:"mt-2",children:[jsxRuntime.jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsxRuntime.jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let x=a||u;return jsxRuntime.jsx("div",{className:g("size-full",t),"data-streamdown":"mermaid",ref:C,children:jsxRuntime.jsx(co,{className:g(n?"size-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:l,zoomStep:.1,children:jsxRuntime.jsx("div",{"aria-label":"Mermaid chart",className:g("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:x},role:"img"})})})};exports.a=g;exports.b=xo;exports.c=Tr;exports.d=lt;exports.e=Ve;exports.f=to;exports.g=Ln;exports.h=ze;exports.i=Vn;exports.j=S;exports.k=so;exports.l=zn;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var chunkNJFWWDMZ_cjs=require('./chunk-NJFWWDMZ.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var R=chunkNJFWWDMZ_cjs.a("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"),k=react.memo(({children:o,result:e,language:n,className:s,...p})=>{let i=react.useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsxRuntime.jsx("pre",{className:chunkNJFWWDMZ_cjs.a(s,"p-4 text-sm dark:bg-(--code-dark-bg)!"),"data-language":n,"data-streamdown":"code-block-body",style:i,...p,children:jsxRuntime.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,r)=>jsxRuntime.jsx("span",{className:R,children:a.map((t,g)=>jsxRuntime.jsx("span",{className:"dark:bg-(--code-dark-bg)! dark:text-(--code-dark)!",style:{color:t.color,backgroundColor:t.bgColor,...t.htmlStyle},...t.htmlAttrs,children:t.content},g))},r))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var y=({className:o,language:e,style:n,...s})=>jsxRuntime.jsx("div",{className:chunkNJFWWDMZ_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...s});var B=({language:o,children:e})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:e})]});var I=/\n+$/,Q=({code:o,language:e,className:n,children:s,...p})=>{let{theme:i}=react.useContext(chunkNJFWWDMZ_cjs.j),a=chunkNJFWWDMZ_cjs.c(),r=react.useMemo(()=>o.replace(I,""),[o]),t=react.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:r.split(`
|
|
3
|
+
`).map(d=>[{content:d,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[r]),[g,c]=react.useState(t);return react.useEffect(()=>{if(!a){c(t);return}let d=a.highlight({code:r,language:e,themes:i},x=>{c(x);});if(d){c(d);return}c(t);},[r,e,i,a,t]),jsxRuntime.jsx(chunkNJFWWDMZ_cjs.b.Provider,{value:{code:o},children:jsxRuntime.jsxs(y,{language:e,children:[jsxRuntime.jsx(B,{language:e,children:s}),jsxRuntime.jsx(k,{className:n,language:e,result:g,...p})]})})};exports.CodeBlock=Q;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {a,j,c,b}from'./chunk-N537QM36.js';import {memo,useMemo,useContext,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';var R=a("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"),k=memo(({children:o,result:e,language:n,className:s,...p})=>{let i=useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsx("pre",{className:a(s,"p-4 text-sm dark:bg-(--code-dark-bg)!"),"data-language":n,"data-streamdown":"code-block-body",style:i,...p,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,r)=>jsx("span",{className:R,children:a.map((t,g)=>jsx("span",{className:"dark:bg-(--code-dark-bg)! dark:text-(--code-dark)!",style:{color:t.color,backgroundColor:t.bgColor,...t.htmlStyle},...t.htmlAttrs,children:t.content},g))},r))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var y=({className:o,language:e,style:n,...s})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...s});var B=({language:o,children:e})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsx("div",{className:"flex items-center gap-2",children:e})]});var I=/\n+$/,Q=({code:o,language:e,className:n,children:s,...p})=>{let{theme:i}=useContext(j),a=c(),r=useMemo(()=>o.replace(I,""),[o]),t=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:r.split(`
|
|
3
|
+
`).map(d=>[{content:d,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[r]),[g,c$1]=useState(t);return useEffect(()=>{if(!a){c$1(t);return}let d=a.highlight({code:r,language:e,themes:i},x=>{c$1(x);});if(d){c$1(d);return}c$1(t);},[r,e,i,a,t]),jsx(b.Provider,{value:{code:o},children:jsxs(y,{language:e,children:[jsx(B,{language:e,children:s}),jsx(k,{className:n,language:e,result:g,...p})]})})};export{Q as CodeBlock};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var chunkNJFWWDMZ_cjs=require('./chunk-NJFWWDMZ.cjs');Object.defineProperty(exports,"Block",{enumerable:true,get:function(){return chunkNJFWWDMZ_cjs.k}});Object.defineProperty(exports,"Streamdown",{enumerable:true,get:function(){return chunkNJFWWDMZ_cjs.l}});Object.defineProperty(exports,"StreamdownContext",{enumerable:true,get:function(){return chunkNJFWWDMZ_cjs.j}});Object.defineProperty(exports,"createPrismPlugin",{enumerable:true,get:function(){return chunkNJFWWDMZ_cjs.f}});Object.defineProperty(exports,"defaultRehypePlugins",{enumerable:true,get:function(){return chunkNJFWWDMZ_cjs.h}});Object.defineProperty(exports,"defaultRemarkPlugins",{enumerable:true,get:function(){return chunkNJFWWDMZ_cjs.i}});Object.defineProperty(exports,"parseMarkdownIntoBlocks",{enumerable:true,get:function(){return chunkNJFWWDMZ_cjs.e}});Object.defineProperty(exports,"prism",{enumerable:true,get:function(){return chunkNJFWWDMZ_cjs.g}});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { JSX, ComponentType } from 'react';
|
|
4
|
+
import { MermaidConfig } from 'mermaid';
|
|
5
|
+
import { RemendOptions } from 'remend';
|
|
6
|
+
import { PluggableList, Pluggable } from 'unified';
|
|
7
|
+
import { Element } from 'hast';
|
|
8
|
+
import { Options as Options$1 } from 'remark-rehype';
|
|
9
|
+
|
|
10
|
+
interface ExtraProps {
|
|
11
|
+
node?: Element | undefined;
|
|
12
|
+
}
|
|
13
|
+
type Components = {
|
|
14
|
+
[Key in keyof JSX.IntrinsicElements]?: ComponentType<JSX.IntrinsicElements[Key] & ExtraProps> | keyof JSX.IntrinsicElements;
|
|
15
|
+
} & {
|
|
16
|
+
[key: string]: ComponentType<Record<string, unknown> & ExtraProps> | keyof JSX.IntrinsicElements | undefined;
|
|
17
|
+
};
|
|
18
|
+
interface Options {
|
|
19
|
+
children?: string;
|
|
20
|
+
components?: Components;
|
|
21
|
+
rehypePlugins?: PluggableList;
|
|
22
|
+
remarkPlugins?: PluggableList;
|
|
23
|
+
remarkRehypeOptions?: Readonly<Options$1>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A single token in a highlighted line
|
|
28
|
+
*/
|
|
29
|
+
interface HighlightToken {
|
|
30
|
+
content: string;
|
|
31
|
+
color?: string;
|
|
32
|
+
bgColor?: string;
|
|
33
|
+
htmlStyle?: Record<string, string>;
|
|
34
|
+
htmlAttrs?: Record<string, string>;
|
|
35
|
+
offset?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result from code highlighting
|
|
39
|
+
*/
|
|
40
|
+
interface HighlightResult {
|
|
41
|
+
tokens: HighlightToken[][];
|
|
42
|
+
fg?: string;
|
|
43
|
+
bg?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Options for highlighting code
|
|
47
|
+
*/
|
|
48
|
+
interface HighlightOptions {
|
|
49
|
+
code: string;
|
|
50
|
+
language: string;
|
|
51
|
+
themes: [string, string];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Plugin for code syntax highlighting
|
|
55
|
+
*/
|
|
56
|
+
interface CodeHighlighterPlugin {
|
|
57
|
+
name: string;
|
|
58
|
+
type: "code-highlighter";
|
|
59
|
+
/**
|
|
60
|
+
* Highlight code and return tokens
|
|
61
|
+
* Returns null if highlighting not ready yet (async loading)
|
|
62
|
+
* Use callback for async result
|
|
63
|
+
*/
|
|
64
|
+
highlight: (options: HighlightOptions, callback?: (result: HighlightResult) => void) => HighlightResult | null;
|
|
65
|
+
/**
|
|
66
|
+
* Check if language is supported
|
|
67
|
+
*/
|
|
68
|
+
supportsLanguage: (language: string) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get list of supported languages
|
|
71
|
+
*/
|
|
72
|
+
getSupportedLanguages: () => string[];
|
|
73
|
+
/**
|
|
74
|
+
* Get the configured themes
|
|
75
|
+
*/
|
|
76
|
+
getThemes: () => [string, string];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Mermaid instance interface
|
|
80
|
+
*/
|
|
81
|
+
interface MermaidInstance {
|
|
82
|
+
initialize: (config: MermaidConfig) => void;
|
|
83
|
+
render: (id: string, source: string) => Promise<{
|
|
84
|
+
svg: string;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Plugin for diagram rendering (Mermaid)
|
|
89
|
+
*/
|
|
90
|
+
interface DiagramPlugin {
|
|
91
|
+
name: "mermaid";
|
|
92
|
+
type: "diagram";
|
|
93
|
+
/**
|
|
94
|
+
* Language identifier for code blocks
|
|
95
|
+
*/
|
|
96
|
+
language: string;
|
|
97
|
+
/**
|
|
98
|
+
* Get the mermaid instance (initialized with optional config)
|
|
99
|
+
*/
|
|
100
|
+
getMermaid: (config?: MermaidConfig) => MermaidInstance;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Plugin for math rendering (KaTeX)
|
|
104
|
+
*/
|
|
105
|
+
interface MathPlugin {
|
|
106
|
+
name: "katex";
|
|
107
|
+
type: "math";
|
|
108
|
+
/**
|
|
109
|
+
* Get remark plugin for parsing math syntax
|
|
110
|
+
*/
|
|
111
|
+
remarkPlugin: Pluggable;
|
|
112
|
+
/**
|
|
113
|
+
* Get rehype plugin for rendering math
|
|
114
|
+
*/
|
|
115
|
+
rehypePlugin: Pluggable;
|
|
116
|
+
/**
|
|
117
|
+
* Get CSS styles for math rendering (injected into head)
|
|
118
|
+
*/
|
|
119
|
+
getStyles?: () => string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Plugin for CJK text handling
|
|
123
|
+
*/
|
|
124
|
+
interface CjkPlugin {
|
|
125
|
+
name: "cjk";
|
|
126
|
+
type: "cjk";
|
|
127
|
+
/**
|
|
128
|
+
* Remark plugins that must run BEFORE remarkGfm
|
|
129
|
+
* (e.g., remark-cjk-friendly which modifies emphasis handling)
|
|
130
|
+
*/
|
|
131
|
+
remarkPluginsBefore: Pluggable[];
|
|
132
|
+
/**
|
|
133
|
+
* Remark plugins that must run AFTER remarkGfm
|
|
134
|
+
* (e.g., autolink boundary splitting, strikethrough enhancements)
|
|
135
|
+
*/
|
|
136
|
+
remarkPluginsAfter: Pluggable[];
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated Use remarkPluginsBefore and remarkPluginsAfter instead
|
|
139
|
+
* All remark plugins (for backwards compatibility)
|
|
140
|
+
*/
|
|
141
|
+
remarkPlugins: Pluggable[];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Plugin configuration passed to Streamdown
|
|
145
|
+
*/
|
|
146
|
+
interface PluginConfig {
|
|
147
|
+
code?: CodeHighlighterPlugin;
|
|
148
|
+
mermaid?: DiagramPlugin;
|
|
149
|
+
math?: MathPlugin;
|
|
150
|
+
cjk?: CjkPlugin;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Options for creating a Prism code plugin
|
|
157
|
+
*/
|
|
158
|
+
interface PrismPluginOptions {
|
|
159
|
+
/**
|
|
160
|
+
* Themes for syntax highlighting [light, dark]
|
|
161
|
+
* @default ["github-light", "github-dark"]
|
|
162
|
+
*/
|
|
163
|
+
themes?: [string, string];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a Prism-based code plugin
|
|
167
|
+
*/
|
|
168
|
+
declare function createPrismPlugin(options?: PrismPluginOptions): CodeHighlighterPlugin;
|
|
169
|
+
/**
|
|
170
|
+
* Pre-configured Prism plugin with default settings
|
|
171
|
+
*/
|
|
172
|
+
declare const prism: CodeHighlighterPlugin;
|
|
173
|
+
|
|
174
|
+
type ControlsConfig = boolean | {
|
|
175
|
+
table?: boolean;
|
|
176
|
+
code?: boolean;
|
|
177
|
+
mermaid?: boolean | {
|
|
178
|
+
download?: boolean;
|
|
179
|
+
copy?: boolean;
|
|
180
|
+
fullscreen?: boolean;
|
|
181
|
+
panZoom?: boolean;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
interface LinkSafetyModalProps {
|
|
185
|
+
url: string;
|
|
186
|
+
isOpen: boolean;
|
|
187
|
+
onClose: () => void;
|
|
188
|
+
onConfirm: () => void;
|
|
189
|
+
}
|
|
190
|
+
interface LinkSafetyConfig {
|
|
191
|
+
enabled: boolean;
|
|
192
|
+
onLinkCheck?: (url: string) => Promise<boolean> | boolean;
|
|
193
|
+
renderModal?: (props: LinkSafetyModalProps) => React.ReactNode;
|
|
194
|
+
}
|
|
195
|
+
interface MermaidErrorComponentProps {
|
|
196
|
+
error: string;
|
|
197
|
+
chart: string;
|
|
198
|
+
retry: () => void;
|
|
199
|
+
}
|
|
200
|
+
interface MermaidOptions {
|
|
201
|
+
config?: MermaidConfig;
|
|
202
|
+
errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
|
|
203
|
+
}
|
|
204
|
+
type AllowedTags = Record<string, string[]>;
|
|
205
|
+
type StreamdownProps = Options & {
|
|
206
|
+
mode?: "static" | "streaming";
|
|
207
|
+
BlockComponent?: React.ComponentType<BlockProps>;
|
|
208
|
+
parseMarkdownIntoBlocksFn?: (markdown: string) => string[];
|
|
209
|
+
parseIncompleteMarkdown?: boolean;
|
|
210
|
+
className?: string;
|
|
211
|
+
theme?: [string, string];
|
|
212
|
+
mermaid?: MermaidOptions;
|
|
213
|
+
controls?: ControlsConfig;
|
|
214
|
+
isAnimating?: boolean;
|
|
215
|
+
caret?: keyof typeof carets;
|
|
216
|
+
plugins?: PluginConfig;
|
|
217
|
+
remend?: RemendOptions;
|
|
218
|
+
linkSafety?: LinkSafetyConfig;
|
|
219
|
+
/** Custom tags to allow through sanitization with their permitted attributes */
|
|
220
|
+
allowedTags?: AllowedTags;
|
|
221
|
+
};
|
|
222
|
+
declare const defaultRehypePlugins: Record<string, Pluggable>;
|
|
223
|
+
declare const defaultRemarkPlugins: Record<string, Pluggable>;
|
|
224
|
+
declare const carets: {
|
|
225
|
+
block: string;
|
|
226
|
+
circle: string;
|
|
227
|
+
};
|
|
228
|
+
interface StreamdownContextType {
|
|
229
|
+
theme: [string, string];
|
|
230
|
+
controls: ControlsConfig;
|
|
231
|
+
isAnimating: boolean;
|
|
232
|
+
mode: "static" | "streaming";
|
|
233
|
+
mermaid?: MermaidOptions;
|
|
234
|
+
linkSafety?: LinkSafetyConfig;
|
|
235
|
+
}
|
|
236
|
+
declare const StreamdownContext: react.Context<StreamdownContextType>;
|
|
237
|
+
type BlockProps = Options & {
|
|
238
|
+
content: string;
|
|
239
|
+
shouldParseIncompleteMarkdown: boolean;
|
|
240
|
+
index: number;
|
|
241
|
+
};
|
|
242
|
+
declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, index: __, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
243
|
+
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, theme, mermaid, controls, isAnimating, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, allowedTags, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
244
|
+
|
|
245
|
+
export { type AllowedTags, Block, type CjkPlugin, type CodeHighlighterPlugin, type ControlsConfig, type DiagramPlugin, type HighlightOptions, type LinkSafetyConfig, type LinkSafetyModalProps, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, type PrismPluginOptions, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, createPrismPlugin, defaultRehypePlugins, defaultRemarkPlugins, parseMarkdownIntoBlocks, prism };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { JSX, ComponentType } from 'react';
|
|
4
|
+
import { MermaidConfig } from 'mermaid';
|
|
5
|
+
import { RemendOptions } from 'remend';
|
|
6
|
+
import { PluggableList, Pluggable } from 'unified';
|
|
7
|
+
import { Element } from 'hast';
|
|
8
|
+
import { Options as Options$1 } from 'remark-rehype';
|
|
9
|
+
|
|
10
|
+
interface ExtraProps {
|
|
11
|
+
node?: Element | undefined;
|
|
12
|
+
}
|
|
13
|
+
type Components = {
|
|
14
|
+
[Key in keyof JSX.IntrinsicElements]?: ComponentType<JSX.IntrinsicElements[Key] & ExtraProps> | keyof JSX.IntrinsicElements;
|
|
15
|
+
} & {
|
|
16
|
+
[key: string]: ComponentType<Record<string, unknown> & ExtraProps> | keyof JSX.IntrinsicElements | undefined;
|
|
17
|
+
};
|
|
18
|
+
interface Options {
|
|
19
|
+
children?: string;
|
|
20
|
+
components?: Components;
|
|
21
|
+
rehypePlugins?: PluggableList;
|
|
22
|
+
remarkPlugins?: PluggableList;
|
|
23
|
+
remarkRehypeOptions?: Readonly<Options$1>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A single token in a highlighted line
|
|
28
|
+
*/
|
|
29
|
+
interface HighlightToken {
|
|
30
|
+
content: string;
|
|
31
|
+
color?: string;
|
|
32
|
+
bgColor?: string;
|
|
33
|
+
htmlStyle?: Record<string, string>;
|
|
34
|
+
htmlAttrs?: Record<string, string>;
|
|
35
|
+
offset?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result from code highlighting
|
|
39
|
+
*/
|
|
40
|
+
interface HighlightResult {
|
|
41
|
+
tokens: HighlightToken[][];
|
|
42
|
+
fg?: string;
|
|
43
|
+
bg?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Options for highlighting code
|
|
47
|
+
*/
|
|
48
|
+
interface HighlightOptions {
|
|
49
|
+
code: string;
|
|
50
|
+
language: string;
|
|
51
|
+
themes: [string, string];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Plugin for code syntax highlighting
|
|
55
|
+
*/
|
|
56
|
+
interface CodeHighlighterPlugin {
|
|
57
|
+
name: string;
|
|
58
|
+
type: "code-highlighter";
|
|
59
|
+
/**
|
|
60
|
+
* Highlight code and return tokens
|
|
61
|
+
* Returns null if highlighting not ready yet (async loading)
|
|
62
|
+
* Use callback for async result
|
|
63
|
+
*/
|
|
64
|
+
highlight: (options: HighlightOptions, callback?: (result: HighlightResult) => void) => HighlightResult | null;
|
|
65
|
+
/**
|
|
66
|
+
* Check if language is supported
|
|
67
|
+
*/
|
|
68
|
+
supportsLanguage: (language: string) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get list of supported languages
|
|
71
|
+
*/
|
|
72
|
+
getSupportedLanguages: () => string[];
|
|
73
|
+
/**
|
|
74
|
+
* Get the configured themes
|
|
75
|
+
*/
|
|
76
|
+
getThemes: () => [string, string];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Mermaid instance interface
|
|
80
|
+
*/
|
|
81
|
+
interface MermaidInstance {
|
|
82
|
+
initialize: (config: MermaidConfig) => void;
|
|
83
|
+
render: (id: string, source: string) => Promise<{
|
|
84
|
+
svg: string;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Plugin for diagram rendering (Mermaid)
|
|
89
|
+
*/
|
|
90
|
+
interface DiagramPlugin {
|
|
91
|
+
name: "mermaid";
|
|
92
|
+
type: "diagram";
|
|
93
|
+
/**
|
|
94
|
+
* Language identifier for code blocks
|
|
95
|
+
*/
|
|
96
|
+
language: string;
|
|
97
|
+
/**
|
|
98
|
+
* Get the mermaid instance (initialized with optional config)
|
|
99
|
+
*/
|
|
100
|
+
getMermaid: (config?: MermaidConfig) => MermaidInstance;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Plugin for math rendering (KaTeX)
|
|
104
|
+
*/
|
|
105
|
+
interface MathPlugin {
|
|
106
|
+
name: "katex";
|
|
107
|
+
type: "math";
|
|
108
|
+
/**
|
|
109
|
+
* Get remark plugin for parsing math syntax
|
|
110
|
+
*/
|
|
111
|
+
remarkPlugin: Pluggable;
|
|
112
|
+
/**
|
|
113
|
+
* Get rehype plugin for rendering math
|
|
114
|
+
*/
|
|
115
|
+
rehypePlugin: Pluggable;
|
|
116
|
+
/**
|
|
117
|
+
* Get CSS styles for math rendering (injected into head)
|
|
118
|
+
*/
|
|
119
|
+
getStyles?: () => string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Plugin for CJK text handling
|
|
123
|
+
*/
|
|
124
|
+
interface CjkPlugin {
|
|
125
|
+
name: "cjk";
|
|
126
|
+
type: "cjk";
|
|
127
|
+
/**
|
|
128
|
+
* Remark plugins that must run BEFORE remarkGfm
|
|
129
|
+
* (e.g., remark-cjk-friendly which modifies emphasis handling)
|
|
130
|
+
*/
|
|
131
|
+
remarkPluginsBefore: Pluggable[];
|
|
132
|
+
/**
|
|
133
|
+
* Remark plugins that must run AFTER remarkGfm
|
|
134
|
+
* (e.g., autolink boundary splitting, strikethrough enhancements)
|
|
135
|
+
*/
|
|
136
|
+
remarkPluginsAfter: Pluggable[];
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated Use remarkPluginsBefore and remarkPluginsAfter instead
|
|
139
|
+
* All remark plugins (for backwards compatibility)
|
|
140
|
+
*/
|
|
141
|
+
remarkPlugins: Pluggable[];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Plugin configuration passed to Streamdown
|
|
145
|
+
*/
|
|
146
|
+
interface PluginConfig {
|
|
147
|
+
code?: CodeHighlighterPlugin;
|
|
148
|
+
mermaid?: DiagramPlugin;
|
|
149
|
+
math?: MathPlugin;
|
|
150
|
+
cjk?: CjkPlugin;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Options for creating a Prism code plugin
|
|
157
|
+
*/
|
|
158
|
+
interface PrismPluginOptions {
|
|
159
|
+
/**
|
|
160
|
+
* Themes for syntax highlighting [light, dark]
|
|
161
|
+
* @default ["github-light", "github-dark"]
|
|
162
|
+
*/
|
|
163
|
+
themes?: [string, string];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a Prism-based code plugin
|
|
167
|
+
*/
|
|
168
|
+
declare function createPrismPlugin(options?: PrismPluginOptions): CodeHighlighterPlugin;
|
|
169
|
+
/**
|
|
170
|
+
* Pre-configured Prism plugin with default settings
|
|
171
|
+
*/
|
|
172
|
+
declare const prism: CodeHighlighterPlugin;
|
|
173
|
+
|
|
174
|
+
type ControlsConfig = boolean | {
|
|
175
|
+
table?: boolean;
|
|
176
|
+
code?: boolean;
|
|
177
|
+
mermaid?: boolean | {
|
|
178
|
+
download?: boolean;
|
|
179
|
+
copy?: boolean;
|
|
180
|
+
fullscreen?: boolean;
|
|
181
|
+
panZoom?: boolean;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
interface LinkSafetyModalProps {
|
|
185
|
+
url: string;
|
|
186
|
+
isOpen: boolean;
|
|
187
|
+
onClose: () => void;
|
|
188
|
+
onConfirm: () => void;
|
|
189
|
+
}
|
|
190
|
+
interface LinkSafetyConfig {
|
|
191
|
+
enabled: boolean;
|
|
192
|
+
onLinkCheck?: (url: string) => Promise<boolean> | boolean;
|
|
193
|
+
renderModal?: (props: LinkSafetyModalProps) => React.ReactNode;
|
|
194
|
+
}
|
|
195
|
+
interface MermaidErrorComponentProps {
|
|
196
|
+
error: string;
|
|
197
|
+
chart: string;
|
|
198
|
+
retry: () => void;
|
|
199
|
+
}
|
|
200
|
+
interface MermaidOptions {
|
|
201
|
+
config?: MermaidConfig;
|
|
202
|
+
errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
|
|
203
|
+
}
|
|
204
|
+
type AllowedTags = Record<string, string[]>;
|
|
205
|
+
type StreamdownProps = Options & {
|
|
206
|
+
mode?: "static" | "streaming";
|
|
207
|
+
BlockComponent?: React.ComponentType<BlockProps>;
|
|
208
|
+
parseMarkdownIntoBlocksFn?: (markdown: string) => string[];
|
|
209
|
+
parseIncompleteMarkdown?: boolean;
|
|
210
|
+
className?: string;
|
|
211
|
+
theme?: [string, string];
|
|
212
|
+
mermaid?: MermaidOptions;
|
|
213
|
+
controls?: ControlsConfig;
|
|
214
|
+
isAnimating?: boolean;
|
|
215
|
+
caret?: keyof typeof carets;
|
|
216
|
+
plugins?: PluginConfig;
|
|
217
|
+
remend?: RemendOptions;
|
|
218
|
+
linkSafety?: LinkSafetyConfig;
|
|
219
|
+
/** Custom tags to allow through sanitization with their permitted attributes */
|
|
220
|
+
allowedTags?: AllowedTags;
|
|
221
|
+
};
|
|
222
|
+
declare const defaultRehypePlugins: Record<string, Pluggable>;
|
|
223
|
+
declare const defaultRemarkPlugins: Record<string, Pluggable>;
|
|
224
|
+
declare const carets: {
|
|
225
|
+
block: string;
|
|
226
|
+
circle: string;
|
|
227
|
+
};
|
|
228
|
+
interface StreamdownContextType {
|
|
229
|
+
theme: [string, string];
|
|
230
|
+
controls: ControlsConfig;
|
|
231
|
+
isAnimating: boolean;
|
|
232
|
+
mode: "static" | "streaming";
|
|
233
|
+
mermaid?: MermaidOptions;
|
|
234
|
+
linkSafety?: LinkSafetyConfig;
|
|
235
|
+
}
|
|
236
|
+
declare const StreamdownContext: react.Context<StreamdownContextType>;
|
|
237
|
+
type BlockProps = Options & {
|
|
238
|
+
content: string;
|
|
239
|
+
shouldParseIncompleteMarkdown: boolean;
|
|
240
|
+
index: number;
|
|
241
|
+
};
|
|
242
|
+
declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, index: __, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
243
|
+
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, theme, mermaid, controls, isAnimating, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, allowedTags, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
244
|
+
|
|
245
|
+
export { type AllowedTags, Block, type CjkPlugin, type CodeHighlighterPlugin, type ControlsConfig, type DiagramPlugin, type HighlightOptions, type LinkSafetyConfig, type LinkSafetyModalProps, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, type PrismPluginOptions, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, createPrismPlugin, defaultRehypePlugins, defaultRemarkPlugins, parseMarkdownIntoBlocks, prism };
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "streamdown-prism",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"homepage": "https://github.com/larry-pan/streamdown-prism",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/larry-pan/streamdown-prism.git"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"postbuild": "node scripts/postbuild.js",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:ui": "vitest --ui run",
|
|
29
|
+
"test:coverage": "vitest --coverage run",
|
|
30
|
+
"bench": "vitest bench --run > results.txt",
|
|
31
|
+
"bench:ui": "vitest bench --ui --run",
|
|
32
|
+
"size": "node scripts/bundle-size.js"
|
|
33
|
+
},
|
|
34
|
+
"author": "Larry Pan <larrypan.2006@outlook.com>",
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"description": "A minimal fork of streamdown using Prism instead of Shiki for syntax highlighting.",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
39
|
+
"@testing-library/react": "^16.3.0",
|
|
40
|
+
"@types/hast": "^3.0.4",
|
|
41
|
+
"@types/react": "^19.2.7",
|
|
42
|
+
"@types/react-dom": "^19.2.3",
|
|
43
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
44
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
45
|
+
"jsdom": "^27.3.0",
|
|
46
|
+
"mermaid": "^11.12.2",
|
|
47
|
+
"react": "^19.0.0",
|
|
48
|
+
"react-dom": "^19.0.0",
|
|
49
|
+
"react-markdown": "^10.1.0",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"typescript": "^5.7.0",
|
|
52
|
+
"vitest": "^4.0.15"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"clsx": "^2.1.1",
|
|
59
|
+
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
60
|
+
"html-url-attributes": "^3.0.1",
|
|
61
|
+
"marked": "^17.0.1",
|
|
62
|
+
"prism-react-renderer": "^2.4.1",
|
|
63
|
+
"rehype-harden": "^1.1.7",
|
|
64
|
+
"rehype-raw": "^7.0.0",
|
|
65
|
+
"rehype-sanitize": "^6.0.0",
|
|
66
|
+
"remark-gfm": "^4.0.1",
|
|
67
|
+
"remark-parse": "^11.0.0",
|
|
68
|
+
"remark-rehype": "^11.1.2",
|
|
69
|
+
"remend": "^1.0.1",
|
|
70
|
+
"tailwind-merge": "^3.4.0",
|
|
71
|
+
"unified": "^11.0.5",
|
|
72
|
+
"unist-util-visit": "^5.0.0"
|
|
73
|
+
}
|
|
74
|
+
}
|