@lofcz/streamdown 2.9.0 → 2.9.1

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.
@@ -1,17 +1,17 @@
1
1
  "use client";
2
- import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidElement,useId,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Bn from'rehype-raw';import gr,{defaultSchema}from'rehype-sanitize';import hi from'remark-gfm';import yi from'remend';import {visitParents,SKIP}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Sa from'remark-parse';import Ra from'remark-rehype';import {unified}from'unified';import {visit,SKIP as SKIP$1}from'unist-util-visit';import {Lexer}from'marked';var Mr=300,Ir="300px",Nr=500;function Qt(e={}){let{immediate:t=false,debounceDelay:o=Mr,rootMargin:n=Ir,idleTimeout:r=Nr}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),d=useRef(null),c=useMemo(()=>m=>{let g=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-g))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,g)=>window.requestIdleCallback(m,g):c,[c]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?m=>window.cancelIdleCallback(m):m=>{clearTimeout(m);},[]);return useEffect(()=>{if(t){a(true);return}let m=l.current;if(!m)return;i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);let g=()=>{i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);},f=x=>{d.current=p(h=>{h.timeRemaining()>0||h.didTimeout?(a(true),x.disconnect()):d.current=p(()=>{a(true),x.disconnect();},{timeout:r/2});},{timeout:r});},y=x=>{g(),i.current=window.setTimeout(()=>{var I,j;let h=x.takeRecords();(h.length===0||(j=(I=h.at(-1))==null?void 0:I.isIntersecting)!=null&&j)&&f(x);},o);},b=(x,h)=>{x.isIntersecting?y(h):g();},k=new IntersectionObserver(x=>{for(let h of x)b(h,k);},{rootMargin:n,threshold:0});return k.observe(m),()=>{i.current&&clearTimeout(i.current),d.current&&u(d.current),k.disconnect();}},[t,o,n,r,u,p]),{shouldRender:s,containerRef:l}}function bt(){return {current:0}}var to=/\s/,eo=/^\s+$/,Rr=new Set(["code","pre","svg","math","annotation"]),Er=new Set(["svg","math","annotation"]),Ar=new Set(["img","hr"]),Ae=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",oo=(e,t)=>{let o=t?Er:Rr;return e.some(n=>Ae(n)&&o.has(n.tagName))},Hr=e=>{for(let t=e.length-1;t>=0;t--){let o=e[t];if(Ae(o)&&o.tagName==="li")return o}},Dr=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${o}ms;--sd-marker-easing:${n}`;},Br=new Set(["ul","ol","li"]),no=e=>{for(let t of e.children)if(Ae(t)){if(t.tagName==="input")return t;if(Br.has(t.tagName))continue;let o=no(t);if(o)return o}},ro=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-animation:sd-${t.animation};--sd-duration:${o}ms;--sd-easing:${t.easing};--sd-delay:${n}ms`;},Or=(e,t,o,n)=>{let r=no(e);r&&ro(r,t,o,n);},Vr=(e,t,o,n,r)=>{if(oo(t,n.animateCodeBlocks))return;let s=n.prevContentLength,a=s>0&&r.count<s,l=a?0:(n.startIndex+r.newIndex++)*o.stagger;ro(e,o,a?0:o.duration,l);},_r=e=>{let t=[],o="",n=false;for(let r of e){let s=to.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},jr=e=>{let t=[],o="";for(let n of e)to.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Fr=(e,t,o,n,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;return s&&(a+=`;--sd-delay:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},zr=(e,t,o,n,r)=>{var b;let s=t.at(-1);if(!(s&&"children"in s))return;if(oo(t,n.animateCodeBlocks))return SKIP;let a=s,l=a.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let d=o.sep==="char"?jr(i):_r(i),c=t.some(k=>Ae(k)&&k.tagName==="a"),p=d;if(o.sep==="word"&&c){let k=[];for(let x of d)eo.test(x)&&k.length>0?k[k.length-1]+=x:k.push(x);p=k;}let u=n.prevContentLength,m=Hr(t),g=!!(m&&!((b=m.properties)!=null&&b["data-sd-animate-marker"])),f=false,y=p.map(k=>{let x=r.count;if(r.count+=k.length,eo.test(k))return {type:"text",value:k};let h=u>0&&x<u,M=h?0:(n.startIndex+r.newIndex++)*o.stagger;if(m&&g&&!f){let I=h?0:o.duration;Dr(m,I,M,o.easing),Or(m,o,I,M),f=true;}return Fr(k,o.animation,o.duration,o.easing,h,M)});return a.children.splice(l,1,...y),l+y.length},$r=0;function He(e){var s,a,l,i,d;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",cursor:e==null?void 0:e.cursor,duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(d=e==null?void 0:e.stagger)!=null?d:40},o={animateCodeBlocks:false,prevContentLength:0,lastRenderCharCount:0,lastRenderNewWordCount:0,startIndex:0},n=$r++,r=()=>c=>{let p={count:0,newIndex:0};t.cursor&&(o.startIndex=t.cursor.current),visitParents(c,u=>u.type==="text"||Ae(u)&&Ar.has(u.tagName),(u,m)=>{if(u.type==="text")return zr(u,m,t,o,p);Vr(u,m,t,o,p);}),o.lastRenderCharCount=p.count,o.lastRenderNewWordCount=p.newIndex,t.cursor&&(t.cursor.current+=p.newIndex),o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(c){o.animateCodeBlocks=c;},setPrevContentLength(c){o.prevContentLength=c;},setStartIndex(c){o.startIndex=c;},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c},getLastRenderNewWordCount(){let c=o.lastRenderNewWordCount;return o.lastRenderNewWordCount=0,c}}}He();var ht=createContext(false),yt=()=>useContext(ht);var De=(...e)=>twMerge(clsx(e)),Ke=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},Zr=(e,t)=>{if(!e||!t)return t;let o=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(o)?n:`${e}:${n}`).join(" ")},io=e=>e?(...t)=>Zr(e,twMerge(clsx(t))):De,oe=(e,t,o)=>{let n=typeof t=="string"&&o.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([n+t],{type:o}):t,s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s);};var Xe=createContext(De),w=()=>useContext(Xe);var Jr=De("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Yr=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),s=o.slice(n+1).trim();r&&s&&(t[r]=s);}}return t},mo=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=w(),{isAnimating:d}=useContext(L),c=useRef(null),p=useRef(true),u=Ke(r);useEffect(()=>{let f=c.current;if(!(f&&u))return;let y=()=>{let b=f.scrollHeight-f.scrollTop-f.clientHeight<8;p.current=b;};return f.addEventListener("scroll",y,{passive:true}),()=>f.removeEventListener("scroll",y)},[u]),useEffect(()=>{let f=c.current;f&&u&&d&&p.current&&f.scrollTo({top:f.scrollHeight,behavior:"instant"});},[d,u]),useEffect(()=>{d||(p.current=true);},[d]);let m=useMemo(()=>i(Jr),[i]),g=useMemo(()=>{let f={};return t.bg&&(f["--sdm-bg"]=t.bg),t.fg&&(f["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(f,Yr(t.rootStyle)),f},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:i(n,u?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",ref:c,style:u?{maxHeight:u}:void 0,...l,children:jsx("pre",{className:i(n,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:g,children:jsx("code",{className:a?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((f,y)=>jsx("span",{className:a?m:void 0,children:f.length===0||f.length===1&&f[0].content===""?`
3
- `:f.map((b,k)=>{let x={},h=!!b.bgColor;if(b.color&&(x["--sdm-c"]=b.color),b.bgColor&&(x["--sdm-tbg"]=b.bgColor),b.htmlStyle)for(let[M,I]of Object.entries(b.htmlStyle))M==="color"?x["--sdm-c"]=I:M==="background-color"?(x["--sdm-tbg"]=I,h=true):x[M]=I;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",h&&"bg-[var(--sdm-tbg)]",h&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:x,...b.htmlAttrs,children:b.content},k)})},y))})})})},(e,t)=>e.maxHeight===t.maxHeight&&e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var Ct=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=w();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var kt=createContext({code:""}),Ge=()=>useContext(kt);var xt=({language:e})=>{let t=w();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var ss=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
- `;)t--;return e.slice(0,t)},as=lazy(()=>import('./highlighted-body-7HCBLPPD.js').then(e=>({default:e.HighlightedCodeBlockBody}))),vt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=w(),{codeBlockMaxHeight:d}=useContext(L),c=useMemo(()=>ss(e),[e]),p=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:c.split(`
5
- `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[c]);return jsx(kt.Provider,{value:{code:e},children:jsxs(Ct,{isIncomplete:r,language:t,children:[jsx(xt,{language:t}),n?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,jsx(Suspense,{fallback:jsx(mo,{className:o,language:t,lineNumbers:a,maxHeight:d,result:p,startLine:s,...l}),children:jsx(as,{className:o,code:c,language:t,lineNumbers:a,maxHeight:d,raw:p,startLine:s,...l})})]})})};var fo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),go=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),bo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),ho=e=>jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),yo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),wo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Co=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),ko=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),xo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),vo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var Oe={CheckIcon:fo,CopyIcon:go,DownloadIcon:bo,ExternalLinkIcon:ko,Loader2Icon:ho,Maximize2Icon:yo,RotateCcwIcon:wo,XIcon:Co,ZoomInIcon:xo,ZoomOutIcon:vo},Po=createContext(Oe),ms=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},Tt=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...Oe,...e}:Oe);ms(o.current,e)||(o.current=e,n.current=e?{...Oe,...e}:Oe);let r=n.current;return jsx(Po.Provider,{value:r,children:t})},D=()=>useContext(Po);var Ue={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},Je=createContext(Ue),O=()=>useContext(Je);var Ye=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=w(),[i,d]=useState(false),c=useRef(0),{code:p}=Ge(),{isAnimating:u}=useContext(L),m=O(),g=s!=null?s:p,f=async()=>{var k;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(g),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),o));}catch(x){t==null||t(x);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let y=D(),b=i?y.CheckIcon:y.CopyIcon;return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:m.copyCode,type:"button",...a,children:n!=null?n:jsx(b,{size:14})})};var Io={"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"},Pt=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=w(),{code:i}=Ge(),{isAnimating:d}=useContext(L),c=O(),p=D(),u=s!=null?s:i,g=`file.${o&&o in Io?Io[o]:"txt"}`,f="text/plain",y=()=>{try{oe(g,u,f),e==null||e();}catch(b){t==null||t(b);}};return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:d,onClick:y,title:c.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var Qe=()=>{let{Loader2Icon:e}=D(),t=w();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var Ve=0,ue=()=>{Ve+=1,Ve===1&&(document.body.style.overflow="hidden");},pe=()=>{Ve=Math.max(0,Ve-1),Ve===0&&(document.body.style.overflow="");};var xs=["github-light","github-dark"],vs={enabled:true},Ts={codeBlockMaxHeight:400,shikiTheme:xs,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:vs,tableMaxHeight:300},L=createContext(Ts);var Ns=/\.[^/.]+$/,So=(e,t)=>{if(typeof e=="boolean")return e;let o=e.image;return o===false?false:o===true||o===void 0?true:o[t]!==false},Ro=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i,XIcon:d}=D(),c=w(),p=useRef(null),[u,m]=useState(false),[g,f]=useState(false),[y,b]=useState(false),{controls:k}=useContext(L),x=O(),h=So(k,"download"),M=So(k,"fullscreen"),I=l.width!=null||l.height!=null,j=h&&(u||I)&&!g,B=g&&!I,S=M&&!!o&&!g&&u;useEffect(()=>{let N=p.current;if(N!=null&&N.complete){let te=N.naturalWidth>0;m(te),f(!te);}},[]),useEffect(()=>{if(!y)return;ue();let N=te=>{te.key==="Escape"&&b(false);};return document.addEventListener("keydown",N),()=>{document.removeEventListener("keydown",N),pe();}},[y]);let _=useCallback(N=>{m(true),f(false),r==null||r(N);},[r]),Q=useCallback(N=>{m(false),f(true),s==null||s(N);},[s]),F=useCallback(()=>{S&&b(true);},[S]),q=useCallback(()=>{b(false);},[]),ee=useCallback(N=>{a==null||a(N),!N.defaultPrevented&&F();},[a,F]),U=async N=>{if(N.stopPropagation(),!!o)try{let J=await(await fetch(o)).blob(),Z=new URL(o,window.location.origin).pathname.split("/").pop()||"",ye=Z.split(".").pop(),re=Z.includes(".")&&ye!==void 0&&ye.length<=4,V="";if(re)V=Z;else {let T=J.type,R="png";T.includes("jpeg")||T.includes("jpg")?R="jpg":T.includes("png")?R="png":T.includes("svg")?R="svg":T.includes("gif")?R="gif":T.includes("webp")&&(R="webp"),V=`${(n||Z||"image").replace(Ns,"")}.${R}`;}oe(V,J,J.type);}catch(te){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:c("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:c("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:c("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:c("m-0 block h-auto max-w-full rounded-lg",S&&"cursor-zoom-in",B&&"hidden",t),"data-streamdown":"image",onClick:ee,onError:Q,onLoad:_,ref:p,src:o,...l}),B&&jsx("span",{className:c("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:x.imageNotAvailable}),j&&jsx("button",{className:c("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 focus-visible:opacity-100 group-hover/image:opacity-100"),onClick:U,title:x.downloadImage,type:"button",children:jsx(i,{size:14})})]}),y?createPortal(jsxs("div",{className:c("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:q,onKeyDown:N=>{N.key==="Escape"&&q();},role:"button",tabIndex:0,children:[jsx("button",{className:c("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:q,title:x.exitFullscreen,type:"button",children:jsx(d,{size:20})}),jsx("div",{onClick:N=>N.stopPropagation(),onKeyDown:N=>N.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:c("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var Ho=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=D(),i=w(),[d,c]=useState(false),p=O(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3);}catch(f){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){ue();let f=y=>{y.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),pe();}}},[t,o]),!t||typeof document=="undefined")return null;let g=jsx("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:f=>{f.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:i("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[jsx("button",{className:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:p.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i("flex flex-col gap-2"),children:[jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:i("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i("flex gap-2"),children:[jsx("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:u,type:"button",children:d?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:m,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:p.openLink})]})]})]})});return createPortal(g,document.body)};var et=createContext(null),Lt=()=>useContext(et),uc=()=>{var t;let e=Lt();return (t=e==null?void 0:e.code)!=null?t:null},Ie=()=>{var t;let e=Lt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Do=e=>{var o;let t=Lt();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var Ds=/(<svg\b)/,Vo=/<svg\b[^>]*>/i,Bs=/\bviewBox=(['"])(.*?)\1/i,Os=/\swidth=(['"]).*?\1/i,Vs=/\sheight=(['"]).*?\1/i,Bo=/\sstyle=(['"])(.*?)\1/i,Oo=/^<svg/i,_s=/^width\s*:/i,js=/^height\s*:/i,Fs=/^max-width\s*:/i,zs=/[\s,]+/,$s=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Ds,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),_o=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let o=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return o?new XMLSerializer().serializeToString(o):e},St=e=>{let t=e.match(Vo);if(!t)return null;let n=t[0].match(Bs),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(zs).map(i=>Number.parseFloat(i));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],l=s[3];return a>0&&l>0?{height:l,width:a}:null},jo=e=>{let t=e.match(Vo);if(!t)return e;try{let o=t[0],n=St(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(Os,"").replace(Vs,""),l=a.match(Bo),i=`width:${r}px;height:${s}px;max-width:none;`;if(l){let d=l[1],p=l[2].split(";").map(m=>m.trim()).filter(Boolean).filter(m=>!(_s.test(m)||js.test(m)||Fs.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;a=a.replace(Bo,` style=${d}${u}${d}`);}else a=a.replace(Oo,`<svg style="${i}"`);return a=a.replace(Oo,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Fo=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=$s(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let d=document.createElement("canvas"),c=i.width*o,p=i.height*o;d.width=c,d.height=p;let u=d.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,c,p),d.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=l;})};var tt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=w(),[l,i]=useState(false),d=useRef(null),{isAnimating:c}=useContext(L),p=D(),u=Ie(),m=O(),g=async f=>{try{if(f==="mmd"){oe("diagram.mmd",e,"text/plain"),i(!1),n==null||n(f);return}if(!u){s==null||s(new Error("Mermaid plugin not available"));return}let y=u.getMermaid(r),b=e.split("").reduce((M,I)=>(M<<5)-M+I.charCodeAt(0)|0,0),k=`mermaid-${Math.abs(b)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:x}=await y.render(k,e);if(!x){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let h=_o(x);if(f==="svg"){oe("diagram.svg",h,"image/svg+xml"),i(!1),n==null||n(f);return}if(f==="png"){let M=await Fo(h);oe("diagram.png",M,"image/png"),n==null||n(f),i(!1);return}}catch(y){s==null||s(y);}};return useEffect(()=>{let f=y=>{let b=y.composedPath();d.current&&!b.includes(d.current)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:a("relative"),ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:c,onClick:()=>i(!l),title:m.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var qo=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=D(),i=w(),[d,c]=useState(false),{isAnimating:p,controls:u}=useContext(L),m=O(),g=(()=>{if(typeof u=="boolean")return u;let b=u.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),f=(()=>{if(typeof u=="boolean")return u;let b=u.mermaid;return b===false?false:b===true||b===void 0?true:b.download!==false})(),y=()=>{c(!d);};return useEffect(()=>{if(d){ue();let b=k=>{k.key==="Escape"&&c(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),pe();}}},[d]),useEffect(()=>{d?o==null||o():n&&n();},[d,o,n]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:y,title:m.viewFullscreen,type:"button",...s,children:jsx(a,{size:14})}),d?createPortal(jsxs("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:y,onKeyDown:b=>{b.key==="Escape"&&y();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[f?jsx(tt,{chart:e,config:t}):null,jsx("button",{className:i("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:y,title:m.exitFullscreen,type:"button",children:jsx(l,{size:20})})]}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(Wo,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:g})})]}),document.body):null]})};var Ne=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let l of n)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],d=l.querySelectorAll("td");for(let c of d)i.push(((a=c.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},ve=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,d=false;for(let c of l){if(c==='"'){i=true,d=true;break}(c===","||c===`
2
+ import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidElement,useId,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Bn from'rehype-raw';import gr,{defaultSchema}from'rehype-sanitize';import bi from'remark-gfm';import yi from'remend';import {visitParents,SKIP}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Ra from'remark-parse';import Sa from'remark-rehype';import {unified}from'unified';import {visit,SKIP as SKIP$1}from'unist-util-visit';import {Lexer}from'marked';var Mr=300,Ir="300px",Lr=500;function Qt(e={}){let{immediate:t=false,debounceDelay:o=Mr,rootMargin:n=Ir,idleTimeout:r=Lr}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),d=useRef(null),c=useMemo(()=>m=>{let g=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-g))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,g)=>window.requestIdleCallback(m,g):c,[c]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?m=>window.cancelIdleCallback(m):m=>{clearTimeout(m);},[]);return useEffect(()=>{if(t){a(true);return}let m=l.current;if(!m)return;i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);let g=()=>{i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);},f=x=>{d.current=p(b=>{b.timeRemaining()>0||b.didTimeout?(a(true),x.disconnect()):d.current=p(()=>{a(true),x.disconnect();},{timeout:r/2});},{timeout:r});},y=x=>{g(),i.current=window.setTimeout(()=>{var I,j;let b=x.takeRecords();(b.length===0||(j=(I=b.at(-1))==null?void 0:I.isIntersecting)!=null&&j)&&f(x);},o);},h=(x,b)=>{x.isIntersecting?y(b):g();},k=new IntersectionObserver(x=>{for(let b of x)h(b,k);},{rootMargin:n,threshold:0});return k.observe(m),()=>{i.current&&clearTimeout(i.current),d.current&&u(d.current),k.disconnect();}},[t,o,n,r,u,p]),{shouldRender:s,containerRef:l}}function ht(){return {current:0}}var to=/\s/,eo=/^\s+$/,Sr=new Set(["code","pre","svg","math","annotation"]),Er=new Set(["svg","math","annotation"]),Ar=new Set(["img","hr"]),Ae=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",oo=(e,t)=>{let o=t?Er:Sr;return e.some(n=>Ae(n)&&o.has(n.tagName))},Hr=e=>{for(let t=e.length-1;t>=0;t--){let o=e[t];if(Ae(o)&&o.tagName==="li")return o}},Dr=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${o}ms;--sd-marker-easing:${n}`;},Br=new Set(["ul","ol","li"]),no=e=>{for(let t of e.children)if(Ae(t)){if(t.tagName==="input")return t;if(Br.has(t.tagName))continue;let o=no(t);if(o)return o}},ro=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-animation:sd-${t.animation};--sd-duration:${o}ms;--sd-easing:${t.easing};--sd-delay:${n}ms`;},Or=(e,t,o,n)=>{let r=no(e);r&&ro(r,t,o,n);},Vr=(e,t,o,n,r)=>{if(oo(t,n.animateCodeBlocks))return;let s=n.prevContentLength,a=s>0&&r.count<s,l=a?0:(n.startIndex+r.newIndex++)*o.stagger;ro(e,o,a?0:o.duration,l);},_r=e=>{let t=[],o="",n=false;for(let r of e){let s=to.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},jr=e=>{let t=[],o="";for(let n of e)to.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Fr=(e,t,o,n,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;return s&&(a+=`;--sd-delay:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},zr=(e,t,o,n,r)=>{var h;let s=t.at(-1);if(!(s&&"children"in s))return;if(oo(t,n.animateCodeBlocks))return SKIP;let a=s,l=a.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let d=o.sep==="char"?jr(i):_r(i),c=t.some(k=>Ae(k)&&k.tagName==="a"),p=d;if(o.sep==="word"&&c){let k=[];for(let x of d)eo.test(x)&&k.length>0?k[k.length-1]+=x:k.push(x);p=k;}let u=n.prevContentLength,m=Hr(t),g=!!(m&&!((h=m.properties)!=null&&h["data-sd-animate-marker"])),f=false,y=p.map(k=>{let x=r.count;if(r.count+=k.length,eo.test(k))return {type:"text",value:k};let b=u>0&&x<u,M=b?0:(n.startIndex+r.newIndex++)*o.stagger;if(m&&g&&!f){let I=b?0:o.duration;Dr(m,I,M,o.easing),Or(m,o,I,M),f=true;}return Fr(k,o.animation,o.duration,o.easing,b,M)});return a.children.splice(l,1,...y),l+y.length},$r=0;function He(e){var s,a,l,i,d;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",cursor:e==null?void 0:e.cursor,duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(d=e==null?void 0:e.stagger)!=null?d:40},o={animateCodeBlocks:false,prevContentLength:0,lastRenderCharCount:0,lastRenderNewWordCount:0,startIndex:0},n=$r++,r=()=>c=>{let p={count:0,newIndex:0};t.cursor&&(o.startIndex=t.cursor.current),visitParents(c,u=>u.type==="text"||Ae(u)&&Ar.has(u.tagName),(u,m)=>{if(u.type==="text")return zr(u,m,t,o,p);Vr(u,m,t,o,p);}),o.lastRenderCharCount=p.count,o.lastRenderNewWordCount=p.newIndex,t.cursor&&(t.cursor.current+=p.newIndex),o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(c){o.animateCodeBlocks=c;},setPrevContentLength(c){o.prevContentLength=c;},setStartIndex(c){o.startIndex=c;},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c},getLastRenderNewWordCount(){let c=o.lastRenderNewWordCount;return o.lastRenderNewWordCount=0,c}}}He();var bt=createContext(false),yt=()=>useContext(bt);var De=(...e)=>twMerge(clsx(e)),Ke=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},Zr=(e,t)=>{if(!e||!t)return t;let o=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(o)?n:`${e}:${n}`).join(" ")},io=e=>e?(...t)=>Zr(e,twMerge(clsx(t))):De,oe=(e,t,o)=>{let n=typeof t=="string"&&o.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([n+t],{type:o}):t,s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s);};var Xe=createContext(De),w=()=>useContext(Xe);var Jr=De("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Yr=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),s=o.slice(n+1).trim();r&&s&&(t[r]=s);}}return t},mo=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=w(),{isAnimating:d}=useContext(N),c=useRef(null),p=useRef(true),u=Ke(r);useEffect(()=>{let f=c.current;if(!(f&&u))return;let y=()=>{let h=f.scrollHeight-f.scrollTop-f.clientHeight<8;p.current=h;};return f.addEventListener("scroll",y,{passive:true}),()=>f.removeEventListener("scroll",y)},[u]),useEffect(()=>{let f=c.current;f&&u&&d&&p.current&&f.scrollTo({top:f.scrollHeight,behavior:"instant"});},[d,u]),useEffect(()=>{d||(p.current=true);},[d]);let m=useMemo(()=>i(Jr),[i]),g=useMemo(()=>{let f={};return t.bg&&(f["--sdm-bg"]=t.bg),t.fg&&(f["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(f,Yr(t.rootStyle)),f},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:i(n,u?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",ref:c,style:u?{maxHeight:u}:void 0,...l,children:jsx("pre",{className:i(n,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:g,children:jsx("code",{className:a?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((f,y)=>jsx("span",{className:a?m:void 0,children:f.length===0||f.length===1&&f[0].content===""?`
3
+ `:f.map((h,k)=>{let x={},b=!!h.bgColor;if(h.color&&(x["--sdm-c"]=h.color),h.bgColor&&(x["--sdm-tbg"]=h.bgColor),h.htmlStyle)for(let[M,I]of Object.entries(h.htmlStyle))M==="color"?x["--sdm-c"]=I:M==="background-color"?(x["--sdm-tbg"]=I,b=true):x[M]=I;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",b&&"bg-[var(--sdm-tbg)]",b&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:x,...h.htmlAttrs,children:h.content},k)})},y))})})})},(e,t)=>e.maxHeight===t.maxHeight&&e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var Ct=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=w();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var kt=createContext({code:""}),Ge=()=>useContext(kt);var xt=({language:e})=>{let t=w();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var ss=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
+ `;)t--;return e.slice(0,t)},as=lazy(()=>import('./highlighted-body-33HEA3YT.js').then(e=>({default:e.HighlightedCodeBlockBody}))),vt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=w(),{codeBlockMaxHeight:d}=useContext(N),c=useMemo(()=>ss(e),[e]),p=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:c.split(`
5
+ `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[c]);return jsx(kt.Provider,{value:{code:e},children:jsxs(Ct,{isIncomplete:r,language:t,children:[jsx(xt,{language:t}),n?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,jsx(Suspense,{fallback:jsx(mo,{className:o,language:t,lineNumbers:a,maxHeight:d,result:p,startLine:s,...l}),children:jsx(as,{className:o,code:c,language:t,lineNumbers:a,maxHeight:d,raw:p,startLine:s,...l})})]})})};var fo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),go=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),ho=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),bo=e=>jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),yo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),wo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Co=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),ko=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),xo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),vo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var Oe={CheckIcon:fo,CopyIcon:go,DownloadIcon:ho,ExternalLinkIcon:ko,Loader2Icon:bo,Maximize2Icon:yo,RotateCcwIcon:wo,XIcon:Co,ZoomInIcon:xo,ZoomOutIcon:vo},Po=createContext(Oe),ms=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},Tt=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...Oe,...e}:Oe);ms(o.current,e)||(o.current=e,n.current=e?{...Oe,...e}:Oe);let r=n.current;return jsx(Po.Provider,{value:r,children:t})},D=()=>useContext(Po);var Ue={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},Je=createContext(Ue),O=()=>useContext(Je);var Ye=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=w(),[i,d]=useState(false),c=useRef(0),{code:p}=Ge(),{isAnimating:u}=useContext(N),m=O(),g=s!=null?s:p,f=async()=>{var k;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(g),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),o));}catch(x){t==null||t(x);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let y=D(),h=i?y.CheckIcon:y.CopyIcon;return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:m.copyCode,type:"button",...a,children:n!=null?n:jsx(h,{size:14})})};var Io={"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"},Pt=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=w(),{code:i}=Ge(),{isAnimating:d}=useContext(N),c=O(),p=D(),u=s!=null?s:i,g=`file.${o&&o in Io?Io[o]:"txt"}`,f="text/plain",y=()=>{try{oe(g,u,f),e==null||e();}catch(h){t==null||t(h);}};return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:d,onClick:y,title:c.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var Qe=()=>{let{Loader2Icon:e}=D(),t=w();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var Ve=0,ue=()=>{Ve+=1,Ve===1&&(document.body.style.overflow="hidden");},pe=()=>{Ve=Math.max(0,Ve-1),Ve===0&&(document.body.style.overflow="");};var xs=["github-light","github-dark"],vs={enabled:true},Ts={codeBlockMaxHeight:400,shikiTheme:xs,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:vs,tableMaxHeight:300},N=createContext(Ts);var Ls=/\.[^/.]+$/,Ro=(e,t)=>{if(typeof e=="boolean")return e;let o=e.image;return o===false?false:o===true||o===void 0?true:o[t]!==false},So=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i,XIcon:d}=D(),c=w(),p=useRef(null),[u,m]=useState(false),[g,f]=useState(false),[y,h]=useState(false),{controls:k}=useContext(N),x=O(),b=Ro(k,"download"),M=Ro(k,"fullscreen"),I=l.width!=null||l.height!=null,j=b&&(u||I)&&!g,B=g&&!I,R=M&&!!o&&!g&&u;useEffect(()=>{let L=p.current;if(L!=null&&L.complete){let te=L.naturalWidth>0;m(te),f(!te);}},[]),useEffect(()=>{if(!y)return;ue();let L=te=>{te.key==="Escape"&&h(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),pe();}},[y]);let _=useCallback(L=>{m(true),f(false),r==null||r(L);},[r]),Q=useCallback(L=>{m(false),f(true),s==null||s(L);},[s]),F=useCallback(()=>{R&&h(true);},[R]),q=useCallback(()=>{h(false);},[]),ee=useCallback(L=>{a==null||a(L),!L.defaultPrevented&&F();},[a,F]),U=async L=>{if(L.stopPropagation(),!!o)try{let J=await(await fetch(o)).blob(),Z=new URL(o,window.location.origin).pathname.split("/").pop()||"",ye=Z.split(".").pop(),re=Z.includes(".")&&ye!==void 0&&ye.length<=4,V="";if(re)V=Z;else {let T=J.type,S="png";T.includes("jpeg")||T.includes("jpg")?S="jpg":T.includes("png")?S="png":T.includes("svg")?S="svg":T.includes("gif")?S="gif":T.includes("webp")&&(S="webp"),V=`${(n||Z||"image").replace(Ls,"")}.${S}`;}oe(V,J,J.type);}catch(te){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:c("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:c("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:c("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:c("m-0 block h-auto max-w-full rounded-lg",R&&"cursor-zoom-in",B&&"hidden",t),"data-streamdown":"image",onClick:ee,onError:Q,onLoad:_,ref:p,src:o,...l}),B&&jsx("span",{className:c("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:x.imageNotAvailable}),j&&jsx("button",{className:c("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 focus-visible:opacity-100 group-hover/image:opacity-100"),onClick:U,title:x.downloadImage,type:"button",children:jsx(i,{size:14})})]}),y?createPortal(jsxs("div",{className:c("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:q,onKeyDown:L=>{L.key==="Escape"&&q();},role:"button",tabIndex:0,children:[jsx("button",{className:c("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:q,title:x.exitFullscreen,type:"button",children:jsx(d,{size:20})}),jsx("div",{onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:c("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var Ho=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=D(),i=w(),[d,c]=useState(false),p=O(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3);}catch(f){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){ue();let f=y=>{y.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),pe();}}},[t,o]),!t||typeof document=="undefined")return null;let g=jsx("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:f=>{f.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:i("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[jsx("button",{className:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:p.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i("flex flex-col gap-2"),children:[jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:i("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i("flex gap-2"),children:[jsx("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:u,type:"button",children:d?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:m,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:p.openLink})]})]})]})});return createPortal(g,document.body)};var et=createContext(null),Nt=()=>useContext(et),uc=()=>{var t;let e=Nt();return (t=e==null?void 0:e.code)!=null?t:null},Ie=()=>{var t;let e=Nt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Do=e=>{var o;let t=Nt();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var Ds=/(<svg\b)/,Vo=/<svg\b[^>]*>/i,Bs=/\bviewBox=(['"])(.*?)\1/i,Os=/\swidth=(['"]).*?\1/i,Vs=/\sheight=(['"]).*?\1/i,Bo=/\sstyle=(['"])(.*?)\1/i,Oo=/^<svg/i,_s=/^width\s*:/i,js=/^height\s*:/i,Fs=/^max-width\s*:/i,zs=/[\s,]+/,$s=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Ds,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),_o=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let o=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return o?new XMLSerializer().serializeToString(o):e},Rt=e=>{let t=e.match(Vo);if(!t)return null;let n=t[0].match(Bs),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(zs).map(i=>Number.parseFloat(i));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],l=s[3];return a>0&&l>0?{height:l,width:a}:null},jo=e=>{let t=e.match(Vo);if(!t)return e;try{let o=t[0],n=Rt(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(Os,"").replace(Vs,""),l=a.match(Bo),i=`width:${r}px;height:${s}px;max-width:none;`;if(l){let d=l[1],p=l[2].split(";").map(m=>m.trim()).filter(Boolean).filter(m=>!(_s.test(m)||js.test(m)||Fs.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;a=a.replace(Bo,` style=${d}${u}${d}`);}else a=a.replace(Oo,`<svg style="${i}"`);return a=a.replace(Oo,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Fo=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=$s(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let d=document.createElement("canvas"),c=i.width*o,p=i.height*o;d.width=c,d.height=p;let u=d.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,c,p),d.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=l;})};var tt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=w(),[l,i]=useState(false),d=useRef(null),{isAnimating:c}=useContext(N),p=D(),u=Ie(),m=O(),g=async f=>{try{if(f==="mmd"){oe("diagram.mmd",e,"text/plain"),i(!1),n==null||n(f);return}if(!u){s==null||s(new Error("Mermaid plugin not available"));return}let y=u.getMermaid(r),h=e.split("").reduce((M,I)=>(M<<5)-M+I.charCodeAt(0)|0,0),k=`mermaid-${Math.abs(h)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:x}=await y.render(k,e);if(!x){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let b=_o(x);if(f==="svg"){oe("diagram.svg",b,"image/svg+xml"),i(!1),n==null||n(f);return}if(f==="png"){let M=await Fo(b);oe("diagram.png",M,"image/png"),n==null||n(f),i(!1);return}}catch(y){s==null||s(y);}};return useEffect(()=>{let f=y=>{let h=y.composedPath();d.current&&!h.includes(d.current)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:a("relative"),ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:c,onClick:()=>i(!l),title:m.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var qo=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=D(),i=w(),[d,c]=useState(false),{isAnimating:p,controls:u}=useContext(N),m=O(),g=(()=>{if(typeof u=="boolean")return u;let h=u.mermaid;return h===false?false:h===true||h===void 0?true:h.panZoom!==false})(),f=(()=>{if(typeof u=="boolean")return u;let h=u.mermaid;return h===false?false:h===true||h===void 0?true:h.download!==false})(),y=()=>{c(!d);};return useEffect(()=>{if(d){ue();let h=k=>{k.key==="Escape"&&c(false);};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),pe();}}},[d]),useEffect(()=>{d?o==null||o():n&&n();},[d,o,n]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:y,title:m.viewFullscreen,type:"button",...s,children:jsx(a,{size:14})}),d?createPortal(jsxs("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:y,onKeyDown:h=>{h.key==="Escape"&&y();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:[f?jsx(tt,{chart:e,config:t}):null,jsx("button",{className:i("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:y,title:m.exitFullscreen,type:"button",children:jsx(l,{size:20})})]}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:jsx(Wo,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:g})})]}),document.body):null]})};var Le=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let l of n)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],d=l.querySelectorAll("td");for(let c of d)i.push(((a=c.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},ve=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,d=false;for(let c of l){if(c==='"'){i=true,d=true;break}(c===","||c===`
6
6
  `)&&(i=true);}return i?d?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let l of o)s[a]=l.map(n).join(","),a+=1;return s.join(`
7
7
  `)},Et=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let c of l)if(c===" "||c===`
8
8
  `||c==="\r"){i=true;break}if(!i)return l;let d=[];for(let c of l)c===" "?d.push("\\t"):c===`
9
9
  `?d.push("\\n"):c==="\r"?d.push("\\r"):d.push(c);return d.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let l of o)s[a]=l.map(n).join(" "),a+=1;return s.join(`
10
10
  `)},ot=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):o.push(n);return o.join("")},Te=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(l=>ot(l));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let d=0;d<t.length;d+=1)i[d]=d<l.length?ot(l[d]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(d=>ot(d));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
11
- `)};var ze=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=w(),[a,l]=useState(false),[i,d]=useState(false),c=useRef(null),p=useRef(0),{isAnimating:u}=useContext(L),m=O(),g=async b=>{var k,x;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.write)){n==null||n(new Error("Clipboard API not available"));return}try{let h=(x=c.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),M=h==null?void 0:h.querySelector("table");if(!M){n==null||n(new Error("Table not found"));return}let I=Ne(M),S=({csv:ve,tsv:Et,md:Te}[b]||Te)(I),_=new ClipboardItem({"text/plain":new Blob([S],{type:"text/plain"}),"text/html":new Blob([M.outerHTML],{type:"text/html"})});await navigator.clipboard.write([_]),d(!0),l(!1),o==null||o(b),p.current=window.setTimeout(()=>d(!1),r);}catch(h){n==null||n(h);}};useEffect(()=>{let b=k=>{let x=k.composedPath();c.current&&!x.includes(c.current)&&l(false);};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b),window.clearTimeout(p.current);}},[]);let f=D(),y=i?f.CheckIcon:f.CopyIcon;return jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>l(!a),title:m.copyTable,type:"button",children:e!=null?e:jsx(y,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("md"),title:m.copyTableAsMarkdown,type:"button",children:m.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:m.copyTableAsCsv,type:"button",children:m.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var na=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=w(),{isAnimating:l}=useContext(L),i=O(),d=D(),c=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=m==null?void 0:m.querySelector("table");if(!g){n==null||n(new Error("Table not found"));return}let f=Ne(g),y="",b="",k="";switch(r){case "csv":y=ve(f),b="text/csv",k="csv";break;case "markdown":y=Te(f),b="text/markdown",k="md";break;default:y=ve(f),b="text/csv",k="csv";}oe(`${s||"table"}.${k}`,y,b),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:c,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})})},$e=({children:e,className:t,onDownload:o,onError:n})=>{let r=w(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(L),d=O(),c=D(),p=u=>{var m;try{let g=(m=l.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=g==null?void 0:g.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let y=Ne(f),b=u==="csv"?ve(y):Te(y);oe(`table.${u==="csv"?"csv":"md"}`,b,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(g){n==null||n(g);}};return useEffect(()=>{let u=m=>{let g=m.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>a(!s),title:d.downloadTable,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("csv"),title:d.downloadTableAsCsv,type:"button",children:d.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("markdown"),title:d.downloadTableAsMarkdown,type:"button",children:d.tableFormatMarkdown})]}):null]})};var Jo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=D(),a=w(),[l,i]=useState(false),{isAnimating:d}=useContext(L),c=O(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){ue();let m=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),pe();}}},[l]),jsxs(Fragment,{children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:d,onClick:p,title:c.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":c.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:u,onKeyDown:m=>{m.key==="Escape"&&u();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(ze,{}):null,n?jsx($e,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:c.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var en=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=w(),{isAnimating:d}=useContext(L),c=useRef(null),p=useRef(true),u=Ke(o);useEffect(()=>{let b=c.current;if(!(b&&u))return;let k=()=>{let x=b.scrollHeight-b.scrollTop-b.clientHeight<8;p.current=x;};return b.addEventListener("scroll",k,{passive:true}),()=>b.removeEventListener("scroll",k)},[u]),useEffect(()=>{let b=c.current;b&&u&&d&&p.current&&b.scrollTo({top:b.scrollHeight,behavior:"instant"});}),useEffect(()=>{d||(p.current=true);},[d]);let m=n&&r,g=n&&s,f=n&&a,y=m||g||f;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[y?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[m?jsx(ze,{}):null,g?jsx($e,{}):null,f?jsx(Jo,{showCopy:m,showDownload:g,children:e}):null]}):null,jsx("div",{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),ref:c,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:i("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var fa=/startLine=(\d+)/,ga=/\bnoLineNumbers\b/,ba=lazy(()=>import('./mermaid-36ZAAFZN.js').then(e=>({default:e.Mermaid}))),ha=/language-([^\s]+)/;function at(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(o==null?void 0:o.offset)===(n==null?void 0:n.offset)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)&&(r==null?void 0:r.offset)===(s==null?void 0:s.offset)}function H(e,t){return e.className===t.className&&at(e.node,t.node)}var Ot=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Bt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},on=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},nt=(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},qe=createContext({depth:0,ulDepth:0,isUnordered:false}),ya={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Vt=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:s,ulDepth:a}=useContext(qe),l=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...n,children:jsx(qe.Provider,{value:l,children:e})})},(e,t)=>H(e,t));Vt.displayName="MarkdownOl";var an=memo(({children:e,className:t,node:o,...n})=>{var f;let r=w(),{depth:s,ulDepth:a,isUnordered:l}=useContext(qe),{listStyle:i}=useContext(L),d=ya[i],c=l&&a>0?d[(a-1)%d.length]:void 0,p=Array.isArray(e)?e.filter(y=>y!==`
12
- `&&y!==""):[e],u=p[0],m=isValidElement(u)?(f=u.props.node)==null?void 0:f.tagName:void 0,g=p.length===1&&isValidElement(u)&&(u.type==="p"||m==="p")?u.props.children:e;return jsx("li",{className:r("py-1 [&>p]:inline",c,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:g})},(e,t)=>e.className===t.className&&at(e.node,t.node));an.displayName="MarkdownLi";var ln=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:s,ulDepth:a}=useContext(qe),l=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...n,children:jsx(qe.Provider,{value:l,children:e})})},(e,t)=>H(e,t));ln.displayName="MarkdownUl";var cn=memo(({className:e,node:t,...o})=>{let n=w();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>H(e,t));cn.displayName="MarkdownHr";var dn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>H(e,t));dn.displayName="MarkdownStrong";var wa=({children:e,className:t,href:o,node:n,...r})=>{let s=w(),{linkSafety:a}=useContext(L),[l,i]=useState(false),d=o==="streamdown:incomplete-link",c=useCallback(async g=>{if(!(!(a!=null&&a.enabled&&o)||d)){if(g.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,d]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{i(false);},[]),m={url:o!=null?o:"",isOpen:l,onClose:u,onConfirm:p};return a!=null&&a.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",onClick:c,type:"button",children:e}),a.renderModal?a.renderModal(m):jsx(Ho,{...m})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},mn=memo(wa,(e,t)=>H(e,t)&&e.href===t.href);mn.displayName="MarkdownA";var un=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>H(e,t));un.displayName="MarkdownH1";var pn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>H(e,t));pn.displayName="MarkdownH2";var fn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>H(e,t));fn.displayName="MarkdownH3";var gn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>H(e,t));gn.displayName="MarkdownH4";var bn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>H(e,t));bn.displayName="MarkdownH5";var hn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>H(e,t));hn.displayName="MarkdownH6";var yn=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(L),a=Ot(r,"table"),l=Bt(r,"copy"),i=Bt(r,"download"),d=Bt(r,"fullscreen");return jsx(en,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:d,...n,children:e})},(e,t)=>H(e,t));yn.displayName="MarkdownTable";var wn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>H(e,t));wn.displayName="MarkdownThead";var Cn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>H(e,t));Cn.displayName="MarkdownTbody";var kn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>H(e,t));kn.displayName="MarkdownTr";var xn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>H(e,t));xn.displayName="MarkdownTh";var vn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>H(e,t));vn.displayName="MarkdownTd";var Tn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>H(e,t));Tn.displayName="MarkdownBlockquote";var Pn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>H(e,t));Pn.displayName="MarkdownSup";var nn={"markdown-alert-note":"border-l-blue-500 bg-blue-500/5 [&_.markdown-alert-title]:text-blue-600 dark:[&_.markdown-alert-title]:text-blue-400","markdown-alert-tip":"border-l-green-600 bg-green-600/5 [&_.markdown-alert-title]:text-green-700 dark:[&_.markdown-alert-title]:text-green-400","markdown-alert-important":"border-l-purple-600 bg-purple-600/5 [&_.markdown-alert-title]:text-purple-700 dark:[&_.markdown-alert-title]:text-purple-400","markdown-alert-warning":"border-l-amber-600 bg-amber-600/5 [&_.markdown-alert-title]:text-amber-700 dark:[&_.markdown-alert-title]:text-amber-400","markdown-alert-caution":"border-l-red-600 bg-red-600/5 [&_.markdown-alert-title]:text-red-700 dark:[&_.markdown-alert-title]:text-red-400"},Mn=memo(({children:e,className:t,node:o,...n})=>{let r=w();if(t==null?void 0:t.includes("markdown-alert")){let a=Object.keys(nn).find(l=>t==null?void 0:t.includes(l));return jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 px-4 py-3 [&>p:last-child]:mb-0",a?nn[a]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>H(e,t));Mn.displayName="MarkdownDiv";var In=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>H(e,t));In.displayName="MarkdownSub";var Nn=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var u,m;if(!isValidElement(i))return false;let d=Array.isArray(i.props.children)?i.props.children:[i.props.children],c=false,p=false;for(let g of d)if(g){if(typeof g=="string")g.trim()!==""&&(c=true);else if(isValidElement(g))if(((u=g.props)==null?void 0:u["data-footnote-backref"])!==void 0)p=true;else {let f=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let y of f){if(typeof y=="string"&&y.trim()!==""){c=true;break}if(isValidElement(y)&&((m=y.props)==null?void 0:m["data-footnote-backref"])===void 0){c=true;break}}}}return p&&!c},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===Vt){let c=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(p=>!s(p));return c.length===0?null:{...i,props:{...i.props,children:c}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>H(e,t));Nn.displayName="MarkdownSection";var Ca=({node:e,className:t,children:o,...n})=>{var B,S;let r=w(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(L),d=Ie(),c=yt(),p=t==null?void 0:t.match(ha),u=(B=p==null?void 0:p.at(1))!=null?B:"",m=Do(u);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let g=(S=e==null?void 0:e.properties)==null?void 0:S.metastring,f=g==null?void 0:g.match(fa),y=f?Number.parseInt(f[1],10):void 0,b=y!==void 0&&y>=1?y:void 0,x=!(g?ga.test(g):false)&&i!==false,h="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?h=o.props.children:typeof o=="string"&&(h=o),m){let _=m.component;return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsx(_,{code:h,isIncomplete:c,language:u,meta:g})})}if(u==="mermaid"&&d){let _=Ot(l,"mermaid"),Q=nt(l,"download"),F=nt(l,"copy"),q=nt(l,"fullscreen"),ee=nt(l,"panZoom"),U=_&&(Q||F||q);return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),U?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[Q?jsx(tt,{chart:h,config:a==null?void 0:a.config}):null,F?jsx(Ye,{code:h}):null,q?jsx(qo,{chart:h,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(ba,{chart:h,config:a==null?void 0:a.config,showControls:ee})})]})})}let M=Ot(l,"code"),I=on(l,"download"),j=on(l,"copy");return jsx(vt,{className:t,code:h,isIncomplete:c,language:u,lineNumbers:x,startLine:b,children:M?jsxs(Fragment,{children:[I?jsx(Pt,{code:h,language:u}):null,j?jsx(Ye,{}):null]}):null})},Ln=memo(Ca,(e,t)=>e.className===t.className&&at(e.node,t.node));Ln.displayName="MarkdownCode";var Sn=memo(Ro,(e,t)=>e.className===t.className&&at(e.node,t.node));Sn.displayName="MarkdownImg";var rn={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Rn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),s=O(),a=n["data-alert-type"],l=a&&a in rn?rn[a]:void 0,i=l?s[l]:void 0,d=e;return i&&(d=[...(Array.isArray(e)?e:[e]).filter(u=>!(typeof u=="string"&&u.trim().length>0)),i]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...n,children:d})},(e,t)=>H(e,t));Rn.displayName="MarkdownAlertTitle";var En=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Rn,{className:t,node:o,...n,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=s[0].props.node,l=a==null?void 0:a.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>H(e,t));En.displayName="MarkdownParagraph";var An={ol:Vt,li:an,ul:ln,hr:cn,strong:dn,a:mn,h1:un,h2:pn,h3:fn,h4:gn,h5:bn,h6:hn,table:yn,thead:wn,tbody:Cn,tr:kn,th:xn,td:vn,blockquote:Tn,code:Ln,div:Mn,img:Sn,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Pn,sub:In,p:En,section:Nn};var ka=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,xa=/\p{L}/u;function it(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(ka.test(o))return "rtl";if(xa.test(o))return "ltr"}return "ltr"}var va=/^[ \t]{0,3}(`{3,}|~{3,})/,Ta=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,_t=e=>{let t=e.split(`
11
+ `)};var ze=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=w(),[a,l]=useState(false),[i,d]=useState(false),c=useRef(null),p=useRef(0),{isAnimating:u}=useContext(N),m=O(),g=async h=>{var k,x;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.write)){n==null||n(new Error("Clipboard API not available"));return}try{let b=(x=c.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),M=b==null?void 0:b.querySelector("table");if(!M){n==null||n(new Error("Table not found"));return}let I=Le(M),R=({csv:ve,tsv:Et,md:Te}[h]||Te)(I),_=new ClipboardItem({"text/plain":new Blob([R],{type:"text/plain"}),"text/html":new Blob([M.outerHTML],{type:"text/html"})});await navigator.clipboard.write([_]),d(!0),l(!1),o==null||o(h),p.current=window.setTimeout(()=>d(!1),r);}catch(b){n==null||n(b);}};useEffect(()=>{let h=k=>{let x=k.composedPath();c.current&&!x.includes(c.current)&&l(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h),window.clearTimeout(p.current);}},[]);let f=D(),y=i?f.CheckIcon:f.CopyIcon;return jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>l(!a),title:m.copyTable,type:"button",children:e!=null?e:jsx(y,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("md"),title:m.copyTableAsMarkdown,type:"button",children:m.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:m.copyTableAsCsv,type:"button",children:m.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var na=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=w(),{isAnimating:l}=useContext(N),i=O(),d=D(),c=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=m==null?void 0:m.querySelector("table");if(!g){n==null||n(new Error("Table not found"));return}let f=Le(g),y="",h="",k="";switch(r){case "csv":y=ve(f),h="text/csv",k="csv";break;case "markdown":y=Te(f),h="text/markdown",k="md";break;default:y=ve(f),h="text/csv",k="csv";}oe(`${s||"table"}.${k}`,y,h),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:c,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})})},$e=({children:e,className:t,onDownload:o,onError:n})=>{let r=w(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(N),d=O(),c=D(),p=u=>{var m;try{let g=(m=l.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=g==null?void 0:g.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let y=Le(f),h=u==="csv"?ve(y):Te(y);oe(`table.${u==="csv"?"csv":"md"}`,h,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(g){n==null||n(g);}};return useEffect(()=>{let u=m=>{let g=m.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>a(!s),title:d.downloadTable,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("csv"),title:d.downloadTableAsCsv,type:"button",children:d.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("markdown"),title:d.downloadTableAsMarkdown,type:"button",children:d.tableFormatMarkdown})]}):null]})};var Jo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=D(),a=w(),[l,i]=useState(false),{isAnimating:d}=useContext(N),c=O(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){ue();let m=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),pe();}}},[l]),jsxs(Fragment,{children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:d,onClick:p,title:c.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":c.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:u,onKeyDown:m=>{m.key==="Escape"&&u();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(ze,{}):null,n?jsx($e,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:c.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var en=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=w(),{isAnimating:d}=useContext(N),c=useRef(null),p=useRef(true),u=Ke(o);useEffect(()=>{let h=c.current;if(!(h&&u))return;let k=()=>{let x=h.scrollHeight-h.scrollTop-h.clientHeight<8;p.current=x;};return h.addEventListener("scroll",k,{passive:true}),()=>h.removeEventListener("scroll",k)},[u]),useEffect(()=>{let h=c.current;h&&u&&d&&p.current&&h.scrollTo({top:h.scrollHeight,behavior:"instant"});}),useEffect(()=>{d||(p.current=true);},[d]);let m=n&&r,g=n&&s,f=n&&a,y=m||g||f;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[y?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[m?jsx(ze,{}):null,g?jsx($e,{}):null,f?jsx(Jo,{showCopy:m,showDownload:g,children:e}):null]}):null,jsx("div",{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),ref:c,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:i("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var fa=/startLine=(\d+)/,ga=/\bnoLineNumbers\b/,ha=lazy(()=>import('./mermaid-RQAJEEXV.js').then(e=>({default:e.Mermaid}))),ba=/language-([^\s]+)/;function at(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(o==null?void 0:o.offset)===(n==null?void 0:n.offset)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)&&(r==null?void 0:r.offset)===(s==null?void 0:s.offset)}function H(e,t){return e.className===t.className&&at(e.node,t.node)}var Ot=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Bt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},on=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},nt=(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},qe=createContext({depth:0,ulDepth:0,isUnordered:false}),ya={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Vt=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:s,ulDepth:a}=useContext(qe),l=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...n,children:jsx(qe.Provider,{value:l,children:e})})},(e,t)=>H(e,t));Vt.displayName="MarkdownOl";var an=memo(({children:e,className:t,node:o,...n})=>{var f;let r=w(),{depth:s,ulDepth:a,isUnordered:l}=useContext(qe),{listStyle:i}=useContext(N),d=ya[i],c=l&&a>0?d[(a-1)%d.length]:void 0,p=Array.isArray(e)?e.filter(y=>y!==`
12
+ `&&y!==""):[e],u=p[0],m=isValidElement(u)?(f=u.props.node)==null?void 0:f.tagName:void 0,g=p.length===1&&isValidElement(u)&&(u.type==="p"||m==="p")?u.props.children:e;return t!=null&&t.includes("task-list-item")?jsx("li",{className:r("my-1 flex list-none items-center gap-2 [&>input]:m-0 [&>p]:inline",t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:g}):jsx("li",{className:r("py-1 [&>p]:inline",c,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:g})},(e,t)=>e.className===t.className&&at(e.node,t.node));an.displayName="MarkdownLi";var ln=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:s,ulDepth:a}=useContext(qe),l=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...n,children:jsx(qe.Provider,{value:l,children:e})})},(e,t)=>H(e,t));ln.displayName="MarkdownUl";var cn=memo(({className:e,node:t,...o})=>{let n=w();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>H(e,t));cn.displayName="MarkdownHr";var dn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>H(e,t));dn.displayName="MarkdownStrong";var wa=({children:e,className:t,href:o,node:n,...r})=>{let s=w(),{linkSafety:a}=useContext(N),[l,i]=useState(false),d=o==="streamdown:incomplete-link",c=useCallback(async g=>{if(!(!(a!=null&&a.enabled&&o)||d)){if(g.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,d]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{i(false);},[]),m={url:o!=null?o:"",isOpen:l,onClose:u,onConfirm:p};return a!=null&&a.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",onClick:c,type:"button",children:e}),a.renderModal?a.renderModal(m):jsx(Ho,{...m})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},mn=memo(wa,(e,t)=>H(e,t)&&e.href===t.href);mn.displayName="MarkdownA";var un=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>H(e,t));un.displayName="MarkdownH1";var pn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>H(e,t));pn.displayName="MarkdownH2";var fn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>H(e,t));fn.displayName="MarkdownH3";var gn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>H(e,t));gn.displayName="MarkdownH4";var hn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>H(e,t));hn.displayName="MarkdownH5";var bn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>H(e,t));bn.displayName="MarkdownH6";var yn=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(N),a=Ot(r,"table"),l=Bt(r,"copy"),i=Bt(r,"download"),d=Bt(r,"fullscreen");return jsx(en,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:d,...n,children:e})},(e,t)=>H(e,t));yn.displayName="MarkdownTable";var wn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>H(e,t));wn.displayName="MarkdownThead";var Cn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>H(e,t));Cn.displayName="MarkdownTbody";var kn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>H(e,t));kn.displayName="MarkdownTr";var xn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>H(e,t));xn.displayName="MarkdownTh";var vn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>H(e,t));vn.displayName="MarkdownTd";var Tn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>H(e,t));Tn.displayName="MarkdownBlockquote";var Pn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>H(e,t));Pn.displayName="MarkdownSup";var nn={"markdown-alert-note":"border-l-blue-500 bg-blue-500/5 [&_.markdown-alert-title]:text-blue-600 dark:[&_.markdown-alert-title]:text-blue-400","markdown-alert-tip":"border-l-green-600 bg-green-600/5 [&_.markdown-alert-title]:text-green-700 dark:[&_.markdown-alert-title]:text-green-400","markdown-alert-important":"border-l-purple-600 bg-purple-600/5 [&_.markdown-alert-title]:text-purple-700 dark:[&_.markdown-alert-title]:text-purple-400","markdown-alert-warning":"border-l-amber-600 bg-amber-600/5 [&_.markdown-alert-title]:text-amber-700 dark:[&_.markdown-alert-title]:text-amber-400","markdown-alert-caution":"border-l-red-600 bg-red-600/5 [&_.markdown-alert-title]:text-red-700 dark:[&_.markdown-alert-title]:text-red-400"},Mn=memo(({children:e,className:t,node:o,...n})=>{let r=w();if(t==null?void 0:t.includes("markdown-alert")){let a=Object.keys(nn).find(l=>t==null?void 0:t.includes(l));return jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 px-4 py-3 [&>p:last-child]:mb-0",a?nn[a]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>H(e,t));Mn.displayName="MarkdownDiv";var In=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>H(e,t));In.displayName="MarkdownSub";var Ln=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var u,m;if(!isValidElement(i))return false;let d=Array.isArray(i.props.children)?i.props.children:[i.props.children],c=false,p=false;for(let g of d)if(g){if(typeof g=="string")g.trim()!==""&&(c=true);else if(isValidElement(g))if(((u=g.props)==null?void 0:u["data-footnote-backref"])!==void 0)p=true;else {let f=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let y of f){if(typeof y=="string"&&y.trim()!==""){c=true;break}if(isValidElement(y)&&((m=y.props)==null?void 0:m["data-footnote-backref"])===void 0){c=true;break}}}}return p&&!c},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===Vt){let c=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(p=>!s(p));return c.length===0?null:{...i,props:{...i.props,children:c}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>H(e,t));Ln.displayName="MarkdownSection";var Ca=({node:e,className:t,children:o,...n})=>{var B,R;let r=w(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(N),d=Ie(),c=yt(),p=t==null?void 0:t.match(ba),u=(B=p==null?void 0:p.at(1))!=null?B:"",m=Do(u);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let g=(R=e==null?void 0:e.properties)==null?void 0:R.metastring,f=g==null?void 0:g.match(fa),y=f?Number.parseInt(f[1],10):void 0,h=y!==void 0&&y>=1?y:void 0,x=!(g?ga.test(g):false)&&i!==false,b="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?b=o.props.children:typeof o=="string"&&(b=o),m){let _=m.component;return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsx(_,{code:b,isIncomplete:c,language:u,meta:g})})}if(u==="mermaid"&&d){let _=Ot(l,"mermaid"),Q=nt(l,"download"),F=nt(l,"copy"),q=nt(l,"fullscreen"),ee=nt(l,"panZoom"),U=_&&(Q||F||q);return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),U?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[Q?jsx(tt,{chart:b,config:a==null?void 0:a.config}):null,F?jsx(Ye,{code:b}):null,q?jsx(qo,{chart:b,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(ha,{chart:b,config:a==null?void 0:a.config,showControls:ee})})]})})}let M=Ot(l,"code"),I=on(l,"download"),j=on(l,"copy");return jsx(vt,{className:t,code:b,isIncomplete:c,language:u,lineNumbers:x,startLine:h,children:M?jsxs(Fragment,{children:[I?jsx(Pt,{code:b,language:u}):null,j?jsx(Ye,{}):null]}):null})},Nn=memo(Ca,(e,t)=>e.className===t.className&&at(e.node,t.node));Nn.displayName="MarkdownCode";var Rn=memo(So,(e,t)=>e.className===t.className&&at(e.node,t.node));Rn.displayName="MarkdownImg";var rn={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Sn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),s=O(),a=n["data-alert-type"],l=a&&a in rn?rn[a]:void 0,i=l?s[l]:void 0,d=e;return i&&(d=[...(Array.isArray(e)?e:[e]).filter(u=>!(typeof u=="string"&&u.trim().length>0)),i]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...n,children:d})},(e,t)=>H(e,t));Sn.displayName="MarkdownAlertTitle";var En=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Sn,{className:t,node:o,...n,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=s[0].props.node,l=a==null?void 0:a.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>H(e,t));En.displayName="MarkdownParagraph";var An={ol:Vt,li:an,ul:ln,hr:cn,strong:dn,a:mn,h1:un,h2:pn,h3:fn,h4:gn,h5:hn,h6:bn,table:yn,thead:wn,tbody:Cn,tr:kn,th:xn,td:vn,blockquote:Tn,code:Nn,div:Mn,img:Rn,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Pn,sub:In,p:En,section:Ln};var ka=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,xa=/\p{L}/u;function it(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(ka.test(o))return "rtl";if(xa.test(o))return "ltr"}return "ltr"}var va=/^[ \t]{0,3}(`{3,}|~{3,})/,Ta=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,_t=e=>{let t=e.split(`
13
13
  `),o=null,n=0;for(let r of t){let s=va.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null},Hn=e=>{let t=e.split(`
14
- `);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&Ta.test(n))return true}return false};var Dn=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var On=[],Vn={allowDangerousHtml:true},lt=new WeakMap,Ft=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let p="default";return this.keyCache.set(t,p),p}let a=p=>{if(!p||p.length===0)return "";let u="";for(let m=0;m<p.length;m+=1){let g=p[m];if(m>0&&(u+=","),Array.isArray(g)){let[f,y]=g;if(typeof f=="function"){let b=lt.get(f);b||(b=f.name,lt.set(f,b)),u+=b;}else u+=String(f);u+=":",u+=JSON.stringify(y);}else if(typeof g=="function"){let f=lt.get(g);f||(f=g.name,lt.set(g,f)),u+=f;}else u+=String(g);}return u},l=a(n),i=a(r),d=s?JSON.stringify(s):"",c=`${i}::${l}::${d}`;return this.keyCache.set(t,c),c}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},_n=new Ft,zt=e=>{let t=Ha(e),o=e.children||"",n=t.runSync(t.parse(o),o);return ja(n,e)},Ha=e=>{let t=_n.get(e);if(t)return t;let o=Ba(e);return _n.set(e,o),o},Da=e=>e.some(t=>Array.isArray(t)?t[0]===Bn:t===Bn),Ba=e=>{let t=e.rehypePlugins||On,o=e.remarkPlugins||On,n=Da(t)?o:[...o,Dn],r=e.remarkRehypeOptions?{...Vn,...e.remarkRehypeOptions}:Vn;return unified().use(Sa).use(n).use(Ra,r).use(t)},jn=e=>e,Oa=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},Va=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],s=urlAttributes[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},_a=(e,t,o,n,r,s)=>{let a=false;return n?a=!n.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,o)),a},ja=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let d=l||jn;visit(e,(c,p,u)=>{if(c.type==="raw"&&u&&typeof p=="number")return Oa(u,p,s,c.value),p;if(c.type==="element"&&(Va(c,d),_a(c,p,u,n,r,o)&&u&&typeof p=="number"))return a&&c.children?u.children.splice(p,1,...c.children):u.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var za=/\[\^[\w-]{1,200}\](?!:)/,$a=/\[\^[\w-]{1,200}\]:/;var Wa=/<(\w+)[\s>]/,qa=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Fn=new Map,zn=new Map,qn=e=>{let t=e.toLowerCase(),o=Fn.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Fn.set(t,n),n},Za=e=>{let t=e.toLowerCase(),o=zn.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return zn.set(t,n),n},$n=(e,t)=>{if(qa.has(t.toLowerCase()))return 0;let o=e.match(qn(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Wn=(e,t)=>{let o=e.match(Za(t));return o?o.length:0},Ka=(e,t)=>{let o=e.match(qn(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},Xa=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},ct=e=>{let t=za.test(e),o=$a.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],s=[],a=false;for(let l of n){let i=l.raw,d=r.length;if(s.length>0){r[d-1]+=i;let c=s.at(-1),p=$n(i,c),u=Wn(i,c);for(let m=0;m<p;m+=1)s.push(c);for(let m=0;m<u;m+=1)s.length>0&&s.at(-1)===c&&s.pop();continue}if(l.type==="html"&&l.block){let c=i.match(Wa);if(c){let p=c[1],u=$n(i,p),m=Wn(i,p);u>m&&!Ka(i,p)&&s.push(p);}}if(d>0&&!a){let c=r[d-1];if(Xa(c)%2===1){r[d-1]=c+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r},$t=(e,t,o=ct)=>{if(!(t!=null&&t.source&&e.startsWith(t.source)))return {source:e,blocks:o(e)};if(e===t.source)return t;if(t.blocks.length<=1)return {source:e,blocks:o(e)};let n=t.blocks.slice(0,-1),r=0;for(let i of n)r+=i.length;let s=e.slice(0,r);if(n.join("")!==s)return {source:e,blocks:o(e)};let a=e.slice(r),l=o(a);return {source:e,blocks:[...n,...l]}};var Zn=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`<${n}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");o=o.replace(r,(s,a)=>`<${n}${a}></${n}>`);}for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let d=l.includes(`
14
+ `);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&Ta.test(n))return true}return false};var Dn=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var On=[],Vn={allowDangerousHtml:true},lt=new WeakMap,Ft=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let p="default";return this.keyCache.set(t,p),p}let a=p=>{if(!p||p.length===0)return "";let u="";for(let m=0;m<p.length;m+=1){let g=p[m];if(m>0&&(u+=","),Array.isArray(g)){let[f,y]=g;if(typeof f=="function"){let h=lt.get(f);h||(h=f.name,lt.set(f,h)),u+=h;}else u+=String(f);u+=":",u+=JSON.stringify(y);}else if(typeof g=="function"){let f=lt.get(g);f||(f=g.name,lt.set(g,f)),u+=f;}else u+=String(g);}return u},l=a(n),i=a(r),d=s?JSON.stringify(s):"",c=`${i}::${l}::${d}`;return this.keyCache.set(t,c),c}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},_n=new Ft,zt=e=>{let t=Ha(e),o=e.children||"",n=t.runSync(t.parse(o),o);return ja(n,e)},Ha=e=>{let t=_n.get(e);if(t)return t;let o=Ba(e);return _n.set(e,o),o},Da=e=>e.some(t=>Array.isArray(t)?t[0]===Bn:t===Bn),Ba=e=>{let t=e.rehypePlugins||On,o=e.remarkPlugins||On,n=Da(t)?o:[...o,Dn],r=e.remarkRehypeOptions?{...Vn,...e.remarkRehypeOptions}:Vn;return unified().use(Ra).use(n).use(Sa,r).use(t)},jn=e=>e,Oa=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},Va=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],s=urlAttributes[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},_a=(e,t,o,n,r,s)=>{let a=false;return n?a=!n.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,o)),a},ja=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let d=l||jn;visit(e,(c,p,u)=>{if(c.type==="raw"&&u&&typeof p=="number")return Oa(u,p,s,c.value),p;if(c.type==="element"&&(Va(c,d),_a(c,p,u,n,r,o)&&u&&typeof p=="number"))return a&&c.children?u.children.splice(p,1,...c.children):u.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var za=/\[\^[\w-]{1,200}\](?!:)/,$a=/\[\^[\w-]{1,200}\]:/;var Wa=/<(\w+)[\s>]/,qa=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Fn=new Map,zn=new Map,qn=e=>{let t=e.toLowerCase(),o=Fn.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Fn.set(t,n),n},Za=e=>{let t=e.toLowerCase(),o=zn.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return zn.set(t,n),n},$n=(e,t)=>{if(qa.has(t.toLowerCase()))return 0;let o=e.match(qn(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Wn=(e,t)=>{let o=e.match(Za(t));return o?o.length:0},Ka=(e,t)=>{let o=e.match(qn(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},Xa=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},ct=e=>{let t=za.test(e),o=$a.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],s=[],a=false;for(let l of n){let i=l.raw,d=r.length;if(s.length>0){r[d-1]+=i;let c=s.at(-1),p=$n(i,c),u=Wn(i,c);for(let m=0;m<p;m+=1)s.push(c);for(let m=0;m<u;m+=1)s.length>0&&s.at(-1)===c&&s.pop();continue}if(l.type==="html"&&l.block){let c=i.match(Wa);if(c){let p=c[1],u=$n(i,p),m=Wn(i,p);u>m&&!Ka(i,p)&&s.push(p);}}if(d>0&&!a){let c=r[d-1];if(Xa(c)%2===1){r[d-1]=c+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r},$t=(e,t,o=ct)=>{if(!(t!=null&&t.source&&e.startsWith(t.source)))return {source:e,blocks:o(e)};if(e===t.source)return t;if(t.blocks.length<=1)return {source:e,blocks:o(e)};let n=t.blocks.slice(0,-1),r=0;for(let i of n)r+=i.length;let s=e.slice(0,r);if(n.join("")!==s)return {source:e,blocks:o(e)};let a=e.slice(r),l=o(a);return {source:e,blocks:[...n,...l]}};var Zn=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`<${n}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");o=o.replace(r,(s,a)=>`<${n}${a}></${n}>`);}for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let d=l.includes(`
15
15
 
16
16
  `),c=!l.startsWith(`
17
17
  `),p=l.includes(`
@@ -23,5 +23,5 @@ import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidEleme
23
23
  `)?"":`
24
24
  `);return `${a}${m}${i}
25
25
 
26
- `});}return o};var Ga=/([\\`*_~[\]|])/g,Ua=e=>e.replace(Ga,"\\$1"),Kn=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let d=Ua(l).replace(/\n\n/g,"&#10;&#10;");return a+d+i});}return o};var Xn=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(Xn).join(""):"",Gn=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{if(o.has(n.tagName.toLowerCase())){let r=Xn(n);n.children=r?[{type:"text",value:r}]:[];}});};var oi=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),ni=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),ri=e=>{let t=unified().use(Sa).use(Ra,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},Un=(e,t=[])=>o=>{if(!e||e.length===0)return;let n=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(o,"element",s=>{let a=s.tagName.toLowerCase();if(!n.has(a)||r.has(a)||!oi(s))return;let l=ni(s);if(!l.includes(`
27
- `))return;let i=ri(l);s.children=i;});};var Jn=()=>e=>{visit(e,"code",t=>{var o,n;t.meta&&(t.data=(o=t.data)!=null?o:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta});});};var li={NOTE:{icon:"info",kind:"note",title:"Note",iconPath:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},TIP:{icon:"light-bulb",kind:"tip",title:"Tip",iconPath:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"},IMPORTANT:{icon:"report",kind:"important",title:"Important",iconPath:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"},WARNING:{icon:"alert",kind:"warning",title:"Warning",iconPath:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575ZM8.75 5.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPath:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25a.749.749 0 0 1-.53.22H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}},ci=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,Yn=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=Yn(n);return o},di=e=>({type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="${e.iconPath}"></path></svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"],"data-alert-type":e.kind}}}),mi=e=>{var p,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let o=t.children[0];if(!o||o.type!=="text")return;let n=Yn(o).trimStart(),r=n.match(ci);if(!r)return;let s=li[r[1].toUpperCase()],a=n.slice(r[0].length),l=t.children.slice(1);if(a.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[di(s)],d=[];a.length>0&&d.push({type:"text",value:a});let c=l;return ((p=c[0])==null?void 0:p.type)==="break"&&(c=c.slice(1)),d.push(...c),d.length>0&&d.some(m=>m.type!=="text"||m.value.trim().length>0)&&i.push({type:"paragraph",children:d}),i.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=i,SKIP$1},Qn=()=>e=>{visit(e,"blockquote",mi);};var wi=/^[ \t]*<[\w!/?-]/,Ci=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,ki=e=>typeof e!="string"||e.length===0||!wi.test(e)?e:e.replace(Ci,"$1"),nr,rr,sr,ar,ir,lr,cr,dr,mr,ur,pr,dt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(rr=(nr=defaultSchema.protocols)==null?void 0:nr.href)!=null?rr:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(ar=(sr=defaultSchema.attributes)==null?void 0:sr.div)!=null?ar:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution))$/]],p:[...(lr=(ir=defaultSchema.attributes)==null?void 0:ir.p)!=null?lr:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(dr=(cr=defaultSchema.attributes)==null?void 0:cr.svg)!=null?dr:[],"className","viewBox","width","height","ariaHidden"],path:[...(ur=(mr=defaultSchema.attributes)==null?void 0:mr.path)!=null?ur:[],"d"]},tagNames:[...(pr=defaultSchema.tagNames)!=null?pr:[],"svg","path"]},Wt={raw:Bn,sanitize:[gr,dt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},xi={gfm:[hi,{}],githubAlerts:Qn,codeMeta:Jn},tr=Object.values(Wt),vi=Object.values(xi),or=new WeakMap;function Ti(e){var r;let t=or.get(e);if(t)return t;let o={...dt,tagNames:[...(r=dt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...dt.attributes,...e}},n=[Wt.raw,[gr,o],Wt.harden];return or.set(e,n),n}var Pi={block:" \u258B",circle:" \u25CF"},Mi=["github-light","github-dark"],Ii={enabled:true},br=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{if(a){let c=a.getLastRenderCharCount();a.setPrevContentLength(c),a.setAnimateCodeBlocks(r);}let i=typeof e=="string"&&o?ki(e):e,d=jsx(zt,{...l,children:i});return jsx(ht.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:d}):d})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});br.displayName="Block";var Ni=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=tr,remarkPlugins:l=vi,className:i,shikiTheme:d=Mi,mermaid:c,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,tableMaxHeight:g=300,animated:f,BlockComponent:y=br,parseMarkdownIntoBlocksFn:b=ct,caret:k,listStyle:x="hierarchical",plugins:h,remend:M,linkSafety:I=Ii,lineNumbers:j=true,allowedTags:B,literalTagContent:S,translations:_,icons:Q,prefix:F,onAnimationStart:q,onAnimationEnd:ee,...U})=>{var Jt;let be=useId(),N=useMemo(()=>io(F),[F]),te=useRef(null),J=useRef(q),he=useRef(ee);J.current=q,he.current=ee,useEffect(()=>{var P,$,K;if(t==="static")return;let C=te.current;if(te.current=m,C===null){m&&((P=J.current)==null||P.call(J));return}m&&!C?($=J.current)==null||$.call(J):!m&&C&&((K=he.current)==null||K.call(he));},[m,t]);let Z=useMemo(()=>B?Object.keys(B):[],[B]),ye=useRef(null),re=useMemo(()=>{if(typeof e!="string")return "";let C=e;return S&&S.length>0&&(C=Kn(C,S)),Z.length>0&&(C=Zn(C,Z)),C},[e,Z,S]),V=useMemo(()=>{let C=t==="streaming"?ye.current:null,P=$t(re,C,b);if(ye.current=t==="streaming"?P:null,!(t==="streaming"&&n)||P.blocks.length===0)return P.blocks;let $=P.blocks.length-1,K=P.blocks[$],me=yi(K,M);if(me===K)return P.blocks;let Ee=P.blocks.slice();return Ee[$]=me,Ee},[re,b,t,n,M]),T=useMemo(()=>f===true?"true":f?JSON.stringify(f):"",[f]),R=useRef(null),X=useRef([]),Y=useRef([]),qt=useRef(null),Zt=useRef("");T?(Zt.current!==T&&(Zt.current=T,R.current=bt(),X.current=[],Y.current=[]),R.current&&(R.current.current=0)):(R.current=null,X.current=[],Y.current=[]);R.current?(Jt=X.current[0])!=null?Jt:(()=>{var P;let C=He({...T!=="true"?f:{},cursor:(P=R.current)!=null?P:void 0});return X.current[0]=C,C})():null;let we=useDeferredValue(V),se=useMemo(()=>{if(t!=="streaming"||R.current||we===V||we.length===0)return V;let C=we.length,P=V.length;if(P===0)return we;if(C!==P)return V;for(let K=0;K<C-1;K+=1)if(we[K]!==V[K])return V;let $=we.slice();return $[C-1]=V[P-1],$},[V,we,t]),ut=useMemo(()=>o==="auto"?se.map(it):void 0,[se,o]),Cr=useMemo(()=>se.map((C,P)=>`${be}-${P}`),[se.length,be]),Kt=useMemo(()=>{var C,P;return {codeBlockMaxHeight:p,shikiTheme:(P=(C=h==null?void 0:h.code)==null?void 0:C.getThemes())!=null?P:d,controls:u,isAnimating:m,lineNumbers:j,listStyle:x,mode:t,mermaid:c,linkSafety:I,tableMaxHeight:g}},[p,d,u,m,j,x,t,c,I,h==null?void 0:h.code,g]),kr=useMemo(()=>_?JSON.stringify(_):"",[_]),Xt=useMemo(()=>({...Ue,..._}),[kr]),Gt=useMemo(()=>{let{inlineCode:C,...P}=s!=null?s:{},$={...An,...P};if(C){let K=$.code;$.code=me=>"data-block"in me?K?createElement(K,me):null:createElement(C,me);}return $},[s]),Ut=useMemo(()=>{let C=[];return h!=null&&h.cjk&&(C=[...C,...h.cjk.remarkPluginsBefore]),C=[...C,...l],h!=null&&h.cjk&&(C=[...C,...h.cjk.remarkPluginsAfter]),h!=null&&h.math&&(C=[...C,h.math.remarkPlugin]),C},[l,h==null?void 0:h.math,h==null?void 0:h.cjk]),Re=useMemo(()=>{let C=a;return B&&Object.keys(B).length>0&&a===tr&&(C=Ti(B)),Z.length>0&&(C=[...C,[Un,Z,S!=null?S:[]]]),S&&S.length>0&&(C=[...C,[Gn,S]]),h!=null&&h.math&&(C=[...C,h.math.rehypePlugin]),C},[a,h==null?void 0:h.math,B,Z,S]),pt=useMemo(()=>{if(!m||se.length===0)return false;let C=se.at(-1);return _t(C)||Hn(C)},[m,se]),xr=useMemo(()=>k&&m&&!pt?{"--streamdown-caret":`"${Pi[k]}"`}:void 0,[k,m,pt]),vr=C=>{let P=null;R.current&&m&&(X.current[C]||(X.current[C]=He({...T!=="true"?f:{},cursor:R.current})),P=X.current[C]),qt.current!==Re&&(Y.current=[],qt.current=Re),P&&!Y.current[C]&&(Y.current[C]=[...Re,P.rehypePlugin]);let $=P&&Y.current[C]?Y.current[C]:Re;return {blockAnimatePlugin:P,blockRehypePlugins:$}};return t==="static"?jsx(Je.Provider,{value:Xt,children:jsx(et.Provider,{value:h!=null?h:null,children:jsx(L.Provider,{value:Kt,children:jsx(Tt,{icons:Q,children:jsx(Xe.Provider,{value:N,children:jsx("div",{className:N("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?it(re):o,children:jsx(zt,{components:Gt,rehypePlugins:Re,remarkPlugins:Ut,...U,children:re})})})})})})}):jsx(Je.Provider,{value:Xt,children:jsx(et.Provider,{value:h!=null?h:null,children:jsx(L.Provider,{value:Kt,children:jsx(Tt,{icons:Q,children:jsx(Xe.Provider,{value:N,children:jsxs("div",{className:N("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",k&&!pt?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),style:xr,children:[se.length===0&&k&&m&&jsx("span",{}),se.map((C,P)=>{var Yt;let $=P===se.length-1,K=m&&$&&_t(C),{blockAnimatePlugin:me,blockRehypePlugins:Ee}=vr(P);return jsx(y,{animatePlugin:me,components:Gt,content:C,dir:(Yt=ut==null?void 0:ut[P])!=null?Yt:o!=="auto"?o:void 0,index:P,isIncomplete:K,rehypePlugins:Ee,remarkPlugins:Ut,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...U},Cr[P])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Ni.displayName="Streamdown";var wr=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:l=true,initialZoom:i=1,isAutoFit:d=false,fullscreen:c=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:m}=D(),g=w(),f=useRef(null),y=useRef(null),[b,k]=useState(i),[x,h]=useState(r),[M,I]=useState(i),[j,B]=useState({x:0,y:0}),[S,_]=useState(false),[Q,F]=useState(false),[q,ee]=useState({x:0,y:0}),[U,be]=useState({x:0,y:0}),N=useCallback(T=>{I(R=>Math.max(x,Math.min(s,R+T))),F(true);},[x,s]),te=useCallback(()=>{N(a);},[N,a]),J=useCallback(()=>{N(-a);},[N,a]),he=useCallback(()=>{I(b),B({x:0,y:0}),F(false);},[b]),Z=useCallback(T=>{T.preventDefault();let R=T.deltaY>0?-a:a;N(R);},[N,a]),ye=useCallback(T=>{if(T.button!==0||T.isPrimary===false)return;_(true),F(true),ee({x:T.clientX,y:T.clientY}),be(j);let R=T.currentTarget;R instanceof HTMLElement&&R.setPointerCapture(T.pointerId);},[j]),re=useCallback(T=>{if(!S)return;T.preventDefault();let R=T.clientX-q.x,X=T.clientY-q.y;B({x:U.x+R,y:U.y+X});},[S,q,U]),V=useCallback(T=>{_(false);let R=T.currentTarget;R instanceof HTMLElement&&R.releasePointerCapture(T.pointerId);},[]);return useEffect(()=>{h(r),d||(k(i),I(i));},[i,d,r]),useEffect(()=>{if(!(d&&o))return;let T=f.current;if(!T)return;let R=T.clientWidth,X=T.clientHeight;if(!(R>0&&X>0))return;let Y=Math.min(R/o.width,X/o.height,1);!(Y>0)||Number.isNaN(Y)||(k(Y),h(Math.min(r,Y)),Q||(I(Y),B({x:0,y:0})));},[o,Q,d,r]),useEffect(()=>{d&&F(false);},[d]),useEffect(()=>{let T=f.current;if(T)return T.addEventListener("wheel",Z,{passive:false}),()=>{T.removeEventListener("wheel",Z);}},[Z]),useEffect(()=>{let T=y.current;if(T&&S)return document.body.style.userSelect="none",T.addEventListener("pointermove",re,{passive:false}),T.addEventListener("pointerup",V),T.addEventListener("pointercancel",V),()=>{document.body.style.userSelect="",T.removeEventListener("pointermove",re),T.removeEventListener("pointerup",V),T.removeEventListener("pointercancel",V);}},[S,re,V]),jsxs("div",{className:g("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:f,style:{cursor:S?"grabbing":"grab"},children:[l?jsxs("div",{className:g("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",c?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:g("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>=s,onClick:te,title:"Zoom in",type:"button",children:jsx(u,{size:16})}),jsx("button",{className:g("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<=x,onClick:J,title:"Zoom out",type:"button",children:jsx(m,{size:16})}),jsx("button",{className:g("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:he,title:"Reset zoom and pan",type:"button",children:jsx(p,{size:16})})]}):null,jsx("div",{className:g("flex-1 origin-center transition-transform duration-150 ease-out",c?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:ye,ref:y,role:"application",style:{transform:`translate(${j.x}px, ${j.y}px) scale(${M})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Wo=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=w(),[a,l]=useState(null),[i,d]=useState(false),[c,p]=useState(""),[u,m]=useState(null),[g,f]=useState(""),[y,b]=useState(0),{mermaid:k}=useContext(L),x=Ie(),h=k==null?void 0:k.errorComponent,{shouldRender:M,containerRef:I}=Qt({immediate:n});if(useEffect(()=>{if(!M)return;if(!x){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),d(!0);let S=x.getMermaid(o),_=e.split("").reduce((U,be)=>(U<<5)-U+be.charCodeAt(0)|0,0),Q=`mermaid-${Math.abs(_)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:F}=await S.render(Q,e),q=St(F),ee=n?F:jo(F);p(ee),m(q),f(ee);}catch(S){if(!(g||c)){let _=S instanceof Error?S.message:"Failed to render Mermaid chart";l(_);}}finally{d(false);}})();},[e,o,y,M,x]),!(M||c||g))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:I});if(i&&!c&&!g)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:I,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(a&&!c&&!g){let B=()=>b(S=>S+1);return h?jsx("div",{ref:I,children:jsx(h,{chart:e,error:a,retry:B})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:I,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let j=c||g;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:I,children:jsx(wr,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:u,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:j},role:"img"})})})};export{ki as A,Wt as B,xi as C,br as D,Ni as E,bt as a,He as b,yt as c,mo as d,Ct as e,xt as f,uc as g,vt as h,Ue as i,Ye as j,Pt as k,Qe as l,L as m,Wo as n,Ne as o,ve as p,Et as q,ot as r,Te as s,ze as t,na as u,$e as v,it as w,jn as x,ct as y,$t as z};
26
+ `});}return o};var Ga=/([\\`*_~[\]|])/g,Ua=e=>e.replace(Ga,"\\$1"),Kn=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let d=Ua(l).replace(/\n\n/g,"&#10;&#10;");return a+d+i});}return o};var Xn=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(Xn).join(""):"",Gn=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{if(o.has(n.tagName.toLowerCase())){let r=Xn(n);n.children=r?[{type:"text",value:r}]:[];}});};var oi=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),ni=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),ri=e=>{let t=unified().use(Ra).use(Sa,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},Un=(e,t=[])=>o=>{if(!e||e.length===0)return;let n=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(o,"element",s=>{let a=s.tagName.toLowerCase();if(!n.has(a)||r.has(a)||!oi(s))return;let l=ni(s);if(!l.includes(`
27
+ `))return;let i=ri(l);s.children=i;});};var Jn=()=>e=>{visit(e,"code",t=>{var o,n;t.meta&&(t.data=(o=t.data)!=null?o:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta});});};var li={NOTE:{icon:"info",kind:"note",title:"Note",iconPaths:[{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]},TIP:{icon:"light-bulb",kind:"tip",title:"Tip",iconPaths:[{d:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"}]},IMPORTANT:{icon:"report",kind:"important",title:"Important",iconPaths:[{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}]},WARNING:{icon:"alert",kind:"warning",title:"Warning",iconPaths:[{d:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",fillRule:"evenodd"}]},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPaths:[{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25a.749.749 0 0 1-.53.22H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]}},ci=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,Yn=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=Yn(n);return o},di=e=>{let t=e.iconPaths.map(o=>`<path d="${o.d}"${o.fillRule?` fill-rule="${o.fillRule}"`:""}></path>`).join("");return {type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">${t}</svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"],"data-alert-type":e.kind}}}},mi=e=>{var p,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let o=t.children[0];if(!o||o.type!=="text")return;let n=Yn(o).trimStart(),r=n.match(ci);if(!r)return;let s=li[r[1].toUpperCase()],a=n.slice(r[0].length),l=t.children.slice(1);if(a.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[di(s)],d=[];a.length>0&&d.push({type:"text",value:a});let c=l;return ((p=c[0])==null?void 0:p.type)==="break"&&(c=c.slice(1)),d.push(...c),d.length>0&&d.some(m=>m.type!=="text"||m.value.trim().length>0)&&i.push({type:"paragraph",children:d}),i.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=i,SKIP$1},Qn=()=>e=>{visit(e,"blockquote",mi);};var wi=/^[ \t]*<[\w!/?-]/,Ci=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,ki=e=>typeof e!="string"||e.length===0||!wi.test(e)?e:e.replace(Ci,"$1"),nr,rr,sr,ar,ir,lr,cr,dr,mr,ur,pr,dt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(rr=(nr=defaultSchema.protocols)==null?void 0:nr.href)!=null?rr:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(ar=(sr=defaultSchema.attributes)==null?void 0:sr.div)!=null?ar:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution))$/]],p:[...(lr=(ir=defaultSchema.attributes)==null?void 0:ir.p)!=null?lr:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(dr=(cr=defaultSchema.attributes)==null?void 0:cr.svg)!=null?dr:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(ur=(mr=defaultSchema.attributes)==null?void 0:mr.path)!=null?ur:[],"d","fillRule"]},tagNames:[...(pr=defaultSchema.tagNames)!=null?pr:[],"svg","path"]},Wt={raw:Bn,sanitize:[gr,dt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},xi={gfm:[bi,{}],githubAlerts:Qn,codeMeta:Jn},tr=Object.values(Wt),vi=Object.values(xi),or=new WeakMap;function Ti(e){var r;let t=or.get(e);if(t)return t;let o={...dt,tagNames:[...(r=dt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...dt.attributes,...e}},n=[Wt.raw,[gr,o],Wt.harden];return or.set(e,n),n}var Pi={block:" \u258B",circle:" \u25CF"},Mi=["github-light","github-dark"],Ii={enabled:true},hr=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{if(a){let c=a.getLastRenderCharCount();a.setPrevContentLength(c),a.setAnimateCodeBlocks(r);}let i=typeof e=="string"&&o?ki(e):e,d=jsx(zt,{...l,children:i});return jsx(bt.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:d}):d})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});hr.displayName="Block";var Li=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=tr,remarkPlugins:l=vi,className:i,shikiTheme:d=Mi,mermaid:c,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,tableMaxHeight:g=300,animated:f,BlockComponent:y=hr,parseMarkdownIntoBlocksFn:h=ct,caret:k,listStyle:x="hierarchical",plugins:b,remend:M,linkSafety:I=Ii,lineNumbers:j=true,allowedTags:B,literalTagContent:R,translations:_,icons:Q,prefix:F,onAnimationStart:q,onAnimationEnd:ee,...U})=>{var Jt;let he=useId(),L=useMemo(()=>io(F),[F]),te=useRef(null),J=useRef(q),be=useRef(ee);J.current=q,be.current=ee,useEffect(()=>{var P,$,K;if(t==="static")return;let C=te.current;if(te.current=m,C===null){m&&((P=J.current)==null||P.call(J));return}m&&!C?($=J.current)==null||$.call(J):!m&&C&&((K=be.current)==null||K.call(be));},[m,t]);let Z=useMemo(()=>B?Object.keys(B):[],[B]),ye=useRef(null),re=useMemo(()=>{if(typeof e!="string")return "";let C=e;return R&&R.length>0&&(C=Kn(C,R)),Z.length>0&&(C=Zn(C,Z)),C},[e,Z,R]),V=useMemo(()=>{let C=t==="streaming"?ye.current:null,P=$t(re,C,h);if(ye.current=t==="streaming"?P:null,!(t==="streaming"&&n)||P.blocks.length===0)return P.blocks;let $=P.blocks.length-1,K=P.blocks[$],me=yi(K,M);if(me===K)return P.blocks;let Ee=P.blocks.slice();return Ee[$]=me,Ee},[re,h,t,n,M]),T=useMemo(()=>f===true?"true":f?JSON.stringify(f):"",[f]),S=useRef(null),X=useRef([]),Y=useRef([]),qt=useRef(null),Zt=useRef("");T?(Zt.current!==T&&(Zt.current=T,S.current=ht(),X.current=[],Y.current=[]),S.current&&(S.current.current=0)):(S.current=null,X.current=[],Y.current=[]);S.current?(Jt=X.current[0])!=null?Jt:(()=>{var P;let C=He({...T!=="true"?f:{},cursor:(P=S.current)!=null?P:void 0});return X.current[0]=C,C})():null;let we=useDeferredValue(V),se=useMemo(()=>{if(t!=="streaming"||S.current||we===V||we.length===0)return V;let C=we.length,P=V.length;if(P===0)return we;if(C!==P)return V;for(let K=0;K<C-1;K+=1)if(we[K]!==V[K])return V;let $=we.slice();return $[C-1]=V[P-1],$},[V,we,t]),ut=useMemo(()=>o==="auto"?se.map(it):void 0,[se,o]),Cr=useMemo(()=>se.map((C,P)=>`${he}-${P}`),[se.length,he]),Kt=useMemo(()=>{var C,P;return {codeBlockMaxHeight:p,shikiTheme:(P=(C=b==null?void 0:b.code)==null?void 0:C.getThemes())!=null?P:d,controls:u,isAnimating:m,lineNumbers:j,listStyle:x,mode:t,mermaid:c,linkSafety:I,tableMaxHeight:g}},[p,d,u,m,j,x,t,c,I,b==null?void 0:b.code,g]),kr=useMemo(()=>_?JSON.stringify(_):"",[_]),Xt=useMemo(()=>({...Ue,..._}),[kr]),Gt=useMemo(()=>{let{inlineCode:C,...P}=s!=null?s:{},$={...An,...P};if(C){let K=$.code;$.code=me=>"data-block"in me?K?createElement(K,me):null:createElement(C,me);}return $},[s]),Ut=useMemo(()=>{let C=[];return b!=null&&b.cjk&&(C=[...C,...b.cjk.remarkPluginsBefore]),C=[...C,...l],b!=null&&b.cjk&&(C=[...C,...b.cjk.remarkPluginsAfter]),b!=null&&b.math&&(C=[...C,b.math.remarkPlugin]),C},[l,b==null?void 0:b.math,b==null?void 0:b.cjk]),Se=useMemo(()=>{let C=a;return B&&Object.keys(B).length>0&&a===tr&&(C=Ti(B)),Z.length>0&&(C=[...C,[Un,Z,R!=null?R:[]]]),R&&R.length>0&&(C=[...C,[Gn,R]]),b!=null&&b.math&&(C=[...C,b.math.rehypePlugin]),C},[a,b==null?void 0:b.math,B,Z,R]),pt=useMemo(()=>{if(!m||se.length===0)return false;let C=se.at(-1);return _t(C)||Hn(C)},[m,se]),xr=useMemo(()=>k&&m&&!pt?{"--streamdown-caret":`"${Pi[k]}"`}:void 0,[k,m,pt]),vr=C=>{let P=null;S.current&&m&&(X.current[C]||(X.current[C]=He({...T!=="true"?f:{},cursor:S.current})),P=X.current[C]),qt.current!==Se&&(Y.current=[],qt.current=Se),P&&!Y.current[C]&&(Y.current[C]=[...Se,P.rehypePlugin]);let $=P&&Y.current[C]?Y.current[C]:Se;return {blockAnimatePlugin:P,blockRehypePlugins:$}};return t==="static"?jsx(Je.Provider,{value:Xt,children:jsx(et.Provider,{value:b!=null?b:null,children:jsx(N.Provider,{value:Kt,children:jsx(Tt,{icons:Q,children:jsx(Xe.Provider,{value:L,children:jsx("div",{className:L("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?it(re):o,children:jsx(zt,{components:Gt,rehypePlugins:Se,remarkPlugins:Ut,...U,children:re})})})})})})}):jsx(Je.Provider,{value:Xt,children:jsx(et.Provider,{value:b!=null?b:null,children:jsx(N.Provider,{value:Kt,children:jsx(Tt,{icons:Q,children:jsx(Xe.Provider,{value:L,children:jsxs("div",{className:L("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",k&&!pt?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),style:xr,children:[se.length===0&&k&&m&&jsx("span",{}),se.map((C,P)=>{var Yt;let $=P===se.length-1,K=m&&$&&_t(C),{blockAnimatePlugin:me,blockRehypePlugins:Ee}=vr(P);return jsx(y,{animatePlugin:me,components:Gt,content:C,dir:(Yt=ut==null?void 0:ut[P])!=null?Yt:o!=="auto"?o:void 0,index:P,isIncomplete:K,rehypePlugins:Ee,remarkPlugins:Ut,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...U},Cr[P])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Li.displayName="Streamdown";var wr=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:l=true,initialZoom:i=1,isAutoFit:d=false,fullscreen:c=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:m}=D(),g=w(),f=useRef(null),y=useRef(null),[h,k]=useState(i),[x,b]=useState(r),[M,I]=useState(i),[j,B]=useState({x:0,y:0}),[R,_]=useState(false),[Q,F]=useState(false),[q,ee]=useState({x:0,y:0}),[U,he]=useState({x:0,y:0}),L=useCallback(T=>{I(S=>Math.max(x,Math.min(s,S+T))),F(true);},[x,s]),te=useCallback(()=>{L(a);},[L,a]),J=useCallback(()=>{L(-a);},[L,a]),be=useCallback(()=>{I(h),B({x:0,y:0}),F(false);},[h]),Z=useCallback(T=>{T.preventDefault();let S=T.deltaY>0?-a:a;L(S);},[L,a]),ye=useCallback(T=>{if(T.button!==0||T.isPrimary===false)return;_(true),F(true),ee({x:T.clientX,y:T.clientY}),he(j);let S=T.currentTarget;S instanceof HTMLElement&&S.setPointerCapture(T.pointerId);},[j]),re=useCallback(T=>{if(!R)return;T.preventDefault();let S=T.clientX-q.x,X=T.clientY-q.y;B({x:U.x+S,y:U.y+X});},[R,q,U]),V=useCallback(T=>{_(false);let S=T.currentTarget;S instanceof HTMLElement&&S.releasePointerCapture(T.pointerId);},[]);return useEffect(()=>{b(r),d||(k(i),I(i));},[i,d,r]),useEffect(()=>{if(!(d&&o))return;let T=f.current;if(!T)return;let S=T.clientWidth,X=T.clientHeight;if(!(S>0&&X>0))return;let Y=Math.min(S/o.width,X/o.height,1);!(Y>0)||Number.isNaN(Y)||(k(Y),b(Math.min(r,Y)),Q||(I(Y),B({x:0,y:0})));},[o,Q,d,r]),useEffect(()=>{d&&F(false);},[d]),useEffect(()=>{let T=f.current;if(T)return T.addEventListener("wheel",Z,{passive:false}),()=>{T.removeEventListener("wheel",Z);}},[Z]),useEffect(()=>{let T=y.current;if(T&&R)return document.body.style.userSelect="none",T.addEventListener("pointermove",re,{passive:false}),T.addEventListener("pointerup",V),T.addEventListener("pointercancel",V),()=>{document.body.style.userSelect="",T.removeEventListener("pointermove",re),T.removeEventListener("pointerup",V),T.removeEventListener("pointercancel",V);}},[R,re,V]),jsxs("div",{className:g("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:f,style:{cursor:R?"grabbing":"grab"},children:[l?jsxs("div",{className:g("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",c?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:g("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>=s,onClick:te,title:"Zoom in",type:"button",children:jsx(u,{size:16})}),jsx("button",{className:g("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<=x,onClick:J,title:"Zoom out",type:"button",children:jsx(m,{size:16})}),jsx("button",{className:g("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:be,title:"Reset zoom and pan",type:"button",children:jsx(p,{size:16})})]}):null,jsx("div",{className:g("flex-1 origin-center transition-transform duration-150 ease-out",c?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:ye,ref:y,role:"application",style:{transform:`translate(${j.x}px, ${j.y}px) scale(${M})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Wo=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=w(),[a,l]=useState(null),[i,d]=useState(false),[c,p]=useState(""),[u,m]=useState(null),[g,f]=useState(""),[y,h]=useState(0),{mermaid:k}=useContext(N),x=Ie(),b=k==null?void 0:k.errorComponent,{shouldRender:M,containerRef:I}=Qt({immediate:n});if(useEffect(()=>{if(!M)return;if(!x){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),d(!0);let R=x.getMermaid(o),_=e.split("").reduce((U,he)=>(U<<5)-U+he.charCodeAt(0)|0,0),Q=`mermaid-${Math.abs(_)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:F}=await R.render(Q,e),q=Rt(F),ee=n?F:jo(F);p(ee),m(q),f(ee);}catch(R){if(!(g||c)){let _=R instanceof Error?R.message:"Failed to render Mermaid chart";l(_);}}finally{d(false);}})();},[e,o,y,M,x]),!(M||c||g))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:I});if(i&&!c&&!g)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:I,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(a&&!c&&!g){let B=()=>h(R=>R+1);return b?jsx("div",{ref:I,children:jsx(b,{chart:e,error:a,retry:B})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:I,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let j=c||g;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:I,children:jsx(wr,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:u,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:j},role:"img"})})})};export{ki as A,Wt as B,xi as C,hr as D,Li as E,ht as a,He as b,yt as c,mo as d,Ct as e,xt as f,uc as g,vt as h,Ue as i,Ye as j,Pt as k,Qe as l,N as m,Wo as n,Le as o,ve as p,Et as q,ot as r,Te as s,ze as t,na as u,$e as v,it as w,jn as x,ct as y,$t as z};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {m,g,d}from'./chunk-TA335CDR.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e,maxHeight:h,raw:t,className:m$1,startLine:d$1,lineNumbers:a,...p})=>{let{shikiTheme:r}=useContext(m),i=g(),[c,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let l=i.highlight({code:s,language:e,themes:r},H=>{o(H);});l&&o(l);},[s,e,r,i,t]),jsx(d,{className:m$1,language:e,lineNumbers:a,maxHeight:h,result:c,startLine:d$1,...p})};export{x as HighlightedCodeBlockBody};
2
+ import {m,g,d}from'./chunk-WRHXGPDT.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e,maxHeight:h,raw:t,className:m$1,startLine:d$1,lineNumbers:a,...p})=>{let{shikiTheme:r}=useContext(m),i=g(),[c,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let l=i.highlight({code:s,language:e,themes:r},H=>{o(H);});l&&o(l);},[s,e,r,i,t]),jsx(d,{className:m$1,language:e,lineNumbers:a,maxHeight:h,result:c,startLine:d$1,...p})};export{x as HighlightedCodeBlockBody};
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{D as Block,h as CodeBlock,e as CodeBlockContainer,j as CodeBlockCopyButton,k as CodeBlockDownloadButton,f as CodeBlockHeader,l as CodeBlockSkeleton,E as Streamdown,m as StreamdownContext,t as TableCopyDropdown,u as TableDownloadButton,v as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,B as defaultRehypePlugins,C as defaultRemarkPlugins,i as defaultTranslations,x as defaultUrlTransform,w as detectTextDirection,r as escapeMarkdownTableCell,o as extractTableDataFromElement,A as normalizeHtmlIndentation,y as parseMarkdownIntoBlocks,z as parseMarkdownIntoBlocksIncremental,p as tableDataToCSV,s as tableDataToMarkdown,q as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-TA335CDR.js';
2
+ export{D as Block,h as CodeBlock,e as CodeBlockContainer,j as CodeBlockCopyButton,k as CodeBlockDownloadButton,f as CodeBlockHeader,l as CodeBlockSkeleton,E as Streamdown,m as StreamdownContext,t as TableCopyDropdown,u as TableDownloadButton,v as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,B as defaultRehypePlugins,C as defaultRemarkPlugins,i as defaultTranslations,x as defaultUrlTransform,w as detectTextDirection,r as escapeMarkdownTableCell,o as extractTableDataFromElement,A as normalizeHtmlIndentation,y as parseMarkdownIntoBlocks,z as parseMarkdownIntoBlocksIncremental,p as tableDataToCSV,s as tableDataToMarkdown,q as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-WRHXGPDT.js';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{n as Mermaid}from'./chunk-WRHXGPDT.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/streamdown",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -49,8 +49,8 @@
49
49
  "shiki": "^3.19.0",
50
50
  "tsup": "^8.5.1",
51
51
  "vitest": "^4.0.15",
52
- "@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
53
52
  "@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3",
53
+ "@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
54
54
  "@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2"
55
55
  },
56
56
  "peerDependencies": {
@@ -1,2 +0,0 @@
1
- "use client";
2
- export{n as Mermaid}from'./chunk-TA335CDR.js';