streamdown 1.6.9 → 1.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-ES5ZJKGK.cjs +10 -0
- package/dist/chunk-OGVTOU66.js +10 -0
- package/dist/{code-block-LTULQHW3.cjs → code-block-CWAJLW7T.cjs} +3 -2
- package/dist/{code-block-JS6V4U2P.js → code-block-QI2IAROF.js} +3 -2
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +2 -1
- package/dist/mermaid-M3FQV3C2.cjs +2 -0
- package/dist/mermaid-NA5CF7SZ.js +2 -0
- package/package.json +4 -2
- package/dist/chunk-7N2FFGCA.cjs +0 -21
- package/dist/chunk-T7OEMACY.js +0 -21
- package/dist/mermaid-NTG464FS.cjs +0 -1
- package/dist/mermaid-ZSTFYFNX.js +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var react=require('react'),rehypeHarden=require('rehype-harden'),we=require('rehype-katex'),qo=require('rehype-raw'),$o=require('remark-cjk-friendly'),zo=require('remark-cjk-friendly-gfm-strikethrough'),Xo=require('remark-gfm'),ke=require('remark-math'),Fo=require('remend'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),hastUtilToJsxRuntime=require('hast-util-to-jsx-runtime'),xo=require('remark-parse'),Co=require('remark-rehype'),unified=require('unified'),marked=require('marked');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var we__default=/*#__PURE__*/_interopDefault(we);var qo__default=/*#__PURE__*/_interopDefault(qo);var $o__default=/*#__PURE__*/_interopDefault($o);var zo__default=/*#__PURE__*/_interopDefault(zo);var Xo__default=/*#__PURE__*/_interopDefault(Xo);var ke__default=/*#__PURE__*/_interopDefault(ke);var Fo__default=/*#__PURE__*/_interopDefault(Fo);var xo__default=/*#__PURE__*/_interopDefault(xo);var Co__default=/*#__PURE__*/_interopDefault(Co);var u=(...e)=>tailwindMerge.twMerge(clsx.clsx(e)),R=(e,t,n)=>{let o=typeof t=="string"?new Blob([t],{type:n}):t,s=URL.createObjectURL(o),r=document.createElement("a");r.href=s,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s);};var Dt=react.createContext({code:""}),U=()=>react.useContext(Dt);var ie=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:s,code:r,...i})=>{let[a,d]=react.useState(false),c=react.useRef(0),{code:m}=U(),{isAnimating:l}=react.useContext(C),p=r!=null?r:m,g=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{a||(await navigator.clipboard.writeText(p),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),n));}catch(w){t==null||t(w);}};react.useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let f=a?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-copy-button",disabled:l,onClick:g,title:"Copy Code",type:"button",...i,children:o!=null?o:jsxRuntime.jsx(f,{size:14})})};var xe={"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"},Me=({onDownload:e,onError:t,language:n,children:o,className:s,code:r,...i})=>{let{code:a}=U(),{isAnimating:d}=react.useContext(C),c=r!=null?r:a,l=`file.${n&&n in xe?xe[n]:"txt"}`,p="text/plain",g=()=>{try{R(l,c,p),e==null||e();}catch(f){t==null||t(f);}};return jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-download-button",disabled:d,onClick:g,title:"Download file",type:"button",...i,children:o!=null?o:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})})};var de=()=>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(lucideReact.Loader2Icon,{className:"size-4 animate-spin"})})]});var Jt=/\.[^/.]+$/,Pe=({node:e,className:t,src:n,alt:o,...s})=>{let r=async()=>{if(n)try{let a=await(await fetch(n)).blob(),c=new URL(n,window.location.origin).pathname.split("/").pop()||"",m=c.split(".").pop(),l=c.includes(".")&&m!==void 0&&m.length<=4,p="";if(l)p=c;else {let g=a.type,f="png";g.includes("jpeg")||g.includes("jpg")?f="jpg":g.includes("png")?f="png":g.includes("svg")?f="svg":g.includes("gif")?f="gif":g.includes("webp")&&(f="webp"),p=`${(o||c||"image").replace(Jt,"")}.${f}`;}R(p,a,a.type);}catch(i){console.error("Failed to download image:",i);}};return n?jsxRuntime.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntime.jsx("img",{alt:o,className:u("max-w-full rounded-lg",t),"data-streamdown":"image",src:n,...s}),jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntime.jsx("button",{className:u("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:r,title:"Download image",type:"button",children:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})})]}):null};var _=async e=>{let n={...{startOnLoad:false,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:true},...e},s=(await import('mermaid')).default;return s.initialize(n),s},Te=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((s,r)=>{let i="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),a=new Image;a.crossOrigin="anonymous",a.onload=()=>{let d=document.createElement("canvas"),c=a.width*n,m=a.height*n;d.width=c,d.height=m;let l=d.getContext("2d");if(!l){r(new Error("Failed to create 2D canvas context for PNG export"));return}l.drawImage(a,0,0,c,m),d.toBlob(p=>{if(!p){r(new Error("Failed to create PNG blob"));return}s(p);},"image/png");},a.onerror=()=>r(new Error("Failed to load SVG image")),a.src=i;})};var Se=({chart:e,children:t,className:n,onDownload:o,config:s,onError:r})=>{let[i,a]=react.useState(false),d=react.useRef(null),{isAnimating:c}=react.useContext(C),m=async l=>{try{if(l==="mmd"){R("diagram.mmd",e,"text/plain"),a(!1),o==null||o(l);return}let p=await _(s),g=e.split("").reduce((w,v)=>(w<<5)-w+v.charCodeAt(0)|0,0),f=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:b}=await p.render(f,e);if(!b){r==null||r(new Error("SVG not found. Please wait for the diagram to render."));return}if(l==="svg"){R("diagram.svg",b,"image/svg+xml"),a(!1),o==null||o(l);return}if(l==="png"){let w=await Te(b);R("diagram.png",w,"image/png"),o==null||o(l),a(!1);return}}catch(p){r==null||r(p);}};return react.useEffect(()=>{let l=p=>{d.current&&!d.current.contains(p.target)&&a(false);};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:d,children:[jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:c,onClick:()=>a(!i),title:"Download diagram",type:"button",children:t!=null?t:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})}),i&&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("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:()=>m("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:()=>m("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]})]})};var J=0,to=()=>{J+=1,J===1&&(document.body.style.overflow="hidden");},oo=()=>{J=Math.max(0,J-1),J===0&&(document.body.style.overflow="");},De=({chart:e,config:t,onFullscreen:n,onExit:o,className:s,...r})=>{let[i,a]=react.useState(false),{isAnimating:d,controls:c}=react.useContext(C),m=(()=>{if(typeof c=="boolean")return c;let p=c.mermaid;return p===false?false:p===true||p===void 0?true:p.panZoom!==false})(),l=()=>{a(!i);};return react.useEffect(()=>{if(i){to();let p=g=>{g.key==="Escape"&&a(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),oo();}}},[i]),react.useEffect(()=>{i?n==null||n():o&&o();},[i,n,o]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),disabled:d,onClick:l,title:"View fullscreen",type:"button",...r,children:jsxRuntime.jsx(lucideReact.Maximize2Icon,{size:14})}),i&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:l,onKeyDown:p=>{p.key==="Escape"&&l();},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:l,title:"Exit fullscreen",type:"button",children:jsxRuntime.jsx(lucideReact.XIcon,{size:20})}),jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:jsxRuntime.jsx(Ee,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:m})})]})]})};var Y=e=>{var r,i;let t=[],n=[],o=e.querySelectorAll("thead th");for(let a of o)t.push(((r=a.textContent)==null?void 0:r.trim())||"");let s=e.querySelectorAll("tbody tr");for(let a of s){let d=[],c=a.querySelectorAll("td");for(let m of c)d.push(((i=m.textContent)==null?void 0:i.trim())||"");n.push(d);}return {headers:t,rows:n}},Q=e=>{let{headers:t,rows:n}=e,o=a=>{let d=false,c=false;for(let m=0;m<a.length;m+=1){let l=a[m];if(l==='"'){d=true,c=true;break}(l===","||l===`
|
|
3
|
+
`)&&(d=true);}return d?c?`"${a.replace(/"/g,'""')}"`:`"${a}"`:a},s=t.length>0?n.length+1:n.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(o).join(","),i+=1);for(let a of n)r[i]=a.map(o).join(","),i+=1;return r.join(`
|
|
4
|
+
`)},Le=e=>{let{headers:t,rows:n}=e,o=a=>{let d=false;for(let m=0;m<a.length;m+=1){let l=a[m];if(l===" "||l===`
|
|
5
|
+
`||l==="\r"){d=true;break}}if(!d)return a;let c=[];for(let m=0;m<a.length;m+=1){let l=a[m];l===" "?c.push("\\t"):l===`
|
|
6
|
+
`?c.push("\\n"):l==="\r"?c.push("\\r"):c.push(l);}return c.join("")},s=t.length>0?n.length+1:n.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(o).join(" "),i+=1);for(let a of n)r[i]=a.map(o).join(" "),i+=1;return r.join(`
|
|
7
|
+
`)},ce=e=>{let t=false;for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="\\"||s==="|"){t=true;break}}if(!t)return e;let n=[];for(let o=0;o<e.length;o+=1){let s=e[o];s==="\\"?n.push("\\\\"):s==="|"?n.push("\\|"):n.push(s);}return n.join("")},Be=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),s=0,r=t.map(a=>ce(a));o[s]=`| ${r.join(" | ")} |`,s+=1;let i=new Array(t.length);for(let a=0;a<t.length;a+=1)i[a]="---";o[s]=`| ${i.join(" | ")} |`,s+=1;for(let a of n)if(a.length<t.length){let d=new Array(t.length);for(let c=0;c<t.length;c+=1)d[c]=c<a.length?ce(a[c]):"";o[s]=`| ${d.join(" | ")} |`,s+=1;}else {let d=a.map(c=>ce(c));o[s]=`| ${d.join(" | ")} |`,s+=1;}return o.join(`
|
|
8
|
+
`)};var Oe=({children:e,className:t,onCopy:n,onError:o,timeout:s=2e3})=>{let[r,i]=react.useState(false),[a,d]=react.useState(false),c=react.useRef(null),m=react.useRef(0),{isAnimating:l}=react.useContext(C),p=async f=>{var b,w;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.write)){o==null||o(new Error("Clipboard API not available"));return}try{let v=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),T=v==null?void 0:v.querySelector("table");if(!T){o==null||o(new Error("Table not found"));return}let M=Y(T),P=f==="csv"?Q(M):Le(M),j=new ClipboardItem({"text/plain":new Blob([P],{type:"text/plain"}),"text/html":new Blob([T.outerHTML],{type:"text/html"})});await navigator.clipboard.write([j]),d(!0),i(!1),n==null||n(f),m.current=window.setTimeout(()=>d(!1),s);}catch(v){o==null||o(v);}};react.useEffect(()=>{let f=b=>{c.current&&!c.current.contains(b.target)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(m.current);}},[]);let g=a?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:()=>i(!r),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(g,{size:14})}),r&&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:()=>p("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:()=>p("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]})]})};var $e=({children:e,className:t,onDownload:n,onError:o})=>{let[s,r]=react.useState(false),i=react.useRef(null),{isAnimating:a}=react.useContext(C),d=c=>{var m;try{let l=(m=i.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),p=l==null?void 0:l.querySelector("table");if(!p){o==null||o(new Error("Table not found"));return}let g=Y(p),f=c==="csv"?Q(g):Be(g);R(`table.${c==="csv"?"csv":"md"}`,f,c==="csv"?"text/csv":"text/markdown"),r(!1),n==null||n(c);}catch(l){o==null||o(l);}};return react.useEffect(()=>{let c=m=>{i.current&&!i.current.contains(m.target)&&r(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:i,children:[jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:a,onClick:()=>r(!s),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(lucideReact.DownloadIcon,{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:()=>d("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:()=>d("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]})]})};var Xe=({children:e,className:t,showControls:n,...o})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(Oe,{}),jsxRuntime.jsx($e,{})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:u("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var fo=react.lazy(()=>import('./code-block-CWAJLW7T.cjs').then(e=>({default:e.CodeBlock}))),go=react.lazy(()=>import('./mermaid-M3FQV3C2.cjs').then(e=>({default:e.Mermaid}))),bo=/language-([^\s]+)/;function re(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 n=e.position.start,o=t.position.start,s=e.position.end,r=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(s==null?void 0:s.line)===(r==null?void 0:r.line)&&(s==null?void 0:s.column)===(r==null?void 0:r.column)}function x(e,t){return e.className===t.className&&re(e.node,t.node)}var pe=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ne=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},ue=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("ol",{className:u("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>x(e,t));ue.displayName="MarkdownOl";var Ve=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("li",{className:u("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&re(e.node,t.node));Ve.displayName="MarkdownLi";var Ke=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("ul",{className:u("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>x(e,t));Ke.displayName="MarkdownUl";var Ze=react.memo(({className:e,node:t,...n})=>jsxRuntime.jsx("hr",{className:u("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>x(e,t));Ze.displayName="MarkdownHr";var Ue=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("span",{className:u("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>x(e,t));Ue.displayName="MarkdownStrong";var Ge=react.memo(({children:e,className:t,href:n,node:o,...s})=>{let r=n==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:u("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...s,children:e})},(e,t)=>x(e,t)&&e.href===t.href);Ge.displayName="MarkdownA";var _e=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h1",{className:u("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>x(e,t));_e.displayName="MarkdownH1";var Ye=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h2",{className:u("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>x(e,t));Ye.displayName="MarkdownH2";var Qe=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h3",{className:u("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>x(e,t));Qe.displayName="MarkdownH3";var et=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h4",{className:u("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>x(e,t));et.displayName="MarkdownH4";var tt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h5",{className:u("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>x(e,t));tt.displayName="MarkdownH5";var ot=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h6",{className:u("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>x(e,t));ot.displayName="MarkdownH6";var nt=react.memo(({children:e,className:t,node:n,...o})=>{let{controls:s}=react.useContext(C),r=pe(s,"table");return jsxRuntime.jsx(Xe,{className:t,"data-streamdown":"table-wrapper",showControls:r,...o,children:e})},(e,t)=>x(e,t));nt.displayName="MarkdownTable";var rt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("thead",{className:u("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>x(e,t));rt.displayName="MarkdownThead";var st=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("tbody",{className:u("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>x(e,t));st.displayName="MarkdownTbody";var at=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("tr",{className:u("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>x(e,t));at.displayName="MarkdownTr";var it=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("th",{className:u("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>x(e,t));it.displayName="MarkdownTh";var lt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("td",{className:u("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>x(e,t));lt.displayName="MarkdownTd";var dt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("blockquote",{className:u("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>x(e,t));dt.displayName="MarkdownBlockquote";var ct=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("sup",{className:u("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>x(e,t));ct.displayName="MarkdownSup";var mt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("sub",{className:u("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>x(e,t));mt.displayName="MarkdownSub";var pt=react.memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let r=d=>{var p,g;if(!react.isValidElement(d))return false;let c=Array.isArray(d.props.children)?d.props.children:[d.props.children],m=false,l=false;for(let f of c)if(f){if(typeof f=="string")f.trim()!==""&&(m=true);else if(react.isValidElement(f))if(((p=f.props)==null?void 0:p["data-footnote-backref"])!==void 0)l=true;else {let b=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let w of b){if(typeof w=="string"&&w.trim()!==""){m=true;break}if(react.isValidElement(w)&&((g=w.props)==null?void 0:g["data-footnote-backref"])===void 0){m=true;break}}}}return l&&!m},i=Array.isArray(e)?e.map(d=>{if(!react.isValidElement(d))return d;if(d.type===ue){let m=(Array.isArray(d.props.children)?d.props.children:[d.props.children]).filter(l=>!r(l));return m.length===0?null:{...d,props:{...d.props,children:m}}}return d}):e;return (Array.isArray(i)?i.some(d=>d!==null):i!==null)?jsxRuntime.jsx("section",{className:t,...o,children:i}):null}return jsxRuntime.jsx("section",{className:t,...o,children:e})},(e,t)=>x(e,t));pt.displayName="MarkdownSection";var ho=({node:e,className:t,children:n,...o})=>{var l,p,g;let s=((l=e==null?void 0:e.position)==null?void 0:l.start.line)===((p=e==null?void 0:e.position)==null?void 0:p.end.line),{mermaid:r,controls:i}=react.useContext(C);if(s)return jsxRuntime.jsx("code",{className:u("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let a=t==null?void 0:t.match(bo),d=(g=a==null?void 0:a.at(1))!=null?g:"",c="";if(react.isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?c=n.props.children:typeof n=="string"&&(c=n),d==="mermaid"){let f=pe(i,"mermaid"),b=ne(i,"download"),w=ne(i,"copy"),v=ne(i,"fullscreen"),T=ne(i,"panZoom");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(de,{}),children:jsxRuntime.jsxs("div",{className:u("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[f&&(b||w||v)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b&&jsxRuntime.jsx(Se,{chart:c,config:r==null?void 0:r.config}),w&&jsxRuntime.jsx(ie,{code:c}),v&&jsxRuntime.jsx(De,{chart:c,config:r==null?void 0:r.config})]}),jsxRuntime.jsx(go,{chart:c,config:r==null?void 0:r.config,showControls:T})]})})}let m=pe(i,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(de,{}),children:jsxRuntime.jsx(fo,{className:u("overflow-x-auto border-border border-t",t),code:c,language:d,children:m&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Me,{code:c,language:d}),jsxRuntime.jsx(ie,{})]})})})},ut=react.memo(ho,(e,t)=>e.className===t.className&&re(e.node,t.node));ut.displayName="MarkdownCode";var ft=react.memo(Pe,(e,t)=>e.className===t.className&&re(e.node,t.node));ft.displayName="MarkdownImg";var gt=react.memo(({children:e,className:t,node:n,...o})=>{var i;let r=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");return r.length===1&&react.isValidElement(r[0])&&((i=r[0].props.node)==null?void 0:i.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):jsxRuntime.jsx("p",{className:t,...o,children:e})},(e,t)=>x(e,t));gt.displayName="MarkdownParagraph";var bt={ol:ue,li:Ve,ul:Ke,hr:Ze,strong:Ue,a:Ge,h1:_e,h2:Ye,h3:Qe,h4:et,h5:tt,h6:ot,table:nt,thead:rt,tbody:st,tr:at,th:it,td:lt,blockquote:dt,code:ut,img:ft,pre:({children:e})=>e,sup:ct,sub:mt,p:gt,section:pt};var yt=[],wt={allowDangerousHtml:true},se=new WeakMap,fe=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,s=t.remarkPlugins,r=t.remarkRehypeOptions;if(!(o||s||r)){let l="default";return this.keyCache.set(t,l),l}let i=l=>{if(!l||l.length===0)return "";let p="";for(let g=0;g<l.length;g+=1){let f=l[g];if(g>0&&(p+=","),Array.isArray(f)){let[b,w]=f;if(typeof b=="function"){let v=se.get(b);v||(v=b.name,se.set(b,v)),p+=v;}else p+=String(b);p+=":",p+=JSON.stringify(w);}else if(typeof f=="function"){let b=se.get(f);b||(b=f.name,se.set(f,b)),p+=b;}else p+=String(f);}return p},a=i(o),d=i(s),c=r?JSON.stringify(r):"",m=`${d}::${a}::${c}`;return this.keyCache.set(t,m),m}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let s=this.cache.keys().next().value;s&&this.cache.delete(s);}this.cache.set(o,n);}clear(){this.cache.clear();}},kt=new fe,ge=e=>{let t=Po(e),n=e.children||"";return No(t.runSync(t.parse(n),n),e)},Po=e=>{let t=kt.get(e);if(t)return t;let n=To(e);return kt.set(e,n),n},To=e=>{let t=e.rehypePlugins||yt,n=e.remarkPlugins||yt,o=e.remarkRehypeOptions?{...wt,...e.remarkRehypeOptions}:wt;return unified.unified().use(xo__default.default).use(n).use(Co__default.default,o).use(t)},No=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Ro=/\[\^[^\]\s]{1,200}\](?!:)/,Io=/\[\^[^\]\s]{1,200}\]:/,Eo=/<\/(\w+)>/,Do=/<(\w+)[\s>]/,be=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]==="$"},Lo=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]==="$"},he=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},ye=e=>{let t=Ro.test(e),n=Io.test(e);if(t||n)return [e];let o=marked.Lexer.lex(e,{gfm:true}),s=[],r=[];for(let i of o){let a=i.raw,d=s.length;if(r.length>0){if(s[d-1]+=a,i.type==="html"){let m=a.match(Eo);if(m){let l=m[1];r.at(-1)===l&&r.pop();}}continue}if(i.type==="html"&&i.block){let m=a.match(Do);if(m){let l=m[1];a.includes(`</${l}>`)||r.push(l);}}if(a.trim()==="$$"&&d>0){let m=s[d-1],l=be(m),p=he(m);if(l&&p%2===1){s[d-1]=m+a;continue}}if(d>0&&Lo(a)){let m=s[d-1],l=be(m),p=he(m),g=he(a);if(l&&p%2===1&&!be(a)&&g===1){s[d-1]=m+a;continue}}s.push(a);}return s};var Jo={raw:qo__default.default,katex:[we__default.default,{errorColor:"var(--color-muted-foreground)"}],harden:[rehypeHarden.harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Wo={gfm:[Xo__default.default,{}],math:[ke__default.default,{singleDollarTextMath:false}],cjkFriendly:[$o__default.default,{}],cjkFriendlyGfmStrikethrough:[zo__default.default,{}]},Vo=Object.values(Jo),Ko=Object.values(Wo),Zo={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0},C=react.createContext(Zo),Ct=react.memo(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let o=react.useMemo(()=>typeof e=="string"&&t?Fo__default.default(e.trim()):e,[e,t]);return jsxRuntime.jsx(ge,{...n,children:o})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(s=>{var r,i;return ((r=e.components)==null?void 0:r[s])!==((i=t.components)==null?void 0:i[s])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Ct.displayName="Block";var Uo=["github-light","github-dark"],Go=react.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:n=true,components:o,rehypePlugins:s=Vo,remarkPlugins:r=Ko,className:i,shikiTheme:a=Uo,mermaid:d,controls:c=true,isAnimating:m=false,BlockComponent:l=Ct,parseMarkdownIntoBlocksFn:p=ye,...g})=>{let f=react.useId(),[b,w]=react.useTransition(),[v,T]=react.useState([]),M=react.useMemo(()=>p(typeof e=="string"?e:""),[e,p]);react.useEffect(()=>{t==="streaming"?w(()=>{T(M);}):T(M);},[M,t]);let P=t==="streaming"?v:M,j=react.useMemo(()=>P.map((I,E)=>`${f}-${E}`),[P.length,f]),A=react.useMemo(()=>({shikiTheme:a,controls:c,isAnimating:m,mode:t,mermaid:d}),[a,c,m,t,d]),H=react.useMemo(()=>({...bt,...o}),[o]);return react.useEffect(()=>{if(!(Array.isArray(s)&&s.some(S=>Array.isArray(S)?S[0]===we__default.default:S===we__default.default)))return;let E=false;if(Array.isArray(r)){let S=r.find(Z=>Array.isArray(Z)?Z[0]===ke__default.default:Z===ke__default.default);S&&Array.isArray(S)&&S[1]&&(E=S[1].singleDollarTextMath===true);}let D=typeof e=="string"?e:"",O=D.includes("$$"),y=E&&(/[^$]\$[^$]/.test(D)||/^\$[^$]/.test(D)||/[^$]\$$/.test(D));(O||y)&&import('katex/dist/katex.min.css');},[s,r,e]),t==="static"?jsxRuntime.jsx(C.Provider,{value:A,children:jsxRuntime.jsx("div",{className:u("space-y-4 whitespace-normal",i),children:jsxRuntime.jsx(ge,{components:H,rehypePlugins:s,remarkPlugins:r,...g,children:e})})}):jsxRuntime.jsx(C.Provider,{value:A,children:jsxRuntime.jsx("div",{className:u("space-y-4 whitespace-normal",i),children:P.map((I,E)=>jsxRuntime.jsx(l,{components:H,content:I,index:E,rehypePlugins:s,remarkPlugins:r,shouldParseIncompleteMarkdown:n,...g},j[E]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Go.displayName="Streamdown";var Nt=({children:e,className:t,minZoom:n=.5,maxZoom:o=3,zoomStep:s=.1,showControls:r=true,initialZoom:i=1,fullscreen:a=false})=>{let d=react.useRef(null),c=react.useRef(null),[m,l]=react.useState(i),[p,g]=react.useState({x:0,y:0}),[f,b]=react.useState(false),[w,v]=react.useState({x:0,y:0}),[T,M]=react.useState({x:0,y:0}),P=react.useCallback(y=>{l(N=>Math.max(n,Math.min(o,N+y)));},[n,o]),j=react.useCallback(()=>{P(s);},[P,s]),A=react.useCallback(()=>{P(-s);},[P,s]),H=react.useCallback(()=>{l(i),g({x:0,y:0});},[i]),I=react.useCallback(y=>{y.preventDefault();let N=y.deltaY>0?-s:s;P(N);},[P,s]),E=react.useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;b(true),v({x:y.clientX,y:y.clientY}),M(p);let N=y.currentTarget;N instanceof HTMLElement&&N.setPointerCapture(y.pointerId);},[p]),D=react.useCallback(y=>{if(!f)return;y.preventDefault();let N=y.clientX-w.x,S=y.clientY-w.y;g({x:T.x+N,y:T.y+S});},[f,w,T]),O=react.useCallback(y=>{b(false);let N=y.currentTarget;N instanceof HTMLElement&&N.releasePointerCapture(y.pointerId);},[]);return react.useEffect(()=>{let y=d.current;if(y)return y.addEventListener("wheel",I,{passive:false}),()=>{y.removeEventListener("wheel",I);}},[I]),react.useEffect(()=>{let y=c.current;if(y&&f)return document.body.style.userSelect="none",y.addEventListener("pointermove",D,{passive:false}),y.addEventListener("pointerup",O),y.addEventListener("pointercancel",O),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",D),y.removeEventListener("pointerup",O),y.removeEventListener("pointercancel",O);}},[f,D,O]),jsxRuntime.jsxs("div",{className:u("relative",a?"h-full w-full":"w-full",t),ref:d,style:{cursor:f?"grabbing":"grab"},children:[r&&jsxRuntime.jsxs("div",{className:u("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",a?"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:m>=o,onClick:j,title:"Zoom in",type:"button",children:jsxRuntime.jsx(lucideReact.ZoomInIcon,{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:m<=n,onClick:A,title:"Zoom out",type:"button",children:jsxRuntime.jsx(lucideReact.ZoomOutIcon,{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:H,title:"Reset zoom and pan",type:"button",children:jsxRuntime.jsx(lucideReact.RotateCcwIcon,{size:16})})]}),jsxRuntime.jsx("div",{className:u("origin-center transition-transform duration-150 ease-out",a&&"flex w-full items-center justify-center"),onPointerDown:E,ref:c,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${m})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Ee=({chart:e,className:t,config:n,fullscreen:o=false,showControls:s=true})=>{let[r,i]=react.useState(null),[a,d]=react.useState(true),[c,m]=react.useState(""),[l,p]=react.useState(""),[g,f]=react.useState(0),{mermaid:b}=react.useContext(C),w=b==null?void 0:b.errorComponent;if(react.useEffect(()=>{(async()=>{try{i(null),d(!0);let M=await _(n),P=e.split("").reduce((H,I)=>(H<<5)-H+I.charCodeAt(0)|0,0),j=`mermaid-${Math.abs(P)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:A}=await M.render(j,e);m(A),p(A);}catch(M){if(!(l||c)){let P=M instanceof Error?M.message:"Failed to render Mermaid chart";i(P);}}finally{d(false);}})();},[e,n,g]),a&&!c&&!l)return jsxRuntime.jsx("div",{className:u("my-4 flex justify-center p-4",t),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(r&&!c&&!l){let T=()=>f(M=>M+1);return w?jsxRuntime.jsx(w,{chart:e,error:r,retry:T}):jsxRuntime.jsxs("div",{className:u("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[jsxRuntime.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),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 v=c||l;return jsxRuntime.jsx(Nt,{className:u(o?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:o,maxZoom:3,minZoom:.5,showControls:s,zoomStep:.1,children:jsxRuntime.jsx("div",{"aria-label":"Mermaid chart",className:u("flex justify-center",o&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:v},role:"img"})})};exports.a=u;exports.b=Dt;exports.c=Ee;exports.d=ye;exports.e=Jo;exports.f=Wo;exports.g=C;exports.h=Ct;exports.i=Go;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {createContext,lazy,memo,useContext,isValidElement,useMemo,useId,useTransition,useState,useEffect,Suspense,useRef,useCallback}from'react';import {harden}from'rehype-harden';import we from'rehype-katex';import qo from'rehype-raw';import $o from'remark-cjk-friendly';import zo from'remark-cjk-friendly-gfm-strikethrough';import Xo from'remark-gfm';import ke from'remark-math';import Fo from'remend';import {DownloadIcon,CheckIcon,CopyIcon,Maximize2Icon,XIcon,Loader2Icon,ZoomInIcon,ZoomOutIcon,RotateCcwIcon}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import xo from'remark-parse';import Co from'remark-rehype';import {unified}from'unified';import {Lexer}from'marked';var u=(...e)=>twMerge(clsx(e)),R=(e,t,n)=>{let o=typeof t=="string"?new Blob([t],{type:n}):t,s=URL.createObjectURL(o),r=document.createElement("a");r.href=s,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s);};var Dt=createContext({code:""}),U=()=>useContext(Dt);var ie=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:s,code:r,...i})=>{let[a,d]=useState(false),c=useRef(0),{code:m}=U(),{isAnimating:l}=useContext(C),p=r!=null?r:m,g=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{a||(await navigator.clipboard.writeText(p),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),n));}catch(w){t==null||t(w);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let f=a?CheckIcon:CopyIcon;return jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-copy-button",disabled:l,onClick:g,title:"Copy Code",type:"button",...i,children:o!=null?o:jsx(f,{size:14})})};var xe={"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"},Me=({onDownload:e,onError:t,language:n,children:o,className:s,code:r,...i})=>{let{code:a}=U(),{isAnimating:d}=useContext(C),c=r!=null?r:a,l=`file.${n&&n in xe?xe[n]:"txt"}`,p="text/plain",g=()=>{try{R(l,c,p),e==null||e();}catch(f){t==null||t(f);}};return jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-download-button",disabled:d,onClick:g,title:"Download file",type:"button",...i,children:o!=null?o:jsx(DownloadIcon,{size:14})})};var de=()=>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(Loader2Icon,{className:"size-4 animate-spin"})})]});var Jt=/\.[^/.]+$/,Pe=({node:e,className:t,src:n,alt:o,...s})=>{let r=async()=>{if(n)try{let a=await(await fetch(n)).blob(),c=new URL(n,window.location.origin).pathname.split("/").pop()||"",m=c.split(".").pop(),l=c.includes(".")&&m!==void 0&&m.length<=4,p="";if(l)p=c;else {let g=a.type,f="png";g.includes("jpeg")||g.includes("jpg")?f="jpg":g.includes("png")?f="png":g.includes("svg")?f="svg":g.includes("gif")?f="gif":g.includes("webp")&&(f="webp"),p=`${(o||c||"image").replace(Jt,"")}.${f}`;}R(p,a,a.type);}catch(i){console.error("Failed to download image:",i);}};return n?jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsx("img",{alt:o,className:u("max-w-full rounded-lg",t),"data-streamdown":"image",src:n,...s}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsx("button",{className:u("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:r,title:"Download image",type:"button",children:jsx(DownloadIcon,{size:14})})]}):null};var _=async e=>{let n={...{startOnLoad:false,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:true},...e},s=(await import('mermaid')).default;return s.initialize(n),s},Te=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((s,r)=>{let i="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),a=new Image;a.crossOrigin="anonymous",a.onload=()=>{let d=document.createElement("canvas"),c=a.width*n,m=a.height*n;d.width=c,d.height=m;let l=d.getContext("2d");if(!l){r(new Error("Failed to create 2D canvas context for PNG export"));return}l.drawImage(a,0,0,c,m),d.toBlob(p=>{if(!p){r(new Error("Failed to create PNG blob"));return}s(p);},"image/png");},a.onerror=()=>r(new Error("Failed to load SVG image")),a.src=i;})};var Se=({chart:e,children:t,className:n,onDownload:o,config:s,onError:r})=>{let[i,a]=useState(false),d=useRef(null),{isAnimating:c}=useContext(C),m=async l=>{try{if(l==="mmd"){R("diagram.mmd",e,"text/plain"),a(!1),o==null||o(l);return}let p=await _(s),g=e.split("").reduce((w,v)=>(w<<5)-w+v.charCodeAt(0)|0,0),f=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:b}=await p.render(f,e);if(!b){r==null||r(new Error("SVG not found. Please wait for the diagram to render."));return}if(l==="svg"){R("diagram.svg",b,"image/svg+xml"),a(!1),o==null||o(l);return}if(l==="png"){let w=await Te(b);R("diagram.png",w,"image/png"),o==null||o(l),a(!1);return}}catch(p){r==null||r(p);}};return useEffect(()=>{let l=p=>{d.current&&!d.current.contains(p.target)&&a(false);};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l);}},[]),jsxs("div",{className:"relative",ref:d,children:[jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:c,onClick:()=>a(!i),title:"Download diagram",type:"button",children:t!=null?t:jsx(DownloadIcon,{size:14})}),i&&jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("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:()=>m("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:()=>m("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]})]})};var J=0,to=()=>{J+=1,J===1&&(document.body.style.overflow="hidden");},oo=()=>{J=Math.max(0,J-1),J===0&&(document.body.style.overflow="");},De=({chart:e,config:t,onFullscreen:n,onExit:o,className:s,...r})=>{let[i,a]=useState(false),{isAnimating:d,controls:c}=useContext(C),m=(()=>{if(typeof c=="boolean")return c;let p=c.mermaid;return p===false?false:p===true||p===void 0?true:p.panZoom!==false})(),l=()=>{a(!i);};return useEffect(()=>{if(i){to();let p=g=>{g.key==="Escape"&&a(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),oo();}}},[i]),useEffect(()=>{i?n==null||n():o&&o();},[i,n,o]),jsxs(Fragment,{children:[jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),disabled:d,onClick:l,title:"View fullscreen",type:"button",...r,children:jsx(Maximize2Icon,{size:14})}),i&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:l,onKeyDown:p=>{p.key==="Escape"&&l();},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:l,title:"Exit fullscreen",type:"button",children:jsx(XIcon,{size:20})}),jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:jsx(Ee,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:m})})]})]})};var Y=e=>{var r,i;let t=[],n=[],o=e.querySelectorAll("thead th");for(let a of o)t.push(((r=a.textContent)==null?void 0:r.trim())||"");let s=e.querySelectorAll("tbody tr");for(let a of s){let d=[],c=a.querySelectorAll("td");for(let m of c)d.push(((i=m.textContent)==null?void 0:i.trim())||"");n.push(d);}return {headers:t,rows:n}},Q=e=>{let{headers:t,rows:n}=e,o=a=>{let d=false,c=false;for(let m=0;m<a.length;m+=1){let l=a[m];if(l==='"'){d=true,c=true;break}(l===","||l===`
|
|
3
|
+
`)&&(d=true);}return d?c?`"${a.replace(/"/g,'""')}"`:`"${a}"`:a},s=t.length>0?n.length+1:n.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(o).join(","),i+=1);for(let a of n)r[i]=a.map(o).join(","),i+=1;return r.join(`
|
|
4
|
+
`)},Le=e=>{let{headers:t,rows:n}=e,o=a=>{let d=false;for(let m=0;m<a.length;m+=1){let l=a[m];if(l===" "||l===`
|
|
5
|
+
`||l==="\r"){d=true;break}}if(!d)return a;let c=[];for(let m=0;m<a.length;m+=1){let l=a[m];l===" "?c.push("\\t"):l===`
|
|
6
|
+
`?c.push("\\n"):l==="\r"?c.push("\\r"):c.push(l);}return c.join("")},s=t.length>0?n.length+1:n.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(o).join(" "),i+=1);for(let a of n)r[i]=a.map(o).join(" "),i+=1;return r.join(`
|
|
7
|
+
`)},ce=e=>{let t=false;for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="\\"||s==="|"){t=true;break}}if(!t)return e;let n=[];for(let o=0;o<e.length;o+=1){let s=e[o];s==="\\"?n.push("\\\\"):s==="|"?n.push("\\|"):n.push(s);}return n.join("")},Be=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),s=0,r=t.map(a=>ce(a));o[s]=`| ${r.join(" | ")} |`,s+=1;let i=new Array(t.length);for(let a=0;a<t.length;a+=1)i[a]="---";o[s]=`| ${i.join(" | ")} |`,s+=1;for(let a of n)if(a.length<t.length){let d=new Array(t.length);for(let c=0;c<t.length;c+=1)d[c]=c<a.length?ce(a[c]):"";o[s]=`| ${d.join(" | ")} |`,s+=1;}else {let d=a.map(c=>ce(c));o[s]=`| ${d.join(" | ")} |`,s+=1;}return o.join(`
|
|
8
|
+
`)};var Oe=({children:e,className:t,onCopy:n,onError:o,timeout:s=2e3})=>{let[r,i]=useState(false),[a,d]=useState(false),c=useRef(null),m=useRef(0),{isAnimating:l}=useContext(C),p=async f=>{var b,w;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.write)){o==null||o(new Error("Clipboard API not available"));return}try{let v=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),T=v==null?void 0:v.querySelector("table");if(!T){o==null||o(new Error("Table not found"));return}let M=Y(T),P=f==="csv"?Q(M):Le(M),j=new ClipboardItem({"text/plain":new Blob([P],{type:"text/plain"}),"text/html":new Blob([T.outerHTML],{type:"text/html"})});await navigator.clipboard.write([j]),d(!0),i(!1),n==null||n(f),m.current=window.setTimeout(()=>d(!1),s);}catch(v){o==null||o(v);}};useEffect(()=>{let f=b=>{c.current&&!c.current.contains(b.target)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(m.current);}},[]);let g=a?CheckIcon:CopyIcon;return jsxs("div",{className:"relative",ref:c,children:[jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:()=>i(!r),title:"Copy table",type:"button",children:e!=null?e:jsx(g,{size:14})}),r&&jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]})]})};var $e=({children:e,className:t,onDownload:n,onError:o})=>{let[s,r]=useState(false),i=useRef(null),{isAnimating:a}=useContext(C),d=c=>{var m;try{let l=(m=i.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),p=l==null?void 0:l.querySelector("table");if(!p){o==null||o(new Error("Table not found"));return}let g=Y(p),f=c==="csv"?Q(g):Be(g);R(`table.${c==="csv"?"csv":"md"}`,f,c==="csv"?"text/csv":"text/markdown"),r(!1),n==null||n(c);}catch(l){o==null||o(l);}};return useEffect(()=>{let c=m=>{i.current&&!i.current.contains(m.target)&&r(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxs("div",{className:"relative",ref:i,children:[jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:a,onClick:()=>r(!s),title:"Download table",type:"button",children:e!=null?e:jsx(DownloadIcon,{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:()=>d("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:()=>d("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]})]})};var Xe=({children:e,className:t,showControls:n,...o})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(Oe,{}),jsx($e,{})]}),jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:u("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var fo=lazy(()=>import('./code-block-QI2IAROF.js').then(e=>({default:e.CodeBlock}))),go=lazy(()=>import('./mermaid-NA5CF7SZ.js').then(e=>({default:e.Mermaid}))),bo=/language-([^\s]+)/;function re(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 n=e.position.start,o=t.position.start,s=e.position.end,r=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(s==null?void 0:s.line)===(r==null?void 0:r.line)&&(s==null?void 0:s.column)===(r==null?void 0:r.column)}function x(e,t){return e.className===t.className&&re(e.node,t.node)}var pe=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ne=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},ue=memo(({children:e,className:t,node:n,...o})=>jsx("ol",{className:u("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>x(e,t));ue.displayName="MarkdownOl";var Ve=memo(({children:e,className:t,node:n,...o})=>jsx("li",{className:u("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&re(e.node,t.node));Ve.displayName="MarkdownLi";var Ke=memo(({children:e,className:t,node:n,...o})=>jsx("ul",{className:u("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>x(e,t));Ke.displayName="MarkdownUl";var Ze=memo(({className:e,node:t,...n})=>jsx("hr",{className:u("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>x(e,t));Ze.displayName="MarkdownHr";var Ue=memo(({children:e,className:t,node:n,...o})=>jsx("span",{className:u("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>x(e,t));Ue.displayName="MarkdownStrong";var Ge=memo(({children:e,className:t,href:n,node:o,...s})=>{let r=n==="streamdown:incomplete-link";return jsx("a",{className:u("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...s,children:e})},(e,t)=>x(e,t)&&e.href===t.href);Ge.displayName="MarkdownA";var _e=memo(({children:e,className:t,node:n,...o})=>jsx("h1",{className:u("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>x(e,t));_e.displayName="MarkdownH1";var Ye=memo(({children:e,className:t,node:n,...o})=>jsx("h2",{className:u("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>x(e,t));Ye.displayName="MarkdownH2";var Qe=memo(({children:e,className:t,node:n,...o})=>jsx("h3",{className:u("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>x(e,t));Qe.displayName="MarkdownH3";var et=memo(({children:e,className:t,node:n,...o})=>jsx("h4",{className:u("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>x(e,t));et.displayName="MarkdownH4";var tt=memo(({children:e,className:t,node:n,...o})=>jsx("h5",{className:u("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>x(e,t));tt.displayName="MarkdownH5";var ot=memo(({children:e,className:t,node:n,...o})=>jsx("h6",{className:u("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>x(e,t));ot.displayName="MarkdownH6";var nt=memo(({children:e,className:t,node:n,...o})=>{let{controls:s}=useContext(C),r=pe(s,"table");return jsx(Xe,{className:t,"data-streamdown":"table-wrapper",showControls:r,...o,children:e})},(e,t)=>x(e,t));nt.displayName="MarkdownTable";var rt=memo(({children:e,className:t,node:n,...o})=>jsx("thead",{className:u("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>x(e,t));rt.displayName="MarkdownThead";var st=memo(({children:e,className:t,node:n,...o})=>jsx("tbody",{className:u("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>x(e,t));st.displayName="MarkdownTbody";var at=memo(({children:e,className:t,node:n,...o})=>jsx("tr",{className:u("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>x(e,t));at.displayName="MarkdownTr";var it=memo(({children:e,className:t,node:n,...o})=>jsx("th",{className:u("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>x(e,t));it.displayName="MarkdownTh";var lt=memo(({children:e,className:t,node:n,...o})=>jsx("td",{className:u("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>x(e,t));lt.displayName="MarkdownTd";var dt=memo(({children:e,className:t,node:n,...o})=>jsx("blockquote",{className:u("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>x(e,t));dt.displayName="MarkdownBlockquote";var ct=memo(({children:e,className:t,node:n,...o})=>jsx("sup",{className:u("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>x(e,t));ct.displayName="MarkdownSup";var mt=memo(({children:e,className:t,node:n,...o})=>jsx("sub",{className:u("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>x(e,t));mt.displayName="MarkdownSub";var pt=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let r=d=>{var p,g;if(!isValidElement(d))return false;let c=Array.isArray(d.props.children)?d.props.children:[d.props.children],m=false,l=false;for(let f of c)if(f){if(typeof f=="string")f.trim()!==""&&(m=true);else if(isValidElement(f))if(((p=f.props)==null?void 0:p["data-footnote-backref"])!==void 0)l=true;else {let b=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let w of b){if(typeof w=="string"&&w.trim()!==""){m=true;break}if(isValidElement(w)&&((g=w.props)==null?void 0:g["data-footnote-backref"])===void 0){m=true;break}}}}return l&&!m},i=Array.isArray(e)?e.map(d=>{if(!isValidElement(d))return d;if(d.type===ue){let m=(Array.isArray(d.props.children)?d.props.children:[d.props.children]).filter(l=>!r(l));return m.length===0?null:{...d,props:{...d.props,children:m}}}return d}):e;return (Array.isArray(i)?i.some(d=>d!==null):i!==null)?jsx("section",{className:t,...o,children:i}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>x(e,t));pt.displayName="MarkdownSection";var ho=({node:e,className:t,children:n,...o})=>{var l,p,g;let s=((l=e==null?void 0:e.position)==null?void 0:l.start.line)===((p=e==null?void 0:e.position)==null?void 0:p.end.line),{mermaid:r,controls:i}=useContext(C);if(s)return jsx("code",{className:u("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let a=t==null?void 0:t.match(bo),d=(g=a==null?void 0:a.at(1))!=null?g:"",c="";if(isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?c=n.props.children:typeof n=="string"&&(c=n),d==="mermaid"){let f=pe(i,"mermaid"),b=ne(i,"download"),w=ne(i,"copy"),v=ne(i,"fullscreen"),T=ne(i,"panZoom");return jsx(Suspense,{fallback:jsx(de,{}),children:jsxs("div",{className:u("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[f&&(b||w||v)&&jsxs("div",{className:"flex items-center justify-end gap-2",children:[b&&jsx(Se,{chart:c,config:r==null?void 0:r.config}),w&&jsx(ie,{code:c}),v&&jsx(De,{chart:c,config:r==null?void 0:r.config})]}),jsx(go,{chart:c,config:r==null?void 0:r.config,showControls:T})]})})}let m=pe(i,"code");return jsx(Suspense,{fallback:jsx(de,{}),children:jsx(fo,{className:u("overflow-x-auto border-border border-t",t),code:c,language:d,children:m&&jsxs(Fragment,{children:[jsx(Me,{code:c,language:d}),jsx(ie,{})]})})})},ut=memo(ho,(e,t)=>e.className===t.className&&re(e.node,t.node));ut.displayName="MarkdownCode";var ft=memo(Pe,(e,t)=>e.className===t.className&&re(e.node,t.node));ft.displayName="MarkdownImg";var gt=memo(({children:e,className:t,node:n,...o})=>{var i;let r=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");return r.length===1&&isValidElement(r[0])&&((i=r[0].props.node)==null?void 0:i.tagName)==="img"?jsx(Fragment,{children:e}):jsx("p",{className:t,...o,children:e})},(e,t)=>x(e,t));gt.displayName="MarkdownParagraph";var bt={ol:ue,li:Ve,ul:Ke,hr:Ze,strong:Ue,a:Ge,h1:_e,h2:Ye,h3:Qe,h4:et,h5:tt,h6:ot,table:nt,thead:rt,tbody:st,tr:at,th:it,td:lt,blockquote:dt,code:ut,img:ft,pre:({children:e})=>e,sup:ct,sub:mt,p:gt,section:pt};var yt=[],wt={allowDangerousHtml:true},se=new WeakMap,fe=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,s=t.remarkPlugins,r=t.remarkRehypeOptions;if(!(o||s||r)){let l="default";return this.keyCache.set(t,l),l}let i=l=>{if(!l||l.length===0)return "";let p="";for(let g=0;g<l.length;g+=1){let f=l[g];if(g>0&&(p+=","),Array.isArray(f)){let[b,w]=f;if(typeof b=="function"){let v=se.get(b);v||(v=b.name,se.set(b,v)),p+=v;}else p+=String(b);p+=":",p+=JSON.stringify(w);}else if(typeof f=="function"){let b=se.get(f);b||(b=f.name,se.set(f,b)),p+=b;}else p+=String(f);}return p},a=i(o),d=i(s),c=r?JSON.stringify(r):"",m=`${d}::${a}::${c}`;return this.keyCache.set(t,m),m}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let s=this.cache.keys().next().value;s&&this.cache.delete(s);}this.cache.set(o,n);}clear(){this.cache.clear();}},kt=new fe,ge=e=>{let t=Po(e),n=e.children||"";return No(t.runSync(t.parse(n),n),e)},Po=e=>{let t=kt.get(e);if(t)return t;let n=To(e);return kt.set(e,n),n},To=e=>{let t=e.rehypePlugins||yt,n=e.remarkPlugins||yt,o=e.remarkRehypeOptions?{...wt,...e.remarkRehypeOptions}:wt;return unified().use(xo).use(n).use(Co,o).use(t)},No=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Ro=/\[\^[^\]\s]{1,200}\](?!:)/,Io=/\[\^[^\]\s]{1,200}\]:/,Eo=/<\/(\w+)>/,Do=/<(\w+)[\s>]/,be=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]==="$"},Lo=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]==="$"},he=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},ye=e=>{let t=Ro.test(e),n=Io.test(e);if(t||n)return [e];let o=Lexer.lex(e,{gfm:true}),s=[],r=[];for(let i of o){let a=i.raw,d=s.length;if(r.length>0){if(s[d-1]+=a,i.type==="html"){let m=a.match(Eo);if(m){let l=m[1];r.at(-1)===l&&r.pop();}}continue}if(i.type==="html"&&i.block){let m=a.match(Do);if(m){let l=m[1];a.includes(`</${l}>`)||r.push(l);}}if(a.trim()==="$$"&&d>0){let m=s[d-1],l=be(m),p=he(m);if(l&&p%2===1){s[d-1]=m+a;continue}}if(d>0&&Lo(a)){let m=s[d-1],l=be(m),p=he(m),g=he(a);if(l&&p%2===1&&!be(a)&&g===1){s[d-1]=m+a;continue}}s.push(a);}return s};var Jo={raw:qo,katex:[we,{errorColor:"var(--color-muted-foreground)"}],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Wo={gfm:[Xo,{}],math:[ke,{singleDollarTextMath:false}],cjkFriendly:[$o,{}],cjkFriendlyGfmStrikethrough:[zo,{}]},Vo=Object.values(Jo),Ko=Object.values(Wo),Zo={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0},C=createContext(Zo),Ct=memo(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let o=useMemo(()=>typeof e=="string"&&t?Fo(e.trim()):e,[e,t]);return jsx(ge,{...n,children:o})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(s=>{var r,i;return ((r=e.components)==null?void 0:r[s])!==((i=t.components)==null?void 0:i[s])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Ct.displayName="Block";var Uo=["github-light","github-dark"],Go=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:n=true,components:o,rehypePlugins:s=Vo,remarkPlugins:r=Ko,className:i,shikiTheme:a=Uo,mermaid:d,controls:c=true,isAnimating:m=false,BlockComponent:l=Ct,parseMarkdownIntoBlocksFn:p=ye,...g})=>{let f=useId(),[b,w]=useTransition(),[v,T]=useState([]),M=useMemo(()=>p(typeof e=="string"?e:""),[e,p]);useEffect(()=>{t==="streaming"?w(()=>{T(M);}):T(M);},[M,t]);let P=t==="streaming"?v:M,j=useMemo(()=>P.map((I,E)=>`${f}-${E}`),[P.length,f]),A=useMemo(()=>({shikiTheme:a,controls:c,isAnimating:m,mode:t,mermaid:d}),[a,c,m,t,d]),H=useMemo(()=>({...bt,...o}),[o]);return useEffect(()=>{if(!(Array.isArray(s)&&s.some(S=>Array.isArray(S)?S[0]===we:S===we)))return;let E=false;if(Array.isArray(r)){let S=r.find(Z=>Array.isArray(Z)?Z[0]===ke:Z===ke);S&&Array.isArray(S)&&S[1]&&(E=S[1].singleDollarTextMath===true);}let D=typeof e=="string"?e:"",O=D.includes("$$"),y=E&&(/[^$]\$[^$]/.test(D)||/^\$[^$]/.test(D)||/[^$]\$$/.test(D));(O||y)&&import('katex/dist/katex.min.css');},[s,r,e]),t==="static"?jsx(C.Provider,{value:A,children:jsx("div",{className:u("space-y-4 whitespace-normal",i),children:jsx(ge,{components:H,rehypePlugins:s,remarkPlugins:r,...g,children:e})})}):jsx(C.Provider,{value:A,children:jsx("div",{className:u("space-y-4 whitespace-normal",i),children:P.map((I,E)=>jsx(l,{components:H,content:I,index:E,rehypePlugins:s,remarkPlugins:r,shouldParseIncompleteMarkdown:n,...g},j[E]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Go.displayName="Streamdown";var Nt=({children:e,className:t,minZoom:n=.5,maxZoom:o=3,zoomStep:s=.1,showControls:r=true,initialZoom:i=1,fullscreen:a=false})=>{let d=useRef(null),c=useRef(null),[m,l]=useState(i),[p,g]=useState({x:0,y:0}),[f,b]=useState(false),[w,v]=useState({x:0,y:0}),[T,M]=useState({x:0,y:0}),P=useCallback(y=>{l(N=>Math.max(n,Math.min(o,N+y)));},[n,o]),j=useCallback(()=>{P(s);},[P,s]),A=useCallback(()=>{P(-s);},[P,s]),H=useCallback(()=>{l(i),g({x:0,y:0});},[i]),I=useCallback(y=>{y.preventDefault();let N=y.deltaY>0?-s:s;P(N);},[P,s]),E=useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;b(true),v({x:y.clientX,y:y.clientY}),M(p);let N=y.currentTarget;N instanceof HTMLElement&&N.setPointerCapture(y.pointerId);},[p]),D=useCallback(y=>{if(!f)return;y.preventDefault();let N=y.clientX-w.x,S=y.clientY-w.y;g({x:T.x+N,y:T.y+S});},[f,w,T]),O=useCallback(y=>{b(false);let N=y.currentTarget;N instanceof HTMLElement&&N.releasePointerCapture(y.pointerId);},[]);return useEffect(()=>{let y=d.current;if(y)return y.addEventListener("wheel",I,{passive:false}),()=>{y.removeEventListener("wheel",I);}},[I]),useEffect(()=>{let y=c.current;if(y&&f)return document.body.style.userSelect="none",y.addEventListener("pointermove",D,{passive:false}),y.addEventListener("pointerup",O),y.addEventListener("pointercancel",O),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",D),y.removeEventListener("pointerup",O),y.removeEventListener("pointercancel",O);}},[f,D,O]),jsxs("div",{className:u("relative",a?"h-full w-full":"w-full",t),ref:d,style:{cursor:f?"grabbing":"grab"},children:[r&&jsxs("div",{className:u("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",a?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:m>=o,onClick:j,title:"Zoom in",type:"button",children:jsx(ZoomInIcon,{size:16})}),jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:m<=n,onClick:A,title:"Zoom out",type:"button",children:jsx(ZoomOutIcon,{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:H,title:"Reset zoom and pan",type:"button",children:jsx(RotateCcwIcon,{size:16})})]}),jsx("div",{className:u("origin-center transition-transform duration-150 ease-out",a&&"flex w-full items-center justify-center"),onPointerDown:E,ref:c,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${m})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Ee=({chart:e,className:t,config:n,fullscreen:o=false,showControls:s=true})=>{let[r,i]=useState(null),[a,d]=useState(true),[c,m]=useState(""),[l,p]=useState(""),[g,f]=useState(0),{mermaid:b}=useContext(C),w=b==null?void 0:b.errorComponent;if(useEffect(()=>{(async()=>{try{i(null),d(!0);let M=await _(n),P=e.split("").reduce((H,I)=>(H<<5)-H+I.charCodeAt(0)|0,0),j=`mermaid-${Math.abs(P)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:A}=await M.render(j,e);m(A),p(A);}catch(M){if(!(l||c)){let P=M instanceof Error?M.message:"Failed to render Mermaid chart";i(P);}}finally{d(false);}})();},[e,n,g]),a&&!c&&!l)return jsx("div",{className:u("my-4 flex justify-center p-4",t),children:jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!c&&!l){let T=()=>f(M=>M+1);return w?jsx(w,{chart:e,error:r,retry:T}):jsxs("div",{className:u("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),jsxs("details",{className:"mt-2",children:[jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let v=c||l;return jsx(Nt,{className:u(o?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:o,maxZoom:3,minZoom:.5,showControls:s,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:u("flex justify-center",o&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:v},role:"img"})})};export{u as a,Dt as b,Ee as c,ye as d,Jo as e,Wo as f,C as g,Ct as h,Go as i};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var chunkES5ZJKGK_cjs=require('./chunk-ES5ZJKGK.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),shiki=require('shiki'),javascript=require('shiki/engine/javascript');var v=chunkES5ZJKGK_cjs.a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),b=react.memo(({children:e,result:t,language:o,className:r,...s})=>{let n=react.useMemo(()=>({backgroundColor:t.bg,color:t.fg}),[t.bg,t.fg]);return jsxRuntime.jsx("pre",{className:chunkES5ZJKGK_cjs.a(r,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-language":o,"data-streamdown":"code-block-body",style:n,...s,children:jsxRuntime.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:t.tokens.map((l,d)=>jsxRuntime.jsx("span",{className:v,children:l.map((a,i)=>jsxRuntime.jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:a.color,backgroundColor:a.bgColor,...a.htmlStyle},...a.htmlAttrs,children:a.content},i))},d))})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className);var y=({className:e,language:t,style:o,...r})=>jsxRuntime.jsx("div",{className:chunkES5ZJKGK_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",e),"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r});var L=({language:e,children:t})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":e,"data-streamdown":"code-block-header",children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:e}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:t})]});var $=javascript.createJavaScriptRegexEngine({forgiving:true}),m=new Map,p=new Map,g=new Map,E=(e,t)=>`${e}-${t[0]}-${t[1]}`,A=(e,t,o)=>{let r=e.slice(0,100),s=e.length>100?e.slice(-100):"";return `${t}:${o[0]}:${o[1]}:${e.length}:${r}:${s}`},T=e=>Object.hasOwn(shiki.bundledLanguages,e),K=(e,t)=>{let o=T(e)?e:"text",r=E(o,t);if(m.has(r))return m.get(r);let s=shiki.createHighlighter({themes:t,langs:[o],engine:$});return m.set(r,s),s},h=(e,t,o,r)=>{let s=T(t)?t:"text",n=A(e,s,o);return p.has(n)?p.get(n):(r&&(g.has(n)||g.set(n,new Set),g.get(n).add(r)),K(s,o).then(l=>{let d=l.codeToTokens(e,{lang:s,themes:{light:o[0],dark:o[1]}});p.set(n,d);let a=g.get(n);if(a){for(let i of a)i(d);g.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),g.delete(n);}),null)};var le=({code:e,language:t,className:o,children:r,...s})=>{let{shikiTheme:n}=react.useContext(chunkES5ZJKGK_cjs.g),l=react.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:e.split(`
|
|
3
|
+
`).map(i=>[{content:i,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[e]),[d,a]=react.useState(l);return react.useEffect(()=>{let i=h(e,t,n);if(i){a(i);return}h(e,t,n,x=>{a(x);});},[e,t,n]),jsxRuntime.jsx(chunkES5ZJKGK_cjs.b.Provider,{value:{code:e},children:jsxRuntime.jsxs(y,{language:t,children:[jsxRuntime.jsx(L,{language:t,children:r}),jsxRuntime.jsx(b,{className:o,language:t,result:d,...s})]})})};exports.CodeBlock=le;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import {a,g as g$1,b as b$1}from'./chunk-OGVTOU66.js';import {memo,useMemo,useContext,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';import {createHighlighter,bundledLanguages}from'shiki';import {createJavaScriptRegexEngine}from'shiki/engine/javascript';var v=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),b=memo(({children:e,result:t,language:o,className:r,...s})=>{let n=useMemo(()=>({backgroundColor:t.bg,color:t.fg}),[t.bg,t.fg]);return jsx("pre",{className:a(r,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-language":o,"data-streamdown":"code-block-body",style:n,...s,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:t.tokens.map((l,d)=>jsx("span",{className:v,children:l.map((a,i)=>jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:a.color,backgroundColor:a.bgColor,...a.htmlStyle},...a.htmlAttrs,children:a.content},i))},d))})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className);var y=({className:e,language:t,style:o,...r})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",e),"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r});var L=({language:e,children:t})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":e,"data-streamdown":"code-block-header",children:[jsx("span",{className:"ml-1 font-mono lowercase",children:e}),jsx("div",{className:"flex items-center gap-2",children:t})]});var $=createJavaScriptRegexEngine({forgiving:true}),m=new Map,p=new Map,g=new Map,E=(e,t)=>`${e}-${t[0]}-${t[1]}`,A=(e,t,o)=>{let r=e.slice(0,100),s=e.length>100?e.slice(-100):"";return `${t}:${o[0]}:${o[1]}:${e.length}:${r}:${s}`},T=e=>Object.hasOwn(bundledLanguages,e),K=(e,t)=>{let o=T(e)?e:"text",r=E(o,t);if(m.has(r))return m.get(r);let s=createHighlighter({themes:t,langs:[o],engine:$});return m.set(r,s),s},h=(e,t,o,r)=>{let s=T(t)?t:"text",n=A(e,s,o);return p.has(n)?p.get(n):(r&&(g.has(n)||g.set(n,new Set),g.get(n).add(r)),K(s,o).then(l=>{let d=l.codeToTokens(e,{lang:s,themes:{light:o[0],dark:o[1]}});p.set(n,d);let a=g.get(n);if(a){for(let i of a)i(d);g.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),g.delete(n);}),null)};var le=({code:e,language:t,className:o,children:r,...s})=>{let{shikiTheme:n}=useContext(g$1),l=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:e.split(`
|
|
3
|
+
`).map(i=>[{content:i,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[e]),[d,a]=useState(l);return useEffect(()=>{let i=h(e,t,n);if(i){a(i);return}h(e,t,n,x=>{a(x);});},[e,t,n]),jsx(b$1.Provider,{value:{code:e},children:jsxs(y,{language:t,children:[jsx(L,{language:t,children:r}),jsx(b,{className:o,language:t,result:d,...s})]})})};export{le as CodeBlock};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var chunkES5ZJKGK_cjs=require('./chunk-ES5ZJKGK.cjs');Object.defineProperty(exports,"Block",{enumerable:true,get:function(){return chunkES5ZJKGK_cjs.h}});Object.defineProperty(exports,"Streamdown",{enumerable:true,get:function(){return chunkES5ZJKGK_cjs.i}});Object.defineProperty(exports,"StreamdownContext",{enumerable:true,get:function(){return chunkES5ZJKGK_cjs.g}});Object.defineProperty(exports,"defaultRehypePlugins",{enumerable:true,get:function(){return chunkES5ZJKGK_cjs.e}});Object.defineProperty(exports,"defaultRemarkPlugins",{enumerable:true,get:function(){return chunkES5ZJKGK_cjs.f}});Object.defineProperty(exports,"parseMarkdownIntoBlocks",{enumerable:true,get:function(){return chunkES5ZJKGK_cjs.d}});
|
package/dist/index.d.cts
CHANGED
|
@@ -24,8 +24,6 @@ type Options = {
|
|
|
24
24
|
|
|
25
25
|
declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
26
26
|
|
|
27
|
-
declare const parseIncompleteMarkdown: (text: string) => string;
|
|
28
|
-
|
|
29
27
|
type ControlsConfig = boolean | {
|
|
30
28
|
table?: boolean;
|
|
31
29
|
code?: boolean;
|
|
@@ -74,4 +72,4 @@ type BlockProps = Options & {
|
|
|
74
72
|
declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
75
73
|
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, BlockComponent, parseMarkdownIntoBlocksFn, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
76
74
|
|
|
77
|
-
export { Block, type ControlsConfig, type MermaidErrorComponentProps, type MermaidOptions, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins,
|
|
75
|
+
export { Block, type ControlsConfig, type MermaidErrorComponentProps, type MermaidOptions, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins, parseMarkdownIntoBlocks };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,8 +24,6 @@ type Options = {
|
|
|
24
24
|
|
|
25
25
|
declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
26
26
|
|
|
27
|
-
declare const parseIncompleteMarkdown: (text: string) => string;
|
|
28
|
-
|
|
29
27
|
type ControlsConfig = boolean | {
|
|
30
28
|
table?: boolean;
|
|
31
29
|
code?: boolean;
|
|
@@ -74,4 +72,4 @@ type BlockProps = Options & {
|
|
|
74
72
|
declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
75
73
|
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, BlockComponent, parseMarkdownIntoBlocksFn, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
76
74
|
|
|
77
|
-
export { Block, type ControlsConfig, type MermaidErrorComponentProps, type MermaidOptions, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins,
|
|
75
|
+
export { Block, type ControlsConfig, type MermaidErrorComponentProps, type MermaidOptions, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins, parseMarkdownIntoBlocks };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
export{h as Block,i as Streamdown,g as StreamdownContext,e as defaultRehypePlugins,f as defaultRemarkPlugins,d as parseMarkdownIntoBlocks}from'./chunk-OGVTOU66.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "streamdown",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -64,10 +64,12 @@
|
|
|
64
64
|
"shiki": "^3.12.2",
|
|
65
65
|
"tailwind-merge": "^3.3.1",
|
|
66
66
|
"unified": "^11.0.5",
|
|
67
|
-
"unist-util-visit": "^5.0.0"
|
|
67
|
+
"unist-util-visit": "^5.0.0",
|
|
68
|
+
"remend": "1.0.1"
|
|
68
69
|
},
|
|
69
70
|
"scripts": {
|
|
70
71
|
"build": "tsup",
|
|
72
|
+
"postbuild": "node scripts/postbuild.js",
|
|
71
73
|
"test": "vitest run",
|
|
72
74
|
"test:ui": "vitest --ui run",
|
|
73
75
|
"test:coverage": "vitest --coverage run",
|
package/dist/chunk-7N2FFGCA.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';var react=require('react'),rehypeHarden=require('rehype-harden'),Pe=require('rehype-katex'),wn=require('rehype-raw'),kn=require('remark-cjk-friendly'),vn=require('remark-cjk-friendly-gfm-strikethrough'),Cn=require('remark-gfm'),Te=require('remark-math'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),hastUtilToJsxRuntime=require('hast-util-to-jsx-runtime'),Io=require('remark-parse'),Bo=require('remark-rehype'),unified=require('unified'),marked=require('marked');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Pe__default=/*#__PURE__*/_interopDefault(Pe);var wn__default=/*#__PURE__*/_interopDefault(wn);var kn__default=/*#__PURE__*/_interopDefault(kn);var vn__default=/*#__PURE__*/_interopDefault(vn);var Cn__default=/*#__PURE__*/_interopDefault(Cn);var Te__default=/*#__PURE__*/_interopDefault(Te);var Io__default=/*#__PURE__*/_interopDefault(Io);var Bo__default=/*#__PURE__*/_interopDefault(Bo);var u=(...e)=>tailwindMerge.twMerge(clsx.clsx(e)),I=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s);};var Ht=react.createContext({code:""}),G=()=>react.useContext(Ht);var de=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:s,code:r,...i})=>{let[a,l]=react.useState(false),d=react.useRef(0),{code:m}=G(),{isAnimating:c}=react.useContext(M),p=r!=null?r:m,g=async()=>{var h;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{a||(await navigator.clipboard.writeText(p),l(!0),e==null||e(),d.current=window.setTimeout(()=>l(!1),o));}catch(w){t==null||t(w);}};react.useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let f=a?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-copy-button",disabled:c,onClick:g,title:"Copy Code",type:"button",...i,children:n!=null?n:jsxRuntime.jsx(f,{size:14})})};var xe={"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"},Ie=({onDownload:e,onError:t,language:o,children:n,className:s,code:r,...i})=>{let{code:a}=G(),{isAnimating:l}=react.useContext(M),d=r!=null?r:a,c=`file.${o&&o in xe?xe[o]:"txt"}`,p="text/plain",g=()=>{try{I(c,d,p),e==null||e();}catch(f){t==null||t(f);}};return jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-download-button",disabled:l,onClick:g,title:"Download file",type:"button",...i,children:n!=null?n:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})})};var pe=()=>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(lucideReact.Loader2Icon,{className:"size-4 animate-spin"})})]});var Gt=/\.[^/.]+$/,Be=({node:e,className:t,src:o,alt:n,...s})=>{let r=async()=>{if(o)try{let a=await(await fetch(o)).blob(),d=new URL(o,window.location.origin).pathname.split("/").pop()||"",m=d.split(".").pop(),c=d.includes(".")&&m!==void 0&&m.length<=4,p="";if(c)p=d;else {let g=a.type,f="png";g.includes("jpeg")||g.includes("jpg")?f="jpg":g.includes("png")?f="png":g.includes("svg")?f="svg":g.includes("gif")?f="gif":g.includes("webp")&&(f="webp"),p=`${(n||d||"image").replace(Gt,"")}.${f}`;}I(p,a,a.type);}catch(i){console.error("Failed to download image:",i);}};return o?jsxRuntime.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntime.jsx("img",{alt:n,className:u("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...s}),jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntime.jsx("button",{className:u("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:r,title:"Download image",type:"button",children:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})})]}):null};var Q=async e=>{let o={...{startOnLoad:false,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:true},...e},s=(await import('mermaid')).default;return s.initialize(o),s},Ae=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((s,r)=>{let i="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),a=new Image;a.crossOrigin="anonymous",a.onload=()=>{let l=document.createElement("canvas"),d=a.width*o,m=a.height*o;l.width=d,l.height=m;let c=l.getContext("2d");if(!c){r(new Error("Failed to create 2D canvas context for PNG export"));return}c.drawImage(a,0,0,d,m),l.toBlob(p=>{if(!p){r(new Error("Failed to create PNG blob"));return}s(p);},"image/png");},a.onerror=()=>r(new Error("Failed to load SVG image")),a.src=i;})};var Re=({chart:e,children:t,className:o,onDownload:n,config:s,onError:r})=>{let[i,a]=react.useState(false),l=react.useRef(null),{isAnimating:d}=react.useContext(M),m=async c=>{try{if(c==="mmd"){I("diagram.mmd",e,"text/plain"),a(!1),n==null||n(c);return}let p=await Q(s),g=e.split("").reduce((w,v)=>(w<<5)-w+v.charCodeAt(0)|0,0),f=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:h}=await p.render(f,e);if(!h){r==null||r(new Error("SVG not found. Please wait for the diagram to render."));return}if(c==="svg"){I("diagram.svg",h,"image/svg+xml"),a(!1),n==null||n(c);return}if(c==="png"){let w=await Ae(h);I("diagram.png",w,"image/png"),n==null||n(c),a(!1);return}}catch(p){r==null||r(p);}};return react.useEffect(()=>{let c=p=>{l.current&&!l.current.contains(p.target)&&a(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:l,children:[jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d,onClick:()=>a(!i),title:"Download diagram",type:"button",children:t!=null?t:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})}),i&&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("svg"),type:"button",title:"Download diagram as SVG",children:"SVG"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("png"),type:"button",title:"Download diagram as PNG",children:"PNG"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("mmd"),type:"button",title:"Download diagram as MMD",children:"MMD"})]})]})};var X=0,lo=()=>{X+=1,X===1&&(document.body.style.overflow="hidden");},co=()=>{X=Math.max(0,X-1),X===0&&(document.body.style.overflow="");},je=({chart:e,config:t,onFullscreen:o,onExit:n,className:s,...r})=>{let[i,a]=react.useState(false),{isAnimating:l,controls:d}=react.useContext(M),m=(()=>{if(typeof d=="boolean")return d;let p=d.mermaid;return p===false?false:p===true||p===void 0?true:p.panZoom!==false})(),c=()=>{a(!i);};return react.useEffect(()=>{if(i){lo();let p=g=>{g.key==="Escape"&&a(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),co();}}},[i]),react.useEffect(()=>{i?o==null||o():n&&n();},[i,o,n]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),disabled:l,onClick:c,title:"View fullscreen",type:"button",...r,children:jsxRuntime.jsx(lucideReact.Maximize2Icon,{size:14})}),i&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:c,onKeyDown:p=>{p.key==="Escape"&&c();},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:c,title:"Exit fullscreen",type:"button",children:jsxRuntime.jsx(lucideReact.XIcon,{size:20})}),jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:jsxRuntime.jsx(De,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:m})})]})]})};var ee=e=>{var r,i;let t=[],o=[],n=e.querySelectorAll("thead th");for(let a of n)t.push(((r=a.textContent)==null?void 0:r.trim())||"");let s=e.querySelectorAll("tbody tr");for(let a of s){let l=[],d=a.querySelectorAll("td");for(let m of d)l.push(((i=m.textContent)==null?void 0:i.trim())||"");o.push(l);}return {headers:t,rows:o}},te=e=>{let{headers:t,rows:o}=e,n=a=>{let l=false,d=false;for(let m=0;m<a.length;m+=1){let c=a[m];if(c==='"'){l=true,d=true;break}(c===","||c===`
|
|
2
|
-
`)&&(l=true);}return l?d?`"${a.replace(/"/g,'""')}"`:`"${a}"`:a},s=t.length>0?o.length+1:o.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(n).join(","),i+=1);for(let a of o)r[i]=a.map(n).join(","),i+=1;return r.join(`
|
|
3
|
-
`)},Oe=e=>{let{headers:t,rows:o}=e,n=a=>{let l=false;for(let m=0;m<a.length;m+=1){let c=a[m];if(c===" "||c===`
|
|
4
|
-
`||c==="\r"){l=true;break}}if(!l)return a;let d=[];for(let m=0;m<a.length;m+=1){let c=a[m];c===" "?d.push("\\t"):c===`
|
|
5
|
-
`?d.push("\\n"):c==="\r"?d.push("\\r"):d.push(c);}return d.join("")},s=t.length>0?o.length+1:o.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(n).join(" "),i+=1);for(let a of o)r[i]=a.map(n).join(" "),i+=1;return r.join(`
|
|
6
|
-
`)},ue=e=>{let t=false;for(let n=0;n<e.length;n+=1){let s=e[n];if(s==="\\"||s==="|"){t=true;break}}if(!t)return e;let o=[];for(let n=0;n<e.length;n+=1){let s=e[n];s==="\\"?o.push("\\\\"):s==="|"?o.push("\\|"):o.push(s);}return o.join("")},He=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),s=0,r=t.map(a=>ue(a));n[s]=`| ${r.join(" | ")} |`,s+=1;let i=new Array(t.length);for(let a=0;a<t.length;a+=1)i[a]="---";n[s]=`| ${i.join(" | ")} |`,s+=1;for(let a of o)if(a.length<t.length){let l=new Array(t.length);for(let d=0;d<t.length;d+=1)l[d]=d<a.length?ue(a[d]):"";n[s]=`| ${l.join(" | ")} |`,s+=1;}else {let l=a.map(d=>ue(d));n[s]=`| ${l.join(" | ")} |`,s+=1;}return n.join(`
|
|
7
|
-
`)};var Ue=({children:e,className:t,onCopy:o,onError:n,timeout:s=2e3})=>{let[r,i]=react.useState(false),[a,l]=react.useState(false),d=react.useRef(null),m=react.useRef(0),{isAnimating:c}=react.useContext(M),p=async f=>{var h,w;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.write)){n==null||n(new Error("Clipboard API not available"));return}try{let v=(w=d.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),N=v==null?void 0:v.querySelector("table");if(!N){n==null||n(new Error("Table not found"));return}let P=ee(N),T=f==="csv"?te(P):Oe(P),D=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([N.outerHTML],{type:"text/html"})});await navigator.clipboard.write([D]),l(!0),i(!1),o==null||o(f),m.current=window.setTimeout(()=>l(!1),s);}catch(v){n==null||n(v);}};react.useEffect(()=>{let f=h=>{d.current&&!d.current.contains(h.target)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(m.current);}},[]);let g=a?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsxs("div",{className:"relative",ref:d,children:[jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:()=>i(!r),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(g,{size:14})}),r&&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:()=>p("csv"),type:"button",title:"Copy table as CSV",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("tsv"),type:"button",title:"Copy table as TSV",children:"TSV"})]})]})};var Fe=({children:e,className:t,onDownload:o,onError:n})=>{let[s,r]=react.useState(false),i=react.useRef(null),{isAnimating:a}=react.useContext(M),l=d=>{var m;try{let c=(m=i.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),p=c==null?void 0:c.querySelector("table");if(!p){n==null||n(new Error("Table not found"));return}let g=ee(p),f=d==="csv"?te(g):He(g);I(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),r(!1),o==null||o(d);}catch(c){n==null||n(c);}};return react.useEffect(()=>{let d=m=>{i.current&&!i.current.contains(m.target)&&r(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:i,children:[jsxRuntime.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:a,onClick:()=>r(!s),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(lucideReact.DownloadIcon,{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:()=>l("csv"),type:"button",title:"Download table as CSV",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",title:"Download table as Markdown",children:"Markdown"})]})]})};var Je=({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(Ue,{}),jsxRuntime.jsx(Fe,{})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:u("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});var vo=react.lazy(()=>import('./code-block-LTULQHW3.cjs').then(e=>({default:e.CodeBlock}))),Co=react.lazy(()=>import('./mermaid-NTG464FS.cjs').then(e=>({default:e.Mermaid}))),Mo=/language-([^\s]+)/;function ae(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,s=e.position.end,r=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(s==null?void 0:s.line)===(r==null?void 0:r.line)&&(s==null?void 0:s.column)===(r==null?void 0:r.column)}function C(e,t){return e.className===t.className&&ae(e.node,t.node)}var ge=(e,t)=>typeof e=="boolean"?e:e[t]!==false,se=(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:u("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>C(e,t));he.displayName="MarkdownOl";var Ge=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("li",{className:u("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ae(e.node,t.node));Ge.displayName="MarkdownLi";var Ye=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("ul",{className:u("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>C(e,t));Ye.displayName="MarkdownUl";var Qe=react.memo(({className:e,node:t,...o})=>jsxRuntime.jsx("hr",{className:u("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>C(e,t));Qe.displayName="MarkdownHr";var et=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("span",{className:u("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>C(e,t));et.displayName="MarkdownStrong";var tt=react.memo(({children:e,className:t,href:o,node:n,...s})=>{let r=o==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:u("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...s,children:e})},(e,t)=>C(e,t)&&e.href===t.href);tt.displayName="MarkdownA";var ot=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h1",{className:u("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>C(e,t));ot.displayName="MarkdownH1";var nt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h2",{className:u("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>C(e,t));nt.displayName="MarkdownH2";var rt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h3",{className:u("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>C(e,t));rt.displayName="MarkdownH3";var st=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h4",{className:u("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>C(e,t));st.displayName="MarkdownH4";var at=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h5",{className:u("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>C(e,t));at.displayName="MarkdownH5";var it=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h6",{className:u("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>C(e,t));it.displayName="MarkdownH6";var lt=react.memo(({children:e,className:t,node:o,...n})=>{let{controls:s}=react.useContext(M),r=ge(s,"table");return jsxRuntime.jsx(Je,{className:t,"data-streamdown":"table-wrapper",showControls:r,...n,children:e})},(e,t)=>C(e,t));lt.displayName="MarkdownTable";var ct=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("thead",{className:u("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>C(e,t));ct.displayName="MarkdownThead";var dt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("tbody",{className:u("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>C(e,t));dt.displayName="MarkdownTbody";var mt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("tr",{className:u("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>C(e,t));mt.displayName="MarkdownTr";var pt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("th",{className:u("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>C(e,t));pt.displayName="MarkdownTh";var ut=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("td",{className:u("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>C(e,t));ut.displayName="MarkdownTd";var ft=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("blockquote",{className:u("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>C(e,t));ft.displayName="MarkdownBlockquote";var gt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("sup",{className:u("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>C(e,t));gt.displayName="MarkdownSup";var ht=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("sub",{className:u("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>C(e,t));ht.displayName="MarkdownSub";var bt=react.memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let r=l=>{var p,g;if(!react.isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],m=false,c=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(m=true);else if(react.isValidElement(f))if(((p=f.props)==null?void 0:p["data-footnote-backref"])!==void 0)c=true;else {let h=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let w of h){if(typeof w=="string"&&w.trim()!==""){m=true;break}if(react.isValidElement(w)&&((g=w.props)==null?void 0:g["data-footnote-backref"])===void 0){m=true;break}}}}return c&&!m},i=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===he){let m=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(c=>!r(c));return m.length===0?null:{...l,props:{...l.props,children:m}}}return l}):e;return (Array.isArray(i)?i.some(l=>l!==null):i!==null)?jsxRuntime.jsx("section",{className:t,...n,children:i}):null}return jsxRuntime.jsx("section",{className:t,...n,children:e})},(e,t)=>C(e,t));bt.displayName="MarkdownSection";var Po=({node:e,className:t,children:o,...n})=>{var c,p,g;let s=((c=e==null?void 0:e.position)==null?void 0:c.start.line)===((p=e==null?void 0:e.position)==null?void 0:p.end.line),{mermaid:r,controls:i}=react.useContext(M);if(s)return jsxRuntime.jsx("code",{className:u("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let a=t==null?void 0:t.match(Mo),l=(g=a==null?void 0:a.at(1))!=null?g:"",d="";if(react.isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?d=o.props.children:typeof o=="string"&&(d=o),l==="mermaid"){let f=ge(i,"mermaid"),h=se(i,"download"),w=se(i,"copy"),v=se(i,"fullscreen"),N=se(i,"panZoom");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(pe,{}),children:jsxRuntime.jsxs("div",{className:u("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[f&&(h||w||v)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h&&jsxRuntime.jsx(Re,{chart:d,config:r==null?void 0:r.config}),w&&jsxRuntime.jsx(de,{code:d}),v&&jsxRuntime.jsx(je,{chart:d,config:r==null?void 0:r.config})]}),jsxRuntime.jsx(Co,{chart:d,config:r==null?void 0:r.config,showControls:N})]})})}let m=ge(i,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(pe,{}),children:jsxRuntime.jsx(vo,{className:u("overflow-x-auto border-border border-t",t),code:d,language:l,children:m&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ie,{code:d,language:l}),jsxRuntime.jsx(de,{})]})})})},yt=react.memo(Po,(e,t)=>e.className===t.className&&ae(e.node,t.node));yt.displayName="MarkdownCode";var wt=react.memo(Be,(e,t)=>e.className===t.className&&ae(e.node,t.node));wt.displayName="MarkdownImg";var kt=react.memo(({children:e,className:t,node:o,...n})=>{var i;let r=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");return r.length===1&&react.isValidElement(r[0])&&((i=r[0].props.node)==null?void 0:i.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):jsxRuntime.jsx("p",{className:t,...n,children:e})},(e,t)=>C(e,t));kt.displayName="MarkdownParagraph";var vt={ol:he,li:Ge,ul:Ye,hr:Qe,strong:et,a:tt,h1:ot,h2:nt,h3:rt,h4:st,h5:at,h6:it,table:lt,thead:ct,tbody:dt,tr:mt,th:pt,td:ut,blockquote:ft,code:yt,img:wt,pre:({children:e})=>e,sup:gt,sub:ht,p:kt,section:bt};var Mt=[],Pt={allowDangerousHtml:true},ie=new WeakMap,be=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,s=t.remarkPlugins,r=t.remarkRehypeOptions;if(!(n||s||r)){let c="default";return this.keyCache.set(t,c),c}let i=c=>{if(!c||c.length===0)return "";let p="";for(let g=0;g<c.length;g+=1){let f=c[g];if(g>0&&(p+=","),Array.isArray(f)){let[h,w]=f;if(typeof h=="function"){let v=ie.get(h);v||(v=h.name,ie.set(h,v)),p+=v;}else p+=String(h);p+=":",p+=JSON.stringify(w);}else if(typeof f=="function"){let h=ie.get(f);h||(h=f.name,ie.set(f,h)),p+=h;}else p+=String(f);}return p},a=i(n),l=i(s),d=r?JSON.stringify(r):"",m=`${l}::${a}::${d}`;return this.keyCache.set(t,m),m}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let s=this.cache.keys().next().value;s&&this.cache.delete(s);}this.cache.set(n,o);}clear(){this.cache.clear();}},Tt=new be,ye=e=>{let t=Lo(e),o=e.children||"";return Eo(t.runSync(t.parse(o),o),e)},Lo=e=>{let t=Tt.get(e);if(t)return t;let o=Ro(e);return Tt.set(e,o),o},Ro=e=>{let t=e.rehypePlugins||Mt,o=e.remarkPlugins||Mt,n=e.remarkRehypeOptions?{...Pt,...e.remarkRehypeOptions}:Pt;return unified.unified().use(Io__default.default).use(o).use(Bo__default.default,n).use(t)},Eo=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Do=/\[\^[^\]\s]{1,200}\](?!:)/,jo=/\[\^[^\]\s]{1,200}\]:/,Oo=/<\/(\w+)>/,Ho=/<(\w+)[\s>]/,we=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
8
|
-
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},qo=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
|
-
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},ke=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=Do.test(e),o=jo.test(e);if(t||o)return [e];let n=marked.Lexer.lex(e,{gfm:true}),s=[],r=[];for(let i of n){let a=i.raw,l=s.length;if(r.length>0){if(s[l-1]+=a,i.type==="html"){let m=a.match(Oo);if(m){let c=m[1];r.at(-1)===c&&r.pop();}}continue}if(i.type==="html"&&i.block){let m=a.match(Ho);if(m){let c=m[1];a.includes(`</${c}>`)||r.push(c);}}if(a.trim()==="$$"&&l>0){let m=s[l-1],c=we(m),p=ke(m);if(c&&p%2===1){s[l-1]=m+a;continue}}if(l>0&&qo(a)){let m=s[l-1],c=we(m),p=ke(m),g=ke(a);if(c&&p%2===1&&!we(a)&&g===1){s[l-1]=m+a;continue}}s.push(a);}return s};var zo=/(\*\*)([^*]*?)$/,Wo=/(__)([^_]*?)$/,Uo=/(\*\*\*)([^*]*?)$/,_o=/(\*)([^*]*?)$/,Fo=/(_)([^_]*?)$/,Xo=/(`)([^`]*?)$/,Jo=/(~~)([^~]*?)$/,q=/^[\s_~*`]*$/,Nt=/^[\s]*[-*+][\s]+$/,Vo=/[\p{L}\p{N}_]/u,Ko=/^```[^`\n]*```?$/,Zo=/^\*{4,}$/,R=e=>{if(!e)return false;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?true:Vo.test(e)},le=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
|
|
10
|
-
`)};var Go=(e,t)=>{let o=1;for(let n=t-1;n>=0;n-=1)if(e[n]==="]")o+=1;else if(e[n]==="["&&(o-=1,o===0))return n;return -1},Yo=(e,t)=>{let o=1;for(let n=t+1;n<e.length;n+=1)if(e[n]==="[")o+=1;else if(e[n]==="]"&&(o-=1,o===0))return n;return -1},Ce=(e,t)=>{let o=false,n=false;for(let s=0;s<t;s+=1){if(e.substring(s,s+3)==="```"){n=!n,s+=2;continue}!n&&e[s]==="`"&&(o=!o);}return o||n},Qo=e=>{let t=e.lastIndexOf("](");if(t!==-1&&!Ce(e,t)&&!e.substring(t+2).includes(")")){let n=Go(e,t);if(n!==-1&&!Ce(e,n)){let s=n>0&&e[n-1]==="!",r=s?n-1:n,i=e.substring(0,r),a=e.substring(n+1,t);return s?i:`${i}[${a}](streamdown:incomplete-link)`}}for(let o=e.length-1;o>=0;o-=1)if(e[o]==="["&&!Ce(e,o)){let n=o>0&&e[o-1]==="!",s=n?o-1:o;if(!e.substring(o+1).includes("]")){let a=e.substring(0,s);return n?a:`${e}](streamdown:incomplete-link)`}if(Yo(e,o)===-1){let a=e.substring(0,s);return n?a:`${e}](streamdown:incomplete-link)`}}return e},en=e=>{if(le(e))return e;let t=e.match(zo);if(t){let o=t[2];if(!o||q.test(o))return e;let n=e.lastIndexOf(t[1]),r=e.substring(0,n).lastIndexOf(`
|
|
11
|
-
`),i=r===-1?0:r+1,a=e.substring(i,n);if(Nt.test(a)&&o.includes(`
|
|
12
|
-
`))return e;if((e.match(/\*\*/g)||[]).length%2===1)return `${e}**`}return e},tn=e=>{let t=e.match(Wo);if(t){let o=t[2];if(!o||q.test(o))return e;let n=e.lastIndexOf(t[1]),r=e.substring(0,n).lastIndexOf(`
|
|
13
|
-
`),i=r===-1?0:r+1,a=e.substring(i,n);if(Nt.test(a)&&o.includes(`
|
|
14
|
-
`))return e;if((e.match(/__/g)||[]).length%2===1)return `${e}__`}return e},on=e=>{let t=0,o=e.length;for(let n=0;n<o;n+=1){if(e[n]!=="*")continue;let s=n>0?e[n-1]:"",r=n<o-1?e[n+1]:"";if(s==="\\"||s==="*"||r==="*"||s&&r&&R(s)&&R(r))continue;let i=0;for(let l=n-1;l>=0;l-=1)if(e[l]===`
|
|
15
|
-
`){i=l+1;break}let a=true;for(let l=i;l<n;l+=1)if(e[l]!==" "&&e[l]!==" "){a=false;break}a&&(r===" "||r===" ")||(t+=1);}return t},nn=e=>{if(le(e))return e;if(e.match(_o)){let o=-1;for(let r=0;r<e.length;r+=1)if(e[r]==="*"&&e[r-1]!=="*"&&e[r+1]!=="*"&&e[r-1]!=="\\"){let i=r>0?e[r-1]:"",a=r<e.length-1?e[r+1]:"";if(i&&a&&R(i)&&R(a))continue;o=r;break}if(o===-1)return e;let n=e.substring(o+1);if(!n||q.test(n))return e;if(on(e)%2===1)return `${e}*`}return e},xt=(e,t)=>{let o=false,n=false;for(let s=0;s<e.length&&s<t;s+=1){if(e[s]==="\\"&&e[s+1]==="$"){s+=1;continue}e[s]==="$"&&(e[s+1]==="$"?(n=!n,s+=1,o=false):n||(o=!o));}return o||n},rn=e=>{let t=e.includes("$"),o=0,n=e.length;for(let s=0;s<n;s+=1){if(e[s]!=="_")continue;let r=s>0?e[s-1]:"",i=s<n-1?e[s+1]:"";r!=="\\"&&(t&&xt(e,s)||r==="_"||i==="_"||r&&i&&R(r)&&R(i)||(o+=1));}return o},sn=e=>{if(le(e))return e;if(e.match(Fo)){let o=-1;for(let r=0;r<e.length;r+=1)if(e[r]==="_"&&e[r-1]!=="_"&&e[r+1]!=="_"&&e[r-1]!=="\\"&&!xt(e,r)){let i=r>0?e[r-1]:"",a=r<e.length-1?e[r+1]:"";if(i&&a&&R(i)&&R(a))continue;o=r;break}if(o===-1)return e;let n=e.substring(o+1);if(!n||q.test(n))return e;if(rn(e)%2===1){let r=e.length;for(;r>0&&e[r-1]===`
|
|
16
|
-
`;)r-=1;if(r<e.length){let i=e.slice(0,r),a=e.slice(r);return `${i}_${a}`}return `${e}_`}}return e},an=(e,t)=>{let o=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",s=t>1&&e.substring(t-2,t+1)==="```";return o||n||s},ln=e=>{let t=0;for(let o=0;o<e.length;o+=1)e[o]==="`"&&!an(e,o)&&(t+=1);return t},cn=e=>{if(e.match(Ko)&&!e.includes(`
|
|
17
|
-
`))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let o=(e.match(/```/g)||[]).length,n=o%2===1;if(o>0&&o%2===0&&e.includes(`
|
|
18
|
-
`)||(e.endsWith("```\n")||e.endsWith("```"))&&o%2===0)return e;let s=e.match(Xo);if(s&&!n){let r=s[2];if(!r||q.test(r))return e;if(ln(e)%2===1)return `${e}\``}return e},dn=e=>{let t=e.match(Jo);if(t){let o=t[2];if(!o||q.test(o))return e;if((e.match(/~~/g)||[]).length%2===1)return `${e}~~`}return e},mn=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let o=e.indexOf("$$");return o!==-1&&e.indexOf(`
|
|
19
|
-
`,o)!==-1&&!e.endsWith(`
|
|
20
|
-
`)?`${e}
|
|
21
|
-
$$`:`${e}$$`},pn=e=>{let t=0,o=0;for(let n=0;n<e.length;n+=1)e[n]==="*"?o+=1:(o>=3&&(t+=Math.floor(o/3)),o=0);return o>=3&&(t+=Math.floor(o/3)),t},un=e=>{if(le(e)||Zo.test(e))return e;let t=e.match(Uo);if(t){let o=t[2];if(!o||q.test(o))return e;if(pn(e)%2===1)return `${e}***`}return e},Me=e=>{if(!e||typeof e!="string")return e;let t=e,o=Qo(t);return o.endsWith("](streamdown:incomplete-link)")?o:(t=o,t=un(t),t=en(t),t=tn(t),t=nn(t),t=sn(t),t=cn(t),t=dn(t),t=mn(t),t)};var Mn={raw:wn__default.default,katex:[Pe__default.default,{errorColor:"var(--color-muted-foreground)"}],harden:[rehypeHarden.harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Pn={gfm:[Cn__default.default,{}],math:[Te__default.default,{singleDollarTextMath:false}],cjkFriendly:[kn__default.default,{}],cjkFriendlyGfmStrikethrough:[vn__default.default,{}]},Tn=Object.values(Mn),Nn=Object.values(Pn),xn={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0},M=react.createContext(xn),Bt=react.memo(({content:e,shouldParseIncompleteMarkdown:t,...o})=>{let n=react.useMemo(()=>typeof e=="string"&&t?Me(e.trim()):e,[e,t]);return jsxRuntime.jsx(ye,{...o,children:n})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||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(s=>{var r,i;return ((r=e.components)==null?void 0:r[s])!==((i=t.components)==null?void 0:i[s])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Bt.displayName="Block";var Sn=["github-light","github-dark"],In=react.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=true,components:n,rehypePlugins:s=Tn,remarkPlugins:r=Nn,className:i,shikiTheme:a=Sn,mermaid:l,controls:d=true,isAnimating:m=false,BlockComponent:c=Bt,parseMarkdownIntoBlocksFn:p=ve,...g})=>{let f=react.useId(),[h,w]=react.useTransition(),[v,N]=react.useState([]),P=react.useMemo(()=>p(typeof e=="string"?e:""),[e,p]);react.useEffect(()=>{t==="streaming"?w(()=>{N(P);}):N(P);},[P,t]);let T=t==="streaming"?v:P,D=react.useMemo(()=>T.map((B,A)=>`${f}-${A}`),[T.length,f]),j=react.useMemo(()=>({shikiTheme:a,controls:d,isAnimating:m,mode:t,mermaid:l}),[a,d,m,t,l]),O=react.useMemo(()=>({...vt,...n}),[n]);return react.useEffect(()=>{if(!(Array.isArray(s)&&s.some(S=>Array.isArray(S)?S[0]===Pe__default.default:S===Pe__default.default)))return;let A=false;if(Array.isArray(r)){let S=r.find(Z=>Array.isArray(Z)?Z[0]===Te__default.default:Z===Te__default.default);S&&Array.isArray(S)&&S[1]&&(A=S[1].singleDollarTextMath===true);}let L=typeof e=="string"?e:"",H=L.includes("$$"),y=A&&(/[^$]\$[^$]/.test(L)||/^\$[^$]/.test(L)||/[^$]\$$/.test(L));(H||y)&&import('katex/dist/katex.min.css');},[s,r,e]),t==="static"?jsxRuntime.jsx(M.Provider,{value:j,children:jsxRuntime.jsx("div",{className:u("space-y-4 whitespace-normal",i),children:jsxRuntime.jsx(ye,{components:O,rehypePlugins:s,remarkPlugins:r,...g,children:e})})}):jsxRuntime.jsx(M.Provider,{value:j,children:jsxRuntime.jsx("div",{className:u("space-y-4 whitespace-normal",i),children:T.map((B,A)=>jsxRuntime.jsx(c,{components:O,content:B,index:A,rehypePlugins:s,remarkPlugins:r,shouldParseIncompleteMarkdown:o,...g},D[A]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);In.displayName="Streamdown";var Et=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:s=.1,showControls:r=true,initialZoom:i=1,fullscreen:a=false})=>{let l=react.useRef(null),d=react.useRef(null),[m,c]=react.useState(i),[p,g]=react.useState({x:0,y:0}),[f,h]=react.useState(false),[w,v]=react.useState({x:0,y:0}),[N,P]=react.useState({x:0,y:0}),T=react.useCallback(y=>{c(x=>Math.max(o,Math.min(n,x+y)));},[o,n]),D=react.useCallback(()=>{T(s);},[T,s]),j=react.useCallback(()=>{T(-s);},[T,s]),O=react.useCallback(()=>{c(i),g({x:0,y:0});},[i]),B=react.useCallback(y=>{y.preventDefault();let x=y.deltaY>0?-s:s;T(x);},[T,s]),A=react.useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;h(true),v({x:y.clientX,y:y.clientY}),P(p);let x=y.currentTarget;x instanceof HTMLElement&&x.setPointerCapture(y.pointerId);},[p]),L=react.useCallback(y=>{if(!f)return;y.preventDefault();let x=y.clientX-w.x,S=y.clientY-w.y;g({x:N.x+x,y:N.y+S});},[f,w,N]),H=react.useCallback(y=>{h(false);let x=y.currentTarget;x instanceof HTMLElement&&x.releasePointerCapture(y.pointerId);},[]);return react.useEffect(()=>{let y=l.current;if(y)return y.addEventListener("wheel",B,{passive:false}),()=>{y.removeEventListener("wheel",B);}},[B]),react.useEffect(()=>{let y=d.current;if(y&&f)return document.body.style.userSelect="none",y.addEventListener("pointermove",L,{passive:false}),y.addEventListener("pointerup",H),y.addEventListener("pointercancel",H),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",L),y.removeEventListener("pointerup",H),y.removeEventListener("pointercancel",H);}},[f,L,H]),jsxRuntime.jsxs("div",{className:u("relative",a?"h-full w-full":"w-full",t),ref:l,style:{cursor:f?"grabbing":"grab"},children:[r&&jsxRuntime.jsxs("div",{className:u("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",a?"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:m>=n,onClick:D,title:"Zoom in",type:"button",children:jsxRuntime.jsx(lucideReact.ZoomInIcon,{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:m<=o,onClick:j,title:"Zoom out",type:"button",children:jsxRuntime.jsx(lucideReact.ZoomOutIcon,{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:O,title:"Reset zoom and pan",type:"button",children:jsxRuntime.jsx(lucideReact.RotateCcwIcon,{size:16})})]}),jsxRuntime.jsx("div",{className:u("origin-center transition-transform duration-150 ease-out",a&&"flex w-full items-center justify-center"),onPointerDown:A,ref:d,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${m})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var De=({chart:e,className:t,config:o,fullscreen:n=false,showControls:s=true})=>{let[r,i]=react.useState(null),[a,l]=react.useState(true),[d,m]=react.useState(""),[c,p]=react.useState(""),[g,f]=react.useState(0),{mermaid:h}=react.useContext(M),w=h==null?void 0:h.errorComponent;if(react.useEffect(()=>{(async()=>{try{i(null),l(!0);let P=await Q(o),T=e.split("").reduce((O,B)=>(O<<5)-O+B.charCodeAt(0)|0,0),D=`mermaid-${Math.abs(T)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:j}=await P.render(D,e);m(j),p(j);}catch(P){if(!(c||d)){let T=P instanceof Error?P.message:"Failed to render Mermaid chart";i(T);}}finally{l(false);}})();},[e,o,g]),a&&!d&&!c)return jsxRuntime.jsx("div",{className:u("my-4 flex justify-center p-4",t),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(r&&!d&&!c){let N=()=>f(P=>P+1);return w?jsxRuntime.jsx(w,{chart:e,error:r,retry:N}):jsxRuntime.jsxs("div",{className:u("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[jsxRuntime.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),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 v=d||c;return jsxRuntime.jsx(Et,{className:u(n?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:s,zoomStep:.1,children:jsxRuntime.jsx("div",{"aria-label":"Mermaid chart",className:u("flex justify-center",n&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:v},role:"img"})})};exports.a=u;exports.b=Ht;exports.c=De;exports.d=ve;exports.e=Me;exports.f=Mn;exports.g=Pn;exports.h=M;exports.i=Bt;exports.j=In;
|
package/dist/chunk-T7OEMACY.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {createContext,lazy,memo,useContext,isValidElement,useMemo,useId,useTransition,useState,useEffect,Suspense,useRef,useCallback}from'react';import {harden}from'rehype-harden';import Pe from'rehype-katex';import wn from'rehype-raw';import kn from'remark-cjk-friendly';import vn from'remark-cjk-friendly-gfm-strikethrough';import Cn from'remark-gfm';import Te from'remark-math';import {DownloadIcon,CheckIcon,CopyIcon,Maximize2Icon,XIcon,Loader2Icon,ZoomInIcon,ZoomOutIcon,RotateCcwIcon}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import Io from'remark-parse';import Bo from'remark-rehype';import {unified}from'unified';import {Lexer}from'marked';var u=(...e)=>twMerge(clsx(e)),I=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s);};var Ht=createContext({code:""}),G=()=>useContext(Ht);var de=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:s,code:r,...i})=>{let[a,l]=useState(false),d=useRef(0),{code:m}=G(),{isAnimating:c}=useContext(M),p=r!=null?r:m,g=async()=>{var h;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{a||(await navigator.clipboard.writeText(p),l(!0),e==null||e(),d.current=window.setTimeout(()=>l(!1),o));}catch(w){t==null||t(w);}};useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let f=a?CheckIcon:CopyIcon;return jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-copy-button",disabled:c,onClick:g,title:"Copy Code",type:"button",...i,children:n!=null?n:jsx(f,{size:14})})};var xe={"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"},Ie=({onDownload:e,onError:t,language:o,children:n,className:s,code:r,...i})=>{let{code:a}=G(),{isAnimating:l}=useContext(M),d=r!=null?r:a,c=`file.${o&&o in xe?xe[o]:"txt"}`,p="text/plain",g=()=>{try{I(c,d,p),e==null||e();}catch(f){t==null||t(f);}};return jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-download-button",disabled:l,onClick:g,title:"Download file",type:"button",...i,children:n!=null?n:jsx(DownloadIcon,{size:14})})};var pe=()=>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(Loader2Icon,{className:"size-4 animate-spin"})})]});var Gt=/\.[^/.]+$/,Be=({node:e,className:t,src:o,alt:n,...s})=>{let r=async()=>{if(o)try{let a=await(await fetch(o)).blob(),d=new URL(o,window.location.origin).pathname.split("/").pop()||"",m=d.split(".").pop(),c=d.includes(".")&&m!==void 0&&m.length<=4,p="";if(c)p=d;else {let g=a.type,f="png";g.includes("jpeg")||g.includes("jpg")?f="jpg":g.includes("png")?f="png":g.includes("svg")?f="svg":g.includes("gif")?f="gif":g.includes("webp")&&(f="webp"),p=`${(n||d||"image").replace(Gt,"")}.${f}`;}I(p,a,a.type);}catch(i){console.error("Failed to download image:",i);}};return o?jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:u("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...s}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsx("button",{className:u("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:r,title:"Download image",type:"button",children:jsx(DownloadIcon,{size:14})})]}):null};var Q=async e=>{let o={...{startOnLoad:false,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:true},...e},s=(await import('mermaid')).default;return s.initialize(o),s},Ae=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((s,r)=>{let i="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),a=new Image;a.crossOrigin="anonymous",a.onload=()=>{let l=document.createElement("canvas"),d=a.width*o,m=a.height*o;l.width=d,l.height=m;let c=l.getContext("2d");if(!c){r(new Error("Failed to create 2D canvas context for PNG export"));return}c.drawImage(a,0,0,d,m),l.toBlob(p=>{if(!p){r(new Error("Failed to create PNG blob"));return}s(p);},"image/png");},a.onerror=()=>r(new Error("Failed to load SVG image")),a.src=i;})};var Re=({chart:e,children:t,className:o,onDownload:n,config:s,onError:r})=>{let[i,a]=useState(false),l=useRef(null),{isAnimating:d}=useContext(M),m=async c=>{try{if(c==="mmd"){I("diagram.mmd",e,"text/plain"),a(!1),n==null||n(c);return}let p=await Q(s),g=e.split("").reduce((w,v)=>(w<<5)-w+v.charCodeAt(0)|0,0),f=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:h}=await p.render(f,e);if(!h){r==null||r(new Error("SVG not found. Please wait for the diagram to render."));return}if(c==="svg"){I("diagram.svg",h,"image/svg+xml"),a(!1),n==null||n(c);return}if(c==="png"){let w=await Ae(h);I("diagram.png",w,"image/png"),n==null||n(c),a(!1);return}}catch(p){r==null||r(p);}};return useEffect(()=>{let c=p=>{l.current&&!l.current.contains(p.target)&&a(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxs("div",{className:"relative",ref:l,children:[jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d,onClick:()=>a(!i),title:"Download diagram",type:"button",children:t!=null?t:jsx(DownloadIcon,{size:14})}),i&&jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("svg"),type:"button",title:"Download diagram as SVG",children:"SVG"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("png"),type:"button",title:"Download diagram as PNG",children:"PNG"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("mmd"),type:"button",title:"Download diagram as MMD",children:"MMD"})]})]})};var X=0,lo=()=>{X+=1,X===1&&(document.body.style.overflow="hidden");},co=()=>{X=Math.max(0,X-1),X===0&&(document.body.style.overflow="");},je=({chart:e,config:t,onFullscreen:o,onExit:n,className:s,...r})=>{let[i,a]=useState(false),{isAnimating:l,controls:d}=useContext(M),m=(()=>{if(typeof d=="boolean")return d;let p=d.mermaid;return p===false?false:p===true||p===void 0?true:p.panZoom!==false})(),c=()=>{a(!i);};return useEffect(()=>{if(i){lo();let p=g=>{g.key==="Escape"&&a(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),co();}}},[i]),useEffect(()=>{i?o==null||o():n&&n();},[i,o,n]),jsxs(Fragment,{children:[jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),disabled:l,onClick:c,title:"View fullscreen",type:"button",...r,children:jsx(Maximize2Icon,{size:14})}),i&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:c,onKeyDown:p=>{p.key==="Escape"&&c();},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:c,title:"Exit fullscreen",type:"button",children:jsx(XIcon,{size:20})}),jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:jsx(De,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:m})})]})]})};var ee=e=>{var r,i;let t=[],o=[],n=e.querySelectorAll("thead th");for(let a of n)t.push(((r=a.textContent)==null?void 0:r.trim())||"");let s=e.querySelectorAll("tbody tr");for(let a of s){let l=[],d=a.querySelectorAll("td");for(let m of d)l.push(((i=m.textContent)==null?void 0:i.trim())||"");o.push(l);}return {headers:t,rows:o}},te=e=>{let{headers:t,rows:o}=e,n=a=>{let l=false,d=false;for(let m=0;m<a.length;m+=1){let c=a[m];if(c==='"'){l=true,d=true;break}(c===","||c===`
|
|
2
|
-
`)&&(l=true);}return l?d?`"${a.replace(/"/g,'""')}"`:`"${a}"`:a},s=t.length>0?o.length+1:o.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(n).join(","),i+=1);for(let a of o)r[i]=a.map(n).join(","),i+=1;return r.join(`
|
|
3
|
-
`)},Oe=e=>{let{headers:t,rows:o}=e,n=a=>{let l=false;for(let m=0;m<a.length;m+=1){let c=a[m];if(c===" "||c===`
|
|
4
|
-
`||c==="\r"){l=true;break}}if(!l)return a;let d=[];for(let m=0;m<a.length;m+=1){let c=a[m];c===" "?d.push("\\t"):c===`
|
|
5
|
-
`?d.push("\\n"):c==="\r"?d.push("\\r"):d.push(c);}return d.join("")},s=t.length>0?o.length+1:o.length,r=new Array(s),i=0;t.length>0&&(r[i]=t.map(n).join(" "),i+=1);for(let a of o)r[i]=a.map(n).join(" "),i+=1;return r.join(`
|
|
6
|
-
`)},ue=e=>{let t=false;for(let n=0;n<e.length;n+=1){let s=e[n];if(s==="\\"||s==="|"){t=true;break}}if(!t)return e;let o=[];for(let n=0;n<e.length;n+=1){let s=e[n];s==="\\"?o.push("\\\\"):s==="|"?o.push("\\|"):o.push(s);}return o.join("")},He=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),s=0,r=t.map(a=>ue(a));n[s]=`| ${r.join(" | ")} |`,s+=1;let i=new Array(t.length);for(let a=0;a<t.length;a+=1)i[a]="---";n[s]=`| ${i.join(" | ")} |`,s+=1;for(let a of o)if(a.length<t.length){let l=new Array(t.length);for(let d=0;d<t.length;d+=1)l[d]=d<a.length?ue(a[d]):"";n[s]=`| ${l.join(" | ")} |`,s+=1;}else {let l=a.map(d=>ue(d));n[s]=`| ${l.join(" | ")} |`,s+=1;}return n.join(`
|
|
7
|
-
`)};var Ue=({children:e,className:t,onCopy:o,onError:n,timeout:s=2e3})=>{let[r,i]=useState(false),[a,l]=useState(false),d=useRef(null),m=useRef(0),{isAnimating:c}=useContext(M),p=async f=>{var h,w;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.write)){n==null||n(new Error("Clipboard API not available"));return}try{let v=(w=d.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),N=v==null?void 0:v.querySelector("table");if(!N){n==null||n(new Error("Table not found"));return}let P=ee(N),T=f==="csv"?te(P):Oe(P),D=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([N.outerHTML],{type:"text/html"})});await navigator.clipboard.write([D]),l(!0),i(!1),o==null||o(f),m.current=window.setTimeout(()=>l(!1),s);}catch(v){n==null||n(v);}};useEffect(()=>{let f=h=>{d.current&&!d.current.contains(h.target)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(m.current);}},[]);let g=a?CheckIcon:CopyIcon;return jsxs("div",{className:"relative",ref:d,children:[jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:()=>i(!r),title:"Copy table",type:"button",children:e!=null?e:jsx(g,{size:14})}),r&&jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("csv"),type:"button",title:"Copy table as CSV",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("tsv"),type:"button",title:"Copy table as TSV",children:"TSV"})]})]})};var Fe=({children:e,className:t,onDownload:o,onError:n})=>{let[s,r]=useState(false),i=useRef(null),{isAnimating:a}=useContext(M),l=d=>{var m;try{let c=(m=i.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),p=c==null?void 0:c.querySelector("table");if(!p){n==null||n(new Error("Table not found"));return}let g=ee(p),f=d==="csv"?te(g):He(g);I(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),r(!1),o==null||o(d);}catch(c){n==null||n(c);}};return useEffect(()=>{let d=m=>{i.current&&!i.current.contains(m.target)&&r(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxs("div",{className:"relative",ref:i,children:[jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:a,onClick:()=>r(!s),title:"Download table",type:"button",children:e!=null?e:jsx(DownloadIcon,{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:()=>l("csv"),type:"button",title:"Download table as CSV",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",title:"Download table as Markdown",children:"Markdown"})]})]})};var Je=({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(Ue,{}),jsx(Fe,{})]}),jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:u("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});var vo=lazy(()=>import('./code-block-JS6V4U2P.js').then(e=>({default:e.CodeBlock}))),Co=lazy(()=>import('./mermaid-ZSTFYFNX.js').then(e=>({default:e.Mermaid}))),Mo=/language-([^\s]+)/;function ae(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,s=e.position.end,r=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(s==null?void 0:s.line)===(r==null?void 0:r.line)&&(s==null?void 0:s.column)===(r==null?void 0:r.column)}function C(e,t){return e.className===t.className&&ae(e.node,t.node)}var ge=(e,t)=>typeof e=="boolean"?e:e[t]!==false,se=(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:u("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>C(e,t));he.displayName="MarkdownOl";var Ge=memo(({children:e,className:t,node:o,...n})=>jsx("li",{className:u("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ae(e.node,t.node));Ge.displayName="MarkdownLi";var Ye=memo(({children:e,className:t,node:o,...n})=>jsx("ul",{className:u("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>C(e,t));Ye.displayName="MarkdownUl";var Qe=memo(({className:e,node:t,...o})=>jsx("hr",{className:u("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>C(e,t));Qe.displayName="MarkdownHr";var et=memo(({children:e,className:t,node:o,...n})=>jsx("span",{className:u("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>C(e,t));et.displayName="MarkdownStrong";var tt=memo(({children:e,className:t,href:o,node:n,...s})=>{let r=o==="streamdown:incomplete-link";return jsx("a",{className:u("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...s,children:e})},(e,t)=>C(e,t)&&e.href===t.href);tt.displayName="MarkdownA";var ot=memo(({children:e,className:t,node:o,...n})=>jsx("h1",{className:u("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>C(e,t));ot.displayName="MarkdownH1";var nt=memo(({children:e,className:t,node:o,...n})=>jsx("h2",{className:u("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>C(e,t));nt.displayName="MarkdownH2";var rt=memo(({children:e,className:t,node:o,...n})=>jsx("h3",{className:u("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>C(e,t));rt.displayName="MarkdownH3";var st=memo(({children:e,className:t,node:o,...n})=>jsx("h4",{className:u("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>C(e,t));st.displayName="MarkdownH4";var at=memo(({children:e,className:t,node:o,...n})=>jsx("h5",{className:u("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>C(e,t));at.displayName="MarkdownH5";var it=memo(({children:e,className:t,node:o,...n})=>jsx("h6",{className:u("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>C(e,t));it.displayName="MarkdownH6";var lt=memo(({children:e,className:t,node:o,...n})=>{let{controls:s}=useContext(M),r=ge(s,"table");return jsx(Je,{className:t,"data-streamdown":"table-wrapper",showControls:r,...n,children:e})},(e,t)=>C(e,t));lt.displayName="MarkdownTable";var ct=memo(({children:e,className:t,node:o,...n})=>jsx("thead",{className:u("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>C(e,t));ct.displayName="MarkdownThead";var dt=memo(({children:e,className:t,node:o,...n})=>jsx("tbody",{className:u("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>C(e,t));dt.displayName="MarkdownTbody";var mt=memo(({children:e,className:t,node:o,...n})=>jsx("tr",{className:u("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>C(e,t));mt.displayName="MarkdownTr";var pt=memo(({children:e,className:t,node:o,...n})=>jsx("th",{className:u("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>C(e,t));pt.displayName="MarkdownTh";var ut=memo(({children:e,className:t,node:o,...n})=>jsx("td",{className:u("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>C(e,t));ut.displayName="MarkdownTd";var ft=memo(({children:e,className:t,node:o,...n})=>jsx("blockquote",{className:u("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>C(e,t));ft.displayName="MarkdownBlockquote";var gt=memo(({children:e,className:t,node:o,...n})=>jsx("sup",{className:u("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>C(e,t));gt.displayName="MarkdownSup";var ht=memo(({children:e,className:t,node:o,...n})=>jsx("sub",{className:u("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>C(e,t));ht.displayName="MarkdownSub";var bt=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let r=l=>{var p,g;if(!isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],m=false,c=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(m=true);else if(isValidElement(f))if(((p=f.props)==null?void 0:p["data-footnote-backref"])!==void 0)c=true;else {let h=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let w of h){if(typeof w=="string"&&w.trim()!==""){m=true;break}if(isValidElement(w)&&((g=w.props)==null?void 0:g["data-footnote-backref"])===void 0){m=true;break}}}}return c&&!m},i=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===he){let m=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(c=>!r(c));return m.length===0?null:{...l,props:{...l.props,children:m}}}return l}):e;return (Array.isArray(i)?i.some(l=>l!==null):i!==null)?jsx("section",{className:t,...n,children:i}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>C(e,t));bt.displayName="MarkdownSection";var Po=({node:e,className:t,children:o,...n})=>{var c,p,g;let s=((c=e==null?void 0:e.position)==null?void 0:c.start.line)===((p=e==null?void 0:e.position)==null?void 0:p.end.line),{mermaid:r,controls:i}=useContext(M);if(s)return jsx("code",{className:u("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let a=t==null?void 0:t.match(Mo),l=(g=a==null?void 0:a.at(1))!=null?g:"",d="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?d=o.props.children:typeof o=="string"&&(d=o),l==="mermaid"){let f=ge(i,"mermaid"),h=se(i,"download"),w=se(i,"copy"),v=se(i,"fullscreen"),N=se(i,"panZoom");return jsx(Suspense,{fallback:jsx(pe,{}),children:jsxs("div",{className:u("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[f&&(h||w||v)&&jsxs("div",{className:"flex items-center justify-end gap-2",children:[h&&jsx(Re,{chart:d,config:r==null?void 0:r.config}),w&&jsx(de,{code:d}),v&&jsx(je,{chart:d,config:r==null?void 0:r.config})]}),jsx(Co,{chart:d,config:r==null?void 0:r.config,showControls:N})]})})}let m=ge(i,"code");return jsx(Suspense,{fallback:jsx(pe,{}),children:jsx(vo,{className:u("overflow-x-auto border-border border-t",t),code:d,language:l,children:m&&jsxs(Fragment,{children:[jsx(Ie,{code:d,language:l}),jsx(de,{})]})})})},yt=memo(Po,(e,t)=>e.className===t.className&&ae(e.node,t.node));yt.displayName="MarkdownCode";var wt=memo(Be,(e,t)=>e.className===t.className&&ae(e.node,t.node));wt.displayName="MarkdownImg";var kt=memo(({children:e,className:t,node:o,...n})=>{var i;let r=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");return r.length===1&&isValidElement(r[0])&&((i=r[0].props.node)==null?void 0:i.tagName)==="img"?jsx(Fragment,{children:e}):jsx("p",{className:t,...n,children:e})},(e,t)=>C(e,t));kt.displayName="MarkdownParagraph";var vt={ol:he,li:Ge,ul:Ye,hr:Qe,strong:et,a:tt,h1:ot,h2:nt,h3:rt,h4:st,h5:at,h6:it,table:lt,thead:ct,tbody:dt,tr:mt,th:pt,td:ut,blockquote:ft,code:yt,img:wt,pre:({children:e})=>e,sup:gt,sub:ht,p:kt,section:bt};var Mt=[],Pt={allowDangerousHtml:true},ie=new WeakMap,be=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,s=t.remarkPlugins,r=t.remarkRehypeOptions;if(!(n||s||r)){let c="default";return this.keyCache.set(t,c),c}let i=c=>{if(!c||c.length===0)return "";let p="";for(let g=0;g<c.length;g+=1){let f=c[g];if(g>0&&(p+=","),Array.isArray(f)){let[h,w]=f;if(typeof h=="function"){let v=ie.get(h);v||(v=h.name,ie.set(h,v)),p+=v;}else p+=String(h);p+=":",p+=JSON.stringify(w);}else if(typeof f=="function"){let h=ie.get(f);h||(h=f.name,ie.set(f,h)),p+=h;}else p+=String(f);}return p},a=i(n),l=i(s),d=r?JSON.stringify(r):"",m=`${l}::${a}::${d}`;return this.keyCache.set(t,m),m}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let s=this.cache.keys().next().value;s&&this.cache.delete(s);}this.cache.set(n,o);}clear(){this.cache.clear();}},Tt=new be,ye=e=>{let t=Lo(e),o=e.children||"";return Eo(t.runSync(t.parse(o),o),e)},Lo=e=>{let t=Tt.get(e);if(t)return t;let o=Ro(e);return Tt.set(e,o),o},Ro=e=>{let t=e.rehypePlugins||Mt,o=e.remarkPlugins||Mt,n=e.remarkRehypeOptions?{...Pt,...e.remarkRehypeOptions}:Pt;return unified().use(Io).use(o).use(Bo,n).use(t)},Eo=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Do=/\[\^[^\]\s]{1,200}\](?!:)/,jo=/\[\^[^\]\s]{1,200}\]:/,Oo=/<\/(\w+)>/,Ho=/<(\w+)[\s>]/,we=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
8
|
-
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},qo=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
|
-
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},ke=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=Do.test(e),o=jo.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),s=[],r=[];for(let i of n){let a=i.raw,l=s.length;if(r.length>0){if(s[l-1]+=a,i.type==="html"){let m=a.match(Oo);if(m){let c=m[1];r.at(-1)===c&&r.pop();}}continue}if(i.type==="html"&&i.block){let m=a.match(Ho);if(m){let c=m[1];a.includes(`</${c}>`)||r.push(c);}}if(a.trim()==="$$"&&l>0){let m=s[l-1],c=we(m),p=ke(m);if(c&&p%2===1){s[l-1]=m+a;continue}}if(l>0&&qo(a)){let m=s[l-1],c=we(m),p=ke(m),g=ke(a);if(c&&p%2===1&&!we(a)&&g===1){s[l-1]=m+a;continue}}s.push(a);}return s};var zo=/(\*\*)([^*]*?)$/,Wo=/(__)([^_]*?)$/,Uo=/(\*\*\*)([^*]*?)$/,_o=/(\*)([^*]*?)$/,Fo=/(_)([^_]*?)$/,Xo=/(`)([^`]*?)$/,Jo=/(~~)([^~]*?)$/,q=/^[\s_~*`]*$/,Nt=/^[\s]*[-*+][\s]+$/,Vo=/[\p{L}\p{N}_]/u,Ko=/^```[^`\n]*```?$/,Zo=/^\*{4,}$/,R=e=>{if(!e)return false;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?true:Vo.test(e)},le=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
|
|
10
|
-
`)};var Go=(e,t)=>{let o=1;for(let n=t-1;n>=0;n-=1)if(e[n]==="]")o+=1;else if(e[n]==="["&&(o-=1,o===0))return n;return -1},Yo=(e,t)=>{let o=1;for(let n=t+1;n<e.length;n+=1)if(e[n]==="[")o+=1;else if(e[n]==="]"&&(o-=1,o===0))return n;return -1},Ce=(e,t)=>{let o=false,n=false;for(let s=0;s<t;s+=1){if(e.substring(s,s+3)==="```"){n=!n,s+=2;continue}!n&&e[s]==="`"&&(o=!o);}return o||n},Qo=e=>{let t=e.lastIndexOf("](");if(t!==-1&&!Ce(e,t)&&!e.substring(t+2).includes(")")){let n=Go(e,t);if(n!==-1&&!Ce(e,n)){let s=n>0&&e[n-1]==="!",r=s?n-1:n,i=e.substring(0,r),a=e.substring(n+1,t);return s?i:`${i}[${a}](streamdown:incomplete-link)`}}for(let o=e.length-1;o>=0;o-=1)if(e[o]==="["&&!Ce(e,o)){let n=o>0&&e[o-1]==="!",s=n?o-1:o;if(!e.substring(o+1).includes("]")){let a=e.substring(0,s);return n?a:`${e}](streamdown:incomplete-link)`}if(Yo(e,o)===-1){let a=e.substring(0,s);return n?a:`${e}](streamdown:incomplete-link)`}}return e},en=e=>{if(le(e))return e;let t=e.match(zo);if(t){let o=t[2];if(!o||q.test(o))return e;let n=e.lastIndexOf(t[1]),r=e.substring(0,n).lastIndexOf(`
|
|
11
|
-
`),i=r===-1?0:r+1,a=e.substring(i,n);if(Nt.test(a)&&o.includes(`
|
|
12
|
-
`))return e;if((e.match(/\*\*/g)||[]).length%2===1)return `${e}**`}return e},tn=e=>{let t=e.match(Wo);if(t){let o=t[2];if(!o||q.test(o))return e;let n=e.lastIndexOf(t[1]),r=e.substring(0,n).lastIndexOf(`
|
|
13
|
-
`),i=r===-1?0:r+1,a=e.substring(i,n);if(Nt.test(a)&&o.includes(`
|
|
14
|
-
`))return e;if((e.match(/__/g)||[]).length%2===1)return `${e}__`}return e},on=e=>{let t=0,o=e.length;for(let n=0;n<o;n+=1){if(e[n]!=="*")continue;let s=n>0?e[n-1]:"",r=n<o-1?e[n+1]:"";if(s==="\\"||s==="*"||r==="*"||s&&r&&R(s)&&R(r))continue;let i=0;for(let l=n-1;l>=0;l-=1)if(e[l]===`
|
|
15
|
-
`){i=l+1;break}let a=true;for(let l=i;l<n;l+=1)if(e[l]!==" "&&e[l]!==" "){a=false;break}a&&(r===" "||r===" ")||(t+=1);}return t},nn=e=>{if(le(e))return e;if(e.match(_o)){let o=-1;for(let r=0;r<e.length;r+=1)if(e[r]==="*"&&e[r-1]!=="*"&&e[r+1]!=="*"&&e[r-1]!=="\\"){let i=r>0?e[r-1]:"",a=r<e.length-1?e[r+1]:"";if(i&&a&&R(i)&&R(a))continue;o=r;break}if(o===-1)return e;let n=e.substring(o+1);if(!n||q.test(n))return e;if(on(e)%2===1)return `${e}*`}return e},xt=(e,t)=>{let o=false,n=false;for(let s=0;s<e.length&&s<t;s+=1){if(e[s]==="\\"&&e[s+1]==="$"){s+=1;continue}e[s]==="$"&&(e[s+1]==="$"?(n=!n,s+=1,o=false):n||(o=!o));}return o||n},rn=e=>{let t=e.includes("$"),o=0,n=e.length;for(let s=0;s<n;s+=1){if(e[s]!=="_")continue;let r=s>0?e[s-1]:"",i=s<n-1?e[s+1]:"";r!=="\\"&&(t&&xt(e,s)||r==="_"||i==="_"||r&&i&&R(r)&&R(i)||(o+=1));}return o},sn=e=>{if(le(e))return e;if(e.match(Fo)){let o=-1;for(let r=0;r<e.length;r+=1)if(e[r]==="_"&&e[r-1]!=="_"&&e[r+1]!=="_"&&e[r-1]!=="\\"&&!xt(e,r)){let i=r>0?e[r-1]:"",a=r<e.length-1?e[r+1]:"";if(i&&a&&R(i)&&R(a))continue;o=r;break}if(o===-1)return e;let n=e.substring(o+1);if(!n||q.test(n))return e;if(rn(e)%2===1){let r=e.length;for(;r>0&&e[r-1]===`
|
|
16
|
-
`;)r-=1;if(r<e.length){let i=e.slice(0,r),a=e.slice(r);return `${i}_${a}`}return `${e}_`}}return e},an=(e,t)=>{let o=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",s=t>1&&e.substring(t-2,t+1)==="```";return o||n||s},ln=e=>{let t=0;for(let o=0;o<e.length;o+=1)e[o]==="`"&&!an(e,o)&&(t+=1);return t},cn=e=>{if(e.match(Ko)&&!e.includes(`
|
|
17
|
-
`))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let o=(e.match(/```/g)||[]).length,n=o%2===1;if(o>0&&o%2===0&&e.includes(`
|
|
18
|
-
`)||(e.endsWith("```\n")||e.endsWith("```"))&&o%2===0)return e;let s=e.match(Xo);if(s&&!n){let r=s[2];if(!r||q.test(r))return e;if(ln(e)%2===1)return `${e}\``}return e},dn=e=>{let t=e.match(Jo);if(t){let o=t[2];if(!o||q.test(o))return e;if((e.match(/~~/g)||[]).length%2===1)return `${e}~~`}return e},mn=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let o=e.indexOf("$$");return o!==-1&&e.indexOf(`
|
|
19
|
-
`,o)!==-1&&!e.endsWith(`
|
|
20
|
-
`)?`${e}
|
|
21
|
-
$$`:`${e}$$`},pn=e=>{let t=0,o=0;for(let n=0;n<e.length;n+=1)e[n]==="*"?o+=1:(o>=3&&(t+=Math.floor(o/3)),o=0);return o>=3&&(t+=Math.floor(o/3)),t},un=e=>{if(le(e)||Zo.test(e))return e;let t=e.match(Uo);if(t){let o=t[2];if(!o||q.test(o))return e;if(pn(e)%2===1)return `${e}***`}return e},Me=e=>{if(!e||typeof e!="string")return e;let t=e,o=Qo(t);return o.endsWith("](streamdown:incomplete-link)")?o:(t=o,t=un(t),t=en(t),t=tn(t),t=nn(t),t=sn(t),t=cn(t),t=dn(t),t=mn(t),t)};var Mn={raw:wn,katex:[Pe,{errorColor:"var(--color-muted-foreground)"}],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Pn={gfm:[Cn,{}],math:[Te,{singleDollarTextMath:false}],cjkFriendly:[kn,{}],cjkFriendlyGfmStrikethrough:[vn,{}]},Tn=Object.values(Mn),Nn=Object.values(Pn),xn={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0},M=createContext(xn),Bt=memo(({content:e,shouldParseIncompleteMarkdown:t,...o})=>{let n=useMemo(()=>typeof e=="string"&&t?Me(e.trim()):e,[e,t]);return jsx(ye,{...o,children:n})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||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(s=>{var r,i;return ((r=e.components)==null?void 0:r[s])!==((i=t.components)==null?void 0:i[s])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Bt.displayName="Block";var Sn=["github-light","github-dark"],In=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=true,components:n,rehypePlugins:s=Tn,remarkPlugins:r=Nn,className:i,shikiTheme:a=Sn,mermaid:l,controls:d=true,isAnimating:m=false,BlockComponent:c=Bt,parseMarkdownIntoBlocksFn:p=ve,...g})=>{let f=useId(),[h,w]=useTransition(),[v,N]=useState([]),P=useMemo(()=>p(typeof e=="string"?e:""),[e,p]);useEffect(()=>{t==="streaming"?w(()=>{N(P);}):N(P);},[P,t]);let T=t==="streaming"?v:P,D=useMemo(()=>T.map((B,A)=>`${f}-${A}`),[T.length,f]),j=useMemo(()=>({shikiTheme:a,controls:d,isAnimating:m,mode:t,mermaid:l}),[a,d,m,t,l]),O=useMemo(()=>({...vt,...n}),[n]);return useEffect(()=>{if(!(Array.isArray(s)&&s.some(S=>Array.isArray(S)?S[0]===Pe:S===Pe)))return;let A=false;if(Array.isArray(r)){let S=r.find(Z=>Array.isArray(Z)?Z[0]===Te:Z===Te);S&&Array.isArray(S)&&S[1]&&(A=S[1].singleDollarTextMath===true);}let L=typeof e=="string"?e:"",H=L.includes("$$"),y=A&&(/[^$]\$[^$]/.test(L)||/^\$[^$]/.test(L)||/[^$]\$$/.test(L));(H||y)&&import('katex/dist/katex.min.css');},[s,r,e]),t==="static"?jsx(M.Provider,{value:j,children:jsx("div",{className:u("space-y-4 whitespace-normal",i),children:jsx(ye,{components:O,rehypePlugins:s,remarkPlugins:r,...g,children:e})})}):jsx(M.Provider,{value:j,children:jsx("div",{className:u("space-y-4 whitespace-normal",i),children:T.map((B,A)=>jsx(c,{components:O,content:B,index:A,rehypePlugins:s,remarkPlugins:r,shouldParseIncompleteMarkdown:o,...g},D[A]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);In.displayName="Streamdown";var Et=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:s=.1,showControls:r=true,initialZoom:i=1,fullscreen:a=false})=>{let l=useRef(null),d=useRef(null),[m,c]=useState(i),[p,g]=useState({x:0,y:0}),[f,h]=useState(false),[w,v]=useState({x:0,y:0}),[N,P]=useState({x:0,y:0}),T=useCallback(y=>{c(x=>Math.max(o,Math.min(n,x+y)));},[o,n]),D=useCallback(()=>{T(s);},[T,s]),j=useCallback(()=>{T(-s);},[T,s]),O=useCallback(()=>{c(i),g({x:0,y:0});},[i]),B=useCallback(y=>{y.preventDefault();let x=y.deltaY>0?-s:s;T(x);},[T,s]),A=useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;h(true),v({x:y.clientX,y:y.clientY}),P(p);let x=y.currentTarget;x instanceof HTMLElement&&x.setPointerCapture(y.pointerId);},[p]),L=useCallback(y=>{if(!f)return;y.preventDefault();let x=y.clientX-w.x,S=y.clientY-w.y;g({x:N.x+x,y:N.y+S});},[f,w,N]),H=useCallback(y=>{h(false);let x=y.currentTarget;x instanceof HTMLElement&&x.releasePointerCapture(y.pointerId);},[]);return useEffect(()=>{let y=l.current;if(y)return y.addEventListener("wheel",B,{passive:false}),()=>{y.removeEventListener("wheel",B);}},[B]),useEffect(()=>{let y=d.current;if(y&&f)return document.body.style.userSelect="none",y.addEventListener("pointermove",L,{passive:false}),y.addEventListener("pointerup",H),y.addEventListener("pointercancel",H),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",L),y.removeEventListener("pointerup",H),y.removeEventListener("pointercancel",H);}},[f,L,H]),jsxs("div",{className:u("relative",a?"h-full w-full":"w-full",t),ref:l,style:{cursor:f?"grabbing":"grab"},children:[r&&jsxs("div",{className:u("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",a?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:m>=n,onClick:D,title:"Zoom in",type:"button",children:jsx(ZoomInIcon,{size:16})}),jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:m<=o,onClick:j,title:"Zoom out",type:"button",children:jsx(ZoomOutIcon,{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:O,title:"Reset zoom and pan",type:"button",children:jsx(RotateCcwIcon,{size:16})})]}),jsx("div",{className:u("origin-center transition-transform duration-150 ease-out",a&&"flex w-full items-center justify-center"),onPointerDown:A,ref:d,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${m})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var De=({chart:e,className:t,config:o,fullscreen:n=false,showControls:s=true})=>{let[r,i]=useState(null),[a,l]=useState(true),[d,m]=useState(""),[c,p]=useState(""),[g,f]=useState(0),{mermaid:h}=useContext(M),w=h==null?void 0:h.errorComponent;if(useEffect(()=>{(async()=>{try{i(null),l(!0);let P=await Q(o),T=e.split("").reduce((O,B)=>(O<<5)-O+B.charCodeAt(0)|0,0),D=`mermaid-${Math.abs(T)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:j}=await P.render(D,e);m(j),p(j);}catch(P){if(!(c||d)){let T=P instanceof Error?P.message:"Failed to render Mermaid chart";i(T);}}finally{l(false);}})();},[e,o,g]),a&&!d&&!c)return jsx("div",{className:u("my-4 flex justify-center p-4",t),children:jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!d&&!c){let N=()=>f(P=>P+1);return w?jsx(w,{chart:e,error:r,retry:N}):jsxs("div",{className:u("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),jsxs("details",{className:"mt-2",children:[jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let v=d||c;return jsx(Et,{className:u(n?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:s,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:u("flex justify-center",n&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:v},role:"img"})})};export{u as a,Ht as b,De as c,ve as d,Me as e,Mn as f,Pn as g,M as h,Bt as i,In as j};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk7N2FFGCA_cjs=require('./chunk-7N2FFGCA.cjs');Object.defineProperty(exports,"Mermaid",{enumerable:true,get:function(){return chunk7N2FFGCA_cjs.c}});
|
package/dist/mermaid-ZSTFYFNX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{c as Mermaid}from'./chunk-T7OEMACY.js';
|