streamdown 1.6.7 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VF3PSAD2.js → chunk-EK3FW32D.js} +2 -2
- package/dist/{chunk-X2CNSGMM.cjs → chunk-SF773HSE.cjs} +2 -2
- package/dist/code-block-M5RMG6MJ.cjs +2 -0
- package/dist/code-block-RYKACFZZ.js +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/mermaid-CZAVW2Z4.cjs +1 -0
- package/dist/mermaid-I5V5WURR.js +1 -0
- package/package.json +1 -1
- package/dist/code-block-QUPNYJF5.js +0 -2
- package/dist/code-block-Z77EJIB4.cjs +0 -2
- package/dist/mermaid-LEH2MBRN.js +0 -1
- package/dist/mermaid-OUSRGB7Z.cjs +0 -1
|
@@ -4,7 +4,7 @@ import {createContext,lazy,memo,useContext,isValidElement,useMemo,useId,useTrans
|
|
|
4
4
|
`||d==="\r"){l=true;break}}if(!l)return i;let c=[];for(let m=0;m<i.length;m+=1){let d=i[m];d===" "?c.push("\\t"):d===`
|
|
5
5
|
`?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);}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),m=useRef(0),{isAnimating:d}=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 C=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),N=C==null?void 0:C.querySelector("table");if(!N){o==null||o(new Error("Table not found"));return}let x=ie(N),T=u==="csv"?ae(x):it(x),O=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([N.outerHTML],{type:"text/html"})});await navigator.clipboard.write([O]),l(!0),a(!1),n==null||n(u),m.current=window.setTimeout(()=>l(!1),r);}catch(C){o==null||o(C);}};useEffect(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(m.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:d,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",title:"Copy table as CSV",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),type:"button",title:"Copy table as TSV",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 m;try{let d=(m=a.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),f=d==null?void 0:d.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(d){o==null||o(d);}};return useEffect(()=>{let c=m=>{a.current&&!a.current.contains(m.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",title:"Download table as CSV",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",title:"Download table as Markdown",children:"Markdown"})]})]})};var 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-QUPNYJF5.js').then(e=>({default:e.CodeBlock}))),bo=lazy(()=>import('./mermaid-LEH2MBRN.js').then(e=>({default:e.Mermaid}))),yo=/language-([^\s]+)/;function fe(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 v(e,t){return e.className===t.className&&fe(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,me=(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)=>v(e,t));xe.displayName="MarkdownOl";var wt=memo(({children:e,className:t,node:n,...o})=>jsx("li",{className:p("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&fe(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)=>v(e,t));kt.displayName="MarkdownUl";var Ct=memo(({className:e,node:t,...n})=>jsx("hr",{className:p("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>v(e,t));Ct.displayName="MarkdownHr";var vt=memo(({children:e,className:t,node:n,...o})=>jsx("span",{className:p("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>v(e,t));vt.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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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],m=false,d=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(m=true);else if(isValidElement(u))if(((f=u.props)==null?void 0:f["data-footnote-backref"])!==void 0)d=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()!==""){m=true;break}if(isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){m=true;break}}}}return d&&!m},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===xe){let m=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(d=>!s(d));return m.length===0?null:{...l,props:{...l.props,children:m}}}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)=>v(e,t));Ht.displayName="MarkdownSection";var wo=({node:e,className:t,children:n,...o})=>{var d,f,h;let r=((d=e==null?void 0:e.position)==null?void 0:d.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=me(a,"download"),w=me(a,"copy"),C=me(a,"fullscreen"),N=me(a,"panZoom");return jsx(Suspense,{fallback:jsx(Ce,{}),children:jsxs("div",{className:p("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||w||C)&&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(we,{code:c}),C&&jsx(st,{chart:c,config:s==null?void 0:s.config})]}),jsx(bo,{chart:c,config:s==null?void 0:s.config,showControls:N})]})})}let m=Me(a,"code");return jsx(Suspense,{fallback:jsx(Ce,{}),children:jsx(go,{className:p("overflow-x-auto border-border border-t",t),code:c,language:l,children:m&&jsxs(Fragment,{children:[jsx(Ge,{code:c,language:l}),jsx(we,{})]})})})},zt=memo(wo,(e,t)=>e.className===t.className&&fe(e.node,t.node));zt.displayName="MarkdownCode";var _t=memo(Ye,(e,t)=>e.className===t.className&&fe(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)=>v(e,t));qt.displayName="MarkdownParagraph";var Ut={ol:xe,li:wt,ul:kt,hr:Ct,strong:vt,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 he=Sn(Qt());function Z(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 m=e[++s],d=-1;if(l){a(l);return}for(;++d<r.length;)(c[d]===null||c[d]===void 0)&&(c[d]=r[d]);r=c,m?en(m,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 m=c;if(i&&n)throw m;return r(m)}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:Co,extname:vo,join:Po,sep:"/"};function ko(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');G(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 Co(e){if(G(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 vo(e){G(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;)G(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Mo(n)}function Mo(e){G(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 G(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, he.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=pe(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=pe(t),l=o.parse(i);o.run(l,i,function(m,d,f){if(m||!d||!f)return c(m);let h=d,u=o.stringify(h,f);Eo(u)?f.value=u:f.result=u,c(m,f);});function c(m,d){m||!d?a(m):s?s(d):n(void 0,d);}}}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=pe(n);r.run(t,l,c);function c(m,d,f){let h=d||t;m?i(m):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=pe(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[m,...d]=c;l(m,d);}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, he.default)(true,r.settings,c.settings));}function i(c){let m=-1;if(c!=null)if(Array.isArray(c))for(;++m<c.length;){let d=c[m];s(d);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,m){let d=-1,f=-1;for(;++d<o.length;)if(o[d][0]===c){f=d;break}if(f===-1)o.push([c,...m]);else if(m.length>0){let[h,...u]=m,g=o[f][1];Z(g)&&Z(h)&&(h=(0, he.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(!Z(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 pe(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},ge=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 d="default";return this.keyCache.set(t,d),d}let a=d=>{if(!d||d.length===0)return "";let f="";for(let h=0;h<d.length;h+=1){let u=d[h];if(h>0&&(f+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let C=ge.get(g);C||(C=g.name,ge.set(g,C)),f+=C;}else f+=String(g);f+=":",f+=JSON.stringify(w);}else if(typeof u=="function"){let g=ge.get(u);g||(g=u.name,ge.set(u,g)),f+=g;}else f+=String(u);}return f},i=a(o),l=a(r),c=s?JSON.stringify(s):"",m=`${l}::${i}::${c}`;return this.keyCache.set(t,m),m}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let 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),m=useRef(0),{isAnimating:d}=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 C=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),N=C==null?void 0:C.querySelector("table");if(!N){o==null||o(new Error("Table not found"));return}let x=ie(N),T=u==="csv"?ae(x):it(x),O=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([N.outerHTML],{type:"text/html"})});await navigator.clipboard.write([O]),l(!0),a(!1),n==null||n(u),m.current=window.setTimeout(()=>l(!1),r);}catch(C){o==null||o(C);}};useEffect(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(m.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:d,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",title:"Copy table as CSV",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),type:"button",title:"Copy table as TSV",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 m;try{let d=(m=a.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),f=d==null?void 0:d.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(d){o==null||o(d);}};return useEffect(()=>{let c=m=>{a.current&&!a.current.contains(m.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",title:"Download table as CSV",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",title:"Download table as Markdown",children:"Markdown"})]})]})};var 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-RYKACFZZ.js').then(e=>({default:e.CodeBlock}))),bo=lazy(()=>import('./mermaid-I5V5WURR.js').then(e=>({default:e.Mermaid}))),yo=/language-([^\s]+)/;function fe(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 v(e,t){return e.className===t.className&&fe(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,me=(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)=>v(e,t));xe.displayName="MarkdownOl";var wt=memo(({children:e,className:t,node:n,...o})=>jsx("li",{className:p("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&fe(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)=>v(e,t));kt.displayName="MarkdownUl";var Ct=memo(({className:e,node:t,...n})=>jsx("hr",{className:p("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>v(e,t));Ct.displayName="MarkdownHr";var vt=memo(({children:e,className:t,node:n,...o})=>jsx("span",{className:p("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>v(e,t));vt.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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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],m=false,d=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(m=true);else if(isValidElement(u))if(((f=u.props)==null?void 0:f["data-footnote-backref"])!==void 0)d=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()!==""){m=true;break}if(isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){m=true;break}}}}return d&&!m},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===xe){let m=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(d=>!s(d));return m.length===0?null:{...l,props:{...l.props,children:m}}}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)=>v(e,t));Ht.displayName="MarkdownSection";var wo=({node:e,className:t,children:n,...o})=>{var d,f,h;let r=((d=e==null?void 0:e.position)==null?void 0:d.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=me(a,"download"),w=me(a,"copy"),C=me(a,"fullscreen"),N=me(a,"panZoom");return jsx(Suspense,{fallback:jsx(Ce,{}),children:jsxs("div",{className:p("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||w||C)&&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(we,{code:c}),C&&jsx(st,{chart:c,config:s==null?void 0:s.config})]}),jsx(bo,{chart:c,config:s==null?void 0:s.config,showControls:N})]})})}let m=Me(a,"code");return jsx(Suspense,{fallback:jsx(Ce,{}),children:jsx(go,{className:p("overflow-x-auto border-border border-t",t),code:c,language:l,children:m&&jsxs(Fragment,{children:[jsx(Ge,{code:c,language:l}),jsx(we,{})]})})})},zt=memo(wo,(e,t)=>e.className===t.className&&fe(e.node,t.node));zt.displayName="MarkdownCode";var _t=memo(Ye,(e,t)=>e.className===t.className&&fe(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)=>v(e,t));qt.displayName="MarkdownParagraph";var Ut={ol:xe,li:wt,ul:kt,hr:Ct,strong:vt,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 he=Sn(Qt());function Z(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 m=e[++s],d=-1;if(l){a(l);return}for(;++d<r.length;)(c[d]===null||c[d]===void 0)&&(c[d]=r[d]);r=c,m?en(m,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 m=c;if(i&&n)throw m;return r(m)}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:Co,extname:vo,join:Po,sep:"/"};function ko(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');G(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 Co(e){if(G(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 vo(e){G(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;)G(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Mo(n)}function Mo(e){G(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 G(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, he.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=pe(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=pe(t),l=o.parse(i);o.run(l,i,function(m,d,f){if(m||!d||!f)return c(m);let h=d,u=o.stringify(h,f);Eo(u)?f.value=u:f.result=u,c(m,f);});function c(m,d){m||!d?a(m):s?s(d):n(void 0,d);}}}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=pe(n);r.run(t,l,c);function c(m,d,f){let h=d||t;m?i(m):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=pe(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[m,...d]=c;l(m,d);}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, he.default)(true,r.settings,c.settings));}function i(c){let m=-1;if(c!=null)if(Array.isArray(c))for(;++m<c.length;){let d=c[m];s(d);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,m){let d=-1,f=-1;for(;++d<o.length;)if(o[d][0]===c){f=d;break}if(f===-1)o.push([c,...m]);else if(m.length>0){let[h,...u]=m,g=o[f][1];Z(g)&&Z(h)&&(h=(0, he.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(!Z(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 pe(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},ge=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 d="default";return this.keyCache.set(t,d),d}let a=d=>{if(!d||d.length===0)return "";let f="";for(let h=0;h<d.length;h+=1){let u=d[h];if(h>0&&(f+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let C=ge.get(g);C||(C=g.name,ge.set(g,C)),f+=C;}else f+=String(g);f+=":",f+=JSON.stringify(w);}else if(typeof u=="function"){let g=ge.get(u);g||(g=u.name,ge.set(u,g)),f+=g;}else f+=String(u);}return f},i=a(o),l=a(r),c=s?JSON.stringify(s):"",m=`${l}::${i}::${c}`;return this.keyCache.set(t,m),m}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let 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 m=i.match(Vo);if(m){let d=m[1];s.at(-1)===d&&s.pop();}}continue}if(a.type==="html"&&a.block){let m=i.match(Wo);if(m){let d=m[1];i.includes(`</${d}>`)||s.push(d);}}if(i.trim()==="$$"&&l>0){let m=r[l-1],d=ze(m),f=_e(m);if(d&&f%2===1){r[l-1]=m+i;continue}}if(l>0&&Xo(i)){let m=r[l-1],d=ze(m),f=_e(m),h=_e(i);if(d&&f%2===1&&!ze(i)&&h===1){r[l-1]=m+i;continue}}r.push(i);}return r};var Jo=/(\*\*)([^*]*?)$/,Ko=/(__)([^_]*?)$/,Zo=/(\*\*\*)([^*]*?)$/,Go=/(\*)([^*]*?)$/,Yo=/(_)([^_]*?)$/,Qo=/(`)([^`]*?)$/,er=/(~~)([^~]*?)$/,q=/^[\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)},be=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(be(e))return e;let t=e.match(Jo);if(t){let n=t[2];if(!n||q.test(n))return e;let o=e.lastIndexOf(t[1]),s=e.substring(0,o).lastIndexOf(`
|
|
@@ -18,4 +18,4 @@ import {createContext,lazy,memo,useContext,isValidElement,useMemo,useId,useTrans
|
|
|
18
18
|
`)||(e.endsWith("```\n")||e.endsWith("```"))&&n%2===0)return e;let r=e.match(Qo);if(r&&!o){let s=r[2];if(!s||q.test(s))return e;if(pr(e)%2===1)return `${e}\``}return e},gr=e=>{let t=e.match(er);if(t){let n=t[2];if(!n||q.test(n))return e;if((e.match(/~~/g)||[]).length%2===1)return `${e}~~`}return e},br=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let n=e.indexOf("$$");return n!==-1&&e.indexOf(`
|
|
19
19
|
`,n)!==-1&&!e.endsWith(`
|
|
20
20
|
`)?`${e}
|
|
21
|
-
$$`:`${e}$$`},yr=e=>{let t=0,n=0;for(let o=0;o<e.length;o+=1)e[o]==="*"?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0);return n>=3&&(t+=Math.floor(n/3)),t},wr=e=>{if(be(e)||or.test(e))return e;let t=e.match(Zo);if(t){let n=t[2];if(!n||q.test(n))return e;if(yr(e)%2===1)return `${e}***`}return e},Fe=e=>{if(!e||typeof e!="string")return e;let t=e,n=ir(t);return n.endsWith("](streamdown:incomplete-link)")?n:(t=n,t=wr(t),t=ar(t),t=lr(t),t=dr(t),t=fr(t),t=hr(t),t=gr(t),t=br(t),t)};var Sr={harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],defaultOrigin:void 0,allowDataImages:true}]
|
|
21
|
+
$$`:`${e}$$`},yr=e=>{let t=0,n=0;for(let o=0;o<e.length;o+=1)e[o]==="*"?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0);return n>=3&&(t+=Math.floor(n/3)),t},wr=e=>{if(be(e)||or.test(e))return e;let t=e.match(Zo);if(t){let n=t[2];if(!n||q.test(n))return e;if(yr(e)%2===1)return `${e}***`}return e},Fe=e=>{if(!e||typeof e!="string")return e;let t=e,n=ir(t);return n.endsWith("](streamdown:incomplete-link)")?n:(t=n,t=wr(t),t=ar(t),t=lr(t),t=dr(t),t=fr(t),t=hr(t),t=gr(t),t=br(t),t)};var Sr={raw:xr,katex:[Ve,{errorColor:"var(--color-muted-foreground)"}],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],defaultOrigin:void 0,allowDataImages:true}]},Ar={gfm:[Ir,{}],math:[We,{singleDollarTextMath:false}],cjkFriendly:[Tr,{}],cjkFriendlyGfmStrikethrough:[Nr,{}]},Er=Object.values(Sr),Lr=Object.values(Ar),Br={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0},P=createContext(Br),bn=memo(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let o=useMemo(()=>typeof e=="string"&&t?Fe(e.trim()):e,[e,t]);return jsx(He,{...n,children:o})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});bn.displayName="Block";var Rr=["github-light","github-dark"],Dr=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:n=true,components:o,rehypePlugins:r=Er,remarkPlugins:s=Lr,className:a,shikiTheme:i=Rr,mermaid:l,controls:c=true,isAnimating:m=false,BlockComponent:d=bn,parseMarkdownIntoBlocksFn:f=qe,...h})=>{let u=useId(),[g,w]=useTransition(),[C,N]=useState([]),x=useMemo(()=>f(typeof e=="string"?e:""),[e,f]);useEffect(()=>{t==="streaming"?w(()=>{N(x);}):N(x);},[x,t]);let T=t==="streaming"?C:x,O=useMemo(()=>T.map((L,B)=>`${u}-${B}`),[T.length,u]),H=useMemo(()=>({shikiTheme:i,controls:c,isAnimating:m,mode:t,mermaid:l}),[i,c,m,t,l]),z=useMemo(()=>({...Ut,...o}),[o]);return useEffect(()=>{if(!(Array.isArray(r)&&r.some(S=>Array.isArray(S)?S[0]===Ve:S===Ve)))return;let B=false;if(Array.isArray(s)){let S=s.find(ne=>Array.isArray(ne)?ne[0]===We:ne===We);S&&Array.isArray(S)&&S[1]&&(B=S[1].singleDollarTextMath===true);}let R=typeof e=="string"?e:"",_=R.includes("$$"),y=B&&(/[^$]\$[^$]/.test(R)||/^\$[^$]/.test(R)||/[^$]\$$/.test(R));(_||y)&&import('katex/dist/katex.min.css');},[r,s,e]),t==="static"?jsx(P.Provider,{value:H,children:jsx("div",{className:p("space-y-4 whitespace-normal",a),children:jsx(He,{components:z,rehypePlugins:r,remarkPlugins:s,...h,children:e})})}):jsx(P.Provider,{value:H,children:jsx("div",{className:p("space-y-4 whitespace-normal",a),children:T.map((L,B)=>jsx(d,{components:z,content:L,index:B,rehypePlugins:r,remarkPlugins:s,shouldParseIncompleteMarkdown:n,...h},O[B]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Dr.displayName="Streamdown";var Cn=({children:e,className:t,minZoom:n=.5,maxZoom:o=3,zoomStep:r=.1,showControls:s=true,initialZoom:a=1,fullscreen:i=false})=>{let l=useRef(null),c=useRef(null),[m,d]=useState(a),[f,h]=useState({x:0,y:0}),[u,g]=useState(false),[w,C]=useState({x:0,y:0}),[N,x]=useState({x:0,y:0}),T=useCallback(y=>{d(I=>Math.max(n,Math.min(o,I+y)));},[n,o]),O=useCallback(()=>{T(r);},[T,r]),H=useCallback(()=>{T(-r);},[T,r]),z=useCallback(()=>{d(a),h({x:0,y:0});},[a]),L=useCallback(y=>{y.preventDefault();let I=y.deltaY>0?-r:r;T(I);},[T,r]),B=useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;g(true),C({x:y.clientX,y:y.clientY}),x(f);let I=y.currentTarget;I instanceof HTMLElement&&I.setPointerCapture(y.pointerId);},[f]),R=useCallback(y=>{if(!u)return;y.preventDefault();let I=y.clientX-w.x,S=y.clientY-w.y;h({x:N.x+I,y:N.y+S});},[u,w,N]),_=useCallback(y=>{g(false);let I=y.currentTarget;I instanceof HTMLElement&&I.releasePointerCapture(y.pointerId);},[]);return useEffect(()=>{let y=l.current;if(y)return y.addEventListener("wheel",L,{passive:false}),()=>{y.removeEventListener("wheel",L);}},[L]),useEffect(()=>{let y=c.current;if(y&&u)return document.body.style.userSelect="none",y.addEventListener("pointermove",R,{passive:false}),y.addEventListener("pointerup",_),y.addEventListener("pointercancel",_),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",R),y.removeEventListener("pointerup",_),y.removeEventListener("pointercancel",_);}},[u,R,_]),jsxs("div",{className:p("relative",i?"h-full w-full":"w-full",t),ref:l,style:{cursor:u?"grabbing":"grab"},children:[s&&jsxs("div",{className:p("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",i?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:m>=o,onClick:O,title:"Zoom in",type:"button",children:jsx(ZoomInIcon,{size:16})}),jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:m<=n,onClick:H,title:"Zoom out",type:"button",children:jsx(ZoomOutIcon,{size:16})}),jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:z,title:"Reset zoom and pan",type:"button",children:jsx(RotateCcwIcon,{size:16})})]}),jsx("div",{className:p("origin-center transition-transform duration-150 ease-out",i&&"flex h-full w-full items-center justify-center"),onPointerDown:B,ref:c,role:"application",style:{transform:`translate(${f.x}px, ${f.y}px) scale(${m})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var rt=({chart:e,className:t,config:n,fullscreen:o=false,showControls:r=true})=>{let[s,a]=useState(null),[i,l]=useState(true),[c,m]=useState(""),[d,f]=useState(""),[h,u]=useState(0),{mermaid:g}=useContext(P),w=g==null?void 0:g.errorComponent;if(useEffect(()=>{(async()=>{try{a(null),l(!0);let x=await se(n),T=e.split("").reduce((z,L)=>(z<<5)-z+L.charCodeAt(0)|0,0),O=`mermaid-${Math.abs(T)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:H}=await x.render(O,e);m(H),f(H);}catch(x){if(!(d||c)){let T=x instanceof Error?x.message:"Failed to render Mermaid chart";a(T);}}finally{l(false);}})();},[e,n,h]),i&&!c&&!d)return jsx("div",{className:p("my-4 flex justify-center p-4",t),children:jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(s&&!c&&!d){let N=()=>u(x=>x+1);return w?jsx(w,{chart:e,error:s,retry:N}):jsxs("div",{className:p("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",s]}),jsxs("details",{className:"mt-2",children:[jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let C=c||d;return jsx(Cn,{className:p(o?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:o,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:p("flex justify-center",o&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:C},role:"img"})})};export{p as a,Rn as b,rt as c,qe as d,Fe as e,Sr as f,Ar as g,P as h,bn as i,Dr as j};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
`||d==="\r"){l=true;break}}if(!l)return i;let c=[];for(let m=0;m<i.length;m+=1){let d=i[m];d===" "?c.push("\\t"):d===`
|
|
5
5
|
`?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);}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),m=react.useRef(0),{isAnimating:d}=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 C=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),N=C==null?void 0:C.querySelector("table");if(!N){o==null||o(new Error("Table not found"));return}let x=ie(N),T=u==="csv"?ae(x):it(x),O=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([N.outerHTML],{type:"text/html"})});await navigator.clipboard.write([O]),l(!0),a(!1),n==null||n(u),m.current=window.setTimeout(()=>l(!1),r);}catch(C){o==null||o(C);}};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(m.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:d,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",title:"Copy table as CSV",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),type:"button",title:"Copy table as TSV",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 m;try{let d=(m=a.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),f=d==null?void 0:d.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(d){o==null||o(d);}};return react.useEffect(()=>{let c=m=>{a.current&&!a.current.contains(m.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",title:"Download table as CSV",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",title:"Download table as Markdown",children:"Markdown"})]})]})};var 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-Z77EJIB4.cjs').then(e=>({default:e.CodeBlock}))),bo=react.lazy(()=>import('./mermaid-OUSRGB7Z.cjs').then(e=>({default:e.Mermaid}))),yo=/language-([^\s]+)/;function fe(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 v(e,t){return e.className===t.className&&fe(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,me=(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)=>v(e,t));xe.displayName="MarkdownOl";var wt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("li",{className:p("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&fe(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)=>v(e,t));kt.displayName="MarkdownUl";var Ct=react.memo(({className:e,node:t,...n})=>jsxRuntime.jsx("hr",{className:p("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>v(e,t));Ct.displayName="MarkdownHr";var vt=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)=>v(e,t));vt.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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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],m=false,d=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(m=true);else if(react.isValidElement(u))if(((f=u.props)==null?void 0:f["data-footnote-backref"])!==void 0)d=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()!==""){m=true;break}if(react.isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){m=true;break}}}}return d&&!m},a=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===xe){let m=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(d=>!s(d));return m.length===0?null:{...l,props:{...l.props,children:m}}}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)=>v(e,t));Ht.displayName="MarkdownSection";var wo=({node:e,className:t,children:n,...o})=>{var d,f,h;let r=((d=e==null?void 0:e.position)==null?void 0:d.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=me(a,"download"),w=me(a,"copy"),C=me(a,"fullscreen"),N=me(a,"panZoom");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(Ce,{}),children: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||C)&&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(we,{code:c}),C&&jsxRuntime.jsx(st,{chart:c,config:s==null?void 0:s.config})]}),jsxRuntime.jsx(bo,{chart:c,config:s==null?void 0:s.config,showControls:N})]})})}let m=Me(a,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(Ce,{}),children:jsxRuntime.jsx(go,{className:p("overflow-x-auto border-border border-t",t),code:c,language:l,children:m&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ge,{code:c,language:l}),jsxRuntime.jsx(we,{})]})})})},zt=react.memo(wo,(e,t)=>e.className===t.className&&fe(e.node,t.node));zt.displayName="MarkdownCode";var _t=react.memo(Ye,(e,t)=>e.className===t.className&&fe(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)=>v(e,t));qt.displayName="MarkdownParagraph";var Ut={ol:xe,li:wt,ul:kt,hr:Ct,strong:vt,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 he=Sn(Qt());function Z(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 m=e[++s],d=-1;if(l){a(l);return}for(;++d<r.length;)(c[d]===null||c[d]===void 0)&&(c[d]=r[d]);r=c,m?en(m,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 m=c;if(i&&n)throw m;return r(m)}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:Co,extname:vo,join:Po,sep:"/"};function ko(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');G(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 Co(e){if(G(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 vo(e){G(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;)G(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Mo(n)}function Mo(e){G(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 G(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, he.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=pe(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=pe(t),l=o.parse(i);o.run(l,i,function(m,d,f){if(m||!d||!f)return c(m);let h=d,u=o.stringify(h,f);Eo(u)?f.value=u:f.result=u,c(m,f);});function c(m,d){m||!d?a(m):s?s(d):n(void 0,d);}}}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=pe(n);r.run(t,l,c);function c(m,d,f){let h=d||t;m?i(m):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=pe(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[m,...d]=c;l(m,d);}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, he.default)(true,r.settings,c.settings));}function i(c){let m=-1;if(c!=null)if(Array.isArray(c))for(;++m<c.length;){let d=c[m];s(d);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,m){let d=-1,f=-1;for(;++d<o.length;)if(o[d][0]===c){f=d;break}if(f===-1)o.push([c,...m]);else if(m.length>0){let[h,...u]=m,g=o[f][1];Z(g)&&Z(h)&&(h=(0, he.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(!Z(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 pe(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},ge=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 d="default";return this.keyCache.set(t,d),d}let a=d=>{if(!d||d.length===0)return "";let f="";for(let h=0;h<d.length;h+=1){let u=d[h];if(h>0&&(f+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let C=ge.get(g);C||(C=g.name,ge.set(g,C)),f+=C;}else f+=String(g);f+=":",f+=JSON.stringify(w);}else if(typeof u=="function"){let g=ge.get(u);g||(g=u.name,ge.set(u,g)),f+=g;}else f+=String(u);}return f},i=a(o),l=a(r),c=s?JSON.stringify(s):"",m=`${l}::${i}::${c}`;return this.keyCache.set(t,m),m}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let 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),m=react.useRef(0),{isAnimating:d}=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 C=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),N=C==null?void 0:C.querySelector("table");if(!N){o==null||o(new Error("Table not found"));return}let x=ie(N),T=u==="csv"?ae(x):it(x),O=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([N.outerHTML],{type:"text/html"})});await navigator.clipboard.write([O]),l(!0),a(!1),n==null||n(u),m.current=window.setTimeout(()=>l(!1),r);}catch(C){o==null||o(C);}};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(m.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:d,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",title:"Copy table as CSV",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),type:"button",title:"Copy table as TSV",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 m;try{let d=(m=a.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"]'),f=d==null?void 0:d.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(d){o==null||o(d);}};return react.useEffect(()=>{let c=m=>{a.current&&!a.current.contains(m.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",title:"Download table as CSV",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",title:"Download table as Markdown",children:"Markdown"})]})]})};var 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-M5RMG6MJ.cjs').then(e=>({default:e.CodeBlock}))),bo=react.lazy(()=>import('./mermaid-CZAVW2Z4.cjs').then(e=>({default:e.Mermaid}))),yo=/language-([^\s]+)/;function fe(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 v(e,t){return e.className===t.className&&fe(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,me=(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)=>v(e,t));xe.displayName="MarkdownOl";var wt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("li",{className:p("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&fe(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)=>v(e,t));kt.displayName="MarkdownUl";var Ct=react.memo(({className:e,node:t,...n})=>jsxRuntime.jsx("hr",{className:p("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>v(e,t));Ct.displayName="MarkdownHr";var vt=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)=>v(e,t));vt.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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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)=>v(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],m=false,d=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(m=true);else if(react.isValidElement(u))if(((f=u.props)==null?void 0:f["data-footnote-backref"])!==void 0)d=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()!==""){m=true;break}if(react.isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){m=true;break}}}}return d&&!m},a=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===xe){let m=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(d=>!s(d));return m.length===0?null:{...l,props:{...l.props,children:m}}}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)=>v(e,t));Ht.displayName="MarkdownSection";var wo=({node:e,className:t,children:n,...o})=>{var d,f,h;let r=((d=e==null?void 0:e.position)==null?void 0:d.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=me(a,"download"),w=me(a,"copy"),C=me(a,"fullscreen"),N=me(a,"panZoom");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(Ce,{}),children: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||C)&&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(we,{code:c}),C&&jsxRuntime.jsx(st,{chart:c,config:s==null?void 0:s.config})]}),jsxRuntime.jsx(bo,{chart:c,config:s==null?void 0:s.config,showControls:N})]})})}let m=Me(a,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(Ce,{}),children:jsxRuntime.jsx(go,{className:p("overflow-x-auto border-border border-t",t),code:c,language:l,children:m&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ge,{code:c,language:l}),jsxRuntime.jsx(we,{})]})})})},zt=react.memo(wo,(e,t)=>e.className===t.className&&fe(e.node,t.node));zt.displayName="MarkdownCode";var _t=react.memo(Ye,(e,t)=>e.className===t.className&&fe(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)=>v(e,t));qt.displayName="MarkdownParagraph";var Ut={ol:xe,li:wt,ul:kt,hr:Ct,strong:vt,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 he=Sn(Qt());function Z(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 m=e[++s],d=-1;if(l){a(l);return}for(;++d<r.length;)(c[d]===null||c[d]===void 0)&&(c[d]=r[d]);r=c,m?en(m,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 m=c;if(i&&n)throw m;return r(m)}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:Co,extname:vo,join:Po,sep:"/"};function ko(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');G(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 Co(e){if(G(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 vo(e){G(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;)G(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Mo(n)}function Mo(e){G(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 G(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, he.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=pe(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=pe(t),l=o.parse(i);o.run(l,i,function(m,d,f){if(m||!d||!f)return c(m);let h=d,u=o.stringify(h,f);Eo(u)?f.value=u:f.result=u,c(m,f);});function c(m,d){m||!d?a(m):s?s(d):n(void 0,d);}}}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=pe(n);r.run(t,l,c);function c(m,d,f){let h=d||t;m?i(m):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=pe(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[m,...d]=c;l(m,d);}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, he.default)(true,r.settings,c.settings));}function i(c){let m=-1;if(c!=null)if(Array.isArray(c))for(;++m<c.length;){let d=c[m];s(d);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,m){let d=-1,f=-1;for(;++d<o.length;)if(o[d][0]===c){f=d;break}if(f===-1)o.push([c,...m]);else if(m.length>0){let[h,...u]=m,g=o[f][1];Z(g)&&Z(h)&&(h=(0, he.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(!Z(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 pe(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},ge=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 d="default";return this.keyCache.set(t,d),d}let a=d=>{if(!d||d.length===0)return "";let f="";for(let h=0;h<d.length;h+=1){let u=d[h];if(h>0&&(f+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let C=ge.get(g);C||(C=g.name,ge.set(g,C)),f+=C;}else f+=String(g);f+=":",f+=JSON.stringify(w);}else if(typeof u=="function"){let g=ge.get(u);g||(g=u.name,ge.set(u,g)),f+=g;}else f+=String(u);}return f},i=a(o),l=a(r),c=s?JSON.stringify(s):"",m=`${l}::${i}::${c}`;return this.keyCache.set(t,m),m}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let 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 m=i.match(Vo);if(m){let d=m[1];s.at(-1)===d&&s.pop();}}continue}if(a.type==="html"&&a.block){let m=i.match(Wo);if(m){let d=m[1];i.includes(`</${d}>`)||s.push(d);}}if(i.trim()==="$$"&&l>0){let m=r[l-1],d=ze(m),f=_e(m);if(d&&f%2===1){r[l-1]=m+i;continue}}if(l>0&&Xo(i)){let m=r[l-1],d=ze(m),f=_e(m),h=_e(i);if(d&&f%2===1&&!ze(i)&&h===1){r[l-1]=m+i;continue}}r.push(i);}return r};var Jo=/(\*\*)([^*]*?)$/,Ko=/(__)([^_]*?)$/,Zo=/(\*\*\*)([^*]*?)$/,Go=/(\*)([^*]*?)$/,Yo=/(_)([^_]*?)$/,Qo=/(`)([^`]*?)$/,er=/(~~)([^~]*?)$/,q=/^[\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)},be=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(be(e))return e;let t=e.match(Jo);if(t){let n=t[2];if(!n||q.test(n))return e;let o=e.lastIndexOf(t[1]),s=e.substring(0,o).lastIndexOf(`
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
`)||(e.endsWith("```\n")||e.endsWith("```"))&&n%2===0)return e;let r=e.match(Qo);if(r&&!o){let s=r[2];if(!s||q.test(s))return e;if(pr(e)%2===1)return `${e}\``}return e},gr=e=>{let t=e.match(er);if(t){let n=t[2];if(!n||q.test(n))return e;if((e.match(/~~/g)||[]).length%2===1)return `${e}~~`}return e},br=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let n=e.indexOf("$$");return n!==-1&&e.indexOf(`
|
|
19
19
|
`,n)!==-1&&!e.endsWith(`
|
|
20
20
|
`)?`${e}
|
|
21
|
-
$$`:`${e}$$`},yr=e=>{let t=0,n=0;for(let o=0;o<e.length;o+=1)e[o]==="*"?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0);return n>=3&&(t+=Math.floor(n/3)),t},wr=e=>{if(be(e)||or.test(e))return e;let t=e.match(Zo);if(t){let n=t[2];if(!n||q.test(n))return e;if(yr(e)%2===1)return `${e}***`}return e},Fe=e=>{if(!e||typeof e!="string")return e;let t=e,n=ir(t);return n.endsWith("](streamdown:incomplete-link)")?n:(t=n,t=wr(t),t=ar(t),t=lr(t),t=dr(t),t=fr(t),t=hr(t),t=gr(t),t=br(t),t)};var Sr={harden:[rehypeHarden.harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],defaultOrigin:void 0,allowDataImages:true}]
|
|
21
|
+
$$`:`${e}$$`},yr=e=>{let t=0,n=0;for(let o=0;o<e.length;o+=1)e[o]==="*"?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0);return n>=3&&(t+=Math.floor(n/3)),t},wr=e=>{if(be(e)||or.test(e))return e;let t=e.match(Zo);if(t){let n=t[2];if(!n||q.test(n))return e;if(yr(e)%2===1)return `${e}***`}return e},Fe=e=>{if(!e||typeof e!="string")return e;let t=e,n=ir(t);return n.endsWith("](streamdown:incomplete-link)")?n:(t=n,t=wr(t),t=ar(t),t=lr(t),t=dr(t),t=fr(t),t=hr(t),t=gr(t),t=br(t),t)};var Sr={raw:xr__default.default,katex:[Ve__default.default,{errorColor:"var(--color-muted-foreground)"}],harden:[rehypeHarden.harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],defaultOrigin:void 0,allowDataImages:true}]},Ar={gfm:[Ir__default.default,{}],math:[We__default.default,{singleDollarTextMath:false}],cjkFriendly:[Tr__default.default,{}],cjkFriendlyGfmStrikethrough:[Nr__default.default,{}]},Er=Object.values(Sr),Lr=Object.values(Ar),Br={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0},P=react.createContext(Br),bn=react.memo(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let o=react.useMemo(()=>typeof e=="string"&&t?Fe(e.trim()):e,[e,t]);return jsxRuntime.jsx(He,{...n,children:o})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});bn.displayName="Block";var Rr=["github-light","github-dark"],Dr=react.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:n=true,components:o,rehypePlugins:r=Er,remarkPlugins:s=Lr,className:a,shikiTheme:i=Rr,mermaid:l,controls:c=true,isAnimating:m=false,BlockComponent:d=bn,parseMarkdownIntoBlocksFn:f=qe,...h})=>{let u=react.useId(),[g,w]=react.useTransition(),[C,N]=react.useState([]),x=react.useMemo(()=>f(typeof e=="string"?e:""),[e,f]);react.useEffect(()=>{t==="streaming"?w(()=>{N(x);}):N(x);},[x,t]);let T=t==="streaming"?C:x,O=react.useMemo(()=>T.map((L,B)=>`${u}-${B}`),[T.length,u]),H=react.useMemo(()=>({shikiTheme:i,controls:c,isAnimating:m,mode:t,mermaid:l}),[i,c,m,t,l]),z=react.useMemo(()=>({...Ut,...o}),[o]);return react.useEffect(()=>{if(!(Array.isArray(r)&&r.some(S=>Array.isArray(S)?S[0]===Ve__default.default:S===Ve__default.default)))return;let B=false;if(Array.isArray(s)){let S=s.find(ne=>Array.isArray(ne)?ne[0]===We__default.default:ne===We__default.default);S&&Array.isArray(S)&&S[1]&&(B=S[1].singleDollarTextMath===true);}let R=typeof e=="string"?e:"",_=R.includes("$$"),y=B&&(/[^$]\$[^$]/.test(R)||/^\$[^$]/.test(R)||/[^$]\$$/.test(R));(_||y)&&import('katex/dist/katex.min.css');},[r,s,e]),t==="static"?jsxRuntime.jsx(P.Provider,{value:H,children:jsxRuntime.jsx("div",{className:p("space-y-4 whitespace-normal",a),children:jsxRuntime.jsx(He,{components:z,rehypePlugins:r,remarkPlugins:s,...h,children:e})})}):jsxRuntime.jsx(P.Provider,{value:H,children:jsxRuntime.jsx("div",{className:p("space-y-4 whitespace-normal",a),children:T.map((L,B)=>jsxRuntime.jsx(d,{components:z,content:L,index:B,rehypePlugins:r,remarkPlugins:s,shouldParseIncompleteMarkdown:n,...h},O[B]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Dr.displayName="Streamdown";var Cn=({children:e,className:t,minZoom:n=.5,maxZoom:o=3,zoomStep:r=.1,showControls:s=true,initialZoom:a=1,fullscreen:i=false})=>{let l=react.useRef(null),c=react.useRef(null),[m,d]=react.useState(a),[f,h]=react.useState({x:0,y:0}),[u,g]=react.useState(false),[w,C]=react.useState({x:0,y:0}),[N,x]=react.useState({x:0,y:0}),T=react.useCallback(y=>{d(I=>Math.max(n,Math.min(o,I+y)));},[n,o]),O=react.useCallback(()=>{T(r);},[T,r]),H=react.useCallback(()=>{T(-r);},[T,r]),z=react.useCallback(()=>{d(a),h({x:0,y:0});},[a]),L=react.useCallback(y=>{y.preventDefault();let I=y.deltaY>0?-r:r;T(I);},[T,r]),B=react.useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;g(true),C({x:y.clientX,y:y.clientY}),x(f);let I=y.currentTarget;I instanceof HTMLElement&&I.setPointerCapture(y.pointerId);},[f]),R=react.useCallback(y=>{if(!u)return;y.preventDefault();let I=y.clientX-w.x,S=y.clientY-w.y;h({x:N.x+I,y:N.y+S});},[u,w,N]),_=react.useCallback(y=>{g(false);let I=y.currentTarget;I instanceof HTMLElement&&I.releasePointerCapture(y.pointerId);},[]);return react.useEffect(()=>{let y=l.current;if(y)return y.addEventListener("wheel",L,{passive:false}),()=>{y.removeEventListener("wheel",L);}},[L]),react.useEffect(()=>{let y=c.current;if(y&&u)return document.body.style.userSelect="none",y.addEventListener("pointermove",R,{passive:false}),y.addEventListener("pointerup",_),y.addEventListener("pointercancel",_),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",R),y.removeEventListener("pointerup",_),y.removeEventListener("pointercancel",_);}},[u,R,_]),jsxRuntime.jsxs("div",{className:p("relative",i?"h-full w-full":"w-full",t),ref:l,style:{cursor:u?"grabbing":"grab"},children:[s&&jsxRuntime.jsxs("div",{className:p("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",i?"bottom-4 left-4":"bottom-2 left-2"),children:[jsxRuntime.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:m>=o,onClick:O,title:"Zoom in",type:"button",children:jsxRuntime.jsx(lucideReact.ZoomInIcon,{size:16})}),jsxRuntime.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:m<=n,onClick:H,title:"Zoom out",type:"button",children:jsxRuntime.jsx(lucideReact.ZoomOutIcon,{size:16})}),jsxRuntime.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:z,title:"Reset zoom and pan",type:"button",children:jsxRuntime.jsx(lucideReact.RotateCcwIcon,{size:16})})]}),jsxRuntime.jsx("div",{className:p("origin-center transition-transform duration-150 ease-out",i&&"flex h-full w-full items-center justify-center"),onPointerDown:B,ref:c,role:"application",style:{transform:`translate(${f.x}px, ${f.y}px) scale(${m})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var rt=({chart:e,className:t,config:n,fullscreen:o=false,showControls:r=true})=>{let[s,a]=react.useState(null),[i,l]=react.useState(true),[c,m]=react.useState(""),[d,f]=react.useState(""),[h,u]=react.useState(0),{mermaid:g}=react.useContext(P),w=g==null?void 0:g.errorComponent;if(react.useEffect(()=>{(async()=>{try{a(null),l(!0);let x=await se(n),T=e.split("").reduce((z,L)=>(z<<5)-z+L.charCodeAt(0)|0,0),O=`mermaid-${Math.abs(T)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:H}=await x.render(O,e);m(H),f(H);}catch(x){if(!(d||c)){let T=x instanceof Error?x.message:"Failed to render Mermaid chart";a(T);}}finally{l(false);}})();},[e,n,h]),i&&!c&&!d)return jsxRuntime.jsx("div",{className:p("my-4 flex justify-center p-4",t),children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsxRuntime.jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(s&&!c&&!d){let N=()=>u(x=>x+1);return w?jsxRuntime.jsx(w,{chart:e,error:s,retry:N}):jsxRuntime.jsxs("div",{className:p("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[jsxRuntime.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",s]}),jsxRuntime.jsxs("details",{className:"mt-2",children:[jsxRuntime.jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsxRuntime.jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let C=c||d;return jsxRuntime.jsx(Cn,{className:p(o?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:o,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsxRuntime.jsx("div",{"aria-label":"Mermaid chart",className:p("flex justify-center",o&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:C},role:"img"})})};exports.a=p;exports.b=Rn;exports.c=rt;exports.d=qe;exports.e=Fe;exports.f=Sr;exports.g=Ar;exports.h=P;exports.i=bn;exports.j=Dr;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkSF773HSE_cjs=require('./chunk-SF773HSE.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),shiki=require('shiki'),javascript=require('shiki/engine/javascript');var v=chunkSF773HSE_cjs.a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),b=react.memo(({children:e,result:t,language:o,className:r,...s})=>{let n=react.useMemo(()=>({backgroundColor:t.bg,color:t.fg}),[t.bg,t.fg]);return jsxRuntime.jsx("pre",{className:chunkSF773HSE_cjs.a(r,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-language":o,"data-streamdown":"code-block-body",style:n,...s,children:jsxRuntime.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:t.tokens.map((l,d)=>jsxRuntime.jsx("span",{className:v,children:l.map((a,i)=>jsxRuntime.jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:a.color,backgroundColor:a.bgColor,...a.htmlStyle},...a.htmlAttrs,children:a.content},i))},d))})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className);var C=({className:e,language:t,style:o,...r})=>jsxRuntime.jsx("div",{className:chunkSF773HSE_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",e),"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r});var L=({language:e,children:t})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":e,"data-streamdown":"code-block-header",children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:e}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:t})]});var $=javascript.createJavaScriptRegexEngine({forgiving:true}),m=new Map,p=new Map,g=new Map,E=(e,t)=>`${e}-${t[0]}-${t[1]}`,A=(e,t,o)=>{let r=e.slice(0,100),s=e.length>100?e.slice(-100):"";return `${t}:${o[0]}:${o[1]}:${e.length}:${r}:${s}`},T=e=>Object.hasOwn(shiki.bundledLanguages,e),K=(e,t)=>{let o=T(e)?e:"text",r=E(o,t);if(m.has(r))return m.get(r);let s=shiki.createHighlighter({themes:t,langs:[o],engine:$});return m.set(r,s),s},h=(e,t,o,r)=>{let s=T(t)?t:"text",n=A(e,s,o);return p.has(n)?p.get(n):(r&&(g.has(n)||g.set(n,new Set),g.get(n).add(r)),K(s,o).then(l=>{let d=l.codeToTokens(e,{lang:s,themes:{light:o[0],dark:o[1]}});p.set(n,d);let a=g.get(n);if(a){for(let i of a)i(d);g.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),g.delete(n);}),null)};var ie=({code:e,language:t,className:o,children:r,...s})=>{let{shikiTheme:n}=react.useContext(chunkSF773HSE_cjs.h),l=react.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:e.split(`
|
|
2
|
+
`).map(i=>[{content:i,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[e]),[d,a]=react.useState(l);return react.useEffect(()=>{let i=h(e,t,n);if(i){a(i);return}h(e,t,n,x=>{a(x);});},[e,t,n]),jsxRuntime.jsx(chunkSF773HSE_cjs.b.Provider,{value:{code:e},children:jsxRuntime.jsxs(C,{language:t,children:[jsxRuntime.jsx(L,{language:t,children:r}),jsxRuntime.jsx(b,{className:o,language:t,result:d,...s})]})})};exports.CodeBlock=ie;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a,h as h$1,b as b$1}from'./chunk-EK3FW32D.js';import {memo,useMemo,useContext,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';import {createHighlighter,bundledLanguages}from'shiki';import {createJavaScriptRegexEngine}from'shiki/engine/javascript';var v=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),b=memo(({children:e,result:t,language:o,className:r,...s})=>{let n=useMemo(()=>({backgroundColor:t.bg,color:t.fg}),[t.bg,t.fg]);return jsx("pre",{className:a(r,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-language":o,"data-streamdown":"code-block-body",style:n,...s,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:t.tokens.map((l,d)=>jsx("span",{className:v,children:l.map((a,i)=>jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:a.color,backgroundColor:a.bgColor,...a.htmlStyle},...a.htmlAttrs,children:a.content},i))},d))})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className);var C=({className:e,language:t,style:o,...r})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",e),"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r});var L=({language:e,children:t})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":e,"data-streamdown":"code-block-header",children:[jsx("span",{className:"ml-1 font-mono lowercase",children:e}),jsx("div",{className:"flex items-center gap-2",children:t})]});var $=createJavaScriptRegexEngine({forgiving:true}),m=new Map,p=new Map,g=new Map,E=(e,t)=>`${e}-${t[0]}-${t[1]}`,A=(e,t,o)=>{let r=e.slice(0,100),s=e.length>100?e.slice(-100):"";return `${t}:${o[0]}:${o[1]}:${e.length}:${r}:${s}`},T=e=>Object.hasOwn(bundledLanguages,e),K=(e,t)=>{let o=T(e)?e:"text",r=E(o,t);if(m.has(r))return m.get(r);let s=createHighlighter({themes:t,langs:[o],engine:$});return m.set(r,s),s},h=(e,t,o,r)=>{let s=T(t)?t:"text",n=A(e,s,o);return p.has(n)?p.get(n):(r&&(g.has(n)||g.set(n,new Set),g.get(n).add(r)),K(s,o).then(l=>{let d=l.codeToTokens(e,{lang:s,themes:{light:o[0],dark:o[1]}});p.set(n,d);let a=g.get(n);if(a){for(let i of a)i(d);g.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),g.delete(n);}),null)};var ie=({code:e,language:t,className:o,children:r,...s})=>{let{shikiTheme:n}=useContext(h$1),l=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:e.split(`
|
|
2
|
+
`).map(i=>[{content:i,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[e]),[d,a]=useState(l);return useEffect(()=>{let i=h(e,t,n);if(i){a(i);return}h(e,t,n,x=>{a(x);});},[e,t,n]),jsx(b$1.Provider,{value:{code:e},children:jsxs(C,{language:t,children:[jsx(L,{language:t,children:r}),jsx(b,{className:o,language:t,result:d,...s})]})})};export{ie as CodeBlock};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkSF773HSE_cjs=require('./chunk-SF773HSE.cjs');Object.defineProperty(exports,"Block",{enumerable:true,get:function(){return chunkSF773HSE_cjs.i}});Object.defineProperty(exports,"Streamdown",{enumerable:true,get:function(){return chunkSF773HSE_cjs.j}});Object.defineProperty(exports,"StreamdownContext",{enumerable:true,get:function(){return chunkSF773HSE_cjs.h}});Object.defineProperty(exports,"defaultRehypePlugins",{enumerable:true,get:function(){return chunkSF773HSE_cjs.f}});Object.defineProperty(exports,"defaultRemarkPlugins",{enumerable:true,get:function(){return chunkSF773HSE_cjs.g}});Object.defineProperty(exports,"parseIncompleteMarkdown",{enumerable:true,get:function(){return chunkSF773HSE_cjs.e}});Object.defineProperty(exports,"parseMarkdownIntoBlocks",{enumerable:true,get:function(){return chunkSF773HSE_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-
|
|
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-EK3FW32D.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkSF773HSE_cjs=require('./chunk-SF773HSE.cjs');Object.defineProperty(exports,"Mermaid",{enumerable:true,get:function(){return chunkSF773HSE_cjs.c}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{c as Mermaid}from'./chunk-EK3FW32D.js';
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a,h as h$1,b}from'./chunk-VF3PSAD2.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 s=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-language":t,"data-streamdown":"code-block-body",style:s,...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((l,d)=>jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:l.color,backgroundColor:l.bgColor,...l.htmlStyle},...l.htmlAttrs,children:l.content},d))},i))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var C=({className:o,language:e,style:t,...r})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...t},...r});var T=({language:o,children:e})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsx("div",{className:"flex items-center gap-2",children:e})]});var v=createJavaScriptRegexEngine({forgiving:true}),m=new Map,p=new Map,c=new Map,M=(o,e)=>`${o}-${e[0]}-${e[1]}`,$=(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}`},E=(o,e)=>{let t=M(o,e);if(m.has(t))return m.get(t);let r=createHighlighter({themes:e,langs:[o],engine:v});return m.set(t,r),r},h=(o,e,t,r)=>{let n=$(o,e,t);return p.has(n)?p.get(n):(r&&(c.has(n)||c.set(n,new Set),c.get(n).add(r)),E(e,t).then(s=>{let a=s.codeToTokens(o,{lang:e,themes:{light:t[0],dark:t[1]}});p.set(n,a);let i=c.get(n);if(i){for(let l of i)l(a);c.delete(n);}}).catch(s=>{console.error("Failed to highlight code:",s),c.delete(n);}),null)};var se=({code:o,language:e,className:t,children:r,...n})=>{let{shikiTheme:s}=useContext(h$1),a=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
|
|
2
|
-
`).map(d=>[{content:d,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[i,l]=useState(a);return useEffect(()=>{let d=h(o,e,s);if(d){l(d);return}h(o,e,s,x=>{l(x);});},[o,e,s]),jsx(b.Provider,{value:{code:o},children:jsxs(C,{language:e,children:[jsx(T,{language:e,children:r}),jsx(B,{className:t,language:e,result:i,...n})]})})};export{se as CodeBlock};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkX2CNSGMM_cjs=require('./chunk-X2CNSGMM.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),shiki=require('shiki'),javascript=require('shiki/engine/javascript');var H=chunkX2CNSGMM_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 s=react.useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsxRuntime.jsx("pre",{className:chunkX2CNSGMM_cjs.a(r,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-language":t,"data-streamdown":"code-block-body",style:s,...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((l,d)=>jsxRuntime.jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:l.color,backgroundColor:l.bgColor,...l.htmlStyle},...l.htmlAttrs,children:l.content},d))},i))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var C=({className:o,language:e,style:t,...r})=>jsxRuntime.jsx("div",{className:chunkX2CNSGMM_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...t},...r});var T=({language:o,children:e})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:e})]});var v=javascript.createJavaScriptRegexEngine({forgiving:true}),m=new Map,p=new Map,c=new Map,M=(o,e)=>`${o}-${e[0]}-${e[1]}`,$=(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}`},E=(o,e)=>{let t=M(o,e);if(m.has(t))return m.get(t);let r=shiki.createHighlighter({themes:e,langs:[o],engine:v});return m.set(t,r),r},h=(o,e,t,r)=>{let n=$(o,e,t);return p.has(n)?p.get(n):(r&&(c.has(n)||c.set(n,new Set),c.get(n).add(r)),E(e,t).then(s=>{let a=s.codeToTokens(o,{lang:e,themes:{light:t[0],dark:t[1]}});p.set(n,a);let i=c.get(n);if(i){for(let l of i)l(a);c.delete(n);}}).catch(s=>{console.error("Failed to highlight code:",s),c.delete(n);}),null)};var se=({code:o,language:e,className:t,children:r,...n})=>{let{shikiTheme:s}=react.useContext(chunkX2CNSGMM_cjs.h),a=react.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
|
|
2
|
-
`).map(d=>[{content:d,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[i,l]=react.useState(a);return react.useEffect(()=>{let d=h(o,e,s);if(d){l(d);return}h(o,e,s,x=>{l(x);});},[o,e,s]),jsxRuntime.jsx(chunkX2CNSGMM_cjs.b.Provider,{value:{code:o},children:jsxRuntime.jsxs(C,{language:e,children:[jsxRuntime.jsx(T,{language:e,children:r}),jsxRuntime.jsx(B,{className:t,language:e,result:i,...n})]})})};exports.CodeBlock=se;
|
package/dist/mermaid-LEH2MBRN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{c as Mermaid}from'./chunk-VF3PSAD2.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkX2CNSGMM_cjs=require('./chunk-X2CNSGMM.cjs');Object.defineProperty(exports,"Mermaid",{enumerable:true,get:function(){return chunkX2CNSGMM_cjs.c}});
|