@yuriai/web 0.2.32-beta.9 → 0.2.33
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/assets/{AssistantContactStatus-U2ayATMD.js → AssistantContactStatus-BecTSK5f.js} +3 -3
- package/dist/assets/{AssistantUnreadBadge-C7WyywGy.js → AssistantUnreadBadge-DXBINpQi.js} +1 -1
- package/dist/assets/{AssistantView-C6T1jtXQ.js → AssistantView-CsTe7SbK.js} +1 -1
- package/dist/assets/{DiagramView-IgpFr7Ad.js → DiagramView-xR1d8Ci2.js} +1 -1
- package/dist/assets/{GuiPluginSurface-Xon3K0Ye.js → GuiPluginSurface-DWRx9_eT.js} +1 -1
- package/dist/assets/MarkdownRenderer-WSxkmNai.js +2 -0
- package/dist/assets/MarkdownRendererImpl-CVuPLz_2.js +10 -0
- package/dist/assets/{MarkstreamRendererImpl-EpBnVy9J.css → MarkstreamRendererImpl-C6aiJnjl.css} +1 -1
- package/dist/assets/MarkstreamRendererImpl-ChHTqL5i.js +3 -0
- package/dist/assets/{MobileDetailNavigation-AhJrPvbe.js → MobileDetailNavigation-CR8A8U_9.js} +1 -1
- package/dist/assets/{MobileShareBridge-CU2d4BFH.js → MobileShareBridge-HTePwQfS.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-CPjiwmHB.js → MobileTabPageHeader-DefPdEd9.js} +1 -1
- package/dist/assets/{MultiRunWindow-D-gvaDXb.js → MultiRunWindow-BcZ0T4aM.js} +1 -1
- package/dist/assets/{SettingsView-CxSuGFL6.js → SettingsView-23-CPGGR.js} +1 -1
- package/dist/assets/{SettingsWindow-CCJwAnC3.js → SettingsWindow-BP17xUN4.js} +1 -1
- package/dist/assets/{SetupTourDialog-CK1v0uRP.js → SetupTourDialog-DpBf7CQD.js} +1 -1
- package/dist/assets/{TerminalView-DlhVWUe8.js → TerminalView-D63MDq0o.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Ds7SKZHj.js → ToolOutputDialog-GHLioHaB.js} +1 -1
- package/dist/assets/{VoiceSettings-BE8lkEwf.js → VoiceSettings-CE3EP3rH.js} +1 -1
- package/dist/assets/{appThemeRegistry-CbefbcVq.js → appThemeRegistry-CH4WssKX.js} +1 -1
- package/dist/assets/{capgoAdapter-d6YK7KL9.js → capgoAdapter-Dy6n1WSE.js} +1 -1
- package/dist/assets/{gitApi-DoKis0bk.js → gitApi-C9-qJDQ6.js} +1 -1
- package/dist/assets/{insertionBoundaries-B8jk0_j1.js → insertionBoundaries-DBgOjaGM.js} +1 -1
- package/dist/assets/{main-Co1xRLXl.js → main-C9v4tzOp.js} +2 -2
- package/dist/assets/{main-CAvOV0iK.js → main-DqXuTHzy.js} +4 -4
- package/dist/assets/{mcpQueries-D4l8oM5L.js → mcpQueries-BtTn7vvF.js} +1 -1
- package/dist/assets/{miniChat-fZwKyemy.js → miniChat-bbNf-k6A.js} +2 -2
- package/dist/assets/{mobile-DFfwrMgN.js → mobile-C90aX0Ai.js} +2 -2
- package/dist/assets/{mobileBackNavigation-B0VjuaZ7.js → mobileBackNavigation-BdgpYYzc.js} +1 -1
- package/dist/assets/{multirun-CYlgZpf6.js → multirun-CXgyUUR_.js} +1 -1
- package/dist/assets/{native-config-CqRupvkq.js → native-config-Npmx-FHi.js} +1 -1
- package/dist/assets/{projectMeta-BYt0k5kv.js → projectMeta-Byov-Bf8.js} +1 -1
- package/dist/assets/{pwa-DJfe-p9M.js → pwa-BPywK9hc.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-BC6N63GR.js → queue-abort-optimistic-Cd9goCtP.js} +1 -1
- package/dist/assets/{readiness-B0MqQAM_.js → readiness-Ba0wqXJe.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CL-voe-E.js → renderElectronMiniChatApp-Dgj_tRzV.js} +2 -2
- package/dist/assets/{renderMobileApp-BgIQU-Mn.js → renderMobileApp-muVQ8WGb.js} +4 -4
- package/dist/assets/{runtimeConfig-BpTQpEdh.js → runtimeConfig-YOnCHT8o.js} +1 -1
- package/dist/assets/runtimeEndpointReset-BP4JwHFJ.css +1 -0
- package/dist/assets/{runtimeEndpointReset-DsL19kc6.js → runtimeEndpointReset-BkJyMZon.js} +3 -3
- package/dist/assets/{sessionLookup-BNBqtDm8.js → sessionLookup-BjxeNni8.js} +1 -1
- package/dist/assets/{speechSettingsQueries-CdSoAwxA.js → speechSettingsQueries-CvDICLsw.js} +1 -1
- package/dist/assets/{src-w7q1kIVl.css → src-GtPQ8f4o.css} +1 -1
- package/dist/assets/types-BkSficP0.js +2 -0
- package/dist/assets/{useAppFontEffects-BVlUZ0h3.js → useAppFontEffects-DoOyrAD1.js} +28 -28
- package/dist/assets/{useDesktopWindowControlsLayout-Clo0JUjg.js → useDesktopWindowControlsLayout-Dnn-eOUA.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DEH8TUjx.js → useEffectiveDirectory-DouDG4ZI.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BvCMbmxg.js → useMobileNavigationStore-C2mIlnz9.js} +4 -4
- package/dist/assets/{usePluginsStore-DcqFju9y.js → usePluginsStore-CePF_bcX.js} +1 -1
- package/dist/assets/useStreamingTextThrottle-VhgGU_te.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-C7aY9AZe.js → useWorkerHighlightedLines-D0Nf66Jj.js} +1 -1
- package/dist/assets/{vendor-markstream-react-DfLaSG3W.js → vendor-markstream-react-6zxyQLCD.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +6 -6
- package/package.json +1 -1
- package/server/index.js +1 -0
- package/server/lib/opencode/DOCUMENTATION.md +9 -0
- package/server/lib/opencode/proxy.js +29 -4
- package/server/lib/opencode/proxy.test.js +85 -1
- package/server/lib/opencode/server-utils-runtime.js +2 -0
- package/dist/assets/MarkdownRenderer-Ch6gZ9IN.js +0 -2
- package/dist/assets/MarkdownRendererImpl-DsZCkMxR.js +0 -10
- package/dist/assets/MarkstreamRendererImpl-BEXDd_Ye.js +0 -3
- package/dist/assets/runtimeEndpointReset-BL9hV6J1.css +0 -1
- package/dist/assets/types-9GpBCyXz.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./runtime-switch-DEZ1K7qW.js";import{n}from"./runtime-fetch-D0YWp3FJ.js";import{a as r,i,r as a}from"./vendor-zustand-vDaAPGfl.js";import{o,ot as s,s as c}from"./vendor-base-ui-CzHs0bHY.js";import{At as l}from"./gitApiHttp-MWsHNHuo.js";import{x as u}from"./useUIStore-BerIUSLP.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{s as f}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as p,i as m,o as h}from"./queryRuntime-2dx7jbt9.js";import{f as g,r as _,t as v}from"./button-C-gRcs_2.js";import{ga as y,va as b}from"./useMobileNavigationStore-BvCMbmxg.js";var x=d(),S=s();function ee(e){let t=(0,x.c)(17),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:s}=e,l=i!==void 0&&i,{t:u}=g(),d;t[0]!==n||t[1]!==l||t[2]!==r?(d=e=>{!l&&e!==n&&r(e)},t[0]=n,t[1]=l,t[2]=r,t[3]=d):d=t[3];let f;t[4]===s?f=t[5]:(f=_(`yuri-settings-switch`,s),t[4]=s,t[5]=f);let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[!1,!0],t[6]=p):p=t[6];let m;t[7]!==n||t[8]!==u?(m=p.map(e=>(0,S.jsxs)(c,{value:e,nativeButton:!0,render:(0,S.jsx)(v,{variant:`ghost`,size:`xs`}),className:`yuri-settings-switch-option`,children:[n===e&&(0,S.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,S.jsx)(`span`,{className:`relative`,children:u(e?`settings.switch.on`:`settings.switch.off`)})]},String(e))),t[7]=n,t[8]=u,t[9]=m):m=t[9];let h;return t[10]!==a||t[11]!==n||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==m?(h=(0,S.jsx)(o,{value:n,onValueChange:d,disabled:l,"aria-label":a,"aria-orientation":`horizontal`,"data-slot":`settings-switch`,className:f,onClick:w,onKeyDown:C,children:m}),t[10]=a,t[11]=n,t[12]=l,t[13]=d,t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function C(e){return e.stopPropagation()}function w(e){return e.stopPropagation()}function T(e){let t=(0,x.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=_(`flex shrink-0 items-center justify-between gap-3 py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,S.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,S.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function E(e){let t=(0,x.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=_(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,S.jsx)(T,{className:`py-0`,actions:r,children:n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=_(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,S.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,S.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let v;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(v=(0,S.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=v):v=t[20],v}function D(e){let t=(0,x.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,S.jsx)(O,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,S.jsx)(E,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function O(e){let t=(0,x.c)(25),{label:n,children:r,description:i,footer:a,itemId:o,className:s,copyClassName:c,controlClassName:l}=e,u;t[0]===s?u=t[1]:(u=_(`yuri-settings-group-row yuri-settings-split-row`,s),t[0]=s,t[1]=u);let d;t[2]===c?d=t[3]:(d=_(`yuri-settings-split-row-copy`,c),t[2]=c,t[3]=d);let f;t[4]===n?f=t[5]:(f=n?(0,S.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=f);let p;t[6]===i?p=t[7]:(p=i?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=p);let m;t[8]!==d||t[9]!==f||t[10]!==p?(m=(0,S.jsxs)(`div`,{className:d,children:[f,p]}),t[8]=d,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]===l?h=t[13]:(h=_(`yuri-settings-split-row-control`,l),t[12]=l,t[13]=h);let g;t[14]!==r||t[15]!==h?(g=(0,S.jsx)(`div`,{"data-settings-value":``,className:h,children:r}),t[14]=r,t[15]=h,t[16]=g):g=t[16];let v;t[17]===a?v=t[18]:(v=a?(0,S.jsx)(`div`,{"data-slot":`settings-row-footer`,className:`col-span-full min-w-0`,children:a}):null,t[17]=a,t[18]=v);let y;return t[19]!==o||t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==v?(y=(0,S.jsxs)(`div`,{"data-settings-item":o,className:u,children:[m,g,v]}),t[19]=o,t[20]=u,t[21]=m,t[22]=g,t[23]=v,t[24]=y):y=t[24],y}function te(e){let t=(0,x.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=ne,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=_(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,v=u||void 0,y,b;t[7]===f?(y=t[8],b=t[9]):(y=e=>{p(e.target)||f()},b=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=y,t[9]=b);let C;t[10]===i?C=t[11]:(C=(0,S.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=C);let w;t[12]===o?w=t[13]:(w=o?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=w);let T;t[14]!==w||t[15]!==C?(T=(0,S.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[C,w]}),t[14]=w,t[15]=C,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(E=(0,S.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,S.jsx)(ee,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=E):E=t[21];let D;return t[22]!==n||t[23]!==s||t[24]!==T||t[25]!==E||t[26]!==h||t[27]!==g||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,S.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":v,onClick:y,onKeyDown:b,children:[T,E]}),t[22]=n,t[23]=s,t[24]=T,t[25]=E,t[26]=h,t[27]=g,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function ne(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var k=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},A=()=>{let e=l.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},re=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},ie=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},ae=e=>({source:re(e.source),state:ie(e.state)}),oe=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>ae(e))};async function j(e,t){return oe((await A().list(k(e),t?{signal:t}:void 0))?.data)}async function se(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await A().update({...k(e),targets:[r]},n?{signal:n}:void 0)}function ce(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var le=1500,M=e=>e?.trim()||null,N=(t,n=e())=>h.plugins.list(t,n),P=(t,n,r=!1,i=e())=>h.plugins.registry(t,n,r,i),F=(t,n=e())=>h.plugins.runtime(t,n),I=0,L=()=>(I+=1,I),R=(e,t,n)=>e.getQueryData(F(t,n)),z=(t=y(),r=e())=>{let i=M(t);return{queryKey:N(i,r),queryFn:async({signal:e})=>{let t=await n(he(`/api/config/plugins`,i),{headers:U(i),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let r=await t.json();return{entries:r.entries??[],files:r.files??[]}},staleTime:5e3,retry:2}},B=(t,r,i=!1,a=e(),o=!1)=>{let s=M(t),c=m(r);return{queryKey:o?[...P(s,c,i,a),`details`]:P(s,c,i,a),queryFn:async({signal:e})=>{let t={};for(let r of _e(c)){let a=ge(r,i,s),c=await n(o?`${a}&details=true`:a,{headers:U(s),signal:e});if(!c.ok)throw Error(`Failed to load plugin registry info`);let l=await c.json();for(let e of l.results??[])t[e.spec]=e}return t},staleTime:i?0:3e5,retry:2}},ue=(t=y(),n=e())=>{let r=M(t);return{queryKey:F(r,n),queryFn:async({signal:e})=>{let t=L(),i=await j(r,e);if(t!==I){let e=R(p,r,n);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},de=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=b(ve),a;t[2]===i?a=t[3]:(a=z(M(i)??M(l.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},fe=(e,t)=>{let n=(0,x.c)(6),r=t!==void 0&&t,i=b(ye),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=B(M(i)??M(l.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),f(o)},V=()=>{let e=(0,x.c)(2),t=b(be),n;return e[0]===t?n=e[1]:(n=M(t)??M(l.getDirectory()),e[0]=t,e[1]=n),n},pe=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=V(),a;t[2]===i?a=t[3]:(a=ue(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},H=async(t,n,r)=>{let i=M(n);return e()===r?t.fetchQuery({...z(i,r),staleTime:0}):t.getQueryData(N(i,r))??{entries:[],files:[]}},me=async(t,n,r)=>{let i=M(n);if(e()!==r)return R(t,i,r);let a=L(),o=await j(i);return a!==I||e()!==r?R(t,i,r):(t.setQueryData(F(i,r),o),o)};function he(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ge(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function _e(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>le){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function U(e){return e?{"x-opencode-directory":e}:void 0}function ve(e){return e.getActiveProject?.()?.path??null}function ye(e){return e.getActiveProject?.()?.path??null}function be(e){return e.getActiveProject?.()?.path??null}var W=()=>{try{let e=b.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=l.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},xe=5e3,Se=`__default__`,G=new Map,K=new Map,Ce=1500,q=e=>e?.trim()||Se,we=e=>{G.delete(q(e))},J=r()(a(i((r,i)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:e=>r({selectedId:e}),setDraft:e=>r({draft:e}),loadPlugins:async n=>{let a=W(),o=e(),s=t(),c=()=>o===e()&&s===t()&&a===W(),l=q(a),u=Date.now(),d=G.get(l)??0,f=i().entries.length>0||i().files.length>0;if(!n?.force&&f&&u-d<xe)return!0;let m=K.get(l);if(!n?.force&&m)return m;let h=(async()=>{r({isLoading:!0});try{let e=n?.force?await H(p,a,o):await p.fetchQuery(z(a,o));return c()?(r({entries:e.entries??[],files:e.files??[],isLoading:!1}),G.set(l,Date.now()),n?.force||i().loadRegistryInfo(),!0):!1}catch(e){return console.error(`[PluginsStore] Failed to load plugins:`,e),c()&&r({isLoading:!1}),!1}})();K.set(l,h);try{return await h}finally{K.delete(l)}},loadRegistryInfo:async e=>{let t=Ee(e?.specs??i().entries.map(e=>e.spec));if(t.length===0){r({isLoadingRegistry:!1});return}r({isLoadingRegistry:!0});try{let a=W(),o={...i().registryInfo};for(let r of De(t)){let t=await n(Te(r,e?.force===!0,a),{headers:X(a)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let i=await $(t);for(let e of i.results??[])o[e.spec]=e}r({registryInfo:o,isLoadingRegistry:!1})}catch(e){console.error(`[PluginsStore] Failed to load plugin registry info:`,e),r({isLoadingRegistry:!1})}},updateToLatest:async e=>{let t=i().entries.find(t=>t.id===e);if(!t)return{ok:!1};let n=i().registryInfo[t.spec];return!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion?{ok:!1}:await i().updateEntry(e,{spec:`${n.name}@${n.latestVersion}`})},createEntry:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/entry`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(Oe(e))}));return t.ok&&i().loadRegistryInfo({specs:[e.spec],force:!0}),t},updateEntry:async(t,r)=>{let a=(p.getQueryData(z(W(),e()).queryKey)?.entries??i().entries).find(e=>e.id===t),o=a?.spec,s=r.spec??o,c=await Q(async e=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(t)}`,e),{method:`PATCH`,headers:Z(e),body:JSON.stringify(Oe(r))}),a&&s?{...a,spec:s}:void 0);return c.ok&&s&&i().loadRegistryInfo({specs:[s],force:!0}),c},deleteEntry:async e=>{let t=i().entries.find(t=>t.id===e),a=await Q(async t=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));if(a.ok&&i().selectedId===e&&r({selectedId:null}),a.ok&&t){let e={...i().registryInfo};delete e[t.spec],r({registryInfo:e})}return a},readFile:async e=>{try{let t=W(),r=await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:X(t)});if(!r.ok)throw Error(`Failed to read plugin file`);return await $(r)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Q(async t=>await n(Y(`/api/config/plugins/file`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>Q(async r=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,r),{method:`PUT`,headers:Z(r),body:JSON.stringify(t)})),deleteFile:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));return t.ok&&i().selectedId===e&&r({selectedId:null}),t},getById:e=>i().entries.find(t=>t.id===e)??i().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:u(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Y(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Te(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Ee(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function De(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>Ce?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function X(e){return e?{"x-opencode-directory":e}:void 0}function Z(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Oe(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Q(n,r){let i=e(),a=t();try{let o=W(),s=await n(o),c=await $(s).catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update plugin configuration`);if(i!==e()||a!==t())return{ok:!0};we(o);let l=await H(p,o,i);if(o===W()&&i===e()&&a===t()){let e=r&&J.getState().selectedId===r.id?l.entries.find(e=>e.spec===r.spec&&e.scope===r.scope&&e.sourcePath===r.sourcePath):void 0;J.setState({entries:l.entries,files:l.files,...e?{selectedId:e.id}:{}}),G.set(q(o),Date.now())}return{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function $(e){return await e.json()}export{V as a,de as c,D as d,E as f,ee as g,T as h,me as i,ce as l,te as m,B as n,fe as o,O as p,z as r,pe as s,J as t,se as u};
|
|
1
|
+
import{i as e,n as t}from"./runtime-switch-DEZ1K7qW.js";import{n}from"./runtime-fetch-D0YWp3FJ.js";import{a as r,i,r as a}from"./vendor-zustand-vDaAPGfl.js";import{o,ot as s,s as c}from"./vendor-base-ui-CzHs0bHY.js";import{At as l}from"./gitApiHttp-MWsHNHuo.js";import{x as u}from"./useUIStore-BerIUSLP.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{s as f}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as p,i as m,o as h}from"./queryRuntime-2dx7jbt9.js";import{f as g,r as _,t as v}from"./button-C-gRcs_2.js";import{ga as y,va as b}from"./useMobileNavigationStore-C2mIlnz9.js";var x=d(),S=s();function ee(e){let t=(0,x.c)(17),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:s}=e,l=i!==void 0&&i,{t:u}=g(),d;t[0]!==n||t[1]!==l||t[2]!==r?(d=e=>{!l&&e!==n&&r(e)},t[0]=n,t[1]=l,t[2]=r,t[3]=d):d=t[3];let f;t[4]===s?f=t[5]:(f=_(`yuri-settings-switch`,s),t[4]=s,t[5]=f);let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[!1,!0],t[6]=p):p=t[6];let m;t[7]!==n||t[8]!==u?(m=p.map(e=>(0,S.jsxs)(c,{value:e,nativeButton:!0,render:(0,S.jsx)(v,{variant:`ghost`,size:`xs`}),className:`yuri-settings-switch-option`,children:[n===e&&(0,S.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,S.jsx)(`span`,{className:`relative`,children:u(e?`settings.switch.on`:`settings.switch.off`)})]},String(e))),t[7]=n,t[8]=u,t[9]=m):m=t[9];let h;return t[10]!==a||t[11]!==n||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==m?(h=(0,S.jsx)(o,{value:n,onValueChange:d,disabled:l,"aria-label":a,"aria-orientation":`horizontal`,"data-slot":`settings-switch`,className:f,onClick:w,onKeyDown:C,children:m}),t[10]=a,t[11]=n,t[12]=l,t[13]=d,t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function C(e){return e.stopPropagation()}function w(e){return e.stopPropagation()}function T(e){let t=(0,x.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=_(`flex shrink-0 items-center justify-between gap-3 py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,S.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,S.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function E(e){let t=(0,x.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=_(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,S.jsx)(T,{className:`py-0`,actions:r,children:n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=_(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,S.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,S.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let v;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(v=(0,S.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=v):v=t[20],v}function D(e){let t=(0,x.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,S.jsx)(O,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,S.jsx)(E,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function O(e){let t=(0,x.c)(25),{label:n,children:r,description:i,footer:a,itemId:o,className:s,copyClassName:c,controlClassName:l}=e,u;t[0]===s?u=t[1]:(u=_(`yuri-settings-group-row yuri-settings-split-row`,s),t[0]=s,t[1]=u);let d;t[2]===c?d=t[3]:(d=_(`yuri-settings-split-row-copy`,c),t[2]=c,t[3]=d);let f;t[4]===n?f=t[5]:(f=n?(0,S.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=f);let p;t[6]===i?p=t[7]:(p=i?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=p);let m;t[8]!==d||t[9]!==f||t[10]!==p?(m=(0,S.jsxs)(`div`,{className:d,children:[f,p]}),t[8]=d,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]===l?h=t[13]:(h=_(`yuri-settings-split-row-control`,l),t[12]=l,t[13]=h);let g;t[14]!==r||t[15]!==h?(g=(0,S.jsx)(`div`,{"data-settings-value":``,className:h,children:r}),t[14]=r,t[15]=h,t[16]=g):g=t[16];let v;t[17]===a?v=t[18]:(v=a?(0,S.jsx)(`div`,{"data-slot":`settings-row-footer`,className:`col-span-full min-w-0`,children:a}):null,t[17]=a,t[18]=v);let y;return t[19]!==o||t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==v?(y=(0,S.jsxs)(`div`,{"data-settings-item":o,className:u,children:[m,g,v]}),t[19]=o,t[20]=u,t[21]=m,t[22]=g,t[23]=v,t[24]=y):y=t[24],y}function te(e){let t=(0,x.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=ne,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=_(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,v=u||void 0,y,b;t[7]===f?(y=t[8],b=t[9]):(y=e=>{p(e.target)||f()},b=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=y,t[9]=b);let C;t[10]===i?C=t[11]:(C=(0,S.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=C);let w;t[12]===o?w=t[13]:(w=o?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=w);let T;t[14]!==w||t[15]!==C?(T=(0,S.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[C,w]}),t[14]=w,t[15]=C,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(E=(0,S.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,S.jsx)(ee,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=E):E=t[21];let D;return t[22]!==n||t[23]!==s||t[24]!==T||t[25]!==E||t[26]!==h||t[27]!==g||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,S.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":v,onClick:y,onKeyDown:b,children:[T,E]}),t[22]=n,t[23]=s,t[24]=T,t[25]=E,t[26]=h,t[27]=g,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function ne(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var k=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},A=()=>{let e=l.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},re=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},ie=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},ae=e=>({source:re(e.source),state:ie(e.state)}),oe=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>ae(e))};async function j(e,t){return oe((await A().list(k(e),t?{signal:t}:void 0))?.data)}async function se(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await A().update({...k(e),targets:[r]},n?{signal:n}:void 0)}function ce(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var le=1500,M=e=>e?.trim()||null,N=(t,n=e())=>h.plugins.list(t,n),P=(t,n,r=!1,i=e())=>h.plugins.registry(t,n,r,i),F=(t,n=e())=>h.plugins.runtime(t,n),I=0,L=()=>(I+=1,I),R=(e,t,n)=>e.getQueryData(F(t,n)),z=(t=y(),r=e())=>{let i=M(t);return{queryKey:N(i,r),queryFn:async({signal:e})=>{let t=await n(he(`/api/config/plugins`,i),{headers:U(i),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let r=await t.json();return{entries:r.entries??[],files:r.files??[]}},staleTime:5e3,retry:2}},B=(t,r,i=!1,a=e(),o=!1)=>{let s=M(t),c=m(r);return{queryKey:o?[...P(s,c,i,a),`details`]:P(s,c,i,a),queryFn:async({signal:e})=>{let t={};for(let r of _e(c)){let a=ge(r,i,s),c=await n(o?`${a}&details=true`:a,{headers:U(s),signal:e});if(!c.ok)throw Error(`Failed to load plugin registry info`);let l=await c.json();for(let e of l.results??[])t[e.spec]=e}return t},staleTime:i?0:3e5,retry:2}},ue=(t=y(),n=e())=>{let r=M(t);return{queryKey:F(r,n),queryFn:async({signal:e})=>{let t=L(),i=await j(r,e);if(t!==I){let e=R(p,r,n);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},de=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=b(ve),a;t[2]===i?a=t[3]:(a=z(M(i)??M(l.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},fe=(e,t)=>{let n=(0,x.c)(6),r=t!==void 0&&t,i=b(ye),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=B(M(i)??M(l.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),f(o)},V=()=>{let e=(0,x.c)(2),t=b(be),n;return e[0]===t?n=e[1]:(n=M(t)??M(l.getDirectory()),e[0]=t,e[1]=n),n},pe=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=V(),a;t[2]===i?a=t[3]:(a=ue(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},H=async(t,n,r)=>{let i=M(n);return e()===r?t.fetchQuery({...z(i,r),staleTime:0}):t.getQueryData(N(i,r))??{entries:[],files:[]}},me=async(t,n,r)=>{let i=M(n);if(e()!==r)return R(t,i,r);let a=L(),o=await j(i);return a!==I||e()!==r?R(t,i,r):(t.setQueryData(F(i,r),o),o)};function he(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ge(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function _e(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>le){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function U(e){return e?{"x-opencode-directory":e}:void 0}function ve(e){return e.getActiveProject?.()?.path??null}function ye(e){return e.getActiveProject?.()?.path??null}function be(e){return e.getActiveProject?.()?.path??null}var W=()=>{try{let e=b.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=l.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},xe=5e3,Se=`__default__`,G=new Map,K=new Map,Ce=1500,q=e=>e?.trim()||Se,we=e=>{G.delete(q(e))},J=r()(a(i((r,i)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:e=>r({selectedId:e}),setDraft:e=>r({draft:e}),loadPlugins:async n=>{let a=W(),o=e(),s=t(),c=()=>o===e()&&s===t()&&a===W(),l=q(a),u=Date.now(),d=G.get(l)??0,f=i().entries.length>0||i().files.length>0;if(!n?.force&&f&&u-d<xe)return!0;let m=K.get(l);if(!n?.force&&m)return m;let h=(async()=>{r({isLoading:!0});try{let e=n?.force?await H(p,a,o):await p.fetchQuery(z(a,o));return c()?(r({entries:e.entries??[],files:e.files??[],isLoading:!1}),G.set(l,Date.now()),n?.force||i().loadRegistryInfo(),!0):!1}catch(e){return console.error(`[PluginsStore] Failed to load plugins:`,e),c()&&r({isLoading:!1}),!1}})();K.set(l,h);try{return await h}finally{K.delete(l)}},loadRegistryInfo:async e=>{let t=Ee(e?.specs??i().entries.map(e=>e.spec));if(t.length===0){r({isLoadingRegistry:!1});return}r({isLoadingRegistry:!0});try{let a=W(),o={...i().registryInfo};for(let r of De(t)){let t=await n(Te(r,e?.force===!0,a),{headers:X(a)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let i=await $(t);for(let e of i.results??[])o[e.spec]=e}r({registryInfo:o,isLoadingRegistry:!1})}catch(e){console.error(`[PluginsStore] Failed to load plugin registry info:`,e),r({isLoadingRegistry:!1})}},updateToLatest:async e=>{let t=i().entries.find(t=>t.id===e);if(!t)return{ok:!1};let n=i().registryInfo[t.spec];return!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion?{ok:!1}:await i().updateEntry(e,{spec:`${n.name}@${n.latestVersion}`})},createEntry:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/entry`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(Oe(e))}));return t.ok&&i().loadRegistryInfo({specs:[e.spec],force:!0}),t},updateEntry:async(t,r)=>{let a=(p.getQueryData(z(W(),e()).queryKey)?.entries??i().entries).find(e=>e.id===t),o=a?.spec,s=r.spec??o,c=await Q(async e=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(t)}`,e),{method:`PATCH`,headers:Z(e),body:JSON.stringify(Oe(r))}),a&&s?{...a,spec:s}:void 0);return c.ok&&s&&i().loadRegistryInfo({specs:[s],force:!0}),c},deleteEntry:async e=>{let t=i().entries.find(t=>t.id===e),a=await Q(async t=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));if(a.ok&&i().selectedId===e&&r({selectedId:null}),a.ok&&t){let e={...i().registryInfo};delete e[t.spec],r({registryInfo:e})}return a},readFile:async e=>{try{let t=W(),r=await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:X(t)});if(!r.ok)throw Error(`Failed to read plugin file`);return await $(r)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Q(async t=>await n(Y(`/api/config/plugins/file`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>Q(async r=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,r),{method:`PUT`,headers:Z(r),body:JSON.stringify(t)})),deleteFile:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));return t.ok&&i().selectedId===e&&r({selectedId:null}),t},getById:e=>i().entries.find(t=>t.id===e)??i().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:u(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Y(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Te(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Ee(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function De(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>Ce?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function X(e){return e?{"x-opencode-directory":e}:void 0}function Z(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Oe(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Q(n,r){let i=e(),a=t();try{let o=W(),s=await n(o),c=await $(s).catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update plugin configuration`);if(i!==e()||a!==t())return{ok:!0};we(o);let l=await H(p,o,i);if(o===W()&&i===e()&&a===t()){let e=r&&J.getState().selectedId===r.id?l.entries.find(e=>e.spec===r.spec&&e.scope===r.scope&&e.sourcePath===r.sourcePath):void 0;J.setState({entries:l.entries,files:l.files,...e?{selectedId:e.id}:{}}),G.set(q(o),Date.now())}return{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function $(e){return await e.json()}export{V as a,de as c,D as d,E as f,ee as g,T as h,me as i,ce as l,te as m,B as n,fe as o,O as p,z as r,pe as s,J as t,se as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{st as t}from"./vendor-base-ui-CzHs0bHY.js";import{t as n}from"./platform-sEg2IOLZ.js";import{r}from"./FadeInOnReveal-BRrU2ivL.js";var i=e(t(),1),a=(e,t,n)=>{let r=t-e;return Math.max(0,n-r)},o=e=>{e.timer&&=(clearTimeout(e.timer),null)},s=({text:e,isStreaming:t,throttleMs:s=r(n()).textThrottleMs,identityKey:c})=>{let[l,u]=i.useState(e),d=i.useRef(e),f=i.useRef(l),p=i.useRef({timer:null,pendingText:e,lastEmitAt:0});return i.useEffect(()=>{d.current=e},[e]),i.useEffect(()=>{f.current=l},[l]),i.useEffect(()=>{let e=p.current;o(e),e.pendingText=d.current,e.lastEmitAt=0,u(d.current)},[c]),i.useEffect(()=>{let n=p.current;n.pendingText=e;let r=f.current,i=t&&r.length>e.length?r:e;if(!t){o(n),n.lastEmitAt=Date.now(),u(i);return}let c=Date.now(),l=a(n.lastEmitAt,c,s);if(l<=0){o(n),n.lastEmitAt=c,u(i);return}return o(n),n.timer=setTimeout(()=>{n.timer=null,n.lastEmitAt=Date.now(),u(e=>t&&e.length>n.pendingText.length?e:n.pendingText)},l),()=>{o(n)}},[t,e,s]),i.useEffect(()=>{let e=p.current;return()=>{o(e)}},[]),l};export{s as t};
|
package/dist/assets/{useWorkerHighlightedLines-C7aY9AZe.js → useWorkerHighlightedLines-D0Nf66Jj.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{y as r}from"./useUIStore-BerIUSLP.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{f as a,r as o,t as s}from"./button-C-gRcs_2.js";import{n as c}from"./useThemeSystem-CNzUUkFn.js";import{n as l}from"./Icon-OJf0qBKf.js";import{n as u}from"./MarkdownRenderer-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{y as r}from"./useUIStore-BerIUSLP.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{f as a,r as o,t as s}from"./button-C-gRcs_2.js";import{n as c}from"./useThemeSystem-CNzUUkFn.js";import{n as l}from"./Icon-OJf0qBKf.js";import{n as u}from"./MarkdownRenderer-WSxkmNai.js";import{n as d,r as f}from"./toolHelpers-iEHVHQ9p.js";import{n as p}from"./markdownTheme-CHNl6tUv.js";import{n as m,t as h}from"./markdown-worker-oBGEB9Eg.js";var g=e(n(),1),_=i(),v=t(),y=e=>e===`in_progress`||e===`completed`||e===`cancelled`?e:`pending`,b=e=>e.status===`completed`||e.status===`cancelled`,x={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},S={in_progress:`text-foreground`,pending:`text-muted-foreground/60`,completed:`text-muted-foreground`,cancelled:`text-muted-foreground/60`},C={in_progress:`text-foreground`,pending:`text-muted-foreground`,completed:`text-muted-foreground/60 line-through decoration-1`,cancelled:`text-muted-foreground/60 line-through decoration-1`},w=1.2,T=24,E=`1 1`,D=e=>{let t=(0,_.c)(23),{status:n,className:r}=e,{t:i}=a(),s=x[n],c;t[0]!==i||t[1]!==s?(c=i(s),t[0]=i,t[1]=s,t[2]=c):c=t[2];let l=S[n],u;t[3]!==r||t[4]!==l?(u=o(`size-[1em] shrink-0 transition-colors duration-300`,l,r),t[3]=r,t[4]=l,t[5]=u):u=t[5];let d=n===`pending`?w:void 0,f=n===`pending`?T:void 0,p=n===`pending`?E:void 0,m;t[6]!==d||t[7]!==f||t[8]!==p?(m=(0,v.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:d,pathLength:f,strokeDasharray:p}),t[6]=d,t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===n?h=t[11]:(h=n===`in_progress`?(0,v.jsx)(`path`,{d:`M4.8 8h6.4M8.6 5.4 11.2 8l-2.6 2.6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[10]=n,t[11]=h);let g;t[12]===n?g=t[13]:(g=n===`completed`?(0,v.jsx)(`path`,{d:`M5 8 7.5 11 11 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[12]=n,t[13]=g);let y;t[14]===n?y=t[15]:(y=n===`cancelled`?(0,v.jsx)(`path`,{d:`M3.5 12.5 12.5 3.5`,stroke:`currentColor`}):null,t[14]=n,t[15]=y);let b;return t[16]!==g||t[17]!==y||t[18]!==c||t[19]!==u||t[20]!==m||t[21]!==h?(b=(0,v.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,role:`img`,"aria-label":c,className:u,children:[m,h,g,y]}),t[16]=g,t[17]=y,t[18]=c,t[19]=u,t[20]=m,t[21]=h,t[22]=b):b=t[22],b},O=3.2,k=e=>{let t=Math.PI*2*e,n=8+O*Math.sin(t),r=8-O*Math.cos(t);return`M8 8 L8 4.8 A${O} ${O} 0 ${+(e>.5)} 1 ${n.toFixed(3)} ${r.toFixed(3)} Z`},A=e=>{let t=(0,_.c)(11),{done:n,total:r,spinning:i,className:a}=e,s=n===void 0?0:n,c=r===void 0?0:r,l=i!==void 0&&i,u=c>0?Math.min(1,s/c):0,d;t[0]===a?d=t[1]:(d=o(`size-[1.15em] shrink-0 text-foreground`,a),t[0]=a,t[1]=d);let f=l?`yuri-todo-spin`:void 0,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p={transformBox:`fill-box`,transformOrigin:`center`},t[2]=p):p=t[2];let m;t[3]===f?m=t[4]:(m=(0,v.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:w,pathLength:T,strokeDasharray:E,className:f,style:p}),t[3]=f,t[4]=m);let h;t[5]===u?h=t[6]:(h=u>0?(0,v.jsx)(`path`,{d:k(u),fill:`currentColor`,className:`transition-opacity duration-300`}):null,t[5]=u,t[6]=h);let g;return t[7]!==d||t[8]!==m||t[9]!==h?(g=(0,v.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:d,children:[m,h]}),t[7]=d,t[8]=m,t[9]=h,t[10]=g):g=t[10],g},j=({done:e,total:t,className:n,animate:r=!0})=>{let i=g.useRef(e),a=r&&i.current!==e;return g.useEffect(()=>{i.current=e},[e]),(0,v.jsxs)(`span`,{className:o(`shrink-0 tabular-nums`,n),children:[(0,v.jsx)(`span`,{className:o(a&&`yuri-todo-count-tick`),children:e},e),`/${t}`]})},ee=e=>{let t=(0,_.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=o(`flex size-[1.15em] shrink-0 items-center justify-center rounded-full bg-[var(--status-success)] text-[var(--status-success-foreground)]`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,v.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`size-[70%]`,children:(0,v.jsx)(`path`,{d:`M4.5 8.2 7 10.8 11.5 5.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,v.jsx)(`span`,{"data-todo-complete":!0,className:r,children:i}),t[3]=r,t[4]=a),a},M=e=>{let t=(0,_.c)(27),{todos:n,isWorking:r,animate:i,className:s,rowClassName:c,listRef:l,id:u}=e,d=r!==void 0&&r,f=i!==void 0&&i,{t:p}=a(),m=n.findIndex(N),h;t[0]!==m||t[1]!==n?(h=m>=0?m:n.findIndex(P),t[0]=m,t[1]=n,t[2]=h):h=t[2];let g=h,b;t[3]===n?b=t[4]:(b=n.some(F),t[3]=n,t[4]=b);let S=b,w;t[5]===s?w=t[6]:(w=o(`m-0 flex min-w-0 list-none flex-col gap-[0.125em] p-0`,s),t[5]=s,t[6]=w);let T;if(t[7]!==g||t[8]!==f||t[9]!==S||t[10]!==d||t[11]!==c||t[12]!==p||t[13]!==n){let e;t[15]!==g||t[16]!==f||t[17]!==S||t[18]!==d||t[19]!==c||t[20]!==p?(e=(e,t)=>{let n=y(e.status),r=d&&!S&&t===g&&n===`pending`?`in_progress`:n;return(0,v.jsxs)(`li`,{"data-status":r,"aria-current":t===g?`step`:void 0,className:o(`grid min-w-0 shrink-0 grid-cols-[auto_minmax(0,1fr)] items-start py-[0.25em]`,c??`gap-[0.6em] px-[0.5em]`,f&&`yuri-todo-row-in`),children:[(0,v.jsx)(`span`,{className:o(`flex h-[1.32em] w-[1.15em] items-center justify-center`,f&&`yuri-todo-icon-pop`),title:p(x[r]),children:(0,v.jsx)(D,{status:r})},r),(0,v.jsx)(`span`,{dir:`auto`,title:e.content,className:o(`line-clamp-3 min-w-0 whitespace-normal text-[0.88em] break-words leading-[1.5] transition-colors duration-300`,C[r]),children:(0,v.jsx)(`span`,{className:o(r===`in_progress`&&`animate-text-shimmer`),children:e.content})})]},e.id??`${t}:${e.content}`)},t[15]=g,t[16]=f,t[17]=S,t[18]=d,t[19]=c,t[20]=p,t[21]=e):e=t[21],T=n.map(e),t[7]=g,t[8]=f,t[9]=S,t[10]=d,t[11]=c,t[12]=p,t[13]=n,t[14]=T}else T=t[14];let E;return t[22]!==u||t[23]!==l||t[24]!==w||t[25]!==T?(E=(0,v.jsx)(`ul`,{id:u,ref:l,className:w,children:T}),t[22]=u,t[23]=l,t[24]=w,t[25]=T,t[26]=E):E=t[26],E};function N(e){return e.status===`in_progress`}function P(e){return e.status===`pending`}function F(e){return e.status===`in_progress`}var I=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),L=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,R=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=L(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},z=e=>`<pre><code>${I(e)}</code></pre>`,B=e=>{let t=(0,_.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=g.useRef(null),m;t[0]===d?m=t[1]:(m=p(d),t[0]=d,t[1]=m);let y=m,b,x;t[2]!==n||t[3]!==s||t[4]!==u?(b=()=>{let e=f.current;e&&(e.innerHTML=z(n),R(e,u,s))},x=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=b,t[6]=x):(b=t[5],x=t[6]),g.useLayoutEffect(b,x);let S,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(S=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return h(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,R(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=S,t[12]=C):(S=t[11],C=t[12]),g.useEffect(S,C);let w;t[13]===i?w=t[14]:(w=o(`typography-code`,i),t[13]=i,t[14]=w);let T=y,E;t[15]!==a||t[16]!==T?(E={...T,...a},t[15]=a,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,v.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},V=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},H=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},U=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,W=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,G=(e,t)=>!e||typeof e!=`object`?String(e):f(e,t||``),K=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},q=e=>{if(!e||typeof e!=`object`)return;let t=K(e.patch)??K(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=K(e.patch)??K(e.diff);if(t)return t}},J=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},Y=(e,t,n)=>{let r=V(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&U(r)&&(r=W(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=q(n);if(e)return e}return r},X=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},Z=(e,t)=>{try{let n=e.trim().split(`
|
|
4
4
|
`).filter(Boolean);if(n.length===0)return null;let i=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,v.jsx)(`div`,{className:o(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:r.tool.popup,children:i.map((e,t)=>(0,v.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,v.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,v.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Q={backgroundColor:`var(--status-info)`,opacity:.6},te=(e,t,n)=>{try{let i=e.trim().split(`
|
package/dist/assets/{vendor-markstream-react-DfLaSG3W.js → vendor-markstream-react-6zxyQLCD.js}
RENAMED
|
@@ -170,4 +170,4 @@ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{at as n,ot as r
|
|
|
170
170
|
`),t},[Ee,r,Ue,J,q,Je,d]),Xe=(0,_.useCallback)(()=>{let e=Ye(),t=ee.current;if(!t)return ee.current=e,e;for(let n of Object.keys(t))n in e||delete t[n];return Object.assign(t,e),t},[Ye]),Ze=(0,_.useCallback)(e=>{let t=e(Xe());return E.current=t,D.current=typeof t.safeClean==`function`?()=>t.safeClean():typeof t.cleanupEditor==`function`?()=>t.cleanupEditor():null,t},[Xe]),Qe=(0,_.useMemo)(()=>JSON.stringify({diffStyle:q.diffStyle,expandUnchanged:q.expandUnchanged,collapsedContextThreshold:q.collapsedContextThreshold,hunkSeparators:q.hunkSeparators,lineDiffType:q.lineDiffType,maxLineDiffLength:q.maxLineDiffLength,expansionLineCount:q.expansionLineCount,context:q.parseDiffOptions?.context}),[q]);(0,_.useEffect)(()=>{Xe()},[q,Xe]),(0,_.useEffect)(()=>()=>{var e,t,n;j.current+=1,(e=D.current)==null||e.call(D),Pe(),D.current=null,O.current=null,k.current=null,A.current=null,E.current=null,F.current=null,M.current=null,(n=(t=N.current)?.destroy)==null||n.call(t),N.current=null},[Pe]),(0,_.useEffect)(()=>{var e,t;if(typeof window>`u`||B)return;let n=T.current;if(!n)return;(t=(e=N.current)?.destroy)==null||t.call(e);let r=P(n,{rootMargin:`400px`});return N.current=r,r.isVisible()&&ae(!0),r.whenVisible.then(()=>ae(!0)),()=>{r.destroy(),N.current===r&&(N.current=null)}},[P,B]),(0,_.useEffect)(()=>{let e=!0;return typeof window>`u`?()=>{e=!1}:E.current?(Xe(),()=>{e=!1}):((async()=>{try{let t=await Gx();if(!e)return;if(!t)return void ie(!0);let n=t.createCodeBlockRuntime,r=t.detectLanguage;if(typeof r==`function`&&(M.current=r),typeof n!=`function`)return void ie(!0);F.current=n,Ze(n),V(!0)}catch{e&&ie(!0)}})(),()=>{e=!1})},[Ze,Xe]),(0,_.useEffect)(()=>{if(!n.language&&!U&&M.current)try{let e=M.current(String(n.code??``));e&&de(e)}catch{}},[U,n.code,n.language]);let $e=(0,_.useMemo)(()=>String(n.language||U||ue||`plaintext`),[U,ue,n.language]),et=(0,_.useMemo)(()=>Eb($e),[$e]),tt=(0,_.useMemo)(()=>Db(et),[et]),nt=(0,_.useMemo)(()=>tt===`plaintext`,[tt]),rt=(0,_.useMemo)(()=>Ab(et),[et,ye]),it=(0,_.useMemo)(()=>!!o&&(et===`html`||et===`svg`),[et,o]),at=(0,_.useMemo)(()=>{let e=et;return e?jb[e]||e.charAt(0).toUpperCase()+e.slice(1):jb[``]||`Plain Text`},[et]),ot=(0,_.useMemo)(()=>function(e,t,n){let r=function(e){let t=function(e){let t=String(e??``).split(/\r?\n/,1)[0]?.trim()??``;if(t.length<3)return``;let n=t[0];if(n!=="`"&&n!==`~`||t[1]!==n||t[2]!==n)return``;let r=3;for(;t[r]===n;)r+=1;return t.slice(r).trim()}(e);if(!t)return``;let n=t.split(/\s+/).filter(Boolean);if(!n.length)return``;let r=n[0]===`diff`?n.slice(1):n;for(let e of r){let t=e.includes(`:`)?e.slice(e.indexOf(`:`)+1):e;if(t&&/[./\\-]/.test(t))return t}return``}(e);return{title:r||t,caption:r?n?`Diff / ${t}`:t:``}}(String(n.raw??``),at,!!n.diff),[at,n.diff,n.raw]),st=ot.title,ct=ot.caption,lt=(0,_.useMemo)(()=>n.diff?n.updatedCode??n.code??``:n.code??``,[n.code,n.diff,n.updatedCode]),ut=(0,_.useMemo)(()=>{let e=e=>{if(e!=null)return typeof e==`number`?`${e}px`:String(e)},t={},r=e(f),i=e(p);return r&&(t.minWidth=r),i&&(t.maxWidth=i),n.diff?(t.color=`var(--markstream-diff-shell-fg)`,t.borderColor=`var(--markstream-diff-shell-border)`):(t.color=`var(--vscode-editor-foreground, var(--markstream-code-fallback-fg, var(--code-fg)))`,t.backgroundColor=`var(--vscode-editor-background, var(--markstream-code-fallback-bg, var(--code-bg)))`,t.borderColor=`var(--markstream-code-border-color, var(--code-border))`),t},[p,f,n.diff]),dt=(0,_.useMemo)(()=>n.code.length>0||(n.originalCode?.length??0)>0||(n.updatedCode?.length??0)>0,[n.code,n.originalCode,n.updatedCode]),ft=!1===a&&i||!1!==a&&i&&!dt;(0,_.useEffect)(()=>{if(z||!oe||!H||!B)return;let e=E.current;Xe();let t=()=>{var t;n.diff&&((t=e?.refreshDiffPresentation)==null||t.call(e)),Je(),G||((typeof window<`u`&&typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>Ne(W)):null)??Ne(W))};e?.setTheme&&J?Promise.resolve(e.setTheme(J)).then(t).catch(()=>{}):t()},[G,H,Ve,W,oe,n.diff,J,Ne,Je,Xe,z,B]);let pt=(0,_.useCallback)(async()=>{if(z||!B||G||ft)return null;let e=E.current,t=w.current;if(!e||!t||!e.createEditor)return null;Xe();let n=Ie.current,r=n.diff?`diff`:`single`,i=A.current,a=r===`diff`?!!e.getDiffEditorView?.call(e):!!e.getEditorView?.call(e);if(k.current===r&&i===t&&a)return null;if(O.current)return O.current;j.current+=1;let o=j.current;se(!0);let s=(async()=>{var r;try{(r=D.current)==null||r.call(D),k.current=null,A.current=null,le(!1);let i=tt;if(n.diff?typeof e.createDiffEditor==`function`?(k.current=`diff`,await e.createDiffEditor(t,String(n.originalCode??``),String(n.updatedCode??``),i)):(k.current=`single`,await e.createEditor(t,String(n.updatedCode??n.code??``),i)):(k.current=`single`,await e.createEditor(t,String(n.code??``),i)),A.current=t,j.current!==o)return;Fe(),Je(),W||G||Ne(!1);let a=await Promise.race([Jx(t,e.whenVisualReady),new Promise(e=>{window.setTimeout(()=>e(!0),1500)})]);if(j.current!==o||!a)return;Me(W),le(!0)}catch{j.current===o&&(R.current=tt,ie(!0))}})().finally(()=>{O.current===s&&(O.current=null)});return O.current=s,s},[Me,Fe,G,W,tt,Ne,ft,Je,Xe,z,B]);(0,_.useEffect)(()=>{Xe();let e=I.current!==u;I.current=u;let t=De.current!==Ee;De.current=Ee;let r=te.current;if(te.current=Qe,z||!oe)return;let i=!1;if(e||t){let e=F.current;if(e){Le(),E.current=null,D.current=null;try{Ze(e),i=!0}catch{ie(!0);return}}}let a=!!(n.diff&&r!==Qe);if(!i&&!a||!B||!H&&!i||G||ft)return;let o=!1;return(async()=>{if(i||Le(),!o)try{await pt()}catch{}})(),()=>{o=!0}},[G,u,H,Ee,pt,Ze,oe,Qe,n.diff,Le,ft,Xe,z,B]),(0,_.useEffect)(()=>{if(z){let e=R.current;if(e===void 0||e===tt)return;R.current=void 0,Le(),ie(!1);return}oe&&B&&(G||ft?Le():pt())},[G,pt,tt,oe,Le,ft,z,B]),(0,_.useEffect)(()=>{if(z||!oe||!B||G||ft)return;let e=E.current;if(!e)return;let t=String(n.code??``);(async()=>{let r=U;if(!r&&M.current)try{r=Eb(M.current(t)),r&&fe(r)}catch{}let i=Db(r||et);if(e.createEditor&&w.current){try{await Promise.resolve(pt())}catch{}let e=O.current;if(e)try{await e}catch{}}try{n.diff&&e.updateDiff?await Promise.resolve(e.updateDiff(String(n.originalCode??``),String(n.updatedCode??``),i)):e.updateCode&&await Promise.resolve(e.updateCode(t,i))}catch{}let a=w.current;a&&a.getAttribute(`data-markstream-enhanced`)!==`true`&&await Jx(a,e.whenVisualReady)&&(Me(W),le(!0)),Ne(W)})()},[Me,et,U,G,H,pt,W,oe,n.code,n.diff,n.originalCode,n.updatedCode,Ne,ft,z,B]),(0,_.useEffect)(()=>{if(z||!oe||!B||G||ft||!W&&i)return;let e=typeof window<`u`&&typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>Ne(W)):null;return e??Ne(W),()=>{e!=null&&typeof window<`u`&&typeof window.cancelAnimationFrame==`function`&&window.cancelAnimationFrame(e)}},[G,W,i,oe,Ne,ft,z,B]),(0,_.useEffect)(()=>{var e;if(!s||z)return;let t=E.current;if(t){try{let n=k.current===`diff`?t.getDiffEditorView?.call(t):t.getEditorView?.call(t);(e=n?.updateOptions)==null||e.call(n,{fontSize:Ce})}catch{}Ne(W)}},[s,W,Ce,n.diff,Ne,z]),(0,_.useEffect)(()=>{Te||zx(!0)},[Te]);let mt=(0,_.useCallback)((e,t)=>{if(!Te)return;let n=e.currentTarget;n&&!n.disabled&&(`clientX`in e&&(e.clientX,e.clientY),Rx(n,t,`top`,!1,0,He))},[He,Te]),ht=(0,_.useCallback)(()=>{Te&&zx()},[Te]),gt=(0,_.useCallback)(async()=>{var e;try{typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`&&await navigator.clipboard.writeText(String(lt)),me(!0),(e=t.onCopy)==null||e.call(t,String(lt)),setTimeout(()=>me(!1),1e3)}catch{}},[t,lt]),_t=(0,_.useCallback)(()=>{if(!it)return;let e=et===`html`?`text/html`:`image/svg+xml`,r=et===`html`?K(`artifacts.htmlPreviewTitle`)||`HTML Preview`:K(`artifacts.svgPreviewTitle`)||`SVG Preview`;typeof t.onPreviewCode==`function`?t.onPreviewCode({node:n,artifactType:e,artifactTitle:r,id:`temp-${et}-${Date.now()}`}):et===`html`&&ve(e=>!e)},[et,it,n,t,K]);return(0,v.jsxs)(`div`,{ref:T,className:[`code-block-container my-4 rounded-lg border overflow-hidden shadow-sm`,He?`border-gray-700/30`:`border-gray-200`,i?`is-rendering`:``,He?`is-dark`:``,n.diff?`is-diff`:``,nt?`is-plain-text`:``].join(` `),style:ut,children:[m&&(0,v.jsxs)(`div`,{className:`code-block-header`,children:[(0,v.jsxs)(`div`,{className:`code-header-main`,children:[(0,v.jsx)(`span`,{className:`icon-slot h-4 w-4 flex-shrink-0`,dangerouslySetInnerHTML:{__html:rt}}),(0,v.jsxs)(`div`,{className:`code-header-copy min-w-0`,children:[(0,v.jsx)(`div`,{className:`code-header-title truncate`,children:st}),ct&&(0,v.jsx)(`div`,{className:`code-header-caption truncate`,children:ct})]})]}),(0,v.jsxs)(`div`,{className:`code-header-actions`,children:[b&&(0,v.jsx)(`button`,{type:`button`,className:`code-action-btn transition-colors`,"aria-pressed":G,onClick:()=>ge(e=>!e),onMouseEnter:e=>mt(e,G?K(`common.expand`)||`Expand`:K(`common.collapse`)||`Collapse`),onFocus:e=>mt(e,G?K(`common.expand`)||`Expand`:K(`common.collapse`)||`Collapse`),onMouseLeave:ht,onBlur:ht,children:(0,v.jsx)(`svg`,{style:{rotate:G?`0deg`:`90deg`},xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`action-icon`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m9 18l6-6l-6-6`})})}),x&&s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`button`,{type:`button`,className:`code-action-btn transition-colors`,disabled:Ce<=10,onClick:()=>we(e=>Math.max(10,e-1)),onMouseEnter:e=>mt(e,K(`common.decrease`)||`Decrease`),onFocus:e=>mt(e,K(`common.decrease`)||`Decrease`),onMouseLeave:ht,onBlur:ht,children:(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`action-icon`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M5 12h14`})})}),(0,v.jsx)(`button`,{type:`button`,className:`code-action-btn transition-colors`,disabled:Ce===xe,onClick:()=>we(xe),onMouseEnter:e=>mt(e,K(`common.reset`)||`Reset`),onFocus:e=>mt(e,K(`common.reset`)||`Reset`),onMouseLeave:ht,onBlur:ht,children:(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`action-icon`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`path`,{d:`M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,v.jsx)(`path`,{d:`M3 3v5h5`})]})})}),(0,v.jsx)(`button`,{type:`button`,className:`code-action-btn transition-colors`,disabled:Ce>=36,onClick:()=>we(e=>Math.min(36,e+1)),onMouseEnter:e=>mt(e,K(`common.increase`)||`Increase`),onFocus:e=>mt(e,K(`common.increase`)||`Increase`),onMouseLeave:ht,onBlur:ht,children:(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`action-icon`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M5 12h14m-7-7v14`})})})]}),h&&(0,v.jsx)(`button`,{type:`button`,className:`code-action-btn transition-colors`,"aria-label":pe?K(`common.copied`)||`Copied`:K(`common.copy`)||`Copy`,onClick:gt,onMouseEnter:e=>mt(e,pe?K(`common.copied`)||`Copied`:K(`common.copy`)||`Copy`),onFocus:e=>mt(e,pe?K(`common.copied`)||`Copied`:K(`common.copy`)||`Copy`),onMouseLeave:ht,onBlur:ht,children:(0,v.jsx)(`svg`,pe?{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`action-icon`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M20 6L9 17l-5-5`})}:{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`action-icon`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,v.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]})})}),g&&(0,v.jsx)(`button`,{type:`button`,className:`code-action-btn transition-colors`,"aria-pressed":W,onClick:e=>{he(e=>!e),mt(e,W?K(`common.expand`)||`Expand`:K(`common.collapse`)||`Collapse`)},onMouseEnter:e=>mt(e,W?K(`common.collapse`)||`Collapse`:K(`common.expand`)||`Expand`),onFocus:e=>mt(e,W?K(`common.collapse`)||`Collapse`:K(`common.expand`)||`Expand`),onMouseLeave:ht,onBlur:ht,children:(0,v.jsx)(`svg`,W?{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`action-icon`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6`})}:{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`action-icon`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6`})})}),it&&y&&(0,v.jsx)(`button`,{type:`button`,className:`code-action-btn transition-colors`,"aria-label":K(`common.preview`)||`Preview`,onClick:_t,onMouseEnter:e=>mt(e,K(`common.preview`)||`Preview`),onFocus:e=>mt(e,K(`common.preview`)||`Preview`),onMouseLeave:ht,onBlur:ht,children:(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,children:(0,v.jsxs)(`g`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,children:[(0,v.jsx)(`path`,{d:`M23.628 7.41c-.12-1.172-.08-3.583-.9-4.233c-1.921-1.51-6.143-1.11-8.815-1.19c-3.481-.15-7.193.14-10.625.24a.34.34 0 0 0 0 .67c3.472-.05 7.074-.29 10.575-.09c2.471.15 6.653-.14 8.254 1.16c.4.33.41 2.732.49 3.582a42 42 0 0 1 .08 9.005a13.8 13.8 0 0 1-.45 3.001c-2.42 1.4-19.69 2.381-20.72.55a21 21 0 0 1-.65-4.632a41.5 41.5 0 0 1 .12-7.964c.08 0 7.334.33 12.586.24c2.331 0 4.682-.13 6.764-.21a.33.33 0 0 0 0-.66c-7.714-.16-12.897-.43-19.31.05c.11-1.38.48-3.922.38-4.002a.3.3 0 0 0-.42 0c-.37.41-.29 1.77-.36 2.251s-.14 1.07-.2 1.6a45 45 0 0 0-.36 8.645a21.8 21.8 0 0 0 .66 5.002c1.46 2.702 17.248 1.461 20.95.43c1.45-.4 1.69-.8 1.871-1.95c.575-3.809.602-7.68.08-11.496`}),(0,v.jsx)(`path`,{d:`M4.528 5.237a.84.84 0 0 0-.21-1c-.77-.41-1.71.39-1 1.1a.83.83 0 0 0 1.21-.1m2.632-.25c.14-.14.19-.84-.2-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.2-.09m2.88 0a.83.83 0 0 0-.21-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.21-.09m-4.29 8.735c0 .08.23 2.471.31 2.561a.371.371 0 0 0 .63-.14c0-.09 0 0 .15-1.72a10 10 0 0 0-.11-2.232a5.3 5.3 0 0 1-.26-1.37a.3.3 0 0 0-.54-.24a6.8 6.8 0 0 0-.2 2.33c-1.281-.38-1.121.13-1.131-.42a15 15 0 0 0-.19-1.93c-.16-.17-.36-.17-.51.14a20 20 0 0 0-.43 3.471c.04.773.18 1.536.42 2.272c.26.4.7.22.7-.1c0-.09-.16-.09 0-1.862c.06-1.18-.23-.3 1.16-.76m5.033-2.552c.32-.07.41-.28.39-.37c0-.55-3.322-.34-3.462-.24s-.2.18-.18.28s0 .11 0 .16a3.8 3.8 0 0 0 1.591.361v.82a15 15 0 0 0-.13 3.132c0 .2-.09.94.17 1.16a.34.34 0 0 0 .48 0c.125-.35.196-.718.21-1.09a8 8 0 0 0 .14-3.232c0-.13.05-.7-.1-.89a8 8 0 0 0 .89-.09m5.544-.181a.69.69 0 0 0-.89-.44a2.8 2.8 0 0 0-1.252 1.001a2.3 2.3 0 0 0-.41-.83a1 1 0 0 0-1.6.27a7 7 0 0 0-.35 2.07c0 .571 0 2.642.06 2.762c.14 1.09 1 .51.63.13a17.6 17.6 0 0 1 .38-3.962c.32-1.18.32.2.39.51s.11 1.081.73 1.081s.48-.93 1.401-1.78q.075 1.345 0 2.69a15 15 0 0 0 0 1.811a.34.34 0 0 0 .68 0q.112-.861.11-1.73a16.7 16.7 0 0 0 .12-3.582m1.441-.201c-.05.16-.3 3.002-.31 3.202a6.3 6.3 0 0 0 .21 1.741c.33 1 1.21 1.07 2.291.82a3.7 3.7 0 0 0 1.14-.23c.21-.22.10-.59-.41-.64q-.817.096-1.64.07c-.44-.07-.34 0-.67-4.442q.015-.185 0-.37a.316.316 0 0 0-.23-.38a.316.316 0 0 0-.38.23`})]})})})]})]}),(0,v.jsxs)(`div`,{className:`code-block-body${G?` code-block-body--collapsed`:``}${W?` code-block-body--expanded`:``}`,children:[!G&&(!!a||!i)&&(z?(0,v.jsx)(Hb,{className:`code-fallback-plain m-0`,diffInline:We,node:n,showLineNumbers:Ee,style:qe}):(0,v.jsxs)(`div`,{className:`code-editor-layer`,children:[(0,v.jsx)(`div`,{ref:w,className:`code-editor-container`+(a?``:` code-height-placeholder`),"data-markstream-enhanced":ce?`true`:`false`,"data-markstream-host-hidden":ce?void 0:`true`,style:{"--markstream-editor-initial-height":`${Ke}px`,visibility:ce?`visible`:`hidden`},"aria-hidden":!ce}),!ce&&(0,v.jsx)(`div`,{className:`code-editor-fallback-surface`,children:(0,v.jsx)(Hb,{className:`code-fallback-plain m-0`,diffInline:We,node:n,showLineNumbers:Ee,style:qe})})]})),!a&&i&&(0,v.jsx)(`div`,{className:`code-loading-placeholder`,children:(0,v.jsxs)(`div`,{className:`loading-skeleton`,children:[(0,v.jsx)(`div`,{className:`skeleton-line`}),(0,v.jsx)(`div`,{className:`skeleton-line`}),(0,v.jsx)(`div`,{className:`skeleton-line short`})]})})]}),_e&&!t.onPreviewCode&&it&&et===`html`&&(0,v.jsx)(Bx,{code:String(n.code??``),htmlPreviewAllowScripts:t.htmlPreviewAllowScripts,htmlPreviewSandbox:t.htmlPreviewSandbox,isDark:r,onClose:()=>ve(!1)}),(0,v.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,role:`status`,children:pe?K(`common.copied`)||`Copied`:``})]})}function $x(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=$x(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Q(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=$x(e))&&(r&&(r+=` `),r+=t);return r}var eS=()=>a(()=>import(`./d2_markstream-react-DtM9g53j.js`),[]),tS=null,nS=eS;async function rS(){if(tS)return tS;let e=nS;if(!e)return null;let t;try{t=await e()}catch(t){throw e===eS?Error(`Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.`):t}return t?(tS=function(e){if(!e)return e;if(e.D2&&typeof e.D2==`function`)return e.D2;if(e.default&&e.default.D2&&typeof e.default.D2==`function`)return e.default.D2;let t=e.default??e;return typeof t==`function`?t:t?.D2&&typeof t.D2==`function`?t.D2:t}(t),tS):null}var iS={loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},aS={N1:`#E5E7EB`,N2:`#CBD5E1`,N3:`#94A3B8`,N4:`#64748B`,N5:`#475569`,N6:`#334155`,N7:`#0B1220`,B1:`#60A5FA`,B2:`#3B82F6`,B3:`#2563EB`,B4:`#1D4ED8`,B5:`#1E40AF`,B6:`#111827`,AA2:`#22D3EE`,AA4:`#0EA5E9`,AA5:`#0284C7`,AB4:`#FBBF24`,AB5:`#F59E0B`},oS=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],sS=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function cS(e){if(!e)return``;let t=e.trim();return sS.test(t)?t:``}function lS(e){let t={...iS,...e},{t:n}=kx(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(()=>typeof window>`u`),C=(0,_.useRef)(0),w=(0,_.useRef)(null),T=(0,_.useRef)(!1),E=(0,_.useRef)(!1),D=(0,_.useRef)(0),O=(0,_.useRef)(null),k=(0,_.useRef)(!1),A=(0,_.useRef)(null),j=(0,_.useRef)(null),M=(0,_.useRef)(null),N=(0,_.useRef)(null),P=(0,_.useRef)(!1),ee=(0,_.useRef)(()=>{}),F=Tx(),I=t.node?.code??``,te=s||!l||!p,L=!!p,ne=(0,_.useMemo)(()=>{if(!t.maxHeight)return;let e=typeof t.maxHeight==`number`?`${t.maxHeight}px`:String(t.maxHeight);return{maxHeight:e,"--ms-d2-render-max-height":e}},[t.maxHeight]),re=(0,_.useMemo)(()=>{if(te&&h)return{minHeight:`${h}px`}},[h,te]);(0,_.useEffect)(()=>{P.current=y},[y]),(0,_.useEffect)(()=>{let e=A.current;if(!e)return;let t=F(e,{rootMargin:`160px`});return j.current=t,t.isVisible()&&S(!0),t.whenVisible.then(()=>S(!0)),()=>{t.destroy(),j.current=null}},[F]);let R=(0,_.useCallback)(()=>{let e=M.current;if(!e)return;let t=e.getBoundingClientRect().height;t>0&&g(e=>e===t?e:t)},[]),z=(0,_.useCallback)((e=!1)=>{if(T.current||typeof window>`u`||E.current||!x)return;if(P.current)return void(k.current=!0);let n=Math.max(120,Number(t.progressiveIntervalMs)||0),r=Date.now()-D.current;if(!e&&r<n)return k.current=!0,void(O.current==null&&(O.current=window.setTimeout(()=>{O.current=null,k.current&&(k.current=!1,z(!0))},Math.max(0,n-r))));T.current=!0;let i=()=>{T.current=!1,D.current=Date.now(),ee.current()};typeof window<`u`&&typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(i):setTimeout(i,0)},[t.progressiveIntervalMs,x]),ie=(0,_.useCallback)(async()=>{if(w.current)return w.current;let e=await rS();if(!e)return null;if(typeof e==`function`){let t=new e;return t&&typeof t.compile==`function`?w.current=t:typeof e.compile==`function`&&(w.current=e),w.current}return e?.D2&&typeof e.D2==`function`?(w.current=new e.D2,w.current):(typeof e.compile==`function`&&(w.current=e),w.current)},[]),B=(0,_.useCallback)(async()=>{if(typeof window>`u`||E.current||!x||t.loading&&!t.progressiveRender)return;if(!I)return m(``),void f(null);let e=++C.current;b(!0),f(null);try{let n=await ie();if(!n)return u(!1),c(!0),m(``),void f(`D2 is not available.`);if(typeof n.compile!=`function`||typeof n.render!=`function`)throw Error(`D2 instance is missing compile/render methods.`);u(!0);let r=await n.compile(I);if(e!==C.current)return;let i=r?.diagram??r,a=r?.renderOptions??r?.options??{},o=t.themeId??a.themeID,s=t.darkThemeId??a.darkThemeID,l={...a};if(l.themeID=t.isDark&&s!=null?s:o,l.darkThemeID=null,l.darkThemeOverrides=null,t.isDark){let e=a.themeOverrides&&typeof a.themeOverrides==`object`?a.themeOverrides:null;l.themeOverrides={...aS,...e||{}}}let d=await n.render(i,l);if(e!==C.current)return;let p=function(e){return e?typeof e==`string`?e:typeof e.svg==`string`?e.svg:typeof e.data==`string`?e.data:``:``}(d);if(!p)throw Error(`D2 render returned empty output.`);let h=function(e){if(typeof window>`u`||typeof DOMParser>`u`||!e)return``;let t=e.replace(/["']\s*javascript:/gi,`#`).replace(/\bjavascript:/gi,`#`).replace(/["']\s*vbscript:/gi,`#`).replace(/\bvbscript:/gi,`#`).replace(/\bdata:text\/html/gi,`#`),n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;if(!n||n.nodeName.toLowerCase()!==`svg`)return``;let r=n;return function(e){let t=new Set([`script`]),n=[e,...Array.from(e.querySelectorAll(`*`))];for(let e of n){if(t.has(e.tagName.toLowerCase())){e.remove();continue}let n=Array.from(e.attributes);for(let t of n){let n=t.name;if(/^on/i.test(n))e.removeAttribute(n);else{if(n===`style`&&t.value){let r=t.value;if(oS.some(e=>e.test(r))){e.removeAttribute(n);continue}}if((n===`href`||n===`xlink:href`)&&t.value){let r=cS(t.value);if(!r){e.removeAttribute(n);continue}r!==t.value&&e.setAttribute(n,r)}}}}}(r),r.classList.add(`markstream-d2-root-svg`),r.outerHTML}(p);m(h||``),t.loading&&c(!1),f(null)}catch(n){if(e!==C.current)return;let r=n?.message?String(n.message):`D2 render failed.`;t.loading||f(r),r.includes(`@terrastruct/d2`)&&(u(!1),c(!0))}finally{e===C.current&&(b(!1),k.current&&(k.current=!1,z()))}},[I,ie,t.darkThemeId,t.isDark,t.loading,t.progressiveRender,t.themeId,z,x]);(0,_.useEffect)(()=>{ee.current=B},[B]);let ae=(0,_.useCallback)(async()=>{var e;try{(e=navigator==null?void 0:navigator.clipboard)!=null&&e.writeText&&await navigator.clipboard.writeText(I),i(!0),setTimeout(()=>i(!1),1e3)}catch{}},[I]),oe=(0,_.useCallback)(()=>{if(p)try{let e=new Blob([p],{type:`image/svg+xml;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`Failed to export SVG:`,e)}},[p]),V=(0,_.useCallback)((e,n)=>{var r;(r=e.currentTarget)&&!r.disabled&&Rx(e.currentTarget,n,`top`,!1,(e.clientX,e.clientY),t.isDark)},[t.isDark]),H=(0,_.useCallback)(()=>{zx()},[]);return(0,_.useEffect)(()=>{z()},[I,t.loading,t.isDark,z]),(0,_.useEffect)(()=>{t.loading||z(!0)},[t.loading,z]),(0,_.useEffect)(()=>{let e=requestAnimationFrame(()=>R());return()=>cancelAnimationFrame(e)},[te,p,I,R]),(0,_.useEffect)(()=>{E.current=!1,z();let e=requestAnimationFrame(()=>R());if(typeof ResizeObserver<`u`){let e=new ResizeObserver(()=>{R()});N.current=e,M.current&&e.observe(M.current)}return()=>{var t;E.current=!0,O.current!=null&&(clearTimeout(O.current),O.current=null),(t=N.current)==null||t.disconnect(),N.current=null,cancelAnimationFrame(e)}},[z,R]),(0,v.jsxs)(`div`,{ref:A,className:Q(`d2-block my-4 rounded-lg border overflow-hidden shadow-sm`,t.isDark?`border-gray-700/30 bg-gray-900 text-gray-100`:`border-gray-200 bg-white text-gray-900`),children:[t.showHeader&&(0,v.jsxs)(`div`,{className:`d2-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5`,style:{color:`var(--vscode-editor-foreground)`,backgroundColor:`var(--vscode-editor-background)`},children:[(0,v.jsx)(`div`,{className:`flex items-center gap-x-2`,children:(0,v.jsx)(`span`,{className:`text-sm font-medium font-mono`,children:`D2`})}),(0,v.jsxs)(`div`,{className:`flex items-center gap-x-2`,children:[t.showModeToggle&&(0,v.jsxs)(`div`,{className:Q(`flex items-center gap-x-1 rounded-md p-0.5`,t.isDark?`bg-gray-700`:`bg-gray-100`),children:[(0,v.jsx)(`button`,{type:`button`,className:Q(`mode-btn px-2 py-1 text-xs rounded`,!s&&`is-active`),onClick:()=>c(!1),onMouseEnter:e=>V(e,n(`common.preview`)||`Preview`),onFocus:e=>V(e,n(`common.preview`)||`Preview`),onMouseLeave:H,onBlur:H,children:n(`common.preview`)||`Preview`}),(0,v.jsx)(`button`,{type:`button`,className:Q(`mode-btn px-2 py-1 text-xs rounded`,s&&`is-active`),onClick:()=>c(!0),onMouseEnter:e=>V(e,n(`common.source`)||`Source`),onFocus:e=>V(e,n(`common.source`)||`Source`),onMouseLeave:H,onBlur:H,children:n(`common.source`)||`Source`})]}),t.showCopyButton&&(0,v.jsx)(`button`,{type:`button`,className:`d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]`,"aria-label":r?n(`common.copied`)||`Copied`:n(`common.copy`)||`Copy`,onClick:ae,onMouseEnter:e=>V(e,r?n(`common.copied`)||`Copied`:n(`common.copy`)||`Copy`),onFocus:e=>V(e,r?n(`common.copied`)||`Copied`:n(`common.copy`)||`Copy`),onMouseLeave:H,onBlur:H,children:(0,v.jsx)(`svg`,r?{xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M20 6L9 17l-5-5`})}:{xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,v.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]})})}),t.showExportButton&&p&&(0,v.jsx)(`button`,{type:`button`,className:`d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]`,"aria-label":n(`common.export`)||`Export`,onClick:oe,onMouseEnter:e=>V(e,n(`common.export`)||`Export`),onFocus:e=>V(e,n(`common.export`)||`Export`),onMouseLeave:H,onBlur:H,children:(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M12 3v12m0-12l-4 4m4-4l4 4M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4`})})}),t.showCollapseButton&&(0,v.jsx)(`button`,{type:`button`,className:`d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]`,"aria-pressed":a,onClick:()=>o(e=>!e),onMouseEnter:e=>V(e,a?n(`common.expand`)||`Expand`:n(`common.collapse`)||`Collapse`),onFocus:e=>V(e,a?n(`common.expand`)||`Expand`:n(`common.collapse`)||`Collapse`),onMouseLeave:H,onBlur:H,children:(0,v.jsx)(`svg`,{style:{transform:`rotate(${a?0:90}deg)`},xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m9 18l6-6l-6-6`})})})]})]}),!a&&(0,v.jsx)(`div`,{ref:M,className:`d2-block-body`,style:re,children:t.loading&&!L?(0,v.jsxs)(`div`,{className:`d2-source px-4 py-4`,children:[(0,v.jsx)(`pre`,{className:`d2-code`,children:(0,v.jsx)(`code`,{children:I})}),d&&(0,v.jsx)(`p`,{className:`d2-error mt-2 text-xs`,children:d})]}):(0,v.jsx)(v.Fragment,{children:(0,v.jsxs)(`div`,te?{className:`d2-source px-4 py-4`,children:[(0,v.jsx)(`pre`,{className:`d2-code`,children:(0,v.jsx)(`code`,{children:I})}),d&&(0,v.jsx)(`p`,{className:`d2-error mt-2 text-xs`,children:d})]}:{className:`d2-render`,style:ne,children:[(0,v.jsx)(`div`,{className:`d2-svg`,dangerouslySetInnerHTML:{__html:p}}),d&&(0,v.jsx)(`p`,{className:`d2-error px-4 pb-3 text-xs`,children:d})]})})})]})}function uS(e){let{node:t,ctx:n,renderNode:r,indexKey:i}=e,a=Array.isArray(t.items)?t.items:[];return(0,v.jsx)(`dl`,{className:`definition-list`,"data-index-key":i,children:a.map((e,t)=>(0,v.jsxs)(`div`,{className:`mb-4`,children:[(0,v.jsx)(`dt`,{className:`definition-term font-semibold`,children:n&&r?sb(e.term,n,`${String(i??`definition`)}-term-${t}`,r):null}),(0,v.jsx)(`dd`,{className:`definition-desc ml-4`,children:n&&r?sb(e.definition,n,`${String(i??`definition`)}-desc-${t}`,r):null})]},`${String(i??`definition`)}-${t}`))})}function dS(e){let{node:t}=e;return(0,v.jsx)(`span`,{className:`emoji-node`,children:t.name??t.markup})}function fS(e){return(0,v.jsx)(`em`,{className:`emphasis-node`,children:e.children})}function pS(e){let{node:t}=e,n=(0,_.useCallback)(e=>{if(e.preventDefault(),typeof document>`u`)return;let n=document.getElementById(`fnref-${String(t.id??``)}`);n&&n.scrollIntoView({behavior:`smooth`})},[t.id]);return(0,v.jsx)(`a`,{className:`footnote-anchor text-sm hover:underline cursor-pointer`,href:`#fnref-${t.id}`,title:`返回引用 ${t.id}`,onClick:n,children:`↩︎`})}function mS(e){let{node:t,ctx:n,renderNode:r,indexKey:i}=e;return(0,v.jsx)(`div`,{id:`fnref--${t.id}`,className:`footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2`,children:(0,v.jsx)(`div`,{className:`flex-1`,children:n&&r?ob(t.children,n,String(i??`footnote-${t.id}`),r):null})})}function hS(e){let{node:t}=e,n=(0,_.useMemo)(()=>`#fnref--${t.id}`,[t.id]),r=(0,_.useMemo)(()=>({href:n}),[n]),i=(0,_.useCallback)(e=>{if(e.preventDefault(),typeof document>`u`)return;let t=document.querySelector(n);t&&t.scrollIntoView({behavior:`smooth`})},[n]);return(0,v.jsx)(`sup`,{id:`fnref-${t.id}`,className:`footnote-reference`,onClick:i,children:(0,v.jsxs)(`span`,{...r,title:`查看脚注 ${t.id}`,className:`footnote-link cursor-pointer`,children:[`[`,t.id,`]`]})})}function gS(e){return(0,v.jsx)(`br`,{className:`hard-break`})}function _S(e){let{node:t,ctx:n,renderNode:r,indexKey:i,children:a}=e,o=Math.min(6,Math.max(1,Number(t.level)||1)),s=`h${o}`,{class:c,className:l,style:u,...d}=t?.attrs??{};return(0,v.jsx)(s,{dir:`auto`,className:Q(`heading-node font-semibold`,`heading-${o}`,c,l),...typeof u==`object`&&u?{style:u}:{},...d,children:a??(n&&r?ob(t.children,n,String(i??`heading-${o}`),r):null)})}function vS(e){return(0,v.jsx)(`mark`,{className:`highlight-node`,children:e.children})}function yS(e){let{node:t,placeholder:n,customId:r}=e,i=e.htmlPolicy??e.ctx?.htmlPolicy??`safe`,a=Tx(),[o,s]=(0,_.useState)(null),c=(0,_.useRef)(null),[l,u]=(0,_.useState)(()=>typeof window>`u`),[d,f]=(0,_.useState)(t.content),p=!!t.loading,m=(0,_.useSyncExternalStore)(fb,pb,pb),h=(0,_.useMemo)(()=>({...e.customComponents??e.ctx?.customComponents??hb(r),...e.ctx?.htmlComponents??{}}),[r,e.ctx?.customComponents,e.ctx?.htmlComponents,e.customComponents,m]),g=(0,_.useMemo)(()=>({...h,...e.ctx?.streamingComponents??{}}),[h,e.ctx?.streamingComponents]);(0,_.useEffect)(()=>{var e;if(typeof window>`u`)return void u(!0);if((e=c.current)==null||e.destroy(),c.current=null,!p)return u(!0),void f(t.content);if(!o)return void u(!1);let n=a(o,{rootMargin:`400px`});return c.current=n,n.isVisible()&&u(!0),n.whenVisible.then(()=>u(!0)).catch(()=>{}),()=>{n.destroy(),c.current=null}},[o,p,t.content,a]),(0,_.useEffect)(()=>()=>{var e;(e=c.current)==null||e.destroy(),c.current=null},[]),(0,_.useEffect)(()=>{p&&!l||f(t.content)},[p,t.content,l]);let y=(0,_.useMemo)(()=>{let e=ab(xy(t.attrs??void 0,i));return e?Wb(e):void 0},[i,t.attrs]),b=(0,_.useMemo)(()=>String(t.tag??``).trim(),[t.tag]),x=(0,_.useMemo)(()=>Kc(b),[b]),S=(0,_.useMemo)(()=>{let e=ab(xy(t.attrs??void 0,i,b));return e?Wb(e):void 0},[i,t.attrs,b]),C=(0,_.useMemo)(()=>Cy(by(xy(t.attrs??void 0,i,x))),[i,t.attrs,x]),w=(0,_.useMemo)(()=>Array.isArray(t.children)?t.children:[],[t.children]),T=w.length>0&&!!b&&!bc.has(b.toLowerCase())&&!ly(b,i)&&!!e.ctx&&!!e.renderNode,E=(0,_.useMemo)(()=>function(e){let t={...e||{}},n=typeof t.className==`string`?t.className.trim():``;return t.className=n?`html-block-node ${n}`:`html-block-node`,t}(S),[S]),D=(0,_.useMemo)(()=>i!==`escape`&&Jb(t.content??``,g),[g,i,t.content]),O=(0,_.useMemo)(()=>D&&t.content?rx(t.content,h,i,{ctx:e.ctx,keyPrefix:String(e.indexKey??`html-block`),nodeComponents:e.ctx?.streamingComponents,propComponents:e.ctx?.htmlComponents,renderNode:e.renderNode,sourceNode:t}):null,[h,i,t.autoClosed,t.content,t.loading,e.ctx,e.indexKey,e.renderNode,D]),k=(0,_.useMemo)(()=>ky(d??``,i),[i,d]),A=(0,_.useMemo)(()=>T&&e.ctx&&e.renderNode?ob(w,e.ctx,`${String(e.indexKey??`html-block`)}-structured`,e.renderNode):null,[T,e.ctx,e.indexKey,e.renderNode,w]),j=x?e.ctx?.htmlComponents?.[x]:void 0,M=(0,v.jsx)(`div`,{className:`html-block-node__placeholder`,children:n??(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`span`,{className:`html-block-node__placeholder-bar`}),(0,v.jsx)(`span`,{className:`html-block-node__placeholder-bar w-4/5`}),(0,v.jsx)(`span`,{className:`html-block-node__placeholder-bar w-2/3`})]})});return T&&j?_.createElement(j,C,A):T?_.createElement(b,{...E,ref:s},l?A:M):(0,v.jsx)(`div`,{ref:s,className:`html-block-node`,...y,children:l?D&&O?(0,v.jsx)(v.Fragment,{children:O}):(0,v.jsx)(`div`,{dangerouslySetInnerHTML:{__html:k}}):M})}var bS=(()=>{try{return!1}catch{}return!1})();function xS(e){bS&&console.warn(e)}function SS(e,t,n=!1){let r=Object.entries(t??{}),i=r.length>0?r.map(([e,t])=>t===``?` ${e}`:` ${e}="${t}"`).join(``):``;return n?`<${e}${i} />`:`<${e}${i}>`}function CS(e,t){Array.isArray(t)?e.push(...t):t!=null&&e.push(t)}function wS(e,t){for(let n of Gb(e)){if(n.type!==`tag_open`&&n.type!==`self_closing`)continue;let e=n.tagName??``;if(qb(e,t)&&gb(t[e]||t[e.toLowerCase()])===`block`)return!0}return!1}function TS(e,t){return t.nodeComponents?.[e]||t.nodeComponents?.[e.toLowerCase()]}function ES(e){if(e==null||typeof e==`boolean`)return``;if(typeof e==`string`||typeof e==`number`)return String(e);if(Array.isArray(e))return e.map(ES).join(``);if(!_.isValidElement(e))return``;let t=e;if(typeof t.type!=`string`)return ES(t.props.children);let n=Object.entries(t.props).filter(([e,t])=>e!==`children`&&e!==`key`&&e!==`ref`&&t!=null&&typeof t!=`boolean`).map(([e,t])=>` ${e===`className`?`class`:e}="${String(t)}"`).join(``);return`<${t.type}${n}>${ES(t.props.children)}</${t.type}>`}function DS(e){return Object.entries(e).map(([e,t])=>[e,t===``?null:t])}function OS(e){let t=e.sourceNode,n=!0!==e.ctx?.final&&(!1===e.ctx?.final||!!t?.loading);return{loading:n,autoClosed:n||!!t?.autoClosed}}function kS(e,t,n,r,i,a,o,s,c,l){let u=qb(e,r),d=!!TS(e,o);if(yc.has(e.toLowerCase())||!u&&!d&&uy(e,a))return null;if(!u&&!d&&ly(e,a))return[SS(e,t),...n,`</${e}>`];let f=Kb(t,a,e),p=f.key,m=p!=null&&p!==``?p:i;if(d)return function(e,t,n,r,i,a,o,s=OS(i)){let c=Kc(e),l=a??function(e){return e.map(ES).join(``)}(n),u={type:c,tag:c,attrs:DS(t),content:l,raw:o??`${SS(e,t)}${l}</${e}>`,loading:s.loading,autoClosed:s.autoClosed};if(i.ctx&&i.renderNode)return i.renderNode(u,r,i.ctx);let d=TS(e,i);return d?_.createElement(d,{key:r,node:u}):null}(e,t,n,String(m),o,s,c,l);if(u){let t=r[e]||r[e.toLowerCase()],i=Cy(f);return _.createElement(t,{...i,key:m},...n)}return _.createElement(e,{...Wb(f),key:m},...n)}function AS(e){let{node:t,customId:n}=e,r=e.htmlPolicy??e.ctx?.htmlPolicy??`safe`,i=(0,_.useRef)(null),[a,o]=(0,_.useState)(!1);(0,_.useEffect)(()=>{o(!0)},[]);let s=_.useMemo(()=>({...e.ctx?.customComponents??hb(n),...e.ctx?.htmlComponents??{}}),[n,e.ctx?.customComponents,e.ctx?.htmlComponents]),c=_.useMemo(()=>({...s,...e.ctx?.streamingComponents??{}}),[s,e.ctx?.streamingComponents]),l=_.useMemo(()=>ky(t.content??``,r),[r,t.content]),u=_.useMemo(()=>String(t.tag??``).trim(),[t.tag]),d=_.useMemo(()=>Kc(u),[u]),f=_.useMemo(()=>Array.isArray(t.children)?t.children:[],[t.children]),p=_.useMemo(()=>Cy(by(xy(t.attrs??void 0,r,d))),[r,t.attrs,d]),m=d?e.ctx?.htmlComponents?.[d]:void 0,h=f.length>0&&!!u&&r!==`escape`&&!ly(u,r)&&!!e.ctx&&!!e.renderNode&&!!m,g=_.useMemo(()=>h&&e.ctx&&e.renderNode?ob(f,e.ctx,`${String(e.indexKey??`html-inline`)}-structured`,e.renderNode):null,[h,e.ctx,e.indexKey,e.renderNode,f]),y=_.useMemo(()=>{let n=t.content;if(!n)return{mode:`html`,content:``};if(r===`escape`||!Jb(n,c))return{mode:`html`,content:n};let i=function(e,t,n=`safe`,r={}){if(!e)return[];try{return function(e,t,n=`safe`,r={}){let i=0,a=r.keyPrefix??`ms-html`,o=[],s=[];for(let c of e)if(c.type===`text`){if(o.length>0&&o[o.length-1].hardBlocked)continue;(o.length>0?o[o.length-1].children:s).push(c.content),o.length>0&&o[o.length-1].sourceParts.push(c.content)}else if(c.type===`self_closing`){let e=c.attrs||{},l=SS(c.tagName,e,!0),u=qb(c.tagName,t),d=!!TS(c.tagName,r);if(yc.has(c.tagName.toLowerCase())||!u&&!d&&uy(c.tagName,n))continue;if(!u&&!d&&ly(c.tagName,n)){(o.length>0?o[o.length-1].children:s).push(l),o.length>0&&o[o.length-1].sourceParts.push(l);continue}let f=kS(c.tagName,e,[],t,`${a}-${i++}`,n,r,``,l,{loading:!1,autoClosed:!1});CS(o.length>0?o[o.length-1].children:s,f),o.length>0&&o[o.length-1].sourceParts.push(l)}else if(c.type===`tag_open`){let e=o.length>0&&o[o.length-1].hardBlocked,i=qb(c.tagName,t),a=!!TS(c.tagName,r);o.push({tagName:c.tagName,children:[],attrs:c.attrs,sourceParts:[],customComponent:i||a,hardBlocked:e||yc.has(c.tagName.toLowerCase())||!i&&!a&&uy(c.tagName,n),softBlocked:!e&&!i&&!a&&ly(c.tagName,n)})}else if(c.type===`tag_close`){let e=c.tagName.toLowerCase(),l=-1;for(let t=o.length-1;t>=0;t--)if(o[t].tagName.toLowerCase()===e){l=t;break}if(l!==-1)for(;o.length>l;){let c=o.pop(),u=c.sourceParts.join(``),d=`${SS(c.tagName,c.attrs||{})}${u}</${c.tagName}>`,f;if(c.hardBlocked)f=null;else if(c.softBlocked)f=[SS(c.tagName,c.attrs||{}),...c.children,`</${c.tagName}>`];else{let o=c.tagName.toLowerCase()===e?{loading:!1,autoClosed:!1}:OS(r);f=kS(c.tagName,c.attrs||{},c.children,t,`${a}-${i++}`,n,r,u,d,o)}o.length>0?CS(o[o.length-1].children,f):CS(s,f),o.length>0&&!c.hardBlocked&&o[o.length-1].sourceParts.push(d),c.tagName.toLowerCase()!==e&&o.length>l&&xS(`Auto-closing unclosed tag: <${c.tagName}>`)}else xS(`Ignoring closing tag with no matching opening tag: </${c.tagName}>`)}for(;o.length>0;){let e=o.pop(),c=e.sourceParts.join(``),l=`${SS(e.tagName,e.attrs||{})}${c}`,u;u=e.hardBlocked?null:e.softBlocked?[SS(e.tagName,e.attrs||{}),...e.children,`</${e.tagName}>`]:kS(e.tagName,e.attrs||{},e.children,t,`${a}-${i++}`,n,r,c,l,OS(r)),CS(s,u),o.length>0&&!e.hardBlocked&&o[o.length-1].sourceParts.push(l),xS(`Auto-closing unclosed tag: <${e.tagName}>`)}return s}(Gb(e),t,n,r)}catch(e){return i=e,bS&&console.error(`Failed to parse HTML to React nodes:`,i),null}var i}(n,s,r,{ctx:e.ctx,keyPrefix:String(e.indexKey??`html-inline`),nodeComponents:e.ctx?.streamingComponents,renderNode:e.renderNode,sourceNode:t});return i===null?{mode:`html`,content:n}:{mode:`dynamic`,block:wS(n,c),nodes:i}},[s,c,r,t.autoClosed,t.content,t.loading,e.ctx,e.indexKey,e.renderNode]);return(0,_.useEffect)(()=>{if(!a||!i.current||y.mode!==`html`)return;let e=i.current;e.innerHTML=``;let t=document.createElement(`template`);t.innerHTML=l,e.appendChild(t.content.cloneNode(!0))},[y.mode,a,l]),!t.loading||t.autoClosed||h||y.mode===`dynamic`?h?_.createElement(m,p,g):y.mode===`dynamic`?y.block?(0,v.jsx)(v.Fragment,{children:y.nodes}):(0,v.jsx)(`span`,{className:`html-inline-node`,style:{display:`inline`},children:y.nodes}):(0,v.jsx)(`span`,{ref:i,className:`html-inline-node`,style:{display:`inline`}}):(0,v.jsx)(`span`,{className:`html-inline-node html-inline-node--loading`,children:t.content})}var jS={fallbackSrc:``,lazy:!0,usePlaceholder:!0};function MS(e,t,n){return n||e?{src:e,stage:`primary`}:t?{src:t,stage:`fallback`}:{src:``,stage:`failed`}}function NS(e){let t={...jS,...e},n=Ic(t.node.src),r=Ic(t.fallbackSrc),i=MS(n,r,t.node.loading),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(i.src),[d,f]=(0,_.useState)(i.stage),p=l;return(0,_.useEffect)(()=>{let e=MS(n,r,t.node.loading);u(e.src),f(e.stage),o(!1),c(e.stage===`failed`)},[n,r,t.node.loading]),!t.node.loading&&d!==`failed`&&p?(0,v.jsx)(`img`,{src:p,alt:String(t.node.alt??t.node.title??``),title:String(t.node.title??t.node.alt??``),className:`image-node__img`+(a?` is-loaded`:``),loading:t.lazy?`lazy`:`eager`,decoding:`async`,tabIndex:a?0:-1,"aria-label":t.node.alt??`Preview image`,onError:()=>{var e;if(d===`primary`&&r&&r!==l)return u(r),f(`fallback`),o(!1),void c(!1);f(`failed`),c(!0),(e=t.onError)==null||e.call(t,l)},onLoad:()=>{var e;o(!0),c(!1),(e=t.onLoad)==null||e.call(t,p)},onClick:e=>{var n;e.preventDefault(),a&&!s&&((n=t.onClick)==null||n.call(t,[e,p]))}},`image`):t.node.loading&&!s?(0,v.jsx)(`span`,{className:`image-node__placeholder`,children:t.usePlaceholder?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`span`,{className:`image-node__spinner`,"aria-hidden":`true`}),(0,v.jsx)(`span`,{className:`image-node__placeholder-text`,children:`Loading image...`})]}):(0,v.jsx)(`span`,{className:`image-node__placeholder-text`,children:t.node.raw??`Loading image…`})},`placeholder`):t.node.loading||d!==`failed`?null:(0,v.jsxs)(`span`,{className:`image-node__error`,children:[(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,v.jsx)(`path`,{fill:`currentColor`,d:`M2 2h20v10h-2V4H4v9.586l5-5L14.414 14L13 15.414l-4-4l-5 5V20h8v2H2zm13.547 5a1 1 0 1 0 0 2a1 1 0 0 0 0-2m-3 1a3 3 0 1 1 6 0a3 3 0 0 1-6 0m3.625 6.757L19 17.586l2.828-2.829l1.415 1.415L20.414 19l2.829 2.828l-1.415 1.415L19 20.414l-2.828 2.829l-1.415-1.415L17.586 19l-2.829-2.828z`})}),(0,v.jsx)(`span`,{className:`image-node__placeholder-text`,children:`Image failed to load`})]})}var PS=null,FS=null,IS=(0,v.jsx)(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 291 300`,fill:`none`,className:`w-4 h-4 flex-shrink-0`,xmlns:`http://www.w3.org/2000/svg`,children:(0,v.jsxs)(`g`,{children:[(0,v.jsx)(`path`,{d:`M140.904 239.376C128.83 239.683 119.675 239.299 115.448 243.843C110.902 248.07 111.288 257.227 110.979 269.302C111.118 274.675 111.118 279.478 111.472 283.52C111.662 285.638 111.95 287.547 112.406 289.224C112.411 289.243 112.416 289.259 112.422 289.28C112.462 289.419 112.496 289.558 112.539 289.691C113.168 291.787 114.088 293.491 115.446 294.758C116.662 296.064 118.283 296.963 120.264 297.69C120.36 297.614 120.464 297.646 120.555 297.675C120.56 297.68 120.56 297.68 120.566 297.68C120.848 297.768 121.142 297.846 121.443 297.923C121.454 297.923 121.464 297.928 121.478 297.934C122.875 298.272 124.424 298.507 126.11 298.678C126.326 298.696 126.542 298.718 126.763 298.739C130.79 299.086 135.558 299.088 140.904 299.222C152.974 298.912 162.128 299.302 166.36 294.758C170.904 290.526 170.515 281.371 170.824 269.302C170.515 257.227 170.907 248.07 166.36 243.843C162.131 239.299 152.974 239.683 140.904 239.376Z`,fill:`#FF6376`}),(0,v.jsx)(`path`,{d:`M21.2155 128.398C12.6555 128.616 6.16484 128.339 3.16751 131.56C-0.0538222 134.56 0.218178 141.054 -0.000488281 149.608C0.218178 158.168 -0.0538222 164.659 3.16751 167.656C6.16484 170.878 12.6555 170.606 21.2155 170.824C25.0262 170.726 28.4288 170.726 31.2955 170.475C32.7968 170.342 34.1488 170.136 35.3382 169.814C35.3542 169.811 35.3648 169.806 35.3782 169.803C35.4768 169.774 35.5755 169.747 35.6688 169.718C37.1568 169.272 38.3648 168.622 39.2635 167.656C40.1915 166.795 40.8262 165.646 41.2715 164.243C41.2875 164.174 41.3115 164.102 41.3328 164.035C41.3328 164.035 41.3355 164.032 41.3355 164.027C41.3968 163.827 41.4529 163.622 41.5062 163.406C41.5062 163.398 41.5115 163.392 41.5142 163.382C41.7542 162.392 41.9222 161.294 42.0422 160.096C42.0555 159.944 42.0715 159.792 42.0848 159.635C42.3328 156.779 42.3328 153.398 42.4262 149.608C42.2075 141.054 42.4848 134.56 39.2635 131.56C36.2635 128.339 29.7728 128.616 21.2155 128.398Z`,fill:`#FFCCCC`}),(0,v.jsx)(`path`,{d:`M81.0595 184.171C70.8568 184.433 63.1208 184.102 59.5475 187.942C55.7075 191.518 56.0328 199.254 55.7742 209.454C56.0328 219.657 55.7075 227.393 59.5475 230.963C63.1208 234.803 70.8568 234.478 81.0595 234.739C85.6008 234.622 89.6595 234.622 93.0728 234.323C94.8648 234.163 96.4755 233.921 97.8942 233.534C97.9102 233.529 97.9235 233.526 97.9422 233.521C98.0568 233.486 98.1742 233.457 98.2888 233.422C100.06 232.889 101.5 232.113 102.569 230.963C103.676 229.937 104.433 228.566 104.964 226.894C104.985 226.811 105.012 226.726 105.036 226.646C105.041 226.643 105.041 226.643 105.041 226.638C105.116 226.401 105.18 226.153 105.244 225.897C105.244 225.889 105.249 225.881 105.254 225.867C105.54 224.689 105.74 223.379 105.881 221.953C105.9 221.771 105.916 221.59 105.934 221.403C106.228 218.001 106.228 213.969 106.342 209.454C106.081 199.254 106.412 191.518 102.572 187.942C98.9955 184.102 91.2568 184.433 81.0595 184.171Z`,fill:`#FF939F`}),(0,v.jsx)(`path`,{d:`M260.591 151.87C215.652 151.87 203.02 164.523 203.02 209.462H198.476C198.476 164.523 185.836 151.881 140.895 151.881V147.337C185.836 147.337 198.487 134.705 198.487 89.7659H203.02C203.02 134.705 215.652 147.337 260.591 147.337V151.87ZM286.052 124.158C281.82 119.614 272.66 120.001 260.591 119.689C248.521 119.385 239.361 119.771 235.129 115.227C230.585 110.995 230.983 101.846 230.671 89.7659C230.513 83.7312 230.535 78.4272 230.023 74.1019C229.513 69.7659 228.481 66.4219 226.209 64.3046C221.967 59.7606 212.817 60.1472 200.748 59.8459C188.681 60.1472 179.519 59.7606 175.287 64.3046C170.753 68.5366 171.129 77.6966 170.828 89.7659C170.516 101.835 170.9 110.995 166.356 115.227C162.124 119.771 152.985 119.374 140.905 119.689C138.873 119.739 136.924 119.771 135.071 119.811C119.313 118.697 106.337 112.318 106.337 89.7659C106.212 84.6699 106.233 80.1792 105.807 76.5206C105.367 72.8726 104.492 70.0379 102.575 68.2566C99.0013 64.4112 91.2573 64.7446 81.0653 64.4832C70.86 64.7446 63.1186 64.4112 59.5533 68.2566C55.708 71.8299 56.0306 79.5632 55.7693 89.7659C56.0306 99.9686 55.708 107.702 59.5533 111.278C63.1186 115.113 70.86 114.79 81.0653 115.049C103.617 115.049 109.996 128.035 111.1 143.803C111.068 145.659 111.028 147.587 110.975 149.619C111.121 154.987 111.121 159.79 111.476 163.835C111.663 165.95 111.945 167.857 112.404 169.534C112.412 169.555 112.412 169.566 112.423 169.598C112.465 169.734 112.497 169.867 112.537 170.003C113.164 172.099 114.092 173.809 115.447 175.07C116.665 176.371 118.281 177.278 120.271 177.905C120.364 177.934 120.46 177.955 120.564 177.987C120.855 178.081 121.145 178.153 121.439 178.238C121.46 178.238 121.471 178.238 121.479 178.249C122.876 178.582 124.42 178.822 126.108 178.987C126.327 179.009 126.545 179.03 126.764 179.051C130.788 179.395 135.559 179.395 140.905 179.529C152.975 179.843 162.124 179.457 166.356 184.001C170.9 188.233 170.516 197.371 170.828 209.451C171.129 221.529 170.743 230.681 175.287 234.91C179.519 239.454 188.681 239.07 200.748 239.371C206.127 239.235 210.921 239.235 214.975 238.881C217.079 238.694 218.985 238.403 220.676 237.955C220.695 237.945 220.705 237.934 220.727 237.934C220.873 237.891 220.999 237.859 221.135 237.819C223.228 237.193 224.937 236.265 226.209 234.91C227.511 233.691 228.409 232.065 229.044 230.097C229.065 230.003 229.095 229.899 229.127 229.803V229.793C229.22 229.513 229.295 229.222 229.367 228.918C229.367 228.897 229.377 228.897 229.377 228.878C229.721 227.481 229.951 225.937 230.127 224.249C230.137 224.03 230.169 223.811 230.191 223.593C230.535 219.571 230.535 214.798 230.671 209.451C230.972 197.371 230.585 188.233 235.129 184.001C239.361 179.457 248.511 179.843 260.591 179.529C272.66 179.227 281.82 179.614 286.052 175.07C290.596 170.838 290.209 161.689 290.511 149.619C290.209 137.539 290.596 128.379 286.052 124.158Z`,fill:`#FF356A`}),(0,v.jsx)(`path`,{d:`M112.405 49.848C112.411 49.8694 112.416 49.8827 112.421 49.904C112.461 50.0427 112.499 50.1814 112.539 50.3147C113.171 52.4134 114.088 54.1147 115.448 55.384C116.661 56.6907 118.283 57.5894 120.264 58.2134C120.36 58.24 120.464 58.2694 120.555 58.3014C120.56 58.3067 120.56 58.3067 120.565 58.3067C120.848 58.3947 121.141 58.4694 121.443 58.5467C121.453 58.5467 121.464 58.552 121.48 58.5574C122.875 58.896 124.424 59.1334 126.112 59.3014C126.325 59.3227 126.541 59.3414 126.763 59.3627C130.789 59.712 135.56 59.712 140.904 59.8454C152.973 59.5387 162.128 59.928 166.36 55.384C170.907 51.152 170.515 41.9947 170.824 29.9254C170.517 17.8507 170.907 8.69602 166.363 4.46935C162.131 -0.0746511 152.973 0.309349 140.904 1.52588e-05C128.829 0.309349 119.675 -0.0746511 115.448 4.46935C110.904 8.69602 111.288 17.8507 110.979 29.9254C111.117 35.3014 111.117 40.1014 111.472 44.144C111.661 46.2614 111.949 48.1707 112.405 49.848Z`,fill:`#FF6376`})]})}),LS={maxHeight:`500px`,loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function RS(e){let t={...LS,...e},{t:n}=kx(),[r,i]=(0,_.useState)(!1),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(()=>typeof window>`u`),m=t.node.code,h=(0,_.useMemo)(()=>t.maxHeight&&t.maxHeight!==`none`?ix(t.maxHeight):null,[t.maxHeight]),g=(0,_.useMemo)(()=>ix(t.estimatedPreviewHeightPx)??ax(m),[m,t.estimatedPreviewHeightPx]),[y,b]=(0,_.useState)(()=>`${ox(g,360,h)}px`),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(1),[D,O]=(0,_.useState)({x:0,y:0}),[k,A]=(0,_.useState)(!1),j=(0,_.useRef)(null),M=(0,_.useRef)(null),N=(0,_.useRef)(null),P=(0,_.useRef)(null),ee=(0,_.useRef)(null),F=(0,_.useRef)({x:0,y:0}),I=(0,_.useRef)(null),te=(0,_.useRef)(0),L=Tx(),ne=(0,_.useCallback)(()=>{let e=j.current;return ix(e?getComputedStyle(e).getPropertyValue(`--ms-size-diagram-min-height`).trim():``)??360},[]),re=(0,_.useCallback)(()=>ox(g,ne(),h),[g,h,ne]),R=(0,_.useCallback)(e=>{let n=re();if(!t.maxHeight||t.maxHeight===`none`)return`${Math.max(e,n)}px`;let r=Number.parseFloat(String(t.maxHeight));return Number.isFinite(r)?`${Math.max(Math.min(e,r),n)}px`:`${Math.max(e,n)}px`},[t.maxHeight,re]),z=(0,_.useCallback)(()=>{let e=j.current;if(!e)return;let t=e.scrollHeight;t>0&&b(R(t))},[R]);(0,_.useEffect)(()=>{c||o||b(e=>{let t=ix(e),n=re();return t!=null&&t>=n?e:`${n}px`})},[o,re,c]);let ie=(0,_.useCallback)(async()=>{var e;try{await navigator.clipboard?.writeText(m),i(!0),(e=t.onCopy)==null||e.call(t,m),setTimeout(()=>i(!1),1e3)}catch{}},[m,t]),B=(0,_.useCallback)(async()=>{var e,n,r,i,o,s,c,l;if(!f||!j.current)return;let u=j.current,d=m,p=!1===t.loading,h=++te.current,g=null,_=null;try{let t=await async function(){return FS||PS||(PS=a(()=>import(`./infographic_markstream-react-C3vVus-4.js`).then(e=>{let t=e&&e.default?e.default:e,n=t;return typeof t==`function`&&t.prototype&&t.prototype.render?n=t:e.Infographic?n=e.Infographic:t&&t.Infographic&&(n=t.Infographic),FS=n,n}),[]).catch(e=>(console.warn(`Failed to load @antv/infographic`,e),null)),PS)}();if(h!==te.current||u!==j.current)return;if(!t)throw Error(`Infographic library failed to load.`);_=Array.from(u.childNodes),g=new t({container:u,width:`100%`,height:`100%`});let o=``,s=!1;if((e=g.on)==null||e.call(g,`error`,e=>{o=(Array.isArray(e)?e:[e]).map(e=>e instanceof Error?e.message:typeof e==`string`?e:String(e&&typeof e==`object`&&`message`in e?e.message??``:e??``)).filter(Boolean).join(`; `)}),(n=g.on)==null||n.call(g,`rendered`,()=>{s=!0}),g.render(d),o)throw Error(o);let c=Array.from(u.childNodes),l=c.length>0&&(c.length!==_.length||c.some((e,t)=>e!==_?.[t]));if(!s&&!l)throw Error(`Infographic render returned empty output.`);(i=(r=I.current)?.destroy)==null||i.call(r),I.current=g,g=null,S(!0),w(!1),setTimeout(()=>{z()},0)}catch(e){if(h!==te.current||u!==j.current)return;(o=g?.destroy)==null||o.call(g),g=null,p&&!1===t.loading&&d===m?(console.error(`Failed to render infographic:`,e),(c=(s=I.current)?.destroy)==null||c.call(s),I.current=null,S(!1),w(!0),u.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${e instanceof Error?e.message:`Unknown error`}</div>`):_&&u.replaceChildren(..._)}finally{(l=g?.destroy)==null||l.call(g)}},[m,t.loading,z,f]);(0,_.useEffect)(()=>{let e=M.current;if(!e)return;let t=L(e,{rootMargin:`160px`});return N.current=t,t.isVisible()&&p(!0),t.whenVisible.then(()=>p(!0)),()=>{t.destroy(),N.current=null}},[L]),(0,_.useEffect)(()=>{!f||c||o||B()},[m,o,B,c,f]),(0,_.useEffect)(()=>()=>{var e,t;te.current+=1,I.current&&=((t=(e=I.current).destroy)==null||t.call(e),null)},[]);let ae=(0,_.useCallback)(()=>{d(!1),P.current&&(P.current.innerHTML=``),ee.current=null,document.body.style.overflow=``},[]),oe=(0,_.useCallback)(()=>{d(!0),document.body.style.overflow=`hidden`},[]);(0,_.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&ae()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,ae]),(0,_.useEffect)(()=>{u&&setTimeout(()=>{if(j.current&&P.current){P.current.innerHTML=``;let e=document.createElement(`div`);Object.assign(e.style,{transition:`transform 0.1s ease`,transformOrigin:`center center`,width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`});let t=j.current.cloneNode(!0);t.classList.add(`fullscreen`),t.style.height=`auto`,e.appendChild(t),P.current.appendChild(e),ee.current=e,e.style.transform=`translate(${D.x}px, ${D.y}px) scale(${T})`}},0)},[u]),(0,_.useEffect)(()=>{u&&ee.current&&(ee.current.style.transform=`translate(${D.x}px, ${D.y}px) scale(${T})`)},[u,D,T]);let V=(0,_.useCallback)(()=>{let e=j.current?.querySelector(`svg`);if(!e)return;let t=new XMLSerializer().serializeToString(e),n=new Blob([t],{type:`image/svg+xml;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`infographic-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},[]),H=e=>{A(!0);let t=`touches`in e?e.touches[0].clientX:e.clientX,n=`touches`in e?e.touches[0].clientY:e.clientY;F.current={x:t-D.x,y:n-D.y}},se=e=>{if(!k)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=`touches`in e?e.touches[0].clientY:e.clientY;O({x:t-F.current.x,y:n-F.current.y})},ce=()=>A(!1),le=t.isDark?`p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200`:`p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700`,ue=c||o;return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{ref:M,"data-markstream-infographic":`1`,"data-markstream-mode":c?`source`:C?`error`:x?`preview`:`pending`,className:Q(`my-4 rounded-lg border overflow-hidden shadow-sm`,t.isDark?`border-gray-700/30`:`border-gray-200`,{"is-rendering":t.loading}),children:[t.showHeader&&(0,v.jsxs)(`div`,{className:Q(`flex justify-between items-center px-4 py-2.5 border-b`,t.isDark?`bg-gray-800 border-gray-700/30`:`bg-gray-50 border-gray-200`),children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-x-2 overflow-hidden`,children:[IS,(0,v.jsx)(`span`,{className:Q(`text-sm font-medium font-mono truncate`,t.isDark?`text-gray-400`:`text-gray-600`),children:`Infographic`})]}),t.showModeToggle&&(0,v.jsxs)(`div`,{className:Q(`flex items-center gap-x-1 rounded-md p-0.5`,t.isDark?`bg-gray-700`:`bg-gray-100`),children:[(0,v.jsx)(`button`,{className:Q(`px-2.5 py-1 text-xs rounded transition-colors`,c?t.isDark?`text-gray-400 hover:text-gray-200`:`text-gray-500 hover:text-gray-700`:t.isDark?`bg-gray-600 text-gray-200 shadow-sm`:`bg-white text-gray-700 shadow-sm`),onClick:()=>l(!1),onMouseEnter:e=>Rx(e.currentTarget,n(`common.preview`)||`Preview`,`top`,!1,0,t.isDark),onMouseLeave:()=>zx(),children:(0,v.jsxs)(`div`,{className:`flex items-center gap-x-1`,children:[(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0`}),(0,v.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}),(0,v.jsx)(`span`,{children:n(`common.preview`)||`Preview`})]})}),(0,v.jsx)(`button`,{className:Q(`px-2.5 py-1 text-xs rounded transition-colors`,c?t.isDark?`bg-gray-600 text-gray-200 shadow-sm`:`bg-white text-gray-700 shadow-sm`:t.isDark?`text-gray-400 hover:text-gray-200`:`text-gray-500 hover:text-gray-700`),onClick:()=>l(!0),onMouseEnter:e=>Rx(e.currentTarget,n(`common.source`)||`Source`,`top`,!1,0,t.isDark),onMouseLeave:()=>zx(),children:(0,v.jsxs)(`div`,{className:`flex items-center gap-x-1`,children:[(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m16 18l6-6l-6-6M8 6l-6 6l6 6`})}),(0,v.jsx)(`span`,{children:n(`common.source`)||`Source`})]})})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-x-1`,children:[t.showCollapseButton&&(0,v.jsx)(`button`,{className:le,onClick:()=>s(!o),onMouseEnter:e=>Rx(e.currentTarget,o?n(`common.expand`)||`Expand`:n(`common.collapse`)||`Collapse`,`top`,!1,0,t.isDark),onMouseLeave:()=>zx(),children:(0,v.jsx)(`svg`,{style:{rotate:o?`0deg`:`90deg`},xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m9 18l6-6l-6-6`})})}),t.showCopyButton&&(0,v.jsx)(`button`,{className:le,onClick:ie,onMouseEnter:e=>Rx(e.currentTarget,r?n(`common.copied`)||`Copied`:n(`common.copy`)||`Copy`,`top`,!1,0,t.isDark),onMouseLeave:()=>zx(),children:(0,v.jsx)(`svg`,r?{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M20 6L9 17l-5-5`})}:{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,v.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]})})}),t.showExportButton&&(0,v.jsx)(`button`,{className:Q(le,ue&&`opacity-50 cursor-not-allowed`),disabled:ue,onClick:V,onMouseEnter:e=>Rx(e.currentTarget,n(`common.export`)||`Export`,`top`,!1,0,t.isDark),onMouseLeave:()=>zx(),children:(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`path`,{d:`M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,v.jsx)(`path`,{d:`m7 10l5 5l5-5`})]})})}),t.showFullscreenButton&&(0,v.jsx)(`button`,{className:Q(le,ue&&`opacity-50 cursor-not-allowed`),disabled:ue,onClick:oe,onMouseEnter:e=>Rx(e.currentTarget,u?n(`common.minimize`)||`Minimize`:n(`common.open`)||`Open`,`top`,!1,0,t.isDark),onMouseLeave:()=>zx(),children:(0,v.jsx)(`svg`,u?{xmlns:`http://www.w3.org/2000/svg`,width:`0.75rem`,height:`0.75rem`,viewBox:`0 0 24 24`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6`})}:{xmlns:`http://www.w3.org/2000/svg`,width:`0.75rem`,height:`0.75rem`,viewBox:`0 0 24 24`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6`})})})]})]}),!o&&(0,v.jsx)(`div`,{children:c?(0,v.jsx)(`div`,{className:Q(`p-4`,t.isDark?`bg-gray-900`:`bg-gray-50`),children:(0,v.jsx)(`pre`,{className:Q(`text-sm font-mono whitespace-pre-wrap`,t.isDark?`text-gray-300`:`text-gray-700`),children:m})}):(0,v.jsxs)(`div`,{className:`relative`,children:[t.showZoomControls&&(0,v.jsx)(`div`,{className:`absolute top-2 right-2 z-10 rounded-lg`,children:(0,v.jsxs)(`div`,{className:`flex items-center gap-2 backdrop-blur rounded-lg`,children:[(0,v.jsx)(`button`,{className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onClick:()=>E(Math.min(T+.1,3)),children:`+`}),(0,v.jsx)(`button`,{className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onClick:()=>E(Math.max(T-.1,.5)),children:`-`}),(0,v.jsxs)(`button`,{className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onClick:()=>{E(1),O({x:0,y:0})},children:[Math.round(100*T),`%`]})]})}),(0,v.jsxs)(`div`,{className:Q(`infographic-preview relative transition-all duration-100 overflow-hidden block`,t.isDark?`bg-gray-900`:`bg-gray-50`),style:{height:y,maxHeight:t.maxHeight??void 0,minHeight:`var(--ms-size-diagram-min-height, 360px)`},onMouseDown:H,onMouseMove:se,onMouseUp:ce,onMouseLeave:ce,onTouchStart:H,onTouchMove:se,onTouchEnd:ce,children:[!x&&!C&&(0,v.jsx)(`pre`,{className:Q(`absolute inset-0 overflow-auto p-4 text-left text-sm font-mono whitespace-pre-wrap`,t.isDark?`text-gray-300`:`text-gray-700`),children:m}),(0,v.jsx)(`div`,{className:Q(`absolute inset-0 cursor-grab`,k&&`cursor-grabbing`),style:{transform:`translate(${D.x}px, ${D.y}px) scale(${T})`},children:(0,v.jsx)(`div`,{ref:j,className:`w-full text-center flex items-center justify-center min-h-full`})})]})]})})]}),u&&typeof document<`u`&&(0,hx.createPortal)((0,v.jsx)(`div`,{className:`markstream-react fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,onClick:ae,role:`dialog`,"aria-modal":`true`,children:(0,v.jsxs)(`div`,{className:Q(`dialog-panel relative w-full h-full max-w-full max-h-full rounded shadow-lg overflow-hidden`,t.isDark?`bg-gray-900`:`bg-white`),onClick:e=>e.stopPropagation(),children:[(0,v.jsxs)(`div`,{className:`absolute top-6 right-6 z-50 flex items-center gap-2`,children:[(0,v.jsx)(`button`,{className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onClick:()=>E(Math.min(T+.1,3)),children:`+`}),(0,v.jsx)(`button`,{className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onClick:()=>E(Math.max(T-.1,.5)),children:`-`}),(0,v.jsxs)(`button`,{className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onClick:()=>{E(1),O({x:0,y:0})},children:[Math.round(100*T),`%`]}),(0,v.jsx)(`button`,{className:Q(`inline-flex items-center justify-center p-2 rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onClick:ae,children:`X`})]}),(0,v.jsx)(`div`,{ref:P,className:Q(`w-full h-full flex items-center justify-center p-4 overflow-hidden`,!k&&`cursor-grab`,k&&`cursor-grabbing`),onMouseDown:H,onMouseMove:se,onMouseUp:ce,onMouseLeave:ce,onTouchStart:H,onTouchMove:se,onTouchEnd:ce})]})}),document.body)]})}function zS(e,t){return e.reduce((e,n)=>{let r=t==null||n.id===t?{...n,fading:!1}:n,i=e[e.length-1];return!i||i.fading||r.fading?e.push(r):e[e.length-1]={...i,content:i.content+r.content},e},[])}function BS(e){var t;let{node:n,children:r,ctx:i,indexKey:a,fade:o}=e,s=String(n.code??``),c=(t=o??i?.fade)==null||t,l=a==null||a===``?``:String(a),[u,d]=(0,_.useState)(s?[{id:0,content:s,fading:!1}]:[]),f=bx(),p=(0,_.useRef)(s),m=(0,_.useRef)(1),h=(0,_.useRef)(void 0);return(0,_.useEffect)(()=>{let e=f?.getStreamRenderVersion()??i?.streamRenderVersion,t=e!==h.current;if(r!=null)return p.current=``,d([]),void(h.current=e);let n=f?.textStreamState??i?.textStreamState,a=l?n?.get(l):void 0,o=p.current,u=!!(o===s&&a&&s.startsWith(a)&&s.length>a.length);if(u&&(o=a),c)if(s!==o)if(o&&s.startsWith(o)){let e=s.slice(o.length);d(t=>{if(u)return[{id:m.current++,content:o,fading:!1},{id:m.current++,content:e,fading:!0}];let n=t[t.length-1];return n?.fading?[...t.slice(0,-1),{...n,content:n.content+e}]:[...t,{id:m.current++,content:e,fading:!0}]})}else d(s?[{id:m.current++,content:s,fading:!1}]:[]);else t&&d(e=>e.some(e=>e.fading)?zS(e):e);else d(e=>e.length!==1||e[0]?.fading||e[0].content!==s?s?[{id:m.current++,content:s,fading:!1}]:[]:e);p.current=s,h.current=e,l&&n?.set(l,s)},[r,s,f,i?.textStreamState,i?.streamRenderVersion,l,c]),(0,v.jsx)(`code`,{className:`inline-code inline text-[85%] px-1 py-0.5 rounded font-mono bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full`,children:r||u.map(e=>(0,v.jsx)(`span`,{className:e.fading?Q(`text-node-stream-delta`,e.id%2==0?`text-node-stream-delta--a`:`text-node-stream-delta--b`):void 0,onAnimationEnd:e.fading?()=>{t=e.id,d(e=>e.some(e=>e.id===t&&e.fading)?zS(e,t):e);return;var t}:void 0,children:e.content},e.id))})}function VS(e){return(0,v.jsx)(`ins`,{className:`insert-node`,children:e.children})}function HS(e,t){return e.reduce((e,n)=>{let r=t==null||n.id===t?{...n,fading:!1}:n,i=e[e.length-1];return!i||i.fading||r.fading?e.push(r):e[e.length-1]={...i,content:i.content+r.content},e},[])}function US({content:e}){let t=(0,_.useRef)(e),n=(0,_.useRef)(t.current),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=r.current;if(t)if(e.startsWith(n.current)){let r=e.slice(n.current.length);r&&t.appendChild(document.createTextNode(r)),n.current=e}else t.textContent=e,n.current=e},[e]),(0,v.jsx)(`span`,{ref:r,children:t.current})}function WS(e){var t;let{node:n,children:r,ctx:i,indexKey:a,fade:o}=e,s=String(n.content??``),c=(t=o??i?.fade)==null||t,l=a==null||a===``?``:String(a),[u,d]=(0,_.useState)(s?[{id:0,content:s,fading:!1}]:[]),f=bx(),p=(0,_.useRef)(s),m=(0,_.useRef)(1),h=(0,_.useRef)(void 0);return(0,_.useEffect)(()=>{let e=f?.getStreamRenderVersion()??i?.streamRenderVersion,t=e!==h.current;if(r!=null)return p.current=``,d([]),void(h.current=e);let n=f?.textStreamState??i?.textStreamState,a=l?n?.get(l):void 0,o=p.current,u=!!(o===s&&a&&s.startsWith(a)&&s.length>a.length);if(u&&(o=a),c)if(s!==o)if(o&&s.startsWith(o)){let e=s.slice(o.length);d(t=>{if(u)return[{id:m.current++,content:o,fading:!1},{id:m.current++,content:e,fading:!0}];let n=t[t.length-1];return n?.fading?[...t.slice(0,-1),{...n,content:n.content+e}]:[...t,{id:m.current++,content:e,fading:!0}]})}else d(s?[{id:m.current++,content:s,fading:!1}]:[]);else t&&d(e=>e.some(e=>e.fading)?HS(e):e);else d(e=>{if(!s)return[];let t=e.reduce((e,t)=>e+t.content,``);return s===t?e:s.startsWith(t)?[...e,{id:m.current++,content:s.slice(t.length),fading:!1}]:[{id:m.current++,content:s,fading:!1}]});p.current=s,h.current=e,l&&n?.set(l,s)},[r,s,f,i?.textStreamState,i?.streamRenderVersion,l,c]),(0,v.jsx)(`span`,r==null?{className:Q(`text-node whitespace-pre-wrap break-words`,n.center&&`text-node-center`),children:u.map(e=>(0,v.jsx)(`span`,{className:e.fading?Q(`text-node-stream-delta`,e.id%2==0?`text-node-stream-delta--a`:`text-node-stream-delta--b`):void 0,onAnimationEnd:e.fading?()=>{t=e.id,d(e=>e.some(e=>e.id===t&&e.fading)?HS(e,t):e);return;var t}:void 0,children:e.fading?e.content:(0,v.jsx)(US,{content:e.content})},e.id))}:{className:Q(`text-node whitespace-pre-wrap break-words`,n.center&&`text-node-center`),children:r})}function GS(e){let{node:t,ctx:n,renderNode:r,indexKey:i}=e,a=!1!==e.showTooltip,o=e.isDark??n?.isDark,s=(0,_.useMemo)(()=>{let t=e.underlineBottom===void 0?`-3px`:typeof e.underlineBottom==`number`?`${e.underlineBottom}px`:String(e.underlineBottom),n=e.animationOpacity??.35,r=Math.max(.12,Math.min(.5*n,n));return{"--link-color":e.color??`#0366d6`,"--underline-height":`${e.underlineHeight??2}px`,"--underline-bottom":t,"--underline-opacity":String(n),"--underline-rest-opacity":String(r),"--underline-duration":`${e.animationDuration??1.6}s`,"--underline-timing":e.animationTiming??`ease-in-out`,"--underline-iteration":typeof e.animationIteration==`number`?String(e.animationIteration):e.animationIteration??`infinite`}},[e.animationDuration,e.animationIteration,e.animationOpacity,e.animationTiming,e.color,e.underlineBottom,e.underlineHeight]),c=(0,_.useMemo)(()=>yy({href:String(t.href??``)}).href,[t.href]),l=typeof t.title==`string`&&t.title.trim().length>0?t.title:String(c??``),u=Pc(c),d=(0,_.useCallback)(e=>{a&&Rx(e.currentTarget,String(t.title||c||t.text||``),`top`,!1,(e.clientX,e.clientY),o)},[o,t.text,t.title,c,a]),f=(0,_.useCallback)(()=>{a&&zx()},[a]);return t.loading?(0,v.jsx)(`span`,{className:`link-loading inline-flex items-baseline gap-1.5`,"aria-hidden":`false`,style:s,children:(0,v.jsxs)(`span`,{className:`link-text-wrapper relative inline-flex`,children:[(0,v.jsx)(`span`,{className:`leading-[normal] link-text`,children:(0,v.jsx)(WS,{node:{type:`text`,content:String(t.text??``)},ctx:n,indexKey:`${String(i??`link`)}-loading`,typewriter:e.typewriter})}),(0,v.jsx)(`span`,{className:`link-loading-indicator`,"aria-hidden":`true`})]})}):(0,v.jsx)(`a`,{className:`link-node`,href:c||void 0,title:a?``:l,"aria-label":`Link: ${l}`,target:u?`_blank`:void 0,rel:u?`noopener noreferrer`:void 0,style:s,onMouseEnter:d,onMouseLeave:f,children:n&&r?ob(t.children,n,String(i??`link`),r):(0,v.jsx)(WS,{node:{type:`text`,content:String(t.text??``)},ctx:n,indexKey:`${String(i??`link`)}-fallback`,typewriter:e.typewriter})})}function KS(e){let{node:t,ctx:n,renderNode:r,value:i,indexKey:a,children:o}=e;return(0,v.jsx)(`li`,{className:`list-item pl-1.5 my-2`,dir:`auto`,value:i??void 0,children:o??(n&&r?ob(t.children,n,String(a??`list-item`),r):null)})}function qS(e){let{node:t,ctx:n,renderNode:r,indexKey:i}=e,a=t.ordered?`ol`:`ul`,o=t.ordered&&t.start?t.start:void 0,s=n&&hb(n.customId).list_item||KS;return(0,v.jsx)(a,{className:Q(`list-node my-5 pl-[calc(13/8*1em)]`,t.ordered?`list-decimal`:`list-disc max-lg:my-[calc(4/3*1em)] max-lg:pl-[calc(14/9*1em)]`),start:o,children:t.items?.map((e,a)=>(0,v.jsx)(s,{node:e,value:t.ordered?(t.start??1)+a:void 0,ctx:n,renderNode:r,indexKey:`${String(i??`list`)}-${a}`,customId:n?.customId,isDark:n?.isDark,typewriter:n?.typewriter},`${String(i??`list`)}-${a}`))})}var JS=null,YS=null,XS=!1,ZS=new Map,QS=new Map,$S=5,eC=new Set;function tC(){if(ZS.size<$S&&eC.size){let e=Array.from(eC);eC.clear();for(let t of e)try{t()}catch{}}}var nC=`WORKER_BUSY`;async function rC(e,t=!0,n=2e3,r){performance.now();let i=sx(e);if(YS)return Promise.reject(YS);let a=`${t?`d`:`i`}:${i}`,o=QS.get(a);if(o)return Promise.resolve(o);let s=JS||(YS=Error(`[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker().`),YS.name=`WORKER_INIT_ERROR`,YS.code=`WORKER_INIT_ERROR`,null);if(!s)return Promise.reject(YS);if(ZS.size>=$S){let e=Error(`Worker busy`);return e.name=`WorkerBusy`,e.code=nC,e.busy=!0,e.inFlight=ZS.size,e.max=$S,Promise.reject(e)}return new Promise((e,a)=>{if(r?.aborted){let e=Error(`Aborted`);e.name=`AbortError`,a(e);return}let o=Math.random().toString(36).slice(2),c=setTimeout(()=>{ZS.delete(o);let e=Error(`Worker render timed out`);e.name=`WorkerTimeout`,e.code=`WORKER_TIMEOUT`,a(e),tC()},n),l=()=>{},u=()=>{ZS.delete(o),clearTimeout(c),eC.delete(l);let e=Error(`Aborted`);e.name=`AbortError`,a(e),tC()};r&&r.addEventListener(`abort`,u,{once:!0}),ZS.set(o,{resolve:t=>{r&&r.removeEventListener(`abort`,u),e(t)},reject:e=>{r&&r.removeEventListener(`abort`,u),a(e)},timeoutId:c});try{s.postMessage({id:o,content:i,displayMode:t,debug:XS})}catch(e){ZS.delete(o),clearTimeout(c),r&&r.removeEventListener(`abort`,u),a(e),tC()}})}function iC(e,t,n){let r=`${t?`d`:`i`}:${sx(e)}`;if(QS.set(r,n),QS.size>200){let e=QS.keys().next().value;QS.delete(e)}}function aC(e=1500,t){return ZS.size<$S?Promise.resolve():new Promise((n,r)=>{if(t?.aborted){let e=Error(`Aborted`);e.name=`AbortError`,r(e);return}let i=null;function a(){eC.delete(o),i!=null&&clearTimeout(i),t&&t.removeEventListener(`abort`,s)}function o(){a(),n()}function s(){a();let e=Error(`Aborted`);e.name=`AbortError`,r(e)}i=e>0?setTimeout(()=>{a(),r(Error(`Timeout waiting for worker slot`))},e):null,t&&t.addEventListener(`abort`,s,{once:!0}),eC.add(o)})}var oC={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};async function sC(e,t=!0,n={}){let r=n.timeout??oC.timeout,i=n.waitTimeout??oC.waitTimeout,a=n.backoffMs??oC.backoffMs,o=n.maxRetries??oC.maxRetries,s=Number.isFinite(o)?Math.max(0,Math.min(Math.floor(o),8)):oC.maxRetries,c=n.signal,l=0;for(;;){if(c?.aborted){let e=Error(`Aborted`);throw e.name=`AbortError`,e}try{return await rC(e,t,r,c)}catch(e){if(e?.code!==`WORKER_BUSY`||l>=s)throw e;if(l++,await aC(i,c).catch(()=>{}),c?.aborted){let e=Error(`Aborted`);throw e.name=`AbortError`,e}a>0&&await new Promise(e=>setTimeout(e,a*l))}}}var cC=null,lC=!1;async function uC(){if(cC)return cC;if(lC)return null;try{return cC=await a(()=>import(`./vendor-katex-DNVSTX6g.js`).then(e=>e.r),__vite__mapDeps([3,1])),await a(()=>import(`./vendor-katex-DNVSTX6g.js`).then(e=>e.t),__vite__mapDeps([3,1])),cC}catch{return lC=!0,null}}function dC({node:e}){let t=(0,_.useRef)(null),n=(0,_.useRef)(null),r=(0,_.useRef)(null),i=Tx(),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(()=>typeof window>`u`),l=(0,_.useRef)(0);return(0,_.useEffect)(()=>{let e=t.current;if(!e)return;let n=i(e,{rootMargin:`400px`});return r.current=n,n.isVisible()&&c(!0),n.whenVisible.then(()=>c(!0)),()=>{n.destroy(),r.current=null}},[i]),(0,_.useEffect)(()=>{let t=sx(e.content??``);if(!t)return n.current&&(n.current.innerHTML=``),void o(!1);if(!s)return void o(!0);let r=!1,i=new AbortController,a=++l.current;return sC(t,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:i.signal}).then(e=>{r||a!==l.current||(n.current&&(n.current.innerHTML=e),o(!1))}).catch(async i=>{if(r||a!==l.current||!n.current)return;let s=i?.code||i?.name;if(s===`WORKER_INIT_ERROR`||i?.fallbackToRenderer||s===`WORKER_BUSY`||s===`WORKER_TIMEOUT`){let i=await uC();if(i)try{let s=i.renderToString(t,{throwOnError:e.loading,displayMode:!0});!r&&a===l.current&&n.current&&(n.current.innerHTML=s,o(!1),iC(t,!0,s));return}catch{}}e.loading||(n.current.textContent=e.raw,o(!1))}),()=>{r=!0,i.abort()}},[e.content,e.loading,e.raw,s]),(0,v.jsx)(`div`,{ref:t,className:`math-block text-center overflow-x-auto relative min-h-[40px]`,children:(0,v.jsx)(`div`,{ref:n,className:a?`math-rendering`:void 0})})}function fC({node:e}){let t=(0,_.useRef)(null),n=(0,_.useRef)(null),r=(0,_.useRef)(null),i=Tx(),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(()=>typeof window>`u`),l=(0,_.useRef)(0);return(0,_.useEffect)(()=>{let e=t.current;if(!e)return;let n=i(e,{rootMargin:`400px`});return r.current=n,n.isVisible()&&c(!0),n.whenVisible.then(()=>c(!0)),()=>{n.destroy(),r.current=null}},[i]),(0,_.useEffect)(()=>{let t=sx(e.content??``);if(!t)return n.current&&(n.current.innerHTML=``),void o(!1);if(!s)return void o(!0);let r=!1,i=new AbortController,a=++l.current,c=e.markup===`$$`;return sC(t,c,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||a!==l.current||n.current&&(n.current.innerHTML=e,o(!1))}).catch(async i=>{if(r||a!==l.current||!n.current)return;let s=i?.code||i?.name;if(s===`WORKER_INIT_ERROR`||i?.fallbackToRenderer||s===`WORKER_BUSY`||s===`WORKER_TIMEOUT`){let i=await uC();if(i)try{let s=i.renderToString(t,{throwOnError:e.loading,displayMode:c});!r&&a===l.current&&n.current&&(n.current.innerHTML=s,o(!1),iC(t,c,s));return}catch{}}e.loading||(n.current.textContent=e.raw,o(!1))}),()=>{r=!0,i.abort()}},[e.content,e.loading,e.raw,e.markup,s]),(0,v.jsxs)(`span`,{ref:t,className:`math-inline-wrapper`,children:[(0,v.jsx)(`span`,{ref:n,className:`math-inline`+(a?` math-inline--hidden`:``)}),a&&(0,v.jsxs)(`span`,{className:`math-inline__loading`,role:`status`,"aria-live":`polite`,children:[(0,v.jsx)(`span`,{className:`math-inline__spinner`,"aria-hidden":`true`}),(0,v.jsx)(`span`,{className:`sr-only`,children:`Loading`})]})]})}function pC(e){try{if(typeof globalThis<`u`&&typeof globalThis.requestAnimationFrame==`function`)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}var mC=null,hC=null,gC=new Map,_C=5,vC=`WORKER_BUSY`;function yC(e,t,n=1400){if(hC)return Promise.reject(hC);let r=mC||(hC=Error(`[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker().`),hC.name=`WORKER_INIT_ERROR`,hC.code=`WORKER_INIT_ERROR`,null);if(!r)return Promise.reject(hC);if(gC.size>=_C){let e=Error(`Worker busy`);return e.name=`WorkerBusy`,e.code=vC,e.inFlight=gC.size,e.max=_C,Promise.reject(e)}return new Promise((i,a)=>{let o=Math.random().toString(36).slice(2),s=!1,c=null,l=()=>{s||(s=!0,c!=null&&clearTimeout(c),gC.delete(o))};gC.set(o,{resolve:e=>{l(),i(e)},reject:e=>{l(),a(e)}});try{r.postMessage({id:o,action:e,payload:t})}catch(e){gC.delete(o),a(e);return}c=setTimeout(()=>{let e=Error(`Worker call timed out`);e.name=`WorkerTimeout`,e.code=`WORKER_TIMEOUT`,gC.get(o)?.reject(e)},n)})}async function bC(e,t,n=1400){return yC(`canParse`,{code:e,theme:t},n)}async function xC(e,t,n=2400){return yC(`findPrefix`,{code:e,theme:t},n)}function SC(){var e;(e=mC?.terminate)==null||e.call(mC),mC=null,hC=null,gC.clear()}var CC=null,wC=!1,TC=null,EC=null;function DC(e,t){var n;if(!e||!t)return;let r=function(e){return`${String(e?.securityLevel??`strict`)}|htmlLabels:${!1===e?.flowchart?.htmlLabels?`0`:`1`}`}(t);if(TC!==r)try{typeof e.initialize==`function`?e.initialize(t):(n=e.mermaidAPI)!=null&&n.initialize&&e.mermaidAPI.initialize(t),TC=r}catch{}}var OC=typeof window<`u`?_.useLayoutEffect:_.useEffect,kC={USE_PROFILES:{svg:!0},FORBID_TAGS:[`script`],FORBID_ATTR:[/^on/i],ADD_TAGS:[`style`],ADD_ATTR:[`style`],SAFE_FOR_TEMPLATES:!0};function AC(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=``}}function jC(e,t,n={}){if(!e)return``;let r=function(e,t){if(!e)return``;let n=Zy(t);return n?(AC(e),e.appendChild(n),e.innerHTML):``}(e,t);return r||n.keepPreviousOnFailure||AC(e),r}function MC(e,t,n){if(n&&e?.querySelector(`svg`))try{t?.(e)}catch{}}var NC={maxHeight:`500px`,loading:!0,workerTimeoutMs:1400,parseTimeoutMs:1800,renderTimeoutMs:2500,fullRenderTimeoutMs:4e3,renderDebounceMs:300,contentStableDelayMs:500,previewPollDelayMs:800,previewPollMaxDelayMs:4e3,previewPollMaxAttempts:12,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showFullscreenButton:!0,showCollapseButton:!0,showZoomControls:!0,enableWheelZoom:!1,isStrict:!0,enableMermaidInteractions:!1};function PC(e){let t={...NC,...e},{t:n}=kx(),r=(0,_.useMemo)(()=>Ab(`mermaid`),[]),i=t.node?.code??``,o=(0,_.useMemo)(()=>i.replace(/\]::([^:])/g,`]:::$1`).replace(/:::subgraphNode$/gm,`::subgraphNode`),[i]),s=t.workerTimeoutMs??NC.workerTimeoutMs,c=t.parseTimeoutMs??NC.parseTimeoutMs,l=t.renderTimeoutMs??NC.renderTimeoutMs,u=t.fullRenderTimeoutMs??NC.fullRenderTimeoutMs,d=Math.max(0,t.renderDebounceMs??NC.renderDebounceMs),f=(0,_.useMemo)(()=>t.maxHeight&&t.maxHeight!==`none`?cx(t.maxHeight):null,[t.maxHeight]),p=(0,_.useMemo)(()=>cx(t.estimatedPreviewHeightPx)??lx(o),[o,t.estimatedPreviewHeightPx]),[m,h]=(0,_.useState)(!1),[g,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(1),[E,D]=(0,_.useState)({x:0,y:0}),[O,k]=(0,_.useState)(!1),[A,j]=(0,_.useState)(!1),[M,N]=(0,_.useState)(!1),[P,ee]=(0,_.useState)(null),[F,I]=(0,_.useState)(!1),[te,L]=(0,_.useState)(()=>`${ux(p,360,f)}px`),[ne,re]=(0,_.useState)(typeof window>`u`),R=(0,_.useRef)(null),z=(0,_.useRef)(null),ie=(0,_.useRef)(null),B=(0,_.useRef)(null),ae=(0,_.useRef)(null),oe=(0,_.useRef)(null),V=(0,_.useRef)(null),H=(0,_.useRef)({x:0,y:0}),se=(0,_.useRef)(0),ce=(0,_.useRef)({}),le=(0,_.useRef)(null),ue=(0,_.useRef)(``),de=(0,_.useRef)(!1),U=(0,_.useRef)(null),fe=(0,_.useRef)(!1),pe=(0,_.useRef)({zoom:1,translateX:0,translateY:0,containerHeight:te||`360px`}),me=Tx(),W=!!(t.node?.loading??t.loading),he=t.isDark?`dark`:`light`,G=!!t.isStrict,ge=!0===t.enableMermaidInteractions,_e=(0,_.useMemo)(()=>G?{startOnLoad:!1,securityLevel:`strict`,suppressErrorRendering:!0,dompurifyConfig:kC,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:`loose`,suppressErrorRendering:!0},[G]);(0,_.useEffect)(()=>{fe.current=M},[M]);let ve=(0,_.useCallback)(()=>{let e=z.current;return cx(e?getComputedStyle(e).getPropertyValue(`--ms-size-diagram-min-height`).trim():``)??360},[]),ye=(0,_.useCallback)(()=>ux(p,ve(),f),[p,f,ve]);(0,_.useEffect)(()=>{g||b||L(e=>{let t=cx(e),n=ye();return t!=null&&t>=n?e:`${n}px`})},[b,ye,g]),(0,_.useEffect)(()=>{ce.current={}},[he,o,G]),(0,_.useEffect)(()=>{let e=!1;return(async()=>{let t=await async function(e){if(CC)return DC(CC,e),CC;if(EC){let t=await EC;return t&&DC(t,e),t}if(wC)return null;try{wC=!0,EC=(async()=>{try{let t=await a(()=>import(`./__vite-optional-peer-dep_mermaid_markstream-react-CQGbcmkI.js`),[]),n=t?.default||t;if(CC=n?.default?n.default:n?.mermaidAPI?n:n?.mermaid?n.mermaid:n,!CC)throw Error(`Mermaid module did not export expected API`);return DC(CC,e??{startOnLoad:!1,securityLevel:`strict`,flowchart:{htmlLabels:!1}}),CC}catch(e){return console.warn(`[markstream-react] Failed to load mermaid:`,e),null}finally{EC=null}})();let t=await EC;return t&&DC(t,e),t}catch{return null}}(_e);e||(R.current=t,h(!!t),de.current||y(!t))})(),()=>{e=!0}},[_e]),(0,_.useEffect)(()=>{let e=z.current;if(!e)return;let t=me(e,{rootMargin:`400px`});return U.current=t,t.isVisible()&&re(!0),t.whenVisible.then(()=>re(!0)),()=>{t.destroy(),U.current=null}},[me]),(0,_.useEffect)(()=>{if(typeof document>`u`||!F)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[F]);let be=(0,_.useCallback)(()=>f,[f]),K=(0,_.useCallback)(e=>{let n=z.current,r=B.current;if(!n||!r)return;let i=r.querySelector(`svg`);if(!i)return;let a=0,o=0,s=i.getAttribute(`viewBox`);if(s){let e=s.split(` `);e.length===4&&(a=Number.parseFloat(e[2]),o=Number.parseFloat(e[3]))}if(a&&o||!i.hasAttribute(`width`)||!i.hasAttribute(`height`)||(a=Number.parseFloat(i.getAttribute(`width`)||`0`),o=Number.parseFloat(i.getAttribute(`height`)||`0`)),!a||!o||Number.isNaN(a)||Number.isNaN(o))try{let e=i.getBBox();a=e.width,o=e.height}catch{return}if(!(a>0&&o>0))return;let c=(e??n.clientWidth)*(o/a),l=Number.isFinite(c)&&c>0?c:o,u=be(),d=u==null?l:Math.min(l,u),f=ye();L(`${t.maxHeight===`none`?d:Math.max(d,f)}px`)},[t.maxHeight,ye,be]);(0,_.useEffect)(()=>{if(!z.current||typeof ResizeObserver>`u`||g||b)return;let e=new ResizeObserver(e=>{if(!e.length)return;let t=e[0].contentRect.width;pC(()=>K(t))});return e.observe(z.current),()=>e.disconnect()},[b,g,K]),(0,_.useEffect)(()=>{g||b||K()},[b,t.maxHeight,g,K]),(0,_.useEffect)(()=>()=>{SC()},[]),(0,_.useLayoutEffect)(()=>{let e=ce.current[he];!g&&B.current&&e!=null&&e.svg&&(jC(B.current,e.svg)&&(le.current=e.bindFunctions??null,MC(B.current,e.bindFunctions,ge)),pC(()=>K()))},[ge,g,he,K]);let q=(0,_.useCallback)(async(e,n,r)=>{if(!R.current||!B.current)return!1;j(!0);try{let t=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=LC(e,n),a=await VC(()=>R.current.render(t,i),{timeoutMs:u,signal:r});if(!a?.svg)return!1;let o=jC(B.current,a.svg);return!!o&&(le.current=a.bindFunctions??null,MC(B.current,a.bindFunctions,ge),K(),ce.current[n]={svg:o,bindFunctions:a.bindFunctions},N(!0),ee(null),!0)}catch(e){if(!W){if(typeof t.onRenderError==`function`&&B.current&&!0===t.onRenderError(e,o,B.current))return!1;ee(e instanceof Error?e.message:String(e))}return!1}finally{j(!1)}},[ge,u,W,K]),xe=(0,_.useCallback)(async(e,t,n)=>{if(R.current&&B.current){j(!0);try{let r=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=LC(BC(e)||e,t),a=await VC(()=>R.current.render(r,i),{timeoutMs:l,signal:n});if(a?.svg){let e=jC(B.current,a.svg,{keepPreviousOnFailure:!0});e&&(le.current=a.bindFunctions??null,MC(B.current,a.bindFunctions,ge)),e&&K()}}catch{}finally{j(!1)}}},[ge,l,W,K]),Se=(0,_.useCallback)(async(e,t)=>{if(!e.trim())return AC(B.current),N(!1),void(ue.current=``);let n=e.replace(/\s+/g,``);if(n===ue.current&&fe.current)return;let r=++se.current;if(RC(e)===`gantt`){let i=BC(e);if(!i.trim())return;try{if(await IC(i,he,{workerTimeout:s,parseTimeout:c,mermaid:R.current,signal:t}),t?.aborted||se.current!==r)return;i===e?await q(e,he,t)&&(ue.current=n):await xe(i,he,t)}catch(e){if(e?.name===`AbortError`)return}return}try{if(await IC(e,he,{workerTimeout:s,parseTimeout:c,mermaid:R.current,signal:t}),t?.aborted||se.current!==r)return;await q(e,he,t)&&(ue.current=n);return}catch(e){if(e?.name===`AbortError`)return}try{let n=await async function(e,t,n){try{let r=await xC(e,t,n.workerTimeout);if(r)return r}catch(e){if(e?.name===`AbortError`)throw e}return BC(e)}(e,he,{workerTimeout:s,signal:t});if(!n||t?.aborted||se.current!==r)return;await xe(n,he,t)}catch{}},[c,q,xe,he,s]),Ce=(0,_.useCallback)(()=>ne&&!g&&!b,[b,g,ne]);(0,_.useEffect)(()=>{if(!Ce()||!R.current)return;let e=new AbortController,t=window.setTimeout(()=>{!e.signal.aborted&&Ce()&&Se(o,e.signal)},d);return()=>{e.abort(),window.clearTimeout(t)}},[o,Ce,m,Se,d]);let we=(0,_.useCallback)((e,n)=>{e.clientX,e.clientY,Rx(e.currentTarget,n,`top`,!1,0,t.isDark)},[t.isDark]),Te=(0,_.useCallback)(async()=>{var e;try{await navigator.clipboard?.writeText(o),C(!0),(e=t.onCopy)==null||e.call(t,o),setTimeout(()=>C(!1),1e3)}catch{}},[o,t]),Ee=(0,_.useCallback)(()=>{var e;let n=B.current?.querySelector(`svg`)??null;if(!n)return;let r=HC(n),i={payload:{type:`export`},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:n,svgString:r};(e=t.onExport)==null||e.call(t,i),i.defaultPrevented||function(e,t){let n=t??HC(e),r=new Blob([n],{type:`image/svg+xml;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`mermaid-${Date.now()}.svg`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}(n,r)},[t]),De=(0,_.useCallback)(()=>{V.current=null,AC(oe.current)},[]),Oe=(0,_.useCallback)(()=>{I(!1),De()},[De]),ke=(0,_.useCallback)(()=>{var e;let n=B.current?.querySelector(`svg`)??null,r={payload:{type:`open-modal`},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:n,svgString:n?HC(n):null};(e=t.onOpenModal)==null||e.call(t,r),r.defaultPrevented||I(!0)},[t]);(0,_.useEffect)(()=>{if(!F||typeof window>`u`)return;let e=e=>{e.key===`Escape`&&Oe()};try{window.addEventListener(`keydown`,e)}catch{}return()=>{try{window.removeEventListener(`keydown`,e)}catch{}}},[Oe,F]),OC(()=>{if(!F)return;let e=oe.current,t=z.current;if(!e||!t)return;let n=`translate(${E.x}px, ${E.y}px) scale(${w})`,r=t.cloneNode(!0);r.classList.add(`fullscreen`),r.style.height=`100%`,r.style.maxHeight=`100%`;let i=r.querySelector(`[data-mermaid-wrapper]`);i&&(V.current=i,i.style.transform=n),AC(e),e.appendChild(r),MC(e,le.current??ce.current[he]?.bindFunctions,ge)},[ge,F,he]),(0,_.useEffect)(()=>{F&&V.current&&(V.current.style.transform=`translate(${E.x}px, ${E.y}px) scale(${w})`)},[F,E.x,E.y,w]);let Ae=g||A||b,je=(0,_.useMemo)(()=>t.isDark?`mermaid-action-btn p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200`:`mermaid-action-btn p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700`,[t.isDark]),Me=(0,_.useCallback)(e=>{var n;let r={payload:{type:`toggle-mode`,target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if((n=t.onToggleMode)==null||n.call(t,e,r),!r.defaultPrevented)if(de.current=!0,e===`preview`){y(!1);let e=pe.current;T(e.zoom),D({x:e.translateX,y:e.translateY}),L(e.containerHeight)}else pe.current={zoom:w,translateX:E.x,translateY:E.y,containerHeight:te},y(!0)},[o,te,Se,t,he,E.x,E.y,K,w]),Ne=(0,_.useCallback)(e=>{if(!1===t.enableWheelZoom||!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let n=z.current;if(!n)return;let r=n.getBoundingClientRect(),i=e.clientX-r.left-E.x,a=e.clientY-r.top-E.y,o=.01*-e.deltaY,s=FC(w+o,.5,3);if(s===w)return;let c=s/w;D({x:E.x-i*(c-1),y:E.y-a*(c-1)}),T(s)},[E,w]),Pe=(0,_.useCallback)((e,t)=>{k(!0),H.current={x:e-E.x,y:t-E.y}},[E.x,E.y]),Fe=(0,_.useCallback)((e,t)=>{O&&D({x:e-H.current.x,y:t-H.current.y})},[O]),Ie=(0,_.useCallback)(()=>{k(!1)},[]),Le=(0,v.jsxs)(`div`,{className:`relative`,children:[t.showZoomControls&&(0,v.jsx)(`div`,{className:`absolute top-2 right-2 z-10 rounded-lg`,children:(0,v.jsxs)(`div`,{className:`flex items-center gap-2 backdrop-blur rounded-lg`,children:[(0,v.jsx)(`button`,{type:`button`,className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onMouseEnter:e=>we(e,n(`common.zoomIn`)),onMouseLeave:()=>zx(),onClick:()=>T(FC(w+.1,.5,3)),children:`+`}),(0,v.jsx)(`button`,{type:`button`,className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onMouseEnter:e=>we(e,n(`common.zoomOut`)),onMouseLeave:()=>zx(),onClick:()=>T(FC(w-.1,.5,3)),children:`−`}),(0,v.jsxs)(`button`,{type:`button`,className:Q(`p-2 text-xs rounded transition-colors`,t.isDark?`text-gray-400 hover:bg-gray-700`:`text-gray-600 hover:bg-gray-200`),onMouseEnter:e=>we(e,n(`common.resetZoom`)),onMouseLeave:()=>zx(),onClick:()=>{T(1),D({x:0,y:0})},children:[Math.round(100*w),`%`]})]})}),(0,v.jsxs)(`div`,{ref:z,className:Q(`relative overflow-hidden block transition-[height] duration-150 ease-out`,t.isDark?`bg-gray-900`:`bg-gray-50`),style:{height:te,maxHeight:t.maxHeight??void 0,minHeight:`var(--ms-size-diagram-min-height, 360px)`},onWheel:Ne,onMouseDown:e=>{e.button===0&&(e.preventDefault(),Pe(e.clientX,e.clientY))},onMouseMove:e=>Fe(e.clientX,e.clientY),onMouseUp:Ie,onMouseLeave:Ie,onTouchStart:e=>{let t=e.touches[0];t&&Pe(t.clientX,t.clientY)},onTouchMove:e=>{let t=e.touches[0];t&&Fe(t.clientX,t.clientY)},onTouchEnd:Ie,children:[(0,v.jsx)(`div`,{ref:ie,"data-mermaid-wrapper":!0,className:Q(`absolute inset-0 cursor-grab`,{"cursor-grabbing":O}),style:{transform:`translate(${E.x}px, ${E.y}px) scale(${w})`},children:(0,v.jsx)(`div`,{ref:B,className:`_mermaid w-full text-center flex items-center justify-center min-h-full`})}),(A||W)&&(0,v.jsxs)(`div`,{className:`mermaid-loading`,children:[(0,v.jsx)(`span`,{className:`mermaid-spinner`}),(0,v.jsx)(`span`,{children:`Rendering diagram…`})]})]})]}),Re=t.showHeader&&(0,v.jsxs)(`div`,{className:Q(`mermaid-block-header flex justify-between items-center px-4 py-2.5 border-b`,t.isDark?`bg-gray-800 border-gray-700/30`:`bg-gray-50 border-gray-200`),children:[(0,v.jsxs)(`div`,{className:`flex items-center space-x-2 overflow-hidden`,children:[(0,v.jsx)(`span`,{className:`icon-slot h-4 w-4 flex-shrink-0`,dangerouslySetInnerHTML:{__html:r}}),(0,v.jsx)(`span`,{className:Q(`text-sm font-medium font-mono truncate`,t.isDark?`text-gray-400`:`text-gray-600`),children:`Mermaid`})]}),t.showModeToggle&&m&&(0,v.jsxs)(`div`,{className:Q(`flex items-center space-x-1 rounded-md p-0.5`,t.isDark?`bg-gray-700`:`bg-gray-100`),children:[(0,v.jsx)(`button`,{type:`button`,className:Q(`px-2.5 py-1 text-xs rounded transition-colors`,g?t.isDark?`text-gray-400 hover:text-gray-200`:`text-gray-500 hover:text-gray-700`:t.isDark?`bg-gray-600 text-gray-200 shadow-sm`:`bg-white text-gray-700 shadow-sm`),onClick:()=>Me(`preview`),onMouseEnter:e=>we(e,n(`common.preview`)),onFocus:e=>we(e,n(`common.preview`)),onMouseLeave:()=>zx(),onBlur:()=>zx(),children:(0,v.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0`}),(0,v.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}),(0,v.jsx)(`span`,{children:n(`common.preview`)})]})}),(0,v.jsx)(`button`,{type:`button`,className:Q(`px-2.5 py-1 text-xs rounded transition-colors`,g?t.isDark?`bg-gray-600 text-gray-200 shadow-sm`:`bg-white text-gray-700 shadow-sm`:t.isDark?`text-gray-400 hover:text-gray-200`:`text-gray-500 hover:text-gray-700`),onClick:()=>Me(`source`),onMouseEnter:e=>we(e,n(`common.source`)),onFocus:e=>we(e,n(`common.source`)),onMouseLeave:()=>zx(),onBlur:()=>zx(),children:(0,v.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m16 18l6-6l-6-6M8 6l-6 6l6 6`})}),(0,v.jsx)(`span`,{children:n(`common.source`)})]})})]}),(0,v.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[t.showCollapseButton&&(0,v.jsx)(`button`,{type:`button`,className:je,"aria-pressed":b,onClick:()=>x(e=>!e),onMouseEnter:e=>we(e,n(b?`common.expand`:`common.collapse`)),onFocus:e=>we(e,n(b?`common.expand`:`common.collapse`)),onMouseLeave:()=>zx(),onBlur:()=>zx(),children:(0,v.jsx)(`svg`,{style:{rotate:b?`0deg`:`90deg`},xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m9 18l6-6l-6-6`})})}),t.showCopyButton&&(0,v.jsx)(`button`,{type:`button`,className:je,onClick:Te,onMouseEnter:e=>we(e,n(S?`common.copied`:`common.copy`)),onFocus:e=>we(e,n(S?`common.copied`:`common.copy`)),onMouseLeave:()=>zx(),onBlur:()=>zx(),children:(0,v.jsx)(`svg`,S?{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M20 6L9 17l-5-5`})}:{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,v.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]})})}),t.showExportButton&&m&&(0,v.jsx)(`button`,{type:`button`,className:Q(je,Ae?`opacity-50 cursor-not-allowed`:``),disabled:Ae,onClick:Ee,onMouseEnter:e=>we(e,n(`common.export`)),onFocus:e=>we(e,n(`common.export`)),onMouseLeave:()=>zx(),onBlur:()=>zx(),children:(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,v.jsx)(`path`,{d:`M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,v.jsx)(`path`,{d:`m7 10l5 5l5-5`})]})})}),t.showFullscreenButton&&m&&(0,v.jsx)(`button`,{type:`button`,className:Q(je,Ae?`opacity-50 cursor-not-allowed`:``),disabled:Ae,onClick:F?Oe:ke,onMouseEnter:e=>we(e,n(F?`common.minimize`:`common.open`)),onFocus:e=>we(e,n(F?`common.minimize`:`common.open`)),onMouseLeave:()=>zx(),onBlur:()=>zx(),children:(0,v.jsx)(`svg`,F?{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6`})}:{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,className:`w-3 h-3`,children:(0,v.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6`})})})]})]}),ze=(0,v.jsxs)(`div`,{children:[g?(0,v.jsx)(`div`,{className:Q(`p-4`,t.isDark?`bg-gray-900 text-gray-300`:`bg-gray-50 text-gray-700`),children:(0,v.jsx)(`pre`,{className:`text-sm font-mono whitespace-pre-wrap`,children:o})}):Le,P&&(0,v.jsx)(`div`,{className:`mermaid-error`,children:P})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{"data-markstream-mermaid":`1`,"data-markstream-mode":g?`source`:M?`preview`:`pending`,className:Q(`my-4 rounded-lg border overflow-hidden shadow-sm mermaid-block`,t.isDark?`border-gray-700/30`:`border-gray-200`,{"is-rendering":W}),children:[Re,(0,v.jsx)(`div`,{ref:ae,style:{display:b?`none`:``},children:ze})]}),F&&typeof document<`u`&&(0,hx.createPortal)((0,v.jsx)(`div`,{className:`markstream-react mermaid-modal-overlay`,onClick:()=>Oe(),children:(0,v.jsxs)(`div`,{className:Q(`mermaid-modal-panel`,{"is-dark":t.isDark}),role:`dialog`,"aria-modal":`true`,onClick:e=>e.stopPropagation(),children:[(0,v.jsxs)(`div`,{className:`mermaid-modal-header`,children:[(0,v.jsx)(`span`,{className:`mermaid-modal-title`,children:`Mermaid ${n(`common.preview`)}`}),(0,v.jsx)(`button`,{type:`button`,className:`mermaid-modal-close`,onClick:Oe,children:n(`common.close`)})]}),(0,v.jsx)(`div`,{className:`mermaid-modal-body`,children:(0,v.jsx)(`div`,{ref:oe,className:`mermaid-modal-content`})})]})}),document.body)]})}function FC(e,t,n){return Math.min(Math.max(e,t),n)}async function IC(e,t,n){try{if(await bC(e,t,n.workerTimeout))return!0}catch(e){if(e?.name===`AbortError`)throw e}if(!n.mermaid)throw Error(`Mermaid not available`);let r=LC(e,t),i=n.mermaid;if(typeof i.parse==`function`)return await VC(()=>i.parse(r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0;let a=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await VC(()=>i.render(a,r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0}function LC(e,t){return e.trimStart().startsWith(`%%{`)?e:`%%{init: {"theme": "${t===`dark`?`dark`:`default`}"}}%%\n${e}`}function RC(e){for(let t of e.split(/\r?\n/)){let e=t.trim();if(!(!e||e.startsWith(`%%`)))return(e.match(/^([A-Z][\w-]*)\b/i)?.[1])?.toLowerCase()||``}return``}function zC(e){let t=e.trim();return!(!t||t.startsWith(`%%`))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(t)&&t.includes(`:`)}function BC(e){if(RC(e)===`gantt`)return function(e){let t=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&t.length>0&&t.pop();t.length>0;){let e=t[t.length-1]?.trim();if(e&&!e.startsWith(`%%`)){if(zC(e))break;t.pop()}else t.pop()}return t.some(zC)?t.join(`
|
|
171
171
|
`):``}(e);let t=e.split(`
|
|
172
172
|
`);for(;t.length>0;){let e=t[t.length-1].trimEnd();if(e!==``){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join(`
|
|
173
|
-
`)}async function VC(e,t={}){let{timeoutMs:n,signal:r}=t;return r?.aborted?Promise.reject(new DOMException(`Aborted`,`AbortError`)):new Promise((t,i)=>{let a=!1,o=null;function s(){a||(a=!0,c(),i(new DOMException(`Aborted`,`AbortError`)))}function c(){o!=null&&clearTimeout(o),r&&r.removeEventListener(`abort`,s)}r&&r.addEventListener(`abort`,s,{once:!0}),n&&n>0&&(o=setTimeout(()=>{a||(a=!0,c(),i(Error(`Operation timed out`)))},n)),e().then(e=>{a||(a=!0,c(),t(e))}).catch(e=>{a||(a=!0,c(),i(e))})})}function HC(e){return new XMLSerializer().serializeToString(e)}function UC(e){let{node:t}=e;return(0,v.jsxs)(`div`,{className:`unknown-node text-sm text-gray-500 italic`,children:[`Unsupported node type:`,` `,String(t?.type)]})}function WC(e){return e?.type===`text`&&String(e?.content??``).trim()===``}function GC(e,t,n,r){let i=e.filter(e=>!WC(e)),a=i.length>0&&i.every(e=>e.type===`image`||function(e){let t=function(e){return e?.type===`link`&&Array.isArray(e?.children)?e.children.filter(e=>!WC(e)):[]}(e);return t.length===1&&t[0]?.type===`image`}(e));if(!a||i.length<=1)return ob(e,n,r,t);let o=[];for(let t=0;t<e.length;t++){let n=e[t];if(!WC(n)){o.push(n);continue}let r=o.length>0,i=e.slice(t+1).some(e=>!WC(e));r&&i&&o.push({...n,content:` `,raw:` `})}return o.map((e,i)=>a&&WC(e)?(0,v.jsx)(_.Fragment,{children:String(e?.content??``)},`${r}-${i}`):t(e,`${r}-${i}`,n))}function KC(e){let{node:t,ctx:n,renderNode:r,indexKey:i,children:a}=e;if(!n||!r)return(0,v.jsx)(`p`,{dir:`auto`,className:`paragraph-node`,children:a});let o=t.children??[],s={...n.customComponents??hb(n.customId),...n.htmlComponents??{},...n.streamingComponents??{}},c=[],l=[],u=()=>{if(!l.length)return;let e=c.length;c.push((0,v.jsx)(`p`,{dir:`auto`,className:`paragraph-node`,children:GC(l.slice(),r,n,`${String(i??`paragraph`)}-${e}`)},`${String(i??`paragraph`)}-inline-${e}`)),l.length=0};return o.forEach((e,t)=>{let a=(n.htmlPolicy??`safe`)!==`escape`||e.type!==`html_inline`&&e.type!==`html_block`;ib.has(e.type)||a&&fx(e,s,n.customHtmlTags)?(u(),c.push((0,v.jsx)(_.Fragment,{children:r(e,`${String(i??`paragraph`)}-block-${t}`,n)},`${String(i??`paragraph`)}-block-${t}`))):l.push(e)}),u(),c.length?(0,v.jsx)(v.Fragment,{children:c}):(0,v.jsx)(`p`,{dir:`auto`,className:`paragraph-node`,children:GC(o,r,n,String(i??`paragraph`))})}function qC(e){let{node:t}=e,n=(0,_.useCallback)(n=>{var r;(r=e.onClick)==null||r.call(e,n,t.id,e.messageId,e.threadId)},[t.id,e]);return(0,v.jsx)(`span`,{className:`reference-node cursor-pointer bg-[hsl(var(--muted))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]`,role:`button`,tabIndex:0,onClick:n,onMouseEnter:n=>{var r;(r=e.onMouseEnter)==null||r.call(e,n,t.id,e.messageId,e.threadId)},onMouseLeave:n=>{var r;(r=e.onMouseLeave)==null||r.call(e,n,t.id,e.messageId,e.threadId)},onKeyDown:e=>{e.key!==`Enter`&&e.key!==` `||n(e)},children:t.id})}function JC(e){return(0,v.jsx)(`s`,{className:`strikethrough-node`,children:e.children})}function YC(e){return(0,v.jsx)(`strong`,{className:`strong-node`,children:e.children})}function XC(e){return(0,v.jsx)(`sub`,{className:`subscript-node`,children:e.children})}function ZC(e){return(0,v.jsx)(`sup`,{className:`superscript-node`,children:e.children})}function QC(e){let{node:t,ctx:n,renderNode:r,indexKey:i}=e,a=Array.isArray(t?.header?.cells)?t.header.cells:[],o=!!t?.loading,s=Array.isArray(t?.rows)?t.rows:[],c=_.useRef(null),l=_.useRef(null),u=_.useRef(null),[d,f]=_.useState([]),p=e=>e===`right`?`text-right`:e===`center`?`text-center`:`text-left`,m=()=>{let e=u.current;e&&(window.removeEventListener(`pointermove`,e.move),window.removeEventListener(`pointerup`,e.stop),window.removeEventListener(`pointercancel`,e.stop),u.current=null),l.current=null};return _.useEffect(()=>(m(),f([]),m),[a.length]),(0,v.jsxs)(`div`,{className:`table-node-wrapper`,"data-index-key":i,children:[(0,v.jsxs)(`table`,{ref:c,className:Q(`my-8 text-sm table-node`,o&&`table-node--loading`),"aria-busy":o,children:[d.length>0&&(0,v.jsx)(`colgroup`,{children:a.map((e,t)=>(0,v.jsx)(`col`,{style:d[t]>0?{width:`${d[t]}px`}:void 0},`col-${t}`))}),(0,v.jsx)(`thead`,{className:`border-[var(--table-border,#cbd5e1)]`,children:(0,v.jsx)(`tr`,{className:`border-b`,children:a.map((e,t)=>(0,v.jsxs)(`th`,{className:Q(`font-semibold p-[calc(4/7*1em)]`,p(e.align)),dir:`auto`,children:[n&&r?sb(e.children,n,`${String(i??`table`)}-th-${t}`,r):null,t<a.length-1&&(0,v.jsx)(`button`,{type:`button`,className:`table-node__resize-handle`,"aria-label":`Resize columns ${t+1} and ${t+2}`,onPointerDown:e=>((e,t)=>{if(t.button!==0)return;let n=(()=>{let e=c.current?.querySelectorAll(`thead th`);return Array.from(e??[],e=>Math.round(e.getBoundingClientRect().width))})(),r=n[e],i=n[e+1];if(!r||!i)return;t.preventDefault(),m(),l.current={index:e,startX:t.clientX,startWidth:r,nextStartWidth:i,widths:n},f(n);let a=e=>{let t=l.current;if(!t)return;e.preventDefault();let n=t.startWidth+t.nextStartWidth,r=Math.min(48,Math.floor(n/2)),i=Math.max(r,Math.min(n-r,Math.round(t.startWidth+e.clientX-t.startX))),a=[...t.widths];a[t.index]=i,a[t.index+1]=n-i,f(a)},o=()=>{m()};u.current={move:a,stop:o},window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)})(t,e)})]},`header-${t}`))})}),(0,v.jsx)(`tbody`,{children:s.map((e,t)=>(0,v.jsx)(`tr`,{className:Q(`border-[var(--table-border,#cbd5e1)]`,t<s.length-1&&`border-b`),children:e.cells?.map((e,a)=>(0,v.jsx)(`td`,{className:Q(`p-[calc(4/7*1em)]`,p(e.align)),dir:`auto`,children:n&&r?sb(e.children,n,`${String(i??`table`)}-row-${t}-${a}`,r):null},`cell-${t}-${a}`))},`row-${t}`))})]}),o&&(0,v.jsxs)(`div`,{className:`table-node__loading`,role:`status`,"aria-live":`polite`,children:[(0,v.jsx)(`span`,{className:`table-node__spinner`,"aria-hidden":`true`}),(0,v.jsx)(`span`,{className:`sr-only`,children:`Loading`})]})]})}function $C(){return(0,v.jsx)(`hr`,{className:`hr-node thematic-break`})}function ew(e){let{node:t,ctx:n,renderNode:r,indexKey:i}=e,a=`vmr-container vmr-container-${t.name}`,o=(0,_.useMemo)(()=>{if(t.attrs)return Array.isArray(t.attrs)?ab(t.attrs):t.attrs},[t.attrs]);return(0,v.jsx)(`div`,{className:a,...o,children:n&&r&&Array.isArray(t.children)?t.children.map((e,t)=>(0,v.jsx)(_.Fragment,{children:r(e,`${String(i??`vmr-container`)}-${t}`,n)},`${String(i??`vmr-container`)}-${t}`)):null})}function tw(e,t,n,r,i={}){let a=mx(r.codeBlockProps),o=r.events.onHandleArtifactClick?e=>{var i,a;let o=e.type===`image/svg+xml`?`image/svg+xml`:`text/html`;(a=(i=r.events).onHandleArtifactClick)==null||a.call(i,{node:e.content==null?t:{...t,code:e.content},artifactType:o,artifactTitle:e.title||(o===`image/svg+xml`?`SVG Preview`:`HTML Preview`),id:String(n)})}:void 0;return _.createElement(e,{key:n,node:t,loading:!!t.loading,stream:r.codeBlockStream,customId:r.customId,isDark:r.isDark,darkTheme:r.codeBlockThemes?.darkTheme,lightTheme:r.codeBlockThemes?.lightTheme,themes:r.codeBlockThemes?.themes,minWidth:r.codeBlockThemes?.minWidth,maxWidth:r.codeBlockThemes?.maxWidth,onCopy:r.events.onCopy,onPreviewCode:o,...a,codeBlockOptions:r.codeBlockOptions,...i,ctx:r,renderNode:$,indexKey:n,typewriter:r.typewriter,fade:r.fade})}function nw(e,t,n,r,i={}){return _.createElement(e,{key:n,node:t,isDark:r.isDark,...i})}function $(e,t,n){let r=n.customComponents??hb(n.customId),i=n.streamingComponents??{},a=n.htmlComponents??{},s=function(e){if(e.type===`html_block`||e.type===`html_inline`)return``;let t=Kc(e.type),n=Kc(e.tag);return t&&n&&t===n?t:``}(e),c=s?i[s]:null,l=s&&!c?a[s]:null,u=e.type===`code_block`?null:r[e.type];if(c)return _.createElement(c,{key:t,node:e,customId:n.customId,isDark:n.isDark,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade});if(l)return function(e,t,n,r,i){let a=Cy(by(xy(t.attrs??void 0,r.htmlPolicy??`safe`,i))),o=Array.isArray(t.children)?ob(t.children,r,`${String(n)}-html`,$):t.content??null;return _.createElement(e,{...a,key:n},o)}(l,e,t,n,s);if(u)return _.createElement(u,{key:t,node:e,customId:n.customId,isDark:n.isDark,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade});if(e.type===`html_block`||e.type===`html_inline`){let a=dx(e,{...r,...i},n.customHtmlTags),o=String(e.tag??``).trim().toLowerCase()||Yc(e.content),s=a?.tag??o;if(s){let i=a?.component??r[s],o=a?.isWhitelisted??(n.customHtmlTags??[]).some(e=>e.toLowerCase()===s);if(o&&i){let r={...e,type:s,tag:s,content:Qc(e.content,s)};return _.createElement(i,{key:t,node:r,customId:n.customId,isDark:n.isDark,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade})}let c=String(e.content??e.raw??``);if(!o&&Zc(c,s))return e.type===`html_inline`?(0,v.jsx)(WS,{node:{type:`text`,content:c,raw:c},ctx:n,indexKey:t,typewriter:n.typewriter,fade:n.fade},t):(0,v.jsx)(KC,{node:{type:`paragraph`,children:[{type:`text`,content:c,raw:c}],raw:c},ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t)}}switch(e.type){case`text`:return(0,v.jsx)(WS,{node:e,ctx:n,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`text_special`:return(0,v.jsx)(WS,{node:{type:`text`,content:e.content??``,center:e.center},ctx:n,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`paragraph`:return(0,v.jsx)(KC,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`heading`:return(0,v.jsx)(_S,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`blockquote`:return(0,v.jsx)(uw,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`list`:return(0,v.jsx)(qS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`list_item`:return(0,v.jsx)(KS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`table`:return(0,v.jsx)(QC,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`definition_list`:return(0,v.jsx)(uS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`footnote`:return(0,v.jsx)(mS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`footnote_reference`:return(0,v.jsx)(hS,{node:e},t);case`footnote_anchor`:return(0,v.jsx)(pS,{node:e},t);case`admonition`:return(0,v.jsx)(_x,{node:e,ctx:n,renderNode:$,indexKey:t,isDark:n.isDark,typewriter:n.typewriter,fade:n.fade},t);case`hardbreak`:return(0,v.jsx)(gS,{node:e,typewriter:n.typewriter,fade:n.fade},t);case`link`:return(0,v.jsx)(GS,{node:e,ctx:n,renderNode:$,indexKey:t,isDark:n.isDark,showTooltip:typeof n.showTooltips==`boolean`?n.showTooltips:void 0,typewriter:n.typewriter,fade:n.fade},t);case`image`:return(0,v.jsx)(NS,{node:e},t);case`inline_code`:return(0,v.jsx)(BS,{node:e,ctx:n,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`code_block`:return function(e,t,n,r){let i=function(e){let t=String(e?.language||``).trim();if(!t)return``;let[n]=t.split(/\s+/),[r]=n.split(`:`);return r.toLowerCase()}(e),a=Eb(i),s=function(e,t){let n=t.trim().toLowerCase();if(!n)return null;for(let t of[n,Eb(n),o(n)]){let n=t&&e[t];if(n)return n}return null}(r,i);if(a===`mermaid`){let i=function(e,t){let n={...t.mermaidProps||{}};return cx(n.estimatedPreviewHeightPx)??(n.estimatedPreviewHeightPx=ux(lx(String(e?.code??``)),void 0,n.maxHeight===`none`?null:cx(n.maxHeight)??void 0)),n}(e,n),a=s||r.mermaid;if(a)return nw(a,e,t,n,i);if(!n.renderCodeBlocksAsPre)return(0,v.jsx)(PC,{node:e,isDark:n.isDark,loading:!!e.loading,...i},t)}if(a===`infographic`){let i=function(e,t){let n={...t.infographicProps||{}};return ix(n.estimatedPreviewHeightPx)??(n.estimatedPreviewHeightPx=ox(ax(String(e?.code??``)),void 0,n.maxHeight===`none`?null:ix(n.maxHeight)??void 0)),n}(e,n),a=s||r.infographic;return a?nw(a,e,t,n,i):(0,v.jsx)(RS,{node:e,isDark:n.isDark,loading:!!e.loading,...i},t)}if(a===`d2`||a===`d2lang`){let i=s||r.d2;return i?nw(i,e,t,n,n.d2Props||{}):(0,v.jsx)(lS,{node:e,isDark:n.isDark,loading:!!e.loading,...n.d2Props||{}},t)}if(s)return tw(s,e,t,n);let c=r.code_block;if(c)return tw(c,e,t,n);if(n.renderCodeBlocksAsPre||a===`mermaid`){let r=n.codeBlockProps?.showLineNumbers,i=n.codeBlockOptions?.disableLineNumbers,a=n.codeBlockOptions?.overflow;return(0,v.jsx)(Hb,{node:e,style:a?{whiteSpace:a===`scroll`?`pre`:`pre-wrap`}:void 0,showLineNumbers:typeof r==`boolean`?r:typeof i==`boolean`&&!i},t)}return(0,v.jsx)(Qx,{node:e,loading:!!e.loading,stream:n.codeBlockStream,themes:n.codeBlockThemes?.themes,darkTheme:n.codeBlockThemes?.darkTheme,lightTheme:n.codeBlockThemes?.lightTheme,minWidth:n.codeBlockThemes?.minWidth,maxWidth:n.codeBlockThemes?.maxWidth,isDark:n.isDark,onCopy:n.events.onCopy,...mx(n.codeBlockProps),codeBlockOptions:n.codeBlockOptions},t)}(e,t,n,r);case`strong`:return(0,v.jsx)(YC,{node:e,children:ob(e.children,n,`${String(t)}-strong`,$)},t);case`emphasis`:return(0,v.jsx)(fS,{node:e,children:ob(e.children,n,`${String(t)}-em`,$)},t);case`strikethrough`:return(0,v.jsx)(JC,{node:e,children:ob(e.children,n,`${String(t)}-strike`,$)},t);case`highlight`:return(0,v.jsx)(vS,{node:e,children:ob(e.children,n,`${String(t)}-highlight`,$)},t);case`insert`:return(0,v.jsx)(VS,{node:e,children:ob(e.children,n,`${String(t)}-insert`,$)},t);case`subscript`:return(0,v.jsx)(XC,{node:e,children:ob(e.children,n,`${String(t)}-sub`,$)},t);case`superscript`:return(0,v.jsx)(ZC,{node:e,children:ob(e.children,n,`${String(t)}-sup`,$)},t);case`checkbox`:case`checkbox_input`:return(0,v.jsx)(Dx,{node:e,typewriter:n.typewriter,fade:n.fade},t);case`emoji`:return(0,v.jsx)(dS,{node:e,typewriter:n.typewriter,fade:n.fade},t);case`thematic_break`:return(0,v.jsx)($C,{},t);case`math_inline`:return(0,v.jsx)(fC,{node:e},t);case`math_block`:return(0,v.jsx)(dC,{node:e},t);case`reference`:return(0,v.jsx)(qC,{node:e,ctx:n,typewriter:n.typewriter,fade:n.fade},t);case`html_block`:case`html_inline`:return e.type===`html_block`?(0,v.jsx)(yS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade,customId:n.customId},t):(0,v.jsx)(AS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade,customId:n.customId},t);case`vmr_container`:return(0,v.jsx)(ew,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`label_open`:case`label_close`:return null;default:return(0,v.jsx)(UC,{node:e},t)}}var rw={codeBlockStream:!0,typewriter:!1,fade:!0,smoothStreaming:`auto`,batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:320,liveNodeBuffer:60},iw=rb();function aw(e,t){return e.type===t.type&&e.raw===t.raw&&e.loading===t.loading&&e.autoClosed===t.autoClosed&&!!function(e,t){if(e===t)return!0;if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=e,r=t;return n.startLine===r.startLine&&n.endLine===r.endLine}(e.sourceMap,t.sourceMap)&&(e.type!==`code_block`&&t.type!==`code_block`||e.diff===t.diff)}function ow(e){let t=(0,_.useMemo)(()=>vb(e),[e]),n=(0,_.useRef)(t);return function(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}(n.current,t)||(n.current=t),n.current}var sw=_.memo(({node:e,nodeKey:t,renderCtx:n})=>$(e,t,n),(e,t)=>e.node===t.node&&e.renderCtx===t.renderCtx&&e.nodeKey===t.nodeKey),cw=_.memo(({props:e,parsedNodes:t,renderCtx:n,indexPrefix:r,containerRef:i,showTypewriterCursor:a,typewriterCursorRef:o})=>{let s=Tx(),c=typeof window<`u`,l=typeof window<`u`&&typeof window.requestIdleCallback==`function`,u=Math.max(0,Math.trunc(e.renderBatchSize??80)),d=Math.max(0,Math.trunc(e.initialRenderBatchSize??(u||t.length))),f=!1!==e.batchRendering&&u>0&&c,p=Math.max(0,e.liveNodeBuffer??60),m=Math.max(1,e.maxLiveNodes??320),h=(e.maxLiveNodes??0)>0&&t.length>m,g=!1!==e.viewportPriority,y=f&&(e.maxLiveNodes??0)<=0,b=(0,_.useMemo)(()=>!1!==e.deferNodesUntilVisible&&!((e.maxLiveNodes??0)<=0)&&!h&&!(t.length>900)&&g,[t.length,e.deferNodesUntilVisible,e.maxLiveNodes,g,h]),[x,S]=(0,_.useState)(()=>y?Math.min(t.length,d):t.length),C=(0,_.useRef)(x);(0,_.useEffect)(()=>{C.current=x},[x]);let w=y?x:t.length,[T,E]=(0,_.useState)(0),[D,O]=(0,_.useState)({start:0,end:t.length}),k=(0,_.useRef)(new Map),[A,j]=(0,_.useState)(0),M=(0,_.useRef)({}),N=(0,_.useRef)(new Map),P=(0,_.useRef)(new Map),ee=(0,_.useRef)(new Map),F=(0,_.useRef)(new Map),I=(0,_.useRef)(new Set),te=(0,_.useRef)(x),L=(0,_.useRef)(null),ne=(0,_.useRef)(null),re=(0,_.useRef)(null),R=(0,_.useRef)(!1),z=(0,_.useRef)(null),ie=(0,_.useRef)(Math.max(1,u||1)),B=(0,_.useRef)(t.length),ae=(0,_.useRef)({key:e.indexKey,total:t.length}),oe=(0,_.useRef)(t),V=(0,_.useRef)({batchSize:u,initial:d,delay:e.renderBatchDelay??16,enabled:y}),H=b||h,se=(0,_.useMemo)(()=>{let e=k.current;if(!e.size)return 32;let t=0;for(let n of e.values())t+=n;return Math.max(16,t/e.size)},[A]),ce=(0,_.useMemo)(()=>{if(!h)return t.map((e,t)=>({node:e,index:t}));let e=t.length,n=Math.max(0,Math.min(D.start,e)),r=Math.max(n,Math.min(D.end,e));return t.slice(n,r).map((e,t)=>({node:e,index:n+t}))},[t,D,h]);B.current=(0,_.useMemo)(()=>{if(!h)return t.length;let e=Math.max(D.end+p,d),n=Math.min(t.length,e);return Math.max(x,n)},[t.length,h,D.end,p,d,x]);let le=(0,_.useCallback)((e,t)=>{if(e>=t)return 0;let n=k.current,r=0;for(let i=e;i<t;i++)r+=n.get(i)??se;return r},[se]),ue=h?le(0,Math.min(D.start,t.length)):0,de=h?le(Math.min(D.end,t.length),t.length):0,U=(0,_.useCallback)(()=>{L.current!=null&&typeof cancelAnimationFrame==`function`&&(cancelAnimationFrame(L.current),L.current=null),ne.current!=null&&(window.clearTimeout(ne.current),ne.current=null),re.current!=null&&typeof window.cancelIdleCallback==`function`&&(window.cancelIdleCallback(re.current),re.current=null),R.current=!1,z.current=null},[]),fe=(0,_.useCallback)(t=>{if(!y)return;let n=Math.max(2,e.renderBatchBudgetMs??6),r=Math.max(1,u||1),i=Math.max(1,Math.floor(r/4));t>1.2*n?ie.current=Math.max(i,Math.floor(.7*ie.current)):t<.5*n&&ie.current<r&&(ie.current=Math.min(r,Math.ceil(1.2*ie.current)))},[y,e.renderBatchBudgetMs,u]),pe=(0,_.useCallback)((t,n={})=>{if(!y)return;let r=B.current;if(C.current>=r)return;let i=Math.max(1,t),a=e=>{let t=typeof performance<`u`?performance.now():Date.now();S(t=>{let n=Math.min(B.current,t+Math.max(1,e));return C.current=n,n});let n=typeof performance<`u`?performance.now():Date.now();fe(n-t)},o=()=>{let e=Math.max(1,Math.round(ie.current));pe(e)},s=t=>{L.current=null,ne.current=null,re.current=null,R.current=!1;let n=z.current;if(z.current=null,a(n??i),C.current>=B.current)return;if(!t)return void o();let r=Math.max(2,e.renderBatchBudgetMs??6);for(;C.current<B.current&&!((typeof t.timeRemaining==`function`?t.timeRemaining():0)<=.5*r);)a(Math.max(1,Math.round(ie.current)));C.current<B.current&&o()};if(!c||n.immediate)return void s();let u=Math.max(0,e.renderBatchDelay??16);if(z.current=z.current==null?i:Math.max(z.current,i),!R.current){if(R.current=!0,l){let t=Math.max(0,e.renderBatchIdleTimeoutMs??120);re.current=window.requestIdleCallback(e=>s(e),{timeout:t});return}typeof requestAnimationFrame==`function`?L.current=requestAnimationFrame(()=>{u===0?s():ne.current=window.setTimeout(()=>s(),u)}):ne.current=window.setTimeout(()=>s(),u)}},[fe,l,y,c,e.renderBatchDelay,e.renderBatchBudgetMs,e.renderBatchIdleTimeoutMs]);(0,_.useEffect)(()=>{let n=e.indexKey,r=t.length,i=ae.current,a=n===void 0?r!==i.total:n!==i.key,o=oe.current,s=Math.min(o.length,t.length),l=0;for(;l<s&&o[l]===t[l];)l+=1;ae.current={key:n,total:r};let f=V.current,p=e.renderBatchDelay??16,m=f.batchSize!==u||f.initial!==d||f.delay!==p||f.enabled!==y;if(V.current={batchSize:u,initial:d,delay:p,enabled:y},(a||m||!y)&&U(),(a||m)&&(ie.current=Math.max(1,u||1)),n!==i.key)I.current.clear();else if(a)for(let e of I.current)e>=l&&I.current.delete(e);if(!r)return C.current=0,void S(0);let h=B.current;if(!y)return C.current=h,void S(h);if(a||m){let e=Math.min(h,d);C.current=e,S(e),e<h&&pe(Math.max(1,d),{immediate:!c});return}let g=Math.min(C.current,h);g!==C.current&&(C.current=g,S(g)),C.current<h&&pe(Math.max(1,u||1))},[U,y,c,t.length,e.indexKey,e.renderBatchDelay,u,d,pe]),(0,_.useEffect)(()=>{oe.current=t},[t]),(0,_.useEffect)(()=>{if(!h)return void O({start:0,end:t.length});let e=t.length;if(!e)return void O({start:0,end:0});let n=Math.max(0,Math.min(T,e-1)),r=Math.max(0,n-p),i=Math.min(e,n+p+1),a=i-r;if(a>m){let e=a-m;r+=Math.ceil(e/2),i-=Math.floor(e/2)}else if(a<m){let t=m-a;r=Math.max(0,r-Math.ceil(t/2)),i=Math.min(e,i+Math.floor(t/2))}O({start:r,end:i})},[T,p,m,t.length,h]),(0,_.useEffect)(()=>()=>{U();for(let e of N.current.values())e.destroy();N.current.clear()},[U]);let me=(0,_.useCallback)(e=>{for(let[t,n]of N.current.entries())t>=e&&(n.destroy(),N.current.delete(t),delete M.current[t],P.current.delete(t),ee.current.delete(t),F.current.delete(t))},[]);(0,_.useEffect)(()=>{me(w)},[me,w]),(0,_.useEffect)(()=>{let e=t.length,n=!1;for(let t of Array.from(k.current.keys()))t>=e&&(k.current.delete(t),n=!0);n&&j(e=>e+1);for(let t of Object.keys(M.current))Number(t)>=e&&delete M.current[t];for(let t of Array.from(I.current))t>=e&&I.current.delete(t)},[t.length]);let W=(0,_.useCallback)((e,t)=>{b&&t&&(M.current[e]=!0),t&&h&&E(t=>e>t?e:t)},[b,h]),he=(0,_.useCallback)(e=>{let t=N.current.get(e);t&&(t.destroy(),N.current.delete(e))},[]),G=(0,_.useCallback)((e,t)=>{let n=P.current;if(t?n.set(e,t):n.delete(e),!H||!t)return he(e),b&&!t&&delete M.current[e],void(t&&W(e,!0));if(e<d&&!h)return he(e),void W(e,!0);he(e);let r=s(t,{rootMargin:`400px`});N.current.set(e,r),r.isVisible()&&W(e,!0),r.whenVisible.then(()=>W(e,!0)).catch(()=>{})},[b,he,W,s,d,H,h]),ge=(0,_.useCallback)(e=>{let t=ee.current.get(e);if(t)return t;let n=t=>G(e,t);return ee.current.set(e,n),n},[G]),_e=(0,_.useCallback)((e,t)=>{if(!t)return void(k.current.has(e)&&(k.current.delete(e),j(e=>e+1)));let n=()=>{let n=t.offsetHeight;n&&k.current.get(e)!==n&&(k.current.set(e,n),j(e=>e+1))};typeof queueMicrotask==`function`?queueMicrotask(n):Promise.resolve().then(n)},[]),ve=(0,_.useCallback)(e=>{let t=F.current.get(e);if(t)return t;let n=t=>_e(e,t);return F.current.set(e,n),n},[_e]),ye=(0,_.useCallback)(e=>!(y&&e>=C.current)&&(!b||e<d||!0===M.current[e]),[b,y,d]),be=(0,_.useCallback)(e=>t=>{if(!e)return;let n=t.target;n!=null&&n.closest(`[data-node-index]`)&&e(t)},[]);(0,_.useEffect)(()=>{for(let[e,t]of P.current.entries())t&&G(e,t)},[G]),(0,_.useEffect)(()=>{h&&x>te.current&&E(x-1),te.current=x},[x,h]);let K=h?(0,v.jsx)(`div`,{className:`node-spacer`,style:{height:`${ue}px`},"aria-hidden":`true`}):null,q=h?(0,v.jsx)(`div`,{className:`node-spacer`,style:{height:`${de}px`},"aria-hidden":`true`}):null;return(0,v.jsxs)(`div`,{ref:i,className:`markstream-react markdown-renderer${e.isDark?` dark`:``}${h?` virtualized`:``}`,"data-custom-id":e.customId,onClick:e.onClick,onMouseOver:be(e.onMouseOver),onMouseOut:be(e.onMouseOut),children:[K,ce.map(({node:t,index:i})=>{let a=ye(i),o=k.current.get(i)??se,s=!1!==e.fade&&t.type!==`code_block`&&!I.current.has(i)&&a;return s&&I.current.add(i),(0,v.jsx)(`div`,{ref:ge(i),className:`node-slot`,"data-node-index":i,"data-node-type":t.type,children:(0,v.jsx)(`div`,a?{ref:ve(i),className:`node-content`+(s?` fade-node typewriter-node`:``),children:(0,v.jsx)(sw,{node:t,nodeKey:`${r}-${i}`,renderCtx:n})}:{className:`node-placeholder`,style:{height:`${o}px`}})},`${r}-${i}`)}),q,a&&(0,v.jsx)(`span`,{ref:o,className:`typewriter-cursor`,"aria-hidden":`true`})]})},function(e,t){if(e.renderCtx!==t.renderCtx||e.indexPrefix!==t.indexPrefix||e.containerRef!==t.containerRef||e.showTypewriterCursor!==t.showTypewriterCursor)return!1;let n=e.parsedNodes,r=t.parsedNodes;if(n===r)return!0;if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;let i=e.props,a=t.props;return i.isDark===a.isDark&&i.typewriter===a.typewriter&&i.fade===a.fade&&i.batchRendering===a.batchRendering&&i.initialRenderBatchSize===a.initialRenderBatchSize&&i.renderBatchSize===a.renderBatchSize&&i.renderBatchDelay===a.renderBatchDelay&&i.renderBatchBudgetMs===a.renderBatchBudgetMs&&i.renderBatchIdleTimeoutMs===a.renderBatchIdleTimeoutMs&&i.deferNodesUntilVisible===a.deferNodesUntilVisible&&i.maxLiveNodes===a.maxLiveNodes&&i.liveNodeBuffer===a.liveNodeBuffer&&i.viewportPriority===a.viewportPriority&&i.indexKey===a.indexKey&&i.onClick===a.onClick&&i.onMouseOver===a.onMouseOver&&i.onMouseOut===a.onMouseOut});function lw(e){let t={...rw,...e},n=(0,_.useRef)(null),r=(0,_.useRef)(new Map),i=(0,_.useRef)(0),a=(0,_.useRef)(null),o=Ex(t.smoothStreamingOptions),s=_.useContext(vx),c=(0,_.useRef)(new Set),[l,u]=(0,_.useState)(()=>!0===t.smoothStreaming);(0,_.useEffect)(()=>{u(!0)},[]);let d=Array.isArray(t.nodes)&&t.nodes.length>0,f=(0,_.useMemo)(()=>!1!==t.smoothStreaming&&!d&&(!0===t.smoothStreaming||!s)&&(!0===t.smoothStreaming||!0===t.typewriter||(t.maxLiveNodes??0)<=0),[d,s,t.maxLiveNodes,t.smoothStreaming,t.typewriter]),p=l&&f,m=p?o.visible:t.content??``,h=(0,_.useMemo)(()=>{let e=t.parseOptions??{};return t.final??e.final},[t.final,t.parseOptions]),g=t.content??``,y=d||o.source===g,b=(0,_.useMemo)(()=>p&&h!=null?!!(h&&y&&o.caughtUp):h,[h,y,o.caughtUp,p]),x=(0,_.useRef)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(void 0),T=(0,_.useRef)(0),E=(0,_.useMemo)(()=>new Set([`code_block`,`admonition`,`table`,`math_block`,`html_block`,`image`]),[]),D=(0,_.useCallback)(e=>{if(!e||typeof e!=`object`)return!1;let t=e.type;return typeof t==`string`&&E.has(t)},[E]),O=(0,_.useCallback)(e=>{if(!e||typeof e!=`object`)return 0;let t=e,n=t.raw??t.content??t.code;if(typeof n==`string`)return n.length;let r=t.children;if(Array.isArray(r))return r.reduce((e,t)=>e+O(t),0);let i=t.items;return Array.isArray(i)?i.reduce((e,t)=>e+O(t),0):0},[]),k=(0,_.useCallback)(()=>t.nodes?.length?t.nodes.reduce((e,t)=>e+O(t),0):(t.content??``).length,[t.nodes,t.content,O]),A=(0,_.useCallback)(()=>{w.current&&=(clearTimeout(w.current),void 0)},[]),j=(0,_.useCallback)(e=>{let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){if(!(e.textContent??``).trim())return NodeFilter.FILTER_REJECT;let t=e.parentElement;return t?t.closest(`.typewriter-cursor, .height-estimation-probes, [data-node-type="code_block"], [data-node-type="admonition"], [data-node-type="table"], [data-node-type="math_block"], [data-node-type="html_block"], [data-node-type="image"], script, style`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),n=null,r=t.nextNode();for(;r;)n=r,r=t.nextNode();return n},[]),M=(0,_.useCallback)(()=>{if(typeof window>`u`||!S||!n.current||!x.current)return;let e=n.current,t=x.current,r=j(e),i=e.getBoundingClientRect(),a=0,o=0,s=20;if(r?.textContent){let t=document.createRange(),n=r.textContent.length;t.setStart(r,Math.max(0,n-1)),t.setEnd(r,n);let c=typeof t.getClientRects==`function`?t.getClientRects():void 0,l=c?.[c.length-1]??r.parentElement?.getBoundingClientRect();l&&(a=l.right-i.left+e.scrollLeft,o=l.top-i.top+e.scrollTop,s=l.height||s),t.detach()}t.style.transform=`translate(${Math.max(0,a)}px, ${Math.max(0,o)}px)`,t.style.height=`${s}px`},[S,n,j]);(0,_.useEffect)(()=>{S&&requestAnimationFrame(()=>{M()})},[S,M]),(0,_.useEffect)(()=>()=>{A()},[A]);let N=d?t.nodes:m;a.current!==N&&(i.current+=1,a.current=N);let P=(0,_.useSyncExternalStore)(fb,pb,pb),ee=(0,_.useMemo)(()=>hb(t.customId),[t.customId,P]),F=ow(t.streamingComponents),I=ow(t.htmlComponents);(0,_.useEffect)(()=>{c.current},[I,F]);let te=(0,_.useMemo)(()=>t.customId?`renderer-${t.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[t.customId]),L=(0,_.useMemo)(()=>{let e=(t.parseOptions??{}).customHtmlTags??[];return Jc(t.customHtmlTags,Array.isArray(e)?e:[],Object.keys(F))},[t.customId,t.customHtmlTags,t.parseOptions,P,F]),ne=(0,_.useMemo)(()=>{let e=L;return e&&e.length!==0?rb(te,{customHtmlTags:e}):rb(te)},[te,L]),re=(0,_.useMemo)(()=>{let e=ne;return t.customMarkdownIt?t.customMarkdownIt(e):e},[ne,t.customMarkdownIt]),R=(0,_.useMemo)(()=>{let e=t.parseOptions??{},n=b,r=n!=null,i=L.length>0;return r||i?{...e,...r?{final:n}:{},...i?{customHtmlTags:L}:{}}:e},[L,b,t.parseOptions]),z=(0,_.useMemo)(()=>{let e=!!t.debugPerformance&&typeof console<`u`&&typeof performance<`u`,n=e?performance.now():0,r=[];return d?r=t.nodes.map(e=>({...e})):m&&(r=Kv(m,re??iw,R)),e&&(Math.round(performance.now()-n),r.length,m.length),r},[t.debugPerformance,m,d,t.nodes,R,re,t.customId,P,L]),ie=(0,_.useCallback)(()=>{let e=z[z.length-1];return!D(e)},[z,D]);(0,_.useEffect)(()=>{if(typeof window>`u`||d)return;if(b)return C(!1),void A();let e=k(),n=ie();return!1===t.typewriter||!n||e<=T.current?(!1!==t.typewriter&&n||C(!1),void(T.current=e)):(T.current=e,C(!0),A(),requestAnimationFrame(()=>{M()}),w.current=setTimeout(()=>{C(!1)},3e3),()=>{A()})},[m,t.nodes,t.typewriter,t.content,b,z.length,d,k,ie,A,M]);let B=(0,_.useRef)([]),ae=R?.postTransformNodes,oe=(0,_.useRef)(ae);oe.current!==ae&&(B.current=[],oe.current=ae);let V=function(e,t){if(!t.length)return e;let n=Array(e.length),r=e.length===t.length;for(let i=0;i<e.length;i++){let a=i<t.length?t[i]:null;a&&aw(a,e[i])?n[i]=a:(n[i]=e[i],r=!1)}return r?t:n}(z,B.current);B.current=V,(0,_.useEffect)(()=>{if(d)return void o.reset(``);let e=t.content??``;if(!p)return o.reset(e),void(h&&o.finish({flush:!0}));let n=o.getSnapshot().source;e?e===n||(e.startsWith(n)?o.enqueue(e.slice(n.length)):o.reset(e)):o.reset(``),h&&o.finish()},[d,t.content,h,p]),(0,_.useEffect)(()=>{if(typeof window>`u`||t.renderCodeBlocksAsPre||!V.some(e=>e?.type===`code_block`&&Eb(String(e?.language??``))!==`mermaid`))return;let e=window.requestIdleCallback??((e,t)=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),t?.timeout??600)),n=window.cancelIdleCallback??(e=>window.clearTimeout(e)),r=e(()=>{Gx()},{timeout:900});return()=>n(r)},[V,t.renderCodeBlocksAsPre]);let H=(0,_.useMemo)(()=>t.indexKey==null?`markdown-renderer`:String(t.indexKey),[t.indexKey]),se=(0,_.useMemo)(()=>({...typeof t.showTooltips==`boolean`?{showTooltips:t.showTooltips}:{},...t.codeBlockProps||{}}),[t.codeBlockProps,t.showTooltips]),ce=(0,_.useMemo)(()=>({...t.mermaidProps||{}}),[t.mermaidProps]),le=(0,_.useMemo)(()=>({...t.d2Props||{}}),[t.d2Props]),ue=(0,_.useMemo)(()=>({...t.infographicProps||{}}),[t.infographicProps]),de=(0,_.useMemo)(()=>({customId:t.customId,isDark:t.isDark,final:b,indexKey:H,typewriter:t.typewriter,fade:t.fade,textStreamState:r.current,streamRenderVersion:i.current,customComponents:ee,streamingComponents:F,htmlComponents:I,customHtmlTags:L,htmlPolicy:t.htmlPolicy??`safe`,showTooltips:t.showTooltips,renderCodeBlocksAsPre:t.renderCodeBlocksAsPre,codeBlockStream:t.codeBlockStream,codeBlockOptions:t.codeBlockOptions,codeBlockProps:se,mermaidProps:ce,d2Props:le,infographicProps:ue,codeBlockThemes:{themes:t.themes,darkTheme:t.codeBlockDarkTheme,lightTheme:t.codeBlockLightTheme,minWidth:t.codeBlockMinWidth,maxWidth:t.codeBlockMaxWidth},events:{onCopy:t.onCopy,onHandleArtifactClick:t.onHandleArtifactClick}}),[t.customId,t.isDark,b,H,t.typewriter,t.fade,t.showTooltips,t.htmlPolicy,t.renderCodeBlocksAsPre,t.codeBlockStream,t.codeBlockOptions,L,se,ce,le,ue,t.themes,t.codeBlockDarkTheme,t.codeBlockLightTheme,t.codeBlockMinWidth,t.codeBlockMaxWidth,t.onCopy,t.onHandleArtifactClick,ee,F,I]);de.streamRenderVersion=i.current,de.textStreamState=r.current;let U=(0,_.useRef)(null);return U.current||={textStreamState:r.current,getStreamRenderVersion:()=>i.current},(0,v.jsx)(yx.Provider,{value:U.current,children:(0,v.jsx)(vx.Provider,{value:p,children:(0,v.jsx)(wx,{getRoot:()=>n.current,enabled:!1!==t.viewportPriority,children:(0,v.jsx)(cw,{props:t,parsedNodes:V,renderCtx:de,indexPrefix:H,containerRef:n,showTypewriterCursor:S,typewriterCursorRef:x})})})})}function uw(e){let{node:t,ctx:n,renderNode:r,indexKey:i,children:a}=e;return(0,v.jsx)(`blockquote`,{className:`blockquote-node`,dir:`auto`,cite:t.cite,children:a??(n&&r?(0,v.jsx)(lw,{nodes:t.children||[],indexKey:`blockquote-${String(i??`blockquote`)}`,customId:n.customId,isDark:n.isDark,typewriter:n.typewriter,viewportPriority:!0,codeBlockStream:n.codeBlockStream,renderCodeBlocksAsPre:n.renderCodeBlocksAsPre,codeBlockOptions:n.codeBlockOptions,codeBlockProps:n.codeBlockProps,themes:n.codeBlockThemes?.themes,codeBlockDarkTheme:n.codeBlockThemes?.darkTheme,codeBlockLightTheme:n.codeBlockThemes?.lightTheme,codeBlockMinWidth:n.codeBlockThemes?.minWidth,codeBlockMaxWidth:n.codeBlockThemes?.maxWidth,htmlPolicy:n.htmlPolicy,showTooltips:n.showTooltips,onCopy:n.events.onCopy,onHandleArtifactClick:n.events.onHandleArtifactClick}):null)})}export{mb as a,BS as i,GS as n,_b as o,WS as r,lw as t};
|
|
173
|
+
`)}async function VC(e,t={}){let{timeoutMs:n,signal:r}=t;return r?.aborted?Promise.reject(new DOMException(`Aborted`,`AbortError`)):new Promise((t,i)=>{let a=!1,o=null;function s(){a||(a=!0,c(),i(new DOMException(`Aborted`,`AbortError`)))}function c(){o!=null&&clearTimeout(o),r&&r.removeEventListener(`abort`,s)}r&&r.addEventListener(`abort`,s,{once:!0}),n&&n>0&&(o=setTimeout(()=>{a||(a=!0,c(),i(Error(`Operation timed out`)))},n)),e().then(e=>{a||(a=!0,c(),t(e))}).catch(e=>{a||(a=!0,c(),i(e))})})}function HC(e){return new XMLSerializer().serializeToString(e)}function UC(e){let{node:t}=e;return(0,v.jsxs)(`div`,{className:`unknown-node text-sm text-gray-500 italic`,children:[`Unsupported node type:`,` `,String(t?.type)]})}function WC(e){return e?.type===`text`&&String(e?.content??``).trim()===``}function GC(e,t,n,r){let i=e.filter(e=>!WC(e)),a=i.length>0&&i.every(e=>e.type===`image`||function(e){let t=function(e){return e?.type===`link`&&Array.isArray(e?.children)?e.children.filter(e=>!WC(e)):[]}(e);return t.length===1&&t[0]?.type===`image`}(e));if(!a||i.length<=1)return ob(e,n,r,t);let o=[];for(let t=0;t<e.length;t++){let n=e[t];if(!WC(n)){o.push(n);continue}let r=o.length>0,i=e.slice(t+1).some(e=>!WC(e));r&&i&&o.push({...n,content:` `,raw:` `})}return o.map((e,i)=>a&&WC(e)?(0,v.jsx)(_.Fragment,{children:String(e?.content??``)},`${r}-${i}`):t(e,`${r}-${i}`,n))}function KC(e){let{node:t,ctx:n,renderNode:r,indexKey:i,children:a}=e;if(!n||!r)return(0,v.jsx)(`p`,{dir:`auto`,className:`paragraph-node`,children:a});let o=t.children??[],s={...n.customComponents??hb(n.customId),...n.htmlComponents??{},...n.streamingComponents??{}},c=[],l=[],u=()=>{if(!l.length)return;let e=c.length;c.push((0,v.jsx)(`p`,{dir:`auto`,className:`paragraph-node`,children:GC(l.slice(),r,n,`${String(i??`paragraph`)}-${e}`)},`${String(i??`paragraph`)}-inline-${e}`)),l.length=0};return o.forEach((e,t)=>{let a=(n.htmlPolicy??`safe`)!==`escape`||e.type!==`html_inline`&&e.type!==`html_block`;ib.has(e.type)||a&&fx(e,s,n.customHtmlTags)?(u(),c.push((0,v.jsx)(_.Fragment,{children:r(e,`${String(i??`paragraph`)}-block-${t}`,n)},`${String(i??`paragraph`)}-block-${t}`))):l.push(e)}),u(),c.length?(0,v.jsx)(v.Fragment,{children:c}):(0,v.jsx)(`p`,{dir:`auto`,className:`paragraph-node`,children:GC(o,r,n,String(i??`paragraph`))})}function qC(e){let{node:t}=e,n=(0,_.useCallback)(n=>{var r;(r=e.onClick)==null||r.call(e,n,t.id,e.messageId,e.threadId)},[t.id,e]);return(0,v.jsx)(`span`,{className:`reference-node cursor-pointer bg-[hsl(var(--muted))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]`,role:`button`,tabIndex:0,onClick:n,onMouseEnter:n=>{var r;(r=e.onMouseEnter)==null||r.call(e,n,t.id,e.messageId,e.threadId)},onMouseLeave:n=>{var r;(r=e.onMouseLeave)==null||r.call(e,n,t.id,e.messageId,e.threadId)},onKeyDown:e=>{e.key!==`Enter`&&e.key!==` `||n(e)},children:t.id})}function JC(e){return(0,v.jsx)(`s`,{className:`strikethrough-node`,children:e.children})}function YC(e){return(0,v.jsx)(`strong`,{className:`strong-node`,children:e.children})}function XC(e){return(0,v.jsx)(`sub`,{className:`subscript-node`,children:e.children})}function ZC(e){return(0,v.jsx)(`sup`,{className:`superscript-node`,children:e.children})}function QC(e){let{node:t,ctx:n,renderNode:r,indexKey:i}=e,a=Array.isArray(t?.header?.cells)?t.header.cells:[],o=!!t?.loading,s=Array.isArray(t?.rows)?t.rows:[],c=_.useRef(null),l=_.useRef(null),u=_.useRef(null),[d,f]=_.useState([]),p=e=>e===`right`?`text-right`:e===`center`?`text-center`:`text-left`,m=()=>{let e=u.current;e&&(window.removeEventListener(`pointermove`,e.move),window.removeEventListener(`pointerup`,e.stop),window.removeEventListener(`pointercancel`,e.stop),u.current=null),l.current=null};return _.useEffect(()=>(m(),f([]),m),[a.length]),(0,v.jsxs)(`div`,{className:`table-node-wrapper`,"data-index-key":i,children:[(0,v.jsxs)(`table`,{ref:c,className:Q(`my-8 text-sm table-node`,o&&`table-node--loading`),"aria-busy":o,children:[d.length>0&&(0,v.jsx)(`colgroup`,{children:a.map((e,t)=>(0,v.jsx)(`col`,{style:d[t]>0?{width:`${d[t]}px`}:void 0},`col-${t}`))}),(0,v.jsx)(`thead`,{className:`border-[var(--table-border,#cbd5e1)]`,children:(0,v.jsx)(`tr`,{className:`border-b`,children:a.map((e,t)=>(0,v.jsxs)(`th`,{className:Q(`font-semibold p-[calc(4/7*1em)]`,p(e.align)),dir:`auto`,children:[n&&r?sb(e.children,n,`${String(i??`table`)}-th-${t}`,r):null,t<a.length-1&&(0,v.jsx)(`button`,{type:`button`,className:`table-node__resize-handle`,"aria-label":`Resize columns ${t+1} and ${t+2}`,onPointerDown:e=>((e,t)=>{if(t.button!==0)return;let n=(()=>{let e=c.current?.querySelectorAll(`thead th`);return Array.from(e??[],e=>Math.round(e.getBoundingClientRect().width))})(),r=n[e],i=n[e+1];if(!r||!i)return;t.preventDefault(),m(),l.current={index:e,startX:t.clientX,startWidth:r,nextStartWidth:i,widths:n},f(n);let a=e=>{let t=l.current;if(!t)return;e.preventDefault();let n=t.startWidth+t.nextStartWidth,r=Math.min(48,Math.floor(n/2)),i=Math.max(r,Math.min(n-r,Math.round(t.startWidth+e.clientX-t.startX))),a=[...t.widths];a[t.index]=i,a[t.index+1]=n-i,f(a)},o=()=>{m()};u.current={move:a,stop:o},window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)})(t,e)})]},`header-${t}`))})}),(0,v.jsx)(`tbody`,{children:s.map((e,t)=>(0,v.jsx)(`tr`,{className:Q(`border-[var(--table-border,#cbd5e1)]`,t<s.length-1&&`border-b`),children:e.cells?.map((e,a)=>(0,v.jsx)(`td`,{className:Q(`p-[calc(4/7*1em)]`,p(e.align)),dir:`auto`,children:n&&r?sb(e.children,n,`${String(i??`table`)}-row-${t}-${a}`,r):null},`cell-${t}-${a}`))},`row-${t}`))})]}),o&&(0,v.jsxs)(`div`,{className:`table-node__loading`,role:`status`,"aria-live":`polite`,children:[(0,v.jsx)(`span`,{className:`table-node__spinner`,"aria-hidden":`true`}),(0,v.jsx)(`span`,{className:`sr-only`,children:`Loading`})]})]})}function $C(){return(0,v.jsx)(`hr`,{className:`hr-node thematic-break`})}function ew(e){let{node:t,ctx:n,renderNode:r,indexKey:i}=e,a=`vmr-container vmr-container-${t.name}`,o=(0,_.useMemo)(()=>{if(t.attrs)return Array.isArray(t.attrs)?ab(t.attrs):t.attrs},[t.attrs]);return(0,v.jsx)(`div`,{className:a,...o,children:n&&r&&Array.isArray(t.children)?t.children.map((e,t)=>(0,v.jsx)(_.Fragment,{children:r(e,`${String(i??`vmr-container`)}-${t}`,n)},`${String(i??`vmr-container`)}-${t}`)):null})}function tw(e,t,n,r,i={}){let a=mx(r.codeBlockProps),o=r.events.onHandleArtifactClick?e=>{var i,a;let o=e.type===`image/svg+xml`?`image/svg+xml`:`text/html`;(a=(i=r.events).onHandleArtifactClick)==null||a.call(i,{node:e.content==null?t:{...t,code:e.content},artifactType:o,artifactTitle:e.title||(o===`image/svg+xml`?`SVG Preview`:`HTML Preview`),id:String(n)})}:void 0;return _.createElement(e,{key:n,node:t,loading:!!t.loading,stream:r.codeBlockStream,customId:r.customId,isDark:r.isDark,darkTheme:r.codeBlockThemes?.darkTheme,lightTheme:r.codeBlockThemes?.lightTheme,themes:r.codeBlockThemes?.themes,minWidth:r.codeBlockThemes?.minWidth,maxWidth:r.codeBlockThemes?.maxWidth,onCopy:r.events.onCopy,onPreviewCode:o,...a,codeBlockOptions:r.codeBlockOptions,...i,ctx:r,renderNode:$,indexKey:n,typewriter:r.typewriter,fade:r.fade})}function nw(e,t,n,r,i={}){return _.createElement(e,{key:n,node:t,isDark:r.isDark,...i})}function $(e,t,n){let r=n.customComponents??hb(n.customId),i=n.streamingComponents??{},a=n.htmlComponents??{},s=function(e){if(e.type===`html_block`||e.type===`html_inline`)return``;let t=Kc(e.type),n=Kc(e.tag);return t&&n&&t===n?t:``}(e),c=s?i[s]:null,l=s&&!c?a[s]:null,u=e.type===`code_block`?null:r[e.type];if(c)return _.createElement(c,{key:t,node:e,customId:n.customId,isDark:n.isDark,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade});if(l)return function(e,t,n,r,i){let a=Cy(by(xy(t.attrs??void 0,r.htmlPolicy??`safe`,i))),o=Array.isArray(t.children)?ob(t.children,r,`${String(n)}-html`,$):t.content??null;return _.createElement(e,{...a,key:n},o)}(l,e,t,n,s);if(u)return _.createElement(u,{key:t,node:e,customId:n.customId,isDark:n.isDark,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade});if(e.type===`html_block`||e.type===`html_inline`){let a=dx(e,{...r,...i},n.customHtmlTags),o=String(e.tag??``).trim().toLowerCase()||Yc(e.content),s=a?.tag??o;if(s){let i=a?.component??r[s],o=a?.isWhitelisted??(n.customHtmlTags??[]).some(e=>e.toLowerCase()===s);if(o&&i){let r={...e,type:s,tag:s,content:Qc(e.content,s)};return _.createElement(i,{key:t,node:r,customId:n.customId,isDark:n.isDark,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade})}let c=String(e.content??e.raw??``);if(!o&&Zc(c,s))return e.type===`html_inline`?(0,v.jsx)(WS,{node:{type:`text`,content:c,raw:c},ctx:n,indexKey:t,typewriter:n.typewriter,fade:n.fade},t):(0,v.jsx)(KC,{node:{type:`paragraph`,children:[{type:`text`,content:c,raw:c}],raw:c},ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t)}}switch(e.type){case`text`:return(0,v.jsx)(WS,{node:e,ctx:n,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`text_special`:return(0,v.jsx)(WS,{node:{type:`text`,content:e.content??``,center:e.center},ctx:n,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`paragraph`:return(0,v.jsx)(KC,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`heading`:return(0,v.jsx)(_S,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`blockquote`:return(0,v.jsx)(uw,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`list`:return(0,v.jsx)(qS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`list_item`:return(0,v.jsx)(KS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`table`:return(0,v.jsx)(QC,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`definition_list`:return(0,v.jsx)(uS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`footnote`:return(0,v.jsx)(mS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`footnote_reference`:return(0,v.jsx)(hS,{node:e},t);case`footnote_anchor`:return(0,v.jsx)(pS,{node:e},t);case`admonition`:return(0,v.jsx)(_x,{node:e,ctx:n,renderNode:$,indexKey:t,isDark:n.isDark,typewriter:n.typewriter,fade:n.fade},t);case`hardbreak`:return(0,v.jsx)(gS,{node:e,typewriter:n.typewriter,fade:n.fade},t);case`link`:return(0,v.jsx)(GS,{node:e,ctx:n,renderNode:$,indexKey:t,isDark:n.isDark,showTooltip:typeof n.showTooltips==`boolean`?n.showTooltips:void 0,typewriter:n.typewriter,fade:n.fade},t);case`image`:return(0,v.jsx)(NS,{node:e},t);case`inline_code`:return(0,v.jsx)(BS,{node:e,ctx:n,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`code_block`:return function(e,t,n,r){let i=function(e){let t=String(e?.language||``).trim();if(!t)return``;let[n]=t.split(/\s+/),[r]=n.split(`:`);return r.toLowerCase()}(e),a=Eb(i),s=function(e,t){let n=t.trim().toLowerCase();if(!n)return null;for(let t of[n,Eb(n),o(n)]){let n=t&&e[t];if(n)return n}return null}(r,i);if(a===`mermaid`){let i=function(e,t){let n={...t.mermaidProps||{}};return cx(n.estimatedPreviewHeightPx)??(n.estimatedPreviewHeightPx=ux(lx(String(e?.code??``)),void 0,n.maxHeight===`none`?null:cx(n.maxHeight)??void 0)),n}(e,n),a=s||r.mermaid;if(a)return nw(a,e,t,n,i);if(!n.renderCodeBlocksAsPre)return(0,v.jsx)(PC,{node:e,isDark:n.isDark,loading:!!e.loading,...i},t)}if(a===`infographic`){let i=function(e,t){let n={...t.infographicProps||{}};return ix(n.estimatedPreviewHeightPx)??(n.estimatedPreviewHeightPx=ox(ax(String(e?.code??``)),void 0,n.maxHeight===`none`?null:ix(n.maxHeight)??void 0)),n}(e,n),a=s||r.infographic;return a?nw(a,e,t,n,i):(0,v.jsx)(RS,{node:e,isDark:n.isDark,loading:!!e.loading,...i},t)}if(a===`d2`||a===`d2lang`){let i=s||r.d2;return i?nw(i,e,t,n,n.d2Props||{}):(0,v.jsx)(lS,{node:e,isDark:n.isDark,loading:!!e.loading,...n.d2Props||{}},t)}if(s)return tw(s,e,t,n);let c=r.code_block;if(c)return tw(c,e,t,n);if(n.renderCodeBlocksAsPre||a===`mermaid`){let r=n.codeBlockProps?.showLineNumbers,i=n.codeBlockOptions?.disableLineNumbers,a=n.codeBlockOptions?.overflow;return(0,v.jsx)(Hb,{node:e,style:a?{whiteSpace:a===`scroll`?`pre`:`pre-wrap`}:void 0,showLineNumbers:typeof r==`boolean`?r:typeof i==`boolean`&&!i},t)}return(0,v.jsx)(Qx,{node:e,loading:!!e.loading,stream:n.codeBlockStream,themes:n.codeBlockThemes?.themes,darkTheme:n.codeBlockThemes?.darkTheme,lightTheme:n.codeBlockThemes?.lightTheme,minWidth:n.codeBlockThemes?.minWidth,maxWidth:n.codeBlockThemes?.maxWidth,isDark:n.isDark,onCopy:n.events.onCopy,...mx(n.codeBlockProps),codeBlockOptions:n.codeBlockOptions},t)}(e,t,n,r);case`strong`:return(0,v.jsx)(YC,{node:e,children:ob(e.children,n,`${String(t)}-strong`,$)},t);case`emphasis`:return(0,v.jsx)(fS,{node:e,children:ob(e.children,n,`${String(t)}-em`,$)},t);case`strikethrough`:return(0,v.jsx)(JC,{node:e,children:ob(e.children,n,`${String(t)}-strike`,$)},t);case`highlight`:return(0,v.jsx)(vS,{node:e,children:ob(e.children,n,`${String(t)}-highlight`,$)},t);case`insert`:return(0,v.jsx)(VS,{node:e,children:ob(e.children,n,`${String(t)}-insert`,$)},t);case`subscript`:return(0,v.jsx)(XC,{node:e,children:ob(e.children,n,`${String(t)}-sub`,$)},t);case`superscript`:return(0,v.jsx)(ZC,{node:e,children:ob(e.children,n,`${String(t)}-sup`,$)},t);case`checkbox`:case`checkbox_input`:return(0,v.jsx)(Dx,{node:e,typewriter:n.typewriter,fade:n.fade},t);case`emoji`:return(0,v.jsx)(dS,{node:e,typewriter:n.typewriter,fade:n.fade},t);case`thematic_break`:return(0,v.jsx)($C,{},t);case`math_inline`:return(0,v.jsx)(fC,{node:e},t);case`math_block`:return(0,v.jsx)(dC,{node:e},t);case`reference`:return(0,v.jsx)(qC,{node:e,ctx:n,typewriter:n.typewriter,fade:n.fade},t);case`html_block`:case`html_inline`:return e.type===`html_block`?(0,v.jsx)(yS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade,customId:n.customId},t):(0,v.jsx)(AS,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade,customId:n.customId},t);case`vmr_container`:return(0,v.jsx)(ew,{node:e,ctx:n,renderNode:$,indexKey:t,typewriter:n.typewriter,fade:n.fade},t);case`label_open`:case`label_close`:return null;default:return(0,v.jsx)(UC,{node:e},t)}}var rw={codeBlockStream:!0,typewriter:!1,fade:!0,smoothStreaming:`auto`,batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:320,liveNodeBuffer:60},iw=rb();function aw(e,t){return e.type===t.type&&e.raw===t.raw&&e.loading===t.loading&&e.autoClosed===t.autoClosed&&!!function(e,t){if(e===t)return!0;if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=e,r=t;return n.startLine===r.startLine&&n.endLine===r.endLine}(e.sourceMap,t.sourceMap)&&(e.type!==`code_block`&&t.type!==`code_block`||e.diff===t.diff)}function ow(e){let t=(0,_.useMemo)(()=>vb(e),[e]),n=(0,_.useRef)(t);return function(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}(n.current,t)||(n.current=t),n.current}var sw=_.memo(({node:e,nodeKey:t,renderCtx:n})=>$(e,t,n),(e,t)=>e.node===t.node&&e.renderCtx===t.renderCtx&&e.nodeKey===t.nodeKey),cw=_.memo(({props:e,parsedNodes:t,renderCtx:n,indexPrefix:r,containerRef:i,showTypewriterCursor:a,typewriterCursorRef:o})=>{let s=Tx(),c=typeof window<`u`,l=typeof window<`u`&&typeof window.requestIdleCallback==`function`,u=Math.max(0,Math.trunc(e.renderBatchSize??80)),d=Math.max(0,Math.trunc(e.initialRenderBatchSize??(u||t.length))),f=!1!==e.batchRendering&&u>0&&c,p=Math.max(0,e.liveNodeBuffer??60),m=Math.max(1,e.maxLiveNodes??320),h=(e.maxLiveNodes??0)>0&&t.length>m,g=!1!==e.viewportPriority,y=f&&(e.maxLiveNodes??0)<=0,b=(0,_.useMemo)(()=>!1!==e.deferNodesUntilVisible&&!((e.maxLiveNodes??0)<=0)&&!h&&!(t.length>900)&&g,[t.length,e.deferNodesUntilVisible,e.maxLiveNodes,g,h]),[x,S]=(0,_.useState)(()=>y?Math.min(t.length,d):t.length),C=(0,_.useRef)(x);(0,_.useEffect)(()=>{C.current=x},[x]);let w=y?x:t.length,[T,E]=(0,_.useState)(0),[D,O]=(0,_.useState)({start:0,end:t.length}),k=(0,_.useRef)(new Map),[A,j]=(0,_.useState)(0),M=(0,_.useRef)({}),N=(0,_.useRef)(new Map),P=(0,_.useRef)(new Map),ee=(0,_.useRef)(new Map),F=(0,_.useRef)(new Map),I=(0,_.useRef)(new Set),te=(0,_.useRef)(x),L=(0,_.useRef)(null),ne=(0,_.useRef)(null),re=(0,_.useRef)(null),R=(0,_.useRef)(!1),z=(0,_.useRef)(null),ie=(0,_.useRef)(Math.max(1,u||1)),B=(0,_.useRef)(t.length),ae=(0,_.useRef)({key:e.indexKey,total:t.length}),oe=(0,_.useRef)(t),V=(0,_.useRef)({batchSize:u,initial:d,delay:e.renderBatchDelay??16,enabled:y}),H=b||h,se=(0,_.useMemo)(()=>{let e=k.current;if(!e.size)return 32;let t=0;for(let n of e.values())t+=n;return Math.max(16,t/e.size)},[A]),ce=(0,_.useMemo)(()=>{if(!h)return t.map((e,t)=>({node:e,index:t}));let e=t.length,n=Math.max(0,Math.min(D.start,e)),r=Math.max(n,Math.min(D.end,e));return t.slice(n,r).map((e,t)=>({node:e,index:n+t}))},[t,D,h]);B.current=(0,_.useMemo)(()=>{if(!h)return t.length;let e=Math.max(D.end+p,d),n=Math.min(t.length,e);return Math.max(x,n)},[t.length,h,D.end,p,d,x]);let le=(0,_.useCallback)((e,t)=>{if(e>=t)return 0;let n=k.current,r=0;for(let i=e;i<t;i++)r+=n.get(i)??se;return r},[se]),ue=h?le(0,Math.min(D.start,t.length)):0,de=h?le(Math.min(D.end,t.length),t.length):0,U=(0,_.useCallback)(()=>{L.current!=null&&typeof cancelAnimationFrame==`function`&&(cancelAnimationFrame(L.current),L.current=null),ne.current!=null&&(window.clearTimeout(ne.current),ne.current=null),re.current!=null&&typeof window.cancelIdleCallback==`function`&&(window.cancelIdleCallback(re.current),re.current=null),R.current=!1,z.current=null},[]),fe=(0,_.useCallback)(t=>{if(!y)return;let n=Math.max(2,e.renderBatchBudgetMs??6),r=Math.max(1,u||1),i=Math.max(1,Math.floor(r/4));t>1.2*n?ie.current=Math.max(i,Math.floor(.7*ie.current)):t<.5*n&&ie.current<r&&(ie.current=Math.min(r,Math.ceil(1.2*ie.current)))},[y,e.renderBatchBudgetMs,u]),pe=(0,_.useCallback)((t,n={})=>{if(!y)return;let r=B.current;if(C.current>=r)return;let i=Math.max(1,t),a=e=>{let t=typeof performance<`u`?performance.now():Date.now();S(t=>{let n=Math.min(B.current,t+Math.max(1,e));return C.current=n,n});let n=typeof performance<`u`?performance.now():Date.now();fe(n-t)},o=()=>{let e=Math.max(1,Math.round(ie.current));pe(e)},s=t=>{L.current=null,ne.current=null,re.current=null,R.current=!1;let n=z.current;if(z.current=null,a(n??i),C.current>=B.current)return;if(!t)return void o();let r=Math.max(2,e.renderBatchBudgetMs??6);for(;C.current<B.current&&!((typeof t.timeRemaining==`function`?t.timeRemaining():0)<=.5*r);)a(Math.max(1,Math.round(ie.current)));C.current<B.current&&o()};if(!c||n.immediate)return void s();let u=Math.max(0,e.renderBatchDelay??16);if(z.current=z.current==null?i:Math.max(z.current,i),!R.current){if(R.current=!0,l){let t=Math.max(0,e.renderBatchIdleTimeoutMs??120);re.current=window.requestIdleCallback(e=>s(e),{timeout:t});return}typeof requestAnimationFrame==`function`?L.current=requestAnimationFrame(()=>{u===0?s():ne.current=window.setTimeout(()=>s(),u)}):ne.current=window.setTimeout(()=>s(),u)}},[fe,l,y,c,e.renderBatchDelay,e.renderBatchBudgetMs,e.renderBatchIdleTimeoutMs]);(0,_.useEffect)(()=>{let n=e.indexKey,r=t.length,i=ae.current,a=n===void 0?r!==i.total:n!==i.key,o=oe.current,s=Math.min(o.length,t.length),l=0;for(;l<s&&o[l]===t[l];)l+=1;ae.current={key:n,total:r};let f=V.current,p=e.renderBatchDelay??16,m=f.batchSize!==u||f.initial!==d||f.delay!==p||f.enabled!==y;if(V.current={batchSize:u,initial:d,delay:p,enabled:y},(a||m||!y)&&U(),(a||m)&&(ie.current=Math.max(1,u||1)),n!==i.key)I.current.clear();else if(a)for(let e of I.current)e>=l&&I.current.delete(e);if(!r)return C.current=0,void S(0);let h=B.current;if(!y)return C.current=h,void S(h);if(a||m){let e=Math.min(h,d);C.current=e,S(e),e<h&&pe(Math.max(1,d),{immediate:!c});return}let g=Math.min(C.current,h);g!==C.current&&(C.current=g,S(g)),C.current<h&&pe(Math.max(1,u||1))},[U,y,c,t.length,e.indexKey,e.renderBatchDelay,u,d,pe]),(0,_.useEffect)(()=>{oe.current=t},[t]),(0,_.useEffect)(()=>{if(!h)return void O({start:0,end:t.length});let e=t.length;if(!e)return void O({start:0,end:0});let n=Math.max(0,Math.min(T,e-1)),r=Math.max(0,n-p),i=Math.min(e,n+p+1),a=i-r;if(a>m){let e=a-m;r+=Math.ceil(e/2),i-=Math.floor(e/2)}else if(a<m){let t=m-a;r=Math.max(0,r-Math.ceil(t/2)),i=Math.min(e,i+Math.floor(t/2))}O({start:r,end:i})},[T,p,m,t.length,h]),(0,_.useEffect)(()=>()=>{U();for(let e of N.current.values())e.destroy();N.current.clear()},[U]);let me=(0,_.useCallback)(e=>{for(let[t,n]of N.current.entries())t>=e&&(n.destroy(),N.current.delete(t),delete M.current[t],P.current.delete(t),ee.current.delete(t),F.current.delete(t))},[]);(0,_.useEffect)(()=>{me(w)},[me,w]),(0,_.useEffect)(()=>{let e=t.length,n=!1;for(let t of Array.from(k.current.keys()))t>=e&&(k.current.delete(t),n=!0);n&&j(e=>e+1);for(let t of Object.keys(M.current))Number(t)>=e&&delete M.current[t];for(let t of Array.from(I.current))t>=e&&I.current.delete(t)},[t.length]);let W=(0,_.useCallback)((e,t)=>{b&&t&&(M.current[e]=!0),t&&h&&E(t=>e>t?e:t)},[b,h]),he=(0,_.useCallback)(e=>{let t=N.current.get(e);t&&(t.destroy(),N.current.delete(e))},[]),G=(0,_.useCallback)((e,t)=>{let n=P.current;if(t?n.set(e,t):n.delete(e),!H||!t)return he(e),b&&!t&&delete M.current[e],void(t&&W(e,!0));if(e<d&&!h)return he(e),void W(e,!0);he(e);let r=s(t,{rootMargin:`400px`});N.current.set(e,r),r.isVisible()&&W(e,!0),r.whenVisible.then(()=>W(e,!0)).catch(()=>{})},[b,he,W,s,d,H,h]),ge=(0,_.useCallback)(e=>{let t=ee.current.get(e);if(t)return t;let n=t=>G(e,t);return ee.current.set(e,n),n},[G]),_e=(0,_.useCallback)((e,t)=>{if(!t)return void(k.current.has(e)&&(k.current.delete(e),j(e=>e+1)));let n=()=>{let n=t.offsetHeight;n&&k.current.get(e)!==n&&(k.current.set(e,n),j(e=>e+1))};typeof queueMicrotask==`function`?queueMicrotask(n):Promise.resolve().then(n)},[]),ve=(0,_.useCallback)(e=>{let t=F.current.get(e);if(t)return t;let n=t=>_e(e,t);return F.current.set(e,n),n},[_e]),ye=(0,_.useCallback)(e=>!(y&&e>=C.current)&&(!b||e<d||!0===M.current[e]),[b,y,d]),be=(0,_.useCallback)(e=>t=>{if(!e)return;let n=t.target;n!=null&&n.closest(`[data-node-index]`)&&e(t)},[]);(0,_.useEffect)(()=>{for(let[e,t]of P.current.entries())t&&G(e,t)},[G]),(0,_.useEffect)(()=>{h&&x>te.current&&E(x-1),te.current=x},[x,h]);let K=h?(0,v.jsx)(`div`,{className:`node-spacer`,style:{height:`${ue}px`},"aria-hidden":`true`}):null,q=h?(0,v.jsx)(`div`,{className:`node-spacer`,style:{height:`${de}px`},"aria-hidden":`true`}):null;return(0,v.jsxs)(`div`,{ref:i,className:`markstream-react markdown-renderer${e.isDark?` dark`:``}${h?` virtualized`:``}`,"data-custom-id":e.customId,onClick:e.onClick,onMouseOver:be(e.onMouseOver),onMouseOut:be(e.onMouseOut),children:[K,ce.map(({node:t,index:i})=>{let a=ye(i),o=k.current.get(i)??se,s=!1!==e.fade&&t.type!==`code_block`&&!I.current.has(i)&&a;return s&&I.current.add(i),(0,v.jsx)(`div`,{ref:ge(i),className:`node-slot`,"data-node-index":i,"data-node-type":t.type,children:(0,v.jsx)(`div`,a?{ref:H?ve(i):void 0,className:`node-content`+(s?` fade-node typewriter-node`:``),children:(0,v.jsx)(sw,{node:t,nodeKey:`${r}-${i}`,renderCtx:n})}:{className:`node-placeholder`,style:{height:`${o}px`}})},`${r}-${i}`)}),q,a&&(0,v.jsx)(`span`,{ref:o,className:`typewriter-cursor`,"aria-hidden":`true`})]})},function(e,t){if(e.renderCtx!==t.renderCtx||e.indexPrefix!==t.indexPrefix||e.containerRef!==t.containerRef||e.showTypewriterCursor!==t.showTypewriterCursor)return!1;let n=e.parsedNodes,r=t.parsedNodes;if(n===r)return!0;if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;let i=e.props,a=t.props;return i.isDark===a.isDark&&i.typewriter===a.typewriter&&i.fade===a.fade&&i.batchRendering===a.batchRendering&&i.initialRenderBatchSize===a.initialRenderBatchSize&&i.renderBatchSize===a.renderBatchSize&&i.renderBatchDelay===a.renderBatchDelay&&i.renderBatchBudgetMs===a.renderBatchBudgetMs&&i.renderBatchIdleTimeoutMs===a.renderBatchIdleTimeoutMs&&i.deferNodesUntilVisible===a.deferNodesUntilVisible&&i.maxLiveNodes===a.maxLiveNodes&&i.liveNodeBuffer===a.liveNodeBuffer&&i.viewportPriority===a.viewportPriority&&i.indexKey===a.indexKey&&i.onClick===a.onClick&&i.onMouseOver===a.onMouseOver&&i.onMouseOut===a.onMouseOut});function lw(e){let t={...rw,...e},n=(0,_.useRef)(null),r=(0,_.useRef)(new Map),i=(0,_.useRef)(0),a=(0,_.useRef)(null),o=Ex(t.smoothStreamingOptions),s=_.useContext(vx),c=(0,_.useRef)(new Set),[l,u]=(0,_.useState)(()=>!0===t.smoothStreaming);(0,_.useEffect)(()=>{u(!0)},[]);let d=Array.isArray(t.nodes)&&t.nodes.length>0,f=(0,_.useMemo)(()=>!1!==t.smoothStreaming&&!d&&(!0===t.smoothStreaming||!s)&&(!0===t.smoothStreaming||!0===t.typewriter||(t.maxLiveNodes??0)<=0),[d,s,t.maxLiveNodes,t.smoothStreaming,t.typewriter]),p=l&&f,m=p?o.visible:t.content??``,h=(0,_.useMemo)(()=>{let e=t.parseOptions??{};return t.final??e.final},[t.final,t.parseOptions]),g=t.content??``,y=d||o.source===g,b=(0,_.useMemo)(()=>p&&h!=null?!!(h&&y&&o.caughtUp):h,[h,y,o.caughtUp,p]),x=(0,_.useRef)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(void 0),T=(0,_.useRef)(0),E=(0,_.useMemo)(()=>new Set([`code_block`,`admonition`,`table`,`math_block`,`html_block`,`image`]),[]),D=(0,_.useCallback)(e=>{if(!e||typeof e!=`object`)return!1;let t=e.type;return typeof t==`string`&&E.has(t)},[E]),O=(0,_.useCallback)(e=>{if(!e||typeof e!=`object`)return 0;let t=e,n=t.raw??t.content??t.code;if(typeof n==`string`)return n.length;let r=t.children;if(Array.isArray(r))return r.reduce((e,t)=>e+O(t),0);let i=t.items;return Array.isArray(i)?i.reduce((e,t)=>e+O(t),0):0},[]),k=(0,_.useCallback)(()=>t.nodes?.length?t.nodes.reduce((e,t)=>e+O(t),0):(t.content??``).length,[t.nodes,t.content,O]),A=(0,_.useCallback)(()=>{w.current&&=(clearTimeout(w.current),void 0)},[]),j=(0,_.useCallback)(e=>{let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){if(!(e.textContent??``).trim())return NodeFilter.FILTER_REJECT;let t=e.parentElement;return t?t.closest(`.typewriter-cursor, .height-estimation-probes, [data-node-type="code_block"], [data-node-type="admonition"], [data-node-type="table"], [data-node-type="math_block"], [data-node-type="html_block"], [data-node-type="image"], script, style`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),n=null,r=t.nextNode();for(;r;)n=r,r=t.nextNode();return n},[]),M=(0,_.useCallback)(()=>{if(typeof window>`u`||!S||!n.current||!x.current)return;let e=n.current,t=x.current,r=j(e),i=e.getBoundingClientRect(),a=0,o=0,s=20;if(r?.textContent){let t=document.createRange(),n=r.textContent.length;t.setStart(r,Math.max(0,n-1)),t.setEnd(r,n);let c=typeof t.getClientRects==`function`?t.getClientRects():void 0,l=c?.[c.length-1]??r.parentElement?.getBoundingClientRect();l&&(a=l.right-i.left+e.scrollLeft,o=l.top-i.top+e.scrollTop,s=l.height||s),t.detach()}t.style.transform=`translate(${Math.max(0,a)}px, ${Math.max(0,o)}px)`,t.style.height=`${s}px`},[S,n,j]);(0,_.useEffect)(()=>{S&&requestAnimationFrame(()=>{M()})},[S,M]),(0,_.useEffect)(()=>()=>{A()},[A]);let N=d?t.nodes:m;a.current!==N&&(i.current+=1,a.current=N);let P=(0,_.useSyncExternalStore)(fb,pb,pb),ee=(0,_.useMemo)(()=>hb(t.customId),[t.customId,P]),F=ow(t.streamingComponents),I=ow(t.htmlComponents);(0,_.useEffect)(()=>{c.current},[I,F]);let te=(0,_.useMemo)(()=>t.customId?`renderer-${t.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[t.customId]),L=(0,_.useMemo)(()=>{let e=(t.parseOptions??{}).customHtmlTags??[];return Jc(t.customHtmlTags,Array.isArray(e)?e:[],Object.keys(F))},[t.customId,t.customHtmlTags,t.parseOptions,P,F]),ne=(0,_.useMemo)(()=>{let e=L;return e&&e.length!==0?rb(te,{customHtmlTags:e}):rb(te)},[te,L]),re=(0,_.useMemo)(()=>{let e=ne;return t.customMarkdownIt?t.customMarkdownIt(e):e},[ne,t.customMarkdownIt]),R=(0,_.useMemo)(()=>{let e=t.parseOptions??{},n=b,r=n!=null,i=L.length>0;return r||i?{...e,...r?{final:n}:{},...i?{customHtmlTags:L}:{}}:e},[L,b,t.parseOptions]),z=(0,_.useMemo)(()=>{let e=!!t.debugPerformance&&typeof console<`u`&&typeof performance<`u`,n=e?performance.now():0,r=[];return d?r=t.nodes.map(e=>({...e})):m&&(r=Kv(m,re??iw,R)),e&&(Math.round(performance.now()-n),r.length,m.length),r},[t.debugPerformance,m,d,t.nodes,R,re,t.customId,P,L]),ie=(0,_.useCallback)(()=>{let e=z[z.length-1];return!D(e)},[z,D]);(0,_.useEffect)(()=>{if(typeof window>`u`||d)return;if(b)return C(!1),void A();let e=k(),n=ie();return!1===t.typewriter||!n||e<=T.current?(!1!==t.typewriter&&n||C(!1),void(T.current=e)):(T.current=e,C(!0),A(),requestAnimationFrame(()=>{M()}),w.current=setTimeout(()=>{C(!1)},3e3),()=>{A()})},[m,t.nodes,t.typewriter,t.content,b,z.length,d,k,ie,A,M]);let B=(0,_.useRef)([]),ae=R?.postTransformNodes,oe=(0,_.useRef)(ae);oe.current!==ae&&(B.current=[],oe.current=ae);let V=function(e,t){if(!t.length)return e;let n=Array(e.length),r=e.length===t.length;for(let i=0;i<e.length;i++){let a=i<t.length?t[i]:null;a&&aw(a,e[i])?n[i]=a:(n[i]=e[i],r=!1)}return r?t:n}(z,B.current);B.current=V,(0,_.useEffect)(()=>{if(d||!p)return void(o.getSnapshot().source&&o.reset(``));let e=t.content??``,n=o.getSnapshot().source;e?e===n||(e.startsWith(n)?o.enqueue(e.slice(n.length)):o.reset(e)):o.reset(``),h&&o.finish()},[d,t.content,h,p]),(0,_.useEffect)(()=>{if(typeof window>`u`||t.renderCodeBlocksAsPre||!V.some(e=>e?.type===`code_block`&&Eb(String(e?.language??``))!==`mermaid`))return;let e=window.requestIdleCallback??((e,t)=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),t?.timeout??600)),n=window.cancelIdleCallback??(e=>window.clearTimeout(e)),r=e(()=>{Gx()},{timeout:900});return()=>n(r)},[V,t.renderCodeBlocksAsPre]);let H=(0,_.useMemo)(()=>t.indexKey==null?`markdown-renderer`:String(t.indexKey),[t.indexKey]),se=(0,_.useMemo)(()=>({...typeof t.showTooltips==`boolean`?{showTooltips:t.showTooltips}:{},...t.codeBlockProps||{}}),[t.codeBlockProps,t.showTooltips]),ce=(0,_.useMemo)(()=>({...t.mermaidProps||{}}),[t.mermaidProps]),le=(0,_.useMemo)(()=>({...t.d2Props||{}}),[t.d2Props]),ue=(0,_.useMemo)(()=>({...t.infographicProps||{}}),[t.infographicProps]),de=(0,_.useMemo)(()=>({customId:t.customId,isDark:t.isDark,final:b,indexKey:H,typewriter:t.typewriter,fade:t.fade,textStreamState:r.current,streamRenderVersion:i.current,customComponents:ee,streamingComponents:F,htmlComponents:I,customHtmlTags:L,htmlPolicy:t.htmlPolicy??`safe`,showTooltips:t.showTooltips,renderCodeBlocksAsPre:t.renderCodeBlocksAsPre,codeBlockStream:t.codeBlockStream,codeBlockOptions:t.codeBlockOptions,codeBlockProps:se,mermaidProps:ce,d2Props:le,infographicProps:ue,codeBlockThemes:{themes:t.themes,darkTheme:t.codeBlockDarkTheme,lightTheme:t.codeBlockLightTheme,minWidth:t.codeBlockMinWidth,maxWidth:t.codeBlockMaxWidth},events:{onCopy:t.onCopy,onHandleArtifactClick:t.onHandleArtifactClick}}),[t.customId,t.isDark,b,H,t.typewriter,t.fade,t.showTooltips,t.htmlPolicy,t.renderCodeBlocksAsPre,t.codeBlockStream,t.codeBlockOptions,L,se,ce,le,ue,t.themes,t.codeBlockDarkTheme,t.codeBlockLightTheme,t.codeBlockMinWidth,t.codeBlockMaxWidth,t.onCopy,t.onHandleArtifactClick,ee,F,I]);de.streamRenderVersion=i.current,de.textStreamState=r.current;let U=(0,_.useRef)(null);return U.current||={textStreamState:r.current,getStreamRenderVersion:()=>i.current},(0,v.jsx)(yx.Provider,{value:U.current,children:(0,v.jsx)(vx.Provider,{value:p,children:(0,v.jsx)(wx,{getRoot:()=>n.current,enabled:!1!==t.viewportPriority,children:(0,v.jsx)(cw,{props:t,parsedNodes:V,renderCtx:de,indexPrefix:H,containerRef:n,showTypewriterCursor:S,typewriterCursorRef:x})})})})}function uw(e){let{node:t,ctx:n,renderNode:r,indexKey:i,children:a}=e;return(0,v.jsx)(`blockquote`,{className:`blockquote-node`,dir:`auto`,cite:t.cite,children:a??(n&&r?(0,v.jsx)(lw,{nodes:t.children||[],indexKey:`blockquote-${String(i??`blockquote`)}`,customId:n.customId,isDark:n.isDark,typewriter:n.typewriter,viewportPriority:!0,codeBlockStream:n.codeBlockStream,renderCodeBlocksAsPre:n.renderCodeBlocksAsPre,codeBlockOptions:n.codeBlockOptions,codeBlockProps:n.codeBlockProps,themes:n.codeBlockThemes?.themes,codeBlockDarkTheme:n.codeBlockThemes?.darkTheme,codeBlockLightTheme:n.codeBlockThemes?.lightTheme,codeBlockMinWidth:n.codeBlockThemes?.minWidth,codeBlockMaxWidth:n.codeBlockThemes?.maxWidth,htmlPolicy:n.htmlPolicy,showTooltips:n.showTooltips,onCopy:n.events.onCopy,onHandleArtifactClick:n.events.onHandleArtifactClick}):null)})}export{mb as a,BS as i,GS as n,_b as o,WS as r,lw as t};
|
package/dist/index.html
CHANGED
|
@@ -571,7 +571,7 @@
|
|
|
571
571
|
opacity: 0.72;
|
|
572
572
|
}
|
|
573
573
|
</style>
|
|
574
|
-
<script type="module" crossorigin src="/assets/main-
|
|
574
|
+
<script type="module" crossorigin src="/assets/main-C9v4tzOp.js"></script>
|
|
575
575
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
576
576
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-DBn9yahL.js">
|
|
577
577
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-DEZ1K7qW.js">
|
|
@@ -604,11 +604,11 @@
|
|
|
604
604
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-BMWW_0wH.js">
|
|
605
605
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-D6bwc3Kj.js">
|
|
606
606
|
<link rel="modulepreload" crossorigin href="/assets/platform-sEg2IOLZ.js">
|
|
607
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
608
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
609
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
610
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
611
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
607
|
+
<link rel="modulepreload" crossorigin href="/assets/types-BkSficP0.js">
|
|
608
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-Dy6n1WSE.js">
|
|
609
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-Npmx-FHi.js">
|
|
610
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-YOnCHT8o.js">
|
|
611
|
+
<link rel="stylesheet" crossorigin href="/assets/src-GtPQ8f4o.css">
|
|
612
612
|
</head>
|
|
613
613
|
<body class="h-full bg-background text-foreground">
|
|
614
614
|
<!-- Keep the startup layer outside #root. React replaces every child of
|