streamdown 1.6.4 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,7 +31,7 @@ npm i streamdown
31
31
  Then, update your Tailwind `globals.css` to include the following.
32
32
 
33
33
  ```css
34
- @source "../node_modules/streamdown/dist/index.js";
34
+ @source "../node_modules/streamdown/dist/*.js";
35
35
  ```
36
36
 
37
37
  Make sure the path matches the location of the `node_modules` folder in your project. This will ensure that the Streamdown styles are applied to your project.
@@ -4,7 +4,7 @@ import {createContext,lazy,memo,useContext,isValidElement,useMemo,useId,useTrans
4
4
  `||m==="\r"){l=true;break}}if(!l)return i;let c=[];for(let d=0;d<i.length;d+=1){let m=i[d];m===" "?c.push("\\t"):m===`
5
5
  `?c.push("\\n"):m==="\r"?c.push("\\r"):c.push(m);}return c.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(" "),a+=1);for(let i of n)s[a]=i.map(o).join(" "),a+=1;return s.join(`
6
6
  `)},ve=e=>{let t=false;for(let o=0;o<e.length;o+=1){let r=e[o];if(r==="\\"||r==="|"){t=true;break}}if(!t)return e;let n=[];for(let o=0;o<e.length;o+=1){let r=e[o];r==="\\"?n.push("\\\\"):r==="|"?n.push("\\|"):n.push(r);}return n.join("")},at=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(i=>ve(i));o[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let i=0;i<t.length;i+=1)a[i]="---";o[r]=`| ${a.join(" | ")} |`,r+=1;for(let i of n)if(i.length<t.length){let l=new Array(t.length);for(let c=0;c<t.length;c+=1)l[c]=c<i.length?ve(i[c]):"";o[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=i.map(c=>ve(c));o[r]=`| ${l.join(" | ")} |`,r+=1;}return o.join(`
7
- `)};var mt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let[s,a]=useState(false),[i,l]=useState(false),c=useRef(null),d=useRef(0),{isAnimating:m}=useContext(P),f=async u=>{var g,w;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.write)){o==null||o(new Error("Clipboard API not available"));return}try{let k=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),x=k==null?void 0:k.querySelector("table");if(!x){o==null||o(new Error("Table not found"));return}let N=ie(x),T=u==="csv"?ae(N):it(N),B=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([x.outerHTML],{type:"text/html"})});await navigator.clipboard.write([B]),l(!0),a(!1),n==null||n(u),d.current=window.setTimeout(()=>l(!1),r);}catch(k){o==null||o(k);}};useEffect(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(d.current);}},[]);let h=i?CheckIcon:CopyIcon;return jsxs("div",{className:"relative",ref:c,children:[jsx("button",{className:p("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>a(!s),title:"Copy table",type:"button",children:e!=null?e:jsx(h,{size:14})}),s&&jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("csv"),type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),type:"button",children:"TSV"})]})]})};var ut=({children:e,className:t,onDownload:n,onError:o})=>{let[r,s]=useState(false),a=useRef(null),{isAnimating:i}=useContext(P),l=c=>{var d;try{let m=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),f=m==null?void 0:m.querySelector("table");if(!f){o==null||o(new Error("Table not found"));return}let h=ie(f),u=c==="csv"?ae(h):at(h);E(`table.${c==="csv"?"csv":"md"}`,u,c==="csv"?"text/csv":"text/markdown"),s(!1),n==null||n(c);}catch(m){o==null||o(m);}};return useEffect(()=>{let c=d=>{a.current&&!a.current.contains(d.target)&&s(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxs("div",{className:"relative",ref:a,children:[jsx("button",{className:p("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!r),title:"Download table",type:"button",children:e!=null?e:jsx(DownloadIcon,{size:14})}),r&&jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};var ht=({children:e,className:t,showControls:n,...o})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(mt,{}),jsx(ut,{})]}),jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:p("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var go=lazy(()=>import('./code-block-24IEBRFM.js').then(e=>({default:e.CodeBlock}))),bo=lazy(()=>import('./mermaid-AOIWFCXG.js').then(e=>({default:e.Mermaid}))),yo=/language-([^\s]+)/;function me(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let n=e.position.start,o=t.position.start,r=e.position.end,s=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function C(e,t){return e.className===t.className&&me(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Ce=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},xe=memo(({children:e,className:t,node:n,...o})=>jsx("ol",{className:p("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>C(e,t));xe.displayName="MarkdownOl";var wt=memo(({children:e,className:t,node:n,...o})=>jsx("li",{className:p("py-1",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&me(e.node,t.node));wt.displayName="MarkdownLi";var kt=memo(({children:e,className:t,node:n,...o})=>jsx("ul",{className:p("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>C(e,t));kt.displayName="MarkdownUl";var vt=memo(({className:e,node:t,...n})=>jsx("hr",{className:p("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>C(e,t));vt.displayName="MarkdownHr";var Ct=memo(({children:e,className:t,node:n,...o})=>jsx("span",{className:p("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>C(e,t));Ct.displayName="MarkdownStrong";var Pt=memo(({children:e,className:t,href:n,node:o,...r})=>{let s=n==="streamdown:incomplete-link";return jsx("a",{className:p("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},(e,t)=>C(e,t)&&e.href===t.href);Pt.displayName="MarkdownA";var Mt=memo(({children:e,className:t,node:n,...o})=>jsx("h1",{className:p("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>C(e,t));Mt.displayName="MarkdownH1";var xt=memo(({children:e,className:t,node:n,...o})=>jsx("h2",{className:p("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>C(e,t));xt.displayName="MarkdownH2";var Tt=memo(({children:e,className:t,node:n,...o})=>jsx("h3",{className:p("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>C(e,t));Tt.displayName="MarkdownH3";var Nt=memo(({children:e,className:t,node:n,...o})=>jsx("h4",{className:p("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>C(e,t));Nt.displayName="MarkdownH4";var It=memo(({children:e,className:t,node:n,...o})=>jsx("h5",{className:p("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>C(e,t));It.displayName="MarkdownH5";var St=memo(({children:e,className:t,node:n,...o})=>jsx("h6",{className:p("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>C(e,t));St.displayName="MarkdownH6";var At=memo(({children:e,className:t,node:n,...o})=>{let{controls:r}=useContext(P),s=Me(r,"table");return jsx(ht,{className:t,"data-streamdown":"table-wrapper",showControls:s,...o,children:e})},(e,t)=>C(e,t));At.displayName="MarkdownTable";var Et=memo(({children:e,className:t,node:n,...o})=>jsx("thead",{className:p("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>C(e,t));Et.displayName="MarkdownThead";var Lt=memo(({children:e,className:t,node:n,...o})=>jsx("tbody",{className:p("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>C(e,t));Lt.displayName="MarkdownTbody";var Bt=memo(({children:e,className:t,node:n,...o})=>jsx("tr",{className:p("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>C(e,t));Bt.displayName="MarkdownTr";var Rt=memo(({children:e,className:t,node:n,...o})=>jsx("th",{className:p("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>C(e,t));Rt.displayName="MarkdownTh";var Dt=memo(({children:e,className:t,node:n,...o})=>jsx("td",{className:p("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>C(e,t));Dt.displayName="MarkdownTd";var jt=memo(({children:e,className:t,node:n,...o})=>jsx("blockquote",{className:p("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>C(e,t));jt.displayName="MarkdownBlockquote";var $t=memo(({children:e,className:t,node:n,...o})=>jsx("sup",{className:p("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>C(e,t));$t.displayName="MarkdownSup";var Ot=memo(({children:e,className:t,node:n,...o})=>jsx("sub",{className:p("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>C(e,t));Ot.displayName="MarkdownSub";var Ht=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=l=>{var f,h;if(!isValidElement(l))return false;let c=Array.isArray(l.props.children)?l.props.children:[l.props.children],d=false,m=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(d=true);else if(isValidElement(u))if(((f=u.props)==null?void 0:f["data-footnote-backref"])!==void 0)m=true;else {let g=Array.isArray(u.props.children)?u.props.children:[u.props.children];for(let w of g){if(typeof w=="string"&&w.trim()!==""){d=true;break}if(isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){d=true;break}}}}return m&&!d},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===xe){let d=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return d.length===0?null:{...l,props:{...l.props,children:d}}}return l}):e;return (Array.isArray(a)?a.some(l=>l!==null):a!==null)?jsx("section",{className:t,...o,children:a}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>C(e,t));Ht.displayName="MarkdownSection";var wo=({node:e,className:t,children:n,...o})=>{var m,f,h;let r=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((f=e==null?void 0:e.position)==null?void 0:f.end.line),{mermaid:s,controls:a}=useContext(P);if(r)return jsx("code",{className:p("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let i=t==null?void 0:t.match(yo),l=(h=i==null?void 0:i.at(1))!=null?h:"",c="";if(isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?c=n.props.children:typeof n=="string"&&(c=n),l==="mermaid"){let u=Me(a,"mermaid"),g=Ce(a,"download"),w=Ce(a,"copy"),k=Ce(a,"fullscreen");return jsxs("div",{className:p("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||w||k)&&jsxs("div",{className:"flex items-center justify-end gap-2",children:[g&&jsx(tt,{chart:c,config:s==null?void 0:s.config}),w&&jsx(ye,{code:c}),k&&jsx(st,{chart:c,config:s==null?void 0:s.config})]}),jsx(Suspense,{fallback:jsx(ke,{}),children:jsx(bo,{chart:c,config:s==null?void 0:s.config})})]})}let d=Me(a,"code");return jsx(Suspense,{fallback:jsx(ke,{}),children:jsx(go,{className:p("overflow-x-auto border-border border-t",t),code:c,"data-language":l,"data-streamdown":"code-block",language:l,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d&&jsxs(Fragment,{children:[jsx(Ze,{code:c,language:l}),jsx(ye,{})]})})})},zt=memo(wo,(e,t)=>e.className===t.className&&me(e.node,t.node));zt.displayName="MarkdownCode";var _t=memo(Ye,(e,t)=>e.className===t.className&&me(e.node,t.node));_t.displayName="MarkdownImg";var qt=memo(({children:e,className:t,node:n,...o})=>{var a;let s=(Array.isArray(e)?e:[e]).filter(i=>i!=null&&i!=="");return s.length===1&&isValidElement(s[0])&&((a=s[0].props.node)==null?void 0:a.tagName)==="img"?jsx(Fragment,{children:e}):jsx("p",{className:t,...o,children:e})},(e,t)=>C(e,t));qt.displayName="MarkdownParagraph";var Ut={ol:xe,li:wt,ul:kt,hr:vt,strong:Ct,a:Pt,h1:Mt,h2:xt,h3:Tt,h4:Nt,h5:It,h6:St,table:At,thead:Et,tbody:Lt,tr:Bt,th:Rt,td:Dt,blockquote:jt,code:zt,img:_t,pre:({children:e})=>e,sup:$t,sub:Ot,p:qt,section:Ht};function Te(e){if(e)throw e}var pe=Sn(Qt());function G(e){if(typeof e!="object"||e===null)return false;let t=Object.getPrototypeOf(e);return (t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ne(){let e=[],t={run:n,use:o};return t;function n(...r){let s=-1,a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);i(null,...r);function i(l,...c){let d=e[++s],m=-1;if(l){a(l);return}for(;++m<r.length;)(c[m]===null||c[m]===void 0)&&(c[m]=r[m]);r=c,d?en(d,i)(...c):a(null,...c);}}function o(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function en(e,t){let n;return o;function o(...a){let i=e.length>a.length,l;i&&a.push(r);try{l=e.apply(this,a);}catch(c){let d=c;if(i&&n)throw d;return r(d)}i||(l&&l.then&&typeof l.then=="function"?l.then(s,r):l instanceof Error?r(l):s(l));}function r(a,...i){n||(n=true,t(a,...i));}function s(a){r(null,a);}}function Se(e){return !e||typeof e!="object"?"":"position"in e||"type"in e?tn(e.position):"start"in e||"end"in e?tn(e):"line"in e||"column"in e?Ie(e):""}function Ie(e){return nn(e&&e.line)+":"+nn(e&&e.column)}function tn(e){return Ie(e&&e.start)+"-"+Ie(e&&e.end)}function nn(e){return e&&typeof e=="number"?e:1}var M=class extends Error{constructor(t,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let r="",s={},a=false;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(a=true,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof o=="string"){let l=o.indexOf(":");l===-1?s.ruleId=o:(s.source=o.slice(0,l),s.ruleId=o.slice(l+1));}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position);}let i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=Se(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0;}};M.prototype.file="";M.prototype.name="";M.prototype.reason="";M.prototype.message="";M.prototype.stack="";M.prototype.column=void 0;M.prototype.line=void 0;M.prototype.ancestors=void 0;M.prototype.cause=void 0;M.prototype.fatal=void 0;M.prototype.place=void 0;M.prototype.ruleId=void 0;M.prototype.source=void 0;var A={basename:ko,dirname:vo,extname:Co,join:Po,sep:"/"};function ko(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Z(e);let n=0,o=-1,r=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else o<0&&(s=true,o=r+1);return o<0?"":e.slice(n,o)}if(t===e)return "";let a=-1,i=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else a<0&&(s=true,a=r+1),i>-1&&(e.codePointAt(r)===t.codePointAt(i--)?i<0&&(o=r):(i=-1,o=a));return n===o?o=a:o<0&&(o=e.length),e.slice(n,o)}function vo(e){if(Z(e),e.length===0)return ".";let t=-1,n=e.length,o;for(;--n;)if(e.codePointAt(n)===47){if(o){t=n;break}}else o||(o=true);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Co(e){Z(e);let t=e.length,n=-1,o=0,r=-1,s=0,a;for(;t--;){let i=e.codePointAt(t);if(i===47){if(a){o=t+1;break}continue}n<0&&(a=true,n=t+1),i===46?r<0?r=t:s!==1&&(s=1):r>-1&&(s=-1);}return r<0||n<0||s===0||s===1&&r===n-1&&r===o+1?"":e.slice(r,n)}function Po(...e){let t=-1,n;for(;++t<e.length;)Z(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Mo(n)}function Mo(e){Z(e);let t=e.codePointAt(0)===47,n=xo(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function xo(e,t){let n="",o=0,r=-1,s=0,a=-1,i,l;for(;++a<=e.length;){if(a<e.length)i=e.codePointAt(a);else {if(i===47)break;i=47;}if(i===47){if(!(r===a-1||s===1))if(r!==a-1&&s===2){if(n.length<2||o!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",o=0):(n=n.slice(0,l),o=n.length-1-n.lastIndexOf("/")),r=a,s=0;continue}}else if(n.length>0){n="",o=0,r=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",o=2);}else n.length>0?n+="/"+e.slice(r+1,a):n=e.slice(r+1,a),o=a-r-1;r=a,s=0;}else i===46&&s>-1?s++:s=-1;}return n}function Z(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var on={cwd:To};function To(){return "/"}function X(e){return !!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function rn(e){if(typeof e=="string")e=new URL(e);else if(!X(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return No(e)}function No(e){if(e.hostname!==""){let o=new TypeError('File URL host must be "localhost" or empty on darwin');throw o.code="ERR_INVALID_FILE_URL_HOST",o}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let o=t.codePointAt(n+2);if(o===70||o===102){let r=new TypeError("File URL path must not include encoded / characters");throw r.code="ERR_INVALID_FILE_URL_PATH",r}}return decodeURIComponent(t)}var Ae=["history","path","basename","stem","extname","dirname"],Y=class{constructor(t){let n;t?X(t)?n={path:t}:typeof t=="string"||Io(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":on.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o=-1;for(;++o<Ae.length;){let s=Ae[o];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s]);}let r;for(r in n)Ae.includes(r)||(this[r]=n[r]);}get basename(){return typeof this.path=="string"?A.basename(this.path):void 0}set basename(t){Le(t,"basename"),Ee(t,"basename"),this.path=A.join(this.dirname||"",t);}get dirname(){return typeof this.path=="string"?A.dirname(this.path):void 0}set dirname(t){sn(this.basename,"dirname"),this.path=A.join(t||"",this.basename);}get extname(){return typeof this.path=="string"?A.extname(this.path):void 0}set extname(t){if(Ee(t,"extname"),sn(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=A.join(this.dirname,this.stem+(t||""));}get path(){return this.history[this.history.length-1]}set path(t){X(t)&&(t=rn(t)),Le(t,"path"),this.path!==t&&this.history.push(t);}get stem(){return typeof this.path=="string"?A.basename(this.path,this.extname):void 0}set stem(t){Le(t,"stem"),Ee(t,"stem"),this.path=A.join(this.dirname||"",t+(this.extname||""));}fail(t,n,o){let r=this.message(t,n,o);throw r.fatal=true,r}info(t,n,o){let r=this.message(t,n,o);return r.fatal=void 0,r}message(t,n,o){let r=new M(t,n,o);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=false,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Ee(e,t){if(e&&e.includes(A.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+A.sep+"`")}function Le(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function sn(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Io(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var an=(function(e){let o=this.constructor.prototype,r=o[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,o),s});var So={}.hasOwnProperty,je=class e extends an{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ne();}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let o=this.attachers[n];t.use(...o);}return t.data((0, pe.default)(true,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(De("data",this.frozen),this.namespace[t]=n,this):So.call(this.namespace,t)&&this.namespace[t]||void 0:t?(De("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...o]=this.attachers[this.freezeIndex];if(o[0]===false)continue;o[0]===true&&(o[0]=void 0);let r=n.call(t,...o);typeof r=="function"&&this.transformers.use(r);}return this.frozen=true,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=ue(t),o=this.parser||this.Parser;return Be("parse",o),o(String(n),n)}process(t,n){let o=this;return this.freeze(),Be("process",this.parser||this.Parser),Re("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(s,a){let i=ue(t),l=o.parse(i);o.run(l,i,function(d,m,f){if(d||!m||!f)return c(d);let h=m,u=o.stringify(h,f);Eo(u)?f.value=u:f.result=u,c(d,f);});function c(d,m){d||!m?a(d):s?s(m):n(void 0,m);}}}processSync(t){let n=false,o;return this.freeze(),Be("processSync",this.parser||this.Parser),Re("processSync",this.compiler||this.Compiler),this.process(t,r),cn("processSync","process",n),o;function r(s,a){n=true,Te(s),o=a;}}run(t,n,o){ln(t),this.freeze();let r=this.transformers;return !o&&typeof n=="function"&&(o=n,n=void 0),o?s(void 0,o):new Promise(s);function s(a,i){let l=ue(n);r.run(t,l,c);function c(d,m,f){let h=m||t;d?i(d):a?a(h):o(void 0,h,f);}}}runSync(t,n){let o=false,r;return this.run(t,n,s),cn("runSync","run",o),r;function s(a,i){Te(a),r=i,o=true;}}stringify(t,n){this.freeze();let o=ue(n),r=this.compiler||this.Compiler;return Re("stringify",r),ln(t),r(t,o)}use(t,...n){let o=this.attachers,r=this.namespace;if(De("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?i(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[d,...m]=c;l(d,m);}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(c.plugins),c.settings&&(r.settings=(0, pe.default)(true,r.settings,c.settings));}function i(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){let m=c[d];s(m);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let m=-1,f=-1;for(;++m<o.length;)if(o[m][0]===c){f=m;break}if(f===-1)o.push([c,...d]);else if(d.length>0){let[h,...u]=d,g=o[f][1];G(g)&&G(h)&&(h=(0, pe.default)(true,g,h)),o[f]=[c,h,...u];}}}},$e=new je().freeze();function Be(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Re(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function De(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ln(e){if(!G(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function cn(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ue(e){return Ao(e)?e:new Y(e)}function Ao(e){return !!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Eo(e){return typeof e=="string"||Lo(e)}function Lo(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var dn=[],mn={allowDangerousHtml:true},he=new WeakMap,Oe=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let f="";for(let h=0;h<m.length;h+=1){let u=m[h];if(h>0&&(f+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let k=he.get(g);k||(k=g.name,he.set(g,k)),f+=k;}else f+=String(g);f+=":",f+=JSON.stringify(w);}else if(typeof u=="function"){let g=he.get(u);g||(g=u.name,he.set(u,g)),f+=g;}else f+=String(u);}return f},i=a(o),l=a(r),c=s?JSON.stringify(s):"",d=`${l}::${i}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},fn=new Oe,He=e=>{let t=Ho(e),n=e.children||"";return _o(t.runSync(t.parse(n),n),e)},Ho=e=>{let t=fn.get(e);if(t)return t;let n=zo(e);return fn.set(e,n),n},zo=e=>{let t=e.rehypePlugins||dn,n=e.remarkPlugins||dn,o=e.remarkRehypeOptions?{...mn,...e.remarkRehypeOptions}:mn;return $e().use($o).use(n).use(Oo,o).use(t)},_o=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Uo=/\[\^[^\]\s]{1,200}\](?!:)/,Fo=/\[\^[^\]\s]{1,200}\]:/,Vo=/<\/(\w+)>/,Wo=/<(\w+)[\s>]/,ze=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
7
+ `)};var mt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let[s,a]=useState(false),[i,l]=useState(false),c=useRef(null),d=useRef(0),{isAnimating:m}=useContext(P),f=async u=>{var g,w;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.write)){o==null||o(new Error("Clipboard API not available"));return}try{let k=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),x=k==null?void 0:k.querySelector("table");if(!x){o==null||o(new Error("Table not found"));return}let N=ie(x),T=u==="csv"?ae(N):it(N),B=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([x.outerHTML],{type:"text/html"})});await navigator.clipboard.write([B]),l(!0),a(!1),n==null||n(u),d.current=window.setTimeout(()=>l(!1),r);}catch(k){o==null||o(k);}};useEffect(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(d.current);}},[]);let h=i?CheckIcon:CopyIcon;return jsxs("div",{className:"relative",ref:c,children:[jsx("button",{className:p("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>a(!s),title:"Copy table",type:"button",children:e!=null?e:jsx(h,{size:14})}),s&&jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("csv"),type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),type:"button",children:"TSV"})]})]})};var ut=({children:e,className:t,onDownload:n,onError:o})=>{let[r,s]=useState(false),a=useRef(null),{isAnimating:i}=useContext(P),l=c=>{var d;try{let m=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),f=m==null?void 0:m.querySelector("table");if(!f){o==null||o(new Error("Table not found"));return}let h=ie(f),u=c==="csv"?ae(h):at(h);E(`table.${c==="csv"?"csv":"md"}`,u,c==="csv"?"text/csv":"text/markdown"),s(!1),n==null||n(c);}catch(m){o==null||o(m);}};return useEffect(()=>{let c=d=>{a.current&&!a.current.contains(d.target)&&s(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxs("div",{className:"relative",ref:a,children:[jsx("button",{className:p("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!r),title:"Download table",type:"button",children:e!=null?e:jsx(DownloadIcon,{size:14})}),r&&jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};var ht=({children:e,className:t,showControls:n,...o})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(mt,{}),jsx(ut,{})]}),jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:p("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var go=lazy(()=>import('./code-block-SSS47RZT.js').then(e=>({default:e.CodeBlock}))),bo=lazy(()=>import('./mermaid-BHACL5H7.js').then(e=>({default:e.Mermaid}))),yo=/language-([^\s]+)/;function me(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let n=e.position.start,o=t.position.start,r=e.position.end,s=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function C(e,t){return e.className===t.className&&me(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Ce=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},xe=memo(({children:e,className:t,node:n,...o})=>jsx("ol",{className:p("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>C(e,t));xe.displayName="MarkdownOl";var wt=memo(({children:e,className:t,node:n,...o})=>jsx("li",{className:p("py-1",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&me(e.node,t.node));wt.displayName="MarkdownLi";var kt=memo(({children:e,className:t,node:n,...o})=>jsx("ul",{className:p("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>C(e,t));kt.displayName="MarkdownUl";var vt=memo(({className:e,node:t,...n})=>jsx("hr",{className:p("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>C(e,t));vt.displayName="MarkdownHr";var Ct=memo(({children:e,className:t,node:n,...o})=>jsx("span",{className:p("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>C(e,t));Ct.displayName="MarkdownStrong";var Pt=memo(({children:e,className:t,href:n,node:o,...r})=>{let s=n==="streamdown:incomplete-link";return jsx("a",{className:p("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},(e,t)=>C(e,t)&&e.href===t.href);Pt.displayName="MarkdownA";var Mt=memo(({children:e,className:t,node:n,...o})=>jsx("h1",{className:p("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>C(e,t));Mt.displayName="MarkdownH1";var xt=memo(({children:e,className:t,node:n,...o})=>jsx("h2",{className:p("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>C(e,t));xt.displayName="MarkdownH2";var Tt=memo(({children:e,className:t,node:n,...o})=>jsx("h3",{className:p("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>C(e,t));Tt.displayName="MarkdownH3";var Nt=memo(({children:e,className:t,node:n,...o})=>jsx("h4",{className:p("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>C(e,t));Nt.displayName="MarkdownH4";var It=memo(({children:e,className:t,node:n,...o})=>jsx("h5",{className:p("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>C(e,t));It.displayName="MarkdownH5";var St=memo(({children:e,className:t,node:n,...o})=>jsx("h6",{className:p("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>C(e,t));St.displayName="MarkdownH6";var At=memo(({children:e,className:t,node:n,...o})=>{let{controls:r}=useContext(P),s=Me(r,"table");return jsx(ht,{className:t,"data-streamdown":"table-wrapper",showControls:s,...o,children:e})},(e,t)=>C(e,t));At.displayName="MarkdownTable";var Et=memo(({children:e,className:t,node:n,...o})=>jsx("thead",{className:p("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>C(e,t));Et.displayName="MarkdownThead";var Lt=memo(({children:e,className:t,node:n,...o})=>jsx("tbody",{className:p("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>C(e,t));Lt.displayName="MarkdownTbody";var Bt=memo(({children:e,className:t,node:n,...o})=>jsx("tr",{className:p("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>C(e,t));Bt.displayName="MarkdownTr";var Rt=memo(({children:e,className:t,node:n,...o})=>jsx("th",{className:p("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>C(e,t));Rt.displayName="MarkdownTh";var Dt=memo(({children:e,className:t,node:n,...o})=>jsx("td",{className:p("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>C(e,t));Dt.displayName="MarkdownTd";var jt=memo(({children:e,className:t,node:n,...o})=>jsx("blockquote",{className:p("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>C(e,t));jt.displayName="MarkdownBlockquote";var $t=memo(({children:e,className:t,node:n,...o})=>jsx("sup",{className:p("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>C(e,t));$t.displayName="MarkdownSup";var Ot=memo(({children:e,className:t,node:n,...o})=>jsx("sub",{className:p("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>C(e,t));Ot.displayName="MarkdownSub";var Ht=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=l=>{var f,h;if(!isValidElement(l))return false;let c=Array.isArray(l.props.children)?l.props.children:[l.props.children],d=false,m=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(d=true);else if(isValidElement(u))if(((f=u.props)==null?void 0:f["data-footnote-backref"])!==void 0)m=true;else {let g=Array.isArray(u.props.children)?u.props.children:[u.props.children];for(let w of g){if(typeof w=="string"&&w.trim()!==""){d=true;break}if(isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){d=true;break}}}}return m&&!d},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===xe){let d=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return d.length===0?null:{...l,props:{...l.props,children:d}}}return l}):e;return (Array.isArray(a)?a.some(l=>l!==null):a!==null)?jsx("section",{className:t,...o,children:a}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>C(e,t));Ht.displayName="MarkdownSection";var wo=({node:e,className:t,children:n,...o})=>{var m,f,h;let r=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((f=e==null?void 0:e.position)==null?void 0:f.end.line),{mermaid:s,controls:a}=useContext(P);if(r)return jsx("code",{className:p("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let i=t==null?void 0:t.match(yo),l=(h=i==null?void 0:i.at(1))!=null?h:"",c="";if(isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?c=n.props.children:typeof n=="string"&&(c=n),l==="mermaid"){let u=Me(a,"mermaid"),g=Ce(a,"download"),w=Ce(a,"copy"),k=Ce(a,"fullscreen");return jsxs("div",{className:p("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||w||k)&&jsxs("div",{className:"flex items-center justify-end gap-2",children:[g&&jsx(tt,{chart:c,config:s==null?void 0:s.config}),w&&jsx(ye,{code:c}),k&&jsx(st,{chart:c,config:s==null?void 0:s.config})]}),jsx(Suspense,{fallback:jsx(ke,{}),children:jsx(bo,{chart:c,config:s==null?void 0:s.config})})]})}let d=Me(a,"code");return jsx(Suspense,{fallback:jsx(ke,{}),children:jsx(go,{className:p("overflow-x-auto border-border border-t",t),code:c,"data-language":l,"data-streamdown":"code-block",language:l,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d&&jsxs(Fragment,{children:[jsx(Ze,{code:c,language:l}),jsx(ye,{})]})})})},zt=memo(wo,(e,t)=>e.className===t.className&&me(e.node,t.node));zt.displayName="MarkdownCode";var _t=memo(Ye,(e,t)=>e.className===t.className&&me(e.node,t.node));_t.displayName="MarkdownImg";var qt=memo(({children:e,className:t,node:n,...o})=>{var a;let s=(Array.isArray(e)?e:[e]).filter(i=>i!=null&&i!=="");return s.length===1&&isValidElement(s[0])&&((a=s[0].props.node)==null?void 0:a.tagName)==="img"?jsx(Fragment,{children:e}):jsx("p",{className:t,...o,children:e})},(e,t)=>C(e,t));qt.displayName="MarkdownParagraph";var Ut={ol:xe,li:wt,ul:kt,hr:vt,strong:Ct,a:Pt,h1:Mt,h2:xt,h3:Tt,h4:Nt,h5:It,h6:St,table:At,thead:Et,tbody:Lt,tr:Bt,th:Rt,td:Dt,blockquote:jt,code:zt,img:_t,pre:({children:e})=>e,sup:$t,sub:Ot,p:qt,section:Ht};function Te(e){if(e)throw e}var pe=Sn(Qt());function G(e){if(typeof e!="object"||e===null)return false;let t=Object.getPrototypeOf(e);return (t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ne(){let e=[],t={run:n,use:o};return t;function n(...r){let s=-1,a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);i(null,...r);function i(l,...c){let d=e[++s],m=-1;if(l){a(l);return}for(;++m<r.length;)(c[m]===null||c[m]===void 0)&&(c[m]=r[m]);r=c,d?en(d,i)(...c):a(null,...c);}}function o(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function en(e,t){let n;return o;function o(...a){let i=e.length>a.length,l;i&&a.push(r);try{l=e.apply(this,a);}catch(c){let d=c;if(i&&n)throw d;return r(d)}i||(l&&l.then&&typeof l.then=="function"?l.then(s,r):l instanceof Error?r(l):s(l));}function r(a,...i){n||(n=true,t(a,...i));}function s(a){r(null,a);}}function Se(e){return !e||typeof e!="object"?"":"position"in e||"type"in e?tn(e.position):"start"in e||"end"in e?tn(e):"line"in e||"column"in e?Ie(e):""}function Ie(e){return nn(e&&e.line)+":"+nn(e&&e.column)}function tn(e){return Ie(e&&e.start)+"-"+Ie(e&&e.end)}function nn(e){return e&&typeof e=="number"?e:1}var M=class extends Error{constructor(t,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let r="",s={},a=false;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(a=true,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof o=="string"){let l=o.indexOf(":");l===-1?s.ruleId=o:(s.source=o.slice(0,l),s.ruleId=o.slice(l+1));}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position);}let i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=Se(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0;}};M.prototype.file="";M.prototype.name="";M.prototype.reason="";M.prototype.message="";M.prototype.stack="";M.prototype.column=void 0;M.prototype.line=void 0;M.prototype.ancestors=void 0;M.prototype.cause=void 0;M.prototype.fatal=void 0;M.prototype.place=void 0;M.prototype.ruleId=void 0;M.prototype.source=void 0;var A={basename:ko,dirname:vo,extname:Co,join:Po,sep:"/"};function ko(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Z(e);let n=0,o=-1,r=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else o<0&&(s=true,o=r+1);return o<0?"":e.slice(n,o)}if(t===e)return "";let a=-1,i=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else a<0&&(s=true,a=r+1),i>-1&&(e.codePointAt(r)===t.codePointAt(i--)?i<0&&(o=r):(i=-1,o=a));return n===o?o=a:o<0&&(o=e.length),e.slice(n,o)}function vo(e){if(Z(e),e.length===0)return ".";let t=-1,n=e.length,o;for(;--n;)if(e.codePointAt(n)===47){if(o){t=n;break}}else o||(o=true);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Co(e){Z(e);let t=e.length,n=-1,o=0,r=-1,s=0,a;for(;t--;){let i=e.codePointAt(t);if(i===47){if(a){o=t+1;break}continue}n<0&&(a=true,n=t+1),i===46?r<0?r=t:s!==1&&(s=1):r>-1&&(s=-1);}return r<0||n<0||s===0||s===1&&r===n-1&&r===o+1?"":e.slice(r,n)}function Po(...e){let t=-1,n;for(;++t<e.length;)Z(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Mo(n)}function Mo(e){Z(e);let t=e.codePointAt(0)===47,n=xo(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function xo(e,t){let n="",o=0,r=-1,s=0,a=-1,i,l;for(;++a<=e.length;){if(a<e.length)i=e.codePointAt(a);else {if(i===47)break;i=47;}if(i===47){if(!(r===a-1||s===1))if(r!==a-1&&s===2){if(n.length<2||o!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",o=0):(n=n.slice(0,l),o=n.length-1-n.lastIndexOf("/")),r=a,s=0;continue}}else if(n.length>0){n="",o=0,r=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",o=2);}else n.length>0?n+="/"+e.slice(r+1,a):n=e.slice(r+1,a),o=a-r-1;r=a,s=0;}else i===46&&s>-1?s++:s=-1;}return n}function Z(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var on={cwd:To};function To(){return "/"}function X(e){return !!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function rn(e){if(typeof e=="string")e=new URL(e);else if(!X(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return No(e)}function No(e){if(e.hostname!==""){let o=new TypeError('File URL host must be "localhost" or empty on darwin');throw o.code="ERR_INVALID_FILE_URL_HOST",o}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let o=t.codePointAt(n+2);if(o===70||o===102){let r=new TypeError("File URL path must not include encoded / characters");throw r.code="ERR_INVALID_FILE_URL_PATH",r}}return decodeURIComponent(t)}var Ae=["history","path","basename","stem","extname","dirname"],Y=class{constructor(t){let n;t?X(t)?n={path:t}:typeof t=="string"||Io(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":on.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o=-1;for(;++o<Ae.length;){let s=Ae[o];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s]);}let r;for(r in n)Ae.includes(r)||(this[r]=n[r]);}get basename(){return typeof this.path=="string"?A.basename(this.path):void 0}set basename(t){Le(t,"basename"),Ee(t,"basename"),this.path=A.join(this.dirname||"",t);}get dirname(){return typeof this.path=="string"?A.dirname(this.path):void 0}set dirname(t){sn(this.basename,"dirname"),this.path=A.join(t||"",this.basename);}get extname(){return typeof this.path=="string"?A.extname(this.path):void 0}set extname(t){if(Ee(t,"extname"),sn(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=A.join(this.dirname,this.stem+(t||""));}get path(){return this.history[this.history.length-1]}set path(t){X(t)&&(t=rn(t)),Le(t,"path"),this.path!==t&&this.history.push(t);}get stem(){return typeof this.path=="string"?A.basename(this.path,this.extname):void 0}set stem(t){Le(t,"stem"),Ee(t,"stem"),this.path=A.join(this.dirname||"",t+(this.extname||""));}fail(t,n,o){let r=this.message(t,n,o);throw r.fatal=true,r}info(t,n,o){let r=this.message(t,n,o);return r.fatal=void 0,r}message(t,n,o){let r=new M(t,n,o);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=false,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Ee(e,t){if(e&&e.includes(A.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+A.sep+"`")}function Le(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function sn(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Io(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var an=(function(e){let o=this.constructor.prototype,r=o[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,o),s});var So={}.hasOwnProperty,je=class e extends an{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ne();}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let o=this.attachers[n];t.use(...o);}return t.data((0, pe.default)(true,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(De("data",this.frozen),this.namespace[t]=n,this):So.call(this.namespace,t)&&this.namespace[t]||void 0:t?(De("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...o]=this.attachers[this.freezeIndex];if(o[0]===false)continue;o[0]===true&&(o[0]=void 0);let r=n.call(t,...o);typeof r=="function"&&this.transformers.use(r);}return this.frozen=true,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=ue(t),o=this.parser||this.Parser;return Be("parse",o),o(String(n),n)}process(t,n){let o=this;return this.freeze(),Be("process",this.parser||this.Parser),Re("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(s,a){let i=ue(t),l=o.parse(i);o.run(l,i,function(d,m,f){if(d||!m||!f)return c(d);let h=m,u=o.stringify(h,f);Eo(u)?f.value=u:f.result=u,c(d,f);});function c(d,m){d||!m?a(d):s?s(m):n(void 0,m);}}}processSync(t){let n=false,o;return this.freeze(),Be("processSync",this.parser||this.Parser),Re("processSync",this.compiler||this.Compiler),this.process(t,r),cn("processSync","process",n),o;function r(s,a){n=true,Te(s),o=a;}}run(t,n,o){ln(t),this.freeze();let r=this.transformers;return !o&&typeof n=="function"&&(o=n,n=void 0),o?s(void 0,o):new Promise(s);function s(a,i){let l=ue(n);r.run(t,l,c);function c(d,m,f){let h=m||t;d?i(d):a?a(h):o(void 0,h,f);}}}runSync(t,n){let o=false,r;return this.run(t,n,s),cn("runSync","run",o),r;function s(a,i){Te(a),r=i,o=true;}}stringify(t,n){this.freeze();let o=ue(n),r=this.compiler||this.Compiler;return Re("stringify",r),ln(t),r(t,o)}use(t,...n){let o=this.attachers,r=this.namespace;if(De("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?i(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[d,...m]=c;l(d,m);}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(c.plugins),c.settings&&(r.settings=(0, pe.default)(true,r.settings,c.settings));}function i(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){let m=c[d];s(m);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let m=-1,f=-1;for(;++m<o.length;)if(o[m][0]===c){f=m;break}if(f===-1)o.push([c,...d]);else if(d.length>0){let[h,...u]=d,g=o[f][1];G(g)&&G(h)&&(h=(0, pe.default)(true,g,h)),o[f]=[c,h,...u];}}}},$e=new je().freeze();function Be(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Re(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function De(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ln(e){if(!G(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function cn(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ue(e){return Ao(e)?e:new Y(e)}function Ao(e){return !!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Eo(e){return typeof e=="string"||Lo(e)}function Lo(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var dn=[],mn={allowDangerousHtml:true},he=new WeakMap,Oe=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let f="";for(let h=0;h<m.length;h+=1){let u=m[h];if(h>0&&(f+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let k=he.get(g);k||(k=g.name,he.set(g,k)),f+=k;}else f+=String(g);f+=":",f+=JSON.stringify(w);}else if(typeof u=="function"){let g=he.get(u);g||(g=u.name,he.set(u,g)),f+=g;}else f+=String(u);}return f},i=a(o),l=a(r),c=s?JSON.stringify(s):"",d=`${l}::${i}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},fn=new Oe,He=e=>{let t=Ho(e),n=e.children||"";return _o(t.runSync(t.parse(n),n),e)},Ho=e=>{let t=fn.get(e);if(t)return t;let n=zo(e);return fn.set(e,n),n},zo=e=>{let t=e.rehypePlugins||dn,n=e.remarkPlugins||dn,o=e.remarkRehypeOptions?{...mn,...e.remarkRehypeOptions}:mn;return $e().use($o).use(n).use(Oo,o).use(t)},_o=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Uo=/\[\^[^\]\s]{1,200}\](?!:)/,Fo=/\[\^[^\]\s]{1,200}\]:/,Vo=/<\/(\w+)>/,Wo=/<(\w+)[\s>]/,ze=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
8
8
  `||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},Xo=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
9
9
  `||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},_e=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},qe=e=>{let t=Uo.test(e),n=Fo.test(e);if(t||n)return [e];let o=Lexer.lex(e,{gfm:true}),r=[],s=[];for(let a of o){let i=a.raw,l=r.length;if(s.length>0){if(r[l-1]+=i,a.type==="html"){let d=i.match(Vo);if(d){let m=d[1];s.at(-1)===m&&s.pop();}}continue}if(a.type==="html"&&a.block){let d=i.match(Wo);if(d){let m=d[1];i.includes(`</${m}>`)||s.push(m);}}if(i.trim()==="$$"&&l>0){let d=r[l-1],m=ze(d),f=_e(d);if(m&&f%2===1){r[l-1]=d+i;continue}}if(l>0&&Xo(i)){let d=r[l-1],m=ze(d),f=_e(d),h=_e(i);if(m&&f%2===1&&!ze(i)&&h===1){r[l-1]=d+i;continue}}r.push(i);}return r};var Jo=/(\*\*)([^*]*?)$/,Ko=/(__)([^_]*?)$/,Go=/(\*\*\*)([^*]*?)$/,Zo=/(\*)([^*]*?)$/,Yo=/(_)([^_]*?)$/,Qo=/(`)([^`]*?)$/,er=/(~~)([^~]*?)$/,_=/^[\s_~*`]*$/,un=/^[\s]*[-*+][\s]+$/,tr=/[\p{L}\p{N}_]/u,nr=/^```[^`\n]*```?$/,or=/^\*{4,}$/,D=e=>{if(!e)return false;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?true:tr.test(e)},ge=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
10
10
  `)};var rr=(e,t)=>{let n=1;for(let o=t-1;o>=0;o-=1)if(e[o]==="]")n+=1;else if(e[o]==="["&&(n-=1,n===0))return o;return -1},sr=(e,t)=>{let n=1;for(let o=t+1;o<e.length;o+=1)if(e[o]==="[")n+=1;else if(e[o]==="]"&&(n-=1,n===0))return o;return -1},Ue=(e,t)=>{let n=false,o=false;for(let r=0;r<t;r+=1){if(e.substring(r,r+3)==="```"){o=!o,r+=2;continue}!o&&e[r]==="`"&&(n=!n);}return n||o},ir=e=>{let t=e.lastIndexOf("](");if(t!==-1&&!Ue(e,t)&&!e.substring(t+2).includes(")")){let o=rr(e,t);if(o!==-1&&!Ue(e,o)){let r=o>0&&e[o-1]==="!",s=r?o-1:o,a=e.substring(0,s),i=e.substring(o+1,t);return r?a:`${a}[${i}](streamdown:incomplete-link)`}}for(let n=e.length-1;n>=0;n-=1)if(e[n]==="["&&!Ue(e,n)){let o=n>0&&e[n-1]==="!",r=o?n-1:n;if(!e.substring(n+1).includes("]")){let i=e.substring(0,r);return o?i:`${e}](streamdown:incomplete-link)`}if(sr(e,n)===-1){let i=e.substring(0,r);return o?i:`${e}](streamdown:incomplete-link)`}}return e},ar=e=>{if(ge(e))return e;let t=e.match(Jo);if(t){let n=t[2];if(!n||_.test(n))return e;let o=e.lastIndexOf(t[1]),s=e.substring(0,o).lastIndexOf(`
@@ -4,7 +4,7 @@
4
4
  `||m==="\r"){l=true;break}}if(!l)return i;let c=[];for(let d=0;d<i.length;d+=1){let m=i[d];m===" "?c.push("\\t"):m===`
5
5
  `?c.push("\\n"):m==="\r"?c.push("\\r"):c.push(m);}return c.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(" "),a+=1);for(let i of n)s[a]=i.map(o).join(" "),a+=1;return s.join(`
6
6
  `)},ve=e=>{let t=false;for(let o=0;o<e.length;o+=1){let r=e[o];if(r==="\\"||r==="|"){t=true;break}}if(!t)return e;let n=[];for(let o=0;o<e.length;o+=1){let r=e[o];r==="\\"?n.push("\\\\"):r==="|"?n.push("\\|"):n.push(r);}return n.join("")},at=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(i=>ve(i));o[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let i=0;i<t.length;i+=1)a[i]="---";o[r]=`| ${a.join(" | ")} |`,r+=1;for(let i of n)if(i.length<t.length){let l=new Array(t.length);for(let c=0;c<t.length;c+=1)l[c]=c<i.length?ve(i[c]):"";o[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=i.map(c=>ve(c));o[r]=`| ${l.join(" | ")} |`,r+=1;}return o.join(`
7
- `)};var mt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let[s,a]=react.useState(false),[i,l]=react.useState(false),c=react.useRef(null),d=react.useRef(0),{isAnimating:m}=react.useContext(P),f=async u=>{var g,w;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.write)){o==null||o(new Error("Clipboard API not available"));return}try{let k=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),x=k==null?void 0:k.querySelector("table");if(!x){o==null||o(new Error("Table not found"));return}let N=ie(x),T=u==="csv"?ae(N):it(N),B=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([x.outerHTML],{type:"text/html"})});await navigator.clipboard.write([B]),l(!0),a(!1),n==null||n(u),d.current=window.setTimeout(()=>l(!1),r);}catch(k){o==null||o(k);}};react.useEffect(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(d.current);}},[]);let h=i?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsx("button",{className:p("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>a(!s),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(h,{size:14})}),s&&jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("csv"),type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),type:"button",children:"TSV"})]})]})};var ut=({children:e,className:t,onDownload:n,onError:o})=>{let[r,s]=react.useState(false),a=react.useRef(null),{isAnimating:i}=react.useContext(P),l=c=>{var d;try{let m=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),f=m==null?void 0:m.querySelector("table");if(!f){o==null||o(new Error("Table not found"));return}let h=ie(f),u=c==="csv"?ae(h):at(h);E(`table.${c==="csv"?"csv":"md"}`,u,c==="csv"?"text/csv":"text/markdown"),s(!1),n==null||n(c);}catch(m){o==null||o(m);}};return react.useEffect(()=>{let c=d=>{a.current&&!a.current.contains(d.target)&&s(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:a,children:[jsxRuntime.jsx("button",{className:p("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!r),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})}),r&&jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};var ht=({children:e,className:t,showControls:n,...o})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(mt,{}),jsxRuntime.jsx(ut,{})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:p("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var go=react.lazy(()=>import('./code-block-FUVDDOWB.cjs').then(e=>({default:e.CodeBlock}))),bo=react.lazy(()=>import('./mermaid-O6WH3TJD.cjs').then(e=>({default:e.Mermaid}))),yo=/language-([^\s]+)/;function me(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let n=e.position.start,o=t.position.start,r=e.position.end,s=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function C(e,t){return e.className===t.className&&me(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Ce=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},xe=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("ol",{className:p("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>C(e,t));xe.displayName="MarkdownOl";var wt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("li",{className:p("py-1",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&me(e.node,t.node));wt.displayName="MarkdownLi";var kt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("ul",{className:p("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>C(e,t));kt.displayName="MarkdownUl";var vt=react.memo(({className:e,node:t,...n})=>jsxRuntime.jsx("hr",{className:p("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>C(e,t));vt.displayName="MarkdownHr";var Ct=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("span",{className:p("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>C(e,t));Ct.displayName="MarkdownStrong";var Pt=react.memo(({children:e,className:t,href:n,node:o,...r})=>{let s=n==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:p("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},(e,t)=>C(e,t)&&e.href===t.href);Pt.displayName="MarkdownA";var Mt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h1",{className:p("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>C(e,t));Mt.displayName="MarkdownH1";var xt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h2",{className:p("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>C(e,t));xt.displayName="MarkdownH2";var Tt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h3",{className:p("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>C(e,t));Tt.displayName="MarkdownH3";var Nt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h4",{className:p("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>C(e,t));Nt.displayName="MarkdownH4";var It=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h5",{className:p("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>C(e,t));It.displayName="MarkdownH5";var St=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h6",{className:p("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>C(e,t));St.displayName="MarkdownH6";var At=react.memo(({children:e,className:t,node:n,...o})=>{let{controls:r}=react.useContext(P),s=Me(r,"table");return jsxRuntime.jsx(ht,{className:t,"data-streamdown":"table-wrapper",showControls:s,...o,children:e})},(e,t)=>C(e,t));At.displayName="MarkdownTable";var Et=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("thead",{className:p("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>C(e,t));Et.displayName="MarkdownThead";var Lt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("tbody",{className:p("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>C(e,t));Lt.displayName="MarkdownTbody";var Bt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("tr",{className:p("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>C(e,t));Bt.displayName="MarkdownTr";var Rt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("th",{className:p("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>C(e,t));Rt.displayName="MarkdownTh";var Dt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("td",{className:p("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>C(e,t));Dt.displayName="MarkdownTd";var jt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("blockquote",{className:p("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>C(e,t));jt.displayName="MarkdownBlockquote";var $t=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("sup",{className:p("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>C(e,t));$t.displayName="MarkdownSup";var Ot=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("sub",{className:p("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>C(e,t));Ot.displayName="MarkdownSub";var Ht=react.memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=l=>{var f,h;if(!react.isValidElement(l))return false;let c=Array.isArray(l.props.children)?l.props.children:[l.props.children],d=false,m=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(d=true);else if(react.isValidElement(u))if(((f=u.props)==null?void 0:f["data-footnote-backref"])!==void 0)m=true;else {let g=Array.isArray(u.props.children)?u.props.children:[u.props.children];for(let w of g){if(typeof w=="string"&&w.trim()!==""){d=true;break}if(react.isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){d=true;break}}}}return m&&!d},a=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===xe){let d=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return d.length===0?null:{...l,props:{...l.props,children:d}}}return l}):e;return (Array.isArray(a)?a.some(l=>l!==null):a!==null)?jsxRuntime.jsx("section",{className:t,...o,children:a}):null}return jsxRuntime.jsx("section",{className:t,...o,children:e})},(e,t)=>C(e,t));Ht.displayName="MarkdownSection";var wo=({node:e,className:t,children:n,...o})=>{var m,f,h;let r=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((f=e==null?void 0:e.position)==null?void 0:f.end.line),{mermaid:s,controls:a}=react.useContext(P);if(r)return jsxRuntime.jsx("code",{className:p("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let i=t==null?void 0:t.match(yo),l=(h=i==null?void 0:i.at(1))!=null?h:"",c="";if(react.isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?c=n.props.children:typeof n=="string"&&(c=n),l==="mermaid"){let u=Me(a,"mermaid"),g=Ce(a,"download"),w=Ce(a,"copy"),k=Ce(a,"fullscreen");return jsxRuntime.jsxs("div",{className:p("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||w||k)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[g&&jsxRuntime.jsx(tt,{chart:c,config:s==null?void 0:s.config}),w&&jsxRuntime.jsx(ye,{code:c}),k&&jsxRuntime.jsx(st,{chart:c,config:s==null?void 0:s.config})]}),jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(ke,{}),children:jsxRuntime.jsx(bo,{chart:c,config:s==null?void 0:s.config})})]})}let d=Me(a,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(ke,{}),children:jsxRuntime.jsx(go,{className:p("overflow-x-auto border-border border-t",t),code:c,"data-language":l,"data-streamdown":"code-block",language:l,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ze,{code:c,language:l}),jsxRuntime.jsx(ye,{})]})})})},zt=react.memo(wo,(e,t)=>e.className===t.className&&me(e.node,t.node));zt.displayName="MarkdownCode";var _t=react.memo(Ye,(e,t)=>e.className===t.className&&me(e.node,t.node));_t.displayName="MarkdownImg";var qt=react.memo(({children:e,className:t,node:n,...o})=>{var a;let s=(Array.isArray(e)?e:[e]).filter(i=>i!=null&&i!=="");return s.length===1&&react.isValidElement(s[0])&&((a=s[0].props.node)==null?void 0:a.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):jsxRuntime.jsx("p",{className:t,...o,children:e})},(e,t)=>C(e,t));qt.displayName="MarkdownParagraph";var Ut={ol:xe,li:wt,ul:kt,hr:vt,strong:Ct,a:Pt,h1:Mt,h2:xt,h3:Tt,h4:Nt,h5:It,h6:St,table:At,thead:Et,tbody:Lt,tr:Bt,th:Rt,td:Dt,blockquote:jt,code:zt,img:_t,pre:({children:e})=>e,sup:$t,sub:Ot,p:qt,section:Ht};function Te(e){if(e)throw e}var pe=Sn(Qt());function G(e){if(typeof e!="object"||e===null)return false;let t=Object.getPrototypeOf(e);return (t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ne(){let e=[],t={run:n,use:o};return t;function n(...r){let s=-1,a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);i(null,...r);function i(l,...c){let d=e[++s],m=-1;if(l){a(l);return}for(;++m<r.length;)(c[m]===null||c[m]===void 0)&&(c[m]=r[m]);r=c,d?en(d,i)(...c):a(null,...c);}}function o(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function en(e,t){let n;return o;function o(...a){let i=e.length>a.length,l;i&&a.push(r);try{l=e.apply(this,a);}catch(c){let d=c;if(i&&n)throw d;return r(d)}i||(l&&l.then&&typeof l.then=="function"?l.then(s,r):l instanceof Error?r(l):s(l));}function r(a,...i){n||(n=true,t(a,...i));}function s(a){r(null,a);}}function Se(e){return !e||typeof e!="object"?"":"position"in e||"type"in e?tn(e.position):"start"in e||"end"in e?tn(e):"line"in e||"column"in e?Ie(e):""}function Ie(e){return nn(e&&e.line)+":"+nn(e&&e.column)}function tn(e){return Ie(e&&e.start)+"-"+Ie(e&&e.end)}function nn(e){return e&&typeof e=="number"?e:1}var M=class extends Error{constructor(t,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let r="",s={},a=false;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(a=true,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof o=="string"){let l=o.indexOf(":");l===-1?s.ruleId=o:(s.source=o.slice(0,l),s.ruleId=o.slice(l+1));}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position);}let i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=Se(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0;}};M.prototype.file="";M.prototype.name="";M.prototype.reason="";M.prototype.message="";M.prototype.stack="";M.prototype.column=void 0;M.prototype.line=void 0;M.prototype.ancestors=void 0;M.prototype.cause=void 0;M.prototype.fatal=void 0;M.prototype.place=void 0;M.prototype.ruleId=void 0;M.prototype.source=void 0;var A={basename:ko,dirname:vo,extname:Co,join:Po,sep:"/"};function ko(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Z(e);let n=0,o=-1,r=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else o<0&&(s=true,o=r+1);return o<0?"":e.slice(n,o)}if(t===e)return "";let a=-1,i=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else a<0&&(s=true,a=r+1),i>-1&&(e.codePointAt(r)===t.codePointAt(i--)?i<0&&(o=r):(i=-1,o=a));return n===o?o=a:o<0&&(o=e.length),e.slice(n,o)}function vo(e){if(Z(e),e.length===0)return ".";let t=-1,n=e.length,o;for(;--n;)if(e.codePointAt(n)===47){if(o){t=n;break}}else o||(o=true);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Co(e){Z(e);let t=e.length,n=-1,o=0,r=-1,s=0,a;for(;t--;){let i=e.codePointAt(t);if(i===47){if(a){o=t+1;break}continue}n<0&&(a=true,n=t+1),i===46?r<0?r=t:s!==1&&(s=1):r>-1&&(s=-1);}return r<0||n<0||s===0||s===1&&r===n-1&&r===o+1?"":e.slice(r,n)}function Po(...e){let t=-1,n;for(;++t<e.length;)Z(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Mo(n)}function Mo(e){Z(e);let t=e.codePointAt(0)===47,n=xo(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function xo(e,t){let n="",o=0,r=-1,s=0,a=-1,i,l;for(;++a<=e.length;){if(a<e.length)i=e.codePointAt(a);else {if(i===47)break;i=47;}if(i===47){if(!(r===a-1||s===1))if(r!==a-1&&s===2){if(n.length<2||o!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",o=0):(n=n.slice(0,l),o=n.length-1-n.lastIndexOf("/")),r=a,s=0;continue}}else if(n.length>0){n="",o=0,r=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",o=2);}else n.length>0?n+="/"+e.slice(r+1,a):n=e.slice(r+1,a),o=a-r-1;r=a,s=0;}else i===46&&s>-1?s++:s=-1;}return n}function Z(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var on={cwd:To};function To(){return "/"}function X(e){return !!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function rn(e){if(typeof e=="string")e=new URL(e);else if(!X(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return No(e)}function No(e){if(e.hostname!==""){let o=new TypeError('File URL host must be "localhost" or empty on darwin');throw o.code="ERR_INVALID_FILE_URL_HOST",o}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let o=t.codePointAt(n+2);if(o===70||o===102){let r=new TypeError("File URL path must not include encoded / characters");throw r.code="ERR_INVALID_FILE_URL_PATH",r}}return decodeURIComponent(t)}var Ae=["history","path","basename","stem","extname","dirname"],Y=class{constructor(t){let n;t?X(t)?n={path:t}:typeof t=="string"||Io(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":on.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o=-1;for(;++o<Ae.length;){let s=Ae[o];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s]);}let r;for(r in n)Ae.includes(r)||(this[r]=n[r]);}get basename(){return typeof this.path=="string"?A.basename(this.path):void 0}set basename(t){Le(t,"basename"),Ee(t,"basename"),this.path=A.join(this.dirname||"",t);}get dirname(){return typeof this.path=="string"?A.dirname(this.path):void 0}set dirname(t){sn(this.basename,"dirname"),this.path=A.join(t||"",this.basename);}get extname(){return typeof this.path=="string"?A.extname(this.path):void 0}set extname(t){if(Ee(t,"extname"),sn(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=A.join(this.dirname,this.stem+(t||""));}get path(){return this.history[this.history.length-1]}set path(t){X(t)&&(t=rn(t)),Le(t,"path"),this.path!==t&&this.history.push(t);}get stem(){return typeof this.path=="string"?A.basename(this.path,this.extname):void 0}set stem(t){Le(t,"stem"),Ee(t,"stem"),this.path=A.join(this.dirname||"",t+(this.extname||""));}fail(t,n,o){let r=this.message(t,n,o);throw r.fatal=true,r}info(t,n,o){let r=this.message(t,n,o);return r.fatal=void 0,r}message(t,n,o){let r=new M(t,n,o);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=false,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Ee(e,t){if(e&&e.includes(A.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+A.sep+"`")}function Le(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function sn(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Io(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var an=(function(e){let o=this.constructor.prototype,r=o[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,o),s});var So={}.hasOwnProperty,je=class e extends an{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ne();}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let o=this.attachers[n];t.use(...o);}return t.data((0, pe.default)(true,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(De("data",this.frozen),this.namespace[t]=n,this):So.call(this.namespace,t)&&this.namespace[t]||void 0:t?(De("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...o]=this.attachers[this.freezeIndex];if(o[0]===false)continue;o[0]===true&&(o[0]=void 0);let r=n.call(t,...o);typeof r=="function"&&this.transformers.use(r);}return this.frozen=true,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=ue(t),o=this.parser||this.Parser;return Be("parse",o),o(String(n),n)}process(t,n){let o=this;return this.freeze(),Be("process",this.parser||this.Parser),Re("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(s,a){let i=ue(t),l=o.parse(i);o.run(l,i,function(d,m,f){if(d||!m||!f)return c(d);let h=m,u=o.stringify(h,f);Eo(u)?f.value=u:f.result=u,c(d,f);});function c(d,m){d||!m?a(d):s?s(m):n(void 0,m);}}}processSync(t){let n=false,o;return this.freeze(),Be("processSync",this.parser||this.Parser),Re("processSync",this.compiler||this.Compiler),this.process(t,r),cn("processSync","process",n),o;function r(s,a){n=true,Te(s),o=a;}}run(t,n,o){ln(t),this.freeze();let r=this.transformers;return !o&&typeof n=="function"&&(o=n,n=void 0),o?s(void 0,o):new Promise(s);function s(a,i){let l=ue(n);r.run(t,l,c);function c(d,m,f){let h=m||t;d?i(d):a?a(h):o(void 0,h,f);}}}runSync(t,n){let o=false,r;return this.run(t,n,s),cn("runSync","run",o),r;function s(a,i){Te(a),r=i,o=true;}}stringify(t,n){this.freeze();let o=ue(n),r=this.compiler||this.Compiler;return Re("stringify",r),ln(t),r(t,o)}use(t,...n){let o=this.attachers,r=this.namespace;if(De("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?i(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[d,...m]=c;l(d,m);}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(c.plugins),c.settings&&(r.settings=(0, pe.default)(true,r.settings,c.settings));}function i(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){let m=c[d];s(m);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let m=-1,f=-1;for(;++m<o.length;)if(o[m][0]===c){f=m;break}if(f===-1)o.push([c,...d]);else if(d.length>0){let[h,...u]=d,g=o[f][1];G(g)&&G(h)&&(h=(0, pe.default)(true,g,h)),o[f]=[c,h,...u];}}}},$e=new je().freeze();function Be(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Re(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function De(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ln(e){if(!G(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function cn(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ue(e){return Ao(e)?e:new Y(e)}function Ao(e){return !!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Eo(e){return typeof e=="string"||Lo(e)}function Lo(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var dn=[],mn={allowDangerousHtml:true},he=new WeakMap,Oe=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let f="";for(let h=0;h<m.length;h+=1){let u=m[h];if(h>0&&(f+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let k=he.get(g);k||(k=g.name,he.set(g,k)),f+=k;}else f+=String(g);f+=":",f+=JSON.stringify(w);}else if(typeof u=="function"){let g=he.get(u);g||(g=u.name,he.set(u,g)),f+=g;}else f+=String(u);}return f},i=a(o),l=a(r),c=s?JSON.stringify(s):"",d=`${l}::${i}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},fn=new Oe,He=e=>{let t=Ho(e),n=e.children||"";return _o(t.runSync(t.parse(n),n),e)},Ho=e=>{let t=fn.get(e);if(t)return t;let n=zo(e);return fn.set(e,n),n},zo=e=>{let t=e.rehypePlugins||dn,n=e.remarkPlugins||dn,o=e.remarkRehypeOptions?{...mn,...e.remarkRehypeOptions}:mn;return $e().use($o__default.default).use(n).use(Oo__default.default,o).use(t)},_o=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Uo=/\[\^[^\]\s]{1,200}\](?!:)/,Fo=/\[\^[^\]\s]{1,200}\]:/,Vo=/<\/(\w+)>/,Wo=/<(\w+)[\s>]/,ze=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
7
+ `)};var mt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let[s,a]=react.useState(false),[i,l]=react.useState(false),c=react.useRef(null),d=react.useRef(0),{isAnimating:m}=react.useContext(P),f=async u=>{var g,w;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.write)){o==null||o(new Error("Clipboard API not available"));return}try{let k=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),x=k==null?void 0:k.querySelector("table");if(!x){o==null||o(new Error("Table not found"));return}let N=ie(x),T=u==="csv"?ae(N):it(N),B=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([x.outerHTML],{type:"text/html"})});await navigator.clipboard.write([B]),l(!0),a(!1),n==null||n(u),d.current=window.setTimeout(()=>l(!1),r);}catch(k){o==null||o(k);}};react.useEffect(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(d.current);}},[]);let h=i?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsx("button",{className:p("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>a(!s),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(h,{size:14})}),s&&jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("csv"),type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),type:"button",children:"TSV"})]})]})};var ut=({children:e,className:t,onDownload:n,onError:o})=>{let[r,s]=react.useState(false),a=react.useRef(null),{isAnimating:i}=react.useContext(P),l=c=>{var d;try{let m=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),f=m==null?void 0:m.querySelector("table");if(!f){o==null||o(new Error("Table not found"));return}let h=ie(f),u=c==="csv"?ae(h):at(h);E(`table.${c==="csv"?"csv":"md"}`,u,c==="csv"?"text/csv":"text/markdown"),s(!1),n==null||n(c);}catch(m){o==null||o(m);}};return react.useEffect(()=>{let c=d=>{a.current&&!a.current.contains(d.target)&&s(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:a,children:[jsxRuntime.jsx("button",{className:p("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!r),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})}),r&&jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};var ht=({children:e,className:t,showControls:n,...o})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(mt,{}),jsxRuntime.jsx(ut,{})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:p("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var go=react.lazy(()=>import('./code-block-NMIOKTOP.cjs').then(e=>({default:e.CodeBlock}))),bo=react.lazy(()=>import('./mermaid-CBNUSGBO.cjs').then(e=>({default:e.Mermaid}))),yo=/language-([^\s]+)/;function me(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let n=e.position.start,o=t.position.start,r=e.position.end,s=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function C(e,t){return e.className===t.className&&me(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Ce=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},xe=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("ol",{className:p("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>C(e,t));xe.displayName="MarkdownOl";var wt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("li",{className:p("py-1",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&me(e.node,t.node));wt.displayName="MarkdownLi";var kt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("ul",{className:p("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>C(e,t));kt.displayName="MarkdownUl";var vt=react.memo(({className:e,node:t,...n})=>jsxRuntime.jsx("hr",{className:p("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>C(e,t));vt.displayName="MarkdownHr";var Ct=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("span",{className:p("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>C(e,t));Ct.displayName="MarkdownStrong";var Pt=react.memo(({children:e,className:t,href:n,node:o,...r})=>{let s=n==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:p("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},(e,t)=>C(e,t)&&e.href===t.href);Pt.displayName="MarkdownA";var Mt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h1",{className:p("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>C(e,t));Mt.displayName="MarkdownH1";var xt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h2",{className:p("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>C(e,t));xt.displayName="MarkdownH2";var Tt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h3",{className:p("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>C(e,t));Tt.displayName="MarkdownH3";var Nt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h4",{className:p("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>C(e,t));Nt.displayName="MarkdownH4";var It=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h5",{className:p("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>C(e,t));It.displayName="MarkdownH5";var St=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h6",{className:p("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>C(e,t));St.displayName="MarkdownH6";var At=react.memo(({children:e,className:t,node:n,...o})=>{let{controls:r}=react.useContext(P),s=Me(r,"table");return jsxRuntime.jsx(ht,{className:t,"data-streamdown":"table-wrapper",showControls:s,...o,children:e})},(e,t)=>C(e,t));At.displayName="MarkdownTable";var Et=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("thead",{className:p("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>C(e,t));Et.displayName="MarkdownThead";var Lt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("tbody",{className:p("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>C(e,t));Lt.displayName="MarkdownTbody";var Bt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("tr",{className:p("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>C(e,t));Bt.displayName="MarkdownTr";var Rt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("th",{className:p("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>C(e,t));Rt.displayName="MarkdownTh";var Dt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("td",{className:p("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>C(e,t));Dt.displayName="MarkdownTd";var jt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("blockquote",{className:p("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>C(e,t));jt.displayName="MarkdownBlockquote";var $t=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("sup",{className:p("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>C(e,t));$t.displayName="MarkdownSup";var Ot=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("sub",{className:p("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>C(e,t));Ot.displayName="MarkdownSub";var Ht=react.memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=l=>{var f,h;if(!react.isValidElement(l))return false;let c=Array.isArray(l.props.children)?l.props.children:[l.props.children],d=false,m=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(d=true);else if(react.isValidElement(u))if(((f=u.props)==null?void 0:f["data-footnote-backref"])!==void 0)m=true;else {let g=Array.isArray(u.props.children)?u.props.children:[u.props.children];for(let w of g){if(typeof w=="string"&&w.trim()!==""){d=true;break}if(react.isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){d=true;break}}}}return m&&!d},a=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===xe){let d=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return d.length===0?null:{...l,props:{...l.props,children:d}}}return l}):e;return (Array.isArray(a)?a.some(l=>l!==null):a!==null)?jsxRuntime.jsx("section",{className:t,...o,children:a}):null}return jsxRuntime.jsx("section",{className:t,...o,children:e})},(e,t)=>C(e,t));Ht.displayName="MarkdownSection";var wo=({node:e,className:t,children:n,...o})=>{var m,f,h;let r=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((f=e==null?void 0:e.position)==null?void 0:f.end.line),{mermaid:s,controls:a}=react.useContext(P);if(r)return jsxRuntime.jsx("code",{className:p("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let i=t==null?void 0:t.match(yo),l=(h=i==null?void 0:i.at(1))!=null?h:"",c="";if(react.isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?c=n.props.children:typeof n=="string"&&(c=n),l==="mermaid"){let u=Me(a,"mermaid"),g=Ce(a,"download"),w=Ce(a,"copy"),k=Ce(a,"fullscreen");return jsxRuntime.jsxs("div",{className:p("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||w||k)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[g&&jsxRuntime.jsx(tt,{chart:c,config:s==null?void 0:s.config}),w&&jsxRuntime.jsx(ye,{code:c}),k&&jsxRuntime.jsx(st,{chart:c,config:s==null?void 0:s.config})]}),jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(ke,{}),children:jsxRuntime.jsx(bo,{chart:c,config:s==null?void 0:s.config})})]})}let d=Me(a,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(ke,{}),children:jsxRuntime.jsx(go,{className:p("overflow-x-auto border-border border-t",t),code:c,"data-language":l,"data-streamdown":"code-block",language:l,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ze,{code:c,language:l}),jsxRuntime.jsx(ye,{})]})})})},zt=react.memo(wo,(e,t)=>e.className===t.className&&me(e.node,t.node));zt.displayName="MarkdownCode";var _t=react.memo(Ye,(e,t)=>e.className===t.className&&me(e.node,t.node));_t.displayName="MarkdownImg";var qt=react.memo(({children:e,className:t,node:n,...o})=>{var a;let s=(Array.isArray(e)?e:[e]).filter(i=>i!=null&&i!=="");return s.length===1&&react.isValidElement(s[0])&&((a=s[0].props.node)==null?void 0:a.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):jsxRuntime.jsx("p",{className:t,...o,children:e})},(e,t)=>C(e,t));qt.displayName="MarkdownParagraph";var Ut={ol:xe,li:wt,ul:kt,hr:vt,strong:Ct,a:Pt,h1:Mt,h2:xt,h3:Tt,h4:Nt,h5:It,h6:St,table:At,thead:Et,tbody:Lt,tr:Bt,th:Rt,td:Dt,blockquote:jt,code:zt,img:_t,pre:({children:e})=>e,sup:$t,sub:Ot,p:qt,section:Ht};function Te(e){if(e)throw e}var pe=Sn(Qt());function G(e){if(typeof e!="object"||e===null)return false;let t=Object.getPrototypeOf(e);return (t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ne(){let e=[],t={run:n,use:o};return t;function n(...r){let s=-1,a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);i(null,...r);function i(l,...c){let d=e[++s],m=-1;if(l){a(l);return}for(;++m<r.length;)(c[m]===null||c[m]===void 0)&&(c[m]=r[m]);r=c,d?en(d,i)(...c):a(null,...c);}}function o(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function en(e,t){let n;return o;function o(...a){let i=e.length>a.length,l;i&&a.push(r);try{l=e.apply(this,a);}catch(c){let d=c;if(i&&n)throw d;return r(d)}i||(l&&l.then&&typeof l.then=="function"?l.then(s,r):l instanceof Error?r(l):s(l));}function r(a,...i){n||(n=true,t(a,...i));}function s(a){r(null,a);}}function Se(e){return !e||typeof e!="object"?"":"position"in e||"type"in e?tn(e.position):"start"in e||"end"in e?tn(e):"line"in e||"column"in e?Ie(e):""}function Ie(e){return nn(e&&e.line)+":"+nn(e&&e.column)}function tn(e){return Ie(e&&e.start)+"-"+Ie(e&&e.end)}function nn(e){return e&&typeof e=="number"?e:1}var M=class extends Error{constructor(t,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let r="",s={},a=false;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(a=true,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof o=="string"){let l=o.indexOf(":");l===-1?s.ruleId=o:(s.source=o.slice(0,l),s.ruleId=o.slice(l+1));}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position);}let i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=Se(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0;}};M.prototype.file="";M.prototype.name="";M.prototype.reason="";M.prototype.message="";M.prototype.stack="";M.prototype.column=void 0;M.prototype.line=void 0;M.prototype.ancestors=void 0;M.prototype.cause=void 0;M.prototype.fatal=void 0;M.prototype.place=void 0;M.prototype.ruleId=void 0;M.prototype.source=void 0;var A={basename:ko,dirname:vo,extname:Co,join:Po,sep:"/"};function ko(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Z(e);let n=0,o=-1,r=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else o<0&&(s=true,o=r+1);return o<0?"":e.slice(n,o)}if(t===e)return "";let a=-1,i=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else a<0&&(s=true,a=r+1),i>-1&&(e.codePointAt(r)===t.codePointAt(i--)?i<0&&(o=r):(i=-1,o=a));return n===o?o=a:o<0&&(o=e.length),e.slice(n,o)}function vo(e){if(Z(e),e.length===0)return ".";let t=-1,n=e.length,o;for(;--n;)if(e.codePointAt(n)===47){if(o){t=n;break}}else o||(o=true);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Co(e){Z(e);let t=e.length,n=-1,o=0,r=-1,s=0,a;for(;t--;){let i=e.codePointAt(t);if(i===47){if(a){o=t+1;break}continue}n<0&&(a=true,n=t+1),i===46?r<0?r=t:s!==1&&(s=1):r>-1&&(s=-1);}return r<0||n<0||s===0||s===1&&r===n-1&&r===o+1?"":e.slice(r,n)}function Po(...e){let t=-1,n;for(;++t<e.length;)Z(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Mo(n)}function Mo(e){Z(e);let t=e.codePointAt(0)===47,n=xo(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function xo(e,t){let n="",o=0,r=-1,s=0,a=-1,i,l;for(;++a<=e.length;){if(a<e.length)i=e.codePointAt(a);else {if(i===47)break;i=47;}if(i===47){if(!(r===a-1||s===1))if(r!==a-1&&s===2){if(n.length<2||o!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",o=0):(n=n.slice(0,l),o=n.length-1-n.lastIndexOf("/")),r=a,s=0;continue}}else if(n.length>0){n="",o=0,r=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",o=2);}else n.length>0?n+="/"+e.slice(r+1,a):n=e.slice(r+1,a),o=a-r-1;r=a,s=0;}else i===46&&s>-1?s++:s=-1;}return n}function Z(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var on={cwd:To};function To(){return "/"}function X(e){return !!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function rn(e){if(typeof e=="string")e=new URL(e);else if(!X(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return No(e)}function No(e){if(e.hostname!==""){let o=new TypeError('File URL host must be "localhost" or empty on darwin');throw o.code="ERR_INVALID_FILE_URL_HOST",o}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let o=t.codePointAt(n+2);if(o===70||o===102){let r=new TypeError("File URL path must not include encoded / characters");throw r.code="ERR_INVALID_FILE_URL_PATH",r}}return decodeURIComponent(t)}var Ae=["history","path","basename","stem","extname","dirname"],Y=class{constructor(t){let n;t?X(t)?n={path:t}:typeof t=="string"||Io(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":on.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o=-1;for(;++o<Ae.length;){let s=Ae[o];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s]);}let r;for(r in n)Ae.includes(r)||(this[r]=n[r]);}get basename(){return typeof this.path=="string"?A.basename(this.path):void 0}set basename(t){Le(t,"basename"),Ee(t,"basename"),this.path=A.join(this.dirname||"",t);}get dirname(){return typeof this.path=="string"?A.dirname(this.path):void 0}set dirname(t){sn(this.basename,"dirname"),this.path=A.join(t||"",this.basename);}get extname(){return typeof this.path=="string"?A.extname(this.path):void 0}set extname(t){if(Ee(t,"extname"),sn(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=A.join(this.dirname,this.stem+(t||""));}get path(){return this.history[this.history.length-1]}set path(t){X(t)&&(t=rn(t)),Le(t,"path"),this.path!==t&&this.history.push(t);}get stem(){return typeof this.path=="string"?A.basename(this.path,this.extname):void 0}set stem(t){Le(t,"stem"),Ee(t,"stem"),this.path=A.join(this.dirname||"",t+(this.extname||""));}fail(t,n,o){let r=this.message(t,n,o);throw r.fatal=true,r}info(t,n,o){let r=this.message(t,n,o);return r.fatal=void 0,r}message(t,n,o){let r=new M(t,n,o);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=false,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Ee(e,t){if(e&&e.includes(A.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+A.sep+"`")}function Le(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function sn(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Io(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var an=(function(e){let o=this.constructor.prototype,r=o[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,o),s});var So={}.hasOwnProperty,je=class e extends an{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ne();}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let o=this.attachers[n];t.use(...o);}return t.data((0, pe.default)(true,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(De("data",this.frozen),this.namespace[t]=n,this):So.call(this.namespace,t)&&this.namespace[t]||void 0:t?(De("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...o]=this.attachers[this.freezeIndex];if(o[0]===false)continue;o[0]===true&&(o[0]=void 0);let r=n.call(t,...o);typeof r=="function"&&this.transformers.use(r);}return this.frozen=true,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=ue(t),o=this.parser||this.Parser;return Be("parse",o),o(String(n),n)}process(t,n){let o=this;return this.freeze(),Be("process",this.parser||this.Parser),Re("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(s,a){let i=ue(t),l=o.parse(i);o.run(l,i,function(d,m,f){if(d||!m||!f)return c(d);let h=m,u=o.stringify(h,f);Eo(u)?f.value=u:f.result=u,c(d,f);});function c(d,m){d||!m?a(d):s?s(m):n(void 0,m);}}}processSync(t){let n=false,o;return this.freeze(),Be("processSync",this.parser||this.Parser),Re("processSync",this.compiler||this.Compiler),this.process(t,r),cn("processSync","process",n),o;function r(s,a){n=true,Te(s),o=a;}}run(t,n,o){ln(t),this.freeze();let r=this.transformers;return !o&&typeof n=="function"&&(o=n,n=void 0),o?s(void 0,o):new Promise(s);function s(a,i){let l=ue(n);r.run(t,l,c);function c(d,m,f){let h=m||t;d?i(d):a?a(h):o(void 0,h,f);}}}runSync(t,n){let o=false,r;return this.run(t,n,s),cn("runSync","run",o),r;function s(a,i){Te(a),r=i,o=true;}}stringify(t,n){this.freeze();let o=ue(n),r=this.compiler||this.Compiler;return Re("stringify",r),ln(t),r(t,o)}use(t,...n){let o=this.attachers,r=this.namespace;if(De("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?i(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[d,...m]=c;l(d,m);}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(c.plugins),c.settings&&(r.settings=(0, pe.default)(true,r.settings,c.settings));}function i(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){let m=c[d];s(m);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let m=-1,f=-1;for(;++m<o.length;)if(o[m][0]===c){f=m;break}if(f===-1)o.push([c,...d]);else if(d.length>0){let[h,...u]=d,g=o[f][1];G(g)&&G(h)&&(h=(0, pe.default)(true,g,h)),o[f]=[c,h,...u];}}}},$e=new je().freeze();function Be(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Re(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function De(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ln(e){if(!G(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function cn(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ue(e){return Ao(e)?e:new Y(e)}function Ao(e){return !!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Eo(e){return typeof e=="string"||Lo(e)}function Lo(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var dn=[],mn={allowDangerousHtml:true},he=new WeakMap,Oe=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let f="";for(let h=0;h<m.length;h+=1){let u=m[h];if(h>0&&(f+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let k=he.get(g);k||(k=g.name,he.set(g,k)),f+=k;}else f+=String(g);f+=":",f+=JSON.stringify(w);}else if(typeof u=="function"){let g=he.get(u);g||(g=u.name,he.set(u,g)),f+=g;}else f+=String(u);}return f},i=a(o),l=a(r),c=s?JSON.stringify(s):"",d=`${l}::${i}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},fn=new Oe,He=e=>{let t=Ho(e),n=e.children||"";return _o(t.runSync(t.parse(n),n),e)},Ho=e=>{let t=fn.get(e);if(t)return t;let n=zo(e);return fn.set(e,n),n},zo=e=>{let t=e.rehypePlugins||dn,n=e.remarkPlugins||dn,o=e.remarkRehypeOptions?{...mn,...e.remarkRehypeOptions}:mn;return $e().use($o__default.default).use(n).use(Oo__default.default,o).use(t)},_o=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Uo=/\[\^[^\]\s]{1,200}\](?!:)/,Fo=/\[\^[^\]\s]{1,200}\]:/,Vo=/<\/(\w+)>/,Wo=/<(\w+)[\s>]/,ze=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
8
8
  `||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},Xo=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
9
9
  `||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},_e=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},qe=e=>{let t=Uo.test(e),n=Fo.test(e);if(t||n)return [e];let o=marked.Lexer.lex(e,{gfm:true}),r=[],s=[];for(let a of o){let i=a.raw,l=r.length;if(s.length>0){if(r[l-1]+=i,a.type==="html"){let d=i.match(Vo);if(d){let m=d[1];s.at(-1)===m&&s.pop();}}continue}if(a.type==="html"&&a.block){let d=i.match(Wo);if(d){let m=d[1];i.includes(`</${m}>`)||s.push(m);}}if(i.trim()==="$$"&&l>0){let d=r[l-1],m=ze(d),f=_e(d);if(m&&f%2===1){r[l-1]=d+i;continue}}if(l>0&&Xo(i)){let d=r[l-1],m=ze(d),f=_e(d),h=_e(i);if(m&&f%2===1&&!ze(i)&&h===1){r[l-1]=d+i;continue}}r.push(i);}return r};var Jo=/(\*\*)([^*]*?)$/,Ko=/(__)([^_]*?)$/,Go=/(\*\*\*)([^*]*?)$/,Zo=/(\*)([^*]*?)$/,Yo=/(_)([^_]*?)$/,Qo=/(`)([^`]*?)$/,er=/(~~)([^~]*?)$/,_=/^[\s_~*`]*$/,un=/^[\s]*[-*+][\s]+$/,tr=/[\p{L}\p{N}_]/u,nr=/^```[^`\n]*```?$/,or=/^\*{4,}$/,D=e=>{if(!e)return false;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?true:tr.test(e)},ge=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
10
10
  `)};var rr=(e,t)=>{let n=1;for(let o=t-1;o>=0;o-=1)if(e[o]==="]")n+=1;else if(e[o]==="["&&(n-=1,n===0))return o;return -1},sr=(e,t)=>{let n=1;for(let o=t+1;o<e.length;o+=1)if(e[o]==="[")n+=1;else if(e[o]==="]"&&(n-=1,n===0))return o;return -1},Ue=(e,t)=>{let n=false,o=false;for(let r=0;r<t;r+=1){if(e.substring(r,r+3)==="```"){o=!o,r+=2;continue}!o&&e[r]==="`"&&(n=!n);}return n||o},ir=e=>{let t=e.lastIndexOf("](");if(t!==-1&&!Ue(e,t)&&!e.substring(t+2).includes(")")){let o=rr(e,t);if(o!==-1&&!Ue(e,o)){let r=o>0&&e[o-1]==="!",s=r?o-1:o,a=e.substring(0,s),i=e.substring(o+1,t);return r?a:`${a}[${i}](streamdown:incomplete-link)`}}for(let n=e.length-1;n>=0;n-=1)if(e[n]==="["&&!Ue(e,n)){let o=n>0&&e[n-1]==="!",r=o?n-1:n;if(!e.substring(n+1).includes("]")){let i=e.substring(0,r);return o?i:`${e}](streamdown:incomplete-link)`}if(sr(e,n)===-1){let i=e.substring(0,r);return o?i:`${e}](streamdown:incomplete-link)`}}return e},ar=e=>{if(ge(e))return e;let t=e.match(Jo);if(t){let n=t[2];if(!n||_.test(n))return e;let o=e.lastIndexOf(t[1]),s=e.substring(0,o).lastIndexOf(`
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkREBQGU66_cjs=require('./chunk-REBQGU66.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),shiki=require('shiki'),javascript=require('shiki/engine/javascript');var H=chunkREBQGU66_cjs.a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),b=react.memo(({children:o,result:e,language:t,className:r,...n})=>{let l=react.useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsxRuntime.jsx("pre",{className:chunkREBQGU66_cjs.a(r,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-code-block":true,"data-language":t,style:l,...n,children:jsxRuntime.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,i)=>jsxRuntime.jsx("span",{className:H,children:a.map((s,g)=>jsxRuntime.jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:s.color,backgroundColor:s.bgColor,...s.htmlStyle},...s.htmlAttrs,children:s.content},g))},i))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var y=({className:o,language:e,style:t,...r})=>jsxRuntime.jsx("div",{className:chunkREBQGU66_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-code-block-container":true,"data-language":e,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...t},...r});var x=({language:o,children:e})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":true,"data-language":o,children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:e})]});var M=javascript.createJavaScriptRegexEngine({forgiving:true}),p=new Map,h=new Map,d=new Map,$=(o,e)=>`${o}-${e[0]}-${e[1]}`,E=(o,e,t)=>{let r=o.slice(0,100),n=o.length>100?o.slice(-100):"";return `${e}:${t[0]}:${t[1]}:${o.length}:${r}:${n}`},A=(o,e)=>{let t=$(o,e);if(p.has(t))return p.get(t);let r=shiki.createHighlighter({themes:e,langs:[o],engine:M});return p.set(t,r),r},k=(o,e,t,r)=>{let n=E(o,e,t);return h.has(n)?h.get(n):(r&&(d.has(n)||d.set(n,new Set),d.get(n).add(r)),A(e,t).then(l=>{let a=l.codeToTokens(o,{lang:e,themes:{light:t[0],dark:t[1]}});h.set(n,a);let i=d.get(n);if(i){for(let s of i)s(a);d.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),d.delete(n);}),null)};var le=({code:o,language:e,className:t,children:r,preClassName:n,...l})=>{let{shikiTheme:a}=react.useContext(chunkREBQGU66_cjs.h),i=react.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
2
+ `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[s,g]=react.useState(i);return react.useEffect(()=>{let u=k(o,e,a);if(u){g(u);return}k(o,e,a,R=>{g(R);});},[o,e,a]),jsxRuntime.jsx(chunkREBQGU66_cjs.b.Provider,{value:{code:o},children:jsxRuntime.jsxs(y,{language:e,children:[jsxRuntime.jsx(x,{language:e,children:r}),jsxRuntime.jsx(b,{className:t,language:e,result:s,...l})]})})};exports.CodeBlock=le;
@@ -0,0 +1,2 @@
1
+ import {a,h as h$1,b as b$1}from'./chunk-I3LWQRNF.js';import {memo,useMemo,useContext,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';import {createHighlighter}from'shiki';import {createJavaScriptRegexEngine}from'shiki/engine/javascript';var H=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),b=memo(({children:o,result:e,language:t,className:r,...n})=>{let l=useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsx("pre",{className:a(r,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-code-block":true,"data-language":t,style:l,...n,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,i)=>jsx("span",{className:H,children:a.map((s,g)=>jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:s.color,backgroundColor:s.bgColor,...s.htmlStyle},...s.htmlAttrs,children:s.content},g))},i))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var y=({className:o,language:e,style:t,...r})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-code-block-container":true,"data-language":e,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...t},...r});var x=({language:o,children:e})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":true,"data-language":o,children:[jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsx("div",{className:"flex items-center gap-2",children:e})]});var M=createJavaScriptRegexEngine({forgiving:true}),p=new Map,h=new Map,d=new Map,$=(o,e)=>`${o}-${e[0]}-${e[1]}`,E=(o,e,t)=>{let r=o.slice(0,100),n=o.length>100?o.slice(-100):"";return `${e}:${t[0]}:${t[1]}:${o.length}:${r}:${n}`},A=(o,e)=>{let t=$(o,e);if(p.has(t))return p.get(t);let r=createHighlighter({themes:e,langs:[o],engine:M});return p.set(t,r),r},k=(o,e,t,r)=>{let n=E(o,e,t);return h.has(n)?h.get(n):(r&&(d.has(n)||d.set(n,new Set),d.get(n).add(r)),A(e,t).then(l=>{let a=l.codeToTokens(o,{lang:e,themes:{light:t[0],dark:t[1]}});h.set(n,a);let i=d.get(n);if(i){for(let s of i)s(a);d.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),d.delete(n);}),null)};var le=({code:o,language:e,className:t,children:r,preClassName:n,...l})=>{let{shikiTheme:a}=useContext(h$1),i=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
2
+ `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[s,g]=useState(i);return useEffect(()=>{let u=k(o,e,a);if(u){g(u);return}k(o,e,a,R=>{g(R);});},[o,e,a]),jsx(b$1.Provider,{value:{code:o},children:jsxs(y,{language:e,children:[jsx(x,{language:e,children:r}),jsx(b,{className:t,language:e,result:s,...l})]})})};export{le as CodeBlock};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkINS6426L_cjs=require('./chunk-INS6426L.cjs');Object.defineProperty(exports,"Block",{enumerable:true,get:function(){return chunkINS6426L_cjs.i}});Object.defineProperty(exports,"Streamdown",{enumerable:true,get:function(){return chunkINS6426L_cjs.j}});Object.defineProperty(exports,"StreamdownContext",{enumerable:true,get:function(){return chunkINS6426L_cjs.h}});Object.defineProperty(exports,"defaultRehypePlugins",{enumerable:true,get:function(){return chunkINS6426L_cjs.f}});Object.defineProperty(exports,"defaultRemarkPlugins",{enumerable:true,get:function(){return chunkINS6426L_cjs.g}});Object.defineProperty(exports,"parseIncompleteMarkdown",{enumerable:true,get:function(){return chunkINS6426L_cjs.e}});Object.defineProperty(exports,"parseMarkdownIntoBlocks",{enumerable:true,get:function(){return chunkINS6426L_cjs.d}});
1
+ 'use strict';var chunkREBQGU66_cjs=require('./chunk-REBQGU66.cjs');Object.defineProperty(exports,"Block",{enumerable:true,get:function(){return chunkREBQGU66_cjs.i}});Object.defineProperty(exports,"Streamdown",{enumerable:true,get:function(){return chunkREBQGU66_cjs.j}});Object.defineProperty(exports,"StreamdownContext",{enumerable:true,get:function(){return chunkREBQGU66_cjs.h}});Object.defineProperty(exports,"defaultRehypePlugins",{enumerable:true,get:function(){return chunkREBQGU66_cjs.f}});Object.defineProperty(exports,"defaultRemarkPlugins",{enumerable:true,get:function(){return chunkREBQGU66_cjs.g}});Object.defineProperty(exports,"parseIncompleteMarkdown",{enumerable:true,get:function(){return chunkREBQGU66_cjs.e}});Object.defineProperty(exports,"parseMarkdownIntoBlocks",{enumerable:true,get:function(){return chunkREBQGU66_cjs.d}});
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{i as Block,j as Streamdown,h as StreamdownContext,f as defaultRehypePlugins,g as defaultRemarkPlugins,e as parseIncompleteMarkdown,d as parseMarkdownIntoBlocks}from'./chunk-L5764EZV.js';
1
+ export{i as Block,j as Streamdown,h as StreamdownContext,f as defaultRehypePlugins,g as defaultRemarkPlugins,e as parseIncompleteMarkdown,d as parseMarkdownIntoBlocks}from'./chunk-I3LWQRNF.js';
@@ -0,0 +1 @@
1
+ export{c as Mermaid}from'./chunk-I3LWQRNF.js';
@@ -0,0 +1 @@
1
+ 'use strict';var chunkREBQGU66_cjs=require('./chunk-REBQGU66.cjs');Object.defineProperty(exports,"Mermaid",{enumerable:true,get:function(){return chunkREBQGU66_cjs.c}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamdown",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,2 +0,0 @@
1
- import {a,h as h$1,b as b$1}from'./chunk-L5764EZV.js';import {memo,useMemo,useContext,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';import {createHighlighter}from'shiki';import {createJavaScriptRegexEngine}from'shiki/engine/javascript';var H=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),y=memo(({children:o,result:e,language:t,className:r,...n})=>{let l=useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsx("pre",{className:a(r,"p-4 text-sm"),"data-code-block":true,"data-language":t,style:l,...n,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,i)=>jsx("span",{className:H,children:a.map((s,u)=>jsx("span",{style:{color:s.color,backgroundColor:s.bgColor,...s.htmlStyle},...s.htmlAttrs,children:s.content},u))},i))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var b=({className:o,language:e,style:t,...r})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-code-block-container":true,"data-language":e,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...t},...r});var x=({language:o,children:e})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":true,"data-language":o,children:[jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsx("div",{className:"flex items-center gap-2",children:e})]});var M=createJavaScriptRegexEngine({forgiving:true}),p=new Map,h=new Map,d=new Map,$=(o,e)=>`${o}-${e[0]}-${e[1]}`,E=(o,e,t)=>{let r=o.slice(0,100),n=o.length>100?o.slice(-100):"";return `${e}:${t[0]}:${t[1]}:${o.length}:${r}:${n}`},A=(o,e)=>{let t=$(o,e);if(p.has(t))return p.get(t);let r=createHighlighter({themes:e,langs:[o],engine:M});return p.set(t,r),r},f=(o,e,t,r)=>{let n=E(o,e,t);return h.has(n)?h.get(n):(r&&(d.has(n)||d.set(n,new Set),d.get(n).add(r)),A(e,t).then(l=>{let a=l.codeToTokens(o,{lang:e,themes:{light:t[0],dark:t[1]}});h.set(n,a);let i=d.get(n);if(i){for(let s of i)s(a);d.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),d.delete(n);}),null)};var le=({code:o,language:e,className:t,children:r,preClassName:n,...l})=>{let{shikiTheme:a}=useContext(h$1),i=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
2
- `).map(g=>[{content:g,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[s,u]=useState(i);return useEffect(()=>{let g=f(o,e,a);if(g){u(g);return}f(o,e,a,R=>{u(R);});},[o,e,a]),jsx(b$1.Provider,{value:{code:o},children:jsxs(b,{language:e,children:[jsx(x,{language:e,children:r}),jsx(y,{className:t,language:e,result:s,...l})]})})};export{le as CodeBlock};
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkINS6426L_cjs=require('./chunk-INS6426L.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),shiki=require('shiki'),javascript=require('shiki/engine/javascript');var H=chunkINS6426L_cjs.a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),y=react.memo(({children:o,result:e,language:t,className:r,...n})=>{let l=react.useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsxRuntime.jsx("pre",{className:chunkINS6426L_cjs.a(r,"p-4 text-sm"),"data-code-block":true,"data-language":t,style:l,...n,children:jsxRuntime.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,i)=>jsxRuntime.jsx("span",{className:H,children:a.map((s,u)=>jsxRuntime.jsx("span",{style:{color:s.color,backgroundColor:s.bgColor,...s.htmlStyle},...s.htmlAttrs,children:s.content},u))},i))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var b=({className:o,language:e,style:t,...r})=>jsxRuntime.jsx("div",{className:chunkINS6426L_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-code-block-container":true,"data-language":e,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...t},...r});var x=({language:o,children:e})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":true,"data-language":o,children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:e})]});var M=javascript.createJavaScriptRegexEngine({forgiving:true}),p=new Map,h=new Map,d=new Map,$=(o,e)=>`${o}-${e[0]}-${e[1]}`,E=(o,e,t)=>{let r=o.slice(0,100),n=o.length>100?o.slice(-100):"";return `${e}:${t[0]}:${t[1]}:${o.length}:${r}:${n}`},A=(o,e)=>{let t=$(o,e);if(p.has(t))return p.get(t);let r=shiki.createHighlighter({themes:e,langs:[o],engine:M});return p.set(t,r),r},f=(o,e,t,r)=>{let n=E(o,e,t);return h.has(n)?h.get(n):(r&&(d.has(n)||d.set(n,new Set),d.get(n).add(r)),A(e,t).then(l=>{let a=l.codeToTokens(o,{lang:e,themes:{light:t[0],dark:t[1]}});h.set(n,a);let i=d.get(n);if(i){for(let s of i)s(a);d.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),d.delete(n);}),null)};var le=({code:o,language:e,className:t,children:r,preClassName:n,...l})=>{let{shikiTheme:a}=react.useContext(chunkINS6426L_cjs.h),i=react.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
2
- `).map(g=>[{content:g,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[s,u]=react.useState(i);return react.useEffect(()=>{let g=f(o,e,a);if(g){u(g);return}f(o,e,a,R=>{u(R);});},[o,e,a]),jsxRuntime.jsx(chunkINS6426L_cjs.b.Provider,{value:{code:o},children:jsxRuntime.jsxs(b,{language:e,children:[jsxRuntime.jsx(x,{language:e,children:r}),jsxRuntime.jsx(y,{className:t,language:e,result:s,...l})]})})};exports.CodeBlock=le;
@@ -1 +0,0 @@
1
- export{c as Mermaid}from'./chunk-L5764EZV.js';
@@ -1 +0,0 @@
1
- 'use strict';var chunkINS6426L_cjs=require('./chunk-INS6426L.cjs');Object.defineProperty(exports,"Mermaid",{enumerable:true,get:function(){return chunkINS6426L_cjs.c}});