@lofcz/streamdown 2.14.1 → 2.15.0
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-6TBP27CO.js +2 -0
- package/dist/chunk-TXJ25TS2.js +51 -0
- package/dist/diagram-O5F65CLC.js +2 -0
- package/dist/highlighted-body-N5O52WFD.js +2 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +1 -1
- package/dist/lib/controls.d.ts +2 -2
- package/dist/lib/diagram/adapter.d.ts +11 -0
- package/dist/lib/diagram/context.d.ts +2 -0
- package/dist/lib/diagram/controls.d.ts +4 -0
- package/dist/lib/diagram/download-button.d.ts +15 -0
- package/dist/lib/diagram/fullscreen-button.d.ts +23 -0
- package/dist/lib/diagram/index.d.ts +13 -0
- package/dist/lib/diagram/labels.d.ts +6 -0
- package/dist/lib/diagram/options.d.ts +1 -0
- package/dist/lib/mermaid/download-button.d.ts +1 -1
- package/dist/lib/mermaid/fullscreen-button.d.ts +1 -1
- package/dist/lib/mermaid/index.d.ts +3 -3
- package/dist/lib/plantuml/download-button.d.ts +1 -1
- package/dist/lib/plantuml/fullscreen-button.d.ts +1 -1
- package/dist/lib/plantuml/index.d.ts +3 -3
- package/dist/lib/plugin-context.d.ts +18 -1
- package/dist/lib/plugin-types.d.ts +95 -1
- package/dist/lib/preprocess-custom-tags.d.ts +5 -0
- package/dist/lib/streamdown-context.d.ts +37 -19
- package/dist/lib/tailwind-classes.d.ts +1 -1
- package/dist/lib/tailwind-classes.js +1 -1
- package/dist/lib/translations-context.d.ts +20 -0
- package/dist/openscad-RHDHURT6.js +2 -0
- package/dist/{viewer-A5T7PMUM.js → viewer-URBRVFVJ.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-EMUDB4GM.js +0 -2
- package/dist/chunk-FYGB27SX.js +0 -50
- package/dist/highlighted-body-PPVGTFLS.js +0 -2
- package/dist/mermaid-HNKQSOWL.js +0 -2
- package/dist/openscad-6N3MT4TE.js +0 -2
- package/dist/plantuml-GGYHKHKF.js +0 -2
package/dist/chunk-FYGB27SX.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {a,f,b,i,c,g,h,e,d}from'./chunk-EMUDB4GM.js';import {createContext,memo,useContext,useMemo,lazy,isValidElement,useLayoutEffect,useId,useRef,useEffect,useDeferredValue,useState,cloneElement,createElement,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Fo from'rehype-raw';import Vs,{defaultSchema}from'rehype-sanitize';import ld from'remark-gfm';import id from'remend';import {visitParents,SKIP as SKIP$1}from'unist-util-visit-parents';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import ul from'remark-parse';import pl from'remark-rehype';import {unified}from'unified';import {visit,SKIP}from'unist-util-visit';import {toText}from'hast-util-to-text';import {Lexer}from'marked';var Js=300,Ys="300px",Qs=500;function Ze(e={}){let{immediate:t=false,debounceDelay:n=Js,rootMargin:o=Ys,idleTimeout:r=Qs}=e,[s,a]=useState(false),c=useRef(null),l=useRef(null),i=useRef(null),d=useMemo(()=>y=>{let p=Date.now();return window.setTimeout(()=>{y({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-p))});},1)},[]),m=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(y,p)=>window.requestIdleCallback(y,p):d,[d]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?y=>window.cancelIdleCallback(y):y=>{clearTimeout(y);},[]);return useEffect(()=>{if(t){a(true);return}let y=c.current;if(!y)return;l.current&&(clearTimeout(l.current),l.current=null),i.current&&(u(i.current),i.current=null);let p=()=>{l.current&&(clearTimeout(l.current),l.current=null),i.current&&(u(i.current),i.current=null);},b=C=>{i.current=m(x=>{x.timeRemaining()>0||x.didTimeout?(a(true),C.disconnect()):i.current=m(()=>{a(true),C.disconnect();},{timeout:r/2});},{timeout:r});},h=C=>{p(),l.current=window.setTimeout(()=>{var E,R;let x=C.takeRecords();(x.length===0||(R=(E=x.at(-1))==null?void 0:E.isIntersecting)!=null&&R)&&b(C);},n);},f=(C,x)=>{C.isIntersecting?h(x):p();},g=new IntersectionObserver(C=>{for(let x of C)f(x,g);},{rootMargin:o,threshold:0});return g.observe(y),()=>{l.current&&clearTimeout(l.current),i.current&&u(i.current),g.disconnect();}},[t,n,o,r,u,m]),{shouldRender:s,containerRef:c}}var ea=320,ta=4,no=()=>typeof performance=="undefined"?Date.now():performance.now();function mn(e){var s,a;let t=(s=e==null?void 0:e.now)!=null?s:no,n=(a=e==null?void 0:e.maxBacklogMs)!=null?a:ea,o=0,r=0;return {now:t,beginPass(c){r=Math.min(Math.max(o,c),c+n);},mark(){return r},rewind(c){r=c;},take(c,l,i){if(c<=0)return {baseDelay:0,step:Math.max(0,l)};let d=Math.max(0,l),m=d===0?0:Math.min(d,ta),u=Math.max(r,i),y=i+n,p=u+Math.max(0,c-1)*d,b=d;if(p>y&&c>1)if(u<y){let f=y-u;b=Math.max(m,f/(c-1));}else b=m;let h=Math.max(0,Math.round(u-i));return r=u+c*b,{baseDelay:h,step:b}},commitPass(){o=r;}}}function na(){return {current:0}}var oo=/\s/,un=/^\s+$/,oa=new Set(["pre","svg","math","annotation"]),ra=new Set(["svg","math","annotation"]),dn=new Set(["img","hr"]),sa=new Set(["ul","ol","li"]),He=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",pn=(e,t)=>{let n=t?ra:oa;return e.some(o=>He(o)&&n.has(o.tagName))},aa=e=>{for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(He(n)&&n.tagName==="li")return n}},la=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${n}ms;--sd-marker-easing:${o}`;},ro=e=>{for(let t of e.children)if(He(t)){if(t.tagName==="input")return t;if(sa.has(t.tagName))continue;let n=ro(t);if(n)return n}},so=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-animation:sd-${t.animation};--sd-duration:${n}ms;--sd-easing:${t.easing};--sd-delay:${o}ms`;},ia=(e,t,n,o)=>{let r=ro(e);r&&so(r,t,n,o);},ao=e=>{var t;for(let n=e.length-1;n>=0;n-=1){let o=e[n];if(He(o)){if((t=o.properties)!=null&&t["data-sd-animated"])break;o.properties={...o.properties,"data-sd-animated":true};}}},lo=e=>{let t=[],n="",o=false;for(let r of e){let s=oo.test(r);if(s!==o&&n){if(s){n+=r,o=true;continue}t.push(n),n="";}n+=r,o=s;}return n&&t.push(n),t},io=e=>{let t=[],n="";for(let o of e)oo.test(o)?t.length>0&&!un.test(t.at(-1))?t[t.length-1]+=o:n+=o:(n&&(t.push(n),n=""),t.push(o));return n&&(t.length>0?t[t.length-1]+=n:t.push(n)),t},ca=(e,t,n,o,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:n}ms;--sd-easing:${o}`;return s&&(a+=`;--sd-delay:${Math.round(s)}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},da=(e,t,n,o)=>{let r=0,s=0;return visitParents(e,a=>a.type==="text"||He(a)&&dn.has(a.tagName),(a,c)=>{if(pn(c,n.animateCodeBlocks))return SKIP$1;if(He(a)&&dn.has(a.tagName)){o>0&&s<o||(r+=1),s+=1;return}let l=a.value;if(!l.trim()){s+=l.length;return}let i=t.sep==="char"?io(l):lo(l);for(let d of i){let m=s;s+=d.length,!un.test(d)&&(o>0&&m<o||(r+=1));}}),r},ma=(e,t,n,o,r,s)=>{if(pn(t,o.animateCodeBlocks))return;let a=o.prevContentLength,c=r.count;r.count+=1;let l=a>0&&c<a,i=l?0:s.baseDelay+r.newIndex++*s.step;so(e,n,l?0:n.duration,i),ao(t);},ua=(e,t,n,o,r,s)=>{var f;let a=t.at(-1);if(!(a&&"children"in a))return;if(pn(t,o.animateCodeBlocks))return SKIP$1;let c=a,l=c.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let d=n.sep==="char"?io(i):lo(i),m=o.prevContentLength,u=false,y=aa(t),p=!!(y&&!((f=y.properties)!=null&&f["data-sd-animate-marker"])),b=false,h=d.map(g=>{let C=r.count;if(r.count+=g.length,un.test(g))return {type:"text",value:g};let x=m>0&&C<m,S=x?0:s.baseDelay+r.newIndex++*s.step;if(y&&p&&!b){let E=x?0:n.duration;la(y,E,S,n.easing),ia(y,n,E,S),b=true;}return u=true,ca(g,n.animation,n.duration,n.easing,x,S)});return u&&ao(t),c.children.splice(l,1,...h),l+h.length},pa=0;function Lt(e){var s,a,c,l,i;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(c=e==null?void 0:e.easing)!=null?c:"ease",sep:(l=e==null?void 0:e.sep)!=null?l:"word",stagger:(i=e==null?void 0:e.stagger)!=null?i:40,timeline:e==null?void 0:e.timeline},n={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},o=pa++,r=()=>d=>{var b;let m={count:0,newIndex:0};n.prevContentLength=n.committedCharCount;let u=t.timeline,y=(b=u==null?void 0:u.now())!=null?b:no();u&&(n.pendingMark===null?n.pendingMark=u.mark():u.rewind(n.pendingMark));let p=u?u.take(da(d,t,n,n.prevContentLength),t.stagger,y):{baseDelay:0,step:t.stagger};visitParents(d,h=>h.type==="text"||He(h)&&dn.has(h.tagName),(h,f)=>{if(h.type==="text")return ua(h,f,t,n,m,p);ma(h,f,t,n,m,p);}),n.lastRenderCharCount=m.count,n.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${o}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){n.animateCodeBlocks=d;},setPrevContentLength(d){n.committedCharCount=d,n.prevContentLength=d;},getLastRenderCharCount(){return n.lastRenderCharCount},commit(){n.committedCharCount=n.lastRenderCharCount,n.pendingMark=null;}}}Lt();var fn=createContext(false),rt=()=>useContext(fn);function co(e){let t=[],n=[],o=0;return r=>{let s=new Map;for(let l=0;l<t.length;l+=1){let i=t[l],d=n[l];i!==void 0&&d!==void 0&&!s.has(i)&&s.set(i,d);}let a=new Set,c=r.map((l,i)=>{let d=t[i],m=n[i];if(d!==void 0&&m!==void 0&&!a.has(m)&&(d===l||l.startsWith(d)))return a.add(m),m;let u=s.get(l);if(u!==void 0&&!a.has(u))return a.add(u),u;let y=`${e}-${o}`;return o+=1,a.add(y),y});return t=r,n=c,c}}var st=({scrollRef:e,ref:t,...n})=>jsx("div",{ref:e,...n});var Ca=8,wa=e=>e.scrollHeight-e.scrollTop-e.clientHeight<Ca,fo=e=>{var n,o;let t=(o=(n=e.touches[0])!=null?n:e.changedTouches[0])!=null?o:null;return typeof(t==null?void 0:t.clientY)=="number"?t.clientY:null},At=({enabled:e,isAnimating:t,content:n})=>{let[o,r]=useState(null),s=useRef(true),a=useRef(0),c=useCallback(i=>{r(d=>d===i?d:i);},[]),l=useCallback(i=>{t&&s.current&&(i.scrollTo({top:i.scrollHeight,behavior:"instant"}),a.current=i.scrollTop);},[t]);return useEffect(()=>{t||(s.current=true);},[t]),useEffect(()=>{if(!(e&&o))return;a.current=o.scrollTop;let i=()=>{s.current=false;},d=h=>{h.deltaY<0&&i();},m=null,u=h=>{m=fo(h);},y=h=>{if(m===null)return;let f=fo(h);if(f===null)return;let g=f-m;Math.abs(g)<=3||(g>0&&i(),m=f);},p=()=>{m=null;},b=()=>{let h=o.scrollTop<a.current;if(a.current=o.scrollTop,h){i();return}wa(o)&&(s.current=true);};return o.addEventListener("wheel",d,{capture:true,passive:true}),o.addEventListener("touchstart",u,{passive:true}),o.addEventListener("touchmove",y,{passive:true}),o.addEventListener("touchend",p,{passive:true}),o.addEventListener("touchcancel",p,{passive:true}),o.addEventListener("scroll",b,{passive:true}),()=>{o.removeEventListener("wheel",d,{capture:true}),o.removeEventListener("touchstart",u),o.removeEventListener("touchmove",y),o.removeEventListener("touchend",p),o.removeEventListener("touchcancel",p),o.removeEventListener("scroll",b);}},[e,o]),useLayoutEffect(()=>{if(!(e&&o)||(l(o),typeof ResizeObserver=="undefined"))return;let i=new ResizeObserver(()=>{l(o);});i.observe(o);for(let d of o.children)i.observe(d);return ()=>{i.disconnect();}},[n,o,e,l]),c};var ka=a("block"),Pa=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Sa=e=>{let t={};for(let n of e.split(";")){let o=n.indexOf(":");if(o>0){let r=n.slice(0,o).trim(),s=n.slice(o+1).trim();r&&s&&(t[r]=s);}}return t},go=memo(({children:e,result:t,language:n,className:o,maxHeight:r,startLine:s,lineNumbers:a=true,...c})=>{let l=f(),{isAnimating:i,scrollable:d}=useContext(T),m=d!=null?d:st,u=b(r),y=At({content:t,enabled:!!u,isAnimating:i}),p=useMemo(()=>l(Pa),[l]),b$1=useMemo(()=>l(ka),[l]),h=useMemo(()=>{let f={};return t.bg&&(f["--sdm-bg"]=t.bg),t.fg&&(f["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(f,Sa(t.rootStyle)),f},[t.bg,t.fg,t.rootStyle]);return jsx(m,{className:l(o,u?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",scrollRef:y,style:u?{maxHeight:u}:void 0,...c,children:jsx("pre",{className:l(o,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:h,children:jsx("code",{className:a?l("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((f,g)=>jsx("span",{className:a?p:b$1,children:f.length===0||f.length===1&&f[0].content===""?`
|
|
3
|
-
`:f.map((C,x)=>{let S={},E=!!C.bgColor;if(C.color&&(S["--sdm-c"]=C.color),C.bgColor&&(S["--sdm-tbg"]=C.bgColor),C.htmlStyle)for(let[R,D]of Object.entries(C.htmlStyle))R==="color"?S["--sdm-c"]=D:R==="background-color"?(S["--sdm-tbg"]=D,E=true):S[R]=D;return jsx("span",{className:l("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",E&&"bg-[var(--sdm-tbg)]",E&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...C.htmlAttrs,children:C.content},x)})},g))})})})});var bn=({className:e,language:t,style:n,isIncomplete:o,...r})=>{let s=f();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":o||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...r})};var hn=createContext({code:""}),Dt=()=>useContext(hn);var yn=({language:e})=>{let t=f();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var La=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
-
`;)t--;return e.slice(0,t)},Aa=lazy(()=>import('./highlighted-body-PPVGTFLS.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Cn=({code:e,language:t,className:n,children:o,isIncomplete:r=false,startLine:s,lineNumbers:a,...c})=>{let l=f(),{codeBlockMaxHeight:i}=useContext(T),d=useMemo(()=>La(e),[e]),m=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
|
|
5
|
-
`).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(hn.Provider,{value:{code:e},children:jsxs(bn,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(yn,{language:t}),o?jsx("div",{className:l("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:l("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:o})}):null,jsx(Suspense,{fallback:jsx(go,{className:n,language:t,lineNumbers:a,maxHeight:i,result:m,startLine:s,...c}),children:jsx(Aa,{className:n,code:d,language:t,lineNumbers:a,maxHeight:i,raw:m,startLine:s,...c})})]})})};var yo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),Co=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),wo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),vo=e=>jsxs("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),xo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),ko=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Po=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),So=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),To=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Eo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var lt={CheckIcon:yo,CopyIcon:Co,DownloadIcon:wo,ExternalLinkIcon:So,Loader2Icon:vo,Maximize2Icon:xo,RotateCcwIcon:ko,XIcon:Po,ZoomInIcon:To,ZoomOutIcon:Eo},Mo=createContext(lt),_a=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?false:n.every(r=>e[r]===t[r])},wn=({icons:e,children:t})=>{let n=useRef(e),o=useRef(e?{...lt,...e}:lt);_a(n.current,e)||(n.current=e,o.current=e?{...lt,...e}:lt);let r=o.current;return jsx(Mo.Provider,{value:r,children:t})},H=()=>useContext(Mo);var Ke=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:r,code:s,label:a,...c})=>{let l=f(),[i$1,d]=useState(false),m=useRef(0),{code:u}=Dt(),{isAnimating:y}=useContext(T),p=i(),b=s!=null?s:u,h=a!=null?a:p.copyCode,f$1=async()=>{var x;if(typeof window=="undefined"||!((x=navigator==null?void 0:navigator.clipboard)!=null&&x.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i$1||(await navigator.clipboard.writeText(b),d(!0),e==null||e(),m.current=window.setTimeout(()=>d(!1),n));}catch(S){t==null||t(S);}};useEffect(()=>()=>{window.clearTimeout(m.current);},[]);let g=H(),C=i$1?g.CheckIcon:g.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":h,className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:y,onClick:f$1,title:h,type:"button",...c,children:o!=null?o:jsx(C,{"aria-hidden":"true",size:14})}),i$1&&jsx("output",{"aria-live":"polite",className:"sr-only",children:p.copied})]})};var pe=(e,t,n)=>{if(typeof e=="boolean")return n;let o=e[t];if(typeof o!="object")return n;let r=o.download;return typeof r!="object"?n:r.filename||n};function Be(e,t){if(typeof e=="boolean")return {};let n=e[t];if(typeof n!="object")return {};let o=n.copy;return typeof o!="object"||o===null?{}:{onCopy:o.onCopy,onError:o.onError}}var Io={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},xn=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...a})=>{let c=f(),{code:l}=Dt(),{isAnimating:i$1,controls:d$1}=useContext(T),m=i(),u=H(),y=s!=null?s:l,p=n&&n in Io?Io[n]:"txt",b=`${pe(d$1,"code","file")}.${p}`,h="text/plain",f$1=()=>{try{d(b,y,h),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{"aria-label":m.downloadFile,className:c("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:i$1,onClick:f$1,title:m.downloadFile,type:"button",...a,children:o!=null?o:jsx(u.DownloadIcon,{size:14})})};var qe=()=>{let{Loader2Icon:e}=H(),t=f();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var it=0,de=()=>{it+=1,it===1&&(document.body.style.overflow="hidden");},me=()=>{it=Math.max(0,it-1),it===0&&(document.body.style.overflow="");};var Xa=["github-light","github-dark"],Ga={enabled:true},Ja={codeBlockMaxHeight:400,shikiTheme:Xa,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,openscad:void 0,plantuml:void 0,linkSafety:Ga,portal:void 0,tableMaxHeight:300},T=createContext(Ja);var tl=/\.[^/.]+$/,Ao=(e,t)=>{if(typeof e=="boolean")return e;let n=e.image;return n===false?false:n===true||n===void 0?true:n[t]!==false},Do=({node:e,className:t,src:n,alt:o,onLoad:r,onError:s,onClick:a,...c})=>{let{DownloadIcon:l,XIcon:i$1}=H(),d$1=f(),m=useRef(null),[u,y]=useState(false),[p,b]=useState(false),[h,f$1]=useState(false),{controls:g}=useContext(T),C=i(),x=Ao(g,"download"),S=Ao(g,"fullscreen"),E=c.width!=null||c.height!=null,R=x&&(u||E)&&!p,D=p&&!E,P=S&&!!n&&!p&&u;useEffect(()=>{let L=m.current;if(L!=null&&L.complete){let G=L.naturalWidth>0;y(G),b(!G);}},[]),useEffect(()=>{if(!h)return;de();let L=G=>{G.key==="Escape"&&f$1(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),me();}},[h]);let M=useCallback(L=>{y(true),b(false),r==null||r(L);},[r]),V=useCallback(L=>{y(false),b(true),s==null||s(L);},[s]),j=useCallback(()=>{P&&f$1(true);},[P]),$=useCallback(()=>{f$1(false);},[]),Z=useCallback(L=>{a==null||a(L),!L.defaultPrevented&&j();},[a,j]),F=async L=>{if(L.stopPropagation(),!!n)try{let K=await(await fetch(n)).blob(),q=new URL(n,window.location.origin).pathname.split("/").pop()||"",Q=q.split(".").pop(),ie=q.includes(".")&&Q!==void 0&&Q.length<=4,se="";if(ie)se=q;else {let ae=K.type,le="png";ae.includes("jpeg")||ae.includes("jpg")?le="jpg":ae.includes("png")?le="png":ae.includes("svg")?le="svg":ae.includes("gif")?le="gif":ae.includes("webp")&&(le="webp"),se=`${(o||q||"image").replace(tl,"")}.${le}`;}d(se,K,K.type);}catch(G){window.open(n,"_blank");}};return n?n==="streamdown:incomplete-image"?jsx("div",{className:d$1("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:d$1("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:d$1("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:o,className:d$1("m-0 block h-auto max-w-full rounded-lg",P&&"cursor-zoom-in",D&&"hidden",t),"data-streamdown":"image",onClick:Z,onError:V,onLoad:M,ref:m,src:n,...c}),D&&jsx("span",{className:d$1("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:C.imageNotAvailable}),R&&jsx("button",{"aria-label":C.downloadImage,className:d$1("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 focus-visible:opacity-100 group-hover/image:opacity-100"),onClick:F,title:C.downloadImage,type:"button",children:jsx(l,{size:14})})]}),h?createPortal(jsxs("div",{className:d$1("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:$,onKeyDown:L=>{L.key==="Escape"&&$();},role:"button",tabIndex:0,children:[jsx("button",{"aria-label":C.exitFullscreen,className:d$1("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:$,title:C.exitFullscreen,type:"button",children:jsx(i$1,{size:20})}),jsx("div",{onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:jsx("img",{alt:o,className:d$1("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:n})})]}),document.body):null]}):null};var he=e=>{let t=typeof e=="function"?e():e;return t!=null?t:document.body};var Bo=({url:e,isOpen:t,onClose:n,onConfirm:o})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:c}=H(),l=f(),[i$1,d]=useState(false),m=i(),{portal:u}=useContext(T),y=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(h){}},[e]),p=useCallback(()=>{o(),n();},[o,n]);if(useEffect(()=>{if(t){de();let h=f=>{f.key==="Escape"&&n();};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),me();}}},[t,n]),!t||typeof document=="undefined")return null;let b=jsx("div",{className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:n,onKeyDown:h=>{h.key==="Escape"&&n();},role:"button",tabIndex:0,children:jsxs("div",{className:l("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:[jsx("button",{"aria-label":m.close,className:l("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:m.close,type:"button",children:jsx(c,{size:16})}),jsxs("div",{className:l("flex flex-col gap-2"),children:[jsxs("div",{className:l("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:m.openExternalLink})]}),jsx("p",{className:l("text-muted-foreground text-sm"),children:m.externalLinkWarning})]}),jsx("div",{className:l("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:l("flex gap-2"),children:[jsx("button",{className:l("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:y,type:"button",children:i$1?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:m.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:m.copyLink})]})}),jsxs("button",{className:l("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:p,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:m.openLink})]})]})]})});return createPortal(b,he(u))};var _o=()=>e=>{visit(e,"html",(n,o,r)=>{!r||typeof o!="number"||(r.children[o]={type:"text",value:n.value});});};var zo=[],Vo={allowDangerousHtml:true},Ht=new WeakMap,En=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let u="";for(let y=0;y<m.length;y+=1){let p=m[y];if(y>0&&(u+=","),Array.isArray(p)){let[b,h]=p;if(typeof b=="function"){let f=Ht.get(b);f||(f=b.name,Ht.set(b,f)),u+=f;}else u+=String(b);u+=":",u+=JSON.stringify(h);}else if(typeof p=="function"){let b=Ht.get(p);b||(b=p.name,Ht.set(p,b)),u+=b;}else u+=String(p);}return u},c=a(o),l=a(r),i=s?JSON.stringify(s):"",d=`${l}::${c}::${i}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},$o=new En,dt=e=>{let t=bl(e),n=e.children||"",o=t.runSync(t.parse(n),n);return xl(o,e)},bl=e=>{let t=$o.get(e);if(t)return t;let n=yl(e);return $o.set(e,n),n},hl=e=>e.some(t=>Array.isArray(t)?t[0]===Fo:t===Fo),yl=e=>{let t=e.rehypePlugins||zo,n=e.remarkPlugins||zo,o=hl(t)?n:[...n,_o],r=e.remarkRehypeOptions?{...Vo,...e.remarkRehypeOptions}:Vo;return unified().use(ul).use(o).use(pl,r).use(t)},jo=e=>e,Cl=(e,t,n,o)=>{n?e.children.splice(t,1):e.children[t]={type:"text",value:o};},wl=(e,t)=>{var n;for(let o in urlAttributes)if(Object.hasOwn(urlAttributes,o)&&Object.hasOwn(e.properties,o)){let r=e.properties[o],s=urlAttributes[o];(s===null||s.includes(e.tagName))&&(e.properties[o]=(n=t(String(r||""),o,e))!=null?n:void 0);}},vl=(e,t,n,o,r,s)=>{let a=false;return o?a=!o.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,n)),a},xl=(e,t)=>{let{allowElement:n,allowedElements:o,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:c}=t;if(n||o||r||s||c){let i=c||jo;visit(e,(d,m,u)=>{if(d.type==="raw"&&u&&typeof m=="number")return Cl(u,m,s,d.value),m;if(d.type==="element"&&(wl(d,i),vl(d,m,u,o,r,n)&&u&&typeof m=="number"))return a&&d.children?u.children.splice(m,1,...d.children):u.children.splice(m,1),m});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Ot=createContext(null),mt=()=>useContext(Ot),Au=()=>{var t;let e=mt();return (t=e==null?void 0:e.code)!=null?t:null},Xe=()=>{var t;let e=mt();return (t=e==null?void 0:e.mermaid)!=null?t:null},Ge=()=>{var t;let e=mt();return (t=e==null?void 0:e.plantuml)!=null?t:null},Je=()=>{var t;let e=mt();return (t=e==null?void 0:e.openscad)!=null?t:null};var Uo=e=>{var n;let t=mt();return t!=null&&t.renderers&&e&&(n=t.renderers.find(o=>Array.isArray(o.language)?o.language.includes(e):o.language===e))!=null?n:null};var Sl=/(<svg\b)/,Ko=/<svg\b[^>]*>/i,Tl=/\bviewBox=(['"])(.*?)\1/i,El=/\swidth=(['"]).*?\1/gi,Rl=/\sheight=(['"]).*?\1/gi,Wo=/\sstyle=(['"])(.*?)\1/i,Zo=/^<svg/i,Ml=/^width\s*:/i,Il=/^height\s*:/i,Nl=/^max-width\s*:/i,Ll=/[\s,]+/,Al=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Sl,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),Bt=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let n=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return n?new XMLSerializer().serializeToString(n):e},ut=e=>{let t=e.match(Ko);if(!t)return null;let o=t[0].match(Tl),r=o==null?void 0:o[2];if(!r)return null;let s=r.trim().split(Ll).map(l=>Number.parseFloat(l));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],c=s[3];return a>0&&c>0?{height:c,width:a}:null},_t=e=>{let t=e.match(Ko);if(!t)return e;try{let n=t[0],o=ut(e);if(!o)return e;let{width:r,height:s}=o,a=n.replace(El,"").replace(Rl,""),c=a.match(Wo),l=`width:${r}px;height:${s}px;max-width:none;`;if(c){let i=c[1],m=c[2].split(";").map(y=>y.trim()).filter(Boolean).filter(y=>!(Ml.test(y)||Il.test(y)||Nl.test(y))).join(";"),u=`${l}${m?`${m};`:""}`;a=a.replace(Wo,` style=${i}${u}${i}`);}else a=a.replace(Zo,`<svg style="${l}"`);return a=a.replace(Zo,`<svg width="${r}" height="${s}"`),e.replace(n,a)}catch(n){return e}},Ft=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((r,s)=>{let a=Al(e),c="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let i=document.createElement("canvas"),d=l.width*n,m=l.height*n;i.width=d,i.height=m;let u=i.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(l,0,0,d,m),i.toBlob(y=>{if(!y){s(new Error("Failed to create PNG blob"));return}r(y);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=c;})};var zt=({chart:e,children:t,className:n,onDownload:o,config:r,onError:s})=>{let a=f(),[c,l]=useState(false),i$1=useRef(null),{isAnimating:d$1,controls:m}=useContext(T),u=H(),y=Xe(),p=i(),b=pe(m,"mermaid","diagram"),h=async f=>{try{if(f==="mmd"){let R=`${b}.mmd`;d(R,e,"text/plain"),l(!1),o==null||o(f);return}if(!y){s==null||s(new Error("Mermaid plugin not available"));return}let g=y.getMermaid(r),C=e.split("").reduce((R,D)=>(R<<5)-R+D.charCodeAt(0)|0,0),x=`mermaid-${Math.abs(C)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:S}=await g.render(x,e);if(!S){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let E=Bt(S);if(f==="svg"){let R=`${b}.svg`;d(R,E,"image/svg+xml"),l(!1),o==null||o(f);return}if(f==="png"){let R=await Ft(E);d(`${b}.png`,R,"image/png"),o==null||o(f),l(!1);return}}catch(g){s==null||s(g);}};return useEffect(()=>{let f=g=>{let C=g.composedPath();i$1.current&&!C.includes(i$1.current)&&l(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:a("relative"),ref:i$1,children:[jsx("button",{"aria-label":p.downloadDiagram,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:d$1,onClick:()=>l(!c),title:p.downloadDiagram,type:"button",children:t!=null?t:jsx(u.DownloadIcon,{"aria-hidden":"true",size:14})}),c?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":p.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("svg"),title:p.downloadDiagramAsSvg,type:"button",children:p.mermaidFormatSvg}),jsx("button",{"aria-label":p.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("png"),title:p.downloadDiagramAsPng,type:"button",children:p.mermaidFormatPng}),jsx("button",{"aria-label":p.downloadDiagramAsMmd,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("mmd"),title:p.downloadDiagramAsMmd,type:"button",children:p.mermaidFormatMmd})]}):null]})};var Jo=({chart:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=H(),l=f(),[i$1,d]=useState(false),{isAnimating:m,controls:u,portal:y}=useContext(T),p=i(),b=(()=>{if(typeof u=="boolean")return u;let g=u.mermaid;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),h=(()=>{if(typeof u=="boolean")return u;let g=u.mermaid;return g===false?false:g===true||g===void 0?true:g.download!==false})(),f$1=()=>{d(!i$1);};return useEffect(()=>{if(i$1){de();let g=C=>{C.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),me();}}},[i$1]),useEffect(()=>{i$1?n==null||n():o&&o();},[i$1,n,o]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:f$1,title:p.viewFullscreen,type:"button",...s,"aria-label":p.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i$1?createPortal(jsxs("div",{"aria-label":p.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:f$1,onKeyDown:g=>{g.key==="Escape"&&f$1();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[h?jsx(zt,{chart:e,config:t}):null,jsx("button",{"aria-label":p.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:p.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:jsx(Go,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:b})})]}),he(y)):null]})};var Qo={"3mf":"model/3mf",stl:"model/stl"},Vt=({children:e,className:t,code:n,config:o,onDownload:r,onError:s})=>{let a=f(),[c,l]=useState(false),[i$1,d$1]=useState(false),m=useRef(null),{controls:u,isAnimating:y}=useContext(T),p=H(),b=Je(),h=i(),f$1=pe(u,"openscad","model"),g=async C=>{try{if(C==="scad"){d(`${f$1}.scad`,n,"text/plain"),l(!1),r==null||r(C);return}if(!b){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let x=b.getOpenScad(o),{data:S}=await x.render(n,{...o,format:C}),E=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${f$1}.${C}`,new Blob([E],{type:Qo[C]}),Qo[C]),r==null||r(C),l(!1);}catch(x){s==null||s(x);}finally{d$1(false);}};return useEffect(()=>{let C=x=>{let S=x.composedPath();m.current&&!S.includes(m.current)&&l(false);};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C);}},[]),jsxs("div",{className:a("relative"),ref:m,children:[jsx("button",{"aria-label":h.downloadModel,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:y||i$1,onClick:()=>l(!c),title:h.downloadModel,type:"button",children:e!=null?e:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),c?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":h.downloadModelAsScad,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("scad"),title:h.downloadModelAsScad,type:"button",children:h.openscadFormatScad}),jsx("button",{"aria-label":h.downloadModelAsStl,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("stl"),title:h.downloadModelAsStl,type:"button",children:h.openscadFormatStl}),jsx("button",{"aria-label":h.downloadModelAs3mf,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("3mf"),title:h.downloadModelAs3mf,type:"button",children:h.openscadFormat3mf})]}):null]})};var Xl=lazy(()=>import('./viewer-A5T7PMUM.js').then(e=>({default:e.OpenScadViewer}))),tr=({className:e,code:t,config:n,fullscreen:o=false})=>{let r=f(),s=i(),[a,c]=useState(null),[l,i$1]=useState(false),[d,m]=useState(null),[u,y]=useState(null),[p,b]=useState(0),{openscad:h}=useContext(T),f$1=Je(),g=h==null?void 0:h.errorComponent,C=rt(),{shouldRender:x,containerRef:S}=Ze({immediate:o});if(useEffect(()=>{if(!x||C)return;if(!f$1){c(s.openscadPluginMissing);return}(async()=>{try{c(null),i$1(!0);let P=await f$1.getOpenScad(n).render(t,n);m(P),y(P);}catch(D){if(!(u||d)){let P=D instanceof Error?D.message:s.openscadRenderFailed;c(P);}}finally{i$1(false);}})();},[t,n,p,x,C,f$1,s]),!(x||d||u))return jsx("div",{className:r("my-4 min-h-[200px]",e),ref:S});if(C&&!d&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:S,children:jsxs("div",{className:r("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:r("text-sm"),children:s.openscadWriting})]})});if(l&&!d&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:S,children:jsxs("div",{className:r("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:r("text-sm"),children:s.openscadLoading})]})});if(a&&!d&&!u){let R=()=>b(D=>D+1);return g?jsx("div",{ref:S,children:jsx(g,{code:t,error:a,retry:R})}):jsxs("div",{className:r("rounded-md bg-red-50 p-4",e),ref:S,children:[jsxs("p",{className:r("font-mono text-red-700 text-sm"),children:[s.openscadErrorLabel,": ",a]}),jsxs("details",{className:r("mt-2"),children:[jsx("summary",{className:r("cursor-pointer text-red-600 text-xs"),children:s.showCode}),jsx("pre",{className:r("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:t})]})]})}let E=d!=null?d:u;return jsx("div",{className:r("size-full",e),"data-streamdown":"openscad",ref:S,children:jsx(Suspense,{fallback:jsx("div",{className:r("flex h-full items-center justify-center"),children:jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2 text-muted-foreground")})}),children:E?jsx(Xl,{className:e,data:E.data,format:E.format,fullscreen:o}):null})})};var or=({code:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=H(),l=f(),[i$1,d]=useState(false),{isAnimating:m,controls:u,portal:y}=useContext(T),p=i(),b=(()=>{if(typeof u=="boolean")return u;let f=u.openscad;return f===false?false:f===true||f===void 0?true:f.download!==false})(),h=()=>{d(!i$1);};return useEffect(()=>{if(i$1){de();let f=g=>{g.key==="Escape"&&d(false);};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),me();}}},[i$1]),useEffect(()=>{i$1?n==null||n():o&&o();},[i$1,n,o]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,title:p.viewFullscreen,type:"button",...s,"aria-label":p.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i$1?createPortal(jsxs("div",{"aria-label":p.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"openscad-fullscreen",onClick:h,onKeyDown:f=>{f.key==="Escape"&&h();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[b?jsx(Vt,{code:e,config:t}):null,jsx("button",{"aria-label":p.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:p.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:jsx(tr,{className:l("size-full"),code:e,config:t,fullscreen:true})})]}),he(y)):null]})};var $t=({chart:e,children:t,className:n,onDownload:o,config:r,onError:s})=>{let a=f(),[c,l]=useState(false),i$1=useRef(null),{isAnimating:d$1,controls:m}=useContext(T),u=H(),y=Ge(),p=i(),b=pe(m,"plantuml","diagram"),h=async f=>{try{if(f==="puml"){d(`${b}.puml`,e,"text/plain"),l(!1),o==null||o(f);return}if(!y){s==null||s(new Error("PlantUML plugin not available"));return}let g=y.getPlantUml(r),{svg:C}=await g.render(e,r);if(!C){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let x=Bt(C);if(f==="svg"){d(`${b}.svg`,x,"image/svg+xml"),l(!1),o==null||o(f);return}let S=await Ft(x);d(`${b}.png`,S,"image/png"),o==null||o(f),l(!1);}catch(g){s==null||s(g);}};return useEffect(()=>{let f=g=>{let C=g.composedPath();i$1.current&&!C.includes(i$1.current)&&l(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:a("relative"),ref:i$1,children:[jsx("button",{"aria-label":p.downloadDiagram,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:d$1,onClick:()=>l(!c),title:p.downloadDiagram,type:"button",children:t!=null?t:jsx(u.DownloadIcon,{"aria-hidden":"true",size:14})}),c?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":p.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("svg"),title:p.downloadDiagramAsSvg,type:"button",children:p.plantumlFormatSvg}),jsx("button",{"aria-label":p.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("png"),title:p.downloadDiagramAsPng,type:"button",children:p.plantumlFormatPng}),jsx("button",{"aria-label":p.downloadDiagramAsPuml,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("puml"),title:p.downloadDiagramAsPuml,type:"button",children:p.plantumlFormatPuml})]}):null]})};var yt=e=>e>0?e:null,si=(e,t)=>{if(e.endsWith("px"))return yt(Number.parseFloat(e));if(e.endsWith("rem")){let n=Number.parseFloat(getComputedStyle(document.documentElement).fontSize||"16");return yt(Number.parseFloat(e)*n)}if(e.endsWith("em")){let n=Number.parseFloat(getComputedStyle(t).fontSize||"16");return yt(Number.parseFloat(e)*n)}if(e.endsWith("vh"))return yt(Number.parseFloat(e)/100*window.innerHeight);if(e.endsWith("%")){let n=t.parentElement;return n&&n.clientHeight>0?yt(Number.parseFloat(e)/100*n.clientHeight):null}return null},Nn=(e,t)=>{let n=t.trim().toLowerCase();return !n||n==="none"||n==="auto"?null:si(n,e)},ai=/^min\(\s*([^,]+)\s*,\s*([^)]+)\s*\)$/i,li=(e,t)=>{let n=Nn(e,t);if(n!=null)return n;let o=t.trim().match(ai);if(!o)return null;let r=Nn(e,o[1].trim()),s=Nn(e,o[2].trim());return r==null||s==null?null:Math.min(r,s)},ii=(e,t,n)=>{let o=t.clientWidth;if(!(o>0))return null;if(n){let d=t.clientHeight;if(!(d>0))return null;let m=Math.min(o/e.width,d/e.height,1);return !(m>0)||Number.isNaN(m)?null:{fitZoom:m,viewportHeight:null}}let r=Math.min(o/e.width,1);if(!(r>0)||Number.isNaN(r))return null;let s=e.height*r,a=null,c=t;for(;c&&a==null;){let d=getComputedStyle(c);a=li(c,d.maxHeight),c=c.parentElement;}let l=a!=null?Math.min(s,a):s,i=Math.min(r,l/e.height,1);return !(i>0)||Number.isNaN(i)?null:{fitZoom:i,viewportHeight:l}},Ut=({children:e,className:t,contentSize:n,fitKey:o,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:c=true,initialZoom:l=1,isAutoFit:i$1=false,fullscreen:d=false})=>{let{RotateCcwIcon:m,ZoomInIcon:u,ZoomOutIcon:y}=H(),p=f(),b=i(),h=useRef(null),f$1=useRef(null),g=useRef(false),[C,x]=useState(l),[S,E]=useState(r),[R,D]=useState(l),[P,M]=useState({x:0,y:0}),[V,j]=useState(false),[$,Z]=useState({x:0,y:0}),[F,U]=useState({x:0,y:0}),[L,G]=useState(null),K=useCallback(I=>{let z=h.current;if(!z)return;let Te=ii(I,z,d);if(!Te)return;let{fitZoom:Me,viewportHeight:ce}=Te;G(ce),x(Me),E(Math.min(r,Me)),g.current||(D(Me),M({x:0,y:0}));},[d,r]),W=useCallback(I=>{D(z=>Math.max(S,Math.min(s,z+I))),g.current=true;},[S,s]),q=useCallback(()=>{W(a);},[W,a]),Q=useCallback(()=>{W(-a);},[W,a]),ie=useCallback(()=>{D(C),M({x:0,y:0}),g.current=false;},[C]),se=useCallback(I=>{I.preventDefault();let z=I.deltaY>0?-a:a;W(z);},[W,a]),ae=useCallback(I=>{if(I.button!==0||I.isPrimary===false)return;j(true),g.current=true,Z({x:I.clientX,y:I.clientY}),U(P);let z=I.currentTarget;z instanceof HTMLElement&&z.setPointerCapture(I.pointerId);},[P]),le=useCallback(I=>{if(!V)return;I.preventDefault();let z=I.clientX-$.x,Te=I.clientY-$.y;M({x:F.x+z,y:F.y+Te});},[V,$,F]),oe=useCallback(I=>{j(false);let z=I.currentTarget;z instanceof HTMLElement&&z.releasePointerCapture(I.pointerId);},[]);useEffect(()=>{E(r),i$1||(x(l),D(l),G(null));},[l,i$1,r]),useLayoutEffect(()=>{if(!(i$1&&n))return;K(n);let I=h.current;if(!I||typeof ResizeObserver=="undefined")return;let z=new ResizeObserver(()=>{K(n);});return z.observe(I),()=>{z.disconnect();}},[K,n,i$1]),useEffect(()=>{i$1&&(g.current=false);},[o,i$1]),useEffect(()=>{let I=h.current;if(I)return I.addEventListener("wheel",se,{passive:false}),()=>{I.removeEventListener("wheel",se);}},[se]),useEffect(()=>{let I=f$1.current;if(I&&V)return document.body.style.userSelect="none",I.addEventListener("pointermove",le,{passive:false}),I.addEventListener("pointerup",oe),I.addEventListener("pointercancel",oe),()=>{document.body.style.userSelect="",I.removeEventListener("pointermove",le),I.removeEventListener("pointerup",oe),I.removeEventListener("pointercancel",oe);}},[V,le,oe]);let Ue=!d&&i$1&&L!=null?{height:L}:void 0;return jsxs("div",{className:p("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:h,style:{cursor:V?"grabbing":"grab",...Ue},children:[c?jsxs("div",{className:p("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",d?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{"aria-label":b.zoomIn,className:p("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:R>=s,onClick:q,title:b.zoomIn,type:"button",children:jsx(u,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":b.zoomOut,className:p("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:R<=S,onClick:Q,title:b.zoomOut,type:"button",children:jsx(y,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":b.resetView,className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:ie,title:b.resetView,type:"button",children:jsx(m,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:p("flex h-full w-full flex-1 origin-center items-center justify-center transition-transform duration-150 ease-out"),onPointerDown:ae,ref:f$1,role:"application",style:{transform:`translate(${P.x}px, ${P.y}px) scale(${R})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var mi=()=>{if(typeof document=="undefined")return false;let e=document.documentElement;return e.classList.contains("dark")||e.dataset.theme==="dark"||e.dataset.colorMode==="dark"},ar=({chart:e,className:t,config:n,fullscreen:o=false,showControls:r=true})=>{let s=f(),a=i(),[c,l]=useState(null),[i$1,d]=useState(false),[m,u]=useState(""),[y,p]=useState(null),[b,h]=useState(""),[f$1,g]=useState(0),{plantuml:C}=useContext(T),x=Ge(),S=C==null?void 0:C.errorComponent,{shouldRender:E,containerRef:R}=Ze({immediate:o});if(useEffect(()=>{if(!E)return;if(!x){l(a.plantumlPluginMissing);return}(async()=>{var M,V,j;try{l(null),d(!0);let $=x.getPlantUml(n),Z=(j=(V=n==null?void 0:n.dark)!=null?V:(M=C==null?void 0:C.config)==null?void 0:M.dark)!=null?j:mi(),{svg:F}=await $.render(e,{dark:Z}),U=ut(F),L=o?F:_t(F);u(L),p(U),h(L);}catch($){if(!(b||m)){let Z=$ instanceof Error?$.message:a.plantumlRenderFailed;l(Z);}}finally{d(false);}})();},[e,n,f$1,E,x]),!(E||m||b))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:R});if(i$1&&!m&&!b)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:R,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:a.diagramLoading})]})});if(c&&!m&&!b){let P=()=>g(M=>M+1);return S?jsx("div",{ref:R,children:jsx(S,{chart:e,error:c,retry:P})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:R,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:[a.plantumlErrorLabel,": ",c]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:a.showCode}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let D=m||b;return jsx("div",{className:s("size-full",t),"data-streamdown":"plantuml",ref:R,children:jsx(Ut,{className:s(o?"size-full overflow-hidden":"overflow-hidden",t),contentSize:y,fitKey:e,fullscreen:o,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":a.plantumlChart,className:s("flex justify-center",o?"size-full items-center":null),dangerouslySetInnerHTML:{__html:D},role:"img"})})})};var ir=({chart:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=H(),l=f(),[i$1,d]=useState(false),{isAnimating:m,controls:u,portal:y}=useContext(T),p=i(),b=(()=>{if(typeof u=="boolean")return u;let g=u.plantuml;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),h=(()=>{if(typeof u=="boolean")return u;let g=u.plantuml;return g===false?false:g===true||g===void 0?true:g.download!==false})(),f$1=()=>{d(!i$1);};return useEffect(()=>{if(i$1){de();let g=C=>{C.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),me();}}},[i$1]),useEffect(()=>{i$1?n==null||n():o&&o();},[i$1,n,o]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:f$1,title:p.viewFullscreen,type:"button",...s,"aria-label":p.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i$1?createPortal(jsxs("div",{"aria-label":p.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"plantuml-fullscreen",onClick:f$1,onKeyDown:g=>{g.key==="Escape"&&f$1();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[h?jsx($t,{chart:e,config:t}):null,jsx("button",{"aria-label":p.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:p.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:jsx(ar,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:b})})]}),he(y)):null]})};var An=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(An).join(""):isValidElement(e)?An(e.props.children):"",cr=(e,t,n)=>n!=null?n:(t?toText(t):An(e)).replace(/\s+/g," ").trim()||void 0;function Dn(e){var n;if(e.nodeType===Node.TEXT_NODE)return (n=e.textContent)!=null?n:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
|
|
6
|
-
`:Array.from(t.childNodes).map(Dn).join("")}var Qe=e=>{let t=[],n=[],o=e.querySelectorAll("thead th");for(let s of o)t.push(Dn(s).trim());let r=e.querySelectorAll("tbody tr");for(let s of r){let a=[],c=s.querySelectorAll("td");for(let l of c)a.push(Dn(l).trim());n.push(a);}return {headers:t,rows:n}},Ct=e=>{var n;if(typeof e!="object")return ",";let t=e.table;return typeof t!="object"?",":(n=t.csvSeparator)!=null?n:","},je=(e,t=",")=>{let n;t==="auto"?Intl.NumberFormat().format(1.1).includes(",")?n=";":n=",":n=t;let{headers:o,rows:r}=e,s=i=>{let d=false;for(let m of i)if(m===n||m==='"'||m===`
|
|
7
|
-
`||m==="\r"){d=true;break}return d?`"${i.replace(/"/g,'""')}"`:i},a=o.length>0?r.length+1:r.length,c=new Array(a),l=0;o.length>0&&(c[l]=o.map(s).join(n),l+=1);for(let i of r)c[l]=i.map(s).join(n),l+=1;return c.join(`
|
|
8
|
-
`)},Hn=e=>{let{headers:t,rows:n}=e,o=c=>{let l=false;for(let d of c)if(d===" "||d===`
|
|
9
|
-
`||d==="\r"){l=true;break}if(!l)return c;let i=[];for(let d of c)d===" "?i.push("\\t"):d===`
|
|
10
|
-
`?i.push("\\n"):d==="\r"?i.push("\\r"):i.push(d);return i.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 c of n)s[a]=c.map(o).join(" "),a+=1;return s.join(`
|
|
11
|
-
`)},Zt=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"||o===`
|
|
12
|
-
`){t=true;break}if(!t)return e;let n=[];for(let o of e)o==="\\"?n.push("\\\\"):o==="|"?n.push("\\|"):o===`
|
|
13
|
-
`?n.push("<br>"):n.push(o);return n.join("")},et=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(c=>Zt(c));o[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let c=0;c<t.length;c+=1)a[c]="---";o[r]=`| ${a.join(" | ")} |`,r+=1;for(let c of n)if(c.length<t.length){let l=new Array(t.length);for(let i=0;i<t.length;i+=1)l[i]=i<c.length?Zt(c[i]):"";o[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=c.map(i=>Zt(i));o[r]=`| ${l.join(" | ")} |`,r+=1;}return o.join(`
|
|
14
|
-
`)};var vt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let s=f(),[a,c]=useState(false),[l,i$1]=useState(false),d=useRef(null),m=useRef(0),{isAnimating:u,controls:y}=useContext(T),p=i(),b=Ct(y),h=Be(y,"table"),f$1=n!=null?n:h.onCopy,g=o!=null?o:h.onError,C=async E=>{var R,D;if(typeof window=="undefined"||!((R=navigator==null?void 0:navigator.clipboard)!=null&&R.write)){g==null||g(new Error("Clipboard API not available"));return}try{let P=(D=d.current)==null?void 0:D.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),M=P==null?void 0:P.querySelector("table");if(!M){g==null||g(new Error("Table not found"));return}let V=Qe(M),j="";E==="csv"?j=je(V,b):E==="tsv"?j=Hn(V):j=et(V);let $=new ClipboardItem({"text/plain":new Blob([j],{type:"text/plain"}),"text/html":new Blob([M.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),i$1(!0),c(!1),f$1==null||f$1(E),m.current=window.setTimeout(()=>i$1(!1),r);}catch(P){g==null||g(P);}};useEffect(()=>{let E=R=>{let D=R.composedPath();d.current&&!D.includes(d.current)&&c(false);};return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E),window.clearTimeout(m.current);}},[]);let x=H(),S=l?x.CheckIcon:x.CopyIcon;return jsxs("div",{className:s("relative"),ref:d,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>c(!a),title:p.copyTable,type:"button",children:e!=null?e:jsx(S,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("md"),title:p.copyTableAsMarkdown,type:"button",children:p.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("csv"),title:p.copyTableAsCsv,type:"button",children:p.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var ki=({children:e,className:t,onDownload:n,onError:o,format:r="csv",filename:s})=>{let a=f(),{isAnimating:c,controls:l}=useContext(T),i$1=i(),d$1=H(),m=Ct(l),u=y=>{try{let b=y.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),h=b==null?void 0:b.querySelector("table");if(!h){o==null||o(new Error("Table not found"));return}let f=Qe(h),g="",C="",x="";switch(r){case "csv":g=je(f,m),C="text/csv",x="csv";break;case "markdown":g=et(f),C="text/markdown",x="md";break;default:g=je(f,m),C="text/csv",x="csv";}d(`${s||pe(l,"table","table")}.${x}`,g,C),n==null||n();}catch(p){o==null||o(p);}};return jsx("button",{"aria-label":r==="csv"?i$1.downloadTableAsCsv:i$1.downloadTableAsMarkdown,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:u,title:r==="csv"?i$1.downloadTableAsCsv:i$1.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d$1.DownloadIcon,{size:14})})},xt=({children:e,className:t,onDownload:n,onError:o})=>{let r=f(),[s,a]=useState(false),c=useRef(null),{isAnimating:l,controls:i$1}=useContext(T),d$1=i(),m=H(),u=Ct(i$1),y=p=>{var b;try{let h=(b=c.current)==null?void 0:b.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=h==null?void 0:h.querySelector("table");if(!f){o==null||o(new Error("Table not found"));return}let g=Qe(f),C=p==="csv"?je(g,u):et(g),x=p==="csv"?"csv":"md",S=`${pe(i$1,"table","table")}.${x}`;d(S,C,p==="csv"?"text/csv":"text/markdown"),a(!1),n==null||n(p);}catch(h){o==null||o(h);}};return useEffect(()=>{let p=b=>{let h=b.composedPath();c.current&&!h.includes(c.current)&&a(false);};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p);}},[]),jsxs("div",{className:r("relative"),ref:c,children:[jsx("button",{"aria-label":d$1.downloadTable,className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:()=>a(!s),title:d$1.downloadTable,type:"button",children:e!=null?e:jsx(m.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":d$1.downloadTableAsCsv,className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("csv"),title:d$1.downloadTableAsCsv,type:"button",children:d$1.tableFormatCsv}),jsx("button",{"aria-label":d$1.downloadTableAsMarkdown,className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("markdown"),title:d$1.downloadTableAsMarkdown,type:"button",children:d$1.tableFormatMarkdown})]}):null]})};var gr=({children:e,className:t,showCopy:n=true,showDownload:o=true})=>{let{Maximize2Icon:r,XIcon:s}=H(),a=f(),[c,l]=useState(false),{isAnimating:i$1,portal:d}=useContext(T),m=i(),u=()=>{l(true);},y=()=>{l(false);};return useEffect(()=>{if(c){de();let p=b=>{b.key==="Escape"&&l(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),me();}}},[c]),jsxs(Fragment,{children:[jsx("button",{"aria-label":m.viewFullscreen,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i$1,onClick:u,title:m.viewFullscreen,type:"button",children:jsx(r,{size:14})}),c?createPortal(jsx("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:y,onKeyDown:p=>{p.key==="Escape"&&y();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[n?jsx(vt,{}):null,o?jsx(xt,{}):null,jsx("button",{"aria-label":m.exitFullscreen,className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:y,title:m.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),he(d)):null]})};var hr=({children:e,className:t,maxHeight:n,showControls:o,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...c})=>{let l=f(),{isAnimating:i,scrollable:d}=useContext(T),m=d!=null?d:st,u=b(n),y=At({content:e,enabled:!!u,isAnimating:i}),p=o&&r,b$1=o&&s,h=o&&a,f$1=p||b$1||h;return jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[f$1?jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[p?jsx(vt,{}):null,b$1?jsx(xt,{}):null,h?jsx(gr,{showCopy:p,showDownload:b$1,children:e}):null]}):null,jsx(m,{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:y,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:l("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...c,children:e})})]})};var Ai=/startLine=(\d+)/,Di=/\bnoLineNumbers\b/,Hi=lazy(()=>import('./mermaid-HNKQSOWL.js').then(e=>({default:e.Mermaid}))),Oi=lazy(()=>import('./plantuml-GGYHKHKF.js').then(e=>({default:e.PlantUml}))),Bi=lazy(()=>import('./openscad-6N3MT4TE.js').then(e=>({default:e.OpenScad}))),_i=/language-([^\s]+)/,Ce=e=>e.props,Fi="node";function _(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return false;let o=e,r=t;for(let s of n)if(s!==Fi&&!Object.is(o[s],r[s]))return false;return true}function zi(e,t){var n,o;return ((n=e==null?void 0:e.properties)==null?void 0:n.metastring)===((o=t==null?void 0:t.properties)==null?void 0:o.metastring)}function Vi(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=Ce(e).children;if(typeof t=="string")return t}}var xr=(e,t)=>Array.isArray(t)?t.includes(e):t===e,$i=(e,t)=>!!(t&&xr(e,t.language)),ji=(e,t)=>!!(t&&xr(e,t.language)),Pt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,_n=(e,t)=>{if(typeof e=="boolean")return e;let n=e.table;return n===false?false:n===true||n===void 0?true:n[t]!==false},yr=(e,t)=>{if(typeof e=="boolean")return e;let n=e.code;return n===false?false:n===true||n===void 0?true:n[t]!==false},qt=(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},Xt=(e,t)=>{if(typeof e=="boolean")return e;let n=e.plantuml;return n===false?false:n===true||n===void 0?true:n[t]!==false},Fn=(e,t)=>{if(typeof e=="boolean")return e;let n=e.openscad;return n===false?false:n===true||n===void 0?true:n[t]!==false},St=createContext({depth:0,ulDepth:0,isUnordered:false}),Ui={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Vn=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(St),c=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...o,children:jsx(St.Provider,{value:c,children:e})})},(e,t)=>_(e,t));Vn.displayName="MarkdownOl";var kr=memo(({children:e,className:t,node:n,...o})=>{var b;let r=f(),{depth:s,ulDepth:a,isUnordered:c}=useContext(St),{listStyle:l}=useContext(T),i=Ui[l],d=c&&a>0?i[(a-1)%i.length]:void 0,m=Array.isArray(e)?e.filter(h=>h!==`
|
|
15
|
-
`&&h!==""):[e],u=m[0],y=isValidElement(u)?(b=Ce(u).node)==null?void 0:b.tagName:void 0,p=m.length===1&&isValidElement(u)&&(u.type==="p"||y==="p")?Ce(u).children:e;return t!=null&&t.includes("task-list-item")?jsx("li",{className:r("my-1 flex list-none items-center gap-2 [&>input]:m-0 [&>p]:inline",t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...o,children:p}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...o,children:p})},(e,t)=>_(e,t));kr.displayName="MarkdownLi";var Pr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(St),c=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...o,children:jsx(St.Provider,{value:c,children:e})})},(e,t)=>_(e,t));Pr.displayName="MarkdownUl";var Sr=memo(({className:e,node:t,...n})=>{let o=f();return jsx("hr",{className:o("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n})},(e,t)=>_(e,t));Sr.displayName="MarkdownHr";var Tr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...o,children:e})},(e,t)=>_(e,t));Tr.displayName="MarkdownStrong";var Wi=({children:e,className:t,href:n,node:o,...r})=>{let s=f(),{linkSafety:a}=useContext(T),[c,l]=useState(false),i=n==="streamdown:incomplete-link",d=useCallback(async p=>{if(!(!(a!=null&&a.enabled&&n)||i)){if(p.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(n)){window.open(n,"_blank","noreferrer");return}l(true);}},[a,n,i]),m=useCallback(()=>{n&&window.open(n,"_blank","noreferrer");},[n]),u=useCallback(()=>{l(false);},[]),y={url:n!=null?n:"",isOpen:c,onClose:u,onConfirm:m};return a!=null&&a.enabled&&n?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":i,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(y):jsx(Bo,{...y})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":i,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},Er=memo(Wi,(e,t)=>_(e,t));Er.displayName="MarkdownA";var Rr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e})},(e,t)=>_(e,t));Rr.displayName="MarkdownH1";var Mr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e})},(e,t)=>_(e,t));Mr.displayName="MarkdownH2";var Ir=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e})},(e,t)=>_(e,t));Ir.displayName="MarkdownH3";var Nr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e})},(e,t)=>_(e,t));Nr.displayName="MarkdownH4";var Lr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e})},(e,t)=>_(e,t));Lr.displayName="MarkdownH5";var Ar=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e})},(e,t)=>_(e,t));Ar.displayName="MarkdownH6";var Dr=memo(({children:e,className:t,node:n,...o})=>{let{controls:r,tableMaxHeight:s}=useContext(T),a=Pt(r,"table"),c=_n(r,"copy"),l=_n(r,"download"),i=_n(r,"fullscreen");return jsx(hr,{className:t,maxHeight:s,showControls:a,showCopy:c,showDownload:l,showFullscreen:i,...o,children:e})},(e,t)=>_(e,t));Dr.displayName="MarkdownTable";var Hr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e})},(e,t)=>_(e,t));Hr.displayName="MarkdownThead";var Or=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...o,children:e})},(e,t)=>_(e,t));Or.displayName="MarkdownTbody";var Br=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...o,children:e})},(e,t)=>_(e,t));Br.displayName="MarkdownTr";var _r=memo(({children:e,className:t,node:n,title:o,...r})=>{let s=f(),a=cr(e,n,o);return jsx("th",{className:s("min-w-0 overflow-hidden px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...r,title:a,children:jsx("span",{className:s("wrap-anywhere line-clamp-2"),children:e})})},(e,t)=>_(e,t));_r.displayName="MarkdownTh";var Fr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("td",{className:r("wrap-anywhere min-w-0 px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e})},(e,t)=>_(e,t));Fr.displayName="MarkdownTd";var zr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e})},(e,t)=>_(e,t));zr.displayName="MarkdownBlockquote";var Vr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...o,children:e})},(e,t)=>_(e,t));Vr.displayName="MarkdownSup";var Zi=()=>({}),Ki=e=>{try{let t=atob(e),n=Uint8Array.from(t,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}catch(t){return ""}},$r=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{calloutIcon:s,calloutStyle:a,components:c,remarkPlugins:l,rehypePlugins:i}=useContext(T),d=o,m=d["data-callout-title"],u=d["data-callout-color"],y=d["data-callout-icon"],p=d["data-callout-body"],b=p?Ki(p):"",h=(a!=null?a:Zi)(u),f$1=y&&s?s(y):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:h,...o,children:[m!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[f$1,m]}):null,b.trim().length>0?jsx(dt,{components:c,rehypePlugins:i,remarkPlugins:l,children:b}):null]})},(e,t)=>_(e,t));$r.displayName="MarkdownCallout";var Cr={"markdown-alert-note":"border-l-blue-500 bg-blue-500/5 [&_.markdown-alert-title]:text-blue-600 dark:[&_.markdown-alert-title]:text-blue-400","markdown-alert-tip":"border-l-green-600 bg-green-600/5 [&_.markdown-alert-title]:text-green-700 dark:[&_.markdown-alert-title]:text-green-400","markdown-alert-important":"border-l-purple-600 bg-purple-600/5 [&_.markdown-alert-title]:text-purple-700 dark:[&_.markdown-alert-title]:text-purple-400","markdown-alert-warning":"border-l-amber-600 bg-amber-600/5 [&_.markdown-alert-title]:text-amber-700 dark:[&_.markdown-alert-title]:text-amber-400","markdown-alert-caution":"border-l-red-600 bg-red-600/5 [&_.markdown-alert-title]:text-red-700 dark:[&_.markdown-alert-title]:text-red-400"},jr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx($r,{className:t,node:n,...o,children:e});if(s){let c=Object.keys(Cr).find(l=>t==null?void 0:t.includes(l));return jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 px-4 py-3 [&>p:last-child]:mb-0",c?Cr[c]:null,t),...o,children:e})}return jsx("div",{className:r(t),...o,children:e})},(e,t)=>_(e,t));jr.displayName="MarkdownDiv";var Ur=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...o,children:e})},(e,t)=>_(e,t));Ur.displayName="MarkdownSub";var Wr=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=l=>{if(!isValidElement(l))return false;let i=Ce(l).children,d=Array.isArray(i)?i:[i],m=false,u=false;for(let y of d)if(y){if(typeof y=="string")y.trim()!==""&&(m=true);else if(isValidElement(y))if(Ce(y)["data-footnote-backref"]!==void 0)u=true;else {let p=Ce(y).children,b=Array.isArray(p)?p:[p];for(let h of b){if(typeof h=="string"&&h.trim()!==""){m=true;break}if(isValidElement(h)&&Ce(h)["data-footnote-backref"]===void 0){m=true;break}}}}return u&&!m},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===Vn){let i=Ce(l).children,m=(Array.isArray(i)?i:[i]).filter(u=>!s(u));return m.length===0?null:{...l,props:{...Ce(l),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)=>_(e,t));Wr.displayName="MarkdownSection";var qi=({node:e,className:t,children:n,...o})=>{var U,L,G;let r=f(),s=!("data-block"in o),{mermaid:a,plantuml:c,openscad:l,controls:i$1,lineNumbers:d}=useContext(T),m=Xe(),u=Ge(),y=Je(),p=rt(),b=i(),h=t==null?void 0:t.match(_i),f$1=(U=h==null?void 0:h.at(1))!=null?U:"",g=Uo(f$1);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let C=(L=e==null?void 0:e.properties)==null?void 0:L.metastring,x=typeof C=="string"?C:void 0,S=x==null?void 0:x.match(Ai),E=S?Number.parseInt(S[1],10):void 0,R=E!==void 0&&E>=1?E:void 0,P=!(x?Di.test(x):false)&&d!==false,M=(G=Vi(n))!=null?G:"";if(g){let K=g.component;return jsx(Suspense,{fallback:jsx(qe,{}),children:jsx(K,{code:M,isIncomplete:p,language:f$1,meta:x})})}if(f$1==="mermaid"&&m){let K=Pt(i$1,"mermaid"),W=qt(i$1,"download"),q=qt(i$1,"copy"),Q=qt(i$1,"fullscreen"),ie=qt(i$1,"panZoom"),se=K&&(W||q||Q);return jsx(Suspense,{fallback:jsx(qe,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":"mermaid-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),se?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[W?jsx(zt,{chart:M,config:a==null?void 0:a.config}):null,q?jsx(Ke,{code:M,label:b.copyDiagram,...Be(i$1,"mermaid")}):null,Q?jsx(Jo,{chart:M,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("overflow-hidden rounded-md border border-border bg-background"),children:jsx(Hi,{chart:M,config:a==null?void 0:a.config,showControls:ie})})]})})}if($i(f$1,u)){let K=Pt(i$1,"plantuml"),W=Xt(i$1,"download"),q=Xt(i$1,"copy"),Q=Xt(i$1,"fullscreen"),ie=Xt(i$1,"panZoom"),se=K&&(W||q||Q);return jsx(Suspense,{fallback:jsx(qe,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":"plantuml-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:f$1})}),se?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"plantuml-block-actions",children:[W?jsx($t,{chart:M,config:c==null?void 0:c.config}):null,q?jsx(Ke,{code:M,label:b.copyDiagram,...Be(i$1,"plantuml")}):null,Q?jsx(ir,{chart:M,config:c==null?void 0:c.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Oi,{chart:M,config:c==null?void 0:c.config,showControls:ie})})]})})}if(ji(f$1,y)){let K=Pt(i$1,"openscad"),W=Fn(i$1,"download"),q=Fn(i$1,"copy"),Q=Fn(i$1,"fullscreen"),ie=K&&(W||q||Q);return jsx(Suspense,{fallback:jsx(qe,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":"openscad-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:f$1})}),ie?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"openscad-block-actions",children:[W?jsx(Vt,{code:M,config:l==null?void 0:l.config}):null,q?jsx(Ke,{code:M,label:b.copyModel,...Be(i$1,"openscad")}):null,Q?jsx(or,{code:M,config:l==null?void 0:l.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Bi,{code:M,config:l==null?void 0:l.config})})]})})}let V=Pt(i$1,"code"),j=yr(i$1,"download"),$=yr(i$1,"copy"),{"data-block":Z,...F}=o;return jsx(Cn,{className:t,code:M,isIncomplete:p,language:f$1,lineNumbers:P,startLine:R,...F,children:V?jsxs(Fragment,{children:[j?jsx(xn,{code:M,language:f$1}):null,$?jsx(Ke,{...Be(i$1,"code")}):null]}):null})},Zr=memo(qi,(e,t)=>_(e,t)&&zi(e.node,t.node));Zr.displayName="MarkdownCode";var Kr=memo(Do,(e,t)=>_(e,t));Kr.displayName="MarkdownImg";var wr={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},qr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=i(),a=o["data-alert-type"],c=a&&a in wr?wr[a]:void 0,l=c?s[c]:void 0,i$1=e;return l&&(i$1=[...(Array.isArray(e)?e:[e]).filter(u=>!(typeof u=="string"&&u.trim().length>0)),l]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...o,children:i$1})},(e,t)=>_(e,t));qr.displayName="MarkdownAlertTitle";var Xr=memo(({children:e,className:t,node:n,...o})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(qr,{className:t,node:n,...o,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=Ce(s[0]).node,c=a==null?void 0:a.tagName;if(c==="img")return jsx(Fragment,{children:e});if(c==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...o,children:e})},(e,t)=>_(e,t));Xr.displayName="MarkdownParagraph";var Gr={ol:Vn,li:kr,ul:Pr,hr:Sr,strong:Tr,a:Er,h1:Rr,h2:Mr,h3:Ir,h4:Nr,h5:Lr,h6:Ar,table:Dr,thead:Hr,tbody:Or,tr:Br,th:_r,td:Fr,blockquote:zr,code:Zr,div:jr,img:Kr,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Vr,sub:Ur,p:Xr,section:Wr};var Xi=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Gi=/\p{L}/u;function Tt(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,"").replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,""),n,o=0,r=0;for(let s of t){if(Xi.test(s)){n!=null||(n="rtl"),r+=1;continue}Gi.test(s)&&(n!=null||(n="ltr"),o+=1);}return r>o?"rtl":o>r?"ltr":n!=null?n:"ltr"}var Ji=/^[ \t]{0,3}(`{3,}|~{3,})/;var Jr=e=>{let t=e.split(`
|
|
16
|
-
`),n=null,o=0;for(let r of t){let s=Ji.exec(r);if(n===null){if(s){let a=s[1];n=a[0],o=a.length;}}else if(s){let a=s[1],c=a[0],l=a.length;c===n&&l>=o&&(n=null,o=0);}}return n!==null};var Qi=/\[\^[\w-]{1,200}\](?!:)/,ec=/\[\^[\w-]{1,200}\]:/,tc=/<([A-Za-z][\w:-]*)[\s>/]/,nc=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Yr=new Map,Qr=new Map,ns=e=>{let t=e.toLowerCase(),n=Yr.get(t);if(n)return n;let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Yr.set(t,o),o},oc=e=>{let t=e.toLowerCase(),n=Qr.get(t);if(n)return n;let o=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Qr.set(t,o),o},es=(e,t)=>{if(nc.has(t.toLowerCase()))return 0;let n=e.match(ns(t));if(!n)return 0;let o=0;for(let r of n)r.trimEnd().endsWith("/>")||(o+=1);return o},ts=(e,t)=>{let n=e.match(oc(t));return n?n.length:0},rc=(e,t)=>{let n=e.match(ns(t));return !!n&&n.every(o=>o.trimEnd().endsWith("/>"))},sc=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},os=e=>Qi.test(e)||ec.test(e),ac=/\r\n|\r/g,lc=e=>new Lexer({gfm:true}).blockTokens(e),ic=`
|
|
17
|
-
|
|
18
|
-
`,cc=e=>{var t;for(let n=e.length-3;n>=0;n-=1)if((t=e.at(n))!=null&&t.endsWith(ic))return n+1;return 0},dc=e=>` ${e}`.slice(1),$n=(e,t)=>({source:e,blocks:t(e),verifiedCount:0,verifiedLength:0}),mc=(e,t,n)=>{var c,l,i,d;let o=cc(e.blocks);if(o===0)return null;let r=(c=e.verifiedCount)!=null?c:0,s=(l=e.verifiedLength)!=null?l:0;if(r>o){r=o,s=0;for(let m=0;m<r;m+=1)s+=(d=(i=e.blocks.at(m))==null?void 0:i.length)!=null?d:0;}for(;r<o;){let m=e.blocks.at(r);if(m===void 0||!t.startsWith(m,s))return null;s+=m.length,r+=1;}let a=n(t.slice(s)).map(dc);return {source:t,blocks:e.blocks.slice(0,o).concat(a),verifiedCount:r,verifiedLength:s}},Et=e=>{if(os(e))return [e];let t=e.includes("\r")?e.replace(ac,`
|
|
19
|
-
`):e,n=lc(t),o=[],r=[],s=false;for(let a of n){let c=a.raw,l=o.length;if(r.length>0){o[l-1]+=c;let i=r.at(-1),d=es(c,i),m=ts(c,i);for(let u=0;u<d;u+=1)r.push(i);for(let u=0;u<m;u+=1)r.length>0&&r.at(-1)===i&&r.pop();continue}if(a.type==="html"&&a.block){let i=c.match(tc);if(i){let d=i[1],m=es(c,d),u=ts(c,d);m>u&&!rc(c,d)&&r.push(d);}}if(a.type==="space"&&l>0){o[l-1]+=c;continue}if(l>0&&!s){let i=o[l-1];if(sc(i)%2===1){o[l-1]=i+c;continue}}o.push(c),a.type!=="space"&&(s=a.type==="code");}return o},jn=(e,t,n=Et)=>{var o;return t!=null&&t.source&&e.startsWith(t.source)?e===t.source?t:n===Et&&os(e)?$n(e,n):(o=mc(t,e,n))!=null?o:$n(e,n):$n(e,n)};var uc=/^ {0,3}(`{3,}|~{3,})/,pc=/^\n[ \t]*\n/,ss=(e,t,n)=>{let o=t;for(;o<n&&e[o]==="`";)o+=1;return o},fc=(e,t,n,o)=>{let r=t;for(;r<n;){let s=e[r];if(s==="`"){let a=ss(e,r,n);if(a-r===o)return r;r=a;continue}if(s===`
|
|
20
|
-
`&&pc.test(e.slice(r,r+64)))return -1;r+=1;}return -1},rs=(e,t,n,o)=>{let r=t;for(;r<n;){if(e[r]!=="`"){r+=1;continue}let s=ss(e,r,n),a=s-r,c=fc(e,s,n,a);if(c===-1){r=s;continue}o.push([r,c+a]),r=c+a;}},gc=e=>{let t=[],n=e.length,o=null,r=0,s=0;for(;s<n;){let a=e.indexOf(`
|
|
21
|
-
`,s),c=a===-1?n:a,l=e.slice(s,c),i=uc.exec(l);if(o){let d=i==null?void 0:i[1];d&&d[0]===o.char&&d.length>=o.length&&l.slice(i[0].length).trim()===""&&(t.push([o.start,c]),o=null,r=c);}else if(i){let d=i[1],m=l.slice(i[0].length);d[0]==="`"&&m.includes("`")||(rs(e,r,s,t),o={char:d[0],length:d.length,start:s});}s=c+1;}return o?t.push([o.start,n]):rs(e,r,n,t),t},bc=(e,t)=>{let n=0,o=e.length-1;for(;n<=o;){let r=Math.floor((n+o)/2),[s,a]=e[r];if(t<s)o=r-1;else if(t>=a)n=r+1;else return true}return false},Jt=e=>{let t=null;return n=>(t===null&&(t=gc(e)),bc(t,n))},as=(e,t,n)=>{let o=Jt(e);return e.replace(t,(r,...s)=>{let a=s.findIndex(l=>typeof l=="number"),c=s[a];return o(c)?r:n(r,...s.slice(0,a))})},Yt=(e,t,n)=>{let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),r=new RegExp(`</${t}\\s*>`,"gi"),s=Jt(e),a="",c=0,l=o.exec(e);for(;l;){if(s(l.index)){l=o.exec(e);continue}let i=l.index+l[0].length;r.lastIndex=i;let d=r.exec(e);for(;d&&s(d.index);)d=r.exec(e);if(!d)break;a+=e.slice(c,l.index)+n(l[0],e.slice(i,d.index),d[0]),c=d.index+d[0].length,o.lastIndex=c,l=o.exec(e);}return c===0?e:a+e.slice(c)};var hc=/^\n*/,yc=/\n*$/,Un=/\n\n/g,Cc=(e,t,n)=>{if(!t.includes(`
|
|
22
|
-
`))return e+t+n;let r=t.replace(Un,`
|
|
23
|
-
<!---->
|
|
24
|
-
`).replace(hc,`
|
|
25
|
-
|
|
26
|
-
`).replace(yc,`
|
|
27
|
-
|
|
28
|
-
`);return `${e}${r}${n}
|
|
29
|
-
|
|
30
|
-
`},wc=(e,t)=>{let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),o=new RegExp(`</${t}\\s*>`,"gi"),r=Jt(e),s=i=>{o.lastIndex=i;let d=o.exec(e);for(;d&&r(d.index);)d=o.exec(e);return d!==null},a="",c=0,l=n.exec(e);for(;l;){let i=l[0],d=l.index+i.length;if(r(l.index)){l=n.exec(e);continue}if(s(d)){l=n.exec(e);continue}let m=e.slice(d);if(a+=e.slice(c,l.index),m.length===0){a+=i,c=d,l=n.exec(e);continue}if(m.startsWith(`
|
|
31
|
-
|
|
32
|
-
`)){let p=m.slice(2).replace(Un,`
|
|
33
|
-
<!---->
|
|
34
|
-
`);a+=`${i}
|
|
35
|
-
|
|
36
|
-
${p}`,c=e.length;break}if(!m.startsWith(`
|
|
37
|
-
`)){a+=i,c=d,l=n.exec(e);continue}let u=m.slice(1);if(u.trim().length===0){a+=i,c=d,l=n.exec(e);continue}let y=u.replace(Un,`
|
|
38
|
-
<!---->
|
|
39
|
-
`);a+=`${i}
|
|
40
|
-
|
|
41
|
-
${y}`,c=e.length;break}return c===0?e:a+e.slice(c)},ls=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`<${o}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");n=as(n,r,(s,a)=>`<${o}${a}></${o}>`);}for(let o of t)n=Yt(n,o,Cc),n=wc(n,o);return n};var vc=/([\\`*_~[\]|])/g,xc=e=>e.replace(vc,"\\$1"),is=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t)n=Yt(n,o,(r,s,a)=>{let c=xc(s).replace(/\n\n/g," ");return r+c+a});return n};var Pc=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),cs=new Set(["code","kbd","pre","samp","var"]);function ds(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!cs.has(t.tagName)?ds(t):"").join("")}function ms(){return e=>{visit(e,"element",t=>{if(cs.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}Pc.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=Tt(ds(t))));});}}var us=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{var s;if(!n.has(o.tagName.toLowerCase()))return;let r=o.children.filter(a=>a.type==="element").map(a=>{var c;return {tag:a.tagName,props:(c=a.properties)!=null?c:{},text:toText(a).trim()}});o.properties=(s=o.properties)!=null?s:{},o.properties["data-content"]=JSON.stringify(r),o.children=[];});};var ps=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(ps).join(""):"",fs=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{if(n.has(o.tagName.toLowerCase())){let r=ps(o);o.children=r?[{type:"text",value:r}]:[];}});};var Lc=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Ac=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Dc=e=>{let t=unified().use(ul).use(pl,{allowDangerousHtml:true}),n=t.parse(e);return t.runSync(n).children},gs=(e,t=[])=>n=>{if(!e||e.length===0)return;let o=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(n,"element",s=>{let a=s.tagName.toLowerCase();if(!o.has(a)||r.has(a)||!Lc(s))return;let c=Ac(s);if(!c.includes(`
|
|
42
|
-
`))return;let l=Dc(c);s.children=l;});};var bs=()=>e=>{visit(e,"code",t=>{var n,o;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(o=t.data.hProperties)!=null?o:{},metastring:t.meta});});};var hs=/^>>>[ \t]?(.*)$/,Oc=/^<<<\s*$/,Bc=/^>+\s*$/,_c=/^<+\s*$/,Fc=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,zc=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Vc=/^[a-z0-9-]+$/,$c=e=>{let t=Fc.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:n,iconBrace:o,title:r,color:s}=t.groups,a=n!=null?n:o;return {icon:a&&Vc.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&zc.test(s)?s:void 0}},Wn=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),jc=e=>{let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n)},Uc=(e,t)=>{var i;let n=hs.exec(e[t]),o=(i=n==null?void 0:n[1])!=null?i:"",r=$c(o),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(Oc.test(d)){a+=1;break}if(Bc.test(d)||_c.test(d)){a+=1;break}s.push(d);}let c=s.join(`
|
|
43
|
-
`).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${Wn(r.title)}"`:"",r.color!==void 0?`data-callout-color="${Wn(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${Wn(r.icon)}"`:"",`data-callout-body="${jc(c)}"`].filter(Boolean).join(" ")}></div>`,next:a}},ys=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
|
|
44
|
-
`),n=[],o=0,r=false;for(;o<t.length;)if(hs.test(t[o])){let s=Uc(t,o);n.push(s.replacement),o=s.next,r=true;}else n.push(t[o]),o+=1;return r?n.join(`
|
|
45
|
-
`):e},Cs=()=>()=>{};var Zc=/^([a-zA-Z][a-zA-Z\d+\-.]*:)/,Kc=e=>new Set(e.map(t=>t.trim().toLowerCase()).filter(t=>t.length>0).map(t=>t.endsWith(":")?t:`${t}:`));function qc(e,t){if(e.children.length!==1)return false;let[n]=e.children;if(n.type!=="text")return false;let o=Zc.exec(e.url);if(!o)return false;let r=o[1].toLowerCase();return t.has(r)?r==="mailto:"?e.url===`mailto:${n.value}`:e.url===n.value||e.url===`${r}//${n.value}`:false}var ws=(e=[])=>{let t=Kc(e);return n=>{t.size!==0&&visit(n,"link",(o,r,s)=>{if(!(!s||r===void 0)&&qc(o,t))return s.children.splice(r,1,...o.children),r});}};var Jc={NOTE:{icon:"info",kind:"note",title:"Note",iconPaths:[{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]},TIP:{icon:"light-bulb",kind:"tip",title:"Tip",iconPaths:[{d:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"}]},IMPORTANT:{icon:"report",kind:"important",title:"Important",iconPaths:[{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}]},WARNING:{icon:"alert",kind:"warning",title:"Warning",iconPaths:[{d:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",fillRule:"evenodd"}]},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPaths:[{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25a.749.749 0 0 1-.53.22H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]}},Yc=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,vs=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let n="";for(let o of t)n+=vs(o);return n},Qc=e=>{let t=e.iconPaths.map(n=>`<path d="${n.d}"${n.fillRule?` fill-rule="${n.fillRule}"`:""}></path>`).join("");return {type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">${t}</svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"],"data-alert-type":e.kind}}}},ed=e=>{var m,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let n=t.children[0];if(!n||n.type!=="text")return;let o=vs(n).trimStart(),r=o.match(Yc);if(!r)return;let s=Jc[r[1].toUpperCase()],a=o.slice(r[0].length),c=t.children.slice(1);if(a.trim().length===0&&c.length===0&&e.children.length===1)return;let l=[Qc(s)],i=[];a.length>0&&i.push({type:"text",value:a});let d=c;return ((m=d[0])==null?void 0:m.type)==="break"&&(d=d.slice(1)),i.push(...d),i.length>0&&i.some(y=>y.type!=="text"||y.value.trim().length>0)&&l.push({type:"paragraph",children:i}),l.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=l,SKIP},xs=()=>e=>{visit(e,"blockquote",ed);};var cd=/^[ \t]*<[\w!/?-]/,dd=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,md=e=>typeof e!="string"||e.length===0||!cd.test(e)?e:e.replace(dd,"$1"),Ts,Es,Rs,Ms,Is,Ns,Ls,As,Ds,Hs,Os,Bs,_s,Qt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Es=(Ts=defaultSchema.protocols)==null?void 0:Ts.href)!=null?Es:[],"tel","streamdown"],src:[...(Ms=(Rs=defaultSchema.protocols)==null?void 0:Rs.src)!=null?Ms:[],"streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(Ns=(Is=defaultSchema.attributes)==null?void 0:Is.div)!=null?Ns:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(As=(Ls=defaultSchema.attributes)==null?void 0:Ls.p)!=null?As:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(Hs=(Ds=defaultSchema.attributes)==null?void 0:Ds.svg)!=null?Hs:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(Bs=(Os=defaultSchema.attributes)==null?void 0:Os.path)!=null?Bs:[],"d","fillRule"]},tagNames:[...(_s=defaultSchema.tagNames)!=null?_s:[],"svg","path"]},Zn={raw:Fo,sanitize:[Vs,Qt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},ud={gfm:[ld,{}],githubAlerts:xs,containerAlerts:Cs,codeMeta:bs},Ps=Object.values(Zn),pd=Object.values(ud),Ss=new WeakMap;function fd(e){var r;let t=Ss.get(e);if(t)return t;let n={...Qt,tagNames:[...(r=Qt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...Qt.attributes,...e}},o=[Zn.raw,[Vs,n],Zn.harden];return Ss.set(e,o),o}var gd={block:" \u258B",circle:" \u25CF"},bd=["github-light","github-dark"],hd={enabled:true},$s=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:o,isIncomplete:r,dir:s,animatePlugin:a,...c})=>{useLayoutEffect(()=>{a==null||a.commit();}),a==null||a.setAnimateCodeBlocks(r);let l=typeof e=="string"&&n?md(e):e,i=jsx(dt,{...c,children:l});return jsx(fn.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:i}):i})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let 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||!!e.animatePlugin!=!!t.animatePlugin)});$s.displayName="Block";var yd=memo(({children:e$1,mode:t="streaming",dir:n,parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Ps,remarkPlugins:c$1=pd,className:l,shikiTheme:i,mermaid:d,openscad:m,plantuml:u,codeBlockMaxHeight:y=400,controls:p=true,isAnimating:b=false,scrollable:h$1,tableMaxHeight:f=300,animated:g$1,BlockComponent:C=$s,parseMarkdownIntoBlocksFn:x=Et,caret:S,listStyle:E="hierarchical",calloutIcon:R,calloutStyle:D,plugins:P,remend:M,linkSafety:V=hd,portal:j,lineNumbers:$=true,allowedTags:Z,literalTagContent:F,dataOnlyTags:U,disableAutolinkProtocols:L,translations:G,icons:K,prefix:W,onAnimationStart:q,onAnimationEnd:Q,...ie})=>{let se=useId(),ae=useMemo(()=>c(W),[W]),le=useRef(null),oe=useRef(q),Ue=useRef(Q);oe.current=q,Ue.current=Q,useEffect(()=>{var A,ee,J;if(t==="static")return;let k=le.current;if(le.current=b,k===null){b&&((A=oe.current)==null||A.call(oe));return}b&&!k?(ee=oe.current)==null||ee.call(oe):!b&&k&&((J=Ue.current)==null||J.call(Ue));},[b,t]);let I=useMemo(()=>Z?Object.keys(Z):[],[Z]),z=useMemo(()=>{if(!(U!=null&&U.length))return I;let k=new Set(U.map(A=>A.toLowerCase()));return I.filter(A=>!k.has(A.toLowerCase()))},[I,U]),Te=useRef(null),Me=useMemo(()=>{if(typeof e$1!="string")return "";let k=e$1;return F&&F.length>0&&(k=is(k,F)),z.length>0&&(k=ls(k,z)),k=ys(k),k},[e$1,z,F]),ce=useMemo(()=>{let k=t==="streaming"?Te.current:null,A=jn(Me,k,x);if(Te.current=t==="streaming"?A:null,!(t==="streaming"&&o)||A.blocks.length===0)return A.blocks;let ee=A.blocks.length-1,J=A.blocks[ee],ve=id(J,M);if(ve===J)return A.blocks;let De=A.blocks.slice();return De[ee]=ve,De},[Me,x,t,o,M]),We=useMemo(()=>g$1===true?"true":g$1?JSON.stringify(g$1):"",[g$1]),ue=useRef(null),ot=useRef([]),Ie=useRef([]),qn=useRef(null),tn=useRef("");if(We){if(tn.current!==We){tn.current=We;let k=We!=="true"?g$1.maxBacklogMs:void 0;ue.current=mn({maxBacklogMs:k}),ot.current=[],Ie.current=[];}else ue.current||(ue.current=mn());b&&ue.current&&ue.current.beginPass(ue.current.now());}else ue.current=null,ot.current=[],Ie.current=[],tn.current="";useLayoutEffect(()=>{var k;b&&((k=ue.current)==null||k.commitPass());});let Ne=useDeferredValue(ce),Le=useMemo(()=>{if(t!=="streaming"||ue.current||Ne===ce||Ne.length===0)return ce;let k=Ne.length,A=ce.length;if(A===0)return Ne;if(k!==A)return ce;for(let J=0;J<k-1;J+=1)if(Ne[J]!==ce[J])return ce;let ee=Ne.slice();return ee[k-1]=ce[A-1],ee},[ce,Ne,t]),nn=useMemo(()=>n==="auto"?Le.map(Tt):void 0,[Le,n]),[Xn]=useState(()=>co(se)),Ws=useMemo(()=>Xn(Le),[Le,Xn]),Zs=useMemo(()=>G?JSON.stringify(G):"",[G]),Gn=useMemo(()=>({...g,...G}),[Zs]),Mt=useMemo(()=>{let{inlineCode:k,...A}=s!=null?s:{},ee={...Gr,...A};if(k){let J=ee.code;ee.code=ve=>"data-block"in ve?J?createElement(J,ve):null:createElement(k,ve);}return ee},[s]),It=useMemo(()=>{let k=[];return P!=null&&P.cjk&&(k=[...k,...P.cjk.remarkPluginsBefore]),k=[...k,...c$1],L&&L.length>0&&(k=[...k,[ws,L]]),P!=null&&P.cjk&&(k=[...k,...P.cjk.remarkPluginsAfter]),P!=null&&P.math&&(k=[...k,P.math.remarkPlugin]),k},[c$1,P==null?void 0:P.math,P==null?void 0:P.cjk,L]),Ae=useMemo(()=>{let k=a;return Z&&Object.keys(Z).length>0&&a===Ps&&(k=fd(Z)),z.length>0&&(k=[...k,[gs,z,F!=null?F:[]]]),F&&F.length>0&&(k=[...k,[fs,F]]),U&&U.length>0&&(k=[...k,[us,U]]),P!=null&&P.math&&(k=[...k,P.math.rehypePlugin]),n==="auto"&&t==="static"&&(k=[...k,ms]),k},[a,P==null?void 0:P.math,Z,z,F,U,n,t]),Jn=useMemo(()=>{var k,A;return {calloutIcon:R,calloutStyle:D,codeBlockMaxHeight:y,shikiTheme:(A=i!=null?i:(k=P==null?void 0:P.code)==null?void 0:k.getThemes())!=null?A:bd,controls:p,isAnimating:b,lineNumbers:$,listStyle:E,mode:t,mermaid:d,openscad:m,plantuml:u,linkSafety:V,portal:j,scrollable:h$1,tableMaxHeight:f,components:Mt,remarkPlugins:It,rehypePlugins:Ae}},[R,D,y,i,p,b,$,E,t,d,m,u,V,j,h$1,P==null?void 0:P.code,f,Mt,It,Ae]),Ks=useMemo(()=>S&&b?{"--streamdown-caret":`"${gd[S]}"`}:void 0,[S,b]),qs=k=>{let A=null;if(ue.current&&b){if(!ot.current[k]){let J=We&&We!=="true"?g$1:{},{maxBacklogMs:ve,...De}=J;ot.current[k]=Lt({...De,timeline:ue.current});}A=ot.current[k];}qn.current!==Ae&&(Ie.current=[],qn.current=Ae),A&&!Ie.current[k]&&(Ie.current[k]=[...Ae,A.rehypePlugin]);let ee=A&&Ie.current[k]?Ie.current[k]:Ae;return {blockAnimatePlugin:A,blockRehypePlugins:ee}};return t==="static"?jsx(h.Provider,{value:Gn,children:jsx(Ot.Provider,{value:P!=null?P:null,children:jsx(T.Provider,{value:Jn,children:jsx(wn,{icons:K,children:jsx(e.Provider,{value:ae,children:jsx("div",{className:ae("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",l),dir:n==="auto"?void 0:n,children:jsx(dt,{components:Mt,rehypePlugins:Ae,remarkPlugins:It,...ie,children:Me})})})})})})}):jsx(h.Provider,{value:Gn,children:jsx(Ot.Provider,{value:P!=null?P:null,children:jsx(T.Provider,{value:Jn,children:jsx(wn,{icons:K,children:jsx(e.Provider,{value:ae,children:jsxs("div",{className:ae("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",S?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,l),"data-streamdown":"container",style:Ks,children:[Le.length===0&&S&&b&&jsx("span",{}),Le.map((k,A)=>{var Yn;let ee=A===Le.length-1,J=b&&ee&&Jr(k),{blockAnimatePlugin:ve,blockRehypePlugins:De}=qs(A);return jsx(C,{animatePlugin:ve,components:Mt,content:k,dir:(Yn=nn==null?void 0:nn[A])!=null?Yn:n!=="auto"?n:void 0,index:A,isIncomplete:J,rehypePlugins:De,remarkPlugins:It,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:o,...ie},Ws[A])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&e.disableAutolinkProtocols===t.disableAutolinkProtocols&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);yd.displayName="Streamdown";var js=/[(){}[\]]/,wd=/[\s;]/,vd=/^[\w-]+$/,xd=/:::[\w-]+\s*$/,kd=/^[/\\]/,Pd=/[/\\]$/,Sd=/("[^"]*")/,Td=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],Rt=e=>`"${e.replace(/"/g,"#quot;")}"`,Ed=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),Rd=e=>{var o,r,s,a;let t=e.split(`
|
|
46
|
-
`),n=0;if(((o=t[n])==null?void 0:o.trim())==="---"){for(n+=1;n<t.length&&((r=t[n])==null?void 0:r.trim())!=="---";)n+=1;n+=1;}for(;n<t.length;){let c=(a=(s=t[n])==null?void 0:s.trim())!=null?a:"";if(c&&!c.startsWith("%%")){let l=c.split(wd,1)[0];return l==="mindmap"?"mindmap":l==="flowchart"||l==="graph"?"flowchart":null}n+=1;}return null},Md=e=>{for(let[t,n]of Td){let o=e.indexOf(t);if(o===-1||!e.endsWith(n))continue;let r=e.slice(0,o);if(r&&!vd.test(r))continue;let s=e.slice(o+t.length,e.length-n.length);if(!(s.includes(n)&&n!==t))return {id:r,open:t,close:n,inner:s}}return null},Id=e=>{let t=e.length-e.trimStart().length,n=e.slice(0,t),o=e.trim();if(!o||o.startsWith("%%")||o.startsWith("::icon"))return e;let r=Md(o);if(r)return !Ed(r.inner)&&(js.test(r.inner)||r.inner.includes('"'))?`${n}${r.id}${r.open}${Rt(r.inner)}${r.close}`:e;if(js.test(o)){let s=o.replace(xd,"").trimEnd();return `${n}[${Rt(s)}]`}return e},Nd=e=>{let t=e.split(`
|
|
47
|
-
`),n=false;return t.map(o=>n?Id(o):(o.trim()&&(n=true),o)).join(`
|
|
48
|
-
`)},Ld=e=>e.startsWith("(")&&e.endsWith(")")||kd.test(e)||Pd.test(e),Kn=(e,t)=>e.split(Sd).map((n,o)=>o%2===0?t(n):n).join(""),Ad=e=>{if(e.trim().startsWith("%%"))return e;let t=Kn(e,n=>n.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(o,r)=>Ld(r)?o:`[${Rt(r)}]`));return t=Kn(t,n=>n.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(o,r)=>`{${Rt(r)}}`)),t=Kn(t,n=>n.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(o,r)=>`|${Rt(r)}|`)),t},Dd=e=>e.split(`
|
|
49
|
-
`).map(Ad).join(`
|
|
50
|
-
`),Us=e=>{let t=Rd(e);if(!t)return null;let n=t==="mindmap"?Nd(e):Dd(e);return n===e?null:n};var Bd=async(e,t,n)=>{try{return await e.render(t,n)}catch(o){let r=Us(n);if(!r)throw o;try{return await e.render(`${t}-autofix`,r)}catch(s){throw o}}},Go=({chart:e,className:t,config:n,fullscreen:o=false,showControls:r=true})=>{let s=f(),a=i(),[c,l]=useState(null),[i$1,d]=useState(false),[m,u]=useState(""),[y,p]=useState(null),[b,h]=useState(""),[f$1,g]=useState(0),{mermaid:C}=useContext(T),x=Xe(),S=C==null?void 0:C.errorComponent,{shouldRender:E,containerRef:R}=Ze({immediate:o});if(useEffect(()=>{if(!E)return;if(!x){l(a.mermaidPluginMissing);return}(async()=>{try{l(null),d(!0);let M=x.getMermaid(n),V=e.split("").reduce((U,L)=>(U<<5)-U+L.charCodeAt(0)|0,0),j=`mermaid-${Math.abs(V)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:$}=await Bd(M,j,e),Z=ut($),F=o?$:_t($);u(F),p(Z),h(F);}catch(M){if(!(b||m)){let V=M instanceof Error?M.message:a.mermaidRenderFailed;l(V);}}finally{d(false);}})();},[e,n,f$1,E,x]),!(E||m||b))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:R});if(i$1&&!m&&!b)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:R,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:a.diagramLoading})]})});if(c&&!m&&!b){let P=()=>g(M=>M+1);return S?jsx("div",{ref:R,children:jsx(S,{chart:e,error:c,retry:P})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:R,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:[a.mermaidErrorLabel,": ",c]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:a.showCode}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let D=m||b;return jsx("div",{className:s(o?"size-full":"max-h-[min(70vh,40rem)] w-full",t),"data-streamdown":"mermaid",ref:R,children:jsx(Ut,{className:s(o?"size-full overflow-hidden":"max-h-[min(70vh,40rem)] overflow-hidden",t),contentSize:y,fitKey:e,fullscreen:o,isAutoFit:true,maxZoom:3,minZoom:.1,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":a.mermaidChart,className:s("flex justify-center",o?"size-full items-center":null),dangerouslySetInnerHTML:{__html:D},role:"img"})})})};export{Et as A,jn as B,md as C,Zn as D,ud as E,$s as F,yd as G,na as a,Lt as b,rt as c,st as d,go as e,bn as f,yn as g,Au as h,Cn as i,Ke as j,xn as k,qe as l,T as m,jo as n,Go as o,tr as p,ar as q,Qe as r,je as s,Hn as t,Zt as u,et as v,vt as w,ki as x,xt as y,Tt as z};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {m,h,e}from'./chunk-FYGB27SX.js';import'./chunk-EMUDB4GM.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e$1,maxHeight:h$1,raw:t,className:m$1,startLine:d,lineNumbers:a,...c})=>{let{shikiTheme:l}=useContext(m),i=h(),[p,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let g=i.highlight({code:s,language:e$1,themes:l},H=>{o(H);});g&&o(g);},[s,e$1,l,i,t]),jsx(e,{className:m$1,language:e$1,lineNumbers:a,maxHeight:h$1,result:p,startLine:d,...c})};export{x as HighlightedCodeBlockBody};
|
package/dist/mermaid-HNKQSOWL.js
DELETED