@lofcz/streamdown 2.10.0 → 2.10.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.
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidElement,useLayoutEffect,useId,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Ko from'rehype-raw';import Hr,{defaultSchema}from'rehype-sanitize';import nl from'remark-gfm';import rl from'remend';import {visitParents,SKIP as SKIP$1}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 ia from'remark-parse';import la from'remark-rehype';import {unified}from'unified';import {visit,SKIP}from'unist-util-visit';import {Lexer}from'marked';import {toText}from'hast-util-to-text';var Zr=300,Kr="300px",Gr=500;function lo(e={}){let{immediate:t=false,debounceDelay:o=Zr,rootMargin:n=Kr,idleTimeout:r=Gr}=e,[a,s]=useState(false),l=useRef(null),i=useRef(null),c=useRef(null),d=useMemo(()=>m=>{let f=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-f))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,f)=>window.requestIdleCallback(m,f):d,[d]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?m=>window.cancelIdleCallback(m):m=>{clearTimeout(m);},[]);return useEffect(()=>{if(t){s(true);return}let m=l.current;if(!m)return;i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);let f=()=>{i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);},g=k=>{c.current=p(T=>{T.timeRemaining()>0||T.didTimeout?(s(true),k.disconnect()):c.current=p(()=>{s(true),k.disconnect();},{timeout:r/2});},{timeout:r});},b=k=>{f(),i.current=window.setTimeout(()=>{var S,x;let T=k.takeRecords();(T.length===0||(x=(S=T.at(-1))==null?void 0:S.isIntersecting)!=null&&x)&&g(k);},o);},h=(k,T)=>{k.isIntersecting?b(T):f();},y=new IntersectionObserver(k=>{for(let T of k)h(T,y);},{rootMargin:n,threshold:0});return y.observe(m),()=>{i.current&&clearTimeout(i.current),c.current&&u(c.current),y.disconnect();}},[t,o,n,r,u,p]),{shouldRender:a,containerRef:l}}var Xr=320,Ur=4,uo=()=>typeof performance=="undefined"?Date.now():performance.now();function Pt(e){var a,s;let t=(a=e==null?void 0:e.now)!=null?a:uo,o=(s=e==null?void 0:e.maxBacklogMs)!=null?s:Xr,n=0,r=0;return {now:t,beginPass(l){r=Math.min(Math.max(n,l),l+o);},mark(){return r},rewind(l){r=l;},take(l,i,c){if(l<=0)return {baseDelay:0,step:Math.max(0,i)};let d=Math.max(0,i),p=d===0?0:Math.min(d,Ur),u=Math.max(r,c),m=c+o,f=u+Math.max(0,l-1)*d,g=d;if(f>m&&l>1)if(u<m){let h=m-u;g=Math.max(p,h/(l-1));}else g=p;let b=Math.max(0,Math.round(u-c));return r=u+l*g,{baseDelay:b,step:g}},commitPass(){n=r;}}}function Jr(){return {current:0}}var po=/\s/,Mt=/^\s+$/,Yr=new Set(["code","pre","svg","math","annotation"]),Qr=new Set(["svg","math","annotation"]),Tt=new Set(["img","hr"]),es=new Set(["ul","ol","li"]),Me=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",St=(e,t)=>{let o=t?Qr:Yr;return e.some(n=>Me(n)&&o.has(n.tagName))},ts=e=>{for(let t=e.length-1;t>=0;t-=1){let o=e[t];if(Me(o)&&o.tagName==="li")return o}},os=(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}`;},fo=e=>{for(let t of e.children)if(Me(t)){if(t.tagName==="input")return t;if(es.has(t.tagName))continue;let o=fo(t);if(o)return o}},go=(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`;},ns=(e,t,o,n)=>{let r=fo(e);r&&go(r,t,o,n);},bo=e=>{var t;for(let o=e.length-1;o>=0;o-=1){let n=e[o];if(Me(n)){if((t=n.properties)!=null&&t["data-sd-animated"])break;n.properties={...n.properties,"data-sd-animated":true};}}},ho=e=>{let t=[],o="",n=false;for(let r of e){let a=po.test(r);if(a!==n&&o){if(a){o+=r,n=true;continue}t.push(o),o="";}o+=r,n=a;}return o&&t.push(o),t},yo=e=>{let t=[],o="";for(let n of e)po.test(n)?t.length>0&&!Mt.test(t.at(-1))?t[t.length-1]+=n:o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&(t.length>0?t[t.length-1]+=o:t.push(o)),t},rs=(e,t,o,n,r,a)=>{let s=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;return a&&(s+=`;--sd-delay:${Math.round(a)}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:s},children:[{type:"text",value:e}]}},ss=(e,t,o,n)=>{let r=0,a=0;return visitParents(e,s=>s.type==="text"||Me(s)&&Tt.has(s.tagName),(s,l)=>{if(St(l,o.animateCodeBlocks))return SKIP$1;if(Me(s)&&Tt.has(s.tagName)){n>0&&a<n||(r+=1);return}let i=s.value;if(!i.trim()){a+=i.length;return}let c=t.sep==="char"?yo(i):ho(i);for(let d of c){let p=a;a+=d.length,!Mt.test(d)&&(n>0&&p<n||(r+=1));}}),r},as=(e,t,o,n,r,a)=>{if(St(t,n.animateCodeBlocks))return;let s=n.prevContentLength,l=s>0&&r.count<s,i=l?0:a.baseDelay+r.newIndex++*a.step;go(e,o,l?0:o.duration,i),bo(t);},is=(e,t,o,n,r,a)=>{var h;let s=t.at(-1);if(!(s&&"children"in s))return;if(St(t,n.animateCodeBlocks))return SKIP$1;let l=s,i=l.children.indexOf(e);if(i===-1)return;let c=e.value;if(!c.trim()){r.count+=c.length;return}let d=o.sep==="char"?yo(c):ho(c),p=n.prevContentLength,u=false,m=ts(t),f=!!(m&&!((h=m.properties)!=null&&h["data-sd-animate-marker"])),g=false,b=d.map(y=>{let k=r.count;if(r.count+=y.length,Mt.test(y))return {type:"text",value:y};let T=p>0&&k<p,M=T?0:a.baseDelay+r.newIndex++*a.step;if(m&&f&&!g){let S=T?0:o.duration;os(m,S,M,o.easing),ns(m,o,S,M),g=true;}return u=true,rs(y,o.animation,o.duration,o.easing,T,M)});return u&&bo(t),l.children.splice(i,1,...b),i+b.length},ls=0;function nt(e){var a,s,l,i,c;let t={animation:(a=e==null?void 0:e.animation)!=null?a:"fadeIn",duration:(s=e==null?void 0:e.duration)!=null?s:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(c=e==null?void 0:e.stagger)!=null?c:40,timeline:e==null?void 0:e.timeline},o={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},n=ls++,r=()=>d=>{var g;let p={count:0,newIndex:0};o.prevContentLength=o.committedCharCount;let u=t.timeline,m=(g=u==null?void 0:u.now())!=null?g:uo();u&&(o.pendingMark===null?o.pendingMark=u.mark():u.rewind(o.pendingMark));let f=u?u.take(ss(d,t,o,o.prevContentLength),t.stagger,m):{baseDelay:0,step:t.stagger};visitParents(d,b=>b.type==="text"||Me(b)&&Tt.has(b.tagName),(b,h)=>{if(b.type==="text")return is(b,h,t,o,p,f);as(b,h,t,o,p,f);}),o.lastRenderCharCount=p.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){o.animateCodeBlocks=d;},setPrevContentLength(d){o.committedCharCount=d,o.prevContentLength=d;},getLastRenderCharCount(){return o.lastRenderCharCount},commit(){o.committedCharCount=o.lastRenderCharCount,o.pendingMark=null;}}}nt();var It=createContext(false),Rt=()=>useContext(It);var Ae=(...e)=>twMerge(clsx(e)),rt=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},ms=(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(" ")},ko=e=>e?(...t)=>ms(e,twMerge(clsx(t))):Ae,se=(e,t,o)=>{let n=typeof t=="string"&&o.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([n+t],{type:o}):t,a=URL.createObjectURL(r),s=document.createElement("a");s.href=a,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(a);};var st=createContext(Ae),w=()=>useContext(st);var Fe=({scrollRef:e,...t})=>jsx("div",{ref:e,...t});var hs=Ae("block"),ys=Ae("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"),Cs=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),a=o.slice(n+1).trim();r&&a&&(t[r]=a);}}return t},vo=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:a,lineNumbers:s=true,...l})=>{let i=w(),{isAnimating:c,scrollable:d}=useContext(I),p=d!=null?d:Fe,u=useRef(null),m=useRef(true),f=rt(r);useEffect(()=>{let y=u.current;if(!(y&&f))return;let k=()=>{let T=y.scrollHeight-y.scrollTop-y.clientHeight<8;m.current=T;};return y.addEventListener("scroll",k,{passive:true}),()=>y.removeEventListener("scroll",k)},[f]),useEffect(()=>{let y=u.current;y&&f&&c&&m.current&&y.scrollTo({top:y.scrollHeight,behavior:"instant"});},[c,f]),useEffect(()=>{c||(m.current=true);},[c]);let g=useMemo(()=>i(ys),[i]),b=useMemo(()=>i(hs),[i]),h=useMemo(()=>{let y={};return t.bg&&(y["--sdm-bg"]=t.bg),t.fg&&(y["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(y,Cs(t.rootStyle)),y},[t.bg,t.fg,t.rootStyle]);return jsx(p,{className:i(n,f?"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",scrollRef:u,style:f?{maxHeight:f}: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:h,children:jsx("code",{className:s?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&a&&a>1?{counterReset:`line ${a-1}`}:void 0,children:t.tokens.map((y,k)=>jsx("span",{className:s?g:b,children:y.length===0||y.length===1&&y[0].content===""?`
3
+ `:y.map((T,M)=>{let S={},x=!!T.bgColor;if(T.color&&(S["--sdm-c"]=T.color),T.bgColor&&(S["--sdm-tbg"]=T.bgColor),T.htmlStyle)for(let[_,D]of Object.entries(T.htmlStyle))_==="color"?S["--sdm-c"]=D:_==="background-color"?(S["--sdm-tbg"]=D,x=true):S[_]=D;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",x&&"bg-[var(--sdm-tbg)]",x&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...T.htmlAttrs,children:T.content},M)})},k))})})})});var Nt=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let a=w();return jsx("div",{className:a("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 At=createContext({code:""}),at=()=>useContext(At);var Dt=({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 Ms=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
+ `;)t--;return e.slice(0,t)},Ss=lazy(()=>import('./highlighted-body-BXQQW6YV.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Ht=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:a,lineNumbers:s,...l})=>{let i=w(),{codeBlockMaxHeight:c}=useContext(I),d=useMemo(()=>Ms(e),[e]),p=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
5
+ `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(At.Provider,{value:{code:e},children:jsxs(Nt,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(Dt,{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(vo,{className:o,language:t,lineNumbers:s,maxHeight:c,result:p,startLine:a,...l}),children:jsx(Ss,{className:o,code:d,language:t,lineNumbers:s,maxHeight:c,raw:p,startLine:a,...l})})]})})};var Mo=e=>jsx("svg",{"aria-hidden":"true",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"})}),So=e=>jsx("svg",{"aria-hidden":"true",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"})}),Io=e=>jsx("svg",{"aria-hidden":"true",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"})}),Ro=e=>jsxs("svg",{"aria-hidden":"true",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"})]}),Eo=e=>jsx("svg",{"aria-hidden":"true",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"})}),Lo=e=>jsx("svg",{"aria-hidden":"true",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"})}),No=e=>jsx("svg",{"aria-hidden":"true",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"})}),Ao=e=>jsx("svg",{"aria-hidden":"true",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"})}),Do=e=>jsx("svg",{"aria-hidden":"true",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"})}),Ho=e=>jsx("svg",{"aria-hidden":"true",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 $e={CheckIcon:Mo,CopyIcon:So,DownloadIcon:Io,ExternalLinkIcon:Ao,Loader2Icon:Ro,Maximize2Icon:Eo,RotateCcwIcon:Lo,XIcon:No,ZoomInIcon:Do,ZoomOutIcon:Ho},Oo=createContext($e),Ns=(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])},Bt=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...$e,...e}:$e);Ns(o.current,e)||(o.current=e,n.current=e?{...$e,...e}:$e);let r=n.current;return jsx(Oo.Provider,{value:r,children:t})},B=()=>useContext(Oo);var it={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",zoomIn:"Zoom in",zoomOut:"Zoom out",resetView:"Reset zoom and pan",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"},lt=createContext(it),O=()=>useContext(lt);var ct=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:a,...s})=>{let l=w(),[i,c]=useState(false),d=useRef(0),{code:p}=at(),{isAnimating:u}=useContext(I),m=O(),f=a!=null?a:p,g=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(f),c(!0),e==null||e(),d.current=window.setTimeout(()=>c(!1),o));}catch(k){t==null||t(k);}};useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let b=B(),h=i?b.CheckIcon:b.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":m.copyCode,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:g,title:m.copyCode,type:"button",...s,children:n!=null?n:jsx(h,{"aria-hidden":"true",size:14})}),i&&jsx("output",{"aria-live":"polite",className:"sr-only",children:m.copied})]})};var _o={"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"},_t=({onDownload:e,onError:t,language:o,children:n,className:r,code:a,...s})=>{let l=w(),{code:i}=at(),{isAnimating:c}=useContext(I),d=O(),p=B(),u=a!=null?a:i,f=`file.${o&&o in _o?_o[o]:"txt"}`,g="text/plain",b=()=>{try{se(f,u,g),e==null||e();}catch(h){t==null||t(h);}};return jsx("button",{"aria-label":d.downloadFile,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:c,onClick:b,title:d.downloadFile,type:"button",...s,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var dt=()=>{let{Loader2Icon:e}=B(),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 We=0,be=()=>{We+=1,We===1&&(document.body.style.overflow="hidden");},he=()=>{We=Math.max(0,We-1),We===0&&(document.body.style.overflow="");};var qs=["github-light","github-dark"],Zs={enabled:true},Ks={codeBlockMaxHeight:400,shikiTheme:qs,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:Zs,tableMaxHeight:300},I=createContext(Ks);var Js=/\.[^/.]+$/,Fo=(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},zo=({node:e,className:t,src:o,alt:n,onLoad:r,onError:a,onClick:s,...l})=>{let{DownloadIcon:i,XIcon:c}=B(),d=w(),p=useRef(null),[u,m]=useState(false),[f,g]=useState(false),[b,h]=useState(false),{controls:y}=useContext(I),k=O(),T=Fo(y,"download"),M=Fo(y,"fullscreen"),S=l.width!=null||l.height!=null,x=T&&(u||S)&&!f,_=f&&!S,D=M&&!!o&&!f&&u;useEffect(()=>{let E=p.current;if(E!=null&&E.complete){let $=E.naturalWidth>0;m($),g(!$);}},[]),useEffect(()=>{if(!b)return;be();let E=$=>{$.key==="Escape"&&h(false);};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),he();}},[b]);let F=useCallback(E=>{m(true),g(false),r==null||r(E);},[r]),W=useCallback(E=>{m(false),g(true),a==null||a(E);},[a]),H=useCallback(()=>{D&&h(true);},[D]),z=useCallback(()=>{h(false);},[]),q=useCallback(E=>{s==null||s(E),!E.defaultPrevented&&H();},[s,H]),Y=async E=>{if(E.stopPropagation(),!!o)try{let ie=await(await fetch(o)).blob(),oe=new URL(o,window.location.origin).pathname.split("/").pop()||"",de=oe.split(".").pop(),ne=oe.includes(".")&&de!==void 0&&de.length<=4,ee="";if(ne)ee=oe;else {let V=ie.type,P="png";V.includes("jpeg")||V.includes("jpg")?P="jpg":V.includes("png")?P="png":V.includes("svg")?P="svg":V.includes("gif")?P="gif":V.includes("webp")&&(P="webp"),ee=`${(n||oe||"image").replace(Js,"")}.${P}`;}se(ee,ie,ie.type);}catch($){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:d("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:d("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:d("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:d("m-0 block h-auto max-w-full rounded-lg",D&&"cursor-zoom-in",_&&"hidden",t),"data-streamdown":"image",onClick:q,onError:W,onLoad:F,ref:p,src:o,...l}),_&&jsx("span",{className:d("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:k.imageNotAvailable}),x&&jsx("button",{className:d("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:Y,title:k.downloadImage,type:"button",children:jsx(i,{size:14})})]}),b?createPortal(jsxs("div",{className:d("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:z,onKeyDown:E=>{E.key==="Escape"&&z();},role:"button",tabIndex:0,children:[jsx("button",{className:d("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:z,title:k.exitFullscreen,type:"button",children:jsx(c,{size:20})}),jsx("div",{onClick:E=>E.stopPropagation(),onKeyDown:E=>E.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:d("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var qo=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:a,ExternalLinkIcon:s,XIcon:l}=B(),i=w(),[c,d]=useState(false),p=O(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(g){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){be();let g=b=>{b.key==="Escape"&&o();};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),he();}}},[t,o]),!t||typeof document=="undefined")return null;let f=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:g=>{g.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:g=>g.stopPropagation(),onKeyDown:g=>g.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(s,{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:c?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(a,{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(s,{size:14}),jsx("span",{children:p.openLink})]})]})]})});return createPortal(f,document.body)};var Zo=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var Go=[],Xo={allowDangerousHtml:true},mt=new WeakMap,$t=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,a=t.remarkRehypeOptions;if(!(n||r||a)){let p="default";return this.keyCache.set(t,p),p}let s=p=>{if(!p||p.length===0)return "";let u="";for(let m=0;m<p.length;m+=1){let f=p[m];if(m>0&&(u+=","),Array.isArray(f)){let[g,b]=f;if(typeof g=="function"){let h=mt.get(g);h||(h=g.name,mt.set(g,h)),u+=h;}else u+=String(g);u+=":",u+=JSON.stringify(b);}else if(typeof f=="function"){let g=mt.get(f);g||(g=f.name,mt.set(f,g)),u+=g;}else u+=String(f);}return u},l=s(n),i=s(r),c=a?JSON.stringify(a):"",d=`${i}::${l}::${c}`;return this.keyCache.set(t,d),d}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();}},Uo=new $t,Ze=e=>{let t=ma(e),o=e.children||"",n=t.runSync(t.parse(o),o);return ha(n,e)},ma=e=>{let t=Uo.get(e);if(t)return t;let o=pa(e);return Uo.set(e,o),o},ua=e=>e.some(t=>Array.isArray(t)?t[0]===Ko:t===Ko),pa=e=>{let t=e.rehypePlugins||Go,o=e.remarkPlugins||Go,n=ua(t)?o:[...o,Zo],r=e.remarkRehypeOptions?{...Xo,...e.remarkRehypeOptions}:Xo;return unified().use(ia).use(n).use(la,r).use(t)},Jo=e=>e,fa=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},ga=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],a=urlAttributes[n];(a===null||a.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},ba=(e,t,o,n,r,a)=>{let s=false;return n?s=!n.includes(e.tagName):r&&(s=r.includes(e.tagName)),!s&&a&&typeof t=="number"&&(s=!a(e,t,o)),s},ha=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:a,unwrapDisallowed:s,urlTransform:l}=t;if(o||n||r||a||l){let c=l||Jo;visit(e,(d,p,u)=>{if(d.type==="raw"&&u&&typeof p=="number")return fa(u,p,a,d.value),p;if(d.type==="element"&&(ga(d,c),ba(d,p,u,n,r,o)&&u&&typeof p=="number"))return s&&d.children?u.children.splice(p,1,...d.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 ut=createContext(null),Wt=()=>useContext(ut),ud=()=>{var t;let e=Wt();return (t=e==null?void 0:e.code)!=null?t:null},De=()=>{var t;let e=Wt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Yo=e=>{var o;let t=Wt();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 wa=/(<svg\b)/,tn=/<svg\b[^>]*>/i,ka=/\bviewBox=(['"])(.*?)\1/i,xa=/\swidth=(['"]).*?\1/i,va=/\sheight=(['"]).*?\1/i,Qo=/\sstyle=(['"])(.*?)\1/i,en=/^<svg/i,Ta=/^width\s*:/i,Pa=/^height\s*:/i,Ma=/^max-width\s*:/i,Sa=/[\s,]+/,Ia=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(wa,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),on=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},qt=e=>{let t=e.match(tn);if(!t)return null;let n=t[0].match(ka),r=n==null?void 0:n[2];if(!r)return null;let a=r.trim().split(Sa).map(i=>Number.parseFloat(i));if(a.length<4||a.slice(0,4).some(Number.isNaN))return null;let s=a[2],l=a[3];return s>0&&l>0?{height:l,width:s}:null},nn=e=>{let t=e.match(tn);if(!t)return e;try{let o=t[0],n=qt(e);if(!n)return e;let{width:r,height:a}=n,s=o.replace(xa,"").replace(va,""),l=s.match(Qo),i=`width:${r}px;height:${a}px;max-width:none;`;if(l){let c=l[1],p=l[2].split(";").map(m=>m.trim()).filter(Boolean).filter(m=>!(Ta.test(m)||Pa.test(m)||Ma.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;s=s.replace(Qo,` style=${c}${u}${c}`);}else s=s.replace(en,`<svg style="${i}"`);return s=s.replace(en,`<svg width="${r}" height="${a}"`),e.replace(o,s)}catch(o){return e}},rn=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,a)=>{let s=Ia(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(s))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let c=document.createElement("canvas"),d=i.width*o,p=i.height*o;c.width=d,c.height=p;let u=c.getContext("2d");if(!u){a(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,d,p),c.toBlob(m=>{if(!m){a(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},i.onerror=()=>a(new Error("Failed to load SVG image")),i.src=l;})};var pt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:a})=>{let s=w(),[l,i]=useState(false),c=useRef(null),{isAnimating:d}=useContext(I),p=B(),u=De(),m=O(),f=async g=>{try{if(g==="mmd"){se("diagram.mmd",e,"text/plain"),i(!1),n==null||n(g);return}if(!u){a==null||a(new Error("Mermaid plugin not available"));return}let b=u.getMermaid(r),h=e.split("").reduce((M,S)=>(M<<5)-M+S.charCodeAt(0)|0,0),y=`mermaid-${Math.abs(h)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:k}=await b.render(y,e);if(!k){a==null||a(new Error("SVG not found. Please wait for the diagram to render."));return}let T=on(k);if(g==="svg"){se("diagram.svg",T,"image/svg+xml"),i(!1),n==null||n(g);return}if(g==="png"){let M=await rn(T);se("diagram.png",M,"image/png"),n==null||n(g),i(!1);return}}catch(b){a==null||a(b);}};return useEffect(()=>{let g=b=>{let h=b.composedPath();c.current&&!h.includes(c.current)&&i(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g);}},[]),jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{"aria-label":m.downloadDiagram,className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d,onClick:()=>i(!l),title:m.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),l?jsxs("div",{className:s("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",{"aria-label":m.downloadDiagramAsSvg,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{"aria-label":m.downloadDiagramAsPng,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{"aria-label":m.downloadDiagramAsMmd,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var cn=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...a})=>{let{Maximize2Icon:s,XIcon:l}=B(),i=w(),[c,d]=useState(false),{isAnimating:p,controls:u}=useContext(I),m=O(),f=(()=>{if(typeof u=="boolean")return u;let h=u.mermaid;return h===false?false:h===true||h===void 0?true:h.panZoom!==false})(),g=(()=>{if(typeof u=="boolean")return u;let h=u.mermaid;return h===false?false:h===true||h===void 0?true:h.download!==false})(),b=()=>{d(!c);};return useEffect(()=>{if(c){be();let h=y=>{y.key==="Escape"&&d(false);};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),he();}}},[c]),useEffect(()=>{c?o==null||o():n&&n();},[c,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:b,title:m.viewFullscreen,type:"button",...a,"aria-label":m.viewFullscreen,children:jsx(s,{"aria-hidden":"true",size:14})}),c?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:b,onKeyDown:h=>{h.key==="Escape"&&b();},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:[g?jsx(pt,{chart:e,config:t}):null,jsx("button",{"aria-label":m.exitFullscreen,className:i("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:b,title:m.exitFullscreen,type:"button",children:jsx(l,{"aria-hidden":"true",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(ln,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:f})})]}),document.body):null]})};function Kt(e){var o;if(e.nodeType===Node.TEXT_NODE)return (o=e.textContent)!=null?o:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
6
+ `:Array.from(t.childNodes).map(Kt).join("")}var He=e=>{let t=[],o=[],n=e.querySelectorAll("thead th");for(let a of n)t.push(Kt(a).trim());let r=e.querySelectorAll("tbody tr");for(let a of r){let s=[],l=a.querySelectorAll("td");for(let i of l)s.push(Kt(i).trim());o.push(s);}return {headers:t,rows:o}},Ee=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,c=false;for(let d of l){if(d==='"'){i=true,c=true;break}(d===","||d===`
7
+ `)&&(i=true);}return i?c?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?o.length+1:o.length,a=new Array(r),s=0;t.length>0&&(a[s]=t.map(n).join(","),s+=1);for(let l of o)a[s]=l.map(n).join(","),s+=1;return a.join(`
8
+ `)},Gt=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let d of l)if(d===" "||d===`
9
+ `||d==="\r"){i=true;break}if(!i)return l;let c=[];for(let d of l)d===" "?c.push("\\t"):d===`
10
+ `?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.join("")},r=t.length>0?o.length+1:o.length,a=new Array(r),s=0;t.length>0&&(a[s]=t.map(n).join(" "),s+=1);for(let l of o)a[s]=l.map(n).join(" "),s+=1;return a.join(`
11
+ `)},ft=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"||n===`
12
+ `){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):n===`
13
+ `?o.push("<br>"):o.push(n);return o.join("")},Le=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,a=t.map(l=>ft(l));n[r]=`| ${a.join(" | ")} |`,r+=1;let s=new Array(t.length);for(let l=0;l<t.length;l+=1)s[l]="---";n[r]=`| ${s.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]=c<l.length?ft(l[c]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>ft(c));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
14
+ `)};var Xe=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let a=w(),[s,l]=useState(false),[i,c]=useState(false),d=useRef(null),p=useRef(0),{isAnimating:u}=useContext(I),m=O(),f=async h=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){n==null||n(new Error("Clipboard API not available"));return}try{let T=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),M=T==null?void 0:T.querySelector("table");if(!M){n==null||n(new Error("Table not found"));return}let S=He(M),D=({csv:Ee,tsv:Gt,md:Le}[h]||Le)(S),F=new ClipboardItem({"text/plain":new Blob([D],{type:"text/plain"}),"text/html":new Blob([M.outerHTML],{type:"text/html"})});await navigator.clipboard.write([F]),c(!0),l(!1),o==null||o(h),p.current=window.setTimeout(()=>c(!1),r);}catch(T){n==null||n(T);}};useEffect(()=>{let h=y=>{let k=y.composedPath();d.current&&!k.includes(d.current)&&l(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h),window.clearTimeout(p.current);}},[]);let g=B(),b=i?g.CheckIcon:g.CopyIcon;return 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",t),disabled:u,onClick:()=>l(!s),title:m.copyTable,type:"button",children:e!=null?e:jsx(b,{height:14,width:14})}),s?jsxs("div",{className:a("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:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("md"),title:m.copyTableAsMarkdown,type:"button",children:m.tableFormatMarkdown}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("csv"),title:m.copyTableAsCsv,type:"button",children:m.tableFormatCsv}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var za=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:a})=>{let s=w(),{isAnimating:l}=useContext(I),i=O(),c=B(),d=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=m==null?void 0:m.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let g=He(f),b="",h="",y="";switch(r){case "csv":b=Ee(g),h="text/csv",y="csv";break;case "markdown":b=Le(g),h="text/markdown",y="md";break;default:b=Ee(g),h="text/csv",y="csv";}se(`${a||"table"}.${y}`,b,h),o==null||o();}catch(u){n==null||n(u);}};return 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:l,onClick:d,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})})},Ue=({children:e,className:t,onDownload:o,onError:n})=>{let r=w(),[a,s]=useState(false),l=useRef(null),{isAnimating:i}=useContext(I),c=O(),d=B(),p=u=>{var m;try{let f=(m=l.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=f==null?void 0:f.querySelector("table");if(!g){n==null||n(new Error("Table not found"));return}let b=He(g),h=u==="csv"?Ee(b):Le(b);se(`table.${u==="csv"?"csv":"md"}`,h,u==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(u);}catch(f){n==null||n(f);}};return useEffect(()=>{let u=m=>{let f=m.composedPath();l.current&&!f.includes(l.current)&&s(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:()=>s(!a),title:c.downloadTable,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})}),a?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:c.downloadTableAsCsv,type:"button",children:c.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:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})};var gn=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:a}=B(),s=w(),[l,i]=useState(false),{isAnimating:c}=useContext(I),d=O(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){be();let m=f=>{f.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),he();}}},[l]),jsxs(Fragment,{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:c,onClick:p,title:d.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":d.viewFullscreen,"aria-modal":"true",className:s("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:s("flex h-full flex-col"),onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:[jsxs("div",{className:s("flex items-center justify-end gap-1 p-4"),children:[o?jsx(Xe,{}):null,n?jsx(Ue,{}):null,jsx("button",{className:s("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:d.exitFullscreen,type:"button",children:jsx(a,{size:20})})]}),jsx("div",{className:s("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:s("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var yn=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:a=true,showFullscreen:s=true,...l})=>{let i=w(),{isAnimating:c,scrollable:d}=useContext(I),p=d!=null?d:Fe,u=useRef(null),m=useRef(true),f=rt(o);useEffect(()=>{let k=u.current;if(!(k&&f))return;let T=()=>{let M=k.scrollHeight-k.scrollTop-k.clientHeight<8;m.current=M;};return k.addEventListener("scroll",T,{passive:true}),()=>k.removeEventListener("scroll",T)},[f]),useEffect(()=>{let k=u.current;k&&f&&c&&m.current&&k.scrollTo({top:k.scrollHeight,behavior:"instant"});}),useEffect(()=>{c||(m.current=true);},[c]);let g=n&&r,b=n&&a,h=n&&s,y=g||b||h;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:[g?jsx(Xe,{}):null,b?jsx(Ue,{}):null,h?jsx(gn,{showCopy:g,showDownload:b,children:e}):null]}):null,jsx(p,{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:u,style:f?{maxHeight:f}:void 0,children:jsx("table",{className:i("w-full min-w-max table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var Qa=/startLine=(\d+)/,ei=/\bnoLineNumbers\b/,ti=lazy(()=>import('./mermaid-P2MAAXNP.js').then(e=>({default:e.Mermaid}))),oi=/language-([^\s]+)/,ce=e=>e.props,ni="node";function A(e,t){let o=Object.keys(e);if(o.length!==Object.keys(t).length)return false;let n=e,r=t;for(let a of o)if(a!==ni&&!Object.is(n[a],r[a]))return false;return true}function ri(e,t){var o,n;return ((o=e==null?void 0:e.properties)==null?void 0:o.metastring)===((n=t==null?void 0:t.properties)==null?void 0:n.metastring)}function si(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=ce(e).children;if(typeof t=="string")return t}}var Qt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Yt=(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},wn=(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},gt=(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},Ye=createContext({depth:0,ulDepth:0,isUnordered:false}),ai={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},eo=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:a,ulDepth:s}=useContext(Ye),l=useMemo(()=>({depth:a+1,ulDepth:s,isUnordered:false}),[a,s]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":a,"data-streamdown":"ordered-list",...n,children:jsx(Ye.Provider,{value:l,children:e})})},(e,t)=>A(e,t));eo.displayName="MarkdownOl";var Tn=memo(({children:e,className:t,node:o,...n})=>{var g;let r=w(),{depth:a,ulDepth:s,isUnordered:l}=useContext(Ye),{listStyle:i}=useContext(I),c=ai[i],d=l&&s>0?c[(s-1)%c.length]:void 0,p=Array.isArray(e)?e.filter(b=>b!==`
15
+ `&&b!==""):[e],u=p[0],m=isValidElement(u)?(g=ce(u).node)==null?void 0:g.tagName:void 0,f=p.length===1&&isValidElement(u)&&(u.type==="p"||m==="p")?ce(u).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":a>0?a-1:0,"data-streamdown":"list-item",...n,children:f}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":a>0?a-1:0,"data-streamdown":"list-item",...n,children:f})},(e,t)=>A(e,t));Tn.displayName="MarkdownLi";var Pn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:a,ulDepth:s}=useContext(Ye),l=useMemo(()=>({depth:a+1,ulDepth:s+1,isUnordered:true}),[a,s]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":a,"data-streamdown":"unordered-list",...n,children:jsx(Ye.Provider,{value:l,children:e})})},(e,t)=>A(e,t));Pn.displayName="MarkdownUl";var Mn=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)=>A(e,t));Mn.displayName="MarkdownHr";var Sn=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)=>A(e,t));Sn.displayName="MarkdownStrong";var ii=({children:e,className:t,href:o,node:n,...r})=>{let a=w(),{linkSafety:s}=useContext(I),[l,i]=useState(false),c=o==="streamdown:incomplete-link",d=useCallback(async f=>{if(!(!(s!=null&&s.enabled&&o)||c)){if(f.preventDefault(),s.onLinkCheck&&await s.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[s,o,c]),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 s!=null&&s.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:a("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),s.renderModal?s.renderModal(m):jsx(qo,{...m})]}):jsx("a",{className:a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},In=memo(ii,(e,t)=>A(e,t));In.displayName="MarkdownA";var Rn=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)=>A(e,t));Rn.displayName="MarkdownH1";var En=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)=>A(e,t));En.displayName="MarkdownH2";var Ln=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)=>A(e,t));Ln.displayName="MarkdownH3";var Nn=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)=>A(e,t));Nn.displayName="MarkdownH4";var An=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)=>A(e,t));An.displayName="MarkdownH5";var Dn=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)=>A(e,t));Dn.displayName="MarkdownH6";var Hn=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:a}=useContext(I),s=Qt(r,"table"),l=Yt(r,"copy"),i=Yt(r,"download"),c=Yt(r,"fullscreen");return jsx(yn,{className:t,maxHeight:a,showControls:s,showCopy:l,showDownload:i,showFullscreen:c,...n,children:e})},(e,t)=>A(e,t));Hn.displayName="MarkdownTable";var Bn=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)=>A(e,t));Bn.displayName="MarkdownThead";var On=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)=>A(e,t));On.displayName="MarkdownTbody";var _n=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)=>A(e,t));_n.displayName="MarkdownTr";var Vn=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)=>A(e,t));Vn.displayName="MarkdownTh";var jn=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)=>A(e,t));jn.displayName="MarkdownTd";var Fn=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)=>A(e,t));Fn.displayName="MarkdownBlockquote";var zn=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)=>A(e,t));zn.displayName="MarkdownSup";var li=()=>({}),ci=e=>{try{let t=atob(e),o=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder().decode(o)}catch(t){return ""}},$n=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{calloutIcon:a,calloutStyle:s,components:l,remarkPlugins:i,rehypePlugins:c}=useContext(I),d=n,p=d["data-callout-title"],u=d["data-callout-color"],m=d["data-callout-icon"],f=d["data-callout-body"],g=f?ci(f):"",b=(s!=null?s:li)(u),h=m&&a?a(m):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:b,...n,children:[p!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[h,p]}):null,g.trim().length>0?jsx(Ze,{components:l,rehypePlugins:c,remarkPlugins:i,children:g}):null]})},(e,t)=>A(e,t));$n.displayName="MarkdownCallout";var kn={"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"},Wn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),a=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx($n,{className:t,node:o,...n,children:e});if(a){let l=Object.keys(kn).find(i=>t==null?void 0:t.includes(i));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",l?kn[l]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>A(e,t));Wn.displayName="MarkdownDiv";var qn=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)=>A(e,t));qn.displayName="MarkdownSub";var Zn=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let a=i=>{if(!isValidElement(i))return false;let c=ce(i).children,d=Array.isArray(c)?c:[c],p=false,u=false;for(let m of d)if(m){if(typeof m=="string")m.trim()!==""&&(p=true);else if(isValidElement(m))if(ce(m)["data-footnote-backref"]!==void 0)u=true;else {let f=ce(m).children,g=Array.isArray(f)?f:[f];for(let b of g){if(typeof b=="string"&&b.trim()!==""){p=true;break}if(isValidElement(b)&&ce(b)["data-footnote-backref"]===void 0){p=true;break}}}}return u&&!p},s=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===eo){let c=ce(i).children,p=(Array.isArray(c)?c:[c]).filter(u=>!a(u));return p.length===0?null:{...i,props:{...ce(i),children:p}}}return i}):e;return (Array.isArray(s)?s.some(i=>i!==null):s!==null)?jsx("section",{className:t,...n,children:s}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>A(e,t));Zn.displayName="MarkdownSection";var di=({node:e,className:t,children:o,...n})=>{var W,H,z;let r=w(),a=!("data-block"in n),{mermaid:s,controls:l,lineNumbers:i}=useContext(I),c=De(),d=Rt(),p=t==null?void 0:t.match(oi),u=(W=p==null?void 0:p.at(1))!=null?W:"",m=Yo(u);if(a)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let f=(H=e==null?void 0:e.properties)==null?void 0:H.metastring,g=typeof f=="string"?f:void 0,b=g==null?void 0:g.match(Qa),h=b?Number.parseInt(b[1],10):void 0,y=h!==void 0&&h>=1?h:void 0,T=!(g?ei.test(g):false)&&i!==false,M=(z=si(o))!=null?z:"";if(m){let q=m.component;return jsx(Suspense,{fallback:jsx(dt,{}),children:jsx(q,{code:M,isIncomplete:d,language:u,meta:g})})}if(u==="mermaid"&&c){let q=Qt(l,"mermaid"),Y=gt(l,"download"),Q=gt(l,"copy"),E=gt(l,"fullscreen"),$=gt(l,"panZoom"),ie=q&&(Y||Q||E);return jsx(Suspense,{fallback:jsx(dt,{}),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-incomplete":d||void 0,"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"})}),ie?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:[Y?jsx(pt,{chart:M,config:s==null?void 0:s.config}):null,Q?jsx(ct,{code:M}):null,E?jsx(cn,{chart:M,config:s==null?void 0:s.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(ti,{chart:M,config:s==null?void 0:s.config,showControls:$})})]})})}let S=Qt(l,"code"),x=wn(l,"download"),_=wn(l,"copy"),{"data-block":D,...F}=n;return jsx(Ht,{className:t,code:M,isIncomplete:d,language:u,lineNumbers:T,startLine:y,...F,children:S?jsxs(Fragment,{children:[x?jsx(_t,{code:M,language:u}):null,_?jsx(ct,{}):null]}):null})},Kn=memo(di,(e,t)=>A(e,t)&&ri(e.node,t.node));Kn.displayName="MarkdownCode";var Gn=memo(zo,(e,t)=>A(e,t));Gn.displayName="MarkdownImg";var xn={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Xn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),a=O(),s=n["data-alert-type"],l=s&&s in xn?xn[s]:void 0,i=l?a[l]:void 0,c=e;return i&&(c=[...(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:c})},(e,t)=>A(e,t));Xn.displayName="MarkdownAlertTitle";var Un=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Xn,{className:t,node:o,...n,children:e});let a=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(a.length===1&&isValidElement(a[0])){let s=ce(a[0]).node,l=s==null?void 0:s.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&"data-block"in a[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>A(e,t));Un.displayName="MarkdownParagraph";var Jn={ol:eo,li:Tn,ul:Pn,hr:Mn,strong:Sn,a:In,h1:Rn,h2:En,h3:Ln,h4:Nn,h5:An,h6:Dn,table:Hn,thead:Bn,tbody:On,tr:_n,th:Vn,td:jn,blockquote:Fn,code:Kn,div:Wn,img:Gn,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:zn,sub:qn,p:Un,section:Zn};var mi=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ui=/\p{L}/u;function Qe(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,"").replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,""),o,n=0,r=0;for(let a of t){if(mi.test(a)){o!=null||(o="rtl"),r+=1;continue}ui.test(a)&&(o!=null||(o="ltr"),n+=1);}return r>n?"rtl":n>r?"ltr":o!=null?o:"ltr"}var pi=/^[ \t]{0,3}(`{3,}|~{3,})/;var Yn=e=>{let t=e.split(`
16
+ `),o=null,n=0;for(let r of t){let a=pi.exec(r);if(o===null){if(a){let s=a[1];o=s[0],n=s.length;}}else if(a){let s=a[1],l=s[0],i=s.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null};var gi=/\[\^[\w-]{1,200}\](?!:)/,bi=/\[\^[\w-]{1,200}\]:/;var hi=/<(\w+)[\s>]/,yi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Qn=new Map,er=new Map,nr=e=>{let t=e.toLowerCase(),o=Qn.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Qn.set(t,n),n},Ci=e=>{let t=e.toLowerCase(),o=er.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return er.set(t,n),n},tr=(e,t)=>{if(yi.has(t.toLowerCase()))return 0;let o=e.match(nr(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},or=(e,t)=>{let o=e.match(Ci(t));return o?o.length:0},wi=(e,t)=>{let o=e.match(nr(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},ki=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},ht=e=>{let t=gi.test(e),o=bi.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],a=[],s=false;for(let l of n){let i=l.raw,c=r.length;if(a.length>0){r[c-1]+=i;let d=a.at(-1),p=tr(i,d),u=or(i,d);for(let m=0;m<p;m+=1)a.push(d);for(let m=0;m<u;m+=1)a.length>0&&a.at(-1)===d&&a.pop();continue}if(l.type==="html"&&l.block){let d=i.match(hi);if(d){let p=d[1],u=tr(i,p),m=or(i,p);u>m&&!wi(i,p)&&a.push(p);}}if(c>0&&!s){let d=r[c-1];if(ki(d)%2===1){r[c-1]=d+i;continue}}r.push(i),l.type!=="space"&&(s=l.type==="code");}return r},to=(e,t,o=ht)=>{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 a=e.slice(0,r);if(n.join("")!==a)return {source:e,blocks:o(e)};let s=e.slice(r),l=o(s);return {source:e,blocks:[...n,...l]}};var rr=(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,(a,s)=>`<${n}${s}></${n}>`);}for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(a,s,l,i)=>{let c=l.includes(`
17
+
18
+ `),d=!l.startsWith(`
19
+ `),p=l.includes(`
20
+ `);if(!(c||d&&p))return s+l+i;let u=l.replace(/\n\n/g,`
21
+ <!---->
22
+ `),m=(u.startsWith(`
23
+ `)?"":`
24
+ `)+u+(u.endsWith(`
25
+ `)?"":`
26
+ `);return `${s}${m}${i}
27
+
28
+ `});}return o};var xi=/([\\`*_~[\]|])/g,vi=e=>e.replace(xi,"\\$1"),sr=(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,(a,s,l,i)=>{let c=vi(l).replace(/\n\n/g,"&#10;&#10;");return s+c+i});}return o};var Pi=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),ar=new Set(["code","kbd","pre","samp","var"]);function ir(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!ar.has(t.tagName)?ir(t):"").join("")}function lr(){return e=>{visit(e,"element",t=>{if(ar.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}Pi.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=Qe(ir(t))));});}}var cr=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{var a;if(!o.has(n.tagName.toLowerCase()))return;let r=n.children.filter(s=>s.type==="element").map(s=>{var l;return {tag:s.tagName,props:(l=s.properties)!=null?l:{},text:toText(s).trim()}});n.properties=(a=n.properties)!=null?a:{},n.properties["data-content"]=JSON.stringify(r),n.children=[];});};var dr=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(dr).join(""):"",mr=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=dr(n);n.children=r?[{type:"text",value:r}]:[];}});};var Ai=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Di=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Hi=e=>{let t=unified().use(ia).use(la,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},ur=(e,t=[])=>o=>{if(!e||e.length===0)return;let n=new Set(e.map(a=>a.toLowerCase())),r=new Set((t!=null?t:[]).map(a=>a.toLowerCase()));visit(o,"element",a=>{let s=a.tagName.toLowerCase();if(!n.has(s)||r.has(s)||!Ai(a))return;let l=Di(a);if(!l.includes(`
29
+ `))return;let i=Hi(l);a.children=i;});};var pr=()=>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 fr=/^>>>[ \t]?(.*)$/,Oi=/^<<<\s*$/,_i=/^>+\s*$/,Vi=/^<+\s*$/,ji=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,Fi=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,zi=/^[a-z0-9-]+$/,$i=e=>{let t=ji.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:o,iconBrace:n,title:r,color:a}=t.groups,s=o!=null?o:n;return {icon:s&&zi.test(s)?s:void 0,title:r!==void 0&&r.length>0?r:void 0,color:a&&Fi.test(a)?a:void 0}},oo=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Wi=e=>{let t=new TextEncoder().encode(e),o="";for(let n of t)o+=String.fromCharCode(n);return btoa(o)},qi=(e,t)=>{var c;let o=fr.exec(e[t]),n=(c=o==null?void 0:o[1])!=null?c:"",r=$i(n),a=[],s=t+1;for(;s<e.length;s+=1){let d=e[s];if(Oi.test(d)){s+=1;break}if(_i.test(d)||Vi.test(d)){s+=1;break}a.push(d);}let l=a.join(`
30
+ `).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${oo(r.title)}"`:"",r.color!==void 0?`data-callout-color="${oo(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${oo(r.icon)}"`:"",`data-callout-body="${Wi(l)}"`].filter(Boolean).join(" ")}></div>`,next:s}},gr=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
31
+ `),o=[],n=0,r=false;for(;n<t.length;)if(fr.test(t[n])){let a=qi(t,n);o.push(a.replacement),n=a.next,r=true;}else o.push(t[n]),n+=1;return r?o.join(`
32
+ `):e},br=()=>()=>{};var Gi={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"}]}},Xi=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,hr=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=hr(n);return o},Ui=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}}}},Ji=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=hr(o).trimStart(),r=n.match(Xi);if(!r)return;let a=Gi[r[1].toUpperCase()],s=n.slice(r[0].length),l=t.children.slice(1);if(s.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[Ui(a)],c=[];s.length>0&&c.push({type:"text",value:s});let d=l;return ((p=d[0])==null?void 0:p.type)==="break"&&(d=d.slice(1)),c.push(...d),c.length>0&&c.some(m=>m.type!=="text"||m.value.trim().length>0)&&i.push({type:"paragraph",children:c}),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-${a.kind}`]},e.children=i,SKIP},yr=()=>e=>{visit(e,"blockquote",Ji);};var sl=/^[ \t]*<[\w!/?-]/,al=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,il=e=>typeof e!="string"||e.length===0||!sl.test(e)?e:e.replace(al,"$1"),xr,vr,Tr,Pr,Mr,Sr,Ir,Rr,Er,Lr,Nr,yt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(vr=(xr=defaultSchema.protocols)==null?void 0:xr.href)!=null?vr:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(Pr=(Tr=defaultSchema.attributes)==null?void 0:Tr.div)!=null?Pr:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(Sr=(Mr=defaultSchema.attributes)==null?void 0:Mr.p)!=null?Sr:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(Rr=(Ir=defaultSchema.attributes)==null?void 0:Ir.svg)!=null?Rr:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(Lr=(Er=defaultSchema.attributes)==null?void 0:Er.path)!=null?Lr:[],"d","fillRule"]},tagNames:[...(Nr=defaultSchema.tagNames)!=null?Nr:[],"svg","path"]},no={raw:Ko,sanitize:[Hr,yt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},ll={gfm:[nl,{}],githubAlerts:yr,containerAlerts:br,codeMeta:pr},wr=Object.values(no),cl=Object.values(ll),kr=new WeakMap;function dl(e){var r;let t=kr.get(e);if(t)return t;let o={...yt,tagNames:[...(r=yt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...yt.attributes,...e}},n=[no.raw,[Hr,o],no.harden];return kr.set(e,n),n}var ml={block:" \u258B",circle:" \u25CF"},ul=["github-light","github-dark"],pl={enabled:true},Br=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:a,animatePlugin:s,...l})=>{useLayoutEffect(()=>{s==null||s.commit();}),s==null||s.setAnimateCodeBlocks(r);let i=typeof e=="string"&&o?il(e):e,c=jsx(Ze,{...l,children:i});return jsx(It.Provider,{value:r,children:a?jsx("div",{dir:a,style:{display:"contents"},children:c}):c})},(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 a,s;return ((a=e.components)==null?void 0:a[r])!==((s=t.components)==null?void 0:s[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins||!!e.animatePlugin!=!!t.animatePlugin)});Br.displayName="Block";var fl=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:a,rehypePlugins:s=wr,remarkPlugins:l=cl,className:i,shikiTheme:c,mermaid:d,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,scrollable:f,tableMaxHeight:g=300,animated:b,BlockComponent:h=Br,parseMarkdownIntoBlocksFn:y=ht,caret:k,listStyle:T="hierarchical",calloutIcon:M,calloutStyle:S,plugins:x,remend:_,linkSafety:D=pl,lineNumbers:F=true,allowedTags:W,literalTagContent:H,dataOnlyTags:z,translations:q,icons:Y,prefix:Q,onAnimationStart:E,onAnimationEnd:$,...ie})=>{let Ve=useId(),oe=useMemo(()=>ko(Q),[Q]),de=useRef(null),ne=useRef(E),ee=useRef($);ne.current=E,ee.current=$,useEffect(()=>{var R,X,Z;if(t==="static")return;let C=de.current;if(de.current=m,C===null){m&&((R=ne.current)==null||R.call(ne));return}m&&!C?(X=ne.current)==null||X.call(ne):!m&&C&&((Z=ee.current)==null||Z.call(ee));},[m,t]);let V=useMemo(()=>W?Object.keys(W):[],[W]),P=useRef(null),j=useMemo(()=>{if(typeof e!="string")return "";let C=e;return H&&H.length>0&&(C=sr(C,H)),V.length>0&&(C=rr(C,V)),C=gr(C),C},[e,V,H]),G=useMemo(()=>{let C=t==="streaming"?P.current:null,R=to(j,C,y);if(P.current=t==="streaming"?R:null,!(t==="streaming"&&n)||R.blocks.length===0)return R.blocks;let X=R.blocks.length-1,Z=R.blocks[X],me=rl(Z,_);if(me===Z)return R.blocks;let Pe=R.blocks.slice();return Pe[X]=me,Pe},[j,y,t,n,_]),te=useMemo(()=>b===true?"true":b?JSON.stringify(b):"",[b]),re=useRef(null),je=useRef([]),ke=useRef([]),ro=useRef(null),wt=useRef("");if(te){if(wt.current!==te){wt.current=te;let C=te!=="true"?b.maxBacklogMs:void 0;re.current=Pt({maxBacklogMs:C}),je.current=[],ke.current=[];}else re.current||(re.current=Pt());m&&re.current&&re.current.beginPass(re.current.now());}else re.current=null,je.current=[],ke.current=[],wt.current="";useLayoutEffect(()=>{var C;m&&((C=re.current)==null||C.commitPass());});let xe=useDeferredValue(G),ve=useMemo(()=>{if(t!=="streaming"||re.current||xe===G||xe.length===0)return G;let C=xe.length,R=G.length;if(R===0)return xe;if(C!==R)return G;for(let Z=0;Z<C-1;Z+=1)if(xe[Z]!==G[Z])return G;let X=xe.slice();return X[C-1]=G[R-1],X},[G,xe,t]),kt=useMemo(()=>o==="auto"?ve.map(Qe):void 0,[ve,o]),jr=useMemo(()=>ve.map((C,R)=>`${Ve}-${R}`),[ve.length,Ve]),Fr=useMemo(()=>q?JSON.stringify(q):"",[q]),so=useMemo(()=>({...it,...q}),[Fr]),tt=useMemo(()=>{let{inlineCode:C,...R}=a!=null?a:{},X={...Jn,...R};if(C){let Z=X.code;X.code=me=>"data-block"in me?Z?createElement(Z,me):null:createElement(C,me);}return X},[a]),ot=useMemo(()=>{let C=[];return x!=null&&x.cjk&&(C=[...C,...x.cjk.remarkPluginsBefore]),C=[...C,...l],x!=null&&x.cjk&&(C=[...C,...x.cjk.remarkPluginsAfter]),x!=null&&x.math&&(C=[...C,x.math.remarkPlugin]),C},[l,x==null?void 0:x.math,x==null?void 0:x.cjk]),Te=useMemo(()=>{let C=s;return W&&Object.keys(W).length>0&&s===wr&&(C=dl(W)),V.length>0&&(C=[...C,[ur,V,H!=null?H:[]]]),H&&H.length>0&&(C=[...C,[mr,H]]),z&&z.length>0&&(C=[...C,[cr,z]]),x!=null&&x.math&&(C=[...C,x.math.rehypePlugin]),o==="auto"&&t==="static"&&(C=[...C,lr]),C},[s,x==null?void 0:x.math,W,V,H,z,o,t]),ao=useMemo(()=>{var C,R;return {calloutIcon:M,calloutStyle:S,codeBlockMaxHeight:p,shikiTheme:(R=c!=null?c:(C=x==null?void 0:x.code)==null?void 0:C.getThemes())!=null?R:ul,controls:u,isAnimating:m,lineNumbers:F,listStyle:T,mode:t,mermaid:d,linkSafety:D,scrollable:f,tableMaxHeight:g,components:tt,remarkPlugins:ot,rehypePlugins:Te}},[M,S,p,c,u,m,F,T,t,d,D,f,x==null?void 0:x.code,g,tt,ot,Te]),zr=useMemo(()=>k&&m?{"--streamdown-caret":`"${ml[k]}"`}:void 0,[k,m]),$r=C=>{let R=null;if(re.current&&m){if(!je.current[C]){let Z=te&&te!=="true"?b:{},{maxBacklogMs:me,...Pe}=Z;je.current[C]=nt({...Pe,timeline:re.current});}R=je.current[C];}ro.current!==Te&&(ke.current=[],ro.current=Te),R&&!ke.current[C]&&(ke.current[C]=[...Te,R.rehypePlugin]);let X=R&&ke.current[C]?ke.current[C]:Te;return {blockAnimatePlugin:R,blockRehypePlugins:X}};return t==="static"?jsx(lt.Provider,{value:so,children:jsx(ut.Provider,{value:x!=null?x:null,children:jsx(I.Provider,{value:ao,children:jsx(Bt,{icons:Y,children:jsx(st.Provider,{value:oe,children:jsx("div",{className:oe("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?void 0:o,children:jsx(Ze,{components:tt,rehypePlugins:Te,remarkPlugins:ot,...ie,children:j})})})})})})}):jsx(lt.Provider,{value:so,children:jsx(ut.Provider,{value:x!=null?x:null,children:jsx(I.Provider,{value:ao,children:jsx(Bt,{icons:Y,children:jsx(st.Provider,{value:oe,children:jsxs("div",{className:oe("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",k?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",style:zr,children:[ve.length===0&&k&&m&&jsx("span",{}),ve.map((C,R)=>{var io;let X=R===ve.length-1,Z=m&&X&&Yn(C),{blockAnimatePlugin:me,blockRehypePlugins:Pe}=$r(R);return jsx(h,{animatePlugin:me,components:tt,content:C,dir:(io=kt==null?void 0:kt[R])!=null?io:o!=="auto"?o:void 0,index:R,isIncomplete:Z,rehypePlugins:Pe,remarkPlugins:ot,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...ie},jr[R])})]})})})})})})},(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.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);fl.displayName="Streamdown";var Vr=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:a=3,zoomStep:s=.1,showControls:l=true,initialZoom:i=1,isAutoFit:c=false,fullscreen:d=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:m}=B(),f=w(),g=O(),b=useRef(null),h=useRef(null),[y,k]=useState(i),[T,M]=useState(r),[S,x]=useState(i),[_,D]=useState({x:0,y:0}),[F,W]=useState(false),[H,z]=useState(false),[q,Y]=useState({x:0,y:0}),[Q,E]=useState({x:0,y:0}),$=useCallback(P=>{x(j=>Math.max(T,Math.min(a,j+P))),z(true);},[T,a]),ie=useCallback(()=>{$(s);},[$,s]),Ve=useCallback(()=>{$(-s);},[$,s]),oe=useCallback(()=>{x(y),D({x:0,y:0}),z(false);},[y]),de=useCallback(P=>{P.preventDefault();let j=P.deltaY>0?-s:s;$(j);},[$,s]),ne=useCallback(P=>{if(P.button!==0||P.isPrimary===false)return;W(true),z(true),Y({x:P.clientX,y:P.clientY}),E(_);let j=P.currentTarget;j instanceof HTMLElement&&j.setPointerCapture(P.pointerId);},[_]),ee=useCallback(P=>{if(!F)return;P.preventDefault();let j=P.clientX-q.x,G=P.clientY-q.y;D({x:Q.x+j,y:Q.y+G});},[F,q,Q]),V=useCallback(P=>{W(false);let j=P.currentTarget;j instanceof HTMLElement&&j.releasePointerCapture(P.pointerId);},[]);return useEffect(()=>{M(r),c||(k(i),x(i));},[i,c,r]),useEffect(()=>{if(!(c&&o))return;let P=b.current;if(!P)return;let j=P.clientWidth,G=P.clientHeight;if(!(j>0&&G>0))return;let te=Math.min(j/o.width,G/o.height,1);!(te>0)||Number.isNaN(te)||(k(te),M(Math.min(r,te)),H||(x(te),D({x:0,y:0})));},[o,H,c,r]),useEffect(()=>{c&&z(false);},[c]),useEffect(()=>{let P=b.current;if(P)return P.addEventListener("wheel",de,{passive:false}),()=>{P.removeEventListener("wheel",de);}},[de]),useEffect(()=>{let P=h.current;if(P&&F)return document.body.style.userSelect="none",P.addEventListener("pointermove",ee,{passive:false}),P.addEventListener("pointerup",V),P.addEventListener("pointercancel",V),()=>{document.body.style.userSelect="",P.removeEventListener("pointermove",ee),P.removeEventListener("pointerup",V),P.removeEventListener("pointercancel",V);}},[F,ee,V]),jsxs("div",{className:f("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:b,style:{cursor:F?"grabbing":"grab"},children:[l?jsxs("div",{className:f("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",d?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{"aria-label":g.zoomIn,className:f("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:S>=a,onClick:ie,title:g.zoomIn,type:"button",children:jsx(u,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":g.zoomOut,className:f("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:S<=T,onClick:Ve,title:g.zoomOut,type:"button",children:jsx(m,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":g.resetView,className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:oe,title:g.resetView,type:"button",children:jsx(p,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:f("flex-1 origin-center transition-transform duration-150 ease-out",d?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:ne,ref:h,role:"application",style:{transform:`translate(${_.x}px, ${_.y}px) scale(${S})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var ln=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let a=w(),[s,l]=useState(null),[i,c]=useState(false),[d,p]=useState(""),[u,m]=useState(null),[f,g]=useState(""),[b,h]=useState(0),{mermaid:y}=useContext(I),k=De(),T=y==null?void 0:y.errorComponent,{shouldRender:M,containerRef:S}=lo({immediate:n});if(useEffect(()=>{if(!M)return;if(!k){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),c(!0);let D=k.getMermaid(o),F=e.split("").reduce((Y,Q)=>(Y<<5)-Y+Q.charCodeAt(0)|0,0),W=`mermaid-${Math.abs(F)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:H}=await D.render(W,e),z=qt(H),q=n?H:nn(H);p(q),m(z),g(q);}catch(D){if(!(f||d)){let F=D instanceof Error?D.message:"Failed to render Mermaid chart";l(F);}}finally{c(false);}})();},[e,o,b,M,k]),!(M||d||f))return jsx("div",{className:a("my-4 min-h-[200px]",t),ref:S});if(i&&!d&&!f)return jsx("div",{className:a("my-4 flex justify-center p-4",t),ref:S,children:jsxs("div",{className:a("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:a("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:a("text-sm"),children:"Loading diagram..."})]})});if(s&&!d&&!f){let _=()=>h(D=>D+1);return T?jsx("div",{ref:S,children:jsx(T,{chart:e,error:s,retry:_})}):jsxs("div",{className:a("rounded-md bg-red-50 p-4",t),ref:S,children:[jsxs("p",{className:a("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",s]}),jsxs("details",{className:a("mt-2"),children:[jsx("summary",{className:a("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:a("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let x=d||f;return jsx("div",{className:a("size-full",t),"data-streamdown":"mermaid",ref:S,children:jsx(Vr,{className:a(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:a("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:x},role:"img"})})})};export{to as A,il as B,no as C,ll as D,Br as E,fl as F,Jr as a,nt as b,Rt as c,Fe as d,vo as e,Nt as f,Dt as g,ud as h,Ht as i,it as j,ct as k,_t as l,dt as m,I as n,Jo as o,ln as p,He as q,Ee as r,Gt as s,ft as t,Le as u,Xe as v,za as w,Ue as x,Qe as y,ht as z};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {n,h,e}from'./chunk-BLX5JJMJ.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e$1,maxHeight:h$1,raw:t,className:m,startLine:d,lineNumbers:a,...c})=>{let{shikiTheme:l}=useContext(n),i=h(),[p,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let g=i.highlight({code:s,language:e$1,themes:l},H=>{o(H);});g&&o(g);},[s,e$1,l,i,t]),jsx(e,{className:m,language:e$1,lineNumbers:a,maxHeight:h$1,result:p,startLine:d,...c})};export{x as HighlightedCodeBlockBody};
2
+ import {n,h,e}from'./chunk-R7K6WJMN.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e$1,maxHeight:h$1,raw:t,className:m,startLine:d,lineNumbers:a,...c})=>{let{shikiTheme:l}=useContext(n),i=h(),[p,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let g=i.highlight({code:s,language:e$1,themes:l},H=>{o(H);});g&&o(g);},[s,e$1,l,i,t]),jsx(e,{className:m,language:e$1,lineNumbers:a,maxHeight:h$1,result:p,startLine:d,...c})};export{x as HighlightedCodeBlockBody};
package/dist/index.d.ts CHANGED
@@ -44,7 +44,15 @@ export declare const normalizeHtmlIndentation: (content: string) => string;
44
44
  export type AllowedTags = Record<string, string[]>;
45
45
  export type StreamdownProps = Options & {
46
46
  mode?: "static" | "streaming";
47
- /** Text direction for blocks. "auto" detects per-block using first strong character algorithm. */
47
+ /**
48
+ * Text direction. `"ltr"` / `"rtl"` force a single direction.
49
+ * `"auto"` detects direction per block: in streaming mode via parsed
50
+ * markdown blocks, in static mode via a rehype pass on each semantic
51
+ * block (headings, paragraphs, list items, table cells, etc.).
52
+ * Detection uses a content-majority strong-character count with
53
+ * first-strong as the tie-breaker; fenced/inline code is excluded from
54
+ * the evidence and code blocks are always rendered LTR.
55
+ */
48
56
  dir?: "auto" | "ltr" | "rtl";
49
57
  BlockComponent?: React.ComponentType<BlockProps>;
50
58
  parseMarkdownIntoBlocksFn?: (markdown: string) => string[];
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{E as Block,i as CodeBlock,f as CodeBlockContainer,k as CodeBlockCopyButton,l as CodeBlockDownloadButton,g as CodeBlockHeader,m as CodeBlockSkeleton,d as DefaultScrollable,F as Streamdown,n as StreamdownContext,v as TableCopyDropdown,w as TableDownloadButton,x as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,C as defaultRehypePlugins,D as defaultRemarkPlugins,j as defaultTranslations,o as defaultUrlTransform,y as detectTextDirection,t as escapeMarkdownTableCell,q as extractTableDataFromElement,B as normalizeHtmlIndentation,z as parseMarkdownIntoBlocks,A as parseMarkdownIntoBlocksIncremental,r as tableDataToCSV,u as tableDataToMarkdown,s as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-BLX5JJMJ.js';
2
+ export{E as Block,i as CodeBlock,f as CodeBlockContainer,k as CodeBlockCopyButton,l as CodeBlockDownloadButton,g as CodeBlockHeader,m as CodeBlockSkeleton,d as DefaultScrollable,F as Streamdown,n as StreamdownContext,v as TableCopyDropdown,w as TableDownloadButton,x as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,C as defaultRehypePlugins,D as defaultRemarkPlugins,j as defaultTranslations,o as defaultUrlTransform,y as detectTextDirection,t as escapeMarkdownTableCell,q as extractTableDataFromElement,B as normalizeHtmlIndentation,z as parseMarkdownIntoBlocks,A as parseMarkdownIntoBlocksIncremental,r as tableDataToCSV,u as tableDataToMarkdown,s as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-R7K6WJMN.js';
@@ -1,28 +1,72 @@
1
1
  import type { Pluggable } from "unified";
2
2
  /**
3
- * Shared cursor used to chain stagger delays across sibling blocks in a
4
- * single render pass. Create one instance per Streamdown component and
5
- * reset `cursor.current = 0` before each React render so that block 0
6
- * starts at index 0 and each subsequent block continues from where the
7
- * previous one left off.
3
+ * Soft budget for how long a cascade may run ahead of wall-clock.
4
+ * Fast streams compress their stagger to fit, instead of either:
5
+ * - growing an unbounded opacity:0 queue, or
6
+ * - truncating start times and re-introducing #482 overlap.
7
+ *
8
+ * When the budget is already exhausted mid-pass, later blocks keep a
9
+ * {@link MIN_STAGGER_STEP_MS} floor so they still cascade (slight overshoot)
10
+ * rather than all firing at once.
11
+ */
12
+ export declare const MAX_ANIMATION_BACKLOG_MS = 320;
13
+ /**
14
+ * Floor for per-word stagger under compression. Keeps multi-block passes
15
+ * from collapsing to step=0 once the first block(s) consume the budget.
16
+ */
17
+ export declare const MIN_STAGGER_STEP_MS = 4;
18
+ export interface ScheduleSlot {
19
+ /** CSS delay (ms) for the first new word in this batch. */
20
+ baseDelay: number;
21
+ /** Effective stagger (ms) between words — may be < requested under load. */
22
+ step: number;
23
+ }
24
+ /**
25
+ * Shared wall-clock timeline that serializes stagger delays across blocks
26
+ * and across streaming ticks — even when settled blocks are memoized.
27
+ *
28
+ * Render-pass protocol (driven by Streamdown):
29
+ * 1. `beginPass(now)` once at the start of each React render
30
+ * 2. each block's rehype plugin calls `take(wordCount, stagger, now)`
31
+ * 3. `commitPass()` once in a layout effect after paint
32
+ *
33
+ * StrictMode / discarded-render safety is per-plugin via `mark`/`rewind`:
34
+ * the first rehype run in a commit marks the cursor; a re-run rewinds
35
+ * before taking again so delays stay identical.
36
+ */
37
+ export interface AnimateTimeline {
38
+ beginPass: (now: number) => void;
39
+ commitPass: () => void;
40
+ /** Snapshot of the working cursor (passNextStartAt). */
41
+ mark: () => number;
42
+ now: () => number;
43
+ /** Restore the working cursor to a prior mark. */
44
+ rewind: (mark: number) => void;
45
+ take: (wordCount: number, stagger: number, now: number) => ScheduleSlot;
46
+ }
47
+ export interface CreateAnimateTimelineOptions {
48
+ maxBacklogMs?: number;
49
+ now?: () => number;
50
+ }
51
+ export declare function createAnimateTimeline(options?: CreateAnimateTimelineOptions): AnimateTimeline;
52
+ /**
53
+ * @deprecated Use {@link createAnimateTimeline}. Kept so existing fork
54
+ * consumers that imported the cursor helper still resolve.
8
55
  */
9
56
  export interface AnimateCursor {
10
57
  current: number;
11
58
  }
59
+ /** @deprecated Use {@link createAnimateTimeline}. */
12
60
  export declare function createAnimateCursor(): AnimateCursor;
13
61
  export interface AnimatePlugin {
14
62
  /**
15
- * Returns the total HAST text node character count from the last
16
- * rehype run, then resets to 0. Use this value as the argument to
17
- * setPrevContentLength on the next render.
63
+ * Commit the last rehype char count so the *next* rehype run treats that
64
+ * many characters as already-visible. Also clears the StrictMode rewind
65
+ * mark so the next commit starts clean. Called from Block's useLayoutEffect.
18
66
  */
67
+ commit: () => void;
68
+ /** Peak char count written by the last rehype run. Non-destructive. */
19
69
  getLastRenderCharCount: () => number;
20
- /**
21
- * Returns the number of newly-animated words from the last rehype run,
22
- * then resets to 0. Pass this value to setStartIndex() on the next
23
- * sibling block so its stagger delays chain after ours.
24
- */
25
- getLastRenderNewWordCount: () => number;
26
70
  name: "animate";
27
71
  rehypePlugin: Pluggable;
28
72
  /**
@@ -32,35 +76,30 @@ export interface AnimatePlugin {
32
76
  */
33
77
  setAnimateCodeBlocks: (enabled: boolean) => void;
34
78
  /**
35
- * Set the number of HAST text characters from a previous render.
36
- * Characters up to this count will get duration=0ms, preventing
37
- * re-animation of already-visible content during streaming updates.
79
+ * Manually set how many HAST characters count as already-rendered.
80
+ * Prefer `commit()` in React; this is for tests / custom hosts.
38
81
  */
39
82
  setPrevContentLength: (length: number) => void;
40
- /**
41
- * Set the animation word index to start from. Used when no shared
42
- * cursor is provided. Use the value returned by
43
- * getLastRenderNewWordCount() from the previous sibling block to
44
- * ensure that a new block's stagger delays begin after the previous
45
- * block's animation is still completing, preventing concurrent reveals.
46
- */
47
- setStartIndex: (index: number) => void;
48
83
  type: "animate";
49
84
  }
50
85
  export interface AnimateOptions {
51
86
  animation?: "fadeIn" | "blurIn" | "slideUp" | (string & {});
52
- /**
53
- * Shared cursor for automatic cross-block stagger chaining. When
54
- * provided the plugin reads `cursor.current` as the start index and
55
- * increments it by the number of newly animated words after each run,
56
- * so sibling blocks automatically pick up where the previous one left
57
- * off without any manual `setStartIndex` calls.
58
- */
59
- cursor?: AnimateCursor;
60
87
  duration?: number;
61
88
  easing?: string;
89
+ /**
90
+ * Soft cap (ms) on how far ahead of wall-clock words may be scheduled.
91
+ * Larger values favour longer cascades / stricter cross-block serialization;
92
+ * smaller values keep a fast stream visually caught up. @default 320
93
+ */
94
+ maxBacklogMs?: number;
62
95
  sep?: "word" | "char";
63
96
  stagger?: number;
64
97
  }
65
- export declare function createAnimatePlugin(options?: AnimateOptions): AnimatePlugin;
98
+ /**
99
+ * Create an animate rehype plugin. The optional `timeline` is an internal
100
+ * Streamdown wiring detail — not part of the public `animated` prop surface.
101
+ */
102
+ export declare function createAnimatePlugin(options?: AnimateOptions & {
103
+ timeline?: AnimateTimeline;
104
+ }): AnimatePlugin;
66
105
  export declare const animate: AnimatePlugin;
@@ -1,13 +1,13 @@
1
1
  /**
2
- * Detect text direction using the "first strong character" algorithm.
3
- * Strips common markdown syntax then finds the first Unicode letter
4
- * with strong directionality.
2
+ * Detect text direction by counting strong characters in the text.
3
+ * Ties use the first strong character, preserving intuitive behavior for
4
+ * short mixed labels while allowing RTL-majority prose that starts with an
5
+ * English identifier to remain RTL.
5
6
  *
6
- * Note: markdown stripping is best-effort nested formatting,
7
- * multi-line fenced code blocks, and raw HTML are not fully handled.
8
- * This is acceptable since the algorithm only needs to reach the first
9
- * strong character, which is almost always in plain prose.
7
+ * Markdown stripping is best-effort. Fenced and inline code are excluded
8
+ * because code is always rendered LTR and should not influence surrounding
9
+ * prose.
10
10
  *
11
- * @returns "rtl" if first strong char is RTL, "ltr" otherwise
11
+ * @returns "rtl" if RTL strong characters are the majority, "ltr" otherwise
12
12
  */
13
13
  export declare function detectTextDirection(text: string): "ltr" | "rtl";
@@ -0,0 +1,7 @@
1
+ import type { Root } from "hast";
2
+ /**
3
+ * Assign direction to each rendered semantic block without splitting the
4
+ * Markdown document, so references and footnotes continue to resolve across
5
+ * block boundaries.
6
+ */
7
+ export declare function rehypeBlockDirection(): (tree: Root) => void;
@@ -29,10 +29,13 @@ export interface StreamdownTranslations {
29
29
  mermaidFormatSvg: string;
30
30
  openExternalLink: string;
31
31
  openLink: string;
32
+ resetView: string;
32
33
  tableFormatCsv: string;
33
34
  tableFormatMarkdown: string;
34
35
  tableFormatTsv: string;
35
36
  viewFullscreen: string;
37
+ zoomIn: string;
38
+ zoomOut: string;
36
39
  }
37
40
  export declare const defaultTranslations: StreamdownTranslations;
38
41
  export declare const TranslationsContext: import("react").Context<StreamdownTranslations>;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{p as Mermaid}from'./chunk-R7K6WJMN.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/streamdown",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -68,7 +68,7 @@
68
68
  "rehype-harden": "^1.1.8",
69
69
  "rehype-raw": "^7.0.0",
70
70
  "rehype-sanitize": "^6.0.0",
71
- "remark-gfm": "^4.0.1",
71
+ "remark-gfm": "npm:@lofcz/remark-gfm@^4.0.1",
72
72
  "remark-parse": "^11.0.0",
73
73
  "remark-rehype": "^11.1.2",
74
74
  "remend": "npm:@lofcz/remend@^1.3.0",
@@ -1,29 +0,0 @@
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 Fo from'rehype-raw';import Tr,{defaultSchema}from'rehype-sanitize';import ji from'remark-gfm';import Fi from'remend';import {visitParents,SKIP}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Gs from'remark-parse';import Us from'remark-rehype';import {unified}from'unified';import {visit,SKIP as SKIP$1}from'unist-util-visit';import {Lexer}from'marked';import {toText}from'hast-util-to-text';var Br=300,Or="300px",Vr=500;function ro(e={}){let{immediate:t=false,debounceDelay:o=Br,rootMargin:n=Or,idleTimeout:r=Vr}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),c=useRef(null),d=useMemo(()=>m=>{let f=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-f))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,f)=>window.requestIdleCallback(m,f):d,[d]),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),c.current&&(u(c.current),c.current=null);let f=()=>{i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);},b=y=>{c.current=p(I=>{I.timeRemaining()>0||I.didTimeout?(a(true),y.disconnect()):c.current=p(()=>{a(true),y.disconnect();},{timeout:r/2});},{timeout:r});},h=y=>{f(),i.current=window.setTimeout(()=>{var S,x;let I=y.takeRecords();(I.length===0||(x=(S=I.at(-1))==null?void 0:S.isIntersecting)!=null&&x)&&b(y);},o);},g=(y,I)=>{y.isIntersecting?h(I):f();},k=new IntersectionObserver(y=>{for(let I of y)g(I,k);},{rootMargin:n,threshold:0});return k.observe(m),()=>{i.current&&clearTimeout(i.current),c.current&&u(c.current),k.disconnect();}},[t,o,n,r,u,p]),{shouldRender:s,containerRef:l}}function Pt(){return {current:0}}var ao=/\s/,so=/^\s+$/,Fr=new Set(["code","pre","svg","math","annotation"]),$r=new Set(["svg","math","annotation"]),zr=new Set(["img","hr"]),_e=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",io=(e,t)=>{let o=t?$r:Fr;return e.some(n=>_e(n)&&o.has(n.tagName))},Wr=e=>{for(let t=e.length-1;t>=0;t--){let o=e[t];if(_e(o)&&o.tagName==="li")return o}},qr=(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}`;},Zr=new Set(["ul","ol","li"]),lo=e=>{for(let t of e.children)if(_e(t)){if(t.tagName==="input")return t;if(Zr.has(t.tagName))continue;let o=lo(t);if(o)return o}},co=(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`;},Kr=(e,t,o,n)=>{let r=lo(e);r&&co(r,t,o,n);},Xr=(e,t,o,n,r)=>{if(io(t,n.animateCodeBlocks))return;let s=n.prevContentLength,a=s>0&&r.count<s,l=a?0:(n.startIndex+r.newIndex++)*o.stagger;co(e,o,a?0:o.duration,l);},Gr=e=>{let t=[],o="",n=false;for(let r of e){let s=ao.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},Ur=e=>{let t=[],o="";for(let n of e)ao.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Jr=(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}]}},Yr=(e,t,o,n,r)=>{var g;let s=t.at(-1);if(!(s&&"children"in s))return;if(io(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 c=o.sep==="char"?Ur(i):Gr(i),d=t.some(k=>_e(k)&&k.tagName==="a"),p=c;if(o.sep==="word"&&d){let k=[];for(let y of c)so.test(y)&&k.length>0?k[k.length-1]+=y:k.push(y);p=k;}let u=n.prevContentLength,m=Wr(t),f=!!(m&&!((g=m.properties)!=null&&g["data-sd-animate-marker"])),b=false,h=p.map(k=>{let y=r.count;if(r.count+=k.length,so.test(k))return {type:"text",value:k};let I=u>0&&y<u,T=I?0:(n.startIndex+r.newIndex++)*o.stagger;if(m&&f&&!b){let S=I?0:o.duration;qr(m,S,T,o.easing),Kr(m,o,S,T),b=true;}return Jr(k,o.animation,o.duration,o.easing,I,T)});return a.children.splice(l,1,...h),l+h.length},Qr=0;function je(e){var s,a,l,i,c;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:(c=e==null?void 0:e.stagger)!=null?c:40},o={animateCodeBlocks:false,prevContentLength:0,lastRenderCharCount:0,lastRenderNewWordCount:0,startIndex:0},n=Qr++,r=()=>d=>{let p={count:0,newIndex:0};t.cursor&&(o.startIndex=t.cursor.current),visitParents(d,u=>u.type==="text"||_e(u)&&zr.has(u.tagName),(u,m)=>{if(u.type==="text")return Yr(u,m,t,o,p);Xr(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(d){o.animateCodeBlocks=d;},setPrevContentLength(d){o.prevContentLength=d;},setStartIndex(d){o.startIndex=d;},getLastRenderCharCount(){let d=o.lastRenderCharCount;return o.lastRenderCharCount=0,d},getLastRenderNewWordCount(){let d=o.lastRenderNewWordCount;return o.lastRenderNewWordCount=0,d}}}je();var Tt=createContext(false),It=()=>useContext(Tt);var Fe=(...e)=>twMerge(clsx(e)),nt=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},os=(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(" ")},po=e=>e?(...t)=>os(e,twMerge(clsx(t))):Fe,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 rt=createContext(Fe),C=()=>useContext(rt);var $e=({scrollRef:e,...t})=>jsx("div",{ref:e,...t});var ls=Fe("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"),cs=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},bo=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=C(),{isAnimating:c,scrollable:d}=useContext(R),p=d!=null?d:$e,u=useRef(null),m=useRef(true),f=nt(r);useEffect(()=>{let g=u.current;if(!(g&&f))return;let k=()=>{let y=g.scrollHeight-g.scrollTop-g.clientHeight<8;m.current=y;};return g.addEventListener("scroll",k,{passive:true}),()=>g.removeEventListener("scroll",k)},[f]),useEffect(()=>{let g=u.current;g&&f&&c&&m.current&&g.scrollTo({top:g.scrollHeight,behavior:"instant"});},[c,f]),useEffect(()=>{c||(m.current=true);},[c]);let b=useMemo(()=>i(ls),[i]),h=useMemo(()=>{let g={};return t.bg&&(g["--sdm-bg"]=t.bg),t.fg&&(g["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(g,cs(t.rootStyle)),g},[t.bg,t.fg,t.rootStyle]);return jsx(p,{className:i(n,f?"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",scrollRef:u,style:f?{maxHeight:f}: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:h,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((g,k)=>jsx("span",{className:a?b:void 0,children:g.length===0||g.length===1&&g[0].content===""?`
3
- `:g.map((y,I)=>{let T={},S=!!y.bgColor;if(y.color&&(T["--sdm-c"]=y.color),y.bgColor&&(T["--sdm-tbg"]=y.bgColor),y.htmlStyle)for(let[x,j]of Object.entries(y.htmlStyle))x==="color"?T["--sdm-c"]=j:x==="background-color"?(T["--sdm-tbg"]=j,S=true):T[x]=j;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",S&&"bg-[var(--sdm-tbg)]",S&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:T,...y.htmlAttrs,children:y.content},I)})},k))})})})},(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 Rt=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=C();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 St=createContext({code:""}),st=()=>useContext(St);var Lt=({language:e})=>{let t=C();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 bs=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
- `;)t--;return e.slice(0,t)},hs=lazy(()=>import('./highlighted-body-BREFO7HV.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Nt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=C(),{codeBlockMaxHeight:c}=useContext(R),d=useMemo(()=>bs(e),[e]),p=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
5
- `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(St.Provider,{value:{code:e},children:jsxs(Rt,{isIncomplete:r,language:t,children:[jsx(Lt,{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(bo,{className:o,language:t,lineNumbers:a,maxHeight:c,result:p,startLine:s,...l}),children:jsx(hs,{className:o,code:d,language:t,lineNumbers:a,maxHeight:c,raw:p,startLine:s,...l})})]})})};var Co=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"})}),wo=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"})}),ko=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"})}),xo=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"})]}),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.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"})}),Po=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"})}),To=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"})}),Io=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"})}),Mo=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"})}),Ro=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var We={CheckIcon:Co,CopyIcon:wo,DownloadIcon:ko,ExternalLinkIcon:Io,Loader2Icon:xo,Maximize2Icon:vo,RotateCcwIcon:Po,XIcon:To,ZoomInIcon:Mo,ZoomOutIcon:Ro},Lo=createContext(We),xs=(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])},Et=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...We,...e}:We);xs(o.current,e)||(o.current=e,n.current=e?{...We,...e}:We);let r=n.current;return jsx(Lo.Provider,{value:r,children:t})},O=()=>useContext(Lo);var at={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"},it=createContext(at),_=()=>useContext(it);var lt=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=C(),[i,c]=useState(false),d=useRef(0),{code:p}=st(),{isAnimating:u}=useContext(R),m=_(),f=s!=null?s:p,b=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(f),c(!0),e==null||e(),d.current=window.setTimeout(()=>c(!1),o));}catch(y){t==null||t(y);}};useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let h=O(),g=i?h.CheckIcon:h.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:b,title:m.copyCode,type:"button",...a,children:n!=null?n:jsx(g,{size:14})})};var Eo={"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"},At=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=C(),{code:i}=st(),{isAnimating:c}=useContext(R),d=_(),p=O(),u=s!=null?s:i,f=`file.${o&&o in Eo?Eo[o]:"txt"}`,b="text/plain",h=()=>{try{oe(f,u,b),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:c,onClick:h,title:d.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var ct=()=>{let{Loader2Icon:e}=O(),t=C();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 qe=0,fe=()=>{qe+=1,qe===1&&(document.body.style.overflow="hidden");},ge=()=>{qe=Math.max(0,qe-1),qe===0&&(document.body.style.overflow="");};var As=["github-light","github-dark"],Hs={enabled:true},Ds={codeBlockMaxHeight:400,shikiTheme:As,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:Hs,tableMaxHeight:300},R=createContext(Ds);var _s=/\.[^/.]+$/,Do=(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},Bo=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i,XIcon:c}=O(),d=C(),p=useRef(null),[u,m]=useState(false),[f,b]=useState(false),[h,g]=useState(false),{controls:k}=useContext(R),y=_(),I=Do(k,"download"),T=Do(k,"fullscreen"),S=l.width!=null||l.height!=null,x=I&&(u||S)&&!f,j=f&&!S,D=T&&!!o&&!f&&u;useEffect(()=>{let L=p.current;if(L!=null&&L.complete){let ee=L.naturalWidth>0;m(ee),b(!ee);}},[]),useEffect(()=>{if(!h)return;fe();let L=ee=>{ee.key==="Escape"&&g(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),ge();}},[h]);let z=useCallback(L=>{m(true),b(false),r==null||r(L);},[r]),V=useCallback(L=>{m(false),b(true),s==null||s(L);},[s]),A=useCallback(()=>{D&&g(true);},[D]),F=useCallback(()=>{g(false);},[]),X=useCallback(L=>{a==null||a(L),!L.defaultPrevented&&A();},[a,A]),J=async L=>{if(L.stopPropagation(),!!o)try{let ue=await(await fetch(o)).blob(),Y=new URL(o,window.location.origin).pathname.split("/").pop()||"",Ce=Y.split(".").pop(),Q=Y.includes(".")&&Ce!==void 0&&Ce.length<=4,G="";if(Q)G=Y;else {let P=ue.type,B="png";P.includes("jpeg")||P.includes("jpg")?B="jpg":P.includes("png")?B="png":P.includes("svg")?B="svg":P.includes("gif")?B="gif":P.includes("webp")&&(B="webp"),G=`${(n||Y||"image").replace(_s,"")}.${B}`;}oe(G,ue,ue.type);}catch(ee){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:d("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:d("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:d("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:d("m-0 block h-auto max-w-full rounded-lg",D&&"cursor-zoom-in",j&&"hidden",t),"data-streamdown":"image",onClick:X,onError:V,onLoad:z,ref:p,src:o,...l}),j&&jsx("span",{className:d("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:y.imageNotAvailable}),x&&jsx("button",{className:d("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:J,title:y.downloadImage,type:"button",children:jsx(i,{size:14})})]}),h?createPortal(jsxs("div",{className:d("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:F,onKeyDown:L=>{L.key==="Escape"&&F();},role:"button",tabIndex:0,children:[jsx("button",{className:d("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:F,title:y.exitFullscreen,type:"button",children:jsx(c,{size:20})}),jsx("div",{onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:d("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var _o=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=O(),i=C(),[c,d]=useState(false),p=_(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(b){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){fe();let b=h=>{h.key==="Escape"&&o();};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),ge();}}},[t,o]),!t||typeof document=="undefined")return null;let f=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:b=>{b.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:b=>b.stopPropagation(),onKeyDown:b=>b.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:c?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(f,document.body)};var jo=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var $o=[],zo={allowDangerousHtml:true},dt=new WeakMap,Vt=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 f=p[m];if(m>0&&(u+=","),Array.isArray(f)){let[b,h]=f;if(typeof b=="function"){let g=dt.get(b);g||(g=b.name,dt.set(b,g)),u+=g;}else u+=String(b);u+=":",u+=JSON.stringify(h);}else if(typeof f=="function"){let b=dt.get(f);b||(b=f.name,dt.set(f,b)),u+=b;}else u+=String(f);}return u},l=a(n),i=a(r),c=s?JSON.stringify(s):"",d=`${i}::${l}::${c}`;return this.keyCache.set(t,d),d}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();}},Wo=new Vt,Ke=e=>{let t=Qs(e),o=e.children||"",n=t.runSync(t.parse(o),o);return sa(n,e)},Qs=e=>{let t=Wo.get(e);if(t)return t;let o=ta(e);return Wo.set(e,o),o},ea=e=>e.some(t=>Array.isArray(t)?t[0]===Fo:t===Fo),ta=e=>{let t=e.rehypePlugins||$o,o=e.remarkPlugins||$o,n=ea(t)?o:[...o,jo],r=e.remarkRehypeOptions?{...zo,...e.remarkRehypeOptions}:zo;return unified().use(Gs).use(n).use(Us,r).use(t)},qo=e=>e,oa=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},na=(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);}},ra=(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},sa=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let c=l||qo;visit(e,(d,p,u)=>{if(d.type==="raw"&&u&&typeof p=="number")return oa(u,p,s,d.value),p;if(d.type==="element"&&(na(d,c),ra(d,p,u,n,r,o)&&u&&typeof p=="number"))return a&&d.children?u.children.splice(p,1,...d.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 mt=createContext(null),_t=()=>useContext(mt),Uc=()=>{var t;let e=_t();return (t=e==null?void 0:e.code)!=null?t:null},Ne=()=>{var t;let e=_t();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Zo=e=>{var o;let t=_t();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 la=/(<svg\b)/,Go=/<svg\b[^>]*>/i,ca=/\bviewBox=(['"])(.*?)\1/i,da=/\swidth=(['"]).*?\1/i,ma=/\sheight=(['"]).*?\1/i,Ko=/\sstyle=(['"])(.*?)\1/i,Xo=/^<svg/i,ua=/^width\s*:/i,pa=/^height\s*:/i,fa=/^max-width\s*:/i,ga=/[\s,]+/,ba=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(la,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),Uo=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},jt=e=>{let t=e.match(Go);if(!t)return null;let n=t[0].match(ca),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(ga).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(Go);if(!t)return e;try{let o=t[0],n=jt(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(da,"").replace(ma,""),l=a.match(Ko),i=`width:${r}px;height:${s}px;max-width:none;`;if(l){let c=l[1],p=l[2].split(";").map(m=>m.trim()).filter(Boolean).filter(m=>!(ua.test(m)||pa.test(m)||fa.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;a=a.replace(Ko,` style=${c}${u}${c}`);}else a=a.replace(Xo,`<svg style="${i}"`);return a=a.replace(Xo,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Yo=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=ba(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let c=document.createElement("canvas"),d=i.width*o,p=i.height*o;c.width=d,c.height=p;let u=c.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,d,p),c.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 ut=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=C(),[l,i]=useState(false),c=useRef(null),{isAnimating:d}=useContext(R),p=O(),u=Ne(),m=_(),f=async b=>{try{if(b==="mmd"){oe("diagram.mmd",e,"text/plain"),i(!1),n==null||n(b);return}if(!u){s==null||s(new Error("Mermaid plugin not available"));return}let h=u.getMermaid(r),g=e.split("").reduce((T,S)=>(T<<5)-T+S.charCodeAt(0)|0,0),k=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await h.render(k,e);if(!y){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let I=Uo(y);if(b==="svg"){oe("diagram.svg",I,"image/svg+xml"),i(!1),n==null||n(b);return}if(b==="png"){let T=await Yo(I);oe("diagram.png",T,"image/png"),n==null||n(b),i(!1);return}}catch(h){s==null||s(h);}};return useEffect(()=>{let b=h=>{let g=h.composedPath();c.current&&!g.includes(c.current)&&i(false);};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b);}},[]),jsxs("div",{className:a("relative"),ref:c,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:d,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:()=>f("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:()=>f("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:()=>f("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var on=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=O(),i=C(),[c,d]=useState(false),{isAnimating:p,controls:u}=useContext(R),m=_(),f=(()=>{if(typeof u=="boolean")return u;let g=u.mermaid;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),b=(()=>{if(typeof u=="boolean")return u;let g=u.mermaid;return g===false?false:g===true||g===void 0?true:g.download!==false})(),h=()=>{d(!c);};return useEffect(()=>{if(c){fe();let g=k=>{k.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ge();}}},[c]),useEffect(()=>{c?o==null||o():n&&n();},[c,o,n]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:h,title:m.viewFullscreen,type:"button",...s,children:jsx(a,{size:14})}),c?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:h,onKeyDown:g=>{g.key==="Escape"&&h();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[b?jsx(ut,{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:h,title:m.exitFullscreen,type:"button",children:jsx(l,{size:20})})]}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:jsx(tn,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:f})})]}),document.body):null]})};var Ee=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=[],c=l.querySelectorAll("td");for(let d of c)i.push(((a=d.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},Re=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,c=false;for(let d of l){if(d==='"'){i=true,c=true;break}(d===","||d===`
6
- `)&&(i=true);}return i?c?`"${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
- `)},$t=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let d of l)if(d===" "||d===`
8
- `||d==="\r"){i=true;break}if(!i)return l;let c=[];for(let d of l)d===" "?c.push("\\t"):d===`
9
- `?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.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
- `)},pt=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):o.push(n);return o.join("")},Se=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(l=>pt(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 c=0;c<t.length;c+=1)i[c]=c<l.length?pt(l[c]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>pt(c));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
11
- `)};var Ue=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=C(),[a,l]=useState(false),[i,c]=useState(false),d=useRef(null),p=useRef(0),{isAnimating:u}=useContext(R),m=_(),f=async g=>{var k,y;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 I=(y=d.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),T=I==null?void 0:I.querySelector("table");if(!T){n==null||n(new Error("Table not found"));return}let S=Ee(T),D=({csv:Re,tsv:$t,md:Se}[g]||Se)(S),z=new ClipboardItem({"text/plain":new Blob([D],{type:"text/plain"}),"text/html":new Blob([T.outerHTML],{type:"text/html"})});await navigator.clipboard.write([z]),c(!0),l(!1),o==null||o(g),p.current=window.setTimeout(()=>c(!1),r);}catch(I){n==null||n(I);}};useEffect(()=>{let g=k=>{let y=k.composedPath();d.current&&!y.includes(d.current)&&l(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g),window.clearTimeout(p.current);}},[]);let b=O(),h=i?b.CheckIcon:b.CopyIcon;return jsxs("div",{className:s("relative"),ref:d,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(h,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("md"),title: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:()=>f("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:()=>f("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var La=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=C(),{isAnimating:l}=useContext(R),i=_(),c=O(),d=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=m==null?void 0:m.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let b=Ee(f),h="",g="",k="";switch(r){case "csv":h=Re(b),g="text/csv",k="csv";break;case "markdown":h=Se(b),g="text/markdown",k="md";break;default:h=Re(b),g="text/csv",k="csv";}oe(`${s||"table"}.${k}`,h,g),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:d,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})})},Je=({children:e,className:t,onDownload:o,onError:n})=>{let r=C(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(R),c=_(),d=O(),p=u=>{var m;try{let f=(m=l.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),b=f==null?void 0:f.querySelector("table");if(!b){n==null||n(new Error("Table not found"));return}let h=Ee(b),g=u==="csv"?Re(h):Se(h);oe(`table.${u==="csv"?"csv":"md"}`,g,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(f){n==null||n(f);}};return useEffect(()=>{let u=m=>{let f=m.composedPath();l.current&&!f.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:c.downloadTable,type:"button",children:e!=null?e:jsx(d.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:c.downloadTableAsCsv,type:"button",children:c.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:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})};var cn=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=O(),a=C(),[l,i]=useState(false),{isAnimating:c}=useContext(R),d=_(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){fe();let m=f=>{f.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),ge();}}},[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:c,onClick:p,title:d.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":d.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(Ue,{}):null,n?jsx(Je,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:d.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 un=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=C(),{isAnimating:c,scrollable:d}=useContext(R),p=d!=null?d:$e,u=useRef(null),m=useRef(true),f=nt(o);useEffect(()=>{let y=u.current;if(!(y&&f))return;let I=()=>{let T=y.scrollHeight-y.scrollTop-y.clientHeight<8;m.current=T;};return y.addEventListener("scroll",I,{passive:true}),()=>y.removeEventListener("scroll",I)},[f]),useEffect(()=>{let y=u.current;y&&f&&c&&m.current&&y.scrollTo({top:y.scrollHeight,behavior:"instant"});}),useEffect(()=>{c||(m.current=true);},[c]);let b=n&&r,h=n&&s,g=n&&a,k=b||h||g;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:[k?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[b?jsx(Ue,{}):null,h?jsx(Je,{}):null,g?jsx(cn,{showCopy:b,showDownload:h,children:e}):null]}):null,jsx(p,{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:u,style:f?{maxHeight:f}:void 0,children:jsx("table",{className:i("w-full min-w-max table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var Fa=/startLine=(\d+)/,$a=/\bnoLineNumbers\b/,za=lazy(()=>import('./mermaid-BQVPVJSQ.js').then(e=>({default:e.Mermaid}))),Wa=/language-([^\s]+)/,se=e=>e.props;function bt(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&&bt(e.node,t.node)}var Kt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Zt=(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},fn=(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},ft=(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}),qa={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Xt=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{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));Xt.displayName="MarkdownOl";var yn=memo(({children:e,className:t,node:o,...n})=>{var b;let r=C(),{depth:s,ulDepth:a,isUnordered:l}=useContext(Qe),{listStyle:i}=useContext(R),c=qa[i],d=l&&a>0?c[(a-1)%c.length]:void 0,p=Array.isArray(e)?e.filter(h=>h!==`
12
- `&&h!==""):[e],u=p[0],m=isValidElement(u)?(b=se(u).node)==null?void 0:b.tagName:void 0,f=p.length===1&&isValidElement(u)&&(u.type==="p"||m==="p")?se(u).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:f}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:f})},(e,t)=>e.className===t.className&&bt(e.node,t.node));yn.displayName="MarkdownLi";var Cn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{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));Cn.displayName="MarkdownUl";var wn=memo(({className:e,node:t,...o})=>{let n=C();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>H(e,t));wn.displayName="MarkdownHr";var kn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>H(e,t));kn.displayName="MarkdownStrong";var Za=({children:e,className:t,href:o,node:n,...r})=>{let s=C(),{linkSafety:a}=useContext(R),[l,i]=useState(false),c=o==="streamdown:incomplete-link",d=useCallback(async f=>{if(!(!(a!=null&&a.enabled&&o)||c)){if(f.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,c]),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":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(m):jsx(_o,{...m})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},xn=memo(Za,(e,t)=>H(e,t)&&e.href===t.href);xn.displayName="MarkdownA";var vn=memo(({children:e,className:t,node:o,...n})=>{let r=C();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));vn.displayName="MarkdownH1";var Pn=memo(({children:e,className:t,node:o,...n})=>{let r=C();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 Tn=memo(({children:e,className:t,node:o,...n})=>{let r=C();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));Tn.displayName="MarkdownH3";var In=memo(({children:e,className:t,node:o,...n})=>{let r=C();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));In.displayName="MarkdownH4";var Mn=memo(({children:e,className:t,node:o,...n})=>{let r=C();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));Mn.displayName="MarkdownH5";var Rn=memo(({children:e,className:t,node:o,...n})=>{let r=C();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));Rn.displayName="MarkdownH6";var Sn=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(R),a=Kt(r,"table"),l=Zt(r,"copy"),i=Zt(r,"download"),c=Zt(r,"fullscreen");return jsx(un,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:c,...n,children:e})},(e,t)=>H(e,t));Sn.displayName="MarkdownTable";var Ln=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>H(e,t));Ln.displayName="MarkdownThead";var Nn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>H(e,t));Nn.displayName="MarkdownTbody";var En=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>H(e,t));En.displayName="MarkdownTr";var An=memo(({children:e,className:t,node:o,...n})=>{let r=C();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));An.displayName="MarkdownTh";var Hn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>H(e,t));Hn.displayName="MarkdownTd";var Dn=memo(({children:e,className:t,node:o,...n})=>{let r=C();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));Dn.displayName="MarkdownBlockquote";var Bn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>H(e,t));Bn.displayName="MarkdownSup";var Ka=()=>({}),Xa=e=>{try{let t=atob(e),o=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder().decode(o)}catch(t){return ""}},On=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{calloutIcon:s,calloutStyle:a,components:l,remarkPlugins:i,rehypePlugins:c}=useContext(R),d=n,p=d["data-callout-title"],u=d["data-callout-color"],m=d["data-callout-icon"],f=d["data-callout-body"],b=f?Xa(f):"",h=(a!=null?a:Ka)(u),g=m&&s?s(m):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:h,...n,children:[p!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[g,p]}):null,b.trim().length>0?jsx(Ke,{components:l,rehypePlugins:c,remarkPlugins:i,children:b}):null]})},(e,t)=>H(e,t));On.displayName="MarkdownCallout";var gn={"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"},Vn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(On,{className:t,node:o,...n,children:e});if(s){let l=Object.keys(gn).find(i=>t==null?void 0:t.includes(i));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",l?gn[l]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>H(e,t));Vn.displayName="MarkdownDiv";var _n=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>H(e,t));_n.displayName="MarkdownSub";var jn=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{if(!isValidElement(i))return false;let c=se(i).children,d=Array.isArray(c)?c:[c],p=false,u=false;for(let m of d)if(m){if(typeof m=="string")m.trim()!==""&&(p=true);else if(isValidElement(m))if(se(m)["data-footnote-backref"]!==void 0)u=true;else {let f=se(m).children,b=Array.isArray(f)?f:[f];for(let h of b){if(typeof h=="string"&&h.trim()!==""){p=true;break}if(isValidElement(h)&&se(h)["data-footnote-backref"]===void 0){p=true;break}}}}return u&&!p},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===Xt){let c=se(i).children,p=(Array.isArray(c)?c:[c]).filter(u=>!s(u));return p.length===0?null:{...i,props:{...se(i),children:p}}}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));jn.displayName="MarkdownSection";var Ga=({node:e,className:t,children:o,...n})=>{var D,z;let r=C(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(R),c=Ne(),d=It(),p=t==null?void 0:t.match(Wa),u=(D=p==null?void 0:p.at(1))!=null?D:"",m=Zo(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 f=(z=e==null?void 0:e.properties)==null?void 0:z.metastring,b=typeof f=="string"?f:void 0,h=b==null?void 0:b.match(Fa),g=h?Number.parseInt(h[1],10):void 0,k=g!==void 0&&g>=1?g:void 0,I=!(b?$a.test(b):false)&&i!==false,T="";if(isValidElement(o)){let V=se(o).children;typeof V=="string"&&(T=V);}else typeof o=="string"&&(T=o);if(m){let V=m.component;return jsx(Suspense,{fallback:jsx(ct,{}),children:jsx(V,{code:T,isIncomplete:d,language:u,meta:b})})}if(u==="mermaid"&&c){let V=Kt(l,"mermaid"),A=ft(l,"download"),F=ft(l,"copy"),X=ft(l,"fullscreen"),J=ft(l,"panZoom"),ae=V&&(A||F||X);return jsx(Suspense,{fallback:jsx(ct,{}),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-incomplete":d||void 0,"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"})}),ae?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:[A?jsx(ut,{chart:T,config:a==null?void 0:a.config}):null,F?jsx(lt,{code:T}):null,X?jsx(on,{chart:T,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(za,{chart:T,config:a==null?void 0:a.config,showControls:J})})]})})}let S=Kt(l,"code"),x=fn(l,"download"),j=fn(l,"copy");return jsx(Nt,{className:t,code:T,isIncomplete:d,language:u,lineNumbers:I,startLine:k,children:S?jsxs(Fragment,{children:[x?jsx(At,{code:T,language:u}):null,j?jsx(lt,{}):null]}):null})},Fn=memo(Ga,(e,t)=>e.className===t.className&&bt(e.node,t.node));Fn.displayName="MarkdownCode";var $n=memo(Bo,(e,t)=>e.className===t.className&&bt(e.node,t.node));$n.displayName="MarkdownImg";var bn={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},zn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),s=_(),a=n["data-alert-type"],l=a&&a in bn?bn[a]:void 0,i=l?s[l]:void 0,c=e;return i&&(c=[...(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:c})},(e,t)=>H(e,t));zn.displayName="MarkdownAlertTitle";var Wn=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(zn,{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=se(s[0]).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));Wn.displayName="MarkdownParagraph";var qn={ol:Xt,li:yn,ul:Cn,hr:wn,strong:kn,a:xn,h1:vn,h2:Pn,h3:Tn,h4:In,h5:Mn,h6:Rn,table:Sn,thead:Ln,tbody:Nn,tr:En,th:An,td:Hn,blockquote:Dn,code:Fn,div:Vn,img:$n,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Bn,sub:_n,p:Wn,section:jn};var Ua=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Ja=/\p{L}/u;function ht(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(Ua.test(o))return "rtl";if(Ja.test(o))return "ltr"}return "ltr"}var Ya=/^[ \t]{0,3}(`{3,}|~{3,})/;var Zn=e=>{let t=e.split(`
13
- `),o=null,n=0;for(let r of t){let s=Ya.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};var ei=/\[\^[\w-]{1,200}\](?!:)/,ti=/\[\^[\w-]{1,200}\]:/;var oi=/<(\w+)[\s>]/,ni=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Kn=new Map,Xn=new Map,Jn=e=>{let t=e.toLowerCase(),o=Kn.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Kn.set(t,n),n},ri=e=>{let t=e.toLowerCase(),o=Xn.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Xn.set(t,n),n},Gn=(e,t)=>{if(ni.has(t.toLowerCase()))return 0;let o=e.match(Jn(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Un=(e,t)=>{let o=e.match(ri(t));return o?o.length:0},si=(e,t)=>{let o=e.match(Jn(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},ai=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},yt=e=>{let t=ei.test(e),o=ti.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,c=r.length;if(s.length>0){r[c-1]+=i;let d=s.at(-1),p=Gn(i,d),u=Un(i,d);for(let m=0;m<p;m+=1)s.push(d);for(let m=0;m<u;m+=1)s.length>0&&s.at(-1)===d&&s.pop();continue}if(l.type==="html"&&l.block){let d=i.match(oi);if(d){let p=d[1],u=Gn(i,p),m=Un(i,p);u>m&&!si(i,p)&&s.push(p);}}if(c>0&&!a){let d=r[c-1];if(ai(d)%2===1){r[c-1]=d+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r},Gt=(e,t,o=yt)=>{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 Yn=(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 c=l.includes(`
14
-
15
- `),d=!l.startsWith(`
16
- `),p=l.includes(`
17
- `);if(!(c||d&&p))return a+l+i;let u=l.replace(/\n\n/g,`
18
- <!---->
19
- `),m=(u.startsWith(`
20
- `)?"":`
21
- `)+u+(u.endsWith(`
22
- `)?"":`
23
- `);return `${a}${m}${i}
24
-
25
- `});}return o};var ii=/([\\`*_~[\]|])/g,li=e=>e.replace(ii,"\\$1"),Qn=(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 c=li(l).replace(/\n\n/g,"&#10;&#10;");return a+c+i});}return o};var er=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{var s;if(!o.has(n.tagName.toLowerCase()))return;let r=n.children.filter(a=>a.type==="element").map(a=>{var l;return {tag:a.tagName,props:(l=a.properties)!=null?l:{},text:toText(a).trim()}});n.properties=(s=n.properties)!=null?s:{},n.properties["data-content"]=JSON.stringify(r),n.children=[];});};var tr=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(tr).join(""):"",or=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=tr(n);n.children=r?[{type:"text",value:r}]:[];}});};var bi=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),hi=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),yi=e=>{let t=unified().use(Gs).use(Us,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},nr=(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)||!bi(s))return;let l=hi(s);if(!l.includes(`
26
- `))return;let i=yi(l);s.children=i;});};var rr=()=>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 sr=/^>>>[ \t]?(.*)$/,wi=/^<<<\s*$/,ki=/^>+\s*$/,xi=/^<+\s*$/,vi=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,Pi=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Ti=/^[a-z0-9-]+$/,Ii=e=>{let t=vi.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:o,iconBrace:n,title:r,color:s}=t.groups,a=o!=null?o:n;return {icon:a&&Ti.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&Pi.test(s)?s:void 0}},Ut=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Mi=e=>{let t=new TextEncoder().encode(e),o="";for(let n of t)o+=String.fromCharCode(n);return btoa(o)},Ri=(e,t)=>{var c;let o=sr.exec(e[t]),n=(c=o==null?void 0:o[1])!=null?c:"",r=Ii(n),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(wi.test(d)){a+=1;break}if(ki.test(d)||xi.test(d)){a+=1;break}s.push(d);}let l=s.join(`
27
- `).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${Ut(r.title)}"`:"",r.color!==void 0?`data-callout-color="${Ut(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${Ut(r.icon)}"`:"",`data-callout-body="${Mi(l)}"`].filter(Boolean).join(" ")}></div>`,next:a}},ar=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
28
- `),o=[],n=0,r=false;for(;n<t.length;)if(sr.test(t[n])){let s=Ri(t,n);o.push(s.replacement),n=s.next,r=true;}else o.push(t[n]),n+=1;return r?o.join(`
29
- `):e},ir=()=>()=>{};var Ni={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"}]}},Ei=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,lr=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=lr(n);return o},Ai=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}}}},Hi=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=lr(o).trimStart(),r=n.match(Ei);if(!r)return;let s=Ni[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=[Ai(s)],c=[];a.length>0&&c.push({type:"text",value:a});let d=l;return ((p=d[0])==null?void 0:p.type)==="break"&&(d=d.slice(1)),c.push(...d),c.length>0&&c.some(m=>m.type!=="text"||m.value.trim().length>0)&&i.push({type:"paragraph",children:c}),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},cr=()=>e=>{visit(e,"blockquote",Hi);};var $i=/^[ \t]*<[\w!/?-]/,zi=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Wi=e=>typeof e!="string"||e.length===0||!$i.test(e)?e:e.replace(zi,"$1"),pr,fr,gr,br,hr,yr,Cr,wr,kr,xr,vr,Ct={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(fr=(pr=defaultSchema.protocols)==null?void 0:pr.href)!=null?fr:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(br=(gr=defaultSchema.attributes)==null?void 0:gr.div)!=null?br:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(yr=(hr=defaultSchema.attributes)==null?void 0:hr.p)!=null?yr:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(wr=(Cr=defaultSchema.attributes)==null?void 0:Cr.svg)!=null?wr:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(xr=(kr=defaultSchema.attributes)==null?void 0:kr.path)!=null?xr:[],"d","fillRule"]},tagNames:[...(vr=defaultSchema.tagNames)!=null?vr:[],"svg","path"]},Jt={raw:Fo,sanitize:[Tr,Ct],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},qi={gfm:[ji,{}],githubAlerts:cr,containerAlerts:ir,codeMeta:rr},mr=Object.values(Jt),Zi=Object.values(qi),ur=new WeakMap;function Ki(e){var r;let t=ur.get(e);if(t)return t;let o={...Ct,tagNames:[...(r=Ct.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...Ct.attributes,...e}},n=[Jt.raw,[Tr,o],Jt.harden];return ur.set(e,n),n}var Xi={block:" \u258B",circle:" \u25CF"},Gi=["github-light","github-dark"],Ui={enabled:true},Ir=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{if(a){let d=a.getLastRenderCharCount();a.setPrevContentLength(d),a.setAnimateCodeBlocks(r);}let i=typeof e=="string"&&o?Wi(e):e,c=jsx(Ke,{...l,children:i});return jsx(Tt.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:c}):c})},(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)});Ir.displayName="Block";var Ji=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=mr,remarkPlugins:l=Zi,className:i,shikiTheme:c=Gi,mermaid:d,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,scrollable:f,tableMaxHeight:b=300,animated:h,BlockComponent:g=Ir,parseMarkdownIntoBlocksFn:k=yt,caret:y,listStyle:I="hierarchical",calloutIcon:T,calloutStyle:S,plugins:x,remend:j,linkSafety:D=Ui,lineNumbers:z=true,allowedTags:V,literalTagContent:A,dataOnlyTags:F,translations:X,icons:J,prefix:ae,onAnimationStart:L,onAnimationEnd:ee,...ue})=>{var oo;let Be=useId(),Y=useMemo(()=>po(ae),[ae]),Ce=useRef(null),Q=useRef(L),G=useRef(ee);Q.current=L,G.current=ee,useEffect(()=>{var M,q,Z;if(t==="static")return;let w=Ce.current;if(Ce.current=m,w===null){m&&((M=Q.current)==null||M.call(Q));return}m&&!w?(q=Q.current)==null||q.call(Q):!m&&w&&((Z=G.current)==null||Z.call(G));},[m,t]);let P=useMemo(()=>V?Object.keys(V):[],[V]),B=useRef(null),te=useMemo(()=>{if(typeof e!="string")return "";let w=e;return A&&A.length>0&&(w=Qn(w,A)),P.length>0&&(w=Yn(w,P)),w=ar(w),w},[e,P,A]),W=useMemo(()=>{let w=t==="streaming"?B.current:null,M=Gt(te,w,k);if(B.current=t==="streaming"?M:null,!(t==="streaming"&&n)||M.blocks.length===0)return M.blocks;let q=M.blocks.length-1,Z=M.blocks[q],pe=Fi(Z,j);if(pe===Z)return M.blocks;let Ve=M.blocks.slice();return Ve[q]=pe,Ve},[te,k,t,n,j]),Oe=useMemo(()=>h===true?"true":h?JSON.stringify(h):"",[h]),ie=useRef(null),we=useRef([]),ke=useRef([]),Yt=useRef(null),Qt=useRef("");Oe?(Qt.current!==Oe&&(Qt.current=Oe,ie.current=Pt(),we.current=[],ke.current=[]),ie.current&&(ie.current.current=0)):(ie.current=null,we.current=[],ke.current=[]);ie.current?(oo=we.current[0])!=null?oo:(()=>{var M;let w=je({...Oe!=="true"?h:{},cursor:(M=ie.current)!=null?M:void 0});return we.current[0]=w,w})():null;let xe=useDeferredValue(W),ve=useMemo(()=>{if(t!=="streaming"||ie.current||xe===W||xe.length===0)return W;let w=xe.length,M=W.length;if(M===0)return xe;if(w!==M)return W;for(let Z=0;Z<w-1;Z+=1)if(xe[Z]!==W[Z])return W;let q=xe.slice();return q[w-1]=W[M-1],q},[W,xe,t]),kt=useMemo(()=>o==="auto"?ve.map(ht):void 0,[ve,o]),Lr=useMemo(()=>ve.map((w,M)=>`${Be}-${M}`),[ve.length,Be]),Nr=useMemo(()=>X?JSON.stringify(X):"",[X]),eo=useMemo(()=>({...at,...X}),[Nr]),tt=useMemo(()=>{let{inlineCode:w,...M}=s!=null?s:{},q={...qn,...M};if(w){let Z=q.code;q.code=pe=>"data-block"in pe?Z?createElement(Z,pe):null:createElement(w,pe);}return q},[s]),ot=useMemo(()=>{let w=[];return x!=null&&x.cjk&&(w=[...w,...x.cjk.remarkPluginsBefore]),w=[...w,...l],x!=null&&x.cjk&&(w=[...w,...x.cjk.remarkPluginsAfter]),x!=null&&x.math&&(w=[...w,x.math.remarkPlugin]),w},[l,x==null?void 0:x.math,x==null?void 0:x.cjk]),Pe=useMemo(()=>{let w=a;return V&&Object.keys(V).length>0&&a===mr&&(w=Ki(V)),P.length>0&&(w=[...w,[nr,P,A!=null?A:[]]]),A&&A.length>0&&(w=[...w,[or,A]]),F&&F.length>0&&(w=[...w,[er,F]]),x!=null&&x.math&&(w=[...w,x.math.rehypePlugin]),w},[a,x==null?void 0:x.math,V,P,A,F]),to=useMemo(()=>{var w,M;return {calloutIcon:T,calloutStyle:S,codeBlockMaxHeight:p,shikiTheme:(M=(w=x==null?void 0:x.code)==null?void 0:w.getThemes())!=null?M:c,controls:u,isAnimating:m,lineNumbers:z,listStyle:I,mode:t,mermaid:d,linkSafety:D,scrollable:f,tableMaxHeight:b,components:tt,remarkPlugins:ot,rehypePlugins:Pe}},[T,S,p,c,u,m,z,I,t,d,D,f,x==null?void 0:x.code,b,tt,ot,Pe]),Er=useMemo(()=>y&&m?{"--streamdown-caret":`"${Xi[y]}"`}:void 0,[y,m]),Ar=w=>{let M=null;ie.current&&m&&(we.current[w]||(we.current[w]=je({...Oe!=="true"?h:{},cursor:ie.current})),M=we.current[w]),Yt.current!==Pe&&(ke.current=[],Yt.current=Pe),M&&!ke.current[w]&&(ke.current[w]=[...Pe,M.rehypePlugin]);let q=M&&ke.current[w]?ke.current[w]:Pe;return {blockAnimatePlugin:M,blockRehypePlugins:q}};return t==="static"?jsx(it.Provider,{value:eo,children:jsx(mt.Provider,{value:x!=null?x:null,children:jsx(R.Provider,{value:to,children:jsx(Et,{icons:J,children:jsx(rt.Provider,{value:Y,children:jsx("div",{className:Y("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?ht(te):o,children:jsx(Ke,{components:tt,rehypePlugins:Pe,remarkPlugins:ot,...ue,children:te})})})})})})}):jsx(it.Provider,{value:eo,children:jsx(mt.Provider,{value:x!=null?x:null,children:jsx(R.Provider,{value:to,children:jsx(Et,{icons:J,children:jsx(rt.Provider,{value:Y,children:jsxs("div",{className:Y("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",y?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",style:Er,children:[ve.length===0&&y&&m&&jsx("span",{}),ve.map((w,M)=>{var no;let q=M===ve.length-1,Z=m&&q&&Zn(w),{blockAnimatePlugin:pe,blockRehypePlugins:Ve}=Ar(M);return jsx(g,{animatePlugin:pe,components:tt,content:w,dir:(no=kt==null?void 0:kt[M])!=null?no:o!=="auto"?o:void 0,index:M,isIncomplete:Z,rehypePlugins:Ve,remarkPlugins:ot,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...ue},Lr[M])})]})})})})})})},(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.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Ji.displayName="Streamdown";var Sr=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:l=true,initialZoom:i=1,isAutoFit:c=false,fullscreen:d=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:m}=O(),f=C(),b=useRef(null),h=useRef(null),[g,k]=useState(i),[y,I]=useState(r),[T,S]=useState(i),[x,j]=useState({x:0,y:0}),[D,z]=useState(false),[V,A]=useState(false),[F,X]=useState({x:0,y:0}),[J,ae]=useState({x:0,y:0}),L=useCallback(P=>{S(B=>Math.max(y,Math.min(s,B+P))),A(true);},[y,s]),ee=useCallback(()=>{L(a);},[L,a]),ue=useCallback(()=>{L(-a);},[L,a]),Be=useCallback(()=>{S(g),j({x:0,y:0}),A(false);},[g]),Y=useCallback(P=>{P.preventDefault();let B=P.deltaY>0?-a:a;L(B);},[L,a]),Ce=useCallback(P=>{if(P.button!==0||P.isPrimary===false)return;z(true),A(true),X({x:P.clientX,y:P.clientY}),ae(x);let B=P.currentTarget;B instanceof HTMLElement&&B.setPointerCapture(P.pointerId);},[x]),Q=useCallback(P=>{if(!D)return;P.preventDefault();let B=P.clientX-F.x,te=P.clientY-F.y;j({x:J.x+B,y:J.y+te});},[D,F,J]),G=useCallback(P=>{z(false);let B=P.currentTarget;B instanceof HTMLElement&&B.releasePointerCapture(P.pointerId);},[]);return useEffect(()=>{I(r),c||(k(i),S(i));},[i,c,r]),useEffect(()=>{if(!(c&&o))return;let P=b.current;if(!P)return;let B=P.clientWidth,te=P.clientHeight;if(!(B>0&&te>0))return;let W=Math.min(B/o.width,te/o.height,1);!(W>0)||Number.isNaN(W)||(k(W),I(Math.min(r,W)),V||(S(W),j({x:0,y:0})));},[o,V,c,r]),useEffect(()=>{c&&A(false);},[c]),useEffect(()=>{let P=b.current;if(P)return P.addEventListener("wheel",Y,{passive:false}),()=>{P.removeEventListener("wheel",Y);}},[Y]),useEffect(()=>{let P=h.current;if(P&&D)return document.body.style.userSelect="none",P.addEventListener("pointermove",Q,{passive:false}),P.addEventListener("pointerup",G),P.addEventListener("pointercancel",G),()=>{document.body.style.userSelect="",P.removeEventListener("pointermove",Q),P.removeEventListener("pointerup",G),P.removeEventListener("pointercancel",G);}},[D,Q,G]),jsxs("div",{className:f("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:b,style:{cursor:D?"grabbing":"grab"},children:[l?jsxs("div",{className:f("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",d?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:f("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:T>=s,onClick:ee,title:"Zoom in",type:"button",children:jsx(u,{size:16})}),jsx("button",{className:f("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:T<=y,onClick:ue,title:"Zoom out",type:"button",children:jsx(m,{size:16})}),jsx("button",{className:f("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:f("flex-1 origin-center transition-transform duration-150 ease-out",d?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:Ce,ref:h,role:"application",style:{transform:`translate(${x.x}px, ${x.y}px) scale(${T})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var tn=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=C(),[a,l]=useState(null),[i,c]=useState(false),[d,p]=useState(""),[u,m]=useState(null),[f,b]=useState(""),[h,g]=useState(0),{mermaid:k}=useContext(R),y=Ne(),I=k==null?void 0:k.errorComponent,{shouldRender:T,containerRef:S}=ro({immediate:n});if(useEffect(()=>{if(!T)return;if(!y){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),c(!0);let D=y.getMermaid(o),z=e.split("").reduce((J,ae)=>(J<<5)-J+ae.charCodeAt(0)|0,0),V=`mermaid-${Math.abs(z)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:A}=await D.render(V,e),F=jt(A),X=n?A:Jo(A);p(X),m(F),b(X);}catch(D){if(!(f||d)){let z=D instanceof Error?D.message:"Failed to render Mermaid chart";l(z);}}finally{c(false);}})();},[e,o,h,T,y]),!(T||d||f))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:S});if(i&&!d&&!f)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:S,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&&!d&&!f){let j=()=>g(D=>D+1);return I?jsx("div",{ref:S,children:jsx(I,{chart:e,error:a,retry:j})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:S,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 x=d||f;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:S,children:jsx(Sr,{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:x},role:"img"})})})};export{Gt as A,Wi as B,Jt as C,qi as D,Ir as E,Ji as F,Pt as a,je as b,It as c,$e as d,bo as e,Rt as f,Lt as g,Uc as h,Nt as i,at as j,lt as k,At as l,ct as m,R as n,qo as o,tn as p,Ee as q,Re as r,$t as s,pt as t,Se as u,Ue as v,La as w,Je as x,ht as y,yt as z};
@@ -1,2 +0,0 @@
1
- "use client";
2
- export{p as Mermaid}from'./chunk-BLX5JJMJ.js';